Sweden-Number/dlls/win32u/tests/win32u.c

116 lines
3.8 KiB
C

/*
* Copyright 2021 Jacek Caban for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "ntstatus.h"
#define WIN32_NO_STATUS
#include "wine/test.h"
#include "winbase.h"
#include "ntuser.h"
static void test_NtUserEnumDisplayDevices(void)
{
NTSTATUS ret;
DISPLAY_DEVICEW info = { sizeof(DISPLAY_DEVICEW) };
SetLastError( 0xdeadbeef );
ret = NtUserEnumDisplayDevices( NULL, 0, &info, 0 );
ok( !ret && GetLastError() == 0xdeadbeef,
"NtUserEnumDisplayDevices returned %x %u\n", ret, GetLastError() );
SetLastError( 0xdeadbeef );
ret = NtUserEnumDisplayDevices( NULL, 12345, &info, 0 );
ok( ret == STATUS_UNSUCCESSFUL && GetLastError() == 0xdeadbeef,
"NtUserEnumDisplayDevices returned %x %u\n", ret,
GetLastError() );
info.cb = 0;
SetLastError( 0xdeadbeef );
ret = NtUserEnumDisplayDevices( NULL, 0, &info, 0 );
ok( ret == STATUS_UNSUCCESSFUL && GetLastError() == 0xdeadbeef,
"NtUserEnumDisplayDevices returned %x %u\n", ret, GetLastError() );
SetLastError( 0xdeadbeef );
ret = NtUserEnumDisplayDevices( NULL, 12345, &info, 0 );
ok( ret == STATUS_UNSUCCESSFUL && GetLastError() == 0xdeadbeef,
"NtUserEnumDisplayDevices returned %x %u\n", ret, GetLastError() );
SetLastError( 0xdeadbeef );
ret = NtUserEnumDisplayDevices( NULL, 0, NULL, 0 );
ok( ret == STATUS_UNSUCCESSFUL && GetLastError() == 0xdeadbeef,
"NtUserEnumDisplayDevices returned %x %u\n", ret, GetLastError() );
SetLastError( 0xdeadbeef );
ret = NtUserEnumDisplayDevices( NULL, 12345, NULL, 0 );
ok( ret == STATUS_UNSUCCESSFUL && GetLastError() == 0xdeadbeef,
"NtUserEnumDisplayDevices returned %x %u\n", ret, GetLastError() );
}
static void test_NtUserCloseWindowStation(void)
{
BOOL ret;
SetLastError( 0xdeadbeef );
ret = NtUserCloseWindowStation( 0 );
ok( !ret && GetLastError() == ERROR_INVALID_HANDLE,
"NtUserCloseWindowStation returned %x %u\n", ret, GetLastError() );
}
static void test_window_props(void)
{
HANDLE prop;
ATOM atom;
HWND hwnd;
BOOL ret;
hwnd = CreateWindowExA( 0, "static", NULL, WS_POPUP, 0,0,0,0,0,0,0, NULL );
atom = GlobalAddAtomW( L"test" );
ret = NtUserSetProp( hwnd, UlongToPtr(atom), UlongToHandle(0xdeadbeef) );
ok( ret, "NtUserSetProp failed: %u\n", GetLastError() );
prop = GetPropW( hwnd, L"test" );
ok( prop == UlongToHandle(0xdeadbeef), "prop = %p\n", prop );
prop = NtUserGetProp( hwnd, UlongToPtr(atom) );
ok( prop == UlongToHandle(0xdeadbeef), "prop = %p\n", prop );
prop = NtUserRemoveProp( hwnd, UlongToPtr(atom) );
ok( prop == UlongToHandle(0xdeadbeef), "prop = %p\n", prop );
prop = GetPropW(hwnd, L"test");
ok(!prop, "prop = %p\n", prop);
GlobalDeleteAtom( atom );
DestroyWindow( hwnd );
}
START_TEST(win32u)
{
/* native win32u.dll fails if user32 is not loaded, so make sure it's fully initialized */
GetDesktopWindow();
test_NtUserEnumDisplayDevices(); /* Must run before test_NtUserCloseWindowStation. */
test_NtUserCloseWindowStation();
test_window_props();
}