From 9046d69084df42239013bc6689bd38d742fc1a3f Mon Sep 17 00:00:00 2001 From: Thomas Faber Date: Sat, 20 Jun 2015 09:07:29 +0000 Subject: [PATCH] [SHELL32_APITEST] - Add a test showing that repeated calls to SHGetDesktopFolder return pointers to the same object, and that its CreateViewObject method instead creates new objects. CORE-9839 svn path=/trunk/; revision=68200 --- rostests/apitests/shell32/CMakeLists.txt | 10 ++- rostests/apitests/shell32/CShellDesktop.cpp | 86 +++++++++++++++++++++ rostests/apitests/shell32/testlist.c | 3 +- 3 files changed, 96 insertions(+), 3 deletions(-) create mode 100644 rostests/apitests/shell32/CShellDesktop.cpp diff --git a/rostests/apitests/shell32/CMakeLists.txt b/rostests/apitests/shell32/CMakeLists.txt index 514c21b2c54..81a82147eac 100644 --- a/rostests/apitests/shell32/CMakeLists.txt +++ b/rostests/apitests/shell32/CMakeLists.txt @@ -1,7 +1,13 @@ set_cpp(WITH_RUNTIME) -add_executable(shell32_apitest menu.cpp testlist.c) + +include_directories(${REACTOS_SOURCE_DIR}/lib/atl) + +add_executable(shell32_apitest + CShellDesktop.cpp + menu.cpp + testlist.c) target_link_libraries(shell32_apitest wine uuid) set_module_type(shell32_apitest win32cui) -add_importlibs(shell32_apitest msvcrt kernel32 user32 gdi32 shell32 ole32 shlwapi) +add_importlibs(shell32_apitest user32 gdi32 shell32 ole32 oleaut32 shlwapi msvcrt kernel32) add_cd_file(TARGET shell32_apitest DESTINATION reactos/bin FOR all) diff --git a/rostests/apitests/shell32/CShellDesktop.cpp b/rostests/apitests/shell32/CShellDesktop.cpp new file mode 100644 index 00000000000..c11348b7160 --- /dev/null +++ b/rostests/apitests/shell32/CShellDesktop.cpp @@ -0,0 +1,86 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory + * PURPOSE: Test for CShellDesktop + * PROGRAMMER: Thomas Faber + */ + +#include "shelltest.h" +#include +#include +#include + +#define NDEBUG +#include +#include + +static +VOID +TestShellFolder( + _In_ IShellFolder2 *psf2) +{ + HRESULT hr; + CComPtr pdt; + CComPtr pdt_2; + CComPtr pcm; + CComPtr pcm_2; + CComPtr psv; + CComPtr psv_2; + + hr = psf2->CreateViewObject(NULL, IID_PPV_ARG(IDropTarget, &pdt)); + ok(hr == S_OK, "hr = %lx\n", hr); + + hr = psf2->CreateViewObject(NULL, IID_PPV_ARG(IDropTarget, &pdt_2)); + ok(hr == S_OK, "hr = %lx\n", hr); + ok(pdt != pdt_2, "Expected %p != %p\n", static_cast(pdt), static_cast(pdt_2)); + + hr = psf2->CreateViewObject(NULL, IID_PPV_ARG(IContextMenu, &pcm)); + ok(hr == S_OK, "hr = %lx\n", hr); + + hr = psf2->CreateViewObject(NULL, IID_PPV_ARG(IContextMenu, &pcm_2)); + ok(hr == S_OK, "hr = %lx\n", hr); + ok(pcm != pcm_2, "Expected %p != %p\n", static_cast(pcm), static_cast(pcm_2)); + + hr = psf2->CreateViewObject(NULL, IID_PPV_ARG(IShellView, &psv)); + ok(hr == S_OK, "hr = %lx\n", hr); + + hr = psf2->CreateViewObject(NULL, IID_PPV_ARG(IShellView, &psv_2)); + ok(hr == S_OK, "hr = %lx\n", hr); + ok(psv != psv_2, "Expected %p != %p\n", static_cast(psv), static_cast(psv_2)); +} + +START_TEST(CShellDesktop) +{ + HRESULT hr; + CComPtr psf2; + CComPtr psf2_2; + CComPtr psf; + + CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); + + hr = CoCreateInstance(CLSID_ShellDesktop, + NULL, + CLSCTX_INPROC_SERVER, + IID_PPV_ARG(IShellFolder2, &psf2)); + ok(hr == S_OK, "hr = %lx\n", hr); + if (FAILED(hr)) + { + skip("Could not instantiate CShellDesktop\n"); + return; + } + + /* second create should give us a pointer to the same object */ + hr = CoCreateInstance(CLSID_ShellDesktop, + NULL, + CLSCTX_INPROC_SERVER, + IID_PPV_ARG(IShellFolder2, &psf2_2)); + ok(hr == S_OK, "hr = %lx\n", hr); + ok(psf2 == psf2_2, "Expected %p == %p\n", static_cast(psf2), static_cast(psf2_2)); + + /* SHGetDesktopFolder should also give us the same pointer */ + hr = SHGetDesktopFolder(&psf); + ok(hr == S_OK, "hr = %lx\n", hr); + ok(psf == static_cast(psf2), "Expected %p == %p\n", static_cast(psf), static_cast(psf2)); + + TestShellFolder(psf2); +} diff --git a/rostests/apitests/shell32/testlist.c b/rostests/apitests/shell32/testlist.c index 7cb8973d0bd..4f5b6d92c43 100644 --- a/rostests/apitests/shell32/testlist.c +++ b/rostests/apitests/shell32/testlist.c @@ -3,11 +3,12 @@ #define STANDALONE #include +extern void func_CShellDesktop(void); extern void func_menu(void); const struct test winetest_testlist[] = { + { "CShellDesktop", func_CShellDesktop }, { "menu", func_menu }, - { 0, 0 } };