sync user32_winetest with wine 1.1.34
authorChristoph von Wittich <christoph_vw@reactos.org>
Sat, 5 Dec 2009 19:25:28 +0000 (19:25 +0000)
committerChristoph von Wittich <christoph_vw@reactos.org>
Sat, 5 Dec 2009 19:25:28 +0000 (19:25 +0000)
svn path=/trunk/; revision=44416

rostests/winetests/user32/class.c
rostests/winetests/user32/dde.c
rostests/winetests/user32/edit.c
rostests/winetests/user32/win.c

index 7b42ce3..b11b5d2 100755 (executable)
@@ -572,6 +572,7 @@ static void test_instances(void)
     SetClassLongPtrA( hwnd, GCLP_HMODULE, 0xdeadbeef );
     check_instance( "EDIT", (HINSTANCE)0x12345678, (HINSTANCE)0x12345678, (HINSTANCE)0xdeadbeef );
     check_thread_instance( "EDIT", (HINSTANCE)0x12345678, (HINSTANCE)0x12345678, (HINSTANCE)0xdeadbeef );
+    DestroyWindow(hwnd);
 }
 
 static void test_builtinproc(void)
@@ -707,6 +708,7 @@ static void test_builtinproc(void)
 
         oldproc = (WNDPROC)SetWindowLongPtrW(hwnd, GWLP_WNDPROC, (LONG_PTR)ClassTest_WndProc);
         ok(IS_WNDPROC_HANDLE(oldproc) == FALSE, "Class %s shouldn't return a handle\n", NORMAL_CLASSES[i]);
+        SetWindowLongPtrW(hwnd, GWLP_WNDPROC, (LONG_PTR)oldproc);
         DestroyWindow(hwnd);
     }
 
@@ -747,6 +749,8 @@ static void test_builtinproc(void)
     CallWindowProcW((WNDPROC)GetWindowLongPtrW(hwnd, GWLP_WNDPROC), hwnd, WM_GETTEXT, 120, (LPARAM)buf);
     ok(memcmp(buf, classW, sizeof(classW)) == 0, "WM_GETTEXT invalid return\n");
 
+    SetWindowLongPtrA(hwnd, GWLP_WNDPROC, (LONG_PTR)oldproc);
+
     DestroyWindow(hwnd);
 
     hwnd = CreateWindowA(WC_EDITA, classA, WS_OVERLAPPEDWINDOW,
@@ -768,7 +772,7 @@ static void test_builtinproc(void)
     CallWindowProcW((WNDPROC)GetWindowLongPtrW(hwnd, GWLP_WNDPROC), hwnd, WM_GETTEXT, 120, (LPARAM)buf);
     ok(memcmp(buf, classW, sizeof(classW)) == 0, "WM_GETTEXT invalid return\n");
 
-    SetWindowLongPtrW(hwnd, GWLP_WNDPROC, (LONG_PTR)ClassTest_WndProc);
+    oldproc = (WNDPROC)SetWindowLongPtrW(hwnd, GWLP_WNDPROC, (LONG_PTR)ClassTest_WndProc);
     SetWindowTextW(hwnd, unistring);
     CallWindowProcW((WNDPROC)GetWindowLongPtrW(hwnd, GWLP_WNDPROC), hwnd, WM_GETTEXT, 120, (LPARAM)buf);
     ok(memcmp(buf, unistring, sizeof(unistring)) == 0, "WM_GETTEXT invalid return\n");
@@ -781,6 +785,8 @@ static void test_builtinproc(void)
     CallWindowProcA((WNDPROC)GetWindowLongPtrA(hwnd, GWLP_WNDPROC), hwnd, WM_GETTEXT, 120, (LPARAM)buf);
     ok(memcmp(buf, classA, sizeof(classA)) == 0, "WM_GETTEXT invalid return\n");
 
+    SetWindowLongPtrW(hwnd, GWLP_WNDPROC, (LONG_PTR)oldproc);
+
     DestroyWindow(hwnd);
 }
 
index 202bb41..3a0d656 100755 (executable)
@@ -2013,7 +2013,7 @@ static void test_UnpackDDElParam(void)
        broken(hi == 0xbeef), /* win2k */
        "Expected 0, got %08lx\n", hi);
 
-    hglobal = GlobalAlloc(GMEM_DDESHARE, 2);
+    hglobal = GlobalAlloc(GMEM_DDESHARE, 2 * sizeof(*ptr));
     ptr = GlobalLock(hglobal);
     ptr[0] = 0xcafebabe;
     ptr[1] = 0xdeadbeef;
