Commit a96b0170 authored by Alexandre Julliard's avatar Alexandre Julliard

user32/tests: Add some tests for GDI clipboard formats.

parent 228d8559
......@@ -754,6 +754,10 @@ static BOOL is_freed( HANDLE handle )
}
static UINT format_id;
static HBITMAP bitmap, bitmap2;
static HPALETTE palette;
static HPEN pen;
static const LOGPALETTE logpalette = { 0x300, 1 };
static void test_handles( HWND hwnd )
{
......@@ -766,6 +770,10 @@ static void test_handles( HWND hwnd )
trace( "hwnd %p\n", hwnd );
htext = create_text();
htext2 = create_text();
bitmap = CreateBitmap( 10, 10, 1, 1, NULL );
bitmap2 = CreateBitmap( 10, 10, 1, 1, NULL );
palette = CreatePalette( &logpalette );
pen = CreatePen( PS_SOLID, 1, 0 );
r = OpenClipboard( hwnd );
ok( r, "gle %d\n", GetLastError() );
......@@ -778,6 +786,18 @@ static void test_handles( HWND hwnd )
h = SetClipboardData( format_id, htext2 );
ok( h == htext2, "got %p\n", h );
ok( is_moveable( h ), "expected moveable mem %p\n", h );
h = SetClipboardData( CF_BITMAP, bitmap );
ok( h == bitmap, "got %p\n", h );
ok( GetObjectType( h ) == OBJ_BITMAP, "expected bitmap %p\n", h );
h = SetClipboardData( CF_PALETTE, palette );
ok( h == palette, "got %p\n", h );
ok( GetObjectType( h ) == OBJ_PAL, "expected palette %p\n", h );
h = SetClipboardData( CF_GDIOBJFIRST + 1, bitmap2 );
ok( h == bitmap2, "got %p\n", h );
ok( GetObjectType( h ) == OBJ_BITMAP, "expected bitmap %p\n", h );
h = SetClipboardData( CF_GDIOBJFIRST + 2, pen );
ok( h == pen, "got %p\n", h );
ok( GetObjectType( h ) == OBJ_PEN, "expected pen %p\n", h );
data = GetClipboardData( CF_TEXT );
ok( data == htext, "wrong data %p\n", data );
......@@ -793,6 +813,10 @@ static void test_handles( HWND hwnd )
/* data handles are still valid */
ok( is_moveable( htext ), "expected moveable mem %p\n", htext );
ok( is_moveable( htext2 ), "expected moveable mem %p\n", htext );
ok( GetObjectType( bitmap ) == OBJ_BITMAP, "expected bitmap %p\n", bitmap );
ok( GetObjectType( bitmap2 ) == OBJ_BITMAP, "expected bitmap %p\n", bitmap2 );
ok( GetObjectType( palette ) == OBJ_PAL, "expected palette %p\n", palette );
ok( GetObjectType( pen ) == OBJ_PEN, "expected pen %p\n", pen );
r = OpenClipboard( hwnd );
ok( r, "gle %d\n", GetLastError() );
......@@ -806,12 +830,6 @@ static void test_handles( HWND hwnd )
data = GetClipboardData( CF_TEXT );
todo_wine ok( is_fixed( data ), "expected fixed mem %p\n", data );
data = GetClipboardData( CF_OEMTEXT );
todo_wine ok( is_fixed( data ), "expected fixed mem %p\n", data );
data = GetClipboardData( CF_UNICODETEXT );
todo_wine ok( is_fixed( data ), "expected fixed mem %p\n", data );
data = GetClipboardData( format_id );
todo_wine ok( is_fixed( data ), "expected fixed mem %p\n", data );
}
......@@ -827,12 +845,38 @@ static void test_handles( HWND hwnd )
ok( data == htext2, "wrong data %p, cf %08x\n", data, format_id );
}
data = GetClipboardData( CF_OEMTEXT );
todo_wine ok( is_fixed( data ), "expected fixed mem %p\n", data );
data = GetClipboardData( CF_UNICODETEXT );
todo_wine ok( is_fixed( data ), "expected fixed mem %p\n", data );
data = GetClipboardData( CF_BITMAP );
ok( data == bitmap, "expected bitmap %p\n", data );
data = GetClipboardData( CF_PALETTE );
ok( data == palette, "expected palette %p\n", data );
data = GetClipboardData( CF_GDIOBJFIRST + 1 );
ok( data == bitmap2, "expected bitmap2 %p\n", data );
data = GetClipboardData( CF_GDIOBJFIRST + 2 );
ok( data == pen, "expected pen %p\n", data );
data = GetClipboardData( CF_DIB );
todo_wine ok( is_fixed( data ), "expected fixed mem %p\n", data );
data = GetClipboardData( CF_DIBV5 );
todo_wine ok( is_fixed( data ), "expected fixed mem %p\n", data );
ok( GetObjectType( bitmap ) == OBJ_BITMAP, "expected bitmap %p\n", bitmap );
ok( GetObjectType( bitmap2 ) == OBJ_BITMAP, "expected bitmap %p\n", bitmap2 );
ok( GetObjectType( palette ) == OBJ_PAL, "expected palette %p\n", palette );
ok( GetObjectType( pen ) == OBJ_PEN, "expected pen %p\n", pen );
r = EmptyClipboard();
ok( r, "gle %d\n", GetLastError() );
/* w2003, w2008 don't seem to free the data here */
ok( is_freed( htext ) || broken( !is_freed( htext )), "expected freed mem %p\n", htext );
ok( is_freed( htext2 ) || broken( !is_freed( htext2 )), "expected freed mem %p\n", htext );
ok( !GetObjectType( bitmap ), "expected freed handle %p\n", bitmap );
ok( !GetObjectType( palette ), "expected freed handle %p\n", palette );
ok( GetObjectType( bitmap2 ) == OBJ_BITMAP, "expected bitmap2 %p\n", bitmap2 );
ok( GetObjectType( pen ) == OBJ_PEN, "expected pen %p\n", pen );
r = CloseClipboard();
ok( r, "gle %d\n", GetLastError() );
......@@ -863,6 +907,26 @@ static DWORD WINAPI test_handles_thread2( void *arg )
ptr = GlobalLock( h );
if (ptr) ok( !strcmp( "test", ptr ), "wrong data '%.5s'\n", ptr );
GlobalUnlock( h );
h = GetClipboardData( CF_BITMAP );
ok( GetObjectType( h ) == OBJ_BITMAP, "expected bitmap %p\n", h );
ok( h == bitmap, "different bitmap %p / %p\n", h, bitmap );
trace( "bitmap %p\n", h );
h = GetClipboardData( CF_PALETTE );
ok( GetObjectType( h ) == OBJ_PAL, "expected palette %p\n", h );
ok( h == palette, "different palette %p / %p\n", h, palette );
trace( "palette %p\n", h );
h = GetClipboardData( CF_GDIOBJFIRST + 1 );
ok( GetObjectType( h ) == OBJ_BITMAP, "expected bitmap %p\n", h );
ok( h == bitmap2, "different bitmap %p / %p\n", h, bitmap2 );
trace( "bitmap2 %p\n", h );
h = GetClipboardData( CF_GDIOBJFIRST + 2 );
ok( GetObjectType( h ) == OBJ_PEN, "expected pen %p\n", h );
ok( h == pen, "different pen %p / %p\n", h, pen );
trace( "pen %p\n", h );
h = GetClipboardData( CF_DIB );
todo_wine ok( is_fixed( h ), "expected fixed mem %p\n", h );
h = GetClipboardData( CF_DIBV5 );
todo_wine ok( is_fixed( h ), "expected fixed mem %p\n", h );
r = CloseClipboard();
ok( r, "gle %d\n", GetLastError() );
return 0;
......@@ -887,6 +951,22 @@ static void test_handles_process( const char *str )
ptr = GlobalLock( h );
if (ptr) ok( !strcmp( str, ptr ), "wrong data '%.5s'\n", ptr );
GlobalUnlock( h );
h = GetClipboardData( CF_BITMAP );
todo_wine ok( GetObjectType( h ) == OBJ_BITMAP, "expected bitmap %p\n", h );
trace( "bitmap %p\n", h );
h = GetClipboardData( CF_PALETTE );
todo_wine ok( GetObjectType( h ) == OBJ_PAL, "expected palette %p\n", h );
trace( "palette %p\n", h );
h = GetClipboardData( CF_GDIOBJFIRST + 1 );
ok( !GetObjectType( h ), "expected invalid %p\n", h );
trace( "bitmap2 %p\n", h );
h = GetClipboardData( CF_GDIOBJFIRST + 2 );
ok( !GetObjectType( h ), "expected invalid %p\n", h );
trace( "pen %p\n", h );
h = GetClipboardData( CF_DIB );
todo_wine ok( is_fixed( h ), "expected fixed mem %p\n", h );
h = GetClipboardData( CF_DIBV5 );
todo_wine ok( is_fixed( h ), "expected fixed mem %p\n", h );
r = CloseClipboard();
ok( r, "gle %d\n", GetLastError() );
}
......@@ -897,13 +977,18 @@ static void test_data_handles(void)
HANDLE h;
HWND hwnd = CreateWindowA( "static", NULL, WS_POPUP, 0, 0, 10, 10, 0, 0, 0, NULL );
format_id = RegisterClipboardFormatA( "my_cool_clipboard_format" );
ok( hwnd != 0, "window creation failed\n" );
format_id = RegisterClipboardFormatA( "my_cool_clipboard_format" );
test_handles( 0 );
test_handles( GetDesktopWindow() );
test_handles( hwnd );
run_thread( test_handles_thread, hwnd, __LINE__ );
bitmap = CreateBitmap( 10, 10, 1, 1, NULL );
bitmap2 = CreateBitmap( 10, 10, 1, 1, NULL );
palette = CreatePalette( &logpalette );
pen = CreatePen( PS_SOLID, 1, 0 );
r = OpenClipboard( hwnd );
ok( r, "gle %d\n", GetLastError() );
r = EmptyClipboard();
......@@ -912,6 +997,14 @@ static void test_data_handles(void)
ok( is_moveable( h ), "expected moveable mem %p\n", h );
h = SetClipboardData( format_id, create_text() );
ok( is_moveable( h ), "expected moveable mem %p\n", h );
h = SetClipboardData( CF_BITMAP, bitmap );
ok( GetObjectType( h ) == OBJ_BITMAP, "expected bitmap %p\n", h );
h = SetClipboardData( CF_PALETTE, palette );
ok( GetObjectType( h ) == OBJ_PAL, "expected palette %p\n", h );
h = SetClipboardData( CF_GDIOBJFIRST + 1, bitmap2 );
ok( GetObjectType( h ) == OBJ_BITMAP, "expected bitmap %p\n", h );
h = SetClipboardData( CF_GDIOBJFIRST + 2, pen );
ok( GetObjectType( h ) == OBJ_PEN, "expected pen %p\n", h );
r = CloseClipboard();
ok( r, "gle %d\n", GetLastError() );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment