ReactOS 0.4.16-dev-1946-g52006dd
clipboard.c File Reference
#include <stdio.h>
#include "wine/test.h"
#include "winbase.h"
#include "winerror.h"
#include "wingdi.h"
#include "winuser.h"
#include "winnls.h"
Include dependency graph for clipboard.c:

Go to the source code of this file.

Macros

#define check_messages(a, b, c, d, e, f)   check_messages_(__LINE__,a,b,c,d,e,f)
 

Functions

static BOOL (WINAPI *pAddClipboardFormatListener)(HWND hwnd)
 
static DWORD WINAPI open_clipboard_thread (LPVOID arg)
 
static DWORD WINAPI empty_clipboard_thread (LPVOID arg)
 
static DWORD WINAPI open_and_empty_clipboard_thread (LPVOID arg)
 
static DWORD WINAPI open_and_empty_clipboard_win_thread (LPVOID arg)
 
static DWORD WINAPI set_clipboard_data_thread (LPVOID arg)
 
static void set_clipboard_data_process (int arg)
 
static void grab_clipboard_process (int arg)
 
static void run_thread (LPTHREAD_START_ROUTINE func, void *arg, int line)
 
static void run_process (const char *args)
 
static LRESULT CALLBACK winproc_wrapper (HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
 
static void test_ClipboardOwner (void)
 
static void test_RegisterClipboardFormatA (void)
 
static HGLOBAL create_textA (void)
 
static HGLOBAL create_textW (void)
 
static HANDLE create_metafile (void)
 
static HENHMETAFILE create_emf (void)
 
static HBITMAP create_bitmap (void)
 
static HBITMAP create_dib (BOOL v5)
 
static LRESULT CALLBACK renderer_winproc (HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
 
static void test_synthesized (void)
 
static DWORD WINAPI clipboard_render_data_thread (void *param)
 
static LRESULT CALLBACK clipboard_wnd_proc (HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
 
static void get_clipboard_data_process (void)
 
static void check_messages_ (int line, HWND win, UINT seq_diff, UINT draw, UINT update, UINT destroy, UINT render)
 
static DWORD WINAPI clipboard_thread (void *param)
 
static void test_messages (void)
 
static BOOL is_moveable (HANDLE handle)
 
static BOOL is_fixed (HANDLE handle)
 
static BOOL is_freed (HANDLE handle)
 
static void test_handles (HWND hwnd)
 
static DWORD WINAPI test_handles_thread (void *arg)
 
static DWORD WINAPI test_handles_thread2 (void *arg)
 
static void test_handles_process (const char *str)
 
static void test_handles_process_open (const char *str)
 
static void test_handles_process_dib (const char *str)
 
static void test_data_handles (void)
 
static void test_GetUpdatedClipboardFormats (void)
 
static void test_string_data (void)
 
static void test_string_data_process (int i)
 
 START_TEST (clipboard)
 

Variables

static UINT count
 
static UINT UINTout_count
 
static int thread_from_line
 
static charargv0
 
static WNDPROC old_proc
 
static CRITICAL_SECTION clipboard_cs
 
static HWND next_wnd
 
static UINT wm_drawclipboard
 
static UINT wm_clipboardupdate
 
static UINT wm_destroyclipboard
 
static UINT wm_renderformat
 
static UINT nb_formats
 
static BOOL cross_thread
 
static BOOL do_render_format
 
static HANDLE update_event
 
static UINT old_seq
 
static UINT format_id
 
static HBITMAP bitmap
 
static HBITMAP bitmap2
 
static HPALETTE palette
 
static const LOGPALETTE logpalette = { 0x300, 1, {{ 0x12, 0x34, 0x56, 0x78 }}}
 
struct {
   char   strA [12]
 
   WCHAR   strW [12]
 
   UINT   len
 
test_data []
 

Macro Definition Documentation

◆ check_messages

#define check_messages (   a,
  b,
  c,
  d,
  e,
  f 
)    check_messages_(__LINE__,a,b,c,d,e,f)

Definition at line 1029 of file clipboard.c.

Function Documentation

◆ BOOL()

static BOOL ( WINAPI pAddClipboardFormatListener)
static

◆ check_messages_()

static void check_messages_ ( int  line,
HWND  win,
UINT  seq_diff,
UINT  draw,
UINT  update,
UINT  destroy,
UINT  render 
)
static

Definition at line 1002 of file clipboard.c.

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}
void destroy(_Tp *__pointer)
Definition: _construct.h:278
#define ok(value,...)
Definition: atltest.h:57
#define broken(x)
Definition: atltest.h:178
#define ok_(x1, x2)
Definition: atltest.h:61
#define msg(x)
Definition: auth_time.c:54
GLuint GLuint GLsizei count
Definition: gl.h:1545
static real win[4][36]
static HANDLE update_event
Definition: clipboard.c:898
static UINT old_seq
Definition: clipboard.c:1000
static BOOL cross_thread
Definition: clipboard.c:896
unsigned int UINT
Definition: ndis.h:50
EXTINLINE DWORD WINAPI GetClipboardSequenceNumber(VOID)
Definition: ntwrapper.h:202
static void render(void)
Definition: ssstars.c:272
Definition: dsound.c:943
Definition: parser.c:49
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
#define WAIT_OBJECT_0
Definition: winbase.h:383
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI PeekMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
#define PM_REMOVE
Definition: winuser.h:1207
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
#define WM_USER
Definition: winuser.h:1923

◆ clipboard_render_data_thread()

static DWORD WINAPI clipboard_render_data_thread ( void param)
static

Definition at line 882 of file clipboard.c.

883{
885 ok( handle != 0, "SetClipboardData failed: %d\n", GetLastError() );
886 return 0;
887}
#define CF_UNICODETEXT
Definition: constants.h:408
static HGLOBAL create_textW(void)
Definition: clipboard.c:494
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
HANDLE WINAPI SetClipboardData(_In_ UINT, _In_opt_ HANDLE)

Referenced by clipboard_wnd_proc().

◆ clipboard_thread()

static DWORD WINAPI clipboard_thread ( void param)
static

Definition at line 1031 of file clipboard.c.

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}
#define trace
Definition: atltest.h:70
#define CF_WAVE
Definition: constants.h:407
#define CF_TEXT
Definition: constants.h:396
#define CF_OEMTEXT
Definition: constants.h:402
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static const struct pixel_format_desc formats[]
Definition: util.c:59
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define SetLastError(x)
Definition: compat.h:752
return ret
Definition: mutex.c:146
unsigned int BOOL
Definition: ntddk_ex.h:94
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLfloat param
Definition: glext.h:5796
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
static HWND next_wnd
Definition: clipboard.c:1035
static BOOL do_render_format
Definition: clipboard.c:897
#define check_messages(a, b, c, d, e, f)
Definition: clipboard.c:1029
static CRITICAL_SECTION clipboard_cs
Definition: clipboard.c:889
static HGLOBAL create_textA(void)
Definition: clipboard.c:485
static void run_process(const char *args)
Definition: clipboard.c:162
DWORD WINAPI GetCurrentThreadId(void)
Definition: thread.c:459
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define GMEM_FIXED
Definition: winbase.h:317
DWORD WINAPI GetWindowThreadProcessId(HWND hWnd, PDWORD lpdwProcessId)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define ERROR_INVALID_WINDOW_HANDLE
Definition: winerror.h:1226
BOOL WINAPI CloseClipboard(void)
Definition: ntwrapper.h:178
HWND WINAPI GetClipboardOwner(void)
Definition: ntwrapper.h:196
BOOL WINAPI OpenClipboard(_In_opt_ HWND)
HANDLE WINAPI GetClipboardData(_In_ UINT)
HWND WINAPI SetClipboardViewer(_In_ HWND)
HWND WINAPI GetDesktopWindow(void)
Definition: window.c:628
BOOL WINAPI ChangeClipboardChain(_In_ HWND, _In_ HWND)
BOOL WINAPI EmptyClipboard(void)
Definition: ntwrapper.h:190
int WINAPI CountClipboardFormats(void)
Definition: ntwrapper.h:184
BOOL WINAPI PostMessageA(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI IsClipboardFormatAvailable(_In_ UINT)

Referenced by test_messages().

◆ clipboard_wnd_proc()

static LRESULT CALLBACK clipboard_wnd_proc ( HWND  hwnd,
UINT  msg,
WPARAM  wp,
LPARAM  lp 
)
static

Definition at line 900 of file clipboard.c.

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}
#define CloseHandle
Definition: compat.h:739
HANDLE HWND
Definition: compat.h:19
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
#define INFINITE
Definition: serial.h:102
unsigned long DWORD
Definition: ntddk_ex.h:95
LONG_PTR LRESULT
Definition: minwindef.h:176
static UINT wm_drawclipboard
Definition: clipboard.c:1036
static UINT wm_renderformat
Definition: clipboard.c:894
static UINT wm_destroyclipboard
Definition: clipboard.c:893
static DWORD WINAPI clipboard_render_data_thread(void *param)
Definition: clipboard.c:882
static UINT nb_formats
Definition: clipboard.c:895
static UINT wm_clipboardupdate
Definition: clipboard.c:892
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
DWORD WINAPI InSendMessageEx(LPVOID lpReserved)
Definition: message.c:1391
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_DESTROYCLIPBOARD
Definition: winuser.h:1896
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define WM_DRAWCLIPBOARD
Definition: winuser.h:1897
#define WM_CHANGECBCHAIN
Definition: winuser.h:1902
#define WM_RENDERFORMAT
Definition: winuser.h:1894

◆ create_bitmap()

static HBITMAP create_bitmap ( void  )
static

Definition at line 530 of file clipboard.c.

531{
532 HDC hdc = GetDC( 0 );
534 ReleaseDC( 0, hdc );
535 return CreateBitmap( 10, 10, 1, bpp, NULL );
536}
DWORD bpp
Definition: surface.c:185
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:88
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)
#define BITSPIXEL
Definition: wingdi.h:720
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HDC WINAPI GetDC(_In_opt_ HWND)

