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