wined3d: read_from_framebuffer_texture() isn't suitable for readback of onscreen...
[wine/testsucceed.git] / dlls / msi / tests / suminfo.c
bloba0b225b6bd9235b4afccfce485e4fc4756f1cf62
1 /*
2 * Copyright (C) 2005 Mike McCormack for CodeWeavers
4 * A test program for MSI database files.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #define COBJMACROS
23 #include <stdio.h>
24 #include <windows.h>
25 #include <msi.h>
26 #include <msiquery.h>
27 #include <objidl.h>
29 #include "wine/test.h"
32 * The following are defined in Windows SDK's msidefs.h
33 * but that file doesn't exist in the msvc6 header set.
35 * Some are already defined in PropIdl.h - undefine them
37 #undef PID_DICTIONARY
38 #undef PID_CODEPAGE
39 #undef PID_SUBJECT
40 #undef PID_SECURITY
42 #define PID_DICTIONARY 0
43 #define PID_CODEPAGE 1
44 #define PID_TITLE 2
45 #define PID_SUBJECT 3
46 #define PID_AUTHOR 4
47 #define PID_KEYWORDS 5
48 #define PID_COMMENTS 6
49 #define PID_TEMPLATE 7
50 #define PID_LASTAUTHOR 8
51 #define PID_REVNUMBER 9
52 #define PID_EDITTINE 10
53 #define PID_LASTPRINTED 11
54 #define PID_CREATE_DTM 12
55 #define PID_LASTSAVE_DTM 13
56 #define PID_PAGECOUNT 14
57 #define PID_WORDCOUNT 15
58 #define PID_CHARCOUNT 16
59 #define PID_THUMBNAIL 17
60 #define PID_APPNAME 18
61 #define PID_SECURITY 19
62 #define PID_MSIVERSION PID_PAGECOUNT
63 #define PID_MSISOURCE PID_WORDCOUNT
64 #define PID_MSIRESTRICT PID_CHARCOUNT
66 const char *msifile = "winetest-suminfo.msi";
67 static const WCHAR msifileW[] = {
68 'w','i','n','e','t','e','s','t','-','s','u','m','i','n','f','o','.','m','s','i',0 };
70 static void test_suminfo(void)
72 MSIHANDLE hdb = 0, hsuminfo;
73 UINT r, count, type;
74 DWORD sz;
75 INT val;
76 FILETIME ft;
77 char buf[0x10];
79 DeleteFile(msifile);
81 /* just MsiOpenDatabase should not create a file */
82 r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
83 ok(r == ERROR_SUCCESS, "MsiOpenDatabase failed\n");
85 r = MsiGetSummaryInformation(hdb, NULL, 0, NULL);
86 ok(r == ERROR_INVALID_PARAMETER, "MsiGetSummaryInformation wrong error\n");
88 r = MsiGetSummaryInformation(hdb, NULL, 0, &hsuminfo);
89 ok(r == ERROR_SUCCESS, "MsiGetSummaryInformation failed\n");
91 r = MsiSummaryInfoGetPropertyCount(0, NULL);
92 ok(r == ERROR_INVALID_HANDLE, "getpropcount failed\n");
94 r = MsiSummaryInfoGetPropertyCount(hsuminfo, NULL);
95 ok(r == ERROR_SUCCESS, "getpropcount failed\n");
97 count = -1;
98 r = MsiSummaryInfoGetPropertyCount(hsuminfo, &count);
99 ok(r == ERROR_SUCCESS, "getpropcount failed\n");
100 ok(count == 0, "count should be zero\n");
102 r = MsiSummaryInfoGetProperty(hsuminfo, 0, NULL, NULL, NULL, 0, NULL);
103 ok(r == ERROR_SUCCESS, "getpropcount failed\n");
105 r = MsiSummaryInfoGetProperty(hsuminfo, -1, NULL, NULL, NULL, 0, NULL);
106 ok(r == ERROR_UNKNOWN_PROPERTY, "MsiSummaryInfoGetProperty wrong error\n");
108 r = MsiSummaryInfoGetProperty(hsuminfo, PID_SECURITY+1, NULL, NULL, NULL, 0, NULL);
109 ok(r == ERROR_UNKNOWN_PROPERTY, "MsiSummaryInfoGetProperty wrong error\n");
111 type = -1;
112 r = MsiSummaryInfoGetProperty(hsuminfo, 0, &type, NULL, NULL, 0, NULL);
113 ok(r == ERROR_SUCCESS, "getpropcount failed\n");
114 ok(type == 0, "wrong type\n");
116 type = -1;
117 val = 1234;
118 r = MsiSummaryInfoGetProperty(hsuminfo, 0, &type, &val, NULL, 0, NULL);
119 ok(r == ERROR_SUCCESS, "getpropcount failed\n");
120 ok(type == 0, "wrong type\n");
121 ok(val == 1234, "wrong val\n");
123 buf[0]='x';
124 buf[1]=0;
125 sz = 0x10;
126 r = MsiSummaryInfoGetProperty(hsuminfo, PID_REVNUMBER, &type, &val, NULL, buf, &sz);
127 ok(r == ERROR_SUCCESS, "getpropcount failed\n");
128 ok(buf[0]=='x', "cleared buffer\n");
129 ok(sz == 0x10, "count wasn't zero\n");
130 ok(type == VT_EMPTY, "should be empty\n");
132 r = MsiSummaryInfoSetProperty(hsuminfo, PID_TITLE, VT_LPSTR, 0, NULL, "Mike");
133 ok(r == ERROR_FUNCTION_FAILED, "MsiSummaryInfoSetProperty wrong error\n");
135 r = MsiSummaryInfoSetProperty(hsuminfo, PID_TITLE, VT_LPSTR, 1, NULL, "JungAh");
136 ok(r == ERROR_FUNCTION_FAILED, "MsiSummaryInfoSetProperty wrong error\n");
138 r = MsiSummaryInfoSetProperty(hsuminfo, PID_TITLE, VT_LPSTR, 1, &ft, "Mike");
139 ok(r == ERROR_FUNCTION_FAILED, "MsiSummaryInfoSetProperty wrong error\n");
141 r = MsiSummaryInfoSetProperty(hsuminfo, PID_CODEPAGE, VT_I2, 1, &ft, "JungAh");
142 ok(r == ERROR_FUNCTION_FAILED, "MsiSummaryInfoSetProperty wrong error\n");
144 r = MsiCloseHandle(hsuminfo);
145 ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
147 /* try again with the update count set */
148 r = MsiGetSummaryInformation(hdb, NULL, 1, &hsuminfo);
149 ok(r == ERROR_SUCCESS, "MsiGetSummaryInformation failed\n");
151 r = MsiSummaryInfoSetProperty(hsuminfo, 0, VT_LPSTR, 1, NULL, NULL);
152 ok(r == ERROR_DATATYPE_MISMATCH, "MsiSummaryInfoSetProperty wrong error\n");
154 r = MsiSummaryInfoSetProperty(hsuminfo, PID_CODEPAGE, VT_LPSTR, 1, NULL, NULL);
155 ok(r == ERROR_DATATYPE_MISMATCH, "MsiSummaryInfoSetProperty wrong error\n");
157 r = MsiSummaryInfoSetProperty(hsuminfo, PID_TITLE, VT_I4, 0, NULL, "Mike");
158 ok(r == ERROR_DATATYPE_MISMATCH, "MsiSummaryInfoSetProperty wrong error\n");
160 r = MsiSummaryInfoSetProperty(hsuminfo, PID_AUTHOR, VT_I4, 0, NULL, "JungAh");
161 ok(r == ERROR_DATATYPE_MISMATCH, "MsiSummaryInfoSetProperty wrong error\n");
163 r = MsiSummaryInfoSetProperty(hsuminfo, PID_KEYWORDS, VT_I2, 0, NULL, "Mike");
164 ok(r == ERROR_DATATYPE_MISMATCH, "MsiSummaryInfoSetProperty wrong error\n");
166 r = MsiSummaryInfoSetProperty(hsuminfo, PID_COMMENTS, VT_FILETIME, 0, NULL, "JungAh");
167 ok(r == ERROR_DATATYPE_MISMATCH, "MsiSummaryInfoSetProperty wrong error\n");
169 r = MsiSummaryInfoSetProperty(hsuminfo, PID_TEMPLATE, VT_I2, 0, NULL, "Mike");
170 ok(r == ERROR_DATATYPE_MISMATCH, "MsiSummaryInfoSetProperty wrong error\n");
172 r = MsiSummaryInfoSetProperty(hsuminfo, PID_LASTAUTHOR, VT_LPSTR, 0, NULL, NULL);
173 ok(r == ERROR_INVALID_PARAMETER, "MsiSummaryInfoSetProperty wrong error\n");
175 r = MsiSummaryInfoSetProperty(hsuminfo, PID_LASTSAVE_DTM, VT_FILETIME, 0, NULL, NULL);
176 ok(r == ERROR_INVALID_PARAMETER, "MsiSummaryInfoSetProperty wrong error\n");
178 r = MsiSummaryInfoSetProperty(hsuminfo, PID_LASTAUTHOR, VT_LPWSTR, 0, NULL, "h\0i\0\0");
179 ok(r == ERROR_DATATYPE_MISMATCH, "MsiSummaryInfoSetProperty wrong error\n");
181 r = MsiSummaryInfoSetProperty(hsuminfo, PID_REVNUMBER, VT_I4, 0, NULL, "Jungah");
182 ok(r == ERROR_DATATYPE_MISMATCH, "MsiSummaryInfoSetProperty wrong error\n");
184 r = MsiSummaryInfoSetProperty(hsuminfo, PID_PAGECOUNT, VT_LPSTR, 1, NULL, NULL);
185 ok(r == ERROR_DATATYPE_MISMATCH, "MsiSummaryInfoSetProperty wrong error\n");
187 r = MsiSummaryInfoSetProperty(hsuminfo, PID_TITLE, VT_LPSTR, 0, NULL, "Mike");
188 ok(r == ERROR_SUCCESS, "MsiSummaryInfoSetProperty failed\n");
190 sz = 2;
191 strcpy(buf,"x");
192 r = MsiSummaryInfoGetProperty(hsuminfo, PID_TITLE, &type, NULL, NULL, buf, &sz );
193 ok(r == ERROR_MORE_DATA, "MsiSummaryInfoSetProperty failed\n");
194 ok(sz == 4, "count was wrong\n");
195 ok(type == VT_LPSTR, "type was wrong\n");
196 ok(!strcmp(buf,"M"), "buffer was wrong\n");
198 sz = 4;
199 strcpy(buf,"x");
200 r = MsiSummaryInfoGetProperty(hsuminfo, PID_TITLE, &type, NULL, NULL, buf, &sz );
201 ok(r == ERROR_MORE_DATA, "MsiSummaryInfoSetProperty failed\n");
202 ok(sz == 4, "count was wrong\n");
203 ok(type == VT_LPSTR, "type was wrong\n");
204 ok(!strcmp(buf,"Mik"), "buffer was wrong\n");
206 r = MsiSummaryInfoSetProperty(hsuminfo, PID_TITLE, VT_LPSTR, 0, NULL, "JungAh");
207 ok(r == ERROR_SUCCESS, "MsiSummaryInfoSetProperty failed\n");
209 r = MsiSummaryInfoSetProperty(hsuminfo, PID_CODEPAGE, VT_I2, 1, &ft, "Mike");
210 ok(r == ERROR_FUNCTION_FAILED, "MsiSummaryInfoSetProperty wrong error\n");
212 r = MsiCloseHandle(hsuminfo);
213 ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
215 /* try again with a higher update count */
216 r = MsiGetSummaryInformation(hdb, NULL, 10, &hsuminfo);
217 ok(r == ERROR_SUCCESS, "MsiGetSummaryInformation failed\n");
219 r = MsiSummaryInfoSetProperty(hsuminfo, PID_TITLE, VT_LPSTR, 0, NULL, "JungAh");
220 ok(r == ERROR_SUCCESS, "MsiSummaryInfoSetProperty failed\n");
222 r = MsiSummaryInfoSetProperty(hsuminfo, PID_CODEPAGE, VT_LPSTR, 1, NULL, NULL);
223 ok(r == ERROR_DATATYPE_MISMATCH, "MsiSummaryInfoSetProperty wrong error\n");
225 r = MsiSummaryInfoSetProperty(hsuminfo, PID_CODEPAGE, VT_I2, 1, NULL, NULL);
226 ok(r == ERROR_SUCCESS, "MsiSummaryInfoSetProperty wrong error\n");
228 r = MsiSummaryInfoSetProperty(hsuminfo, PID_CODEPAGE, VT_I2, 1, &ft, "Mike");
229 ok(r == ERROR_SUCCESS, "MsiSummaryInfoSetProperty wrong error\n");
231 r = MsiSummaryInfoSetProperty(hsuminfo, PID_AUTHOR, VT_LPSTR, 1, &ft, "Mike");
232 ok(r == ERROR_SUCCESS, "MsiSummaryInfoSetProperty wrong error\n");
234 r = MsiSummaryInfoPersist(hsuminfo);
235 ok(r == ERROR_SUCCESS, "MsiSummaryInfoPersist failed\n");
237 MsiDatabaseCommit(hdb);
239 r = MsiCloseHandle(hsuminfo);
240 ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
242 r = MsiCloseHandle(hdb);
243 ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
245 /* filename, non-zero update count */
246 MsiGetSummaryInformation(0, msifile, 1, &hsuminfo);
247 ok(r == ERROR_SUCCESS, "MsiGetSummaryInformation failed\n");
249 r = MsiSummaryInfoSetProperty(hsuminfo, PID_AUTHOR, VT_LPSTR, 1, &ft, "Mike");
250 ok(r == ERROR_SUCCESS, "MsiSummaryInfoSetProperty wrong error\n");
252 r = MsiSummaryInfoPersist(hsuminfo);
253 ok(r == ERROR_SUCCESS, "MsiSummaryInfoPersist failed %u\n", r);
255 r = MsiCloseHandle(hsuminfo);
256 ok(r == ERROR_SUCCESS, "MsiCloseHandle failed %u\n", r);
258 /* filename, zero update count */
259 MsiGetSummaryInformation(0, msifile, 0, &hsuminfo);
260 ok(r == ERROR_SUCCESS, "MsiGetSummaryInformation failed %u\n", r);
262 r = MsiSummaryInfoSetProperty(hsuminfo, PID_AUTHOR, VT_LPSTR, 1, &ft, "Mike");
263 todo_wine ok(r == ERROR_FUNCTION_FAILED, "MsiSummaryInfoSetProperty wrong error, %u\n", r);
265 r = MsiSummaryInfoPersist(hsuminfo);
266 ok(r == ERROR_FUNCTION_FAILED, "MsiSummaryInfoPersist wrong error %u\n", r);
268 r = MsiCloseHandle(hsuminfo);
269 ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
271 r = DeleteFile(msifile);
272 ok(r, "DeleteFile failed\n");
275 static const WCHAR tb[] = { 0x4840, 0x3f7f, 0x4164, 0x422f, 0x4836, 0 }; /* _Tables */
276 static const WCHAR sd[] = { 0x4840, 0x3f3f, 0x4577, 0x446c, 0x3b6a, 0x45e4, 0x4824, 0 }; /* _StringData */
277 static const WCHAR sp[] = { 0x4840, 0x3f3f, 0x4577, 0x446c, 0x3e6a, 0x44b2, 0x482f, 0 }; /* _StringPool */
279 #define LOSE_CONST(x) ((LPSTR)(UINT_PTR)(x))
281 static void test_create_database_binary(void)
283 static const CLSID CLSID_MsiDatabase =
284 { 0xc1084, 0, 0, {0xc0, 0, 0, 0, 0, 0, 0, 0x46 } };
285 static const CLSID IID_IPropertySetStorage =
286 { 0x13a, 0, 0, {0xc0, 0, 0, 0, 0, 0, 0, 0x46 } };
287 static const CLSID FMTID_SummaryInformation =
288 { 0xf29f85e0, 0x4ff9, 0x1068, {0xab, 0x91, 0x08, 0x00, 0x2b, 0x27, 0xb3, 0xd9}};
289 DWORD mode = STGM_CREATE | STGM_READWRITE | STGM_DIRECT | STGM_SHARE_EXCLUSIVE;
290 IPropertySetStorage *pss = NULL;
291 IPropertyStorage *ps = NULL;
292 IStorage *stg = NULL;
293 IStream *stm = NULL;
294 HRESULT r;
295 PROPSPEC propspec[10];
296 PROPVARIANT propvar[10];
297 USHORT data[2] = { 0, 0 };
299 r = StgCreateDocfile( msifileW, mode, 0, &stg );
300 ok( r == S_OK, "failed to create database\n");
302 r = IStorage_SetClass( stg, &CLSID_MsiDatabase );
303 ok( r == S_OK, "failed to set clsid\n");
305 /* create the _StringData stream */
306 r = IStorage_CreateStream( stg, sd, STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stm );
307 ok( r == S_OK, "failed to create stream\n");
309 IStream_Release( stm );
311 /* create the _StringPool stream */
312 r = IStorage_CreateStream( stg, sp, STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stm );
313 ok( r == S_OK, "failed to create stream\n");
315 r = IStream_Write( stm, data, sizeof data, NULL );
316 ok( r == S_OK, "failed to write stream\n");
318 IStream_Release( stm );
320 /* create the _Tables stream */
321 r = IStorage_CreateStream( stg, tb, STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stm );
322 ok( r == S_OK, "failed to create stream\n");
324 IStream_Release( stm );
326 r = IStorage_QueryInterface( stg, &IID_IPropertySetStorage, (void**) &pss );
327 ok( r == S_OK, "failed to set clsid\n");
329 r = IPropertySetStorage_Create( pss, &FMTID_SummaryInformation, NULL, 0, mode, &ps );
330 ok( r == S_OK, "failed to create property set\n");
332 r = IPropertyStorage_SetClass( ps, &FMTID_SummaryInformation );
333 ok( r == S_OK, "failed to set class\n");
335 propspec[0].ulKind = PRSPEC_PROPID;
336 U(propspec[0]).propid = PID_TITLE;
337 propvar[0].vt = VT_LPSTR;
338 U(propvar[0]).pszVal = LOSE_CONST("test title");
340 propspec[1].ulKind = PRSPEC_PROPID;
341 U(propspec[1]).propid = PID_SUBJECT;
342 propvar[1].vt = VT_LPSTR;
343 U(propvar[1]).pszVal = LOSE_CONST("msi suminfo / property storage test");
345 propspec[2].ulKind = PRSPEC_PROPID;
346 U(propspec[2]).propid = PID_AUTHOR;
347 propvar[2].vt = VT_LPSTR;
348 U(propvar[2]).pszVal = LOSE_CONST("mike_m");
350 propspec[3].ulKind = PRSPEC_PROPID;
351 U(propspec[3]).propid = PID_TEMPLATE;
352 propvar[3].vt = VT_LPSTR;
353 U(propvar[3]).pszVal = LOSE_CONST(";1033"); /* actually the string table's codepage */
355 propspec[4].ulKind = PRSPEC_PROPID;
356 U(propspec[4]).propid = PID_REVNUMBER;
357 propvar[4].vt = VT_LPSTR;
358 U(propvar[4]).pszVal = LOSE_CONST("{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}");
360 propspec[5].ulKind = PRSPEC_PROPID;
361 U(propspec[5]).propid = PID_PAGECOUNT;
362 propvar[5].vt = VT_I4;
363 U(propvar[5]).lVal = 100;
365 propspec[6].ulKind = PRSPEC_PROPID;
366 U(propspec[6]).propid = PID_WORDCOUNT;
367 propvar[6].vt = VT_I4;
368 U(propvar[6]).lVal = 0;
370 /* MSDN says that PID_LASTPRINTED should be a VT_FILETIME... */
371 propspec[7].ulKind = PRSPEC_PROPID;
372 U(propspec[7]).propid = PID_LASTPRINTED;
373 propvar[7].vt = VT_LPSTR;
374 U(propvar[7]).pszVal = LOSE_CONST("7/1/1999 5:17");
376 r = IPropertyStorage_WriteMultiple( ps, 8, propspec, propvar, PID_FIRST_USABLE );
377 ok( r == S_OK, "failed to write properties\n");
379 IPropertyStorage_Commit( ps, STGC_DEFAULT );
381 IPropertyStorage_Release( ps );
382 IPropertySetStorage_Release( pss );
384 IStorage_Commit( stg, STGC_DEFAULT );
385 IStorage_Release( stg );
388 static void test_summary_binary(void)
390 MSIHANDLE hdb = 0, hsuminfo = 0;
391 UINT r, type, count;
392 INT ival;
393 DWORD sz;
394 char sval[20];
396 DeleteFile( msifile );
398 test_create_database_binary();
400 ok( INVALID_FILE_ATTRIBUTES != GetFileAttributes(msifile), "file doesn't exist!\n");
402 /* just MsiOpenDatabase should not create a file */
403 r = MsiOpenDatabase(msifile, MSIDBOPEN_READONLY, &hdb);
404 ok(r == ERROR_SUCCESS, "MsiOpenDatabase failed\n");
406 r = MsiGetSummaryInformation(hdb, NULL, 0, &hsuminfo);
407 ok(r == ERROR_SUCCESS, "MsiGetSummaryInformation failed\n");
410 * Check what reading PID_LASTPRINTED does...
411 * The string value is written to the msi file
412 * but it appears that we're not allowed to read it back again.
413 * We can still read its type though...?
415 sz = sizeof sval;
416 sval[0] = 0;
417 type = 0;
418 r = MsiSummaryInfoGetProperty(hsuminfo, PID_LASTPRINTED, &type, NULL, NULL, sval, &sz);
419 ok(r == ERROR_SUCCESS, "MsiSummaryInfoGetProperty failed\n");
420 ok(!lstrcmpA(sval, "") || !lstrcmpA(sval, "7"),
421 "Expected empty string or \"7\", got \"%s\"\n", sval);
422 todo_wine {
423 ok(type == VT_LPSTR, "Expected VT_LPSTR, got %d\n", type);
424 ok(sz == 0 || sz == 1, "Expected 0 or 1, got %d\n", sz);
427 ival = -1;
428 r = MsiSummaryInfoGetProperty(hsuminfo, PID_WORDCOUNT, &type, &ival, NULL, NULL, NULL);
429 ok(r == ERROR_SUCCESS, "MsiSummaryInfoGetProperty failed\n");
430 todo_wine ok( ival == 0, "value incorrect\n");
432 /* looks like msi adds some of its own values in here */
433 count = 0;
434 r = MsiSummaryInfoGetPropertyCount( hsuminfo, &count );
435 ok(r == ERROR_SUCCESS, "getpropcount failed\n");
436 todo_wine ok(count == 10, "prop count incorrect\n");
438 r = MsiSummaryInfoSetProperty( hsuminfo, PID_TITLE, VT_LPSTR, 0, NULL, "Mike" );
439 ok(r == ERROR_FUNCTION_FAILED, "MsiSummaryInfoSetProperty failed %u\n", r);
441 r = MsiSummaryInfoPersist( hsuminfo );
442 ok(r == ERROR_FUNCTION_FAILED, "MsiSummaryInfoPersist failed %u\n", r);
444 MsiCloseHandle( hsuminfo );
445 MsiCloseHandle( hdb );
447 DeleteFile( msifile );
450 START_TEST(suminfo)
452 test_suminfo();
453 test_summary_binary();