ReactOS 0.4.15-dev-5667-ged97270
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 1033 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 1006 of file clipboard.c.

1007{
1008 MSG msg;
1009 UINT count, fmt, seq;
1010
1012 ok_(__FILE__, line)(seq - old_seq == seq_diff, "sequence diff %d\n", seq - old_seq);
1013 old_seq = seq;
1014
1015 if (!cross_thread)
1016 {
1017 while (PeekMessageW( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageW( &msg );
1018 }
1019
1020 if (update && !broken(!pAddClipboardFormatListener))
1021 ok(WaitForSingleObject(update_event, 1000) == WAIT_OBJECT_0, "wait failed\n");
1022
1023 count = SendMessageA( win, WM_USER + 1, 0, 0 );
1024 ok_(__FILE__, line)(count == draw, "WM_DRAWCLIPBOARD %sreceived\n", draw ? "not " : "");
1025 count = SendMessageA( win, WM_USER + 2, 0, 0 );
1026 ok_(__FILE__, line)(count == update || broken(!pAddClipboardFormatListener),
1027 "WM_CLIPBOARDUPDATE %sreceived\n", update ? "not " : "");
1028 count = SendMessageA( win, WM_USER + 3, 0, 0 );
1029 ok_(__FILE__, line)(count == destroy, "WM_DESTROYCLIPBOARD %sreceived\n", destroy ? "not " : "");
1030 fmt = SendMessageA( win, WM_USER + 4, 0, 0 );
1031 ok_(__FILE__, line)(fmt == render, "WM_RENDERFORMAT received %04x, expected %04x\n", fmt, render);
1032}
void destroy(_Tp *__pointer)
Definition: _construct.h:278
#define broken(x)
Definition: _sntprintf.h:21
#define ok(value,...)
Definition: atltest.h:57
#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:902
static UINT old_seq
Definition: clipboard.c:1004
static BOOL cross_thread
Definition: clipboard.c:900
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:406
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:1186
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
#define WM_USER
Definition: winuser.h:1885

◆ clipboard_render_data_thread()

static DWORD WINAPI clipboard_render_data_thread ( void param)
static

Definition at line 886 of file clipboard.c.

887{
889 ok( handle != 0, "SetClipboardData failed: %d\n", GetLastError() );
890 return 0;
891}
#define CF_UNICODETEXT
Definition: constants.h:408
static HGLOBAL create_textW(void)
Definition: clipboard.c:498
DWORD WINAPI GetLastError(void)
Definition: except.c:1040
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 1035 of file clipboard.c.

1036{
1037 HWND ret, win = param;
1038 BOOL r;
1039 MSG msg;
1040 HANDLE handle;
1042
1044 trace( "%s-threaded test\n", cross_thread ? "multi" : "single" );
1045
1047
1049 SetLastError(0xdeadbeef);
1051 ok(GetLastError() == 0xdeadbeef, "GetLastError = %d\n", GetLastError());
1053
1054 SetLastError( 0xdeadbeef );
1055 ret = SetClipboardViewer( (HWND)0xdead );
1056 ok( !ret, "SetClipboardViewer succeeded\n" );
1057 ok( GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "wrong error %u\n", GetLastError() );
1058 SetLastError( 0xdeadbeef );
1059 r = ChangeClipboardChain( win, (HWND)0xdead );
1060 ok( !r, "ChangeClipboardChain succeeded\n" );
1061 ok( GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "wrong error %u\n", GetLastError() );
1062 SetLastError( 0xdeadbeef );
1063 r = ChangeClipboardChain( (HWND)0xdead, next_wnd );
1064 ok( !r, "ChangeClipboardChain succeeded\n" );
1065 ok( GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "wrong error %u\n", GetLastError() );
1066
1067 if (pAddClipboardFormatListener)
1068 {
1069 r = pAddClipboardFormatListener(win);
1070 ok( r, "AddClipboardFormatListener failed err %d\n", GetLastError());
1071 SetLastError( 0xdeadbeef );
1072 r = pAddClipboardFormatListener( win );
1073 ok( !r, "AddClipboardFormatListener succeeded\n" );
1074 ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
1075 SetLastError( 0xdeadbeef );
1076 r = pAddClipboardFormatListener( (HWND)0xdead );
1077 ok( !r, "AddClipboardFormatListener succeeded\n" );
1078 ok( GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "wrong error %u\n", GetLastError() );
1079 r = pAddClipboardFormatListener( GetDesktopWindow() );
1080 ok( r, "AddClipboardFormatListener failed err %d\n", GetLastError());
1081 r = pRemoveClipboardFormatListener( GetDesktopWindow() );
1082 ok( r, "RemoveClipboardFormatListener failed err %d\n", GetLastError());
1083 }
1084
1085 check_messages(win, 0, 1, 0, 0, 0);
1086
1087 SetLastError( 0xdeadbeef );
1088 r = OpenClipboard( (HWND)0xdead );
1089 ok( !r, "OpenClipboard succeeded\n" );
1090 ok( GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "wrong error %u\n", GetLastError() );
1091
1092 r = OpenClipboard(win);
1093 ok(r, "OpenClipboard failed: %d\n", GetLastError());
1094
1095 check_messages(win, 0, 0, 0, 0, 0);
1096
1097 r = EmptyClipboard();
1098 ok(r, "EmptyClipboard failed: %d\n", GetLastError());
1099
1100 check_messages(win, 1, 0, 0, 0, 0);
1101
1102 r = EmptyClipboard();
1103 ok(r, "EmptyClipboard failed: %d\n", GetLastError());
1104 /* sequence changes again, even though it was already empty */
1105 check_messages(win, 1, 0, 0, 1, 0);
1106 count = SendMessageA( win, WM_USER+5, 0, 0 );
1107 ok( !count, "wrong format count %u on WM_DESTROYCLIPBOARD\n", count );
1108
1110 ok(handle != 0, "SetClipboardData failed: %d\n", GetLastError());
1111
1112 check_messages(win, 1, 0, 0, 0, 0);
1113
1115
1116 check_messages(win, 1, 0, 0, 0, 0);
1117
1118 SetClipboardData( CF_UNICODETEXT, 0 ); /* same data again */
1119
1120 check_messages(win, 1, 0, 0, 0, 0);
1121
1122 ok( IsClipboardFormatAvailable( CF_TEXT ), "CF_TEXT available\n" );
1123 ok( IsClipboardFormatAvailable( CF_UNICODETEXT ), "CF_UNICODETEXT available\n" );
1124 ok( !IsClipboardFormatAvailable( CF_OEMTEXT ), "CF_OEMTEXT available\n" );
1125
1127 r = CloseClipboard();
1128 ok(r, "CloseClipboard failed: %d\n", GetLastError());
1130
1131 check_messages(win, 2, 1, 1, 0, 0);
1132
1133 r = OpenClipboard(win);
1134 ok(r, "OpenClipboard failed: %d\n", GetLastError());
1135
1136 check_messages(win, 0, 0, 0, 0, 0);
1137
1138 ok( IsClipboardFormatAvailable( CF_TEXT ), "CF_TEXT available\n" );
1139 ok( IsClipboardFormatAvailable( CF_UNICODETEXT ), "CF_UNICODETEXT available\n" );
1140 ok( IsClipboardFormatAvailable( CF_OEMTEXT ), "CF_OEMTEXT available\n" );
1141
1142 ok( GetClipboardOwner() == win, "wrong owner %p\n", GetClipboardOwner());
1144 ok( !handle, "got data for CF_UNICODETEXT\n" );
1145 fmt = SendMessageA( win, WM_USER+4, 0, 0 );
1146 ok( fmt == CF_UNICODETEXT, "WM_RENDERFORMAT received %04x\n", fmt );
1147
1150 ok( handle != NULL, "didn't get data for CF_OEMTEXT\n" );
1151 fmt = SendMessageA( win, WM_USER+4, 0, 0 );
1152 ok( fmt == CF_UNICODETEXT, "WM_RENDERFORMAT received %04x\n", fmt );
1154
1156 check_messages(win, 1, 0, 0, 0, 0);
1157
1158 r = CloseClipboard();
1159 ok(r, "CloseClipboard failed: %d\n", GetLastError());
1160 /* no synthesized format, so CloseClipboard doesn't change the sequence */
1161 check_messages(win, 0, 1, 1, 0, 0);
1162
1163 r = OpenClipboard(win);
1164 ok(r, "OpenClipboard failed: %d\n", GetLastError());
1165 r = CloseClipboard();
1166 ok(r, "CloseClipboard failed: %d\n", GetLastError());
1167 /* nothing changed */
1168 check_messages(win, 0, 0, 0, 0, 0);
1169
1171 r = OpenClipboard(0);
1172 ok(r, "OpenClipboard failed: %d\n", GetLastError());
1173 r = EmptyClipboard();
1174 ok(r, "EmptyClipboard failed: %d\n", GetLastError());
1175 r = CloseClipboard();
1176 ok(r, "CloseClipboard failed: %d\n", GetLastError());
1177
1178 check_messages(win, 1, 1, 1, 1, 0);
1179 count = SendMessageA( win, WM_USER+5, 0, 0 );
1180 ok( count == formats, "wrong format count %u on WM_DESTROYCLIPBOARD\n", count );
1181
1182 r = OpenClipboard(win);
1183 ok(r, "OpenClipboard failed: %d\n", GetLastError());
1185 check_messages(win, 1, 0, 0, 0, 0);
1186
1188 r = CloseClipboard();
1189 ok(r, "CloseClipboard failed: %d\n", GetLastError());
1191
1192 check_messages(win, 0, 1, 1, 0, 0);
1193
1194 run_process( "grab_clipboard 0" );
1195
1196 if (!cross_thread)
1197 {
1198 /* in this case we get a cross-thread WM_DRAWCLIPBOARD */
1200 while (PeekMessageW( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageW( &msg );
1202 }
1203 check_messages(win, 1, 1, 1, 0, 0);
1204
1205 r = OpenClipboard(0);
1206 ok(r, "OpenClipboard failed: %d\n", GetLastError());
1208 check_messages(win, 1, 0, 0, 0, 0);
1209
1211 r = CloseClipboard();
1212 ok(r, "CloseClipboard failed: %d\n", GetLastError());
1214
1215 check_messages(win, 0, 1, 1, 0, 0);
1216
1217 run_process( "grab_clipboard 1" );
1218
1219 if (!cross_thread)
1220 {
1221 /* in this case we get a cross-thread WM_DRAWCLIPBOARD */
1223 while (PeekMessageW( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageW( &msg );
1225 }
1226 check_messages(win, 2, 1, 1, 0, 0);
1227
1228 r = OpenClipboard(0);
1229 ok(r, "OpenClipboard failed: %d\n", GetLastError());
1231 check_messages(win, 1, 0, 0, 0, 0);
1232
1234 r = CloseClipboard();
1235 ok(r, "CloseClipboard failed: %d\n", GetLastError());
1237
1238 check_messages(win, 0, 1, 1, 0, 0);
1239
1240 if (cross_thread)
1241 {
1242 r = OpenClipboard( win );
1243 ok(r, "OpenClipboard failed: %d\n", GetLastError());
1244 r = EmptyClipboard();
1245 ok(r, "EmptyClipboard failed: %d\n", GetLastError());
1247 r = CloseClipboard();
1248 ok(r, "CloseClipboard failed: %d\n", GetLastError());
1249
1252 run_process( "get_clipboard_data" );
1254
1255 check_messages(win, 0, 1, 1, 0, CF_TEXT);
1256 }
1257
1258 r = PostMessageA(win, WM_USER, 0, 0);
1259 ok(r, "PostMessage failed: %d\n", GetLastError());
1260
1261 if (pRemoveClipboardFormatListener)
1262 {
1263 r = pRemoveClipboardFormatListener(win);
1264 ok( r, "RemoveClipboardFormatListener failed err %d\n", GetLastError());
1265 SetLastError( 0xdeadbeef );
1266 r = pRemoveClipboardFormatListener(win);
1267 ok( !r, "RemoveClipboardFormatListener succeeded\n" );
1268 ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
1269 SetLastError( 0xdeadbeef );
1270 r = pRemoveClipboardFormatListener( (HWND)0xdead );
1271 ok( !r, "RemoveClipboardFormatListener succeeded\n" );
1272 ok( GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "wrong error %u\n", GetLastError() );
1273 }
1274 return 0;
1275}
#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
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:901
#define check_messages(a, b, c, d, e, f)
Definition: clipboard.c:1033
static CRITICAL_SECTION clipboard_cs
Definition: clipboard.c:893
static HGLOBAL create_textA(void)
Definition: clipboard.c:489
static void run_process(const char *args)
Definition: clipboard.c:166
int ret
DWORD WINAPI GetCurrentThreadId(void)
Definition: thread.c:459
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define GMEM_FIXED
Definition: winbase.h:293
DWORD WINAPI GetWindowThreadProcessId(HWND hWnd, PDWORD lpdwProcessId)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define ERROR_INVALID_WINDOW_HANDLE
Definition: winerror.h:881
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:656
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 904 of file clipboard.c.

905{
906 LRESULT ret;
907 DWORD msg_flags = InSendMessageEx( NULL );
908
909 switch(msg) {
910 case WM_DRAWCLIPBOARD:
911 ok( msg_flags == (cross_thread ? ISMEX_NOTIFY : ISMEX_NOSEND),
912 "WM_DRAWCLIPBOARD wrong flags %x\n", msg_flags );
916 break;
917 case WM_CHANGECBCHAIN:
918 ok( msg_flags == (cross_thread ? ISMEX_SEND : ISMEX_NOSEND),
919 "WM_CHANGECBCHAIN wrong flags %x\n", msg_flags );
920 if (next_wnd == (HWND)wp)
921 next_wnd = (HWND)lp;
922 else if (next_wnd)
923 SendMessageA(next_wnd, msg, wp, lp);
924 break;
926 ok( msg_flags == (cross_thread ? ISMEX_SEND : ISMEX_NOSEND),
927 "WM_DESTROYCLIPBOARD wrong flags %x\n", msg_flags );
929 ok( GetClipboardOwner() == hwnd, "WM_DESTROYCLIPBOARD owner %p\n", GetClipboardOwner() );
931 break;
932 case WM_RENDERFORMAT:
933 ok( !wm_renderformat, "multiple WM_RENDERFORMAT %04x / %04lx\n", wm_renderformat, wp );
934 wm_renderformat = wp;
935
937 {
938 UINT seq, old_seq;
940
943 ok( handle != 0, "SetClipboardData failed: %d\n", GetLastError() );
945 ok( seq == old_seq, "sequence changed\n" );
946 old_seq = seq;
947
949 ok( handle != NULL, "CreateThread failed: %d\n", GetLastError() );
950 ok( WaitForSingleObject(handle, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n" );
953 ok( seq == old_seq, "sequence changed\n" );
954 }
955
956 break;
957 case WM_CLIPBOARDUPDATE:
958 ok( msg_flags == ISMEX_NOSEND, "WM_CLIPBOARDUPDATE wrong flags %x\n", msg_flags );
963 break;
964 case WM_USER:
967 break;
968 case WM_USER+1:
971 return ret;
972 case WM_USER+2:
975 return ret;
976 case WM_USER+3:
979 return ret;
980 case WM_USER+4:
982 wm_renderformat = 0;
983 return ret;
984 case WM_USER+5:
985 return nb_formats;
986 }
987
988 return DefWindowProcA(hwnd, msg, wp, lp);
989}
#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
static UINT wm_drawclipboard
Definition: clipboard.c:1036
static UINT wm_renderformat
Definition: clipboard.c:898
static UINT wm_destroyclipboard
Definition: clipboard.c:897
static DWORD WINAPI clipboard_render_data_thread(void *param)
Definition: clipboard.c:886
static UINT nb_formats
Definition: clipboard.c:899
static UINT wm_clipboardupdate
Definition: clipboard.c:896
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
LONG_PTR LRESULT
Definition: windef.h:209
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_DESTROYCLIPBOARD
Definition: winuser.h:1858
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define WM_DRAWCLIPBOARD
Definition: winuser.h:1859
#define WM_CHANGECBCHAIN
Definition: winuser.h:1864
#define WM_RENDERFORMAT
Definition: winuser.h:1856

◆ create_bitmap()

static HBITMAP create_bitmap ( void  )
static

Definition at line 534 of file clipboard.c.

535{
536 HDC hdc = GetDC( 0 );
538 ReleaseDC( 0, hdc );
539 return CreateBitmap( 10, 10, 1, bpp, NULL );
540}
DWORD bpp
Definition: surface.c:185
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:92
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 542 of file clipboard.c.

543{
544 HANDLE ret;
546
548 sizeof(BITMAPV5HEADER) + 256 * sizeof(RGBQUAD) + 16 * 16 * 4 );
549 hdr = GlobalLock( ret );
550 hdr->biSize = v5 ? sizeof(BITMAPV5HEADER) : sizeof(*hdr);
551 hdr->biWidth = 16;
552 hdr->biHeight = 16;
553 hdr->biPlanes = 1;
554 hdr->biBitCount = 32;
555 hdr->biCompression = BI_RGB;
556 if (v5)
557 {
558 BITMAPV5HEADER *hdr5 = (BITMAPV5HEADER *)hdr;
559 hdr5->bV5RedMask = 0x0000ff;
560 hdr5->bV5GreenMask = 0x00ff00;
561 hdr5->bV5BlueMask = 0xff0000;
562 hdr5->bV5AlphaMask = 0xff000000;
563 }
564 GlobalUnlock( ret );
565 return ret;
566}
#define BI_RGB
Definition: precomp.h:47
ULONG RGBQUAD
Definition: precomp.h:50
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
char hdr[14]
Definition: iptest.cpp:33
#define GMEM_ZEROINIT
Definition: winbase.h:306
#define GMEM_MOVEABLE
Definition: winbase.h:294
#define GMEM_DDESHARE
Definition: winbase.h:298

Referenced by test_synthesized().

◆ create_emf()

static HENHMETAFILE create_emf ( void  )
static

Definition at line 526 of file clipboard.c.

527{
528 const RECT rect = {0, 0, 100, 100};
529 HDC hdc = CreateEnhMetaFileA(NULL, NULL, &rect, "HENHMETAFILE Ole Clipboard Test\0Test\0\0");
530 ExtTextOutA(hdc, 0, 0, ETO_OPAQUE, &rect, "Test String", strlen("Test String"), NULL);
531 return CloseEnhMetaFile(hdc);
532}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
& rect
Definition: startmenu.cpp:1413
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 508 of file clipboard.c.

509{
510 const RECT rect = {0, 0, 100, 100};
511 METAFILEPICT *pict;
512 HANDLE ret;
513 HMETAFILE mf;
515 ExtTextOutA( hdc, 0, 0, ETO_OPAQUE, &rect, "Test String", strlen("Test String"), NULL );
516 mf = CloseMetaFile( hdc );
517 ret = GlobalAlloc( GMEM_DDESHARE | GMEM_MOVEABLE, sizeof(*pict) );
518 pict = GlobalLock( ret );
519 pict->mm = MM_TEXT;
520 pict->xExt = pict->yExt = 100;
521 pict->hMF = mf;
522 GlobalUnlock( ret );
523 return ret;
524}
HMETAFILE hMF
Definition: wingdi.h:2608
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 489 of file clipboard.c.

490{
492 char *p = GlobalLock(h);
493 memcpy(p, "test\0\0\0\0\0", 10);
495 return h;
496}
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 498 of file clipboard.c.

499{
500 static const WCHAR testW[] = {'t','e','s','t',0,0,0,0,0,0};
502 WCHAR *p = GlobalLock(h);
503 memcpy(p, testW, sizeof(testW));
505 return h;
506}
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 47 of file clipboard.c.

48{
49 SetLastError( 0xdeadbeef );
50 ok(!EmptyClipboard(), "%u: EmptyClipboard succeeded\n", thread_from_line );
51 ok( GetLastError() == ERROR_CLIPBOARD_NOT_OPEN, "%u: wrong error %u\n",
53 return 0;
54}
static int thread_from_line
Definition: clipboard.c:37
#define ERROR_CLIPBOARD_NOT_OPEN
Definition: winerror.h:899

Referenced by test_ClipboardOwner().

◆ get_clipboard_data_process()

static void get_clipboard_data_process ( void  )
static

Definition at line 991 of file clipboard.c.

992{
993 HANDLE data;
994 BOOL r;
995
996 r = OpenClipboard(0);
997 ok(r, "OpenClipboard failed: %d\n", GetLastError());
999 ok( data != NULL, "GetClipboardData failed: %d\n", GetLastError());
1000 r = CloseClipboard();
1001 ok(r, "CloseClipboard failed: %d\n", GetLastError());
1002}
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 128 of file clipboard.c.

129{
130 BOOL ret;
131
132 SetLastError( 0xdeadbeef );
133 ret = OpenClipboard( 0 );
134 ok( ret, "OpenClipboard failed\n" );
136 ok( ret, "EmptyClipboard failed\n" );
137 if (arg)
138 {
140 ok( ret != 0, "process %u: SetClipboardData failed err %u\n", arg, GetLastError() );
141 }
142}

Referenced by START_TEST().

◆ is_fixed()

static BOOL is_fixed ( HANDLE  handle)
static

Definition at line 1331 of file clipboard.c.

1332{
1333 void *ptr = GlobalLock( handle );
1334 if (ptr) GlobalUnlock( handle );
1335 return ptr && ptr == handle;
1336}
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 1338 of file clipboard.c.

1339{
1340 return !GlobalSize( handle );
1341}
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 1324 of file clipboard.c.

1325{
1326 void *ptr = GlobalLock( handle );
1327 if (ptr) GlobalUnlock( handle );
1328 return ptr && ptr != handle;
1329}

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 56 of file clipboard.c.

57{
58 HWND hWnd = arg;
59 ok(OpenClipboard(hWnd), "%u: OpenClipboard failed\n", thread_from_line);
60 ok(EmptyClipboard(), "%u: EmptyClipboard failed\n", thread_from_line );
61 return 0;
62}
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 64 of file clipboard.c.

65{
66 HWND hwnd = CreateWindowA( "static", NULL, WS_POPUP, 0, 0, 10, 10, 0, 0, 0, NULL );
67 ok(OpenClipboard(hwnd), "%u: OpenClipboard failed\n", thread_from_line);
68 ok(EmptyClipboard(), "%u: EmptyClipboard failed\n", thread_from_line );
69 return 0;
70}
#define WS_POPUP
Definition: pedump.c:616
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4305

Referenced by test_ClipboardOwner().

◆ open_clipboard_thread()

static DWORD WINAPI open_clipboard_thread ( LPVOID  arg)
static

Definition at line 40 of file clipboard.c.

41{
42 HWND hWnd = arg;
43 ok(OpenClipboard(hWnd), "%u: OpenClipboard failed\n", thread_from_line);
44 return 0;
45}

Referenced by test_ClipboardOwner().

◆ renderer_winproc()

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

Definition at line 568 of file clipboard.c.

569{
570 static UINT rendered;
571 UINT ret;
572
573 switch (msg)
574 {
575 case WM_RENDERFORMAT:
576 if (wp < 32) rendered |= (1 << wp);
577 break;
578 case WM_USER:
579 ret = rendered;
580 rendered = 0;
581 return ret;
582 }
583 return DefWindowProcA( hwnd, msg, wp, lp );
584}

Referenced by test_synthesized().

◆ run_process()

static void run_process ( const char args)
static

Definition at line 166 of file clipboard.c.

167{
168 char cmd[MAX_PATH];
171
172 sprintf( cmd, "%s clipboard %s", argv0, args );
173 memset( &startup, 0, sizeof(startup) );
174 startup.cb = sizeof(startup);
176 "CreateProcess %s failed\n", cmd );
177
179 CloseHandle( info.hProcess );
180 CloseHandle( info.hThread );
181}
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:4742
#define sprintf(buf, format,...)
Definition: sprintf.c:55
static char * argv0
Definition: clipboard.c:38
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 144 of file clipboard.c.

145{
146 DWORD ret;
148
150 thread = CreateThread(NULL, 0, func, arg, 0, NULL);
151 ok(thread != NULL, "%u: CreateThread failed with error %d\n", line, GetLastError());
152 for (;;)
153 {
155 if (ret == WAIT_OBJECT_0 + 1)
156 {
157 MSG msg;
158 while (PeekMessageW( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageW( &msg );
159 }
160 else break;
161 }
162 ok(ret == WAIT_OBJECT_0, "%u: expected WAIT_OBJECT_0, got %u\n", line, ret);
164}
static HANDLE thread
Definition: service.c:33
GLenum func
Definition: glext.h:6028
#define QS_ALLINPUT
Definition: winuser.h:897
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 104 of file clipboard.c.

105{
106 HANDLE ret;
107
108 SetLastError( 0xdeadbeef );
109 if (arg)
110 {
111 ok( IsClipboardFormatAvailable( CF_WAVE ), "process %u: CF_WAVE not available\n", arg );
113 ok( ret != 0, "process %u: SetClipboardData failed err %u\n", arg, GetLastError() );
114 }
115 else
116 {
118 ok( GetLastError() == ERROR_CLIPBOARD_NOT_OPEN, "process %u: wrong error %u\n",
119 arg, GetLastError());
120 ok( !IsClipboardFormatAvailable( CF_WAVE ), "process %u: SetClipboardData succeeded\n", arg );
122 ok( !ret, "process %u: SetClipboardData succeeded\n", arg );
123 ok( GetLastError() == ERROR_CLIPBOARD_NOT_OPEN, "process %u: wrong error %u\n",
124 arg, GetLastError());
125 }
126}

Referenced by START_TEST().

◆ set_clipboard_data_thread()

static DWORD WINAPI set_clipboard_data_thread ( LPVOID  arg)
static

Definition at line 72 of file clipboard.c.

73{
74 HWND hwnd = arg;
75 HANDLE ret;
76
77 SetLastError( 0xdeadbeef );
78 if (GetClipboardOwner() == hwnd)
79 {
81 ok( IsClipboardFormatAvailable( CF_WAVE ), "%u: SetClipboardData failed\n", thread_from_line );
83 ok( ret != 0, "%u: SetClipboardData failed err %u\n", thread_from_line, GetLastError() );
84 SetLastError( 0xdeadbeef );
86 ok( !ret, "%u: GetClipboardData succeeded\n", thread_from_line );
87 ok( GetLastError() == ERROR_CLIPBOARD_NOT_OPEN, "%u: wrong error %u\n",
89 }
90 else
91 {
93 ok( GetLastError() == ERROR_CLIPBOARD_NOT_OPEN, "%u: wrong error %u\n",
95 ok( !IsClipboardFormatAvailable( CF_WAVE ), "%u: SetClipboardData succeeded\n", thread_from_line );
97 ok( !ret, "%u: SetClipboardData succeeded\n", thread_from_line );
98 ok( GetLastError() == ERROR_CLIPBOARD_NOT_OPEN, "%u: wrong error %u\n",
100 }
101 return 0;
102}

Referenced by test_ClipboardOwner().

◆ START_TEST()

START_TEST ( clipboard  )

Definition at line 2150 of file clipboard.c.

2151{
2152 char **argv;
2154 HMODULE mod = GetModuleHandleA( "user32" );
2155
2156 argv0 = argv[0];
2157 pAddClipboardFormatListener = (void *)GetProcAddress( mod, "AddClipboardFormatListener" );
2158 pRemoveClipboardFormatListener = (void *)GetProcAddress( mod, "RemoveClipboardFormatListener" );
2159 pGetUpdatedClipboardFormats = (void *)GetProcAddress( mod, "GetUpdatedClipboardFormats" );
2160
2161 if (argc == 4 && !strcmp( argv[2], "set_clipboard_data" ))
2162 {
2164 return;
2165 }
2166 if (argc == 4 && !strcmp( argv[2], "grab_clipboard" ))
2167 {
2169 return;
2170 }
2171 if (argc == 4 && !strcmp( argv[2], "handles" ))
2172 {
2174 return;
2175 }
2176 if (argc == 4 && !strcmp( argv[2], "handles_open" ))
2177 {
2179 return;
2180 }
2181 if (argc == 4 && !strcmp( argv[2], "handles_dib" ))
2182 {
2184 return;
2185 }
2186 if (argc == 4 && !strcmp( argv[2], "string_data" ))
2187 {
2189 return;
2190 }
2191 if (argc == 3 && !strcmp( argv[2], "get_clipboard_data" ))
2192 {
2194 return;
2195 }
2196
2200 test_messages();
2204}
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 int mod
Definition: i386-dis.c:1289
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
static void test_string_data_process(int i)
Definition: clipboard.c:2093
static void test_messages(void)
Definition: clipboard.c:1277
static void test_ClipboardOwner(void)
Definition: clipboard.c:226
static void test_data_handles(void)
Definition: clipboard.c:1792
static void test_handles_process(const char *str)
Definition: clipboard.c:1678
static void test_GetUpdatedClipboardFormats(void)
Definition: clipboard.c:1916
static void test_handles_process_open(const char *str)
Definition: clipboard.c:1764
static void test_string_data(void)
Definition: clipboard.c:2048
static void test_RegisterClipboardFormatA(void)
Definition: clipboard.c:373
static void get_clipboard_data_process(void)
Definition: clipboard.c:991
static void set_clipboard_data_process(int arg)
Definition: clipboard.c:104
static void grab_clipboard_process(int arg)
Definition: clipboard.c:128
static void test_synthesized(void)
Definition: clipboard.c:586
static void test_handles_process_dib(const char *str)
Definition: clipboard.c:1778
#define argv
Definition: mplay32.c:18
int winetest_get_mainargs(char ***pargv)

◆ test_ClipboardOwner()

static void test_ClipboardOwner ( void  )
static

Definition at line 226 of file clipboard.c.

227{
229 BOOL ret;
230
231 SetLastError(0xdeadbeef);
232 ok(!GetClipboardOwner() && GetLastError() == 0xdeadbeef,
233 "could not perform clipboard test: clipboard already owned\n");
234
235 hWnd1 = CreateWindowExA(0, "static", NULL, WS_POPUP,
236 0, 0, 10, 10, 0, 0, 0, NULL);
237 ok(hWnd1 != 0, "CreateWindowExA error %d\n", GetLastError());
238 trace("hWnd1 = %p\n", hWnd1);
239
240 hWnd2 = CreateWindowExA(0, "static", NULL, WS_POPUP,
241 0, 0, 10, 10, 0, 0, 0, NULL);
242 ok(hWnd2 != 0, "CreateWindowExA error %d\n", GetLastError());
243 trace("hWnd2 = %p\n", hWnd2);
244
245 SetLastError(0xdeadbeef);
246 ok(!CloseClipboard(), "CloseClipboard should fail if clipboard wasn't open\n");
247 ok(GetLastError() == ERROR_CLIPBOARD_NOT_OPEN || broken(GetLastError() == 0xdeadbeef), /* wow64 */
248 "wrong error %u\n", GetLastError());
249
250 ok(OpenClipboard(0), "OpenClipboard failed\n");
251 ok(!GetClipboardOwner(), "clipboard should still be not owned\n");
252 ok(!OpenClipboard(hWnd1), "OpenClipboard should fail since clipboard already opened\n");
253 ok(OpenClipboard(0), "OpenClipboard again failed\n");
255 ok( ret, "CloseClipboard error %d\n", GetLastError());
256
257 ok(OpenClipboard(hWnd1), "OpenClipboard failed\n");
259 run_thread( empty_clipboard_thread, 0, __LINE__ );
261 ok( !IsClipboardFormatAvailable( CF_WAVE ), "CF_WAVE available\n" );
262 ok( !GetClipboardData( CF_WAVE ), "CF_WAVE data available\n" );
263 run_process( "set_clipboard_data 0" );
264 ok(!CloseClipboard(), "CloseClipboard should fail if clipboard wasn't open\n");
265 ok(OpenClipboard(hWnd1), "OpenClipboard failed\n");
266
267 SetLastError(0xdeadbeef);
269 ok(!ret && (GetLastError() == 0xdeadbeef || GetLastError() == ERROR_ACCESS_DENIED),
270 "OpenClipboard should fail without setting last error value, or with ERROR_ACCESS_DENIED, got error %d\n", GetLastError());
271
272 SetLastError(0xdeadbeef);
273 ok(!GetClipboardOwner() && GetLastError() == 0xdeadbeef, "clipboard should still be not owned\n");
275 ok( ret, "EmptyClipboard error %d\n", GetLastError());
276 ok(GetClipboardOwner() == hWnd1, "clipboard should be owned by %p, not by %p\n", hWnd1, GetClipboardOwner());
277 run_thread( empty_clipboard_thread, 0, __LINE__ );
279 ok( IsClipboardFormatAvailable( CF_WAVE ), "CF_WAVE not available\n" );
280 ok( GetClipboardData( CF_WAVE ) != 0, "CF_WAVE data not available\n" );
281 run_process( "set_clipboard_data 1" );
282
283 SetLastError(0xdeadbeef);
285 ok(!ret && (GetLastError() == 0xdeadbeef || GetLastError() == ERROR_ACCESS_DENIED),
286 "OpenClipboard should fail without setting last error value, or with ERROR_ACCESS_DENIED, got error %d\n", GetLastError());
287
289 ok( ret, "CloseClipboard error %d\n", GetLastError());
290 ok(GetClipboardOwner() == hWnd1, "clipboard should still be owned\n");
291
292 /* any window will do, even from a different process */
294 ok( ret, "OpenClipboard error %d\n", GetLastError());
296 ok( ret, "EmptyClipboard error %d\n", GetLastError());
297 ok( GetClipboardOwner() == GetDesktopWindow(), "wrong owner %p/%p\n",
300 ok( IsClipboardFormatAvailable( CF_WAVE ), "CF_WAVE not available\n" );
301 ok( GetClipboardData( CF_WAVE ) != 0, "CF_WAVE data not available\n" );
302 run_process( "set_clipboard_data 2" );
304 ok( ret, "CloseClipboard error %d\n", GetLastError());
305
307 ok( ret, "OpenClipboard error %d\n", GetLastError());
309 ok( ret, "EmptyClipboard error %d\n", GetLastError());
312 ok( GetClipboardOwner() == hWnd1, "wrong owner %p/%p\n", GetClipboardOwner(), hWnd1 );
313 ok( GetClipboardViewer() == hWnd1, "wrong viewer %p/%p\n", GetClipboardViewer(), hWnd1 );
314 ok( GetOpenClipboardWindow() == hWnd1, "wrong open win %p/%p\n", GetOpenClipboardWindow(), hWnd1 );
315 ok( IsClipboardFormatAvailable( CF_WAVE ), "CF_WAVE not available\n" );
316
319 ok( ret, "DestroyWindow error %d\n", GetLastError());
321 ok( ret, "DestroyWindow error %d\n", GetLastError());
322 SetLastError(0xdeadbeef);
323 ok(!GetClipboardOwner() && GetLastError() == 0xdeadbeef, "clipboard should not be owned\n");
324 ok(!GetClipboardViewer() && GetLastError() == 0xdeadbeef, "viewer still exists\n");
325 ok(!GetOpenClipboardWindow() && GetLastError() == 0xdeadbeef, "clipboard should not be open\n");
326 ok( !IsClipboardFormatAvailable( CF_WAVE ), "CF_WAVE available\n" );
327
328 SetLastError( 0xdeadbeef );
330 ok( !ret, "CloseClipboard succeeded\n" );
331 ok( GetLastError() == ERROR_CLIPBOARD_NOT_OPEN, "wrong error %u\n", GetLastError() );
332
333 ret = OpenClipboard( 0 );
334 ok( ret, "OpenClipboard error %d\n", GetLastError());
336 ok( IsClipboardFormatAvailable( CF_WAVE ), "CF_WAVE not available\n" );
337 ok( GetClipboardData( CF_WAVE ) != 0, "CF_WAVE data not available\n" );
338 run_process( "set_clipboard_data 3" );
340 ok( ret, "CloseClipboard error %d\n", GetLastError());
341
343 ok( !GetOpenClipboardWindow(), "wrong open window %p\n", GetOpenClipboardWindow() );
344 ok( !GetClipboardOwner(), "wrong owner window %p\n", GetClipboardOwner() );
345
346 ret = OpenClipboard( 0 );
347 ok( ret, "OpenClipboard error %d\n", GetLastError());
349 ok( IsClipboardFormatAvailable( CF_WAVE ), "CF_WAVE not available\n" );
350 ok( GetClipboardData( CF_WAVE ) != 0, "CF_WAVE data not available\n" );
351 run_process( "set_clipboard_data 4" );
353 ok( ret, "EmptyClipboard error %d\n", GetLastError());
355 ok( ret, "CloseClipboard error %d\n", GetLastError());
356
357 SetLastError( 0xdeadbeef );
359 "SetClipboardData succeeded\n" );
360 ok( GetLastError() == ERROR_CLIPBOARD_NOT_OPEN, "wrong error %u\n", GetLastError() );
361 ok( !IsClipboardFormatAvailable( CF_WAVE ), "SetClipboardData succeeded\n" );
362
364 ok( !GetOpenClipboardWindow(), "wrong open window %p\n", GetOpenClipboardWindow() );
365 ok( GetClipboardOwner() == GetDesktopWindow(), "wrong owner window %p / %p\n",
367
369 ok( !GetOpenClipboardWindow(), "wrong open window %p\n", GetOpenClipboardWindow() );
370 ok( !GetClipboardOwner(), "wrong owner window %p\n", GetClipboardOwner() );
371}
#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:56
static DWORD WINAPI set_clipboard_data_thread(LPVOID arg)
Definition: clipboard.c:72
static DWORD WINAPI open_clipboard_thread(LPVOID arg)
Definition: clipboard.c:40
static DWORD WINAPI open_and_empty_clipboard_win_thread(LPVOID arg)
Definition: clipboard.c:64
static LRESULT CALLBACK winproc_wrapper(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
Definition: clipboard.c:184
static WNDPROC old_proc
Definition: clipboard.c:183
static DWORD WINAPI empty_clipboard_thread(LPVOID arg)
Definition: clipboard.c:47
static void run_thread(LPTHREAD_START_ROUTINE func, void *arg, int line)
Definition: clipboard.c:144
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define GWLP_WNDPROC
Definition: treelist.c:66
#define SetWindowLongPtrA
Definition: winuser.h:5335
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:2896
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 1792 of file clipboard.c.

1793{
1794 BOOL r;
1795 char *ptr;
1796 HANDLE h, text;
1797 HWND hwnd = CreateWindowA( "static", NULL, WS_POPUP, 0, 0, 10, 10, 0, 0, 0, NULL );
1798 BITMAPINFO bmi;
1799 void *bits;
1800
1801 ok( hwnd != 0, "window creation failed\n" );
1802 format_id = RegisterClipboardFormatA( "my_cool_clipboard_format" );
1803 test_handles( 0 );
1805 test_handles( hwnd );
1806 run_thread( test_handles_thread, hwnd, __LINE__ );
1807
1808 bitmap = CreateBitmap( 13, 17, 1, 1, NULL );
1809 bitmap2 = CreateBitmap( 10, 10, 1, 1, NULL );
1811
1812 r = OpenClipboard( hwnd );
1813 ok( r, "gle %d\n", GetLastError() );
1814 r = EmptyClipboard();
1815 ok( r, "gle %d\n", GetLastError() );
1817 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1819 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1821 ok( GetObjectType( h ) == OBJ_BITMAP, "expected bitmap %p\n", h );
1823 ok( GetObjectType( h ) == OBJ_BITMAP, "expected bitmap %p\n", h );
1825 ok( GetObjectType( h ) == OBJ_PAL, "expected palette %p\n", h );
1827 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1828 trace( "metafile %p\n", h );
1830 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1831 trace( "metafile2 %p\n", h );
1833 ok( GetObjectType( h ) == OBJ_ENHMETAFILE, "expected enhmetafile %p\n", h );
1834 trace( "enhmetafile %p\n", h );
1836 ok( GetObjectType( h ) == OBJ_ENHMETAFILE, "expected enhmetafile %p\n", h );
1837 trace( "enhmetafile2 %p\n", h );
1839 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1841 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1842 r = CloseClipboard();
1843 ok( r, "gle %d\n", GetLastError() );
1844
1845 run_thread( test_handles_thread2, 0, __LINE__ );
1846 run_process( "handles test" );
1847
1848 r = OpenClipboard( hwnd );
1849 ok( r, "gle %d\n", GetLastError() );
1851 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1853 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1855 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1857 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1858
1859 r = EmptyClipboard();
1860 ok( r, "gle %d\n", GetLastError() );
1861 text = create_textA();
1863 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1864
1865 run_process( "handles_open foobar" );
1866
1867 ok( is_moveable( text ), "expected moveable mem %p\n", text );
1869 ok( is_fixed( h ), "expected fixed mem %p\n", h );
1870 ok( is_moveable( text ), "expected moveable mem %p\n", text );
1871 ptr = GlobalLock( h );
1872 ok( !strcmp( ptr, "foobar" ), "wrong data '%.8s'\n", ptr );
1873 GlobalUnlock( h );
1874
1875 r = EmptyClipboard();
1876 ok( r, "gle %d\n", GetLastError() );
1877 ok( is_fixed( h ), "expected free mem %p\n", h );
1878 ok( is_freed( text ) || broken( is_moveable(text) ), /* w2003, w2008 */
1879 "expected free mem %p\n", text );
1880 r = CloseClipboard();
1881 ok( r, "gle %d\n", GetLastError() );
1882
1883 /* test CF_BITMAP with a DIB section */
1884 memset( &bmi, 0, sizeof(bmi) );
1885 bmi.bmiHeader.biSize = sizeof( bmi.bmiHeader );
1886 bmi.bmiHeader.biWidth = 29;
1887 bmi.bmiHeader.biHeight = 13;
1888 bmi.bmiHeader.biPlanes = 1;
1889 bmi.bmiHeader.biBitCount = 32;
1890 bitmap = CreateDIBSection( 0, &bmi, DIB_RGB_COLORS, &bits, 0, 0 );
1891
1892 r = OpenClipboard( hwnd );
1893 ok( r, "gle %d\n", GetLastError() );
1894 r = EmptyClipboard();
1895 ok( r, "gle %d\n", GetLastError() );
1897 ok( GetObjectType( h ) == OBJ_BITMAP, "expected bitmap %p\n", h );
1898 trace( "dibsection %p\n", h );
1899 r = CloseClipboard();
1900 ok( r, "gle %d\n", GetLastError() );
1901
1902 run_process( "handles_dib dummy" );
1903
1904 r = OpenClipboard( hwnd );
1905 ok( r, "gle %d\n", GetLastError() );
1906 ok( GetObjectType( bitmap ) == OBJ_BITMAP, "expected bitmap %p\n", bitmap );
1907 r = EmptyClipboard();
1908 ok( r, "gle %d\n", GetLastError() );
1909 ok( !GetObjectType( bitmap ), "expected deleted %p\n", bitmap );
1910 r = CloseClipboard();
1911 ok( r, "gle %d\n", GetLastError() );
1912
1914}
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:1799
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:1331
static BOOL is_freed(HANDLE handle)
Definition: clipboard.c:1338
static DWORD WINAPI test_handles_thread2(void *arg)
Definition: clipboard.c:1627
static DWORD WINAPI test_handles_thread(void *arg)
Definition: clipboard.c:1620
static HPALETTE palette
Definition: clipboard.c:1345
static const LOGPALETTE logpalette
Definition: clipboard.c:1346
static UINT format_id
Definition: clipboard.c:1343
static HBITMAP bitmap2
Definition: clipboard.c:1344
static HANDLE create_metafile(void)
Definition: clipboard.c:508
static BOOL is_moveable(HANDLE handle)
Definition: clipboard.c:1324
#define OBJ_BITMAP
Definition: objidl.idl:1415
#define OBJ_PAL
Definition: objidl.idl:1413
#define OBJ_ENHMETAFILE
Definition: objidl.idl:1421
Definition: uimain.c:89
USHORT biBitCount
Definition: precomp.h:37
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1476
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:199
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 1916 of file clipboard.c.

1917{
1918 BOOL r;
1919 UINT count, formats[256];
1920
1921 if (!pGetUpdatedClipboardFormats)
1922 {
1923 win_skip( "GetUpdatedClipboardFormats not supported\n" );
1924 return;
1925 }
1926
1927 count = 0xdeadbeef;
1928 r = pGetUpdatedClipboardFormats( NULL, 0, &count );
1929 ok( r, "gle %d\n", GetLastError() );
1930 ok( !count, "wrong count %u\n", count );
1931
1932 count = 0xdeadbeef;
1933 r = pGetUpdatedClipboardFormats( NULL, 256, &count );
1934 ok( r, "gle %d\n", GetLastError() );
1935 ok( !count, "wrong count %u\n", count );
1936
1937 SetLastError( 0xdeadbeef );
1938 r = pGetUpdatedClipboardFormats( formats, 256, NULL );
1939 ok( !r, "succeeded\n" );
1940 ok( GetLastError() == ERROR_NOACCESS, "wrong error %u\n", GetLastError() );
1941
1942 count = 0xdeadbeef;
1943 r = pGetUpdatedClipboardFormats( formats, 256, &count );
1944 ok( r, "gle %d\n", GetLastError() );
1945 ok( !count, "wrong count %u\n", count );
1946
1947 r = OpenClipboard( 0 );
1948 ok( r, "gle %d\n", GetLastError() );
1949 r = EmptyClipboard();
1950 ok( r, "gle %d\n", GetLastError() );
1951
1952 count = 0xdeadbeef;
1953 r = pGetUpdatedClipboardFormats( formats, 256, &count );
1954 ok( r, "gle %d\n", GetLastError() );
1955 ok( !count, "wrong count %u\n", count );
1956
1958
1959 count = 0xdeadbeef;
1960 memset( formats, 0xcc, sizeof(formats) );
1961 r = pGetUpdatedClipboardFormats( formats, 256, &count );
1962 ok( r, "gle %d\n", GetLastError() );
1963 ok( count == 1, "wrong count %u\n", count );
1964 ok( formats[0] == CF_UNICODETEXT, "wrong format %u\n", formats[0] );
1965 ok( formats[1] == 0xcccccccc, "wrong format %u\n", formats[1] );
1966
1968 count = 0xdeadbeef;
1969 memset( formats, 0xcc, sizeof(formats) );
1970 r = pGetUpdatedClipboardFormats( formats, 256, &count );
1971 ok( r, "gle %d\n", GetLastError() );
1972 ok( count == 2, "wrong count %u\n", count );
1973 ok( formats[0] == CF_UNICODETEXT, "wrong format %u\n", formats[0] );
1974 ok( formats[1] == CF_TEXT, "wrong format %u\n", formats[1] );
1975 ok( formats[2] == 0xcccccccc, "wrong format %u\n", formats[2] );
1976
1977 SetLastError( 0xdeadbeef );
1978 count = 0xdeadbeef;
1979 r = pGetUpdatedClipboardFormats( formats, 0, &count );
1980 ok( !r, "succeeded\n" );
1981 ok( GetLastError() == ERROR_INSUFFICIENT_BUFFER, "wrong error %u\n", GetLastError() );
1982 ok( count == 2, "wrong count %u\n", count );
1983
1984 SetLastError( 0xdeadbeef );
1985 count = 0xdeadbeef;
1986 r = pGetUpdatedClipboardFormats( formats, 1, &count );
1987 ok( !r, "succeeded\n" );
1988 ok( GetLastError() == ERROR_INSUFFICIENT_BUFFER, "wrong error %u\n", GetLastError() );
1989 ok( count == 2, "wrong count %u\n", count );
1990
1991 r = CloseClipboard();
1992 ok( r, "gle %d\n", GetLastError() );
1993
1994 count = 0xdeadbeef;
1995 memset( formats, 0xcc, sizeof(formats) );
1996 r = pGetUpdatedClipboardFormats( formats, 256, &count );
1997 ok( r, "gle %d\n", GetLastError() );
1998 ok( count == 4, "wrong count %u\n", count );
1999 ok( formats[0] == CF_UNICODETEXT, "wrong format %u\n", formats[0] );
2000 ok( formats[1] == CF_TEXT, "wrong format %u\n", formats[1] );
2001 ok( formats[2] == CF_LOCALE, "wrong format %u\n", formats[2] );
2002 ok( formats[3] == CF_OEMTEXT, "wrong format %u\n", formats[3] );
2003 ok( formats[4] == 0xcccccccc, "wrong format %u\n", formats[4] );
2004
2005 count = 0xdeadbeef;
2006 memset( formats, 0xcc, sizeof(formats) );
2007 r = pGetUpdatedClipboardFormats( formats, 2, &count );
2008 ok( !r, "gle %d\n", GetLastError() );
2009 ok( GetLastError() == ERROR_INSUFFICIENT_BUFFER, "wrong error %u\n", GetLastError() );
2010 ok( count == 4, "wrong count %u\n", count );
2011 ok( formats[0] == 0xcccccccc, "wrong format %u\n", formats[0] );
2012
2013 count = 0xdeadbeef;
2014 r = pGetUpdatedClipboardFormats( NULL, 256, &count );
2015 ok( !r, "gle %d\n", GetLastError() );
2016 ok( GetLastError() == ERROR_NOACCESS, "wrong error %u\n", GetLastError() );
2017 ok( count == 4, "wrong count %u\n", count );
2018
2019 count = 0xdeadbeef;
2020 r = pGetUpdatedClipboardFormats( NULL, 256, &count );
2021 ok( !r, "gle %d\n", GetLastError() );
2022 ok( GetLastError() == ERROR_NOACCESS, "wrong error %u\n", GetLastError() );
2023 ok( count == 4, "wrong count %u\n", count );
2024}
#define CF_LOCALE
Definition: constants.h:411
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define win_skip
Definition: test.h:160
#define ERROR_NOACCESS
Definition: winerror.h:578

Referenced by START_TEST().

◆ test_handles()

static void test_handles ( HWND  hwnd)
static

Definition at line 1348 of file clipboard.c.

1349{
1350 HGLOBAL h, htext, htext2, htext3, htext4, htext5;
1351 HGLOBAL hfixed, hfixed2, hmoveable, empty_fixed, empty_moveable;
1352 void *ptr;
1353 UINT format_id2 = RegisterClipboardFormatA( "another format" );
1354 BOOL r;
1355 HANDLE data;
1356 HBITMAP bitmap_temp;
1357 DWORD process;
1359
1360 trace( "hwnd %p\n", hwnd );
1361 htext = create_textA();
1362 htext2 = create_textA();
1363 htext3 = create_textA();
1364 htext4 = create_textA();
1365 htext5 = create_textA();
1366 bitmap = CreateBitmap( 10, 10, 1, 1, NULL );
1367 bitmap2 = CreateBitmap( 10, 10, 1, 1, NULL );
1369
1370 hfixed = GlobalAlloc( GMEM_FIXED, 17 );
1371 hfixed2 = GlobalAlloc( GMEM_FIXED, 17 );
1372 ok( is_fixed( hfixed ), "expected fixed mem %p\n", hfixed );
1373 ok( GlobalSize( hfixed ) == 17, "wrong size %lu\n", GlobalSize( hfixed ));
1374
1375 hmoveable = GlobalAlloc( GMEM_MOVEABLE, 23 );
1376 ok( is_moveable( hmoveable ), "expected moveable mem %p\n", hmoveable );
1377 ok( GlobalSize( hmoveable ) == 23, "wrong size %lu\n", GlobalSize( hmoveable ));
1378
1379 empty_fixed = GlobalAlloc( GMEM_FIXED, 0 );
1380 ok( is_fixed( empty_fixed ), "expected fixed mem %p\n", empty_fixed );
1381
1382 empty_moveable = GlobalAlloc( GMEM_MOVEABLE, 0 );
1383 /* discarded handles can't be GlobalLock'ed */
1384 ok( is_freed( empty_moveable ), "expected free mem %p\n", empty_moveable );
1385
1386 r = OpenClipboard( hwnd );
1387 ok( r, "gle %d\n", GetLastError() );
1388 r = EmptyClipboard();
1389 ok( r, "gle %d\n", GetLastError() );
1390
1391 h = SetClipboardData( CF_TEXT, htext );
1392 ok( h == htext, "got %p\n", h );
1393 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1394 h = SetClipboardData( format_id, htext2 );
1395 ok( h == htext2, "got %p\n", h );
1396 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1397 bitmap_temp = CreateBitmap( 10, 10, 1, 1, NULL );
1398 h = SetClipboardData( CF_BITMAP, bitmap_temp );
1399 ok( h == bitmap_temp, "got %p\n", h );
1400 ok( GetObjectType( h ) == OBJ_BITMAP, "expected bitmap %p\n", h );
1402 ok( h == bitmap, "got %p\n", h );
1403 ok( GetObjectType( h ) == OBJ_BITMAP, "expected bitmap %p\n", h );
1404 ok( !GetObjectType( bitmap_temp ), "expected free object %p\n", bitmap_temp );
1406 ok( h == bitmap2, "got %p\n", h );
1407 ok( GetObjectType( h ) == OBJ_BITMAP, "expected bitmap %p\n", h );
1409 ok( h == palette, "got %p\n", h );
1410 ok( GetObjectType( h ) == OBJ_PAL, "expected palette %p\n", h );
1411 h = SetClipboardData( CF_GDIOBJFIRST + 3, htext3 );
1412 ok( h == htext3, "got %p\n", h );
1413 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1414 h = SetClipboardData( CF_PRIVATEFIRST + 7, htext5 );
1415 ok( h == htext5, "got %p\n", h );
1416 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1417 h = SetClipboardData( format_id2, empty_moveable );
1418 ok( !h, "got %p\n", h );
1419 GlobalFree( empty_moveable );
1420
1421 if (0) /* crashes on vista64 */
1422 {
1423 ptr = HeapAlloc( GetProcessHeap(), 0, 0 );
1424 h = SetClipboardData( format_id2, ptr );
1425 ok( !h, "got %p\n", h );
1426 HeapFree( GetProcessHeap(), 0, ptr );
1427 }
1428
1429 h = SetClipboardData( format_id2, empty_fixed );
1430 ok( h == empty_fixed, "got %p\n", h );
1431 ok( is_fixed( h ), "expected fixed mem %p\n", h );
1432 h = SetClipboardData( 0xdeadbeef, hfixed2 );
1433 ok( h == hfixed2, "got %p\n", h );
1434 ok( is_fixed( h ), "expected fixed mem %p\n", h );
1435 h = SetClipboardData( 0xdeadbabe, hmoveable );
1436 ok( h == hmoveable, "got %p\n", h );
1437 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1438
1439 ptr = HeapAlloc( GetProcessHeap(), 0, 37 );
1440 h = SetClipboardData( 0xdeadfade, ptr );
1441 ok( h == ptr || !h, "got %p\n", h );
1442 if (!h) /* heap blocks are rejected on >= win8 */
1443 {
1444 HeapFree( GetProcessHeap(), 0, ptr );
1445 ptr = NULL;
1446 }
1447
1449 ok( data == htext, "wrong data %p\n", data );
1450 ok( is_moveable( data ), "expected moveable mem %p\n", data );
1451
1453 ok( data == htext2, "wrong data %p, cf %08x\n", data, format_id );
1454 ok( is_moveable( data ), "expected moveable mem %p\n", data );
1455
1457 ok( data == htext3, "wrong data %p\n", data );
1458 ok( is_moveable( data ), "expected moveable mem %p\n", data );
1459
1461 ok( data == htext5, "wrong data %p\n", data );
1462 ok( is_moveable( data ), "expected moveable mem %p\n", data );
1463
1464 data = GetClipboardData( format_id2 );
1465 ok( data == empty_fixed, "wrong data %p\n", data );
1466 ok( is_fixed( data ), "expected fixed mem %p\n", data );
1467
1468 data = GetClipboardData( 0xdeadbeef );
1469 ok( data == hfixed2, "wrong data %p\n", data );
1470 ok( is_fixed( data ), "expected fixed mem %p\n", data );
1471
1472 data = GetClipboardData( 0xdeadbabe );
1473 ok( data == hmoveable, "wrong data %p\n", data );
1474 ok( is_moveable( data ), "expected moveable mem %p\n", data );
1475
1476 data = GetClipboardData( 0xdeadfade );
1477 ok( data == ptr, "wrong data %p\n", data );
1478
1479 h = SetClipboardData( CF_PRIVATEFIRST + 7, htext4 );
1480 ok( h == htext4, "got %p\n", h );
1481 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1482 ok( is_freed( htext5 ), "expected freed mem %p\n", htext5 );
1483
1484 h = SetClipboardData( 0xdeadbeef, hfixed );
1485 ok( h == hfixed, "got %p\n", h );
1486 ok( is_fixed( h ), "expected fixed mem %p\n", h );
1487 if (0) /* this test is unreliable / crashes */
1488 ok( is_freed( hfixed2 ), "expected freed mem %p\n", hfixed2 );
1489
1490 r = CloseClipboard();
1491 ok( r, "gle %d\n", GetLastError() );
1492
1493 /* data handles are still valid */
1494 ok( is_moveable( htext ), "expected moveable mem %p\n", htext );
1495 ok( is_moveable( htext2 ), "expected moveable mem %p\n", htext2 );
1496 ok( is_moveable( htext3 ), "expected moveable mem %p\n", htext3 );
1497 ok( is_moveable( htext4 ), "expected moveable mem %p\n", htext4 );
1498 ok( GetObjectType( bitmap ) == OBJ_BITMAP, "expected bitmap %p\n", bitmap );
1499 ok( GetObjectType( bitmap2 ) == OBJ_BITMAP, "expected bitmap %p\n", bitmap2 );
1500 ok( GetObjectType( palette ) == OBJ_PAL, "expected palette %p\n", palette );
1501 ok( is_fixed( hfixed ), "expected fixed mem %p\n", hfixed );
1502 ok( is_moveable( hmoveable ), "expected moveable mem %p\n", hmoveable );
1503 ok( is_fixed( empty_fixed ), "expected fixed mem %p\n", empty_fixed );
1504
1505 r = OpenClipboard( hwnd );
1506 ok( r, "gle %d\n", GetLastError() );
1507
1508 /* and now they are freed, unless we are the owner */
1509 if (!is_owner)
1510 {
1511 ok( is_freed( htext ), "expected freed mem %p\n", htext );
1512 ok( is_freed( htext2 ), "expected freed mem %p\n", htext2 );
1513 ok( is_freed( htext3 ), "expected freed mem %p\n", htext3 );
1514 ok( is_freed( htext4 ), "expected freed mem %p\n", htext4 );
1515 ok( is_freed( hmoveable ), "expected freed mem %p\n", hmoveable );
1516
1518 ok( is_fixed( data ), "expected fixed mem %p\n", data );
1519
1521 ok( is_fixed( data ), "expected fixed mem %p\n", data );
1522
1524 ok( is_fixed( data ), "expected fixed mem %p\n", data );
1525
1527 ok( is_fixed( data ), "expected fixed mem %p\n", data );
1528
1529 data = GetClipboardData( format_id2 );
1530 ok( is_fixed( data ), "expected fixed mem %p\n", data );
1531 ok( GlobalSize( data ) == 1, "wrong size %lu\n", GlobalSize( data ));
1532
1533 data = GetClipboardData( 0xdeadbeef );
1534 ok( is_fixed( data ), "expected fixed mem %p\n", data );
1535 ok( GlobalSize( data ) == 17, "wrong size %lu\n", GlobalSize( data ));
1536
1537 data = GetClipboardData( 0xdeadbabe );
1538 ok( is_fixed( data ), "expected fixed mem %p\n", data );
1539 ok( GlobalSize( data ) == 23, "wrong size %lu\n", GlobalSize( data ));
1540
1541 data = GetClipboardData( 0xdeadfade );
1542 ok( is_fixed( data ) || !ptr, "expected fixed mem %p\n", data );
1543 if (ptr) ok( GlobalSize( data ) == 37, "wrong size %lu\n", GlobalSize( data ));
1544 }
1545 else
1546 {
1547 ok( is_moveable( htext ), "expected moveable mem %p\n", htext );
1548 ok( is_moveable( htext2 ), "expected moveable mem %p\n", htext2 );
1549 ok( is_moveable( htext3 ), "expected moveable mem %p\n", htext3 );
1550 ok( is_moveable( htext4 ), "expected moveable mem %p\n", htext4 );
1551 ok( is_moveable( hmoveable ), "expected moveable mem %p\n", hmoveable );
1552
1554 ok( data == htext, "wrong data %p\n", data );
1555
1557 ok( data == htext2, "wrong data %p, cf %08x\n", data, format_id );
1558
1560 ok( data == htext3, "wrong data %p\n", data );
1561
1563 ok( data == htext4, "wrong data %p\n", data );
1564
1565 data = GetClipboardData( format_id2 );
1566 ok( data == empty_fixed, "wrong data %p\n", data );
1567
1568 data = GetClipboardData( 0xdeadbeef );
1569 ok( data == hfixed, "wrong data %p\n", data );
1570
1571 data = GetClipboardData( 0xdeadbabe );
1572 ok( data == hmoveable, "wrong data %p\n", data );
1573
1574 data = GetClipboardData( 0xdeadfade );
1575 ok( data == ptr, "wrong data %p\n", data );
1576 }
1577
1579 ok( is_fixed( data ), "expected fixed mem %p\n", data );
1581 ok( is_fixed( data ), "expected fixed mem %p\n", data );
1583 ok( is_fixed( data ), "expected fixed mem %p\n", data );
1585 ok( data == bitmap, "expected bitmap %p\n", data );
1587 ok( data == bitmap2, "expected bitmap %p\n", data );
1589 ok( data == palette, "expected palette %p\n", data );
1591 ok( is_fixed( data ), "expected fixed mem %p\n", data );
1592 data = GetClipboardData( CF_DIBV5 );
1593 ok( is_fixed( data ), "expected fixed mem %p\n", data );
1594
1595 ok( GetObjectType( bitmap ) == OBJ_BITMAP, "expected bitmap %p\n", bitmap );
1596 ok( GetObjectType( bitmap2 ) == OBJ_BITMAP, "expected bitmap %p\n", bitmap2 );
1597 ok( GetObjectType( palette ) == OBJ_PAL, "expected palette %p\n", palette );
1598 ok( is_fixed( hfixed ), "expected fixed mem %p\n", hfixed );
1599 ok( is_fixed( empty_fixed ), "expected fixed mem %p\n", empty_fixed );
1600
1601 r = EmptyClipboard();
1602 ok( r, "gle %d\n", GetLastError() );
1603
1604 /* w2003, w2008 don't seem to free the data here */
1605 ok( is_freed( htext ) || broken( !is_freed( htext )), "expected freed mem %p\n", htext );
1606 ok( is_freed( htext2 ) || broken( !is_freed( htext2 )), "expected freed mem %p\n", htext2 );
1607 ok( is_freed( htext3 ) || broken( !is_freed( htext3 )), "expected freed mem %p\n", htext3 );
1608 ok( is_freed( htext4 ) || broken( !is_freed( htext4 )), "expected freed mem %p\n", htext4 );
1609 ok( is_freed( hmoveable ) || broken( !is_freed( hmoveable )), "expected freed mem %p\n", hmoveable );
1610 ok( is_fixed( empty_fixed ), "expected fixed mem %p\n", empty_fixed );
1611 ok( is_fixed( hfixed ), "expected fixed mem %p\n", hfixed );
1612 ok( !GetObjectType( bitmap ), "expected freed handle %p\n", bitmap );
1613 ok( !GetObjectType( bitmap2 ), "expected freed handle %p\n", bitmap2 );
1614 ok( !GetObjectType( palette ), "expected freed handle %p\n", palette );
1615
1616 r = CloseClipboard();
1617 ok( r, "gle %d\n", GetLastError() );
1618}
#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 1678 of file clipboard.c.

1679{
1680 BOOL r;
1681 HANDLE h;
1682 char *ptr;
1683 BITMAP bm;
1685 BYTE buffer[1024];
1686
1687 format_id = RegisterClipboardFormatA( "my_cool_clipboard_format" );
1688 r = OpenClipboard( 0 );
1689 ok( r, "gle %d\n", GetLastError() );
1691 ok( is_fixed( h ), "expected fixed mem %p\n", h );
1692 ptr = GlobalLock( h );
1693 ok( !strcmp( str, ptr ), "wrong data '%.5s'\n", ptr );
1694 GlobalUnlock( h );
1696 ok( is_fixed( h ), "expected fixed mem %p\n", h );
1697 ptr = GlobalLock( h );
1698 if (ptr) ok( !strcmp( str, ptr ), "wrong data '%.5s'\n", ptr );
1699 GlobalUnlock( h );
1701 ok( is_fixed( h ), "expected fixed mem %p\n", h );
1702 ptr = GlobalLock( h );
1703 ok( !strcmp( str, ptr ), "wrong data '%.5s'\n", ptr );
1704 GlobalUnlock( h );
1705 trace( "gdiobj %p\n", h );
1707 ok( is_fixed( h ), "expected fixed mem %p\n", h );
1708 ptr = GlobalLock( h );
1709 ok( !strcmp( str, ptr ), "wrong data '%.5s'\n", ptr );
1710 GlobalUnlock( h );
1711 trace( "private %p\n", h );
1713 ok( GetObjectType( h ) == OBJ_BITMAP, "expected bitmap %p\n", h );
1714 ok( GetObjectW( h, sizeof(bm), &bm ) == sizeof(bm), "GetObject %p failed\n", h );
1715 ok( bm.bmWidth == 13 && bm.bmHeight == 17, "wrong bitmap %ux%u\n", bm.bmWidth, bm.bmHeight );
1716 trace( "bitmap %p\n", h );
1718 ok( !GetObjectType( h ), "expected invalid object %p\n", h );
1719 trace( "bitmap2 %p\n", h );
1721 ok( GetObjectType( h ) == OBJ_PAL, "expected palette %p\n", h );
1722 ok( GetPaletteEntries( h, 0, 1, &entry ) == 1, "GetPaletteEntries %p failed\n", h );
1723 ok( entry.peRed == 0x12 && entry.peGreen == 0x34 && entry.peBlue == 0x56,
1724 "wrong color %02x,%02x,%02x\n", entry.peRed, entry.peGreen, entry.peBlue );
1725 trace( "palette %p\n", h );
1727 ok( is_fixed( h ), "expected fixed mem %p\n", h );
1728#ifdef __REACTOS__
1729 if (h != NULL)
1730#endif
1731 ok( GetObjectType( ((METAFILEPICT *)h)->hMF ) == OBJ_METAFILE,
1732 "wrong object %p\n", ((METAFILEPICT *)h)->hMF );
1733 trace( "metafile %p\n", h );
1735 ok( is_fixed( h ), "expected fixed mem %p\n", h );
1736#ifdef __REACTOS__
1737 if (h != NULL)
1738#endif
1739 ok( GetObjectType( ((METAFILEPICT *)h)->hMF ) == OBJ_METAFILE,
1740 "wrong object %p\n", ((METAFILEPICT *)h)->hMF );
1741 trace( "metafile2 %p\n", h );
1743 ok( GetObjectType( h ) == OBJ_ENHMETAFILE, "expected enhmetafile %p\n", h );
1744 ok( GetEnhMetaFileBits( h, sizeof(buffer), buffer ) > sizeof(ENHMETAHEADER),
1745 "GetEnhMetaFileBits failed on %p\n", h );
1746 ok( ((ENHMETAHEADER *)buffer)->nRecords == 3,
1747 "wrong records %u\n", ((ENHMETAHEADER *)buffer)->nRecords );
1748 trace( "enhmetafile %p\n", h );
1750 ok( GetObjectType( h ) == OBJ_ENHMETAFILE, "expected enhmetafile %p\n", h );
1751 ok( GetEnhMetaFileBits( h, sizeof(buffer), buffer ) > sizeof(ENHMETAHEADER),
1752 "GetEnhMetaFileBits failed on %p\n", h );
1753 ok( ((ENHMETAHEADER *)buffer)->nRecords == 3,
1754 "wrong records %u\n", ((ENHMETAHEADER *)buffer)->nRecords );
1755 trace( "enhmetafile2 %p\n", h );
1757 ok( is_fixed( h ), "expected fixed mem %p\n", h );
1758 h = GetClipboardData( CF_DIBV5 );
1759 ok( is_fixed( h ), "expected fixed mem %p\n", h );
1760 r = CloseClipboard();
1761 ok( r, "gle %d\n", GetLastError() );
1762}
GLuint buffer
Definition: glext.h:5915
uint32_t entry
Definition: isohybrid.c:63
#define OBJ_METAFILE
Definition: objidl.idl:1417
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 1778 of file clipboard.c.

1779{
1780 BOOL r;
1781 HANDLE h;
1782
1783 r = OpenClipboard( 0 );
1784 ok( r, "gle %d\n", GetLastError() );
1786 ok( !GetObjectType( h ), "expected invalid object %p\n", h );
1787 trace( "dibsection %p\n", h );
1788 r = CloseClipboard();
1789 ok( r, "gle %d\n", GetLastError() );
1790}

Referenced by START_TEST().

◆ test_handles_process_open()

static void test_handles_process_open ( const char str)
static

Definition at line 1764 of file clipboard.c.

1765{
1767 char *ptr = GlobalLock( text );
1768
1769 strcpy( ptr, str );
1770 GlobalUnlock( text );
1771
1772 /* clipboard already open by parent process */
1774 ok( h == text, "wrong mem %p / %p\n", h, text );
1775 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1776}
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388

Referenced by START_TEST().

◆ test_handles_thread()

static DWORD WINAPI test_handles_thread ( void arg)
static

Definition at line 1620 of file clipboard.c.

1621{
1622 trace( "running from different thread\n" );
1623 test_handles( (HWND)arg );
1624 return 0;
1625}

Referenced by test_data_handles().

◆ test_handles_thread2()

static DWORD WINAPI test_handles_thread2 ( void arg)
static

Definition at line 1627 of file clipboard.c.

1628{
1629 BOOL r;
1630 HANDLE h;
1631 char *ptr;
1632
1633 r = OpenClipboard( 0 );
1634 ok( r, "gle %d\n", GetLastError() );
1636 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1637 ptr = GlobalLock( h );
1638 if (ptr) ok( !strcmp( "test", ptr ), "wrong data '%.5s'\n", ptr );
1639 GlobalUnlock( h );
1641 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1642 ptr = GlobalLock( h );
1643 if (ptr) ok( !strcmp( "test", ptr ), "wrong data '%.5s'\n", ptr );
1644 GlobalUnlock( h );
1646 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1647 ptr = GlobalLock( h );
1648 if (ptr) ok( !strcmp( "test", ptr ), "wrong data '%.5s'\n", ptr );
1649 GlobalUnlock( h );
1650 trace( "gdiobj %p\n", h );
1652 ok( is_moveable( h ), "expected moveable mem %p\n", h );
1653 ptr = GlobalLock( h );
1654 if (ptr) ok( !strcmp( "test", ptr ), "wrong data '%.5s'\n", ptr );
1655 GlobalUnlock( h );
1656 trace( "private %p\n", h );
1658 ok( GetObjectType( h ) == OBJ_BITMAP, "expected bitmap %p\n", h );
1659 ok( h == bitmap, "different bitmap %p / %p\n", h, bitmap );
1660 trace( "bitmap %p\n", h );
1662 ok( GetObjectType( h ) == OBJ_BITMAP, "expected bitmap %p\n", h );
1663 ok( h == bitmap2, "different bitmap %p / %p\n", h, bitmap2 );
1664 trace( "bitmap2 %p\n", h );
1666 ok( GetObjectType( h ) == OBJ_PAL, "expected palette %p\n", h );
1667 ok( h == palette, "different palette %p / %p\n", h, palette );
1668 trace( "palette %p\n", h );
1670 ok( is_fixed( h ), "expected fixed mem %p\n", h );
1671 h = GetClipboardData( CF_DIBV5 );
1672 ok( is_fixed( h ), "expected fixed mem %p\n", h );
1673 r = CloseClipboard();
1674 ok( r, "gle %d\n", GetLastError() );
1675 return 0;
1676}

Referenced by test_data_handles().

◆ test_messages()

static void test_messages ( void  )
static

Definition at line 1277 of file clipboard.c.

1278{
1279 WNDCLASSA cls;
1280 HWND win;
1281 MSG msg;
1282 HANDLE thread;
1283 DWORD tid;
1284
1287
1288 memset(&cls, 0, sizeof(cls));
1291 cls.lpszClassName = "clipboard_test";
1292 RegisterClassA(&cls);
1293
1294 win = CreateWindowA("clipboard_test", NULL, 0, 0, 0, 0, 0, NULL, 0, NULL, 0);
1295 ok(win != NULL, "CreateWindow failed: %d\n", GetLastError());
1296
1297 thread = CreateThread(NULL, 0, clipboard_thread, (void*)win, 0, &tid);
1298 ok(thread != NULL, "CreateThread failed: %d\n", GetLastError());
1299
1300 while(GetMessageA(&msg, NULL, 0, 0))
1301 {
1302 ok( msg.message != WM_DRAWCLIPBOARD, "WM_DRAWCLIPBOARD was posted\n" );
1305 }
1306
1307 ok(WaitForSingleObject(thread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
1309
1310 DestroyWindow( win );
1311
1312 /* same tests again but inside a single thread */
1313
1314 win = CreateWindowA( "clipboard_test", NULL, 0, 0, 0, 0, 0, NULL, 0, NULL, 0 );
1315 ok( win != NULL, "CreateWindow failed: %d\n", GetLastError() );
1316
1318 DestroyWindow( win );
1319
1320 UnregisterClassA("clipboard_test", GetModuleHandleA(NULL));
1322}
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:1035
HINSTANCE hInstance
Definition: winuser.h:3157
LPCSTR lpszClassName
Definition: winuser.h:3162
WNDPROC lpfnWndProc
Definition: winuser.h:3154
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 373 of file clipboard.c.

374{
375 ATOM atom_id;
376 UINT format_id, format_id2;
377 char buf[256];
378 int len;
379 BOOL ret;
381
382 format_id = RegisterClipboardFormatA("my_cool_clipboard_format");
383 ok(format_id > 0xc000 && format_id < 0xffff, "invalid clipboard format id %04x\n", format_id);
384
385 format_id2 = RegisterClipboardFormatA("MY_COOL_CLIPBOARD_FORMAT");
386 ok(format_id2 == format_id, "invalid clipboard format id %04x\n", format_id2);
387
389 ok(len == lstrlenA("my_cool_clipboard_format"), "wrong format name length %d\n", len);
390 ok(!lstrcmpA(buf, "my_cool_clipboard_format"), "wrong format name \"%s\"\n", buf);
391
393 ok(len == 0, "wrong format name length %d\n", len);
394
395 lstrcpyA(buf, "foo");
396 SetLastError(0xdeadbeef);
398 ok(len == 0, "GetAtomNameA should fail\n");
400
402{
403 lstrcpyA(buf, "foo");
404 SetLastError(0xdeadbeef);
406 ok(len == 0, "GlobalGetAtomNameA should fail\n");
408}
409
410 SetLastError(0xdeadbeef);
411 atom_id = FindAtomA("my_cool_clipboard_format");
412 ok(atom_id == 0, "FindAtomA should fail\n");
414
415 if (0)
416 {
417 /* this relies on the clipboard and global atom table being different */
418 SetLastError(0xdeadbeef);
419 atom_id = GlobalFindAtomA("my_cool_clipboard_format");
420 ok(atom_id == 0, "GlobalFindAtomA should fail\n");
422 }
423
424 for (format_id = 0; format_id < 0x10fff; format_id++)
425 {
426 SetLastError(0xdeadbeef);
428
429 if (format_id < 0xc000 || format_id > 0xffff)
430 ok(!len, "GetClipboardFormatNameA should fail, but it returned %d (%s)\n", len, buf);
431 else if (len && winetest_debug > 1)
432 trace("%04x: %s\n", format_id, len ? buf : "");
433 }
434
435 ret = OpenClipboard(0);
436 ok( ret, "OpenClipboard error %d\n", GetLastError());
437
438 /* try some invalid/unregistered formats */
439 SetLastError( 0xdeadbeef );
441 ok( !handle, "SetClipboardData succeeded\n" );
442 ok( GetLastError() == ERROR_CLIPBOARD_NOT_OPEN, "wrong error %u\n", GetLastError());
444 ok( handle != 0, "SetClipboardData failed err %d\n", GetLastError());
446 ok( handle != 0, "SetClipboardData failed err %d\n", GetLastError());
448 ok( handle != 0, "SetClipboardData failed err %d\n", GetLastError());
449
450 ok( IsClipboardFormatAvailable( 0x1234 ), "format missing\n" );
451 ok( IsClipboardFormatAvailable( 0x123456 ), "format missing\n" );
452 ok( IsClipboardFormatAvailable( 0xffff8765 ), "format missing\n" );
453 ok( !IsClipboardFormatAvailable( 0 ), "format available\n" );
454 ok( !IsClipboardFormatAvailable( 0x3456 ), "format available\n" );
455 ok( !IsClipboardFormatAvailable( 0x8765 ), "format available\n" );
456
457 trace("# of formats available: %d\n", CountClipboardFormats());
458
459 format_id = 0;
461 {
462 ok(IsClipboardFormatAvailable(format_id), "format %04x was listed as available\n", format_id);
464 trace("%04x: %s\n", format_id, len ? buf : "");
465 }
466
468 ok( ret, "EmptyClipboard error %d\n", GetLastError());
470 ok( ret, "CloseClipboard error %d\n", GetLastError());
471
473 {
474 SetLastError(0xdeadbeef);
475 ok(!EnumClipboardFormats(0), "EnumClipboardFormats should fail if clipboard wasn't open\n");
477 "Last error should be set to ERROR_CLIPBOARD_NOT_OPEN, not %d\n", GetLastError());
478 }
479
480 SetLastError(0xdeadbeef);
481 ok(!EmptyClipboard(), "EmptyClipboard should fail if clipboard wasn't open\n");
482 ok(GetLastError() == ERROR_CLIPBOARD_NOT_OPEN || broken(GetLastError() == 0xdeadbeef), /* wow64 */
483 "Wrong error %u\n", GetLastError());
484
486 ok(format_id == 1234, "invalid clipboard format id %04x\n", format_id);
487}
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
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 lstrcmpA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:18
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define todo_wine
Definition: custom.c:79
UINT len
Definition: clipboard.c:2030
int winetest_debug
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 2048 of file clipboard.c.

2049{
2050 UINT i;
2051 BOOL r;
2052 HANDLE data;
2053 char cmd[16];
2054 char bufferA[12];
2055 WCHAR bufferW[12];
2056
2057 for (i = 0; i < ARRAY_SIZE(test_data); i++)
2058 {
2059 /* 1-byte Unicode strings crash on Win64 */
2060#ifdef _WIN64
2061 if (!test_data[i].strA[0] && test_data[i].len < sizeof(WCHAR)) continue;
2062#endif
2063 r = OpenClipboard( 0 );
2064 ok( r, "gle %d\n", GetLastError() );
2065 r = EmptyClipboard();
2066 ok( r, "gle %d\n", GetLastError() );
2068 if (test_data[i].strA[0])
2069 {
2072 memcpy( bufferA, test_data[i].strA, test_data[i].len );
2073 bufferA[test_data[i].len - 1] = 0;
2074 ok( !memcmp( data, bufferA, test_data[i].len ),
2075 "%u: wrong data %.*s\n", i, test_data[i].len, (char *)data );
2076 }
2077 else
2078 {
2081 memcpy( bufferW, test_data[i].strW, test_data[i].len );
2082 bufferW[(test_data[i].len + 1) / sizeof(WCHAR) - 1] = 0;
2083 ok( !memcmp( data, bufferW, test_data[i].len ),
2084 "%u: wrong data %s\n", i, wine_dbgstr_wn( data, (test_data[i].len + 1) / sizeof(WCHAR) ));
2085 }
2086 r = CloseClipboard();
2087 ok( r, "gle %d\n", GetLastError() );
2088 sprintf( cmd, "string_data %u", i );
2089 run_process( cmd );
2090 }
2091}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define ARRAY_SIZE(a)
Definition: main.h:24
const char * wine_dbgstr_wn(const WCHAR *str, int n)
Definition: compat.c:367
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:2029
char strA[12]
Definition: clipboard.c:2028

Referenced by START_TEST().

◆ test_string_data_process()

static void test_string_data_process ( int  i)
static

Definition at line 2093 of file clipboard.c.

2094{
2095 BOOL r;
2096 HANDLE data;
2097 UINT len, len2;
2098 char bufferA[12];
2099 WCHAR bufferW[12];
2100
2101 r = OpenClipboard( 0 );
2102 ok( r, "gle %d\n", GetLastError() );
2103 if (test_data[i].strA[0])
2104 {
2106 ok( data != 0, "%u: could not get data\n", i );
2107 len = GlobalSize( data );
2108 ok( len == test_data[i].len, "%u: wrong size %u / %u\n", i, len, test_data[i].len );
2109 memcpy( bufferA, test_data[i].strA, test_data[i].len );
2110 bufferA[test_data[i].len - 1] = 0;
2111 ok( !memcmp( data, bufferA, len ), "%u: wrong data %.*s\n", i, len, (char *)data );
2113 ok( data != 0, "%u: could not get data\n", i );
2114 len = GlobalSize( data );
2115 len2 = MultiByteToWideChar( CP_ACP, 0, bufferA, test_data[i].len, bufferW, 12 );
2116 ok( len == len2 * sizeof(WCHAR), "%u: wrong size %u / %u\n", i, len, len2 );
2117 ok( !memcmp( data, bufferW, len ), "%u: wrong data %s\n", i, wine_dbgstr_wn( data, len2 ));
2118 }
2119 else
2120 {
2122 ok( data != 0, "%u: could not get data\n", i );
2123 len = GlobalSize( data );
2124 ok( len == test_data[i].len, "%u: wrong size %u / %u\n", i, len, test_data[i].len );
2125 memcpy( bufferW, test_data[i].strW, test_data[i].len );
2126 bufferW[(test_data[i].len + 1) / sizeof(WCHAR) - 1] = 0;
2127 ok( !memcmp( data, bufferW, len ),
2128 "%u: wrong data %s\n", i, wine_dbgstr_wn( data, (len + 1) / sizeof(WCHAR) ));
2130 if (test_data[i].len >= sizeof(WCHAR))
2131 {
2132 ok( data != 0, "%u: could not get data\n", i );
2133 len = GlobalSize( data );
2134 len2 = WideCharToMultiByte( CP_ACP, 0, bufferW, test_data[i].len / sizeof(WCHAR),
2135 bufferA, 12, NULL, NULL );
2136 bufferA[len2 - 1] = 0;
2137 ok( len == len2, "%u: wrong size %u / %u\n", i, len, len2 );
2138 ok( !memcmp( data, bufferA, len ), "%u: wrong data %.*s\n", i, len, (char *)data );
2139 }
2140 else
2141 {
2142 ok( !data, "%u: got data for empty string\n", i );
2143 ok( IsClipboardFormatAvailable( CF_TEXT ), "%u: text not available\n", i );
2144 }
2145 }
2146 r = CloseClipboard();
2147 ok( r, "gle %d\n", GetLastError() );
2148}
#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 586 of file clipboard.c.

587{
588 static const struct test
589 {
590 UINT format;
591 UINT expected[8];
592 } tests[] =
593 {
599/* 5 */ { CF_BITMAP, { CF_BITMAP, CF_DIB, CF_DIBV5 }},
600 { CF_DIB, { CF_DIB, CF_BITMAP, CF_DIBV5 }},
601 { CF_DIBV5, { CF_DIBV5, CF_BITMAP, CF_DIB }},
602 };
603
604 HGLOBAL h, htext;
605 HENHMETAFILE emf;
606 BOOL r;
607 UINT cf, i, j, count, rendered, seq, old_seq;
608 HANDLE data;
609 HWND hwnd;
610
611 hwnd = CreateWindowA( "static", NULL, WS_POPUP, 0, 0, 10, 10, 0, 0, 0, NULL );
613
614 htext = create_textA();
615 emf = create_emf();
616
618 ok(r, "gle %d\n", GetLastError());
619 r = EmptyClipboard();
620 ok(r, "gle %d\n", GetLastError());
621 h = SetClipboardData(CF_TEXT, htext);
622 ok(h == htext, "got %p\n", h);
624 ok(h == emf, "got %p\n", h);
625 r = CloseClipboard();
626 ok(r, "gle %d\n", GetLastError());
627
629 ok( count == 6, "count %u\n", count );
631 ok( r, "CF_TEXT not available err %d\n", GetLastError());
633 ok( r, "CF_LOCALE not available err %d\n", GetLastError());
635 ok( r, "CF_OEMTEXT not available err %d\n", GetLastError());
637 ok( r, "CF_UNICODETEXT not available err %d\n", GetLastError());
639 ok( r, "CF_ENHMETAFILE not available err %d\n", GetLastError());
641 ok( r, "CF_METAFILEPICT not available err %d\n", GetLastError());
642
644 ok(r, "gle %d\n", GetLastError());
646 ok(cf == CF_TEXT, "cf %08x\n", cf);
648 ok(data != NULL, "couldn't get data, cf %08x\n", cf);
649
651 ok(cf == CF_ENHMETAFILE, "cf %08x\n", cf);
653 ok(data != NULL, "couldn't get data, cf %08x\n", cf);
654
656 ok(cf == CF_LOCALE, "cf %08x\n", cf);
658 ok(data != NULL, "couldn't get data, cf %08x\n", cf);
659
661 ok(cf == CF_OEMTEXT, "cf %08x\n", cf);
663 ok(data != NULL, "couldn't get data, cf %08x\n", cf);
664
666 ok(cf == CF_UNICODETEXT, "cf %08x\n", cf);
667
669 ok(cf == CF_METAFILEPICT, "cf %08x\n", cf);
671 ok(data != NULL, "couldn't get data, cf %08x\n", cf);
672
674 ok(cf == 0, "cf %08x\n", cf);
675
676 r = EmptyClipboard();
677 ok(r, "gle %d\n", GetLastError());
678
682 r = CloseClipboard();
683 ok(r, "gle %d\n", GetLastError());
684
685 r = OpenClipboard( NULL );
686 ok(r, "gle %d\n", GetLastError());
687 SetLastError( 0xdeadbeef );
689 ok( cf == CF_UNICODETEXT, "cf %08x\n", cf );
690 ok( GetLastError() == ERROR_SUCCESS, "wrong error %u\n", GetLastError() );
691 SetLastError( 0xdeadbeef );
693 ok( cf == CF_TEXT, "cf %08x\n", cf );
694 ok( GetLastError() == ERROR_SUCCESS, "wrong error %u\n", GetLastError() );
695 SetLastError( 0xdeadbeef );
697 ok( cf == CF_OEMTEXT, "cf %08x\n", cf );
698 ok( GetLastError() == ERROR_SUCCESS, "wrong error %u\n", GetLastError() );
699 SetLastError( 0xdeadbeef );
701 ok( cf == CF_LOCALE, "cf %08x\n", cf );
702 ok( GetLastError() == ERROR_SUCCESS, "wrong error %u\n", GetLastError() );
703 SetLastError( 0xdeadbeef );
705 ok( cf == 0, "cf %08x\n", cf );
706 ok( GetLastError() == ERROR_SUCCESS, "wrong error %u\n", GetLastError() );
707 SetLastError( 0xdeadbeef );
708 cf = EnumClipboardFormats( 0xdead );
709 ok( cf == 0, "cf %08x\n", cf );
710 ok( GetLastError() == ERROR_SUCCESS, "wrong error %u\n", GetLastError() );
711
712 r = EmptyClipboard();
713 ok(r, "gle %d\n", GetLastError());
714
715 r = CloseClipboard();
716 ok(r, "gle %d\n", GetLastError());
717
718 for (i = 0; i < ARRAY_SIZE(tests); i++)
719 {
721 ok(r, "%u: gle %d\n", i, GetLastError());
722 r = EmptyClipboard();
723 ok(r, "%u: gle %d\n", i, GetLastError());
724
725 switch (tests[i].format)
726 {
727 case CF_TEXT:
728 case CF_OEMTEXT:
730 break;
731 case CF_UNICODETEXT:
733 break;
734 case CF_ENHMETAFILE:
736 break;
737 case CF_METAFILEPICT:
739 break;
740 case CF_BITMAP:
742 break;
743 case CF_DIB:
744 case CF_DIBV5:
746 break;
747 }
748
750 ok( count == 1, "%u: count %u\n", i, count );
751
752 r = CloseClipboard();
753 ok(r, "%u: gle %d\n", i, GetLastError());
754
756 for (j = 0; tests[i].expected[j]; j++)
757 {
759 ok( r, "%u: %04x not available\n", i, tests[i].expected[j] );
760 }
761 ok( count == j, "%u: count %u instead of %u\n", i, count, j );
762
763 r = OpenClipboard( hwnd );
764 ok(r, "%u: gle %d\n", i, GetLastError());
765 cf = 0;
766 for (j = 0; tests[i].expected[j]; j++)
767 {
769 ok(cf == tests[i].expected[j], "%u.%u: got %04x instead of %04x\n",
770 i, j, cf, tests[i].expected[j] );
771 if (cf != tests[i].expected[j]) break;
774 ok(data != NULL ||
775 broken( tests[i].format == CF_DIBV5 && cf == CF_DIB ), /* >= Vista */
776 "%u: couldn't get data, cf %04x err %d\n", i, cf, GetLastError());
778 ok(seq == old_seq, "sequence changed (test %d %d)\n", i, cf);
779 switch (cf)
780 {
781 case CF_LOCALE:
782 {
783 UINT *ptr = GlobalLock( data );
784 ok( GlobalSize( data ) == sizeof(*ptr), "%u: size %lu\n", i, GlobalSize( data ));
785 ok( *ptr == GetUserDefaultLCID() ||
787 "%u: CF_LOCALE %08x/%08x\n", i, *ptr, GetUserDefaultLCID() );
789 break;
790 }
791 case CF_TEXT:
792 case CF_OEMTEXT:
793 ok( GlobalSize( data ) == 10, "wrong len %ld\n", GlobalSize( data ));
794 break;
795 case CF_UNICODETEXT:
796 ok( GlobalSize( data ) == 10 * sizeof(WCHAR), "wrong len %ld\n", GlobalSize( data ));
797 break;
798 }
799 }
800 if (!tests[i].expected[j])
801 {
803 ok(cf == 0, "%u: cf %04x\n", i, cf);
804 }
805
806 /* now with delayed rendering */
807
808 r = EmptyClipboard();
809 ok(r, "%u: gle %d\n", i, GetLastError());
810
811 rendered = SendMessageA( hwnd, WM_USER, 0, 0 );
812 ok( !rendered, "%u: formats %08x have been rendered\n", i, rendered );
813
815 rendered = SendMessageA( hwnd, WM_USER, 0, 0 );
816 ok( !rendered, "%u: formats %08x have been rendered\n", i, rendered );
817
819 ok( count == 1, "%u: count %u\n", i, count );
820
821 r = CloseClipboard();
822 ok(r, "%u: gle %d\n", i, GetLastError());
823 rendered = SendMessageA( hwnd, WM_USER, 0, 0 );
824 ok( !rendered, "%u: formats %08x have been rendered\n", i, rendered );
825
827 for (j = 0; tests[i].expected[j]; j++)
828 {
830 ok( r, "%u: %04x not available\n", i, tests[i].expected[j] );
831 }
832 ok( count == j, "%u: count %u instead of %u\n", i, count, j );
833 rendered = SendMessageA( hwnd, WM_USER, 0, 0 );
834 ok( !rendered, "%u: formats %08x have been rendered\n", i, rendered );
835
837 ok(r, "%u: gle %d\n", i, GetLastError());
838 cf = 0;
839 for (j = 0; tests[i].expected[j]; j++)
840 {
842 ok(cf == tests[i].expected[j], "%u.%u: got %04x instead of %04x\n",
843 i, j, cf, tests[i].expected[j] );
844 if (cf != tests[i].expected[j]) break;
845 rendered = SendMessageA( hwnd, WM_USER, 0, 0 );
846 ok( !rendered, "%u.%u: formats %08x have been rendered\n", i, j, rendered );
848 rendered = SendMessageA( hwnd, WM_USER, 0, 0 );
849 if (cf == CF_LOCALE)
850 {
851 ok(data != NULL, "%u: CF_LOCALE no data\n", i);
852 ok( !rendered, "%u.%u: formats %08x have been rendered\n", i, j, rendered );
853 }
854 else
855 {
856 ok(!data, "%u: format %04x got data %p\n", i, cf, data);
857 ok( rendered == (1 << tests[i].format),
858 "%u.%u: formats %08x have been rendered\n", i, j, rendered );
859 /* try to render a second time */
861 rendered = SendMessageA( hwnd, WM_USER, 0, 0 );
862 ok( rendered == (1 << tests[i].format),
863 "%u.%u: formats %08x have been rendered\n", i, j, rendered );
864 }
865 }
866 if (!tests[i].expected[j])
867 {
869 ok(cf == 0, "%u: cf %04x\n", i, cf);
870 }
871 r = CloseClipboard();
872 ok(r, "%u: gle %d\n", i, GetLastError());
873 rendered = SendMessageA( hwnd, WM_USER, 0, 0 );
874 ok( !rendered, "%u: formats %08x have been rendered\n", i, rendered );
875 }
876
878 ok(r, "gle %d\n", GetLastError());
879 r = EmptyClipboard();
880 ok(r, "gle %d\n", GetLastError());
881 r = CloseClipboard();
882 ok(r, "gle %d\n", GetLastError());
884}
#define ERROR_SUCCESS
Definition: deptool.c:10
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
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
LCID WINAPI GetUserDefaultLCID(void)
Definition: lang.c:772
static struct test_info tests[]
BOOL expected
Definition: store.c:2063
static HBITMAP create_bitmap(void)
Definition: clipboard.c:534
static LRESULT CALLBACK renderer_winproc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
Definition: clipboard.c:568
static HBITMAP create_dib(BOOL v5)
Definition: clipboard.c:542
#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

Referenced by START_TEST().

◆ winproc_wrapper()

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

Definition at line 184 of file clipboard.c.

185{
186 static int wm_renderallformats;
187 static int wm_drawclipboard;
188 static int seqno;
189 DWORD msg_flags = InSendMessageEx( NULL );
190
191 if (!seqno) seqno = GetClipboardSequenceNumber();
192
193 trace( "%p msg %04x\n", hwnd, msg );
194 if (!wm_renderallformats)
195 {
196 ok( GetClipboardOwner() == hwnd, "%04x: wrong owner %p/%p\n", msg, GetClipboardOwner(), hwnd );
197 ok( seqno == GetClipboardSequenceNumber(), "%04x: seqno changed\n", msg );
198 }
199 else
200 {
201 ok( !GetClipboardOwner(), "%04x: wrong owner %p\n", msg, GetClipboardOwner() );
202 ok( seqno + 1 == GetClipboardSequenceNumber(), "%04x: seqno unchanged\n", msg );
203 }
204 ok( GetClipboardViewer() == hwnd, "%04x: wrong viewer %p/%p\n", msg, GetClipboardViewer(), hwnd );
205 ok( GetOpenClipboardWindow() == hwnd, "%04x: wrong open win %p/%p\n",
207
208 switch (msg)
209 {
210 case WM_DESTROY:
211 ok( wm_renderallformats, "didn't receive WM_RENDERALLFORMATS before WM_DESTROY\n" );
212 ok( wm_drawclipboard, "didn't receive WM_DRAWCLIPBOARD before WM_DESTROY\n" );
213 break;
214 case WM_DRAWCLIPBOARD:
215 ok( msg_flags == ISMEX_NOSEND, "WM_DRAWCLIPBOARD wrong flags %x\n", msg_flags );
217 break;
219 ok( msg_flags == ISMEX_NOSEND, "WM_RENDERALLFORMATS wrong flags %x\n", msg_flags );
220 wm_renderallformats++;
221 break;
222 }
223 return old_proc( hwnd, msg, wp, lp );
224}
#define WM_DESTROY
Definition: winuser.h:1599
#define WM_RENDERALLFORMATS
Definition: winuser.h:1857

Referenced by test_ClipboardOwner().

Variable Documentation

◆ argv0

char* argv0
static

Definition at line 38 of file clipboard.c.

Referenced by run_process(), and START_TEST().

◆ bitmap

HBITMAP bitmap
static

Definition at line 1344 of file clipboard.c.

◆ bitmap2

◆ clipboard_cs

CRITICAL_SECTION clipboard_cs
static

Definition at line 893 of file clipboard.c.

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

◆ count

Definition at line 35 of file clipboard.c.

◆ cross_thread

BOOL cross_thread
static

Definition at line 900 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 901 of file clipboard.c.

Referenced by clipboard_thread(), and clipboard_wnd_proc().

◆ format_id

◆ len

Definition at line 2030 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 899 of file clipboard.c.

Referenced by clipboard_wnd_proc().

◆ next_wnd

HWND next_wnd
static

Definition at line 894 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 1345 of file clipboard.c.

Referenced by BitmapClipper_CopyPalette(), BitmapTestSrc_CopyPalette(), BmpEncoder_SetPalette(), BmpFrameDecode_ReadRLE4(), BmpFrameDecode_ReadRLE8(), BmpFrameEncode_SetPalette(), check_halftone_palette(), 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(), 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_decode_1bpp(), test_decode_24bpp(), test_decode_4bpp(), 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_multiframegif(), 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(), 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(), and wined3d_swapchain_set_palette().

◆ 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 902 of file clipboard.c.

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

◆ wm_clipboardupdate

UINT wm_clipboardupdate
static

Definition at line 896 of file clipboard.c.

Referenced by clipboard_wnd_proc().

◆ wm_destroyclipboard

UINT wm_destroyclipboard
static

Definition at line 897 of file clipboard.c.

Referenced by clipboard_wnd_proc().

◆ wm_drawclipboard

UINT wm_drawclipboard
static

Definition at line 895 of file clipboard.c.

◆ wm_renderformat

UINT wm_renderformat
static

Definition at line 898 of file clipboard.c.

Referenced by clipboard_wnd_proc().