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