4 * Copyright 2004 Robert Shearman
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 #include "wine/test.h"
33 #define ok_ole_success(hr, func) ok(hr == S_OK, #func " failed with error 0x%08lx\n", hr)
35 static void test_MkParseDisplayName()
37 IBindCtx * pbc = NULL;
39 IMoniker * pmk = NULL;
41 IUnknown * object = NULL;
42 /* CLSID of My Computer */
43 static const WCHAR wszDisplayName[] = {'c','l','s','i','d',':',
44 '2','0','D','0','4','F','E','0','-','3','A','E','A','-','1','0','6','9','-','A','2','D','8','-','0','8','0','0','2','B','3','0','3','0','9','D',':',0};
46 hr = CreateBindCtx(0, &pbc);
47 ok_ole_success(hr, CreateBindCtx);
49 hr = MkParseDisplayName(pbc, wszDisplayName, &eaten, &pmk);
50 todo_wine { ok_ole_success(hr, MkParseDisplayName); }
54 hr = IMoniker_BindToObject(pmk, pbc, NULL, &IID_IUnknown, (LPVOID*)&object);
55 ok_ole_success(hr, IMoniker_BindToObject);
57 IUnknown_Release(object);
59 IBindCtx_Release(pbc);
62 static const BYTE expected_moniker_data[] =
64 0x4d,0x45,0x4f,0x57,0x04,0x00,0x00,0x00,
65 0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
66 0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46,
67 0x1a,0x03,0x00,0x00,0x00,0x00,0x00,0x00,
68 0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46,
69 0x00,0x00,0x00,0x00,0x14,0x00,0x00,0x00,
70 0x05,0xe0,0x02,0x00,0x00,0x00,0x00,0x00,
71 0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46,
75 static const LARGE_INTEGER llZero;
77 static void test_class_moniker()
88 hr = CreateClassMoniker(&CLSID_StdComponentCategoriesMgr, &moniker);
89 todo_wine { ok_ole_success(hr, CreateClassMoniker); }
91 hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
93 hr = CoMarshalInterface(stream, &IID_IMoniker, (IUnknown *)moniker, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
94 todo_wine { ok_ole_success(hr, CoMarshalInterface); }
96 hr = GetHGlobalFromStream(stream, &hglobal);
97 ok_ole_success(hr, GetHGlobalFromStream);
99 moniker_size = GlobalSize(hglobal);
101 moniker_data = GlobalLock(hglobal);
103 /* first check we have the right amount of data */
105 ok(moniker_size == sizeof(expected_moniker_data),
106 "Size of marshaled data differs (expected %d, actual %ld)\n",
107 sizeof(expected_moniker_data), moniker_size);
110 /* then do a byte-by-byte comparison */
111 for (i = 0; i < min(moniker_size, sizeof(expected_moniker_data)); i++)
113 if (expected_moniker_data[i] != moniker_data[i])
120 ok(same, "Marshaled data differs\n");
123 trace("Dumping marshaled moniker data:\n");
124 for (i = 0; i < moniker_size; i++)
126 trace("0x%02x,", moniker_data[i]);
127 if (i % 8 == 7) trace("\n");
128 if (i % 8 == 0) trace(" ");
132 GlobalUnlock(hglobal);
134 IStream_Seek(stream, llZero, STREAM_SEEK_SET, NULL);
135 hr = CoReleaseMarshalData(stream);
136 todo_wine { ok_ole_success(hr, CoReleaseMarshalData); }
138 IStream_Release(stream);
139 if (moniker) IMoniker_Release(moniker);
144 CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
146 test_MkParseDisplayName();
147 test_class_moniker();
148 /* FIXME: test moniker creation funcs and parsing other moniker formats */