msi: Consolidate the MsiGetSourcePath tests and add more tests.
[wine] / dlls / msi / tests / package.c
1 /*
2  * tests for Microsoft Installer functionality
3  *
4  * Copyright 2005 Mike McCormack for CodeWeavers
5  * Copyright 2005 Aric Stewart for CodeWeavers
6  *
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.
11  *
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.
16  *
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
20  */
21
22 #define COBJMACROS
23
24 #include <stdio.h>
25 #include <windows.h>
26 #include <msidefs.h>
27 #include <msi.h>
28 #include <msiquery.h>
29
30 #include "wine/test.h"
31
32 static const char msifile[] = "winetest.msi";
33 char CURR_DIR[MAX_PATH];
34
35 /* RegDeleteTreeW from dlls/advapi32/registry.c */
36 LSTATUS WINAPI package_RegDeleteTreeW(HKEY hKey, LPCWSTR lpszSubKey)
37 {
38     LONG ret;
39     DWORD dwMaxSubkeyLen, dwMaxValueLen;
40     DWORD dwMaxLen, dwSize;
41     WCHAR szNameBuf[MAX_PATH], *lpszName = szNameBuf;
42     HKEY hSubKey = hKey;
43
44     if(lpszSubKey)
45     {
46         ret = RegOpenKeyExW(hKey, lpszSubKey, 0, KEY_READ, &hSubKey);
47         if (ret) return ret;
48     }
49
50     ret = RegQueryInfoKeyW(hSubKey, NULL, NULL, NULL, NULL,
51             &dwMaxSubkeyLen, NULL, NULL, &dwMaxValueLen, NULL, NULL, NULL);
52     if (ret) goto cleanup;
53
54     dwMaxSubkeyLen++;
55     dwMaxValueLen++;
56     dwMaxLen = max(dwMaxSubkeyLen, dwMaxValueLen);
57     if (dwMaxLen > sizeof(szNameBuf)/sizeof(WCHAR))
58     {
59         /* Name too big: alloc a buffer for it */
60         if (!(lpszName = HeapAlloc( GetProcessHeap(), 0, dwMaxLen*sizeof(WCHAR))))
61         {
62             ret = ERROR_NOT_ENOUGH_MEMORY;
63             goto cleanup;
64         }
65     }
66
67     /* Recursively delete all the subkeys */
68     while (TRUE)
69     {
70         dwSize = dwMaxLen;
71         if (RegEnumKeyExW(hSubKey, 0, lpszName, &dwSize, NULL,
72                           NULL, NULL, NULL)) break;
73
74         ret = package_RegDeleteTreeW(hSubKey, lpszName);
75         if (ret) goto cleanup;
76     }
77
78     if (lpszSubKey)
79         ret = RegDeleteKeyW(hKey, lpszSubKey);
80     else
81         while (TRUE)
82         {
83             dwSize = dwMaxLen;
84             if (RegEnumValueW(hKey, 0, lpszName, &dwSize,
85                   NULL, NULL, NULL, NULL)) break;
86
87             ret = RegDeleteValueW(hKey, lpszName);
88             if (ret) goto cleanup;
89         }
90
91 cleanup:
92     if (lpszName != szNameBuf)
93         HeapFree(GetProcessHeap(), 0, lpszName);
94     if(lpszSubKey)
95         RegCloseKey(hSubKey);
96     return ret;
97 }
98
99 static UINT do_query(MSIHANDLE hdb, const char *query, MSIHANDLE *phrec)
100 {
101     MSIHANDLE hview = 0;
102     UINT r, ret;
103
104     /* open a select query */
105     r = MsiDatabaseOpenView(hdb, query, &hview);
106     if (r != ERROR_SUCCESS)
107         return r;
108     r = MsiViewExecute(hview, 0);
109     if (r != ERROR_SUCCESS)
110         return r;
111     ret = MsiViewFetch(hview, phrec);
112     r = MsiViewClose(hview);
113     if (r != ERROR_SUCCESS)
114         return r;
115     r = MsiCloseHandle(hview);
116     if (r != ERROR_SUCCESS)
117         return r;
118     return ret;
119 }
120
121 static UINT run_query( MSIHANDLE hdb, const char *query )
122 {
123     MSIHANDLE hview = 0;
124     UINT r;
125
126     r = MsiDatabaseOpenView(hdb, query, &hview);
127     if( r != ERROR_SUCCESS )
128         return r;
129
130     r = MsiViewExecute(hview, 0);
131     if( r == ERROR_SUCCESS )
132         r = MsiViewClose(hview);
133     MsiCloseHandle(hview);
134     return r;
135 }
136
137 static UINT create_component_table( MSIHANDLE hdb )
138 {
139     return run_query( hdb,
140             "CREATE TABLE `Component` ( "
141             "`Component` CHAR(72) NOT NULL, "
142             "`ComponentId` CHAR(38), "
143             "`Directory_` CHAR(72) NOT NULL, "
144             "`Attributes` SHORT NOT NULL, "
145             "`Condition` CHAR(255), "
146             "`KeyPath` CHAR(72) "
147             "PRIMARY KEY `Component`)" );
148 }
149
150 static UINT create_feature_table( MSIHANDLE hdb )
151 {
152     return run_query( hdb,
153             "CREATE TABLE `Feature` ( "
154             "`Feature` CHAR(38) NOT NULL, "
155             "`Feature_Parent` CHAR(38), "
156             "`Title` CHAR(64), "
157             "`Description` CHAR(255), "
158             "`Display` SHORT NOT NULL, "
159             "`Level` SHORT NOT NULL, "
160             "`Directory_` CHAR(72), "
161             "`Attributes` SHORT NOT NULL "
162             "PRIMARY KEY `Feature`)" );
163 }
164
165 static UINT create_feature_components_table( MSIHANDLE hdb )
166 {
167     return run_query( hdb,
168             "CREATE TABLE `FeatureComponents` ( "
169             "`Feature_` CHAR(38) NOT NULL, "
170             "`Component_` CHAR(72) NOT NULL "
171             "PRIMARY KEY `Feature_`, `Component_` )" );
172 }
173
174 static UINT create_file_table( MSIHANDLE hdb )
175 {
176     return run_query( hdb,
177             "CREATE TABLE `File` ("
178             "`File` CHAR(72) NOT NULL, "
179             "`Component_` CHAR(72) NOT NULL, "
180             "`FileName` CHAR(255) NOT NULL, "
181             "`FileSize` LONG NOT NULL, "
182             "`Version` CHAR(72), "
183             "`Language` CHAR(20), "
184             "`Attributes` SHORT, "
185             "`Sequence` SHORT NOT NULL "
186             "PRIMARY KEY `File`)" );
187 }
188
189 static UINT create_remove_file_table( MSIHANDLE hdb )
190 {
191     return run_query( hdb,
192             "CREATE TABLE `RemoveFile` ("
193             "`FileKey` CHAR(72) NOT NULL, "
194             "`Component_` CHAR(72) NOT NULL, "
195             "`FileName` CHAR(255) LOCALIZABLE, "
196             "`DirProperty` CHAR(72) NOT NULL, "
197             "`InstallMode` SHORT NOT NULL "
198             "PRIMARY KEY `FileKey`)" );
199 }
200
201 static UINT create_appsearch_table( MSIHANDLE hdb )
202 {
203     return run_query( hdb,
204             "CREATE TABLE `AppSearch` ("
205             "`Property` CHAR(72) NOT NULL, "
206             "`Signature_` CHAR(72) NOT NULL "
207             "PRIMARY KEY `Property`, `Signature_`)" );
208 }
209
210 static UINT create_reglocator_table( MSIHANDLE hdb )
211 {
212     return run_query( hdb,
213             "CREATE TABLE `RegLocator` ("
214             "`Signature_` CHAR(72) NOT NULL, "
215             "`Root` SHORT NOT NULL, "
216             "`Key` CHAR(255) NOT NULL, "
217             "`Name` CHAR(255), "
218             "`Type` SHORT "
219             "PRIMARY KEY `Signature_`)" );
220 }
221
222 static UINT create_signature_table( MSIHANDLE hdb )
223 {
224     return run_query( hdb,
225             "CREATE TABLE `Signature` ("
226             "`Signature` CHAR(72) NOT NULL, "
227             "`FileName` CHAR(255) NOT NULL, "
228             "`MinVersion` CHAR(20), "
229             "`MaxVersion` CHAR(20), "
230             "`MinSize` LONG, "
231             "`MaxSize` LONG, "
232             "`MinDate` LONG, "
233             "`MaxDate` LONG, "
234             "`Languages` CHAR(255) "
235             "PRIMARY KEY `Signature`)" );
236 }
237
238 static UINT create_launchcondition_table( MSIHANDLE hdb )
239 {
240     return run_query( hdb,
241             "CREATE TABLE `LaunchCondition` ("
242             "`Condition` CHAR(255) NOT NULL, "
243             "`Description` CHAR(255) NOT NULL "
244             "PRIMARY KEY `Condition`)" );
245 }
246
247 static UINT create_property_table( MSIHANDLE hdb )
248 {
249     return run_query( hdb,
250             "CREATE TABLE `Property` ("
251             "`Property` CHAR(72) NOT NULL, "
252             "`Value` CHAR(0) "
253             "PRIMARY KEY `Property`)" );
254 }
255
256 static UINT create_install_execute_sequence_table( MSIHANDLE hdb )
257 {
258     return run_query( hdb,
259             "CREATE TABLE `InstallExecuteSequence` ("
260             "`Action` CHAR(72) NOT NULL, "
261             "`Condition` CHAR(255), "
262             "`Sequence` SHORT "
263             "PRIMARY KEY `Action`)" );
264 }
265
266 static UINT create_media_table( MSIHANDLE hdb )
267 {
268     return run_query( hdb,
269             "CREATE TABLE `Media` ("
270             "`DiskId` SHORT NOT NULL, "
271             "`LastSequence` SHORT NOT NULL, "
272             "`DiskPrompt` CHAR(64), "
273             "`Cabinet` CHAR(255), "
274             "`VolumeLabel` CHAR(32), "
275             "`Source` CHAR(72) "
276             "PRIMARY KEY `DiskId`)" );
277 }
278
279 static UINT create_ccpsearch_table( MSIHANDLE hdb )
280 {
281     return run_query( hdb,
282             "CREATE TABLE `CCPSearch` ("
283             "`Signature_` CHAR(72) NOT NULL "
284             "PRIMARY KEY `Signature_`)" );
285 }
286
287 static UINT create_drlocator_table( MSIHANDLE hdb )
288 {
289     return run_query( hdb,
290             "CREATE TABLE `DrLocator` ("
291             "`Signature_` CHAR(72) NOT NULL, "
292             "`Parent` CHAR(72), "
293             "`Path` CHAR(255), "
294             "`Depth` SHORT "
295             "PRIMARY KEY `Signature_`, `Parent`, `Path`)" );
296 }
297
298 static UINT create_complocator_table( MSIHANDLE hdb )
299 {
300     return run_query( hdb,
301             "CREATE TABLE `CompLocator` ("
302             "`Signature_` CHAR(72) NOT NULL, "
303             "`ComponentId` CHAR(38) NOT NULL, "
304             "`Type` SHORT "
305             "PRIMARY KEY `Signature_`)" );
306 }
307
308 static UINT add_component_entry( MSIHANDLE hdb, const char *values )
309 {
310     char insert[] = "INSERT INTO `Component`  "
311             "(`Component`, `ComponentId`, `Directory_`, `Attributes`, `Condition`, `KeyPath`) "
312             "VALUES( %s )";
313     char *query;
314     UINT sz, r;
315
316     sz = strlen(values) + sizeof insert;
317     query = HeapAlloc(GetProcessHeap(),0,sz);
318     sprintf(query,insert,values);
319     r = run_query( hdb, query );
320     HeapFree(GetProcessHeap(), 0, query);
321     return r;
322 }
323
324 static UINT add_directory_entry( MSIHANDLE hdb, const char *values )
325 {
326     char insert[] = "INSERT INTO `Directory` (`Directory`,`Directory_Parent`,`DefaultDir`) VALUES( %s )";
327     char *query;
328     UINT sz, r;
329
330     sz = strlen(values) + sizeof insert;
331     query = HeapAlloc(GetProcessHeap(),0,sz);
332     sprintf(query,insert,values);
333     r = run_query( hdb, query );
334     HeapFree(GetProcessHeap(), 0, query);
335     return r;
336 }
337
338 static UINT add_feature_entry( MSIHANDLE hdb, const char *values )
339 {
340     char insert[] = "INSERT INTO `Feature` (`Feature`, `Feature_Parent`, "
341                     "`Title`, `Description`, `Display`, `Level`, `Directory_`, `Attributes`) VALUES( %s )";
342     char *query;
343     UINT sz, r;
344
345     sz = strlen(values) + sizeof insert;
346     query = HeapAlloc(GetProcessHeap(),0,sz);
347     sprintf(query,insert,values);
348     r = run_query( hdb, query );
349     HeapFree(GetProcessHeap(), 0, query);
350     return r;
351 }
352
353 static UINT add_feature_components_entry( MSIHANDLE hdb, const char *values )
354 {
355     char insert[] = "INSERT INTO `FeatureComponents` "
356             "(`Feature_`, `Component_`) "
357             "VALUES( %s )";
358     char *query;
359     UINT sz, r;
360
361     sz = strlen(values) + sizeof insert;
362     query = HeapAlloc(GetProcessHeap(),0,sz);
363     sprintf(query,insert,values);
364     r = run_query( hdb, query );
365     HeapFree(GetProcessHeap(), 0, query);
366     return r;
367 }
368
369 static UINT add_file_entry( MSIHANDLE hdb, const char *values )
370 {
371     char insert[] = "INSERT INTO `File` "
372             "(`File`, `Component_`, `FileName`, `FileSize`, `Version`, `Language`, `Attributes`, `Sequence`) "
373             "VALUES( %s )";
374     char *query;
375     UINT sz, r;
376
377     sz = strlen(values) + sizeof insert;
378     query = HeapAlloc(GetProcessHeap(),0,sz);
379     sprintf(query,insert,values);
380     r = run_query( hdb, query );
381     HeapFree(GetProcessHeap(), 0, query);
382     return r;
383 }
384
385 static UINT add_appsearch_entry( MSIHANDLE hdb, const char *values )
386 {
387     char insert[] = "INSERT INTO `AppSearch` "
388             "(`Property`, `Signature_`) "
389             "VALUES( %s )";
390     char *query;
391     UINT sz, r;
392
393     sz = strlen(values) + sizeof insert;
394     query = HeapAlloc(GetProcessHeap(),0,sz);
395     sprintf(query,insert,values);
396     r = run_query( hdb, query );
397     HeapFree(GetProcessHeap(), 0, query);
398     return r;
399 }
400
401 static UINT add_reglocator_entry( MSIHANDLE hdb, const char *values )
402 {
403     char insert[] = "INSERT INTO `RegLocator` "
404             "(`Signature_`, `Root`, `Key`, `Name`, `Type`) "
405             "VALUES( %s )";
406     char *query;
407     UINT sz, r;
408
409     sz = strlen(values) + sizeof insert;
410     query = HeapAlloc(GetProcessHeap(),0,sz);
411     sprintf(query,insert,values);
412     r = run_query( hdb, query );
413     HeapFree(GetProcessHeap(), 0, query);
414     return r;
415 }
416
417 static UINT add_signature_entry( MSIHANDLE hdb, const char *values )
418 {
419     char insert[] = "INSERT INTO `Signature` "
420             "(`Signature`, `FileName`, `MinVersion`, `MaxVersion`,"
421             " `MinSize`, `MaxSize`, `MinDate`, `MaxDate`, `Languages`) "
422             "VALUES( %s )";
423     char *query;
424     UINT sz, r;
425
426     sz = strlen(values) + sizeof insert;
427     query = HeapAlloc(GetProcessHeap(),0,sz);
428     sprintf(query,insert,values);
429     r = run_query( hdb, query );
430     HeapFree(GetProcessHeap(), 0, query);
431     return r;
432 }
433
434 static UINT add_launchcondition_entry( MSIHANDLE hdb, const char *values )
435 {
436     char insert[] = "INSERT INTO `LaunchCondition` "
437             "(`Condition`, `Description`) "
438             "VALUES( %s )";
439     char *query;
440     UINT sz, r;
441
442     sz = strlen(values) + sizeof insert;
443     query = HeapAlloc(GetProcessHeap(),0,sz);
444     sprintf(query,insert,values);
445     r = run_query( hdb, query );
446     HeapFree(GetProcessHeap(), 0, query);
447     return r;
448 }
449
450 static UINT add_property_entry( MSIHANDLE hdb, const char *values )
451 {
452     char insert[] = "INSERT INTO `Property` "
453             "(`Property`, `Value`) "
454             "VALUES( %s )";
455     char *query;
456     UINT sz, r;
457
458     sz = strlen(values) + sizeof insert;
459     query = HeapAlloc(GetProcessHeap(),0,sz);
460     sprintf(query,insert,values);
461     r = run_query( hdb, query );
462     HeapFree(GetProcessHeap(), 0, query);
463     return r;
464 }
465
466 static UINT add_install_execute_sequence_entry( MSIHANDLE hdb, const char *values )
467 {
468     char insert[] = "INSERT INTO `InstallExecuteSequence` "
469             "(`Action`, `Condition`, `Sequence`) "
470             "VALUES( %s )";
471     char *query;
472     UINT sz, r;
473
474     sz = strlen(values) + sizeof insert;
475     query = HeapAlloc(GetProcessHeap(),0,sz);
476     sprintf(query,insert,values);
477     r = run_query( hdb, query );
478     HeapFree(GetProcessHeap(), 0, query);
479     return r;
480 }
481
482 static UINT add_media_entry( MSIHANDLE hdb, const char *values )
483 {
484     char insert[] = "INSERT INTO `Media` "
485             "(`DiskId`, `LastSequence`, `DiskPrompt`, `Cabinet`, `VolumeLabel`, `Source`) "
486             "VALUES( %s )";
487     char *query;
488     UINT sz, r;
489
490     sz = strlen(values) + sizeof insert;
491     query = HeapAlloc(GetProcessHeap(),0,sz);
492     sprintf(query,insert,values);
493     r = run_query( hdb, query );
494     HeapFree(GetProcessHeap(), 0, query);
495     return r;
496 }
497
498 static UINT add_ccpsearch_entry( MSIHANDLE hdb, const char *values )
499 {
500     char insert[] = "INSERT INTO `CCPSearch` (`Signature_`) VALUES( %s )";
501     char *query;
502     UINT sz, r;
503
504     sz = strlen(values) + sizeof insert;
505     query = HeapAlloc(GetProcessHeap(),0,sz);
506     sprintf(query,insert,values);
507     r = run_query( hdb, query );
508     HeapFree(GetProcessHeap(), 0, query);
509     return r;
510 }
511
512 static UINT add_drlocator_entry( MSIHANDLE hdb, const char *values )
513 {
514     char insert[] = "INSERT INTO `DrLocator` "
515             "(`Signature_`, `Parent`, `Path`, `Depth`) "
516             "VALUES( %s )";
517     char *query;
518     UINT sz, r;
519
520     sz = strlen(values) + sizeof insert;
521     query = HeapAlloc(GetProcessHeap(),0,sz);
522     sprintf(query,insert,values);
523     r = run_query( hdb, query );
524     HeapFree(GetProcessHeap(), 0, query);
525     return r;
526 }
527
528 static UINT add_complocator_entry( MSIHANDLE hdb, const char *values )
529 {
530     char insert[] = "INSERT INTO `CompLocator` "
531             "(`Signature_`, `ComponentId`, `Type`) "
532             "VALUES( %s )";
533     char *query;
534     UINT sz, r;
535
536     sz = strlen(values) + sizeof insert;
537     query = HeapAlloc(GetProcessHeap(),0,sz);
538     sprintf(query,insert,values);
539     r = run_query( hdb, query );
540     HeapFree(GetProcessHeap(), 0, query);
541     return r;
542 }
543
544 static UINT set_summary_info(MSIHANDLE hdb)
545 {
546     UINT res;
547     MSIHANDLE suminfo;
548
549     /* build summary info */
550     res = MsiGetSummaryInformation(hdb, NULL, 7, &suminfo);
551     ok( res == ERROR_SUCCESS , "Failed to open summaryinfo\n" );
552
553     res = MsiSummaryInfoSetProperty(suminfo,2, VT_LPSTR, 0,NULL,
554                         "Installation Database");
555     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
556
557     res = MsiSummaryInfoSetProperty(suminfo,3, VT_LPSTR, 0,NULL,
558                         "Installation Database");
559     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
560
561     res = MsiSummaryInfoSetProperty(suminfo,4, VT_LPSTR, 0,NULL,
562                         "Wine Hackers");
563     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
564
565     res = MsiSummaryInfoSetProperty(suminfo,7, VT_LPSTR, 0,NULL,
566                     ";1033");
567     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
568
569     res = MsiSummaryInfoSetProperty(suminfo,9, VT_LPSTR, 0,NULL,
570                     "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}");
571     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
572
573     res = MsiSummaryInfoSetProperty(suminfo, 14, VT_I4, 100, NULL, NULL);
574     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
575
576     res = MsiSummaryInfoSetProperty(suminfo, 15, VT_I4, 0, NULL, NULL);
577     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
578
579     res = MsiSummaryInfoPersist(suminfo);
580     ok( res == ERROR_SUCCESS , "Failed to make summary info persist\n" );
581
582     res = MsiCloseHandle( suminfo);
583     ok( res == ERROR_SUCCESS , "Failed to close suminfo\n" );
584
585     return res;
586 }
587
588
589 static MSIHANDLE create_package_db(void)
590 {
591     MSIHANDLE hdb = 0;
592     UINT res;
593
594     DeleteFile(msifile);
595
596     /* create an empty database */
597     res = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb );
598     ok( res == ERROR_SUCCESS , "Failed to create database\n" );
599     if( res != ERROR_SUCCESS )
600         return hdb;
601
602     res = MsiDatabaseCommit( hdb );
603     ok( res == ERROR_SUCCESS , "Failed to commit database\n" );
604
605     res = set_summary_info(hdb);
606
607     res = run_query( hdb,
608             "CREATE TABLE `Directory` ( "
609             "`Directory` CHAR(255) NOT NULL, "
610             "`Directory_Parent` CHAR(255), "
611             "`DefaultDir` CHAR(255) NOT NULL "
612             "PRIMARY KEY `Directory`)" );
613     ok( res == ERROR_SUCCESS , "Failed to create directory table\n" );
614
615     return hdb;
616 }
617
618 static MSIHANDLE package_from_db(MSIHANDLE hdb)
619 {
620     UINT res;
621     CHAR szPackage[10];
622     MSIHANDLE hPackage;
623
624     sprintf(szPackage,"#%li",hdb);
625     res = MsiOpenPackage(szPackage,&hPackage);
626     if (res != ERROR_SUCCESS)
627         return 0;
628
629     res = MsiCloseHandle(hdb);
630     if (res != ERROR_SUCCESS)
631         return 0;
632
633     return hPackage;
634 }
635
636 static void create_test_file(const CHAR *name)
637 {
638     HANDLE file;
639     DWORD written;
640
641     file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
642     ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name);
643     WriteFile(file, name, strlen(name), &written, NULL);
644     WriteFile(file, "\n", strlen("\n"), &written, NULL);
645     CloseHandle(file);
646 }
647
648 static void test_createpackage(void)
649 {
650     MSIHANDLE hPackage = 0;
651     UINT res;
652
653     hPackage = package_from_db(create_package_db());
654     ok( hPackage != 0, " Failed to create package\n");
655
656     res = MsiCloseHandle( hPackage);
657     ok( res == ERROR_SUCCESS , "Failed to close package\n" );
658     DeleteFile(msifile);
659 }
660
661 static void test_doaction( void )
662 {
663     MSIHANDLE hpkg;
664     UINT r;
665
666     r = MsiDoAction( -1, NULL );
667     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
668
669     hpkg = package_from_db(create_package_db());
670     ok( hpkg, "failed to create package\n");
671
672     r = MsiDoAction(hpkg, NULL);
673     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
674
675     r = MsiDoAction(0, "boo");
676     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
677
678     r = MsiDoAction(hpkg, "boo");
679     ok( r == ERROR_FUNCTION_NOT_CALLED, "wrong return val\n");
680
681     MsiCloseHandle( hpkg );
682     DeleteFile(msifile);
683 }
684
685 static void test_gettargetpath_bad(void)
686 {
687     char buffer[0x80];
688     MSIHANDLE hpkg;
689     DWORD sz;
690     UINT r;
691
692     hpkg = package_from_db(create_package_db());
693     ok( hpkg, "failed to create package\n");
694
695     r = MsiGetTargetPath( 0, NULL, NULL, NULL );
696     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
697
698     r = MsiGetTargetPath( 0, NULL, NULL, &sz );
699     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
700
701     r = MsiGetTargetPath( 0, "boo", NULL, NULL );
702     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
703
704     r = MsiGetTargetPath( 0, "boo", NULL, NULL );
705     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
706
707     r = MsiGetTargetPath( hpkg, "boo", NULL, NULL );
708     ok( r == ERROR_DIRECTORY, "wrong return val\n");
709
710     r = MsiGetTargetPath( hpkg, "boo", buffer, NULL );
711     ok( r == ERROR_DIRECTORY, "wrong return val\n");
712
713     MsiCloseHandle( hpkg );
714     DeleteFile(msifile);
715 }
716
717 static void query_file_path(MSIHANDLE hpkg, LPCSTR file, LPSTR buff)
718 {
719     UINT r;
720     DWORD size;
721     MSIHANDLE rec;
722
723     rec = MsiCreateRecord( 1 );
724     ok(rec, "MsiCreate record failed\n");
725
726     r = MsiRecordSetString( rec, 0, file );
727     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
728
729     size = MAX_PATH;
730     r = MsiFormatRecord( hpkg, rec, buff, &size );
731     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
732
733     MsiCloseHandle( rec );
734 }
735
736 static void test_settargetpath(void)
737 {
738     char tempdir[MAX_PATH+8], buffer[MAX_PATH], file[MAX_PATH];
739     DWORD sz;
740     MSIHANDLE hpkg;
741     UINT r;
742     MSIHANDLE hdb;
743
744     hdb = create_package_db();
745     ok ( hdb, "failed to create package database\n" );
746
747     r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'" );
748     ok( r == S_OK, "failed to add directory entry: %d\n" , r );
749
750     r = create_component_table( hdb );
751     ok( r == S_OK, "cannot create Component table: %d\n", r );
752
753     r = add_component_entry( hdb, "'RootComp', '{83e2694d-0864-4124-9323-6d37630912a1}', 'TARGETDIR', 8, '', 'RootFile'" );
754     ok( r == S_OK, "cannot add dummy component: %d\n", r );
755
756     r = add_component_entry( hdb, "'TestComp', '{A3FB59C8-C293-4F7E-B8C5-F0E1D8EEE4E5}', 'TestDir', 0, '', 'TestFile'" );
757     ok( r == S_OK, "cannot add test component: %d\n", r );
758
759     r = create_feature_table( hdb );
760     ok( r == S_OK, "cannot create Feature table: %d\n", r );
761
762     r = add_feature_entry( hdb, "'TestFeature', '', '', '', 0, 1, '', 0" );
763     ok( r == ERROR_SUCCESS, "cannot add TestFeature to Feature table: %d\n", r );
764
765     r = create_feature_components_table( hdb );
766     ok( r == S_OK, "cannot create FeatureComponents table: %d\n", r );
767
768     r = add_feature_components_entry( hdb, "'TestFeature', 'RootComp'" );
769     ok( r == S_OK, "cannot insert component into FeatureComponents table: %d\n", r );
770
771     r = add_feature_components_entry( hdb, "'TestFeature', 'TestComp'" );
772     ok( r == S_OK, "cannot insert component into FeatureComponents table: %d\n", r );
773
774     add_directory_entry( hdb, "'TestParent', 'TARGETDIR', 'TestParent'" );
775     add_directory_entry( hdb, "'TestDir', 'TestParent', 'TestDir'" );
776
777     r = create_file_table( hdb );
778     ok( r == S_OK, "cannot create File table: %d\n", r );
779
780     r = add_file_entry( hdb, "'RootFile', 'RootComp', 'rootfile.txt', 0, '', '1033', 8192, 1" );
781     ok( r == S_OK, "cannot add file to the File table: %d\n", r );
782
783     r = add_file_entry( hdb, "'TestFile', 'TestComp', 'testfile.txt', 0, '', '1033', 8192, 1" );
784     ok( r == S_OK, "cannot add file to the File table: %d\n", r );
785
786     hpkg = package_from_db( hdb );
787     ok( hpkg, "failed to create package\n");
788
789     r = MsiDoAction( hpkg, "CostInitialize");
790     ok( r == ERROR_SUCCESS, "cost init failed\n");
791
792     r = MsiDoAction( hpkg, "FileCost");
793     ok( r == ERROR_SUCCESS, "file cost failed\n");
794
795     r = MsiDoAction( hpkg, "CostFinalize");
796     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
797
798     r = MsiSetTargetPath( 0, NULL, NULL );
799     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
800
801     r = MsiSetTargetPath( 0, "boo", "C:\\bogusx" );
802     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
803
804     r = MsiSetTargetPath( hpkg, "boo", NULL );
805     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
806
807     r = MsiSetTargetPath( hpkg, "boo", "c:\\bogusx" );
808     ok( r == ERROR_DIRECTORY, "wrong return val\n");
809
810     sz = sizeof tempdir - 1;
811     r = MsiGetTargetPath( hpkg, "TARGETDIR", tempdir, &sz );
812     sprintf( file, "%srootfile.txt", tempdir );
813     query_file_path( hpkg, "[#RootFile]", buffer );
814     ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
815     ok( !lstrcmp(buffer, file), "Expected %s, got %s\n", file, buffer );
816
817     GetTempFileName( tempdir, "_wt", 0, buffer );
818     sprintf( tempdir, "%s\\subdir", buffer );
819
820     r = MsiSetTargetPath( hpkg, "TARGETDIR", buffer );
821     ok( r == ERROR_SUCCESS || r == ERROR_DIRECTORY,
822         "MsiSetTargetPath on file returned %d\n", r );
823
824     r = MsiSetTargetPath( hpkg, "TARGETDIR", tempdir );
825     ok( r == ERROR_SUCCESS || r == ERROR_DIRECTORY,
826         "MsiSetTargetPath on 'subdir' of file returned %d\n", r );
827
828     DeleteFile( buffer );
829
830     r = MsiSetTargetPath( hpkg, "TARGETDIR", buffer );
831     ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
832
833     r = GetFileAttributes( buffer );
834     ok ( r == INVALID_FILE_ATTRIBUTES, "file/directory exists after MsiSetTargetPath. Attributes: %08X\n", r );
835
836     r = MsiSetTargetPath( hpkg, "TARGETDIR", tempdir );
837     ok( r == ERROR_SUCCESS, "MsiSetTargetPath on subsubdir returned %d\n", r );
838
839     sz = sizeof buffer - 1;
840     lstrcat( tempdir, "\\" );
841     r = MsiGetTargetPath( hpkg, "TARGETDIR", buffer, &sz );
842     ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
843     ok( !lstrcmp(buffer, tempdir), "Expected %s, got %s\n", tempdir, buffer);
844
845     sprintf( file, "%srootfile.txt", tempdir );
846     query_file_path( hpkg, "[#RootFile]", buffer );
847     ok( !lstrcmp(buffer, file), "Expected %s, got %s\n", file, buffer);
848
849     r = MsiSetTargetPath( hpkg, "TestParent", "C:\\one\\two" );
850     ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
851
852     query_file_path( hpkg, "[#TestFile]", buffer );
853     ok( !lstrcmp(buffer, "C:\\one\\two\\TestDir\\testfile.txt"),
854         "Expected C:\\one\\two\\TestDir\\testfile.txt, got %s\n", buffer );
855
856     sz = sizeof buffer - 1;
857     r = MsiGetTargetPath( hpkg, "TestParent", buffer, &sz );
858     ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
859     ok( !lstrcmp(buffer, "C:\\one\\two\\"), "Expected C:\\one\\two\\, got %s\n", buffer);
860
861     MsiCloseHandle( hpkg );
862 }
863
864 static void test_condition(void)
865 {
866     MSICONDITION r;
867     MSIHANDLE hpkg;
868
869     hpkg = package_from_db(create_package_db());
870     ok( hpkg, "failed to create package\n");
871
872     r = MsiEvaluateCondition(0, NULL);
873     ok( r == MSICONDITION_ERROR, "wrong return val\n");
874
875     r = MsiEvaluateCondition(hpkg, NULL);
876     ok( r == MSICONDITION_NONE, "wrong return val\n");
877
878     r = MsiEvaluateCondition(hpkg, "");
879     ok( r == MSICONDITION_NONE, "wrong return val\n");
880
881     r = MsiEvaluateCondition(hpkg, "1");
882     ok( r == MSICONDITION_TRUE, "wrong return val\n");
883
884     r = MsiEvaluateCondition(hpkg, "0");
885     ok( r == MSICONDITION_FALSE, "wrong return val\n");
886
887     r = MsiEvaluateCondition(hpkg, "-1");
888     ok( r == MSICONDITION_TRUE, "wrong return val\n");
889
890     r = MsiEvaluateCondition(hpkg, "0 = 0");
891     ok( r == MSICONDITION_TRUE, "wrong return val\n");
892
893     r = MsiEvaluateCondition(hpkg, "0 <> 0");
894     ok( r == MSICONDITION_FALSE, "wrong return val\n");
895
896     r = MsiEvaluateCondition(hpkg, "0 = 1");
897     ok( r == MSICONDITION_FALSE, "wrong return val\n");
898
899     r = MsiEvaluateCondition(hpkg, "0 > 1");
900     ok( r == MSICONDITION_FALSE, "wrong return val\n");
901
902     r = MsiEvaluateCondition(hpkg, "0 ~> 1");
903     ok( r == MSICONDITION_FALSE, "wrong return val\n");
904
905     r = MsiEvaluateCondition(hpkg, "1 > 1");
906     ok( r == MSICONDITION_FALSE, "wrong return val\n");
907
908     r = MsiEvaluateCondition(hpkg, "1 ~> 1");
909     ok( r == MSICONDITION_FALSE, "wrong return val\n");
910
911     r = MsiEvaluateCondition(hpkg, "0 >= 1");
912     ok( r == MSICONDITION_FALSE, "wrong return val\n");
913
914     r = MsiEvaluateCondition(hpkg, "0 ~>= 1");
915     ok( r == MSICONDITION_FALSE, "wrong return val\n");
916
917     r = MsiEvaluateCondition(hpkg, "1 >= 1");
918     ok( r == MSICONDITION_TRUE, "wrong return val\n");
919
920     r = MsiEvaluateCondition(hpkg, "1 ~>= 1");
921     ok( r == MSICONDITION_TRUE, "wrong return val\n");
922
923     r = MsiEvaluateCondition(hpkg, "0 < 1");
924     ok( r == MSICONDITION_TRUE, "wrong return val\n");
925
926     r = MsiEvaluateCondition(hpkg, "0 ~< 1");
927     ok( r == MSICONDITION_TRUE, "wrong return val\n");
928
929     r = MsiEvaluateCondition(hpkg, "1 < 1");
930     ok( r == MSICONDITION_FALSE, "wrong return val\n");
931
932     r = MsiEvaluateCondition(hpkg, "1 ~< 1");
933     ok( r == MSICONDITION_FALSE, "wrong return val\n");
934
935     r = MsiEvaluateCondition(hpkg, "0 <= 1");
936     ok( r == MSICONDITION_TRUE, "wrong return val\n");
937
938     r = MsiEvaluateCondition(hpkg, "0 ~<= 1");
939     ok( r == MSICONDITION_TRUE, "wrong return val\n");
940
941     r = MsiEvaluateCondition(hpkg, "1 <= 1");
942     ok( r == MSICONDITION_TRUE, "wrong return val\n");
943
944     r = MsiEvaluateCondition(hpkg, "1 ~<= 1");
945     ok( r == MSICONDITION_TRUE, "wrong return val\n");
946
947     r = MsiEvaluateCondition(hpkg, "0 >=");
948     ok( r == MSICONDITION_ERROR, "wrong return val\n");
949
950     r = MsiEvaluateCondition(hpkg, " ");
951     ok( r == MSICONDITION_NONE, "wrong return val\n");
952
953     r = MsiEvaluateCondition(hpkg, "LicView <> \"1\"");
954     ok( r == MSICONDITION_TRUE, "wrong return val\n");
955
956     r = MsiEvaluateCondition(hpkg, "LicView <> \"0\"");
957     ok( r == MSICONDITION_TRUE, "wrong return val\n");
958
959     r = MsiEvaluateCondition(hpkg, "LicView <> LicView");
960     ok( r == MSICONDITION_FALSE, "wrong return val\n");
961
962     r = MsiEvaluateCondition(hpkg, "not 0");
963     ok( r == MSICONDITION_TRUE, "wrong return val\n");
964
965     r = MsiEvaluateCondition(hpkg, "not LicView");
966     ok( r == MSICONDITION_TRUE, "wrong return val\n");
967
968     r = MsiEvaluateCondition(hpkg, "not \"A\"");
969     ok( r == MSICONDITION_FALSE, "wrong return val\n");
970
971     r = MsiEvaluateCondition(hpkg, "~not \"A\"");
972     ok( r == MSICONDITION_ERROR, "wrong return val\n");
973
974     r = MsiEvaluateCondition(hpkg, "\"0\"");
975     ok( r == MSICONDITION_TRUE, "wrong return val\n");
976
977     r = MsiEvaluateCondition(hpkg, "1 and 2");
978     ok( r == MSICONDITION_TRUE, "wrong return val\n");
979
980     r = MsiEvaluateCondition(hpkg, "not 0 and 3");
981     ok( r == MSICONDITION_TRUE, "wrong return val\n");
982
983     r = MsiEvaluateCondition(hpkg, "not 0 and 0");
984     ok( r == MSICONDITION_FALSE, "wrong return val\n");
985
986     r = MsiEvaluateCondition(hpkg, "not 0 or 1");
987     ok( r == MSICONDITION_TRUE, "wrong return val\n");
988
989     r = MsiEvaluateCondition(hpkg, "(0)");
990     ok( r == MSICONDITION_FALSE, "wrong return val\n");
991
992     r = MsiEvaluateCondition(hpkg, "(((((1))))))");
993     ok( r == MSICONDITION_ERROR, "wrong return val\n");
994
995     r = MsiEvaluateCondition(hpkg, "(((((1)))))");
996     ok( r == MSICONDITION_TRUE, "wrong return val\n");
997
998     r = MsiEvaluateCondition(hpkg, " \"A\" < \"B\" ");
999     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1000
1001     r = MsiEvaluateCondition(hpkg, " \"A\" > \"B\" ");
1002     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1003
1004     r = MsiEvaluateCondition(hpkg, " \"1\" > \"12\" ");
1005     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1006
1007     r = MsiEvaluateCondition(hpkg, " \"100\" < \"21\" ");
1008     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1009
1010     r = MsiEvaluateCondition(hpkg, "0 < > 0");
1011     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1012
1013     r = MsiEvaluateCondition(hpkg, "(1<<1) == 2");
1014     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1015
1016     r = MsiEvaluateCondition(hpkg, " \"A\" = \"a\" ");
1017     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1018
1019     r = MsiEvaluateCondition(hpkg, " \"A\" ~ = \"a\" ");
1020     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1021
1022     r = MsiEvaluateCondition(hpkg, " \"A\" ~= \"a\" ");
1023     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1024
1025     r = MsiEvaluateCondition(hpkg, " \"A\" ~= 1 ");
1026     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1027
1028     r = MsiEvaluateCondition(hpkg, " \"A\" = 1 ");
1029     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1030
1031     r = MsiEvaluateCondition(hpkg, " 1 ~= 1 ");
1032     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1033
1034     r = MsiEvaluateCondition(hpkg, " 1 ~= \"1\" ");
1035     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1036
1037     r = MsiEvaluateCondition(hpkg, " 1 = \"1\" ");
1038     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1039
1040     r = MsiEvaluateCondition(hpkg, " 0 = \"1\" ");
1041     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1042
1043     r = MsiEvaluateCondition(hpkg, " 0 < \"100\" ");
1044     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1045
1046     r = MsiEvaluateCondition(hpkg, " 100 > \"0\" ");
1047     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1048
1049     r = MsiEvaluateCondition(hpkg, "1 XOR 1");
1050     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1051
1052     r = MsiEvaluateCondition(hpkg, "1 IMP 1");
1053     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1054
1055     r = MsiEvaluateCondition(hpkg, "1 IMP 0");
1056     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1057
1058     r = MsiEvaluateCondition(hpkg, "0 IMP 0");
1059     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1060
1061     r = MsiEvaluateCondition(hpkg, "0 EQV 0");
1062     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1063
1064     r = MsiEvaluateCondition(hpkg, "0 EQV 1");
1065     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1066
1067     r = MsiEvaluateCondition(hpkg, "1 IMP 1 OR 0");
1068     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1069
1070     r = MsiEvaluateCondition(hpkg, "1 IMPL 1");
1071     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1072
1073     r = MsiEvaluateCondition(hpkg, "\"ASFD\" >< \"S\" ");
1074     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1075
1076     r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"s\" ");
1077     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1078
1079     r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"\" ");
1080     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1081
1082     r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"sss\" ");
1083     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1084
1085     MsiSetProperty(hpkg, "mm", "5" );
1086
1087     r = MsiEvaluateCondition(hpkg, "mm = 5");
1088     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1089
1090     r = MsiEvaluateCondition(hpkg, "mm < 6");
1091     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1092
1093     r = MsiEvaluateCondition(hpkg, "mm <= 5");
1094     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1095
1096     r = MsiEvaluateCondition(hpkg, "mm > 4");
1097     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1098
1099     r = MsiEvaluateCondition(hpkg, "mm < 12");
1100     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1101
1102     r = MsiEvaluateCondition(hpkg, "mm = \"5\"");
1103     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1104
1105     r = MsiEvaluateCondition(hpkg, "0 = \"\"");
1106     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1107
1108     r = MsiEvaluateCondition(hpkg, "0 AND \"\"");
1109     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1110
1111     r = MsiEvaluateCondition(hpkg, "1 AND \"\"");
1112     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1113
1114     r = MsiEvaluateCondition(hpkg, "1 AND \"1\"");
1115     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1116
1117     r = MsiEvaluateCondition(hpkg, "3 >< 1");
1118     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1119
1120     r = MsiEvaluateCondition(hpkg, "3 >< 4");
1121     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1122
1123     r = MsiEvaluateCondition(hpkg, "NOT 0 AND 0");
1124     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1125
1126     r = MsiEvaluateCondition(hpkg, "NOT 0 AND 1");
1127     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1128
1129     r = MsiEvaluateCondition(hpkg, "NOT 1 OR 0");
1130     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1131
1132     r = MsiEvaluateCondition(hpkg, "0 AND 1 OR 1");
1133     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1134
1135     r = MsiEvaluateCondition(hpkg, "0 AND 0 OR 1");
1136     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1137
1138     r = MsiEvaluateCondition(hpkg, "NOT 0 AND 1 OR 0");
1139     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1140
1141     r = MsiEvaluateCondition(hpkg, "_1 = _1");
1142     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1143
1144     r = MsiEvaluateCondition(hpkg, "( 1 AND 1 ) = 2");
1145     ok( r == MSICONDITION_ERROR, "wrong return val\n");
1146
1147     r = MsiEvaluateCondition(hpkg, "NOT ( 1 AND 1 )");
1148     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1149
1150     r = MsiEvaluateCondition(hpkg, "NOT A AND (BBBBBBBBBB=2 OR CCC=1) AND Ddddddddd");
1151     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1152
1153     r = MsiEvaluateCondition(hpkg, "Installed<>\"\"");
1154     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1155
1156     r = MsiEvaluateCondition(hpkg, "NOT 1 AND 0");
1157     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1158
1159     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1160     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1161
1162     r = MsiEvaluateCondition(hpkg, "bandalmael<>0");
1163     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1164
1165     r = MsiEvaluateCondition(hpkg, "bandalmael<0");
1166     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1167
1168     r = MsiEvaluateCondition(hpkg, "bandalmael>0");
1169     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1170
1171     r = MsiEvaluateCondition(hpkg, "bandalmael>=0");
1172     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1173
1174     r = MsiEvaluateCondition(hpkg, "bandalmael<=0");
1175     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1176
1177     r = MsiEvaluateCondition(hpkg, "bandalmael~<>0");
1178     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1179
1180     MsiSetProperty(hpkg, "bandalmael", "0" );
1181     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1182     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1183
1184     MsiSetProperty(hpkg, "bandalmael", "" );
1185     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1186     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1187
1188     MsiSetProperty(hpkg, "bandalmael", "asdf" );
1189     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1190     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1191
1192     MsiSetProperty(hpkg, "bandalmael", "0asdf" );
1193     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1194     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1195
1196     MsiSetProperty(hpkg, "bandalmael", "0 " );
1197     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1198     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1199
1200     MsiSetProperty(hpkg, "bandalmael", "-0" );
1201     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1202     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1203
1204     MsiSetProperty(hpkg, "bandalmael", "0000000000000" );
1205     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1206     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1207
1208     MsiSetProperty(hpkg, "bandalmael", "--0" );
1209     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1210     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1211
1212     MsiSetProperty(hpkg, "bandalmael", "0x00" );
1213     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1214     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1215
1216     MsiSetProperty(hpkg, "bandalmael", "-" );
1217     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1218     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1219
1220     MsiSetProperty(hpkg, "bandalmael", "+0" );
1221     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1222     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1223
1224     MsiSetProperty(hpkg, "bandalmael", "0.0" );
1225     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1226     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1227     r = MsiEvaluateCondition(hpkg, "bandalmael<>0");
1228     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1229
1230     MsiSetProperty(hpkg, "one", "hi");
1231     MsiSetProperty(hpkg, "two", "hithere");
1232     r = MsiEvaluateCondition(hpkg, "one >< two");
1233     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1234
1235     MsiSetProperty(hpkg, "one", "hithere");
1236     MsiSetProperty(hpkg, "two", "hi");
1237     r = MsiEvaluateCondition(hpkg, "one >< two");
1238     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1239
1240     MsiSetProperty(hpkg, "one", "hello");
1241     MsiSetProperty(hpkg, "two", "hi");
1242     r = MsiEvaluateCondition(hpkg, "one >< two");
1243     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1244
1245     MsiSetProperty(hpkg, "one", "hellohithere");
1246     MsiSetProperty(hpkg, "two", "hi");
1247     r = MsiEvaluateCondition(hpkg, "one >< two");
1248     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1249
1250     MsiSetProperty(hpkg, "one", "");
1251     MsiSetProperty(hpkg, "two", "hi");
1252     r = MsiEvaluateCondition(hpkg, "one >< two");
1253     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1254
1255     MsiSetProperty(hpkg, "one", "hi");
1256     MsiSetProperty(hpkg, "two", "");
1257     r = MsiEvaluateCondition(hpkg, "one >< two");
1258     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1259
1260     MsiSetProperty(hpkg, "one", "");
1261     MsiSetProperty(hpkg, "two", "");
1262     r = MsiEvaluateCondition(hpkg, "one >< two");
1263     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1264
1265     MsiSetProperty(hpkg, "one", "1234");
1266     MsiSetProperty(hpkg, "two", "1");
1267     r = MsiEvaluateCondition(hpkg, "one >< two");
1268     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1269
1270     MsiSetProperty(hpkg, "one", "one 1234");
1271     MsiSetProperty(hpkg, "two", "1");
1272     r = MsiEvaluateCondition(hpkg, "one >< two");
1273     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1274
1275     MsiSetProperty(hpkg, "one", "hithere");
1276     MsiSetProperty(hpkg, "two", "hi");
1277     r = MsiEvaluateCondition(hpkg, "one << two");
1278     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1279
1280     MsiSetProperty(hpkg, "one", "hi");
1281     MsiSetProperty(hpkg, "two", "hithere");
1282     r = MsiEvaluateCondition(hpkg, "one << two");
1283     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1284
1285     MsiSetProperty(hpkg, "one", "hi");
1286     MsiSetProperty(hpkg, "two", "hi");
1287     r = MsiEvaluateCondition(hpkg, "one << two");
1288     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1289
1290     MsiSetProperty(hpkg, "one", "abcdhithere");
1291     MsiSetProperty(hpkg, "two", "hi");
1292     r = MsiEvaluateCondition(hpkg, "one << two");
1293     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1294
1295     MsiSetProperty(hpkg, "one", "");
1296     MsiSetProperty(hpkg, "two", "hi");
1297     r = MsiEvaluateCondition(hpkg, "one << two");
1298     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1299
1300     MsiSetProperty(hpkg, "one", "hithere");
1301     MsiSetProperty(hpkg, "two", "");
1302     r = MsiEvaluateCondition(hpkg, "one << two");
1303     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1304
1305     MsiSetProperty(hpkg, "one", "");
1306     MsiSetProperty(hpkg, "two", "");
1307     r = MsiEvaluateCondition(hpkg, "one << two");
1308     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1309
1310     MsiSetProperty(hpkg, "one", "1234");
1311     MsiSetProperty(hpkg, "two", "1");
1312     r = MsiEvaluateCondition(hpkg, "one << two");
1313     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1314
1315     MsiSetProperty(hpkg, "one", "1234 one");
1316     MsiSetProperty(hpkg, "two", "1");
1317     r = MsiEvaluateCondition(hpkg, "one << two");
1318     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1319
1320     MsiSetProperty(hpkg, "one", "hithere");
1321     MsiSetProperty(hpkg, "two", "there");
1322     r = MsiEvaluateCondition(hpkg, "one >> two");
1323     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1324
1325     MsiSetProperty(hpkg, "one", "hithere");
1326     MsiSetProperty(hpkg, "two", "hi");
1327     r = MsiEvaluateCondition(hpkg, "one >> two");
1328     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1329
1330     MsiSetProperty(hpkg, "one", "there");
1331     MsiSetProperty(hpkg, "two", "hithere");
1332     r = MsiEvaluateCondition(hpkg, "one >> two");
1333     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1334
1335     MsiSetProperty(hpkg, "one", "there");
1336     MsiSetProperty(hpkg, "two", "there");
1337     r = MsiEvaluateCondition(hpkg, "one >> two");
1338     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1339
1340     MsiSetProperty(hpkg, "one", "abcdhithere");
1341     MsiSetProperty(hpkg, "two", "hi");
1342     r = MsiEvaluateCondition(hpkg, "one >> two");
1343     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1344
1345     MsiSetProperty(hpkg, "one", "");
1346     MsiSetProperty(hpkg, "two", "there");
1347     r = MsiEvaluateCondition(hpkg, "one >> two");
1348     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1349
1350     MsiSetProperty(hpkg, "one", "there");
1351     MsiSetProperty(hpkg, "two", "");
1352     r = MsiEvaluateCondition(hpkg, "one >> two");
1353     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1354
1355     MsiSetProperty(hpkg, "one", "");
1356     MsiSetProperty(hpkg, "two", "");
1357     r = MsiEvaluateCondition(hpkg, "one >> two");
1358     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1359
1360     MsiSetProperty(hpkg, "one", "1234");
1361     MsiSetProperty(hpkg, "two", "4");
1362     r = MsiEvaluateCondition(hpkg, "one >> two");
1363     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1364
1365     MsiSetProperty(hpkg, "one", "one 1234");
1366     MsiSetProperty(hpkg, "two", "4");
1367     r = MsiEvaluateCondition(hpkg, "one >> two");
1368     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1369
1370     MsiSetProperty(hpkg, "MsiNetAssemblySupport", NULL);  /* make sure it's empty */
1371
1372     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322\"");
1373     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1374
1375     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport > \"1.1.4322\"");
1376     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1377
1378     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport >= \"1.1.4322\"");
1379     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1380
1381     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport <= \"1.1.4322\"");
1382     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1383
1384     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport <> \"1.1.4322\"");
1385     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1386
1387     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport ~< \"1.1.4322\"");
1388     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1389
1390     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"abcd\"");
1391     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1392
1393     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a1.1.4322\"");
1394     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1395
1396     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322a\"");
1397     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1398
1399     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"0000001.1.4322\"");
1400     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1401
1402     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322.1\"");
1403     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1404
1405     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322.1.1\"");
1406     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1407
1408     r = MsiEvaluateCondition(hpkg, "\"2\" < \"1.1");
1409     ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1410
1411     r = MsiEvaluateCondition(hpkg, "\"2\" < \"1.1\"");
1412     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1413
1414     r = MsiEvaluateCondition(hpkg, "\"2\" < \"12.1\"");
1415     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1416
1417     r = MsiEvaluateCondition(hpkg, "\"02.1\" < \"2.11\"");
1418     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1419
1420     r = MsiEvaluateCondition(hpkg, "\"02.1.1\" < \"2.1\"");
1421     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1422
1423     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1\"");
1424     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1425
1426     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1\"");
1427     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1428
1429     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"0\"");
1430     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1431
1432     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"-1\"");
1433     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1434
1435     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a\"");
1436     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1437
1438     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"!\"");
1439     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1440
1441     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"!\"");
1442     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1443
1444     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"/\"");
1445     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1446
1447     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \" \"");
1448     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1449
1450     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"azAZ_\"");
1451     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1452
1453     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a[a]\"");
1454     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1455
1456     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a[a]a\"");
1457     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1458
1459     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[a]\"");
1460     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1461
1462     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[a]a\"");
1463     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1464
1465     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"{a}\"");
1466     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1467
1468     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"{a\"");
1469     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1470
1471     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[a\"");
1472     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1473
1474     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a{\"");
1475     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1476
1477     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a]\"");
1478     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1479
1480     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"A\"");
1481     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1482
1483     MsiSetProperty(hpkg, "MsiNetAssemblySupport", "1.1.4322");
1484     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322\"");
1485     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1486
1487     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.14322\"");
1488     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1489
1490     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.5\"");
1491     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1492
1493     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1\"");
1494     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1495
1496     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1\"");
1497     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1498
1499     MsiSetProperty(hpkg, "one", "1");
1500     r = MsiEvaluateCondition(hpkg, "one < \"1\"");
1501     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1502
1503     MsiSetProperty(hpkg, "X", "5.0");
1504
1505     r = MsiEvaluateCondition(hpkg, "X != \"\"");
1506     ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1507
1508     r = MsiEvaluateCondition(hpkg, "X =\"5.0\"");
1509     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1510
1511     r = MsiEvaluateCondition(hpkg, "X =\"5.1\"");
1512     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1513
1514     r = MsiEvaluateCondition(hpkg, "X =\"6.0\"");
1515     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1516
1517     r = MsiEvaluateCondition(hpkg, "X =\"5.0\" or X =\"5.1\" or X =\"6.0\"");
1518     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1519
1520     r = MsiEvaluateCondition(hpkg, "(X =\"5.0\" or X =\"5.1\" or X =\"6.0\")");
1521     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1522
1523     r = MsiEvaluateCondition(hpkg, "X !=\"\" and (X =\"5.0\" or X =\"5.1\" or X =\"6.0\")");
1524     ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1525
1526     /* feature doesn't exist */
1527     r = MsiEvaluateCondition(hpkg, "&nofeature");
1528     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1529
1530     MsiSetProperty(hpkg, "A", "2");
1531     MsiSetProperty(hpkg, "X", "50");
1532
1533     r = MsiEvaluateCondition(hpkg, "2 <= X");
1534     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1535
1536     r = MsiEvaluateCondition(hpkg, "A <= X");
1537     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1538
1539     r = MsiEvaluateCondition(hpkg, "A <= 50");
1540     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1541
1542     MsiSetProperty(hpkg, "X", "50val");
1543
1544     r = MsiEvaluateCondition(hpkg, "2 <= X");
1545     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1546
1547     r = MsiEvaluateCondition(hpkg, "A <= X");
1548     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1549
1550     MsiSetProperty(hpkg, "A", "7");
1551     MsiSetProperty(hpkg, "X", "50");
1552
1553     r = MsiEvaluateCondition(hpkg, "7 <= X");
1554     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1555
1556     r = MsiEvaluateCondition(hpkg, "A <= X");
1557     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1558
1559     r = MsiEvaluateCondition(hpkg, "A <= 50");
1560     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1561
1562     MsiSetProperty(hpkg, "X", "50val");
1563
1564     r = MsiEvaluateCondition(hpkg, "2 <= X");
1565     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1566
1567     r = MsiEvaluateCondition(hpkg, "A <= X");
1568     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1569
1570     MsiCloseHandle( hpkg );
1571     DeleteFile(msifile);
1572 }
1573
1574 static BOOL check_prop_empty( MSIHANDLE hpkg, const char * prop)
1575 {
1576     UINT r;
1577     DWORD sz;
1578     char buffer[2];
1579
1580     sz = sizeof buffer;
1581     strcpy(buffer,"x");
1582     r = MsiGetProperty( hpkg, prop, buffer, &sz );
1583     return r == ERROR_SUCCESS && buffer[0] == 0 && sz == 0;
1584 }
1585
1586 static void test_props(void)
1587 {
1588     MSIHANDLE hpkg, hdb;
1589     UINT r;
1590     DWORD sz;
1591     char buffer[0x100];
1592
1593     hdb = create_package_db();
1594     r = run_query( hdb,
1595             "CREATE TABLE `Property` ( "
1596             "`Property` CHAR(255) NOT NULL, "
1597             "`Value` CHAR(255) "
1598             "PRIMARY KEY `Property`)" );
1599     ok( r == ERROR_SUCCESS , "Failed\n" );
1600
1601     r = run_query(hdb,
1602             "INSERT INTO `Property` "
1603             "(`Property`, `Value`) "
1604             "VALUES( 'MetadataCompName', 'Photoshop.dll' )");
1605     ok( r == ERROR_SUCCESS , "Failed\n" );
1606
1607     hpkg = package_from_db( hdb );
1608     ok( hpkg, "failed to create package\n");
1609
1610     /* test invalid values */
1611     r = MsiGetProperty( 0, NULL, NULL, NULL );
1612     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1613
1614     r = MsiGetProperty( hpkg, NULL, NULL, NULL );
1615     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1616
1617     r = MsiGetProperty( hpkg, "boo", NULL, NULL );
1618     ok( r == ERROR_SUCCESS, "wrong return val\n");
1619
1620     r = MsiGetProperty( hpkg, "boo", buffer, NULL );
1621     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1622
1623     /* test retrieving an empty/nonexistent property */
1624     sz = sizeof buffer;
1625     r = MsiGetProperty( hpkg, "boo", NULL, &sz );
1626     ok( r == ERROR_SUCCESS, "wrong return val\n");
1627     ok( sz == 0, "wrong size returned\n");
1628
1629     check_prop_empty( hpkg, "boo");
1630     sz = 0;
1631     strcpy(buffer,"x");
1632     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1633     ok( r == ERROR_MORE_DATA, "wrong return val\n");
1634     ok( !strcmp(buffer,"x"), "buffer was changed\n");
1635     ok( sz == 0, "wrong size returned\n");
1636
1637     sz = 1;
1638     strcpy(buffer,"x");
1639     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1640     ok( r == ERROR_SUCCESS, "wrong return val\n");
1641     ok( buffer[0] == 0, "buffer was not changed\n");
1642     ok( sz == 0, "wrong size returned\n");
1643
1644     /* set the property to something */
1645     r = MsiSetProperty( 0, NULL, NULL );
1646     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
1647
1648     r = MsiSetProperty( hpkg, NULL, NULL );
1649     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1650
1651     r = MsiSetProperty( hpkg, "", NULL );
1652     ok( r == ERROR_SUCCESS, "wrong return val\n");
1653
1654     /* try set and get some illegal property identifiers */
1655     r = MsiSetProperty( hpkg, "", "asdf" );
1656     ok( r == ERROR_FUNCTION_FAILED, "wrong return val\n");
1657
1658     r = MsiSetProperty( hpkg, "=", "asdf" );
1659     ok( r == ERROR_SUCCESS, "wrong return val\n");
1660
1661     r = MsiSetProperty( hpkg, " ", "asdf" );
1662     ok( r == ERROR_SUCCESS, "wrong return val\n");
1663
1664     r = MsiSetProperty( hpkg, "'", "asdf" );
1665     ok( r == ERROR_SUCCESS, "wrong return val\n");
1666
1667     sz = sizeof buffer;
1668     buffer[0]=0;
1669     r = MsiGetProperty( hpkg, "'", buffer, &sz );
1670     ok( r == ERROR_SUCCESS, "wrong return val\n");
1671     ok( !strcmp(buffer,"asdf"), "buffer was not changed\n");
1672
1673     /* set empty values */
1674     r = MsiSetProperty( hpkg, "boo", NULL );
1675     ok( r == ERROR_SUCCESS, "wrong return val\n");
1676     ok( check_prop_empty( hpkg, "boo"), "prop wasn't empty\n");
1677
1678     r = MsiSetProperty( hpkg, "boo", "" );
1679     ok( r == ERROR_SUCCESS, "wrong return val\n");
1680     ok( check_prop_empty( hpkg, "boo"), "prop wasn't empty\n");
1681
1682     /* set a non-empty value */
1683     r = MsiSetProperty( hpkg, "boo", "xyz" );
1684     ok( r == ERROR_SUCCESS, "wrong return val\n");
1685
1686     sz = 1;
1687     strcpy(buffer,"x");
1688     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1689     ok( r == ERROR_MORE_DATA, "wrong return val\n");
1690     ok( buffer[0] == 0, "buffer was not changed\n");
1691     ok( sz == 3, "wrong size returned\n");
1692
1693     sz = 4;
1694     strcpy(buffer,"x");
1695     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1696     ok( r == ERROR_SUCCESS, "wrong return val\n");
1697     ok( !strcmp(buffer,"xyz"), "buffer was not changed\n");
1698     ok( sz == 3, "wrong size returned\n");
1699
1700     sz = 3;
1701     strcpy(buffer,"x");
1702     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1703     ok( r == ERROR_MORE_DATA, "wrong return val\n");
1704     ok( !strcmp(buffer,"xy"), "buffer was not changed\n");
1705     ok( sz == 3, "wrong size returned\n");
1706
1707     r = MsiSetProperty(hpkg, "SourceDir", "foo");
1708     ok( r == ERROR_SUCCESS, "wrong return val\n");
1709
1710     sz = 4;
1711     r = MsiGetProperty(hpkg, "SOURCEDIR", buffer, &sz);
1712     ok( r == ERROR_SUCCESS, "wrong return val\n");
1713     ok( !strcmp(buffer,""), "buffer wrong\n");
1714     ok( sz == 0, "wrong size returned\n");
1715
1716     sz = 4;
1717     r = MsiGetProperty(hpkg, "SOMERANDOMNAME", buffer, &sz);
1718     ok( r == ERROR_SUCCESS, "wrong return val\n");
1719     ok( !strcmp(buffer,""), "buffer wrong\n");
1720     ok( sz == 0, "wrong size returned\n");
1721
1722     sz = 4;
1723     r = MsiGetProperty(hpkg, "SourceDir", buffer, &sz);
1724     ok( r == ERROR_SUCCESS, "wrong return val\n");
1725     ok( !strcmp(buffer,"foo"), "buffer wrong\n");
1726     ok( sz == 3, "wrong size returned\n");
1727
1728     r = MsiSetProperty(hpkg, "MetadataCompName", "Photoshop.dll");
1729     ok( r == ERROR_SUCCESS, "wrong return val\n");
1730
1731     sz = 0;
1732     r = MsiGetProperty(hpkg, "MetadataCompName", NULL, &sz );
1733     ok( r == ERROR_SUCCESS, "return wrong\n");
1734     ok( sz == 13, "size wrong (%d)\n", sz);
1735
1736     sz = 13;
1737     r = MsiGetProperty(hpkg, "MetadataCompName", buffer, &sz );
1738     ok( r == ERROR_MORE_DATA, "return wrong\n");
1739     ok( !strcmp(buffer,"Photoshop.dl"), "buffer wrong\n");
1740
1741     r = MsiSetProperty(hpkg, "property", "value");
1742     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1743
1744     sz = 6;
1745     r = MsiGetProperty(hpkg, "property", buffer, &sz);
1746     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1747     ok( !strcmp(buffer, "value"), "Expected value, got %s\n", buffer);
1748
1749     r = MsiSetProperty(hpkg, "property", NULL);
1750     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1751
1752     sz = 6;
1753     r = MsiGetProperty(hpkg, "property", buffer, &sz);
1754     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1755     ok( !strlen(buffer), "Expected empty string, got %s\n", buffer);
1756
1757     MsiCloseHandle( hpkg );
1758     DeleteFile(msifile);
1759 }
1760
1761 static BOOL find_prop_in_property(MSIHANDLE hdb, LPCSTR prop, LPCSTR val)
1762 {
1763     MSIHANDLE hview, hrec;
1764     BOOL found;
1765     CHAR buffer[MAX_PATH];
1766     DWORD sz;
1767     UINT r;
1768
1769     r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Property`", &hview);
1770     ok(r == ERROR_SUCCESS, "MsiDatabaseOpenView failed\n");
1771     r = MsiViewExecute(hview, 0);
1772     ok(r == ERROR_SUCCESS, "MsiViewExecute failed\n");
1773
1774     found = FALSE;
1775     while (r == ERROR_SUCCESS && !found)
1776     {
1777         r = MsiViewFetch(hview, &hrec);
1778         if (r != ERROR_SUCCESS) break;
1779
1780         sz = MAX_PATH;
1781         r = MsiRecordGetString(hrec, 1, buffer, &sz);
1782         if (r == ERROR_SUCCESS && !lstrcmpA(buffer, prop))
1783         {
1784             sz = MAX_PATH;
1785             r = MsiRecordGetString(hrec, 2, buffer, &sz);
1786             if (r == ERROR_SUCCESS && !lstrcmpA(buffer, val))
1787                 found = TRUE;
1788         }
1789
1790         MsiCloseHandle(hrec);
1791     }
1792
1793     MsiViewClose(hview);
1794     MsiCloseHandle(hview);
1795
1796     return found;
1797 }
1798
1799 static void test_property_table(void)
1800 {
1801     const char *query;
1802     UINT r;
1803     MSIHANDLE hpkg, hdb, hrec;
1804     char buffer[MAX_PATH];
1805     DWORD sz;
1806     BOOL found;
1807
1808     hdb = create_package_db();
1809     ok( hdb, "failed to create package\n");
1810
1811     hpkg = package_from_db(hdb);
1812     ok( hpkg, "failed to create package\n");
1813
1814     MsiCloseHandle(hdb);
1815
1816     hdb = MsiGetActiveDatabase(hpkg);
1817
1818     query = "CREATE TABLE `_Property` ( "
1819         "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
1820     r = run_query(hdb, query);
1821     ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
1822
1823     MsiCloseHandle(hdb);
1824     MsiCloseHandle(hpkg);
1825     DeleteFile(msifile);
1826
1827     hdb = create_package_db();
1828     ok( hdb, "failed to create package\n");
1829
1830     query = "CREATE TABLE `_Property` ( "
1831         "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
1832     r = run_query(hdb, query);
1833     ok(r == ERROR_SUCCESS, "failed to create table\n");
1834
1835     query = "ALTER `_Property` ADD `foo` INTEGER";
1836     r = run_query(hdb, query);
1837     ok(r == ERROR_BAD_QUERY_SYNTAX, "failed to add column\n");
1838
1839     query = "ALTER TABLE `_Property` ADD `foo` INTEGER";
1840     r = run_query(hdb, query);
1841     ok(r == ERROR_BAD_QUERY_SYNTAX, "failed to add column\n");
1842
1843     query = "ALTER TABLE `_Property` ADD `extra` INTEGER";
1844     r = run_query(hdb, query);
1845     ok(r == ERROR_SUCCESS, "failed to add column\n");
1846
1847     hpkg = package_from_db(hdb);
1848     todo_wine
1849     {
1850         ok(!hpkg, "package should not be created\n");
1851     }
1852
1853     MsiCloseHandle(hdb);
1854     MsiCloseHandle(hpkg);
1855     DeleteFile(msifile);
1856
1857     hdb = create_package_db();
1858     ok (hdb, "failed to create package database\n");
1859
1860     r = create_property_table(hdb);
1861     ok(r == ERROR_SUCCESS, "cannot create Property table: %d\n", r);
1862
1863     r = add_property_entry(hdb, "'prop', 'val'");
1864     ok(r == ERROR_SUCCESS, "cannot add property: %d\n", r);
1865
1866     hpkg = package_from_db(hdb);
1867     ok(hpkg, "failed to create package\n");
1868
1869     MsiCloseHandle(hdb);
1870
1871     sz = MAX_PATH;
1872     r = MsiGetProperty(hpkg, "prop", buffer, &sz);
1873     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1874     ok(!lstrcmp(buffer, "val"), "Expected val, got %s\n", buffer);
1875
1876     hdb = MsiGetActiveDatabase(hpkg);
1877
1878     found = find_prop_in_property(hdb, "prop", "val");
1879     ok(found, "prop should be in the _Property table\n");
1880
1881     r = add_property_entry(hdb, "'dantes', 'mercedes'");
1882     ok(r == ERROR_SUCCESS, "cannot add property: %d\n", r);
1883
1884     query = "SELECT * FROM `_Property` WHERE `Property` = 'dantes'";
1885     r = do_query(hdb, query, &hrec);
1886     ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
1887
1888     found = find_prop_in_property(hdb, "dantes", "mercedes");
1889     ok(found == FALSE, "dantes should not be in the _Property table\n");
1890
1891     sz = MAX_PATH;
1892     lstrcpy(buffer, "aaa");
1893     r = MsiGetProperty(hpkg, "dantes", buffer, &sz);
1894     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1895     ok(lstrlenA(buffer) == 0, "Expected empty string, got %s\n", buffer);
1896
1897     r = MsiSetProperty(hpkg, "dantes", "mercedes");
1898     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1899
1900     found = find_prop_in_property(hdb, "dantes", "mercedes");
1901     ok(found == TRUE, "dantes should be in the _Property table\n");
1902
1903     MsiCloseHandle(hdb);
1904     MsiCloseHandle(hpkg);
1905     DeleteFile(msifile);
1906 }
1907
1908 static UINT try_query_param( MSIHANDLE hdb, LPCSTR szQuery, MSIHANDLE hrec )
1909 {
1910     MSIHANDLE htab = 0;
1911     UINT res;
1912
1913     res = MsiDatabaseOpenView( hdb, szQuery, &htab );
1914     if( res == ERROR_SUCCESS )
1915     {
1916         UINT r;
1917
1918         r = MsiViewExecute( htab, hrec );
1919         if( r != ERROR_SUCCESS )
1920         {
1921             res = r;
1922             fprintf(stderr,"MsiViewExecute failed %08x\n", res);
1923         }
1924
1925         r = MsiViewClose( htab );
1926         if( r != ERROR_SUCCESS )
1927             res = r;
1928
1929         r = MsiCloseHandle( htab );
1930         if( r != ERROR_SUCCESS )
1931             res = r;
1932     }
1933     return res;
1934 }
1935
1936 static UINT try_query( MSIHANDLE hdb, LPCSTR szQuery )
1937 {
1938     return try_query_param( hdb, szQuery, 0 );
1939 }
1940
1941 static void set_summary_str(MSIHANDLE hdb, DWORD pid, LPCSTR value)
1942 {
1943     MSIHANDLE summary;
1944     UINT r;
1945
1946     r = MsiGetSummaryInformationA(hdb, NULL, 1, &summary);
1947     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1948
1949     r = MsiSummaryInfoSetPropertyA(summary, pid, VT_LPSTR, 0, NULL, value);
1950     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1951
1952     r = MsiSummaryInfoPersist(summary);
1953     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1954
1955     MsiCloseHandle(summary);
1956 }
1957
1958 static void set_summary_dword(MSIHANDLE hdb, DWORD pid, DWORD value)
1959 {
1960     MSIHANDLE summary;
1961     UINT r;
1962
1963     r = MsiGetSummaryInformationA(hdb, NULL, 1, &summary);
1964     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1965
1966     r = MsiSummaryInfoSetPropertyA(summary, pid, VT_I4, value, NULL, NULL);
1967     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1968
1969     r = MsiSummaryInfoPersist(summary);
1970     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1971
1972     MsiCloseHandle(summary);
1973 }
1974
1975 static void test_msipackage(void)
1976 {
1977     MSIHANDLE hdb = 0, hpack = 100;
1978     UINT r;
1979     const char *query;
1980     char name[10];
1981
1982     /* NULL szPackagePath */
1983     r = MsiOpenPackage(NULL, &hpack);
1984     ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1985
1986     /* empty szPackagePath */
1987     r = MsiOpenPackage("", &hpack);
1988     todo_wine
1989     {
1990         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1991     }
1992
1993     if (r == ERROR_SUCCESS)
1994         MsiCloseHandle(hpack);
1995
1996     /* nonexistent szPackagePath */
1997     r = MsiOpenPackage("nonexistent", &hpack);
1998     ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
1999
2000     /* NULL hProduct */
2001     r = MsiOpenPackage(msifile, NULL);
2002     ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2003
2004     name[0]='#';
2005     name[1]=0;
2006     r = MsiOpenPackage(name, &hpack);
2007     ok(r == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got %d\n", r);
2008
2009     r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
2010     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2011
2012     /* database exists, but is emtpy */
2013     sprintf(name, "#%ld", hdb);
2014     r = MsiOpenPackage(name, &hpack);
2015     ok(r == ERROR_INSTALL_PACKAGE_INVALID,
2016        "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
2017
2018     query = "CREATE TABLE `Property` ( "
2019             "`Property` CHAR(72), `Value` CHAR(0) "
2020             "PRIMARY KEY `Property`)";
2021     r = try_query(hdb, query);
2022     ok(r == ERROR_SUCCESS, "failed to create Properties table\n");
2023
2024     query = "CREATE TABLE `InstallExecuteSequence` ("
2025             "`Action` CHAR(72), `Condition` CHAR(0), `Sequence` INTEGER "
2026             "PRIMARY KEY `Action`)";
2027     r = try_query(hdb, query);
2028     ok(r == ERROR_SUCCESS, "failed to create InstallExecuteSequence table\n");
2029
2030     /* a few key tables exist */
2031     sprintf(name, "#%ld", hdb);
2032     r = MsiOpenPackage(name, &hpack);
2033     ok(r == ERROR_INSTALL_PACKAGE_INVALID,
2034        "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
2035
2036     MsiCloseHandle(hdb);
2037     DeleteFile(msifile);
2038
2039     /* start with a clean database to show what constitutes a valid package */
2040     r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
2041     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2042
2043     sprintf(name, "#%ld", hdb);
2044
2045     /* The following summary information props must exist:
2046      *  - PID_REVNUMBER
2047      *  - PID_PAGECOUNT
2048      */
2049
2050     set_summary_dword(hdb, PID_PAGECOUNT, 100);
2051     r = MsiOpenPackage(name, &hpack);
2052     ok(r == ERROR_INSTALL_PACKAGE_INVALID,
2053        "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
2054
2055     set_summary_str(hdb, PID_REVNUMBER, "{004757CD-5092-49c2-AD20-28E1CE0DF5F2}");
2056     r = MsiOpenPackage(name, &hpack);
2057     ok(r == ERROR_SUCCESS,
2058        "Expected ERROR_SUCCESS, got %d\n", r);
2059
2060     MsiCloseHandle(hpack);
2061     MsiCloseHandle(hdb);
2062     DeleteFile(msifile);
2063 }
2064
2065 static void test_formatrecord2(void)
2066 {
2067     MSIHANDLE hpkg, hrec ;
2068     char buffer[0x100];
2069     DWORD sz;
2070     UINT r;
2071
2072     hpkg = package_from_db(create_package_db());
2073     ok( hpkg, "failed to create package\n");
2074
2075     r = MsiSetProperty(hpkg, "Manufacturer", " " );
2076     ok( r == ERROR_SUCCESS, "set property failed\n");
2077
2078     hrec = MsiCreateRecord(2);
2079     ok(hrec, "create record failed\n");
2080
2081     r = MsiRecordSetString( hrec, 0, "[ProgramFilesFolder][Manufacturer]\\asdf");
2082     ok( r == ERROR_SUCCESS, "format record failed\n");
2083
2084     buffer[0] = 0;
2085     sz = sizeof buffer;
2086     r = MsiFormatRecord( hpkg, hrec, buffer, &sz );
2087
2088     r = MsiRecordSetString(hrec, 0, "[foo][1]");
2089     r = MsiRecordSetString(hrec, 1, "hoo");
2090     sz = sizeof buffer;
2091     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2092     ok( sz == 3, "size wrong\n");
2093     ok( 0 == strcmp(buffer,"hoo"), "wrong output %s\n",buffer);
2094     ok( r == ERROR_SUCCESS, "format failed\n");
2095
2096     r = MsiRecordSetString(hrec, 0, "x[~]x");
2097     sz = sizeof buffer;
2098     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2099     ok( sz == 3, "size wrong\n");
2100     ok( 0 == strcmp(buffer,"x"), "wrong output %s\n",buffer);
2101     ok( r == ERROR_SUCCESS, "format failed\n");
2102
2103     r = MsiRecordSetString(hrec, 0, "[foo.$%}][1]");
2104     r = MsiRecordSetString(hrec, 1, "hoo");
2105     sz = sizeof buffer;
2106     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2107     ok( sz == 3, "size wrong\n");
2108     ok( 0 == strcmp(buffer,"hoo"), "wrong output %s\n",buffer);
2109     ok( r == ERROR_SUCCESS, "format failed\n");
2110
2111     r = MsiRecordSetString(hrec, 0, "[\\[]");
2112     sz = sizeof buffer;
2113     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2114     ok( sz == 1, "size wrong\n");
2115     ok( 0 == strcmp(buffer,"["), "wrong output %s\n",buffer);
2116     ok( r == ERROR_SUCCESS, "format failed\n");
2117
2118     SetEnvironmentVariable("FOO", "BAR");
2119     r = MsiRecordSetString(hrec, 0, "[%FOO]");
2120     sz = sizeof buffer;
2121     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2122     ok( sz == 3, "size wrong\n");
2123     ok( 0 == strcmp(buffer,"BAR"), "wrong output %s\n",buffer);
2124     ok( r == ERROR_SUCCESS, "format failed\n");
2125
2126     r = MsiRecordSetString(hrec, 0, "[[1]]");
2127     r = MsiRecordSetString(hrec, 1, "%FOO");
2128     sz = sizeof buffer;
2129     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2130     ok( sz == 3, "size wrong\n");
2131     ok( 0 == strcmp(buffer,"BAR"), "wrong output %s\n",buffer);
2132     ok( r == ERROR_SUCCESS, "format failed\n");
2133
2134     MsiCloseHandle( hrec );
2135     MsiCloseHandle( hpkg );
2136     DeleteFile(msifile);
2137 }
2138
2139 /* FIXME: state is INSTALLSTATE_UNKNOWN if any features are removed and the
2140  * feature in question is not in ADD*
2141  */
2142 static void test_states(void)
2143 {
2144     MSIHANDLE hpkg;
2145     UINT r;
2146     MSIHANDLE hdb;
2147     INSTALLSTATE state, action;
2148
2149     hdb = create_package_db();
2150     ok ( hdb, "failed to create package database\n" );
2151
2152     r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
2153     ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
2154
2155     r = create_property_table( hdb );
2156     ok( r == ERROR_SUCCESS, "cannot create Property table: %d\n", r );
2157
2158     r = add_property_entry( hdb, "'ProductCode', '{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}'" );
2159     ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2160
2161     r = add_property_entry( hdb, "'ProductLanguage', '1033'" );
2162     ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2163
2164     r = add_property_entry( hdb, "'ProductName', 'MSITEST'" );
2165     ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2166
2167     r = add_property_entry( hdb, "'ProductVersion', '1.1.1'" );
2168     ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2169
2170     r = create_install_execute_sequence_table( hdb );
2171     ok( r == ERROR_SUCCESS, "cannot create InstallExecuteSequence table: %d\n", r );
2172
2173     r = add_install_execute_sequence_entry( hdb, "'CostInitialize', '', '800'" );
2174     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2175
2176     r = add_install_execute_sequence_entry( hdb, "'FileCost', '', '900'" );
2177     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2178
2179     r = add_install_execute_sequence_entry( hdb, "'CostFinalize', '', '1000'" );
2180     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2181
2182     r = add_install_execute_sequence_entry( hdb, "'InstallValidate', '', '1400'" );
2183     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2184
2185     r = add_install_execute_sequence_entry( hdb, "'InstallInitialize', '', '1500'" );
2186     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2187
2188     r = add_install_execute_sequence_entry( hdb, "'ProcessComponents', '', '1600'" );
2189     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2190
2191     r = add_install_execute_sequence_entry( hdb, "'UnpublishFeatures', '', '1800'" );
2192     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2193
2194     r = add_install_execute_sequence_entry( hdb, "'RegisterProduct', '', '6100'" );
2195     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2196
2197     r = add_install_execute_sequence_entry( hdb, "'PublishFeatures', '', '6300'" );
2198     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2199
2200     r = add_install_execute_sequence_entry( hdb, "'PublishProduct', '', '6400'" );
2201     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2202
2203     r = add_install_execute_sequence_entry( hdb, "'InstallFinalize', '', '6600'" );
2204     ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2205
2206     r = create_media_table( hdb );
2207     ok( r == ERROR_SUCCESS, "cannot create media table: %d\n", r );
2208
2209     r = add_media_entry( hdb, "'1', '3', '', '', 'DISK1', ''");
2210     ok( r == ERROR_SUCCESS, "cannot add media entry: %d\n", r );
2211
2212     r = create_feature_table( hdb );
2213     ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
2214
2215     r = create_component_table( hdb );
2216     ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
2217
2218     /* msidbFeatureAttributesFavorLocal */
2219     r = add_feature_entry( hdb, "'one', '', '', '', 2, 1, '', 0" );
2220     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2221
2222     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
2223     r = add_component_entry( hdb, "'alpha', '{467EC132-739D-4784-A37B-677AA43DBC94}', 'TARGETDIR', 0, '', 'alpha_file'" );
2224     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2225
2226     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
2227     r = add_component_entry( hdb, "'beta', '{2C1F189C-24A6-4C34-B26B-994A6C026506}', 'TARGETDIR', 1, '', 'beta_file'" );
2228     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2229
2230     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
2231     r = add_component_entry( hdb, "'gamma', '{C271E2A4-DE2E-4F70-86D1-6984AF7DE2CA}', 'TARGETDIR', 2, '', 'gamma_file'" );
2232     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2233
2234     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSharedDllRefCount */
2235     r = add_component_entry( hdb, "'theta', '{4EB3129D-81A8-48D5-9801-75600FED3DD9}', 'TARGETDIR', 8, '', 'theta_file'" );
2236     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2237
2238     /* msidbFeatureAttributesFavorSource */
2239     r = add_feature_entry( hdb, "'two', '', '', '', 2, 1, '', 1" );
2240     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2241
2242     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
2243     r = add_component_entry( hdb, "'delta', '{938FD4F2-C648-4259-A03C-7AA3B45643F3}', 'TARGETDIR', 0, '', 'delta_file'" );
2244     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2245
2246     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
2247     r = add_component_entry( hdb, "'epsilon', '{D59713B6-C11D-47F2-A395-1E5321781190}', 'TARGETDIR', 1, '', 'epsilon_file'" );
2248     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2249
2250     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
2251     r = add_component_entry( hdb, "'zeta', '{377D33AB-2FAA-42B9-A629-0C0DAE9B9C7A}', 'TARGETDIR', 2, '', 'zeta_file'" );
2252     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2253
2254     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSharedDllRefCount */
2255     r = add_component_entry( hdb, "'iota', '{5D36F871-B5ED-4801-9E0F-C46B9E5C9669}', 'TARGETDIR', 8, '', 'iota_file'" );
2256     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2257
2258     /* msidbFeatureAttributesFavorSource */
2259     r = add_feature_entry( hdb, "'three', '', '', '', 2, 1, '', 1" );
2260     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2261
2262     /* msidbFeatureAttributesFavorLocal */
2263     r = add_feature_entry( hdb, "'four', '', '', '', 2, 1, '', 0" );
2264     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2265
2266     /* disabled */
2267     r = add_feature_entry( hdb, "'five', '', '', '', 2, 0, '', 1" );
2268     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2269
2270     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
2271     r = add_component_entry( hdb, "'eta', '{DD89003F-0DD4-41B8-81C0-3411A7DA2695}', 'TARGETDIR', 1, '', 'eta_file'" );
2272     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2273
2274     /* no feature parent:msidbComponentAttributesLocalOnly */
2275     r = add_component_entry( hdb, "'kappa', '{D6B93DC3-8DA5-4769-9888-42BFE156BB8B}', 'TARGETDIR', 1, '', 'kappa_file'" );
2276     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2277
2278     /* msidbFeatureAttributesFavorLocal:removed */
2279     r = add_feature_entry( hdb, "'six', '', '', '', 2, 1, '', 0" );
2280     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2281
2282     /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesLocalOnly */
2283     r = add_component_entry( hdb, "'lambda', '{6528C5E4-02A4-4636-A214-7A66A6C35B64}', 'TARGETDIR', 0, '', 'lambda_file'" );
2284     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2285
2286     /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesSourceOnly */
2287     r = add_component_entry( hdb, "'mu', '{97014BAB-6C56-4013-9A63-2BF913B42519}', 'TARGETDIR', 1, '', 'mu_file'" );
2288     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2289
2290     /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesOptional */
2291     r = add_component_entry( hdb, "'nu', '{943DD0D8-5808-4954-8526-3B8493FEDDCD}', 'TARGETDIR', 2, '', 'nu_file'" );
2292     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2293
2294     /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesSharedDllRefCount */
2295     r = add_component_entry( hdb, "'xi', '{D6CF9EF7-6FCF-4930-B34B-F938AEFF9BDB}', 'TARGETDIR', 8, '', 'xi_file'" );
2296     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2297
2298     /* msidbFeatureAttributesFavorSource:removed */
2299     r = add_feature_entry( hdb, "'seven', '', '', '', 2, 1, '', 1" );
2300     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2301
2302     /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesLocalOnly */
2303     r = add_component_entry( hdb, "'omicron', '{7B57521D-15DB-4141-9AA6-01D934A4433F}', 'TARGETDIR', 0, '', 'omicron_file'" );
2304     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2305
2306     /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesSourceOnly */
2307     r = add_component_entry( hdb, "'pi', '{FB85346B-378E-4492-8769-792305471C81}', 'TARGETDIR', 1, '', 'pi_file'" );
2308     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2309
2310     /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesOptional */
2311     r = add_component_entry( hdb, "'rho', '{798F2047-7B0C-4783-8BB0-D703E554114B}', 'TARGETDIR', 2, '', 'rho_file'" );
2312     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2313
2314     /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesSharedDllRefCount */
2315     r = add_component_entry( hdb, "'sigma', '{5CE9DDA8-B67B-4736-9D93-99D61C5B93E7}', 'TARGETDIR', 8, '', 'sigma_file'" );
2316     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2317
2318     r = create_feature_components_table( hdb );
2319     ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
2320
2321     r = add_feature_components_entry( hdb, "'one', 'alpha'" );
2322     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2323
2324     r = add_feature_components_entry( hdb, "'one', 'beta'" );
2325     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2326
2327     r = add_feature_components_entry( hdb, "'one', 'gamma'" );
2328     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2329
2330     r = add_feature_components_entry( hdb, "'one', 'theta'" );
2331     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2332
2333     r = add_feature_components_entry( hdb, "'two', 'delta'" );
2334     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2335
2336     r = add_feature_components_entry( hdb, "'two', 'epsilon'" );
2337     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2338
2339     r = add_feature_components_entry( hdb, "'two', 'zeta'" );
2340     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2341
2342     r = add_feature_components_entry( hdb, "'two', 'iota'" );
2343     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2344
2345     r = add_feature_components_entry( hdb, "'three', 'eta'" );
2346     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2347
2348     r = add_feature_components_entry( hdb, "'four', 'eta'" );
2349     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2350
2351     r = add_feature_components_entry( hdb, "'five', 'eta'" );
2352     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2353
2354     r = add_feature_components_entry( hdb, "'six', 'lambda'" );
2355     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2356
2357     r = add_feature_components_entry( hdb, "'six', 'mu'" );
2358     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2359
2360     r = add_feature_components_entry( hdb, "'six', 'nu'" );
2361     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2362
2363     r = add_feature_components_entry( hdb, "'six', 'xi'" );
2364     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2365
2366     r = add_feature_components_entry( hdb, "'seven', 'omicron'" );
2367     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2368
2369     r = add_feature_components_entry( hdb, "'seven', 'pi'" );
2370     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2371
2372     r = add_feature_components_entry( hdb, "'seven', 'rho'" );
2373     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2374
2375     r = add_feature_components_entry( hdb, "'seven', 'sigma'" );
2376     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2377
2378     r = create_file_table( hdb );
2379     ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
2380
2381     r = add_file_entry( hdb, "'alpha_file', 'alpha', 'alpha.txt', 100, '', '1033', 8192, 1" );
2382     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2383
2384     r = add_file_entry( hdb, "'beta_file', 'beta', 'beta.txt', 0, '', '1033', 8192, 1" );
2385     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2386
2387     r = add_file_entry( hdb, "'gamma_file', 'gamma', 'gamma.txt', 0, '', '1033', 8192, 1" );
2388     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2389
2390     r = add_file_entry( hdb, "'theta_file', 'theta', 'theta.txt', 0, '', '1033', 8192, 1" );
2391     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2392
2393     r = add_file_entry( hdb, "'delta_file', 'delta', 'delta.txt', 0, '', '1033', 8192, 1" );
2394     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2395
2396     r = add_file_entry( hdb, "'epsilon_file', 'epsilon', 'epsilon.txt', 0, '', '1033', 8192, 1" );
2397     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2398
2399     r = add_file_entry( hdb, "'zeta_file', 'zeta', 'zeta.txt', 0, '', '1033', 8192, 1" );
2400     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2401
2402     r = add_file_entry( hdb, "'iota_file', 'iota', 'iota.txt', 0, '', '1033', 8192, 1" );
2403     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2404
2405     /* compressed file */
2406     r = add_file_entry( hdb, "'eta_file', 'eta', 'eta.txt', 0, '', '1033', 16384, 1" );
2407     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2408
2409     r = add_file_entry( hdb, "'kappa_file', 'kappa', 'kappa.txt', 0, '', '1033', 8192, 1" );
2410     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2411
2412     r = add_file_entry( hdb, "'lambda_file', 'lambda', 'lambda.txt', 100, '', '1033', 8192, 1" );
2413     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2414
2415     r = add_file_entry( hdb, "'mu_file', 'mu', 'mu.txt', 100, '', '1033', 8192, 1" );
2416     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2417
2418     r = add_file_entry( hdb, "'nu_file', 'nu', 'nu.txt', 100, '', '1033', 8192, 1" );
2419     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2420
2421     r = add_file_entry( hdb, "'xi_file', 'xi', 'xi.txt', 100, '', '1033', 8192, 1" );
2422     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2423
2424     r = add_file_entry( hdb, "'omicron_file', 'omicron', 'omicron.txt', 100, '', '1033', 8192, 1" );
2425     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2426
2427     r = add_file_entry( hdb, "'pi_file', 'pi', 'pi.txt', 100, '', '1033', 8192, 1" );
2428     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2429
2430     r = add_file_entry( hdb, "'rho_file', 'rho', 'rho.txt', 100, '', '1033', 8192, 1" );
2431     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2432
2433     r = add_file_entry( hdb, "'sigma_file', 'sigma', 'sigma.txt', 100, '', '1033', 8192, 1" );
2434     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2435
2436     MsiDatabaseCommit(hdb);
2437
2438     /* these properties must not be in the saved msi file */
2439     r = add_property_entry( hdb, "'ADDLOCAL', 'one,four'");
2440     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2441
2442     r = add_property_entry( hdb, "'ADDSOURCE', 'two,three'");
2443     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2444
2445     r = add_property_entry( hdb, "'REMOVE', 'six,seven'");
2446     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2447
2448     hpkg = package_from_db( hdb );
2449     ok( hpkg, "failed to create package\n");
2450
2451     MsiCloseHandle(hdb);
2452
2453     state = 0xdeadbee;
2454     action = 0xdeadbee;
2455     r = MsiGetFeatureState(hpkg, "one", &state, &action);
2456     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2457     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2458     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2459
2460     state = 0xdeadbee;
2461     action = 0xdeadbee;
2462     r = MsiGetFeatureState(hpkg, "two", &state, &action);
2463     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2464     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2465     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2466
2467     state = 0xdeadbee;
2468     action = 0xdeadbee;
2469     r = MsiGetFeatureState(hpkg, "three", &state, &action);
2470     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2471     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2472     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2473
2474     state = 0xdeadbee;
2475     action = 0xdeadbee;
2476     r = MsiGetFeatureState(hpkg, "four", &state, &action);
2477     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2478     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2479     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2480
2481     state = 0xdeadbee;
2482     action = 0xdeadbee;
2483     r = MsiGetFeatureState(hpkg, "five", &state, &action);
2484     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2485     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2486     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2487
2488     state = 0xdeadbee;
2489     action = 0xdeadbee;
2490     r = MsiGetFeatureState(hpkg, "six", &state, &action);
2491     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2492     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2493     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2494
2495     state = 0xdeadbee;
2496     action = 0xdeadbee;
2497     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
2498     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2499     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2500     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2501
2502     state = 0xdeadbee;
2503     action = 0xdeadbee;
2504     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
2505     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2506     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2507     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2508
2509     state = 0xdeadbee;
2510     action = 0xdeadbee;
2511     r = MsiGetComponentState(hpkg, "beta", &state, &action);
2512     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2513     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2514     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2515
2516     state = 0xdeadbee;
2517     action = 0xdeadbee;
2518     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
2519     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2520     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2521     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2522
2523     state = 0xdeadbee;
2524     action = 0xdeadbee;
2525     r = MsiGetComponentState(hpkg, "theta", &state, &action);
2526     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2527     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2528     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2529
2530     state = 0xdeadbee;
2531     action = 0xdeadbee;
2532     r = MsiGetComponentState(hpkg, "delta", &state, &action);
2533     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2534     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2535     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2536
2537     state = 0xdeadbee;
2538     action = 0xdeadbee;
2539     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
2540     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2541     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2542     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2543
2544     state = 0xdeadbee;
2545     action = 0xdeadbee;
2546     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
2547     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2548     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2549     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2550
2551     state = 0xdeadbee;
2552     action = 0xdeadbee;
2553     r = MsiGetComponentState(hpkg, "iota", &state, &action);
2554     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2555     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2556     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2557
2558     state = 0xdeadbee;
2559     action = 0xdeadbee;
2560     r = MsiGetComponentState(hpkg, "eta", &state, &action);
2561     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2562     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2563     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2564
2565     state = 0xdeadbee;
2566     action = 0xdeadbee;
2567     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
2568     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2569     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2570     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2571
2572     state = 0xdeadbee;
2573     action = 0xdeadbee;
2574     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
2575     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2576     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2577     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2578
2579     state = 0xdeadbee;
2580     action = 0xdeadbee;
2581     r = MsiGetComponentState(hpkg, "mu", &state, &action);
2582     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2583     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2584     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2585
2586     state = 0xdeadbee;
2587     action = 0xdeadbee;
2588     r = MsiGetComponentState(hpkg, "nu", &state, &action);
2589     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2590     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2591     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2592
2593     state = 0xdeadbee;
2594     action = 0xdeadbee;
2595     r = MsiGetComponentState(hpkg, "xi", &state, &action);
2596     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2597     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2598     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2599
2600     state = 0xdeadbee;
2601     action = 0xdeadbee;
2602     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
2603     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2604     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2605     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2606
2607     state = 0xdeadbee;
2608     action = 0xdeadbee;
2609     r = MsiGetComponentState(hpkg, "pi", &state, &action);
2610     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2611     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2612     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2613
2614     state = 0xdeadbee;
2615     action = 0xdeadbee;
2616     r = MsiGetComponentState(hpkg, "rho", &state, &action);
2617     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2618     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2619     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2620
2621     state = 0xdeadbee;
2622     action = 0xdeadbee;
2623     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
2624     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2625     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2626     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2627
2628     r = MsiDoAction( hpkg, "CostInitialize");
2629     ok( r == ERROR_SUCCESS, "cost init failed\n");
2630
2631     state = 0xdeadbee;
2632     action = 0xdeadbee;
2633     r = MsiGetFeatureState(hpkg, "one", &state, &action);
2634     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2635     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2636     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2637
2638     state = 0xdeadbee;
2639     action = 0xdeadbee;
2640     r = MsiGetFeatureState(hpkg, "two", &state, &action);
2641     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2642     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2643     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2644
2645     state = 0xdeadbee;
2646     action = 0xdeadbee;
2647     r = MsiGetFeatureState(hpkg, "three", &state, &action);
2648     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2649     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2650     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2651
2652     state = 0xdeadbee;
2653     action = 0xdeadbee;
2654     r = MsiGetFeatureState(hpkg, "four", &state, &action);
2655     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2656     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2657     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2658
2659     state = 0xdeadbee;
2660     action = 0xdeadbee;
2661     r = MsiGetFeatureState(hpkg, "five", &state, &action);
2662     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2663     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2664     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2665
2666     state = 0xdeadbee;
2667     action = 0xdeadbee;
2668     r = MsiGetFeatureState(hpkg, "six", &state, &action);
2669     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2670     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2671     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2672
2673     state = 0xdeadbee;
2674     action = 0xdeadbee;
2675     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
2676     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2677     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2678     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2679
2680     state = 0xdeadbee;
2681     action = 0xdeadbee;
2682     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
2683     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2684     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2685     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2686
2687     state = 0xdeadbee;
2688     action = 0xdeadbee;
2689     r = MsiGetComponentState(hpkg, "beta", &state, &action);
2690     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2691     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2692     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2693
2694     state = 0xdeadbee;
2695     action = 0xdeadbee;
2696     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
2697     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2698     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2699     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2700
2701     state = 0xdeadbee;
2702     action = 0xdeadbee;
2703     r = MsiGetComponentState(hpkg, "theta", &state, &action);
2704     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2705     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2706     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2707
2708     state = 0xdeadbee;
2709     action = 0xdeadbee;
2710     r = MsiGetComponentState(hpkg, "delta", &state, &action);
2711     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2712     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2713     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2714
2715     state = 0xdeadbee;
2716     action = 0xdeadbee;
2717     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
2718     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2719     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2720     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2721
2722     state = 0xdeadbee;
2723     action = 0xdeadbee;
2724     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
2725     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2726     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2727     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2728
2729     state = 0xdeadbee;
2730     action = 0xdeadbee;
2731     r = MsiGetComponentState(hpkg, "iota", &state, &action);
2732     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2733     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2734     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2735
2736     state = 0xdeadbee;
2737     action = 0xdeadbee;
2738     r = MsiGetComponentState(hpkg, "eta", &state, &action);
2739     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2740     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2741     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2742
2743     state = 0xdeadbee;
2744     action = 0xdeadbee;
2745     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
2746     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2747     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2748     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2749
2750     state = 0xdeadbee;
2751     action = 0xdeadbee;
2752     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
2753     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2754     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2755     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2756
2757     state = 0xdeadbee;
2758     action = 0xdeadbee;
2759     r = MsiGetComponentState(hpkg, "mu", &state, &action);
2760     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2761     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2762     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2763
2764     state = 0xdeadbee;
2765     action = 0xdeadbee;
2766     r = MsiGetComponentState(hpkg, "nu", &state, &action);
2767     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2768     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2769     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2770
2771     state = 0xdeadbee;
2772     action = 0xdeadbee;
2773     r = MsiGetComponentState(hpkg, "xi", &state, &action);
2774     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2775     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2776     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2777
2778     state = 0xdeadbee;
2779     action = 0xdeadbee;
2780     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
2781     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2782     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2783     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2784
2785     state = 0xdeadbee;
2786     action = 0xdeadbee;
2787     r = MsiGetComponentState(hpkg, "pi", &state, &action);
2788     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2789     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2790     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2791
2792     state = 0xdeadbee;
2793     action = 0xdeadbee;
2794     r = MsiGetComponentState(hpkg, "rho", &state, &action);
2795     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2796     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2797     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2798
2799     state = 0xdeadbee;
2800     action = 0xdeadbee;
2801     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
2802     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2803     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2804     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2805
2806     r = MsiDoAction( hpkg, "FileCost");
2807     ok( r == ERROR_SUCCESS, "file cost failed\n");
2808
2809     state = 0xdeadbee;
2810     action = 0xdeadbee;
2811     r = MsiGetFeatureState(hpkg, "one", &state, &action);
2812     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2813     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2814     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2815
2816     state = 0xdeadbee;
2817     action = 0xdeadbee;
2818     r = MsiGetFeatureState(hpkg, "two", &state, &action);
2819     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2820     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2821     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2822
2823     state = 0xdeadbee;
2824     action = 0xdeadbee;
2825     r = MsiGetFeatureState(hpkg, "three", &state, &action);
2826     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2827     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2828     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2829
2830     state = 0xdeadbee;
2831     action = 0xdeadbee;
2832     r = MsiGetFeatureState(hpkg, "four", &state, &action);
2833     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2834     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2835     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2836
2837     state = 0xdeadbee;
2838     action = 0xdeadbee;
2839     r = MsiGetFeatureState(hpkg, "five", &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_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2843
2844     state = 0xdeadbee;
2845     action = 0xdeadbee;
2846     r = MsiGetFeatureState(hpkg, "six", &state, &action);
2847     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2848     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2849     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2850
2851     state = 0xdeadbee;
2852     action = 0xdeadbee;
2853     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
2854     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2855     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2856     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2857
2858     state = 0xdeadbee;
2859     action = 0xdeadbee;
2860     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
2861     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2862     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2863     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2864
2865     state = 0xdeadbee;
2866     action = 0xdeadbee;
2867     r = MsiGetComponentState(hpkg, "beta", &state, &action);
2868     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2869     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2870     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2871
2872     state = 0xdeadbee;
2873     action = 0xdeadbee;
2874     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
2875     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2876     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2877     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2878
2879     state = 0xdeadbee;
2880     action = 0xdeadbee;
2881     r = MsiGetComponentState(hpkg, "theta", &state, &action);
2882     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2883     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2884     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2885
2886     state = 0xdeadbee;
2887     action = 0xdeadbee;
2888     r = MsiGetComponentState(hpkg, "delta", &state, &action);
2889     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2890     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2891     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2892
2893     state = 0xdeadbee;
2894     action = 0xdeadbee;
2895     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
2896     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2897     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2898     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2899
2900     state = 0xdeadbee;
2901     action = 0xdeadbee;
2902     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
2903     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2904     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2905     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2906
2907     state = 0xdeadbee;
2908     action = 0xdeadbee;
2909     r = MsiGetComponentState(hpkg, "iota", &state, &action);
2910     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2911     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2912     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2913
2914     state = 0xdeadbee;
2915     action = 0xdeadbee;
2916     r = MsiGetComponentState(hpkg, "eta", &state, &action);
2917     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2918     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2919     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2920
2921     state = 0xdeadbee;
2922     action = 0xdeadbee;
2923     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
2924     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2925     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2926     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2927
2928     state = 0xdeadbee;
2929     action = 0xdeadbee;
2930     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
2931     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2932     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2933     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2934
2935     state = 0xdeadbee;
2936     action = 0xdeadbee;
2937     r = MsiGetComponentState(hpkg, "mu", &state, &action);
2938     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2939     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2940     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2941
2942     state = 0xdeadbee;
2943     action = 0xdeadbee;
2944     r = MsiGetComponentState(hpkg, "nu", &state, &action);
2945     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2946     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2947     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2948
2949     state = 0xdeadbee;
2950     action = 0xdeadbee;
2951     r = MsiGetComponentState(hpkg, "xi", &state, &action);
2952     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2953     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2954     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2955
2956     state = 0xdeadbee;
2957     action = 0xdeadbee;
2958     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
2959     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2960     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2961     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2962
2963     state = 0xdeadbee;
2964     action = 0xdeadbee;
2965     r = MsiGetComponentState(hpkg, "pi", &state, &action);
2966     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2967     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2968     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2969
2970     state = 0xdeadbee;
2971     action = 0xdeadbee;
2972     r = MsiGetComponentState(hpkg, "rho", &state, &action);
2973     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2974     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2975     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2976
2977     state = 0xdeadbee;
2978     action = 0xdeadbee;
2979     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
2980     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2981     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2982     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2983
2984     r = MsiDoAction( hpkg, "CostFinalize");
2985     ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
2986
2987     state = 0xdeadbee;
2988     action = 0xdeadbee;
2989     r = MsiGetFeatureState(hpkg, "one", &state, &action);
2990     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2991     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2992     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
2993
2994     state = 0xdeadbee;
2995     action = 0xdeadbee;
2996     r = MsiGetFeatureState(hpkg, "two", &state, &action);
2997     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2998     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2999     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
3000
3001     state = 0xdeadbee;
3002     action = 0xdeadbee;
3003     r = MsiGetFeatureState(hpkg, "three", &state, &action);
3004     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3005     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3006     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3007
3008     state = 0xdeadbee;
3009     action = 0xdeadbee;
3010     r = MsiGetFeatureState(hpkg, "four", &state, &action);
3011     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3012     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3013     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3014
3015     state = 0xdeadbee;
3016     action = 0xdeadbee;
3017     r = MsiGetFeatureState(hpkg, "five", &state, &action);
3018     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3019     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3020     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3021
3022     state = 0xdeadbee;
3023     action = 0xdeadbee;
3024     r = MsiGetFeatureState(hpkg, "six", &state, &action);
3025     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3026     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3027     todo_wine
3028     {
3029         ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3030     }
3031
3032     state = 0xdeadbee;
3033     action = 0xdeadbee;
3034     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
3035     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3036     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3037     todo_wine
3038     {
3039         ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3040     }
3041
3042     state = 0xdeadbee;
3043     action = 0xdeadbee;
3044     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
3045     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3046     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3047     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3048
3049     state = 0xdeadbee;
3050     action = 0xdeadbee;
3051     r = MsiGetComponentState(hpkg, "beta", &state, &action);
3052     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3053     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3054     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
3055
3056     state = 0xdeadbee;
3057     action = 0xdeadbee;
3058     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
3059     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3060     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3061     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3062
3063     state = 0xdeadbee;
3064     action = 0xdeadbee;
3065     r = MsiGetComponentState(hpkg, "theta", &state, &action);
3066     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3067     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3068     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3069
3070     state = 0xdeadbee;
3071     action = 0xdeadbee;
3072     r = MsiGetComponentState(hpkg, "delta", &state, &action);
3073     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3074     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3075     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3076
3077     state = 0xdeadbee;
3078     action = 0xdeadbee;
3079     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
3080     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3081     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3082     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
3083
3084     state = 0xdeadbee;
3085     action = 0xdeadbee;
3086     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
3087     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3088     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3089     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
3090
3091     state = 0xdeadbee;
3092     action = 0xdeadbee;
3093     r = MsiGetComponentState(hpkg, "iota", &state, &action);
3094     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3095     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3096     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3097
3098     state = 0xdeadbee;
3099     action = 0xdeadbee;
3100     r = MsiGetComponentState(hpkg, "eta", &state, &action);
3101     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3102     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3103     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3104
3105     state = 0xdeadbee;
3106     action = 0xdeadbee;
3107     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
3108     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3109     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3110     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3111
3112     state = 0xdeadbee;
3113     action = 0xdeadbee;
3114     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
3115     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3116     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3117     todo_wine
3118     {
3119         ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3120     }
3121
3122     state = 0xdeadbee;
3123     action = 0xdeadbee;
3124     r = MsiGetComponentState(hpkg, "mu", &state, &action);
3125     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3126     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3127     todo_wine
3128     {
3129         ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3130     }
3131
3132     state = 0xdeadbee;
3133     action = 0xdeadbee;
3134     r = MsiGetComponentState(hpkg, "nu", &state, &action);
3135     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3136     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3137     todo_wine
3138     {
3139         ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3140     }
3141
3142     state = 0xdeadbee;
3143     action = 0xdeadbee;
3144     r = MsiGetComponentState(hpkg, "xi", &state, &action);
3145     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3146     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3147     todo_wine
3148     {
3149         ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3150     }
3151
3152     state = 0xdeadbee;
3153     action = 0xdeadbee;
3154     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
3155     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3156     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3157     todo_wine
3158     {
3159         ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3160     }
3161
3162     state = 0xdeadbee;
3163     action = 0xdeadbee;
3164     r = MsiGetComponentState(hpkg, "pi", &state, &action);
3165     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3166     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3167     todo_wine
3168     {
3169         ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3170     }
3171
3172     state = 0xdeadbee;
3173     action = 0xdeadbee;
3174     r = MsiGetComponentState(hpkg, "rho", &state, &action);
3175     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3176     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3177     todo_wine
3178     {
3179         ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3180     }
3181
3182     state = 0xdeadbee;
3183     action = 0xdeadbee;
3184     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
3185     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3186     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3187     todo_wine
3188     {
3189         ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3190     }
3191
3192     MsiCloseHandle( hpkg );
3193
3194     /* publish the features and components */
3195     r = MsiInstallProduct(msifile, "ADDLOCAL=one,four ADDSOURCE=two,three REMOVE=six,seven");
3196     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3197
3198     r = MsiOpenDatabase(msifile, MSIDBOPEN_DIRECT, &hdb);
3199     ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
3200
3201     /* these properties must not be in the saved msi file */
3202     r = add_property_entry( hdb, "'ADDLOCAL', 'one,four'");
3203     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3204
3205     r = add_property_entry( hdb, "'ADDSOURCE', 'two,three'");
3206     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3207
3208     r = add_property_entry( hdb, "'REMOVE', 'six,seven'");
3209     ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3210
3211     hpkg = package_from_db( hdb );
3212     ok( hpkg, "failed to create package\n");
3213
3214     MsiCloseHandle(hdb);
3215
3216     state = 0xdeadbee;
3217     action = 0xdeadbee;
3218     r = MsiGetFeatureState(hpkg, "one", &state, &action);
3219     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3220     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3221     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3222
3223     state = 0xdeadbee;
3224     action = 0xdeadbee;
3225     r = MsiGetFeatureState(hpkg, "two", &state, &action);
3226     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3227     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3228     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3229
3230     state = 0xdeadbee;
3231     action = 0xdeadbee;
3232     r = MsiGetFeatureState(hpkg, "three", &state, &action);
3233     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3234     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3235     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3236
3237     state = 0xdeadbee;
3238     action = 0xdeadbee;
3239     r = MsiGetFeatureState(hpkg, "four", &state, &action);
3240     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3241     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3242     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3243
3244     state = 0xdeadbee;
3245     action = 0xdeadbee;
3246     r = MsiGetFeatureState(hpkg, "five", &state, &action);
3247     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3248     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3249     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3250
3251     state = 0xdeadbee;
3252     action = 0xdeadbee;
3253     r = MsiGetFeatureState(hpkg, "six", &state, &action);
3254     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3255     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3256     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3257
3258     state = 0xdeadbee;
3259     action = 0xdeadbee;
3260     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
3261     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
3262     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3263     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3264
3265     state = 0xdeadbee;
3266     action = 0xdeadbee;
3267     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
3268     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3269     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3270     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3271
3272     state = 0xdeadbee;
3273     action = 0xdeadbee;
3274     r = MsiGetComponentState(hpkg, "beta", &state, &action);
3275     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3276     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3277     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3278
3279     state = 0xdeadbee;
3280     action = 0xdeadbee;
3281     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
3282     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3283     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3284     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3285
3286     state = 0xdeadbee;
3287     action = 0xdeadbee;
3288     r = MsiGetComponentState(hpkg, "theta", &state, &action);
3289     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3290     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3291     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3292
3293     state = 0xdeadbee;
3294     action = 0xdeadbee;
3295     r = MsiGetComponentState(hpkg, "delta", &state, &action);
3296     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3297     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3298     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3299
3300     state = 0xdeadbee;
3301     action = 0xdeadbee;
3302     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
3303     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3304     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3305     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3306
3307     state = 0xdeadbee;
3308     action = 0xdeadbee;
3309     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
3310     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3311     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3312     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3313
3314     state = 0xdeadbee;
3315     action = 0xdeadbee;
3316     r = MsiGetComponentState(hpkg, "iota", &state, &action);
3317     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3318     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3319     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3320
3321     state = 0xdeadbee;
3322     action = 0xdeadbee;
3323     r = MsiGetComponentState(hpkg, "eta", &state, &action);
3324     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3325     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3326     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3327
3328     state = 0xdeadbee;
3329     action = 0xdeadbee;
3330     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
3331     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3332     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3333     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3334
3335     state = 0xdeadbee;
3336     action = 0xdeadbee;
3337     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
3338     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3339     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3340     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3341
3342     state = 0xdeadbee;
3343     action = 0xdeadbee;
3344     r = MsiGetComponentState(hpkg, "mu", &state, &action);
3345     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3346     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3347     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3348
3349     state = 0xdeadbee;
3350     action = 0xdeadbee;
3351     r = MsiGetComponentState(hpkg, "nu", &state, &action);
3352     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3353     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3354     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3355
3356     state = 0xdeadbee;
3357     action = 0xdeadbee;
3358     r = MsiGetComponentState(hpkg, "xi", &state, &action);
3359     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3360     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3361     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3362
3363     state = 0xdeadbee;
3364     action = 0xdeadbee;
3365     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
3366     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3367     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3368     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3369
3370     state = 0xdeadbee;
3371     action = 0xdeadbee;
3372     r = MsiGetComponentState(hpkg, "pi", &state, &action);
3373     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3374     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3375     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3376
3377     state = 0xdeadbee;
3378     action = 0xdeadbee;
3379     r = MsiGetComponentState(hpkg, "rho", &state, &action);
3380     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3381     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3382     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3383
3384     state = 0xdeadbee;
3385     action = 0xdeadbee;
3386     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
3387     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
3388     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
3389     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
3390
3391     r = MsiDoAction( hpkg, "CostInitialize");
3392     ok( r == ERROR_SUCCESS, "cost init failed\n");
3393
3394     state = 0xdeadbee;
3395     action = 0xdeadbee;
3396     r = MsiGetFeatureState(hpkg, "one", &state, &action);
3397     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3398     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3399     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3400
3401     state = 0xdeadbee;
3402     action = 0xdeadbee;
3403     r = MsiGetFeatureState(hpkg, "two", &state, &action);
3404     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3405     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3406     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3407
3408     state = 0xdeadbee;
3409     action = 0xdeadbee;
3410     r = MsiGetFeatureState(hpkg, "three", &state, &action);
3411     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3412     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3413     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3414
3415     state = 0xdeadbee;
3416     action = 0xdeadbee;
3417     r = MsiGetFeatureState(hpkg, "four", &state, &action);
3418     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3419     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3420     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3421
3422     state = 0xdeadbee;
3423     action = 0xdeadbee;
3424     r = MsiGetFeatureState(hpkg, "five", &state, &action);
3425     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3426     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3427     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3428
3429     state = 0xdeadbee;
3430     action = 0xdeadbee;
3431     r = MsiGetFeatureState(hpkg, "six", &state, &action);
3432     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3433     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3434     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3435
3436     state = 0xdeadbee;
3437     action = 0xdeadbee;
3438     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
3439     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3440     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3441     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3442
3443     state = 0xdeadbee;
3444     action = 0xdeadbee;
3445     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
3446     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3447     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3448     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3449
3450     state = 0xdeadbee;
3451     action = 0xdeadbee;
3452     r = MsiGetComponentState(hpkg, "beta", &state, &action);
3453     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3454     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3455     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3456
3457     state = 0xdeadbee;
3458     action = 0xdeadbee;
3459     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
3460     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3461     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3462     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3463
3464     state = 0xdeadbee;
3465     action = 0xdeadbee;
3466     r = MsiGetComponentState(hpkg, "theta", &state, &action);
3467     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3468     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3469     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3470
3471     state = 0xdeadbee;
3472     action = 0xdeadbee;
3473     r = MsiGetComponentState(hpkg, "delta", &state, &action);
3474     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3475     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3476     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3477
3478     state = 0xdeadbee;
3479     action = 0xdeadbee;
3480     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
3481     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3482     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3483     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3484
3485     state = 0xdeadbee;
3486     action = 0xdeadbee;
3487     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
3488     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3489     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3490     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3491
3492     state = 0xdeadbee;
3493     action = 0xdeadbee;
3494     r = MsiGetComponentState(hpkg, "iota", &state, &action);
3495     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3496     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3497     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3498
3499     state = 0xdeadbee;
3500     action = 0xdeadbee;
3501     r = MsiGetComponentState(hpkg, "eta", &state, &action);
3502     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3503     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3504     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3505
3506     state = 0xdeadbee;
3507     action = 0xdeadbee;
3508     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
3509     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3510     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3511     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3512
3513     state = 0xdeadbee;
3514     action = 0xdeadbee;
3515     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
3516     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3517     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3518     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3519
3520     state = 0xdeadbee;
3521     action = 0xdeadbee;
3522     r = MsiGetComponentState(hpkg, "mu", &state, &action);
3523     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3524     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3525     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3526
3527     state = 0xdeadbee;
3528     action = 0xdeadbee;
3529     r = MsiGetComponentState(hpkg, "nu", &state, &action);
3530     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3531     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3532     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3533
3534     state = 0xdeadbee;
3535     action = 0xdeadbee;
3536     r = MsiGetComponentState(hpkg, "xi", &state, &action);
3537     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3538     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3539     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3540
3541     state = 0xdeadbee;
3542     action = 0xdeadbee;
3543     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
3544     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3545     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3546     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3547
3548     state = 0xdeadbee;
3549     action = 0xdeadbee;
3550     r = MsiGetComponentState(hpkg, "pi", &state, &action);
3551     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3552     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3553     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3554
3555     state = 0xdeadbee;
3556     action = 0xdeadbee;
3557     r = MsiGetComponentState(hpkg, "rho", &state, &action);
3558     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3559     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3560     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3561
3562     state = 0xdeadbee;
3563     action = 0xdeadbee;
3564     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
3565     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3566     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3567     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3568
3569     r = MsiDoAction( hpkg, "FileCost");
3570     ok( r == ERROR_SUCCESS, "file cost failed\n");
3571
3572     state = 0xdeadbee;
3573     action = 0xdeadbee;
3574     r = MsiGetFeatureState(hpkg, "one", &state, &action);
3575     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3576     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3577     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3578
3579     state = 0xdeadbee;
3580     action = 0xdeadbee;
3581     r = MsiGetFeatureState(hpkg, "two", &state, &action);
3582     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3583     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3584     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3585
3586     state = 0xdeadbee;
3587     action = 0xdeadbee;
3588     r = MsiGetFeatureState(hpkg, "three", &state, &action);
3589     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3590     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3591     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3592
3593     state = 0xdeadbee;
3594     action = 0xdeadbee;
3595     r = MsiGetFeatureState(hpkg, "four", &state, &action);
3596     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3597     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3598     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3599
3600     state = 0xdeadbee;
3601     action = 0xdeadbee;
3602     r = MsiGetFeatureState(hpkg, "five", &state, &action);
3603     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3604     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3605     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3606
3607     state = 0xdeadbee;
3608     action = 0xdeadbee;
3609     r = MsiGetFeatureState(hpkg, "six", &state, &action);
3610     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3611     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3612     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3613
3614     state = 0xdeadbee;
3615     action = 0xdeadbee;
3616     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
3617     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3618     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3619     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3620
3621     state = 0xdeadbee;
3622     action = 0xdeadbee;
3623     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
3624     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3625     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3626     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3627
3628     state = 0xdeadbee;
3629     action = 0xdeadbee;
3630     r = MsiGetComponentState(hpkg, "beta", &state, &action);
3631     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3632     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3633     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3634
3635     state = 0xdeadbee;
3636     action = 0xdeadbee;
3637     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
3638     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3639     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3640     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3641
3642     state = 0xdeadbee;
3643     action = 0xdeadbee;
3644     r = MsiGetComponentState(hpkg, "theta", &state, &action);
3645     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3646     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3647     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3648
3649     state = 0xdeadbee;
3650     action = 0xdeadbee;
3651     r = MsiGetComponentState(hpkg, "delta", &state, &action);
3652     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3653     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3654     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3655
3656     state = 0xdeadbee;
3657     action = 0xdeadbee;
3658     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
3659     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3660     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3661     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3662
3663     state = 0xdeadbee;
3664     action = 0xdeadbee;
3665     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
3666     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3667     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3668     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3669
3670     state = 0xdeadbee;
3671     action = 0xdeadbee;
3672     r = MsiGetComponentState(hpkg, "iota", &state, &action);
3673     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3674     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3675     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3676
3677     state = 0xdeadbee;
3678     action = 0xdeadbee;
3679     r = MsiGetComponentState(hpkg, "eta", &state, &action);
3680     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3681     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3682     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3683
3684     state = 0xdeadbee;
3685     action = 0xdeadbee;
3686     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
3687     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3688     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3689     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3690
3691     state = 0xdeadbee;
3692     action = 0xdeadbee;
3693     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
3694     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3695     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3696     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3697
3698     state = 0xdeadbee;
3699     action = 0xdeadbee;
3700     r = MsiGetComponentState(hpkg, "mu", &state, &action);
3701     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3702     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3703     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3704
3705     state = 0xdeadbee;
3706     action = 0xdeadbee;
3707     r = MsiGetComponentState(hpkg, "nu", &state, &action);
3708     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3709     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3710     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3711
3712     state = 0xdeadbee;
3713     action = 0xdeadbee;
3714     r = MsiGetComponentState(hpkg, "xi", &state, &action);
3715     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3716     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3717     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3718
3719     state = 0xdeadbee;
3720     action = 0xdeadbee;
3721     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
3722     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3723     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3724     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3725
3726     state = 0xdeadbee;
3727     action = 0xdeadbee;
3728     r = MsiGetComponentState(hpkg, "pi", &state, &action);
3729     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3730     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3731     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3732
3733     state = 0xdeadbee;
3734     action = 0xdeadbee;
3735     r = MsiGetComponentState(hpkg, "rho", &state, &action);
3736     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3737     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3738     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3739
3740     state = 0xdeadbee;
3741     action = 0xdeadbee;
3742     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
3743     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3744     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3745     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3746
3747     r = MsiDoAction( hpkg, "CostFinalize");
3748     ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
3749
3750     state = 0xdeadbee;
3751     action = 0xdeadbee;
3752     r = MsiGetFeatureState(hpkg, "one", &state, &action);
3753     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3754     todo_wine
3755     {
3756         ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
3757     }
3758     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3759
3760     state = 0xdeadbee;
3761     action = 0xdeadbee;
3762     r = MsiGetFeatureState(hpkg, "two", &state, &action);
3763     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3764     todo_wine
3765     {
3766         ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
3767     }
3768     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
3769
3770     state = 0xdeadbee;
3771     action = 0xdeadbee;
3772     r = MsiGetFeatureState(hpkg, "three", &state, &action);
3773     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3774     todo_wine
3775     {
3776         ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
3777     }
3778     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3779
3780     state = 0xdeadbee;
3781     action = 0xdeadbee;
3782     r = MsiGetFeatureState(hpkg, "four", &state, &action);
3783     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3784     todo_wine
3785     {
3786         ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
3787     }
3788     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3789
3790     state = 0xdeadbee;
3791     action = 0xdeadbee;
3792     r = MsiGetFeatureState(hpkg, "five", &state, &action);
3793     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3794     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3795     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3796
3797     state = 0xdeadbee;
3798     action = 0xdeadbee;
3799     r = MsiGetFeatureState(hpkg, "six", &state, &action);
3800     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3801     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3802     todo_wine
3803     {
3804         ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3805     }
3806
3807     state = 0xdeadbee;
3808     action = 0xdeadbee;
3809     r = MsiGetFeatureState(hpkg, "seven", &state, &action);
3810     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3811     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3812     todo_wine
3813     {
3814         ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3815     }
3816
3817     state = 0xdeadbee;
3818     action = 0xdeadbee;
3819     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
3820     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3821     todo_wine
3822     {
3823         ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
3824     }
3825     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3826
3827     state = 0xdeadbee;
3828     action = 0xdeadbee;
3829     r = MsiGetComponentState(hpkg, "beta", &state, &action);
3830     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3831     todo_wine
3832     {
3833         ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
3834     }
3835     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
3836
3837     state = 0xdeadbee;
3838     action = 0xdeadbee;
3839     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
3840     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3841     todo_wine
3842     {
3843         ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
3844     }
3845     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3846
3847     state = 0xdeadbee;
3848     action = 0xdeadbee;
3849     r = MsiGetComponentState(hpkg, "theta", &state, &action);
3850     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3851     todo_wine
3852     {
3853         ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
3854     }
3855     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3856
3857     state = 0xdeadbee;
3858     action = 0xdeadbee;
3859     r = MsiGetComponentState(hpkg, "delta", &state, &action);
3860     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3861     todo_wine
3862     {
3863         ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
3864     }
3865     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3866
3867     state = 0xdeadbee;
3868     action = 0xdeadbee;
3869     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
3870     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3871     todo_wine
3872     {
3873         ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
3874         ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3875     }
3876
3877     state = 0xdeadbee;
3878     action = 0xdeadbee;
3879     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
3880     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3881     todo_wine
3882     {
3883         ok( state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
3884         ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3885     }
3886
3887     state = 0xdeadbee;
3888     action = 0xdeadbee;
3889     r = MsiGetComponentState(hpkg, "iota", &state, &action);
3890     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3891     todo_wine
3892     {
3893         ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
3894     }
3895     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3896
3897     state = 0xdeadbee;
3898     action = 0xdeadbee;
3899     r = MsiGetComponentState(hpkg, "eta", &state, &action);
3900     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3901     todo_wine
3902     {
3903         ok( state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
3904     }
3905     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3906
3907     state = 0xdeadbee;
3908     action = 0xdeadbee;
3909     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
3910     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3911     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3912     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3913
3914     state = 0xdeadbee;
3915     action = 0xdeadbee;
3916     r = MsiGetComponentState(hpkg, "lambda", &state, &action);
3917     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3918     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3919     todo_wine
3920     {
3921         ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3922     }
3923
3924     state = 0xdeadbee;
3925     action = 0xdeadbee;
3926     r = MsiGetComponentState(hpkg, "mu", &state, &action);
3927     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3928     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3929     todo_wine
3930     {
3931         ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3932     }
3933
3934     state = 0xdeadbee;
3935     action = 0xdeadbee;
3936     r = MsiGetComponentState(hpkg, "nu", &state, &action);
3937     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3938     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3939     todo_wine
3940     {
3941         ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3942     }
3943
3944     state = 0xdeadbee;
3945     action = 0xdeadbee;
3946     r = MsiGetComponentState(hpkg, "xi", &state, &action);
3947     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3948     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3949     todo_wine
3950     {
3951         ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3952     }
3953
3954     state = 0xdeadbee;
3955     action = 0xdeadbee;
3956     r = MsiGetComponentState(hpkg, "omicron", &state, &action);
3957     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3958     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3959     todo_wine
3960     {
3961         ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3962     }
3963
3964     state = 0xdeadbee;
3965     action = 0xdeadbee;
3966     r = MsiGetComponentState(hpkg, "pi", &state, &action);
3967     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3968     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3969     todo_wine
3970     {
3971         ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3972     }
3973
3974     state = 0xdeadbee;
3975     action = 0xdeadbee;
3976     r = MsiGetComponentState(hpkg, "rho", &state, &action);
3977     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3978     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3979     todo_wine
3980     {
3981         ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3982     }
3983
3984     state = 0xdeadbee;
3985     action = 0xdeadbee;
3986     r = MsiGetComponentState(hpkg, "sigma", &state, &action);
3987     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3988     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3989     todo_wine
3990     {
3991         ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3992     }
3993
3994     MsiCloseHandle(hpkg);
3995
3996     /* uninstall the product */
3997     r = MsiInstallProduct(msifile, "REMOVE=ALL");
3998     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3999
4000     DeleteFileA(msifile);
4001 }
4002
4003 static void test_getproperty(void)
4004 {
4005     MSIHANDLE hPackage = 0;
4006     char prop[100];
4007     static CHAR empty[] = "";
4008     DWORD size;
4009     UINT r;
4010
4011     hPackage = package_from_db(create_package_db());
4012     ok( hPackage != 0, " Failed to create package\n");
4013
4014     /* set the property */
4015     r = MsiSetProperty(hPackage, "Name", "Value");
4016     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4017
4018     /* retrieve the size, NULL pointer */
4019     size = 0;
4020     r = MsiGetProperty(hPackage, "Name", NULL, &size);
4021     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4022     ok( size == 5, "Expected 5, got %d\n", size);
4023
4024     /* retrieve the size, empty string */
4025     size = 0;
4026     r = MsiGetProperty(hPackage, "Name", empty, &size);
4027     ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
4028     ok( size == 5, "Expected 5, got %d\n", size);
4029
4030     /* don't change size */
4031     r = MsiGetProperty(hPackage, "Name", prop, &size);
4032     ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
4033     ok( size == 5, "Expected 5, got %d\n", size);
4034     ok( !lstrcmp(prop, "Valu"), "Expected Valu, got %s\n", prop);
4035
4036     /* increase the size by 1 */
4037     size++;
4038     r = MsiGetProperty(hPackage, "Name", prop, &size);
4039     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4040     ok( size == 5, "Expected 5, got %d\n", size);
4041     ok( !lstrcmp(prop, "Value"), "Expected Value, got %s\n", prop);
4042
4043     r = MsiCloseHandle( hPackage);
4044     ok( r == ERROR_SUCCESS , "Failed to close package\n" );
4045     DeleteFile(msifile);
4046 }
4047
4048 static void test_removefiles(void)
4049 {
4050     MSIHANDLE hpkg;
4051     UINT r;
4052     MSIHANDLE hdb;
4053
4054     hdb = create_package_db();
4055     ok ( hdb, "failed to create package database\n" );
4056
4057     r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
4058     ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
4059
4060     r = create_feature_table( hdb );
4061     ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
4062
4063     r = create_component_table( hdb );
4064     ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
4065
4066     r = add_feature_entry( hdb, "'one', '', '', '', 2, 1, '', 0" );
4067     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
4068
4069     r = add_component_entry( hdb, "'hydrogen', '', 'TARGETDIR', 0, '', 'hydrogen_file'" );
4070     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
4071
4072     r = add_component_entry( hdb, "'helium', '', 'TARGETDIR', 0, '', 'helium_file'" );
4073     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
4074
4075     r = add_component_entry( hdb, "'lithium', '', 'TARGETDIR', 0, '', 'lithium_file'" );
4076     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
4077
4078     r = add_component_entry( hdb, "'beryllium', '', 'TARGETDIR', 0, '', 'beryllium_file'" );
4079     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
4080
4081     r = add_component_entry( hdb, "'boron', '', 'TARGETDIR', 0, '', 'boron_file'" );
4082     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
4083
4084     r = add_component_entry( hdb, "'carbon', '', 'TARGETDIR', 0, '', 'carbon_file'" );
4085     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
4086
4087     r = create_feature_components_table( hdb );
4088     ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
4089
4090     r = add_feature_components_entry( hdb, "'one', 'hydrogen'" );
4091     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
4092
4093     r = add_feature_components_entry( hdb, "'one', 'helium'" );
4094     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
4095
4096     r = add_feature_components_entry( hdb, "'one', 'lithium'" );
4097     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
4098
4099     r = add_feature_components_entry( hdb, "'one', 'beryllium'" );
4100     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
4101
4102     r = add_feature_components_entry( hdb, "'one', 'boron'" );
4103     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
4104
4105     r = add_feature_components_entry( hdb, "'one', 'carbon'" );
4106     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
4107
4108     r = create_file_table( hdb );
4109     ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
4110
4111     r = add_file_entry( hdb, "'hydrogen_file', 'hydrogen', 'hydrogen.txt', 0, '', '1033', 8192, 1" );
4112     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
4113
4114     r = add_file_entry( hdb, "'helium_file', 'helium', 'helium.txt', 0, '', '1033', 8192, 1" );
4115     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
4116
4117     r = add_file_entry( hdb, "'lithium_file', 'lithium', 'lithium.txt', 0, '', '1033', 8192, 1" );
4118     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
4119
4120     r = add_file_entry( hdb, "'beryllium_file', 'beryllium', 'beryllium.txt', 0, '', '1033', 16384, 1" );
4121     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
4122
4123     r = add_file_entry( hdb, "'boron_file', 'boron', 'boron.txt', 0, '', '1033', 16384, 1" );
4124     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
4125
4126     r = add_file_entry( hdb, "'carbon_file', 'carbon', 'carbon.txt', 0, '', '1033', 16384, 1" );
4127     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
4128
4129     r = create_remove_file_table( hdb );
4130     ok( r == ERROR_SUCCESS, "cannot create Remove File table: %d\n", r);
4131
4132     hpkg = package_from_db( hdb );
4133     ok( hpkg, "failed to create package\n");
4134
4135     MsiCloseHandle( hdb );
4136
4137     create_test_file( "hydrogen.txt" );
4138     create_test_file( "helium.txt" );
4139     create_test_file( "lithium.txt" );
4140     create_test_file( "beryllium.txt" );
4141     create_test_file( "boron.txt" );
4142     create_test_file( "carbon.txt" );
4143
4144     r = MsiSetProperty( hpkg, "TARGETDIR", CURR_DIR );
4145     ok( r == ERROR_SUCCESS, "set property failed\n");
4146
4147     r = MsiDoAction( hpkg, "CostInitialize");
4148     ok( r == ERROR_SUCCESS, "cost init failed\n");
4149
4150     r = MsiDoAction( hpkg, "FileCost");
4151     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
4152
4153     r = MsiDoAction( hpkg, "CostFinalize");
4154     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
4155
4156     r = MsiDoAction( hpkg, "InstallValidate");
4157     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
4158
4159     r = MsiSetComponentState( hpkg, "hydrogen", INSTALLSTATE_ABSENT );
4160     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
4161
4162     r = MsiSetComponentState( hpkg, "helium", INSTALLSTATE_LOCAL );
4163     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
4164
4165     r = MsiSetComponentState( hpkg, "lithium", INSTALLSTATE_SOURCE );
4166     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
4167
4168     r = MsiSetComponentState( hpkg, "beryllium", INSTALLSTATE_ABSENT );
4169     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
4170
4171     r = MsiSetComponentState( hpkg, "boron", INSTALLSTATE_LOCAL );
4172     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
4173
4174     r = MsiSetComponentState( hpkg, "carbon", INSTALLSTATE_SOURCE );
4175     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
4176
4177     r = MsiDoAction( hpkg, "RemoveFiles");
4178     ok( r == ERROR_SUCCESS, "remove files failed\n");
4179
4180     ok(DeleteFileA("hydrogen.txt"), "Expected hydrogen.txt to exist\n");
4181     ok(DeleteFileA("lithium.txt"), "Expected lithium.txt to exist\n");    
4182     ok(DeleteFileA("beryllium.txt"), "Expected beryllium.txt to exist\n");
4183     ok(DeleteFileA("carbon.txt"), "Expected carbon.txt to exist\n");
4184     ok(DeleteFileA("helium.txt"), "Expected helium.txt to exist\n");
4185     ok(DeleteFileA("boron.txt"), "Expected boron.txt to exist\n");
4186
4187     MsiCloseHandle( hpkg );
4188     DeleteFileA(msifile);
4189 }
4190
4191 static void test_appsearch(void)
4192 {
4193     MSIHANDLE hpkg;
4194     UINT r;
4195     MSIHANDLE hdb;
4196     CHAR prop[MAX_PATH];
4197     DWORD size = MAX_PATH;
4198
4199     hdb = create_package_db();
4200     ok ( hdb, "failed to create package database\n" );
4201
4202     r = create_appsearch_table( hdb );
4203     ok( r == ERROR_SUCCESS, "cannot create AppSearch table: %d\n", r );
4204
4205     r = add_appsearch_entry( hdb, "'WEBBROWSERPROG', 'NewSignature1'" );
4206     ok( r == ERROR_SUCCESS, "cannot add entry: %d\n", r );
4207
4208     r = create_reglocator_table( hdb );
4209     ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
4210
4211     r = add_reglocator_entry( hdb, "'NewSignature1', 0, 'htmlfile\\shell\\open\\command', '', 1" );
4212     ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
4213
4214     r = create_signature_table( hdb );
4215     ok( r == ERROR_SUCCESS, "cannot create Signature table: %d\n", r );
4216
4217     r = add_signature_entry( hdb, "'NewSignature1', 'FileName', '', '', '', '', '', '', ''" );
4218     ok( r == ERROR_SUCCESS, "cannot create Signature table: %d\n", r );
4219
4220     hpkg = package_from_db( hdb );
4221     ok( hpkg, "failed to create package\n");
4222
4223     MsiCloseHandle( hdb );
4224
4225     r = MsiDoAction( hpkg, "AppSearch" );
4226     ok( r == ERROR_SUCCESS, "AppSearch failed: %d\n", r);
4227
4228     r = MsiGetPropertyA( hpkg, "WEBBROWSERPROG", prop, &size );
4229     ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
4230     ok( lstrlenA(prop) != 0, "Expected non-zero length\n");
4231
4232     MsiCloseHandle( hpkg );
4233     DeleteFileA(msifile);
4234 }
4235
4236 static void test_featureparents(void)
4237 {
4238     MSIHANDLE hpkg;
4239     UINT r;
4240     MSIHANDLE hdb;
4241     INSTALLSTATE state, action;
4242
4243     hdb = create_package_db();
4244     ok ( hdb, "failed to create package database\n" );
4245
4246     r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
4247     ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
4248
4249     r = create_feature_table( hdb );
4250     ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
4251
4252     r = create_component_table( hdb );
4253     ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
4254
4255     r = create_feature_components_table( hdb );
4256     ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
4257
4258     r = create_file_table( hdb );
4259     ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
4260
4261     /* msidbFeatureAttributesFavorLocal */
4262     r = add_feature_entry( hdb, "'zodiac', '', '', '', 2, 1, '', 0" );
4263     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
4264
4265     /* msidbFeatureAttributesFavorSource */
4266     r = add_feature_entry( hdb, "'perseus', '', '', '', 2, 1, '', 1" );
4267     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
4268
4269     /* msidbFeatureAttributesFavorLocal */
4270     r = add_feature_entry( hdb, "'orion', '', '', '', 2, 1, '', 0" );
4271     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
4272
4273     /* disabled because of install level */
4274     r = add_feature_entry( hdb, "'waters', '', '', '', 15, 101, '', 9" );
4275     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
4276
4277     /* child feature of disabled feature */
4278     r = add_feature_entry( hdb, "'bayer', 'waters', '', '', 14, 1, '', 9" );
4279     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
4280
4281     /* component of disabled feature (install level) */
4282     r = add_component_entry( hdb, "'delphinus', '', 'TARGETDIR', 0, '', 'delphinus_file'" );
4283     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
4284
4285     /* component of disabled child feature (install level) */
4286     r = add_component_entry( hdb, "'hydrus', '', 'TARGETDIR', 0, '', 'hydrus_file'" );
4287     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
4288
4289     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
4290     r = add_component_entry( hdb, "'leo', '', 'TARGETDIR', 0, '', 'leo_file'" );
4291     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
4292
4293     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
4294     r = add_component_entry( hdb, "'virgo', '', 'TARGETDIR', 1, '', 'virgo_file'" );
4295     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
4296
4297     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
4298     r = add_component_entry( hdb, "'libra', '', 'TARGETDIR', 2, '', 'libra_file'" );
4299     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
4300
4301     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
4302     r = add_component_entry( hdb, "'cassiopeia', '', 'TARGETDIR', 0, '', 'cassiopeia_file'" );
4303     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
4304
4305     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
4306     r = add_component_entry( hdb, "'cepheus', '', 'TARGETDIR', 1, '', 'cepheus_file'" );
4307     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
4308
4309     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
4310     r = add_component_entry( hdb, "'andromeda', '', 'TARGETDIR', 2, '', 'andromeda_file'" );
4311     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
4312
4313     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
4314     r = add_component_entry( hdb, "'canis', '', 'TARGETDIR', 0, '', 'canis_file'" );
4315     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
4316
4317     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
4318     r = add_component_entry( hdb, "'monoceros', '', 'TARGETDIR', 1, '', 'monoceros_file'" );
4319     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
4320
4321     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
4322     r = add_component_entry( hdb, "'lepus', '', 'TARGETDIR', 2, '', 'lepus_file'" );
4323
4324     r = add_feature_components_entry( hdb, "'zodiac', 'leo'" );
4325     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
4326
4327     r = add_feature_components_entry( hdb, "'zodiac', 'virgo'" );
4328     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
4329
4330     r = add_feature_components_entry( hdb, "'zodiac', 'libra'" );
4331     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
4332
4333     r = add_feature_components_entry( hdb, "'perseus', 'cassiopeia'" );
4334     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
4335
4336     r = add_feature_components_entry( hdb, "'perseus', 'cepheus'" );
4337     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
4338
4339     r = add_feature_components_entry( hdb, "'perseus', 'andromeda'" );
4340     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
4341
4342     r = add_feature_components_entry( hdb, "'orion', 'leo'" );
4343     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
4344
4345     r = add_feature_components_entry( hdb, "'orion', 'virgo'" );
4346     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
4347
4348     r = add_feature_components_entry( hdb, "'orion', 'libra'" );
4349     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
4350
4351     r = add_feature_components_entry( hdb, "'orion', 'cassiopeia'" );
4352     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
4353
4354     r = add_feature_components_entry( hdb, "'orion', 'cepheus'" );
4355     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
4356
4357     r = add_feature_components_entry( hdb, "'orion', 'andromeda'" );
4358     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
4359
4360     r = add_feature_components_entry( hdb, "'orion', 'canis'" );
4361     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
4362
4363     r = add_feature_components_entry( hdb, "'orion', 'monoceros'" );
4364     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
4365
4366     r = add_feature_components_entry( hdb, "'orion', 'lepus'" );
4367     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
4368
4369     r = add_feature_components_entry( hdb, "'waters', 'delphinus'" );
4370     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
4371
4372     r = add_feature_components_entry( hdb, "'bayer', 'hydrus'" );
4373     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
4374
4375     r = add_file_entry( hdb, "'leo_file', 'leo', 'leo.txt', 100, '', '1033', 8192, 1" );
4376     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
4377
4378     r = add_file_entry( hdb, "'virgo_file', 'virgo', 'virgo.txt', 0, '', '1033', 8192, 1" );
4379     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
4380
4381     r = add_file_entry( hdb, "'libra_file', 'libra', 'libra.txt', 0, '', '1033', 8192, 1" );
4382     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
4383
4384     r = add_file_entry( hdb, "'cassiopeia_file', 'cassiopeia', 'cassiopeia.txt', 0, '', '1033', 8192, 1" );
4385     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
4386
4387     r = add_file_entry( hdb, "'cepheus_file', 'cepheus', 'cepheus.txt', 0, '', '1033', 8192, 1" );
4388     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
4389
4390     r = add_file_entry( hdb, "'andromeda_file', 'andromeda', 'andromeda.txt', 0, '', '1033', 8192, 1" );
4391     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
4392
4393     r = add_file_entry( hdb, "'canis_file', 'canis', 'canis.txt', 0, '', '1033', 8192, 1" );
4394     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
4395
4396     r = add_file_entry( hdb, "'monoceros_file', 'monoceros', 'monoceros.txt', 0, '', '1033', 8192, 1" );
4397     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
4398
4399     r = add_file_entry( hdb, "'lepus_file', 'lepus', 'lepus.txt', 0, '', '1033', 8192, 1" );
4400     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
4401
4402     r = add_file_entry( hdb, "'delphinus_file', 'delphinus', 'delphinus.txt', 0, '', '1033', 8192, 1" );
4403     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
4404
4405     r = add_file_entry( hdb, "'hydrus_file', 'hydrus', 'hydrus.txt', 0, '', '1033', 8192, 1" );
4406     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
4407
4408     hpkg = package_from_db( hdb );
4409     ok( hpkg, "failed to create package\n");
4410
4411     MsiCloseHandle( hdb );
4412
4413     r = MsiDoAction( hpkg, "CostInitialize");
4414     ok( r == ERROR_SUCCESS, "cost init failed\n");
4415
4416     r = MsiDoAction( hpkg, "FileCost");
4417     ok( r == ERROR_SUCCESS, "file cost failed\n");
4418
4419     r = MsiDoAction( hpkg, "CostFinalize");
4420     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
4421
4422     state = 0xdeadbee;
4423     action = 0xdeadbee;
4424     r = MsiGetFeatureState(hpkg, "zodiac", &state, &action);
4425     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4426     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4427     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4428
4429     state = 0xdeadbee;
4430     action = 0xdeadbee;
4431     r = MsiGetFeatureState(hpkg, "perseus", &state, &action);
4432     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4433     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4434     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
4435
4436     state = 0xdeadbee;
4437     action = 0xdeadbee;
4438     r = MsiGetFeatureState(hpkg, "orion", &state, &action);
4439     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4440     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4441     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4442
4443     state = 0xdeadbee;
4444     action = 0xdeadbee;
4445     r = MsiGetFeatureState(hpkg, "waters", &state, &action);
4446     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4447     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4448     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4449
4450     state = 0xdeadbee;
4451     action = 0xdeadbee;
4452     r = MsiGetFeatureState(hpkg, "bayer", &state, &action);
4453     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4454     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
4455     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
4456
4457     state = 0xdeadbee;
4458     action = 0xdeadbee;
4459     r = MsiGetComponentState(hpkg, "leo", &state, &action);
4460     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4461     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
4462     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
4463
4464     state = 0xdeadbee;
4465     action = 0xdeadbee;
4466     r = MsiGetComponentState(hpkg, "virgo", &state, &action);
4467     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4468     ok( state == INSTALLSTATE_UNKNOWN, "Expected virgo INSTALLSTATE_UNKNOWN, got %d\n", state);
4469     ok( action == INSTALLSTATE_SOURCE, "Expected virgo INSTALLSTATE_SOURCE, got %d\n", action);
4470
4471     state = 0xdeadbee;
4472     action = 0xdeadbee;
4473     r = MsiGetComponentState(hpkg, "libra", &state, &action);
4474     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4475     ok( state == INSTALLSTATE_UNKNOWN, "Expected libra INSTALLSTATE_UNKNOWN, got %d\n", state);
4476     ok( action == INSTALLSTATE_LOCAL, "Expected libra INSTALLSTATE_LOCAL, got %d\n", action);
4477
4478     state = 0xdeadbee;
4479     action = 0xdeadbee;
4480     r = MsiGetComponentState(hpkg, "cassiopeia", &state, &action);
4481     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4482     ok( state == INSTALLSTATE_UNKNOWN, "Expected cassiopeia INSTALLSTATE_UNKNOWN, got %d\n", state);
4483     ok( action == INSTALLSTATE_LOCAL, "Expected cassiopeia INSTALLSTATE_LOCAL, got %d\n", action);
4484
4485     state = 0xdeadbee;
4486     action = 0xdeadbee;
4487     r = MsiGetComponentState(hpkg, "cepheus", &state, &action);
4488     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4489     ok( state == INSTALLSTATE_UNKNOWN, "Expected cepheus INSTALLSTATE_UNKNOWN, got %d\n", state);
4490     ok( action == INSTALLSTATE_SOURCE, "Expected cepheus INSTALLSTATE_SOURCE, got %d\n", action);
4491
4492     state = 0xdeadbee;
4493     action = 0xdeadbee;
4494     r = MsiGetComponentState(hpkg, "andromeda", &state, &action);
4495     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4496     ok( state == INSTALLSTATE_UNKNOWN, "Expected andromeda INSTALLSTATE_UNKNOWN, got %d\n", state);
4497     ok( action == INSTALLSTATE_LOCAL, "Expected andromeda INSTALLSTATE_LOCAL, got %d\n", action);
4498
4499     state = 0xdeadbee;
4500     action = 0xdeadbee;
4501     r = MsiGetComponentState(hpkg, "canis", &state, &action);
4502     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4503     ok( state == INSTALLSTATE_UNKNOWN, "Expected canis INSTALLSTATE_UNKNOWN, got %d\n", state);
4504     ok( action == INSTALLSTATE_LOCAL, "Expected canis INSTALLSTATE_LOCAL, got %d\n", action);
4505
4506     state = 0xdeadbee;
4507     action = 0xdeadbee;
4508     r = MsiGetComponentState(hpkg, "monoceros", &state, &action);
4509     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4510     ok( state == INSTALLSTATE_UNKNOWN, "Expected monoceros INSTALLSTATE_UNKNOWN, got %d\n", state);
4511     ok( action == INSTALLSTATE_SOURCE, "Expected monoceros INSTALLSTATE_SOURCE, got %d\n", action);
4512
4513     state = 0xdeadbee;
4514     action = 0xdeadbee;
4515     r = MsiGetComponentState(hpkg, "lepus", &state, &action);
4516     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4517     ok( state == INSTALLSTATE_UNKNOWN, "Expected lepus INSTALLSTATE_UNKNOWN, got %d\n", state);
4518     ok( action == INSTALLSTATE_LOCAL, "Expected lepus INSTALLSTATE_LOCAL, got %d\n", action);
4519
4520     state = 0xdeadbee;
4521     action = 0xdeadbee;
4522     r = MsiGetComponentState(hpkg, "delphinus", &state, &action);
4523     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4524     ok( state == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", state);
4525     ok( action == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", action);
4526
4527     state = 0xdeadbee;
4528     action = 0xdeadbee;
4529     r = MsiGetComponentState(hpkg, "hydrus", &state, &action);
4530     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4531     ok( state == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", state);
4532     ok( action == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", action);
4533
4534     r = MsiSetFeatureState(hpkg, "orion", INSTALLSTATE_ABSENT);
4535     ok( r == ERROR_SUCCESS, "failed to set feature state: %d\n", r);
4536
4537     state = 0xdeadbee;
4538     action = 0xdeadbee;
4539     r = MsiGetFeatureState(hpkg, "zodiac", &state, &action);
4540     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4541     ok( state == INSTALLSTATE_ABSENT, "Expected zodiac INSTALLSTATE_ABSENT, got %d\n", state);
4542     ok( action == INSTALLSTATE_LOCAL, "Expected zodiac INSTALLSTATE_LOCAL, got %d\n", action);
4543
4544     state = 0xdeadbee;
4545     action = 0xdeadbee;
4546     r = MsiGetFeatureState(hpkg, "perseus", &state, &action);
4547     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4548     ok( state == INSTALLSTATE_ABSENT, "Expected perseus INSTALLSTATE_ABSENT, got %d\n", state);
4549     ok( action == INSTALLSTATE_SOURCE, "Expected perseus INSTALLSTATE_SOURCE, got %d\n", action);
4550
4551     state = 0xdeadbee;
4552     action = 0xdeadbee;
4553     r = MsiGetFeatureState(hpkg, "orion", &state, &action);
4554     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4555     ok( state == INSTALLSTATE_ABSENT, "Expected orion INSTALLSTATE_ABSENT, got %d\n", state);
4556     ok( action == INSTALLSTATE_ABSENT, "Expected orion INSTALLSTATE_ABSENT, got %d\n", action);
4557
4558     state = 0xdeadbee;
4559     action = 0xdeadbee;
4560     r = MsiGetComponentState(hpkg, "leo", &state, &action);
4561     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4562     ok( state == INSTALLSTATE_UNKNOWN, "Expected leo INSTALLSTATE_UNKNOWN, got %d\n", state);
4563     ok( action == INSTALLSTATE_LOCAL, "Expected leo INSTALLSTATE_LOCAL, got %d\n", action);
4564
4565     state = 0xdeadbee;
4566     action = 0xdeadbee;
4567     r = MsiGetComponentState(hpkg, "virgo", &state, &action);
4568     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4569     ok( state == INSTALLSTATE_UNKNOWN, "Expected virgo INSTALLSTATE_UNKNOWN, got %d\n", state);
4570     ok( action == INSTALLSTATE_SOURCE, "Expected virgo INSTALLSTATE_SOURCE, got %d\n", action);
4571
4572     state = 0xdeadbee;
4573     action = 0xdeadbee;
4574     r = MsiGetComponentState(hpkg, "libra", &state, &action);
4575     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4576     ok( state == INSTALLSTATE_UNKNOWN, "Expected libra INSTALLSTATE_UNKNOWN, got %d\n", state);
4577     ok( action == INSTALLSTATE_LOCAL, "Expected libra INSTALLSTATE_LOCAL, got %d\n", action);
4578
4579     state = 0xdeadbee;
4580     action = 0xdeadbee;
4581     r = MsiGetComponentState(hpkg, "cassiopeia", &state, &action);
4582     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4583     ok( state == INSTALLSTATE_UNKNOWN, "Expected cassiopeia INSTALLSTATE_UNKNOWN, got %d\n", state);
4584     ok( action == INSTALLSTATE_LOCAL, "Expected cassiopeia INSTALLSTATE_LOCAL, got %d\n", action);
4585
4586     state = 0xdeadbee;
4587     action = 0xdeadbee;
4588     r = MsiGetComponentState(hpkg, "cepheus", &state, &action);
4589     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4590     ok( state == INSTALLSTATE_UNKNOWN, "Expected cepheus INSTALLSTATE_UNKNOWN, got %d\n", state);
4591     ok( action == INSTALLSTATE_SOURCE, "Expected cepheus INSTALLSTATE_SOURCE, got %d\n", action);
4592
4593     state = 0xdeadbee;
4594     action = 0xdeadbee;
4595     r = MsiGetComponentState(hpkg, "andromeda", &state, &action);
4596     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4597     ok( state == INSTALLSTATE_UNKNOWN, "Expected andromeda INSTALLSTATE_UNKNOWN, got %d\n", state);
4598     ok( action == INSTALLSTATE_SOURCE, "Expected andromeda INSTALLSTATE_SOURCE, got %d\n", action);
4599
4600     state = 0xdeadbee;
4601     action = 0xdeadbee;
4602     r = MsiGetComponentState(hpkg, "canis", &state, &action);
4603     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4604     ok( state == INSTALLSTATE_UNKNOWN, "Expected canis INSTALLSTATE_UNKNOWN, got %d\n", state);
4605     ok( action == INSTALLSTATE_UNKNOWN, "Expected canis INSTALLSTATE_UNKNOWN, got %d\n", action);
4606
4607     state = 0xdeadbee;
4608     action = 0xdeadbee;
4609     r = MsiGetComponentState(hpkg, "monoceros", &state, &action);
4610     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4611     ok( state == INSTALLSTATE_UNKNOWN, "Expected monoceros INSTALLSTATE_UNKNOWN, got %d\n", state);
4612     ok( action == INSTALLSTATE_UNKNOWN, "Expected monoceros INSTALLSTATE_UNKNOWN, got %d\n", action);
4613
4614     state = 0xdeadbee;
4615     action = 0xdeadbee;
4616     r = MsiGetComponentState(hpkg, "lepus", &state, &action);
4617     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4618     ok( state == INSTALLSTATE_UNKNOWN, "Expected lepus INSTALLSTATE_UNKNOWN, got %d\n", state);
4619     ok( action == INSTALLSTATE_UNKNOWN, "Expected lepus INSTALLSTATE_UNKNOWN, got %d\n", action);
4620
4621     state = 0xdeadbee;
4622     action = 0xdeadbee;
4623     r = MsiGetComponentState(hpkg, "delphinus", &state, &action);
4624     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4625     ok( state == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", state);
4626     ok( action == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", action);
4627
4628     state = 0xdeadbee;
4629     action = 0xdeadbee;
4630     r = MsiGetComponentState(hpkg, "hydrus", &state, &action);
4631     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
4632     ok( state == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", state);
4633     ok( action == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", action);
4634     
4635     MsiCloseHandle(hpkg);
4636     DeleteFileA(msifile);
4637 }
4638
4639 static void test_installprops(void)
4640 {
4641     MSIHANDLE hpkg, hdb;
4642     CHAR path[MAX_PATH];
4643     CHAR buf[MAX_PATH];
4644     DWORD size, type;
4645     LANGID langid;
4646     HKEY hkey1, hkey2;
4647     int res;
4648     UINT r;
4649
4650     GetCurrentDirectory(MAX_PATH, path);
4651     lstrcat(path, "\\");
4652     lstrcat(path, msifile);
4653
4654     hdb = create_package_db();
4655     ok( hdb, "failed to create database\n");
4656
4657     hpkg = package_from_db(hdb);
4658     ok( hpkg, "failed to create package\n");
4659
4660     MsiCloseHandle(hdb);
4661
4662     size = MAX_PATH;
4663     r = MsiGetProperty(hpkg, "DATABASE", buf, &size);
4664     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
4665     ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
4666
4667     RegOpenKey(HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\MS Setup (ACME)\\User Info", &hkey1);
4668
4669     RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", &hkey2);
4670
4671     size = MAX_PATH;
4672     type = REG_SZ;
4673     *path = '\0';
4674     if (RegQueryValueEx(hkey1, "DefName", NULL, &type, (LPBYTE)path, &size) != ERROR_SUCCESS)
4675     {
4676         size = MAX_PATH;
4677         type = REG_SZ;
4678         RegQueryValueEx(hkey2, "RegisteredOwner", NULL, &type, (LPBYTE)path, &size);
4679     }
4680
4681     /* win9x doesn't set this */
4682     if (*path)
4683     {
4684         size = MAX_PATH;
4685         r = MsiGetProperty(hpkg, "USERNAME", buf, &size);
4686         ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
4687         ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
4688     }
4689
4690     size = MAX_PATH;
4691     type = REG_SZ;
4692     *path = '\0';
4693     if (RegQueryValueEx(hkey1, "DefCompany", NULL, &type, (LPBYTE)path, &size) != ERROR_SUCCESS)
4694     {
4695         size = MAX_PATH;
4696         type = REG_SZ;
4697         RegQueryValueEx(hkey2, "RegisteredOrganization", NULL, &type, (LPBYTE)path, &size);
4698     }
4699
4700     if (*path)
4701     {
4702         size = MAX_PATH;
4703         r = MsiGetProperty(hpkg, "COMPANYNAME", buf, &size);
4704         ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
4705         ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
4706     }
4707
4708     size = MAX_PATH;
4709     r = MsiGetProperty(hpkg, "VersionDatabase", buf, &size);
4710     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
4711     trace("VersionDatabase = %s\n", buf);
4712
4713     size = MAX_PATH;
4714     r = MsiGetProperty(hpkg, "VersionMsi", buf, &size);
4715     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
4716     trace("VersionMsi = %s\n", buf);
4717
4718     size = MAX_PATH;
4719     r = MsiGetProperty(hpkg, "Date", buf, &size);
4720     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
4721     trace("Date = %s\n", buf);
4722
4723     size = MAX_PATH;
4724     r = MsiGetProperty(hpkg, "Time", buf, &size);
4725     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
4726     trace("Time = %s\n", buf);
4727
4728     size = MAX_PATH;
4729     r = MsiGetProperty(hpkg, "PackageCode", buf, &size);
4730     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
4731     trace("PackageCode = %s\n", buf);
4732
4733     langid = GetUserDefaultLangID();
4734     sprintf(path, "%d", langid);
4735
4736     size = MAX_PATH;
4737     r = MsiGetProperty(hpkg, "UserLanguageID", buf, &size);
4738     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS< got %d\n", r);
4739     ok( !lstrcmpA(buf, path), "Expected \"%s\", got \"%s\"\n", path, buf);
4740
4741     res = GetSystemMetrics(SM_CXSCREEN);
4742     size = MAX_PATH;
4743     r = MsiGetProperty(hpkg, "ScreenX", buf, &size);
4744     ok(atol(buf) == res, "Expected %d, got %ld\n", res, atol(buf));
4745
4746     res = GetSystemMetrics(SM_CYSCREEN);
4747     size = MAX_PATH;
4748     r = MsiGetProperty(hpkg, "ScreenY", buf, &size);
4749     ok(atol(buf) == res, "Expected %d, got %ld\n", res, atol(buf));
4750
4751     CloseHandle(hkey1);
4752     CloseHandle(hkey2);
4753     MsiCloseHandle(hpkg);
4754     DeleteFile(msifile);
4755 }
4756
4757 static void test_sourcedirprop(void)
4758 {
4759     MSIHANDLE hpkg, hdb;
4760     CHAR source_dir[MAX_PATH];
4761     CHAR path[MAX_PATH];
4762     DWORD size;
4763     UINT r;
4764
4765     hdb = create_package_db();
4766     ok ( hdb, "failed to create package database\n" );
4767
4768     r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
4769     ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
4770
4771     hpkg = package_from_db( hdb );
4772     ok( hpkg, "failed to create package\n");
4773
4774     MsiCloseHandle( hdb );
4775
4776     size = MAX_PATH;
4777     r = MsiGetProperty( hpkg, "SourceDir", source_dir, &size );
4778     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
4779     ok( !lstrlenA(source_dir), "Expected emtpy source dir, got %s\n", source_dir);
4780
4781     size = MAX_PATH;
4782     r = MsiGetProperty( hpkg, "SOURCEDIR", source_dir, &size );
4783     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
4784     ok( !lstrlenA(source_dir), "Expected emtpy source dir, got %s\n", source_dir);
4785
4786     r = MsiDoAction( hpkg, "CostInitialize");
4787     ok( r == ERROR_SUCCESS, "cost init failed\n");
4788
4789     size = MAX_PATH;
4790     r = MsiGetProperty( hpkg, "SourceDir", source_dir, &size );
4791     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
4792     ok( !lstrlenA(source_dir), "Expected emtpy source dir, got %s\n", source_dir);
4793
4794     size = MAX_PATH;
4795     r = MsiGetProperty( hpkg, "SOURCEDIR", source_dir, &size );
4796     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
4797     ok( !lstrlenA(source_dir), "Expected emtpy source dir, got %s\n", source_dir);
4798
4799     r = MsiDoAction( hpkg, "ResolveSource");
4800     ok( r == ERROR_SUCCESS, "file cost failed\n");
4801
4802     GetCurrentDirectory(MAX_PATH, path);
4803     lstrcatA(path, "\\");
4804
4805     size = MAX_PATH;
4806     r = MsiGetProperty( hpkg, "SourceDir", source_dir, &size );
4807     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
4808     ok( !lstrcmpA(source_dir, path), "Expected %s, got %s\n", path, source_dir);
4809
4810     size = MAX_PATH;
4811     r = MsiGetProperty( hpkg, "SOURCEDIR", source_dir, &size );
4812     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
4813     ok( !lstrcmpA(source_dir, path), "Expected %s, got %s\n", path, source_dir);
4814
4815     size = MAX_PATH;
4816     r = MsiGetProperty( hpkg, "SoUrCeDiR", source_dir, &size );
4817     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
4818     ok( !lstrlenA(source_dir), "Expected emtpy source dir, got %s\n", source_dir);
4819
4820     MsiCloseHandle(hpkg);
4821     DeleteFileA(msifile);
4822 }
4823
4824 static void test_prop_path(void)
4825 {
4826     MSIHANDLE hpkg, hdb;
4827     char buffer[MAX_PATH], cwd[MAX_PATH];
4828     DWORD sz;
4829     UINT r;
4830
4831     GetCurrentDirectory(MAX_PATH, cwd);
4832     strcat(cwd, "\\");
4833
4834     hdb = create_package_db();
4835     ok( hdb, "failed to create database\n");
4836
4837     r = add_directory_entry( hdb, "'TARGETDIR','','SourceDir'" );
4838     ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
4839
4840     r = add_directory_entry( hdb, "'foo','TARGETDIR','foosrc:footgt'" );
4841     ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
4842
4843     hpkg = package_from_db(hdb);
4844     ok( hpkg, "failed to create package\n");
4845
4846     r = MsiGetSourcePath(hpkg, "SourceDir", buffer, &sz );
4847     ok( r == ERROR_DIRECTORY, "failed to get source path\n");
4848
4849     r = MsiGetSourcePath(hpkg, "SOURCEDIR", buffer, &sz );
4850     ok( r == ERROR_DIRECTORY, "failed to get source path\n");
4851
4852     r = MsiDoAction( hpkg, "CostInitialize");
4853     ok( r == ERROR_SUCCESS, "cost init failed\n");
4854
4855     sz = sizeof buffer;
4856     buffer[0] = 0;
4857     r = MsiGetProperty(hpkg, "SourceDir", buffer, &sz);
4858     ok( r == ERROR_SUCCESS, "property not set\n");
4859     ok( !buffer[0], "SourceDir should be empty\n");
4860
4861     sz = sizeof buffer;
4862     buffer[0] = 0;
4863     r = MsiGetProperty(hpkg, "SOURCEDIR", buffer, &sz);
4864     ok( r == ERROR_SUCCESS, "property not set\n");
4865     ok( !buffer[0], "SourceDir should be empty\n");
4866
4867     sz = sizeof buffer;
4868     buffer[0] = 0;
4869     r = MsiGetSourcePath(hpkg, "SourceDir", buffer, &sz );
4870     ok( r == ERROR_SUCCESS, "failed to get source path\n");
4871     ok( !lstrcmpi(cwd, buffer), "SourceDir (%s) should be current dir (%s)\n", buffer, cwd);
4872
4873     sz = sizeof buffer;
4874     buffer[0] = 0;
4875     r = MsiGetProperty(hpkg, "SourceDir", buffer, &sz);
4876     ok( r == ERROR_SUCCESS, "property not set\n");
4877     todo_wine {
4878     ok( !lstrcmpi(cwd, buffer), "SourceDir (%s) should be current dir (%s)\n", buffer, cwd);
4879     }
4880
4881     sz = sizeof buffer;
4882     buffer[0] = 0;
4883     r = MsiGetSourcePath(hpkg, "SOURCEDIR", buffer, &sz );
4884     ok( r == ERROR_DIRECTORY, "failed to get source path\n");
4885
4886     sz = sizeof buffer;
4887     buffer[0] = 0;
4888     r = MsiGetProperty(hpkg, "SOURCEDIR", buffer, &sz);
4889     ok( r == ERROR_SUCCESS, "property not set\n");
4890     todo_wine {
4891     ok( !lstrcmpi(cwd, buffer), "SourceDir (%s) should be current dir (%s)\n", buffer, cwd);
4892     }
4893
4894     r = MsiSetProperty(hpkg, "SourceDir", "goo");
4895     ok( r == ERROR_SUCCESS, "property not set\n");
4896
4897     sz = sizeof buffer;
4898     buffer[0] = 0;
4899     r = MsiGetProperty(hpkg, "SourceDir", buffer, &sz);
4900     ok( r == ERROR_SUCCESS, "property not set\n");
4901     ok( !lstrcmpi(buffer, "goo"), "SourceDir (%s) should be goo\n", buffer);
4902
4903     sz = sizeof buffer;
4904     buffer[0] = 0;
4905     r = MsiGetSourcePath(hpkg, "SourceDir", buffer, &sz );
4906     ok( r == ERROR_SUCCESS, "failed to get source path\n");
4907     ok( !lstrcmpi(buffer, cwd), "SourceDir (%s) should be goo\n", buffer);
4908
4909     sz = sizeof buffer;
4910     buffer[0] = 0;
4911     r = MsiGetProperty(hpkg, "SourceDir", buffer, &sz);
4912     ok( r == ERROR_SUCCESS, "property not set\n");
4913     ok( !lstrcmpi(buffer, "goo"), "SourceDir (%s) should be goo\n", buffer);
4914
4915     MsiCloseHandle( hpkg );
4916     DeleteFile(msifile);
4917 }
4918
4919 static void test_launchconditions(void)
4920 {
4921     MSIHANDLE hpkg;
4922     MSIHANDLE hdb;
4923     UINT r;
4924
4925     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
4926
4927     hdb = create_package_db();
4928     ok( hdb, "failed to create package database\n" );
4929
4930     r = create_launchcondition_table( hdb );
4931     ok( r == ERROR_SUCCESS, "cannot create LaunchCondition table: %d\n", r );
4932
4933     r = add_launchcondition_entry( hdb, "'X = \"1\"', 'one'" );
4934     ok( r == ERROR_SUCCESS, "cannot add launch condition: %d\n", r );
4935
4936     /* invalid condition */
4937     r = add_launchcondition_entry( hdb, "'X != \"1\"', 'one'" );
4938     ok( r == ERROR_SUCCESS, "cannot add launch condition: %d\n", r );
4939
4940     hpkg = package_from_db( hdb );
4941     ok( hpkg, "failed to create package\n");
4942
4943     MsiCloseHandle( hdb );
4944
4945     r = MsiSetProperty( hpkg, "X", "1" );
4946     ok( r == ERROR_SUCCESS, "failed to set property\n" );
4947
4948     /* invalid conditions are ignored */
4949     r = MsiDoAction( hpkg, "LaunchConditions" );
4950     ok( r == ERROR_SUCCESS, "cost init failed\n" );
4951
4952     /* verify LaunchConditions still does some verification */
4953     r = MsiSetProperty( hpkg, "X", "2" );
4954     ok( r == ERROR_SUCCESS, "failed to set property\n" );
4955
4956     r = MsiDoAction( hpkg, "LaunchConditions" );
4957     ok( r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %d\n", r );
4958
4959     MsiCloseHandle( hpkg );
4960     DeleteFile( msifile );
4961 }
4962
4963 static void test_ccpsearch(void)
4964 {
4965     MSIHANDLE hdb, hpkg;
4966     CHAR prop[MAX_PATH];
4967     DWORD size = MAX_PATH;
4968     UINT r;
4969
4970     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
4971
4972     hdb = create_package_db();
4973     ok(hdb, "failed to create package database\n");
4974
4975     r = create_ccpsearch_table(hdb);
4976     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4977
4978     r = add_ccpsearch_entry(hdb, "'CCP_random'");
4979     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4980
4981     r = add_ccpsearch_entry(hdb, "'RMCCP_random'");
4982     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4983
4984     r = create_reglocator_table(hdb);
4985     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4986
4987     r = add_reglocator_entry(hdb, "'CCP_random', 0, 'htmlfile\\shell\\open\\nonexistent', '', 1");
4988     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4989
4990     r = create_drlocator_table(hdb);
4991     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4992
4993     r = add_drlocator_entry(hdb, "'RMCCP_random', '', 'C:\\', '0'");
4994     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4995
4996     r = create_signature_table(hdb);
4997     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4998
4999     hpkg = package_from_db(hdb);
5000     ok(hpkg, "failed to create package\n");
5001
5002     MsiCloseHandle(hdb);
5003
5004     r = MsiDoAction(hpkg, "CCPSearch");
5005     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5006
5007     r = MsiGetPropertyA(hpkg, "CCP_Success", prop, &size);
5008     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5009     ok(!lstrcmpA(prop, "1"), "Expected 1, got %s\n", prop);
5010
5011     MsiCloseHandle(hpkg);
5012     DeleteFileA(msifile);
5013 }
5014
5015 static BOOL squash_guid(LPCWSTR in, LPWSTR out)
5016 {
5017     DWORD i,n=1;
5018     GUID guid;
5019
5020     if (FAILED(CLSIDFromString((LPOLESTR)in, &guid)))
5021         return FALSE;
5022
5023     for(i=0; i<8; i++)
5024         out[7-i] = in[n++];
5025     n++;
5026     for(i=0; i<4; i++)
5027         out[11-i] = in[n++];
5028     n++;
5029     for(i=0; i<4; i++)
5030         out[15-i] = in[n++];
5031     n++;
5032     for(i=0; i<2; i++)
5033     {
5034         out[17+i*2] = in[n++];
5035         out[16+i*2] = in[n++];
5036     }
5037     n++;
5038     for( ; i<8; i++)
5039     {
5040         out[17+i*2] = in[n++];
5041         out[16+i*2] = in[n++];
5042     }
5043     out[32]=0;
5044     return TRUE;
5045 }
5046
5047 static void set_component_path(LPCSTR filename, LPCSTR guid)
5048 {
5049     WCHAR guidW[MAX_PATH];
5050     WCHAR squashedW[MAX_PATH];
5051     CHAR squashed[MAX_PATH];
5052     CHAR substr[MAX_PATH];
5053     CHAR path[MAX_PATH];
5054     HKEY hkey;
5055
5056     MultiByteToWideChar(CP_ACP, 0, guid, -1, guidW, MAX_PATH);
5057     squash_guid(guidW, squashedW);
5058     WideCharToMultiByte(CP_ACP, 0, squashedW, -1, squashed, MAX_PATH, NULL, NULL);
5059
5060     lstrcpyA(substr, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
5061                     "Installer\\UserData\\S-1-5-18\\Components\\");
5062     lstrcatA(substr, squashed);
5063
5064     RegCreateKeyA(HKEY_LOCAL_MACHINE, substr, &hkey);
5065
5066     lstrcpyA(path, CURR_DIR);
5067     lstrcatA(path, "\\");
5068     lstrcatA(path, filename);
5069
5070     /* just using a random squashed product code */
5071     RegSetValueExA(hkey, "7D2F387510109040002000060BECB6AB", 0,
5072                    REG_SZ, (LPBYTE)path, lstrlenA(path));
5073
5074     RegCloseKey(hkey);
5075
5076     lstrcpyA(substr, "SOFTWARE\\Classes\\Installer\\Products\\7D2F387510109040002000060BECB6AB");
5077     RegCreateKeyA(HKEY_LOCAL_MACHINE, substr, &hkey);
5078 }
5079
5080 static void delete_component_path(LPCSTR guid)
5081 {
5082     WCHAR guidW[MAX_PATH];
5083     WCHAR squashedW[MAX_PATH];
5084     WCHAR substrW[MAX_PATH];
5085     CHAR squashed[MAX_PATH];
5086     CHAR substr[MAX_PATH];
5087
5088     MultiByteToWideChar(CP_ACP, 0, guid, -1, guidW, MAX_PATH);
5089     squash_guid(guidW, squashedW);
5090     WideCharToMultiByte(CP_ACP, 0, squashedW, -1, squashed, MAX_PATH, NULL, NULL);
5091
5092     lstrcpyA(substr, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
5093                     "Installer\\UserData\\S-1-5-18\\Components\\");
5094     lstrcatA(substr, squashed);
5095
5096     MultiByteToWideChar(CP_ACP, 0, substr, -1, substrW, MAX_PATH);
5097     package_RegDeleteTreeW(HKEY_LOCAL_MACHINE, substrW);
5098
5099     lstrcpyA(substr, "SOFTWARE\\Classes\\Installer\\Products\\7D2F387510109040002000060BECB6AB");
5100     MultiByteToWideChar(CP_ACP, 0, substr, -1, substrW, MAX_PATH);
5101     package_RegDeleteTreeW(HKEY_LOCAL_MACHINE, substrW);
5102 }
5103
5104 static void test_complocator(void)
5105 {
5106     MSIHANDLE hdb, hpkg;
5107     UINT r;
5108     CHAR prop[MAX_PATH];
5109     CHAR expected[MAX_PATH];
5110     DWORD size = MAX_PATH;
5111
5112     hdb = create_package_db();
5113     ok(hdb, "failed to create package database\n");
5114
5115     r = create_appsearch_table(hdb);
5116     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5117
5118     r = add_appsearch_entry(hdb, "'ABELISAURUS', 'abelisaurus'");
5119     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5120
5121     r = add_appsearch_entry(hdb, "'BACTROSAURUS', 'bactrosaurus'");
5122     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5123
5124     r = add_appsearch_entry(hdb, "'CAMELOTIA', 'camelotia'");
5125     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5126
5127     r = add_appsearch_entry(hdb, "'DICLONIUS', 'diclonius'");
5128     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5129
5130     r = add_appsearch_entry(hdb, "'ECHINODON', 'echinodon'");
5131     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5132
5133     r = add_appsearch_entry(hdb, "'FALCARIUS', 'falcarius'");
5134     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5135
5136     r = add_appsearch_entry(hdb, "'GALLIMIMUS', 'gallimimus'");
5137     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5138
5139     r = add_appsearch_entry(hdb, "'HAGRYPHUS', 'hagryphus'");
5140     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5141
5142     r = add_appsearch_entry(hdb, "'IGUANODON', 'iguanodon'");
5143     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5144
5145     r = add_appsearch_entry(hdb, "'JOBARIA', 'jobaria'");
5146     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5147
5148     r = add_appsearch_entry(hdb, "'KAKURU', 'kakuru'");
5149     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5150
5151     r = add_appsearch_entry(hdb, "'LABOCANIA', 'labocania'");
5152     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5153
5154     r = add_appsearch_entry(hdb, "'MEGARAPTOR', 'megaraptor'");
5155     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5156
5157     r = add_appsearch_entry(hdb, "'NEOSODON', 'neosodon'");
5158     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5159
5160     r = add_appsearch_entry(hdb, "'OLOROTITAN', 'olorotitan'");
5161     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5162
5163     r = add_appsearch_entry(hdb, "'PANTYDRACO', 'pantydraco'");
5164     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5165
5166     r = create_complocator_table(hdb);
5167     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5168
5169     r = add_complocator_entry(hdb, "'abelisaurus', '{E3619EED-305A-418C-B9C7-F7D7377F0934}', 1");
5170     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5171
5172     r = add_complocator_entry(hdb, "'bactrosaurus', '{D56B688D-542F-42Ef-90FD-B6DA76EE8119}', 0");
5173     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5174
5175     r = add_complocator_entry(hdb, "'camelotia', '{8211BE36-2466-47E3-AFB7-6AC72E51AED2}', 1");
5176     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5177
5178     r = add_complocator_entry(hdb, "'diclonius', '{5C767B20-A33C-45A4-B80B-555E512F01AE}', 0");
5179     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5180
5181     r = add_complocator_entry(hdb, "'echinodon', '{A19E16C5-C75D-4699-8111-C4338C40C3CB}', 1");
5182     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5183
5184     r = add_complocator_entry(hdb, "'falcarius', '{17762FA1-A7AE-4CC6-8827-62873C35361D}', 0");
5185     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5186
5187     r = add_complocator_entry(hdb, "'gallimimus', '{75EBF568-C959-41E0-A99E-9050638CF5FB}', 1");
5188     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5189
5190     r = add_complocator_entry(hdb, "'hagrphus', '{D4969B72-17D9-4AB6-BE49-78F2FEE857AC}', 0");
5191     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5192
5193     r = add_complocator_entry(hdb, "'iguanodon', '{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}', 1");
5194     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5195
5196     r = add_complocator_entry(hdb, "'jobaria', '{243C22B1-8C51-4151-B9D1-1AE5265E079E}', 0");
5197     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5198
5199     r = add_complocator_entry(hdb, "'kakuru', '{5D0F03BA-50BC-44F2-ABB1-72C972F4E514}', 1");
5200     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5201
5202     r = add_complocator_entry(hdb, "'labocania', '{C7DDB60C-7828-4046-A6F8-699D5E92F1ED}', 0");
5203     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5204
5205     r = add_complocator_entry(hdb, "'megaraptor', '{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}', 1");
5206     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5207
5208     r = add_complocator_entry(hdb, "'neosodon', '{0B499649-197A-48EF-93D2-AF1C17ED6E90}', 0");
5209     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5210
5211     r = add_complocator_entry(hdb, "'olorotitan', '{54E9E91F-AED2-46D5-A25A-7E50AFA24513}', 1");
5212     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5213
5214     r = add_complocator_entry(hdb, "'pantydraco', '{2A989951-5565-4FA7-93A7-E800A3E67D71}', 0");
5215     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5216
5217     r = create_signature_table(hdb);
5218     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5219
5220     r = add_signature_entry(hdb, "'abelisaurus', 'abelisaurus', '', '', '', '', '', '', ''");
5221     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5222
5223     r = add_signature_entry(hdb, "'bactrosaurus', 'bactrosaurus', '', '', '', '', '', '', ''");
5224     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5225
5226     r = add_signature_entry(hdb, "'camelotia', 'camelotia', '', '', '', '', '', '', ''");
5227     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5228
5229     r = add_signature_entry(hdb, "'diclonius', 'diclonius', '', '', '', '', '', '', ''");
5230     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5231
5232     r = add_signature_entry(hdb, "'iguanodon', 'iguanodon', '', '', '', '', '', '', ''");
5233     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5234
5235     r = add_signature_entry(hdb, "'jobaria', 'jobaria', '', '', '', '', '', '', ''");
5236     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5237
5238     r = add_signature_entry(hdb, "'kakuru', 'kakuru', '', '', '', '', '', '', ''");
5239     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5240
5241     r = add_signature_entry(hdb, "'labocania', 'labocania', '', '', '', '', '', '', ''");
5242     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5243
5244     hpkg = package_from_db(hdb);
5245     ok(hpkg, "failed to create package\n");
5246
5247     MsiCloseHandle(hdb);
5248
5249     create_test_file("abelisaurus");
5250     create_test_file("bactrosaurus");
5251     create_test_file("camelotia");
5252     create_test_file("diclonius");
5253     create_test_file("echinodon");
5254     create_test_file("falcarius");
5255     create_test_file("gallimimus");
5256     create_test_file("hagryphus");
5257     CreateDirectoryA("iguanodon", NULL);
5258     CreateDirectoryA("jobaria", NULL);
5259     CreateDirectoryA("kakuru", NULL);
5260     CreateDirectoryA("labocania", NULL);
5261     CreateDirectoryA("megaraptor", NULL);
5262     CreateDirectoryA("neosodon", NULL);
5263     CreateDirectoryA("olorotitan", NULL);
5264     CreateDirectoryA("pantydraco", NULL);
5265
5266     set_component_path("abelisaurus", "{E3619EED-305A-418C-B9C7-F7D7377F0934}");
5267     set_component_path("bactrosaurus", "{D56B688D-542F-42Ef-90FD-B6DA76EE8119}");
5268     set_component_path("echinodon", "{A19E16C5-C75D-4699-8111-C4338C40C3CB}");
5269     set_component_path("falcarius", "{17762FA1-A7AE-4CC6-8827-62873C35361D}");
5270     set_component_path("iguanodon", "{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}");
5271     set_component_path("jobaria", "{243C22B1-8C51-4151-B9D1-1AE5265E079E}");
5272     set_component_path("megaraptor", "{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}");
5273     set_component_path("neosodon", "{0B499649-197A-48EF-93D2-AF1C17ED6E90}");
5274
5275     r = MsiDoAction(hpkg, "AppSearch");
5276     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5277
5278     size = MAX_PATH;
5279     r = MsiGetPropertyA(hpkg, "ABELISAURUS", prop, &size);
5280     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5281
5282     lstrcpyA(expected, CURR_DIR);
5283     lstrcatA(expected, "\\abelisaurus");
5284     ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
5285        "Expected %s or empty string, got %s\n", expected, prop);
5286
5287     size = MAX_PATH;
5288     r = MsiGetPropertyA(hpkg, "BACTROSAURUS", prop, &size);
5289     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5290     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
5291
5292     size = MAX_PATH;
5293     r = MsiGetPropertyA(hpkg, "CAMELOTIA", prop, &size);
5294     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5295     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
5296
5297     size = MAX_PATH;
5298     r = MsiGetPropertyA(hpkg, "DICLONIUS", prop, &size);
5299     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5300     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
5301
5302     size = MAX_PATH;
5303     r = MsiGetPropertyA(hpkg, "ECHINODON", prop, &size);
5304     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5305
5306     lstrcpyA(expected, CURR_DIR);
5307     lstrcatA(expected, "\\");
5308     ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
5309        "Expected %s or empty string, got %s\n", expected, prop);
5310
5311     size = MAX_PATH;
5312     r = MsiGetPropertyA(hpkg, "FALCARIUS", prop, &size);
5313     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5314     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
5315
5316     size = MAX_PATH;
5317     r = MsiGetPropertyA(hpkg, "GALLIMIMUS", prop, &size);
5318     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5319     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
5320
5321     size = MAX_PATH;
5322     r = MsiGetPropertyA(hpkg, "HAGRYPHUS", prop, &size);
5323     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5324     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
5325
5326     size = MAX_PATH;
5327     r = MsiGetPropertyA(hpkg, "IGUANODON", prop, &size);
5328     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5329     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
5330
5331     size = MAX_PATH;
5332     r = MsiGetPropertyA(hpkg, "JOBARIA", prop, &size);
5333     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5334     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
5335
5336     size = MAX_PATH;
5337     r = MsiGetPropertyA(hpkg, "KAKURU", prop, &size);
5338     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5339     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
5340
5341     size = MAX_PATH;
5342     r = MsiGetPropertyA(hpkg, "LABOCANIA", prop, &size);
5343     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5344     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
5345
5346     size = MAX_PATH;
5347     r = MsiGetPropertyA(hpkg, "MEGARAPTOR", prop, &size);
5348     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5349
5350     lstrcpyA(expected, CURR_DIR);
5351     lstrcatA(expected, "\\");
5352     ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
5353        "Expected %s or empty string, got %s\n", expected, prop);
5354
5355     size = MAX_PATH;
5356     r = MsiGetPropertyA(hpkg, "NEOSODON", prop, &size);
5357     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5358
5359     lstrcpyA(expected, CURR_DIR);
5360     lstrcatA(expected, "\\neosodon\\");
5361     ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
5362        "Expected %s or empty string, got %s\n", expected, prop);
5363
5364     size = MAX_PATH;
5365     r = MsiGetPropertyA(hpkg, "OLOROTITAN", prop, &size);
5366     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5367     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
5368
5369     size = MAX_PATH;
5370     r = MsiGetPropertyA(hpkg, "PANTYDRACO", prop, &size);
5371     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5372     ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
5373
5374     MsiCloseHandle(hpkg);
5375     DeleteFileA("abelisaurus");
5376     DeleteFileA("bactrosaurus");
5377     DeleteFileA("camelotia");
5378     DeleteFileA("diclonius");
5379     DeleteFileA("echinodon");
5380     DeleteFileA("falcarius");
5381     DeleteFileA("gallimimus");
5382     DeleteFileA("hagryphus");
5383     RemoveDirectoryA("iguanodon");
5384     RemoveDirectoryA("jobaria");
5385     RemoveDirectoryA("kakuru");
5386     RemoveDirectoryA("labocania");
5387     RemoveDirectoryA("megaraptor");
5388     RemoveDirectoryA("neosodon");
5389     RemoveDirectoryA("olorotitan");
5390     RemoveDirectoryA("pantydraco");
5391     delete_component_path("{E3619EED-305A-418C-B9C7-F7D7377F0934}");
5392     delete_component_path("{D56B688D-542F-42Ef-90FD-B6DA76EE8119}");
5393     delete_component_path("{A19E16C5-C75D-4699-8111-C4338C40C3CB}");
5394     delete_component_path("{17762FA1-A7AE-4CC6-8827-62873C35361D}");
5395     delete_component_path("{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}");
5396     delete_component_path("{243C22B1-8C51-4151-B9D1-1AE5265E079E}");
5397     delete_component_path("{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}");
5398     delete_component_path("{0B499649-197A-48EF-93D2-AF1C17ED6E90}");
5399     DeleteFileA(msifile);
5400 }
5401
5402 static void test_MsiGetSourcePath(void)
5403 {
5404     MSIHANDLE hdb, hpkg;
5405     CHAR path[MAX_PATH];
5406     CHAR cwd[MAX_PATH];
5407     CHAR subsrc[MAX_PATH];
5408     DWORD size;
5409     UINT r;
5410
5411     lstrcpyA(cwd, CURR_DIR);
5412     lstrcatA(cwd, "\\");
5413
5414     lstrcpyA(subsrc, cwd);
5415     lstrcatA(subsrc, "subsource");
5416     lstrcatA(subsrc, "\\");
5417
5418     hdb = create_package_db();
5419     ok( hdb, "failed to create database\n");
5420
5421     r = add_directory_entry(hdb, "'TARGETDIR', '', 'SourceDir'");
5422     ok(r == S_OK, "failed\n");
5423
5424     r = add_directory_entry(hdb, "'SubDir', 'TARGETDIR', 'subtarget:subsource'");
5425     ok(r == S_OK, "failed\n");
5426
5427     hpkg = package_from_db(hdb);
5428     ok(hpkg, "failed to create package\n");
5429
5430     MsiCloseHandle(hdb);
5431
5432     /* invalid database handle */
5433     size = MAX_PATH;
5434     lstrcpyA(path, "kiwi");
5435     r = MsiGetSourcePath(-1, "TARGETDIR", path, &size);
5436     ok(r == ERROR_INVALID_HANDLE,
5437        "Expected ERROR_INVALID_HANDLE, got %d\n", r);
5438     ok(!lstrcmpA(path, "kiwi"),
5439        "Expected path to be unchanged, got \"%s\"\n", path);
5440     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
5441
5442     /* NULL szFolder */
5443     size = MAX_PATH;
5444     lstrcpyA(path, "kiwi");
5445     r = MsiGetSourcePath(hpkg, NULL, path, &size);
5446     ok(r == ERROR_INVALID_PARAMETER,
5447        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
5448     ok(!lstrcmpA(path, "kiwi"),
5449        "Expected path to be unchanged, got \"%s\"\n", path);
5450     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
5451
5452     /* empty szFolder */
5453     size = MAX_PATH;
5454     lstrcpyA(path, "kiwi");
5455     r = MsiGetSourcePath(hpkg, "", path, &size);
5456     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
5457     ok(!lstrcmpA(path, "kiwi"),
5458        "Expected path to be unchanged, got \"%s\"\n", path);
5459     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
5460
5461     /* try TARGETDIR */
5462     size = MAX_PATH;
5463     lstrcpyA(path, "kiwi");
5464     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
5465     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
5466     ok(!lstrcmpA(path, "kiwi"),
5467        "Expected path to be unchanged, got \"%s\"\n", path);
5468     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
5469
5470     /* try SourceDir */
5471     size = MAX_PATH;
5472     lstrcpyA(path, "kiwi");
5473     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
5474     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
5475     ok(!lstrcmpA(path, "kiwi"),
5476        "Expected path to be unchanged, got \"%s\"\n", path);
5477     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
5478
5479     /* try SOURCEDIR */
5480     size = MAX_PATH;
5481     lstrcpyA(path, "kiwi");
5482     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
5483     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
5484     ok(!lstrcmpA(path, "kiwi"),
5485        "Expected path to be unchanged, got \"%s\"\n", path);
5486     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
5487
5488     /* source path does not exist, but the property exists */
5489     size = MAX_PATH;
5490     lstrcpyA(path, "kiwi");
5491     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
5492     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5493     ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
5494     ok(size == 0, "Expected 0, got %d\n", size);
5495
5496     /* try SubDir */
5497     size = MAX_PATH;
5498     lstrcpyA(path, "kiwi");
5499     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
5500     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
5501     ok(!lstrcmpA(path, "kiwi"),
5502        "Expected path to be unchanged, got \"%s\"\n", path);
5503     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
5504
5505     r = MsiDoAction(hpkg, "CostInitialize");
5506     ok(r == ERROR_SUCCESS, "cost init failed\n");
5507
5508     /* try TARGETDIR after CostInitialize */
5509     size = MAX_PATH;
5510     lstrcpyA(path, "kiwi");
5511     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
5512     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5513     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
5514     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
5515
5516     /* try SourceDir after CostInitialize */
5517     size = MAX_PATH;
5518     lstrcpyA(path, "kiwi");
5519     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
5520     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5521     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
5522     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
5523
5524     /* try SOURCEDIR after CostInitialize */
5525     size = MAX_PATH;
5526     lstrcpyA(path, "kiwi");
5527     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
5528     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
5529     ok(!lstrcmpA(path, "kiwi"),
5530        "Expected path to be unchanged, got \"%s\"\n", path);
5531     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
5532
5533     /* source path does not exist, but the property exists */
5534     size = MAX_PATH;
5535     lstrcpyA(path, "kiwi");
5536     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
5537     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5538     todo_wine
5539     {
5540         ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
5541         ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
5542     }
5543
5544     /* try SubDir after CostInitialize */
5545     size = MAX_PATH;
5546     lstrcpyA(path, "kiwi");
5547     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
5548     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5549     todo_wine
5550     {
5551         ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
5552         ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
5553     }
5554
5555     r = MsiDoAction(hpkg, "ResolveSource");
5556     ok(r == ERROR_SUCCESS, "file cost failed\n");
5557
5558     /* try TARGETDIR after ResolveSource */
5559     size = MAX_PATH;
5560     lstrcpyA(path, "kiwi");
5561     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
5562     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5563     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
5564     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
5565
5566     /* try SourceDir after ResolveSource */
5567     size = MAX_PATH;
5568     lstrcpyA(path, "kiwi");
5569     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
5570     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5571     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
5572     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
5573
5574     /* try SOURCEDIR after ResolveSource */
5575     size = MAX_PATH;
5576     lstrcpyA(path, "kiwi");
5577     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
5578     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
5579     ok(!lstrcmpA(path, "kiwi"),
5580        "Expected path to be unchanged, got \"%s\"\n", path);
5581     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
5582
5583     /* source path does not exist, but the property exists */
5584     size = MAX_PATH;
5585     lstrcpyA(path, "kiwi");
5586     r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
5587     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5588     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
5589     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
5590
5591     /* try SubDir after ResolveSource */
5592     size = MAX_PATH;
5593     lstrcpyA(path, "kiwi");
5594     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
5595     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5596     todo_wine
5597     {
5598         ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
5599         ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
5600     }
5601
5602     r = MsiDoAction(hpkg, "FileCost");
5603     ok(r == ERROR_SUCCESS, "file cost failed\n");
5604
5605     /* try TARGETDIR after FileCost */
5606     size = MAX_PATH;
5607     lstrcpyA(path, "kiwi");
5608     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
5609     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5610     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
5611     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
5612
5613     /* try SourceDir after FileCost */
5614     size = MAX_PATH;
5615     lstrcpyA(path, "kiwi");
5616     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
5617     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5618     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
5619     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
5620
5621     /* try SOURCEDIR after FileCost */
5622     size = MAX_PATH;
5623     lstrcpyA(path, "kiwi");
5624     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
5625     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
5626     ok(!lstrcmpA(path, "kiwi"),
5627        "Expected path to be unchanged, got \"%s\"\n", path);
5628     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
5629
5630     /* try SubDir after FileCost */
5631     size = MAX_PATH;
5632     lstrcpyA(path, "kiwi");
5633     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
5634     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5635     todo_wine
5636     {
5637         ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
5638         ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
5639     }
5640
5641     r = MsiDoAction(hpkg, "CostFinalize");
5642     ok(r == ERROR_SUCCESS, "file cost failed\n");
5643
5644     /* try TARGETDIR after CostFinalize */
5645     size = MAX_PATH;
5646     lstrcpyA(path, "kiwi");
5647     r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
5648     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5649     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
5650     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
5651
5652     /* try SourceDir after CostFinalize */
5653     size = MAX_PATH;
5654     lstrcpyA(path, "kiwi");
5655     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
5656     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5657     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
5658     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
5659
5660     /* try SOURCEDIR after CostFinalize */
5661     size = MAX_PATH;
5662     lstrcpyA(path, "kiwi");
5663     r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
5664     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
5665     ok(!lstrcmpA(path, "kiwi"),
5666        "Expected path to be unchanged, got \"%s\"\n", path);
5667     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
5668
5669     /* try SubDir after CostFinalize */
5670     size = MAX_PATH;
5671     lstrcpyA(path, "kiwi");
5672     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
5673     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5674     todo_wine
5675     {
5676         ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
5677         ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
5678     }
5679
5680     /* nonexistent directory */
5681     size = MAX_PATH;
5682     lstrcpyA(path, "kiwi");
5683     r = MsiGetSourcePath(hpkg, "IDontExist", path, &size);
5684     ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
5685     ok(!lstrcmpA(path, "kiwi"),
5686        "Expected path to be unchanged, got \"%s\"\n", path);
5687     ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
5688
5689     /* NULL szPathBuf */
5690     size = MAX_PATH;
5691     r = MsiGetSourcePath(hpkg, "SourceDir", NULL, &size);
5692     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5693     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
5694
5695     /* NULL pcchPathBuf */
5696     lstrcpyA(path, "kiwi");
5697     r = MsiGetSourcePath(hpkg, "SourceDir", path, NULL);
5698     ok(r == ERROR_INVALID_PARAMETER,
5699        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
5700     ok(!lstrcmpA(path, "kiwi"),
5701        "Expected path to be unchanged, got \"%s\"\n", path);
5702
5703     /* pcchPathBuf is 0 */
5704     size = 0;
5705     lstrcpyA(path, "kiwi");
5706     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
5707     ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
5708     ok(!lstrcmpA(path, "kiwi"),
5709        "Expected path to be unchanged, got \"%s\"\n", path);
5710     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
5711
5712     /* pcchPathBuf does not have room for NULL terminator */
5713     size = lstrlenA(cwd);
5714     lstrcpyA(path, "kiwi");
5715     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
5716     ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
5717     ok(!strncmp(path, cwd, lstrlenA(cwd) - 1),
5718        "Expected path with no backslash, got \"%s\"\n", path);
5719     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
5720
5721     /* pcchPathBuf has room for NULL terminator */
5722     size = lstrlenA(cwd) + 1;
5723     lstrcpyA(path, "kiwi");
5724     r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
5725     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5726     ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
5727     ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
5728
5729     MsiCloseHandle(hpkg);
5730     DeleteFile(msifile);
5731 }
5732
5733 START_TEST(package)
5734 {
5735     GetCurrentDirectoryA(MAX_PATH, CURR_DIR);
5736
5737     test_createpackage();
5738     test_doaction();
5739     test_gettargetpath_bad();
5740     test_settargetpath();
5741     test_props();
5742     test_property_table();
5743     test_condition();
5744     test_msipackage();
5745     test_formatrecord2();
5746     test_states();
5747     test_getproperty();
5748     test_removefiles();
5749     test_appsearch();
5750     test_featureparents();
5751     test_installprops();
5752     test_sourcedirprop();
5753     test_prop_path();
5754     test_launchconditions();
5755     test_ccpsearch();
5756     test_complocator();
5757     test_MsiGetSourcePath();
5758 }