ReactOS 0.4.16-dev-401-g45b008d
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
29#ifdef __REACTOS__
30#define WM_CLIPBOARDUPDATE 0x031D
31#endif
32
33static BOOL (WINAPI *pAddClipboardFormatListener)(HWND hwnd);
34static BOOL (WINAPI *pRemoveClipboardFormatListener)(HWND hwnd);
35static BOOL (WINAPI *pGetUpdatedClipboardFormats)( UINT *formats, UINT count, UINT *out_count );
36
38static char *argv0;
39
41{
42 HWND hWnd = arg;
43 ok(OpenClipboard(hWnd), "%u: OpenClipboard failed\n", thread_from_line);
44 return 0;
45}
46
48{
49 SetLastError( 0xdeadbeef );
50 ok(!EmptyClipboard(), "%u: EmptyClipboard succeeded\n", thread_from_line );
51 ok( GetLastError() == ERROR_CLIPBOARD_NOT_OPEN, "%u: wrong error %u\n",
53 return 0;
54}
55
57{
58 HWND hWnd = arg;
59 ok(OpenClipboard(hWnd), "%u: OpenClipboard failed\n", thread_from_line);
60 ok(EmptyClipboard(), "%u: EmptyClipboard failed\n", thread_from_line );
61 return 0;
62}
63
65{
66 HWND hwnd = CreateWindowA( "static", NULL, WS_POPUP, 0, 0, 10, 10, 0, 0, 0, NULL );
67 ok(OpenClipboard(hwnd), "%u: OpenClipboard failed\n", thread_from_line);
68 ok(EmptyClipboard(), "%u: EmptyClipboard failed\n", thread_from_line );
69 return 0;
70}
71
73{
74 HWND hwnd = arg;
75 HANDLE ret;
76
77 SetLastError( 0xdeadbeef );
78 if (GetClipboardOwner() == hwnd)
79 {
81 ok( IsClipboardFormatAvailable( CF_WAVE ), "%u: SetClipboardData failed\n", thread_from_line );
83 ok( ret != 0, "%u: SetClipboardData failed err %u\n", thread_from_line, GetLastError() );
84 SetLastError( 0xdeadbeef );
86 ok( !ret, "%u: GetClipboardData succeeded\n", thread_from_line );
87 ok( GetLastError() == ERROR_CLIPBOARD_NOT_OPEN, "%u: wrong error %u\n",
89 }
90 else
91 {
93 ok( GetLastError() == ERROR_CLIPBOARD_NOT_OPEN, "%u: wrong error %u\n",
95 ok( !IsClipboardFormatAvailable( CF_WAVE ), "%u: SetClipboardData succeeded\n", thread_from_line );
97 ok( !ret, "%u: SetClipboardData succeeded\n", thread_from_line );
98 ok( GetLastError() == ERROR_CLIPBOARD_NOT_OPEN, "%u: wrong error %u\n",
100 }
101 return 0;
102}
103
105{
106 HANDLE ret;
107
108 SetLastError( 0xdeadbeef );
109 if (arg)
110 {
111 ok( IsClipboardFormatAvailable( CF_WAVE ), "process %u: CF_WAVE not available\n", arg );
113 ok( ret != 0, "process %u: SetClipboardData failed err %u\n", arg, GetLastError() );
114 }
115 else
116 {
118 ok( GetLastError() == ERROR_CLIPBOARD_NOT_OPEN, "process %u: wrong error %u\n",
119 arg, GetLastError());
120 ok( !IsClipboardFormatAvailable( CF_WAVE ), "process %u: SetClipboardData succeeded\n", arg );
122 ok( !ret, "process %u: SetClipboardData succeeded\n", arg );
123 ok( GetLastError() == ERROR_CLIPBOARD_NOT_OPEN, "process %u: wrong error %u\n",
124 arg, GetLastError());
125 }
126}
127
128static void grab_clipboard_process( int arg )
129{
130 BOOL ret;
131
132 SetLastError( 0xdeadbeef );
133 ret = OpenClipboard( 0 );
134 ok( ret, "OpenClipboard failed\n" );
136 ok( ret, "EmptyClipboard failed\n" );
137 if (arg)
138 {
140 ok( ret != 0, "process %u: SetClipboardData failed err %u\n", arg, GetLastError() );
141 }
142}
143
145{
146 DWORD ret;
148
150 thread = CreateThread(NULL, 0, func, arg, 0, NULL);
151 ok(thread != NULL, "%u: CreateThread failed with error %d\n", line, GetLastError());
152 for (;;)
153 {
155 if (ret == WAIT_OBJECT_0 + 1)
156 {
157 MSG msg;
158 while (PeekMessageW( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageW( &msg );
159 }
160 else break;
161 }
162 ok(ret == WAIT_OBJECT_0, "%u: expected WAIT_OBJECT_0, got %u\n", line, ret);
164}
165
166static void run_process( const char *args )
167{
168 char cmd[MAX_PATH];
171
172 sprintf( cmd, "%s clipboard %s", argv0, args );
173 memset( &startup, 0, sizeof(startup) );
174 startup.cb = sizeof(startup);
176 "CreateProcess %s failed\n", cmd );
177
179 CloseHandle( info.hProcess );
180 CloseHandle( info.hThread );
181}
182
185{
186 static int wm_renderallformats;
187 static int wm_drawclipboard;
188 static int seqno;
189 DWORD msg_flags = InSendMessageEx( NULL );
190
191 if (!seqno) seqno = GetClipboardSequenceNumber();
192
193 trace( "%p msg %04x\n", hwnd, msg );
194 if (!wm_renderallformats)
195 {
196 ok( GetClipboardOwner() == hwnd, "%04x: wrong owner %p/%p\n", msg, GetClipboardOwner(), hwnd );
197 ok( seqno == GetClipboardSequenceNumber(), "%04x: seqno changed\n", msg );
198 }
199 else
200 {
201 ok( !GetClipboardOwner(), "%04x: wrong owner %p\n", msg, GetClipboardOwner() );
202 ok( seqno + 1 == GetClipboardSequenceNumber(), "%04x: seqno unchanged\n", msg );
203 }
204 ok( GetClipboardViewer() == hwnd, "%04x: wrong viewer %p/%p\n", msg, GetClipboardViewer(), hwnd );
205 ok( GetOpenClipboardWindow() == hwnd, "%04x: wrong open win %p/%p\n",
207
208 switch (msg)
209 {
210 case WM_DESTROY:
211 ok( wm_renderallformats, "didn't receive WM_RENDERALLFORMATS before WM_DESTROY\n" );
212 ok( wm_drawclipboard, "didn't receive WM_DRAWCLIPBOARD before WM_DESTROY\n" );
213 break;
214 case WM_DRAWCLIPBOARD:
215 ok( msg_flags == ISMEX_NOSEND, "WM_DRAWCLIPBOARD wrong flags %x\n", msg_flags );
217 break;
219 ok( msg_flags == ISMEX_NOSEND, "WM_RENDERALLFORMATS wrong flags %x\n", msg_flags );
220 wm_renderallformats++;
221 break;
222 }
223 return old_proc( hwnd, msg, wp, lp );
224}
225
226static void test_ClipboardOwner(void)
227{
229 BOOL ret;
230
231 SetLastError(0xdeadbeef);
232 ok(!GetClipboardOwner() && GetLastError() == 0xdeadbeef,
233 "could not perform clipboard test: clipboard already owned\n");
234
235 hWnd1 = CreateWindowExA(0, "static", NULL, WS_POPUP,
236 0, 0, 10, 10, 0, 0, 0, NULL);
237 ok(hWnd1 != 0, "CreateWindowExA error %d\n", GetLastError());
238 trace("hWnd1 = %p\n", hWnd1);
239
240 hWnd2 = CreateWindowExA(0, "static", NULL, WS_POPUP,
241 0, 0, 10, 10, 0, 0, 0, NULL);
242 ok(hWnd2 != 0, "CreateWindowExA error %d\n", GetLastError());
243 trace("hWnd2 = %p\n", hWnd2);
244
245 SetLastError(0xdeadbeef);
246 ok(!CloseClipboard(), "CloseClipboard should fail if clipboard wasn't open\n");
247 ok(GetLastError() == ERROR_CLIPBOARD_NOT_OPEN || broken(GetLastError() == 0xdeadbeef), /* wow64 */
248 "wrong error %u\n", GetLastError());
249
250 ok(OpenClipboard(0), "OpenClipboard failed\n");
251 ok(!GetClipboardOwner(), "clipboard should still be not owned\n");
252 ok(!OpenClipboard(hWnd1), "OpenClipboard should fail since clipboard already opened\n");
253 ok(OpenClipboard(0), "OpenClipboard again failed\n");
255 ok( ret, "CloseClipboard error %d\n", GetLastError());
256
257 ok(OpenClipboard(hWnd1), "OpenClipboard failed\n");
259 run_thread( empty_clipboard_thread, 0, __LINE__ );
261 ok( !IsClipboardFormatAvailable( CF_WAVE ), "CF_WAVE available\n" );
262 ok( !GetClipboardData( CF_WAVE ), "CF_WAVE data available\n" );
263 run_process( "set_clipboard_data 0" );
264 ok(!CloseClipboard(), "CloseClipboard should fail if clipboard wasn't open\n");
265 ok(OpenClipboard(hWnd1), "OpenClipboard failed\n");
266
267 SetLastError(0xdeadbeef);
269 ok(!ret && (GetLastError() == 0xdeadbeef || GetLastError() == ERROR_ACCESS_DENIED),
270 "OpenClipboard should fail without setting last error value, or with ERROR_ACCESS_DENIED, got error %d\n", GetLastError());
271
272 SetLastError(0xdeadbeef);
273 ok(!GetClipboardOwner() && GetLastError() == 0xdeadbeef, "clipboard should still be not owned\n");
275 ok( ret, "EmptyClipboard error %d\n", GetLastError());
276 ok(GetClipboardOwner() == hWnd1, "clipboard should be owned by %p, not by %p\n", hWnd1, GetClipboardOwner());
277 run_thread( empty_clipboard_thread, 0, __LINE__ );
279 ok( IsClipboardFormatAvailable( CF_WAVE ), "CF_WAVE not available\n" );
280 ok( GetClipboardData( CF_WAVE ) != 0, "CF_WAVE data not available\n" );
281 run_process( "set_clipboard_data 1" );
282
283 SetLastError(0xdeadbeef);
285 ok(!ret && (GetLastError() == 0xdeadbeef || GetLastError() == ERROR_ACCESS_DENIED),
286 "OpenClipboard should fail without setting last error value, or with ERROR_ACCESS_DENIED, got error %d\n", GetLastError());
287
289 ok( ret, "CloseClipboard error %d\n", GetLastError());
290 ok(GetClipboardOwner() == hWnd1, "clipboard should still be owned\n");
291
292 /* any window will do, even from a different process */
294 ok( ret, "OpenClipboard error %d\n", GetLastError());
296 ok( ret, "EmptyClipboard error %d\n", GetLastError());
297 ok( GetClipboardOwner() == GetDesktopWindow(), "wrong owner %p/%p\n",
300 ok( IsClipboardFormatAvailable( CF_WAVE ), "CF_WAVE not available\n" );
301 ok( GetClipboardData( CF_WAVE ) != 0, "CF_WAVE data not available\n" );
302 run_process( "set_clipboard_data 2" );
304 ok( ret, "CloseClipboard error %d\n", GetLastError());
305
307 ok( ret, "OpenClipboard error %d\n", GetLastError());
309 ok( ret, "EmptyClipboard error %d\n", GetLastError());
312 ok( GetClipboardOwner() == hWnd1, "wrong owner %p/%p\n", GetClipboardOwner(), hWnd1 );
313 ok( GetClipboardViewer() == hWnd1, "wrong viewer %p/%p\n", GetClipboardViewer(), hWnd1 );
314 ok( GetOpenClipboardWindow() == hWnd1, "wrong open win %p/%p\n", GetOpenClipboardWindow(), hWnd1 );
315 ok( IsClipboardFormatAvailable( CF_WAVE ), "CF_WAVE not available\n" );
316
319 ok( ret, "DestroyWindow error %d\n", GetLastError());
321 ok( ret, "DestroyWindow error %d\n", GetLastError());
322 SetLastError(0xdeadbeef);
323 ok(!GetClipboardOwner() && GetLastError() == 0xdeadbeef, "clipboard should not be owned\n");
324 ok(!GetClipboardViewer() && GetLastError() == 0xdeadbeef, "viewer still exists\n");
325 ok(!GetOpenClipboardWindow() && GetLastError() == 0xdeadbeef, "clipboard should not be open\n");
326 ok( !IsClipboardFormatAvailable( CF_WAVE ), "CF_WAVE available\n" );
327
328 SetLastError( 0xdeadbeef );
330 ok( !ret, "CloseClipboard succeeded\n" );
331 ok( GetLastError() == ERROR_CLIPBOARD_NOT_OPEN, "wrong error %u\n", GetLastError() );
332
333 ret = OpenClipboard( 0 );
334 ok( ret, "OpenClipboard error %d\n", GetLastError());
336 ok( IsClipboardFormatAvailable( CF_WAVE ), "CF_WAVE not available\n" );
337 ok( GetClipboardData( CF_WAVE ) != 0, "CF_WAVE data not available\n" );
338 run_process( "set_clipboard_data 3" );
340 ok( ret, "CloseClipboard error %d\n", GetLastError());
341
343 ok( !GetOpenClipboardWindow(), "wrong open window %p\n", GetOpenClipboardWindow() );
344 ok( !GetClipboardOwner(), "wrong owner window %p\n", GetClipboardOwner() );
345
346 ret = OpenClipboard( 0 );
347 ok( ret, "OpenClipboard error %d\n", GetLastError());
349 ok( IsClipboardFormatAvailable( CF_WAVE ), "CF_WAVE not available\n" );
350 ok( GetClipboardData( CF_WAVE ) != 0, "CF_WAVE data not available\n" );
351 run_process( "set_clipboard_data 4" );
353 ok( ret, "EmptyClipboard error %d\n", GetLastError());
355 ok( ret, "CloseClipboard error %d\n", GetLastError());
356
357 SetLastError( 0xdeadbeef );
359 "SetClipboardData succeeded\n" );
360 ok( GetLastError() == ERROR_CLIPBOARD_NOT_OPEN, "wrong error %u\n", GetLastError() );
361 ok( !IsClipboardFormatAvailable( CF_WAVE ), "SetClipboardData succeeded\n" );
362
364 ok( !GetOpenClipboardWindow(), "wrong open window %p\n", GetOpenClipboardWindow() );
365 ok( GetClipboardOwner() == GetDesktopWindow(), "wrong owner window %p / %p\n",
367
369 ok( !GetOpenClipboardWindow(), "wrong open window %p\n", GetOpenClipboardWindow() );
370 ok( !GetClipboardOwner(), "wrong owner window %p\n", GetClipboardOwner() );
371}
372
374{
375 ATOM atom_id;
376 UINT format_id, format_id2;
377 char buf[256];
378 int len;
379 BOOL ret;
381
382 format_id = RegisterClipboardFormatA("my_cool_clipboard_format");
383 ok(format_id > 0xc000 && format_id < 0xffff, "invalid clipboard format id %04x\n", format_id);
384
385 format_id2 = RegisterClipboardFormatA("MY_COOL_CLIPBOARD_FORMAT");
386 ok(format_id2 == format_id, "invalid clipboard format id %04x\n", format_id2);
387
389 ok(len == lstrlenA("my_cool_clipboard_format"), "wrong format name length %d\n", len);
390 ok(!lstrcmpA(buf, "my_cool_clipboard_format"), "wrong format name \"%s\"\n", buf);
391
393 ok(len == 0, "wrong format name length %d\n", len);
394
395 lstrcpyA(buf, "foo");
396 SetLastError(0xdeadbeef);
398 ok(len == 0, "GetAtomNameA should fail\n");
400
402{
403 lstrcpyA(buf, "foo");
404 SetLastError(0xdeadbeef);
406 ok(len == 0, "GlobalGetAtomNameA should fail\n");
408}
409
410 SetLastError(0xdeadbeef);
411 atom_id = FindAtomA("my_cool_clipboard_format");
412 ok(atom_id == 0, "FindAtomA should fail\n");
414
415 if (0)
416 {
417 /* this relies on the clipboard and global atom table being different */
418 SetLastError(0xdeadbeef);
419 atom_id = GlobalFindAtomA("my_cool_clipboard_format");
420 ok(atom_id == 0, "GlobalFindAtomA should fail\n");
422 }
423
424 for (format_id = 0; format_id < 0x10fff; format_id++)
425 {
426 SetLastError(0xdeadbeef);
428
429 if (format_id < 0xc000 || format_id > 0xffff)
430 ok(!len, "GetClipboardFormatNameA should fail, but it returned %d (%s)\n", len, buf);
431 else if (len && winetest_debug > 1)
432 trace("%04x: %s\n", format_id, len ? buf : "");
433 }
434
435 ret = OpenClipboard(0);
436 ok( ret, "OpenClipboard error %d\n", GetLastError());
437
438 /* try some invalid/unregistered formats */
439 SetLastError( 0xdeadbeef );
441 ok( !handle, "SetClipboardData succeeded\n" );
442 ok( GetLastError() == ERROR_CLIPBOARD_NOT_OPEN, "wrong error %u\n", GetLastError());
444 ok( handle != 0, "SetClipboardData failed err %d\n", GetLastError());
446 ok( handle != 0, "SetClipboardData failed err %d\n", GetLastError());
448 ok( handle != 0, "SetClipboardData failed err %d\n", GetLastError());
449
450 ok( IsClipboardFormatAvailable( 0x1234 ), "format missing\n" );
451 ok( IsClipboardFormatAvailable( 0x123456 ), "format missing\n" );
452 ok( IsClipboardFormatAvailable( 0xffff8765 ), "format missing\n" );
453 ok( !IsClipboardFormatAvailable( 0 ), "format available\n" );
454 ok( !IsClipboardFormatAvailable( 0x3456 ), "format available\n" );
455 ok( !IsClipboardFormatAvailable( 0x8765 ), "format available\n" );
456
457 trace("# of formats available: %d\n", CountClipboardFormats());
458
459 format_id = 0;
461 {
462 ok(IsClipboardFormatAvailable(format_id), "format %04x was listed as available\n", format_id);
464 trace("%04x: %s\n", format_id, len ? buf : "");
465 }
466
468 ok( ret, "EmptyClipboard error %d\n", GetLastError());
470 ok( ret, "CloseClipboard error %d\n", GetLastError());
471
473 {
474 SetLastError(0xdeadbeef);
475 ok(!EnumClipboardFormats(0), "EnumClipboardFormats should fail if clipboard wasn't open\n");
477 "Last error should be set to ERROR_CLIPBOARD_NOT_OPEN, not %d\n", GetLastError());
478 }
479
480 SetLastError(0xdeadbeef);
481 ok(!EmptyClipboard(), "EmptyClipboard should fail if clipboard wasn't open\n");
482 ok(GetLastError() == ERROR_CLIPBOARD_NOT_OPEN || broken(GetLastError() == 0xdeadbeef), /* wow64 */
483 "Wrong error %u\n", GetLastError());
484
486 ok(format_id == 1234, "invalid clipboard format id %04x\n", format_id);
487}
488
490{
492 char *p = GlobalLock(h);
493 memcpy(p, "test\0\0\0\0\0", 10);
495 return h;
496}
497
499{
500 static const WCHAR testW[] = {'t','e','s','t',0,0,0,0,0,0};
502 WCHAR *p = GlobalLock(h);
503 memcpy(p, testW, sizeof(testW));
505 return h;
506}
507
509{
510 const RECT rect = {0, 0, 100, 100};
511 METAFILEPICT *pict;
512 HANDLE ret;
513 HMETAFILE mf;
515 ExtTextOutA( hdc, 0, 0, ETO_OPAQUE, &rect, "Test String", strlen("Test String"), NULL );
516 mf = CloseMetaFile( hdc );
517 ret = GlobalAlloc( GMEM_DDESHARE | GMEM_MOVEABLE, sizeof(*pict) );
518 pict = GlobalLock( ret );
519 pict->mm = MM_TEXT;
520 pict->xExt = pict->yExt = 100;
521 pict->hMF = mf;
522 GlobalUnlock( ret );
523 return ret;
524}
525
526static HENHMETAFILE create_emf(void)
527{
528 const RECT rect = {0, 0, 100, 100};
529 HDC hdc = CreateEnhMetaFileA(NULL, NULL, &rect, "HENHMETAFILE Ole Clipboard Test\0Test\0\0");
530 ExtTextOutA(hdc, 0, 0, ETO_OPAQUE, &rect, "Test String", strlen("Test String"), NULL);
531 return CloseEnhMetaFile(hdc);
532}
533
535{
536 HDC hdc = GetDC( 0 );
538 ReleaseDC( 0, hdc );
539 return CreateBitmap( 10, 10, 1, bpp, NULL );
540}
541
543{
544 HANDLE ret;
546
548 sizeof(BITMAPV5HEADER) + 256 * sizeof(RGBQUAD) + 16 * 16 * 4 );
549 hdr = GlobalLock( ret );
550 hdr->biSize = v5 ? sizeof(BITMAPV5HEADER) : sizeof(*hdr);
551 hdr->biWidth = 16;
552 hdr->biHeight = 16;
553 hdr->biPlanes = 1;
554 hdr->biBitCount = 32;
555 hdr->biCompression = BI_RGB;
556 if (v5)
557 {
558 BITMAPV5HEADER *hdr5 = (BITMAPV5HEADER *)hdr;
559 hdr5->bV5RedMask = 0x0000ff;
560 hdr5->bV5GreenMask = 0x00ff00;
561 hdr5->bV5BlueMask = 0xff0000;
562 hdr5->bV5AlphaMask = 0xff000000;
563 }
564 GlobalUnlock( ret );
565 return ret;
566}
567
569{
570 static UINT rendered;
571 UINT ret;
572
573 switch (msg)
574 {
575 case WM_RENDERFORMAT:
576 if (wp < 32) rendered |= (1 << wp);
577 break;
578 case WM_USER:
579 ret = rendered;
580 rendered = 0;
581 return ret;
582 }
583 return DefWindowProcA( hwnd, msg, wp, lp );
584}
585
586static void test_synthesized(void)
587{
588 static const struct test
589 {
590 UINT format;
591 UINT expected[8];
592 } tests[] =
593 {
599/* 5 */ { CF_BITMAP, { CF_BITMAP, CF_DIB, CF_DIBV5 }},
600 { CF_DIB, { CF_DIB, CF_BITMAP, CF_DIBV5 }},
601 { CF_DIBV5, { CF_DIBV5, CF_BITMAP, CF_DIB }},
602 };
603
604 HGLOBAL h, htext;
605 HENHMETAFILE emf;
606 BOOL r;
607 UINT cf, i, j, count, rendered, seq, old_seq;
608 HANDLE data;
609 HWND hwnd;
610
611 hwnd = CreateWindowA( "static", NULL, WS_POPUP, 0, 0, 10, 10, 0, 0, 0, NULL );
613
614 htext = create_textA();
615 emf = create_emf();
616
618 ok(r, "gle %d\n", GetLastError());
619 r = EmptyClipboard();
620 ok(r, "gle %d\n", GetLastError());
621 h = SetClipboardData(CF_TEXT, htext);
622 ok(h == htext, "got %p\n", h);
624 ok(h == emf, "got %p\n", h);
625 r = CloseClipboard();
626 ok(r, "gle %d\n", GetLastError());
627
629 ok( count == 6, "count %u\n", count );
631 ok( r, "CF_TEXT not available err %d\n", GetLastError());
633 ok( r, "CF_LOCALE not available err %d\n", GetLastError());
635 ok( r, "CF_OEMTEXT not available err %d\n", GetLastError());
637 ok( r, "CF_UNICODETEXT not available err %d\n", GetLastError());
639 ok( r, "CF_ENHMETAFILE not available err %d\n", GetLastError());
641 ok( r, "CF_METAFILEPICT not available err %d\n", GetLastError());
642
644 ok(r, "gle %d\n", GetLastError());
646 ok(cf == CF_TEXT, "cf %08x\n", cf);
648 ok(data != NULL, "couldn't get data, cf %08x\n", cf);
649
651 ok(cf == CF_ENHMETAFILE, "cf %08x\n", cf);
653 ok(data != NULL, "couldn't get data, cf %08x\n", cf);
654
656 ok(cf == CF_LOCALE, "cf %08x\n", cf);
658 ok(data != NULL, "couldn't get data, cf %08x\n", cf);
659
661 ok(cf == CF_OEMTEXT, "cf %08x\n", cf);
663 ok(data != NULL, "couldn't get data, cf %08x\n", cf);
664
666 ok(cf == CF_UNICODETEXT, "cf %08x\n", cf);
667
669 ok(cf == CF_METAFILEPICT, "cf %08x\n", cf);
671 ok(data != NULL, "couldn't get data, cf %08x\n", cf);
672
674 ok(cf == 0, "cf %08x\n", cf);
675
676 r = EmptyClipboard();
677 ok(r, "gle %d\n", GetLastError());
678
682 r = CloseClipboard();
683 ok(r, "gle %d\n", GetLastError());
684
685 r = OpenClipboard( NULL );
686 ok(r, "gle %d\n", GetLastError());
687 SetLastError( 0xdeadbeef );
689 ok( cf == CF_UNICODETEXT, "cf %08x\n", cf );
690 ok( GetLastError() == ERROR_SUCCESS, "wrong error %u\n", GetLastError() );
691 SetLastError( 0xdeadbeef );
693 ok( cf == CF_TEXT, "cf %08x\n", cf );
694 ok( GetLastError() == ERROR_SUCCESS, "wrong error %u\n", GetLastError() );
695 SetLastError( 0xdeadbeef );
697 ok( cf == CF_OEMTEXT, "cf %08x\n", cf );
698 ok( GetLastError() == ERROR_SUCCESS, "wrong error %u\n", GetLastError() );
699 SetLastError( 0xdeadbeef );
701 ok( cf == CF_LOCALE, "cf %08x\n", cf );
702 ok( GetLastError() == ERROR_SUCCESS, "wrong error %u\n", GetLastError() );
703 SetLastError( 0xdeadbeef );
705 ok( cf == 0, "cf %08x\n", cf );
706 ok( GetLastError() == ERROR_SUCCESS, "wrong error %u\n", GetLastError() );
707 SetLastError( 0xdeadbeef );
708 cf = EnumClipboardFormats( 0xdead );
709 ok( cf == 0, "cf %08x\n", cf );
710 ok( GetLastError() == ERROR_SUCCESS, "wrong error %u\n", GetLastError() );
711
712 r = EmptyClipboard();
713 ok(r, "gle %d\n", GetLastError());
714
715 r = CloseClipboard();
716 ok(r, "gle %d\n", GetLastError());
717
718 for (i = 0; i < ARRAY_SIZE(tests); i++)
719 {
721 ok(r, "%u: gle %d\n", i, GetLastError());
722 r = EmptyClipboard();
723 ok(r, "%u: gle %d\n", i, GetLastError());
724
725 switch (tests[i].format)
726 {
727 case CF_TEXT:
728 case CF_OEMTEXT:
730 break;
731 case CF_UNICODETEXT:
733 break;
734 case CF_ENHMETAFILE:
736 break;
737 case CF_METAFILEPICT:
739 break;
740 case CF_BITMAP:
742 break;
743 case CF_DIB:
744 case CF_DIBV5:
746 break;
747 }
748
750 ok( count == 1, "%u: count %u\n", i, count );
751
752 r = CloseClipboard();
753 ok(r, "%u: gle %d\n", i, GetLastError());
754
756 for (j = 0; tests[i].expected[j]; j++)
757 {
759 ok( r, "%u: %04x not available\n", i, tests[i].expected[j] );
760 }
761 ok( count == j, "%u: count %u instead of %u\n", i, count, j );
762
763 r = OpenClipboard( hwnd );
764 ok(r, "%u: gle %d\n", i, GetLastError());
765 cf = 0;
766 for (j = 0; tests[i].expected[j]; j++)
767 {
769 ok(cf == tests[i].expected[j], "%u.%u: got %04x instead of %04x\n",
770 i, j, cf, tests[i].expected[j] );
771 if (cf != tests[i].expected[j]) break;
774 ok(data != NULL ||
775 broken( tests[i].format == CF_DIBV5 && cf == CF_DIB ), /* >= Vista */
776 "%u: couldn't get data, cf %04x err %d\n", i, cf, GetLastError());
778 ok(seq == old_seq, "sequence changed (test %d %d)\n", i, cf);
779 switch (cf)
780 {
781 case CF_LOCALE:
782 {
783 UINT *ptr = GlobalLock( data );
784 ok( GlobalSize( data ) == sizeof(*ptr), "%u: size %lu\n", i, GlobalSize( data ));
785 ok( *ptr == GetUserDefaultLCID() ||
787 "%u: CF_LOCALE %08x/%08x\n", i, *ptr, GetUserDefaultLCID() );
789 break;
790 }
791 case CF_TEXT:
792 case CF_OEMTEXT:
793 ok( GlobalSize( data ) == 10, "wrong len %ld\n", GlobalSize( data ));
794 break;
795 case CF_UNICODETEXT:
796 ok( GlobalSize( data ) == 10 * sizeof(WCHAR), "wrong len %ld\n", GlobalSize( data ));
797 break;
798 }
799 }
800 if (!tests[i].expected[j])
801 {
803 ok(cf == 0, "%u: cf %04x\n", i, cf);
804 }
805
806 /* now with delayed rendering */
807
808 r = EmptyClipboard();
809 ok(r, "%u: gle %d\n", i, GetLastError());
810
811 rendered = SendMessageA( hwnd, WM_USER, 0, 0 );
812 ok( !rendered, "%u: formats %08x have been rendered\n", i, rendered );
813
815 rendered = SendMessageA( hwnd, WM_USER, 0, 0 );
816 ok( !rendered, "%u: formats %08x have been rendered\n", i, rendered );
817
819 ok( count == 1, "%u: count %u\n", i, count );
820
821 r = CloseClipboard();
822 ok(r, "%u: gle %d\n", i, GetLastError());
823 rendered = SendMessageA( hwnd, WM_USER, 0, 0 );
824 ok( !rendered, "%u: formats %08x have been rendered\n", i, rendered );
825
827 for (j = 0; tests[i].expected[j]; j++)
828 {
830 ok( r, "%u: %04x not available\n", i, tests[i].expected[j] );
831 }
832 ok( count == j, "%u: count %u instead of %u\n", i, count, j );
833 rendered = SendMessageA( hwnd, WM_USER, 0, 0 );
834 ok( !rendered, "%u: formats %08x have been rendered\n", i, rendered );
835
837 ok(r, "%u: gle %d\n", i, GetLastError());
838 cf = 0;
839 for (j = 0; tests[i].expected[j]; j++)
840 {
842 ok(cf == tests[i].expected[j], "%u.%u: got %04x instead of %04x\n",
843 i, j, cf, tests[i].expected[j] );
844 if (cf != tests[i].expected[j]) break;
845 rendered = SendMessageA( hwnd, WM_USER, 0, 0 );
846 ok( !rendered, "%u.%u: formats %08x have been rendered\n", i, j, rendered );
848 rendered = SendMessageA( hwnd, WM_USER, 0, 0 );
849 if (cf == CF_LOCALE)
850 {
851 ok(data != NULL, "%u: CF_LOCALE no data\n", i);
852 ok( !rendered, "%u.%u: formats %08x have been rendered\n", i, j, rendered );
853 }
854 else
855 {
856 ok(!data, "%u: format %04x got data %p\n", i, cf, data);
857 ok( rendered == (1 << tests[i].format),
858 "%u.%u: formats %08x have been rendered\n", i, j, rendered );
859 /* try to render a second time */
861 rendered = SendMessageA( hwnd, WM_USER, 0, 0 );
862 ok( rendered == (1 << tests[i].format),
863 "%u.%u: formats %08x have been rendered\n", i, j, rendered );
864 }
865 }
866 if (!tests[i].expected[j])
867 {
869 ok(cf == 0, "%u: cf %04x\n", i, cf);
870 }
871 r = CloseClipboard();
872 ok(r, "%u: gle %d\n", i, GetLastError());
873 rendered = SendMessageA( hwnd, WM_USER, 0, 0 );
874 ok( !rendered, "%u: formats %08x have been rendered\n", i, rendered );
875 }
876
878 ok(r, "gle %d\n", GetLastError());
879 r = EmptyClipboard();
880 ok(r, "gle %d\n", GetLastError());
881 r = CloseClipboard();
882 ok(r, "gle %d\n", GetLastError());
884}
885
887{
889 ok( handle != 0, "SetClipboardData failed: %d\n", GetLastError() );
890 return 0;
891}
892
903
905{
906 LRESULT ret;
907 DWORD msg_flags = InSendMessageEx( NULL );
908
909 switch(msg) {
910 case WM_DRAWCLIPBOARD:
911 ok( msg_flags == (cross_thread ? ISMEX_NOTIFY : ISMEX_NOSEND),
912 "WM_DRAWCLIPBOARD wrong flags %x\n", msg_flags );
916 break;
917 case WM_CHANGECBCHAIN:
918 ok( msg_flags == (cross_thread ? ISMEX_SEND : ISMEX_NOSEND),
919 "WM_CHANGECBCHAIN wrong flags %x\n", msg_flags );
920 if (next_wnd == (HWND)wp)
921 next_wnd = (HWND)lp;
922 else if (next_wnd)
923 SendMessageA(next_wnd, msg, wp, lp);
924 break;
926 ok( msg_flags == (cross_thread ? ISMEX_SEND : ISMEX_NOSEND),
927 "WM_DESTROYCLIPBOARD wrong flags %x\n", msg_flags );
929 ok( GetClipboardOwner() == hwnd, "WM_DESTROYCLIPBOARD owner %p\n", GetClipboardOwner() );
931 break;
932 case WM_RENDERFORMAT:
933 ok( !wm_renderformat, "multiple WM_RENDERFORMAT %04x / %04lx\n", wm_renderformat, wp );
934 wm_renderformat = wp;
935
937 {
938 UINT seq, old_seq;
940
943 ok( handle != 0, "SetClipboardData failed: %d\n", GetLastError() );
945 ok( seq == old_seq, "sequence changed\n" );
946 old_seq = seq;
947
949 ok( handle != NULL, "CreateThread failed: %d\n", GetLastError() );
950 ok( WaitForSingleObject(handle, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n" );
953 ok( seq == old_seq, "sequence changed\n" );
954 }
955
956 break;
957 case WM_CLIPBOARDUPDATE:
958 ok( msg_flags == ISMEX_NOSEND, "WM_CLIPBOARDUPDATE wrong flags %x\n", msg_flags );
963 break;
964 case WM_USER:
967 break;
968 case WM_USER+1:
971 return ret;
972 case WM_USER+2:
975 return ret;
976 case WM_USER+3:
979 return ret;
980 case WM_USER+4:
982 wm_renderformat = 0;
983 return ret;
984 case WM_USER+5:
985 return nb_formats;
986 }
987
988 return DefWindowProcA(hwnd, msg, wp, lp);
989}
990
992{
993 HANDLE data;
994 BOOL r;
995
996 r = OpenClipboard(0);
997 ok(r, "OpenClipboard failed: %d\n", GetLastError());
999 ok( data != NULL, "GetClipboardData failed: %d\n", GetLastError());
1000 r = CloseClipboard();
1001 ok(r, "CloseClipboard failed: %d\n", GetLastError());
1002}
1003
1005
1006static void check_messages_(int line, HWND win, UINT seq_diff, UINT draw, UINT update, UINT destroy, UINT render)
1007{
1008 MSG msg;
1009 UINT count, fmt, seq;
1010
1012 ok_(__FILE__, line)(seq - old_seq == seq_diff, "sequence diff %d\n", seq - old_seq);
1013 old_seq = seq;
1014
1015 if (!cross_thread)
1016 {
1017 while (PeekMessageW( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageW( &msg );
1018 }
1019
1020 if (update && !broken(!pAddClipboardFormatListener))
1021 ok(WaitForSingleObject(update_event, 1000) == WAIT_OBJECT_0, "wait failed\n");
1022
1023 count = SendMessageA( win, WM_USER + 1, 0, 0 );
1024 ok_(__FILE__, line)(count == draw, "WM_DRAWCLIPBOARD %sreceived\n", draw ? "not " : "");
1025 count = SendMessageA( win, WM_USER + 2, 0, 0 );
1026 ok_(__FILE__, line)(count == update || broken(!pAddClipboardFormatListener),
1027 "WM_CLIPBOARDUPDATE %sreceived\n", update ? "not " : "");
1028 count = SendMessageA( win, WM_USER + 3, 0, 0 );
1029 ok_(__FILE__, line)(count == destroy, "WM_DESTROYCLIPBOARD %sreceived\n", destroy ? "not " : "");
1030 fmt = SendMessageA( win, WM_USER + 4, 0, 0 );
1031 ok_(__FILE__, line)(fmt == render, "WM_RENDERFORMAT received %04x, expected %04x\n", fmt, render);
1032}
1033#define check_messages(a,b,c,d,e,f) check_messages_(__LINE__,a,b,c,d,e,f)
1034
1036{
1037 HWND ret, win = param;
1038 BOOL r;
1039 MSG msg;
1040 HANDLE handle;
1042
1044 trace( "%s-threaded test\n", cross_thread ? "multi" : "single" );
1045
1047
1049 SetLastError(0xdeadbeef);
1051 ok(GetLastError() == 0xdeadbeef, "GetLastError = %d\n", GetLastError());
1053
1054 SetLastError( 0xdeadbeef );
1055 ret = SetClipboardViewer( (HWND)0xdead );
1056 ok( !ret, "SetClipboardViewer succeeded\n" );
1057 ok( GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "wrong error %u\n", GetLastError() );
1058 SetLastError( 0xdeadbeef );
1059 r = ChangeClipboardChain( win, (HWND)0xdead );
1060 ok( !r, "ChangeClipboardChain succeeded\n" );
1061 ok( GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "wrong error %u\n", GetLastError() );
1062 SetLastError( 0xdeadbeef );
1063 r = ChangeClipboardChain( (HWND)0xdead, next_wnd );
1064 ok( !r, "ChangeClipboardChain succeeded\n" );
1065 ok( GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "wrong error %u\n", GetLastError() );
1066
1067 if (pAddClipboardFormatListener)
1068 {
1069 r = pAddClipboardFormatListener(win);
1070 ok( r, "AddClipboardFormatListener failed err %d\n", GetLastError());
1071 SetLastError( 0xdeadbeef );
1072 r = pAddClipboardFormatListener( win );
1073 ok( !r, "AddClipboardFormatListener succeeded\n" );
1074 ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
1075 SetLastError( 0xdeadbeef );
1076 r = pAddClipboardFormatListener( (HWND)0xdead );
1077 ok( !r, "AddClipboardFormatListener succeeded\n" );
1078 ok( GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "wrong error %u\n", GetLastError() );
1079 r = pAddClipboardFormatListener( GetDesktopWindow() );
1080 ok( r, "AddClipboardFormatListener failed err %d\n", GetLastError());
1081 r = pRemoveClipboardFormatListener( GetDesktopWindow() );
1082 ok( r, "RemoveClipboardFormatListener failed err %d\n", GetLastError());
1083 }
1084
1085 check_messages(win, 0, 1, 0, 0, 0);
1086
1087 SetLastError( 0xdeadbeef );
1088 r = OpenClipboard( (HWND)0xdead );
1089 ok( !r, "OpenClipboard succeeded\n" );
1090 ok( GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "wrong error %u\n", GetLastError() );
1091
1092 r = OpenClipboard(win);
1093 ok(r, "OpenClipboard failed: %d\n", GetLastError());
1094
1095 check_messages(win, 0, 0, 0, 0, 0);
1096
1097 r = EmptyClipboard();
1098 ok(r, "EmptyClipboard failed: %d\n", GetLastError());
1099
1100 check_messages(win, 1, 0, 0, 0, 0);
1101
1102 r = EmptyClipboard();
1103 ok(r, "EmptyClipboard failed: %d\n", GetLastError());
1104 /* sequence changes again, even though it was already empty */
1105 check_messages(win, 1, 0, 0, 1, 0);
1106 count = SendMessageA( win, WM_USER+5, 0, 0 );
1107 ok( !count, "wrong format count %u on WM_DESTROYCLIPBOARD\n", count );
1108
1110 ok(handle != 0, "SetClipboardData failed: %d\n", GetLastError());
1111
1112 check_messages(win, 1, 0, 0, 0, 0);
1113
1115
1116 check_messages(win, 1, 0, 0, 0, 0);
1117
1118 SetClipboardData( CF_UNICODETEXT, 0 ); /* same data again */
1119
1120 check_messages(win, 1, 0, 0, 0, 0);
1121
1122 ok( IsClipboardFormatAvailable( CF_TEXT ), "CF_TEXT available\n" );
1123 ok( IsClipboardFormatAvailable( CF_UNICODETEXT ), "CF_UNICODETEXT available\n" );
1124 ok( !IsClipboardFormatAvailable( CF_OEMTEXT ), "CF_OEMTEXT available\n" );
1125
1127 r = CloseClipboard();
1128 ok(r, "CloseClipboard failed: %d\n", GetLastError());
1130
1131 check_messages(win, 2, 1, 1, 0, 0);
1132
1133 r = OpenClipboard(win);
1134 ok(r, "OpenClipboard failed: %d\n", GetLastError());
1135
1136 check_messages(win, 0, 0, 0, 0, 0);
1137
1138 ok( IsClipboardFormatAvailable( CF_TEXT ), "CF_TEXT available\n" );
1139 ok( IsClipboardFormatAvailable( CF_UNICODETEXT ), "CF_UNICODETEXT available\n" );
1140 ok( IsClipboardFormatAvailable( CF_OEMTEXT ), "CF_OEMTEXT available\n" );
1141
1142 ok( GetClipboardOwner() == win, "wrong owner %p\n", GetClipboardOwner());
1144 ok( !handle, "got data for CF_UNICODETEXT\n" );
1145 fmt = SendMessageA( win, WM_USER+4, 0, 0 );
1146 ok( fmt == CF_UNICODETEXT, "WM_RENDERFORMAT received %04x\n", fmt );
1147
1150 ok( handle != NULL, "didn't get data for CF_OEMTEXT\n" );
1151 fmt = SendMessageA( win, WM_USER+4, 0, 0 );
1152 ok( fmt == CF_UNICODETEXT, "WM_RENDERFORMAT received %04x\n", fmt );
1154
1156 check_messages(win, 1, 0, 0, 0, 0);
1157
1158 r = CloseClipboard();
1159 ok(r, "CloseClipboard failed: %d\n", GetLastError());
1160 /* no synthesized format, so CloseClipboard doesn't change the sequence */
1161 check_messages(win, 0, 1, 1, 0, 0);
1162
1163 r = OpenClipboard(win);
1164 ok(r, "OpenClipboard failed: %d\n", GetLastError());
1165 r = CloseClipboard();
1166 ok(r, "CloseClipboard failed: %d\n", GetLastError());
1167 /* nothing changed */
1168 check_messages(win, 0, 0, 0, 0, 0);
1169
1171 r = OpenClipboard(0);
1172 ok(r, "OpenClipboard failed: %d\n", GetLastError());
1173 r = EmptyClipboard();
1174 ok(r, "EmptyClipboard failed: %d\n", GetLastError());
1175 r = CloseClipboard();
1176 ok(r, "CloseClipboard failed: %d\n", GetLastError());
1177
1178 check_messages(win, 1, 1, 1, 1, 0);
1179 count = SendMessageA( win, WM_USER+5, 0, 0 );
1180 ok( count == formats, "wrong format count %u on WM_DESTROYCLIPBOARD\n", count );
1181
1182 r = OpenClipboard(win);
1183 ok(r, "OpenClipboard failed: %d\n", GetLastError());
1185 check_messages(win, 1, 0, 0, 0, 0);
1186
1188 r = CloseClipboard();
1189 ok(r, "CloseClipboard failed: %d\n", GetLastError());
1191
1192 check_messages(win, 0, 1, 1, 0, 0);
1193
1194 run_process( "grab_clipboard 0" );
1195
1196 if (!cross_thread)
1197 {
1198 /* in this case we get a cross-thread WM_DRAWCLIPBOARD */
1200 while (PeekMessageW( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageW( &msg );
1202 }
1203 check_messages(win, 1, 1, 1, 0, 0);
1204
1205 r = OpenClipboard(0);
1206 ok(r, "OpenClipboard failed: %d\n", GetLastError());
1208 check_messages(win, 1, 0, 0, 0, 0);
1209
1211 r = CloseClipboard();
1212 ok(r, "CloseClipboard failed: %d\n", GetLastError());
1214
1215 check_messages(win, 0, 1, 1, 0, 0);
1216
1217 run_process( "grab_clipboard 1" );
1218
1219 if (!cross_thread)
1220 {
1221 /* in this case we get a cross-thread WM_DRAWCLIPBOARD */
1223 while (PeekMessageW( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageW( &msg );
1225 }
1226 check_messages(win, 2, 1, 1, 0, 0);
1227
1228 r = OpenClipboard(0);
1229 ok(r, "OpenClipboard failed: %d\n", GetLastError());
1231 check_messages(win, 1, 0, 0, 0, 0);
1232
1234 r = CloseClipboard();
1235 ok(r, "CloseClipboard failed: %d\n", GetLastError());
1237
1238 check_messages(win, 0, 1, 1, 0, 0);
1239
1240 if (cross_thread)
1241 {
1242 r = OpenClipboard( win );
1243 ok(r, "OpenClipboard failed: %d\n", GetLastError());
1244 r = EmptyClipboard();
1245 ok(r, "EmptyClipboard failed: %d\n", GetLastError());
1247 r = CloseClipboard();
1248 ok(r, "CloseClipboard failed: %d\n", GetLastError());
1249
1252 run_process( "get_clipboard_data" );
1254
1255 check_messages(win, 0, 1, 1, 0, CF_TEXT);
1256 }
1257
1258 r = PostMessageA(win, WM_USER, 0, 0);
1259 ok(r, "PostMessage failed: %d\n", GetLastError());
1260
1261 if (pRemoveClipboardFormatListener)
1262 {
1263 r = pRemoveClipboardFormatListener(win);
1264 ok( r, "RemoveClipboardFormatListener failed err %d\n", GetLastError());
1265 SetLastError( 0xdeadbeef );
1266 r = pRemoveClipboardFormatListener(win);
1267 ok( !r, "RemoveClipboardFormatListener succeeded\n" );
1268 ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
1269 SetLastError( 0xdeadbeef );
1270 r = pRemoveClipboardFormatListener( (HWND)0xdead );
1271 ok( !r, "RemoveClipboardFormatListener succeeded\n" );
1272 ok( GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "wrong error %u\n", GetLastError() );
1273 }
1274 return 0;
1275}
1276
1277static void test_messages(void)
1278{
1279 WNDCLASSA cls;
1280 HWND win;
1281 MSG msg;
1282 HANDLE thread;
1283 DWORD tid;
1284
1287
1288 memset(&cls, 0, sizeof(cls));
1291 cls.lpszClassName = "clipboard_test";
1292 RegisterClassA(&cls);
1293
1294 win = CreateWindowA("clipboard_test", NULL, 0, 0, 0, 0, 0, NULL, 0, NULL, 0);
1295 ok(win != NULL, "CreateWindow failed: %d\n", GetLastError());
1296
1297 thread = CreateThread(NULL, 0, clipboard_thread, (void*)win, 0, &tid);
1298 ok(thread != NULL, "CreateThread failed: %d\n", GetLastError());
1299
1300 while(GetMessageA(&msg, NULL, 0, 0))
1301 {
1302 ok( msg.message != WM_DRAWCLIPBOARD, "WM_DRAWCLIPBOARD was posted\n" );
1305 }
1306
1307 ok(WaitForSingleObject(thread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
1309
1310 DestroyWindow( win );
1311
1312 /* same tests again but inside a single thread */
1313
1314 win = CreateWindowA( "clipboard_test", NULL, 0, 0, 0, 0, 0, NULL, 0, NULL, 0 );
1315 ok( win != NULL, "CreateWindow failed: %d\n", GetLastError() );
1316
1318 DestroyWindow( win );
1319
1320 UnregisterClassA("clipboard_test", GetModuleHandleA(NULL));
1322}
1323
1325{
1326 void *ptr = GlobalLock( handle );
1327 if (ptr) GlobalUnlock( handle );
1328 return ptr && ptr != handle;
1329}
1330
1332{
1333 void *ptr = GlobalLock( handle );
1334 if (ptr) GlobalUnlock( handle );
1335 return ptr && ptr == handle;
1336}
1337
1339{
1340 return !GlobalSize( handle );
1341}
1342
1345static HPALETTE palette;
1346static const LOGPALETTE logpalette = { 0x300, 1, {{ 0x12, 0x34, 0x56, 0x78 }}};
1347
1348static void test_handles( HWND hwnd )
1349{
1350 HGLOBAL h, htext, htext2, htext3, htext4, htext5;
1351 HGLOBAL hfixed, hfixed2, hmoveable, empty_fixed, empty_moveable;
1352 void *ptr;
1353 UINT format_id2 = RegisterClipboardFormatA( "another format" );
1354 BOOL r;
1355 HANDLE data;
1356 HBITMAP bitmap_temp;
1357 DWORD process;
1359
1360 trace( "hwnd %p\n", hwnd );
1361 htext = create_textA();
1362 htext2 = create_textA();
1363 htext3 = create_textA();
1364 htext4 = create_textA();
1365 htext5 = create_textA();
1366 bitmap = CreateBitmap( 10, 10, 1, 1, NULL );
1367 bitmap2 = CreateBitmap( 10, 10, 1, 1, NULL );
1369
1370 hfixed = GlobalAlloc( GMEM_FIXED, 17 );
1371 hfixed2 = GlobalAlloc( GMEM_FIXED, 17 );
1372 ok( is_fixed( hfixed ), "expected fixed mem %p\n", hfixed );
1373 ok( GlobalSize( hfixed ) == 17, "wrong size %lu\n", GlobalSize( hfixed ));
1374
1375 hmoveable = GlobalAlloc( GMEM_MOVEABLE, 23 );
1376 ok( is_moveable( hmoveable ), "expected moveable mem %p\n", hmoveable );
1377 ok( GlobalSize( hmoveable ) == 23, "wrong size %lu\n", GlobalSize( hmoveable ));
1378
1379 empty_fixed = GlobalAlloc( GMEM_FIXED, 0 );
1380 ok( is_fixed( empty_fixed ), "expected fixed mem %p\n", empty_fixed );
1381
1382 empty_moveable = GlobalAlloc( GMEM_MOVEABLE, 0 );
1383 /* discarded handles can't be GlobalLock'ed */
1384 ok( is_freed( empty_moveable ), "expected free mem %p\n", empty_moveable );
1385
1386 r = OpenClipboard( hwnd );
1387 ok( r, "gle %d\n", GetLastError() );
1388 r = EmptyClipboard();
1389 ok( r, "gle %d\n", GetLastError() );
1390
1391 h = SetClipboardData( CF_TEXT, htext );
1392 ok( h == htext, "got %p\n", h );
1393 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1394 h = SetClipboardData( format_id, htext2 );
1395 ok( h == htext2, "got %p\n", h );
1396 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1397 bitmap_temp = CreateBitmap( 10, 10, 1, 1, NULL );
1398 h = SetClipboardData( CF_BITMAP, bitmap_temp );
1399 ok( h == bitmap_temp, "got %p\n", h );
1400 ok( GetObjectType( h ) == OBJ_BITMAP, "expected bitmap %p\n", h );
1402 ok( h == bitmap, "got %p\n", h );
1403 ok( GetObjectType( h ) == OBJ_BITMAP, "expected bitmap %p\n", h );
1404 ok( !GetObjectType( bitmap_temp ), "expected free object %p\n", bitmap_temp );
1406 ok( h == bitmap2, "got %p\n", h );
1407 ok( GetObjectType( h ) == OBJ_BITMAP, "expected bitmap %p\n", h );
1409 ok( h == palette, "got %p\n", h );
1410 ok( GetObjectType( h ) == OBJ_PAL, "expected palette %p\n", h );
1411 h = SetClipboardData( CF_GDIOBJFIRST + 3, htext3 );
1412 ok( h == htext3, "got %p\n", h );
1413 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1414 h = SetClipboardData( CF_PRIVATEFIRST + 7, htext5 );
1415 ok( h == htext5, "got %p\n", h );
1416 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1417 h = SetClipboardData( format_id2, empty_moveable );
1418 ok( !h, "got %p\n", h );
1419 GlobalFree( empty_moveable );
1420
1421 if (0) /* crashes on vista64 */
1422 {
1423 ptr = HeapAlloc( GetProcessHeap(), 0, 0 );
1424 h = SetClipboardData( format_id2, ptr );
1425 ok( !h, "got %p\n", h );
1426 HeapFree( GetProcessHeap(), 0, ptr );
1427 }
1428
1429 h = SetClipboardData( format_id2, empty_fixed );
1430 ok( h == empty_fixed, "got %p\n", h );
1431 ok( is_fixed( h ), "expected fixed mem %p\n", h );
1432 h = SetClipboardData( 0xdeadbeef, hfixed2 );
1433 ok( h == hfixed2, "got %p\n", h );
1434 ok( is_fixed( h ), "expected fixed mem %p\n", h );
1435 h = SetClipboardData( 0xdeadbabe, hmoveable );
1436 ok( h == hmoveable, "got %p\n", h );
1437 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1438
1439 ptr = HeapAlloc( GetProcessHeap(), 0, 37 );
1440 h = SetClipboardData( 0xdeadfade, ptr );
1441 ok( h == ptr || !h, "got %p\n", h );
1442 if (!h) /* heap blocks are rejected on >= win8 */
1443 {
1444 HeapFree( GetProcessHeap(), 0, ptr );
1445 ptr = NULL;
1446 }
1447
1449 ok( data == htext, "wrong data %p\n", data );
1450 ok( is_moveable( data ), "expected moveable mem %p\n", data );
1451
1453 ok( data == htext2, "wrong data %p, cf %08x\n", data, format_id );
1454 ok( is_moveable( data ), "expected moveable mem %p\n", data );
1455
1457 ok( data == htext3, "wrong data %p\n", data );
1458 ok( is_moveable( data ), "expected moveable mem %p\n", data );
1459
1461 ok( data == htext5, "wrong data %p\n", data );
1462 ok( is_moveable( data ), "expected moveable mem %p\n", data );
1463
1464 data = GetClipboardData( format_id2 );
1465 ok( data == empty_fixed, "wrong data %p\n", data );
1466 ok( is_fixed( data ), "expected fixed mem %p\n", data );
1467
1468 data = GetClipboardData( 0xdeadbeef );
1469 ok( data == hfixed2, "wrong data %p\n", data );
1470 ok( is_fixed( data ), "expected fixed mem %p\n", data );
1471
1472 data = GetClipboardData( 0xdeadbabe );
1473 ok( data == hmoveable, "wrong data %p\n", data );
1474 ok( is_moveable( data ), "expected moveable mem %p\n", data );
1475
1476 data = GetClipboardData( 0xdeadfade );
1477 ok( data == ptr, "wrong data %p\n", data );
1478
1479 h = SetClipboardData( CF_PRIVATEFIRST + 7, htext4 );
1480 ok( h == htext4, "got %p\n", h );
1481 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1482 ok( is_freed( htext5 ), "expected freed mem %p\n", htext5 );
1483
1484 h = SetClipboardData( 0xdeadbeef, hfixed );
1485 ok( h == hfixed, "got %p\n", h );
1486 ok( is_fixed( h ), "expected fixed mem %p\n", h );
1487 if (0) /* this test is unreliable / crashes */
1488 ok( is_freed( hfixed2 ), "expected freed mem %p\n", hfixed2 );
1489
1490 r = CloseClipboard();
1491 ok( r, "gle %d\n", GetLastError() );
1492
1493 /* data handles are still valid */
1494 ok( is_moveable( htext ), "expected moveable mem %p\n", htext );
1495 ok( is_moveable( htext2 ), "expected moveable mem %p\n", htext2 );
1496 ok( is_moveable( htext3 ), "expected moveable mem %p\n", htext3 );
1497 ok( is_moveable( htext4 ), "expected moveable mem %p\n", htext4 );
1498 ok( GetObjectType( bitmap ) == OBJ_BITMAP, "expected bitmap %p\n", bitmap );
1499 ok( GetObjectType( bitmap2 ) == OBJ_BITMAP, "expected bitmap %p\n", bitmap2 );
1500 ok( GetObjectType( palette ) == OBJ_PAL, "expected palette %p\n", palette );
1501 ok( is_fixed( hfixed ), "expected fixed mem %p\n", hfixed );
1502 ok( is_moveable( hmoveable ), "expected moveable mem %p\n", hmoveable );
1503 ok( is_fixed( empty_fixed ), "expected fixed mem %p\n", empty_fixed );
1504
1505 r = OpenClipboard( hwnd );
1506 ok( r, "gle %d\n", GetLastError() );
1507
1508 /* and now they are freed, unless we are the owner */
1509 if (!is_owner)
1510 {
1511 ok( is_freed( htext ), "expected freed mem %p\n", htext );
1512 ok( is_freed( htext2 ), "expected freed mem %p\n", htext2 );
1513 ok( is_freed( htext3 ), "expected freed mem %p\n", htext3 );
1514 ok( is_freed( htext4 ), "expected freed mem %p\n", htext4 );
1515 ok( is_freed( hmoveable ), "expected freed mem %p\n", hmoveable );
1516
1518 ok( is_fixed( data ), "expected fixed mem %p\n", data );
1519
1521 ok( is_fixed( data ), "expected fixed mem %p\n", data );
1522
1524 ok( is_fixed( data ), "expected fixed mem %p\n", data );
1525
1527 ok( is_fixed( data ), "expected fixed mem %p\n", data );
1528
1529 data = GetClipboardData( format_id2 );
1530 ok( is_fixed( data ), "expected fixed mem %p\n", data );
1531 ok( GlobalSize( data ) == 1, "wrong size %lu\n", GlobalSize( data ));
1532
1533 data = GetClipboardData( 0xdeadbeef );
1534 ok( is_fixed( data ), "expected fixed mem %p\n", data );
1535 ok( GlobalSize( data ) == 17, "wrong size %lu\n", GlobalSize( data ));
1536
1537 data = GetClipboardData( 0xdeadbabe );
1538 ok( is_fixed( data ), "expected fixed mem %p\n", data );
1539 ok( GlobalSize( data ) == 23, "wrong size %lu\n", GlobalSize( data ));
1540
1541 data = GetClipboardData( 0xdeadfade );
1542 ok( is_fixed( data ) || !ptr, "expected fixed mem %p\n", data );
1543 if (ptr) ok( GlobalSize( data ) == 37, "wrong size %lu\n", GlobalSize( data ));
1544 }
1545 else
1546 {
1547 ok( is_moveable( htext ), "expected moveable mem %p\n", htext );
1548 ok( is_moveable( htext2 ), "expected moveable mem %p\n", htext2 );
1549 ok( is_moveable( htext3 ), "expected moveable mem %p\n", htext3 );
1550 ok( is_moveable( htext4 ), "expected moveable mem %p\n", htext4 );
1551 ok( is_moveable( hmoveable ), "expected moveable mem %p\n", hmoveable );
1552
1554 ok( data == htext, "wrong data %p\n", data );
1555
1557 ok( data == htext2, "wrong data %p, cf %08x\n", data, format_id );
1558
1560 ok( data == htext3, "wrong data %p\n", data );
1561
1563 ok( data == htext4, "wrong data %p\n", data );
1564
1565 data = GetClipboardData( format_id2 );
1566 ok( data == empty_fixed, "wrong data %p\n", data );
1567
1568 data = GetClipboardData( 0xdeadbeef );
1569 ok( data == hfixed, "wrong data %p\n", data );
1570
1571 data = GetClipboardData( 0xdeadbabe );
1572 ok( data == hmoveable, "wrong data %p\n", data );
1573
1574 data = GetClipboardData( 0xdeadfade );
1575 ok( data == ptr, "wrong data %p\n", data );
1576 }
1577
1579 ok( is_fixed( data ), "expected fixed mem %p\n", data );
1581 ok( is_fixed( data ), "expected fixed mem %p\n", data );
1583 ok( is_fixed( data ), "expected fixed mem %p\n", data );
1585 ok( data == bitmap, "expected bitmap %p\n", data );
1587 ok( data == bitmap2, "expected bitmap %p\n", data );
1589 ok( data == palette, "expected palette %p\n", data );
1591 ok( is_fixed( data ), "expected fixed mem %p\n", data );
1592 data = GetClipboardData( CF_DIBV5 );
1593 ok( is_fixed( data ), "expected fixed mem %p\n", data );
1594
1595 ok( GetObjectType( bitmap ) == OBJ_BITMAP, "expected bitmap %p\n", bitmap );
1596 ok( GetObjectType( bitmap2 ) == OBJ_BITMAP, "expected bitmap %p\n", bitmap2 );
1597 ok( GetObjectType( palette ) == OBJ_PAL, "expected palette %p\n", palette );
1598 ok( is_fixed( hfixed ), "expected fixed mem %p\n", hfixed );
1599 ok( is_fixed( empty_fixed ), "expected fixed mem %p\n", empty_fixed );
1600
1601 r = EmptyClipboard();
1602 ok( r, "gle %d\n", GetLastError() );
1603
1604 /* w2003, w2008 don't seem to free the data here */
1605 ok( is_freed( htext ) || broken( !is_freed( htext )), "expected freed mem %p\n", htext );
1606 ok( is_freed( htext2 ) || broken( !is_freed( htext2 )), "expected freed mem %p\n", htext2 );
1607 ok( is_freed( htext3 ) || broken( !is_freed( htext3 )), "expected freed mem %p\n", htext3 );
1608 ok( is_freed( htext4 ) || broken( !is_freed( htext4 )), "expected freed mem %p\n", htext4 );
1609 ok( is_freed( hmoveable ) || broken( !is_freed( hmoveable )), "expected freed mem %p\n", hmoveable );
1610 ok( is_fixed( empty_fixed ), "expected fixed mem %p\n", empty_fixed );
1611 ok( is_fixed( hfixed ), "expected fixed mem %p\n", hfixed );
1612 ok( !GetObjectType( bitmap ), "expected freed handle %p\n", bitmap );
1613 ok( !GetObjectType( bitmap2 ), "expected freed handle %p\n", bitmap2 );
1614 ok( !GetObjectType( palette ), "expected freed handle %p\n", palette );
1615
1616 r = CloseClipboard();
1617 ok( r, "gle %d\n", GetLastError() );
1618}
1619
1621{
1622 trace( "running from different thread\n" );
1623 test_handles( (HWND)arg );
1624 return 0;
1625}
1626
1628{
1629 BOOL r;
1630 HANDLE h;
1631 char *ptr;
1632
1633 r = OpenClipboard( 0 );
1634 ok( r, "gle %d\n", GetLastError() );
1636 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1637 ptr = GlobalLock( h );
1638 if (ptr) ok( !strcmp( "test", ptr ), "wrong data '%.5s'\n", ptr );
1639 GlobalUnlock( h );
1641 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1642 ptr = GlobalLock( h );
1643 if (ptr) ok( !strcmp( "test", ptr ), "wrong data '%.5s'\n", ptr );
1644 GlobalUnlock( h );
1646 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1647 ptr = GlobalLock( h );
1648 if (ptr) ok( !strcmp( "test", ptr ), "wrong data '%.5s'\n", ptr );
1649 GlobalUnlock( h );
1650 trace( "gdiobj %p\n", h );
1652 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1653 ptr = GlobalLock( h );
1654 if (ptr) ok( !strcmp( "test", ptr ), "wrong data '%.5s'\n", ptr );
1655 GlobalUnlock( h );
1656 trace( "private %p\n", h );
1658 ok( GetObjectType( h ) == OBJ_BITMAP, "expected bitmap %p\n", h );
1659 ok( h == bitmap, "different bitmap %p / %p\n", h, bitmap );
1660 trace( "bitmap %p\n", h );
1662 ok( GetObjectType( h ) == OBJ_BITMAP, "expected bitmap %p\n", h );
1663 ok( h == bitmap2, "different bitmap %p / %p\n", h, bitmap2 );
1664 trace( "bitmap2 %p\n", h );
1666 ok( GetObjectType( h ) == OBJ_PAL, "expected palette %p\n", h );
1667 ok( h == palette, "different palette %p / %p\n", h, palette );
1668 trace( "palette %p\n", h );
1670 ok( is_fixed( h ), "expected fixed mem %p\n", h );
1671 h = GetClipboardData( CF_DIBV5 );
1672 ok( is_fixed( h ), "expected fixed mem %p\n", h );
1673 r = CloseClipboard();
1674 ok( r, "gle %d\n", GetLastError() );
1675 return 0;
1676}
1677
1678static void test_handles_process( const char *str )
1679{
1680 BOOL r;
1681 HANDLE h;
1682 char *ptr;
1683 BITMAP bm;
1685 BYTE buffer[1024];
1686
1687 format_id = RegisterClipboardFormatA( "my_cool_clipboard_format" );
1688 r = OpenClipboard( 0 );
1689 ok( r, "gle %d\n", GetLastError() );
1691 ok( is_fixed( h ), "expected fixed mem %p\n", h );
1692 ptr = GlobalLock( h );
1693 ok( !strcmp( str, ptr ), "wrong data '%.5s'\n", ptr );
1694 GlobalUnlock( h );
1696 ok( is_fixed( h ), "expected fixed mem %p\n", h );
1697 ptr = GlobalLock( h );
1698 if (ptr) ok( !strcmp( str, ptr ), "wrong data '%.5s'\n", ptr );
1699 GlobalUnlock( h );
1701 ok( is_fixed( h ), "expected fixed mem %p\n", h );
1702 ptr = GlobalLock( h );
1703 ok( !strcmp( str, ptr ), "wrong data '%.5s'\n", ptr );
1704 GlobalUnlock( h );
1705 trace( "gdiobj %p\n", h );
1707 ok( is_fixed( h ), "expected fixed mem %p\n", h );
1708 ptr = GlobalLock( h );
1709 ok( !strcmp( str, ptr ), "wrong data '%.5s'\n", ptr );
1710 GlobalUnlock( h );
1711 trace( "private %p\n", h );
1713 ok( GetObjectType( h ) == OBJ_BITMAP, "expected bitmap %p\n", h );
1714 ok( GetObjectW( h, sizeof(bm), &bm ) == sizeof(bm), "GetObject %p failed\n", h );
1715 ok( bm.bmWidth == 13 && bm.bmHeight == 17, "wrong bitmap %ux%u\n", bm.bmWidth, bm.bmHeight );
1716 trace( "bitmap %p\n", h );
1718 ok( !GetObjectType( h ), "expected invalid object %p\n", h );
1719 trace( "bitmap2 %p\n", h );
1721 ok( GetObjectType( h ) == OBJ_PAL, "expected palette %p\n", h );
1722 ok( GetPaletteEntries( h, 0, 1, &entry ) == 1, "GetPaletteEntries %p failed\n", h );
1723 ok( entry.peRed == 0x12 && entry.peGreen == 0x34 && entry.peBlue == 0x56,
1724 "wrong color %02x,%02x,%02x\n", entry.peRed, entry.peGreen, entry.peBlue );
1725 trace( "palette %p\n", h );
1727 ok( is_fixed( h ), "expected fixed mem %p\n", h );
1728#ifdef __REACTOS__
1729 if (h != NULL)
1730#endif
1731 ok( GetObjectType( ((METAFILEPICT *)h)->hMF ) == OBJ_METAFILE,
1732 "wrong object %p\n", ((METAFILEPICT *)h)->hMF );
1733 trace( "metafile %p\n", h );
1735 ok( is_fixed( h ), "expected fixed mem %p\n", h );
1736#ifdef __REACTOS__
1737 if (h != NULL)
1738#endif
1739 ok( GetObjectType( ((METAFILEPICT *)h)->hMF ) == OBJ_METAFILE,
1740 "wrong object %p\n", ((METAFILEPICT *)h)->hMF );
1741 trace( "metafile2 %p\n", h );
1743 ok( GetObjectType( h ) == OBJ_ENHMETAFILE, "expected enhmetafile %p\n", h );
1744 ok( GetEnhMetaFileBits( h, sizeof(buffer), buffer ) > sizeof(ENHMETAHEADER),
1745 "GetEnhMetaFileBits failed on %p\n", h );
1746 ok( ((ENHMETAHEADER *)buffer)->nRecords == 3,
1747 "wrong records %u\n", ((ENHMETAHEADER *)buffer)->nRecords );
1748 trace( "enhmetafile %p\n", h );
1750 ok( GetObjectType( h ) == OBJ_ENHMETAFILE, "expected enhmetafile %p\n", h );
1751 ok( GetEnhMetaFileBits( h, sizeof(buffer), buffer ) > sizeof(ENHMETAHEADER),
1752 "GetEnhMetaFileBits failed on %p\n", h );
1753 ok( ((ENHMETAHEADER *)buffer)->nRecords == 3,
1754 "wrong records %u\n", ((ENHMETAHEADER *)buffer)->nRecords );
1755 trace( "enhmetafile2 %p\n", h );
1757 ok( is_fixed( h ), "expected fixed mem %p\n", h );
1758 h = GetClipboardData( CF_DIBV5 );
1759 ok( is_fixed( h ), "expected fixed mem %p\n", h );
1760 r = CloseClipboard();
1761 ok( r, "gle %d\n", GetLastError() );
1762}
1763
1764static void test_handles_process_open( const char *str )
1765{
1767 char *ptr = GlobalLock( text );
1768
1769 strcpy( ptr, str );
1770 GlobalUnlock( text );
1771
1772 /* clipboard already open by parent process */
1774 ok( h == text, "wrong mem %p / %p\n", h, text );
1775 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1776}
1777
1778static void test_handles_process_dib( const char *str )
1779{
1780 BOOL r;
1781 HANDLE h;
1782
1783 r = OpenClipboard( 0 );
1784 ok( r, "gle %d\n", GetLastError() );
1786 ok( !GetObjectType( h ), "expected invalid object %p\n", h );
1787 trace( "dibsection %p\n", h );
1788 r = CloseClipboard();
1789 ok( r, "gle %d\n", GetLastError() );
1790}
1791
1792static void test_data_handles(void)
1793{
1794 BOOL r;
1795 char *ptr;
1796 HANDLE h, text;
1797 HWND hwnd = CreateWindowA( "static", NULL, WS_POPUP, 0, 0, 10, 10, 0, 0, 0, NULL );
1798 BITMAPINFO bmi;
1799 void *bits;
1800
1801 ok( hwnd != 0, "window creation failed\n" );
1802 format_id = RegisterClipboardFormatA( "my_cool_clipboard_format" );
1803 test_handles( 0 );
1805 test_handles( hwnd );
1806 run_thread( test_handles_thread, hwnd, __LINE__ );
1807
1808 bitmap = CreateBitmap( 13, 17, 1, 1, NULL );
1809 bitmap2 = CreateBitmap( 10, 10, 1, 1, NULL );
1811
1812 r = OpenClipboard( hwnd );
1813 ok( r, "gle %d\n", GetLastError() );
1814 r = EmptyClipboard();
1815 ok( r, "gle %d\n", GetLastError() );
1817 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1819 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1821 ok( GetObjectType( h ) == OBJ_BITMAP, "expected bitmap %p\n", h );
1823 ok( GetObjectType( h ) == OBJ_BITMAP, "expected bitmap %p\n", h );
1825 ok( GetObjectType( h ) == OBJ_PAL, "expected palette %p\n", h );
1827 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1828 trace( "metafile %p\n", h );
1830 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1831 trace( "metafile2 %p\n", h );
1833 ok( GetObjectType( h ) == OBJ_ENHMETAFILE, "expected enhmetafile %p\n", h );
1834 trace( "enhmetafile %p\n", h );
1836 ok( GetObjectType( h ) == OBJ_ENHMETAFILE, "expected enhmetafile %p\n", h );
1837 trace( "enhmetafile2 %p\n", h );
1839 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1841 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1842 r = CloseClipboard();
1843 ok( r, "gle %d\n", GetLastError() );
1844
1845 run_thread( test_handles_thread2, 0, __LINE__ );
1846 run_process( "handles test" );
1847
1848 r = OpenClipboard( hwnd );
1849 ok( r, "gle %d\n", GetLastError() );
1851 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1853 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1855 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1857 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1858
1859 r = EmptyClipboard();
1860 ok( r, "gle %d\n", GetLastError() );
1861 text = create_textA();
1863 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1864
1865 run_process( "handles_open foobar" );
1866
1867 ok( is_moveable( text ), "expected moveable mem %p\n", text );
1869 ok( is_fixed( h ), "expected fixed mem %p\n", h );
1870 ok( is_moveable( text ), "expected moveable mem %p\n", text );
1871 ptr = GlobalLock( h );
1872 ok( !strcmp( ptr, "foobar" ), "wrong data '%.8s'\n", ptr );
1873 GlobalUnlock( h );
1874
1875 r = EmptyClipboard();
1876 ok( r, "gle %d\n", GetLastError() );
1877 ok( is_fixed( h ), "expected free mem %p\n", h );
1878 ok( is_freed( text ) || broken( is_moveable(text) ), /* w2003, w2008 */
1879 "expected free mem %p\n", text );
1880 r = CloseClipboard();
1881 ok( r, "gle %d\n", GetLastError() );
1882
1883 /* test CF_BITMAP with a DIB section */
1884 memset( &bmi, 0, sizeof(bmi) );
1885 bmi.bmiHeader.biSize = sizeof( bmi.bmiHeader );
1886 bmi.bmiHeader.biWidth = 29;
1887 bmi.bmiHeader.biHeight = 13;
1888 bmi.bmiHeader.biPlanes = 1;
1889 bmi.bmiHeader.biBitCount = 32;
1890 bitmap = CreateDIBSection( 0, &bmi, DIB_RGB_COLORS, &bits, 0, 0 );
1891
1892 r = OpenClipboard( hwnd );
1893 ok( r, "gle %d\n", GetLastError() );
1894 r = EmptyClipboard();
1895 ok( r, "gle %d\n", GetLastError() );
1897 ok( GetObjectType( h ) == OBJ_BITMAP, "expected bitmap %p\n", h );
1898 trace( "dibsection %p\n", h );
1899 r = CloseClipboard();
1900 ok( r, "gle %d\n", GetLastError() );
1901
1902 run_process( "handles_dib dummy" );
1903
1904 r = OpenClipboard( hwnd );
1905 ok( r, "gle %d\n", GetLastError() );
1906 ok( GetObjectType( bitmap ) == OBJ_BITMAP, "expected bitmap %p\n", bitmap );
1907 r = EmptyClipboard();
1908 ok( r, "gle %d\n", GetLastError() );
1909 ok( !GetObjectType( bitmap ), "expected deleted %p\n", bitmap );
1910 r = CloseClipboard();
1911 ok( r, "gle %d\n", GetLastError() );
1912
1914}
1915
1917{
1918 BOOL r;
1919 UINT count, formats[256];
1920
1921 if (!pGetUpdatedClipboardFormats)
1922 {
1923 win_skip( "GetUpdatedClipboardFormats not supported\n" );
1924 return;
1925 }
1926
1927 count = 0xdeadbeef;
1928 r = pGetUpdatedClipboardFormats( NULL, 0, &count );
1929 ok( r, "gle %d\n", GetLastError() );
1930 ok( !count, "wrong count %u\n", count );
1931
1932 count = 0xdeadbeef;
1933 r = pGetUpdatedClipboardFormats( NULL, 256, &count );
1934 ok( r, "gle %d\n", GetLastError() );
1935 ok( !count, "wrong count %u\n", count );
1936
1937 SetLastError( 0xdeadbeef );
1938 r = pGetUpdatedClipboardFormats( formats, 256, NULL );
1939 ok( !r, "succeeded\n" );
1940 ok( GetLastError() == ERROR_NOACCESS, "wrong error %u\n", GetLastError() );
1941
1942 count = 0xdeadbeef;
1943 r = pGetUpdatedClipboardFormats( formats, 256, &count );
1944 ok( r, "gle %d\n", GetLastError() );
1945 ok( !count, "wrong count %u\n", count );
1946
1947 r = OpenClipboard( 0 );
1948 ok( r, "gle %d\n", GetLastError() );
1949 r = EmptyClipboard();
1950 ok( r, "gle %d\n", GetLastError() );
1951
1952 count = 0xdeadbeef;
1953 r = pGetUpdatedClipboardFormats( formats, 256, &count );
1954 ok( r, "gle %d\n", GetLastError() );
1955 ok( !count, "wrong count %u\n", count );
1956
1958
1959 count = 0xdeadbeef;
1960 memset( formats, 0xcc, sizeof(formats) );
1961 r = pGetUpdatedClipboardFormats( formats, 256, &count );
1962 ok( r, "gle %d\n", GetLastError() );
1963 ok( count == 1, "wrong count %u\n", count );
1964 ok( formats[0] == CF_UNICODETEXT, "wrong format %u\n", formats[0] );
1965 ok( formats[1] == 0xcccccccc, "wrong format %u\n", formats[1] );
1966
1968 count = 0xdeadbeef;
1969 memset( formats, 0xcc, sizeof(formats) );
1970 r = pGetUpdatedClipboardFormats( formats, 256, &count );
1971 ok( r, "gle %d\n", GetLastError() );
1972 ok( count == 2, "wrong count %u\n", count );
1973 ok( formats[0] == CF_UNICODETEXT, "wrong format %u\n", formats[0] );
1974 ok( formats[1] == CF_TEXT, "wrong format %u\n", formats[1] );
1975 ok( formats[2] == 0xcccccccc, "wrong format %u\n", formats[2] );
1976
1977 SetLastError( 0xdeadbeef );
1978 count = 0xdeadbeef;
1979 r = pGetUpdatedClipboardFormats( formats, 0, &count );
1980 ok( !r, "succeeded\n" );
1981 ok( GetLastError() == ERROR_INSUFFICIENT_BUFFER, "wrong error %u\n", GetLastError() );
1982 ok( count == 2, "wrong count %u\n", count );
1983
1984 SetLastError( 0xdeadbeef );
1985 count = 0xdeadbeef;
1986 r = pGetUpdatedClipboardFormats( formats, 1, &count );
1987 ok( !r, "succeeded\n" );
1988 ok( GetLastError() == ERROR_INSUFFICIENT_BUFFER, "wrong error %u\n", GetLastError() );
1989 ok( count == 2, "wrong count %u\n", count );
1990
1991 r = CloseClipboard();
1992 ok( r, "gle %d\n", GetLastError() );
1993
1994 count = 0xdeadbeef;
1995 memset( formats, 0xcc, sizeof(formats) );
1996 r = pGetUpdatedClipboardFormats( formats, 256, &count );
1997 ok( r, "gle %d\n", GetLastError() );
1998 ok( count == 4, "wrong count %u\n", count );
1999 ok( formats[0] == CF_UNICODETEXT, "wrong format %u\n", formats[0] );
2000 ok( formats[1] == CF_TEXT, "wrong format %u\n", formats[1] );
2001 ok( formats[2] == CF_LOCALE, "wrong format %u\n", formats[2] );
2002 ok( formats[3] == CF_OEMTEXT, "wrong format %u\n", formats[3] );
2003 ok( formats[4] == 0xcccccccc, "wrong format %u\n", formats[4] );
2004
2005 count = 0xdeadbeef;
2006 memset( formats, 0xcc, sizeof(formats) );
2007 r = pGetUpdatedClipboardFormats( formats, 2, &count );
2008 ok( !r, "gle %d\n", GetLastError() );
2009 ok( GetLastError() == ERROR_INSUFFICIENT_BUFFER, "wrong error %u\n", GetLastError() );
2010 ok( count == 4, "wrong count %u\n", count );
2011 ok( formats[0] == 0xcccccccc, "wrong format %u\n", formats[0] );
2012
2013 count = 0xdeadbeef;
2014 r = pGetUpdatedClipboardFormats( NULL, 256, &count );
2015 ok( !r, "gle %d\n", GetLastError() );
2016 ok( GetLastError() == ERROR_NOACCESS, "wrong error %u\n", GetLastError() );
2017 ok( count == 4, "wrong count %u\n", count );
2018
2019 count = 0xdeadbeef;
2020 r = pGetUpdatedClipboardFormats( NULL, 256, &count );
2021 ok( !r, "gle %d\n", GetLastError() );
2022 ok( GetLastError() == ERROR_NOACCESS, "wrong error %u\n", GetLastError() );
2023 ok( count == 4, "wrong count %u\n", count );
2024}
2025
2026static const struct
2027{
2028 char strA[12];
2031} test_data[] =
2032{
2033 { "foo", {0}, 3 }, /* 0 */
2034 { "foo", {0}, 4 },
2035 { "foo\0bar", {0}, 7 },
2036 { "foo\0bar", {0}, 8 },
2037 { "", {'f','o','o'}, 3 * sizeof(WCHAR) },
2038 { "", {'f','o','o',0}, 4 * sizeof(WCHAR) }, /* 5 */
2039 { "", {'f','o','o',0,'b','a','r'}, 7 * sizeof(WCHAR) },
2040 { "", {'f','o','o',0,'b','a','r',0}, 8 * sizeof(WCHAR) },
2041 { "", {'f','o','o'}, 1 },
2042 { "", {'f','o','o'}, 2 },
2043 { "", {'f','o','o'}, 5 }, /* 10 */
2044 { "", {'f','o','o',0}, 7 },
2045 { "", {'f','o','o',0}, 9 },
2047
2048static void test_string_data(void)
2049{
2050 UINT i;
2051 BOOL r;
2052 HANDLE data;
2053 char cmd[16];
2054 char bufferA[12];
2055 WCHAR bufferW[12];
2056
2057 for (i = 0; i < ARRAY_SIZE(test_data); i++)
2058 {
2059 /* 1-byte Unicode strings crash on Win64 */
2060#ifdef _WIN64
2061 if (!test_data[i].strA[0] && test_data[i].len < sizeof(WCHAR)) continue;
2062#endif
2063 r = OpenClipboard( 0 );
2064 ok( r, "gle %d\n", GetLastError() );
2065 r = EmptyClipboard();
2066 ok( r, "gle %d\n", GetLastError() );
2068 if (test_data[i].strA[0])
2069 {
2072 memcpy( bufferA, test_data[i].strA, test_data[i].len );
2073 bufferA[test_data[i].len - 1] = 0;
2074 ok( !memcmp( data, bufferA, test_data[i].len ),
2075 "%u: wrong data %.*s\n", i, test_data[i].len, (char *)data );
2076 }
2077 else
2078 {
2081 memcpy( bufferW, test_data[i].strW, test_data[i].len );
2082 bufferW[(test_data[i].len + 1) / sizeof(WCHAR) - 1] = 0;
2083 ok( !memcmp( data, bufferW, test_data[i].len ),
2084 "%u: wrong data %s\n", i, wine_dbgstr_wn( data, (test_data[i].len + 1) / sizeof(WCHAR) ));
2085 }
2086 r = CloseClipboard();
2087 ok( r, "gle %d\n", GetLastError() );
2088 sprintf( cmd, "string_data %u", i );
2089 run_process( cmd );
2090 }
2091}
2092
2093static void test_string_data_process( int i )
2094{
2095 BOOL r;
2096 HANDLE data;
2097 UINT len, len2;
2098 char bufferA[12];
2099 WCHAR bufferW[12];
2100
2101 r = OpenClipboard( 0 );
2102 ok( r, "gle %d\n", GetLastError() );
2103 if (test_data[i].strA[0])
2104 {
2106 ok( data != 0, "%u: could not get data\n", i );
2107 len = GlobalSize( data );
2108 ok( len == test_data[i].len, "%u: wrong size %u / %u\n", i, len, test_data[i].len );
2109 memcpy( bufferA, test_data[i].strA, test_data[i].len );
2110 bufferA[test_data[i].len - 1] = 0;
2111 ok( !memcmp( data, bufferA, len ), "%u: wrong data %.*s\n", i, len, (char *)data );
2113 ok( data != 0, "%u: could not get data\n", i );
2114 len = GlobalSize( data );
2115 len2 = MultiByteToWideChar( CP_ACP, 0, bufferA, test_data[i].len, bufferW, 12 );
2116 ok( len == len2 * sizeof(WCHAR), "%u: wrong size %u / %u\n", i, len, len2 );
2117 ok( !memcmp( data, bufferW, len ), "%u: wrong data %s\n", i, wine_dbgstr_wn( data, len2 ));
2118 }
2119 else
2120 {
2122 ok( data != 0, "%u: could not get data\n", i );
2123 len = GlobalSize( data );
2124 ok( len == test_data[i].len, "%u: wrong size %u / %u\n", i, len, test_data[i].len );
2125 memcpy( bufferW, test_data[i].strW, test_data[i].len );
2126 bufferW[(test_data[i].len + 1) / sizeof(WCHAR) - 1] = 0;
2127 ok( !memcmp( data, bufferW, len ),
2128 "%u: wrong data %s\n", i, wine_dbgstr_wn( data, (len + 1) / sizeof(WCHAR) ));
2130 if (test_data[i].len >= sizeof(WCHAR))
2131 {
2132 ok( data != 0, "%u: could not get data\n", i );
2133 len = GlobalSize( data );
2134 len2 = WideCharToMultiByte( CP_ACP, 0, bufferW, test_data[i].len / sizeof(WCHAR),
2135 bufferA, 12, NULL, NULL );
2136 bufferA[len2 - 1] = 0;
2137 ok( len == len2, "%u: wrong size %u / %u\n", i, len, len2 );
2138 ok( !memcmp( data, bufferA, len ), "%u: wrong data %.*s\n", i, len, (char *)data );
2139 }
2140 else
2141 {
2142 ok( !data, "%u: got data for empty string\n", i );
2143 ok( IsClipboardFormatAvailable( CF_TEXT ), "%u: text not available\n", i );
2144 }
2145 }
2146 r = CloseClipboard();
2147 ok( r, "gle %d\n", GetLastError() );
2148}
2149
2150START_TEST(clipboard)
2151{
2152 char **argv;
2154 HMODULE mod = GetModuleHandleA( "user32" );
2155
2156 argv0 = argv[0];
2157 pAddClipboardFormatListener = (void *)GetProcAddress( mod, "AddClipboardFormatListener" );
2158 pRemoveClipboardFormatListener = (void *)GetProcAddress( mod, "RemoveClipboardFormatListener" );
2159 pGetUpdatedClipboardFormats = (void *)GetProcAddress( mod, "GetUpdatedClipboardFormats" );
2160
2161 if (argc == 4 && !strcmp( argv[2], "set_clipboard_data" ))
2162 {
2164 return;
2165 }
2166 if (argc == 4 && !strcmp( argv[2], "grab_clipboard" ))
2167 {
2169 return;
2170 }
2171 if (argc == 4 && !strcmp( argv[2], "handles" ))
2172 {
2174 return;
2175 }
2176 if (argc == 4 && !strcmp( argv[2], "handles_open" ))
2177 {
2179 return;
2180 }
2181 if (argc == 4 && !strcmp( argv[2], "handles_dib" ))
2182 {
2184 return;
2185 }
2186 if (argc == 4 && !strcmp( argv[2], "string_data" ))
2187 {
2189 return;
2190 }
2191 if (argc == 3 && !strcmp( argv[2], "get_clipboard_data" ))
2192 {
2194 return;
2195 }
2196
2200 test_messages();
2204}
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
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
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:4195
LCID WINAPI GetUserDefaultLCID(void)
Definition: locale.c:1211
const WCHAR * text
Definition: package.c:1794
#define BI_RGB
Definition: precomp.h:56
ULONG RGBQUAD
Definition: precomp.h:59
#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
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
#define bits
Definition: infblock.c:15
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
static TfClientId tid
#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:2093
static DWORD WINAPI open_and_empty_clipboard_thread(LPVOID arg)
Definition: clipboard.c:56
static UINT wm_renderformat
Definition: clipboard.c:898
static DWORD WINAPI set_clipboard_data_thread(LPVOID arg)
Definition: clipboard.c:72
static BOOL is_fixed(HANDLE handle)
Definition: clipboard.c:1331
static BOOL is_freed(HANDLE handle)
Definition: clipboard.c:1338
static UINT wm_destroyclipboard
Definition: clipboard.c:897
static DWORD WINAPI test_handles_thread2(void *arg)
Definition: clipboard.c:1627
static DWORD WINAPI clipboard_render_data_thread(void *param)
Definition: clipboard.c:886
static void test_messages(void)
Definition: clipboard.c:1277
static HGLOBAL create_textW(void)
Definition: clipboard.c:498
static BOOL do_render_format
Definition: clipboard.c:901
static HANDLE update_event
Definition: clipboard.c:902
static void test_ClipboardOwner(void)
Definition: clipboard.c:226
#define check_messages(a, b, c, d, e, f)
Definition: clipboard.c:1033
static DWORD WINAPI test_handles_thread(void *arg)
Definition: clipboard.c:1620
static void test_data_handles(void)
Definition: clipboard.c:1792
static DWORD WINAPI open_clipboard_thread(LPVOID arg)
Definition: clipboard.c:40
static HBITMAP create_bitmap(void)
Definition: clipboard.c:534
static CRITICAL_SECTION clipboard_cs
Definition: clipboard.c:893
static HPALETTE palette
Definition: clipboard.c:1345
static LRESULT CALLBACK renderer_winproc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
Definition: clipboard.c:568
static DWORD WINAPI open_and_empty_clipboard_win_thread(LPVOID arg)
Definition: clipboard.c:64
static UINT nb_formats
Definition: clipboard.c:899
static LRESULT CALLBACK winproc_wrapper(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
Definition: clipboard.c:184
static void check_messages_(int line, HWND win, UINT seq_diff, UINT draw, UINT update, UINT destroy, UINT render)
Definition: clipboard.c:1006
static void test_handles_process(const char *str)
Definition: clipboard.c:1678
static const LOGPALETTE logpalette
Definition: clipboard.c:1346
static WNDPROC old_proc
Definition: clipboard.c:183
static UINT format_id
Definition: clipboard.c:1343
static void test_GetUpdatedClipboardFormats(void)
Definition: clipboard.c:1916
static void test_handles_process_open(const char *str)
Definition: clipboard.c:1764
static HGLOBAL create_textA(void)
Definition: clipboard.c:489
static HBITMAP create_dib(BOOL v5)
Definition: clipboard.c:542
static HBITMAP bitmap
Definition: clipboard.c:1344
WCHAR strW[12]
Definition: clipboard.c:2029
static HBITMAP bitmap2
Definition: clipboard.c:1344
static void run_process(const char *args)
Definition: clipboard.c:166
static void test_string_data(void)
Definition: clipboard.c:2048
static char * argv0
Definition: clipboard.c:38
char strA[12]
Definition: clipboard.c:2028
static UINT old_seq
Definition: clipboard.c:1004
static DWORD WINAPI clipboard_thread(void *param)
Definition: clipboard.c:1035
static BOOL cross_thread
Definition: clipboard.c:900
UINT len
Definition: clipboard.c:2030
static void test_RegisterClipboardFormatA(void)
Definition: clipboard.c:373
static void get_clipboard_data_process(void)
Definition: clipboard.c:991
static void set_clipboard_data_process(int arg)
Definition: clipboard.c:104
static void grab_clipboard_process(int arg)
Definition: clipboard.c:128
static void test_synthesized(void)
Definition: clipboard.c:586
static UINT wm_clipboardupdate
Definition: clipboard.c:896
static UINT UINT * out_count
Definition: clipboard.c:35
static void test_handles_process_dib(const char *str)
Definition: clipboard.c:1778
static DWORD WINAPI empty_clipboard_thread(LPVOID arg)
Definition: clipboard.c:47
static int thread_from_line
Definition: clipboard.c:37
static void run_thread(LPTHREAD_START_ROUTINE func, void *arg, int line)
Definition: clipboard.c:144
static HANDLE create_metafile(void)
Definition: clipboard.c:508
static BOOL is_moveable(HANDLE handle)
Definition: clipboard.c:1324
#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
#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:163
int winetest_get_mainargs(char ***pargv)
void winetest_wait_child_process(HANDLE process)
#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:3170
LPCSTR lpszClassName
Definition: winuser.h:3175
WNDPROC lpfnWndProc
Definition: winuser.h:3167
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:1476
HMETAFILE hMF
Definition: wingdi.h:2608
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
int ret
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:332
#define GMEM_FIXED
Definition: winbase.h:319
DWORD WINAPI GetWindowThreadProcessId(HWND hWnd, PDWORD lpdwProcessId)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
#define WAIT_OBJECT_0
Definition: winbase.h:432
#define GMEM_MOVEABLE
Definition: winbase.h:320
#define GMEM_DDESHARE
Definition: winbase.h:324
DWORD(WINAPI * LPTHREAD_START_ROUTINE)(LPVOID)
Definition: winbase.h:754
_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:899
#define ERROR_INVALID_WINDOW_HANDLE
Definition: winerror.h:881
#define ERROR_NOACCESS
Definition: winerror.h:578
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:5357
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:1871
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:4318
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define WM_DRAWCLIPBOARD
Definition: winuser.h:1872
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:906
BOOL WINAPI OpenClipboard(_In_opt_ HWND)
UINT WINAPI EnumClipboardFormats(_In_ UINT)
#define WM_CHANGECBCHAIN
Definition: winuser.h:1877
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:1199
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:1898
#define WM_DESTROY
Definition: winuser.h:1612
#define WM_RENDERFORMAT
Definition: winuser.h:1869
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2909
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:1870
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