@@ -2067,6 +2067,8 @@ static void test_UnpackDDElParam(void)
     ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
     ok(lo == 0, "Expected 0, got %08lx\n", lo);
     ok(hi == 0xcafebabe, "Expected 0xcafebabe, got %08lx\n", hi);
+
+    GlobalFree(hglobal);
 }
 
 static HDDEDATA CALLBACK server_end_to_end_callback(UINT uType, UINT uFmt, HCONV hconv,
index 5ca012e..e42127f 100755 (executable)
@@ -1239,6 +1239,45 @@ static void test_edit_control_5(void)
     DestroyWindow(hWnd);
 }
 
+/* Test WM_GETTEXT processing
+ * after destroy messages
+ */
+static void test_edit_control_6(void)
+{
+    static const char *str = "test\r\ntest";
+    char buf[MAXLEN];
+    LONG ret;
+    HWND hWnd;
+
+    hWnd = CreateWindowEx(0,
+              "EDIT",
+              "Test",
+              0,
+              10, 10, 1, 1,
+              NULL, NULL, hinst, NULL);
+    assert(hWnd);
+
+    ret = SendMessageA(hWnd, WM_SETTEXT, 0, (LPARAM)str);
+    ok(ret == TRUE, "Expected %d, got %d\n", TRUE, ret);
+    ret = SendMessageA(hWnd, WM_GETTEXT, MAXLEN, (LPARAM)buf);
+    ok(ret == lstrlen(str), "Expected %s, got len %d\n", str, ret);
+    ok(!lstrcmp(buf, str), "Expected %s, got %s\n", str, buf);
+    buf[0] = 0;
+    ret = SendMessageA(hWnd, WM_DESTROY, 0, 0);
+    ok(ret == 0, "Expected 0, got %d\n", ret);
+    ret = SendMessageA(hWnd, WM_GETTEXT, MAXLEN, (LPARAM)buf);
+    ok(ret == lstrlen(str), "Expected %s, got len %d\n", str, ret);
+    ok(!lstrcmp(buf, str), "Expected %s, got %s\n", str, buf);
+    buf[0] = 0;
+    ret = SendMessageA(hWnd, WM_NCDESTROY, 0, 0);
+    ok(ret == 0, "Expected 0, got %d\n", ret);
+    ret = SendMessageA(hWnd, WM_GETTEXT, MAXLEN, (LPARAM)buf);
+    ok(ret == 0, "Expected 0, got len %d\n", ret);
+    ok(!lstrcmp(buf, ""), "Expected empty string, got %s\n", buf);
+
+    DestroyWindow(hWnd);
+}
+
 static void test_edit_control_limittext(void)
 {
     HWND hwEdit;
@@ -2270,6 +2309,7 @@ START_TEST(edit)
     test_edit_control_3();
     test_edit_control_4();
     test_edit_control_5();
+    test_edit_control_6();
     test_edit_control_limittext();
     test_margins();
     test_margins_font_change();
index 0bd6fbf..24e6ac2 100644 (file)
@@ -2298,7 +2298,7 @@ static LRESULT WINAPI set_focus_on_activate_proc(HWND hwnd, UINT msg, WPARAM wp,
 
 static void test_SetFocus(HWND hwnd)
 {
-    HWND child;
+    HWND child, child2;
     WNDPROC old_wnd_proc;
 
     /* check if we can set focus to non-visible windows */
@@ -2325,6 +2325,14 @@ static void test_SetFocus(HWND hwnd)
     ok( !(GetWindowLong(child,GWL_STYLE) & WS_VISIBLE), "Child %p is visible\n", child );
     ok( GetFocus() == hwnd, "Focus should be on parent %p, not %p\n", hwnd, GetFocus() );
     ShowWindow(child, SW_SHOW);
+    child2 = CreateWindowExA(0, "static", NULL, WS_CHILD, 0, 0, 0, 0, child, 0, 0, NULL);
+    assert(child2);
+    ShowWindow(child2, SW_SHOW);
+    SetFocus(child2);
+    ShowWindow(child, SW_HIDE);
+    ok( !(GetWindowLong(child,GWL_STYLE) & WS_VISIBLE), "Child %p is visible\n", child );
+    ok( GetFocus() == child2, "Focus should be on %p, not %p\n", child2, GetFocus() );
+    ShowWindow(child, SW_SHOW);
     SetFocus(child);
     ok( GetFocus() == child, "Focus should be on child %p\n", child );
     SetWindowPos(child,0,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_HIDEWINDOW);
@@ -2368,6 +2376,7 @@ todo_wine
 
     SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)old_wnd_proc);
 
+    DestroyWindow( child2 );
     DestroyWindow( child );
 }