2 * Unit test suite for rasapi32 functions
4 * Copyright 2008 Austin English
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.
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.
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
23 #include <wine/test.h>
29 static HMODULE hmodule;
30 static DWORD (WINAPI *pRasEnumDevicesA)(LPRASDEVINFOA, LPDWORD, LPDWORD);
32 #define RASAPI32_GET_PROC(func) \
33 p ## func = (void*)GetProcAddress(hmodule, #func); \
35 trace("GetProcAddress(%s) failed\n", #func);
37 static void InitFunctionPtrs(void)
39 hmodule = LoadLibraryA("rasapi32.dll");
41 RASAPI32_GET_PROC(RasEnumDevicesA)
44 static void test_rasenum(void)
48 DWORD bufsize = 0, cb = 0;
49 LPRASDEVINFOA rasDevInfo;
51 if(!pRasEnumDevicesA) {
52 win_skip("Skipping RasEnumDevicesA tests, function not present\n");
56 /* create the return buffer */
57 result = pRasEnumDevicesA(NULL, &bufsize, &cDevices);
58 if(ERROR_RASMAN_CANNOT_INITIALIZE == result) {
59 win_skip("RAS configuration problem\n");
62 trace("RasEnumDevicesA: returned %d buffersize %d\n", result, cb);
63 ok(result == ERROR_BUFFER_TOO_SMALL,
64 "Expected ERROR_BUFFER_TOO_SMALL, got %08d\n", result);
66 rasDevInfo = (LPRASDEVINFO) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
67 max(bufsize,sizeof(RASDEVINFOA)));
69 win_skip("failed to allocate buffer for RasEnumDevicesA tests\n");
73 /* test first parameter */
75 result = pRasEnumDevicesA(NULL, &cb, &cDevices);
76 ok(result == ERROR_BUFFER_TOO_SMALL,
77 "Expected ERROR_BUFFER_TOO_SMALL, got %08d\n", result);
79 rasDevInfo[0].dwSize = 0;
81 result = pRasEnumDevicesA(rasDevInfo, &cb, &cDevices);
83 ok(result == ERROR_INVALID_SIZE,
84 "Expected ERROR_INVALID_SIZE, got %08d\n", result);
86 rasDevInfo[0].dwSize = sizeof(RASDEVINFOA) -1;
88 result = pRasEnumDevicesA(rasDevInfo, &cb, &cDevices);
90 ok(result == ERROR_INVALID_SIZE,
91 "Expected ERROR_INVALID_SIZE, got %08d\n", result);
93 rasDevInfo[0].dwSize = sizeof(RASDEVINFOA) +1;
95 result = pRasEnumDevicesA(rasDevInfo, &cb, &cDevices);
97 ok(result == ERROR_INVALID_SIZE,
98 "Expected ERROR_INVALID_SIZE, got %08d\n", result);
100 /* test second parameter */
101 rasDevInfo[0].dwSize = sizeof(RASDEVINFOA);
102 result = pRasEnumDevicesA(rasDevInfo, NULL, &cDevices);
103 ok(result == ERROR_INVALID_PARAMETER,
104 "Expected ERROR_INVALID_PARAMETER, got %08d\n", result);
106 rasDevInfo[0].dwSize = sizeof(RASDEVINFOA);
108 result = pRasEnumDevicesA(rasDevInfo, &cb, &cDevices);
109 ok(result == ERROR_BUFFER_TOO_SMALL ||
110 result == ERROR_INVALID_SIZE, /* vista, 2k8 */
111 "Expected ERROR_BUFFER_TOO_SMALL/ERROR_INVALID_SIZE, got %08d\n", result);
113 rasDevInfo[0].dwSize = sizeof(RASDEVINFOA);
115 result = pRasEnumDevicesA(rasDevInfo, &cb, &cDevices);
116 ok(result == ERROR_BUFFER_TOO_SMALL,
117 "Expected ERROR_BUFFER_TOO_SMALL, got %08d\n", result);
119 rasDevInfo[0].dwSize = sizeof(RASDEVINFOA);
121 result = pRasEnumDevicesA(rasDevInfo, &cb, &cDevices);
122 ok(result == ERROR_SUCCESS,
123 "Expected ERROR_SUCCESS, got %08d\n", result);
125 /* test third parameter */
126 rasDevInfo[0].dwSize = sizeof(RASDEVINFOA);
128 result = pRasEnumDevicesA(rasDevInfo, &cb, NULL);
129 ok(result == ERROR_INVALID_PARAMETER,
130 "Expected ERROR_INVALID_PARAMETER, got %08d\n", result);
132 /* test combinations of invalid parameters */
133 result = pRasEnumDevicesA(NULL, NULL, &cDevices);
134 ok(result == ERROR_INVALID_PARAMETER,
135 "Expected ERROR_INVALID_PARAMETER, got %08d\n", result);
137 result = pRasEnumDevicesA(NULL, &cb, NULL);
138 ok(result == ERROR_INVALID_PARAMETER,
139 "Expected ERROR_INVALID_PARAMETER, got %08d\n", result);
142 rasDevInfo[0].dwSize = 0;
143 result = pRasEnumDevicesA(rasDevInfo, &cb, &cDevices);
145 ok(result == ERROR_INVALID_SIZE,
146 "Expected ERROR_INVALID_SIZE, got %08d\n", result);
148 HeapFree(GetProcessHeap(), 0, rasDevInfo);