Referenced by BITMAP_LoadImageW(), DataObject_GetData(), image_list_add_bitmap(), test_data_cache_cache(), test_imagelist_storage(), test_load_texture(), test_synthesized(), and test_texture_qi().

◆ create_dib()

static HBITMAP create_dib ( BOOL  v5)
static

Definition at line 538 of file clipboard.c.

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}
#define BI_RGB
Definition: precomp.h:56
ULONG RGBQUAD
Definition: precomp.h:59
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
static ERESOURCE GlobalLock
Definition: sys_arch.c:8
char hdr[14]
Definition: iptest.cpp:33
#define GMEM_ZEROINIT
Definition: winbase.h:330
#define GMEM_MOVEABLE
Definition: winbase.h:318
#define GMEM_DDESHARE
Definition: winbase.h:322

Referenced by test_synthesized().

◆ create_emf()

static HENHMETAFILE create_emf ( void  )
static

Definition at line 522 of file clipboard.c.

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}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
& rect
Definition: startmenu.cpp:1413
Definition: windef.h:99
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
HENHMETAFILE WINAPI CloseEnhMetaFile(_In_ HDC hdc)

◆ create_metafile()

static HANDLE create_metafile ( void  )
static

Definition at line 504 of file clipboard.c.

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}
HMETAFILE hMF
Definition: wingdi.h:3054
HDC WINAPI CreateMetaFileA(_In_opt_ LPCSTR)
HMETAFILE WINAPI CloseMetaFile(_In_ HDC hdc)
#define MM_TEXT
Definition: wingdi.h:873

