user32: Add the tests for GetWindowModuleFileName.
This commit is contained in:
parent
90f0795971
commit
914cb22868
|
@ -4631,6 +4631,77 @@ static void test_Expose(void)
|
|||
DestroyWindow(mw);
|
||||
}
|
||||
|
||||
static void test_GetWindowModuleFileName(void)
|
||||
{
|
||||
HWND hwnd;
|
||||
HINSTANCE hinst;
|
||||
UINT ret1, ret2;
|
||||
char buf1[MAX_PATH], buf2[MAX_PATH];
|
||||
|
||||
hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0,0,0,0, 0, 0, 0, NULL);
|
||||
assert(hwnd);
|
||||
|
||||
hinst = (HINSTANCE)GetWindowLongPtr(hwnd, GWLP_HINSTANCE);
|
||||
ok(hinst == 0, "expected 0, got %p\n", hinst);
|
||||
|
||||
buf1[0] = 0;
|
||||
SetLastError(0xdeadbeef);
|
||||
ret1 = GetModuleFileName(hinst, buf1, sizeof(buf1));
|
||||
ok(ret1, "GetModuleFileName error %u\n", GetLastError());
|
||||
|
||||
buf2[0] = 0;
|
||||
SetLastError(0xdeadbeef);
|
||||
ret2 = GetWindowModuleFileName(hwnd, buf2, sizeof(buf2));
|
||||
ok(ret2, "GetWindowModuleFileName error %u\n", GetLastError());
|
||||
|
||||
ok(ret1 == ret2, "%u != %u\n", ret1, ret2);
|
||||
ok(!strcmp(buf1, buf2), "%s != %s\n", buf1, buf2);
|
||||
|
||||
hinst = GetModuleHandle(0);
|
||||
|
||||
/* MSDN mentions ERROR_INSUFFICIENT_BUFFER, but XP doesn't do it */
|
||||
SetLastError(0xdeadbeef);
|
||||
ret2 = GetModuleFileName(hinst, buf2, ret1 - 2);
|
||||
ok(ret2 == ret1 - 2, "expected %u, got %u\n", ret1 - 2, ret2);
|
||||
ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", GetLastError());
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret2 = GetModuleFileName(hinst, buf2, 0);
|
||||
ok(!ret2, "GetModuleFileName should return 0\n");
|
||||
ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", GetLastError());
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret2 = GetWindowModuleFileName(hwnd, buf2, ret1 - 2);
|
||||
ok(ret2 == ret1 - 2, "expected %u, got %u\n", ret1 - 2, ret2);
|
||||
ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", GetLastError());
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret2 = GetWindowModuleFileName(hwnd, buf2, 0);
|
||||
ok(!ret2, "expected 0, got %u\n", ret2);
|
||||
ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", GetLastError());
|
||||
|
||||
DestroyWindow(hwnd);
|
||||
|
||||
buf2[0] = 0;
|
||||
hwnd = (HWND)0xdeadbeef;
|
||||
SetLastError(0xdeadbeef);
|
||||
ret1 = GetWindowModuleFileName(hwnd, buf1, sizeof(buf1));
|
||||
ok(!ret1, "expected 0, got %u\n", ret1);
|
||||
ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "expected ERROR_INVALID_WINDOW_HANDLE, got %u\n", GetLastError());
|
||||
|
||||
hwnd = GetDesktopWindow();
|
||||
ok(IsWindow(hwnd), "got invalid desktop window %p\n", hwnd);
|
||||
SetLastError(0xdeadbeef);
|
||||
ret1 = GetWindowModuleFileName(hwnd, buf1, sizeof(buf1));
|
||||
ok(!ret1, "expected 0, got %u\n", ret1);
|
||||
|
||||
hwnd = FindWindow("Shell_TrayWnd", NULL);
|
||||
ok(IsWindow(hwnd), "got invalid tray window %p\n", hwnd);
|
||||
SetLastError(0xdeadbeef);
|
||||
ret1 = GetWindowModuleFileName(hwnd, buf1, sizeof(buf1));
|
||||
ok(!ret1, "expected 0, got %u\n", ret1);
|
||||
}
|
||||
|
||||
START_TEST(win)
|
||||
{
|
||||
pGetAncestor = (void *)GetProcAddress( GetModuleHandleA("user32.dll"), "GetAncestor" );
|
||||
|
@ -4675,7 +4746,7 @@ START_TEST(win)
|
|||
|
||||
/* Add the tests below this line */
|
||||
test_params();
|
||||
|
||||
test_GetWindowModuleFileName();
|
||||
test_capture_1();
|
||||
test_capture_2();
|
||||
test_capture_3(hwndMain, hwndMain2);
|
||||
|
|
Loading…
Reference in New Issue