Alexandre Julliard : user32/tests: Add some tests for GDI clipboard formats.
Alexandre Julliard
julliard at winehq.org
Thu Aug 18 10:23:25 CDT 2016
Module: wine
Branch: master
Commit: a96b01707039aa0427ed12698b298f3df26328bc
URL: http://source.winehq.org/git/wine.git/?a=commit;h=a96b01707039aa0427ed12698b298f3df26328bc
Author: Alexandre Julliard <julliard at winehq.org>
Date: Thu Aug 18 20:51:16 2016 +0900
user32/tests: Add some tests for GDI clipboard formats.
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/user32/tests/clipboard.c | 107 +++++++++++++++++++++++++++++++++++++++---
1 file changed, 100 insertions(+), 7 deletions(-)
diff --git a/dlls/user32/tests/clipboard.c b/dlls/user32/tests/clipboard.c
index d218941..2e9cd24 100644
--- a/dlls/user32/tests/clipboard.c
+++ b/dlls/user32/tests/clipboard.c
@@ -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() );
More information about the wine-cvs
mailing list