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>
11 #define ALIGN_DOWN_BY(size, align) \
12 ((ULONG_PTR)(size) & ~((ULONG_PTR)(align) - 1))
14 #define ALIGN_UP_BY(size, align) \
15 (ALIGN_DOWN_BY(((ULONG_PTR)(size) + align - 1), align))
17 START_TEST(GetWindowPlacement
)
19 BYTE buffer
[sizeof(WINDOWPLACEMENT
) + 16];
20 PWINDOWPLACEMENT wp
= (PVOID
)buffer
;
24 SetLastError(0xfeedfab1);
25 ret
= GetWindowPlacement(NULL
, NULL
);
26 error
= GetLastError();
27 ok(ret
== FALSE
, "ret = %d\n", ret
);
28 ok(error
== ERROR_INVALID_WINDOW_HANDLE
, "error = %lu\n", error
);
30 SetLastError(0xfeedfab1);
31 ret
= GetWindowPlacement(GetDesktopWindow(), NULL
);
32 error
= GetLastError();
33 ok(ret
== FALSE
, "ret = %d\n", ret
);
34 ok(error
== ERROR_NOACCESS
, "error = %lu\n", error
);
36 SetLastError(0xfeedfab1);
37 ret
= GetWindowPlacement(GetDesktopWindow(), (PVOID
)(UINT_PTR
)-4);
38 error
= GetLastError();
39 ok(ret
== FALSE
, "ret = %d\n", ret
);
40 ok(error
== ERROR_NOACCESS
, "error = %lu\n", error
);
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
);
48 FillMemory(wp
, sizeof(*wp
), 0x55);
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
);
57 FillMemory(wp
, sizeof(*wp
), 0x55);
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
);
67 FillMemory(wp
, sizeof(*wp
), 0x55);
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
);
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
);
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
);
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
== (UINT
)-1, "wp.ptMinPosition.x = %u\n", wp
->ptMinPosition
.x
);
108 ok(wp
->ptMinPosition
.y
== (UINT
)-1, "wp.ptMinPosition.x = %u\n", wp
->ptMinPosition
.y
);
109 ok(wp
->ptMaxPosition
.x
== (UINT
)-1, "wp.ptMaxPosition.x = %u\n", wp
->ptMaxPosition
.x
);
110 ok(wp
->ptMaxPosition
.y
== (UINT
)-1, "wp.ptMaxPosition.y = %u\n", wp
->ptMaxPosition
.y
);
111 ok(wp
->rcNormalPosition
.left
== 0, "wp.rcNormalPosition.left = %u\n", wp
->rcNormalPosition
.left
);
112 ok(wp
->rcNormalPosition
.top
== 0, "wp.rcNormalPosition.top = %u\n", wp
->rcNormalPosition
.top
);
113 ok(wp
->rcNormalPosition
.right
!= 0 &&
114 wp
->rcNormalPosition
.right
!= 0x55555555, "wp.rcNormalPosition.right = %u\n", wp
->rcNormalPosition
.right
);
115 ok(wp
->rcNormalPosition
.bottom
!= 0 &&
116 wp
->rcNormalPosition
.bottom
!= 0x55555555, "wp.rcNormalPosition.bottom = %u\n", wp
->rcNormalPosition
.bottom
);