[PATCH 6/6] wtsapi32/tests: Add test for WTSRegisterSessionNotificationEx().
Patrick Hibbs
hibbsncc1701 at gmail.com
Sat Jul 13 18:00:02 CDT 2019
Signed-off-by: Patrick Hibbs <hibbsncc1701 at yahoo.com>
---
dlls/wtsapi32/tests/wtsapi.c | 72 ++++++++++++++++++++++++++++++++++++
1 file changed, 72 insertions(+)
diff --git a/dlls/wtsapi32/tests/wtsapi.c b/dlls/wtsapi32/tests/wtsapi.c
index 67f56bbd7f..39f718e29b 100644
--- a/dlls/wtsapi32/tests/wtsapi.c
+++ b/dlls/wtsapi32/tests/wtsapi.c
@@ -22,9 +22,12 @@
#include <winbase.h>
#include <winternl.h>
#include <wtsapi32.h>
+#include <windows.h>
#include "wine/test.h"
+static const CHAR testwindow_class[] = "testwindow";
+
static void test_WTSEnumerateProcessesW(void)
{
BOOL found = FALSE, ret;
@@ -115,9 +118,78 @@ static void test_WTSQueryUserToken(void)
ok(GetLastError()==ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER got: %d\n", GetLastError());
}
+static LRESULT CALLBACK testwindow_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
+{
+ /* TODO: Actually check for WM_WTSSESSION_CHANGE messages.
+ */
+ return DefWindowProcA(hwnd, msg, wparam, lparam);
+}
+
+static void register_testwindow_class(void)
+{
+ WNDCLASSEXA cls;
+
+ ZeroMemory(&cls, sizeof(cls));
+ cls.cbSize = sizeof(cls);
+ cls.style = 0;
+ cls.lpfnWndProc = testwindow_wndproc;
+ cls.hInstance = NULL;
+ cls.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW);
+ cls.hbrBackground = (HBRUSH) COLOR_WINDOW;
+ cls.lpszClassName = testwindow_class;
+
+ RegisterClassExA(&cls);
+}
+
+static void test_WTSRegisterSessionNotificationEx(void)
+{
+ BOOL ret;
+ HWND hwnd0;
+ HWND hwnd1;
+
+ register_testwindow_class();
+
+ hwnd0 = CreateWindowExA(WS_EX_TOOLWINDOW|WS_EX_TOPMOST,
+ testwindow_class, testwindow_class, WS_POPUP|WS_VISIBLE, 0, 0, 0, 0,
+ NULL, NULL, NULL, NULL);
+ ok(hwnd0 != NULL, "couldn't create window\n");
+
+ hwnd1 = CreateWindowExA(WS_EX_TOOLWINDOW|WS_EX_TOPMOST,
+ testwindow_class, testwindow_class, WS_POPUP|WS_VISIBLE, 0, 0, 0, 0,
+ NULL, NULL, NULL, NULL);
+ ok(hwnd1 != NULL, "couldn't create window\n");
+
+ ret = WTSRegisterSessionNotificationEx(WTS_CURRENT_SERVER_HANDLE, hwnd0, 0);
+ ok(ret, "WTSRegisterSessionNotificationEx: Initial call, no registered windows.\n");
+ ret = WTSRegisterSessionNotificationEx(WTS_CURRENT_SERVER_HANDLE, hwnd0, 0);
+ ok(ret, "WTSRegisterSessionNotificationEx: Re-register a window.\n");
+ ret = WTSRegisterSessionNotificationEx(WTS_CURRENT_SERVER_HANDLE, hwnd0, 1);
+ ok(ret,
+ "WTSRegisterSessionNotificationEx: Re-register a window with diff flags.\n");
+ ret = WTSRegisterSessionNotificationEx(WTS_CURRENT_SERVER_HANDLE, hwnd1, 0);
+ ok(ret, "WTSRegisterSessionNotificationEx: Register additional window.\n");
+ ret = WTSRegisterSessionNotificationEx(WTS_CURRENT_SERVER_HANDLE, hwnd1, 0);
+ ok(ret, "WTSRegisterSessionNotificationEx: Re-register window2.\n");
+ ret = WTSRegisterSessionNotificationEx(WTS_CURRENT_SERVER_HANDLE, hwnd1, 1);
+ ok(ret,
+ "WTSRegisterSessionNotificationEx: Re-register window2 with diff flags.\n");
+ ret = WTSUnRegisterSessionNotificationEx(WTS_CURRENT_SERVER_HANDLE, hwnd0);
+ ok(ret, "WTSUnRegisterSessionNotificationEx: Initial call with first window.\n");
+ ret = WTSUnRegisterSessionNotificationEx(WTS_CURRENT_SERVER_HANDLE, hwnd0);
+ ok(ret, "WTSUnRegisterSessionNotificationEx: Repeat call with first window.\n");
+ ret = WTSUnRegisterSessionNotificationEx(WTS_CURRENT_SERVER_HANDLE, hwnd1);
+ ok(ret, "WTSUnRegisterSessionNotificationEx: Initial call with second window.\n");
+ ret = WTSUnRegisterSessionNotificationEx(WTS_CURRENT_SERVER_HANDLE, hwnd1);
+ ok(ret, "WTSUnRegisterSessionNotificationEx: Repeat call with second window.\n");
+
+ DestroyWindow(hwnd0);
+ DestroyWindow(hwnd1);
+}
+
START_TEST (wtsapi)
{
test_WTSEnumerateProcessesW();
test_WTSQuerySessionInformationW();
test_WTSQueryUserToken();
+ test_WTSRegisterSessionNotificationEx();
}
--
2.22.0
More information about the wine-devel
mailing list