ReactOS 0.4.16-dev-1527-g49e652b
clipboard.c
Go to the documentation of this file.
1/*
2 * Unit test suite for clipboard functions.
3 *
4 * Copyright 2002 Dmitry Timoshkov
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21#include <stdio.h>
22#include "wine/test.h"
23#include "winbase.h"
24#include "winerror.h"
25#include "wingdi.h"
26#include "winuser.h"
27#include "winnls.h"
28
29static BOOL (WINAPI *pAddClipboardFormatListener)(HWND hwnd);
30static BOOL (WINAPI *pRemoveClipboardFormatListener)(HWND hwnd);
31static BOOL (WINAPI *pGetUpdatedClipboardFormats)( UINT *formats, UINT count, UINT *out_count );
32
34static char *argv0;
35
37{
38 HWND hWnd = arg;
39 ok(OpenClipboard(hWnd), "%u: OpenClipboard failed\n", thread_from_line);
40 return 0;
41}
42
44{
45 SetLastError( 0xdeadbeef );
46 ok(!EmptyClipboard(), "%u: EmptyClipboard succeeded\n", thread_from_line );
47 ok( GetLastError() == ERROR_CLIPBOARD_NOT_OPEN, "%u: wrong error %u\n",
49 return 0;
50}
51
53{
54 HWND hWnd = arg;
55 ok(OpenClipboard(hWnd), "%u: OpenClipboard failed\n", thread_from_line);
56 ok(EmptyClipboard(), "%u: EmptyClipboard failed\n", thread_from_line );
57 return 0;
58}
59
61{
62 HWND hwnd = CreateWindowA( "static", NULL, WS_POPUP, 0, 0, 10, 10, 0, 0, 0, NULL );
63 ok(OpenClipboard(hwnd), "%u: OpenClipboard failed\n", thread_from_line);
64 ok(EmptyClipboard(), "%u: EmptyClipboard failed\n", thread_from_line );
65 return 0;
66}
67
69{
70 HWND hwnd = arg;
71 HANDLE ret;
72
73 SetLastError( 0xdeadbeef );
74 if (GetClipboardOwner() == hwnd)
75 {
77 ok( IsClipboardFormatAvailable( CF_WAVE ), "%u: SetClipboardData failed\n", thread_from_line );
79 ok( ret != 0, "%u: SetClipboardData failed err %u\n", thread_from_line, GetLastError() );
80 SetLastError( 0xdeadbeef );
82 ok( !ret, "%u: GetClipboardData succeeded\n", thread_from_line );
83 ok( GetLastError() == ERROR_CLIPBOARD_NOT_OPEN, "%u: wrong error %u\n",
85 }
86 else
87 {
89 ok( GetLastError() == ERROR_CLIPBOARD_NOT_OPEN, "%u: wrong error %u\n",
91 ok( !IsClipboardFormatAvailable( CF_WAVE ), "%u: SetClipboardData succeeded\n", thread_from_line );
93 ok( !ret, "%u: SetClipboardData succeeded\n", thread_from_line );
94 ok( GetLastError() == ERROR_CLIPBOARD_NOT_OPEN, "%u: wrong error %u\n",
96 }
97 return 0;
98}
99
101{
102 HANDLE ret;
103
104 SetLastError( 0xdeadbeef );
105 if (arg)
106 {
107 ok( IsClipboardFormatAvailable( CF_WAVE ), "process %u: CF_WAVE not available\n", arg );
109 ok( ret != 0, "process %u: SetClipboardData failed err %u\n", arg, GetLastError() );
110 }
111 else
112 {
114 ok( GetLastError() == ERROR_CLIPBOARD_NOT_OPEN, "process %u: wrong error %u\n",
115 arg, GetLastError());
116 ok( !IsClipboardFormatAvailable( CF_WAVE ), "process %u: SetClipboardData succeeded\n", arg );
118 ok( !ret, "process %u: SetClipboardData succeeded\n", arg );
119 ok( GetLastError() == ERROR_CLIPBOARD_NOT_OPEN, "process %u: wrong error %u\n",
120 arg, GetLastError());
121 }
122}
123
124static void grab_clipboard_process( int arg )
125{
126 BOOL ret;
127
128 SetLastError( 0xdeadbeef );
129 ret = OpenClipboard( 0 );
130 ok( ret, "OpenClipboard failed\n" );
132 ok( ret, "EmptyClipboard failed\n" );
133 if (arg)
134 {
136 ok( ret != 0, "process %u: SetClipboardData failed err %u\n", arg, GetLastError() );
137 }
138}
139
141{
142 DWORD ret;
144
146 thread = CreateThread(NULL, 0, func, arg, 0, NULL);
147 ok(thread != NULL, "%u: CreateThread failed with error %d\n", line, GetLastError());
148 for (;;)
149 {
151 if (ret == WAIT_OBJECT_0 + 1)
152 {
153 MSG msg;
154 while (PeekMessageW( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageW( &msg );
155 }
156 else break;
157 }
158 ok(ret == WAIT_OBJECT_0, "%u: expected WAIT_OBJECT_0, got %u\n", line, ret);
160}
161
162static void run_process( const char *args )
163{
164 char cmd[MAX_PATH];
167
168 sprintf( cmd, "%s clipboard %s", argv0, args );
169 memset( &startup, 0, sizeof(startup) );
170 startup.cb = sizeof(startup);
172 "CreateProcess %s failed\n", cmd );
173
175 CloseHandle( info.hProcess );
176 CloseHandle( info.hThread );
177}
178
181{
182 static int wm_renderallformats;
183 static int wm_drawclipboard;
184 static int seqno;
185 DWORD msg_flags = InSendMessageEx( NULL );
186
187 if (!seqno) seqno = GetClipboardSequenceNumber();
188
189 trace( "%p msg %04x\n", hwnd, msg );
190 if (!wm_renderallformats)
191 {
192 ok( GetClipboardOwner() == hwnd, "%04x: wrong owner %p/%p\n", msg, GetClipboardOwner(), hwnd );
193 ok( seqno == GetClipboardSequenceNumber(), "%04x: seqno changed\n", msg );
194 }
195 else
196 {
197 ok( !GetClipboardOwner(), "%04x: wrong owner %p\n", msg, GetClipboardOwner() );
198 ok( seqno + 1 == GetClipboardSequenceNumber(), "%04x: seqno unchanged\n", msg );
199 }
200 ok( GetClipboardViewer() == hwnd, "%04x: wrong viewer %p/%p\n", msg, GetClipboardViewer(), hwnd );
201 ok( GetOpenClipboardWindow() == hwnd, "%04x: wrong open win %p/%p\n",
203
204 switch (msg)
205 {
206 case WM_DESTROY:
207 ok( wm_renderallformats, "didn't receive WM_RENDERALLFORMATS before WM_DESTROY\n" );
208 ok( wm_drawclipboard, "didn't receive WM_DRAWCLIPBOARD before WM_DESTROY\n" );
209 break;
210 case WM_DRAWCLIPBOARD:
211 ok( msg_flags == ISMEX_NOSEND, "WM_DRAWCLIPBOARD wrong flags %x\n", msg_flags );
213 break;
215 ok( msg_flags == ISMEX_NOSEND, "WM_RENDERALLFORMATS wrong flags %x\n", msg_flags );
216 wm_renderallformats++;
217 break;
218 }
219 return old_proc( hwnd, msg, wp, lp );
220}
221
222static void test_ClipboardOwner(void)
223{
225 BOOL ret;
226
227 SetLastError(0xdeadbeef);
228 ok(!GetClipboardOwner() && GetLastError() == 0xdeadbeef,
229 "could not perform clipboard test: clipboard already owned\n");
230
231 hWnd1 = CreateWindowExA(0, "static", NULL, WS_POPUP,
232 0, 0, 10, 10, 0, 0, 0, NULL);
233 ok(hWnd1 != 0, "CreateWindowExA error %d\n", GetLastError());
234 trace("hWnd1 = %p\n", hWnd1);
235
236 hWnd2 = CreateWindowExA(0, "static", NULL, WS_POPUP,
237 0, 0, 10, 10, 0, 0, 0, NULL);
238 ok(hWnd2 != 0, "CreateWindowExA error %d\n", GetLastError());
239 trace("hWnd2 = %p\n", hWnd2);
240
241 SetLastError(0xdeadbeef);
242 ok(!CloseClipboard(), "CloseClipboard should fail if clipboard wasn't open\n");
243 ok(GetLastError() == ERROR_CLIPBOARD_NOT_OPEN || broken(GetLastError() == 0xdeadbeef), /* wow64 */
244 "wrong error %u\n", GetLastError());
245
246 ok(OpenClipboard(0), "OpenClipboard failed\n");
247 ok(!GetClipboardOwner(), "clipboard should still be not owned\n");
248 ok(!OpenClipboard(hWnd1), "OpenClipboard should fail since clipboard already opened\n");
249 ok(OpenClipboard(0), "OpenClipboard again failed\n");
251 ok( ret, "CloseClipboard error %d\n", GetLastError());
252
253 ok(OpenClipboard(hWnd1), "OpenClipboard failed\n");
255 run_thread( empty_clipboard_thread, 0, __LINE__ );
257 ok( !IsClipboardFormatAvailable( CF_WAVE ), "CF_WAVE available\n" );
258 ok( !GetClipboardData( CF_WAVE ), "CF_WAVE data available\n" );
259 run_process( "set_clipboard_data 0" );
260 ok(!CloseClipboard(), "CloseClipboard should fail if clipboard wasn't open\n");
261 ok(OpenClipboard(hWnd1), "OpenClipboard failed\n");
262
263 SetLastError(0xdeadbeef);
265 ok(!ret && (GetLastError() == 0xdeadbeef || GetLastError() == ERROR_ACCESS_DENIED),
266 "OpenClipboard should fail without setting last error value, or with ERROR_ACCESS_DENIED, got error %d\n", GetLastError());
267
268 SetLastError(0xdeadbeef);
269 ok(!GetClipboardOwner() && GetLastError() == 0xdeadbeef, "clipboard should still be not owned\n");
271 ok( ret, "EmptyClipboard error %d\n", GetLastError());
272 ok(GetClipboardOwner() == hWnd1, "clipboard should be owned by %p, not by %p\n", hWnd1, GetClipboardOwner());
273 run_thread( empty_clipboard_thread, 0, __LINE__ );
275 ok( IsClipboardFormatAvailable( CF_WAVE ), "CF_WAVE not available\n" );
276 ok( GetClipboardData( CF_WAVE ) != 0, "CF_WAVE data not available\n" );
277 run_process( "set_clipboard_data 1" );
278
279 SetLastError(0xdeadbeef);
281 ok(!ret && (GetLastError() == 0xdeadbeef || GetLastError() == ERROR_ACCESS_DENIED),
282 "OpenClipboard should fail without setting last error value, or with ERROR_ACCESS_DENIED, got error %d\n", GetLastError());
283
285 ok( ret, "CloseClipboard error %d\n", GetLastError());
286 ok(GetClipboardOwner() == hWnd1, "clipboard should still be owned\n");
287
288 /* any window will do, even from a different process */
290 ok( ret, "OpenClipboard error %d\n", GetLastError());
292 ok( ret, "EmptyClipboard error %d\n", GetLastError());
293 ok( GetClipboardOwner() == GetDesktopWindow(), "wrong owner %p/%p\n",
296 ok( IsClipboardFormatAvailable( CF_WAVE ), "CF_WAVE not available\n" );
297 ok( GetClipboardData( CF_WAVE ) != 0, "CF_WAVE data not available\n" );
298 run_process( "set_clipboard_data 2" );
300 ok( ret, "CloseClipboard error %d\n", GetLastError());
301
303 ok( ret, "OpenClipboard error %d\n", GetLastError());
305 ok( ret, "EmptyClipboard error %d\n", GetLastError());
308 ok( GetClipboardOwner() == hWnd1, "wrong owner %p/%p\n", GetClipboardOwner(), hWnd1 );
309 ok( GetClipboardViewer() == hWnd1, "wrong viewer %p/%p\n", GetClipboardViewer(), hWnd1 );
310 ok( GetOpenClipboardWindow() == hWnd1, "wrong open win %p/%p\n", GetOpenClipboardWindow(), hWnd1 );
311 ok( IsClipboardFormatAvailable( CF_WAVE ), "CF_WAVE not available\n" );
312
315 ok( ret, "DestroyWindow error %d\n", GetLastError());
317 ok( ret, "DestroyWindow error %d\n", GetLastError());
318 SetLastError(0xdeadbeef);
319 ok(!GetClipboardOwner() && GetLastError() == 0xdeadbeef, "clipboard should not be owned\n");
320 ok(!GetClipboardViewer() && GetLastError() == 0xdeadbeef, "viewer still exists\n");
321 ok(!GetOpenClipboardWindow() && GetLastError() == 0xdeadbeef, "clipboard should not be open\n");
322 ok( !IsClipboardFormatAvailable( CF_WAVE ), "CF_WAVE available\n" );
323
324 SetLastError( 0xdeadbeef );
326 ok( !ret, "CloseClipboard succeeded\n" );
327 ok( GetLastError() == ERROR_CLIPBOARD_NOT_OPEN, "wrong error %u\n", GetLastError() );
328
329 ret = OpenClipboard( 0 );
330 ok( ret, "OpenClipboard error %d\n", GetLastError());
332 ok( IsClipboardFormatAvailable( CF_WAVE ), "CF_WAVE not available\n" );
333 ok( GetClipboardData( CF_WAVE ) != 0, "CF_WAVE data not available\n" );
334 run_process( "set_clipboard_data 3" );
336 ok( ret, "CloseClipboard error %d\n", GetLastError());
337
339 ok( !GetOpenClipboardWindow(), "wrong open window %p\n", GetOpenClipboardWindow() );
340 ok( !GetClipboardOwner(), "wrong owner window %p\n", GetClipboardOwner() );
341
342 ret = OpenClipboard( 0 );
343 ok( ret, "OpenClipboard error %d\n", GetLastError());
345 ok( IsClipboardFormatAvailable( CF_WAVE ), "CF_WAVE not available\n" );
346 ok( GetClipboardData( CF_WAVE ) != 0, "CF_WAVE data not available\n" );
347 run_process( "set_clipboard_data 4" );
349 ok( ret, "EmptyClipboard error %d\n", GetLastError());
351 ok( ret, "CloseClipboard error %d\n", GetLastError());
352
353 SetLastError( 0xdeadbeef );
355 "SetClipboardData succeeded\n" );
356 ok( GetLastError() == ERROR_CLIPBOARD_NOT_OPEN, "wrong error %u\n", GetLastError() );
357 ok( !IsClipboardFormatAvailable( CF_WAVE ), "SetClipboardData succeeded\n" );
358
360 ok( !GetOpenClipboardWindow(), "wrong open window %p\n", GetOpenClipboardWindow() );
361 ok( GetClipboardOwner() == GetDesktopWindow(), "wrong owner window %p / %p\n",
363
365 ok( !GetOpenClipboardWindow(), "wrong open window %p\n", GetOpenClipboardWindow() );
366 ok( !GetClipboardOwner(), "wrong owner window %p\n", GetClipboardOwner() );
367}
368
370{
371 ATOM atom_id;
372 UINT format_id, format_id2;
373 char buf[256];
374 int len;
375 BOOL ret;
377
378 format_id = RegisterClipboardFormatA("my_cool_clipboard_format");
379 ok(format_id > 0xc000 && format_id < 0xffff, "invalid clipboard format id %04x\n", format_id);
380
381 format_id2 = RegisterClipboardFormatA("MY_COOL_CLIPBOARD_FORMAT");
382 ok(format_id2 == format_id, "invalid clipboard format id %04x\n", format_id2);
383
385 ok(len == lstrlenA("my_cool_clipboard_format"), "wrong format name length %d\n", len);
386 ok(!lstrcmpA(buf, "my_cool_clipboard_format"), "wrong format name \"%s\"\n", buf);
387
389 ok(len == 0, "wrong format name length %d\n", len);
390
391 lstrcpyA(buf, "foo");
392 SetLastError(0xdeadbeef);
394 ok(len == 0, "GetAtomNameA should fail\n");
396
398{
399 lstrcpyA(buf, "foo");
400 SetLastError(0xdeadbeef);
402 ok(len == 0, "GlobalGetAtomNameA should fail\n");
404}
405
406 SetLastError(0xdeadbeef);
407 atom_id = FindAtomA("my_cool_clipboard_format");
408 ok(atom_id == 0, "FindAtomA should fail\n");
410
411 if (0)
412 {
413 /* this relies on the clipboard and global atom table being different */
414 SetLastError(0xdeadbeef);
415 atom_id = GlobalFindAtomA("my_cool_clipboard_format");
416 ok(atom_id == 0, "GlobalFindAtomA should fail\n");
418 }
419
420 for (format_id = 0; format_id < 0x10fff; format_id++)
421 {
422 SetLastError(0xdeadbeef);
424
425 if (format_id < 0xc000 || format_id > 0xffff)
426 ok(!len, "GetClipboardFormatNameA should fail, but it returned %d (%s)\n", len, buf);
427 else if (len && winetest_debug > 1)
428 trace("%04x: %s\n", format_id, len ? buf : "");
429 }
430
431 ret = OpenClipboard(0);
432 ok( ret, "OpenClipboard error %d\n", GetLastError());
433
434 /* try some invalid/unregistered formats */
435 SetLastError( 0xdeadbeef );
437 ok( !handle, "SetClipboardData succeeded\n" );
438 ok( GetLastError() == ERROR_CLIPBOARD_NOT_OPEN, "wrong error %u\n", GetLastError());
440 ok( handle != 0, "SetClipboardData failed err %d\n", GetLastError());
442 ok( handle != 0, "SetClipboardData failed err %d\n", GetLastError());
444 ok( handle != 0, "SetClipboardData failed err %d\n", GetLastError());
445
446 ok( IsClipboardFormatAvailable( 0x1234 ), "format missing\n" );
447 ok( IsClipboardFormatAvailable( 0x123456 ), "format missing\n" );
448 ok( IsClipboardFormatAvailable( 0xffff8765 ), "format missing\n" );
449 ok( !IsClipboardFormatAvailable( 0 ), "format available\n" );
450 ok( !IsClipboardFormatAvailable( 0x3456 ), "format available\n" );
451 ok( !IsClipboardFormatAvailable( 0x8765 ), "format available\n" );
452
453 trace("# of formats available: %d\n", CountClipboardFormats());
454
455 format_id = 0;
457 {
458 ok(IsClipboardFormatAvailable(format_id), "format %04x was listed as available\n", format_id);
460 trace("%04x: %s\n", format_id, len ? buf : "");
461 }
462
464 ok( ret, "EmptyClipboard error %d\n", GetLastError());
466 ok( ret, "CloseClipboard error %d\n", GetLastError());
467
469 {
470 SetLastError(0xdeadbeef);
471 ok(!EnumClipboardFormats(0), "EnumClipboardFormats should fail if clipboard wasn't open\n");
473 "Last error should be set to ERROR_CLIPBOARD_NOT_OPEN, not %d\n", GetLastError());
474 }
475
476 SetLastError(0xdeadbeef);
477 ok(!EmptyClipboard(), "EmptyClipboard should fail if clipboard wasn't open\n");
478 ok(GetLastError() == ERROR_CLIPBOARD_NOT_OPEN || broken(GetLastError() == 0xdeadbeef), /* wow64 */
479 "Wrong error %u\n", GetLastError());
480
482 ok(format_id == 1234, "invalid clipboard format id %04x\n", format_id);
483}
484
486{
488 char *p = GlobalLock(h);
489 memcpy(p, "test\0\0\0\0\0", 10);
491 return h;
492}
493
495{
496 static const WCHAR testW[] = {'t','e','s','t',0,0,0,0,0,0};
498 WCHAR *p = GlobalLock(h);
499 memcpy(p, testW, sizeof(testW));
501 return h;
502}
503
505{
506 const RECT rect = {0, 0, 100, 100};
507 METAFILEPICT *pict;
508 HANDLE ret;
509 HMETAFILE mf;
511 ExtTextOutA( hdc, 0, 0, ETO_OPAQUE, &rect, "Test String", strlen("Test String"), NULL );
512 mf = CloseMetaFile( hdc );
513 ret = GlobalAlloc( GMEM_DDESHARE | GMEM_MOVEABLE, sizeof(*pict) );
514 pict = GlobalLock( ret );
515 pict->mm = MM_TEXT;
516 pict->xExt = pict->yExt = 100;
517 pict->hMF = mf;
518 GlobalUnlock( ret );
519 return ret;
520}
521
522static HENHMETAFILE create_emf(void)
523{
524 const RECT rect = {0, 0, 100, 100};
525 HDC hdc = CreateEnhMetaFileA(NULL, NULL, &rect, "HENHMETAFILE Ole Clipboard Test\0Test\0\0");
526 ExtTextOutA(hdc, 0, 0, ETO_OPAQUE, &rect, "Test String", strlen("Test String"), NULL);
527 return CloseEnhMetaFile(hdc);
528}
529
531{
532 HDC hdc = GetDC( 0 );
534 ReleaseDC( 0, hdc );
535 return CreateBitmap( 10, 10, 1, bpp, NULL );
536}
537
539{
540 HANDLE ret;
542
544 sizeof(BITMAPV5HEADER) + 256 * sizeof(RGBQUAD) + 16 * 16 * 4 );
545 hdr = GlobalLock( ret );
546 hdr->biSize = v5 ? sizeof(BITMAPV5HEADER) : sizeof(*hdr);
547 hdr->biWidth = 16;
548 hdr->biHeight = 16;
549 hdr->biPlanes = 1;
550 hdr->biBitCount = 32;
551 hdr->biCompression = BI_RGB;
552 if (v5)
553 {
554 BITMAPV5HEADER *hdr5 = (BITMAPV5HEADER *)hdr;
555 hdr5->bV5RedMask = 0x0000ff;
556 hdr5->bV5GreenMask = 0x00ff00;
557 hdr5->bV5BlueMask = 0xff0000;
558 hdr5->bV5AlphaMask = 0xff000000;
559 }
560 GlobalUnlock( ret );
561 return ret;
562}
563
565{
566 static UINT rendered;
567 UINT ret;
568
569 switch (msg)
570 {
571 case WM_RENDERFORMAT:
572 if (wp < 32) rendered |= (1 << wp);
573 break;
574 case WM_USER:
575 ret = rendered;
576 rendered = 0;
577 return ret;
578 }
579 return DefWindowProcA( hwnd, msg, wp, lp );
580}
581
582static void test_synthesized(void)
583{
584 static const struct test
585 {
586 UINT format;
587 UINT expected[8];
588 } tests[] =
589 {
595/* 5 */ { CF_BITMAP, { CF_BITMAP, CF_DIB, CF_DIBV5 }},
596 { CF_DIB, { CF_DIB, CF_BITMAP, CF_DIBV5 }},
597 { CF_DIBV5, { CF_DIBV5, CF_BITMAP, CF_DIB }},
598 };
599
600 HGLOBAL h, htext;
601 HENHMETAFILE emf;
602 BOOL r;
603 UINT cf, i, j, count, rendered, seq, old_seq;
604 HANDLE data;
605 HWND hwnd;
606
607 hwnd = CreateWindowA( "static", NULL, WS_POPUP, 0, 0, 10, 10, 0, 0, 0, NULL );
609
610 htext = create_textA();
611 emf = create_emf();
612
614 ok(r, "gle %d\n", GetLastError());
615 r = EmptyClipboard();
616 ok(r, "gle %d\n", GetLastError());
617 h = SetClipboardData(CF_TEXT, htext);
618 ok(h == htext, "got %p\n", h);
620 ok(h == emf, "got %p\n", h);
621 r = CloseClipboard();
622 ok(r, "gle %d\n", GetLastError());
623
625 ok( count == 6, "count %u\n", count );
627 ok( r, "CF_TEXT not available err %d\n", GetLastError());
629 ok( r, "CF_LOCALE not available err %d\n", GetLastError());
631 ok( r, "CF_OEMTEXT not available err %d\n", GetLastError());
633 ok( r, "CF_UNICODETEXT not available err %d\n", GetLastError());
635 ok( r, "CF_ENHMETAFILE not available err %d\n", GetLastError());
637 ok( r, "CF_METAFILEPICT not available err %d\n", GetLastError());
638
640 ok(r, "gle %d\n", GetLastError());
642 ok(cf == CF_TEXT, "cf %08x\n", cf);
644 ok(data != NULL, "couldn't get data, cf %08x\n", cf);
645
647 ok(cf == CF_ENHMETAFILE, "cf %08x\n", cf);
649 ok(data != NULL, "couldn't get data, cf %08x\n", cf);
650
652 ok(cf == CF_LOCALE, "cf %08x\n", cf);
654 ok(data != NULL, "couldn't get data, cf %08x\n", cf);
655
657 ok(cf == CF_OEMTEXT, "cf %08x\n", cf);
659 ok(data != NULL, "couldn't get data, cf %08x\n", cf);
660
662 ok(cf == CF_UNICODETEXT, "cf %08x\n", cf);
663
665 ok(cf == CF_METAFILEPICT, "cf %08x\n", cf);
667 ok(data != NULL, "couldn't get data, cf %08x\n", cf);
668
670 ok(cf == 0, "cf %08x\n", cf);
671
672 r = EmptyClipboard();
673 ok(r, "gle %d\n", GetLastError());
674
678 r = CloseClipboard();
679 ok(r, "gle %d\n", GetLastError());
680
681 r = OpenClipboard( NULL );
682 ok(r, "gle %d\n", GetLastError());
683 SetLastError( 0xdeadbeef );
685 ok( cf == CF_UNICODETEXT, "cf %08x\n", cf );
686 ok( GetLastError() == ERROR_SUCCESS, "wrong error %u\n", GetLastError() );
687 SetLastError( 0xdeadbeef );
689 ok( cf == CF_TEXT, "cf %08x\n", cf );
690 ok( GetLastError() == ERROR_SUCCESS, "wrong error %u\n", GetLastError() );
691 SetLastError( 0xdeadbeef );
693 ok( cf == CF_OEMTEXT, "cf %08x\n", cf );
694 ok( GetLastError() == ERROR_SUCCESS, "wrong error %u\n", GetLastError() );
695 SetLastError( 0xdeadbeef );
697 ok( cf == CF_LOCALE, "cf %08x\n", cf );
698 ok( GetLastError() == ERROR_SUCCESS, "wrong error %u\n", GetLastError() );
699 SetLastError( 0xdeadbeef );
701 ok( cf == 0, "cf %08x\n", cf );
702 ok( GetLastError() == ERROR_SUCCESS, "wrong error %u\n", GetLastError() );
703 SetLastError( 0xdeadbeef );
704 cf = EnumClipboardFormats( 0xdead );
705 ok( cf == 0, "cf %08x\n", cf );
706 ok( GetLastError() == ERROR_SUCCESS, "wrong error %u\n", GetLastError() );
707
708 r = EmptyClipboard();
709 ok(r, "gle %d\n", GetLastError());
710
711 r = CloseClipboard();
712 ok(r, "gle %d\n", GetLastError());
713
714 for (i = 0; i < ARRAY_SIZE(tests); i++)
715 {
717 ok(r, "%u: gle %d\n", i, GetLastError());
718 r = EmptyClipboard();
719 ok(r, "%u: gle %d\n", i, GetLastError());
720
721 switch (tests[i].format)
722 {
723 case CF_TEXT:
724 case CF_OEMTEXT:
726 break;
727 case CF_UNICODETEXT:
729 break;
730 case CF_ENHMETAFILE:
732 break;
733 case CF_METAFILEPICT:
735 break;
736 case CF_BITMAP:
738 break;
739 case CF_DIB:
740 case CF_DIBV5:
742 break;
743 }
744
746 ok( count == 1, "%u: count %u\n", i, count );
747
748 r = CloseClipboard();
749 ok(r, "%u: gle %d\n", i, GetLastError());
750
752 for (j = 0; tests[i].expected[j]; j++)
753 {
755 ok( r, "%u: %04x not available\n", i, tests[i].expected[j] );
756 }
757 ok( count == j, "%u: count %u instead of %u\n", i, count, j );
758
759 r = OpenClipboard( hwnd );
760 ok(r, "%u: gle %d\n", i, GetLastError());
761 cf = 0;
762 for (j = 0; tests[i].expected[j]; j++)
763 {
765 ok(cf == tests[i].expected[j], "%u.%u: got %04x instead of %04x\n",
766 i, j, cf, tests[i].expected[j] );
767 if (cf != tests[i].expected[j]) break;
770 ok(data != NULL ||
771 broken( tests[i].format == CF_DIBV5 && cf == CF_DIB ), /* >= Vista */
772 "%u: couldn't get data, cf %04x err %d\n", i, cf, GetLastError());
774 ok(seq == old_seq, "sequence changed (test %d %d)\n", i, cf);
775 switch (cf)
776 {
777 case CF_LOCALE:
778 {
779 UINT *ptr = GlobalLock( data );
780 ok( GlobalSize( data ) == sizeof(*ptr), "%u: size %lu\n", i, GlobalSize( data ));
781 ok( *ptr == GetUserDefaultLCID() ||
783 "%u: CF_LOCALE %08x/%08x\n", i, *ptr, GetUserDefaultLCID() );
785 break;
786 }
787 case CF_TEXT:
788 case CF_OEMTEXT:
789 ok( GlobalSize( data ) == 10, "wrong len %ld\n", GlobalSize( data ));
790 break;
791 case CF_UNICODETEXT:
792 ok( GlobalSize( data ) == 10 * sizeof(WCHAR), "wrong len %ld\n", GlobalSize( data ));
793 break;
794 }
795 }
796 if (!tests[i].expected[j])
797 {
799 ok(cf == 0, "%u: cf %04x\n", i, cf);
800 }
801
802 /* now with delayed rendering */
803
804 r = EmptyClipboard();
805 ok(r, "%u: gle %d\n", i, GetLastError());
806
807 rendered = SendMessageA( hwnd, WM_USER, 0, 0 );
808 ok( !rendered, "%u: formats %08x have been rendered\n", i, rendered );
809
811 rendered = SendMessageA( hwnd, WM_USER, 0, 0 );
812 ok( !rendered, "%u: formats %08x have been rendered\n", i, rendered );
813
815 ok( count == 1, "%u: count %u\n", i, count );
816
817 r = CloseClipboard();
818 ok(r, "%u: gle %d\n", i, GetLastError());
819 rendered = SendMessageA( hwnd, WM_USER, 0, 0 );
820 ok( !rendered, "%u: formats %08x have been rendered\n", i, rendered );
821
823 for (j = 0; tests[i].expected[j]; j++)
824 {
826 ok( r, "%u: %04x not available\n", i, tests[i].expected[j] );
827 }
828 ok( count == j, "%u: count %u instead of %u\n", i, count, j );
829 rendered = SendMessageA( hwnd, WM_USER, 0, 0 );
830 ok( !rendered, "%u: formats %08x have been rendered\n", i, rendered );
831
833 ok(r, "%u: gle %d\n", i, GetLastError());
834 cf = 0;
835 for (j = 0; tests[i].expected[j]; j++)
836 {
838 ok(cf == tests[i].expected[j], "%u.%u: got %04x instead of %04x\n",
839 i, j, cf, tests[i].expected[j] );
840 if (cf != tests[i].expected[j]) break;
841 rendered = SendMessageA( hwnd, WM_USER, 0, 0 );
842 ok( !rendered, "%u.%u: formats %08x have been rendered\n", i, j, rendered );
844 rendered = SendMessageA( hwnd, WM_USER, 0, 0 );
845 if (cf == CF_LOCALE)
846 {
847 ok(data != NULL, "%u: CF_LOCALE no data\n", i);
848 ok( !rendered, "%u.%u: formats %08x have been rendered\n", i, j, rendered );
849 }
850 else
851 {
852 ok(!data, "%u: format %04x got data %p\n", i, cf, data);
853 ok( rendered == (1 << tests[i].format),
854 "%u.%u: formats %08x have been rendered\n", i, j, rendered );
855 /* try to render a second time */
857 rendered = SendMessageA( hwnd, WM_USER, 0, 0 );
858 ok( rendered == (1 << tests[i].format),
859 "%u.%u: formats %08x have been rendered\n", i, j, rendered );
860 }
861 }
862 if (!tests[i].expected[j])
863 {
865 ok(cf == 0, "%u: cf %04x\n", i, cf);
866 }
867 r = CloseClipboard();
868 ok(r, "%u: gle %d\n", i, GetLastError());
869 rendered = SendMessageA( hwnd, WM_USER, 0, 0 );
870 ok( !rendered, "%u: formats %08x have been rendered\n", i, rendered );
871 }
872
874 ok(r, "gle %d\n", GetLastError());
875 r = EmptyClipboard();
876 ok(r, "gle %d\n", GetLastError());
877 r = CloseClipboard();
878 ok(r, "gle %d\n", GetLastError());
880}
881
883{
885 ok( handle != 0, "SetClipboardData failed: %d\n", GetLastError() );
886 return 0;
887}
888
899
901{
902 LRESULT ret;
903 DWORD msg_flags = InSendMessageEx( NULL );
904
905 switch(msg) {
906 case WM_DRAWCLIPBOARD:
907 ok( msg_flags == (cross_thread ? ISMEX_NOTIFY : ISMEX_NOSEND),
908 "WM_DRAWCLIPBOARD wrong flags %x\n", msg_flags );
912 break;
913 case WM_CHANGECBCHAIN:
914 ok( msg_flags == (cross_thread ? ISMEX_SEND : ISMEX_NOSEND),
915 "WM_CHANGECBCHAIN wrong flags %x\n", msg_flags );
916 if (next_wnd == (HWND)wp)
917 next_wnd = (HWND)lp;
918 else if (next_wnd)
919 SendMessageA(next_wnd, msg, wp, lp);
920 break;
922 ok( msg_flags == (cross_thread ? ISMEX_SEND : ISMEX_NOSEND),
923 "WM_DESTROYCLIPBOARD wrong flags %x\n", msg_flags );
925 ok( GetClipboardOwner() == hwnd, "WM_DESTROYCLIPBOARD owner %p\n", GetClipboardOwner() );
927 break;
928 case WM_RENDERFORMAT:
929 ok( !wm_renderformat, "multiple WM_RENDERFORMAT %04x / %04lx\n", wm_renderformat, wp );
930 wm_renderformat = wp;
931
933 {
934 UINT seq, old_seq;
936
939 ok( handle != 0, "SetClipboardData failed: %d\n", GetLastError() );
941 ok( seq == old_seq, "sequence changed\n" );
942 old_seq = seq;
943
945 ok( handle != NULL, "CreateThread failed: %d\n", GetLastError() );
946 ok( WaitForSingleObject(handle, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n" );
949 ok( seq == old_seq, "sequence changed\n" );
950 }
951
952 break;
953 case WM_CLIPBOARDUPDATE:
954 ok( msg_flags == ISMEX_NOSEND, "WM_CLIPBOARDUPDATE wrong flags %x\n", msg_flags );
959 break;
960 case WM_USER:
963 break;
964 case WM_USER+1:
967 return ret;
968 case WM_USER+2:
971 return ret;
972 case WM_USER+3:
975 return ret;
976 case WM_USER+4:
978 wm_renderformat = 0;
979 return ret;
980 case WM_USER+5:
981 return nb_formats;
982 }
983
984 return DefWindowProcA(hwnd, msg, wp, lp);
985}
986
988{
989 HANDLE data;
990 BOOL r;
991
992 r = OpenClipboard(0);
993 ok(r, "OpenClipboard failed: %d\n", GetLastError());
995 ok( data != NULL, "GetClipboardData failed: %d\n", GetLastError());
996 r = CloseClipboard();
997 ok(r, "CloseClipboard failed: %d\n", GetLastError());
998}
999
1001
1002static void check_messages_(int line, HWND win, UINT seq_diff, UINT draw, UINT update, UINT destroy, UINT render)
1003{
1004 MSG msg;
1005 UINT count, fmt, seq;
1006
1008 ok_(__FILE__, line)(seq - old_seq == seq_diff, "sequence diff %d\n", seq - old_seq);
1009 old_seq = seq;
1010
1011 if (!cross_thread)
1012 {
1013 while (PeekMessageW( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageW( &msg );
1014 }
1015
1016 if (update && !broken(!pAddClipboardFormatListener))
1017 ok(WaitForSingleObject(update_event, 1000) == WAIT_OBJECT_0, "wait failed\n");
1018
1019 count = SendMessageA( win, WM_USER + 1, 0, 0 );
1020 ok_(__FILE__, line)(count == draw, "WM_DRAWCLIPBOARD %sreceived\n", draw ? "not " : "");
1021 count = SendMessageA( win, WM_USER + 2, 0, 0 );
1022 ok_(__FILE__, line)(count == update || broken(!pAddClipboardFormatListener),
1023 "WM_CLIPBOARDUPDATE %sreceived\n", update ? "not " : "");
1024 count = SendMessageA( win, WM_USER + 3, 0, 0 );
1025 ok_(__FILE__, line)(count == destroy, "WM_DESTROYCLIPBOARD %sreceived\n", destroy ? "not " : "");
1026 fmt = SendMessageA( win, WM_USER + 4, 0, 0 );
1027 ok_(__FILE__, line)(fmt == render, "WM_RENDERFORMAT received %04x, expected %04x\n", fmt, render);
1028}
1029#define check_messages(a,b,c,d,e,f) check_messages_(__LINE__,a,b,c,d,e,f)
1030
1032{
1033 HWND ret, win = param;
1034 BOOL r;
1035 MSG msg;
1036 HANDLE handle;
1038
1040 trace( "%s-threaded test\n", cross_thread ? "multi" : "single" );
1041
1043
1045 SetLastError(0xdeadbeef);
1047 ok(GetLastError() == 0xdeadbeef, "GetLastError = %d\n", GetLastError());
1049
1050 SetLastError( 0xdeadbeef );
1051 ret = SetClipboardViewer( (HWND)0xdead );
1052 ok( !ret, "SetClipboardViewer succeeded\n" );
1053 ok( GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "wrong error %u\n", GetLastError() );
1054 SetLastError( 0xdeadbeef );
1055 r = ChangeClipboardChain( win, (HWND)0xdead );
1056 ok( !r, "ChangeClipboardChain succeeded\n" );
1057 ok( GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "wrong error %u\n", GetLastError() );
1058 SetLastError( 0xdeadbeef );
1059 r = ChangeClipboardChain( (HWND)0xdead, next_wnd );
1060 ok( !r, "ChangeClipboardChain succeeded\n" );
1061 ok( GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "wrong error %u\n", GetLastError() );
1062
1063 if (pAddClipboardFormatListener)
1064 {
1065 r = pAddClipboardFormatListener(win);
1066 ok( r, "AddClipboardFormatListener failed err %d\n", GetLastError());
1067 SetLastError( 0xdeadbeef );
1068 r = pAddClipboardFormatListener( win );
1069 ok( !r, "AddClipboardFormatListener succeeded\n" );
1070 ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
1071 SetLastError( 0xdeadbeef );
1072 r = pAddClipboardFormatListener( (HWND)0xdead );
1073 ok( !r, "AddClipboardFormatListener succeeded\n" );
1074 ok( GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "wrong error %u\n", GetLastError() );
1075 r = pAddClipboardFormatListener( GetDesktopWindow() );
1076 ok( r, "AddClipboardFormatListener failed err %d\n", GetLastError());
1077 r = pRemoveClipboardFormatListener( GetDesktopWindow() );
1078 ok( r, "RemoveClipboardFormatListener failed err %d\n", GetLastError());
1079 }
1080
1081 check_messages(win, 0, 1, 0, 0, 0);
1082
1083 SetLastError( 0xdeadbeef );
1084 r = OpenClipboard( (HWND)0xdead );
1085 ok( !r, "OpenClipboard succeeded\n" );
1086 ok( GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "wrong error %u\n", GetLastError() );
1087
1088 r = OpenClipboard(win);
1089 ok(r, "OpenClipboard failed: %d\n", GetLastError());
1090
1091 check_messages(win, 0, 0, 0, 0, 0);
1092
1093 r = EmptyClipboard();
1094 ok(r, "EmptyClipboard failed: %d\n", GetLastError());
1095
1096 check_messages(win, 1, 0, 0, 0, 0);
1097
1098 r = EmptyClipboard();
1099 ok(r, "EmptyClipboard failed: %d\n", GetLastError());
1100 /* sequence changes again, even though it was already empty */
1101 check_messages(win, 1, 0, 0, 1, 0);
1102 count = SendMessageA( win, WM_USER+5, 0, 0 );
1103 ok( !count, "wrong format count %u on WM_DESTROYCLIPBOARD\n", count );
1104
1106 ok(handle != 0, "SetClipboardData failed: %d\n", GetLastError());
1107
1108 check_messages(win, 1, 0, 0, 0, 0);
1109
1111
1112 check_messages(win, 1, 0, 0, 0, 0);
1113
1114 SetClipboardData( CF_UNICODETEXT, 0 ); /* same data again */
1115
1116 check_messages(win, 1, 0, 0, 0, 0);
1117
1118 ok( IsClipboardFormatAvailable( CF_TEXT ), "CF_TEXT available\n" );
1119 ok( IsClipboardFormatAvailable( CF_UNICODETEXT ), "CF_UNICODETEXT available\n" );
1120 ok( !IsClipboardFormatAvailable( CF_OEMTEXT ), "CF_OEMTEXT available\n" );
1121
1123 r = CloseClipboard();
1124 ok(r, "CloseClipboard failed: %d\n", GetLastError());
1126
1127 check_messages(win, 2, 1, 1, 0, 0);
1128
1129 r = OpenClipboard(win);
1130 ok(r, "OpenClipboard failed: %d\n", GetLastError());
1131
1132 check_messages(win, 0, 0, 0, 0, 0);
1133
1134 ok( IsClipboardFormatAvailable( CF_TEXT ), "CF_TEXT available\n" );
1135 ok( IsClipboardFormatAvailable( CF_UNICODETEXT ), "CF_UNICODETEXT available\n" );
1136 ok( IsClipboardFormatAvailable( CF_OEMTEXT ), "CF_OEMTEXT available\n" );
1137
1138 ok( GetClipboardOwner() == win, "wrong owner %p\n", GetClipboardOwner());
1140 ok( !handle, "got data for CF_UNICODETEXT\n" );
1141 fmt = SendMessageA( win, WM_USER+4, 0, 0 );
1142 ok( fmt == CF_UNICODETEXT, "WM_RENDERFORMAT received %04x\n", fmt );
1143
1146 ok( handle != NULL, "didn't get data for CF_OEMTEXT\n" );
1147 fmt = SendMessageA( win, WM_USER+4, 0, 0 );
1148 ok( fmt == CF_UNICODETEXT, "WM_RENDERFORMAT received %04x\n", fmt );
1150
1152 check_messages(win, 1, 0, 0, 0, 0);
1153
1154 r = CloseClipboard();
1155 ok(r, "CloseClipboard failed: %d\n", GetLastError());
1156 /* no synthesized format, so CloseClipboard doesn't change the sequence */
1157 check_messages(win, 0, 1, 1, 0, 0);
1158
1159 r = OpenClipboard(win);
1160 ok(r, "OpenClipboard failed: %d\n", GetLastError());
1161 r = CloseClipboard();
1162 ok(r, "CloseClipboard failed: %d\n", GetLastError());
1163 /* nothing changed */
1164 check_messages(win, 0, 0, 0, 0, 0);
1165
1167 r = OpenClipboard(0);
1168 ok(r, "OpenClipboard failed: %d\n", GetLastError());
1169 r = EmptyClipboard();
1170 ok(r, "EmptyClipboard failed: %d\n", GetLastError());
1171 r = CloseClipboard();
1172 ok(r, "CloseClipboard failed: %d\n", GetLastError());
1173
1174 check_messages(win, 1, 1, 1, 1, 0);
1175 count = SendMessageA( win, WM_USER+5, 0, 0 );
1176 ok( count == formats, "wrong format count %u on WM_DESTROYCLIPBOARD\n", count );
1177
1178 r = OpenClipboard(win);
1179 ok(r, "OpenClipboard failed: %d\n", GetLastError());
1181 check_messages(win, 1, 0, 0, 0, 0);
1182
1184 r = CloseClipboard();
1185 ok(r, "CloseClipboard failed: %d\n", GetLastError());
1187
1188 check_messages(win, 0, 1, 1, 0, 0);
1189
1190 run_process( "grab_clipboard 0" );
1191
1192 if (!cross_thread)
1193 {
1194 /* in this case we get a cross-thread WM_DRAWCLIPBOARD */
1196 while (PeekMessageW( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageW( &msg );
1198 }
1199 check_messages(win, 1, 1, 1, 0, 0);
1200
1201 r = OpenClipboard(0);
1202 ok(r, "OpenClipboard failed: %d\n", GetLastError());
1204 check_messages(win, 1, 0, 0, 0, 0);
1205
1207 r = CloseClipboard();
1208 ok(r, "CloseClipboard failed: %d\n", GetLastError());
1210
1211 check_messages(win, 0, 1, 1, 0, 0);
1212
1213 run_process( "grab_clipboard 1" );
1214
1215 if (!cross_thread)
1216 {
1217 /* in this case we get a cross-thread WM_DRAWCLIPBOARD */
1219 while (PeekMessageW( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageW( &msg );
1221 }
1222 check_messages(win, 2, 1, 1, 0, 0);
1223
1224 r = OpenClipboard(0);
1225 ok(r, "OpenClipboard failed: %d\n", GetLastError());
1227 check_messages(win, 1, 0, 0, 0, 0);
1228
1230 r = CloseClipboard();
1231 ok(r, "CloseClipboard failed: %d\n", GetLastError());
1233
1234 check_messages(win, 0, 1, 1, 0, 0);
1235
1236 if (cross_thread)
1237 {
1238 r = OpenClipboard( win );
1239 ok(r, "OpenClipboard failed: %d\n", GetLastError());
1240 r = EmptyClipboard();
1241 ok(r, "EmptyClipboard failed: %d\n", GetLastError());
1243 r = CloseClipboard();
1244 ok(r, "CloseClipboard failed: %d\n", GetLastError());
1245
1248 run_process( "get_clipboard_data" );
1250
1251 check_messages(win, 0, 1, 1, 0, CF_TEXT);
1252 }
1253
1254 r = PostMessageA(win, WM_USER, 0, 0);
1255 ok(r, "PostMessage failed: %d\n", GetLastError());
1256
1257 if (pRemoveClipboardFormatListener)
1258 {
1259 r = pRemoveClipboardFormatListener(win);
1260 ok( r, "RemoveClipboardFormatListener failed err %d\n", GetLastError());
1261 SetLastError( 0xdeadbeef );
1262 r = pRemoveClipboardFormatListener(win);
1263 ok( !r, "RemoveClipboardFormatListener succeeded\n" );
1264 ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
1265 SetLastError( 0xdeadbeef );
1266 r = pRemoveClipboardFormatListener( (HWND)0xdead );
1267 ok( !r, "RemoveClipboardFormatListener succeeded\n" );
1268 ok( GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "wrong error %u\n", GetLastError() );
1269 }
1270 return 0;
1271}
1272
1273static void test_messages(void)
1274{
1275 WNDCLASSA cls;
1276 HWND win;
1277 MSG msg;
1278 HANDLE thread;
1279 DWORD tid;
1280
1283
1284 memset(&cls, 0, sizeof(cls));
1287 cls.lpszClassName = "clipboard_test";
1288 RegisterClassA(&cls);
1289
1290 win = CreateWindowA("clipboard_test", NULL, 0, 0, 0, 0, 0, NULL, 0, NULL, 0);
1291 ok(win != NULL, "CreateWindow failed: %d\n", GetLastError());
1292
1293 thread = CreateThread(NULL, 0, clipboard_thread, (void*)win, 0, &tid);
1294 ok(thread != NULL, "CreateThread failed: %d\n", GetLastError());
1295
1296 while(GetMessageA(&msg, NULL, 0, 0))
1297 {
1298 ok( msg.message != WM_DRAWCLIPBOARD, "WM_DRAWCLIPBOARD was posted\n" );
1301 }
1302
1303 ok(WaitForSingleObject(thread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
1305
1306 DestroyWindow( win );
1307
1308 /* same tests again but inside a single thread */
1309
1310 win = CreateWindowA( "clipboard_test", NULL, 0, 0, 0, 0, 0, NULL, 0, NULL, 0 );
1311 ok( win != NULL, "CreateWindow failed: %d\n", GetLastError() );
1312
1314 DestroyWindow( win );
1315
1316 UnregisterClassA("clipboard_test", GetModuleHandleA(NULL));
1318}
1319
1321{
1322 void *ptr = GlobalLock( handle );
1323 if (ptr) GlobalUnlock( handle );
1324 return ptr && ptr != handle;
1325}
1326
1328{
1329 void *ptr = GlobalLock( handle );
1330 if (ptr) GlobalUnlock( handle );
1331 return ptr && ptr == handle;
1332}
1333
1335{
1336 return !GlobalSize( handle );
1337}
1338
1341static HPALETTE palette;
1342static const LOGPALETTE logpalette = { 0x300, 1, {{ 0x12, 0x34, 0x56, 0x78 }}};
1343
1344static void test_handles( HWND hwnd )
1345{
1346 HGLOBAL h, htext, htext2, htext3, htext4, htext5;
1347 HGLOBAL hfixed, hfixed2, hmoveable, empty_fixed, empty_moveable;
1348 void *ptr;
1349 UINT format_id2 = RegisterClipboardFormatA( "another format" );
1350 BOOL r;
1351 HANDLE data;
1352 HBITMAP bitmap_temp;
1353 DWORD process;
1355
1356 trace( "hwnd %p\n", hwnd );
1357 htext = create_textA();
1358 htext2 = create_textA();
1359 htext3 = create_textA();
1360 htext4 = create_textA();
1361 htext5 = create_textA();
1362 bitmap = CreateBitmap( 10, 10, 1, 1, NULL );
1363 bitmap2 = CreateBitmap( 10, 10, 1, 1, NULL );
1365
1366 hfixed = GlobalAlloc( GMEM_FIXED, 17 );
1367 hfixed2 = GlobalAlloc( GMEM_FIXED, 17 );
1368 ok( is_fixed( hfixed ), "expected fixed mem %p\n", hfixed );
1369 ok( GlobalSize( hfixed ) == 17, "wrong size %lu\n", GlobalSize( hfixed ));
1370
1371 hmoveable = GlobalAlloc( GMEM_MOVEABLE, 23 );
1372 ok( is_moveable( hmoveable ), "expected moveable mem %p\n", hmoveable );
1373 ok( GlobalSize( hmoveable ) == 23, "wrong size %lu\n", GlobalSize( hmoveable ));
1374
1375 empty_fixed = GlobalAlloc( GMEM_FIXED, 0 );
1376 ok( is_fixed( empty_fixed ), "expected fixed mem %p\n", empty_fixed );
1377
1378 empty_moveable = GlobalAlloc( GMEM_MOVEABLE, 0 );
1379 /* discarded handles can't be GlobalLock'ed */
1380 ok( is_freed( empty_moveable ), "expected free mem %p\n", empty_moveable );
1381
1382 r = OpenClipboard( hwnd );
1383 ok( r, "gle %d\n", GetLastError() );
1384 r = EmptyClipboard();
1385 ok( r, "gle %d\n", GetLastError() );
1386
1387 h = SetClipboardData( CF_TEXT, htext );
1388 ok( h == htext, "got %p\n", h );
1389 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1390 h = SetClipboardData( format_id, htext2 );
1391 ok( h == htext2, "got %p\n", h );
1392 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1393 bitmap_temp = CreateBitmap( 10, 10, 1, 1, NULL );
1394 h = SetClipboardData( CF_BITMAP, bitmap_temp );
1395 ok( h == bitmap_temp, "got %p\n", h );
1396 ok( GetObjectType( h ) == OBJ_BITMAP, "expected bitmap %p\n", h );
1398 ok( h == bitmap, "got %p\n", h );
1399 ok( GetObjectType( h ) == OBJ_BITMAP, "expected bitmap %p\n", h );
1400 ok( !GetObjectType( bitmap_temp ), "expected free object %p\n", bitmap_temp );
1402 ok( h == bitmap2, "got %p\n", h );
1403 ok( GetObjectType( h ) == OBJ_BITMAP, "expected bitmap %p\n", h );
1405 ok( h == palette, "got %p\n", h );
1406 ok( GetObjectType( h ) == OBJ_PAL, "expected palette %p\n", h );
1407 h = SetClipboardData( CF_GDIOBJFIRST + 3, htext3 );
1408 ok( h == htext3, "got %p\n", h );
1409 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1410 h = SetClipboardData( CF_PRIVATEFIRST + 7, htext5 );
1411 ok( h == htext5, "got %p\n", h );
1412 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1413 h = SetClipboardData( format_id2, empty_moveable );
1414 ok( !h, "got %p\n", h );
1415 GlobalFree( empty_moveable );
1416
1417 if (0) /* crashes on vista64 */
1418 {
1419 ptr = HeapAlloc( GetProcessHeap(), 0, 0 );
1420 h = SetClipboardData( format_id2, ptr );
1421 ok( !h, "got %p\n", h );
1422 HeapFree( GetProcessHeap(), 0, ptr );
1423 }
1424
1425 h = SetClipboardData( format_id2, empty_fixed );
1426 ok( h == empty_fixed, "got %p\n", h );
1427 ok( is_fixed( h ), "expected fixed mem %p\n", h );
1428 h = SetClipboardData( 0xdeadbeef, hfixed2 );
1429 ok( h == hfixed2, "got %p\n", h );
1430 ok( is_fixed( h ), "expected fixed mem %p\n", h );
1431 h = SetClipboardData( 0xdeadbabe, hmoveable );
1432 ok( h == hmoveable, "got %p\n", h );
1433 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1434
1435 ptr = HeapAlloc( GetProcessHeap(), 0, 37 );
1436 h = SetClipboardData( 0xdeadfade, ptr );
1437 ok( h == ptr || !h, "got %p\n", h );
1438 if (!h) /* heap blocks are rejected on >= win8 */
1439 {
1440 HeapFree( GetProcessHeap(), 0, ptr );
1441 ptr = NULL;
1442 }
1443
1445 ok( data == htext, "wrong data %p\n", data );
1446 ok( is_moveable( data ), "expected moveable mem %p\n", data );
1447
1449 ok( data == htext2, "wrong data %p, cf %08x\n", data, format_id );
1450 ok( is_moveable( data ), "expected moveable mem %p\n", data );
1451
1453 ok( data == htext3, "wrong data %p\n", data );
1454 ok( is_moveable( data ), "expected moveable mem %p\n", data );
1455
1457 ok( data == htext5, "wrong data %p\n", data );
1458 ok( is_moveable( data ), "expected moveable mem %p\n", data );
1459
1460 data = GetClipboardData( format_id2 );
1461 ok( data == empty_fixed, "wrong data %p\n", data );
1462 ok( is_fixed( data ), "expected fixed mem %p\n", data );
1463
1464 data = GetClipboardData( 0xdeadbeef );
1465 ok( data == hfixed2, "wrong data %p\n", data );
1466 ok( is_fixed( data ), "expected fixed mem %p\n", data );
1467
1468 data = GetClipboardData( 0xdeadbabe );
1469 ok( data == hmoveable, "wrong data %p\n", data );
1470 ok( is_moveable( data ), "expected moveable mem %p\n", data );
1471
1472 data = GetClipboardData( 0xdeadfade );
1473 ok( data == ptr, "wrong data %p\n", data );
1474
1475 h = SetClipboardData( CF_PRIVATEFIRST + 7, htext4 );
1476 ok( h == htext4, "got %p\n", h );
1477 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1478 ok( is_freed( htext5 ), "expected freed mem %p\n", htext5 );
1479
1480 h = SetClipboardData( 0xdeadbeef, hfixed );
1481 ok( h == hfixed, "got %p\n", h );
1482 ok( is_fixed( h ), "expected fixed mem %p\n", h );
1483 if (0) /* this test is unreliable / crashes */
1484 ok( is_freed( hfixed2 ), "expected freed mem %p\n", hfixed2 );
1485
1486 r = CloseClipboard();
1487 ok( r, "gle %d\n", GetLastError() );
1488
1489 /* data handles are still valid */
1490 ok( is_moveable( htext ), "expected moveable mem %p\n", htext );
1491 ok( is_moveable( htext2 ), "expected moveable mem %p\n", htext2 );
1492 ok( is_moveable( htext3 ), "expected moveable mem %p\n", htext3 );
1493 ok( is_moveable( htext4 ), "expected moveable mem %p\n", htext4 );
1494 ok( GetObjectType( bitmap ) == OBJ_BITMAP, "expected bitmap %p\n", bitmap );
1495 ok( GetObjectType( bitmap2 ) == OBJ_BITMAP, "expected bitmap %p\n", bitmap2 );
1496 ok( GetObjectType( palette ) == OBJ_PAL, "expected palette %p\n", palette );
1497 ok( is_fixed( hfixed ), "expected fixed mem %p\n", hfixed );
1498 ok( is_moveable( hmoveable ), "expected moveable mem %p\n", hmoveable );
1499 ok( is_fixed( empty_fixed ), "expected fixed mem %p\n", empty_fixed );
1500
1501 r = OpenClipboard( hwnd );
1502 ok( r, "gle %d\n", GetLastError() );
1503
1504 /* and now they are freed, unless we are the owner */
1505 if (!is_owner)
1506 {
1507 ok( is_freed( htext ), "expected freed mem %p\n", htext );
1508 ok( is_freed( htext2 ), "expected freed mem %p\n", htext2 );
1509 ok( is_freed( htext3 ), "expected freed mem %p\n", htext3 );
1510 ok( is_freed( htext4 ), "expected freed mem %p\n", htext4 );
1511 ok( is_freed( hmoveable ), "expected freed mem %p\n", hmoveable );
1512
1514 ok( is_fixed( data ), "expected fixed mem %p\n", data );
1515
1517 ok( is_fixed( data ), "expected fixed mem %p\n", data );
1518
1520 ok( is_fixed( data ), "expected fixed mem %p\n", data );
1521
1523 ok( is_fixed( data ), "expected fixed mem %p\n", data );
1524
1525 data = GetClipboardData( format_id2 );
1526 ok( is_fixed( data ), "expected fixed mem %p\n", data );
1527 ok( GlobalSize( data ) == 1, "wrong size %lu\n", GlobalSize( data ));
1528
1529 data = GetClipboardData( 0xdeadbeef );
1530 ok( is_fixed( data ), "expected fixed mem %p\n", data );
1531 ok( GlobalSize( data ) == 17, "wrong size %lu\n", GlobalSize( data ));
1532
1533 data = GetClipboardData( 0xdeadbabe );
1534 ok( is_fixed( data ), "expected fixed mem %p\n", data );
1535 ok( GlobalSize( data ) == 23, "wrong size %lu\n", GlobalSize( data ));
1536
1537 data = GetClipboardData( 0xdeadfade );
1538 ok( is_fixed( data ) || !ptr, "expected fixed mem %p\n", data );
1539 if (ptr) ok( GlobalSize( data ) == 37, "wrong size %lu\n", GlobalSize( data ));
1540 }
1541 else
1542 {
1543 ok( is_moveable( htext ), "expected moveable mem %p\n", htext );
1544 ok( is_moveable( htext2 ), "expected moveable mem %p\n", htext2 );
1545 ok( is_moveable( htext3 ), "expected moveable mem %p\n", htext3 );
1546 ok( is_moveable( htext4 ), "expected moveable mem %p\n", htext4 );
1547 ok( is_moveable( hmoveable ), "expected moveable mem %p\n", hmoveable );
1548
1550 ok( data == htext, "wrong data %p\n", data );
1551
1553 ok( data == htext2, "wrong data %p, cf %08x\n", data, format_id );
1554
1556 ok( data == htext3, "wrong data %p\n", data );
1557
1559 ok( data == htext4, "wrong data %p\n", data );
1560
1561 data = GetClipboardData( format_id2 );
1562 ok( data == empty_fixed, "wrong data %p\n", data );
1563
1564 data = GetClipboardData( 0xdeadbeef );
1565 ok( data == hfixed, "wrong data %p\n", data );
1566
1567 data = GetClipboardData( 0xdeadbabe );
1568 ok( data == hmoveable, "wrong data %p\n", data );
1569
1570 data = GetClipboardData( 0xdeadfade );
1571 ok( data == ptr, "wrong data %p\n", data );
1572 }
1573
1575 ok( is_fixed( data ), "expected fixed mem %p\n", data );
1577 ok( is_fixed( data ), "expected fixed mem %p\n", data );
1579 ok( is_fixed( data ), "expected fixed mem %p\n", data );
1581 ok( data == bitmap, "expected bitmap %p\n", data );
1583 ok( data == bitmap2, "expected bitmap %p\n", data );
1585 ok( data == palette, "expected palette %p\n", data );
1587 ok( is_fixed( data ), "expected fixed mem %p\n", data );
1588 data = GetClipboardData( CF_DIBV5 );
1589 ok( is_fixed( data ), "expected fixed mem %p\n", data );
1590
1591 ok( GetObjectType( bitmap ) == OBJ_BITMAP, "expected bitmap %p\n", bitmap );
1592 ok( GetObjectType( bitmap2 ) == OBJ_BITMAP, "expected bitmap %p\n", bitmap2 );
1593 ok( GetObjectType( palette ) == OBJ_PAL, "expected palette %p\n", palette );
1594 ok( is_fixed( hfixed ), "expected fixed mem %p\n", hfixed );
1595 ok( is_fixed( empty_fixed ), "expected fixed mem %p\n", empty_fixed );
1596
1597 r = EmptyClipboard();
1598 ok( r, "gle %d\n", GetLastError() );
1599
1600 /* w2003, w2008 don't seem to free the data here */
1601 ok( is_freed( htext ) || broken( !is_freed( htext )), "expected freed mem %p\n", htext );
1602 ok( is_freed( htext2 ) || broken( !is_freed( htext2 )), "expected freed mem %p\n", htext2 );
1603 ok( is_freed( htext3 ) || broken( !is_freed( htext3 )), "expected freed mem %p\n", htext3 );
1604 ok( is_freed( htext4 ) || broken( !is_freed( htext4 )), "expected freed mem %p\n", htext4 );
1605 ok( is_freed( hmoveable ) || broken( !is_freed( hmoveable )), "expected freed mem %p\n", hmoveable );
1606 ok( is_fixed( empty_fixed ), "expected fixed mem %p\n", empty_fixed );
1607 ok( is_fixed( hfixed ), "expected fixed mem %p\n", hfixed );
1608 ok( !GetObjectType( bitmap ), "expected freed handle %p\n", bitmap );
1609 ok( !GetObjectType( bitmap2 ), "expected freed handle %p\n", bitmap2 );
1610 ok( !GetObjectType( palette ), "expected freed handle %p\n", palette );
1611
1612 r = CloseClipboard();
1613 ok( r, "gle %d\n", GetLastError() );
1614}
1615
1617{
1618 trace( "running from different thread\n" );
1619 test_handles( (HWND)arg );
1620 return 0;
1621}
1622
1624{
1625 BOOL r;
1626 HANDLE h;
1627 char *ptr;
1628
1629 r = OpenClipboard( 0 );
1630 ok( r, "gle %d\n", GetLastError() );
1632 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1633 ptr = GlobalLock( h );
1634 if (ptr) ok( !strcmp( "test", ptr ), "wrong data '%.5s'\n", ptr );
1635 GlobalUnlock( h );
1637 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1638 ptr = GlobalLock( h );
1639 if (ptr) ok( !strcmp( "test", ptr ), "wrong data '%.5s'\n", ptr );
1640 GlobalUnlock( h );
1642 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1643 ptr = GlobalLock( h );
1644 if (ptr) ok( !strcmp( "test", ptr ), "wrong data '%.5s'\n", ptr );
1645 GlobalUnlock( h );
1646 trace( "gdiobj %p\n", h );
1648 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1649 ptr = GlobalLock( h );
1650 if (ptr) ok( !strcmp( "test", ptr ), "wrong data '%.5s'\n", ptr );
1651 GlobalUnlock( h );
1652 trace( "private %p\n", h );
1654 ok( GetObjectType( h ) == OBJ_BITMAP, "expected bitmap %p\n", h );
1655 ok( h == bitmap, "different bitmap %p / %p\n", h, bitmap );
1656 trace( "bitmap %p\n", h );
1658 ok( GetObjectType( h ) == OBJ_BITMAP, "expected bitmap %p\n", h );
1659 ok( h == bitmap2, "different bitmap %p / %p\n", h, bitmap2 );
1660 trace( "bitmap2 %p\n", h );
1662 ok( GetObjectType( h ) == OBJ_PAL, "expected palette %p\n", h );
1663 ok( h == palette, "different palette %p / %p\n", h, palette );
1664 trace( "palette %p\n", h );
1666 ok( is_fixed( h ), "expected fixed mem %p\n", h );
1667 h = GetClipboardData( CF_DIBV5 );
1668 ok( is_fixed( h ), "expected fixed mem %p\n", h );
1669 r = CloseClipboard();
1670 ok( r, "gle %d\n", GetLastError() );
1671 return 0;
1672}
1673
1674static void test_handles_process( const char *str )
1675{
1676 BOOL r;
1677 HANDLE h;
1678 char *ptr;
1679 BITMAP bm;
1681 BYTE buffer[1024];
1682
1683 format_id = RegisterClipboardFormatA( "my_cool_clipboard_format" );
1684 r = OpenClipboard( 0 );
1685 ok( r, "gle %d\n", GetLastError() );
1687 ok( is_fixed( h ), "expected fixed mem %p\n", h );
1688 ptr = GlobalLock( h );
1689 ok( !strcmp( str, ptr ), "wrong data '%.5s'\n", ptr );
1690 GlobalUnlock( h );
1692 ok( is_fixed( h ), "expected fixed mem %p\n", h );
1693 ptr = GlobalLock( h );
1694 if (ptr) ok( !strcmp( str, ptr ), "wrong data '%.5s'\n", ptr );
1695 GlobalUnlock( h );
1697 ok( is_fixed( h ), "expected fixed mem %p\n", h );
1698 ptr = GlobalLock( h );
1699 ok( !strcmp( str, ptr ), "wrong data '%.5s'\n", ptr );
1700 GlobalUnlock( h );
1701 trace( "gdiobj %p\n", h );
1703 ok( is_fixed( h ), "expected fixed mem %p\n", h );
1704 ptr = GlobalLock( h );
1705 ok( !strcmp( str, ptr ), "wrong data '%.5s'\n", ptr );
1706 GlobalUnlock( h );
1707 trace( "private %p\n", h );
1709 ok( GetObjectType( h ) == OBJ_BITMAP, "expected bitmap %p\n", h );
1710 ok( GetObjectW( h, sizeof(bm), &bm ) == sizeof(bm), "GetObject %p failed\n", h );
1711 ok( bm.bmWidth == 13 && bm.bmHeight == 17, "wrong bitmap %ux%u\n", bm.bmWidth, bm.bmHeight );
1712 trace( "bitmap %p\n", h );
1714 ok( !GetObjectType( h ), "expected invalid object %p\n", h );
1715 trace( "bitmap2 %p\n", h );
1717 ok( GetObjectType( h ) == OBJ_PAL, "expected palette %p\n", h );
1718 ok( GetPaletteEntries( h, 0, 1, &entry ) == 1, "GetPaletteEntries %p failed\n", h );
1719 ok( entry.peRed == 0x12 && entry.peGreen == 0x34 && entry.peBlue == 0x56,
1720 "wrong color %02x,%02x,%02x\n", entry.peRed, entry.peGreen, entry.peBlue );
1721 trace( "palette %p\n", h );
1723 ok( is_fixed( h ), "expected fixed mem %p\n", h );
1724#ifdef __REACTOS__
1725 if (h != NULL)
1726#endif
1727 ok( GetObjectType( ((METAFILEPICT *)h)->hMF ) == OBJ_METAFILE,
1728 "wrong object %p\n", ((METAFILEPICT *)h)->hMF );
1729 trace( "metafile %p\n", h );
1731 ok( is_fixed( h ), "expected fixed mem %p\n", h );
1732#ifdef __REACTOS__
1733 if (h != NULL)
1734#endif
1735 ok( GetObjectType( ((METAFILEPICT *)h)->hMF ) == OBJ_METAFILE,
1736 "wrong object %p\n", ((METAFILEPICT *)h)->hMF );
1737 trace( "metafile2 %p\n", h );
1739 ok( GetObjectType( h ) == OBJ_ENHMETAFILE, "expected enhmetafile %p\n", h );
1740 ok( GetEnhMetaFileBits( h, sizeof(buffer), buffer ) > sizeof(ENHMETAHEADER),
1741 "GetEnhMetaFileBits failed on %p\n", h );
1742 ok( ((ENHMETAHEADER *)buffer)->nRecords == 3,
1743 "wrong records %u\n", ((ENHMETAHEADER *)buffer)->nRecords );
1744 trace( "enhmetafile %p\n", h );
1746 ok( GetObjectType( h ) == OBJ_ENHMETAFILE, "expected enhmetafile %p\n", h );
1747 ok( GetEnhMetaFileBits( h, sizeof(buffer), buffer ) > sizeof(ENHMETAHEADER),
1748 "GetEnhMetaFileBits failed on %p\n", h );
1749 ok( ((ENHMETAHEADER *)buffer)->nRecords == 3,
1750 "wrong records %u\n", ((ENHMETAHEADER *)buffer)->nRecords );
1751 trace( "enhmetafile2 %p\n", h );
1753 ok( is_fixed( h ), "expected fixed mem %p\n", h );
1754 h = GetClipboardData( CF_DIBV5 );
1755 ok( is_fixed( h ), "expected fixed mem %p\n", h );
1756 r = CloseClipboard();
1757 ok( r, "gle %d\n", GetLastError() );
1758}
1759
1760static void test_handles_process_open( const char *str )
1761{
1763 char *ptr = GlobalLock( text );
1764
1765 strcpy( ptr, str );
1766 GlobalUnlock( text );
1767
1768 /* clipboard already open by parent process */
1770 ok( h == text, "wrong mem %p / %p\n", h, text );
1771 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1772}
1773
1774static void test_handles_process_dib( const char *str )
1775{
1776 BOOL r;
1777 HANDLE h;
1778
1779 r = OpenClipboard( 0 );
1780 ok( r, "gle %d\n", GetLastError() );
1782 ok( !GetObjectType( h ), "expected invalid object %p\n", h );
1783 trace( "dibsection %p\n", h );
1784 r = CloseClipboard();
1785 ok( r, "gle %d\n", GetLastError() );
1786}
1787
1788static void test_data_handles(void)
1789{
1790 BOOL r;
1791 char *ptr;
1792 HANDLE h, text;
1793 HWND hwnd = CreateWindowA( "static", NULL, WS_POPUP, 0, 0, 10, 10, 0, 0, 0, NULL );
1794 BITMAPINFO bmi;
1795 void *bits;
1796
1797 ok( hwnd != 0, "window creation failed\n" );
1798 format_id = RegisterClipboardFormatA( "my_cool_clipboard_format" );
1799 test_handles( 0 );
1801 test_handles( hwnd );
1802 run_thread( test_handles_thread, hwnd, __LINE__ );
1803
1804 bitmap = CreateBitmap( 13, 17, 1, 1, NULL );
1805 bitmap2 = CreateBitmap( 10, 10, 1, 1, NULL );
1807
1808 r = OpenClipboard( hwnd );
1809 ok( r, "gle %d\n", GetLastError() );
1810 r = EmptyClipboard();
1811 ok( r, "gle %d\n", GetLastError() );
1813 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1815 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1817 ok( GetObjectType( h ) == OBJ_BITMAP, "expected bitmap %p\n", h );
1819 ok( GetObjectType( h ) == OBJ_BITMAP, "expected bitmap %p\n", h );
1821 ok( GetObjectType( h ) == OBJ_PAL, "expected palette %p\n", h );
1823 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1824 trace( "metafile %p\n", h );
1826 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1827 trace( "metafile2 %p\n", h );
1829 ok( GetObjectType( h ) == OBJ_ENHMETAFILE, "expected enhmetafile %p\n", h );
1830 trace( "enhmetafile %p\n", h );
1832 ok( GetObjectType( h ) == OBJ_ENHMETAFILE, "expected enhmetafile %p\n", h );
1833 trace( "enhmetafile2 %p\n", h );
1835 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1837 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1838 r = CloseClipboard();
1839 ok( r, "gle %d\n", GetLastError() );
1840
1841 run_thread( test_handles_thread2, 0, __LINE__ );
1842 run_process( "handles test" );
1843
1844 r = OpenClipboard( hwnd );
1845 ok( r, "gle %d\n", GetLastError() );
1847 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1849 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1851 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1853 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1854
1855 r = EmptyClipboard();
1856 ok( r, "gle %d\n", GetLastError() );
1857 text = create_textA();
1859 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1860
1861 run_process( "handles_open foobar" );
1862
1863 ok( is_moveable( text ), "expected moveable mem %p\n", text );
1865 ok( is_fixed( h ), "expected fixed mem %p\n", h );
1866 ok( is_moveable( text ), "expected moveable mem %p\n", text );
1867 ptr = GlobalLock( h );
1868 ok( !strcmp( ptr, "foobar" ), "wrong data '%.8s'\n", ptr );
1869 GlobalUnlock( h );
1870
1871 r = EmptyClipboard();
1872 ok( r, "gle %d\n", GetLastError() );
1873 ok( is_fixed( h ), "expected free mem %p\n", h );
1874 ok( is_freed( text ) || broken( is_moveable(text) ), /* w2003, w2008 */
1875 "expected free mem %p\n", text );
1876 r = CloseClipboard();
1877 ok( r, "gle %d\n", GetLastError() );
1878
1879 /* test CF_BITMAP with a DIB section */
1880 memset( &bmi, 0, sizeof(bmi) );
1881 bmi.bmiHeader.biSize = sizeof( bmi.bmiHeader );
1882 bmi.bmiHeader.biWidth = 29;
1883 bmi.bmiHeader.biHeight = 13;
1884 bmi.bmiHeader.biPlanes = 1;
1885 bmi.bmiHeader.biBitCount = 32;
1886 bitmap = CreateDIBSection( 0, &bmi, DIB_RGB_COLORS, &bits, 0, 0 );
1887
1888 r = OpenClipboard( hwnd );
1889 ok( r, "gle %d\n", GetLastError() );
1890 r = EmptyClipboard();
1891 ok( r, "gle %d\n", GetLastError() );
1893 ok( GetObjectType( h ) == OBJ_BITMAP, "expected bitmap %p\n", h );
1894 trace( "dibsection %p\n", h );
1895 r = CloseClipboard();
1896 ok( r, "gle %d\n", GetLastError() );
1897
1898 run_process( "handles_dib dummy" );
1899
1900 r = OpenClipboard( hwnd );
1901 ok( r, "gle %d\n", GetLastError() );
1902 ok( GetObjectType( bitmap ) == OBJ_BITMAP, "expected bitmap %p\n", bitmap );
1903 r = EmptyClipboard();
1904 ok( r, "gle %d\n", GetLastError() );
1905 ok( !GetObjectType( bitmap ), "expected deleted %p\n", bitmap );
1906 r = CloseClipboard();
1907 ok( r, "gle %d\n", GetLastError() );
1908
1910}
1911
1913{
1914 BOOL r;
1915 UINT count, formats[256];
1916
1917 if (!pGetUpdatedClipboardFormats)
1918 {
1919 win_skip( "GetUpdatedClipboardFormats not supported\n" );
1920 return;
1921 }
1922
1923 count = 0xdeadbeef;
1924 r = pGetUpdatedClipboardFormats( NULL, 0, &count );
1925 ok( r, "gle %d\n", GetLastError() );
1926 ok( !count, "wrong count %u\n", count );
1927
1928 count = 0xdeadbeef;
1929 r = pGetUpdatedClipboardFormats( NULL, 256, &count );
1930 ok( r, "gle %d\n", GetLastError() );
1931 ok( !count, "wrong count %u\n", count );
1932
1933 SetLastError( 0xdeadbeef );
1934 r = pGetUpdatedClipboardFormats( formats, 256, NULL );
1935 ok( !r, "succeeded\n" );
1936 ok( GetLastError() == ERROR_NOACCESS, "wrong error %u\n", GetLastError() );
1937
1938 count = 0xdeadbeef;
1939 r = pGetUpdatedClipboardFormats( formats, 256, &count );
1940 ok( r, "gle %d\n", GetLastError() );
1941 ok( !count, "wrong count %u\n", count );
1942
1943 r = OpenClipboard( 0 );
1944 ok( r, "gle %d\n", GetLastError() );
1945 r = EmptyClipboard();
1946 ok( r, "gle %d\n", GetLastError() );
1947
1948 count = 0xdeadbeef;
1949 r = pGetUpdatedClipboardFormats( formats, 256, &count );
1950 ok( r, "gle %d\n", GetLastError() );
1951 ok( !count, "wrong count %u\n", count );
1952
1954
1955 count = 0xdeadbeef;
1956 memset( formats, 0xcc, sizeof(formats) );
1957 r = pGetUpdatedClipboardFormats( formats, 256, &count );
1958 ok( r, "gle %d\n", GetLastError() );
1959 ok( count == 1, "wrong count %u\n", count );
1960 ok( formats[0] == CF_UNICODETEXT, "wrong format %u\n", formats[0] );
1961 ok( formats[1] == 0xcccccccc, "wrong format %u\n", formats[1] );
1962
1964 count = 0xdeadbeef;
1965 memset( formats, 0xcc, sizeof(formats) );
1966 r = pGetUpdatedClipboardFormats( formats, 256, &count );
1967 ok( r, "gle %d\n", GetLastError() );
1968 ok( count == 2, "wrong count %u\n", count );
1969 ok( formats[0] == CF_UNICODETEXT, "wrong format %u\n", formats[0] );
1970 ok( formats[1] == CF_TEXT, "wrong format %u\n", formats[1] );
1971 ok( formats[2] == 0xcccccccc, "wrong format %u\n", formats[2] );
1972
1973 SetLastError( 0xdeadbeef );
1974 count = 0xdeadbeef;
1975 r = pGetUpdatedClipboardFormats( formats, 0, &count );
1976 ok( !r, "succeeded\n" );
1977 ok( GetLastError() == ERROR_INSUFFICIENT_BUFFER, "wrong error %u\n", GetLastError() );
1978 ok( count == 2, "wrong count %u\n", count );
1979
1980 SetLastError( 0xdeadbeef );
1981 count = 0xdeadbeef;
1982 r = pGetUpdatedClipboardFormats( formats, 1, &count );
1983 ok( !r, "succeeded\n" );
1984 ok( GetLastError() == ERROR_INSUFFICIENT_BUFFER, "wrong error %u\n", GetLastError() );
1985 ok( count == 2, "wrong count %u\n", count );
1986
1987 r = CloseClipboard();
1988 ok( r, "gle %d\n", GetLastError() );
1989
1990 count = 0xdeadbeef;
1991 memset( formats, 0xcc, sizeof(formats) );
1992 r = pGetUpdatedClipboardFormats( formats, 256, &count );
1993 ok( r, "gle %d\n", GetLastError() );
1994 ok( count == 4, "wrong count %u\n", count );
1995 ok( formats[0] == CF_UNICODETEXT, "wrong format %u\n", formats[0] );
1996 ok( formats[1] == CF_TEXT, "wrong format %u\n", formats[1] );
1997 ok( formats[2] == CF_LOCALE, "wrong format %u\n", formats[2] );
1998 ok( formats[3] == CF_OEMTEXT, "wrong format %u\n", formats[3] );
1999 ok( formats[4] == 0xcccccccc, "wrong format %u\n", formats[4] );
2000
2001 count = 0xdeadbeef;
2002 memset( formats, 0xcc, sizeof(formats) );
2003 r = pGetUpdatedClipboardFormats( formats, 2, &count );
2004 ok( !r, "gle %d\n", GetLastError() );
2005 ok( GetLastError() == ERROR_INSUFFICIENT_BUFFER, "wrong error %u\n", GetLastError() );
2006 ok( count == 4, "wrong count %u\n", count );
2007 ok( formats[0] == 0xcccccccc, "wrong format %u\n", formats[0] );
2008
2009 count = 0xdeadbeef;
2010 r = pGetUpdatedClipboardFormats( NULL, 256, &count );
2011 ok( !r, "gle %d\n", GetLastError() );
2012 ok( GetLastError() == ERROR_NOACCESS, "wrong error %u\n", GetLastError() );
2013 ok( count == 4, "wrong count %u\n", count );
2014
2015 count = 0xdeadbeef;
2016 r = pGetUpdatedClipboardFormats( NULL, 256, &count );
2017 ok( !r, "gle %d\n", GetLastError() );
2018 ok( GetLastError() == ERROR_NOACCESS, "wrong error %u\n", GetLastError() );
2019 ok( count == 4, "wrong count %u\n", count );
2020}
2021
2022static const struct
2023{
2024 char strA[12];
2027} test_data[] =
2028{
2029 { "foo", {0}, 3 }, /* 0 */
2030 { "foo", {0}, 4 },
2031 { "foo\0bar", {0}, 7 },
2032 { "foo\0bar", {0}, 8 },
2033 { "", {'f','o','o'}, 3 * sizeof(WCHAR) },
2034 { "", {'f','o','o',0}, 4 * sizeof(WCHAR) }, /* 5 */
2035 { "", {'f','o','o',0,'b','a','r'}, 7 * sizeof(WCHAR) },
2036 { "", {'f','o','o',0,'b','a','r',0}, 8 * sizeof(WCHAR) },
2037 { "", {'f','o','o'}, 1 },
2038 { "", {'f','o','o'}, 2 },
2039 { "", {'f','o','o'}, 5 }, /* 10 */
2040 { "", {'f','o','o',0}, 7 },
2041 { "", {'f','o','o',0}, 9 },
2043
2044static void test_string_data(void)
2045{
2046 UINT i;
2047 BOOL r;
2048 HANDLE data;
2049 char cmd[16];
2050 char bufferA[12];
2051 WCHAR bufferW[12];
2052
2053 for (i = 0; i < ARRAY_SIZE(test_data); i++)
2054 {
2055 /* 1-byte Unicode strings crash on Win64 */
2056#ifdef _WIN64
2057 if (!test_data[i].strA[0] && test_data[i].len < sizeof(WCHAR)) continue;
2058#endif
2059 r = OpenClipboard( 0 );
2060 ok( r, "gle %d\n", GetLastError() );
2061 r = EmptyClipboard();
2062 ok( r, "gle %d\n", GetLastError() );
2064 if (test_data[i].strA[0])
2065 {
2068 memcpy( bufferA, test_data[i].strA, test_data[i].len );
2069 bufferA[test_data[i].len - 1] = 0;
2070 ok( !memcmp( data, bufferA, test_data[i].len ),
2071 "%u: wrong data %.*s\n", i, test_data[i].len, (char *)data );
2072 }
2073 else
2074 {
2077 memcpy( bufferW, test_data[i].strW, test_data[i].len );
2078 bufferW[(test_data[i].len + 1) / sizeof(WCHAR) - 1] = 0;
2079 ok( !memcmp( data, bufferW, test_data[i].len ),
2080 "%u: wrong data %s\n", i, wine_dbgstr_wn( data, (test_data[i].len + 1) / sizeof(WCHAR) ));
2081 }
2082 r = CloseClipboard();
2083 ok( r, "gle %d\n", GetLastError() );
2084 sprintf( cmd, "string_data %u", i );
2085 run_process( cmd );
2086 }
2087}
2088
2089static void test_string_data_process( int i )
2090{
2091 BOOL r;
2092 HANDLE data;
2093 UINT len, len2;
2094 char bufferA[12];
2095 WCHAR bufferW[12];
2096
2097 r = OpenClipboard( 0 );
2098 ok( r, "gle %d\n", GetLastError() );
2099 if (test_data[i].strA[0])
2100 {
2102 ok( data != 0, "%u: could not get data\n", i );
2103 len = GlobalSize( data );
2104 ok( len == test_data[i].len, "%u: wrong size %u / %u\n", i, len, test_data[i].len );
2105 memcpy( bufferA, test_data[i].strA, test_data[i].len );
2106 bufferA[test_data[i].len - 1] = 0;
2107 ok( !memcmp( data, bufferA, len ), "%u: wrong data %.*s\n", i, len, (char *)data );
2109 ok( data != 0, "%u: could not get data\n", i );
2110 len = GlobalSize( data );
2111 len2 = MultiByteToWideChar( CP_ACP, 0, bufferA, test_data[i].len, bufferW, 12 );
2112 ok( len == len2 * sizeof(WCHAR), "%u: wrong size %u / %u\n", i, len, len2 );
2113 ok( !memcmp( data, bufferW, len ), "%u: wrong data %s\n", i, wine_dbgstr_wn( data, len2 ));
2114 }
2115 else
2116 {
2118 ok( data != 0, "%u: could not get data\n", i );
2119 len = GlobalSize( data );
2120 ok( len == test_data[i].len, "%u: wrong size %u / %u\n", i, len, test_data[i].len );
2121 memcpy( bufferW, test_data[i].strW, test_data[i].len );
2122 bufferW[(test_data[i].len + 1) / sizeof(WCHAR) - 1] = 0;
2123 ok( !memcmp( data, bufferW, len ),
2124 "%u: wrong data %s\n", i, wine_dbgstr_wn( data, (len + 1) / sizeof(WCHAR) ));
2126 if (test_data[i].len >= sizeof(WCHAR))
2127 {
2128 ok( data != 0, "%u: could not get data\n", i );
2129 len = GlobalSize( data );
2130 len2 = WideCharToMultiByte( CP_ACP, 0, bufferW, test_data[i].len / sizeof(WCHAR),
2131 bufferA, 12, NULL, NULL );
2132 bufferA[len2 - 1] = 0;
2133 ok( len == len2, "%u: wrong size %u / %u\n", i, len, len2 );
2134 ok( !memcmp( data, bufferA, len ), "%u: wrong data %.*s\n", i, len, (char *)data );
2135 }
2136 else
2137 {
2138 ok( !data, "%u: got data for empty string\n", i );
2139 ok( IsClipboardFormatAvailable( CF_TEXT ), "%u: text not available\n", i );
2140 }
2141 }
2142 r = CloseClipboard();
2143 ok( r, "gle %d\n", GetLastError() );
2144}
2145
2146START_TEST(clipboard)
2147{
2148 char **argv;
2150 HMODULE mod = GetModuleHandleA( "user32" );
2151
2152 argv0 = argv[0];
2153 pAddClipboardFormatListener = (void *)GetProcAddress( mod, "AddClipboardFormatListener" );
2154 pRemoveClipboardFormatListener = (void *)GetProcAddress( mod, "RemoveClipboardFormatListener" );
2155 pGetUpdatedClipboardFormats = (void *)GetProcAddress( mod, "GetUpdatedClipboardFormats" );
2156
2157 if (argc == 4 && !strcmp( argv[2], "set_clipboard_data" ))
2158 {
2160 return;
2161 }
2162 if (argc == 4 && !strcmp( argv[2], "grab_clipboard" ))
2163 {
2165 return;
2166 }
2167 if (argc == 4 && !strcmp( argv[2], "handles" ))
2168 {
2170 return;
2171 }
2172 if (argc == 4 && !strcmp( argv[2], "handles_open" ))
2173 {
2175 return;
2176 }
2177 if (argc == 4 && !strcmp( argv[2], "handles_dib" ))
2178 {
2180 return;
2181 }
2182 if (argc == 4 && !strcmp( argv[2], "string_data" ))
2183 {
2185 return;
2186 }
2187 if (argc == 3 && !strcmp( argv[2], "get_clipboard_data" ))
2188 {
2190 return;
2191 }
2192
2196 test_messages();
2200}
std::map< E_MODULE, HMODULE > mod
Definition: LocaleTests.cpp:66
static POBJECT_TYPE GetObjectType(IN PCWSTR TypeName)
Definition: ObTypes.c:15
static int argc
Definition: ServiceArgs.c:12
void destroy(_Tp *__pointer)
Definition: _construct.h:278
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
static void startup(void)
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define broken(x)
Definition: atltest.h:178
#define START_TEST(x)
Definition: atltest.h:75
#define ok_(x1, x2)
Definition: atltest.h:61
#define msg(x)
Definition: auth_time.c:54
HWND hWnd
Definition: settings.c:17
#define CF_UNICODETEXT
Definition: constants.h:408
#define CF_METAFILEPICT
Definition: constants.h:398
#define CF_BITMAP
Definition: constants.h:397
#define CF_PALETTE
Definition: constants.h:404
#define CF_DSPENHMETAFILE
Definition: constants.h:417
#define CF_WAVE
Definition: constants.h:407
#define CF_DSPMETAFILEPICT
Definition: constants.h:416
#define CF_LOCALE
Definition: constants.h:411
#define CF_DSPBITMAP
Definition: constants.h:415
#define CF_ENHMETAFILE
Definition: constants.h:409
#define CF_TEXT
Definition: constants.h:396
#define CF_GDIOBJFIRST
Definition: constants.h:420
#define CF_PRIVATEFIRST
Definition: constants.h:418
#define CF_DIB
Definition: constants.h:403
#define CF_OEMTEXT
Definition: constants.h:402
#define ARRAY_SIZE(A)
Definition: main.h:20
static HANDLE thread
Definition: service.c:33
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define ERROR_SUCCESS
Definition: deptool.c:10
WORD ATOM
Definition: dimm.idl:113
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
DWORD bpp
Definition: surface.c:185
static const struct pixel_format_desc formats[]
Definition: util.c:59
#define CloseHandle
Definition: compat.h:739
#define GetProcessHeap()
Definition: compat.h:736
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:109
#define SetLastError(x)
Definition: compat.h:752
HANDLE HWND
Definition: compat.h:19
#define GetProcAddress(x, y)
Definition: compat.h:753
#define HeapAlloc
Definition: compat.h:733
#define MAX_PATH
Definition: compat.h:34
#define HeapFree(x, y, z)
Definition: compat.h:735
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
#define CALLBACK
Definition: compat.h:35
#define WideCharToMultiByte
Definition: compat.h:111
#define MultiByteToWideChar
Definition: compat.h:110
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
ATOM WINAPI FindAtomA(LPCSTR lpString)
Definition: atom.c:556
UINT WINAPI GetAtomNameA(ATOM nAtom, LPSTR lpBuffer, int nSize)
Definition: atom.c:577
ATOM WINAPI GlobalFindAtomA(LPCSTR lpString)
Definition: atom.c:464
UINT WINAPI GlobalGetAtomNameA(ATOM nAtom, LPSTR lpBuffer, int nSize)
Definition: atom.c:484
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessA(LPCSTR lpApplicationName, LPSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCSTR lpCurrentDirectory, LPSTARTUPINFOA lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
Definition: proc.c:4747
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:137
int WINAPI lstrcmpA(LPCSTR str1, LPCSTR str2)
Definition: locale.c:4198
LCID WINAPI GetUserDefaultLCID(void)
Definition: locale.c:1216
const WCHAR * text
Definition: package.c:1794
#define BI_RGB
Definition: precomp.h:56
ULONG RGBQUAD
Definition: precomp.h:59
return ret
Definition: mutex.c:146
#define INFINITE
Definition: serial.h:102
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLenum func
Definition: glext.h:6028
GLuint buffer
Definition: glext.h:5915
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
GLfloat GLfloat p
Definition: glext.h:8902
GLfloat param
Definition: glext.h:5796
GLenum GLsizei len
Definition: glext.h:6722
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
SIZE_T NTAPI GlobalSize(HGLOBAL hMem)
Definition: heapmem.c:1090
#define bits
Definition: infblock.c:15
static TfClientId tid
char hdr[14]
Definition: iptest.cpp:33
uint32_t entry
Definition: isohybrid.c:63
static const WCHAR testW[]
Definition: jsregexp.c:44
static real win[4][36]
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
static PVOID ptr
Definition: dispmode.c:27
static struct test_info tests[]
HWND hWnd1
Definition: button.c:416
HWND hWnd2
Definition: button.c:416
#define sprintf(buf, format,...)
Definition: sprintf.c:55
HDC hdc
Definition: main.c:9
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:88
BOOL expected
Definition: store.c:2063
#define todo_wine
Definition: custom.c:89
static UINT wm_drawclipboard
Definition: clipboard.c:1036
static HENHMETAFILE create_emf(void)
Definition: clipboard.c:1505
static LRESULT CALLBACK clipboard_wnd_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
Definition: clipboard.c:1038
static HWND next_wnd
Definition: clipboard.c:1035
static void test_string_data_process(int i)
Definition: clipboard.c:2089
static DWORD WINAPI open_and_empty_clipboard_thread(LPVOID arg)
Definition: clipboard.c:52
static UINT wm_renderformat
Definition: clipboard.c:894
static DWORD WINAPI set_clipboard_data_thread(LPVOID arg)
Definition: clipboard.c:68
static BOOL is_fixed(HANDLE handle)
Definition: clipboard.c:1327
static BOOL is_freed(HANDLE handle)
Definition: clipboard.c:1334
static UINT wm_destroyclipboard
Definition: clipboard.c:893
static DWORD WINAPI test_handles_thread2(void *arg)
Definition: clipboard.c:1623
static DWORD WINAPI clipboard_render_data_thread(void *param)
Definition: clipboard.c:882
static void test_messages(void)
Definition: clipboard.c:1273
static HGLOBAL create_textW(void)
Definition: clipboard.c:494
static BOOL do_render_format
Definition: clipboard.c:897
static HANDLE update_event
Definition: clipboard.c:898
static void test_ClipboardOwner(void)
Definition: clipboard.c:222
#define check_messages(a, b, c, d, e, f)
Definition: clipboard.c:1029
static DWORD WINAPI test_handles_thread(void *arg)
Definition: clipboard.c:1616
static void test_data_handles(void)
Definition: clipboard.c:1788
static DWORD WINAPI open_clipboard_thread(LPVOID arg)
Definition: clipboard.c:36
static HBITMAP create_bitmap(void)
Definition: clipboard.c:530
static CRITICAL_SECTION clipboard_cs
Definition: clipboard.c:889
static HPALETTE palette
Definition: clipboard.c:1341
static LRESULT CALLBACK renderer_winproc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
Definition: clipboard.c:564
static DWORD WINAPI open_and_empty_clipboard_win_thread(LPVOID arg)
Definition: clipboard.c:60
static UINT nb_formats
Definition: clipboard.c:895
static LRESULT CALLBACK winproc_wrapper(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
Definition: clipboard.c:180
static void check_messages_(int line, HWND win, UINT seq_diff, UINT draw, UINT update, UINT destroy, UINT render)
Definition: clipboard.c:1002
static void test_handles_process(const char *str)
Definition: clipboard.c:1674
static const LOGPALETTE logpalette
Definition: clipboard.c:1342
static WNDPROC old_proc
Definition: clipboard.c:179
static UINT format_id
Definition: clipboard.c:1339
static void test_GetUpdatedClipboardFormats(void)
Definition: clipboard.c:1912
static void test_handles_process_open(const char *str)
Definition: clipboard.c:1760
static HGLOBAL create_textA(void)
Definition: clipboard.c:485
static HBITMAP create_dib(BOOL v5)
Definition: clipboard.c:538
static HBITMAP bitmap
Definition: clipboard.c:1340
WCHAR strW[12]
Definition: clipboard.c:2025
static HBITMAP bitmap2
Definition: clipboard.c:1340
static void run_process(const char *args)
Definition: clipboard.c:162
static void test_string_data(void)
Definition: clipboard.c:2044
static char * argv0
Definition: clipboard.c:34
char strA[12]
Definition: clipboard.c:2024
static UINT old_seq
Definition: clipboard.c:1000
static DWORD WINAPI clipboard_thread(void *param)
Definition: clipboard.c:1031
static BOOL cross_thread
Definition: clipboard.c:896
UINT len
Definition: clipboard.c:2026
static void test_RegisterClipboardFormatA(void)
Definition: clipboard.c:369
static void get_clipboard_data_process(void)
Definition: clipboard.c:987
static void set_clipboard_data_process(int arg)
Definition: clipboard.c:100
static void grab_clipboard_process(int arg)
Definition: clipboard.c:124
static void test_synthesized(void)
Definition: clipboard.c:582
static UINT wm_clipboardupdate
Definition: clipboard.c:892
static UINT UINT * out_count
Definition: clipboard.c:31
static void test_handles_process_dib(const char *str)
Definition: clipboard.c:1774
static DWORD WINAPI empty_clipboard_thread(LPVOID arg)
Definition: clipboard.c:43
static int thread_from_line
Definition: clipboard.c:33
static void run_thread(LPTHREAD_START_ROUTINE func, void *arg, int line)
Definition: clipboard.c:140
static HANDLE create_metafile(void)
Definition: clipboard.c:504
static BOOL is_moveable(HANDLE handle)
Definition: clipboard.c:1320
#define argv
Definition: mplay32.c:18
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
unsigned int UINT
Definition: ndis.h:50
#define BOOL
Definition: nt_native.h:43
EXTINLINE DWORD WINAPI GetClipboardSequenceNumber(VOID)
Definition: ntwrapper.h:202
#define OBJ_METAFILE
Definition: objidl.idl:1417
#define OBJ_BITMAP
Definition: objidl.idl:1415
#define OBJ_PAL
Definition: objidl.idl:1413
#define OBJ_ENHMETAFILE
Definition: objidl.idl:1421
#define WS_POPUP
Definition: pedump.c:616
#define test
Definition: rosglue.h:37
#define wine_dbgstr_wn
Definition: testlist.c:2
const WCHAR * str
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
#define MAKELANGID(p, s)
Definition: nls.h:15
#define LANG_ENGLISH
Definition: nls.h:52
#define SUBLANG_DEFAULT
Definition: nls.h:168
int winetest_debug
#define win_skip
Definition: test.h:164
int winetest_get_mainargs(char ***pargv)
void winetest_wait_child_process(HANDLE process)
strcpy
Definition: string.h:131
#define memset(x, y, z)
Definition: compat.h:39
static void render(void)
Definition: ssstars.c:272
& rect
Definition: startmenu.cpp:1413
Definition: bl.h:1331
HINSTANCE hInstance
Definition: winuser.h:3269
LPCSTR lpszClassName
Definition: winuser.h:3274
WNDPROC lpfnWndProc
Definition: winuser.h:3266
Definition: match.c:390
Definition: uimain.c:89
Definition: ftp_var.h:139
Definition: emfdc.c:45
Definition: dsound.c:943
Definition: format.c:58
Definition: parser.c:49
USHORT biBitCount
Definition: precomp.h:46
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1922
HMETAFILE hMF
Definition: wingdi.h:3054
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
#define GWLP_WNDPROC
Definition: treelist.c:66
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:245
UINT WINAPI GetPaletteEntries(HPALETTE hpal, UINT iStartIndex, UINT cEntries, LPPALETTEENTRY ppe)
Definition: palette.c:64
DWORD WINAPI InSendMessageEx(LPVOID lpReserved)
Definition: message.c:1391
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
DWORD WINAPI GetCurrentThreadId(void)
Definition: thread.c:459
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
DWORD WINAPI GetCurrentProcessId(void)
Definition: proc.c:1158
#define GMEM_ZEROINIT
Definition: winbase.h:339
#define GMEM_FIXED
Definition: winbase.h:326
DWORD WINAPI GetWindowThreadProcessId(HWND hWnd, PDWORD lpdwProcessId)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
#define WAIT_OBJECT_0
Definition: winbase.h:439
#define GMEM_MOVEABLE
Definition: winbase.h:327
#define GMEM_DDESHARE
Definition: winbase.h:331
DWORD(WINAPI * LPTHREAD_START_ROUTINE)(LPVOID)
Definition: winbase.h:764
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
UINT_PTR WPARAM
Definition: windef.h:207
void * arg
Definition: msvc.h:10
#define WINAPI
Definition: msvc.h:6
#define ERROR_CLIPBOARD_NOT_OPEN
Definition: winerror.h:1245
#define ERROR_INVALID_WINDOW_HANDLE
Definition: winerror.h:1227
#define ERROR_NOACCESS
Definition: winerror.h:903
static void test_handles(void)
Definition: winstation.c:109
UINT WINAPI GetEnhMetaFileBits(_In_ HENHMETAFILE hEMF, _In_ UINT nSize, _Out_writes_bytes_opt_(nSize) LPBYTE lpData)
#define DIB_RGB_COLORS
Definition: wingdi.h:367
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
HDC WINAPI CreateMetaFileA(_In_opt_ LPCSTR)
HPALETTE WINAPI CreatePalette(_In_reads_(_Inexpressible_(2 *sizeof(WORD)+plpal->palNumEntries *sizeof(PALETTEENTRY))) const LOGPALETTE *)
HMETAFILE WINAPI CloseMetaFile(_In_ HDC hdc)
BOOL WINAPI ExtTextOutA(_In_ HDC hdc, _In_ int x, _In_ int y, _In_ UINT options, _In_opt_ const RECT *lprect, _In_reads_opt_(c) LPCSTR lpString, _In_ UINT c, _In_reads_opt_(c) const INT *lpDx)
HDC WINAPI CreateEnhMetaFileA(_In_opt_ HDC, _In_opt_ LPCSTR, _In_opt_ LPCRECT, _In_opt_ LPCSTR)
#define ETO_OPAQUE
Definition: wingdi.h:647
#define MM_TEXT
Definition: wingdi.h:873
HENHMETAFILE WINAPI CloseEnhMetaFile(_In_ HDC hdc)
#define BITSPIXEL
Definition: wingdi.h:720
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
LRESULT WINAPI DispatchMessageA(_In_ const MSG *)
#define SetWindowLongPtrA
Definition: winuser.h:5456
BOOL WINAPI TranslateMessage(_In_ const MSG *)
HWND WINAPI CreateWindowExA(_In_ DWORD dwExStyle, _In_opt_ LPCSTR lpClassName, _In_opt_ LPCSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
BOOL WINAPI UnregisterClassA(_In_ LPCSTR, HINSTANCE)
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_DESTROYCLIPBOARD
Definition: winuser.h:1896
int WINAPI GetClipboardFormatNameA(_In_ UINT format, _Out_writes_(cchMaxCount) LPSTR lpszFormatName, _In_ int cchMaxCount)
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4417
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define WM_DRAWCLIPBOARD
Definition: winuser.h:1897
HANDLE WINAPI SetClipboardData(_In_ UINT, _In_opt_ HANDLE)
HWND WINAPI GetOpenClipboardWindow(void)
Definition: ntwrapper.h:214
BOOL WINAPI CloseClipboard(void)
Definition: ntwrapper.h:178
HWND WINAPI GetClipboardOwner(void)
Definition: ntwrapper.h:196
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define QS_ALLINPUT
Definition: winuser.h:914
BOOL WINAPI OpenClipboard(_In_opt_ HWND)
UINT WINAPI EnumClipboardFormats(_In_ UINT)
#define WM_CHANGECBCHAIN
Definition: winuser.h:1902
HANDLE WINAPI GetClipboardData(_In_ UINT)
HWND WINAPI SetClipboardViewer(_In_ HWND)
HWND WINAPI GetDesktopWindow(void)
Definition: window.c:628
DWORD WINAPI MsgWaitForMultipleObjectsEx(_In_ DWORD nCount, _In_reads_opt_(nCount) CONST HANDLE *pHandles, _In_ DWORD dwMilliseconds, _In_ DWORD dwWakeMask, _In_ DWORD dwFlags)
ATOM WINAPI RegisterClassA(_In_ CONST WNDCLASSA *)
BOOL WINAPI PeekMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
BOOL WINAPI ChangeClipboardChain(_In_ HWND, _In_ HWND)
#define PM_REMOVE
Definition: winuser.h:1207
BOOL WINAPI EmptyClipboard(void)
Definition: ntwrapper.h:190
HDC WINAPI GetDC(_In_opt_ HWND)
int WINAPI CountClipboardFormats(void)
Definition: ntwrapper.h:184
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
#define WM_USER
Definition: winuser.h:1923
#define WM_DESTROY
Definition: winuser.h:1637
#define WM_RENDERFORMAT
Definition: winuser.h:1894
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:3008
BOOL WINAPI GetMessageA(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
UINT WINAPI RegisterClipboardFormatA(_In_ LPCSTR)
BOOL WINAPI DestroyWindow(_In_ HWND)
BOOL WINAPI PostMessageA(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_RENDERALLFORMATS
Definition: winuser.h:1895
BOOL WINAPI IsClipboardFormatAvailable(_In_ UINT)
HWND WINAPI GetClipboardViewer(void)
Definition: ntwrapper.h:208
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned char BYTE
Definition: xxhash.c:193