user32: Add some tests for window station and desktop object names.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2016-02-01 17:53:10 +09:00
parent 37503be654
commit 34d5994953
3 changed files with 58 additions and 6 deletions

View File

@ -205,6 +205,35 @@ static void test_handles(void)
else if (le == ERROR_ACCESS_DENIED)
win_skip( "Not enough privileges for CreateWindowStation\n" );
SetLastError( 0xdeadbeef );
w2 = OpenWindowStationA( "", TRUE, WINSTA_ALL_ACCESS );
ok( !w2, "open station succeeded\n" );
todo_wine
ok( GetLastError() == ERROR_FILE_NOT_FOUND, "wrong error %u\n", GetLastError() );
SetLastError( 0xdeadbeef );
w2 = CreateWindowStationA( "", 0, WINSTA_ALL_ACCESS, NULL );
ok( w2 != 0, "create station failed err %u\n", GetLastError() );
SetLastError( 0xdeadbeef );
w3 = OpenWindowStationA( "", TRUE, WINSTA_ALL_ACCESS );
todo_wine
ok( w3 != 0, "open station failed err %u\n", GetLastError() );
CloseWindowStation( w3 );
CloseWindowStation( w2 );
SetLastError( 0xdeadbeef );
w2 = CreateWindowStationA( "foo\\bar", 0, WINSTA_ALL_ACCESS, NULL );
ok( !w2, "create station succeeded\n" );
todo_wine
ok( GetLastError() == ERROR_PATH_NOT_FOUND || GetLastError() == ERROR_ACCESS_DENIED,
"wrong error %u\n", GetLastError() );
SetLastError( 0xdeadbeef );
w2 = OpenWindowStationA( "foo\\bar", TRUE, WINSTA_ALL_ACCESS );
ok( !w2, "create station succeeded\n" );
ok( GetLastError() == ERROR_PATH_NOT_FOUND, "wrong error %u\n", GetLastError() );
/* desktops */
d1 = GetThreadDesktop(GetCurrentThreadId());
initial_desktop = d1;
@ -239,6 +268,30 @@ static void test_handles(void)
d2 = OpenDesktopA( "dummy name", 0, TRUE, DESKTOP_ALL_ACCESS );
ok( !d2, "open dummy desktop succeeded\n" );
SetLastError( 0xdeadbeef );
d2 = CreateDesktopA( "", NULL, NULL, 0, DESKTOP_ALL_ACCESS, NULL );
todo_wine
ok( !d2, "create empty desktop succeeded\n" );
todo_wine
ok( GetLastError() == ERROR_INVALID_HANDLE, "wrong error %u\n", GetLastError() );
SetLastError( 0xdeadbeef );
d2 = OpenDesktopA( "", 0, TRUE, DESKTOP_ALL_ACCESS );
ok( !d2, "open mepty desktop succeeded\n" );
todo_wine
ok( GetLastError() == ERROR_INVALID_HANDLE, "wrong error %u\n", GetLastError() );
SetLastError( 0xdeadbeef );
d2 = CreateDesktopA( "foo\\bar", NULL, NULL, 0, DESKTOP_ALL_ACCESS, NULL );
ok( !d2, "create desktop succeeded\n" );
ok( GetLastError() == ERROR_BAD_PATHNAME, "wrong error %u\n", GetLastError() );
SetLastError( 0xdeadbeef );
d2 = OpenDesktopA( "foo\\bar", 0, TRUE, DESKTOP_ALL_ACCESS );
ok( !d2, "open desktop succeeded\n" );
todo_wine
ok( GetLastError() == ERROR_BAD_PATHNAME, "wrong error %u\n", GetLastError() );
d2 = CreateDesktopA( "foobar", NULL, NULL, 0, DESKTOP_ALL_ACCESS, NULL );
ok( d2 != 0, "create foobar desktop failed\n" );
SetLastError( 0xdeadbeef );

View File

@ -118,8 +118,7 @@ HWINSTA WINAPI CreateWindowStationW( LPCWSTR name, DWORD reserved, ACCESS_MASK a
((sa && sa->bInheritHandle) ? OBJ_INHERIT : 0);
req->rootdir = wine_server_obj_handle( get_winstations_dir_handle() );
wine_server_add_data( req, name, len * sizeof(WCHAR) );
/* it doesn't seem to set last error */
wine_server_call( req );
wine_server_call_err( req );
ret = wine_server_ptr_handle( reply->handle );
}
SERVER_END_REQ;
@ -316,8 +315,7 @@ HDESK WINAPI CreateDesktopW( LPCWSTR name, LPCWSTR device, LPDEVMODEW devmode,
req->attributes = OBJ_CASE_INSENSITIVE | OBJ_OPENIF |
((sa && sa->bInheritHandle) ? OBJ_INHERIT : 0);
wine_server_add_data( req, name, len * sizeof(WCHAR) );
/* it doesn't seem to set last error */
wine_server_call( req );
wine_server_call_err( req );
ret = wine_server_ptr_handle( reply->handle );
}
SERVER_END_REQ;
@ -359,7 +357,7 @@ HDESK open_winstation_desktop( HWINSTA hwinsta, LPCWSTR name, DWORD flags, BOOL
req->access = access;
req->attributes = OBJ_CASE_INSENSITIVE | (inherit ? OBJ_INHERIT : 0);
wine_server_add_data( req, name, len * sizeof(WCHAR) );
if (!wine_server_call( req )) ret = wine_server_ptr_handle( reply->handle );
if (!wine_server_call_err( req )) ret = wine_server_ptr_handle( reply->handle );
}
SERVER_END_REQ;
return ret;

View File

@ -191,7 +191,7 @@ static struct desktop *create_desktop( const struct unicode_str *name, unsigned
if (memchrW( name->str, '\\', name->len / sizeof(WCHAR) )) /* no backslash allowed in name */
{
set_error( STATUS_INVALID_PARAMETER );
set_error( STATUS_OBJECT_PATH_SYNTAX_BAD );
return NULL;
}
@ -213,6 +213,7 @@ static struct desktop *create_desktop( const struct unicode_str *name, unsigned
list_add_tail( &winstation->desktops, &desktop->entry );
list_init( &desktop->hotkeys );
}
else clear_error();
}
return desktop;
}