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; 14 INT nCmdShow; 15 DWORD style0; 16 DWORD style1; 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 27 hwnd = CreateWindowA(s_name, s_name, pEntry->style0, 28 CW_USEDEFAULT, CW_USEDEFAULT, 100, 100, 29 NULL, NULL, GetModuleHandleA(NULL), NULL); 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 36 style = (LONG)GetWindowLongPtrA(hwnd, GWL_STYLE); 37 ok(style == pEntry->style1, "Line %d: style was 0x%lX\n", pEntry->lineno, style); 38 39 DestroyWindow(hwnd); 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 }, 68 { __LINE__, FALSE, SW_2, STYLE_0, STYLE_0 | WS_VISIBLE | WS_MAXIMIZE | WS_CLIPSIBLINGS }, 69 { __LINE__, FALSE, SW_3, STYLE_0, STYLE_0 | WS_VISIBLE | WS_MINIMIZE | 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 }, 73 { __LINE__, FALSE, SW_7, STYLE_0, STYLE_0 | WS_VISIBLE | WS_MAXIMIZE | WS_CLIPSIBLINGS }, 74 { __LINE__, FALSE, SW_8, STYLE_0, STYLE_0 | WS_VISIBLE | WS_MINIMIZE | WS_CLIPSIBLINGS }, 75 { __LINE__, FALSE, SW_9, STYLE_0, STYLE_0 | WS_VISIBLE | WS_MINIMIZE | WS_CLIPSIBLINGS }, 76 { __LINE__, FALSE, SW_10, 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 }, 109 { __LINE__, TRUE, SW_1, STYLE_3, WS_OVERLAPPEDWINDOW | 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 }, 123 { __LINE__, TRUE, SW_1, STYLE_4, WS_OVERLAPPEDWINDOW | WS_MAXIMIZE | 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 }, 137 { __LINE__, TRUE, SW_1, STYLE_5, WS_OVERLAPPEDWINDOW | WS_MINIMIZE | 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 152 WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 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 167 START_TEST(ShowWindow) 168 { 169 WNDCLASSA wc; 170 UINT iTest; 171 172 ZeroMemory(&wc, sizeof(wc)); 173 wc.lpfnWndProc = WindowProc; 174 wc.hInstance = GetModuleHandleA(NULL); 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 } 184