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 typedef NET_API_STATUS (WINAPI *NetpGetComputerName_func)(LPWSTR *Buffer);
32 WCHAR user_name[UNLEN + 1];
33 WCHAR computer_name[MAX_COMPUTERNAME_LENGTH + 1];
35 void init_wksta_tests(void)
40 dwSize = sizeof(user_name);
41 ok(GetUserNameW(user_name, &dwSize), "User Name Retrieved");
44 dwSize = sizeof(computer_name);
45 ok(GetComputerNameW(computer_name, &dwSize), "Computer Name Retrieved");
48 void run_get_comp_name_tests(void)
50 HANDLE hnetapi32 = GetModuleHandleA("netapi32.dll");
55 NetpGetComputerName_func pNetpGetComputerName;
56 pNetpGetComputerName = (NetpGetComputerName_func)GetProcAddress(hnetapi32,"NetpGetComputerName");
57 if (pNetpGetComputerName)
59 ok((*pNetpGetComputerName)(&ws) == NERR_Success, "Computer name is retrieved");
60 ok(!lstrcmpW(computer_name, ws), "This is really computer name");
66 void run_wkstausergetinfo_tests(void)
68 LPWKSTA_USER_INFO_0 ui0 = NULL;
69 LPWKSTA_USER_INFO_1 ui1 = NULL;
70 LPWKSTA_USER_INFO_1101 ui1101 = NULL;
74 ok(NetWkstaUserGetInfo(NULL, 0, (LPBYTE *)&ui0) == NERR_Success,
75 "NetWkstaUserGetInfo is successful");
76 ok(!lstrcmpW(user_name, ui0->wkui0_username), "This is really user name");
77 NetApiBufferSize(ui0, &dwSize);
78 ok(dwSize >= (sizeof(WKSTA_USER_INFO_0) +
79 lstrlenW(ui0->wkui0_username) * sizeof(WCHAR)),
80 "Is allocated with NetApiBufferAllocate");
83 ok(NetWkstaUserGetInfo(NULL, 1, (LPBYTE *)&ui1) == NERR_Success,
84 "NetWkstaUserGetInfo is successful");
85 ok(lstrcmpW(ui1->wkui1_username, ui0->wkui0_username) == 0,
86 "the same name as returned for level 0");
87 NetApiBufferSize(ui1, &dwSize);
88 ok(dwSize >= (sizeof(WKSTA_USER_INFO_1) +
89 (lstrlenW(ui1->wkui1_username) +
90 lstrlenW(ui1->wkui1_logon_domain) +
91 lstrlenW(ui1->wkui1_oth_domains) +
92 lstrlenW(ui1->wkui1_logon_server)) * sizeof(WCHAR)),
93 "Is allocated with NetApiBufferAllocate");
96 ok(NetWkstaUserGetInfo(NULL, 1101, (LPBYTE *)&ui1101) == NERR_Success,
97 "NetWkstaUserGetInfo is successful");
98 ok(lstrcmpW(ui1101->wkui1101_oth_domains, ui1->wkui1_oth_domains) == 0,
99 "the same oth_domains as returned for level 1");
100 NetApiBufferSize(ui1101, &dwSize);
101 ok(dwSize >= (sizeof(WKSTA_USER_INFO_1101) +
102 lstrlenW(ui1101->wkui1101_oth_domains) * sizeof(WCHAR)),
103 "Is allocated with NetApiBufferAllocate");
105 NetApiBufferFree(ui0);
106 NetApiBufferFree(ui1);
107 NetApiBufferFree(ui1101);
109 /* errors handling */
110 ok(NetWkstaUserGetInfo(NULL, 10000, (LPBYTE *)&ui0) == ERROR_INVALID_LEVEL,
117 run_get_comp_name_tests();
118 run_wkstausergetinfo_tests();