Index: rostests/apitests/shell32/CDesktopBrowser.cpp =================================================================== --- rostests/apitests/shell32/CDesktopBrowser.cpp (nonexistent) +++ rostests/apitests/shell32/CDesktopBrowser.cpp (working copy) @@ -0,0 +1,149 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory + * PURPOSE: Test for WM_SETTINGCHANGE + * PROGRAMMER: Mark Jansen + */ + +#include "shelltest.h" +#include +#include +#include +#include + +#define NDEBUG +#include +#include + +#define ok_hr(status, expected) ok_hex(status, expected) + +static HWND g_Window; + + + +static void run_tests() +{ + char buf[100]; + DWORD dwRet = GetEnvironmentVariableA("apitest_var", buf, _countof(buf)); + DWORD dwErr = GetLastError(); + ok_hex(dwRet, 0); + ok_hex(dwErr, ERROR_ENVVAR_NOT_FOUND); + + // Set the variable in the env. + SetEnvironmentVariableA("apitest_var", "some randome value"); + dwRet = GetEnvironmentVariableA("apitest_var", buf, _countof(buf)); + ok_hex(dwRet, 0x12); + ok_str(buf, "some randome value"); + + SendMessageW(g_Window, WM_SETTINGCHANGE, NULL, (LPARAM)L"Environment"); + + dwRet = GetEnvironmentVariableA("apitest_var", buf, _countof(buf)); + dwErr = GetLastError(); + ok_hex(dwRet, 0); + ok_hex(dwErr, ERROR_ENVVAR_NOT_FOUND); +} + +const GUID IID_IShellDesktopTray = { 0x213e2df9, 0x9a14, 0x4328, { 0x99, 0xb1, 0x69, 0x61, 0xf9, 0x14, 0x3c, 0xe9 } }; + +class IShellDesktopTray +{ + /*** IUnknown methods ***/ + STDMETHOD_(HRESULT, QueryInterface) (THIS_ REFIID riid, void** ppvObject) + { + if (riid == IID_IUnknown || riid == IID_IShellDesktopTray) + { + *ppvObject = this; + return S_OK; + } + return E_NOINTERFACE; + } + STDMETHOD_(ULONG, AddRef) (THIS) { return 2; } + STDMETHOD_(ULONG, Release) (THIS) { return 1; } + + /*** IShellDesktopTray ***/ + STDMETHOD_(ULONG,GetState)(THIS) { return 0; } + STDMETHOD(GetTrayWindow)(THIS_ HWND*) { return E_FAIL; } + STDMETHOD(RegisterDesktopWindow)(THIS_ HWND) { return E_FAIL; } + STDMETHOD(Unknown)(THIS_ DWORD,DWORD) { return E_FAIL; } +}; + +static UINT g_TestMessage; + +LRESULT CALLBACK test_SubClassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData) +{ + if (uMsg == WM_NCDESTROY) + RemoveWindowSubclass(hWnd, test_SubClassProc, uIdSubclass); + + if (uMsg == g_TestMessage) + { + run_tests(); + PostQuitMessage(0); + } + + return DefSubclassProc(hWnd, uMsg, wParam, lParam); +} + +typedef HANDLE(WINAPI * PSHCREATEDESKTOP)(IShellDesktopTray *ShellDesk); + +struct CCoInit +{ + CCoInit() { hres = CoInitialize(NULL); } + ~CCoInit() { if (SUCCEEDED(hres)) { CoUninitialize(); } } + HRESULT hres; +}; + +START_TEST(CDesktopBrowser) +{ + CCoInit init; + + PSHCREATEDESKTOP SHCreateDesktop = (PSHCREATEDESKTOP) GetProcAddress(LoadLibraryA("shell32.dll"), MAKEINTRESOURCEA(200)); + + IShellDesktopTray tray; + CComPtr browser; + browser.Attach(static_cast(SHCreateDesktop(&tray))); + ok(browser.p != NULL, "Expected an IShellBrowser\n"); + if (!browser.p) + return; + + CComPtr shellView; + HRESULT hr = browser->QueryActiveShellView(&shellView); + ok_hr(hr, S_OK); + if (!SUCCEEDED(hr)) + return; + + hr = browser->GetWindow(&g_Window); + ok_hr(hr, S_OK); + if (!SUCCEEDED(hr)) + return; + + char buf[100]; + GetWindowTextA(g_Window, buf, 100); + ok_str(buf, "Program Manager"); + + RealGetWindowClassA(g_Window, buf, 100); + ok_str(buf, "Progman"); + + DWORD pid; + GetWindowThreadProcessId(g_Window, &pid); + ok_hex(pid, GetCurrentProcessId()); + + g_TestMessage = RegisterWindowMessageW(L"apitest_cb_msg"); + SetWindowSubclass(g_Window, test_SubClassProc, 1, 0); + + // kick off the test loop + PostMessage(g_Window, g_TestMessage, 0, 0); + + MSG Msg; + BOOL bRet; + while ((bRet = GetMessageW(&Msg, NULL, 0, 0)) != 0) + { + if (bRet != -1) + { + if (shellView->TranslateAccelerator(&Msg) != S_OK) + { + TranslateMessage(&Msg); + DispatchMessage(&Msg); + } + } + } +} Index: rostests/apitests/shell32/CMakeLists.txt =================================================================== --- rostests/apitests/shell32/CMakeLists.txt (revision 73453) +++ rostests/apitests/shell32/CMakeLists.txt (working copy) @@ -4,6 +4,7 @@ include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/atl) add_executable(shell32_apitest + CDesktopBrowser.cpp CFSFolder.cpp CMyComputer.cpp CShellDesktop.cpp @@ -15,5 +16,5 @@ testlist.c) target_link_libraries(shell32_apitest wine uuid ${PSEH_LIB}) set_module_type(shell32_apitest win32cui) -add_importlibs(shell32_apitest user32 gdi32 shell32 ole32 oleaut32 advapi32 shlwapi msvcrt kernel32 ntdll) +add_importlibs(shell32_apitest user32 gdi32 shell32 ole32 oleaut32 comctl32 advapi32 shlwapi msvcrt kernel32 ntdll) add_cd_file(TARGET shell32_apitest DESTINATION reactos/bin FOR all) Index: rostests/apitests/shell32/testlist.c =================================================================== --- rostests/apitests/shell32/testlist.c (revision 73453) +++ rostests/apitests/shell32/testlist.c (working copy) @@ -3,6 +3,7 @@ #define STANDALONE #include +extern void func_CDesktopBrowser(void); extern void func_CFSFolder(void); extern void func_CMyComputer(void); extern void func_CShellDesktop(void); @@ -13,6 +14,7 @@ const struct test winetest_testlist[] = { + { "CDesktopBrowser", func_CDesktopBrowser }, { "CFSFolder", func_CFSFolder }, { "CMyComputer", func_CMyComputer }, { "CShellDesktop", func_CShellDesktop },