[USER32_APITEST] Add a PCH.
[reactos.git] / modules / rostests / apitests / user32 / GetWindowPlacement.c
1 /*
2 * PROJECT: ReactOS API tests
3 * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory
4 * PURPOSE: Test for GetWindowPlacement
5 * PROGRAMMERS: Thomas Faber <thomas.faber@reactos.org>
6 */
7
8 #include "precomp.h"
9
10 #define ALIGN_DOWN_BY(size, align) \
11 ((ULONG_PTR)(size) & ~((ULONG_PTR)(align) - 1))
12
13 #define ALIGN_UP_BY(size, align) \
14 (ALIGN_DOWN_BY(((ULONG_PTR)(size) + align - 1), align))
15
16 START_TEST(GetWindowPlacement)
17 {
18 BYTE buffer[sizeof(WINDOWPLACEMENT) + 16];
19 PWINDOWPLACEMENT wp = (PVOID)buffer;
20 DWORD error;
21 BOOL ret;
22
23 SetLastError(0xfeedfab1);
24 ret = GetWindowPlacement(NULL, NULL);
25 error = GetLastError();
26 ok(ret == FALSE, "ret = %d\n", ret);
27 ok(error == ERROR_INVALID_WINDOW_HANDLE, "error = %lu\n", error);
28
29 SetLastError(0xfeedfab1);
30 ret = GetWindowPlacement(GetDesktopWindow(), NULL);
31 error = GetLastError();
32 ok(ret == FALSE, "ret = %d\n", ret);
33 ok(error == ERROR_NOACCESS, "error = %lu\n", error);
34
35 SetLastError(0xfeedfab1);
36 ret = GetWindowPlacement(GetDesktopWindow(), (PVOID)(UINT_PTR)-4);
37 error = GetLastError();
38 ok(ret == FALSE, "ret = %d\n", ret);
39 ok(error == ERROR_NOACCESS, "error = %lu\n", error);
40
41 FillMemory(buffer, sizeof(buffer), 0x55);
42 SetLastError(0xfeedfab1);
43 ret = GetWindowPlacement(GetDesktopWindow(), (PVOID)(ALIGN_UP_BY(buffer, 16) + 1));
44 error = GetLastError();
45 ok(ret == TRUE, "ret = %d\n", ret);
46 ok(error == 0xfeedfab1, "error = %lu\n", error);
47
48 FillMemory(wp, sizeof(*wp), 0x55);
49 wp->length = 0;
50 SetLastError(0xfeedfab1);
51 ret = GetWindowPlacement(NULL, wp);
52 error = GetLastError();
53 ok(ret == FALSE, "ret = %d\n", ret);
54 ok(error == ERROR_INVALID_WINDOW_HANDLE, "error = %lu\n", error);
55 ok(wp->length == 0, "wp.length = %u\n", wp->length);
56
57 FillMemory(wp, sizeof(*wp), 0x55);
58 wp->length = 0;
59 SetLastError(0xfeedfab1);
60 ret = GetWindowPlacement(GetDesktopWindow(), wp);
61 error = GetLastError();
62 ok(ret == TRUE, "ret = %d\n", ret);
63 ok(error == 0xfeedfab1, "error = %lu\n", error);
64 ok(wp->length == sizeof(*wp), "wp.length = %u\n", wp->length);
65 ok(wp->flags == 0, "wp.flags = %x\n", wp->flags);
66
67 FillMemory(wp, sizeof(*wp), 0x55);
68 wp->length = 1;
69 SetLastError(0xfeedfab1);
70 ret = GetWindowPlacement(GetDesktopWindow(), wp);
71 error = GetLastError();
72 ok(ret == TRUE, "ret = %d\n", ret);
73 ok(error == 0xfeedfab1, "error = %lu\n", error);
74 ok(wp->length == sizeof(*wp), "wp.length = %u\n", wp->length);
75 ok(wp->flags == 0, "wp.flags = %x\n", wp->flags);
76
77 FillMemory(wp, sizeof(*wp), 0x55);
78 wp->length = sizeof(*wp) - 1;
79 SetLastError(0xfeedfab1);
80 ret = GetWindowPlacement(GetDesktopWindow(), wp);
81 error = GetLastError();
82 ok(ret == TRUE, "ret = %d\n", ret);
83 ok(error == 0xfeedfab1, "error = %lu\n", error);
84 ok(wp->length == sizeof(*wp), "wp.length = %u\n", wp->length);
85 ok(wp->flags == 0, "wp.flags = %x\n", wp->flags);
86
87 FillMemory(wp, sizeof(*wp), 0x55);
88 wp->length = sizeof(*wp) + 1;
89 SetLastError(0xfeedfab1);
90 ret = GetWindowPlacement(GetDesktopWindow(), wp);
91 error = GetLastError();
92 ok(ret == TRUE, "ret = %d\n", ret);
93 ok(error == 0xfeedfab1, "error = %lu\n", error);
94 ok(wp->length == sizeof(*wp), "wp.length = %u\n", wp->length);
95 ok(wp->flags == 0, "wp.flags = %x\n", wp->flags);
96
97 FillMemory(wp, sizeof(*wp), 0x55);
98 wp->length = sizeof(*wp);
99 SetLastError(0xfeedfab1);
100 ret = GetWindowPlacement(GetDesktopWindow(), wp);
101 error = GetLastError();
102 ok(ret == TRUE, "ret = %d\n", ret);
103 ok(error == 0xfeedfab1, "error = %lu\n", error);
104 ok(wp->length == sizeof(*wp), "wp.length = %u\n", wp->length);
105 ok(wp->flags == 0, "wp.flags = %x\n", wp->flags);
106 ok(wp->showCmd == SW_SHOWNORMAL, "wp.showCmd = %u\n", wp->showCmd);
107 ok(wp->ptMinPosition.x == -1, "wp.ptMinPosition.x = %ld\n", wp->ptMinPosition.x);
108 ok(wp->ptMinPosition.y == -1, "wp.ptMinPosition.x = %ld\n", wp->ptMinPosition.y);
109 ok(wp->ptMaxPosition.x == -1, "wp.ptMaxPosition.x = %ld\n", wp->ptMaxPosition.x);
110 ok(wp->ptMaxPosition.y == -1, "wp.ptMaxPosition.y = %ld\n", wp->ptMaxPosition.y);
111 ok(wp->rcNormalPosition.left == 0, "wp.rcNormalPosition.left = %ld\n", wp->rcNormalPosition.left);
112 ok(wp->rcNormalPosition.top == 0, "wp.rcNormalPosition.top = %ld\n", wp->rcNormalPosition.top);
113 ok(wp->rcNormalPosition.right != 0 &&
114 wp->rcNormalPosition.right != 0x55555555, "wp.rcNormalPosition.right = %ld\n", wp->rcNormalPosition.right);
115 ok(wp->rcNormalPosition.bottom != 0 &&
116 wp->rcNormalPosition.bottom != 0x55555555, "wp.rcNormalPosition.bottom = %ld\n", wp->rcNormalPosition.bottom);
117 }