2 * Copyright 2002 Andriy Palamarchuk
4 * Conformance test of the workstation functions.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "wine/test.h"
30 static NET_API_STATUS (WINAPI *pNetApiBufferFree)(LPVOID)=NULL;
31 static NET_API_STATUS (WINAPI *pNetApiBufferSize)(LPVOID,LPDWORD)=NULL;
32 static NET_API_STATUS (WINAPI *pNetpGetComputerName)(LPWSTR*)=NULL;
33 static NET_API_STATUS (WINAPI *pNetWkstaUserGetInfo)(LPWSTR,DWORD,PBYTE*)=NULL;
35 WCHAR user_name[UNLEN + 1];
36 WCHAR computer_name[MAX_COMPUTERNAME_LENGTH + 1];
38 static int init_wksta_tests(void)
44 dwSize = sizeof(user_name);
45 rc=GetUserNameW(user_name, &dwSize);
46 if (rc==FALSE && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
48 ok(rc, "User Name Retrieved");
51 dwSize = sizeof(computer_name);
52 ok(GetComputerNameW(computer_name, &dwSize), "Computer Name Retrieved");
56 static void run_get_comp_name_tests(void)
60 if (!pNetpGetComputerName)
63 ok(pNetpGetComputerName(&ws) == NERR_Success, "Computer name is retrieved");
64 ok(!lstrcmpW(computer_name, ws), "This is really computer name");
65 pNetApiBufferFree(ws);
68 static void run_wkstausergetinfo_tests(void)
70 LPWKSTA_USER_INFO_0 ui0 = NULL;
71 LPWKSTA_USER_INFO_1 ui1 = NULL;
72 LPWKSTA_USER_INFO_1101 ui1101 = NULL;
75 if (!pNetWkstaUserGetInfo)
79 ok(pNetWkstaUserGetInfo(NULL, 0, (LPBYTE *)&ui0) == NERR_Success,
80 "NetWkstaUserGetInfo is successful");
81 ok(!lstrcmpW(user_name, ui0->wkui0_username), "This is really user name");
82 pNetApiBufferSize(ui0, &dwSize);
83 ok(dwSize >= (sizeof(WKSTA_USER_INFO_0) +
84 lstrlenW(ui0->wkui0_username) * sizeof(WCHAR)),
85 "Is allocated with NetApiBufferAllocate");
88 ok(pNetWkstaUserGetInfo(NULL, 1, (LPBYTE *)&ui1) == NERR_Success,
89 "NetWkstaUserGetInfo is successful");
90 ok(lstrcmpW(ui1->wkui1_username, ui0->wkui0_username) == 0,
91 "the same name as returned for level 0");
92 pNetApiBufferSize(ui1, &dwSize);
93 ok(dwSize >= (sizeof(WKSTA_USER_INFO_1) +
94 (lstrlenW(ui1->wkui1_username) +
95 lstrlenW(ui1->wkui1_logon_domain) +
96 lstrlenW(ui1->wkui1_oth_domains) +
97 lstrlenW(ui1->wkui1_logon_server)) * sizeof(WCHAR)),
98 "Is allocated with NetApiBufferAllocate");
101 ok(pNetWkstaUserGetInfo(NULL, 1101, (LPBYTE *)&ui1101) == NERR_Success,
102 "NetWkstaUserGetInfo is successful");
103 ok(lstrcmpW(ui1101->wkui1101_oth_domains, ui1->wkui1_oth_domains) == 0,
104 "the same oth_domains as returned for level 1");
105 pNetApiBufferSize(ui1101, &dwSize);
106 ok(dwSize >= (sizeof(WKSTA_USER_INFO_1101) +
107 lstrlenW(ui1101->wkui1101_oth_domains) * sizeof(WCHAR)),
108 "Is allocated with NetApiBufferAllocate");
110 pNetApiBufferFree(ui0);
111 pNetApiBufferFree(ui1);
112 pNetApiBufferFree(ui1101);
114 /* errors handling */
115 ok(pNetWkstaUserGetInfo(NULL, 10000, (LPBYTE *)&ui0) == ERROR_INVALID_LEVEL,
121 HMODULE hnetapi32=LoadLibraryA("netapi32.dll");
122 pNetApiBufferFree=(void*)GetProcAddress(hnetapi32,"NetApiBufferFree");
123 pNetApiBufferSize=(void*)GetProcAddress(hnetapi32,"NetApiBufferSize");
124 pNetpGetComputerName=(void*)GetProcAddress(hnetapi32,"NetpGetComputerName");
125 pNetWkstaUserGetInfo=(void*)GetProcAddress(hnetapi32,"NetWkstaUserGetInfo");
126 if (!pNetApiBufferSize)
127 trace("It appears there is no netapi32 functionality on this platform\n");
129 if (init_wksta_tests()) {
130 run_get_comp_name_tests();
131 run_wkstausergetinfo_tests();