Referenced by test_data_handles(), and test_synthesized().

◆ create_textA()

static HGLOBAL create_textA ( void  )
static

Definition at line 485 of file clipboard.c.

486{
488 char *p = GlobalLock(h);
489 memcpy(p, "test\0\0\0\0\0", 10);
491 return h;
492}
GLfloat GLfloat p
Definition: glext.h:8902
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878

Referenced by clipboard_thread(), clipboard_wnd_proc(), test_data_handles(), test_handles(), and test_synthesized().

◆ create_textW()

static HGLOBAL create_textW ( void  )
static

Definition at line 494 of file clipboard.c.

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}
static const WCHAR testW[]
Definition: jsregexp.c:44
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by clipboard_render_data_thread(), and test_synthesized().

◆ empty_clipboard_thread()

static DWORD WINAPI empty_clipboard_thread ( LPVOID  arg)
static

Definition at line 43 of file clipboard.c.

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}
static int thread_from_line
Definition: clipboard.c:33
#define ERROR_CLIPBOARD_NOT_OPEN
Definition: winerror.h:1244

Referenced by test_ClipboardOwner().

◆ get_clipboard_data_process()

static void get_clipboard_data_process ( void  )
static

Definition at line 987 of file clipboard.c.

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}
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950

Referenced by START_TEST().

◆ grab_clipboard_process()

static void grab_clipboard_process ( int  arg)
static

Definition at line 124 of file clipboard.c.

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}

Referenced by START_TEST().

◆ is_fixed()

static BOOL is_fixed ( HANDLE  handle)
static

Definition at line 1327 of file clipboard.c.

1328{
1329 void *ptr = GlobalLock( handle );
1330 if (ptr) GlobalUnlock( handle );
1331 return ptr && ptr == handle;
1332}
static PVOID ptr
Definition: dispmode.c:27

Referenced by test_data_handles(), test_handles(), test_handles_process(), and test_handles_thread2().

◆ is_freed()

static BOOL is_freed ( HANDLE  handle)
static

Definition at line 1334 of file clipboard.c.

1335{
1336 return !GlobalSize( handle );
1337}
SIZE_T NTAPI GlobalSize(HGLOBAL hMem)
Definition: heapmem.c:1090

