1 /* 2 * PROJECT: ReactOS api tests 3 * LICENSE: LGPL-2.0-or-later (https://spdx.org/licenses/LGPL-2.0-or-later) 4 * PURPOSE: Test for Shell Hook 5 * COPYRIGHT: Copyright 2020-2021 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com) 6 */ 7 #include "shelltest.h" 8 #include "undocshell.h" 9 10 struct TEST_ENTRY 11 { 12 INT lineno; 13 UINT nCount; 14 BOOL bIsChild; 15 BOOL bHasOwner; 16 DWORD style; 17 DWORD exstyle; 18 DWORD owner_style; 19 DWORD owner_exstyle; 20 }; 21 22 #define STYLE_0 WS_POPUP 23 #define STYLE_1 (WS_POPUP | WS_VISIBLE) 24 #define STYLE_2 (WS_OVERLAPPED | WS_VISIBLE) 25 26 #define EXSTYLE_0 0 27 #define EXSTYLE_1 WS_EX_APPWINDOW 28 #define EXSTYLE_2 WS_EX_TOOLWINDOW 29 #define EXSTYLE_3 (WS_EX_APPWINDOW | WS_EX_TOOLWINDOW) 30 31 #define TYPE_0 FALSE, FALSE 32 #define TYPE_1 FALSE, TRUE 33 #define TYPE_2 TRUE, TRUE 34 35 static const TEST_ENTRY s_entries1[] = 36 { 37 // TYPE_0 38 { __LINE__, 0, TYPE_0, STYLE_0, EXSTYLE_0 }, 39 { __LINE__, 0, TYPE_0, STYLE_0, EXSTYLE_1 }, 40 { __LINE__, 0, TYPE_0, STYLE_0, EXSTYLE_2 }, 41 { __LINE__, 0, TYPE_0, STYLE_0, EXSTYLE_3 }, 42 { __LINE__, 1, TYPE_0, STYLE_1, EXSTYLE_0 }, 43 { __LINE__, 1, TYPE_0, STYLE_1, EXSTYLE_1 }, 44 { __LINE__, 0, TYPE_0, STYLE_1, EXSTYLE_2 }, 45 { __LINE__, 1, TYPE_0, STYLE_1, EXSTYLE_3 }, 46 { __LINE__, 1, TYPE_0, STYLE_2, EXSTYLE_0 }, 47 { __LINE__, 1, TYPE_0, STYLE_2, EXSTYLE_1 }, 48 { __LINE__, 0, TYPE_0, STYLE_2, EXSTYLE_2 }, 49 { __LINE__, 1, TYPE_0, STYLE_2, EXSTYLE_3 }, 50 51 // TYPE_1 52 { __LINE__, 0, TYPE_1, STYLE_1, EXSTYLE_0, STYLE_0, EXSTYLE_0 }, 53 { __LINE__, 0, TYPE_1, STYLE_1, EXSTYLE_0, STYLE_0, EXSTYLE_1 }, 54 { __LINE__, 0, TYPE_1, STYLE_1, EXSTYLE_0, STYLE_0, EXSTYLE_2 }, 55 { __LINE__, 0, TYPE_1, STYLE_1, EXSTYLE_0, STYLE_0, EXSTYLE_3 }, 56 { __LINE__, 0, TYPE_1, STYLE_1, EXSTYLE_0, STYLE_1, EXSTYLE_0 }, 57 { __LINE__, 0, TYPE_1, STYLE_1, EXSTYLE_0, STYLE_1, EXSTYLE_1 }, 58 { __LINE__, 0, TYPE_1, STYLE_1, EXSTYLE_0, STYLE_1, EXSTYLE_2 }, 59 { __LINE__, 0, TYPE_1, STYLE_1, EXSTYLE_0, STYLE_1, EXSTYLE_3 }, 60 { __LINE__, 0, TYPE_1, STYLE_1, EXSTYLE_0, STYLE_2, EXSTYLE_0 }, 61 { __LINE__, 0, TYPE_1, STYLE_1, EXSTYLE_0, STYLE_2, EXSTYLE_1 }, 62 { __LINE__, 0, TYPE_1, STYLE_1, EXSTYLE_0, STYLE_2, EXSTYLE_2 }, 63 { __LINE__, 0, TYPE_1, STYLE_1, EXSTYLE_0, STYLE_2, EXSTYLE_3 }, 64 { __LINE__, 1, TYPE_1, STYLE_1, EXSTYLE_1, STYLE_0, EXSTYLE_0 }, 65 { __LINE__, 1, TYPE_1, STYLE_1, EXSTYLE_1, STYLE_0, EXSTYLE_1 }, 66 { __LINE__, 1, TYPE_1, STYLE_1, EXSTYLE_1, STYLE_0, EXSTYLE_2 }, 67 { __LINE__, 1, TYPE_1, STYLE_1, EXSTYLE_1, STYLE_0, EXSTYLE_3 }, 68 { __LINE__, 1, TYPE_1, STYLE_1, EXSTYLE_1, STYLE_1, EXSTYLE_0 }, 69 { __LINE__, 1, TYPE_1, STYLE_1, EXSTYLE_1, STYLE_1, EXSTYLE_1 }, 70 { __LINE__, 1, TYPE_1, STYLE_1, EXSTYLE_1, STYLE_1, EXSTYLE_2 }, 71 { __LINE__, 1, TYPE_1, STYLE_1, EXSTYLE_1, STYLE_1, EXSTYLE_3 }, 72 { __LINE__, 1, TYPE_1, STYLE_1, EXSTYLE_1, STYLE_2, EXSTYLE_0 }, 73 { __LINE__, 1, TYPE_1, STYLE_1, EXSTYLE_1, STYLE_2, EXSTYLE_1 }, 74 { __LINE__, 1, TYPE_1, STYLE_1, EXSTYLE_1, STYLE_2, EXSTYLE_2 }, 75 { __LINE__, 1, TYPE_1, STYLE_1, EXSTYLE_1, STYLE_2, EXSTYLE_3 }, 76 { __LINE__, 0, TYPE_1, STYLE_1, EXSTYLE_2, STYLE_0, EXSTYLE_0 }, 77 { __LINE__, 0, TYPE_1, STYLE_1, EXSTYLE_2, STYLE_0, EXSTYLE_1 }, 78 { __LINE__, 0, TYPE_1, STYLE_1, EXSTYLE_2, STYLE_0, EXSTYLE_2 }, 79 { __LINE__, 0, TYPE_1, STYLE_1, EXSTYLE_2, STYLE_0, EXSTYLE_3 }, 80 { __LINE__, 0, TYPE_1, STYLE_1, EXSTYLE_2, STYLE_1, EXSTYLE_0 }, 81 { __LINE__, 0, TYPE_1, STYLE_1, EXSTYLE_2, STYLE_1, EXSTYLE_1 }, 82 { __LINE__, 0, TYPE_1, STYLE_1, EXSTYLE_2, STYLE_1, EXSTYLE_2 }, 83 { __LINE__, 0, TYPE_1, STYLE_1, EXSTYLE_2, STYLE_1, EXSTYLE_3 }, 84 { __LINE__, 0, TYPE_1, STYLE_1, EXSTYLE_2, STYLE_2, EXSTYLE_0 }, 85 { __LINE__, 0, TYPE_1, STYLE_1, EXSTYLE_2, STYLE_2, EXSTYLE_1 }, 86 { __LINE__, 0, TYPE_1, STYLE_1, EXSTYLE_2, STYLE_2, EXSTYLE_2 }, 87 { __LINE__, 0, TYPE_1, STYLE_1, EXSTYLE_2, STYLE_2, EXSTYLE_3 }, 88 { __LINE__, 1, TYPE_1, STYLE_1, EXSTYLE_3, STYLE_0, EXSTYLE_0 }, 89 { __LINE__, 1, TYPE_1, STYLE_1, EXSTYLE_3, STYLE_0, EXSTYLE_1 }, 90 { __LINE__, 1, TYPE_1, STYLE_1, EXSTYLE_3, STYLE_0, EXSTYLE_2 }, 91 { __LINE__, 1, TYPE_1, STYLE_1, EXSTYLE_3, STYLE_0, EXSTYLE_3 }, 92 { __LINE__, 1, TYPE_1, STYLE_1, EXSTYLE_3, STYLE_1, EXSTYLE_0 }, 93 { __LINE__, 1, TYPE_1, STYLE_1, EXSTYLE_3, STYLE_1, EXSTYLE_1 }, 94 { __LINE__, 1, TYPE_1, STYLE_1, EXSTYLE_3, STYLE_1, EXSTYLE_2 }, 95 { __LINE__, 1, TYPE_1, STYLE_1, EXSTYLE_3, STYLE_1, EXSTYLE_3 }, 96 { __LINE__, 1, TYPE_1, STYLE_1, EXSTYLE_3, STYLE_2, EXSTYLE_0 }, 97 { __LINE__, 1, TYPE_1, STYLE_1, EXSTYLE_3, STYLE_2, EXSTYLE_1 }, 98 { __LINE__, 1, TYPE_1, STYLE_1, EXSTYLE_3, STYLE_2, EXSTYLE_2 }, 99 { __LINE__, 1, TYPE_1, STYLE_1, EXSTYLE_3, STYLE_2, EXSTYLE_3 }, 100 { __LINE__, 0, TYPE_1, STYLE_2, EXSTYLE_0, STYLE_0, EXSTYLE_0 }, 101 { __LINE__, 0, TYPE_1, STYLE_2, EXSTYLE_0, STYLE_0, EXSTYLE_1 }, 102 { __LINE__, 0, TYPE_1, STYLE_2, EXSTYLE_0, STYLE_0, EXSTYLE_2 }, 103 { __LINE__, 0, TYPE_1, STYLE_2, EXSTYLE_0, STYLE_0, EXSTYLE_3 }, 104 { __LINE__, 0, TYPE_1, STYLE_2, EXSTYLE_0, STYLE_1, EXSTYLE_0 }, 105 { __LINE__, 0, TYPE_1, STYLE_2, EXSTYLE_0, STYLE_1, EXSTYLE_1 }, 106 { __LINE__, 0, TYPE_1, STYLE_2, EXSTYLE_0, STYLE_1, EXSTYLE_2 }, 107 { __LINE__, 0, TYPE_1, STYLE_2, EXSTYLE_0, STYLE_1, EXSTYLE_3 }, 108 { __LINE__, 0, TYPE_1, STYLE_2, EXSTYLE_0, STYLE_2, EXSTYLE_0 }, 109 { __LINE__, 0, TYPE_1, STYLE_2, EXSTYLE_0, STYLE_2, EXSTYLE_1 }, 110 { __LINE__, 0, TYPE_1, STYLE_2, EXSTYLE_0, STYLE_2, EXSTYLE_2 }, 111 { __LINE__, 0, TYPE_1, STYLE_2, EXSTYLE_0, STYLE_2, EXSTYLE_3 }, 112 { __LINE__, 1, TYPE_1, STYLE_2, EXSTYLE_1, STYLE_0, EXSTYLE_0 }, 113 { __LINE__, 1, TYPE_1, STYLE_2, EXSTYLE_1, STYLE_0, EXSTYLE_1 }, 114 { __LINE__, 1, TYPE_1, STYLE_2, EXSTYLE_1, STYLE_0, EXSTYLE_2 }, 115 { __LINE__, 1, TYPE_1, STYLE_2, EXSTYLE_1, STYLE_0, EXSTYLE_3 }, 116 { __LINE__, 1, TYPE_1, STYLE_2, EXSTYLE_1, STYLE_1, EXSTYLE_0 }, 117 { __LINE__, 1, TYPE_1, STYLE_2, EXSTYLE_1, STYLE_1, EXSTYLE_1 }, 118 { __LINE__, 1, TYPE_1, STYLE_2, EXSTYLE_1, STYLE_1, EXSTYLE_2 }, 119 { __LINE__, 1, TYPE_1, STYLE_2, EXSTYLE_1, STYLE_1, EXSTYLE_3 }, 120 { __LINE__, 1, TYPE_1, STYLE_2, EXSTYLE_1, STYLE_2, EXSTYLE_0 }, 121 { __LINE__, 1, TYPE_1, STYLE_2, EXSTYLE_1, STYLE_2, EXSTYLE_1 }, 122 { __LINE__, 1, TYPE_1, STYLE_2, EXSTYLE_1, STYLE_2, EXSTYLE_2 }, 123 { __LINE__, 1, TYPE_1, STYLE_2, EXSTYLE_1, STYLE_2, EXSTYLE_3 }, 124 { __LINE__, 0, TYPE_1, STYLE_2, EXSTYLE_2, STYLE_0, EXSTYLE_0 }, 125 { __LINE__, 0, TYPE_1, STYLE_2, EXSTYLE_2, STYLE_0, EXSTYLE_1 }, 126 { __LINE__, 0, TYPE_1, STYLE_2, EXSTYLE_2, STYLE_0, EXSTYLE_2 }, 127 { __LINE__, 0, TYPE_1, STYLE_2, EXSTYLE_2, STYLE_0, EXSTYLE_3 }, 128 { __LINE__, 0, TYPE_1, STYLE_2, EXSTYLE_2, STYLE_1, EXSTYLE_0 }, 129 { __LINE__, 0, TYPE_1, STYLE_2, EXSTYLE_2, STYLE_1, EXSTYLE_1 }, 130 { __LINE__, 0, TYPE_1, STYLE_2, EXSTYLE_2, STYLE_1, EXSTYLE_2 }, 131 { __LINE__, 0, TYPE_1, STYLE_2, EXSTYLE_2, STYLE_1, EXSTYLE_3 }, 132 { __LINE__, 0, TYPE_1, STYLE_2, EXSTYLE_2, STYLE_2, EXSTYLE_0 }, 133 { __LINE__, 0, TYPE_1, STYLE_2, EXSTYLE_2, STYLE_2, EXSTYLE_1 }, 134 { __LINE__, 0, TYPE_1, STYLE_2, EXSTYLE_2, STYLE_2, EXSTYLE_2 }, 135 { __LINE__, 0, TYPE_1, STYLE_2, EXSTYLE_2, STYLE_2, EXSTYLE_3 }, 136 { __LINE__, 1, TYPE_1, STYLE_2, EXSTYLE_3, STYLE_0, EXSTYLE_0 }, 137 { __LINE__, 1, TYPE_1, STYLE_2, EXSTYLE_3, STYLE_0, EXSTYLE_1 }, 138 { __LINE__, 1, TYPE_1, STYLE_2, EXSTYLE_3, STYLE_0, EXSTYLE_2 }, 139 { __LINE__, 1, TYPE_1, STYLE_2, EXSTYLE_3, STYLE_0, EXSTYLE_3 }, 140 { __LINE__, 1, TYPE_1, STYLE_2, EXSTYLE_3, STYLE_1, EXSTYLE_0 }, 141 { __LINE__, 1, TYPE_1, STYLE_2, EXSTYLE_3, STYLE_1, EXSTYLE_1 }, 142 { __LINE__, 1, TYPE_1, STYLE_2, EXSTYLE_3, STYLE_1, EXSTYLE_2 }, 143 { __LINE__, 1, TYPE_1, STYLE_2, EXSTYLE_3, STYLE_1, EXSTYLE_3 }, 144 { __LINE__, 1, TYPE_1, STYLE_2, EXSTYLE_3, STYLE_2, EXSTYLE_0 }, 145 { __LINE__, 1, TYPE_1, STYLE_2, EXSTYLE_3, STYLE_2, EXSTYLE_1 }, 146 { __LINE__, 1, TYPE_1, STYLE_2, EXSTYLE_3, STYLE_2, EXSTYLE_2 }, 147 { __LINE__, 1, TYPE_1, STYLE_2, EXSTYLE_3, STYLE_2, EXSTYLE_3 }, 148 149 // TYPE_2 150 { __LINE__, 0, TYPE_2, STYLE_1, EXSTYLE_0, STYLE_0, EXSTYLE_0 }, 151 { __LINE__, 0, TYPE_2, STYLE_1, EXSTYLE_0, STYLE_0, EXSTYLE_1 }, 152 { __LINE__, 0, TYPE_2, STYLE_1, EXSTYLE_0, STYLE_0, EXSTYLE_2 }, 153 { __LINE__, 0, TYPE_2, STYLE_1, EXSTYLE_0, STYLE_0, EXSTYLE_3 }, 154 { __LINE__, 0, TYPE_2, STYLE_1, EXSTYLE_0, STYLE_1, EXSTYLE_0 }, 155 { __LINE__, 0, TYPE_2, STYLE_1, EXSTYLE_0, STYLE_1, EXSTYLE_1 }, 156 { __LINE__, 0, TYPE_2, STYLE_1, EXSTYLE_0, STYLE_1, EXSTYLE_2 }, 157 { __LINE__, 0, TYPE_2, STYLE_1, EXSTYLE_0, STYLE_1, EXSTYLE_3 }, 158 { __LINE__, 0, TYPE_2, STYLE_1, EXSTYLE_0, STYLE_2, EXSTYLE_0 }, 159 { __LINE__, 0, TYPE_2, STYLE_1, EXSTYLE_0, STYLE_2, EXSTYLE_1 }, 160 { __LINE__, 0, TYPE_2, STYLE_1, EXSTYLE_0, STYLE_2, EXSTYLE_2 }, 161 { __LINE__, 0, TYPE_2, STYLE_1, EXSTYLE_0, STYLE_2, EXSTYLE_3 }, 162 { __LINE__, 1, TYPE_2, STYLE_1, EXSTYLE_1, STYLE_0, EXSTYLE_0 }, 163 { __LINE__, 1, TYPE_2, STYLE_1, EXSTYLE_1, STYLE_0, EXSTYLE_1 }, 164 { __LINE__, 1, TYPE_2, STYLE_1, EXSTYLE_1, STYLE_0, EXSTYLE_2 }, 165 { __LINE__, 1, TYPE_2, STYLE_1, EXSTYLE_1, STYLE_0, EXSTYLE_3 }, 166 { __LINE__, 1, TYPE_2, STYLE_1, EXSTYLE_1, STYLE_1, EXSTYLE_0 }, 167 { __LINE__, 1, TYPE_2, STYLE_1, EXSTYLE_1, STYLE_1, EXSTYLE_1 }, 168 { __LINE__, 1, TYPE_2, STYLE_1, EXSTYLE_1, STYLE_1, EXSTYLE_2 }, 169 { __LINE__, 1, TYPE_2, STYLE_1, EXSTYLE_1, STYLE_1, EXSTYLE_3 }, 170 { __LINE__, 1, TYPE_2, STYLE_1, EXSTYLE_1, STYLE_2, EXSTYLE_0 }, 171 { __LINE__, 1, TYPE_2, STYLE_1, EXSTYLE_1, STYLE_2, EXSTYLE_1 }, 172 { __LINE__, 1, TYPE_2, STYLE_1, EXSTYLE_1, STYLE_2, EXSTYLE_2 }, 173 { __LINE__, 1, TYPE_2, STYLE_1, EXSTYLE_1, STYLE_2, EXSTYLE_3 }, 174 { __LINE__, 0, TYPE_2, STYLE_1, EXSTYLE_2, STYLE_0, EXSTYLE_0 }, 175 { __LINE__, 0, TYPE_2, STYLE_1, EXSTYLE_2, STYLE_0, EXSTYLE_1 }, 176 { __LINE__, 0, TYPE_2, STYLE_1, EXSTYLE_2, STYLE_0, EXSTYLE_2 }, 177 { __LINE__, 0, TYPE_2, STYLE_1, EXSTYLE_2, STYLE_0, EXSTYLE_3 }, 178 { __LINE__, 0, TYPE_2, STYLE_1, EXSTYLE_2, STYLE_1, EXSTYLE_0 }, 179 { __LINE__, 0, TYPE_2, STYLE_1, EXSTYLE_2, STYLE_1, EXSTYLE_1 }, 180 { __LINE__, 0, TYPE_2, STYLE_1, EXSTYLE_2, STYLE_1, EXSTYLE_2 }, 181 { __LINE__, 0, TYPE_2, STYLE_1, EXSTYLE_2, STYLE_1, EXSTYLE_3 }, 182 { __LINE__, 0, TYPE_2, STYLE_1, EXSTYLE_2, STYLE_2, EXSTYLE_0 }, 183 { __LINE__, 0, TYPE_2, STYLE_1, EXSTYLE_2, STYLE_2, EXSTYLE_1 }, 184 { __LINE__, 0, TYPE_2, STYLE_1, EXSTYLE_2, STYLE_2, EXSTYLE_2 }, 185 { __LINE__, 0, TYPE_2, STYLE_1, EXSTYLE_2, STYLE_2, EXSTYLE_3 }, 186 { __LINE__, 1, TYPE_2, STYLE_1, EXSTYLE_3, STYLE_0, EXSTYLE_0 }, 187 { __LINE__, 1, TYPE_2, STYLE_1, EXSTYLE_3, STYLE_0, EXSTYLE_1 }, 188 { __LINE__, 1, TYPE_2, STYLE_1, EXSTYLE_3, STYLE_0, EXSTYLE_2 }, 189 { __LINE__, 1, TYPE_2, STYLE_1, EXSTYLE_3, STYLE_0, EXSTYLE_3 }, 190 { __LINE__, 1, TYPE_2, STYLE_1, EXSTYLE_3, STYLE_1, EXSTYLE_0 }, 191 { __LINE__, 1, TYPE_2, STYLE_1, EXSTYLE_3, STYLE_1, EXSTYLE_1 }, 192 { __LINE__, 1, TYPE_2, STYLE_1, EXSTYLE_3, STYLE_1, EXSTYLE_2 }, 193 { __LINE__, 1, TYPE_2, STYLE_1, EXSTYLE_3, STYLE_1, EXSTYLE_3 }, 194 { __LINE__, 1, TYPE_2, STYLE_1, EXSTYLE_3, STYLE_2, EXSTYLE_0 }, 195 { __LINE__, 1, TYPE_2, STYLE_1, EXSTYLE_3, STYLE_2, EXSTYLE_1 }, 196 { __LINE__, 1, TYPE_2, STYLE_1, EXSTYLE_3, STYLE_2, EXSTYLE_2 }, 197 { __LINE__, 1, TYPE_2, STYLE_1, EXSTYLE_3, STYLE_2, EXSTYLE_3 }, 198 { __LINE__, 0, TYPE_2, STYLE_2, EXSTYLE_0, STYLE_0, EXSTYLE_0 }, 199 { __LINE__, 0, TYPE_2, STYLE_2, EXSTYLE_0, STYLE_0, EXSTYLE_1 }, 200 { __LINE__, 0, TYPE_2, STYLE_2, EXSTYLE_0, STYLE_0, EXSTYLE_2 }, 201 { __LINE__, 0, TYPE_2, STYLE_2, EXSTYLE_0, STYLE_0, EXSTYLE_3 }, 202 { __LINE__, 0, TYPE_2, STYLE_2, EXSTYLE_0, STYLE_1, EXSTYLE_0 }, 203 { __LINE__, 0, TYPE_2, STYLE_2, EXSTYLE_0, STYLE_1, EXSTYLE_1 }, 204 { __LINE__, 0, TYPE_2, STYLE_2, EXSTYLE_0, STYLE_1, EXSTYLE_2 }, 205 { __LINE__, 0, TYPE_2, STYLE_2, EXSTYLE_0, STYLE_1, EXSTYLE_3 }, 206 { __LINE__, 0, TYPE_2, STYLE_2, EXSTYLE_0, STYLE_2, EXSTYLE_0 }, 207 { __LINE__, 0, TYPE_2, STYLE_2, EXSTYLE_0, STYLE_2, EXSTYLE_1 }, 208 { __LINE__, 0, TYPE_2, STYLE_2, EXSTYLE_0, STYLE_2, EXSTYLE_2 }, 209 { __LINE__, 0, TYPE_2, STYLE_2, EXSTYLE_0, STYLE_2, EXSTYLE_3 }, 210 { __LINE__, 0, TYPE_2, STYLE_2, EXSTYLE_1, STYLE_0, EXSTYLE_0 }, 211 { __LINE__, 0, TYPE_2, STYLE_2, EXSTYLE_1, STYLE_0, EXSTYLE_1 }, 212 { __LINE__, 0, TYPE_2, STYLE_2, EXSTYLE_1, STYLE_0, EXSTYLE_2 }, 213 { __LINE__, 0, TYPE_2, STYLE_2, EXSTYLE_1, STYLE_0, EXSTYLE_3 }, 214 { __LINE__, 0, TYPE_2, STYLE_2, EXSTYLE_1, STYLE_1, EXSTYLE_0 }, 215 { __LINE__, 0, TYPE_2, STYLE_2, EXSTYLE_1, STYLE_1, EXSTYLE_1 }, 216 { __LINE__, 0, TYPE_2, STYLE_2, EXSTYLE_1, STYLE_1, EXSTYLE_2 }, 217 { __LINE__, 0, TYPE_2, STYLE_2, EXSTYLE_1, STYLE_1, EXSTYLE_3 }, 218 { __LINE__, 0, TYPE_2, STYLE_2, EXSTYLE_1, STYLE_2, EXSTYLE_0 }, 219 { __LINE__, 0, TYPE_2, STYLE_2, EXSTYLE_1, STYLE_2, EXSTYLE_1 }, 220 { __LINE__, 0, TYPE_2, STYLE_2, EXSTYLE_1, STYLE_2, EXSTYLE_2 }, 221 { __LINE__, 0, TYPE_2, STYLE_2, EXSTYLE_1, STYLE_2, EXSTYLE_3 }, 222 { __LINE__, 0, TYPE_2, STYLE_2, EXSTYLE_2, STYLE_0, EXSTYLE_0 }, 223 { __LINE__, 0, TYPE_2, STYLE_2, EXSTYLE_2, STYLE_0, EXSTYLE_1 }, 224 { __LINE__, 0, TYPE_2, STYLE_2, EXSTYLE_2, STYLE_0, EXSTYLE_2 }, 225 { __LINE__, 0, TYPE_2, STYLE_2, EXSTYLE_2, STYLE_0, EXSTYLE_3 }, 226 { __LINE__, 0, TYPE_2, STYLE_2, EXSTYLE_2, STYLE_1, EXSTYLE_0 }, 227 { __LINE__, 0, TYPE_2, STYLE_2, EXSTYLE_2, STYLE_1, EXSTYLE_1 }, 228 { __LINE__, 0, TYPE_2, STYLE_2, EXSTYLE_2, STYLE_1, EXSTYLE_2 }, 229 { __LINE__, 0, TYPE_2, STYLE_2, EXSTYLE_2, STYLE_1, EXSTYLE_3 }, 230 { __LINE__, 0, TYPE_2, STYLE_2, EXSTYLE_2, STYLE_2, EXSTYLE_0 }, 231 { __LINE__, 0, TYPE_2, STYLE_2, EXSTYLE_2, STYLE_2, EXSTYLE_1 }, 232 { __LINE__, 0, TYPE_2, STYLE_2, EXSTYLE_2, STYLE_2, EXSTYLE_2 }, 233 { __LINE__, 0, TYPE_2, STYLE_2, EXSTYLE_2, STYLE_2, EXSTYLE_3 }, 234 { __LINE__, 0, TYPE_2, STYLE_2, EXSTYLE_3, STYLE_0, EXSTYLE_0 }, 235 { __LINE__, 0, TYPE_2, STYLE_2, EXSTYLE_3, STYLE_0, EXSTYLE_1 }, 236 { __LINE__, 0, TYPE_2, STYLE_2, EXSTYLE_3, STYLE_0, EXSTYLE_2 }, 237 { __LINE__, 0, TYPE_2, STYLE_2, EXSTYLE_3, STYLE_0, EXSTYLE_3 }, 238 { __LINE__, 0, TYPE_2, STYLE_2, EXSTYLE_3, STYLE_1, EXSTYLE_0 }, 239 { __LINE__, 0, TYPE_2, STYLE_2, EXSTYLE_3, STYLE_1, EXSTYLE_1 }, 240 { __LINE__, 0, TYPE_2, STYLE_2, EXSTYLE_3, STYLE_1, EXSTYLE_2 }, 241 { __LINE__, 0, TYPE_2, STYLE_2, EXSTYLE_3, STYLE_1, EXSTYLE_3 }, 242 { __LINE__, 0, TYPE_2, STYLE_2, EXSTYLE_3, STYLE_2, EXSTYLE_0 }, 243 { __LINE__, 0, TYPE_2, STYLE_2, EXSTYLE_3, STYLE_2, EXSTYLE_1 }, 244 { __LINE__, 0, TYPE_2, STYLE_2, EXSTYLE_3, STYLE_2, EXSTYLE_2 }, 245 { __LINE__, 0, TYPE_2, STYLE_2, EXSTYLE_3, STYLE_2, EXSTYLE_3 }, 246 }; 247 248 typedef struct RUDEAPP_TEST_ENTRY 249 { 250 INT lineno; 251 UINT nCount; 252 DWORD style; 253 DWORD exstyle; 254 BOOL bSetForeground; 255 BOOL bFullscreen; 256 BOOL bSetFullscreen; 257 } RUDEAPP_TEST_ENTRY; 258 259 static const RUDEAPP_TEST_ENTRY s_entries2[] = 260 { 261 /* STYLE_0 */ 262 { __LINE__, 0, STYLE_0, EXSTYLE_0, FALSE, FALSE, FALSE }, 263 { __LINE__, 0, STYLE_0, EXSTYLE_0, FALSE, FALSE, TRUE }, 264 { __LINE__, 0, STYLE_0, EXSTYLE_0, FALSE, TRUE, FALSE }, 265 { __LINE__, 0, STYLE_0, EXSTYLE_0, FALSE, TRUE, TRUE }, 266 { __LINE__, 0, STYLE_0, EXSTYLE_0, TRUE, FALSE, FALSE }, 267 { __LINE__, 0, STYLE_0, EXSTYLE_0, TRUE, FALSE, TRUE }, 268 { __LINE__, 0, STYLE_0, EXSTYLE_0, TRUE, TRUE, FALSE }, 269 { __LINE__, 0, STYLE_0, EXSTYLE_0, TRUE, TRUE, TRUE }, 270 271 { __LINE__, 0, STYLE_0, EXSTYLE_1, FALSE, FALSE, FALSE }, 272 { __LINE__, 0, STYLE_0, EXSTYLE_1, FALSE, FALSE, TRUE }, 273 { __LINE__, 0, STYLE_0, EXSTYLE_1, FALSE, TRUE, FALSE }, 274 { __LINE__, 0, STYLE_0, EXSTYLE_1, FALSE, TRUE, TRUE }, 275 { __LINE__, 0, STYLE_0, EXSTYLE_1, TRUE, FALSE, FALSE }, 276 { __LINE__, 0, STYLE_0, EXSTYLE_1, TRUE, FALSE, TRUE }, 277 { __LINE__, 0, STYLE_0, EXSTYLE_1, TRUE, TRUE, FALSE }, 278 { __LINE__, 0, STYLE_0, EXSTYLE_1, TRUE, TRUE, TRUE }, 279 280 { __LINE__, 0, STYLE_0, EXSTYLE_2, FALSE, FALSE, FALSE }, 281 { __LINE__, 0, STYLE_0, EXSTYLE_2, FALSE, FALSE, TRUE }, 282 { __LINE__, 0, STYLE_0, EXSTYLE_2, FALSE, TRUE, FALSE }, 283 { __LINE__, 0, STYLE_0, EXSTYLE_2, FALSE, TRUE, TRUE }, 284 { __LINE__, 0, STYLE_0, EXSTYLE_2, TRUE, FALSE, FALSE }, 285 { __LINE__, 0, STYLE_0, EXSTYLE_2, TRUE, FALSE, TRUE }, 286 { __LINE__, 0, STYLE_0, EXSTYLE_2, TRUE, TRUE, FALSE }, 287 { __LINE__, 0, STYLE_0, EXSTYLE_2, TRUE, TRUE, TRUE }, 288 289 { __LINE__, 0, STYLE_0, EXSTYLE_3, FALSE, FALSE, FALSE }, 290 { __LINE__, 0, STYLE_0, EXSTYLE_3, FALSE, FALSE, TRUE }, 291 { __LINE__, 0, STYLE_0, EXSTYLE_3, FALSE, TRUE, FALSE }, 292 { __LINE__, 0, STYLE_0, EXSTYLE_3, FALSE, TRUE, TRUE }, 293 { __LINE__, 0, STYLE_0, EXSTYLE_3, TRUE, FALSE, FALSE }, 294 { __LINE__, 0, STYLE_0, EXSTYLE_3, TRUE, FALSE, TRUE }, 295 { __LINE__, 0, STYLE_0, EXSTYLE_3, TRUE, TRUE, FALSE }, 296 { __LINE__, 0, STYLE_0, EXSTYLE_3, TRUE, TRUE, TRUE }, 297 298 /* STYLE_1 */ 299 { __LINE__, 0, STYLE_1, EXSTYLE_0, FALSE, FALSE, FALSE }, 300 { __LINE__, 1, STYLE_1, EXSTYLE_0, FALSE, FALSE, TRUE }, 301 { __LINE__, 1, STYLE_1, EXSTYLE_0, FALSE, TRUE, FALSE }, 302 { __LINE__, 1, STYLE_1, EXSTYLE_0, FALSE, TRUE, TRUE }, 303 { __LINE__, 0, STYLE_1, EXSTYLE_0, TRUE, FALSE, FALSE }, 304 { __LINE__, 1, STYLE_1, EXSTYLE_0, TRUE, FALSE, TRUE }, 305 { __LINE__, 1, STYLE_1, EXSTYLE_0, TRUE, TRUE, FALSE }, 306 { __LINE__, 1, STYLE_1, EXSTYLE_0, TRUE, TRUE, TRUE }, 307 308 { __LINE__, 0, STYLE_1, EXSTYLE_1, FALSE, FALSE, FALSE }, 309 { __LINE__, 1, STYLE_1, EXSTYLE_1, FALSE, FALSE, TRUE }, 310 { __LINE__, 1, STYLE_1, EXSTYLE_1, FALSE, TRUE, FALSE }, 311 { __LINE__, 1, STYLE_1, EXSTYLE_1, FALSE, TRUE, TRUE }, 312 { __LINE__, 0, STYLE_1, EXSTYLE_1, TRUE, FALSE, FALSE }, 313 { __LINE__, 1, STYLE_1, EXSTYLE_1, TRUE, FALSE, TRUE }, 314 { __LINE__, 1, STYLE_1, EXSTYLE_1, TRUE, TRUE, FALSE }, 315 { __LINE__, 1, STYLE_1, EXSTYLE_1, TRUE, TRUE, TRUE }, 316 317 { __LINE__, 0, STYLE_1, EXSTYLE_2, FALSE, FALSE, FALSE }, 318 { __LINE__, 0, STYLE_1, EXSTYLE_2, FALSE, FALSE, TRUE }, 319 { __LINE__, 0, STYLE_1, EXSTYLE_2, FALSE, TRUE, FALSE }, 320 { __LINE__, 0, STYLE_1, EXSTYLE_2, FALSE, TRUE, TRUE }, 321 { __LINE__, 0, STYLE_1, EXSTYLE_2, TRUE, FALSE, FALSE }, 322 { __LINE__, 0, STYLE_1, EXSTYLE_2, TRUE, FALSE, TRUE }, 323 { __LINE__, 0, STYLE_1, EXSTYLE_2, TRUE, TRUE, FALSE }, 324 { __LINE__, 0, STYLE_1, EXSTYLE_2, TRUE, TRUE, TRUE }, 325 326 { __LINE__, 0, STYLE_1, EXSTYLE_3, FALSE, FALSE, FALSE }, 327 { __LINE__, 0, STYLE_1, EXSTYLE_3, FALSE, FALSE, TRUE }, 328 { __LINE__, 0, STYLE_1, EXSTYLE_3, FALSE, TRUE, FALSE }, 329 { __LINE__, 0, STYLE_1, EXSTYLE_3, FALSE, TRUE, TRUE }, 330 { __LINE__, 0, STYLE_1, EXSTYLE_3, TRUE, FALSE, FALSE }, 331 { __LINE__, 0, STYLE_1, EXSTYLE_3, TRUE, FALSE, TRUE }, 332 { __LINE__, 0, STYLE_1, EXSTYLE_3, TRUE, TRUE, FALSE }, 333 { __LINE__, 0, STYLE_1, EXSTYLE_3, TRUE, TRUE, TRUE }, 334 335 /* STYLE_2 */ 336 { __LINE__, 0, STYLE_2, EXSTYLE_0, FALSE, FALSE, FALSE }, 337 { __LINE__, 1, STYLE_2, EXSTYLE_0, FALSE, FALSE, TRUE }, 338 { __LINE__, 1, STYLE_2, EXSTYLE_0, FALSE, TRUE, FALSE }, 339 { __LINE__, 1, STYLE_2, EXSTYLE_0, FALSE, TRUE, TRUE }, 340 { __LINE__, 0, STYLE_2, EXSTYLE_0, TRUE, FALSE, FALSE }, 341 { __LINE__, 1, STYLE_2, EXSTYLE_0, TRUE, FALSE, TRUE }, 342 { __LINE__, 1, STYLE_2, EXSTYLE_0, TRUE, TRUE, FALSE }, 343 { __LINE__, 1, STYLE_2, EXSTYLE_0, TRUE, TRUE, TRUE }, 344 345 { __LINE__, 0, STYLE_2, EXSTYLE_1, FALSE, FALSE, FALSE }, 346 { __LINE__, 1, STYLE_2, EXSTYLE_1, FALSE, FALSE, TRUE }, 347 { __LINE__, 1, STYLE_2, EXSTYLE_1, FALSE, TRUE, FALSE }, 348 { __LINE__, 1, STYLE_2, EXSTYLE_1, FALSE, TRUE, TRUE }, 349 { __LINE__, 0, STYLE_2, EXSTYLE_1, TRUE, FALSE, FALSE }, 350 { __LINE__, 1, STYLE_2, EXSTYLE_1, TRUE, FALSE, TRUE }, 351 { __LINE__, 1, STYLE_2, EXSTYLE_1, TRUE, TRUE, FALSE }, 352 { __LINE__, 1, STYLE_2, EXSTYLE_1, TRUE, TRUE, TRUE }, 353 354 { __LINE__, 0, STYLE_2, EXSTYLE_2, FALSE, FALSE, FALSE }, 355 { __LINE__, 0, STYLE_2, EXSTYLE_2, FALSE, FALSE, TRUE }, 356 { __LINE__, 0, STYLE_2, EXSTYLE_2, FALSE, TRUE, FALSE }, 357 { __LINE__, 0, STYLE_2, EXSTYLE_2, FALSE, TRUE, TRUE }, 358 { __LINE__, 0, STYLE_2, EXSTYLE_2, TRUE, FALSE, FALSE }, 359 { __LINE__, 0, STYLE_2, EXSTYLE_2, TRUE, FALSE, TRUE }, 360 { __LINE__, 0, STYLE_2, EXSTYLE_2, TRUE, TRUE, FALSE }, 361 { __LINE__, 0, STYLE_2, EXSTYLE_2, TRUE, TRUE, TRUE }, 362 363 { __LINE__, 0, STYLE_2, EXSTYLE_3, FALSE, FALSE, FALSE }, 364 { __LINE__, 0, STYLE_2, EXSTYLE_3, FALSE, FALSE, TRUE }, 365 { __LINE__, 0, STYLE_2, EXSTYLE_3, FALSE, TRUE, FALSE }, 366 { __LINE__, 0, STYLE_2, EXSTYLE_3, FALSE, TRUE, TRUE }, 367 { __LINE__, 0, STYLE_2, EXSTYLE_3, TRUE, FALSE, FALSE }, 368 { __LINE__, 0, STYLE_2, EXSTYLE_3, TRUE, FALSE, TRUE }, 369 { __LINE__, 0, STYLE_2, EXSTYLE_3, TRUE, TRUE, FALSE }, 370 { __LINE__, 0, STYLE_2, EXSTYLE_3, TRUE, TRUE, TRUE }, 371 }; 372 373 static UINT s_uShellHookMsg = 0; 374 static HWND s_hwndHookViewer = NULL; 375 static HWND s_hwndParent = NULL; 376 static HWND s_hwndTarget = NULL; 377 static UINT s_nWindowCreatedCount = 0; 378 static UINT s_nRudeAppActivated = 0; 379 static WCHAR s_szName[] = L"ReactOS ShellHook testcase"; 380 381 static HWND 382 DoCreateWindow(HWND hwndParent, DWORD style, DWORD exstyle, BOOL bFullscreen = FALSE) 383 { 384 INT x = CW_USEDEFAULT, y = CW_USEDEFAULT, cx = 100, cy = 100; 385 if (bFullscreen) 386 { 387 x = y = 0; 388 cx = GetSystemMetrics(SM_CXSCREEN); 389 cy = GetSystemMetrics(SM_CYSCREEN); 390 } 391 return CreateWindowExW(exstyle, s_szName, s_szName, style, x, y, cx, cy, 392 hwndParent, NULL, GetModuleHandleW(NULL), NULL); 393 } 394 395 static void DoTestEntryPart1(const TEST_ENTRY *pEntry) 396 { 397 ok(!pEntry->bIsChild || pEntry->bHasOwner, 398 "Line %d: bIsChild && !bHasOwner\n", pEntry->lineno); 399 400 s_hwndParent = NULL; 401 if (pEntry->bIsChild || pEntry->bHasOwner) 402 { 403 s_hwndParent = DoCreateWindow(NULL, pEntry->owner_style, pEntry->owner_exstyle); 404 } 405 406 DWORD style = pEntry->style; 407 DWORD exstyle = pEntry->exstyle; 408 if (pEntry->bIsChild) 409 style |= WS_CHILD; 410 else 411 style &= ~WS_CHILD; 412 413 s_nWindowCreatedCount = 0; 414 s_hwndTarget = DoCreateWindow(s_hwndParent, style, exstyle); 415 } 416 417 static void DoTestEntryPart2(const TEST_ENTRY *pEntry) 418 { 419 ok(s_nWindowCreatedCount == pEntry->nCount, 420 "Line %d: s_nWindowCreatedCount expected %u but was %u\n", 421 pEntry->lineno, pEntry->nCount, s_nWindowCreatedCount); 422 423 PostMessageW(s_hwndTarget, WM_CLOSE, 0, 0); 424 s_hwndTarget = NULL; 425 426 if (pEntry->bIsChild || pEntry->bHasOwner) 427 { 428 PostMessageW(s_hwndParent, WM_CLOSE, 0, 0); 429 s_hwndParent = NULL; 430 } 431 } 432 433 static void DoRudeAppTest1(const RUDEAPP_TEST_ENTRY *pEntry) 434 { 435 s_hwndParent = NULL; 436 437 DWORD style = pEntry->style; 438 DWORD exstyle = pEntry->exstyle; 439 440 s_nRudeAppActivated = 0; 441 s_hwndTarget = DoCreateWindow(s_hwndParent, style, exstyle, pEntry->bFullscreen); 442 if (pEntry->bSetForeground) 443 SetForegroundWindow(s_hwndTarget); 444 if (pEntry->bSetFullscreen) 445 { 446 MoveWindow(s_hwndTarget, 0, 0, 447 GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), TRUE); 448 } 449 } 450 451 static void DoRudeAppTest2(const RUDEAPP_TEST_ENTRY *pEntry) 452 { 453 ok(s_nRudeAppActivated == pEntry->nCount, 454 "Line %d: s_nRudeAppActivated expected %u but was %u\n", 455 pEntry->lineno, pEntry->nCount, s_nRudeAppActivated); 456 457 PostMessageW(s_hwndTarget, WM_CLOSE, 0, 0); 458 s_hwndTarget = NULL; 459 } 460 461 static LRESULT CALLBACK 462 WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 463 { 464 if (uMsg == s_uShellHookMsg && uMsg != 0) 465 { 466 switch (wParam) 467 { 468 case HSHELL_WINDOWCREATED: 469 if ((HWND)lParam != s_hwndTarget) 470 break; 471 ++s_nWindowCreatedCount; 472 break; 473 474 case HSHELL_RUDEAPPACTIVATED: 475 if ((HWND)lParam != s_hwndTarget) 476 break; 477 ++s_nRudeAppActivated; 478 break; 479 } 480 } 481 #define ID_IGNITION 1000 482 #define ID_BURNING 2000 483 #define ID_RUDEAPPTEST1 3000 484 #define ID_RUDEAPPTEST2 4000 485 switch (uMsg) 486 { 487 case WM_CREATE: 488 PostMessageW(hwnd, WM_COMMAND, ID_IGNITION, 0); 489 return DefWindowProcW(hwnd, uMsg, wParam, lParam); 490 case WM_COMMAND: 491 if (hwnd != s_hwndHookViewer) 492 break; 493 494 if (ID_IGNITION <= wParam && wParam < ID_BURNING) 495 { 496 INT i = (INT)wParam - ID_IGNITION; 497 DoTestEntryPart1(&s_entries1[i]); 498 PostMessageW(hwnd, WM_COMMAND, ID_BURNING + i, 0); 499 } 500 else if (ID_BURNING <= wParam && wParam < ID_RUDEAPPTEST1) 501 { 502 INT i = (INT)wParam - ID_BURNING; 503 DoTestEntryPart2(&s_entries1[i]); 504 ++i; 505 if (i == (INT)_countof(s_entries1)) 506 { 507 PostMessageW(hwnd, WM_COMMAND, ID_RUDEAPPTEST1, 0); 508 break; 509 } 510 PostMessageW(hwnd, WM_COMMAND, ID_IGNITION + i, 0); 511 } 512 else if (ID_RUDEAPPTEST1 <= wParam && wParam < ID_RUDEAPPTEST2) 513 { 514 INT i = (INT)wParam - ID_RUDEAPPTEST1; 515 DoRudeAppTest1(&s_entries2[i]); 516 PostMessageW(hwnd, WM_COMMAND, ID_RUDEAPPTEST2 + i, 0); 517 } 518 else if (ID_RUDEAPPTEST2 <= wParam) 519 { 520 INT i = (INT)wParam - ID_RUDEAPPTEST2; 521 DoRudeAppTest2(&s_entries2[i]); 522 ++i; 523 if (i == (INT)_countof(s_entries2)) 524 { 525 PostQuitMessage(0); 526 break; 527 } 528 PostMessageW(hwnd, WM_COMMAND, ID_RUDEAPPTEST1 + i, 0); 529 } 530 break; 531 default: 532 return DefWindowProcW(hwnd, uMsg, wParam, lParam); 533 } 534 return 0; 535 } 536 537 START_TEST(ShellHook) 538 { 539 WNDCLASSW wc; 540 541 ZeroMemory(&wc, sizeof(wc)); 542 wc.lpfnWndProc = WindowProc; 543 wc.hInstance = GetModuleHandleW(NULL); 544 wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); 545 wc.hCursor = LoadCursor(NULL, IDC_ARROW); 546 wc.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1); 547 wc.lpszClassName = s_szName; 548 if (!RegisterClassW(&wc)) 549 { 550 skip("RegisterClassW failed\n"); 551 return; 552 } 553 554 s_hwndHookViewer = DoCreateWindow(NULL, WS_OVERLAPPEDWINDOW | WS_VISIBLE, 0); 555 if (s_hwndHookViewer == NULL) 556 { 557 skip("CreateWindowExW failed\n"); 558 return; 559 } 560 561 s_uShellHookMsg = RegisterWindowMessageW(L"SHELLHOOK"); 562 RegisterShellHookWindow(s_hwndHookViewer); 563 564 MSG msg; 565 while (GetMessageW(&msg, NULL, 0, 0)) 566 { 567 TranslateMessage(&msg); 568 DispatchMessageW(&msg); 569 } 570 571 DeregisterShellHookWindow(s_hwndHookViewer); 572 DestroyWindow(s_hwndHookViewer); 573 s_hwndHookViewer = NULL; 574 } 575