Dmitry Timoshkov : user32: Add a test for GetClassInfo, make it pass under Wine.

Alexandre Julliard julliard at winehq.org
Tue Aug 3 13:10:34 CDT 2010


Module: wine
Branch: master
Commit: 5aa45d9cf4cb1f089eb42428f7d3adf64d2307fe
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=5aa45d9cf4cb1f089eb42428f7d3adf64d2307fe

Author: Dmitry Timoshkov <dmitry at codeweavers.com>
Date:   Tue Aug  3 17:51:38 2010 +0900

user32: Add a test for GetClassInfo, make it pass under Wine.

---

 dlls/user32/class.c       |   12 +++++++++
 dlls/user32/tests/class.c |   61 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 73 insertions(+), 0 deletions(-)

diff --git a/dlls/user32/class.c b/dlls/user32/class.c
index 6d1ab7f..91409e2 100644
--- a/dlls/user32/class.c
+++ b/dlls/user32/class.c
@@ -1070,6 +1070,12 @@ BOOL WINAPI GetClassInfoExA( HINSTANCE hInstance, LPCSTR name, WNDCLASSEXA *wc )
 
     TRACE("%p %s %p\n", hInstance, debugstr_a(name), wc);
 
+    if (!wc)
+    {
+        SetLastError( ERROR_NOACCESS );
+        return FALSE;
+    }
+
     if (!hInstance) hInstance = user32_module;
 
     if (!IS_INTRESOURCE(name))
@@ -1115,6 +1121,12 @@ BOOL WINAPI GetClassInfoExW( HINSTANCE hInstance, LPCWSTR name, WNDCLASSEXW *wc
 
     TRACE("%p %s %p\n", hInstance, debugstr_w(name), wc);
 
+    if (!wc)
+    {
+        SetLastError( ERROR_NOACCESS );
+        return FALSE;
+    }
+
     if (!hInstance) hInstance = user32_module;
 
     if (!(classPtr = CLASS_FindClass( name, hInstance )))
diff --git a/dlls/user32/tests/class.c b/dlls/user32/tests/class.c
index 800d763..95f8aeb 100644
--- a/dlls/user32/tests/class.c
+++ b/dlls/user32/tests/class.c
@@ -900,10 +900,71 @@ static void test_extra_values(void)
     }
 }
 
+static void test_GetClassInfo(void)
+{
+    static const WCHAR staticW[] = {'s','t','a','t','i','c',0};
+    WNDCLASSA wc;
+    WNDCLASSEXA wcx;
+    BOOL ret;
+
+    SetLastError(0xdeadbeef);
+    ret = GetClassInfoA(0, "static", &wc);
+    ok(ret, "GetClassInfoA() error %d\n", GetLastError());
+
+if (0) { /* crashes under XP */
+    SetLastError(0xdeadbeef);
+    ret = GetClassInfoA(0, "static", NULL);
+    ok(ret, "GetClassInfoA() error %d\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ret = GetClassInfoW(0, staticW, NULL);
+    ok(ret, "GetClassInfoW() error %d\n", GetLastError());
+}
+
+    wcx.cbSize = sizeof(wcx);
+    SetLastError(0xdeadbeef);
+    ret = GetClassInfoExA(0, "static", &wcx);
+    ok(ret, "GetClassInfoExA() error %d\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ret = GetClassInfoExA(0, "static", NULL);
+    ok(!ret, "GetClassInfoExA() should fail\n");
+    ok(GetLastError() == ERROR_NOACCESS ||
+       broken(GetLastError() == 0xdeadbeef), /* win9x */
+       "expected ERROR_NOACCESS, got %d\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ret = GetClassInfoExW(0, staticW, NULL);
+    ok(!ret, "GetClassInfoExW() should fail\n");
+    ok(GetLastError() == ERROR_NOACCESS ||
+       broken(GetLastError() == 0xdeadbeef) /* NT4 */ ||
+       broken(GetLastError() == ERROR_CALL_NOT_IMPLEMENTED), /* win9x */
+       "expected ERROR_NOACCESS, got %d\n", GetLastError());
+
+    wcx.cbSize = 0;
+    SetLastError(0xdeadbeef);
+    ret = GetClassInfoExA(0, "static", &wcx);
+    ok(ret, "GetClassInfoExA() error %d\n", GetLastError());
+    ok(wcx.cbSize == 0, "expected 0, got %u\n", wcx.cbSize);
+
+    wcx.cbSize = sizeof(wcx) - 1;
+    SetLastError(0xdeadbeef);
+    ret = GetClassInfoExA(0, "static", &wcx);
+    ok(ret, "GetClassInfoExA() error %d\n", GetLastError());
+    ok(wcx.cbSize == sizeof(wcx) - 1, "expected sizeof(wcx)-1, got %u\n", wcx.cbSize);
+
+    wcx.cbSize = sizeof(wcx) + 1;
+    SetLastError(0xdeadbeef);
+    ret = GetClassInfoExA(0, "static", &wcx);
+    ok(ret, "GetClassInfoExA() error %d\n", GetLastError());
+    ok(wcx.cbSize == sizeof(wcx) + 1, "expected sizeof(wcx)+1, got %u\n", wcx.cbSize);
+}
+
 START_TEST(class)
 {
     HANDLE hInstance = GetModuleHandleA( NULL );
 
+    test_GetClassInfo();
     test_extra_values();
 
     if (!GetModuleHandleW(0))




More information about the wine-cvs mailing list