Referenced by test_data_handles(), and test_handles().

◆ is_moveable()

static BOOL is_moveable ( HANDLE  handle)
static

Definition at line 1320 of file clipboard.c.

1321{
1322 void *ptr = GlobalLock( handle );
1323 if (ptr) GlobalUnlock( handle );
1324 return ptr && ptr != handle;
1325}

Referenced by test_data_handles(), test_handles(), test_handles_process_open(), and test_handles_thread2().

◆ open_and_empty_clipboard_thread()

static DWORD WINAPI open_and_empty_clipboard_thread ( LPVOID  arg)
static

Definition at line 52 of file clipboard.c.

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}
HWND hWnd
Definition: settings.c:17
void * arg
Definition: msvc.h:10

Referenced by test_ClipboardOwner().

◆ open_and_empty_clipboard_win_thread()

static DWORD WINAPI open_and_empty_clipboard_win_thread ( LPVOID  arg)
static

Definition at line 60 of file clipboard.c.

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}
#define WS_POPUP
Definition: pedump.c:616
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4417

Referenced by test_ClipboardOwner().

◆ open_clipboard_thread()

static DWORD WINAPI open_clipboard_thread ( LPVOID  arg)
static

Definition at line 36 of file clipboard.c.

37{
38 HWND hWnd = arg;
39 ok(OpenClipboard(hWnd), "%u: OpenClipboard failed\n", thread_from_line);
40 return 0;
41}

Referenced by test_ClipboardOwner().

◆ renderer_winproc()

static LRESULT CALLBACK renderer_winproc ( HWND  hwnd,
UINT  msg,
WPARAM  wp,
LPARAM  lp 
)
static

Definition at line 564 of file clipboard.c.

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}

Referenced by test_synthesized().

◆ run_process()

static void run_process ( const char args)
static

Definition at line 162 of file clipboard.c.

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}
static void startup(void)
#define MAX_PATH
Definition: compat.h:34
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:4749
#define sprintf
Definition: sprintf.c:45
static char * argv0
Definition: clipboard.c:34
void winetest_wait_child_process(HANDLE process)
#define memset(x, y, z)
Definition: compat.h:39
Definition: match.c:390
Definition: ftp_var.h:139

Referenced by clipboard_thread(), test_ClipboardOwner(), test_data_handles(), and test_string_data().

◆ run_thread()

static void run_thread ( LPTHREAD_START_ROUTINE  func,
void arg,
int  line 
)
static

Definition at line 140 of file clipboard.c.

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}
static HANDLE thread
Definition: service.c:33
GLenum func
Definition: glext.h:6028
#define QS_ALLINPUT
Definition: winuser.h:914
DWORD WINAPI MsgWaitForMultipleObjectsEx(_In_ DWORD nCount, _In_reads_opt_(nCount) CONST HANDLE *pHandles, _In_ DWORD dwMilliseconds, _In_ DWORD dwWakeMask, _In_ DWORD dwFlags)

Referenced by test_ClipboardOwner(), and test_data_handles().

◆ set_clipboard_data_process()

static void set_clipboard_data_process ( int  arg)
static

Definition at line 100 of file clipboard.c.

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}

Referenced by START_TEST().

◆ set_clipboard_data_thread()

static DWORD WINAPI set_clipboard_data_thread ( LPVOID  arg)
static

Definition at line 68 of file clipboard.c.

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}

Referenced by test_ClipboardOwner().

◆ START_TEST()

START_TEST ( clipboard  )

Definition at line 2146 of file clipboard.c.

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 int argc
Definition: ServiceArgs.c:12
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define GetProcAddress(x, y)
Definition: compat.h:753
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
static void test_string_data_process(int i)
Definition: clipboard.c:2089
static void test_messages(void)
Definition: clipboard.c:1273
static void test_ClipboardOwner(void)
Definition: clipboard.c:222
static void test_data_handles(void)
Definition: clipboard.c:1788
static void test_handles_process(const char *str)
Definition: clipboard.c:1674
static void test_GetUpdatedClipboardFormats(void)
Definition: clipboard.c:1912
static void test_handles_process_open(const char *str)
Definition: clipboard.c:1760
static void test_string_data(void)
Definition: clipboard.c:2044
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 void test_handles_process_dib(const char *str)
Definition: clipboard.c:1774
#define argv
Definition: mplay32.c:18
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
int winetest_get_mainargs(char ***pargv)

◆ test_ClipboardOwner()

static void test_ClipboardOwner ( void  )
static

