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