ReactOS  0.4.12-dev-685-gf36cbf7
CMyComputer.cpp
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS api tests
3  * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory
4  * PURPOSE: Test for CMyComputer
5  * PROGRAMMER: Thomas Faber <thomas.faber@reactos.org>
6  */
7 
8 #include "shelltest.h"
9 
10 #define NDEBUG
11 #include <debug.h>
12 #include <shellutils.h>
13 
14 #define INVALID_POINTER ((PVOID)(ULONG_PTR)0xdeadbeefdeadbeefULL)
15 
16 static
17 VOID
19  _In_ IShellFolder2 *psf2)
20 {
21  HRESULT hr;
22  CComPtr<IDropTarget> pdt;
23  CComPtr<IDropTarget> pdt_2;
24  CComPtr<IContextMenu> pcm;
25  CComPtr<IContextMenu> pcm_2;
26  CComPtr<IShellView> psv;
27  CComPtr<IShellView> psv_2;
28 
29  hr = psf2->CreateViewObject(NULL, IID_PPV_ARG(IDropTarget, &pdt));
30  ok(hr == S_OK, "hr = %lx\n", hr);
31 
32  hr = psf2->CreateViewObject(NULL, IID_PPV_ARG(IDropTarget, &pdt_2));
33  ok(hr == S_OK, "hr = %lx\n", hr);
34  ok(pdt != pdt_2, "Expected %p != %p\n", static_cast<PVOID>(pdt), static_cast<PVOID>(pdt_2));
35 
36  hr = psf2->CreateViewObject(NULL, IID_PPV_ARG(IContextMenu, &pcm));
37  ok(hr == S_OK, "hr = %lx\n", hr);
38 
39  hr = psf2->CreateViewObject(NULL, IID_PPV_ARG(IContextMenu, &pcm_2));
40  ok(hr == S_OK, "hr = %lx\n", hr);
41  ok(pcm != pcm_2, "Expected %p != %p\n", static_cast<PVOID>(pcm), static_cast<PVOID>(pcm_2));
42 
43  hr = psf2->CreateViewObject(NULL, IID_PPV_ARG(IShellView, &psv));
44  ok(hr == S_OK, "hr = %lx\n", hr);
45 
46  hr = psf2->CreateViewObject(NULL, IID_PPV_ARG(IShellView, &psv_2));
47  ok(hr == S_OK, "hr = %lx\n", hr);
48  ok(psv != psv_2, "Expected %p != %p\n", static_cast<PVOID>(psv), static_cast<PVOID>(psv_2));
49 }
50 
52 {
53  CComPtr<IPersistFolder2> ppf2;
54  HRESULT hr = psf2->QueryInterface(IID_PPV_ARG(IPersistFolder2, &ppf2));
55  ok(hr == S_OK, "hr = %lx\n", hr);
56 
57  hr = ppf2->Initialize(NULL);
58  ok(hr == S_OK, "hr = %lx\n", hr);
59 
60  hr = ppf2->Initialize((LPCITEMIDLIST)INVALID_POINTER);
61  ok(hr == S_OK, "hr = %lx\n", hr);
62 
63  //crashes in xp
64  //hr = ppf2->GetCurFolder(NULL);
65  //ok(hr == E_INVALIDARG, "hr = %lx\n", hr);
66 
67  LPITEMIDLIST pidl;
68  hr = ppf2->GetCurFolder(&pidl);
69  ok(hr == S_OK, "hr = %lx\n", hr);
70  // 0 in win10, 14 in xp
71  ok(pidl->mkid.cb == 0x14, "expected empty pidl got cb = %x\n", pidl->mkid.cb);
72 }
73 
74 START_TEST(CMyComputer)
75 {
76  HRESULT hr;
77  CComPtr<IShellFolder2> psf2;
78  CComPtr<IShellFolder2> psf2_2;
79  CComPtr<IShellFolder> psf;
80 
82 
83  hr = CoCreateInstance(CLSID_MyComputer,
84  NULL,
85  CLSCTX_INPROC_SERVER,
86  IID_PPV_ARG(IShellFolder2, &psf2));
87  ok(hr == S_OK, "hr = %lx\n", hr);
88  if (FAILED(hr))
89  {
90  skip("Could not instantiate CShellDesktop\n");
91  return;
92  }
93 
94  /* second create should give us a pointer to the same object */
95  hr = CoCreateInstance(CLSID_MyComputer,
96  NULL,
97  CLSCTX_INPROC_SERVER,
98  IID_PPV_ARG(IShellFolder2, &psf2_2));
99  ok(hr == S_OK, "hr = %lx\n", hr);
100  ok(psf2 == psf2_2, "Expected %p == %p\n", static_cast<PVOID>(psf2), static_cast<PVOID>(psf2_2));
101 
102  TestShellFolder(psf2);
103  TestInitialize(psf2);
104 }
static VOID TestShellFolder(_In_ IShellFolder2 *psf2)
Definition: CMyComputer.cpp:18
HRESULT hr
Definition: shlfolder.c:183
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
#define IID_PPV_ARG(Itype, ppType)
smooth NULL
Definition: ftsmooth.c:416
#define ok(value,...)
Definition: CComObject.cpp:34
LONG HRESULT
Definition: typedefs.h:77
START_TEST(CMyComputer)
Definition: CMyComputer.cpp:74
VOID TestInitialize(_In_ IShellFolder2 *psf2)
Definition: CMyComputer.cpp:51
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3234
#define INVALID_POINTER
Definition: CMyComputer.cpp:14
#define _In_
Definition: no_sal2.h:204
#define S_OK
Definition: intsafe.h:59
#define skip(...)
Definition: CString.cpp:57
HRESULT WINAPI DECLSPEC_HOTPATCH CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit)
Definition: compobj.c:1935
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41