mshtml: Added IOmHistory::get_length implementation.
[wine.git] / dlls / fusion / tests / fusion.c
blob3fc67ef2b91d18a3e39038d37e2686d0f0ca1b41
1 /*
2 * Copyright 2008 James Hawkins
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 <windows.h>
20 #include <fusion.h>
22 #include "wine/test.h"
24 static HMODULE hmscoree;
26 static HRESULT (WINAPI *pGetCachePath)(ASM_CACHE_FLAGS dwCacheFlags,
27 LPWSTR pwzCachePath, PDWORD pcchPath);
28 static HRESULT (WINAPI *pLoadLibraryShim)(LPCWSTR szDllName, LPCWSTR szVersion,
29 LPVOID pvReserved, HMODULE *phModDll);
30 static HRESULT (WINAPI *pGetCORVersion)(LPWSTR pbuffer, DWORD cchBuffer,
31 DWORD *dwLength);
33 static BOOL init_functionpointers(void)
35 HRESULT hr;
36 HMODULE hfusion;
38 static const WCHAR szFusion[] = {'f','u','s','i','o','n','.','d','l','l',0};
40 hmscoree = LoadLibraryA("mscoree.dll");
41 if (!hmscoree)
43 win_skip("mscoree.dll not available\n");
44 return FALSE;
47 pLoadLibraryShim = (void *)GetProcAddress(hmscoree, "LoadLibraryShim");
48 if (!pLoadLibraryShim)
50 win_skip("LoadLibraryShim not available\n");
51 FreeLibrary(hmscoree);
52 return FALSE;
55 pGetCORVersion = (void *)GetProcAddress(hmscoree, "GetCORVersion");
57 hr = pLoadLibraryShim(szFusion, NULL, NULL, &hfusion);
58 if (FAILED(hr))
60 win_skip("fusion.dll not available\n");
61 FreeLibrary(hmscoree);
62 return FALSE;
65 pGetCachePath = (void *)GetProcAddress(hfusion, "GetCachePath");
66 return TRUE;
69 static void test_GetCachePath(void)
71 CHAR windirA[MAX_PATH];
72 WCHAR windir[MAX_PATH];
73 WCHAR cachepath[MAX_PATH];
74 WCHAR version[MAX_PATH];
75 WCHAR path[MAX_PATH];
76 DWORD size;
77 HRESULT hr;
79 static const WCHAR backslash[] = {'\\',0};
80 static const WCHAR nochange[] = {'n','o','c','h','a','n','g','e',0};
81 static const WCHAR assembly[] = {'a','s','s','e','m','b','l','y',0};
82 static const WCHAR gac[] = {'G','A','C',0};
84 if (!pGetCachePath)
86 win_skip("GetCachePath not implemented\n");
87 return;
90 GetWindowsDirectoryA(windirA, MAX_PATH);
91 MultiByteToWideChar(CP_ACP, 0, windirA, -1, windir, MAX_PATH);
92 lstrcpyW(cachepath, windir);
93 lstrcatW(cachepath, backslash);
94 lstrcatW(cachepath, assembly);
95 lstrcatW(cachepath, backslash);
96 lstrcatW(cachepath, gac);
98 /* NULL pwzCachePath, pcchPath is 0 */
99 size = 0;
100 hr = pGetCachePath(ASM_CACHE_GAC, NULL, &size);
101 ok(hr == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER),
102 "Expected HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), got %08x\n", hr);
103 ok(size == lstrlenW(cachepath) + 1,
104 "Expected %d, got %d\n", lstrlenW(cachepath) + 1, size);
106 /* NULL pwszCachePath, pcchPath is MAX_PATH */
107 size = MAX_PATH;
108 hr = pGetCachePath(ASM_CACHE_GAC, NULL, &size);
109 ok(hr == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER),
110 "Expected HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), got %08x\n", hr);
111 ok(size == lstrlenW(cachepath) + 1,
112 "Expected %d, got %d\n", lstrlenW(cachepath) + 1, size);
114 /* both pwszCachePath and pcchPath NULL */
115 hr = pGetCachePath(ASM_CACHE_GAC, NULL, NULL);
116 ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr);
118 /* NULL pcchPath */
119 lstrcpyW(path, nochange);
120 hr = pGetCachePath(ASM_CACHE_GAC, path, NULL);
121 ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr);
122 ok( !lstrcmpW( nochange, path ), "Expected %s, got %s\n", wine_dbgstr_w(nochange), wine_dbgstr_w(path));
124 /* get the cache path */
125 lstrcpyW(path, nochange);
126 size = MAX_PATH;
127 hr = pGetCachePath(ASM_CACHE_GAC, path, &size);
128 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
129 ok( !lstrcmpW( cachepath, path ), "Expected %s, got %s\n", wine_dbgstr_w(cachepath), wine_dbgstr_w(path));
131 /* pcchPath has no room for NULL terminator */
132 lstrcpyW(path, nochange);
133 size = lstrlenW(cachepath);
134 hr = pGetCachePath(ASM_CACHE_GAC, path, &size);
135 ok(hr == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER),
136 "Expected HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), got %08x\n", hr);
137 ok( !lstrcmpW( nochange, path ), "Expected %s, got %s\n", wine_dbgstr_w(nochange), wine_dbgstr_w(path));
139 lstrcpyW(cachepath, windir);
140 lstrcatW(cachepath, backslash);
141 lstrcatW(cachepath, assembly);
143 /* ASM_CACHE_ROOT */
144 lstrcpyW(path, nochange);
145 size = MAX_PATH;
146 hr = pGetCachePath(ASM_CACHE_ROOT, path, &size);
147 ok(hr == S_OK ||
148 broken(hr == E_INVALIDARG), /* .NET 1.1 */
149 "Expected S_OK, got %08x\n", hr);
150 if (hr == S_OK)
151 ok( !lstrcmpW( cachepath, path ), "Expected %s, got %s\n", wine_dbgstr_w(cachepath), wine_dbgstr_w(path));
153 if (pGetCORVersion)
155 CHAR versionA[MAX_PATH];
156 CHAR cachepathA[MAX_PATH];
157 CHAR nativeimgA[MAX_PATH];
158 CHAR zapfmtA[MAX_PATH];
160 if (hr == S_OK)
162 lstrcpyA(nativeimgA, "NativeImages_");
163 #ifdef _WIN64
164 lstrcpyA(zapfmtA, "%s\\%s\\%s%s_64");
165 #else
166 lstrcpyA(zapfmtA, "%s\\%s\\%s%s_32");
167 #endif
169 else
171 lstrcpyA(nativeimgA, "NativeImages1_");
172 lstrcpyA(zapfmtA, "%s\\%s\\%s%s");
175 pGetCORVersion(version, MAX_PATH, &size);
176 WideCharToMultiByte(CP_ACP, 0, version, -1, versionA, MAX_PATH, 0, 0);
178 wsprintfA(cachepathA, zapfmtA, windirA, "assembly", nativeimgA, versionA);
179 MultiByteToWideChar(CP_ACP, 0, cachepathA, -1, cachepath, MAX_PATH);
181 /* ASM_CACHE_ZAP */
182 lstrcpyW(path, nochange);
183 size = MAX_PATH;
184 hr = pGetCachePath(ASM_CACHE_ZAP, path, &size);
185 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
186 ok( !lstrcmpW( cachepath, path ), "Expected %s, got %s\n", wine_dbgstr_w(cachepath), wine_dbgstr_w(path));
189 /* two flags at once */
190 lstrcpyW(path, nochange);
191 size = MAX_PATH;
192 hr = pGetCachePath(ASM_CACHE_GAC | ASM_CACHE_ROOT, path, &size);
193 ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr);
194 ok( !lstrcmpW( nochange, path ), "Expected %s, got %s\n", wine_dbgstr_w(nochange), wine_dbgstr_w(path));
197 START_TEST(fusion)
199 if (!init_functionpointers())
200 return;
202 test_GetCachePath();
204 FreeLibrary(hmscoree);