From 5920a034b8a08b26ca245fca5a0b72745937922b Mon Sep 17 00:00:00 2001 From: Gijs Vermeulen Date: Sun, 21 Mar 2021 22:50:46 +0100 Subject: [PATCH] wtsapi32/tests: Test returned username for WTSQuerySessionInformation(WTSUserName). Signed-off-by: Gijs Vermeulen Signed-off-by: Alexandre Julliard (cherry picked from commit e07c658fafc39432694f96a762a4a2f6cef20bf7) Signed-off-by: Michael Stefaniuc --- dlls/wtsapi32/tests/Makefile.in | 2 +- dlls/wtsapi32/tests/wtsapi.c | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/dlls/wtsapi32/tests/Makefile.in b/dlls/wtsapi32/tests/Makefile.in index a398a8085cd..be0fa8d6772 100644 --- a/dlls/wtsapi32/tests/Makefile.in +++ b/dlls/wtsapi32/tests/Makefile.in @@ -1,5 +1,5 @@ TESTDLL = wtsapi32.dll -IMPORTS = wtsapi32 +IMPORTS = wtsapi32 advapi32 C_SRCS = \ wtsapi.c diff --git a/dlls/wtsapi32/tests/wtsapi.c b/dlls/wtsapi32/tests/wtsapi.c index c9312cd97c5..7cff02de526 100644 --- a/dlls/wtsapi32/tests/wtsapi.c +++ b/dlls/wtsapi32/tests/wtsapi.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include "wine/test.h" @@ -92,10 +93,10 @@ static void test_WTSEnumerateProcessesW(void) static void test_WTSQuerySessionInformation(void) { + WCHAR *buf1, usernameW[UNLEN + 1]; + char *buf2, username[UNLEN + 1]; + DWORD count, tempsize; BOOL ret; - WCHAR *buf1; - char *buf2; - DWORD count; SetLastError(0xdeadbeef); count = 0; @@ -122,6 +123,11 @@ static void test_WTSQuerySessionInformation(void) ok(ret, "got %u\n", GetLastError()); ok(buf1 != NULL, "buf not set\n"); ok(count == (lstrlenW(buf1) + 1) * sizeof(WCHAR), "expected %u, got %u\n", (lstrlenW(buf1) + 1) * sizeof(WCHAR), count); + tempsize = UNLEN + 1; + GetUserNameW(usernameW, &tempsize); + /* Windows Vista, 7 and 8 return uppercase username, while the rest return lowercase. */ + ok(!wcsicmp(buf1, usernameW), "expected %s, got %s\n", wine_dbgstr_w(usernameW), wine_dbgstr_w(buf1)); + ok(count == tempsize * sizeof(WCHAR), "expected %u, got %u\n", tempsize * sizeof(WCHAR), count); WTSFreeMemory(buf1); SetLastError(0xdeadbeef); @@ -149,6 +155,11 @@ static void test_WTSQuerySessionInformation(void) ok(ret, "got %u\n", GetLastError()); ok(buf2 != NULL, "buf not set\n"); ok(count == lstrlenA(buf2) + 1, "expected %u, got %u\n", lstrlenA(buf2) + 1, count); + tempsize = UNLEN + 1; + GetUserNameA(username, &tempsize); + /* Windows Vista, 7 and 8 return uppercase username, while the rest return lowercase. */ + ok(!stricmp(buf2, username), "expected %s, got %s\n", username, buf2); + ok(count == tempsize, "expected %u, got %u\n", tempsize, count); WTSFreeMemory(buf2); }