directmanipulation: Return S_OK form viewport_SetViewportOptions stub.
[wine/zf.git] / dlls / activeds / tests / activeds.c
blobc2dc3d58c4bd4c15a457efaade984420b55f7cd6
1 /*
2 * Copyright 2020 Dmitry Timoshkov
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include <stdarg.h>
20 #include <stdio.h>
22 #define COBJMACROS
24 #include "windef.h"
25 #include "winbase.h"
26 #include "objbase.h"
27 #include "initguid.h"
28 #include "iads.h"
29 #include "adshlp.h"
30 #include "adserr.h"
32 #include "wine/test.h"
34 DEFINE_GUID(CLSID_Pathname,0x080d0d78,0xf421,0x11d0,0xa3,0x6e,0x00,0xc0,0x4f,0xb9,0x50,0xdc);
36 static void test_ADsBuildVarArrayStr(void)
38 const WCHAR *props[] = { L"prop1", L"prop2" };
39 HRESULT hr;
40 VARIANT var, item, *data;
41 LONG start, end, idx;
43 hr = ADsBuildVarArrayStr(NULL, 0, NULL);
44 ok(hr == E_ADS_BAD_PARAMETER || hr == E_FAIL /* XP */, "got %#x\n", hr);
46 hr = ADsBuildVarArrayStr(NULL, 0, &var);
47 ok(hr == S_OK, "got %#x\n", hr);
48 ok(V_VT(&var) == (VT_ARRAY | VT_VARIANT), "got %d\n", V_VT(&var));
49 start = 0xdeadbeef;
50 hr = SafeArrayGetLBound(V_ARRAY(&var), 1, &start);
51 ok(hr == S_OK, "got %#x\n", hr);
52 ok(start == 0, "got %d\n", start);
53 end = 0xdeadbeef;
54 hr = SafeArrayGetUBound(V_ARRAY(&var), 1, &end);
55 ok(hr == S_OK, "got %#x\n", hr);
56 ok(end == -1, "got %d\n", end);
57 VariantClear(&var);
59 hr = ADsBuildVarArrayStr((LPWSTR *)props, ARRAY_SIZE(props), &var);
60 ok(hr == S_OK, "got %#x\n", hr);
61 ok(V_VT(&var) == (VT_ARRAY | VT_VARIANT), "got %d\n", V_VT(&var));
62 start = 0xdeadbeef;
63 hr = SafeArrayGetLBound(V_ARRAY(&var), 1, &start);
64 ok(hr == S_OK, "got %#x\n", hr);
65 ok(start == 0, "got %d\n", start);
66 end = 0xdeadbeef;
67 hr = SafeArrayGetUBound(V_ARRAY(&var), 1, &end);
68 ok(hr == S_OK, "got %#x\n", hr);
69 ok(end == 1, "got %d\n", end);
70 idx = 0;
71 hr = SafeArrayGetElement(V_ARRAY(&var), &idx, &item);
72 ok(hr == S_OK, "got %#x\n", hr);
73 ok(V_VT(&item) == VT_BSTR, "got %d\n", V_VT(&item));
74 ok(!lstrcmpW(V_BSTR(&item), L"prop1"), "got %s\n", wine_dbgstr_w(V_BSTR(&item)));
75 VariantClear(&item);
76 hr = SafeArrayAccessData(V_ARRAY(&var), (void *)&data);
77 ok(hr == S_OK, "got %#x\n", hr);
78 ok(V_VT(&data[0]) == VT_BSTR, "got %d\n", V_VT(&data[0]));
79 ok(!lstrcmpW(V_BSTR(&data[0]), L"prop1"), "got %s\n", wine_dbgstr_w(V_BSTR(&data[0])));
80 ok(V_VT(&data[0]) == VT_BSTR, "got %d\n", V_VT(&data[0]));
81 ok(!lstrcmpW(V_BSTR(&data[1]), L"prop2"), "got %s\n", wine_dbgstr_w(V_BSTR(&data[1])));
82 hr = SafeArrayUnaccessData(V_ARRAY(&var));
83 ok(hr == S_OK, "got %#x\n", hr);
84 VariantClear(&var);
87 static void test_Pathname(void)
89 static const WCHAR * const elem[3] = { L"a=b",L"c=d",L"e=f" };
90 HRESULT hr;
91 IADsPathname *path;
92 BSTR bstr;
93 LONG count, i;
95 hr = CoCreateInstance(&CLSID_Pathname, 0, CLSCTX_INPROC_SERVER, &IID_IADsPathname, (void **)&path);
96 ok(hr == S_OK, "got %#x\n", hr);
98 count = 0xdeadbeef;
99 hr = IADsPathname_GetNumElements(path, &count);
100 ok(hr == S_OK, "got %#x\n", hr);
101 ok(count == 0, "got %d\n", count);
103 bstr = NULL;
104 hr = IADsPathname_Retrieve(path, ADS_FORMAT_X500, &bstr);
105 ok(hr == S_OK, "got %#x\n", hr);
106 ok(bstr && !wcscmp(bstr, L"LDAP://"), "got %s\n", wine_dbgstr_w(bstr));
107 SysFreeString(bstr);
109 bstr = SysAllocString(L"LDAP://sample");
110 hr = IADsPathname_Set(path, bstr, ADS_SETTYPE_FULL);
111 ok(hr == S_OK, "got %#x\n", hr);
112 SysFreeString(bstr);
114 count = 0xdeadbeef;
115 hr = IADsPathname_GetNumElements(path, &count);
116 ok(hr == S_OK, "got %#x\n", hr);
117 ok(count == 0, "got %d\n", count);
119 hr = IADsPathname_GetElement(path, 0, &bstr);
120 ok(hr == HRESULT_FROM_WIN32(ERROR_INVALID_INDEX), "got %#x\n", hr);
121 SysFreeString(bstr);
123 bstr = SysAllocString(L"LDAP://sample:123/a=b,c=d,e=f");
124 hr = IADsPathname_Set(path, bstr, ADS_SETTYPE_FULL);
125 ok(hr == S_OK, "got %#x\n", hr);
126 SysFreeString(bstr);
128 count = 0xdeadbeef;
129 hr = IADsPathname_GetNumElements(path, &count);
130 ok(hr == S_OK, "got %#x\n", hr);
131 ok(count == 3, "got %d\n", count);
133 for (i = 0; i < count; i++)
135 hr = IADsPathname_GetElement(path, i, &bstr);
136 ok(hr == S_OK, "got %#x\n", hr);
137 ok(!wcscmp(bstr, elem[i]), "%u: %s\n", i, wine_dbgstr_w(bstr));
138 SysFreeString(bstr);
141 hr = IADsPathname_Retrieve(path, ADS_FORMAT_X500, &bstr);
142 ok(hr == S_OK, "got %#x\n", hr);
143 ok(!wcscmp(bstr, L"LDAP://sample:123/a=b,c=d,e=f"), "got %s\n", wine_dbgstr_w(bstr));
144 SysFreeString(bstr);
146 hr = IADsPathname_Retrieve(path, ADS_FORMAT_PROVIDER, &bstr);
147 ok(hr == S_OK, "got %#x\n", hr);
148 ok(!wcscmp(bstr, L"LDAP"), "got %s\n", wine_dbgstr_w(bstr));
149 SysFreeString(bstr);
151 hr = IADsPathname_Retrieve(path, ADS_FORMAT_SERVER, &bstr);
152 ok(hr == S_OK, "got %#x\n", hr);
153 ok(!wcscmp(bstr, L"sample:123"), "got %s\n", wine_dbgstr_w(bstr));
154 SysFreeString(bstr);
156 hr = IADsPathname_Retrieve(path, ADS_FORMAT_LEAF, &bstr);
157 ok(hr == S_OK, "got %#x\n", hr);
158 ok(!wcscmp(bstr, L"a=b"), "got %s\n", wine_dbgstr_w(bstr));
159 SysFreeString(bstr);
161 IADsPathname_Release(path);
164 START_TEST(activeds)
166 CoInitialize(NULL);
168 test_Pathname();
169 test_ADsBuildVarArrayStr();
171 CoUninitialize();