Definition at line 222 of file clipboard.c.

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}
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
HWND hWnd1
Definition: button.c:416
HWND hWnd2
Definition: button.c:416
static DWORD WINAPI open_and_empty_clipboard_thread(LPVOID arg)
Definition: clipboard.c:52
static DWORD WINAPI set_clipboard_data_thread(LPVOID arg)
Definition: clipboard.c:68
static DWORD WINAPI open_clipboard_thread(LPVOID arg)
Definition: clipboard.c:36
static DWORD WINAPI open_and_empty_clipboard_win_thread(LPVOID arg)
Definition: clipboard.c:60
static LRESULT CALLBACK winproc_wrapper(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
Definition: clipboard.c:180
static WNDPROC old_proc
Definition: clipboard.c:179
static DWORD WINAPI empty_clipboard_thread(LPVOID arg)
Definition: clipboard.c:43
static void run_thread(LPTHREAD_START_ROUTINE func, void *arg, int line)
Definition: clipboard.c:140
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define GWLP_WNDPROC
Definition: treelist.c:66
#define SetWindowLongPtrA
Definition: winuser.h:5456
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)
HWND WINAPI GetOpenClipboardWindow(void)
Definition: ntwrapper.h:214
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:3008
BOOL WINAPI DestroyWindow(_In_ HWND)
HWND WINAPI GetClipboardViewer(void)
Definition: ntwrapper.h:208

Referenced by START_TEST().

◆ test_data_handles()

static void test_data_handles ( void  )
static

Definition at line 1788 of file clipboard.c.

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}
static POBJECT_TYPE GetObjectType(IN PCWSTR TypeName)
Definition: ObTypes.c:15
#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_DSPMETAFILEPICT
Definition: constants.h:416
#define CF_DSPBITMAP
Definition: constants.h:415
#define CF_ENHMETAFILE
Definition: constants.h:409
#define CF_GDIOBJFIRST
Definition: constants.h:420
#define CF_PRIVATEFIRST
Definition: constants.h:418
const WCHAR * text
Definition: package.c:1794
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
#define bits
Definition: infblock.c:15
static HENHMETAFILE create_emf(void)
Definition: clipboard.c:1505
static BOOL is_fixed(HANDLE handle)
Definition: clipboard.c:1327
static BOOL is_freed(HANDLE handle)
Definition: clipboard.c:1334
static DWORD WINAPI test_handles_thread2(void *arg)
Definition: clipboard.c:1623
static DWORD WINAPI test_handles_thread(void *arg)
Definition: clipboard.c:1616
static HPALETTE palette
Definition: clipboard.c:1341
static const LOGPALETTE logpalette
Definition: clipboard.c:1342
static UINT format_id
Definition: clipboard.c:1339
static HBITMAP bitmap2
Definition: clipboard.c:1340
static HANDLE create_metafile(void)
Definition: clipboard.c:504
static BOOL is_moveable(HANDLE handle)
Definition: clipboard.c:1320
#define OBJ_BITMAP
Definition: objidl.idl:1020
#define OBJ_PAL
Definition: objidl.idl:1018
#define OBJ_ENHMETAFILE
Definition: objidl.idl:1026
Definition: uimain.c:89
USHORT biBitCount
Definition: precomp.h:46
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1922
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:245
static void test_handles(void)
Definition: winstation.c:109
#define DIB_RGB_COLORS
Definition: wingdi.h:367
HPALETTE WINAPI CreatePalette(_In_reads_(_Inexpressible_(2 *sizeof(WORD)+plpal->palNumEntries *sizeof(PALETTEENTRY))) const LOGPALETTE *)
UINT WINAPI RegisterClipboardFormatA(_In_ LPCSTR)

Referenced by START_TEST().

◆ test_GetUpdatedClipboardFormats()

static void test_GetUpdatedClipboardFormats ( void  )
static

Definition at line 1912 of file clipboard.c.

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}
#define CF_LOCALE
Definition: constants.h:411
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define win_skip
Definition: minitest.h:67
#define ERROR_NOACCESS
Definition: winerror.h:902

Referenced by START_TEST().

◆ test_handles()

static void test_handles ( HWND  hwnd)
static

Definition at line 1344 of file clipboard.c.

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}
#define CF_DIB
Definition: constants.h:403
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
static HBITMAP
Definition: button.c:44
DWORD WINAPI GetCurrentProcessId(void)
Definition: proc.c:1158

◆ test_handles_process()

static void test_handles_process ( const char str)
static

