ReactOS 0.4.16-dev-106-g10b08aa
confdlg.c
Go to the documentation of this file.
1/*
2 * Unit test suite for serialui API functions
3 *
4 * Copyright 2007 Detlef Riekenberg
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 *
20 */
21
22#include <stdarg.h>
23#include <stdio.h>
24
25#include "windef.h"
26#include "winbase.h"
27#include "winerror.h"
28#include "winnls.h"
29
30#include "wine/test.h"
31
32
34static DWORD (WINAPI *pCommConfigDialogA)(LPCSTR, HWND, LPCOMMCONFIG);
35static DWORD (WINAPI *pCommConfigDialogW)(LPCWSTR, HWND, LPCOMMCONFIG);
36static DWORD (WINAPI *pGetDefaultCommConfigA)(LPCSTR, LPCOMMCONFIG, LPDWORD);
37static DWORD (WINAPI *pGetDefaultCommConfigW)(LPCWSTR, LPCOMMCONFIG, LPDWORD);
38
39
40static const CHAR com1A[] = "com1";
41static const CHAR emptyA[] = "";
42static const CHAR fmt_comA[] = "com%d";
43static const CHAR str_colonA[] = ":";
44
45static const WCHAR com1W[] = {'c','o','m','1',0};
46static const WCHAR emptyW[] = {0};
47static const WCHAR str_colonW[] = {':',0};
48
49/* ################# */
50
52{
53 LPCSTR ptr;
54
55 ptr = "serialui.dll";
57 if (!hdll) return ptr;
58
59 ptr = "drvCommConfigDialogA";
60 pCommConfigDialogA = (VOID *) GetProcAddress(hdll, ptr);
61 if (!pCommConfigDialogA) return ptr;
62
63 ptr = "drvCommConfigDialogW";
64 pCommConfigDialogW = (VOID *) GetProcAddress(hdll, ptr);
65 if (!pCommConfigDialogW) return ptr;
66
67 ptr = "drvGetDefaultCommConfigA";
68 pGetDefaultCommConfigA = (VOID *) GetProcAddress(hdll, ptr);
69 if (!pGetDefaultCommConfigA) return ptr;
70
71 ptr = "drvGetDefaultCommConfigW";
72 pGetDefaultCommConfigW = (VOID *) GetProcAddress(hdll, ptr);
73 if (!pGetDefaultCommConfigW) return ptr;
74
75
76 return NULL;
77}
78
79/* ################# */
80
82{
83 COMMCONFIG pCC[3];
84 CHAR bufferA[16];
85 DWORD i;
86 DWORD res;
87 DWORD len;
88
89
90 /* test ports "com1" - "com4" */
91 for (i = 1; i < 5 ; i++) {
92 sprintf(bufferA, fmt_comA, i);
93 len = sizeof(pCC);
94 ZeroMemory(pCC, sizeof(pCC));
95 SetLastError(0xdeadbeef);
96 res = pGetDefaultCommConfigA(bufferA, pCC, &len);
98 /* NT does not implement the ANSI API */
99 win_skip("*A not implemented\n");
100 return;
101 }
102
103 if (res == ERROR_SUCCESS) {
104
106 SetLastError(0xdeadbeef);
107 res = pCommConfigDialogA(bufferA, NULL, pCC);
108 /* OK: ERROR_SUCCESS, Cancel: ERROR_CANCELLED */
109 trace("returned %u with %u for '%s'\n", res, GetLastError(), bufferA);
110 }
111
112 ZeroMemory(pCC, sizeof(pCC));
113 SetLastError(0xdeadbeef);
114 res = pCommConfigDialogA(bufferA, NULL, pCC);
116 "returned %u with %u for '%s' (expected ERROR_INSUFFICIENT_BUFFER)\n",
117 res, GetLastError(), bufferA);
118
119
120 SetLastError(0xdeadbeef);
121 res = pCommConfigDialogA(bufferA, NULL, NULL);
123 "returned %u with %u for '%s' (expected ERROR_INVALID_PARAMETER)\n",
124 res, GetLastError(), bufferA);
125 }
126 }
127
128
129 ZeroMemory(pCC, sizeof(pCC));
130 SetLastError(0xdeadbeef);
131 res = pCommConfigDialogA(emptyA, NULL, pCC);
133 "returned %u with %u (expected ERROR_INSUFFICIENT_BUFFER)\n",
134 res, GetLastError());
135
136
137 ZeroMemory(pCC, sizeof(pCC));
138 pCC[0].dwSize = sizeof(COMMCONFIG);
139 SetLastError(0xdeadbeef);
140 res = pCommConfigDialogA(emptyA, NULL, pCC);
141 ok( res == ERROR_BADKEY, "returned %u with %u (expected ERROR_BADKEY)\n",
142 res, GetLastError());
143
144
145 ZeroMemory(pCC, sizeof(pCC));
146 SetLastError(0xdeadbeef);
147 res = pCommConfigDialogA(NULL, NULL, pCC);
149 "returned %u with %u (expected ERROR_INVALID_PARAMETER)\n",
150 res, GetLastError());
151}
152
153/* ################# */
154
156{
157 COMMCONFIG pCC[3];
158 CHAR bufferA[16];
159 WCHAR bufferW[16];
160 DWORD i;
161 DWORD res;
162 DWORD len;
163
164
165 /* test ports "com1" - "com4" */
166 for (i = 1; i < 5 ; i++) {
167 sprintf(bufferA, fmt_comA, i);
168 MultiByteToWideChar(CP_ACP, 0, bufferA, -1, bufferW, ARRAY_SIZE(bufferW));
169 len = sizeof(pCC);
170 ZeroMemory(pCC, sizeof(pCC));
171 SetLastError(0xdeadbeef);
172 res = pGetDefaultCommConfigW(bufferW, pCC, &len);
174 win_skip("*W not implemented\n");
175 return;
176 }
177
178 if (res == ERROR_SUCCESS) {
179
181 SetLastError(0xdeadbeef);
182 res = pCommConfigDialogW(bufferW, NULL, pCC);
183 /* OK: ERROR_SUCCESS, Cancel: ERROR_CANCELLED */
184 trace("returned %u with %u for '%s'\n", res, GetLastError(), bufferA);
185 }
186
187 ZeroMemory(pCC, sizeof(pCC));
188 SetLastError(0xdeadbeef);
189 res = pCommConfigDialogW(bufferW, NULL, pCC);
191 "returned %u with %u for '%s' (expected ERROR_INSUFFICIENT_BUFFER)\n",
192 res, GetLastError(), bufferA);
193
194 SetLastError(0xdeadbeef);
195 res = pCommConfigDialogW(bufferW, NULL, NULL);
197 "returned %u with %u for '%s' (expected ERROR_INVALID_PARAMETER)\n",
198 res, GetLastError(), bufferA);
199 }
200 }
201
202
203 ZeroMemory(pCC, sizeof(pCC));
204 SetLastError(0xdeadbeef);
205 res = pCommConfigDialogW(emptyW, NULL, pCC);
207 "returned %u with %u (expected ERROR_INSUFFICIENT_BUFFER)\n",
208 res, GetLastError());
209
210
211 ZeroMemory(pCC, sizeof(pCC));
212 pCC[0].dwSize = sizeof(COMMCONFIG);
213 SetLastError(0xdeadbeef);
214 res = pCommConfigDialogW(emptyW, NULL, pCC);
215 ok( res == ERROR_BADKEY, "returned %u with %u (expected ERROR_BADKEY)\n",
216 res, GetLastError());
217
218
219 ZeroMemory(pCC, sizeof(pCC));
220 SetLastError(0xdeadbeef);
221 res = pCommConfigDialogW(NULL, NULL, pCC);
223 "returned %u with %u (expected ERROR_INVALID_PARAMETER)\n",
224 res, GetLastError());
225}
226
227
228/* ################# */
229
231{
232 COMMCONFIG pCC[3];
233 CHAR bufferA[16];
234 DWORD i;
235 DWORD res;
236 DWORD len;
237
238
239 /* off by one: one byte smaller */
240 i = sizeof(COMMCONFIG);
241 len = sizeof(COMMCONFIG) -1;
242 ZeroMemory(pCC, sizeof(pCC));
243 SetLastError(0xdeadbeef);
244 res = pGetDefaultCommConfigA(com1A, pCC, &len);
246 /* NT does not implement the ANSI API */
247 win_skip("*A not implemented\n");
248 return;
249 }
250 ok( (res == ERROR_INSUFFICIENT_BUFFER) && (len >= i),
251 "returned %u with %u and %u (expected "
252 "ERROR_INSUFFICIENT_BUFFER and '>= %u')\n", res, GetLastError(), len, i);
253
254 /* test ports "com0" - "com10" */
255 for (i = 0; i < 11 ; i++) {
256 sprintf(bufferA, fmt_comA, i);
257 len = sizeof(pCC);
258 ZeroMemory(pCC, sizeof(pCC));
259 SetLastError(0xdeadbeef);
260 res = pGetDefaultCommConfigA(bufferA, pCC, &len);
261 if (i == 0) {
262 ok( res == ERROR_BADKEY,
263 "returned %u with %u and %u for %s (expected "
264 "ERROR_BADKEY)\n", res, GetLastError(), len, bufferA);
265 }
266 else
267 {
268 ok((res == ERROR_SUCCESS) || (res == ERROR_BADKEY),
269 "returned %u with %u and %u for %s (expected ERROR_SUCCESS or "
270 "ERROR_BADKEY)\n", res, GetLastError(), len, bufferA);
271 }
272
273 /* a name with a colon is invalid */
274 if (res == ERROR_SUCCESS) {
275 lstrcatA(bufferA, str_colonA);
276 len = sizeof(pCC);
277 ZeroMemory(pCC, sizeof(pCC));
278 res = pGetDefaultCommConfigA(bufferA, pCC, &len);
279 ok( res == ERROR_BADKEY,
280 "returned %u with %u and %u for %s (expected '0' with "
281 "ERROR_BADKEY)\n", res, GetLastError(), len, bufferA);
282 }
283 }
284
285
286 /* an empty String is not allowed */
287 len = sizeof(pCC);
288 ZeroMemory(pCC, sizeof(pCC));
289 SetLastError(0xdeadbeef);
290 res = pGetDefaultCommConfigA(emptyA, pCC, &len);
291 ok( res == ERROR_BADKEY,
292 "returned %u with %u and %u for %s (expected ERROR_BADKEY)\n",
294
295 /* some NULL checks */
296 len = sizeof(pCC);
297 ZeroMemory(pCC, sizeof(pCC));
298 SetLastError(0xdeadbeef);
299 res = pGetDefaultCommConfigA(NULL, pCC, &len);
301 "returned %u with %u and %u for NULL (expected ERROR_INVALID_PARAMETER)\n",
302 res, GetLastError(), len);
303
304
305 len = sizeof(pCC);
306 SetLastError(0xdeadbeef);
307 res = pGetDefaultCommConfigA(com1A, NULL, &len);
309 "returned %u with %u and %u (expected ERROR_INVALID_PARAMETER)\n",
310 res, GetLastError(), len);
311
312
313 SetLastError(0xdeadbeef);
314 res = pGetDefaultCommConfigA(com1A, pCC, NULL);
316 "returned %u with %u (expected ERROR_INVALID_PARAMETER)\n",
317 res, GetLastError());
318}
319
320/* ################# */
321
323{
324 COMMCONFIG pCC[3];
325 WCHAR bufferW[16];
326 CHAR bufferA[16];
327 DWORD i;
328 DWORD res;
329 DWORD len;
330
331
332 /* off by one: one byte smaller */
333 i = sizeof(COMMCONFIG);
334 len = sizeof(COMMCONFIG) -1;
335 ZeroMemory(pCC, sizeof(pCC));
336 SetLastError(0xdeadbeef);
337 res = pGetDefaultCommConfigW(com1W, pCC, &len);
339 win_skip("*W not implemented\n");
340 return;
341 }
342 ok( (res == ERROR_INSUFFICIENT_BUFFER) && (len >= i),
343 "returned %u with %u and %u (expected "
344 "ERROR_INSUFFICIENT_BUFFER and '>= %u')\n", res, GetLastError(), len, i);
345
346 /* test ports "com0" - "com10" */
347 for (i = 0; i < 11 ; i++) {
348 sprintf(bufferA, fmt_comA, i);
349 MultiByteToWideChar(CP_ACP, 0, bufferA, -1, bufferW, ARRAY_SIZE(bufferW));
350 len = sizeof(pCC);
351 ZeroMemory(pCC, sizeof(pCC));
352 SetLastError(0xdeadbeef);
353 res = pGetDefaultCommConfigW(bufferW, pCC, &len);
354 if (i == 0) {
355 ok( res == ERROR_BADKEY,
356 "returned %u with %u and %u for %s (expected "
357 "ERROR_BADKEY)\n", res, GetLastError(), len, bufferA);
358 }
359 else
360 {
361 ok((res == ERROR_SUCCESS) || (res == ERROR_BADKEY),
362 "returned %u with %u and %u for %s (expected ERROR_SUCCESS or "
363 "ERROR_BADKEY)\n", res, GetLastError(), len, bufferA);
364 }
365
366 /* a name with a colon is invalid */
367 if (res == ERROR_SUCCESS) {
368 lstrcatA(bufferA, str_colonA);
369 lstrcatW(bufferW, str_colonW);
370 len = sizeof(pCC);
371 ZeroMemory(pCC, sizeof(pCC));
372 res = pGetDefaultCommConfigW(bufferW, pCC, &len);
373 ok( res == ERROR_BADKEY,
374 "returned %u with %u and %u for %s (expected '0' with "
375 "ERROR_BADKEY)\n", res, GetLastError(), len, bufferA);
376 }
377 }
378
379 /* an empty String is not allowed */
380 len = sizeof(pCC);
381 ZeroMemory(pCC, sizeof(pCC));
382 SetLastError(0xdeadbeef);
383 res = pGetDefaultCommConfigW(emptyW, pCC, &len);
384 ok( res == ERROR_BADKEY,
385 "returned %u with %u and %u for %s (expected ERROR_BADKEY)\n",
387
388 /* some NULL checks */
389 len = sizeof(pCC);
390 ZeroMemory(pCC, sizeof(pCC));
391 SetLastError(0xdeadbeef);
392 res = pGetDefaultCommConfigW(NULL, pCC, &len);
394 "returned %u with %u and %u for NULL (expected ERROR_INVALID_PARAMETER)\n",
395 res, GetLastError(), len);
396
397
398 len = sizeof(pCC);
399 SetLastError(0xdeadbeef);
400 res = pGetDefaultCommConfigW(com1W, NULL, &len);
402 "returned %u with %u and %u (expected ERROR_INVALID_PARAMETER)\n",
403 res, GetLastError(), len);
404
405
406 SetLastError(0xdeadbeef);
407 res = pGetDefaultCommConfigW(com1W, pCC, NULL);
409 "returned %u with %u (expected ERROR_INVALID_PARAMETER)\n",
410 res, GetLastError());
411
412}
413
414/* ################# */
415
417{
418 LPCSTR ptr;
419
421 if (ptr) {
422 win_skip("got NULL with %u for %s\n", GetLastError(), ptr);
423 return;
424 }
425
430
431}
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
#define ARRAY_SIZE(A)
Definition: main.h:20
static const CHAR str_colonA[]
Definition: confdlg.c:43
static const WCHAR com1W[]
Definition: confdlg.c:45
static LPCOMMCONFIG
Definition: confdlg.c:34
static void test_drvGetDefaultCommConfigA(void)
Definition: confdlg.c:230
static HWND
Definition: confdlg.c:34
static void test_drvCommConfigDialogW(void)
Definition: confdlg.c:155
static const CHAR emptyA[]
Definition: confdlg.c:41
static void test_drvGetDefaultCommConfigW(void)
Definition: confdlg.c:322
static const CHAR fmt_comA[]
Definition: confdlg.c:42
static const WCHAR emptyW[]
Definition: confdlg.c:46
static HINSTANCE hdll
Definition: confdlg.c:33
static void test_drvCommConfigDialogA(void)
Definition: confdlg.c:81
static LPDWORD
Definition: confdlg.c:36
static const CHAR com1A[]
Definition: confdlg.c:40
static const WCHAR str_colonW[]
Definition: confdlg.c:47
static LPCSTR load_functions(void)
Definition: confdlg.c:51
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:109
#define SetLastError(x)
Definition: compat.h:752
#define GetProcAddress(x, y)
Definition: compat.h:753
#define MultiByteToWideChar
Definition: compat.h:110
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint res
Definition: glext.h:9613
GLenum GLsizei len
Definition: glext.h:6722
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
LPSTR WINAPI lstrcatA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:123
static PVOID ptr
Definition: dispmode.c:27
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define DWORD
Definition: nt_native.h:44
#define win_skip
Definition: test.h:163
int winetest_interactive
DWORD dwSize
Definition: winbase.h:677
struct _COMM_CONFIG COMMCONFIG
#define ZeroMemory
Definition: winbase.h:1712
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define WINAPI
Definition: msvc.h:6
#define ERROR_BADKEY
Definition: winerror.h:589
const char * LPCSTR
Definition: xmlstorage.h:183
__wchar_t WCHAR
Definition: xmlstorage.h:180
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
char CHAR
Definition: xmlstorage.h:175