ReactOS  0.4.13-dev-39-g8b6696f
cache.c
Go to the documentation of this file.
1 /*
2  * Copyright 2012 Hans Leidekker for CodeWeavers
3  *
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.
8  *
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.
13  *
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
17  */
18 
19 #include <stdio.h>
20 
21 #define COBJMACROS
22 
23 #include <windows.h>
24 #include <winsxs.h>
25 
26 #include "wine/test.h"
27 
28 static void test_QueryAssemblyInfo( void )
29 {
30  static const WCHAR emptyW[] = {0};
31  static const WCHAR wine1W[] = {'w','i','n','e',0};
32  static const WCHAR wine2W[] =
33  {'w','i','n','e',',',
34  'v','e','r','s','i','o','n','=','\"','1','.','2','.','3','.','4','\"',0};
35  static const WCHAR wine3W[] =
36  {'w','i','n','e',',',
37  'v','e','r','s','i','o','n','=','\"','1','.','2','.','3','.','4','\"',',',
38  't','y','p','e','=','\"','w','i','n','3','2','\"',0};
39  static const WCHAR wine4W[] =
40  {'w','i','n','e',',',
41  'v','e','r','s','i','o','n','=','\"','1','.','2','.','3','.','4','\"',',',
42  't','y','p','e','=','\"','w','i','n','3','2','\"',',',
43  'p','r','o','c','e','s','s','o','r','A','r','c','h','i','t','e','c','t','u','r','e','=',
44  '\"','x','8','6','\"',0};
45  static const WCHAR wine5W[] =
46  {'w','i','n','e',',',
47  'v','e','r','s','i','o','n','=','\"','1','.','2','.','3','.','4','\"',',',
48  't','y','p','e','=','\"','w','i','n','3','2','\"',',',
49  'p','r','o','c','e','s','s','o','r','A','r','c','h','i','t','e','c','t','u','r','e','=',
50  '\"','x','8','6','\"',',','p','u','b','l','i','c','K','e','y','T','o','k','e','n','=',
51  '\"','1','2','3','4','5','6','7','8','9','0','a','b','c','d','e','f','\"',0};
52  static const WCHAR comctl1W[] =
53  {'m','i','c','r','o','s','o','f','t','.','w','i','n','d','o','w','s','.',
54  'c','o','m','m','o','n','-','c','o','n','t','r','o','l','s',',',
55  'v','e','r','s','i','o','n','=','\"','6','.','0','.','2','6','0','0','.','2','9','8','2','\"',',',
56  't','y','p','e','=','\"','w','i','n','3','2','\"',',',
57  'p','r','o','c','e','s','s','o','r','A','r','c','h','i','t','e','c','t','u','r','e','=',
58  '\"','x','8','6','\"',',','p','u','b','l','i','c','K','e','y','T','o','k','e','n','=',
59  '\"','6','5','9','5','b','6','4','1','4','4','c','c','f','1','d','f','\"',0};
60  static const WCHAR comctl2W[] =
61  {'m','i','c','r','o','s','o','f','t','.','w','i','n','d','o','w','s','.',
62  'c','o','m','m','o','n','-','c','o','n','t','r','o','l','s',',',
63  'v','e','r','s','i','o','n','=','\"','6','.','0','.','3','7','9','0','.','4','7','7','0','\"',',',
64  't','y','p','e','=','\"','w','i','n','3','2','\"',',',
65  'p','r','o','c','e','s','s','o','r','A','r','c','h','i','t','e','c','t','u','r','e','=',
66  '\"','x','8','6','\"',',','p','u','b','l','i','c','K','e','y','T','o','k','e','n','=',
67  '\"','6','5','9','5','b','6','4','1','4','4','c','c','f','1','d','f','\"',0};
68  static const WCHAR comctl3W[] =
69  {'m','i','c','r','o','s','o','f','t','.','w','i','n','d','o','w','s','.',
70  'c','o','m','m','o','n','-','c','o','n','t','r','o','l','s',',',
71  'v','e','r','s','i','o','n','=','\"','6','.','0','.','8','2','5','0','.','0','\"',',',
72  't','y','p','e','=','\"','w','i','n','3','2','\"',',',
73  'p','r','o','c','e','s','s','o','r','A','r','c','h','i','t','e','c','t','u','r','e','=',
74  '\"','x','8','6','\"',',','p','u','b','l','i','c','K','e','y','T','o','k','e','n','=',
75  '\"','6','5','9','5','b','6','4','1','4','4','c','c','f','1','d','f','\"',0};
76  static const WCHAR comctl4W[] =
77  {'m','i','c','r','o','s','o','f','t','.','w','i','n','d','o','w','s','.',
78  'c','o','m','m','o','n','-','c','o','n','t','r','o','l','s',',',
79  'v','e','r','s','i','o','n','=','\"','6','.','0','.','7','6','0','1','.','1','7','5','1','4','\"',',',
80  't','y','p','e','=','\"','w','i','n','3','2','\"',',',
81  'p','r','o','c','e','s','s','o','r','A','r','c','h','i','t','e','c','t','u','r','e','=',
82  '\"','x','8','6','\"',',','p','u','b','l','i','c','K','e','y','T','o','k','e','n','=',
83  '\"','6','5','9','5','b','6','4','1','4','4','c','c','f','1','d','f','\"',0};
84  HRESULT hr;
88  char comctl_path1[MAX_PATH], comctl_path2[MAX_PATH], comctl_path3[MAX_PATH], comctl_path4[MAX_PATH];
89  const WCHAR *comctlW;
90 
91  hr = CreateAssemblyCache( &cache, 0 );
92  ok( hr == S_OK, "got %08x\n", hr );
93  ok( cache != NULL, "got %08x\n", hr );
94 
95  hr = IAssemblyCache_QueryAssemblyInfo( cache, 0, NULL, NULL );
96  ok( hr == E_INVALIDARG, "got %08x\n", hr );
97 
98  hr = IAssemblyCache_QueryAssemblyInfo( cache, 0, emptyW, NULL );
99  ok( hr == E_INVALIDARG, "got %08x\n", hr );
100 
101  hr = IAssemblyCache_QueryAssemblyInfo( cache, 0, wine1W, NULL );
103  broken(hr == E_INVALIDARG) /* winxp */, "got %08x\n", hr );
104 
105  hr = IAssemblyCache_QueryAssemblyInfo( cache, 0, wine2W, NULL );
107  broken(hr == HRESULT_FROM_WIN32( ERROR_NOT_FOUND )) /* winxp */, "got %08x\n", hr );
108 
109  hr = IAssemblyCache_QueryAssemblyInfo( cache, 0, wine3W, NULL );
111  broken(hr == HRESULT_FROM_WIN32( ERROR_NOT_FOUND )) /* winxp */, "got %08x\n", hr );
112 
113  hr = IAssemblyCache_QueryAssemblyInfo( cache, 0, wine4W, NULL );
114  todo_wine ok( hr == HRESULT_FROM_WIN32( ERROR_NOT_FOUND ), "got %08x\n", hr );
115 
116  hr = IAssemblyCache_QueryAssemblyInfo( cache, 0, wine5W, NULL );
117  todo_wine ok( hr == HRESULT_FROM_WIN32( ERROR_NOT_FOUND ), "got %08x\n", hr );
118 
119  GetWindowsDirectoryA( comctl_path1, MAX_PATH );
120  lstrcatA( comctl_path1, "\\winsxs\\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.2600.2982_none_deadbeef" );
121  GetWindowsDirectoryA( comctl_path2, MAX_PATH );
122  lstrcatA( comctl_path2, "\\winsxs\\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.3790.4770_x-ww_05fdf087" );
123  GetWindowsDirectoryA( comctl_path3, MAX_PATH );
124  lstrcatA( comctl_path3, "\\winsxs\\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.8250.0_none_c119e7cca62b92bd" );
125  GetWindowsDirectoryA( comctl_path4, MAX_PATH );
126  lstrcatA( comctl_path4, "\\winsxs\\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7601.17514_none_41e6975e2bd6f2b2" );
127  if (GetFileAttributesA( comctl_path1 ) != INVALID_FILE_ATTRIBUTES) comctlW = comctl1W;
128  else if (GetFileAttributesA( comctl_path2 ) != INVALID_FILE_ATTRIBUTES) comctlW = comctl2W;
129  else if (GetFileAttributesA( comctl_path3 ) != INVALID_FILE_ATTRIBUTES) comctlW = comctl3W;
130  else if (GetFileAttributesA( comctl_path4 ) != INVALID_FILE_ATTRIBUTES) comctlW = comctl4W;
131  else
132  {
133  skip( "no assembly to test with\n" );
134  IAssemblyCache_Release( cache );
135  return;
136  }
137 
138  hr = IAssemblyCache_QueryAssemblyInfo( cache, 0, comctlW, NULL );
139  ok( hr == S_OK, "got %08x\n", hr );
140 
141  memset( &info, 0, sizeof(info) );
142  info.cbAssemblyInfo = sizeof(info);
143  hr = IAssemblyCache_QueryAssemblyInfo( cache, 0, wine5W, &info );
144  todo_wine ok( hr == HRESULT_FROM_WIN32( ERROR_NOT_FOUND ), "got %08x\n", hr );
145 
146  memset( &info, 0, sizeof(info) );
147  info.cbAssemblyInfo = sizeof(info);
148  hr = IAssemblyCache_QueryAssemblyInfo( cache, 0, comctlW, &info );
149  ok( hr == S_OK, "got %08x\n", hr );
150  ok( info.dwAssemblyFlags == 1, "got %08x\n", info.dwAssemblyFlags );
151  ok( !info.uliAssemblySizeInKB.u.LowPart, "got %u\n", info.uliAssemblySizeInKB.u.LowPart );
152  ok( info.pszCurrentAssemblyPathBuf == NULL, "got %p\n", info.pszCurrentAssemblyPathBuf );
153  ok( !info.cchBuf, "got %u\n", info.cchBuf );
154 
155  memset( &info, 0, sizeof(info) );
156  info.cbAssemblyInfo = sizeof(info);
157  info.pszCurrentAssemblyPathBuf = path;
158  info.cchBuf = ARRAY_SIZE( path );
159  hr = IAssemblyCache_QueryAssemblyInfo( cache, 0, comctlW, &info );
160  ok( hr == S_OK, "got %08x\n", hr );
161  ok( info.dwAssemblyFlags == 1, "got %08x\n", info.dwAssemblyFlags );
162  ok( !info.uliAssemblySizeInKB.u.LowPart, "got %u\n", info.uliAssemblySizeInKB.u.LowPart );
163  ok( info.cchBuf == ARRAY_SIZE( path ), "got %u\n", info.cchBuf );
164  ok( path[0], "empty path\n" );
165 
166  memset( &info, 0, sizeof(info) );
167  info.cbAssemblyInfo = sizeof(info);
168  info.pszCurrentAssemblyPathBuf = path;
169  hr = IAssemblyCache_QueryAssemblyInfo( cache, 0, comctlW, &info );
170  ok( hr == HRESULT_FROM_WIN32( ERROR_INSUFFICIENT_BUFFER ), "got %08x\n", hr );
171  ok( info.dwAssemblyFlags == 1, "got %08x\n", info.dwAssemblyFlags );
172  ok( !info.uliAssemblySizeInKB.u.LowPart, "got %u\n", info.uliAssemblySizeInKB.u.LowPart );
173  ok( info.cchBuf, "got %u\n", info.cchBuf );
174 
175  memset( &info, 0, sizeof(info) );
176  info.cbAssemblyInfo = sizeof(info);
177  hr = IAssemblyCache_QueryAssemblyInfo( cache, 1, comctlW, &info );
178  ok( hr == E_INVALIDARG, "got %08x\n", hr );
179  ok( !info.dwAssemblyFlags, "got %08x\n", info.dwAssemblyFlags );
180  ok( !info.uliAssemblySizeInKB.u.LowPart, "got %u\n", info.uliAssemblySizeInKB.u.LowPart );
181  ok( info.pszCurrentAssemblyPathBuf == NULL, "got %p\n", info.pszCurrentAssemblyPathBuf );
182  ok( !info.cchBuf, "got %u\n", info.cchBuf );
183 
184  memset( &info, 0, sizeof(info) );
185  info.cbAssemblyInfo = sizeof(info);
186  hr = IAssemblyCache_QueryAssemblyInfo( cache, 2, comctlW, &info );
187  ok( hr == E_INVALIDARG, "got %08x\n", hr );
188  ok( !info.dwAssemblyFlags, "got %08x\n", info.dwAssemblyFlags );
189  ok( !info.uliAssemblySizeInKB.u.LowPart, "got %u\n", info.uliAssemblySizeInKB.u.LowPart );
190  ok( info.pszCurrentAssemblyPathBuf == NULL, "got %p\n", info.pszCurrentAssemblyPathBuf );
191  ok( !info.cchBuf, "got %u\n", info.cchBuf );
192 
193  memset( &info, 0, sizeof(info) );
194  info.cbAssemblyInfo = sizeof(info);
195  info.pszCurrentAssemblyPathBuf = path;
196  info.cchBuf = ARRAY_SIZE( path );
197  path[0] = 0;
198  hr = IAssemblyCache_QueryAssemblyInfo( cache, 2, comctlW, &info );
199  ok( hr == E_INVALIDARG, "got %08x\n", hr );
200  ok( !info.dwAssemblyFlags, "got %08x\n", info.dwAssemblyFlags );
201  ok( !info.uliAssemblySizeInKB.u.LowPart, "got %u\n", info.uliAssemblySizeInKB.u.LowPart );
202  ok( info.cchBuf == ARRAY_SIZE( path ), "got %u\n", info.cchBuf );
203  ok( !path[0], "got %s\n", wine_dbgstr_w(path) );
204 
205  IAssemblyCache_Release( cache );
206 }
207 
209 {
211 }
Definition: cache.c:46
static const WCHAR wine1W[]
Definition: name.c:29
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
static const WCHAR wine5W[]
Definition: name.c:37
START_TEST(cache)
Definition: cache.c:208
HRESULT hr
Definition: shlfolder.c:183
GLsizei const GLchar ** path
Definition: glext.h:7234
struct _test_info info[]
Definition: SetCursorPos.c:19
HRESULT WINAPI CreateAssemblyCache(IAssemblyCache **obj, DWORD reserved)
Definition: cache.c:833
DWORD WINAPI GetFileAttributesA(LPCSTR lpFileName)
Definition: fileinfo.c:786
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: CString.cpp:62
#define E_INVALIDARG
Definition: ddrawi.h:101
static const WCHAR wine4W[]
Definition: name.c:35
smooth NULL
Definition: ftsmooth.c:416
#define ok(value,...)
Definition: CComObject.cpp:34
LPSTR WINAPI lstrcatA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:123
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define MAX_PATH
Definition: compat.h:26
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
#define todo_wine
Definition: test.h:154
static void test_QueryAssemblyInfo(void)
Definition: cache.c:28
#define broken(x)
Definition: _sntprintf.h:21
static const WCHAR wine2W[]
Definition: name.c:31
#define S_OK
Definition: intsafe.h:59
#define ERROR_SXS_MISSING_ASSEMBLY_IDENTITY_ATTRIBUTE
Definition: winerror.h:2220
static const WCHAR emptyW[]
Definition: navigate.c:36
#define ARRAY_SIZE(a)
Definition: main.h:24
#define skip(...)
Definition: CString.cpp:57
Definition: services.c:325
UINT WINAPI GetWindowsDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
Definition: path.c:2336
static const WCHAR wine3W[]
Definition: name.c:33
#define ERROR_NOT_FOUND
Definition: winerror.h:690
#define memset(x, y, z)
Definition: compat.h:39
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10