Definition at line 1674 of file clipboard.c.

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}
GLuint buffer
Definition: glext.h:5915
uint32_t entry
Definition: isohybrid.c:63
#define OBJ_METAFILE
Definition: objidl.idl:1022
const WCHAR * str
Definition: bl.h:1331
UINT WINAPI GetPaletteEntries(HPALETTE hpal, UINT iStartIndex, UINT cEntries, LPPALETTEENTRY ppe)
Definition: palette.c:64
UINT WINAPI GetEnhMetaFileBits(_In_ HENHMETAFILE hEMF, _In_ UINT nSize, _Out_writes_bytes_opt_(nSize) LPBYTE lpData)
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
unsigned char BYTE
Definition: xxhash.c:193

Referenced by START_TEST().

◆ test_handles_process_dib()

static void test_handles_process_dib ( const char str)
static

Definition at line 1774 of file clipboard.c.

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}

Referenced by START_TEST().

◆ test_handles_process_open()

static void test_handles_process_open ( const char str)
static

Definition at line 1760 of file clipboard.c.

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}
strcpy
Definition: string.h:131

Referenced by START_TEST().

◆ test_handles_thread()

static DWORD WINAPI test_handles_thread ( void arg)
static

Definition at line 1616 of file clipboard.c.

1617{
1618 trace( "running from different thread\n" );
1619 test_handles( (HWND)arg );
1620 return 0;
1621}

Referenced by test_data_handles().

◆ test_handles_thread2()

static DWORD WINAPI test_handles_thread2 ( void arg)
static

Definition at line 1623 of file clipboard.c.

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}

Referenced by test_data_handles().

◆ test_messages()

static void test_messages ( void  )
static

Definition at line 1273 of file clipboard.c.

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}
static TfClientId tid
static LRESULT CALLBACK clipboard_wnd_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
Definition: clipboard.c:1038
static DWORD WINAPI clipboard_thread(void *param)
Definition: clipboard.c:1031
HINSTANCE hInstance
Definition: winuser.h:3269
LPCSTR lpszClassName
Definition: winuser.h:3274
WNDPROC lpfnWndProc
Definition: winuser.h:3266
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
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
LRESULT WINAPI DispatchMessageA(_In_ const MSG *)
BOOL WINAPI TranslateMessage(_In_ const MSG *)
BOOL WINAPI UnregisterClassA(_In_ LPCSTR, HINSTANCE)
ATOM WINAPI RegisterClassA(_In_ CONST WNDCLASSA *)
BOOL WINAPI GetMessageA(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)

Referenced by START_TEST().

◆ test_RegisterClipboardFormatA()

static void test_RegisterClipboardFormatA ( void  )
static

Definition at line 369 of file clipboard.c.

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}
WORD ATOM
Definition: dimm.idl:113
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
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
int WINAPI lstrcmpA(LPCSTR str1, LPCSTR str2)
Definition: locale.c:4198
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLenum GLsizei len
Definition: glext.h:6722
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
int winetest_debug
#define todo_wine
Definition: minitest.h:80
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
UINT len
Definition: clipboard.c:2026
int WINAPI GetClipboardFormatNameA(_In_ UINT format, _Out_writes_(cchMaxCount) LPSTR lpszFormatName, _In_ int cchMaxCount)
UINT WINAPI EnumClipboardFormats(_In_ UINT)

Referenced by START_TEST().

◆ test_string_data()

static void test_string_data ( void  )
static

Definition at line 2044 of file clipboard.c.

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}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define ARRAY_SIZE(A)
Definition: main.h:20
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
WCHAR strW[12]
Definition: clipboard.c:2025
char strA[12]
Definition: clipboard.c:2024
#define wine_dbgstr_wn
Definition: testlist.c:2

Referenced by START_TEST().

◆ test_string_data_process()

static void test_string_data_process ( int  i)
static

Definition at line 2089 of file clipboard.c.

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}
#define CP_ACP
Definition: compat.h:109
#define WideCharToMultiByte
Definition: compat.h:111
#define MultiByteToWideChar
Definition: compat.h:110

Referenced by START_TEST().

◆ test_synthesized()

static void test_synthesized ( void  )
static

Definition at line 582 of file clipboard.c.

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}
#define ERROR_SUCCESS
Definition: deptool.c:10
LCID WINAPI GetUserDefaultLCID(void)
Definition: locale.c:1216
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
static struct test_info tests[]
BOOL expected
Definition: store.c:2000
static HBITMAP create_bitmap(void)
Definition: clipboard.c:530
static LRESULT CALLBACK renderer_winproc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
Definition: clipboard.c:564
static HBITMAP create_dib(BOOL v5)
Definition: clipboard.c:538
#define test
Definition: rosglue.h:37
#define MAKELANGID(p, s)
Definition: nls.h:15
#define LANG_ENGLISH
Definition: nls.h:52
#define SUBLANG_DEFAULT
Definition: nls.h:168
Definition: emfdc.c:45
Definition: format.c:58

