Commit 52d90e3c authored by Alexandre Julliard's avatar Alexandre Julliard

user32/tests: Add some tests for WindowFromDC and destroyed windows.

parent 08193ed7
......@@ -52,11 +52,14 @@ static void test_dc_attributes(void)
rop = GetROP2( hdc );
ok( rop == R2_WHITE, "wrong ROP2 %d\n", rop );
ok( WindowFromDC( hdc ) == hwnd_cache, "wrong window\n" );
ReleaseDC( hwnd_cache, hdc );
ok( WindowFromDC( hdc ) == 0, "wrong window\n" );
hdc = GetDC( hwnd_cache );
rop = GetROP2( hdc );
ok( rop == def_rop, "wrong ROP2 %d after release\n", rop );
SetROP2( hdc, R2_WHITE );
ok( WindowFromDC( hdc ) == hwnd_cache, "wrong window\n" );
ReleaseDC( hwnd_cache, hdc );
old_hdc = hdc;
......@@ -115,6 +118,7 @@ static void test_dc_attributes(void)
ok( rop == 0, "got %d\n", rop );
rop = GetROP2( old_hdc );
ok( rop == 0, "got %d\n", rop );
ok( WindowFromDC( old_hdc ) == 0, "wrong window\n" );
/* test own DC */
......@@ -124,11 +128,14 @@ static void test_dc_attributes(void)
ok( rop == R2_WHITE, "wrong ROP2 %d\n", rop );
old_hdc = hdc;
ok( WindowFromDC( hdc ) == hwnd_owndc, "wrong window\n" );
ReleaseDC( hwnd_owndc, hdc );
ok( WindowFromDC( hdc ) == hwnd_owndc, "wrong window\n" );
hdc = GetDC( hwnd_owndc );
ok( old_hdc == hdc, "didn't get same DC %p/%p\n", old_hdc, hdc );
rop = GetROP2( hdc );
ok( rop == R2_WHITE, "wrong ROP2 %d after release\n", rop );
ok( WindowFromDC( hdc ) == hwnd_owndc, "wrong window\n" );
ReleaseDC( hwnd_owndc, hdc );
rop = GetROP2( hdc );
ok( rop == R2_WHITE, "wrong ROP2 %d after second release\n", rop );
......@@ -141,11 +148,14 @@ static void test_dc_attributes(void)
ok( rop == R2_WHITE, "wrong ROP2 %d\n", rop );
old_hdc = hdc;
ok( WindowFromDC( hdc ) == hwnd_classdc, "wrong window\n" );
ReleaseDC( hwnd_classdc, hdc );
ok( WindowFromDC( hdc ) == hwnd_classdc, "wrong window\n" );
hdc = GetDC( hwnd_classdc );
ok( old_hdc == hdc, "didn't get same DC %p/%p\n", old_hdc, hdc );
rop = GetROP2( hdc );
ok( rop == R2_WHITE, "wrong ROP2 %d after release\n", rop );
ok( WindowFromDC( hdc ) == hwnd_classdc, "wrong window\n" );
ReleaseDC( hwnd_classdc, hdc );
rop = GetROP2( hdc );
ok( rop == R2_WHITE, "wrong ROP2 %d after second release\n", rop );
......@@ -154,12 +164,15 @@ static void test_dc_attributes(void)
old_hdc = GetDC( hwnd_classdc );
SetROP2( old_hdc, R2_BLACK );
ok( WindowFromDC( old_hdc ) == hwnd_classdc, "wrong window\n" );
hdc = GetDC( hwnd_classdc2 );
ok( old_hdc == hdc, "didn't get same DC %p/%p\n", old_hdc, hdc );
rop = GetROP2( hdc );
ok( rop == R2_BLACK, "wrong ROP2 %d for other window\n", rop );
ok( WindowFromDC( hdc ) == hwnd_classdc2, "wrong window\n" );
ReleaseDC( hwnd_classdc, old_hdc );
ReleaseDC( hwnd_classdc, hdc );
ok( WindowFromDC( hdc ) == hwnd_classdc2, "wrong window\n" );
rop = GetROP2( hdc );
ok( rop == R2_BLACK, "wrong ROP2 %d after release\n", rop );
}
......@@ -597,19 +610,83 @@ static void test_dc_layout(void)
static void test_destroyed_window(void)
{
HDC dc;
HDC dc, old_dc;
HDC hdcs[30];
int i, rop;
dc = GetDCEx(hwnd_cache, 0, DCX_USESTYLE);
ok(!dc, "Got a non-NULL DC (%p) for a destroyed window.\n", dc);
dc = GetDC( hwnd_cache );
SetROP2( dc, R2_WHITE );
rop = GetROP2( dc );
ok( rop == R2_WHITE, "wrong ROP2 %d\n", rop );
ok( WindowFromDC( dc ) == hwnd_cache, "wrong window\n" );
old_dc = dc;
DestroyWindow( hwnd_cache );
rop = GetROP2( dc );
todo_wine ok( rop == 0, "wrong ROP2 %d\n", rop );
ok( WindowFromDC( dc ) == 0, "wrong window\n" );
ok( !ReleaseDC( hwnd_cache, dc ), "ReleaseDC succeeded\n" );
dc = GetDC( hwnd_cache );
ok( !dc, "Got a non-NULL DC (%p) for a destroyed window\n", dc );
for (i = 0; i < 30; i++)
{
dc = hdcs[i] = GetDCEx( hwnd_parent, 0, DCX_CACHE | DCX_USESTYLE );
if (dc == old_dc) break;
}
ok( i < 30, "DC for destroyed window not reused\n" );
while (i > 0) ReleaseDC( hwnd_parent, hdcs[--i] );
dc = GetDC( hwnd_classdc );
SetROP2( dc, R2_WHITE );
rop = GetROP2( dc );
ok( rop == R2_WHITE, "wrong ROP2 %d\n", rop );
ok( WindowFromDC( dc ) == hwnd_classdc, "wrong window\n" );
old_dc = dc;
dc = GetDC( hwnd_classdc2 );
ok( old_dc == dc, "wrong DC\n" );
rop = GetROP2( dc );
ok( rop == R2_WHITE, "wrong ROP2 %d\n", rop );
ok( WindowFromDC( dc ) == hwnd_classdc2, "wrong window\n" );
DestroyWindow( hwnd_classdc2 );
dc = GetDCEx(hwnd_owndc, 0, DCX_USESTYLE);
ok(!dc, "Got a non-NULL DC (%p) for a destroyed window.\n", dc);
rop = GetROP2( dc );
ok( rop == R2_WHITE, "wrong ROP2 %d\n", rop );
ok( WindowFromDC( dc ) == 0, "wrong window\n" );
todo_wine ok( !ReleaseDC( hwnd_classdc2, dc ), "ReleaseDC succeeded\n" );
dc = GetDC( hwnd_classdc2 );
ok( !dc, "Got a non-NULL DC (%p) for a destroyed window\n", dc );
dc = GetDC( hwnd_classdc );
ok( dc != 0, "Got NULL DC\n" );
rop = GetROP2( dc );
todo_wine ok( rop == R2_WHITE, "wrong ROP2 %d\n", rop );
ok( WindowFromDC( dc ) == hwnd_classdc, "wrong window\n" );
DestroyWindow( hwnd_classdc );
rop = GetROP2( dc );
todo_wine ok( rop == R2_WHITE, "wrong ROP2 %d\n", rop );
ok( WindowFromDC( dc ) == 0, "wrong window\n" );
todo_wine ok( !ReleaseDC( hwnd_classdc, dc ), "ReleaseDC succeeded\n" );
dc = GetDC( hwnd_classdc );
ok( !dc, "Got a non-NULL DC (%p) for a destroyed window\n", dc );
dc = GetDC( hwnd_owndc );
ok( dc != 0, "Got NULL DC\n" );
rop = GetROP2( dc );
ok( rop == R2_WHITE, "wrong ROP2 %d\n", rop );
ok( WindowFromDC( dc ) == hwnd_owndc, "wrong window\n" );
DestroyWindow( hwnd_owndc );
dc = GetDCEx(hwnd_classdc, 0, DCX_USESTYLE);
ok(!dc, "Got a non-NULL DC (%p) for a destroyed window.\n", dc);
rop = GetROP2( dc );
ok( rop == 0, "wrong ROP2 %d\n", rop );
ok( WindowFromDC( dc ) == 0, "wrong window\n" );
ok( !ReleaseDC( hwnd_owndc, dc ), "ReleaseDC succeeded\n" );
dc = GetDC( hwnd_owndc );
ok( !dc, "Got a non-NULL DC (%p) for a destroyed window\n", dc );
dc = GetDCEx(hwnd_classdc2, 0, DCX_USESTYLE);
ok(!dc, "Got a non-NULL DC (%p) for a destroyed window.\n", dc);
DestroyWindow( hwnd_parent );
}
START_TEST(dce)
......@@ -661,12 +738,6 @@ START_TEST(dce)
test_scroll_window();
test_invisible_create();
test_dc_layout();
DestroyWindow(hwnd_parent);
DestroyWindow(hwnd_classdc2);
DestroyWindow(hwnd_classdc);
DestroyWindow(hwnd_owndc);
DestroyWindow(hwnd_cache);
/* this should be last */
test_destroyed_window();
}
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