[SHELL32_APITEST]
authorThomas Faber <thomas.faber@reactos.org>
Sat, 20 Jun 2015 16:28:38 +0000 (16:28 +0000)
committerThomas Faber <thomas.faber@reactos.org>
Sat, 20 Jun 2015 16:28:38 +0000 (16:28 +0000)
- Add a test for CLSID_MyComputer that shows this folder object is also cached.
CORE-9839

svn path=/trunk/; revision=68209

rostests/apitests/shell32/CMakeLists.txt
rostests/apitests/shell32/CMyComputer.cpp [new file with mode: 0644]
rostests/apitests/shell32/testlist.c

index 81a8214..0d7dbf0 100644 (file)
@@ -4,6 +4,7 @@ set_cpp(WITH_RUNTIME)
 include_directories(${REACTOS_SOURCE_DIR}/lib/atl)
 
 add_executable(shell32_apitest
+    CMyComputer.cpp
     CShellDesktop.cpp
     menu.cpp
     testlist.c)
diff --git a/rostests/apitests/shell32/CMyComputer.cpp b/rostests/apitests/shell32/CMyComputer.cpp
new file mode 100644 (file)
index 0000000..68e42d2
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * PROJECT:         ReactOS api tests
+ * LICENSE:         LGPLv2.1+ - See COPYING.LIB in the top level directory
+ * PURPOSE:         Test for CMyComputer
+ * PROGRAMMER:      Thomas Faber <thomas.faber@reactos.org>
+ */
+
+#include "shelltest.h"
+#include <atlbase.h>
+#include <atlcom.h>
+#include <strsafe.h>
+
+#define NDEBUG
+#include <debug.h>
+#include <shellutils.h>
+
+static
+VOID
+TestShellFolder(
+    _In_ IShellFolder2 *psf2)
+{
+    HRESULT hr;
+    CComPtr<IDropTarget> pdt;
+    CComPtr<IDropTarget> pdt_2;
+    CComPtr<IContextMenu> pcm;
+    CComPtr<IContextMenu> pcm_2;
+    CComPtr<IShellView> psv;
+    CComPtr<IShellView> 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<PVOID>(pdt), static_cast<PVOID>(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<PVOID>(pcm), static_cast<PVOID>(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<PVOID>(psv), static_cast<PVOID>(psv_2));
+}
+
+START_TEST(CMyComputer)
+{
+    HRESULT hr;
+    CComPtr<IShellFolder2> psf2;
+    CComPtr<IShellFolder2> psf2_2;
+    CComPtr<IShellFolder> psf;
+
+    CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
+
+    hr = CoCreateInstance(CLSID_MyComputer,
+                          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_MyComputer,
+                          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<PVOID>(psf2), static_cast<PVOID>(psf2_2));
+
+    TestShellFolder(psf2);
+}
index 4f5b6d9..6246259 100644 (file)
@@ -3,11 +3,13 @@
 #define STANDALONE
 #include <wine/test.h>
 
+extern void func_CMyComputer(void);
 extern void func_CShellDesktop(void);
 extern void func_menu(void);
 
 const struct test winetest_testlist[] =
 {
+    { "CMyComputer", func_CMyComputer },
     { "CShellDesktop", func_CShellDesktop },
     { "menu", func_menu },
     { 0, 0 }