Referenced by START_TEST().

◆ winproc_wrapper()

static LRESULT CALLBACK winproc_wrapper ( HWND  hwnd,
UINT  msg,
WPARAM  wp,
LPARAM  lp 
)
static

Definition at line 180 of file clipboard.c.

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}
#define WM_DESTROY
Definition: winuser.h:1637
#define WM_RENDERALLFORMATS
Definition: winuser.h:1895

Referenced by test_ClipboardOwner().

Variable Documentation

◆ argv0

char* argv0
static

Definition at line 34 of file clipboard.c.

Referenced by run_process(), and START_TEST().

◆ bitmap

HBITMAP bitmap
static

Definition at line 1340 of file clipboard.c.

◆ bitmap2

◆ clipboard_cs

CRITICAL_SECTION clipboard_cs
static

Definition at line 889 of file clipboard.c.

Referenced by clipboard_thread(), clipboard_wnd_proc(), and test_messages().

◆ count

Definition at line 31 of file clipboard.c.

◆ cross_thread

BOOL cross_thread
static

Definition at line 896 of file clipboard.c.

Referenced by check_messages_(), clipboard_thread(), and clipboard_wnd_proc().

◆ do_render_format

BOOL do_render_format
static

Definition at line 897 of file clipboard.c.

Referenced by clipboard_thread(), and clipboard_wnd_proc().

◆ format_id

◆ len

Definition at line 2026 of file clipboard.c.

Referenced by test_RegisterClipboardFormatA(), and test_string_data_process().

◆ logpalette

const LOGPALETTE logpalette = { 0x300, 1, {{ 0x12, 0x34, 0x56, 0x78 }}}
static

◆ nb_formats

UINT nb_formats
static

Definition at line 895 of file clipboard.c.

Referenced by clipboard_wnd_proc().

◆ next_wnd

HWND next_wnd
static

Definition at line 890 of file clipboard.c.

◆ old_proc

WNDPROC old_proc
static

◆ old_seq

UINT old_seq
static

◆ out_count

◆ palette

HPALETTE palette
static

Definition at line 1341 of file clipboard.c.

