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