user32/tests: Add some tests for GetClassName() and versioned classes.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2018-02-02 14:31:40 +03:00 committed by Alexandre Julliard
parent 51a0b4ebb1
commit be8534d387
1 changed files with 35 additions and 5 deletions

View File

@ -1211,12 +1211,15 @@ static void test_actctx_classes(void)
"<windowClass>MyTestClass</windowClass>" "<windowClass>MyTestClass</windowClass>"
"</file>" "</file>"
"</assembly>"; "</assembly>";
static const char *testclass = "MyTestClass";
WNDCLASSA wc; WNDCLASSA wc;
ULONG_PTR cookie; ULONG_PTR cookie;
HANDLE context; HANDLE context;
BOOL ret; BOOL ret;
ATOM class; ATOM class;
HINSTANCE hinst; HINSTANCE hinst;
char buff[64];
HWND hwnd;
create_manifest_file("main.manifest", main_manifest); create_manifest_file("main.manifest", main_manifest);
context = create_test_actctx("main.manifest"); context = create_test_actctx("main.manifest");
@ -1228,29 +1231,56 @@ static void test_actctx_classes(void)
memset(&wc, 0, sizeof(wc)); memset(&wc, 0, sizeof(wc));
wc.lpfnWndProc = ClassTest_WndProc; wc.lpfnWndProc = ClassTest_WndProc;
wc.hIcon = LoadIconW(0, (LPCWSTR)IDI_APPLICATION); wc.hIcon = LoadIconW(0, (LPCWSTR)IDI_APPLICATION);
wc.lpszClassName = "MyTestClass"; wc.lpszClassName = testclass;
hinst = GetModuleHandleW(0); hinst = GetModuleHandleW(0);
ret = GetClassInfoA(hinst, "MyTestClass", &wc); ret = GetClassInfoA(hinst, testclass, &wc);
ok(!ret, "Expected failure.\n"); ok(!ret, "Expected failure.\n");
class = RegisterClassA(&wc); class = RegisterClassA(&wc);
ok(class != 0, "Failed to register class.\n"); ok(class != 0, "Failed to register class.\n");
/* Class info is available by versioned and regular names. */ /* Class info is available by versioned and regular names. */
ret = GetClassInfoA(hinst, "MyTestClass", &wc); ret = GetClassInfoA(hinst, testclass, &wc);
ok(ret, "Failed to get class info.\n"); ok(ret, "Failed to get class info.\n");
hwnd = CreateWindowExA(0, testclass, "test", 0, 0, 0, 0, 0, 0, 0, hinst, 0);
ok(hwnd != NULL, "Failed to create a window.\n");
ret = GetClassNameA(hwnd, buff, sizeof(buff));
ok(ret, "Failed to get class name.\n");
todo_wine
ok(!strcmp(buff, testclass), "Unexpected class name.\n");
ret = GetClassInfoA(hinst, "4.3.2.1!MyTestClass", &wc); ret = GetClassInfoA(hinst, "4.3.2.1!MyTestClass", &wc);
ok(ret, "Failed to get class info.\n"); ok(ret, "Failed to get class info.\n");
ret = UnregisterClassA("MyTestClass", hinst); ret = UnregisterClassA(testclass, hinst);
ok(ret, "Failed to unregister class.\n"); ok(!ret, "Failed to unregister class.\n");
ret = DeactivateActCtx(0, cookie); ret = DeactivateActCtx(0, cookie);
ok(ret, "Failed to deactivate context.\n"); ok(ret, "Failed to deactivate context.\n");
ret = GetClassInfoA(hinst, testclass, &wc);
ok(!ret, "Unexpected ret val %d.\n", ret);
ret = GetClassInfoA(hinst, "4.3.2.1!MyTestClass", &wc);
ok(ret, "Failed to get class info.\n");
ret = GetClassNameA(hwnd, buff, sizeof(buff));
ok(ret, "Failed to get class name.\n");
todo_wine
ok(!strcmp(buff, testclass), "Unexpected class name.\n");
DestroyWindow(hwnd);
ret = UnregisterClassA("MyTestClass", hinst);
ok(!ret, "Unexpected ret value %d.\n", ret);
ret = UnregisterClassA("4.3.2.1!MyTestClass", hinst);
ok(ret, "Failed to unregister class.\n");
/* Register versioned class without active context. */ /* Register versioned class without active context. */
wc.lpszClassName = "4.3.2.1!MyTestClass"; wc.lpszClassName = "4.3.2.1!MyTestClass";
class = RegisterClassA(&wc); class = RegisterClassA(&wc);