ReactOS 0.4.15-dev-7924-g5949c20
ShowWindow.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS API tests
3 * LICENSE: LGPL-2.1+ (https://spdx.org/licenses/LGPL-2.1+)
4 * PURPOSE: Tests for ShowWindow
5 * COPYRIGHT: Copyright 2021 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
6 */
7
8#include "precomp.h"
9
10typedef struct TEST_ENTRY
11{
12 INT lineno;
13 BOOL ret;
18
19static const CHAR s_name[] = "ShowWindow test window";
20
21static void DoTestEntry(const TEST_ENTRY *pEntry)
22{
23 HWND hwnd;
25 BOOL ret;
26
30 ok(!!hwnd, "Line %d: CreateWindowA failed\n", pEntry->lineno);
31
32 ret = !!ShowWindow(hwnd, pEntry->nCmdShow);
33 ok(ret == pEntry->ret, "Line %d: ShowWindow returned %s\n", pEntry->lineno,
34 (ret ? "non-zero" : "zero"));
35
37 ok(style == pEntry->style1, "Line %d: style was 0x%lX\n", pEntry->lineno, style);
38
40}
41
42#define STYLE_0 WS_OVERLAPPEDWINDOW
43#define STYLE_1 (WS_OVERLAPPEDWINDOW | WS_MAXIMIZE)
44#define STYLE_2 (WS_OVERLAPPEDWINDOW | WS_MINIMIZE)
45#define STYLE_3 (WS_OVERLAPPEDWINDOW | WS_VISIBLE)
46#define STYLE_4 (WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_MAXIMIZE)
47#define STYLE_5 (WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_MINIMIZE)
48
49#define SW_0 -1
50#define SW_1 SW_HIDE
51#define SW_2 SW_MAXIMIZE
52#define SW_3 SW_MINIMIZE
53#define SW_4 SW_RESTORE
54#define SW_5 SW_SHOW
55#define SW_6 SW_SHOWDEFAULT
56#define SW_7 SW_SHOWMAXIMIZED
57#define SW_8 SW_SHOWMINIMIZED
58#define SW_9 SW_SHOWMINNOACTIVE
59#define SW_10 SW_SHOWNA
60#define SW_11 SW_SHOWNOACTIVATE
61#define SW_12 SW_SHOWNORMAL
62
63static const TEST_ENTRY s_entries[] =
64{
65 // STYLE_0
66 { __LINE__, FALSE, SW_0, STYLE_0, STYLE_0 | WS_CLIPSIBLINGS },
67 { __LINE__, FALSE, SW_1, STYLE_0, STYLE_0 | WS_CLIPSIBLINGS },
79 // STYLE_1
80 { __LINE__, FALSE, SW_0, STYLE_1, STYLE_1 | WS_CLIPSIBLINGS },
81 { __LINE__, FALSE, SW_1, STYLE_1, STYLE_1 | WS_CLIPSIBLINGS },
84 { __LINE__, FALSE, SW_4, STYLE_1, STYLE_3 | WS_CLIPSIBLINGS },
86 { __LINE__, FALSE, SW_6, STYLE_1, STYLE_3 | WS_CLIPSIBLINGS },
91 { __LINE__, FALSE, SW_11, STYLE_1, STYLE_3 | WS_CLIPSIBLINGS },
92 { __LINE__, FALSE, SW_12, STYLE_1, STYLE_3 | WS_CLIPSIBLINGS },
93 // STYLE_2
94 { __LINE__, FALSE, SW_0, STYLE_2, STYLE_2 | WS_CLIPSIBLINGS },
95 { __LINE__, FALSE, SW_1, STYLE_2, STYLE_2 | WS_CLIPSIBLINGS },
98 { __LINE__, FALSE, SW_4, STYLE_2, STYLE_3 | WS_CLIPSIBLINGS },
100 { __LINE__, FALSE, SW_6, STYLE_2, STYLE_3 | WS_CLIPSIBLINGS },
102 { __LINE__, FALSE, SW_8, STYLE_2, STYLE_2 | WS_VISIBLE | WS_CLIPSIBLINGS },
103 { __LINE__, FALSE, SW_9, STYLE_2, STYLE_2 | WS_VISIBLE | WS_CLIPSIBLINGS },
105 { __LINE__, FALSE, SW_11, STYLE_2, STYLE_3 | WS_CLIPSIBLINGS },
106 { __LINE__, FALSE, SW_12, STYLE_2, STYLE_3 | WS_CLIPSIBLINGS },
107 // STYLE_3
108 { __LINE__, FALSE, SW_0, STYLE_3, STYLE_3 | WS_CLIPSIBLINGS },
110 { __LINE__, TRUE, SW_2, STYLE_3, STYLE_3 | WS_MAXIMIZE | WS_CLIPSIBLINGS },
111 { __LINE__, TRUE, SW_3, STYLE_3, STYLE_3 | WS_MINIMIZE | WS_CLIPSIBLINGS },
112 { __LINE__, TRUE, SW_4, STYLE_3, STYLE_3 | WS_CLIPSIBLINGS },
113 { __LINE__, TRUE, SW_5, STYLE_3, STYLE_3 | WS_CLIPSIBLINGS },
114 { __LINE__, TRUE, SW_6, STYLE_3, STYLE_3 | WS_CLIPSIBLINGS },
115 { __LINE__, TRUE, SW_7, STYLE_3, STYLE_3 | WS_MAXIMIZE | WS_CLIPSIBLINGS },
116 { __LINE__, TRUE, SW_8, STYLE_3, STYLE_3 | WS_MINIMIZE | WS_CLIPSIBLINGS },
117 { __LINE__, TRUE, SW_9, STYLE_3, STYLE_3 | WS_MINIMIZE | WS_CLIPSIBLINGS },
118 { __LINE__, TRUE, SW_10, STYLE_3, STYLE_3 | WS_CLIPSIBLINGS },
119 { __LINE__, TRUE, SW_11, STYLE_3, STYLE_3 | WS_CLIPSIBLINGS },
120 { __LINE__, TRUE, SW_12, STYLE_3, STYLE_3 | WS_CLIPSIBLINGS },
121 // STYLE_4
122 { __LINE__, FALSE, SW_0, STYLE_4, STYLE_4 | WS_CLIPSIBLINGS },
124 { __LINE__, TRUE, SW_2, STYLE_4, STYLE_4 | WS_MAXIMIZE | WS_CLIPSIBLINGS },
125 { __LINE__, TRUE, SW_3, STYLE_4, STYLE_3 | WS_MINIMIZE | WS_CLIPSIBLINGS },
126 { __LINE__, TRUE, SW_4, STYLE_4, STYLE_3 | WS_CLIPSIBLINGS },
127 { __LINE__, TRUE, SW_5, STYLE_4, STYLE_4 | WS_CLIPSIBLINGS },
128 { __LINE__, TRUE, SW_6, STYLE_4, STYLE_3 | WS_CLIPSIBLINGS },
129 { __LINE__, TRUE, SW_7, STYLE_4, STYLE_4 | WS_MAXIMIZE | WS_CLIPSIBLINGS },
130 { __LINE__, TRUE, SW_8, STYLE_4, STYLE_3 | WS_MINIMIZE | WS_CLIPSIBLINGS },
131 { __LINE__, TRUE, SW_9, STYLE_4, STYLE_3 | WS_MINIMIZE | WS_CLIPSIBLINGS },
132 { __LINE__, TRUE, SW_10, STYLE_4, STYLE_4 | WS_CLIPSIBLINGS },
133 { __LINE__, TRUE, SW_11, STYLE_4, STYLE_3 | WS_CLIPSIBLINGS },
134 { __LINE__, TRUE, SW_12, STYLE_4, STYLE_3 | WS_CLIPSIBLINGS },
135 // STYLE_5
136 { __LINE__, FALSE, SW_0, STYLE_5, STYLE_5 | WS_CLIPSIBLINGS },
138 { __LINE__, TRUE, SW_2, STYLE_5, STYLE_3 | WS_MAXIMIZE | WS_CLIPSIBLINGS },
139 { __LINE__, TRUE, SW_3, STYLE_5, STYLE_5 | WS_CLIPSIBLINGS },
140 { __LINE__, TRUE, SW_4, STYLE_5, STYLE_3 | WS_CLIPSIBLINGS },
141 { __LINE__, TRUE, SW_5, STYLE_5, STYLE_5 | WS_CLIPSIBLINGS },
142 { __LINE__, TRUE, SW_6, STYLE_5, STYLE_3 | WS_CLIPSIBLINGS },
143 { __LINE__, TRUE, SW_7, STYLE_5, STYLE_3 | WS_MAXIMIZE | WS_CLIPSIBLINGS },
144 { __LINE__, TRUE, SW_8, STYLE_5, STYLE_5 | WS_CLIPSIBLINGS },
145 { __LINE__, TRUE, SW_9, STYLE_5, STYLE_5 | WS_CLIPSIBLINGS },
146 { __LINE__, TRUE, SW_10, STYLE_5, STYLE_5 | WS_CLIPSIBLINGS },
147 { __LINE__, TRUE, SW_11, STYLE_5, STYLE_3 | WS_CLIPSIBLINGS },
148 { __LINE__, TRUE, SW_12, STYLE_5, STYLE_3 | WS_CLIPSIBLINGS },
149};
150
151static LRESULT CALLBACK
153{
154 switch (uMsg)
155 {
156 case WM_CREATE:
157 return 0;
158 case WM_DESTROY:
160 break;
161 default:
162 return DefWindowProcA(hwnd, uMsg, wParam, lParam);
163 }
164 return 0;
165}
166
168{
169 WNDCLASSA wc;
170 UINT iTest;
171
172 ZeroMemory(&wc, sizeof(wc));
175 wc.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
177 ok_int(1, !!RegisterClassA(&wc));
178
179 for (iTest = 0; iTest < _countof(s_entries); ++iTest)
180 {
181 DoTestEntry(&s_entries[iTest]);
182 }
183}
#define STYLE_3
Definition: ShowWindow.c:45
#define SW_1
Definition: ShowWindow.c:50
#define SW_10
Definition: ShowWindow.c:59
#define SW_12
Definition: ShowWindow.c:61
#define SW_5
Definition: ShowWindow.c:54
static void DoTestEntry(const TEST_ENTRY *pEntry)
Definition: ShowWindow.c:21
static const CHAR s_name[]
Definition: ShowWindow.c:19
#define SW_7
Definition: ShowWindow.c:56
static const TEST_ENTRY s_entries[]
Definition: ShowWindow.c:63
#define SW_3
Definition: ShowWindow.c:52
#define SW_6
Definition: ShowWindow.c:55
#define SW_4
Definition: ShowWindow.c:53
#define STYLE_4
Definition: ShowWindow.c:46
#define SW_9
Definition: ShowWindow.c:58
#define STYLE_5
Definition: ShowWindow.c:47
static LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: ShowWindow.c:152
#define SW_11
Definition: ShowWindow.c:60
#define SW_0
Definition: ShowWindow.c:49
#define STYLE_0
Definition: ShowWindow.c:42
#define STYLE_1
Definition: ShowWindow.c:43
#define SW_2
Definition: ShowWindow.c:51
#define STYLE_2
Definition: ShowWindow.c:44
#define SW_8
Definition: ShowWindow.c:57
Arabic default style
Definition: afstyles.h:94
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
#define ok_int(expression, result)
Definition: atltest.h:134
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define CALLBACK
Definition: compat.h:35
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
unsigned int UINT
Definition: ndis.h:50
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define WS_MAXIMIZE
Definition: pedump.c:623
#define WS_MINIMIZE
Definition: pedump.c:622
#define WS_VISIBLE
Definition: pedump.c:620
long LONG
Definition: pedump.c:60
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
#define _countof(array)
Definition: sndvol32.h:68
Definition: cmd.c:13
INT lineno
Definition: fc.c:16
DWORD style1
Definition: ShowWindow.c:16
DWORD style0
Definition: ShowWindow.c:15
INT ret
Definition: fc.c:17
INT nCmdShow
Definition: ShowWindow.c:14
HBRUSH hbrBackground
Definition: winuser.h:3170
HINSTANCE hInstance
Definition: winuser.h:3167
LPCSTR lpszClassName
Definition: winuser.h:3172
WNDPROC lpfnWndProc
Definition: winuser.h:3164
int32_t INT
Definition: typedefs.h:58
int ret
#define ZeroMemory
Definition: winbase.h:1712
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
UINT_PTR WPARAM
Definition: windef.h:207
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4315
#define WM_CREATE
Definition: winuser.h:1608
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define GetWindowLongPtrA
Definition: winuser.h:4828
ATOM WINAPI RegisterClassA(_In_ CONST WNDCLASSA *)
#define CW_USEDEFAULT
Definition: winuser.h:225
#define WM_DESTROY
Definition: winuser.h:1609
#define GWL_STYLE
Definition: winuser.h:852
BOOL WINAPI DestroyWindow(_In_ HWND)
#define COLOR_3DFACE
Definition: winuser.h:929
char CHAR
Definition: xmlstorage.h:175