ReactOS  0.4.15-dev-3175-g222acf5
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 
10 typedef struct TEST_ENTRY
11 {
12  INT lineno;
13  BOOL ret;
17 } TEST_ENTRY;
18 
19 static const CHAR s_name[] = "ShowWindow test window";
20 
21 static void DoTestEntry(const TEST_ENTRY *pEntry)
22 {
23  HWND hwnd;
24  DWORD style;
25  BOOL ret;
26 
28  CW_USEDEFAULT, CW_USEDEFAULT, 100, 100,
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 
63 static 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 },
70  { __LINE__, FALSE, SW_4, STYLE_0, STYLE_0 | WS_VISIBLE | WS_CLIPSIBLINGS },
71  { __LINE__, FALSE, SW_5, STYLE_0, STYLE_0 | WS_VISIBLE | WS_CLIPSIBLINGS },
72  { __LINE__, FALSE, SW_6, STYLE_0, STYLE_0 | WS_VISIBLE | WS_CLIPSIBLINGS },
77  { __LINE__, FALSE, SW_11, STYLE_0, STYLE_0 | WS_VISIBLE | WS_CLIPSIBLINGS },
78  { __LINE__, FALSE, SW_12, STYLE_0, STYLE_0 | WS_VISIBLE | 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 },
82  { __LINE__, FALSE, SW_2, STYLE_1, STYLE_1 | WS_VISIBLE | WS_CLIPSIBLINGS },
83  { __LINE__, FALSE, SW_3, STYLE_1, STYLE_3 | WS_MINIMIZE | WS_CLIPSIBLINGS },
84  { __LINE__, FALSE, SW_4, STYLE_1, STYLE_3 | WS_CLIPSIBLINGS },
85  { __LINE__, FALSE, SW_5, STYLE_1, STYLE_1 | WS_VISIBLE | WS_CLIPSIBLINGS },
86  { __LINE__, FALSE, SW_6, STYLE_1, STYLE_3 | WS_CLIPSIBLINGS },
87  { __LINE__, FALSE, SW_7, STYLE_1, STYLE_1 | WS_VISIBLE | WS_CLIPSIBLINGS },
88  { __LINE__, FALSE, SW_8, STYLE_1, STYLE_3 | WS_MINIMIZE | WS_CLIPSIBLINGS },
89  { __LINE__, FALSE, SW_9, STYLE_1, STYLE_3 | WS_MINIMIZE | WS_CLIPSIBLINGS },
90  { __LINE__, FALSE, SW_10, STYLE_1, STYLE_1 | WS_VISIBLE | 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 },
96  { __LINE__, FALSE, SW_2, STYLE_2, STYLE_3 | WS_MAXIMIZE | WS_CLIPSIBLINGS },
97  { __LINE__, FALSE, SW_3, STYLE_2, STYLE_2 | WS_VISIBLE | WS_CLIPSIBLINGS },
98  { __LINE__, FALSE, SW_4, STYLE_2, STYLE_3 | WS_CLIPSIBLINGS },
99  { __LINE__, FALSE, SW_5, STYLE_2, STYLE_3 | WS_MINIMIZE | WS_CLIPSIBLINGS },
100  { __LINE__, FALSE, SW_6, STYLE_2, STYLE_3 | WS_CLIPSIBLINGS },
101  { __LINE__, FALSE, SW_7, STYLE_2, STYLE_3 | WS_MAXIMIZE | 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 },
104  { __LINE__, FALSE, SW_10, STYLE_2, STYLE_3 | WS_MINIMIZE | 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 
151 static LRESULT CALLBACK
153 {
154  switch (uMsg)
155  {
156  case WM_CREATE:
157  return 0;
158  case WM_DESTROY:
159  PostQuitMessage(0);
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));
173  wc.lpfnWndProc = WindowProc;
175  wc.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
176  wc.lpszClassName = s_name;
177  ok_int(1, !!RegisterClassA(&wc));
178 
179  for (iTest = 0; iTest < _countof(s_entries); ++iTest)
180  {
181  DoTestEntry(&s_entries[iTest]);
182  }
183 }
static const TEST_ENTRY s_entries[]
Definition: ShowWindow.c:63
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define SW_12
Definition: ShowWindow.c:61
#define TRUE
Definition: types.h:120
#define STYLE_0
Definition: ShowWindow.c:42
#define SW_11
Definition: ShowWindow.c:60
char CHAR
Definition: xmlstorage.h:175
#define SW_8
Definition: ShowWindow.c:57
#define CALLBACK
Definition: compat.h:35
#define SW_5
Definition: ShowWindow.c:54
#define ZeroMemory
Definition: winbase.h:1664
UINT_PTR WPARAM
Definition: windef.h:207
HBRUSH hbrBackground
Definition: winuser.h:3146
#define SW_10
Definition: ShowWindow.c:59
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define STYLE_4
Definition: ShowWindow.c:46
BOOL WINAPI DestroyWindow(_In_ HWND)
int32_t INT
Definition: typedefs.h:58
WPARAM wParam
Definition: combotst.c:138
DWORD style1
Definition: ShowWindow.c:16
DWORD style0
Definition: ShowWindow.c:15
static const CHAR s_name[]
Definition: ShowWindow.c:19
#define SW_6
Definition: ShowWindow.c:55
START_TEST(ShowWindow)
Definition: ShowWindow.c:167
#define COLOR_3DFACE
Definition: winuser.h:919
#define FALSE
Definition: types.h:117
#define SW_3
Definition: ShowWindow.c:52
#define WS_MINIMIZE
Definition: pedump.c:622
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4291
#define SW_2
Definition: ShowWindow.c:51
#define CW_USEDEFAULT
Definition: winuser.h:225
#define ok_int(expression, result)
Definition: atltest.h:134
static void DoTestEntry(const TEST_ENTRY *pEntry)
Definition: ShowWindow.c:21
LONG_PTR LPARAM
Definition: windef.h:208
INT lineno
Definition: fc.c:16
#define WM_DESTROY
Definition: winuser.h:1592
#define GetWindowLongPtrA
Definition: winuser.h:4804
#define STYLE_5
Definition: ShowWindow.c:47
static LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: ShowWindow.c:152
#define _countof(array)
Definition: sndvol32.h:68
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SW_7
Definition: ShowWindow.c:56
int ret
#define STYLE_1
Definition: ShowWindow.c:43
Definition: cmd.c:12
INT nCmdShow
Definition: ShowWindow.c:14
#define STYLE_2
Definition: ShowWindow.c:44
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
LPCSTR lpszClassName
Definition: winuser.h:3148
#define SW_1
Definition: ShowWindow.c:50
#define GWL_STYLE
Definition: winuser.h:846
#define STYLE_3
Definition: ShowWindow.c:45
HINSTANCE hInstance
Definition: winuser.h:3143
#define ok(value,...)
Definition: atltest.h:57
#define SW_4
Definition: ShowWindow.c:53
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
WNDPROC lpfnWndProc
Definition: winuser.h:3140
#define WM_CREATE
Definition: winuser.h:1591
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define SW_0
Definition: ShowWindow.c:49
LONG_PTR LRESULT
Definition: windef.h:209
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
Arabic default style
Definition: afstyles.h:93
INT ret
Definition: fc.c:17
#define WS_VISIBLE
Definition: pedump.c:620
#define SW_9
Definition: ShowWindow.c:58
LPARAM lParam
Definition: combotst.c:139
ATOM WINAPI RegisterClassA(_In_ CONST WNDCLASSA *)
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
struct TEST_ENTRY TEST_ENTRY
#define WS_MAXIMIZE
Definition: pedump.c:623