Referenced by BitmapClipper_CopyPalette(), BitmapTestSrc_CopyPalette(), BmpEncoder_SetPalette(), BmpFrameDecode_ReadRLE4(), BmpFrameDecode_ReadRLE8(), BmpFrameEncode_SetPalette(), check_halftone_palette(), CommonDecoder_CopyPalette(), CommonEncoder_SetPalette(), CommonEncoderFrame_SetPalette(), ComponentFactory_CreatePalette(), convert_argb_pixels(), convert_p8_uint_b8g8r8a8_unorm(), copypixels_to_32bppBGRA(), create_bitmap_from_source_rect(), create_optimal_palette(), d3drm_image_load_8(), d3drm_image_palettise(), d3drm_texture1_Changed(), d3drm_texture2_Changed(), D3DXCreateCubeTextureFromFileExA(), D3DXCreateCubeTextureFromFileExW(), D3DXCreateCubeTextureFromFileInMemoryEx(), D3DXCreateTextureFromFileExA(), D3DXCreateTextureFromFileExW(), D3DXCreateTextureFromFileInMemoryEx(), D3DXCreateTextureFromResourceExA(), D3DXCreateTextureFromResourceExW(), D3DXCreateVolumeTextureFromFileExA(), D3DXCreateVolumeTextureFromFileExW(), D3DXCreateVolumeTextureFromFileInMemoryEx(), D3DXFilterTexture(), D3DXLoadSurfaceFromFileInMemory(), ddraw1_CreatePalette(), ddraw2_CreatePalette(), ddraw4_CreatePalette(), ddraw_palette_GetCaps(), ddraw_palette_GetEntries(), ddraw_palette_init(), ddraw_palette_Release(), ddraw_palette_SetEntries(), ddraw_surface1_GetPalette(), ddraw_surface1_SetPalette(), ddraw_surface2_GetPalette(), ddraw_surface2_SetPalette(), ddraw_surface3_GetPalette(), ddraw_surface3_SetPalette(), ddraw_surface4_GetPalette(), ddraw_surface4_SetPalette(), ddraw_surface7_GetDC(), ddraw_surface7_GetPalette(), ddraw_surface7_SetPalette(), ddraw_surface_set_palette(), DdsEncoder_SetPalette(), DdsFrameEncode_SetPalette(), DECLARE_INTERFACE_(), decode_frame_wic(), DirectDrawMediaStreamImpl_IDirectDrawMediaStream_GetFormat(), EMFDC_SelectPalette(), FormatConverter_CopyPalette(), FormatConverter_Initialize(), GdipBitmapConvertFormat(), GdipCreateBitmapFromHBITMAP(), GdipGetImageAttributesAdjustedPalette(), GdipGetImagePalette(), GdipInitializePalette(), GdipSetImagePalette(), get_bitmap_info(), get_gif_palette(), get_palette(), get_palette_index(), Image::GetPalette(), gif_metadata_reader(), GifDecoder_CopyPalette(), GifEncoder_SetPalette(), GifFrameEncode_SetPalette(), ImagingFactory_CreateBitmapFromHBITMAP(), IMILBitmapImpl_CopyPalette(), IMILBitmapImpl_SetPalette(), IMILBitmapScaler_CopyPalette(), index_to_rgba(), InitBitmap(), load_cube_texture_from_dds(), load_texture_from_dds(), load_volume_texture_from_dds(), metadc_create_palette(), METADC_SelectPalette(), metafile_deserialize_image(), NtGdiDdDDICreateDCFromMemory(), palette_sample(), PaletteImpl_Create(), PaletteImpl_InitializeFromBitmap(), point_filter_argb_pixels(), Image::SetPalette(), setpixel_1bppIndexed(), setpixel_4bppIndexed(), setpixel_8bppIndexed(), surface_load_texture(), test_bitmap_scaler(), test_bitmapbits(), test_converter_8bppIndexed(), test_createbitmap(), test_CreateBitmapFromHBITMAP(), test_createbitmapfromsource(), test_custom_palette(), test_D3DXLoadSurface(), test_data_handles(), test_dds_decoder_global_properties(), test_decode(), test_decode_1bpp(), test_decode_24bpp(), test_decode_4bpp(), test_decode_adobe_cmyk(), test_decode_bitfields(), test_decode_rle4(), test_decode_rle8(), test_default_handler(), test_encoder(), test_GdipInitializePalette(), test_getadjustedpalette(), test_global_gif_palette(), test_global_gif_palette_2frames(), test_handles(), test_handles_thread2(), test_local_gif_palette(), test_media_streams(), test_multi_encoder(), test_multi_encoder_impl(), test_multiframegif(), test_no_gif_palette(), test_palette(), test_palette_brush(), test_palette_from_bitmap(), test_png_palette(), test_predefined_palette(), test_set_frame_palette(), test_SetDIBits(), test_SetDIBitsToDevice(), test_tiff_1bpp_palette(), test_tiff_4bps_bgra(), test_tiff_8bpp_alpha(), test_tiff_8bpp_palette(), test_tiff_palette(), test_writesource_palette(), upload_palette(), wined3d_colour_from_ddraw_colour(), wined3d_palette_apply_to_dc(), wined3d_palette_create(), wined3d_palette_decref(), wined3d_palette_get_entries(), wined3d_palette_incref(), wined3d_palette_init(), wined3d_palette_set_entries(), wined3d_swapchain_set_palette(), and write_source().

◆ strA

◆ strW

◆ 

const struct { ... } test_data[]
Initial value:
=
{
{ "foo", {0}, 3 },
{ "foo", {0}, 4 },
{ "foo\0bar", {0}, 7 },
{ "foo\0bar", {0}, 8 },
{ "", {'f','o','o'}, 3 * sizeof(WCHAR) },
{ "", {'f','o','o',0}, 4 * sizeof(WCHAR) },
{ "", {'f','o','o',0,'b','a','r'}, 7 * sizeof(WCHAR) },
{ "", {'f','o','o',0,'b','a','r',0}, 8 * sizeof(WCHAR) },
{ "", {'f','o','o'}, 1 },
{ "", {'f','o','o'}, 2 },
{ "", {'f','o','o'}, 5 },
{ "", {'f','o','o',0}, 7 },
{ "", {'f','o','o',0}, 9 },
}

◆ thread_from_line

◆ update_event

HANDLE update_event
static

Definition at line 898 of file clipboard.c.

Referenced by check_messages_(), clipboard_wnd_proc(), and test_messages().

◆ wm_clipboardupdate

UINT wm_clipboardupdate
static

Definition at line 892 of file clipboard.c.

Referenced by clipboard_wnd_proc().

◆ wm_destroyclipboard

UINT wm_destroyclipboard
static

Definition at line 893 of file clipboard.c.

Referenced by clipboard_wnd_proc().

◆ wm_drawclipboard

UINT wm_drawclipboard
static

Definition at line 891 of file clipboard.c.

◆ wm_renderformat

UINT wm_renderformat
static

Definition at line 894 of file clipboard.c.

Referenced by clipboard_wnd_proc().