[3/6]user32/tests: Test for SwitchDesktop API

shanmukha sainath addepalli sainath.addepalli at gmail.com
Sat Dec 12 05:06:02 CST 2009


Hi,

       The test for SwitchDesktop has not submitted earlier. This test
performs switching between two desktops using SwitchDesktop API.

-- 
Regards
Sainath A
-------------- next part --------------
From ea5353e4788ec14df8102bd8529ac1264bb9a6d2 Mon Sep 17 00:00:00 2001
From: Sainath Addepalli <sainath.addepalli at gmail.com>
Date: Fri, 11 Dec 2009 19:34:20 +0530
Subject: Test for SwitchDesktop

---
 dlls/user32/tests/win.c |   48 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 48 insertions(+), 0 deletions(-)

diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c
index 24e6ac2..394716f 100644
--- a/dlls/user32/tests/win.c
+++ b/dlls/user32/tests/win.c
@@ -42,6 +42,8 @@
 #define LONG_PTR INT_PTR
 #define ULONG_PTR UINT_PTR
 
+#define DESKTOP_ALL_ACCESS 0x01ff
+
 void dump_region(HRGN hrgn);
 
 static HWND (WINAPI *pGetAncestor)(HWND,UINT);
@@ -5779,6 +5781,51 @@ static void test_winregion(void)
     DestroyWindow(hwnd);
 }
 
+static DWORD CALLBACK thread_switchdesktop( LPVOID arg )
+{
+    HDESK d1 = (HDESK)arg;
+    HDESK d2;
+    BOOL ret;
+    HWND hwnd;
+
+    SetThreadDesktop(d1);
+
+    d2 = CreateDesktop( "foobar", NULL, NULL, 0, DESKTOP_ALL_ACCESS, NULL );
+    ok( d2!=0, "create desktop failed\n");
+
+    ret = SwitchDesktop( d2 );
+    trace("Switch to desktop d2 %d\n", ret );
+    ok( ret != 0, "Switching to dektop %p failed\n", d2 );
+    ok( SetThreadDesktop(d2), "SetThreadDesktop failed\n");
+
+    hwnd = CreateWindowExA(0, "test", NULL, WS_VISIBLE, 10, 10, 10, 10, NULL, 0, 0, NULL);
+    ret = SwitchDesktop( d1 );
+    trace( "Switched back to desktop d1 %d\n", ret );
+    ok( ret != 0, "Switching to desktop %p failed\n", d1 );
+    ok( SetThreadDesktop( d1 ), "SetThreadDesktop failed\n");
+
+    DestroyWindow( hwnd );
+    CloseDesktop( d2 );
+    CloseDesktop( d1 );
+
+    return 0;
+}
+
+static void test_switchdesktop(void)
+{
+    HDESK d1;
+    HANDLE hthread;
+    DWORD tid;
+
+    d1 = GetThreadDesktop(GetCurrentThreadId());
+    if (d1)
+    {
+        hthread = CreateThread( NULL, 0, thread_switchdesktop, (LPVOID)d1, 0, &tid );
+        WaitForSingleObject( hthread, INFINITE );
+        CloseHandle( hthread );
+    }
+}
+
 START_TEST(win)
 {
     HMODULE user32 = GetModuleHandleA( "user32.dll" );
@@ -5863,6 +5910,7 @@ START_TEST(win)
     test_shell_window();
     test_handles( hwndMain );
     test_winregion();
+    test_switchdesktop();
 
     /* add the tests above this line */
     if (hhook) UnhookWindowsHookEx(hhook);
-- 
1.6.0.4


More information about the wine-patches mailing list