push aea352fc3df615e3f4b48daf6f897ea93ad1fffd
[wine/hacks.git] / dlls / msi / tests / package.c
blob2844a2698c03a9304def1afbd93a7b70750ceec0
1 /*
2 * tests for Microsoft Installer functionality
4 * Copyright 2005 Mike McCormack for CodeWeavers
5 * Copyright 2005 Aric Stewart for CodeWeavers
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #define COBJMACROS
24 #include <stdio.h>
25 #include <windows.h>
26 #include <msi.h>
27 #include <msiquery.h>
29 #include "wine/test.h"
31 static const char msifile[] = "winetest.msi";
33 static UINT run_query( MSIHANDLE hdb, const char *query )
35 MSIHANDLE hview = 0;
36 UINT r;
38 r = MsiDatabaseOpenView(hdb, query, &hview);
39 if( r != ERROR_SUCCESS )
40 return r;
42 r = MsiViewExecute(hview, 0);
43 if( r == ERROR_SUCCESS )
44 r = MsiViewClose(hview);
45 MsiCloseHandle(hview);
46 return r;
49 static UINT create_component_table( MSIHANDLE hdb )
51 return run_query( hdb,
52 "CREATE TABLE `Component` ( "
53 "`Component` CHAR(72) NOT NULL, "
54 "`ComponentId` CHAR(38), "
55 "`Directory_` CHAR(72) NOT NULL, "
56 "`Attributes` SHORT NOT NULL, "
57 "`Condition` CHAR(255), "
58 "`KeyPath` CHAR(72) "
59 "PRIMARY KEY `Component`)" );
62 static UINT create_feature_table( MSIHANDLE hdb )
64 return run_query( hdb,
65 "CREATE TABLE `Feature` ( "
66 "`Feature` CHAR(38) NOT NULL, "
67 "`Feature_Parent` CHAR(38), "
68 "`Title` CHAR(64), "
69 "`Description` CHAR(255), "
70 "`Display` SHORT NOT NULL, "
71 "`Level` SHORT NOT NULL, "
72 "`Directory_` CHAR(72), "
73 "`Attributes` SHORT NOT NULL "
74 "PRIMARY KEY `Feature`)" );
77 static UINT create_feature_components_table( MSIHANDLE hdb )
79 return run_query( hdb,
80 "CREATE TABLE `FeatureComponents` ( "
81 "`Feature_` CHAR(38) NOT NULL, "
82 "`Component_` CHAR(72) NOT NULL "
83 "PRIMARY KEY `Feature_`, `Component_` )" );
86 static UINT create_file_table( MSIHANDLE hdb )
88 return run_query( hdb,
89 "CREATE TABLE `File` ("
90 "`File` CHAR(72) NOT NULL, "
91 "`Component_` CHAR(72) NOT NULL, "
92 "`FileName` CHAR(255) NOT NULL, "
93 "`FileSize` LONG NOT NULL, "
94 "`Version` CHAR(72), "
95 "`Language` CHAR(20), "
96 "`Attributes` SHORT, "
97 "`Sequence` SHORT NOT NULL "
98 "PRIMARY KEY `File`)" );
101 static UINT create_remove_file_table( MSIHANDLE hdb )
103 return run_query( hdb,
104 "CREATE TABLE `RemoveFile` ("
105 "`FileKey` CHAR(72) NOT NULL, "
106 "`Component_` CHAR(72) NOT NULL, "
107 "`FileName` CHAR(255) LOCALIZABLE, "
108 "`DirProperty` CHAR(72) NOT NULL, "
109 "`InstallMode` SHORT NOT NULL "
110 "PRIMARY KEY `FileKey`)" );
113 static UINT create_appsearch_table( MSIHANDLE hdb )
115 return run_query( hdb,
116 "CREATE TABLE `AppSearch` ("
117 "`Property` CHAR(72) NOT NULL, "
118 "`Signature_` CHAR(72) NOT NULL "
119 "PRIMARY KEY `Property`, `Signature_`)" );
122 static UINT create_reglocator_table( MSIHANDLE hdb )
124 return run_query( hdb,
125 "CREATE TABLE `RegLocator` ("
126 "`Signature_` CHAR(72) NOT NULL, "
127 "`Root` SHORT NOT NULL, "
128 "`Key` CHAR(255) NOT NULL, "
129 "`Name` CHAR(255), "
130 "`Type` SHORT "
131 "PRIMARY KEY `Signature_`)" );
134 static UINT create_signature_table( MSIHANDLE hdb )
136 return run_query( hdb,
137 "CREATE TABLE `Signature` ("
138 "`Signature` CHAR(72) NOT NULL, "
139 "`FileName` CHAR(255) NOT NULL, "
140 "`MinVersion` CHAR(20), "
141 "`MaxVersion` CHAR(20), "
142 "`MinSize` LONG, "
143 "`MaxSize` LONG, "
144 "`MinDate` LONG, "
145 "`MaxDate` LONG, "
146 "`Languages` CHAR(255) "
147 "PRIMARY KEY `Signature`)" );
150 static UINT create_launchcondition_table( MSIHANDLE hdb )
152 return run_query( hdb,
153 "CREATE TABLE `LaunchCondition` ("
154 "`Condition` CHAR(255) NOT NULL, "
155 "`Description` CHAR(255) NOT NULL "
156 "PRIMARY KEY `Condition`)" );
159 static UINT add_component_entry( MSIHANDLE hdb, const char *values )
161 char insert[] = "INSERT INTO `Component` "
162 "(`Component`, `ComponentId`, `Directory_`, `Attributes`, `Condition`, `KeyPath`) "
163 "VALUES( %s )";
164 char *query;
165 UINT sz, r;
167 sz = strlen(values) + sizeof insert;
168 query = HeapAlloc(GetProcessHeap(),0,sz);
169 sprintf(query,insert,values);
170 r = run_query( hdb, query );
171 HeapFree(GetProcessHeap(), 0, query);
172 return r;
175 static UINT add_feature_entry( MSIHANDLE hdb, const char *values )
177 char insert[] = "INSERT INTO `Feature` (`Feature`, `Feature_Parent`, "
178 "`Title`, `Description`, `Display`, `Level`, `Directory_`, `Attributes`) VALUES( %s )";
179 char *query;
180 UINT sz, r;
182 sz = strlen(values) + sizeof insert;
183 query = HeapAlloc(GetProcessHeap(),0,sz);
184 sprintf(query,insert,values);
185 r = run_query( hdb, query );
186 HeapFree(GetProcessHeap(), 0, query);
187 return r;
190 static UINT add_feature_components_entry( MSIHANDLE hdb, const char *values )
192 char insert[] = "INSERT INTO `FeatureComponents` "
193 "(`Feature_`, `Component_`) "
194 "VALUES( %s )";
195 char *query;
196 UINT sz, r;
198 sz = strlen(values) + sizeof insert;
199 query = HeapAlloc(GetProcessHeap(),0,sz);
200 sprintf(query,insert,values);
201 r = run_query( hdb, query );
202 HeapFree(GetProcessHeap(), 0, query);
203 return r;
206 static UINT add_file_entry( MSIHANDLE hdb, const char *values )
208 char insert[] = "INSERT INTO `File` "
209 "(`File`, `Component_`, `FileName`, `FileSize`, `Version`, `Language`, `Attributes`, `Sequence`) "
210 "VALUES( %s )";
211 char *query;
212 UINT sz, r;
214 sz = strlen(values) + sizeof insert;
215 query = HeapAlloc(GetProcessHeap(),0,sz);
216 sprintf(query,insert,values);
217 r = run_query( hdb, query );
218 HeapFree(GetProcessHeap(), 0, query);
219 return r;
222 static UINT add_appsearch_entry( MSIHANDLE hdb, const char *values )
224 char insert[] = "INSERT INTO `AppSearch` "
225 "(`Property`, `Signature_`) "
226 "VALUES( %s )";
227 char *query;
228 UINT sz, r;
230 sz = strlen(values) + sizeof insert;
231 query = HeapAlloc(GetProcessHeap(),0,sz);
232 sprintf(query,insert,values);
233 r = run_query( hdb, query );
234 HeapFree(GetProcessHeap(), 0, query);
235 return r;
238 static UINT add_reglocator_entry( MSIHANDLE hdb, const char *values )
240 char insert[] = "INSERT INTO `RegLocator` "
241 "(`Signature_`, `Root`, `Key`, `Name`, `Type`) "
242 "VALUES( %s )";
243 char *query;
244 UINT sz, r;
246 sz = strlen(values) + sizeof insert;
247 query = HeapAlloc(GetProcessHeap(),0,sz);
248 sprintf(query,insert,values);
249 r = run_query( hdb, query );
250 HeapFree(GetProcessHeap(), 0, query);
251 return r;
254 static UINT add_signature_entry( MSIHANDLE hdb, const char *values )
256 char insert[] = "INSERT INTO `Signature` "
257 "(`Signature`, `FileName`, `MinVersion`, `MaxVersion`,"
258 " `MinSize`, `MaxSize`, `MinDate`, `MaxDate`, `Languages`) "
259 "VALUES( %s )";
260 char *query;
261 UINT sz, r;
263 sz = strlen(values) + sizeof insert;
264 query = HeapAlloc(GetProcessHeap(),0,sz);
265 sprintf(query,insert,values);
266 r = run_query( hdb, query );
267 HeapFree(GetProcessHeap(), 0, query);
268 return r;
271 static UINT add_launchcondition_entry( MSIHANDLE hdb, const char *values )
273 char insert[] = "INSERT INTO `LaunchCondition` "
274 "(`Condition`, `Description`) "
275 "VALUES( %s )";
276 char *query;
277 UINT sz, r;
279 sz = strlen(values) + sizeof insert;
280 query = HeapAlloc(GetProcessHeap(),0,sz);
281 sprintf(query,insert,values);
282 r = run_query( hdb, query );
283 HeapFree(GetProcessHeap(), 0, query);
284 return r;
287 static UINT set_summary_info(MSIHANDLE hdb)
289 UINT res;
290 MSIHANDLE suminfo;
292 /* build summmary info */
293 res = MsiGetSummaryInformation(hdb, NULL, 7, &suminfo);
294 ok( res == ERROR_SUCCESS , "Failed to open summaryinfo\n" );
296 res = MsiSummaryInfoSetProperty(suminfo,2, VT_LPSTR, 0,NULL,
297 "Installation Database");
298 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
300 res = MsiSummaryInfoSetProperty(suminfo,3, VT_LPSTR, 0,NULL,
301 "Installation Database");
302 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
304 res = MsiSummaryInfoSetProperty(suminfo,4, VT_LPSTR, 0,NULL,
305 "Wine Hackers");
306 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
308 res = MsiSummaryInfoSetProperty(suminfo,7, VT_LPSTR, 0,NULL,
309 ";1033");
310 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
312 res = MsiSummaryInfoSetProperty(suminfo,9, VT_LPSTR, 0,NULL,
313 "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}");
314 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
316 res = MsiSummaryInfoSetProperty(suminfo, 14, VT_I4, 100, NULL, NULL);
317 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
319 res = MsiSummaryInfoSetProperty(suminfo, 15, VT_I4, 0, NULL, NULL);
320 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
322 res = MsiSummaryInfoPersist(suminfo);
323 ok( res == ERROR_SUCCESS , "Failed to make summary info persist\n" );
325 res = MsiCloseHandle( suminfo);
326 ok( res == ERROR_SUCCESS , "Failed to close suminfo\n" );
328 return res;
332 static MSIHANDLE create_package_db(void)
334 MSIHANDLE hdb = 0;
335 UINT res;
337 DeleteFile(msifile);
339 /* create an empty database */
340 res = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb );
341 ok( res == ERROR_SUCCESS , "Failed to create database\n" );
342 if( res != ERROR_SUCCESS )
343 return hdb;
345 res = MsiDatabaseCommit( hdb );
346 ok( res == ERROR_SUCCESS , "Failed to commit database\n" );
348 res = set_summary_info(hdb);
350 res = run_query( hdb,
351 "CREATE TABLE `Directory` ( "
352 "`Directory` CHAR(255) NOT NULL, "
353 "`Directory_Parent` CHAR(255), "
354 "`DefaultDir` CHAR(255) NOT NULL "
355 "PRIMARY KEY `Directory`)" );
356 ok( res == ERROR_SUCCESS , "Failed to create directory table\n" );
358 return hdb;
361 static MSIHANDLE package_from_db(MSIHANDLE hdb)
363 UINT res;
364 CHAR szPackage[10];
365 MSIHANDLE hPackage;
367 sprintf(szPackage,"#%li",hdb);
368 res = MsiOpenPackage(szPackage,&hPackage);
369 ok( res == ERROR_SUCCESS , "Failed to open package\n" );
371 res = MsiCloseHandle(hdb);
372 ok( res == ERROR_SUCCESS , "Failed to close db handle\n" );
374 return hPackage;
377 static void create_test_file(const CHAR *name)
379 HANDLE file;
380 DWORD written;
382 file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
383 ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name);
384 WriteFile(file, name, strlen(name), &written, NULL);
385 WriteFile(file, "\n", strlen("\n"), &written, NULL);
386 CloseHandle(file);
389 static void test_createpackage(void)
391 MSIHANDLE hPackage = 0;
392 UINT res;
394 hPackage = package_from_db(create_package_db());
395 ok( hPackage != 0, " Failed to create package\n");
397 res = MsiCloseHandle( hPackage);
398 ok( res == ERROR_SUCCESS , "Failed to close package\n" );
399 DeleteFile(msifile);
402 static void test_getsourcepath_bad( void )
404 static const char str[] = { 0 };
405 char buffer[0x80];
406 DWORD sz;
407 UINT r;
409 r = MsiGetSourcePath( -1, NULL, NULL, NULL );
410 ok( r == ERROR_INVALID_PARAMETER, "return value wrong\n");
412 sz = 0;
413 r = MsiGetSourcePath( -1, NULL, buffer, &sz );
414 ok( r == ERROR_INVALID_PARAMETER, "return value wrong\n");
416 sz = 0;
417 r = MsiGetSourcePath( -1, str, NULL, &sz );
418 ok( r == ERROR_INVALID_HANDLE, "return value wrong\n");
420 sz = 0;
421 r = MsiGetSourcePath( -1, str, NULL, NULL );
422 ok( r == ERROR_INVALID_HANDLE, "return value wrong\n");
424 sz = 0;
425 r = MsiGetSourcePath( -1, str, buffer, &sz );
426 ok( r == ERROR_INVALID_HANDLE, "return value wrong\n");
429 static UINT add_directory_entry( MSIHANDLE hdb, const char *values )
431 char insert[] = "INSERT INTO `Directory` (`Directory`,`Directory_Parent`,`DefaultDir`) VALUES( %s )";
432 char *query;
433 UINT sz, r;
435 sz = strlen(values) + sizeof insert;
436 query = HeapAlloc(GetProcessHeap(),0,sz);
437 sprintf(query,insert,values);
438 r = run_query( hdb, query );
439 HeapFree(GetProcessHeap(), 0, query);
440 return r;
443 static void test_getsourcepath( void )
445 static const char str[] = { 0 };
446 char buffer[0x80];
447 DWORD sz;
448 UINT r;
449 MSIHANDLE hpkg, hdb;
451 hpkg = package_from_db(create_package_db());
452 ok( hpkg, "failed to create package\n");
454 sz = 0;
455 buffer[0] = 'x';
456 r = MsiGetSourcePath( hpkg, str, buffer, &sz );
457 ok( r == ERROR_DIRECTORY, "return value wrong\n");
458 ok( buffer[0] == 'x', "buffer modified\n");
460 sz = 1;
461 buffer[0] = 'x';
462 r = MsiGetSourcePath( hpkg, str, buffer, &sz );
463 ok( r == ERROR_DIRECTORY, "return value wrong\n");
464 ok( buffer[0] == 'x', "buffer modified\n");
466 MsiCloseHandle( hpkg );
469 /* another test but try create a directory this time */
470 hdb = create_package_db();
471 ok( hdb, "failed to create database\n");
473 r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
474 ok( r == S_OK, "failed\n");
476 hpkg = package_from_db(hdb);
477 ok( hpkg, "failed to create package\n");
479 sz = sizeof buffer -1;
480 strcpy(buffer,"x bad");
481 r = MsiGetSourcePath( hpkg, "TARGETDIR", buffer, &sz );
482 ok( r == ERROR_DIRECTORY, "return value wrong\n");
484 r = MsiDoAction( hpkg, "CostInitialize");
485 ok( r == ERROR_SUCCESS, "cost init failed\n");
486 r = MsiDoAction( hpkg, "CostFinalize");
487 ok( r == ERROR_SUCCESS, "cost finalize failed\n");
489 sz = sizeof buffer -1;
490 buffer[0] = 'x';
491 r = MsiGetSourcePath( hpkg, "TARGETDIR", buffer, &sz );
492 ok( r == ERROR_SUCCESS, "return value wrong\n");
493 ok( sz == strlen(buffer), "returned length wrong\n");
495 sz = 0;
496 strcpy(buffer,"x bad");
497 r = MsiGetSourcePath( hpkg, "TARGETDIR", buffer, &sz );
498 ok( r == ERROR_MORE_DATA, "return value wrong\n");
499 ok( buffer[0] == 'x', "buffer modified\n");
501 r = MsiGetSourcePath( hpkg, "TARGETDIR", NULL, NULL );
502 ok( r == ERROR_SUCCESS, "return value wrong\n");
504 r = MsiGetSourcePath( hpkg, "TARGETDIR ", NULL, NULL );
505 ok( r == ERROR_DIRECTORY, "return value wrong\n");
507 r = MsiGetSourcePath( hpkg, "targetdir", NULL, NULL );
508 ok( r == ERROR_DIRECTORY, "return value wrong\n");
510 r = MsiGetSourcePath( hpkg, "TARGETDIR", buffer, NULL );
511 ok( r == ERROR_INVALID_PARAMETER, "return value wrong\n");
513 r = MsiGetSourcePath( hpkg, "TARGETDIR", NULL, &sz );
514 ok( r == ERROR_SUCCESS, "return value wrong\n");
516 MsiCloseHandle( hpkg );
517 DeleteFile(msifile);
520 static void test_doaction( void )
522 MSIHANDLE hpkg;
523 UINT r;
525 r = MsiDoAction( -1, NULL );
526 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
528 hpkg = package_from_db(create_package_db());
529 ok( hpkg, "failed to create package\n");
531 r = MsiDoAction(hpkg, NULL);
532 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
534 r = MsiDoAction(0, "boo");
535 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
537 r = MsiDoAction(hpkg, "boo");
538 ok( r == ERROR_FUNCTION_NOT_CALLED, "wrong return val\n");
540 MsiCloseHandle( hpkg );
541 DeleteFile(msifile);
544 static void test_gettargetpath_bad(void)
546 char buffer[0x80];
547 MSIHANDLE hpkg;
548 DWORD sz;
549 UINT r;
551 hpkg = package_from_db(create_package_db());
552 ok( hpkg, "failed to create package\n");
554 r = MsiGetTargetPath( 0, NULL, NULL, NULL );
555 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
557 r = MsiGetTargetPath( 0, NULL, NULL, &sz );
558 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
560 r = MsiGetTargetPath( 0, "boo", NULL, NULL );
561 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
563 r = MsiGetTargetPath( 0, "boo", NULL, NULL );
564 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
566 r = MsiGetTargetPath( hpkg, "boo", NULL, NULL );
567 ok( r == ERROR_DIRECTORY, "wrong return val\n");
569 r = MsiGetTargetPath( hpkg, "boo", buffer, NULL );
570 ok( r == ERROR_DIRECTORY, "wrong return val\n");
572 MsiCloseHandle( hpkg );
573 DeleteFile(msifile);
576 static void query_file_path(MSIHANDLE hpkg, LPCSTR file, LPSTR buff)
578 UINT r;
579 DWORD size;
580 MSIHANDLE rec;
582 rec = MsiCreateRecord( 1 );
583 ok(rec, "MsiCreate record failed\n");
585 r = MsiRecordSetString( rec, 0, file );
586 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
588 size = MAX_PATH;
589 r = MsiFormatRecord( hpkg, rec, buff, &size );
590 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
592 MsiCloseHandle( rec );
595 static void test_settargetpath(void)
597 char tempdir[MAX_PATH+8], buffer[MAX_PATH], file[MAX_PATH];
598 DWORD sz;
599 MSIHANDLE hpkg;
600 UINT r;
601 MSIHANDLE hdb;
603 hdb = create_package_db();
604 ok ( hdb, "failed to create package database\n" );
606 r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'" );
607 ok( r == S_OK, "failed to add directory entry: %d\n" , r );
609 r = create_component_table( hdb );
610 ok( r == S_OK, "cannot create Component table: %d\n", r );
612 r = add_component_entry( hdb, "'RootComp', '{83e2694d-0864-4124-9323-6d37630912a1}', 'TARGETDIR', 8, '', 'RootFile'" );
613 ok( r == S_OK, "cannot add dummy component: %d\n", r );
615 r = add_component_entry( hdb, "'TestComp', '{A3FB59C8-C293-4F7E-B8C5-F0E1D8EEE4E5}', 'TestDir', 0, '', 'TestFile'" );
616 ok( r == S_OK, "cannot add test component: %d\n", r );
618 r = create_feature_table( hdb );
619 ok( r == S_OK, "cannot create Feature table: %d\n", r );
621 r = add_feature_entry( hdb, "'TestFeature', '', '', '', 0, 1, '', 0" );
622 ok( r == ERROR_SUCCESS, "cannot add TestFeature to Feature table: %d\n", r );
624 r = create_feature_components_table( hdb );
625 ok( r == S_OK, "cannot create FeatureComponents table: %d\n", r );
627 r = add_feature_components_entry( hdb, "'TestFeature', 'RootComp'" );
628 ok( r == S_OK, "cannot insert component into FeatureComponents table: %d\n", r );
630 r = add_feature_components_entry( hdb, "'TestFeature', 'TestComp'" );
631 ok( r == S_OK, "cannot insert component into FeatureComponents table: %d\n", r );
633 add_directory_entry( hdb, "'TestParent', 'TARGETDIR', 'TestParent'" );
634 add_directory_entry( hdb, "'TestDir', 'TestParent', 'TestDir'" );
636 r = create_file_table( hdb );
637 ok( r == S_OK, "cannot create File table: %d\n", r );
639 r = add_file_entry( hdb, "'RootFile', 'RootComp', 'rootfile.txt', 0, '', '1033', 8192, 1" );
640 ok( r == S_OK, "cannot add file to the File table: %d\n", r );
642 r = add_file_entry( hdb, "'TestFile', 'TestComp', 'testfile.txt', 0, '', '1033', 8192, 1" );
643 ok( r == S_OK, "cannot add file to the File table: %d\n", r );
645 hpkg = package_from_db( hdb );
646 ok( hpkg, "failed to create package\n");
648 r = MsiDoAction( hpkg, "CostInitialize");
649 ok( r == ERROR_SUCCESS, "cost init failed\n");
651 r = MsiDoAction( hpkg, "FileCost");
652 ok( r == ERROR_SUCCESS, "file cost failed\n");
654 r = MsiDoAction( hpkg, "CostFinalize");
655 ok( r == ERROR_SUCCESS, "cost finalize failed\n");
657 r = MsiSetTargetPath( 0, NULL, NULL );
658 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
660 r = MsiSetTargetPath( 0, "boo", "C:\\bogusx" );
661 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
663 r = MsiSetTargetPath( hpkg, "boo", NULL );
664 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
666 r = MsiSetTargetPath( hpkg, "boo", "c:\\bogusx" );
667 ok( r == ERROR_DIRECTORY, "wrong return val\n");
669 sz = sizeof tempdir - 1;
670 r = MsiGetTargetPath( hpkg, "TARGETDIR", tempdir, &sz );
671 sprintf( file, "%srootfile.txt", tempdir );
672 query_file_path( hpkg, "[#RootFile]", buffer );
673 ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
674 ok( !lstrcmp(buffer, file), "Expected %s, got %s\n", file, buffer );
676 GetTempFileName( tempdir, "_wt", 0, buffer );
677 sprintf( tempdir, "%s\\subdir", buffer );
679 r = MsiSetTargetPath( hpkg, "TARGETDIR", buffer );
680 ok( r == ERROR_SUCCESS, "MsiSetTargetPath on file returned %d\n", r );
682 r = MsiSetTargetPath( hpkg, "TARGETDIR", tempdir );
683 ok( r == ERROR_SUCCESS, "MsiSetTargetPath on 'subdir' of file returned %d\n", r );
685 DeleteFile( buffer );
687 r = MsiSetTargetPath( hpkg, "TARGETDIR", buffer );
688 ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
690 r = GetFileAttributes( buffer );
691 ok ( r == INVALID_FILE_ATTRIBUTES, "file/directory exists after MsiSetTargetPath. Attributes: %08X\n", r );
693 r = MsiSetTargetPath( hpkg, "TARGETDIR", tempdir );
694 ok( r == ERROR_SUCCESS, "MsiSetTargetPath on subsubdir returned %d\n", r );
696 sz = sizeof buffer - 1;
697 lstrcat( tempdir, "\\" );
698 r = MsiGetTargetPath( hpkg, "TARGETDIR", buffer, &sz );
699 ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
700 ok( !lstrcmp(buffer, tempdir), "Expected %s, got %s\n", tempdir, buffer);
702 sprintf( file, "%srootfile.txt", tempdir );
703 query_file_path( hpkg, "[#RootFile]", buffer );
704 ok( !lstrcmp(buffer, file), "Expected %s, got %s\n", file, buffer);
706 r = MsiSetTargetPath( hpkg, "TestParent", "C:\\one\\two" );
707 ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
709 query_file_path( hpkg, "[#TestFile]", buffer );
710 ok( !lstrcmp(buffer, "C:\\one\\two\\TestDir\\testfile.txt"),
711 "Expected C:\\one\\two\\TestDir\\testfile.txt, got %s\n", buffer );
713 sz = sizeof buffer - 1;
714 r = MsiGetTargetPath( hpkg, "TestParent", buffer, &sz );
715 ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
716 ok( !lstrcmp(buffer, "C:\\one\\two\\"), "Expected C:\\one\\two\\, got %s\n", buffer);
718 MsiCloseHandle( hpkg );
721 static void test_condition(void)
723 MSICONDITION r;
724 MSIHANDLE hpkg;
726 hpkg = package_from_db(create_package_db());
727 ok( hpkg, "failed to create package\n");
729 r = MsiEvaluateCondition(0, NULL);
730 ok( r == MSICONDITION_ERROR, "wrong return val\n");
732 r = MsiEvaluateCondition(hpkg, NULL);
733 ok( r == MSICONDITION_NONE, "wrong return val\n");
735 r = MsiEvaluateCondition(hpkg, "");
736 ok( r == MSICONDITION_NONE, "wrong return val\n");
738 r = MsiEvaluateCondition(hpkg, "1");
739 ok( r == MSICONDITION_TRUE, "wrong return val\n");
741 r = MsiEvaluateCondition(hpkg, "0");
742 ok( r == MSICONDITION_FALSE, "wrong return val\n");
744 r = MsiEvaluateCondition(hpkg, "0 = 0");
745 ok( r == MSICONDITION_TRUE, "wrong return val\n");
747 r = MsiEvaluateCondition(hpkg, "0 <> 0");
748 ok( r == MSICONDITION_FALSE, "wrong return val\n");
750 r = MsiEvaluateCondition(hpkg, "0 = 1");
751 ok( r == MSICONDITION_FALSE, "wrong return val\n");
753 r = MsiEvaluateCondition(hpkg, "0 > 1");
754 ok( r == MSICONDITION_FALSE, "wrong return val\n");
756 r = MsiEvaluateCondition(hpkg, "0 ~> 1");
757 ok( r == MSICONDITION_FALSE, "wrong return val\n");
759 r = MsiEvaluateCondition(hpkg, "1 > 1");
760 ok( r == MSICONDITION_FALSE, "wrong return val\n");
762 r = MsiEvaluateCondition(hpkg, "1 ~> 1");
763 ok( r == MSICONDITION_FALSE, "wrong return val\n");
765 r = MsiEvaluateCondition(hpkg, "0 >= 1");
766 ok( r == MSICONDITION_FALSE, "wrong return val\n");
768 r = MsiEvaluateCondition(hpkg, "0 ~>= 1");
769 ok( r == MSICONDITION_FALSE, "wrong return val\n");
771 r = MsiEvaluateCondition(hpkg, "1 >= 1");
772 ok( r == MSICONDITION_TRUE, "wrong return val\n");
774 r = MsiEvaluateCondition(hpkg, "1 ~>= 1");
775 ok( r == MSICONDITION_TRUE, "wrong return val\n");
777 r = MsiEvaluateCondition(hpkg, "0 < 1");
778 ok( r == MSICONDITION_TRUE, "wrong return val\n");
780 r = MsiEvaluateCondition(hpkg, "0 ~< 1");
781 ok( r == MSICONDITION_TRUE, "wrong return val\n");
783 r = MsiEvaluateCondition(hpkg, "1 < 1");
784 ok( r == MSICONDITION_FALSE, "wrong return val\n");
786 r = MsiEvaluateCondition(hpkg, "1 ~< 1");
787 ok( r == MSICONDITION_FALSE, "wrong return val\n");
789 r = MsiEvaluateCondition(hpkg, "0 <= 1");
790 ok( r == MSICONDITION_TRUE, "wrong return val\n");
792 r = MsiEvaluateCondition(hpkg, "0 ~<= 1");
793 ok( r == MSICONDITION_TRUE, "wrong return val\n");
795 r = MsiEvaluateCondition(hpkg, "1 <= 1");
796 ok( r == MSICONDITION_TRUE, "wrong return val\n");
798 r = MsiEvaluateCondition(hpkg, "1 ~<= 1");
799 ok( r == MSICONDITION_TRUE, "wrong return val\n");
801 r = MsiEvaluateCondition(hpkg, "0 >=");
802 ok( r == MSICONDITION_ERROR, "wrong return val\n");
804 r = MsiEvaluateCondition(hpkg, " ");
805 ok( r == MSICONDITION_NONE, "wrong return val\n");
807 r = MsiEvaluateCondition(hpkg, "LicView <> \"1\"");
808 ok( r == MSICONDITION_TRUE, "wrong return val\n");
810 r = MsiEvaluateCondition(hpkg, "LicView <> \"0\"");
811 ok( r == MSICONDITION_TRUE, "wrong return val\n");
813 r = MsiEvaluateCondition(hpkg, "LicView <> LicView");
814 ok( r == MSICONDITION_FALSE, "wrong return val\n");
816 r = MsiEvaluateCondition(hpkg, "not 0");
817 ok( r == MSICONDITION_TRUE, "wrong return val\n");
819 r = MsiEvaluateCondition(hpkg, "not LicView");
820 ok( r == MSICONDITION_TRUE, "wrong return val\n");
822 r = MsiEvaluateCondition(hpkg, "not \"A\"");
823 ok( r == MSICONDITION_FALSE, "wrong return val\n");
825 r = MsiEvaluateCondition(hpkg, "~not \"A\"");
826 ok( r == MSICONDITION_ERROR, "wrong return val\n");
828 r = MsiEvaluateCondition(hpkg, "\"0\"");
829 ok( r == MSICONDITION_TRUE, "wrong return val\n");
831 r = MsiEvaluateCondition(hpkg, "1 and 2");
832 ok( r == MSICONDITION_TRUE, "wrong return val\n");
834 r = MsiEvaluateCondition(hpkg, "not 0 and 3");
835 ok( r == MSICONDITION_TRUE, "wrong return val\n");
837 r = MsiEvaluateCondition(hpkg, "not 0 and 0");
838 ok( r == MSICONDITION_FALSE, "wrong return val\n");
840 r = MsiEvaluateCondition(hpkg, "not 0 or 1");
841 ok( r == MSICONDITION_TRUE, "wrong return val\n");
843 r = MsiEvaluateCondition(hpkg, "(0)");
844 ok( r == MSICONDITION_FALSE, "wrong return val\n");
846 r = MsiEvaluateCondition(hpkg, "(((((1))))))");
847 ok( r == MSICONDITION_ERROR, "wrong return val\n");
849 r = MsiEvaluateCondition(hpkg, "(((((1)))))");
850 ok( r == MSICONDITION_TRUE, "wrong return val\n");
852 r = MsiEvaluateCondition(hpkg, " \"A\" < \"B\" ");
853 ok( r == MSICONDITION_TRUE, "wrong return val\n");
855 r = MsiEvaluateCondition(hpkg, " \"A\" > \"B\" ");
856 ok( r == MSICONDITION_FALSE, "wrong return val\n");
858 r = MsiEvaluateCondition(hpkg, " \"1\" > \"12\" ");
859 ok( r == MSICONDITION_FALSE, "wrong return val\n");
861 r = MsiEvaluateCondition(hpkg, " \"100\" < \"21\" ");
862 ok( r == MSICONDITION_TRUE, "wrong return val\n");
864 r = MsiEvaluateCondition(hpkg, "0 < > 0");
865 ok( r == MSICONDITION_ERROR, "wrong return val\n");
867 r = MsiEvaluateCondition(hpkg, "(1<<1) == 2");
868 ok( r == MSICONDITION_ERROR, "wrong return val\n");
870 r = MsiEvaluateCondition(hpkg, " \"A\" = \"a\" ");
871 ok( r == MSICONDITION_FALSE, "wrong return val\n");
873 r = MsiEvaluateCondition(hpkg, " \"A\" ~ = \"a\" ");
874 ok( r == MSICONDITION_ERROR, "wrong return val\n");
876 r = MsiEvaluateCondition(hpkg, " \"A\" ~= \"a\" ");
877 ok( r == MSICONDITION_TRUE, "wrong return val\n");
879 r = MsiEvaluateCondition(hpkg, " \"A\" ~= 1 ");
880 ok( r == MSICONDITION_FALSE, "wrong return val\n");
882 r = MsiEvaluateCondition(hpkg, " \"A\" = 1 ");
883 ok( r == MSICONDITION_FALSE, "wrong return val\n");
885 r = MsiEvaluateCondition(hpkg, " 1 ~= 1 ");
886 ok( r == MSICONDITION_TRUE, "wrong return val\n");
888 r = MsiEvaluateCondition(hpkg, " 1 ~= \"1\" ");
889 ok( r == MSICONDITION_FALSE, "wrong return val\n");
891 r = MsiEvaluateCondition(hpkg, " 1 = \"1\" ");
892 ok( r == MSICONDITION_FALSE, "wrong return val\n");
894 r = MsiEvaluateCondition(hpkg, " 0 = \"1\" ");
895 ok( r == MSICONDITION_FALSE, "wrong return val\n");
897 r = MsiEvaluateCondition(hpkg, " 0 < \"100\" ");
898 ok( r == MSICONDITION_FALSE, "wrong return val\n");
900 r = MsiEvaluateCondition(hpkg, " 100 > \"0\" ");
901 ok( r == MSICONDITION_FALSE, "wrong return val\n");
903 r = MsiEvaluateCondition(hpkg, "1 XOR 1");
904 ok( r == MSICONDITION_FALSE, "wrong return val\n");
906 r = MsiEvaluateCondition(hpkg, "1 IMP 1");
907 ok( r == MSICONDITION_TRUE, "wrong return val\n");
909 r = MsiEvaluateCondition(hpkg, "1 IMP 0");
910 ok( r == MSICONDITION_FALSE, "wrong return val\n");
912 r = MsiEvaluateCondition(hpkg, "0 IMP 0");
913 ok( r == MSICONDITION_TRUE, "wrong return val\n");
915 r = MsiEvaluateCondition(hpkg, "0 EQV 0");
916 ok( r == MSICONDITION_TRUE, "wrong return val\n");
918 r = MsiEvaluateCondition(hpkg, "0 EQV 1");
919 ok( r == MSICONDITION_FALSE, "wrong return val\n");
921 r = MsiEvaluateCondition(hpkg, "1 IMP 1 OR 0");
922 ok( r == MSICONDITION_TRUE, "wrong return val\n");
924 r = MsiEvaluateCondition(hpkg, "1 IMPL 1");
925 ok( r == MSICONDITION_ERROR, "wrong return val\n");
927 r = MsiEvaluateCondition(hpkg, "\"ASFD\" >< \"S\" ");
928 ok( r == MSICONDITION_TRUE, "wrong return val\n");
930 r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"s\" ");
931 ok( r == MSICONDITION_TRUE, "wrong return val\n");
933 r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"\" ");
934 ok( r == MSICONDITION_TRUE, "wrong return val\n");
936 r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"sss\" ");
937 ok( r == MSICONDITION_FALSE, "wrong return val\n");
939 MsiSetProperty(hpkg, "mm", "5" );
941 r = MsiEvaluateCondition(hpkg, "mm = 5");
942 ok( r == MSICONDITION_TRUE, "wrong return val\n");
944 r = MsiEvaluateCondition(hpkg, "mm < 6");
945 ok( r == MSICONDITION_TRUE, "wrong return val\n");
947 r = MsiEvaluateCondition(hpkg, "mm <= 5");
948 ok( r == MSICONDITION_TRUE, "wrong return val\n");
950 r = MsiEvaluateCondition(hpkg, "mm > 4");
951 ok( r == MSICONDITION_TRUE, "wrong return val\n");
953 r = MsiEvaluateCondition(hpkg, "mm < 12");
954 ok( r == MSICONDITION_TRUE, "wrong return val\n");
956 r = MsiEvaluateCondition(hpkg, "mm = \"5\"");
957 ok( r == MSICONDITION_TRUE, "wrong return val\n");
959 r = MsiEvaluateCondition(hpkg, "0 = \"\"");
960 ok( r == MSICONDITION_FALSE, "wrong return val\n");
962 r = MsiEvaluateCondition(hpkg, "0 AND \"\"");
963 ok( r == MSICONDITION_FALSE, "wrong return val\n");
965 r = MsiEvaluateCondition(hpkg, "1 AND \"\"");
966 ok( r == MSICONDITION_FALSE, "wrong return val\n");
968 r = MsiEvaluateCondition(hpkg, "1 AND \"1\"");
969 ok( r == MSICONDITION_TRUE, "wrong return val\n");
971 r = MsiEvaluateCondition(hpkg, "3 >< 1");
972 ok( r == MSICONDITION_TRUE, "wrong return val\n");
974 r = MsiEvaluateCondition(hpkg, "3 >< 4");
975 ok( r == MSICONDITION_FALSE, "wrong return val\n");
977 r = MsiEvaluateCondition(hpkg, "NOT 0 AND 0");
978 ok( r == MSICONDITION_FALSE, "wrong return val\n");
980 r = MsiEvaluateCondition(hpkg, "NOT 0 AND 1");
981 ok( r == MSICONDITION_TRUE, "wrong return val\n");
983 r = MsiEvaluateCondition(hpkg, "NOT 1 OR 0");
984 ok( r == MSICONDITION_FALSE, "wrong return val\n");
986 r = MsiEvaluateCondition(hpkg, "0 AND 1 OR 1");
987 ok( r == MSICONDITION_TRUE, "wrong return val\n");
989 r = MsiEvaluateCondition(hpkg, "0 AND 0 OR 1");
990 ok( r == MSICONDITION_TRUE, "wrong return val\n");
992 r = MsiEvaluateCondition(hpkg, "NOT 0 AND 1 OR 0");
993 ok( r == MSICONDITION_TRUE, "wrong return val\n");
995 r = MsiEvaluateCondition(hpkg, "_1 = _1");
996 ok( r == MSICONDITION_TRUE, "wrong return val\n");
998 r = MsiEvaluateCondition(hpkg, "( 1 AND 1 ) = 2");
999 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1001 r = MsiEvaluateCondition(hpkg, "NOT ( 1 AND 1 )");
1002 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1004 r = MsiEvaluateCondition(hpkg, "NOT A AND (BBBBBBBBBB=2 OR CCC=1) AND Ddddddddd");
1005 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1007 r = MsiEvaluateCondition(hpkg, "Installed<>\"\"");
1008 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1010 r = MsiEvaluateCondition(hpkg, "NOT 1 AND 0");
1011 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1013 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1014 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1016 r = MsiEvaluateCondition(hpkg, "bandalmael<>0");
1017 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1019 r = MsiEvaluateCondition(hpkg, "bandalmael<0");
1020 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1022 r = MsiEvaluateCondition(hpkg, "bandalmael>0");
1023 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1025 r = MsiEvaluateCondition(hpkg, "bandalmael>=0");
1026 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1028 r = MsiEvaluateCondition(hpkg, "bandalmael<=0");
1029 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1031 r = MsiEvaluateCondition(hpkg, "bandalmael~<>0");
1032 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1034 MsiSetProperty(hpkg, "bandalmael", "0" );
1035 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1036 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1038 MsiSetProperty(hpkg, "bandalmael", "" );
1039 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1040 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1042 MsiSetProperty(hpkg, "bandalmael", "asdf" );
1043 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1044 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1046 MsiSetProperty(hpkg, "bandalmael", "0asdf" );
1047 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1048 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1050 MsiSetProperty(hpkg, "bandalmael", "0 " );
1051 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1052 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1054 MsiSetProperty(hpkg, "bandalmael", "-0" );
1055 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1056 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1058 MsiSetProperty(hpkg, "bandalmael", "0000000000000" );
1059 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1060 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1062 MsiSetProperty(hpkg, "bandalmael", "--0" );
1063 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1064 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1066 MsiSetProperty(hpkg, "bandalmael", "0x00" );
1067 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1068 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1070 MsiSetProperty(hpkg, "bandalmael", "-" );
1071 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1072 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1074 MsiSetProperty(hpkg, "bandalmael", "+0" );
1075 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1076 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1078 MsiSetProperty(hpkg, "bandalmael", "0.0" );
1079 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1080 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1081 r = MsiEvaluateCondition(hpkg, "bandalmael<>0");
1082 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1084 MsiSetProperty(hpkg, "one", "hi");
1085 MsiSetProperty(hpkg, "two", "hithere");
1086 r = MsiEvaluateCondition(hpkg, "one >< two");
1087 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1089 MsiSetProperty(hpkg, "one", "hithere");
1090 MsiSetProperty(hpkg, "two", "hi");
1091 r = MsiEvaluateCondition(hpkg, "one >< two");
1092 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1094 MsiSetProperty(hpkg, "one", "hello");
1095 MsiSetProperty(hpkg, "two", "hi");
1096 r = MsiEvaluateCondition(hpkg, "one >< two");
1097 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1099 MsiSetProperty(hpkg, "one", "hellohithere");
1100 MsiSetProperty(hpkg, "two", "hi");
1101 r = MsiEvaluateCondition(hpkg, "one >< two");
1102 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1104 MsiSetProperty(hpkg, "one", "");
1105 MsiSetProperty(hpkg, "two", "hi");
1106 r = MsiEvaluateCondition(hpkg, "one >< two");
1107 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1109 MsiSetProperty(hpkg, "one", "hi");
1110 MsiSetProperty(hpkg, "two", "");
1111 r = MsiEvaluateCondition(hpkg, "one >< two");
1112 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1114 MsiSetProperty(hpkg, "one", "");
1115 MsiSetProperty(hpkg, "two", "");
1116 r = MsiEvaluateCondition(hpkg, "one >< two");
1117 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1119 MsiSetProperty(hpkg, "one", "1234");
1120 MsiSetProperty(hpkg, "two", "1");
1121 r = MsiEvaluateCondition(hpkg, "one >< two");
1122 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1124 MsiSetProperty(hpkg, "one", "one 1234");
1125 MsiSetProperty(hpkg, "two", "1");
1126 r = MsiEvaluateCondition(hpkg, "one >< two");
1127 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1129 MsiSetProperty(hpkg, "one", "hithere");
1130 MsiSetProperty(hpkg, "two", "hi");
1131 r = MsiEvaluateCondition(hpkg, "one << two");
1132 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1134 MsiSetProperty(hpkg, "one", "hi");
1135 MsiSetProperty(hpkg, "two", "hithere");
1136 r = MsiEvaluateCondition(hpkg, "one << two");
1137 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1139 MsiSetProperty(hpkg, "one", "hi");
1140 MsiSetProperty(hpkg, "two", "hi");
1141 r = MsiEvaluateCondition(hpkg, "one << two");
1142 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1144 MsiSetProperty(hpkg, "one", "abcdhithere");
1145 MsiSetProperty(hpkg, "two", "hi");
1146 r = MsiEvaluateCondition(hpkg, "one << two");
1147 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1149 MsiSetProperty(hpkg, "one", "");
1150 MsiSetProperty(hpkg, "two", "hi");
1151 r = MsiEvaluateCondition(hpkg, "one << two");
1152 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1154 MsiSetProperty(hpkg, "one", "hithere");
1155 MsiSetProperty(hpkg, "two", "");
1156 r = MsiEvaluateCondition(hpkg, "one << two");
1157 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1159 MsiSetProperty(hpkg, "one", "");
1160 MsiSetProperty(hpkg, "two", "");
1161 r = MsiEvaluateCondition(hpkg, "one << two");
1162 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1164 MsiSetProperty(hpkg, "one", "1234");
1165 MsiSetProperty(hpkg, "two", "1");
1166 r = MsiEvaluateCondition(hpkg, "one << two");
1167 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1169 MsiSetProperty(hpkg, "one", "1234 one");
1170 MsiSetProperty(hpkg, "two", "1");
1171 r = MsiEvaluateCondition(hpkg, "one << two");
1172 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1174 MsiSetProperty(hpkg, "one", "hithere");
1175 MsiSetProperty(hpkg, "two", "there");
1176 r = MsiEvaluateCondition(hpkg, "one >> two");
1177 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1179 MsiSetProperty(hpkg, "one", "hithere");
1180 MsiSetProperty(hpkg, "two", "hi");
1181 r = MsiEvaluateCondition(hpkg, "one >> two");
1182 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1184 MsiSetProperty(hpkg, "one", "there");
1185 MsiSetProperty(hpkg, "two", "hithere");
1186 r = MsiEvaluateCondition(hpkg, "one >> two");
1187 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1189 MsiSetProperty(hpkg, "one", "there");
1190 MsiSetProperty(hpkg, "two", "there");
1191 r = MsiEvaluateCondition(hpkg, "one >> two");
1192 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1194 MsiSetProperty(hpkg, "one", "abcdhithere");
1195 MsiSetProperty(hpkg, "two", "hi");
1196 r = MsiEvaluateCondition(hpkg, "one >> two");
1197 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1199 MsiSetProperty(hpkg, "one", "");
1200 MsiSetProperty(hpkg, "two", "there");
1201 r = MsiEvaluateCondition(hpkg, "one >> two");
1202 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1204 MsiSetProperty(hpkg, "one", "there");
1205 MsiSetProperty(hpkg, "two", "");
1206 r = MsiEvaluateCondition(hpkg, "one >> two");
1207 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1209 MsiSetProperty(hpkg, "one", "");
1210 MsiSetProperty(hpkg, "two", "");
1211 r = MsiEvaluateCondition(hpkg, "one >> two");
1212 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1214 MsiSetProperty(hpkg, "one", "1234");
1215 MsiSetProperty(hpkg, "two", "4");
1216 r = MsiEvaluateCondition(hpkg, "one >> two");
1217 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1219 MsiSetProperty(hpkg, "one", "one 1234");
1220 MsiSetProperty(hpkg, "two", "4");
1221 r = MsiEvaluateCondition(hpkg, "one >> two");
1222 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1224 MsiSetProperty(hpkg, "MsiNetAssemblySupport", NULL); /* make sure it's empty */
1226 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322\"");
1227 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1229 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport > \"1.1.4322\"");
1230 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1232 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport >= \"1.1.4322\"");
1233 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1235 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport <= \"1.1.4322\"");
1236 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1238 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport <> \"1.1.4322\"");
1239 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1241 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport ~< \"1.1.4322\"");
1242 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1244 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"abcd\"");
1245 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1247 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a1.1.4322\"");
1248 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1250 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322a\"");
1251 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1253 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"0000001.1.4322\"");
1254 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1256 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322.1\"");
1257 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1259 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322.1.1\"");
1260 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1262 r = MsiEvaluateCondition(hpkg, "\"2\" < \"1.1");
1263 ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1265 r = MsiEvaluateCondition(hpkg, "\"2\" < \"1.1\"");
1266 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1268 r = MsiEvaluateCondition(hpkg, "\"2\" < \"12.1\"");
1269 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1271 r = MsiEvaluateCondition(hpkg, "\"02.1\" < \"2.11\"");
1272 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1274 r = MsiEvaluateCondition(hpkg, "\"02.1.1\" < \"2.1\"");
1275 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1277 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1\"");
1278 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1280 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1\"");
1281 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1283 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"0\"");
1284 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1286 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"-1\"");
1287 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1289 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a\"");
1290 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1292 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"!\"");
1293 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1295 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"!\"");
1296 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1298 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"/\"");
1299 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1301 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \" \"");
1302 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1304 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"azAZ_\"");
1305 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1307 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a[a]\"");
1308 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1310 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a[a]a\"");
1311 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1313 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[a]\"");
1314 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1316 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[a]a\"");
1317 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1319 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"{a}\"");
1320 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1322 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"{a\"");
1323 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1325 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[a\"");
1326 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1328 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a{\"");
1329 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1331 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a]\"");
1332 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1334 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"A\"");
1335 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1337 MsiSetProperty(hpkg, "MsiNetAssemblySupport", "1.1.4322");
1338 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322\"");
1339 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1341 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.14322\"");
1342 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1344 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.5\"");
1345 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1347 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1\"");
1348 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1350 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1\"");
1351 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1353 MsiSetProperty(hpkg, "one", "1");
1354 r = MsiEvaluateCondition(hpkg, "one < \"1\"");
1355 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1357 MsiSetProperty(hpkg, "X", "5.0");
1359 r = MsiEvaluateCondition(hpkg, "X != \"\"");
1360 ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1362 r = MsiEvaluateCondition(hpkg, "X =\"5.0\"");
1363 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1365 r = MsiEvaluateCondition(hpkg, "X =\"5.1\"");
1366 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1368 r = MsiEvaluateCondition(hpkg, "X =\"6.0\"");
1369 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1371 r = MsiEvaluateCondition(hpkg, "X =\"5.0\" or X =\"5.1\" or X =\"6.0\"");
1372 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1374 r = MsiEvaluateCondition(hpkg, "(X =\"5.0\" or X =\"5.1\" or X =\"6.0\")");
1375 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1377 r = MsiEvaluateCondition(hpkg, "X !=\"\" and (X =\"5.0\" or X =\"5.1\" or X =\"6.0\")");
1378 ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1380 MsiCloseHandle( hpkg );
1381 DeleteFile(msifile);
1384 static BOOL check_prop_empty( MSIHANDLE hpkg, const char * prop)
1386 UINT r;
1387 DWORD sz;
1388 char buffer[2];
1390 sz = sizeof buffer;
1391 strcpy(buffer,"x");
1392 r = MsiGetProperty( hpkg, prop, buffer, &sz );
1393 return r == ERROR_SUCCESS && buffer[0] == 0 && sz == 0;
1396 static void test_props(void)
1398 MSIHANDLE hpkg, hdb;
1399 UINT r;
1400 DWORD sz;
1401 char buffer[0x100];
1403 hdb = create_package_db();
1404 r = run_query( hdb,
1405 "CREATE TABLE `Property` ( "
1406 "`Property` CHAR(255) NOT NULL, "
1407 "`Value` CHAR(255) "
1408 "PRIMARY KEY `Property`)" );
1409 ok( r == ERROR_SUCCESS , "Failed\n" );
1411 r = run_query(hdb,
1412 "INSERT INTO `Property` "
1413 "(`Property`, `Value`) "
1414 "VALUES( 'MetadataCompName', 'Photoshop.dll' )");
1415 ok( r == ERROR_SUCCESS , "Failed\n" );
1417 hpkg = package_from_db( hdb );
1418 ok( hpkg, "failed to create package\n");
1420 /* test invalid values */
1421 r = MsiGetProperty( 0, NULL, NULL, NULL );
1422 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1424 r = MsiGetProperty( hpkg, NULL, NULL, NULL );
1425 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1427 r = MsiGetProperty( hpkg, "boo", NULL, NULL );
1428 ok( r == ERROR_SUCCESS, "wrong return val\n");
1430 r = MsiGetProperty( hpkg, "boo", buffer, NULL );
1431 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1433 /* test retrieving an empty/nonexistent property */
1434 sz = sizeof buffer;
1435 r = MsiGetProperty( hpkg, "boo", NULL, &sz );
1436 ok( r == ERROR_SUCCESS, "wrong return val\n");
1437 ok( sz == 0, "wrong size returned\n");
1439 check_prop_empty( hpkg, "boo");
1440 sz = 0;
1441 strcpy(buffer,"x");
1442 r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1443 ok( r == ERROR_MORE_DATA, "wrong return val\n");
1444 ok( !strcmp(buffer,"x"), "buffer was changed\n");
1445 ok( sz == 0, "wrong size returned\n");
1447 sz = 1;
1448 strcpy(buffer,"x");
1449 r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1450 ok( r == ERROR_SUCCESS, "wrong return val\n");
1451 ok( buffer[0] == 0, "buffer was not changed\n");
1452 ok( sz == 0, "wrong size returned\n");
1454 /* set the property to something */
1455 r = MsiSetProperty( 0, NULL, NULL );
1456 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
1458 r = MsiSetProperty( hpkg, NULL, NULL );
1459 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1461 r = MsiSetProperty( hpkg, "", NULL );
1462 ok( r == ERROR_SUCCESS, "wrong return val\n");
1464 /* try set and get some illegal property identifiers */
1465 r = MsiSetProperty( hpkg, "", "asdf" );
1466 ok( r == ERROR_FUNCTION_FAILED, "wrong return val\n");
1468 r = MsiSetProperty( hpkg, "=", "asdf" );
1469 ok( r == ERROR_SUCCESS, "wrong return val\n");
1471 r = MsiSetProperty( hpkg, " ", "asdf" );
1472 ok( r == ERROR_SUCCESS, "wrong return val\n");
1474 r = MsiSetProperty( hpkg, "'", "asdf" );
1475 ok( r == ERROR_SUCCESS, "wrong return val\n");
1477 sz = sizeof buffer;
1478 buffer[0]=0;
1479 r = MsiGetProperty( hpkg, "'", buffer, &sz );
1480 ok( r == ERROR_SUCCESS, "wrong return val\n");
1481 ok( !strcmp(buffer,"asdf"), "buffer was not changed\n");
1483 /* set empty values */
1484 r = MsiSetProperty( hpkg, "boo", NULL );
1485 ok( r == ERROR_SUCCESS, "wrong return val\n");
1486 ok( check_prop_empty( hpkg, "boo"), "prop wasn't empty\n");
1488 r = MsiSetProperty( hpkg, "boo", "" );
1489 ok( r == ERROR_SUCCESS, "wrong return val\n");
1490 ok( check_prop_empty( hpkg, "boo"), "prop wasn't empty\n");
1492 /* set a non-empty value */
1493 r = MsiSetProperty( hpkg, "boo", "xyz" );
1494 ok( r == ERROR_SUCCESS, "wrong return val\n");
1496 sz = 1;
1497 strcpy(buffer,"x");
1498 r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1499 ok( r == ERROR_MORE_DATA, "wrong return val\n");
1500 ok( buffer[0] == 0, "buffer was not changed\n");
1501 ok( sz == 3, "wrong size returned\n");
1503 sz = 4;
1504 strcpy(buffer,"x");
1505 r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1506 ok( r == ERROR_SUCCESS, "wrong return val\n");
1507 ok( !strcmp(buffer,"xyz"), "buffer was not changed\n");
1508 ok( sz == 3, "wrong size returned\n");
1510 sz = 3;
1511 strcpy(buffer,"x");
1512 r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1513 ok( r == ERROR_MORE_DATA, "wrong return val\n");
1514 ok( !strcmp(buffer,"xy"), "buffer was not changed\n");
1515 ok( sz == 3, "wrong size returned\n");
1517 r = MsiSetProperty(hpkg, "SourceDir", "foo");
1518 ok( r == ERROR_SUCCESS, "wrong return val\n");
1520 sz = 4;
1521 r = MsiGetProperty(hpkg, "SOURCEDIR", buffer, &sz);
1522 ok( r == ERROR_SUCCESS, "wrong return val\n");
1523 ok( !strcmp(buffer,""), "buffer wrong\n");
1524 ok( sz == 0, "wrong size returned\n");
1526 sz = 4;
1527 r = MsiGetProperty(hpkg, "SOMERANDOMNAME", buffer, &sz);
1528 ok( r == ERROR_SUCCESS, "wrong return val\n");
1529 ok( !strcmp(buffer,""), "buffer wrong\n");
1530 ok( sz == 0, "wrong size returned\n");
1532 sz = 4;
1533 r = MsiGetProperty(hpkg, "SourceDir", buffer, &sz);
1534 ok( r == ERROR_SUCCESS, "wrong return val\n");
1535 ok( !strcmp(buffer,"foo"), "buffer wrong\n");
1536 ok( sz == 3, "wrong size returned\n");
1538 r = MsiSetProperty(hpkg, "MetadataCompName", "Photoshop.dll");
1539 ok( r == ERROR_SUCCESS, "wrong return val\n");
1541 sz = 0;
1542 r = MsiGetProperty(hpkg, "MetadataCompName", NULL, &sz );
1543 ok( r == ERROR_SUCCESS, "return wrong\n");
1544 ok( sz == 13, "size wrong (%d)\n", sz);
1546 sz = 13;
1547 r = MsiGetProperty(hpkg, "MetadataCompName", buffer, &sz );
1548 ok( r == ERROR_MORE_DATA, "return wrong\n");
1549 ok( !strcmp(buffer,"Photoshop.dl"), "buffer wrong\n");
1551 r = MsiSetProperty(hpkg, "property", "value");
1552 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1554 sz = 6;
1555 r = MsiGetProperty(hpkg, "property", buffer, &sz);
1556 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1557 ok( !strcmp(buffer, "value"), "Expected value, got %s\n", buffer);
1559 r = MsiSetProperty(hpkg, "property", NULL);
1560 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1562 sz = 6;
1563 r = MsiGetProperty(hpkg, "property", buffer, &sz);
1564 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1565 ok( !strlen(buffer), "Expected empty string, got %s\n", buffer);
1567 MsiCloseHandle( hpkg );
1568 DeleteFile(msifile);
1571 static void test_properties_table(void)
1573 const char *query;
1574 UINT r;
1575 MSIHANDLE hpkg, hdb;
1576 char buffer[0x10];
1577 DWORD sz;
1579 hdb = create_package_db();
1580 ok( hdb, "failed to create package\n");
1582 hpkg = package_from_db(hdb);
1583 ok( hpkg, "failed to create package\n");
1585 query = "CREATE TABLE `_Properties` ( "
1586 "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
1587 r = run_query(hdb, query);
1588 ok(r == ERROR_INVALID_HANDLE, "failed to create table\n");
1590 MsiCloseHandle( hpkg );
1591 DeleteFile(msifile);
1593 hdb = create_package_db();
1594 ok( hdb, "failed to create package\n");
1596 query = "CREATE TABLE `_Properties` ( "
1597 "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
1598 r = run_query(hdb, query);
1599 ok(r == ERROR_SUCCESS, "failed to create table\n");
1601 query = "ALTER `_Properties` ADD `foo` INTEGER";
1602 r = run_query(hdb, query);
1603 ok(r == ERROR_BAD_QUERY_SYNTAX, "failed to add column\n");
1605 query = "ALTER TABLE `_Properties` ADD `foo` INTEGER";
1606 r = run_query(hdb, query);
1607 ok(r == ERROR_BAD_QUERY_SYNTAX, "failed to add column\n");
1609 query = "ALTER TABLE `_Properties` ADD `extra` INTEGER";
1610 r = run_query(hdb, query);
1611 todo_wine ok(r == ERROR_SUCCESS, "failed to add column\n");
1613 hpkg = package_from_db(hdb);
1614 ok( hpkg, "failed to create package\n");
1616 r = MsiSetProperty( hpkg, "foo", "bar");
1617 ok(r == ERROR_SUCCESS, "failed to create table\n");
1619 sz = sizeof buffer;
1620 r = MsiGetProperty( hpkg, "foo", buffer, &sz);
1621 ok(r == ERROR_SUCCESS, "failed to create table\n");
1623 MsiCloseHandle( hpkg );
1624 DeleteFile(msifile);
1627 static UINT try_query_param( MSIHANDLE hdb, LPCSTR szQuery, MSIHANDLE hrec )
1629 MSIHANDLE htab = 0;
1630 UINT res;
1632 res = MsiDatabaseOpenView( hdb, szQuery, &htab );
1633 if( res == ERROR_SUCCESS )
1635 UINT r;
1637 r = MsiViewExecute( htab, hrec );
1638 if( r != ERROR_SUCCESS )
1640 res = r;
1641 fprintf(stderr,"MsiViewExecute failed %08x\n", res);
1644 r = MsiViewClose( htab );
1645 if( r != ERROR_SUCCESS )
1646 res = r;
1648 r = MsiCloseHandle( htab );
1649 if( r != ERROR_SUCCESS )
1650 res = r;
1652 return res;
1655 static UINT try_query( MSIHANDLE hdb, LPCSTR szQuery )
1657 return try_query_param( hdb, szQuery, 0 );
1660 static void test_msipackage(void)
1662 MSIHANDLE hdb = 0, hpack = 100;
1663 UINT r;
1664 const char *query;
1665 char name[10];
1667 DeleteFile(msifile);
1669 todo_wine {
1670 name[0] = 0;
1671 r = MsiOpenPackage(name, &hpack);
1672 ok(r == ERROR_SUCCESS, "failed to open package with no name\n");
1673 r = MsiCloseHandle(hpack);
1674 ok(r == ERROR_SUCCESS, "failed to close package\n");
1677 /* just MsiOpenDatabase should not create a file */
1678 r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
1679 ok(r == ERROR_SUCCESS, "MsiOpenDatabase failed\n");
1681 name[0]='#';
1682 name[1]=0;
1683 r = MsiOpenPackage(name, &hpack);
1684 ok(r == ERROR_INVALID_HANDLE, "MsiOpenPackage returned wrong code\n");
1686 todo_wine {
1687 /* now try again with our empty database */
1688 sprintf(name, "#%ld", hdb);
1689 r = MsiOpenPackage(name, &hpack);
1690 ok(r == ERROR_INSTALL_PACKAGE_INVALID, "MsiOpenPackage returned wrong code\n");
1691 if (!r) MsiCloseHandle(hpack);
1694 /* create a table */
1695 query = "CREATE TABLE `Property` ( "
1696 "`Property` CHAR(72), `Value` CHAR(0) "
1697 "PRIMARY KEY `Property`)";
1698 r = try_query(hdb, query);
1699 ok(r == ERROR_SUCCESS, "failed to create Properties table\n");
1701 query = "CREATE TABLE `InstallExecuteSequence` ("
1702 "`Action` CHAR(72), `Condition` CHAR(0), `Sequence` INTEGER "
1703 "PRIMARY KEY `Action`)";
1704 r = try_query(hdb, query);
1705 ok(r == ERROR_SUCCESS, "failed to create InstallExecuteSequence table\n");
1707 todo_wine {
1708 sprintf(name, "#%ld", hdb);
1709 r = MsiOpenPackage(name, &hpack);
1710 ok(r == ERROR_INSTALL_PACKAGE_INVALID, "MsiOpenPackage returned wrong code\n");
1711 if (!r) MsiCloseHandle(hpack);
1714 r = MsiCloseHandle(hdb);
1715 ok(r == ERROR_SUCCESS, "MsiCloseHandle(database) failed\n");
1716 DeleteFile(msifile);
1719 static void test_formatrecord2(void)
1721 MSIHANDLE hpkg, hrec ;
1722 char buffer[0x100];
1723 DWORD sz;
1724 UINT r;
1726 hpkg = package_from_db(create_package_db());
1727 ok( hpkg, "failed to create package\n");
1729 r = MsiSetProperty(hpkg, "Manufacturer", " " );
1730 ok( r == ERROR_SUCCESS, "set property failed\n");
1732 hrec = MsiCreateRecord(2);
1733 ok(hrec, "create record failed\n");
1735 r = MsiRecordSetString( hrec, 0, "[ProgramFilesFolder][Manufacturer]\\asdf");
1736 ok( r == ERROR_SUCCESS, "format record failed\n");
1738 buffer[0] = 0;
1739 sz = sizeof buffer;
1740 r = MsiFormatRecord( hpkg, hrec, buffer, &sz );
1742 r = MsiRecordSetString(hrec, 0, "[foo][1]");
1743 r = MsiRecordSetString(hrec, 1, "hoo");
1744 sz = sizeof buffer;
1745 r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
1746 ok( sz == 3, "size wrong\n");
1747 ok( 0 == strcmp(buffer,"hoo"), "wrong output %s\n",buffer);
1748 ok( r == ERROR_SUCCESS, "format failed\n");
1750 r = MsiRecordSetString(hrec, 0, "x[~]x");
1751 sz = sizeof buffer;
1752 r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
1753 ok( sz == 3, "size wrong\n");
1754 ok( 0 == strcmp(buffer,"x"), "wrong output %s\n",buffer);
1755 ok( r == ERROR_SUCCESS, "format failed\n");
1757 r = MsiRecordSetString(hrec, 0, "[foo.$%}][1]");
1758 r = MsiRecordSetString(hrec, 1, "hoo");
1759 sz = sizeof buffer;
1760 r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
1761 ok( sz == 3, "size wrong\n");
1762 ok( 0 == strcmp(buffer,"hoo"), "wrong output %s\n",buffer);
1763 ok( r == ERROR_SUCCESS, "format failed\n");
1765 r = MsiRecordSetString(hrec, 0, "[\\[]");
1766 sz = sizeof buffer;
1767 r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
1768 ok( sz == 1, "size wrong\n");
1769 ok( 0 == strcmp(buffer,"["), "wrong output %s\n",buffer);
1770 ok( r == ERROR_SUCCESS, "format failed\n");
1772 SetEnvironmentVariable("FOO", "BAR");
1773 r = MsiRecordSetString(hrec, 0, "[%FOO]");
1774 sz = sizeof buffer;
1775 r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
1776 ok( sz == 3, "size wrong\n");
1777 ok( 0 == strcmp(buffer,"BAR"), "wrong output %s\n",buffer);
1778 ok( r == ERROR_SUCCESS, "format failed\n");
1780 r = MsiRecordSetString(hrec, 0, "[[1]]");
1781 r = MsiRecordSetString(hrec, 1, "%FOO");
1782 sz = sizeof buffer;
1783 r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
1784 ok( sz == 3, "size wrong\n");
1785 ok( 0 == strcmp(buffer,"BAR"), "wrong output %s\n",buffer);
1786 ok( r == ERROR_SUCCESS, "format failed\n");
1788 MsiCloseHandle( hrec );
1789 MsiCloseHandle( hpkg );
1790 DeleteFile(msifile);
1793 static void test_states(void)
1795 MSIHANDLE hpkg;
1796 UINT r;
1797 MSIHANDLE hdb;
1798 INSTALLSTATE state, action;
1800 hdb = create_package_db();
1801 ok ( hdb, "failed to create package database\n" );
1803 r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
1804 ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
1806 r = create_feature_table( hdb );
1807 ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
1809 r = create_component_table( hdb );
1810 ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
1812 /* msidbFeatureAttributesFavorLocal */
1813 r = add_feature_entry( hdb, "'one', '', '', '', 2, 1, '', 0" );
1814 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
1816 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
1817 r = add_component_entry( hdb, "'alpha', '{467EC132-739D-4784-A37B-677AA43DBC94}', 'TARGETDIR', 0, '', 'alpha_file'" );
1818 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
1820 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
1821 r = add_component_entry( hdb, "'beta', '{2C1F189C-24A6-4C34-B26B-994A6C026506}', 'TARGETDIR', 1, '', 'beta_file'" );
1822 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
1824 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
1825 r = add_component_entry( hdb, "'gamma', '{C271E2A4-DE2E-4F70-86D1-6984AF7DE2CA}', 'TARGETDIR', 2, '', 'gamma_file'" );
1826 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
1828 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSharedDllRefCount */
1829 r = add_component_entry( hdb, "'theta', '{4EB3129D-81A8-48D5-9801-75600FED3DD9}', 'TARGETDIR', 8, '', 'theta_file'" );
1830 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
1832 /* msidbFeatureAttributesFavorSource */
1833 r = add_feature_entry( hdb, "'two', '', '', '', 2, 1, '', 1" );
1834 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
1836 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
1837 r = add_component_entry( hdb, "'delta', '{938FD4F2-C648-4259-A03C-7AA3B45643F3}', 'TARGETDIR', 0, '', 'delta_file'" );
1838 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
1840 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
1841 r = add_component_entry( hdb, "'epsilon', '{D59713B6-C11D-47F2-A395-1E5321781190}', 'TARGETDIR', 1, '', 'epsilon_file'" );
1842 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
1844 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
1845 r = add_component_entry( hdb, "'zeta', '{377D33AB-2FAA-42B9-A629-0C0DAE9B9C7A}', 'TARGETDIR', 2, '', 'zeta_file'" );
1846 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
1848 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSharedDllRefCount */
1849 r = add_component_entry( hdb, "'iota', '{5D36F871-B5ED-4801-9E0F-C46B9E5C9669}', 'TARGETDIR', 8, '', 'iota_file'" );
1850 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
1852 /* msidbFeatureAttributesFavorSource */
1853 r = add_feature_entry( hdb, "'three', '', '', '', 2, 1, '', 1" );
1854 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
1856 /* msidbFeatureAttributesFavorLocal */
1857 r = add_feature_entry( hdb, "'four', '', '', '', 2, 1, '', 0" );
1858 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
1860 /* disabled */
1861 r = add_feature_entry( hdb, "'five', '', '', '', 2, 0, '', 1" );
1862 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
1864 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
1865 r = add_component_entry( hdb, "'eta', '{DD89003F-0DD4-41B8-81C0-3411A7DA2695}', 'TARGETDIR', 1, '', 'eta_file'" );
1866 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
1868 /* no feature parent:msidbComponentAttributesLocalOnly */
1869 r = add_component_entry( hdb, "'kappa', '{D6B93DC3-8DA5-4769-9888-42BFE156BB8B}', 'TARGETDIR', 1, '', 'kappa_file'" );
1870 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
1872 r = create_feature_components_table( hdb );
1873 ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
1875 r = add_feature_components_entry( hdb, "'one', 'alpha'" );
1876 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
1878 r = add_feature_components_entry( hdb, "'one', 'beta'" );
1879 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
1881 r = add_feature_components_entry( hdb, "'one', 'gamma'" );
1882 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
1884 r = add_feature_components_entry( hdb, "'one', 'theta'" );
1885 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
1887 r = add_feature_components_entry( hdb, "'two', 'delta'" );
1888 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
1890 r = add_feature_components_entry( hdb, "'two', 'epsilon'" );
1891 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
1893 r = add_feature_components_entry( hdb, "'two', 'zeta'" );
1894 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
1896 r = add_feature_components_entry( hdb, "'two', 'iota'" );
1897 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
1899 r = add_feature_components_entry( hdb, "'three', 'eta'" );
1900 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
1902 r = add_feature_components_entry( hdb, "'four', 'eta'" );
1903 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
1905 r = add_feature_components_entry( hdb, "'five', 'eta'" );
1906 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
1908 r = create_file_table( hdb );
1909 ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
1911 r = add_file_entry( hdb, "'alpha_file', 'alpha', 'alpha.txt', 100, '', '1033', 8192, 1" );
1912 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
1914 r = add_file_entry( hdb, "'beta_file', 'beta', 'beta.txt', 0, '', '1033', 8192, 1" );
1915 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
1917 r = add_file_entry( hdb, "'gamma_file', 'gamma', 'gamma.txt', 0, '', '1033', 8192, 1" );
1918 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
1920 r = add_file_entry( hdb, "'theta_file', 'theta', 'theta.txt', 0, '', '1033', 8192, 1" );
1921 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
1923 r = add_file_entry( hdb, "'delta_file', 'delta', 'delta.txt', 0, '', '1033', 8192, 1" );
1924 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
1926 r = add_file_entry( hdb, "'epsilon_file', 'epsilon', 'epsilon.txt', 0, '', '1033', 8192, 1" );
1927 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
1929 r = add_file_entry( hdb, "'zeta_file', 'zeta', 'zeta.txt', 0, '', '1033', 8192, 1" );
1930 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
1932 r = add_file_entry( hdb, "'iota_file', 'iota', 'iota.txt', 0, '', '1033', 8192, 1" );
1933 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
1935 /* compressed file */
1936 r = add_file_entry( hdb, "'eta_file', 'eta', 'eta.txt', 0, '', '1033', 16384, 1" );
1937 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
1939 r = add_file_entry( hdb, "'kappa_file', 'kappa', 'kappa.txt', 0, '', '1033', 8192, 1" );
1940 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
1942 hpkg = package_from_db( hdb );
1943 ok( hpkg, "failed to create package\n");
1945 MsiCloseHandle( hdb );
1947 state = 0xdeadbee;
1948 action = 0xdeadbee;
1949 r = MsiGetFeatureState(hpkg, "one", &state, &action);
1950 ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
1951 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
1952 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
1954 state = 0xdeadbee;
1955 action = 0xdeadbee;
1956 r = MsiGetFeatureState(hpkg, "two", &state, &action);
1957 ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
1958 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
1959 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
1961 state = 0xdeadbee;
1962 action = 0xdeadbee;
1963 r = MsiGetFeatureState(hpkg, "three", &state, &action);
1964 ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
1965 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
1966 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
1968 state = 0xdeadbee;
1969 action = 0xdeadbee;
1970 r = MsiGetFeatureState(hpkg, "four", &state, &action);
1971 ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
1972 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
1973 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
1975 state = 0xdeadbee;
1976 action = 0xdeadbee;
1977 r = MsiGetFeatureState(hpkg, "five", &state, &action);
1978 ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
1979 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
1980 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
1982 state = 0xdeadbee;
1983 action = 0xdeadbee;
1984 r = MsiGetComponentState(hpkg, "alpha", &state, &action);
1985 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
1986 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
1987 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
1989 state = 0xdeadbee;
1990 action = 0xdeadbee;
1991 r = MsiGetComponentState(hpkg, "beta", &state, &action);
1992 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
1993 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
1994 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
1996 state = 0xdeadbee;
1997 action = 0xdeadbee;
1998 r = MsiGetComponentState(hpkg, "gamma", &state, &action);
1999 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2000 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2001 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2003 state = 0xdeadbee;
2004 action = 0xdeadbee;
2005 r = MsiGetComponentState(hpkg, "theta", &state, &action);
2006 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2007 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2008 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2010 state = 0xdeadbee;
2011 action = 0xdeadbee;
2012 r = MsiGetComponentState(hpkg, "delta", &state, &action);
2013 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2014 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2015 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2017 state = 0xdeadbee;
2018 action = 0xdeadbee;
2019 r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
2020 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2021 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2022 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2024 state = 0xdeadbee;
2025 action = 0xdeadbee;
2026 r = MsiGetComponentState(hpkg, "zeta", &state, &action);
2027 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2028 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2029 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2031 state = 0xdeadbee;
2032 action = 0xdeadbee;
2033 r = MsiGetComponentState(hpkg, "iota", &state, &action);
2034 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2035 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2036 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2038 state = 0xdeadbee;
2039 action = 0xdeadbee;
2040 r = MsiGetComponentState(hpkg, "eta", &state, &action);
2041 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2042 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2043 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2045 state = 0xdeadbee;
2046 action = 0xdeadbee;
2047 r = MsiGetComponentState(hpkg, "kappa", &state, &action);
2048 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2049 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2050 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2052 r = MsiDoAction( hpkg, "CostInitialize");
2053 ok( r == ERROR_SUCCESS, "cost init failed\n");
2055 state = 0xdeadbee;
2056 action = 0xdeadbee;
2057 r = MsiGetFeatureState(hpkg, "one", &state, &action);
2058 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2059 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2060 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2062 state = 0xdeadbee;
2063 action = 0xdeadbee;
2064 r = MsiGetFeatureState(hpkg, "two", &state, &action);
2065 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2066 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2067 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2069 state = 0xdeadbee;
2070 action = 0xdeadbee;
2071 r = MsiGetFeatureState(hpkg, "three", &state, &action);
2072 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2073 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2074 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2076 state = 0xdeadbee;
2077 action = 0xdeadbee;
2078 r = MsiGetFeatureState(hpkg, "four", &state, &action);
2079 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2080 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2081 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2083 state = 0xdeadbee;
2084 action = 0xdeadbee;
2085 r = MsiGetFeatureState(hpkg, "five", &state, &action);
2086 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2087 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2088 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2090 state = 0xdeadbee;
2091 action = 0xdeadbee;
2092 r = MsiGetComponentState(hpkg, "alpha", &state, &action);
2093 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2094 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2095 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2097 state = 0xdeadbee;
2098 action = 0xdeadbee;
2099 r = MsiGetComponentState(hpkg, "beta", &state, &action);
2100 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2101 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2102 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2104 state = 0xdeadbee;
2105 action = 0xdeadbee;
2106 r = MsiGetComponentState(hpkg, "gamma", &state, &action);
2107 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2108 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2109 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2111 state = 0xdeadbee;
2112 action = 0xdeadbee;
2113 r = MsiGetComponentState(hpkg, "theta", &state, &action);
2114 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2115 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2116 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2118 state = 0xdeadbee;
2119 action = 0xdeadbee;
2120 r = MsiGetComponentState(hpkg, "delta", &state, &action);
2121 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2122 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2123 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2125 state = 0xdeadbee;
2126 action = 0xdeadbee;
2127 r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
2128 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2129 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2130 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2132 state = 0xdeadbee;
2133 action = 0xdeadbee;
2134 r = MsiGetComponentState(hpkg, "zeta", &state, &action);
2135 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2136 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2137 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2139 state = 0xdeadbee;
2140 action = 0xdeadbee;
2141 r = MsiGetComponentState(hpkg, "iota", &state, &action);
2142 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2143 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2144 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2146 state = 0xdeadbee;
2147 action = 0xdeadbee;
2148 r = MsiGetComponentState(hpkg, "eta", &state, &action);
2149 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2150 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2151 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2153 state = 0xdeadbee;
2154 action = 0xdeadbee;
2155 r = MsiGetComponentState(hpkg, "kappa", &state, &action);
2156 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2157 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2158 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2160 r = MsiDoAction( hpkg, "FileCost");
2161 ok( r == ERROR_SUCCESS, "file cost failed\n");
2163 state = 0xdeadbee;
2164 action = 0xdeadbee;
2165 r = MsiGetFeatureState(hpkg, "one", &state, &action);
2166 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2167 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2168 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2170 state = 0xdeadbee;
2171 action = 0xdeadbee;
2172 r = MsiGetFeatureState(hpkg, "two", &state, &action);
2173 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2174 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2175 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2177 state = 0xdeadbee;
2178 action = 0xdeadbee;
2179 r = MsiGetFeatureState(hpkg, "three", &state, &action);
2180 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2181 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2182 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2184 state = 0xdeadbee;
2185 action = 0xdeadbee;
2186 r = MsiGetFeatureState(hpkg, "four", &state, &action);
2187 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2188 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2189 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2191 state = 0xdeadbee;
2192 action = 0xdeadbee;
2193 r = MsiGetFeatureState(hpkg, "five", &state, &action);
2194 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2195 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2196 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2198 state = 0xdeadbee;
2199 action = 0xdeadbee;
2200 r = MsiGetComponentState(hpkg, "alpha", &state, &action);
2201 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2202 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2203 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2205 state = 0xdeadbee;
2206 action = 0xdeadbee;
2207 r = MsiGetComponentState(hpkg, "beta", &state, &action);
2208 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2209 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2210 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2212 state = 0xdeadbee;
2213 action = 0xdeadbee;
2214 r = MsiGetComponentState(hpkg, "gamma", &state, &action);
2215 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2216 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2217 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2219 state = 0xdeadbee;
2220 action = 0xdeadbee;
2221 r = MsiGetComponentState(hpkg, "theta", &state, &action);
2222 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2223 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2224 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2226 state = 0xdeadbee;
2227 action = 0xdeadbee;
2228 r = MsiGetComponentState(hpkg, "delta", &state, &action);
2229 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2230 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2231 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2233 state = 0xdeadbee;
2234 action = 0xdeadbee;
2235 r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
2236 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2237 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2238 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2240 state = 0xdeadbee;
2241 action = 0xdeadbee;
2242 r = MsiGetComponentState(hpkg, "zeta", &state, &action);
2243 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2244 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2245 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2247 state = 0xdeadbee;
2248 action = 0xdeadbee;
2249 r = MsiGetComponentState(hpkg, "iota", &state, &action);
2250 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2251 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2252 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2254 state = 0xdeadbee;
2255 action = 0xdeadbee;
2256 r = MsiGetComponentState(hpkg, "eta", &state, &action);
2257 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2258 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2259 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2261 state = 0xdeadbee;
2262 action = 0xdeadbee;
2263 r = MsiGetComponentState(hpkg, "kappa", &state, &action);
2264 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2265 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2266 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2268 r = MsiDoAction( hpkg, "CostFinalize");
2269 ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
2271 state = 0xdeadbee;
2272 action = 0xdeadbee;
2273 r = MsiGetFeatureState(hpkg, "one", &state, &action);
2274 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2275 ok( state == INSTALLSTATE_ABSENT, "Expected one INSTALLSTATE_ABSENT, got %d\n", state);
2276 ok( action == INSTALLSTATE_LOCAL, "Expected one INSTALLSTATE_LOCAL, got %d\n", action);
2278 state = 0xdeadbee;
2279 action = 0xdeadbee;
2280 r = MsiGetFeatureState(hpkg, "two", &state, &action);
2281 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2282 ok( state == INSTALLSTATE_ABSENT, "Expected two INSTALLSTATE_ABSENT, got %d\n", state);
2283 ok( action == INSTALLSTATE_SOURCE, "Expected two INSTALLSTATE_SOURCE, got %d\n", action);
2285 state = 0xdeadbee;
2286 action = 0xdeadbee;
2287 r = MsiGetFeatureState(hpkg, "three", &state, &action);
2288 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2289 ok( state == INSTALLSTATE_ABSENT, "Expected three INSTALLSTATE_ABSENT, got %d\n", state);
2290 ok( action == INSTALLSTATE_LOCAL, "Expected three INSTALLSTATE_LOCAL, got %d\n", action);
2292 state = 0xdeadbee;
2293 action = 0xdeadbee;
2294 r = MsiGetFeatureState(hpkg, "four", &state, &action);
2295 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2296 ok( state == INSTALLSTATE_ABSENT, "Expected four INSTALLSTATE_ABSENT, got %d\n", state);
2297 ok( action == INSTALLSTATE_LOCAL, "Expected four INSTALLSTATE_LOCAL, got %d\n", action);
2299 state = 0xdeadbee;
2300 action = 0xdeadbee;
2301 r = MsiGetFeatureState(hpkg, "five", &state, &action);
2302 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2303 ok( state == INSTALLSTATE_ABSENT, "Expected five INSTALLSTATE_ABSENT, got %d\n", state);
2304 ok( action == INSTALLSTATE_UNKNOWN, "Expected five INSTALLSTATE_UNKNOWN, got %d\n", action);
2306 state = 0xdeadbee;
2307 action = 0xdeadbee;
2308 r = MsiGetComponentState(hpkg, "alpha", &state, &action);
2309 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2310 ok( state == INSTALLSTATE_ABSENT, "Expected alpha INSTALLSTATE_ABSENT, got %d\n", state);
2311 ok( action == INSTALLSTATE_LOCAL, "Expected alpha INSTALLSTATE_LOCAL, got %d\n", action);
2313 state = 0xdeadbee;
2314 action = 0xdeadbee;
2315 r = MsiGetComponentState(hpkg, "beta", &state, &action);
2316 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2317 ok( state == INSTALLSTATE_ABSENT, "Expected beta INSTALLSTATE_ABSENT, got %d\n", state);
2318 ok( action == INSTALLSTATE_SOURCE, "Expected beta INSTALLSTATE_SOURCE, got %d\n", action);
2320 state = 0xdeadbee;
2321 action = 0xdeadbee;
2322 r = MsiGetComponentState(hpkg, "gamma", &state, &action);
2323 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2324 ok( state == INSTALLSTATE_ABSENT, "Expected gamma INSTALLSTATE_ABSENT, got %d\n", state);
2325 ok( action == INSTALLSTATE_LOCAL, "Expected gamma INSTALLSTATE_LOCAL, got %d\n", action);
2327 state = 0xdeadbee;
2328 action = 0xdeadbee;
2329 r = MsiGetComponentState(hpkg, "theta", &state, &action);
2330 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2331 ok( state == INSTALLSTATE_ABSENT, "Expected theta INSTALLSTATE_ABSENT, got %d\n", state);
2332 ok( action == INSTALLSTATE_LOCAL, "Expected theta INSTALLSTATE_LOCAL, got %d\n", action);
2334 state = 0xdeadbee;
2335 action = 0xdeadbee;
2336 r = MsiGetComponentState(hpkg, "delta", &state, &action);
2337 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2338 ok( state == INSTALLSTATE_ABSENT, "Expected delta INSTALLSTATE_ABSENT, got %d\n", state);
2339 ok( action == INSTALLSTATE_LOCAL, "Expected delta INSTALLSTATE_LOCAL, got %d\n", action);
2341 state = 0xdeadbee;
2342 action = 0xdeadbee;
2343 r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
2344 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2345 ok( state == INSTALLSTATE_ABSENT, "Expected epsilon INSTALLSTATE_ABSENT, got %d\n", state);
2346 ok( action == INSTALLSTATE_SOURCE, "Expected epsilon INSTALLSTATE_SOURCE, got %d\n", action);
2348 state = 0xdeadbee;
2349 action = 0xdeadbee;
2350 r = MsiGetComponentState(hpkg, "zeta", &state, &action);
2351 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2352 ok( state == INSTALLSTATE_ABSENT, "Expected zeta INSTALLSTATE_ABSENT, got %d\n", state);
2353 ok( action == INSTALLSTATE_SOURCE, "Expected zeta INSTALLSTATE_SOURCE, got %d\n", action);
2355 state = 0xdeadbee;
2356 action = 0xdeadbee;
2357 r = MsiGetComponentState(hpkg, "iota", &state, &action);
2358 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2359 ok( state == INSTALLSTATE_ABSENT, "Expected iota INSTALLSTATE_ABSENT, got %d\n", state);
2360 ok( action == INSTALLSTATE_LOCAL, "Expected iota INSTALLSTATE_LOCAL, got %d\n", action);
2362 state = 0xdeadbee;
2363 action = 0xdeadbee;
2364 r = MsiGetComponentState(hpkg, "eta", &state, &action);
2365 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2366 ok( state == INSTALLSTATE_ABSENT, "Expected eta INSTALLSTATE_ABSENT, got %d\n", state);
2367 ok( action == INSTALLSTATE_LOCAL, "Expected eta INSTALLSTATE_LOCAL, got %d\n", action);
2369 state = 0xdeadbee;
2370 action = 0xdeadbee;
2371 r = MsiGetComponentState(hpkg, "kappa", &state, &action);
2372 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2373 ok( state == INSTALLSTATE_ABSENT, "Expected kappa INSTALLSTATE_ABSENT, got %d\n", state);
2374 ok( action == INSTALLSTATE_UNKNOWN, "Expected kappa INSTALLSTATE_UNKNOWN, got %d\n", action);
2376 MsiCloseHandle( hpkg );
2377 DeleteFileA( msifile );
2380 static void test_getproperty(void)
2382 MSIHANDLE hPackage = 0;
2383 char prop[100];
2384 static CHAR empty[] = "";
2385 DWORD size;
2386 UINT r;
2388 hPackage = package_from_db(create_package_db());
2389 ok( hPackage != 0, " Failed to create package\n");
2391 /* set the property */
2392 r = MsiSetProperty(hPackage, "Name", "Value");
2393 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2395 /* retrieve the size, NULL pointer */
2396 size = 0;
2397 r = MsiGetProperty(hPackage, "Name", NULL, &size);
2398 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2399 ok( size == 5, "Expected 5, got %d\n", size);
2401 /* retrieve the size, empty string */
2402 size = 0;
2403 r = MsiGetProperty(hPackage, "Name", empty, &size);
2404 ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
2405 ok( size == 5, "Expected 5, got %d\n", size);
2407 /* don't change size */
2408 r = MsiGetProperty(hPackage, "Name", prop, &size);
2409 ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
2410 ok( size == 5, "Expected 5, got %d\n", size);
2411 ok( !lstrcmp(prop, "Valu"), "Expected Valu, got %s\n", prop);
2413 /* increase the size by 1 */
2414 size++;
2415 r = MsiGetProperty(hPackage, "Name", prop, &size);
2416 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2417 ok( size == 5, "Expected 5, got %d\n", size);
2418 ok( !lstrcmp(prop, "Value"), "Expected Value, got %s\n", prop);
2420 r = MsiCloseHandle( hPackage);
2421 ok( r == ERROR_SUCCESS , "Failed to close package\n" );
2422 DeleteFile(msifile);
2425 static void test_removefiles(void)
2427 MSIHANDLE hpkg;
2428 UINT r;
2429 MSIHANDLE hdb;
2430 char CURR_DIR[MAX_PATH];
2432 GetCurrentDirectoryA(MAX_PATH, CURR_DIR);
2434 hdb = create_package_db();
2435 ok ( hdb, "failed to create package database\n" );
2437 r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
2438 ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
2440 r = create_feature_table( hdb );
2441 ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
2443 r = create_component_table( hdb );
2444 ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
2446 r = add_feature_entry( hdb, "'one', '', '', '', 2, 1, '', 0" );
2447 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2449 r = add_component_entry( hdb, "'hydrogen', '', 'TARGETDIR', 0, '', 'hydrogen_file'" );
2450 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2452 r = add_component_entry( hdb, "'helium', '', 'TARGETDIR', 0, '', 'helium_file'" );
2453 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2455 r = add_component_entry( hdb, "'lithium', '', 'TARGETDIR', 0, '', 'lithium_file'" );
2456 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2458 r = add_component_entry( hdb, "'beryllium', '', 'TARGETDIR', 0, '', 'beryllium_file'" );
2459 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2461 r = add_component_entry( hdb, "'boron', '', 'TARGETDIR', 0, '', 'boron_file'" );
2462 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2464 r = add_component_entry( hdb, "'carbon', '', 'TARGETDIR', 0, '', 'carbon_file'" );
2465 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2467 r = create_feature_components_table( hdb );
2468 ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
2470 r = add_feature_components_entry( hdb, "'one', 'hydrogen'" );
2471 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2473 r = add_feature_components_entry( hdb, "'one', 'helium'" );
2474 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2476 r = add_feature_components_entry( hdb, "'one', 'lithium'" );
2477 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2479 r = add_feature_components_entry( hdb, "'one', 'beryllium'" );
2480 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2482 r = add_feature_components_entry( hdb, "'one', 'boron'" );
2483 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2485 r = add_feature_components_entry( hdb, "'one', 'carbon'" );
2486 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2488 r = create_file_table( hdb );
2489 ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
2491 r = add_file_entry( hdb, "'hydrogen_file', 'hydrogen', 'hydrogen.txt', 0, '', '1033', 8192, 1" );
2492 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2494 r = add_file_entry( hdb, "'helium_file', 'helium', 'helium.txt', 0, '', '1033', 8192, 1" );
2495 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2497 r = add_file_entry( hdb, "'lithium_file', 'lithium', 'lithium.txt', 0, '', '1033', 8192, 1" );
2498 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2500 r = add_file_entry( hdb, "'beryllium_file', 'beryllium', 'beryllium.txt', 0, '', '1033', 16384, 1" );
2501 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2503 r = add_file_entry( hdb, "'boron_file', 'boron', 'boron.txt', 0, '', '1033', 16384, 1" );
2504 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2506 r = add_file_entry( hdb, "'carbon_file', 'carbon', 'carbon.txt', 0, '', '1033', 16384, 1" );
2507 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2509 r = create_remove_file_table( hdb );
2510 ok( r == ERROR_SUCCESS, "cannot create Remove File table: %d\n", r);
2512 hpkg = package_from_db( hdb );
2513 ok( hpkg, "failed to create package\n");
2515 MsiCloseHandle( hdb );
2517 create_test_file( "hydrogen.txt" );
2518 create_test_file( "helium.txt" );
2519 create_test_file( "lithium.txt" );
2520 create_test_file( "beryllium.txt" );
2521 create_test_file( "boron.txt" );
2522 create_test_file( "carbon.txt" );
2524 r = MsiSetProperty( hpkg, "TARGETDIR", CURR_DIR );
2525 ok( r == ERROR_SUCCESS, "set property failed\n");
2527 r = MsiDoAction( hpkg, "CostInitialize");
2528 ok( r == ERROR_SUCCESS, "cost init failed\n");
2530 r = MsiDoAction( hpkg, "FileCost");
2531 ok( r == ERROR_SUCCESS, "cost finalize failed\n");
2533 r = MsiDoAction( hpkg, "CostFinalize");
2534 ok( r == ERROR_SUCCESS, "cost finalize failed\n");
2536 r = MsiDoAction( hpkg, "InstallValidate");
2537 ok( r == ERROR_SUCCESS, "cost finalize failed\n");
2539 r = MsiSetComponentState( hpkg, "hydrogen", INSTALLSTATE_ABSENT );
2540 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
2542 r = MsiSetComponentState( hpkg, "helium", INSTALLSTATE_LOCAL );
2543 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
2545 r = MsiSetComponentState( hpkg, "lithium", INSTALLSTATE_SOURCE );
2546 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
2548 r = MsiSetComponentState( hpkg, "beryllium", INSTALLSTATE_ABSENT );
2549 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
2551 r = MsiSetComponentState( hpkg, "boron", INSTALLSTATE_LOCAL );
2552 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
2554 r = MsiSetComponentState( hpkg, "carbon", INSTALLSTATE_SOURCE );
2555 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
2557 r = MsiDoAction( hpkg, "RemoveFiles");
2558 ok( r == ERROR_SUCCESS, "remove files failed\n");
2560 ok(DeleteFileA("hydrogen.txt"), "Expected hydrogen.txt to exist\n");
2561 ok(DeleteFileA("lithium.txt"), "Expected lithium.txt to exist\n");
2562 ok(DeleteFileA("beryllium.txt"), "Expected beryllium.txt to exist\n");
2563 ok(DeleteFileA("carbon.txt"), "Expected carbon.txt to exist\n");
2564 ok(DeleteFileA("helium.txt"), "Expected helium.txt to exist\n");
2565 ok(DeleteFileA("boron.txt"), "Expected boron.txt to exist\n");
2567 MsiCloseHandle( hpkg );
2568 DeleteFileA(msifile);
2571 static void test_appsearch(void)
2573 MSIHANDLE hpkg;
2574 UINT r;
2575 MSIHANDLE hdb;
2576 CHAR prop[MAX_PATH];
2577 DWORD size = MAX_PATH;
2579 hdb = create_package_db();
2580 ok ( hdb, "failed to create package database\n" );
2582 r = create_appsearch_table( hdb );
2583 ok( r == ERROR_SUCCESS, "cannot create AppSearch table: %d\n", r );
2585 r = add_appsearch_entry( hdb, "'WEBBROWSERPROG', 'NewSignature1'" );
2586 ok( r == ERROR_SUCCESS, "cannot add entry: %d\n", r );
2588 r = create_reglocator_table( hdb );
2589 ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
2591 r = add_reglocator_entry( hdb, "'NewSignature1', 0, 'htmlfile\\shell\\open\\command', '', 1" );
2592 ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
2594 r = create_signature_table( hdb );
2595 ok( r == ERROR_SUCCESS, "cannot create Signature table: %d\n", r );
2597 r = add_signature_entry( hdb, "'NewSignature1', 'FileName', '', '', '', '', '', '', ''" );
2598 ok( r == ERROR_SUCCESS, "cannot create Signature table: %d\n", r );
2600 hpkg = package_from_db( hdb );
2601 ok( hpkg, "failed to create package\n");
2603 MsiCloseHandle( hdb );
2605 r = MsiDoAction( hpkg, "AppSearch" );
2606 ok( r == ERROR_SUCCESS, "AppSearch failed: %d\n", r);
2608 r = MsiGetPropertyA( hpkg, "WEBBROWSERPROG", prop, &size );
2609 ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
2610 ok( lstrlenA(prop) != 0, "Expected non-zero length\n");
2612 MsiCloseHandle( hpkg );
2613 DeleteFileA(msifile);
2616 static void test_featureparents(void)
2618 MSIHANDLE hpkg;
2619 UINT r;
2620 MSIHANDLE hdb;
2621 INSTALLSTATE state, action;
2623 hdb = create_package_db();
2624 ok ( hdb, "failed to create package database\n" );
2626 r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
2627 ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
2629 r = create_feature_table( hdb );
2630 ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
2632 r = create_component_table( hdb );
2633 ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
2635 r = create_feature_components_table( hdb );
2636 ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
2638 r = create_file_table( hdb );
2639 ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
2641 /* msidbFeatureAttributesFavorLocal */
2642 r = add_feature_entry( hdb, "'zodiac', '', '', '', 2, 1, '', 0" );
2643 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2645 /* msidbFeatureAttributesFavorSource */
2646 r = add_feature_entry( hdb, "'perseus', '', '', '', 2, 1, '', 1" );
2647 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2649 /* msidbFeatureAttributesFavorLocal */
2650 r = add_feature_entry( hdb, "'orion', '', '', '', 2, 1, '', 0" );
2651 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2653 /* disabled because of install level */
2654 r = add_feature_entry( hdb, "'waters', '', '', '', 15, 101, '', 9" );
2655 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2657 /* child feature of disabled feature */
2658 r = add_feature_entry( hdb, "'bayer', 'waters', '', '', 14, 1, '', 9" );
2659 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2661 /* component of disabled feature (install level) */
2662 r = add_component_entry( hdb, "'delphinus', '', 'TARGETDIR', 0, '', 'delphinus_file'" );
2663 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2665 /* component of disabled child feature (install level) */
2666 r = add_component_entry( hdb, "'hydrus', '', 'TARGETDIR', 0, '', 'hydrus_file'" );
2667 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2669 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
2670 r = add_component_entry( hdb, "'leo', '', 'TARGETDIR', 0, '', 'leo_file'" );
2671 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2673 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
2674 r = add_component_entry( hdb, "'virgo', '', 'TARGETDIR', 1, '', 'virgo_file'" );
2675 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2677 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
2678 r = add_component_entry( hdb, "'libra', '', 'TARGETDIR', 2, '', 'libra_file'" );
2679 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2681 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
2682 r = add_component_entry( hdb, "'cassiopeia', '', 'TARGETDIR', 0, '', 'cassiopeia_file'" );
2683 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2685 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
2686 r = add_component_entry( hdb, "'cepheus', '', 'TARGETDIR', 1, '', 'cepheus_file'" );
2687 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2689 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
2690 r = add_component_entry( hdb, "'andromeda', '', 'TARGETDIR', 2, '', 'andromeda_file'" );
2691 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2693 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
2694 r = add_component_entry( hdb, "'canis', '', 'TARGETDIR', 0, '', 'canis_file'" );
2695 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2697 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
2698 r = add_component_entry( hdb, "'monoceros', '', 'TARGETDIR', 1, '', 'monoceros_file'" );
2699 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2701 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
2702 r = add_component_entry( hdb, "'lepus', '', 'TARGETDIR', 2, '', 'lepus_file'" );
2704 r = add_feature_components_entry( hdb, "'zodiac', 'leo'" );
2705 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2707 r = add_feature_components_entry( hdb, "'zodiac', 'virgo'" );
2708 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2710 r = add_feature_components_entry( hdb, "'zodiac', 'libra'" );
2711 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2713 r = add_feature_components_entry( hdb, "'perseus', 'cassiopeia'" );
2714 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2716 r = add_feature_components_entry( hdb, "'perseus', 'cepheus'" );
2717 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2719 r = add_feature_components_entry( hdb, "'perseus', 'andromeda'" );
2720 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2722 r = add_feature_components_entry( hdb, "'orion', 'leo'" );
2723 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2725 r = add_feature_components_entry( hdb, "'orion', 'virgo'" );
2726 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2728 r = add_feature_components_entry( hdb, "'orion', 'libra'" );
2729 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2731 r = add_feature_components_entry( hdb, "'orion', 'cassiopeia'" );
2732 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2734 r = add_feature_components_entry( hdb, "'orion', 'cepheus'" );
2735 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2737 r = add_feature_components_entry( hdb, "'orion', 'andromeda'" );
2738 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2740 r = add_feature_components_entry( hdb, "'orion', 'canis'" );
2741 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2743 r = add_feature_components_entry( hdb, "'orion', 'monoceros'" );
2744 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2746 r = add_feature_components_entry( hdb, "'orion', 'lepus'" );
2747 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2749 r = add_feature_components_entry( hdb, "'waters', 'delphinus'" );
2750 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2752 r = add_feature_components_entry( hdb, "'bayer', 'hydrus'" );
2753 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2755 r = add_file_entry( hdb, "'leo_file', 'leo', 'leo.txt', 100, '', '1033', 8192, 1" );
2756 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2758 r = add_file_entry( hdb, "'virgo_file', 'virgo', 'virgo.txt', 0, '', '1033', 8192, 1" );
2759 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2761 r = add_file_entry( hdb, "'libra_file', 'libra', 'libra.txt', 0, '', '1033', 8192, 1" );
2762 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2764 r = add_file_entry( hdb, "'cassiopeia_file', 'cassiopeia', 'cassiopeia.txt', 0, '', '1033', 8192, 1" );
2765 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2767 r = add_file_entry( hdb, "'cepheus_file', 'cepheus', 'cepheus.txt', 0, '', '1033', 8192, 1" );
2768 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2770 r = add_file_entry( hdb, "'andromeda_file', 'andromeda', 'andromeda.txt', 0, '', '1033', 8192, 1" );
2771 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2773 r = add_file_entry( hdb, "'canis_file', 'canis', 'canis.txt', 0, '', '1033', 8192, 1" );
2774 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2776 r = add_file_entry( hdb, "'monoceros_file', 'monoceros', 'monoceros.txt', 0, '', '1033', 8192, 1" );
2777 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2779 r = add_file_entry( hdb, "'lepus_file', 'lepus', 'lepus.txt', 0, '', '1033', 8192, 1" );
2780 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2782 r = add_file_entry( hdb, "'delphinus_file', 'delphinus', 'delphinus.txt', 0, '', '1033', 8192, 1" );
2783 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2785 r = add_file_entry( hdb, "'hydrus_file', 'hydrus', 'hydrus.txt', 0, '', '1033', 8192, 1" );
2786 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2788 hpkg = package_from_db( hdb );
2789 ok( hpkg, "failed to create package\n");
2791 MsiCloseHandle( hdb );
2793 r = MsiDoAction( hpkg, "CostInitialize");
2794 ok( r == ERROR_SUCCESS, "cost init failed\n");
2796 r = MsiDoAction( hpkg, "FileCost");
2797 ok( r == ERROR_SUCCESS, "file cost failed\n");
2799 r = MsiDoAction( hpkg, "CostFinalize");
2800 ok( r == ERROR_SUCCESS, "cost finalize failed\n");
2802 state = 0xdeadbee;
2803 action = 0xdeadbee;
2804 r = MsiGetFeatureState(hpkg, "zodiac", &state, &action);
2805 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2806 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2807 ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
2809 state = 0xdeadbee;
2810 action = 0xdeadbee;
2811 r = MsiGetFeatureState(hpkg, "perseus", &state, &action);
2812 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2813 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2814 ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
2816 state = 0xdeadbee;
2817 action = 0xdeadbee;
2818 r = MsiGetFeatureState(hpkg, "orion", &state, &action);
2819 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2820 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2821 ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
2823 state = 0xdeadbee;
2824 action = 0xdeadbee;
2825 r = MsiGetFeatureState(hpkg, "waters", &state, &action);
2826 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2827 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2828 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2830 state = 0xdeadbee;
2831 action = 0xdeadbee;
2832 r = MsiGetFeatureState(hpkg, "bayer", &state, &action);
2833 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2834 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2835 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2837 state = 0xdeadbee;
2838 action = 0xdeadbee;
2839 r = MsiGetComponentState(hpkg, "leo", &state, &action);
2840 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2841 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2842 ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
2844 state = 0xdeadbee;
2845 action = 0xdeadbee;
2846 r = MsiGetComponentState(hpkg, "virgo", &state, &action);
2847 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2848 ok( state == INSTALLSTATE_UNKNOWN, "Expected virgo INSTALLSTATE_UNKNOWN, got %d\n", state);
2849 ok( action == INSTALLSTATE_SOURCE, "Expected virgo INSTALLSTATE_SOURCE, got %d\n", action);
2851 state = 0xdeadbee;
2852 action = 0xdeadbee;
2853 r = MsiGetComponentState(hpkg, "libra", &state, &action);
2854 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2855 ok( state == INSTALLSTATE_UNKNOWN, "Expected libra INSTALLSTATE_UNKNOWN, got %d\n", state);
2856 ok( action == INSTALLSTATE_LOCAL, "Expected libra INSTALLSTATE_LOCAL, got %d\n", action);
2858 state = 0xdeadbee;
2859 action = 0xdeadbee;
2860 r = MsiGetComponentState(hpkg, "cassiopeia", &state, &action);
2861 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2862 ok( state == INSTALLSTATE_UNKNOWN, "Expected cassiopeia INSTALLSTATE_UNKNOWN, got %d\n", state);
2863 ok( action == INSTALLSTATE_LOCAL, "Expected cassiopeia INSTALLSTATE_LOCAL, got %d\n", action);
2865 state = 0xdeadbee;
2866 action = 0xdeadbee;
2867 r = MsiGetComponentState(hpkg, "cepheus", &state, &action);
2868 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2869 ok( state == INSTALLSTATE_UNKNOWN, "Expected cepheus INSTALLSTATE_UNKNOWN, got %d\n", state);
2870 ok( action == INSTALLSTATE_SOURCE, "Expected cepheus INSTALLSTATE_SOURCE, got %d\n", action);
2872 state = 0xdeadbee;
2873 action = 0xdeadbee;
2874 r = MsiGetComponentState(hpkg, "andromeda", &state, &action);
2875 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2876 ok( state == INSTALLSTATE_UNKNOWN, "Expected andromeda INSTALLSTATE_UNKNOWN, got %d\n", state);
2877 ok( action == INSTALLSTATE_LOCAL, "Expected andromeda INSTALLSTATE_LOCAL, got %d\n", action);
2879 state = 0xdeadbee;
2880 action = 0xdeadbee;
2881 r = MsiGetComponentState(hpkg, "canis", &state, &action);
2882 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2883 ok( state == INSTALLSTATE_UNKNOWN, "Expected canis INSTALLSTATE_UNKNOWN, got %d\n", state);
2884 ok( action == INSTALLSTATE_LOCAL, "Expected canis INSTALLSTATE_LOCAL, got %d\n", action);
2886 state = 0xdeadbee;
2887 action = 0xdeadbee;
2888 r = MsiGetComponentState(hpkg, "monoceros", &state, &action);
2889 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2890 ok( state == INSTALLSTATE_UNKNOWN, "Expected monoceros INSTALLSTATE_UNKNOWN, got %d\n", state);
2891 ok( action == INSTALLSTATE_SOURCE, "Expected monoceros INSTALLSTATE_SOURCE, got %d\n", action);
2893 state = 0xdeadbee;
2894 action = 0xdeadbee;
2895 r = MsiGetComponentState(hpkg, "lepus", &state, &action);
2896 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2897 ok( state == INSTALLSTATE_UNKNOWN, "Expected lepus INSTALLSTATE_UNKNOWN, got %d\n", state);
2898 ok( action == INSTALLSTATE_LOCAL, "Expected lepus INSTALLSTATE_LOCAL, got %d\n", action);
2900 state = 0xdeadbee;
2901 action = 0xdeadbee;
2902 r = MsiGetComponentState(hpkg, "delphinus", &state, &action);
2903 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2904 ok( state == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", state);
2905 ok( action == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", action);
2907 state = 0xdeadbee;
2908 action = 0xdeadbee;
2909 r = MsiGetComponentState(hpkg, "hydrus", &state, &action);
2910 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2911 ok( state == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", state);
2912 ok( action == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", action);
2914 r = MsiSetFeatureState(hpkg, "orion", INSTALLSTATE_ABSENT);
2915 ok( r == ERROR_SUCCESS, "failed to set feature state: %d\n", r);
2917 state = 0xdeadbee;
2918 action = 0xdeadbee;
2919 r = MsiGetFeatureState(hpkg, "zodiac", &state, &action);
2920 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2921 ok( state == INSTALLSTATE_ABSENT, "Expected zodiac INSTALLSTATE_ABSENT, got %d\n", state);
2922 ok( action == INSTALLSTATE_LOCAL, "Expected zodiac INSTALLSTATE_LOCAL, got %d\n", action);
2924 state = 0xdeadbee;
2925 action = 0xdeadbee;
2926 r = MsiGetFeatureState(hpkg, "perseus", &state, &action);
2927 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2928 ok( state == INSTALLSTATE_ABSENT, "Expected perseus INSTALLSTATE_ABSENT, got %d\n", state);
2929 ok( action == INSTALLSTATE_SOURCE, "Expected perseus INSTALLSTATE_SOURCE, got %d\n", action);
2931 state = 0xdeadbee;
2932 action = 0xdeadbee;
2933 r = MsiGetFeatureState(hpkg, "orion", &state, &action);
2934 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2935 ok( state == INSTALLSTATE_ABSENT, "Expected orion INSTALLSTATE_ABSENT, got %d\n", state);
2936 ok( action == INSTALLSTATE_ABSENT, "Expected orion INSTALLSTATE_ABSENT, got %d\n", action);
2938 state = 0xdeadbee;
2939 action = 0xdeadbee;
2940 r = MsiGetComponentState(hpkg, "leo", &state, &action);
2941 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2942 ok( state == INSTALLSTATE_UNKNOWN, "Expected leo INSTALLSTATE_UNKNOWN, got %d\n", state);
2943 ok( action == INSTALLSTATE_LOCAL, "Expected leo INSTALLSTATE_LOCAL, got %d\n", action);
2945 state = 0xdeadbee;
2946 action = 0xdeadbee;
2947 r = MsiGetComponentState(hpkg, "virgo", &state, &action);
2948 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2949 ok( state == INSTALLSTATE_UNKNOWN, "Expected virgo INSTALLSTATE_UNKNOWN, got %d\n", state);
2950 ok( action == INSTALLSTATE_SOURCE, "Expected virgo INSTALLSTATE_SOURCE, got %d\n", action);
2952 state = 0xdeadbee;
2953 action = 0xdeadbee;
2954 r = MsiGetComponentState(hpkg, "libra", &state, &action);
2955 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2956 ok( state == INSTALLSTATE_UNKNOWN, "Expected libra INSTALLSTATE_UNKNOWN, got %d\n", state);
2957 ok( action == INSTALLSTATE_LOCAL, "Expected libra INSTALLSTATE_LOCAL, got %d\n", action);
2959 state = 0xdeadbee;
2960 action = 0xdeadbee;
2961 r = MsiGetComponentState(hpkg, "cassiopeia", &state, &action);
2962 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2963 ok( state == INSTALLSTATE_UNKNOWN, "Expected cassiopeia INSTALLSTATE_UNKNOWN, got %d\n", state);
2964 ok( action == INSTALLSTATE_LOCAL, "Expected cassiopeia INSTALLSTATE_LOCAL, got %d\n", action);
2966 state = 0xdeadbee;
2967 action = 0xdeadbee;
2968 r = MsiGetComponentState(hpkg, "cepheus", &state, &action);
2969 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2970 ok( state == INSTALLSTATE_UNKNOWN, "Expected cepheus INSTALLSTATE_UNKNOWN, got %d\n", state);
2971 ok( action == INSTALLSTATE_SOURCE, "Expected cepheus INSTALLSTATE_SOURCE, got %d\n", action);
2973 state = 0xdeadbee;
2974 action = 0xdeadbee;
2975 r = MsiGetComponentState(hpkg, "andromeda", &state, &action);
2976 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2977 ok( state == INSTALLSTATE_UNKNOWN, "Expected andromeda INSTALLSTATE_UNKNOWN, got %d\n", state);
2978 ok( action == INSTALLSTATE_SOURCE, "Expected andromeda INSTALLSTATE_SOURCE, got %d\n", action);
2980 state = 0xdeadbee;
2981 action = 0xdeadbee;
2982 r = MsiGetComponentState(hpkg, "canis", &state, &action);
2983 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2984 ok( state == INSTALLSTATE_UNKNOWN, "Expected canis INSTALLSTATE_UNKNOWN, got %d\n", state);
2985 ok( action == INSTALLSTATE_UNKNOWN, "Expected canis INSTALLSTATE_UNKNOWN, got %d\n", action);
2987 state = 0xdeadbee;
2988 action = 0xdeadbee;
2989 r = MsiGetComponentState(hpkg, "monoceros", &state, &action);
2990 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2991 ok( state == INSTALLSTATE_UNKNOWN, "Expected monoceros INSTALLSTATE_UNKNOWN, got %d\n", state);
2992 ok( action == INSTALLSTATE_UNKNOWN, "Expected monoceros INSTALLSTATE_UNKNOWN, got %d\n", action);
2994 state = 0xdeadbee;
2995 action = 0xdeadbee;
2996 r = MsiGetComponentState(hpkg, "lepus", &state, &action);
2997 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2998 ok( state == INSTALLSTATE_UNKNOWN, "Expected lepus INSTALLSTATE_UNKNOWN, got %d\n", state);
2999 ok( action == INSTALLSTATE_UNKNOWN, "Expected lepus INSTALLSTATE_UNKNOWN, got %d\n", action);
3001 state = 0xdeadbee;
3002 action = 0xdeadbee;
3003 r = MsiGetComponentState(hpkg, "delphinus", &state, &action);
3004 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3005 ok( state == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", state);
3006 ok( action == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", action);
3008 state = 0xdeadbee;
3009 action = 0xdeadbee;
3010 r = MsiGetComponentState(hpkg, "hydrus", &state, &action);
3011 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3012 ok( state == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", state);
3013 ok( action == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", action);
3015 MsiCloseHandle(hpkg);
3016 DeleteFileA(msifile);
3019 static void test_installprops(void)
3021 MSIHANDLE hpkg, hdb;
3022 CHAR path[MAX_PATH];
3023 CHAR buf[MAX_PATH];
3024 DWORD size, type;
3025 HKEY hkey;
3026 UINT r;
3028 GetCurrentDirectory(MAX_PATH, path);
3029 lstrcat(path, "\\");
3030 lstrcat(path, msifile);
3032 hdb = create_package_db();
3033 ok( hdb, "failed to create database\n");
3035 hpkg = package_from_db(hdb);
3036 ok( hpkg, "failed to create package\n");
3038 MsiCloseHandle(hdb);
3040 size = MAX_PATH;
3041 r = MsiGetProperty(hpkg, "DATABASE", buf, &size);
3042 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
3043 ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
3045 RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", &hkey);
3047 size = MAX_PATH;
3048 type = REG_SZ;
3049 RegQueryValueEx(hkey, "RegisteredOwner", NULL, &type, (LPBYTE)path, &size);
3051 size = MAX_PATH;
3052 r = MsiGetProperty(hpkg, "USERNAME", buf, &size);
3053 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
3054 ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
3056 size = MAX_PATH;
3057 type = REG_SZ;
3058 RegQueryValueEx(hkey, "RegisteredOrganization", NULL, &type, (LPBYTE)path, &size);
3060 size = MAX_PATH;
3061 r = MsiGetProperty(hpkg, "COMPANYNAME", buf, &size);
3062 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
3063 ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
3065 size = MAX_PATH;
3066 r = MsiGetProperty(hpkg, "VersionDatabase", buf, &size);
3067 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
3068 trace("VersionDatabase = %s\n", buf);
3070 size = MAX_PATH;
3071 r = MsiGetProperty(hpkg, "VersionMsi", buf, &size);
3072 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
3073 trace("VersionMsi = %s\n", buf);
3075 size = MAX_PATH;
3076 r = MsiGetProperty(hpkg, "Date", buf, &size);
3077 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
3078 trace("Date = %s\n", buf);
3080 size = MAX_PATH;
3081 r = MsiGetProperty(hpkg, "Time", buf, &size);
3082 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
3083 trace("Time = %s\n", buf);
3085 size = MAX_PATH;
3086 r = MsiGetProperty(hpkg, "PackageCode", buf, &size);
3087 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
3088 trace("PackageCode = %s\n", buf);
3090 CloseHandle(hkey);
3091 MsiCloseHandle(hpkg);
3092 DeleteFile(msifile);
3095 static void test_sourcedirprop(void)
3097 MSIHANDLE hpkg, hdb;
3098 CHAR source_dir[MAX_PATH];
3099 CHAR path[MAX_PATH];
3100 DWORD size;
3101 UINT r;
3103 hdb = create_package_db();
3104 ok ( hdb, "failed to create package database\n" );
3106 r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
3107 ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
3109 hpkg = package_from_db( hdb );
3110 ok( hpkg, "failed to create package\n");
3112 MsiCloseHandle( hdb );
3114 size = MAX_PATH;
3115 r = MsiGetProperty( hpkg, "SourceDir", source_dir, &size );
3116 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
3117 ok( !lstrlenA(source_dir), "Expected emtpy source dir, got %s\n", source_dir);
3119 size = MAX_PATH;
3120 r = MsiGetProperty( hpkg, "SOURCEDIR", source_dir, &size );
3121 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
3122 ok( !lstrlenA(source_dir), "Expected emtpy source dir, got %s\n", source_dir);
3124 r = MsiDoAction( hpkg, "CostInitialize");
3125 ok( r == ERROR_SUCCESS, "cost init failed\n");
3127 size = MAX_PATH;
3128 r = MsiGetProperty( hpkg, "SourceDir", source_dir, &size );
3129 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
3130 ok( !lstrlenA(source_dir), "Expected emtpy source dir, got %s\n", source_dir);
3132 size = MAX_PATH;
3133 r = MsiGetProperty( hpkg, "SOURCEDIR", source_dir, &size );
3134 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
3135 ok( !lstrlenA(source_dir), "Expected emtpy source dir, got %s\n", source_dir);
3137 r = MsiDoAction( hpkg, "ResolveSource");
3138 ok( r == ERROR_SUCCESS, "file cost failed\n");
3140 GetCurrentDirectory(MAX_PATH, path);
3141 lstrcatA(path, "\\");
3143 size = MAX_PATH;
3144 r = MsiGetProperty( hpkg, "SourceDir", source_dir, &size );
3145 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
3146 ok( !lstrcmpA(source_dir, path), "Expected %s, got %s\n", path, source_dir);
3148 size = MAX_PATH;
3149 r = MsiGetProperty( hpkg, "SOURCEDIR", source_dir, &size );
3150 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
3151 ok( !lstrcmpA(source_dir, path), "Expected %s, got %s\n", path, source_dir);
3153 size = MAX_PATH;
3154 r = MsiGetProperty( hpkg, "SoUrCeDiR", source_dir, &size );
3155 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
3156 ok( !lstrlenA(source_dir), "Expected emtpy source dir, got %s\n", source_dir);
3158 MsiCloseHandle(hpkg);
3159 DeleteFileA(msifile);
3162 static void test_prop_path(void)
3164 MSIHANDLE hpkg, hdb;
3165 char buffer[MAX_PATH], cwd[MAX_PATH];
3166 DWORD sz;
3167 UINT r;
3169 GetCurrentDirectory(MAX_PATH, cwd);
3170 strcat(cwd, "\\");
3172 hdb = create_package_db();
3173 ok( hdb, "failed to create database\n");
3175 r = add_directory_entry( hdb, "'TARGETDIR','','SourceDir'" );
3176 ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
3178 r = add_directory_entry( hdb, "'foo','TARGETDIR','foosrc:footgt'" );
3179 ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
3181 hpkg = package_from_db(hdb);
3182 ok( hpkg, "failed to create package\n");
3184 r = MsiGetSourcePath(hpkg, "SourceDir", buffer, &sz );
3185 ok( r == ERROR_DIRECTORY, "failed to get source path\n");
3187 r = MsiGetSourcePath(hpkg, "SOURCEDIR", buffer, &sz );
3188 ok( r == ERROR_DIRECTORY, "failed to get source path\n");
3190 r = MsiDoAction( hpkg, "CostInitialize");
3191 ok( r == ERROR_SUCCESS, "cost init failed\n");
3193 sz = sizeof buffer;
3194 buffer[0] = 0;
3195 r = MsiGetProperty(hpkg, "SourceDir", buffer, &sz);
3196 ok( r == ERROR_SUCCESS, "property not set\n");
3197 ok( !buffer[0], "SourceDir should be empty\n");
3199 sz = sizeof buffer;
3200 buffer[0] = 0;
3201 r = MsiGetProperty(hpkg, "SOURCEDIR", buffer, &sz);
3202 ok( r == ERROR_SUCCESS, "property not set\n");
3203 ok( !buffer[0], "SourceDir should be empty\n");
3205 sz = sizeof buffer;
3206 buffer[0] = 0;
3207 r = MsiGetSourcePath(hpkg, "SourceDir", buffer, &sz );
3208 ok( r == ERROR_SUCCESS, "failed to get source path\n");
3209 ok( !lstrcmpi(cwd, buffer), "SourceDir (%s) should be current dir (%s)\n", buffer, cwd);
3211 sz = sizeof buffer;
3212 buffer[0] = 0;
3213 r = MsiGetProperty(hpkg, "SourceDir", buffer, &sz);
3214 ok( r == ERROR_SUCCESS, "property not set\n");
3215 todo_wine {
3216 ok( !lstrcmpi(cwd, buffer), "SourceDir (%s) should be current dir (%s)\n", buffer, cwd);
3219 sz = sizeof buffer;
3220 buffer[0] = 0;
3221 r = MsiGetSourcePath(hpkg, "SOURCEDIR", buffer, &sz );
3222 ok( r == ERROR_DIRECTORY, "failed to get source path\n");
3224 sz = sizeof buffer;
3225 buffer[0] = 0;
3226 r = MsiGetProperty(hpkg, "SOURCEDIR", buffer, &sz);
3227 ok( r == ERROR_SUCCESS, "property not set\n");
3228 todo_wine {
3229 ok( !lstrcmpi(cwd, buffer), "SourceDir (%s) should be current dir (%s)\n", buffer, cwd);
3232 r = MsiSetProperty(hpkg, "SourceDir", "goo");
3233 ok( r == ERROR_SUCCESS, "property not set\n");
3235 sz = sizeof buffer;
3236 buffer[0] = 0;
3237 r = MsiGetProperty(hpkg, "SourceDir", buffer, &sz);
3238 ok( r == ERROR_SUCCESS, "property not set\n");
3239 ok( !lstrcmpi(buffer, "goo"), "SourceDir (%s) should be goo\n", buffer);
3241 sz = sizeof buffer;
3242 buffer[0] = 0;
3243 r = MsiGetSourcePath(hpkg, "SourceDir", buffer, &sz );
3244 ok( r == ERROR_SUCCESS, "failed to get source path\n");
3245 ok( !lstrcmpi(buffer, cwd), "SourceDir (%s) should be goo\n", buffer);
3247 sz = sizeof buffer;
3248 buffer[0] = 0;
3249 r = MsiGetProperty(hpkg, "SourceDir", buffer, &sz);
3250 ok( r == ERROR_SUCCESS, "property not set\n");
3251 ok( !lstrcmpi(buffer, "goo"), "SourceDir (%s) should be goo\n", buffer);
3253 MsiCloseHandle( hpkg );
3254 DeleteFile(msifile);
3257 static void test_launchconditions(void)
3259 MSIHANDLE hpkg;
3260 MSIHANDLE hdb;
3261 UINT r;
3263 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3265 hdb = create_package_db();
3266 ok( hdb, "failed to create package database\n" );
3268 r = create_launchcondition_table( hdb );
3269 ok( r == ERROR_SUCCESS, "cannot create LaunchCondition table: %d\n", r );
3271 r = add_launchcondition_entry( hdb, "'X = \"1\"', 'one'" );
3272 ok( r == ERROR_SUCCESS, "cannot add launch condition: %d\n", r );
3274 /* invalid condition */
3275 r = add_launchcondition_entry( hdb, "'X != \"1\"', 'one'" );
3276 ok( r == ERROR_SUCCESS, "cannot add launch condition: %d\n", r );
3278 hpkg = package_from_db( hdb );
3279 ok( hpkg, "failed to create package\n");
3281 MsiCloseHandle( hdb );
3283 r = MsiSetProperty( hpkg, "X", "1" );
3284 ok( r == ERROR_SUCCESS, "failed to set property\n" );
3286 /* invalid conditions are ignored */
3287 r = MsiDoAction( hpkg, "LaunchConditions" );
3288 ok( r == ERROR_SUCCESS, "cost init failed\n" );
3290 /* verify LaunchConditions still does some verification */
3291 r = MsiSetProperty( hpkg, "X", "2" );
3292 ok( r == ERROR_SUCCESS, "failed to set property\n" );
3294 r = MsiDoAction( hpkg, "LaunchConditions" );
3295 ok( r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %d\n", r );
3297 MsiCloseHandle( hpkg );
3298 DeleteFile( msifile );
3301 START_TEST(package)
3303 test_createpackage();
3304 test_getsourcepath_bad();
3305 test_getsourcepath();
3306 test_doaction();
3307 test_gettargetpath_bad();
3308 test_settargetpath();
3309 test_props();
3310 test_properties_table();
3311 test_condition();
3312 test_msipackage();
3313 test_formatrecord2();
3314 test_states();
3315 test_getproperty();
3316 test_removefiles();
3317 test_appsearch();
3318 test_featureparents();
3319 test_installprops();
3320 test_sourcedirprop();
3321 test_prop_path();
3322 test_launchconditions();