1c2c66affSColin Finck /*
2c2c66affSColin Finck * Wlanapi - tests
3c2c66affSColin Finck *
4c2c66affSColin Finck * Copyright 2009 Christoph von Wittich
5c2c66affSColin Finck *
6c2c66affSColin Finck * This library is free software; you can redistribute it and/or
7c2c66affSColin Finck * modify it under the terms of the GNU Lesser General Public
8c2c66affSColin Finck * License as published by the Free Software Foundation; either
9c2c66affSColin Finck * version 2.1 of the License, or (at your option) any later version.
10c2c66affSColin Finck *
11c2c66affSColin Finck * This library is distributed in the hope that it will be useful,
12c2c66affSColin Finck * but WITHOUT ANY WARRANTY; without even the implied warranty of
13c2c66affSColin Finck * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14c2c66affSColin Finck * Lesser General Public License for more details.
15c2c66affSColin Finck *
16c2c66affSColin Finck * You should have received a copy of the GNU Lesser General Public
17c2c66affSColin Finck * License along with this library; if not, write to the Free Software
18c2c66affSColin Finck * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19c2c66affSColin Finck */
20c2c66affSColin Finck
21c2c66affSColin Finck #include <apitest.h>
22c2c66affSColin Finck
23c2c66affSColin Finck #include <wlanapi.h>
24c2c66affSColin Finck
25c2c66affSColin Finck static const GUID InterfaceGuid = {0x439b20af, 0x8955, 0x405b, {0x99, 0xf0, 0xa6, 0x2a, 0xf0, 0xc6, 0x8d, 0x43}};
26c2c66affSColin Finck
WlanOpenHandle_test(void)27c2c66affSColin Finck static void WlanOpenHandle_test(void)
28c2c66affSColin Finck {
29c2c66affSColin Finck DWORD ret;
30c2c66affSColin Finck DWORD dwNegotiatedVersion;
31c2c66affSColin Finck HANDLE hClientHandle;
32c2c66affSColin Finck
33c2c66affSColin Finck /* correct call to determine if WlanSvc is running */
34c2c66affSColin Finck ret = WlanOpenHandle(1, NULL, &dwNegotiatedVersion, &hClientHandle);
35c2c66affSColin Finck if (ret == ERROR_SERVICE_EXISTS)
36c2c66affSColin Finck {
37c2c66affSColin Finck skip("Skipping wlanapi tests, WlanSvc is not running\n");
38c2c66affSColin Finck return;
39c2c66affSColin Finck }
40c2c66affSColin Finck ok(ret == ERROR_SUCCESS, "WlanOpenHandle failed, error %ld\n", ret);
41c2c66affSColin Finck WlanCloseHandle(hClientHandle, NULL);
42c2c66affSColin Finck
43c2c66affSColin Finck /* invalid pdwNegotiatedVersion */
44c2c66affSColin Finck ret = WlanOpenHandle(1, NULL, NULL, &hClientHandle);
45c2c66affSColin Finck ok(ret == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
46c2c66affSColin Finck
47c2c66affSColin Finck /* invalid hClientHandle */
48c2c66affSColin Finck ret = WlanOpenHandle(1, NULL, &dwNegotiatedVersion, NULL);
49c2c66affSColin Finck ok(ret == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
50c2c66affSColin Finck
51c2c66affSColin Finck /* invalid pReserved */
52c2c66affSColin Finck ret = WlanOpenHandle(1, (PVOID) 1, &dwNegotiatedVersion, &hClientHandle);
53c2c66affSColin Finck ok(ret == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
54c2c66affSColin Finck }
55c2c66affSColin Finck
WlanCloseHandle_test(void)56c2c66affSColin Finck static void WlanCloseHandle_test(void)
57c2c66affSColin Finck {
58c2c66affSColin Finck DWORD ret;
59*7cf7b27aSTimo Kreuzer HANDLE hClientHandle = (HANDLE)(ULONG_PTR)0xdeadbeefdeadbeef;
60c2c66affSColin Finck
61c2c66affSColin Finck /* invalid pReserved */
62c2c66affSColin Finck ret = WlanCloseHandle(hClientHandle, (PVOID) 1);
63c2c66affSColin Finck ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
64c2c66affSColin Finck
65c2c66affSColin Finck /* invalid hClientHandle */
66c2c66affSColin Finck ret = WlanCloseHandle(NULL, NULL);
67c2c66affSColin Finck ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
68c2c66affSColin Finck
69c2c66affSColin Finck /* invalid hClientHandle */
70c2c66affSColin Finck ret = WlanCloseHandle(hClientHandle, NULL);
71c2c66affSColin Finck ok(ret == ERROR_INVALID_HANDLE, "expected failure\n");
72c2c66affSColin Finck }
73c2c66affSColin Finck
WlanConnect_test(void)74c2c66affSColin Finck static void WlanConnect_test(void)
75c2c66affSColin Finck {
76c2c66affSColin Finck DWORD ret;
77c2c66affSColin Finck WLAN_CONNECTION_PARAMETERS pConnectParams;
78c2c66affSColin Finck
79c2c66affSColin Finck /* invalid pReserved */
80c2c66affSColin Finck ret = WlanConnect((HANDLE) -1, &InterfaceGuid, &pConnectParams, (PVOID) 1);
81c2c66affSColin Finck ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
82c2c66affSColin Finck
83c2c66affSColin Finck /* invalid InterfaceGuid */
84c2c66affSColin Finck ret = WlanConnect((HANDLE) -1, NULL, &pConnectParams, NULL);
85c2c66affSColin Finck ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
86c2c66affSColin Finck
87c2c66affSColin Finck /* invalid hClientHandle */
88c2c66affSColin Finck ret = WlanConnect(NULL, &InterfaceGuid, &pConnectParams, NULL);
89c2c66affSColin Finck ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
90c2c66affSColin Finck
91c2c66affSColin Finck /* invalid connection parameters */
92c2c66affSColin Finck ret = WlanConnect((HANDLE) -1, &InterfaceGuid, NULL, NULL);
93c2c66affSColin Finck ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
94c2c66affSColin Finck }
95c2c66affSColin Finck
WlanDisconnect_test(void)96c2c66affSColin Finck static void WlanDisconnect_test(void)
97c2c66affSColin Finck {
98c2c66affSColin Finck DWORD ret;
99c2c66affSColin Finck
100c2c66affSColin Finck /* invalid pReserved */
101c2c66affSColin Finck ret = WlanDisconnect((HANDLE) -1, &InterfaceGuid, (PVOID) 1);
102c2c66affSColin Finck ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
103c2c66affSColin Finck
104c2c66affSColin Finck /* invalid InterfaceGuid */
105c2c66affSColin Finck ret = WlanDisconnect((HANDLE) -1, NULL, NULL);
106c2c66affSColin Finck ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
107c2c66affSColin Finck
108c2c66affSColin Finck /* invalid hClientHandle */
109c2c66affSColin Finck ret = WlanDisconnect(NULL, &InterfaceGuid, NULL);
110c2c66affSColin Finck ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
111c2c66affSColin Finck }
112c2c66affSColin Finck
WlanScan_test(void)113c2c66affSColin Finck static void WlanScan_test(void)
114c2c66affSColin Finck {
115c2c66affSColin Finck DWORD ret;
116c2c66affSColin Finck DOT11_SSID Ssid;
117c2c66affSColin Finck WLAN_RAW_DATA RawData;
118c2c66affSColin Finck
119c2c66affSColin Finck /* invalid pReserved */
120c2c66affSColin Finck ret = WlanScan((HANDLE) -1, &InterfaceGuid, &Ssid, &RawData, (PVOID) 1);
121c2c66affSColin Finck ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
122c2c66affSColin Finck
123c2c66affSColin Finck /* invalid InterfaceGuid */
124c2c66affSColin Finck ret = WlanScan((HANDLE) -1, NULL, &Ssid, &RawData, NULL);
125c2c66affSColin Finck ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
126c2c66affSColin Finck
127c2c66affSColin Finck /* invalid hClientHandle */
128c2c66affSColin Finck ret = WlanScan(NULL, &InterfaceGuid, &Ssid, &RawData, NULL);
129c2c66affSColin Finck ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
130c2c66affSColin Finck }
131c2c66affSColin Finck
WlanRenameProfile_test(void)132c2c66affSColin Finck static void WlanRenameProfile_test(void)
133c2c66affSColin Finck {
134c2c66affSColin Finck DWORD ret;
135c2c66affSColin Finck
136c2c66affSColin Finck /* invalid pReserved */
137c2c66affSColin Finck ret = WlanRenameProfile((HANDLE) -1, &InterfaceGuid, L"test", L"test1", (PVOID) 1);
138c2c66affSColin Finck ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
139c2c66affSColin Finck
140c2c66affSColin Finck /* invalid InterfaceGuid */
141c2c66affSColin Finck ret = WlanRenameProfile((HANDLE) -1, NULL, L"test", L"test1", NULL);
142c2c66affSColin Finck ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
143c2c66affSColin Finck
144c2c66affSColin Finck /* invalid strOldProfileName */
145c2c66affSColin Finck ret = WlanRenameProfile((HANDLE) -1, &InterfaceGuid, NULL, L"test1", NULL);
146c2c66affSColin Finck ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
147c2c66affSColin Finck
148c2c66affSColin Finck /* invalid strNewProfileName */
149c2c66affSColin Finck ret = WlanRenameProfile((HANDLE) -1, &InterfaceGuid, L"test", NULL, NULL);
150c2c66affSColin Finck ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
151c2c66affSColin Finck }
152c2c66affSColin Finck
WlanDeleteProfile_test(void)153c2c66affSColin Finck static void WlanDeleteProfile_test(void)
154c2c66affSColin Finck {
155c2c66affSColin Finck DWORD ret;
156c2c66affSColin Finck
157c2c66affSColin Finck /* invalid pReserved */
158c2c66affSColin Finck ret = WlanDeleteProfile((HANDLE) -1, &InterfaceGuid, L"test", (PVOID) 1);
159c2c66affSColin Finck ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
160c2c66affSColin Finck
161c2c66affSColin Finck /* invalid InterfaceGuid */
162c2c66affSColin Finck ret = WlanDeleteProfile((HANDLE) -1, NULL, L"test", NULL);
163c2c66affSColin Finck ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
164c2c66affSColin Finck
165c2c66affSColin Finck /* invalid strProfileName */
166c2c66affSColin Finck ret = WlanDeleteProfile((HANDLE) -1, &InterfaceGuid, NULL, NULL);
167c2c66affSColin Finck ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
168c2c66affSColin Finck }
169c2c66affSColin Finck
WlanGetProfile_test(void)170c2c66affSColin Finck static void WlanGetProfile_test(void)
171c2c66affSColin Finck {
172c2c66affSColin Finck DWORD ret;
173c2c66affSColin Finck WCHAR *strProfileXml;
174c2c66affSColin Finck
175c2c66affSColin Finck /* invalid pReserved */
176c2c66affSColin Finck ret = WlanGetProfile((HANDLE) -1, &InterfaceGuid, L"", (PVOID) 1, &strProfileXml, NULL, NULL);
177c2c66affSColin Finck ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
178c2c66affSColin Finck
179c2c66affSColin Finck /* invalid InterfaceGuid */
180c2c66affSColin Finck ret = WlanGetProfile((HANDLE) -1, NULL, L"test", NULL, &strProfileXml, NULL, NULL);
181c2c66affSColin Finck ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
182c2c66affSColin Finck
183c2c66affSColin Finck /* invalid pstrProfileXml */
184c2c66affSColin Finck ret = WlanGetProfile((HANDLE) -1, &InterfaceGuid, L"test", NULL, NULL, NULL, NULL);
185c2c66affSColin Finck ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
186c2c66affSColin Finck }
187c2c66affSColin Finck
WlanEnumInterfaces_test(void)188c2c66affSColin Finck static void WlanEnumInterfaces_test(void)
189c2c66affSColin Finck {
190c2c66affSColin Finck DWORD ret;
191c2c66affSColin Finck PWLAN_INTERFACE_INFO_LIST pInterfaceList;
192c2c66affSColin Finck
193c2c66affSColin Finck /* invalid pReserved */
194c2c66affSColin Finck ret = WlanEnumInterfaces((HANDLE) -1, (PVOID) 1, &pInterfaceList);
195c2c66affSColin Finck ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
196c2c66affSColin Finck
197c2c66affSColin Finck /* invalid pInterfaceList */
198c2c66affSColin Finck ret = WlanEnumInterfaces((HANDLE) -1, NULL, NULL);
199c2c66affSColin Finck ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
200c2c66affSColin Finck }
201c2c66affSColin Finck
WlanGetInterfaceCapability_test(void)202c2c66affSColin Finck static void WlanGetInterfaceCapability_test(void)
203c2c66affSColin Finck {
204c2c66affSColin Finck DWORD ret;
205c2c66affSColin Finck PWLAN_INTERFACE_CAPABILITY pInterfaceCapability;
206c2c66affSColin Finck
207c2c66affSColin Finck /* invalid pReserved */
208c2c66affSColin Finck ret = WlanGetInterfaceCapability((HANDLE) -1, &InterfaceGuid, (PVOID) 1, &pInterfaceCapability);
209c2c66affSColin Finck ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
210c2c66affSColin Finck
211c2c66affSColin Finck /* invalid InterfaceGuid */
212c2c66affSColin Finck ret = WlanGetInterfaceCapability((HANDLE) -1, NULL, NULL, &pInterfaceCapability);
213c2c66affSColin Finck ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
214c2c66affSColin Finck
215c2c66affSColin Finck /* invalid pInterfaceCapability */
216c2c66affSColin Finck ret = WlanGetInterfaceCapability((HANDLE) -1, &InterfaceGuid, NULL, NULL);
217c2c66affSColin Finck ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
218c2c66affSColin Finck }
219c2c66affSColin Finck
220c2c66affSColin Finck
START_TEST(wlanapi)221c2c66affSColin Finck START_TEST(wlanapi)
222c2c66affSColin Finck {
223c2c66affSColin Finck WlanOpenHandle_test();
224c2c66affSColin Finck WlanCloseHandle_test();
225c2c66affSColin Finck WlanConnect_test();
226c2c66affSColin Finck WlanDisconnect_test();
227c2c66affSColin Finck WlanScan_test();
228c2c66affSColin Finck WlanRenameProfile_test();
229c2c66affSColin Finck WlanDeleteProfile_test();
230c2c66affSColin Finck WlanGetProfile_test();
231c2c66affSColin Finck WlanEnumInterfaces_test();
232c2c66affSColin Finck WlanGetInterfaceCapability_test();
233c2c66affSColin Finck }
234