ReactOS 0.4.15-dev-7953-g1f49173
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 <stdio.h>
13#include <shellutils.h>
14
15#define INVALID_POINTER ((PVOID)(ULONG_PTR)0xdeadbeefdeadbeefULL)
16
17static
18VOID
20 _In_ IShellFolder2 *psf2)
21{
22 HRESULT hr;
23 CComPtr<IDropTarget> pdt;
24 CComPtr<IDropTarget> pdt_2;
25 CComPtr<IContextMenu> pcm;
26 CComPtr<IContextMenu> pcm_2;
27 CComPtr<IShellView> psv;
28 CComPtr<IShellView> psv_2;
29
30 hr = psf2->CreateViewObject(NULL, IID_PPV_ARG(IDropTarget, &pdt));
31 ok(hr == S_OK, "hr = %lx\n", hr);
32
33 hr = psf2->CreateViewObject(NULL, IID_PPV_ARG(IDropTarget, &pdt_2));
34 ok(hr == S_OK, "hr = %lx\n", hr);
35 ok(pdt != pdt_2, "Expected %p != %p\n", static_cast<PVOID>(pdt), static_cast<PVOID>(pdt_2));
36
37 hr = psf2->CreateViewObject(NULL, IID_PPV_ARG(IContextMenu, &pcm));
38 ok(hr == S_OK, "hr = %lx\n", hr);
39
40 hr = psf2->CreateViewObject(NULL, IID_PPV_ARG(IContextMenu, &pcm_2));
41 ok(hr == S_OK, "hr = %lx\n", hr);
42 ok(pcm != pcm_2, "Expected %p != %p\n", static_cast<PVOID>(pcm), static_cast<PVOID>(pcm_2));
43
44 hr = psf2->CreateViewObject(NULL, IID_PPV_ARG(IShellView, &psv));
45 ok(hr == S_OK, "hr = %lx\n", hr);
46
47 hr = psf2->CreateViewObject(NULL, IID_PPV_ARG(IShellView, &psv_2));
48 ok(hr == S_OK, "hr = %lx\n", hr);
49 ok(psv != psv_2, "Expected %p != %p\n", static_cast<PVOID>(psv), static_cast<PVOID>(psv_2));
50}
51
53{
54 CComPtr<IPersistFolder2> ppf2;
56 ok(hr == S_OK, "hr = %lx\n", hr);
57
58 hr = ppf2->Initialize(NULL);
59 ok(hr == S_OK, "hr = %lx\n", hr);
60
61 hr = ppf2->Initialize((LPCITEMIDLIST)INVALID_POINTER);
62 ok(hr == S_OK, "hr = %lx\n", hr);
63
64 //crashes in xp
65 //hr = ppf2->GetCurFolder(NULL);
66 //ok(hr == E_INVALIDARG, "hr = %lx\n", hr);
67
68 CComHeapPtr<ITEMIDLIST> pidl;
69 hr = ppf2->GetCurFolder(&pidl);
70 ok(hr == S_OK, "hr = %lx\n", hr);
71 // 0 in win10, 14 in xp
72 ok(pidl->mkid.cb == 0x14, "expected empty pidl got cb = %x\n", pidl->mkid.cb);
73}
74
75START_TEST(CMyComputer)
76{
77 HRESULT hr;
78 CComPtr<IShellFolder2> psf2;
79 CComPtr<IShellFolder2> psf2_2;
80 CComPtr<IShellFolder> psf;
81
83
84 hr = CoCreateInstance(CLSID_MyComputer,
85 NULL,
86 CLSCTX_INPROC_SERVER,
88 ok(hr == S_OK, "hr = %lx\n", hr);
89 if (FAILED(hr))
90 {
91 skip("Could not instantiate CShellDesktop\n");
92 return;
93 }
94
95 /* second create should give us a pointer to the same object */
96 hr = CoCreateInstance(CLSID_MyComputer,
97 NULL,
98 CLSCTX_INPROC_SERVER,
99 IID_PPV_ARG(IShellFolder2, &psf2_2));
100 ok(hr == S_OK, "hr = %lx\n", hr);
101 ok(psf2 == psf2_2, "Expected %p == %p\n", static_cast<PVOID>(psf2), static_cast<PVOID>(psf2_2));
102
103 TestShellFolder(psf2);
104 TestInitialize(psf2);
105}
static VOID TestShellFolder(_In_ IShellFolder2 *psf2)
Definition: CMyComputer.cpp:19
#define INVALID_POINTER
Definition: CMyComputer.cpp:15
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define START_TEST(x)
Definition: atltest.h:75
#define NULL
Definition: types.h:112
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
HRESULT WINAPI DECLSPEC_HOTPATCH CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit)
Definition: compobj.c:2002
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
VOID TestInitialize()
Definition: CFSFolder.cpp:105
#define _In_
Definition: ms_sal.h:308
@ COINIT_APARTMENTTHREADED
Definition: objbase.h:278
HRESULT hr
Definition: shlfolder.c:183
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
#define IID_PPV_ARG(Itype, ppType)