2016-06-16 21:00:08 +00:00
/*
* PROJECT : ReactOS api tests
* LICENSE : LGPLv2 .1 + - See COPYING . LIB in the top level directory
* PURPOSE : Test for ShellDimScreen
* PROGRAMMER : Mark Jansen
*/
# include <apitest.h>
# include <atlbase.h>
# include <atlcom.h>
# define INITGUID
# include <guiddef.h>
// stolen from com_apitest.h
DEFINE_GUID ( CLSID_FadeTask , 0x7EB5FBE4 , 0x2100 , 0x49E6 , 0x85 , 0x93 , 0x17 , 0xE1 , 0x30 , 0x12 , 0x2F , 0x91 ) ;
2019-01-20 14:58:32 +00:00
# define INVALID_POINTER ((PVOID)(ULONG_PTR)0xdeadbeefdeadbeefULL)
2016-06-16 21:00:08 +00:00
typedef HRESULT ( __stdcall * tShellDimScreen ) ( IUnknown * * Unknown , HWND * hWindow ) ;
tShellDimScreen ShellDimScreen ;
static void Test_Dim ( )
{
2019-01-20 14:58:32 +00:00
IUnknown * unk = ( IUnknown * ) INVALID_POINTER ;
HWND wnd = ( HWND ) INVALID_POINTER ;
2016-06-16 21:00:08 +00:00
ULONG count ;
HRESULT hr = ShellDimScreen ( NULL , NULL ) ;
ok_hex ( hr , E_INVALIDARG ) ;
hr = ShellDimScreen ( & unk , & wnd ) ;
ok_hex ( hr , S_OK ) ;
2019-01-20 14:58:32 +00:00
ok ( unk ! = INVALID_POINTER , " Expected a valid object \n " ) ;
ok ( wnd ! = INVALID_POINTER , " Expected a valid window ptr \n " ) ;
2016-06-16 21:00:08 +00:00
ok ( IsWindow ( wnd ) , " Expected a valid window \n " ) ;
ok ( IsWindowVisible ( wnd ) , " Expected the window to be visible \n " ) ;
2019-01-20 14:58:32 +00:00
if ( unk ! = ( ( IUnknown * ) INVALID_POINTER ) & & unk )
2016-06-16 21:00:08 +00:00
{
count = unk - > Release ( ) ;
ok ( count = = 0 , " Expected count to be 0, was: %lu \n " , count ) ;
ok ( ! IsWindow ( wnd ) , " Expected the window to be destroyed \n " ) ;
}
2019-01-20 14:58:32 +00:00
unk = ( IUnknown * ) INVALID_POINTER ;
wnd = ( HWND ) INVALID_POINTER ;
2016-06-16 21:00:08 +00:00
hr = ShellDimScreen ( & unk , & wnd ) ;
ok_hex ( hr , S_OK ) ;
2019-01-20 14:58:32 +00:00
ok ( unk ! = ( ( IUnknown * ) INVALID_POINTER ) , " Expected a valid object \n " ) ;
ok ( wnd ! = ( ( HWND ) INVALID_POINTER ) , " Expected a valid window ptr \n " ) ;
2016-06-16 21:00:08 +00:00
ok ( IsWindow ( wnd ) , " Expected a valid window \n " ) ;
ok ( IsWindowVisible ( wnd ) , " Expected the window to be visible \n " ) ;
2016-08-11 16:50:41 +00:00
char classname [ 100 ] = { 0 } ;
2016-06-16 21:00:08 +00:00
int nRet = GetClassNameA ( wnd , classname , 100 ) ;
ok ( nRet = = 17 , " Expected GetClassName to return 3 was %i \n " , nRet ) ;
ok ( ! strcmp ( classname , " DimmedWindowClass " ) , " Expected classname to be DimmedWindowClass, was %s \n " , classname ) ;
LONG style = GetWindowLong ( wnd , GWL_STYLE ) ;
LONG expectedstyle = WS_POPUP | WS_VISIBLE | WS_DISABLED | WS_CLIPSIBLINGS ;
ok ( style = = expectedstyle , " Expected style to be %lx, was %lx \n " , expectedstyle , style ) ;
style = GetWindowLong ( wnd , GWL_EXSTYLE ) ;
ok ( style = = WS_EX_TOPMOST , " Expected exstyle to be %x, was %lx \n " , WS_EX_TOPMOST , style ) ;
2019-01-20 14:58:32 +00:00
if ( unk ! = ( ( IUnknown * ) INVALID_POINTER ) & & unk )
2016-06-16 21:00:08 +00:00
{
count = unk - > AddRef ( ) ;
ok ( count = = 2 , " Expected count to be 2, was: %lu \n " , count ) ;
count = unk - > Release ( ) ;
ok ( count = = 1 , " Expected count to be 1, was: %lu \n " , count ) ;
IUnknown * unk2 ;
hr = unk - > QueryInterface ( IID_IUnknown , ( void * * ) & unk2 ) ;
ok_hex ( hr , S_OK ) ;
if ( SUCCEEDED ( hr ) )
{
ok ( unk2 = = unk , " Expected the object to be the same, was: %p, %p \n " , unk , unk2 ) ;
unk2 - > Release ( ) ;
}
hr = unk - > QueryInterface ( CLSID_FadeTask , ( void * * ) & unk2 ) ;
ok_hex ( hr , E_NOINTERFACE ) ;
if ( SUCCEEDED ( hr ) )
{
ok ( unk2 = = unk , " Expected the object to be the same, was: %p, %p \n " , unk , unk2 ) ;
unk2 - > Release ( ) ;
}
}
RECT rc ;
GetWindowRect ( wnd , & rc ) ;
ok ( rc . left = = GetSystemMetrics ( SM_XVIRTUALSCREEN ) , " Expected rc.left to be %u, was %lu \n " , GetSystemMetrics ( SM_XVIRTUALSCREEN ) , rc . left ) ;
ok ( rc . top = = GetSystemMetrics ( SM_YVIRTUALSCREEN ) , " Expected rc.top to be %u, was %lu \n " , GetSystemMetrics ( SM_YVIRTUALSCREEN ) , rc . top ) ;
ok ( ( rc . right - rc . left ) = = GetSystemMetrics ( SM_CXVIRTUALSCREEN ) , " Expected rc.left to be %u, was %lu \n " , GetSystemMetrics ( SM_CXVIRTUALSCREEN ) , ( rc . right - rc . left ) ) ;
ok ( ( rc . bottom - rc . top ) = = GetSystemMetrics ( SM_CYVIRTUALSCREEN ) , " Expected rc.top to be %u, was %lu \n " , GetSystemMetrics ( SM_CYVIRTUALSCREEN ) , ( rc . bottom - rc . top ) ) ;
2019-01-20 14:58:32 +00:00
if ( unk ! = ( ( IUnknown * ) INVALID_POINTER ) & & unk )
2016-06-16 21:00:08 +00:00
{
count = unk - > Release ( ) ;
ok ( count = = 0 , " Expected count to be 0, was: %lu \n " , count ) ;
ok ( ! IsWindow ( wnd ) , " Expected the window to be destroyed \n " ) ;
}
}
START_TEST ( ShellDimScreen )
{
HMODULE dll = LoadLibraryA ( " msgina.dll " ) ;
ShellDimScreen = ( tShellDimScreen ) GetProcAddress ( dll , MAKEINTRESOURCEA ( 16 ) ) ;
if ( ! dll | | ! ShellDimScreen )
{
skip ( " msgina!#16 not found, skipping tests \n " ) ;
return ;
}
Test_Dim ( ) ;
}