ReactOS  0.4.14-dev-297-g23e575c
wlanapi.c
Go to the documentation of this file.
1 /*
2  * Wlanapi - tests
3  *
4  * Copyright 2009 Christoph von Wittich
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 #include <apitest.h>
22 
23 #include <wlanapi.h>
24 
25 static const GUID InterfaceGuid = {0x439b20af, 0x8955, 0x405b, {0x99, 0xf0, 0xa6, 0x2a, 0xf0, 0xc6, 0x8d, 0x43}};
26 
27 static void WlanOpenHandle_test(void)
28 {
29  DWORD ret;
30  DWORD dwNegotiatedVersion;
31  HANDLE hClientHandle;
32 
33  /* correct call to determine if WlanSvc is running */
34  ret = WlanOpenHandle(1, NULL, &dwNegotiatedVersion, &hClientHandle);
36  {
37  skip("Skipping wlanapi tests, WlanSvc is not running\n");
38  return;
39  }
40  ok(ret == ERROR_SUCCESS, "WlanOpenHandle failed, error %ld\n", ret);
41  WlanCloseHandle(hClientHandle, NULL);
42 
43  /* invalid pdwNegotiatedVersion */
44  ret = WlanOpenHandle(1, NULL, NULL, &hClientHandle);
45  ok(ret == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
46 
47  /* invalid hClientHandle */
48  ret = WlanOpenHandle(1, NULL, &dwNegotiatedVersion, NULL);
49  ok(ret == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
50 
51  /* invalid pReserved */
52  ret = WlanOpenHandle(1, (PVOID) 1, &dwNegotiatedVersion, &hClientHandle);
53  ok(ret == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
54 }
55 
56 static void WlanCloseHandle_test(void)
57 {
58  DWORD ret;
59  HANDLE hClientHandle = (HANDLE)(ULONG_PTR)0xdeadbeefdeadbeef;
60 
61  /* invalid pReserved */
62  ret = WlanCloseHandle(hClientHandle, (PVOID) 1);
63  ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
64 
65  /* invalid hClientHandle */
67  ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
68 
69  /* invalid hClientHandle */
70  ret = WlanCloseHandle(hClientHandle, NULL);
71  ok(ret == ERROR_INVALID_HANDLE, "expected failure\n");
72 }
73 
74 static void WlanConnect_test(void)
75 {
76  DWORD ret;
77  WLAN_CONNECTION_PARAMETERS pConnectParams;
78 
79  /* invalid pReserved */
80  ret = WlanConnect((HANDLE) -1, &InterfaceGuid, &pConnectParams, (PVOID) 1);
81  ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
82 
83  /* invalid InterfaceGuid */
84  ret = WlanConnect((HANDLE) -1, NULL, &pConnectParams, NULL);
85  ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
86 
87  /* invalid hClientHandle */
88  ret = WlanConnect(NULL, &InterfaceGuid, &pConnectParams, NULL);
89  ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
90 
91  /* invalid connection parameters */
93  ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
94 }
95 
96 static void WlanDisconnect_test(void)
97 {
98  DWORD ret;
99 
100  /* invalid pReserved */
102  ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
103 
104  /* invalid InterfaceGuid */
105  ret = WlanDisconnect((HANDLE) -1, NULL, NULL);
106  ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
107 
108  /* invalid hClientHandle */
110  ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
111 }
112 
113 static void WlanScan_test(void)
114 {
115  DWORD ret;
116  DOT11_SSID Ssid;
117  WLAN_RAW_DATA RawData;
118 
119  /* invalid pReserved */
120  ret = WlanScan((HANDLE) -1, &InterfaceGuid, &Ssid, &RawData, (PVOID) 1);
121  ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
122 
123  /* invalid InterfaceGuid */
124  ret = WlanScan((HANDLE) -1, NULL, &Ssid, &RawData, NULL);
125  ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
126 
127  /* invalid hClientHandle */
128  ret = WlanScan(NULL, &InterfaceGuid, &Ssid, &RawData, NULL);
129  ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
130 }
131 
132 static void WlanRenameProfile_test(void)
133 {
134  DWORD ret;
135 
136  /* invalid pReserved */
137  ret = WlanRenameProfile((HANDLE) -1, &InterfaceGuid, L"test", L"test1", (PVOID) 1);
138  ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
139 
140  /* invalid InterfaceGuid */
141  ret = WlanRenameProfile((HANDLE) -1, NULL, L"test", L"test1", NULL);
142  ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
143 
144  /* invalid strOldProfileName */
145  ret = WlanRenameProfile((HANDLE) -1, &InterfaceGuid, NULL, L"test1", NULL);
146  ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
147 
148  /* invalid strNewProfileName */
149  ret = WlanRenameProfile((HANDLE) -1, &InterfaceGuid, L"test", NULL, NULL);
150  ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
151 }
152 
153 static void WlanDeleteProfile_test(void)
154 {
155  DWORD ret;
156 
157  /* invalid pReserved */
158  ret = WlanDeleteProfile((HANDLE) -1, &InterfaceGuid, L"test", (PVOID) 1);
159  ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
160 
161  /* invalid InterfaceGuid */
162  ret = WlanDeleteProfile((HANDLE) -1, NULL, L"test", NULL);
163  ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
164 
165  /* invalid strProfileName */
167  ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
168 }
169 
170 static void WlanGetProfile_test(void)
171 {
172  DWORD ret;
173  WCHAR *strProfileXml;
174 
175  /* invalid pReserved */
176  ret = WlanGetProfile((HANDLE) -1, &InterfaceGuid, L"", (PVOID) 1, &strProfileXml, NULL, NULL);
177  ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
178 
179  /* invalid InterfaceGuid */
180  ret = WlanGetProfile((HANDLE) -1, NULL, L"test", NULL, &strProfileXml, NULL, NULL);
181  ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
182 
183  /* invalid pstrProfileXml */
184  ret = WlanGetProfile((HANDLE) -1, &InterfaceGuid, L"test", NULL, NULL, NULL, NULL);
185  ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
186 }
187 
188 static void WlanEnumInterfaces_test(void)
189 {
190  DWORD ret;
191  PWLAN_INTERFACE_INFO_LIST pInterfaceList;
192 
193  /* invalid pReserved */
194  ret = WlanEnumInterfaces((HANDLE) -1, (PVOID) 1, &pInterfaceList);
195  ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
196 
197  /* invalid pInterfaceList */
199  ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
200 }
201 
203 {
204  DWORD ret;
205  PWLAN_INTERFACE_CAPABILITY pInterfaceCapability;
206 
207  /* invalid pReserved */
208  ret = WlanGetInterfaceCapability((HANDLE) -1, &InterfaceGuid, (PVOID) 1, &pInterfaceCapability);
209  ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
210 
211  /* invalid InterfaceGuid */
212  ret = WlanGetInterfaceCapability((HANDLE) -1, NULL, NULL, &pInterfaceCapability);
213  ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
214 
215  /* invalid pInterfaceCapability */
217  ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
218 }
219 
220 
221 START_TEST(wlanapi)
222 {
227  WlanScan_test();
233 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
static void WlanCloseHandle_test(void)
Definition: wlanapi.c:56
static void WlanGetInterfaceCapability_test(void)
Definition: wlanapi.c:202
BOOL WlanScan(HANDLE hAdapter)
Definition: wlanconf.c:700
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
static void WlanEnumInterfaces_test(void)
Definition: wlanapi.c:188
static void WlanRenameProfile_test(void)
Definition: wlanapi.c:132
uint32_t ULONG_PTR
Definition: typedefs.h:63
static void WlanDisconnect_test(void)
Definition: wlanapi.c:96
DWORD WINAPI WlanGetProfile(IN HANDLE hClientHandle, IN const GUID *pInterfaceGuid, IN LPCWSTR strProfileName, PVOID pReserved, OUT LPWSTR *pstrProfileXml, DWORD *pdwFlags, PDWORD pdwGrantedAccess)
Definition: profile.c:88
smooth NULL
Definition: ftsmooth.c:416
static void WlanDeleteProfile_test(void)
Definition: wlanapi.c:153
__wchar_t WCHAR
Definition: xmlstorage.h:180
BOOL WlanConnect(HANDLE hAdapter)
Definition: wlanconf.c:530
PVOID HANDLE
Definition: typedefs.h:71
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD WINAPI WlanGetInterfaceCapability(IN HANDLE hClientHandle, IN const GUID *pInterfaceGuid, PVOID pReserved, OUT PWLAN_INTERFACE_CAPABILITY *ppCapability)
Definition: main.c:293
int ret
BOOL WlanDisconnect(HANDLE hAdapter, PIP_ADAPTER_INDEX_MAP IpInfo)
Definition: wlanconf.c:227
#define ERROR_SERVICE_EXISTS
Definition: winerror.h:624
static const GUID InterfaceGuid
Definition: wlanapi.c:25
static const WCHAR L[]
Definition: oid.c:1250
static void WlanScan_test(void)
Definition: wlanapi.c:113
#define ok(value,...)
Definition: atltest.h:57
DWORD WINAPI WlanRenameProfile(IN HANDLE hClientHandle, IN const GUID *pInterfaceGuid, IN LPCWSTR strOldProfileName, IN LPCWSTR strNewProfileName, PVOID pReserved)
Definition: profile.c:62
DWORD WINAPI WlanCloseHandle(IN HANDLE hClientHandle, PVOID pReserved)
Definition: main.c:203
#define skip(...)
Definition: atltest.h:64
static void WlanGetProfile_test(void)
Definition: wlanapi.c:170
static void WlanConnect_test(void)
Definition: wlanapi.c:74
DWORD WINAPI WlanEnumInterfaces(IN HANDLE hClientHandle, PVOID pReserved, OUT PWLAN_INTERFACE_INFO_LIST *ppInterfaceList)
Definition: main.c:226
START_TEST(wlanapi)
Definition: wlanapi.c:221
DWORD WINAPI WlanDeleteProfile(IN HANDLE hClientHandle, IN const GUID *pInterfaceGuid, IN LPCWSTR strProfileName, PVOID pReserved)
Definition: profile.c:37
static void WlanOpenHandle_test(void)
Definition: wlanapi.c:27
DWORD WINAPI WlanOpenHandle(IN DWORD dwClientVersion, PVOID pReserved, OUT DWORD *pdwNegotiatedVersion, OUT HANDLE *phClientHandle)
Definition: main.c:174