Author: gadamopoulos
Date: Sat Nov 12 14:54:12 2016
New Revision: 73212
URL:
http://svn.reactos.org/svn/reactos?rev=73212&view=rev
Log:
[SHELL32_APITEST]
- Add tests for the Initialize method for CDesktopFolder and CDrivesFolder.
- Add tests for CFSFolder to see how it behaves whhile not initialized.
Added:
trunk/rostests/apitests/shell32/CFSFolder.cpp (with props)
Modified:
trunk/rostests/apitests/shell32/CMakeLists.txt
trunk/rostests/apitests/shell32/CMyComputer.cpp
trunk/rostests/apitests/shell32/CShellDesktop.cpp
trunk/rostests/apitests/shell32/testlist.c
Added: trunk/rostests/apitests/shell32/CFSFolder.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/shell32/CFSFolde…
==============================================================================
--- trunk/rostests/apitests/shell32/CFSFolder.cpp (added)
+++ trunk/rostests/apitests/shell32/CFSFolder.cpp [iso-8859-1] Sat Nov 12 14:54:12 2016
@@ -0,0 +1,100 @@
+/*
+ * PROJECT: ReactOS api tests
+ * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory
+ * PURPOSE: Test for CMyComputer
+ * PROGRAMMER: Giannis Adamopoulos
+ */
+
+#include "shelltest.h"
+#include <atlbase.h>
+#include <atlcom.h>
+#include <strsafe.h>
+
+#define NDEBUG
+#include <debug.h>
+#include <shellutils.h>
+
+VOID TestUninitialized()
+{
+ CComPtr<IShellFolder> psf;
+ CComPtr<IEnumIDList> penum;
+ CComPtr<IDropTarget> pdt;
+ CComPtr<IContextMenu> pcm;
+ CComPtr<IShellView> psv;
+ LPITEMIDLIST retrievedPidl;
+ ULONG pceltFetched;
+ HRESULT hr;
+
+ /* Create a CFSFolder */
+ hr = CoCreateInstance(CLSID_ShellFSFolder, NULL, CLSCTX_INPROC_SERVER,
IID_PPV_ARG(IShellFolder, &psf));
+ ok(hr == S_OK, "hr = %lx\n", hr);
+
+ /* An uninitialized CFSFolder doesn't contain any items */
+ hr = psf->EnumObjects(NULL, 0, &penum);
+ ok(hr == S_OK, "hr = %lx\n", hr);
+ hr = penum->Next(0, &retrievedPidl, &pceltFetched);
+ ok(hr == S_FALSE, "hr = %lx\n", hr);
+ hr = penum->Next(1, &retrievedPidl, &pceltFetched);
+ ok(hr == S_FALSE, "hr = %lx\n", hr);
+
+ /* It supports viewing */
+ hr = psf->CreateViewObject(NULL, IID_PPV_ARG(IDropTarget, &pdt));
+ ok(hr == S_OK, "hr = %lx\n", hr);
+ hr = psf->CreateViewObject(NULL, IID_PPV_ARG(IContextMenu, &pcm));
+ ok(hr == S_OK, "hr = %lx\n", hr);
+ hr = psf->CreateViewObject(NULL, IID_PPV_ARG(IShellView, &psv));
+ ok(hr == S_OK, "hr = %lx\n", hr);
+
+ /* And its display name is ... "C:\Documents and Settings\" */
+ STRRET strretName;
+ hr = psf->GetDisplayNameOf(NULL,SHGDN_FORPARSING,&strretName);
+ ok(hr == S_OK, "hr = %lx\n", hr);
+ ok(strretName.uType == STRRET_WSTR, "strretName.uType == %x\n",
strretName.uType);
+ ok(wcscmp(strretName.pOleStr, L"C:\\Documents and Settings\\") == 0,
"wrong name, got: %S\n", strretName.pOleStr);
+
+ hr = psf->GetDisplayNameOf(NULL,SHGDN_FORPARSING|SHGDN_INFOLDER,&strretName);
+ ok(hr == E_INVALIDARG, "hr = %lx\n", hr);
+
+
+
+
+ /* Use Initialize method with a dummy pidl and test the still non initialized
CFSFolder */
+ CComPtr<IPersistFolder2> ppf2;
+ hr = psf->QueryInterface(IID_PPV_ARG(IPersistFolder2, &ppf2));
+ ok(hr == S_OK, "hr = %lx\n", hr);
+
+ /* Create a tiny pidl with no contents */
+ LPITEMIDLIST testpidl = (LPITEMIDLIST)SHAlloc(3 * sizeof(WORD));
+ testpidl->mkid.cb = 2 * sizeof(WORD);
+ *(WORD*)((char*)testpidl + (int)(2 * sizeof(WORD))) = 0;
+
+ hr = ppf2->Initialize(testpidl);
+ ok(hr == S_OK, "hr = %lx\n", hr);
+
+ LPITEMIDLIST pidl;
+ hr = ppf2->GetCurFolder(&pidl);
+ ok(hr == S_OK, "hr = %lx\n", hr);
+ ok(pidl->mkid.cb == 2 * sizeof(WORD), "got wrong pidl size, cb = %x\n",
pidl->mkid.cb);
+
+ /* methods that worked before, now fail */
+ hr = psf->GetDisplayNameOf(NULL,SHGDN_FORPARSING,&strretName);
+ ok(hr == E_FAIL, "hr = %lx\n", hr);
+ hr = psf->EnumObjects(NULL, 0, &penum);
+ ok(hr == HRESULT_FROM_WIN32(ERROR_CANCELLED), "hr = %lx\n", hr);
+
+ /* The following continue to work though */
+ hr = psf->CreateViewObject(NULL, IID_PPV_ARG(IDropTarget, &pdt));
+ ok(hr == S_OK, "hr = %lx\n", hr);
+ hr = psf->CreateViewObject(NULL, IID_PPV_ARG(IContextMenu, &pcm));
+ ok(hr == S_OK, "hr = %lx\n", hr);
+ hr = psf->CreateViewObject(NULL, IID_PPV_ARG(IShellView, &psv));
+ ok(hr == S_OK, "hr = %lx\n", hr);
+
+}
+
+START_TEST(CFSFolder)
+{
+ CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
+
+ TestUninitialized();
+}
Propchange: trunk/rostests/apitests/shell32/CFSFolder.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/rostests/apitests/shell32/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/shell32/CMakeLis…
==============================================================================
--- trunk/rostests/apitests/shell32/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/rostests/apitests/shell32/CMakeLists.txt [iso-8859-1] Sat Nov 12 14:54:12 2016
@@ -4,6 +4,7 @@
include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/atl)
add_executable(shell32_apitest
+ CFSFolder.cpp
CMyComputer.cpp
CShellDesktop.cpp
CShellLink.cpp
Modified: trunk/rostests/apitests/shell32/CMyComputer.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/shell32/CMyCompu…
==============================================================================
--- trunk/rostests/apitests/shell32/CMyComputer.cpp [iso-8859-1] (original)
+++ trunk/rostests/apitests/shell32/CMyComputer.cpp [iso-8859-1] Sat Nov 12 14:54:12 2016
@@ -49,6 +49,29 @@
ok(psv != psv_2, "Expected %p != %p\n", static_cast<PVOID>(psv),
static_cast<PVOID>(psv_2));
}
+VOID TestInitialize(_In_ IShellFolder2 *psf2)
+{
+ CComPtr<IPersistFolder2> ppf2;
+ HRESULT hr = psf2->QueryInterface(IID_PPV_ARG(IPersistFolder2, &ppf2));
+ ok(hr == S_OK, "hr = %lx\n", hr);
+
+ hr = ppf2->Initialize(NULL);
+ ok(hr == S_OK, "hr = %lx\n", hr);
+
+ hr = ppf2->Initialize((LPCITEMIDLIST)0xdeaddead);
+ ok(hr == S_OK, "hr = %lx\n", hr);
+
+ //crashes in xp
+ //hr = ppf2->GetCurFolder(NULL);
+ //ok(hr == E_INVALIDARG, "hr = %lx\n", hr);
+
+ LPITEMIDLIST pidl;
+ hr = ppf2->GetCurFolder(&pidl);
+ ok(hr == S_OK, "hr = %lx\n", hr);
+ // 0 in win10, 14 in xp
+ ok(pidl->mkid.cb == 0x14, "expected empty pidl got cb = %x\n",
pidl->mkid.cb);
+}
+
START_TEST(CMyComputer)
{
HRESULT hr;
@@ -78,4 +101,5 @@
ok(psf2 == psf2_2, "Expected %p == %p\n", static_cast<PVOID>(psf2),
static_cast<PVOID>(psf2_2));
TestShellFolder(psf2);
+ TestInitialize(psf2);
}
Modified: trunk/rostests/apitests/shell32/CShellDesktop.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/shell32/CShellDe…
==============================================================================
--- trunk/rostests/apitests/shell32/CShellDesktop.cpp [iso-8859-1] (original)
+++ trunk/rostests/apitests/shell32/CShellDesktop.cpp [iso-8859-1] Sat Nov 12 14:54:12
2016
@@ -184,6 +184,34 @@
ok(psv != psv_2, "Expected %p != %p\n", static_cast<PVOID>(psv),
static_cast<PVOID>(psv_2));
}
+VOID TestInitialize(_In_ IShellFolder *psf)
+{
+ CComPtr<IPersistFolder2> ppf2;
+ HRESULT hr = psf->QueryInterface(IID_PPV_ARG(IPersistFolder2, &ppf2));
+ ok(hr == S_OK, "hr = %lx\n", hr);
+
+ /* Create a tiny pidl with no contents */
+ LPITEMIDLIST testpidl = (LPITEMIDLIST)SHAlloc(3 * sizeof(WORD));
+ testpidl->mkid.cb = 2 * sizeof(WORD);
+ *(WORD*)((char*)testpidl + (int)(2 * sizeof(WORD))) = 0;
+
+ hr = ppf2->Initialize(testpidl);
+ ok(hr == E_INVALIDARG, "hr = %lx\n", hr);
+
+ //crashes in xp, works on win10
+ //hr = ppf2->Initialize(NULL);
+ //ok(hr == S_OK, "hr = %lx\n", hr);
+ //hr = ppf2->Initialize((LPCITEMIDLIST)0xdeaddead);
+ //ok(hr == S_OK, "hr = %lx\n", hr);
+ //hr = ppf2->GetCurFolder(NULL);
+ //ok(hr == E_INVALIDARG, "hr = %lx\n", hr);
+
+ LPITEMIDLIST pidl;
+ hr = ppf2->GetCurFolder(&pidl);
+ ok(hr == S_OK, "hr = %lx\n", hr);
+ ok(pidl->mkid.cb == 0, "expected empty pidl got cb = %x\n",
pidl->mkid.cb);
+}
+
START_TEST(CShellDesktop)
{
HRESULT hr;
@@ -219,4 +247,5 @@
TestShellFolder(psf2);
TestCompareIDList(psf);
-}
+ TestInitialize(psf);
+}
Modified: trunk/rostests/apitests/shell32/testlist.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/shell32/testlist…
==============================================================================
--- trunk/rostests/apitests/shell32/testlist.c [iso-8859-1] (original)
+++ trunk/rostests/apitests/shell32/testlist.c [iso-8859-1] Sat Nov 12 14:54:12 2016
@@ -3,6 +3,7 @@
#define STANDALONE
#include <wine/test.h>
+extern void func_CFSFolder(void);
extern void func_CMyComputer(void);
extern void func_CShellDesktop(void);
extern void func_CShellLink(void);
@@ -12,6 +13,7 @@
const struct test winetest_testlist[] =
{
+ { "CFSFolder", func_CFSFolder },
{ "CMyComputer", func_CMyComputer },
{ "CShellDesktop", func_CShellDesktop },
{ "CShellLink", func_CShellLink },