ReactOS 0.4.16-dev-125-g798ea90
browse_ctx.c File Reference
#include <stdio.h>
#include <hlink.h>
#include "wine/test.h"
Include dependency graph for browse_ctx.c:

Go to the source code of this file.

Macros

#define COBJMACROS
 

Functions

static void test_SetInitialHlink (void)
 
static void test_BrowseWindowInfo (void)
 
static HRESULT WINAPI Unknown_QueryInterface (IUnknown *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI Unknown_AddRef (IUnknown *iface)
 
static ULONG WINAPI Unknown_Release (IUnknown *iface)
 
static void test_GetObject (void)
 
 START_TEST (browse_ctx)
 

Variables

static IUnknownVtbl UnknownVtbl
 
static IUnknown Unknown = { &UnknownVtbl }
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 19 of file browse_ctx.c.

Function Documentation

◆ START_TEST()

START_TEST ( browse_ctx  )

Definition at line 200 of file browse_ctx.c.

201{
203
207
209}
#define NULL
Definition: types.h:112
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067

◆ test_BrowseWindowInfo()

static void test_BrowseWindowInfo ( void  )
static

Definition at line 86 of file browse_ctx.c.

87{
89 HLBWINFO bwinfo_set, bwinfo_get;
91
92 hres = HlinkCreateBrowseContext(NULL, &IID_IHlinkBrowseContext, (void**)&bc);
93 ok(hres == S_OK, "HlinkCreateBrowseContext failed: 0x%08x\n", hres);
94
95 hres = IHlinkBrowseContext_GetBrowseWindowInfo(bc, NULL);
96 ok(hres == E_INVALIDARG, "GetBrowseWindow failed with wrong code: 0x%08x\n", hres);
97
98 hres = IHlinkBrowseContext_SetBrowseWindowInfo(bc, NULL);
99 ok(hres == E_INVALIDARG, "SetBrowseWindow failed with wrong code: 0x%08x\n", hres);
100
101 memset(&bwinfo_get, -1, sizeof(HLBWINFO));
102
103 hres = IHlinkBrowseContext_GetBrowseWindowInfo(bc, &bwinfo_get);
104 ok(hres == S_OK, "GetBrowseWindowInfo failed: 0x%08x\n", hres);
105 ok(bwinfo_get.cbSize == 0, "Got wrong size: %x\n", bwinfo_get.cbSize);
106
107 bwinfo_set.cbSize = sizeof(HLBWINFO);
108 bwinfo_set.grfHLBWIF = HLBWIF_WEBTOOLBARHIDDEN;
109 bwinfo_set.rcFramePos.left = 1;
110 bwinfo_set.rcFramePos.right = 2;
111 bwinfo_set.rcFramePos.top = 3;
112 bwinfo_set.rcFramePos.bottom = 4;
113 bwinfo_set.rcDocPos.left = 5;
114 bwinfo_set.rcDocPos.right = 6;
115 bwinfo_set.rcDocPos.top = 7;
116 bwinfo_set.rcDocPos.bottom = 8;
117 bwinfo_set.hltbinfo.uDockType = 4321;
118 bwinfo_set.hltbinfo.rcTbPos.left = 9;
119 bwinfo_set.hltbinfo.rcTbPos.right = 10;
120 bwinfo_set.hltbinfo.rcTbPos.top = 11;
121 bwinfo_set.hltbinfo.rcTbPos.bottom = 12;
122 hres = IHlinkBrowseContext_SetBrowseWindowInfo(bc, &bwinfo_set);
123 ok(hres == S_OK, "SetBrowseWindowInfo failed: 0x%08x\n", hres);
124
125 memset(&bwinfo_get, 0, sizeof(HLBWINFO));
126
127 hres = IHlinkBrowseContext_GetBrowseWindowInfo(bc, &bwinfo_get);
128 ok(hres == S_OK, "GetBrowseWindowInfo failed: 0x%08x\n", hres);
129 ok(!memcmp(&bwinfo_set, &bwinfo_get, sizeof(HLBWINFO)), "Set and Get differ\n");
130
131 IHlinkBrowseContext_Release(bc);
132}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define ok(value,...)
Definition: atltest.h:57
PBATCH_CONTEXT bc
Definition: batch.c:67
#define E_INVALIDARG
Definition: ddrawi.h:101
#define S_OK
Definition: intsafe.h:52
HRESULT hres
Definition: protocol.c:465
#define memset(x, y, z)
Definition: compat.h:39

Referenced by START_TEST().

◆ test_GetObject()

static void test_GetObject ( void  )
static

Definition at line 164 of file browse_ctx.c.

165{
168 IUnknown *unk;
169 WCHAR one[] = {'1',0};
170 WCHAR five[] = {'5',0};
173
174 hres = CreateItemMoniker(one, five, &dummy);
175 ok(hres == S_OK, "CreateItemMoniker() failed: 0x%08x\n", hres);
176
177 hres = HlinkCreateBrowseContext(NULL, &IID_IHlinkBrowseContext, (void **)&bc);
178 ok(hres == S_OK, "HlinkCreateBrowseContext() failed: 0x%08x\n", hres);
179
180 hres = IHlinkBrowseContext_GetObject(bc, dummy, FALSE, &unk);
181 ok(hres == MK_E_UNAVAILABLE, "expected MK_E_UNAVAILABLE, got 0x%08x\n", hres);
182
183 hres = IHlinkBrowseContext_Register(bc, 0, &Unknown, dummy, &cookie);
184 ok(hres == S_OK, "Register() failed: 0x%08x\n", hres);
185
186 hres = IHlinkBrowseContext_GetObject(bc, dummy, FALSE, &unk);
187 ok(hres == S_OK, "GetObject() failed: 0x%08x\n", hres);
188 ok(unk == &Unknown, "wrong object returned\n");
189
190 hres = IHlinkBrowseContext_Revoke(bc, cookie);
191 ok(hres == S_OK, "Revoke() failed: 0x%08x\n", hres);
192
193 hres = IHlinkBrowseContext_GetObject(bc, dummy, FALSE, &unk);
194 ok(hres == MK_E_UNAVAILABLE, "expected MK_E_UNAVAILABLE, got 0x%08x\n", hres);
195
196 IHlinkBrowseContext_Release(bc);
197 IMoniker_Release(dummy);
198}
#define FALSE
Definition: types.h:117
unsigned long DWORD
Definition: ntddk_ex.h:95
HRESULT WINAPI CreateItemMoniker(LPCOLESTR lpszDelim, LPCOLESTR lpszItem, IMoniker **ppmk)
Definition: itemmoniker.c:935
int one
Definition: sehframes.cpp:28
Definition: cookie.c:34
#define MK_E_UNAVAILABLE
Definition: winerror.h:2784
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by START_TEST().

◆ test_SetInitialHlink()

static void test_SetInitialHlink ( void  )
static

Definition at line 27 of file browse_ctx.c.

28{
30 IHlink *found_hlink;
31 IMoniker *dummy, *found_moniker;
32 IBindCtx *bindctx;
33 WCHAR one[] = {'1',0};
34 WCHAR five[] = {'5',0};
35 WCHAR *found_name, *exp_name;
37
38 hres = CreateBindCtx(0, &bindctx);
39 ok(hres == S_OK, "CreateBindCtx failed: 0x%08x\n", hres);
40
42 ok(hres == S_OK, "CreateItemMoniker failed: 0x%08x\n", hres);
43
44 hres = IMoniker_GetDisplayName(dummy, bindctx, NULL, &exp_name);
45 ok(hres == S_OK, "GetDisplayName failed: 0x%08x\n", hres);
46
47 hres = HlinkCreateBrowseContext(NULL, &IID_IHlinkBrowseContext, (void**)&bc);
48 ok(hres == S_OK, "HlinkCreateBrowseContext failed: 0x%08x\n", hres);
49
50 hres = IHlinkBrowseContext_SetInitialHlink(bc, dummy, one, NULL);
51 ok(hres == S_OK, "SetInitialHlink failed: 0x%08x\n", hres);
52
53 hres = IHlinkBrowseContext_SetInitialHlink(bc, dummy, one, NULL);
54 ok(hres == CO_E_ALREADYINITIALIZED, "got 0x%08x\n", hres);
55
56 hres = IHlinkBrowseContext_SetInitialHlink(bc, dummy, five, NULL);
57 ok(hres == CO_E_ALREADYINITIALIZED, "got 0x%08x\n", hres);
58
59 /* there's only one */
60 hres = IHlinkBrowseContext_GetHlink(bc, HLID_PREVIOUS, &found_hlink);
61 ok(hres == E_FAIL, "got 0x%08x\n", hres);
62
63 hres = IHlinkBrowseContext_GetHlink(bc, HLID_NEXT, &found_hlink);
64 ok(hres == E_FAIL, "got 0x%08x\n", hres);
65
66 hres = IHlinkBrowseContext_GetHlink(bc, HLID_CURRENT, &found_hlink);
67 ok(hres == S_OK, "GetHlink failed: 0x%08x\n", hres);
68
69 hres = IHlink_GetMonikerReference(found_hlink, HLINKGETREF_DEFAULT, &found_moniker, NULL);
70 ok(hres == S_OK, "GetMonikerReference failed: 0x%08x\n", hres);
71
72 hres = IMoniker_GetDisplayName(found_moniker, bindctx, NULL, &found_name);
73 ok(hres == S_OK, "GetDisplayName failed: 0x%08x\n", hres);
74 ok(!lstrcmpW(found_name, exp_name), "Found display name should have been %s, was: %s\n", wine_dbgstr_w(exp_name), wine_dbgstr_w(found_name));
75
76 CoTaskMemFree(exp_name);
77 CoTaskMemFree(found_name);
78
79 IBindCtx_Release(bindctx);
80 IMoniker_Release(found_moniker);
81 IHlink_Release(found_hlink);
82 IHlinkBrowseContext_Release(bc);
83 IMoniker_Release(dummy);
84}
#define E_FAIL
Definition: ddrawi.h:102
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4242
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
#define wine_dbgstr_w
Definition: kernel32.h:34
HRESULT WINAPI CreateBindCtx(DWORD reserved, LPBC *ppbc)
Definition: bindctx.c:556
#define CO_E_ALREADYINITIALIZED
Definition: winerror.h:2804

Referenced by START_TEST().

◆ Unknown_AddRef()

static ULONG WINAPI Unknown_AddRef ( IUnknown iface)
static

Definition at line 146 of file browse_ctx.c.

147{
148 return 2;
149}

◆ Unknown_QueryInterface()

static HRESULT WINAPI Unknown_QueryInterface ( IUnknown iface,
REFIID  riid,
void **  ppv 
)
static

Definition at line 134 of file browse_ctx.c.

135{
136 *ppv = NULL;
137
139 {
140 *ppv = iface;
141 return S_OK;
142 }
143 return E_NOINTERFACE;
144}
const GUID IID_IUnknown
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define E_NOINTERFACE
Definition: winerror.h:2364

◆ Unknown_Release()

static ULONG WINAPI Unknown_Release ( IUnknown iface)
static

Definition at line 151 of file browse_ctx.c.

152{
153 return 1;
154}

Variable Documentation

◆ Unknown

IUnknown Unknown = { &UnknownVtbl }
static

Definition at line 162 of file browse_ctx.c.

Referenced by test_GetObject().

◆ UnknownVtbl

IUnknownVtbl UnknownVtbl
static
Initial value:
= {
}

Definition at line 156 of file browse_ctx.c.