2 * tests for Microsoft Installer functionality
4 * Copyright 2005 Mike McCormack for CodeWeavers
5 * Copyright 2005 Aric Stewart for CodeWeavers
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.
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.
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
29 #include "wine/test.h"
31 static const char msifile[] = "winetest.msi";
33 static UINT run_query( MSIHANDLE hdb, const char *query )
38 r = MsiDatabaseOpenView(hdb, query, &hview);
39 if( r != ERROR_SUCCESS )
42 r = MsiViewExecute(hview, 0);
43 if( r == ERROR_SUCCESS )
44 r = MsiViewClose(hview);
45 MsiCloseHandle(hview);
49 static UINT create_component_table( MSIHANDLE hdb )
51 return run_query( hdb,
52 "CREATE TABLE `Component` ( "
53 "`Component` CHAR(72) NOT NULL, "
54 "`ComponentId` CHAR(38), "
55 "`Directory_` CHAR(72) NOT NULL, "
56 "`Attributes` SHORT NOT NULL, "
57 "`Condition` CHAR(255), "
59 "PRIMARY KEY `Component`)" );
62 static UINT create_feature_table( MSIHANDLE hdb )
64 return run_query( hdb,
65 "CREATE TABLE `Feature` ( "
66 "`Feature` CHAR(38) NOT NULL, "
67 "`Feature_Parent` CHAR(38), "
69 "`Description` CHAR(255), "
70 "`Display` SHORT NOT NULL, "
71 "`Level` SHORT NOT NULL, "
72 "`Directory_` CHAR(72), "
73 "`Attributes` SHORT NOT NULL "
74 "PRIMARY KEY `Feature`)" );
77 static UINT create_feature_components_table( MSIHANDLE hdb )
79 return run_query( hdb,
80 "CREATE TABLE `FeatureComponents` ( "
81 "`Feature_` CHAR(38) NOT NULL, "
82 "`Component_` CHAR(72) NOT NULL "
83 "PRIMARY KEY `Feature_`, `Component_` )" );
86 static UINT create_file_table( MSIHANDLE hdb )
88 return run_query( hdb,
89 "CREATE TABLE `File` ("
90 "`File` CHAR(72) NOT NULL, "
91 "`Component_` CHAR(72) NOT NULL, "
92 "`FileName` CHAR(255) NOT NULL, "
93 "`FileSize` LONG NOT NULL, "
94 "`Version` CHAR(72), "
95 "`Language` CHAR(20), "
96 "`Attributes` SHORT, "
97 "`Sequence` SHORT NOT NULL "
98 "PRIMARY KEY `File`)" );
101 static UINT create_remove_file_table( MSIHANDLE hdb )
103 return run_query( hdb,
104 "CREATE TABLE `RemoveFile` ("
105 "`FileKey` CHAR(72) NOT NULL, "
106 "`Component_` CHAR(72) NOT NULL, "
107 "`FileName` CHAR(255) LOCALIZABLE, "
108 "`DirProperty` CHAR(72) NOT NULL, "
109 "`InstallMode` SHORT NOT NULL "
110 "PRIMARY KEY `FileKey`)" );
113 static UINT create_appsearch_table( MSIHANDLE hdb )
115 return run_query( hdb,
116 "CREATE TABLE `AppSearch` ("
117 "`Property` CHAR(72) NOT NULL, "
118 "`Signature_` CHAR(72) NOT NULL "
119 "PRIMARY KEY `Property`, `Signature_`)" );
122 static UINT create_reglocator_table( MSIHANDLE hdb )
124 return run_query( hdb,
125 "CREATE TABLE `RegLocator` ("
126 "`Signature_` CHAR(72) NOT NULL, "
127 "`Root` SHORT NOT NULL, "
128 "`Key` CHAR(255) NOT NULL, "
131 "PRIMARY KEY `Signature_`)" );
134 static UINT create_signature_table( MSIHANDLE hdb )
136 return run_query( hdb,
137 "CREATE TABLE `Signature` ("
138 "`Signature` CHAR(72) NOT NULL, "
139 "`FileName` CHAR(255) NOT NULL, "
140 "`MinVersion` CHAR(20), "
141 "`MaxVersion` CHAR(20), "
146 "`Languages` CHAR(255) "
147 "PRIMARY KEY `Signature`)" );
150 static UINT add_component_entry( MSIHANDLE hdb, const char *values )
152 char insert[] = "INSERT INTO `Component` "
153 "(`Component`, `ComponentId`, `Directory_`, `Attributes`, `Condition`, `KeyPath`) "
158 sz = strlen(values) + sizeof insert;
159 query = HeapAlloc(GetProcessHeap(),0,sz);
160 sprintf(query,insert,values);
161 r = run_query( hdb, query );
162 HeapFree(GetProcessHeap(), 0, query);
166 static UINT add_feature_entry( MSIHANDLE hdb, const char *values )
168 char insert[] = "INSERT INTO `Feature` (`Feature`, `Feature_Parent`, "
169 "`Title`, `Description`, `Display`, `Level`, `Directory_`, `Attributes`) VALUES( %s )";
173 sz = strlen(values) + sizeof insert;
174 query = HeapAlloc(GetProcessHeap(),0,sz);
175 sprintf(query,insert,values);
176 r = run_query( hdb, query );
177 HeapFree(GetProcessHeap(), 0, query);
181 static UINT add_feature_components_entry( MSIHANDLE hdb, const char *values )
183 char insert[] = "INSERT INTO `FeatureComponents` "
184 "(`Feature_`, `Component_`) "
189 sz = strlen(values) + sizeof insert;
190 query = HeapAlloc(GetProcessHeap(),0,sz);
191 sprintf(query,insert,values);
192 r = run_query( hdb, query );
193 HeapFree(GetProcessHeap(), 0, query);
197 static UINT add_file_entry( MSIHANDLE hdb, const char *values )
199 char insert[] = "INSERT INTO `File` "
200 "(`File`, `Component_`, `FileName`, `FileSize`, `Version`, `Language`, `Attributes`, `Sequence`) "
205 sz = strlen(values) + sizeof insert;
206 query = HeapAlloc(GetProcessHeap(),0,sz);
207 sprintf(query,insert,values);
208 r = run_query( hdb, query );
209 HeapFree(GetProcessHeap(), 0, query);
213 static UINT add_appsearch_entry( MSIHANDLE hdb, const char *values )
215 char insert[] = "INSERT INTO `AppSearch` "
216 "(`Property`, `Signature_`) "
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);
229 static UINT add_reglocator_entry( MSIHANDLE hdb, const char *values )
231 char insert[] = "INSERT INTO `RegLocator` "
232 "(`Signature_`, `Root`, `Key`, `Name`, `Type`) "
237 sz = strlen(values) + sizeof insert;
238 query = HeapAlloc(GetProcessHeap(),0,sz);
239 sprintf(query,insert,values);
240 r = run_query( hdb, query );
241 HeapFree(GetProcessHeap(), 0, query);
245 static UINT add_signature_entry( MSIHANDLE hdb, const char *values )
247 char insert[] = "INSERT INTO `Signature` "
248 "(`Signature`, `FileName`, `MinVersion`, `MaxVersion`,"
249 " `MinSize`, `MaxSize`, `MinDate`, `MaxDate`, `Languages`) "
254 sz = strlen(values) + sizeof insert;
255 query = HeapAlloc(GetProcessHeap(),0,sz);
256 sprintf(query,insert,values);
257 r = run_query( hdb, query );
258 HeapFree(GetProcessHeap(), 0, query);
262 static UINT set_summary_info(MSIHANDLE hdb)
267 /* build summmary info */
268 res = MsiGetSummaryInformation(hdb, NULL, 7, &suminfo);
269 ok( res == ERROR_SUCCESS , "Failed to open summaryinfo\n" );
271 res = MsiSummaryInfoSetProperty(suminfo,2, VT_LPSTR, 0,NULL,
272 "Installation Database");
273 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
275 res = MsiSummaryInfoSetProperty(suminfo,3, VT_LPSTR, 0,NULL,
276 "Installation Database");
277 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
279 res = MsiSummaryInfoSetProperty(suminfo,4, VT_LPSTR, 0,NULL,
281 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
283 res = MsiSummaryInfoSetProperty(suminfo,7, VT_LPSTR, 0,NULL,
285 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
287 res = MsiSummaryInfoSetProperty(suminfo,9, VT_LPSTR, 0,NULL,
288 "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}");
289 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
291 res = MsiSummaryInfoSetProperty(suminfo, 14, VT_I4, 100, NULL, NULL);
292 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
294 res = MsiSummaryInfoSetProperty(suminfo, 15, VT_I4, 0, NULL, NULL);
295 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
297 res = MsiSummaryInfoPersist(suminfo);
298 ok( res == ERROR_SUCCESS , "Failed to make summary info persist\n" );
300 res = MsiCloseHandle( suminfo);
301 ok( res == ERROR_SUCCESS , "Failed to close suminfo\n" );
307 static MSIHANDLE create_package_db(void)
314 /* create an empty database */
315 res = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb );
316 ok( res == ERROR_SUCCESS , "Failed to create database\n" );
317 if( res != ERROR_SUCCESS )
320 res = MsiDatabaseCommit( hdb );
321 ok( res == ERROR_SUCCESS , "Failed to commit database\n" );
323 res = set_summary_info(hdb);
325 res = run_query( hdb,
326 "CREATE TABLE `Directory` ( "
327 "`Directory` CHAR(255) NOT NULL, "
328 "`Directory_Parent` CHAR(255), "
329 "`DefaultDir` CHAR(255) NOT NULL "
330 "PRIMARY KEY `Directory`)" );
331 ok( res == ERROR_SUCCESS , "Failed to create directory table\n" );
336 static MSIHANDLE package_from_db(MSIHANDLE hdb)
342 sprintf(szPackage,"#%li",hdb);
343 res = MsiOpenPackage(szPackage,&hPackage);
344 ok( res == ERROR_SUCCESS , "Failed to open package\n" );
346 res = MsiCloseHandle(hdb);
347 ok( res == ERROR_SUCCESS , "Failed to close db handle\n" );
352 static void create_test_file(const CHAR *name)
357 file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
358 ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name);
359 WriteFile(file, name, strlen(name), &written, NULL);
360 WriteFile(file, "\n", strlen("\n"), &written, NULL);
364 static void test_createpackage(void)
366 MSIHANDLE hPackage = 0;
369 hPackage = package_from_db(create_package_db());
370 ok( hPackage != 0, " Failed to create package\n");
372 res = MsiCloseHandle( hPackage);
373 ok( res == ERROR_SUCCESS , "Failed to close package\n" );
377 static void test_getsourcepath_bad( void )
379 static const char str[] = { 0 };
384 r = MsiGetSourcePath( -1, NULL, NULL, NULL );
385 ok( r == ERROR_INVALID_PARAMETER, "return value wrong\n");
388 r = MsiGetSourcePath( -1, NULL, buffer, &sz );
389 ok( r == ERROR_INVALID_PARAMETER, "return value wrong\n");
392 r = MsiGetSourcePath( -1, str, NULL, &sz );
393 ok( r == ERROR_INVALID_HANDLE, "return value wrong\n");
396 r = MsiGetSourcePath( -1, str, NULL, NULL );
397 ok( r == ERROR_INVALID_HANDLE, "return value wrong\n");
400 r = MsiGetSourcePath( -1, str, buffer, &sz );
401 ok( r == ERROR_INVALID_HANDLE, "return value wrong\n");
404 static UINT add_directory_entry( MSIHANDLE hdb, const char *values )
406 char insert[] = "INSERT INTO `Directory` (`Directory`,`Directory_Parent`,`DefaultDir`) VALUES( %s )";
410 sz = strlen(values) + sizeof insert;
411 query = HeapAlloc(GetProcessHeap(),0,sz);
412 sprintf(query,insert,values);
413 r = run_query( hdb, query );
414 HeapFree(GetProcessHeap(), 0, query);
418 static void test_getsourcepath( void )
420 static const char str[] = { 0 };
426 hpkg = package_from_db(create_package_db());
427 ok( hpkg, "failed to create package\n");
431 r = MsiGetSourcePath( hpkg, str, buffer, &sz );
432 ok( r == ERROR_DIRECTORY, "return value wrong\n");
433 ok( buffer[0] == 'x', "buffer modified\n");
437 r = MsiGetSourcePath( hpkg, str, buffer, &sz );
438 ok( r == ERROR_DIRECTORY, "return value wrong\n");
439 ok( buffer[0] == 'x', "buffer modified\n");
441 MsiCloseHandle( hpkg );
444 /* another test but try create a directory this time */
445 hdb = create_package_db();
446 ok( hdb, "failed to create database\n");
448 r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
449 ok( r == S_OK, "failed\n");
451 hpkg = package_from_db(hdb);
452 ok( hpkg, "failed to create package\n");
454 sz = sizeof buffer -1;
455 strcpy(buffer,"x bad");
456 r = MsiGetSourcePath( hpkg, "TARGETDIR", buffer, &sz );
459 ok( r == ERROR_DIRECTORY, "return value wrong\n");
462 r = MsiDoAction( hpkg, "CostInitialize");
463 ok( r == ERROR_SUCCESS, "cost init failed\n");
464 r = MsiDoAction( hpkg, "CostFinalize");
465 ok( r == ERROR_SUCCESS, "cost finalize failed\n");
467 sz = sizeof buffer -1;
469 r = MsiGetSourcePath( hpkg, "TARGETDIR", buffer, &sz );
470 ok( r == ERROR_SUCCESS, "return value wrong\n");
471 ok( sz == strlen(buffer), "returned length wrong\n");
474 strcpy(buffer,"x bad");
475 r = MsiGetSourcePath( hpkg, "TARGETDIR", buffer, &sz );
476 ok( r == ERROR_MORE_DATA, "return value wrong\n");
477 ok( buffer[0] == 'x', "buffer modified\n");
479 r = MsiGetSourcePath( hpkg, "TARGETDIR", NULL, NULL );
480 ok( r == ERROR_SUCCESS, "return value wrong\n");
482 r = MsiGetSourcePath( hpkg, "TARGETDIR ", NULL, NULL );
483 ok( r == ERROR_DIRECTORY, "return value wrong\n");
485 r = MsiGetSourcePath( hpkg, "targetdir", NULL, NULL );
486 ok( r == ERROR_DIRECTORY, "return value wrong\n");
488 r = MsiGetSourcePath( hpkg, "TARGETDIR", buffer, NULL );
489 ok( r == ERROR_INVALID_PARAMETER, "return value wrong\n");
491 r = MsiGetSourcePath( hpkg, "TARGETDIR", NULL, &sz );
492 ok( r == ERROR_SUCCESS, "return value wrong\n");
494 MsiCloseHandle( hpkg );
498 static void test_doaction( void )
503 r = MsiDoAction( -1, NULL );
504 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
506 hpkg = package_from_db(create_package_db());
507 ok( hpkg, "failed to create package\n");
509 r = MsiDoAction(hpkg, NULL);
510 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
512 r = MsiDoAction(0, "boo");
513 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
515 r = MsiDoAction(hpkg, "boo");
516 ok( r == ERROR_FUNCTION_NOT_CALLED, "wrong return val\n");
518 MsiCloseHandle( hpkg );
522 static void test_gettargetpath_bad(void)
529 hpkg = package_from_db(create_package_db());
530 ok( hpkg, "failed to create package\n");
532 r = MsiGetTargetPath( 0, NULL, NULL, NULL );
533 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
535 r = MsiGetTargetPath( 0, NULL, NULL, &sz );
536 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
538 r = MsiGetTargetPath( 0, "boo", NULL, NULL );
539 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
541 r = MsiGetTargetPath( 0, "boo", NULL, NULL );
542 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
544 r = MsiGetTargetPath( hpkg, "boo", NULL, NULL );
545 ok( r == ERROR_DIRECTORY, "wrong return val\n");
547 r = MsiGetTargetPath( hpkg, "boo", buffer, NULL );
548 ok( r == ERROR_DIRECTORY, "wrong return val\n");
550 MsiCloseHandle( hpkg );
554 static void query_file_path(MSIHANDLE hpkg, LPCSTR file, LPSTR buff)
560 rec = MsiCreateRecord( 1 );
561 ok(rec, "MsiCreate record failed\n");
563 r = MsiRecordSetString( rec, 0, file );
564 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
567 r = MsiFormatRecord( hpkg, rec, buff, &size );
568 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
570 MsiCloseHandle( rec );
573 static void test_settargetpath(void)
575 char tempdir[MAX_PATH+8], buffer[MAX_PATH], file[MAX_PATH];
581 hdb = create_package_db();
582 ok ( hdb, "failed to create package database\n" );
584 r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'" );
585 ok( r == S_OK, "failed to add directory entry: %d\n" , r );
587 r = create_component_table( hdb );
588 ok( r == S_OK, "cannot create Component table: %d\n", r );
590 r = add_component_entry( hdb, "'RootComp', '{83e2694d-0864-4124-9323-6d37630912a1}', 'TARGETDIR', 8, '', 'RootFile'" );
591 ok( r == S_OK, "cannot add dummy component: %d\n", r );
593 r = add_component_entry( hdb, "'TestComp', '{A3FB59C8-C293-4F7E-B8C5-F0E1D8EEE4E5}', 'TestDir', 0, '', 'TestFile'" );
594 ok( r == S_OK, "cannot add test component: %d\n", r );
596 r = create_feature_table( hdb );
597 ok( r == S_OK, "cannot create Feature table: %d\n", r );
599 r = add_feature_entry( hdb, "'TestFeature', '', '', '', 0, 1, '', 0" );
600 ok( r == ERROR_SUCCESS, "cannot add TestFeature to Feature table: %d\n", r );
602 r = create_feature_components_table( hdb );
603 ok( r == S_OK, "cannot create FeatureComponents table: %d\n", r );
605 r = add_feature_components_entry( hdb, "'TestFeature', 'RootComp'" );
606 ok( r == S_OK, "cannot insert component into FeatureComponents table: %d\n", r );
608 r = add_feature_components_entry( hdb, "'TestFeature', 'TestComp'" );
609 ok( r == S_OK, "cannot insert component into FeatureComponents table: %d\n", r );
611 add_directory_entry( hdb, "'TestParent', 'TARGETDIR', 'TestParent'" );
612 add_directory_entry( hdb, "'TestDir', 'TestParent', 'TestDir'" );
614 r = create_file_table( hdb );
615 ok( r == S_OK, "cannot create File table: %d\n", r );
617 r = add_file_entry( hdb, "'RootFile', 'RootComp', 'rootfile.txt', 0, '', '1033', 8192, 1" );
618 ok( r == S_OK, "cannot add file to the File table: %d\n", r );
620 r = add_file_entry( hdb, "'TestFile', 'TestComp', 'testfile.txt', 0, '', '1033', 8192, 1" );
621 ok( r == S_OK, "cannot add file to the File table: %d\n", r );
623 hpkg = package_from_db( hdb );
624 ok( hpkg, "failed to create package\n");
626 r = MsiDoAction( hpkg, "CostInitialize");
627 ok( r == ERROR_SUCCESS, "cost init failed\n");
629 r = MsiDoAction( hpkg, "FileCost");
630 ok( r == ERROR_SUCCESS, "file cost failed\n");
632 r = MsiDoAction( hpkg, "CostFinalize");
633 ok( r == ERROR_SUCCESS, "cost finalize failed\n");
635 r = MsiSetTargetPath( 0, NULL, NULL );
636 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
638 r = MsiSetTargetPath( 0, "boo", "C:\\bogusx" );
639 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
641 r = MsiSetTargetPath( hpkg, "boo", NULL );
642 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
644 r = MsiSetTargetPath( hpkg, "boo", "c:\\bogusx" );
645 ok( r == ERROR_DIRECTORY, "wrong return val\n");
647 sz = sizeof tempdir - 1;
648 r = MsiGetTargetPath( hpkg, "TARGETDIR", tempdir, &sz );
649 sprintf( file, "%srootfile.txt", tempdir );
650 query_file_path( hpkg, "[#RootFile]", buffer );
651 ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
652 ok( !lstrcmp(buffer, file), "Expected %s, got %s\n", file, buffer );
654 GetTempFileName( tempdir, "_wt", 0, buffer );
655 sprintf( tempdir, "%s\\subdir", buffer );
657 r = MsiSetTargetPath( hpkg, "TARGETDIR", buffer );
658 ok( r == ERROR_SUCCESS, "MsiSetTargetPath on file returned %d\n", r );
660 r = MsiSetTargetPath( hpkg, "TARGETDIR", tempdir );
661 ok( r == ERROR_SUCCESS, "MsiSetTargetPath on 'subdir' of file returned %d\n", r );
663 DeleteFile( buffer );
665 r = MsiSetTargetPath( hpkg, "TARGETDIR", buffer );
666 ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
668 r = GetFileAttributes( buffer );
669 ok ( r == INVALID_FILE_ATTRIBUTES, "file/directory exists after MsiSetTargetPath. Attributes: %08X\n", r );
671 r = MsiSetTargetPath( hpkg, "TARGETDIR", tempdir );
672 ok( r == ERROR_SUCCESS, "MsiSetTargetPath on subsubdir returned %d\n", r );
674 sz = sizeof buffer - 1;
675 lstrcat( tempdir, "\\" );
676 r = MsiGetTargetPath( hpkg, "TARGETDIR", buffer, &sz );
677 ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
680 ok( !lstrcmp(buffer, tempdir), "Expected %s, got %s\n", tempdir, buffer);
683 sprintf( file, "%srootfile.txt", tempdir );
684 query_file_path( hpkg, "[#RootFile]", buffer );
687 ok( !lstrcmp(buffer, file), "Expected %s, got %s\n", file, buffer);
690 r = MsiSetTargetPath( hpkg, "TestParent", "C:\\one\\two" );
691 ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
693 query_file_path( hpkg, "[#TestFile]", buffer );
694 ok( !lstrcmp(buffer, "C:\\one\\two\\TestDir\\testfile.txt"),
695 "Expected C:\\one\\two\\TestDir\\testfile.txt, got %s\n", buffer );
697 sz = sizeof buffer - 1;
698 r = MsiGetTargetPath( hpkg, "TestParent", buffer, &sz );
699 ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
700 ok( !lstrcmp(buffer, "C:\\one\\two\\"), "Expected C:\\one\\two\\, got %s\n", buffer);
702 MsiCloseHandle( hpkg );
705 static void test_condition(void)
710 hpkg = package_from_db(create_package_db());
711 ok( hpkg, "failed to create package\n");
713 r = MsiEvaluateCondition(0, NULL);
714 ok( r == MSICONDITION_ERROR, "wrong return val\n");
716 r = MsiEvaluateCondition(hpkg, NULL);
717 ok( r == MSICONDITION_NONE, "wrong return val\n");
719 r = MsiEvaluateCondition(hpkg, "");
720 ok( r == MSICONDITION_NONE, "wrong return val\n");
722 r = MsiEvaluateCondition(hpkg, "1");
723 ok( r == MSICONDITION_TRUE, "wrong return val\n");
725 r = MsiEvaluateCondition(hpkg, "0");
726 ok( r == MSICONDITION_FALSE, "wrong return val\n");
728 r = MsiEvaluateCondition(hpkg, "0 = 0");
729 ok( r == MSICONDITION_TRUE, "wrong return val\n");
731 r = MsiEvaluateCondition(hpkg, "0 <> 0");
732 ok( r == MSICONDITION_FALSE, "wrong return val\n");
734 r = MsiEvaluateCondition(hpkg, "0 = 1");
735 ok( r == MSICONDITION_FALSE, "wrong return val\n");
737 r = MsiEvaluateCondition(hpkg, "0 > 1");
738 ok( r == MSICONDITION_FALSE, "wrong return val\n");
740 r = MsiEvaluateCondition(hpkg, "0 ~> 1");
741 ok( r == MSICONDITION_FALSE, "wrong return val\n");
743 r = MsiEvaluateCondition(hpkg, "1 > 1");
744 ok( r == MSICONDITION_FALSE, "wrong return val\n");
746 r = MsiEvaluateCondition(hpkg, "1 ~> 1");
747 ok( r == MSICONDITION_FALSE, "wrong return val\n");
749 r = MsiEvaluateCondition(hpkg, "0 >= 1");
750 ok( r == MSICONDITION_FALSE, "wrong return val\n");
752 r = MsiEvaluateCondition(hpkg, "0 ~>= 1");
753 ok( r == MSICONDITION_FALSE, "wrong return val\n");
755 r = MsiEvaluateCondition(hpkg, "1 >= 1");
756 ok( r == MSICONDITION_TRUE, "wrong return val\n");
758 r = MsiEvaluateCondition(hpkg, "1 ~>= 1");
759 ok( r == MSICONDITION_TRUE, "wrong return val\n");
761 r = MsiEvaluateCondition(hpkg, "0 < 1");
762 ok( r == MSICONDITION_TRUE, "wrong return val\n");
764 r = MsiEvaluateCondition(hpkg, "0 ~< 1");
765 ok( r == MSICONDITION_TRUE, "wrong return val\n");
767 r = MsiEvaluateCondition(hpkg, "1 < 1");
768 ok( r == MSICONDITION_FALSE, "wrong return val\n");
770 r = MsiEvaluateCondition(hpkg, "1 ~< 1");
771 ok( r == MSICONDITION_FALSE, "wrong return val\n");
773 r = MsiEvaluateCondition(hpkg, "0 <= 1");
774 ok( r == MSICONDITION_TRUE, "wrong return val\n");
776 r = MsiEvaluateCondition(hpkg, "0 ~<= 1");
777 ok( r == MSICONDITION_TRUE, "wrong return val\n");
779 r = MsiEvaluateCondition(hpkg, "1 <= 1");
780 ok( r == MSICONDITION_TRUE, "wrong return val\n");
782 r = MsiEvaluateCondition(hpkg, "1 ~<= 1");
783 ok( r == MSICONDITION_TRUE, "wrong return val\n");
785 r = MsiEvaluateCondition(hpkg, "0 >=");
786 ok( r == MSICONDITION_ERROR, "wrong return val\n");
788 r = MsiEvaluateCondition(hpkg, " ");
789 ok( r == MSICONDITION_NONE, "wrong return val\n");
791 r = MsiEvaluateCondition(hpkg, "LicView <> \"1\"");
792 ok( r == MSICONDITION_TRUE, "wrong return val\n");
794 r = MsiEvaluateCondition(hpkg, "LicView <> \"0\"");
795 ok( r == MSICONDITION_TRUE, "wrong return val\n");
797 r = MsiEvaluateCondition(hpkg, "LicView <> LicView");
798 ok( r == MSICONDITION_FALSE, "wrong return val\n");
800 r = MsiEvaluateCondition(hpkg, "not 0");
801 ok( r == MSICONDITION_TRUE, "wrong return val\n");
803 r = MsiEvaluateCondition(hpkg, "not LicView");
804 ok( r == MSICONDITION_TRUE, "wrong return val\n");
806 r = MsiEvaluateCondition(hpkg, "not \"A\"");
807 ok( r == MSICONDITION_FALSE, "wrong return val\n");
809 r = MsiEvaluateCondition(hpkg, "~not \"A\"");
810 ok( r == MSICONDITION_ERROR, "wrong return val\n");
812 r = MsiEvaluateCondition(hpkg, "\"0\"");
813 ok( r == MSICONDITION_TRUE, "wrong return val\n");
815 r = MsiEvaluateCondition(hpkg, "1 and 2");
816 ok( r == MSICONDITION_TRUE, "wrong return val\n");
818 r = MsiEvaluateCondition(hpkg, "not 0 and 3");
819 ok( r == MSICONDITION_TRUE, "wrong return val\n");
821 r = MsiEvaluateCondition(hpkg, "not 0 and 0");
822 ok( r == MSICONDITION_FALSE, "wrong return val\n");
824 r = MsiEvaluateCondition(hpkg, "not 0 or 1");
825 ok( r == MSICONDITION_TRUE, "wrong return val\n");
827 r = MsiEvaluateCondition(hpkg, "(0)");
828 ok( r == MSICONDITION_FALSE, "wrong return val\n");
830 r = MsiEvaluateCondition(hpkg, "(((((1))))))");
831 ok( r == MSICONDITION_ERROR, "wrong return val\n");
833 r = MsiEvaluateCondition(hpkg, "(((((1)))))");
834 ok( r == MSICONDITION_TRUE, "wrong return val\n");
836 r = MsiEvaluateCondition(hpkg, " \"A\" < \"B\" ");
837 ok( r == MSICONDITION_TRUE, "wrong return val\n");
839 r = MsiEvaluateCondition(hpkg, " \"A\" > \"B\" ");
840 ok( r == MSICONDITION_FALSE, "wrong return val\n");
842 r = MsiEvaluateCondition(hpkg, " \"1\" > \"12\" ");
843 ok( r == MSICONDITION_FALSE, "wrong return val\n");
845 r = MsiEvaluateCondition(hpkg, " \"100\" < \"21\" ");
846 ok( r == MSICONDITION_TRUE, "wrong return val\n");
848 r = MsiEvaluateCondition(hpkg, "0 < > 0");
849 ok( r == MSICONDITION_ERROR, "wrong return val\n");
851 r = MsiEvaluateCondition(hpkg, "(1<<1) == 2");
852 ok( r == MSICONDITION_ERROR, "wrong return val\n");
854 r = MsiEvaluateCondition(hpkg, " \"A\" = \"a\" ");
855 ok( r == MSICONDITION_FALSE, "wrong return val\n");
857 r = MsiEvaluateCondition(hpkg, " \"A\" ~ = \"a\" ");
858 ok( r == MSICONDITION_ERROR, "wrong return val\n");
860 r = MsiEvaluateCondition(hpkg, " \"A\" ~= \"a\" ");
861 ok( r == MSICONDITION_TRUE, "wrong return val\n");
863 r = MsiEvaluateCondition(hpkg, " \"A\" ~= 1 ");
864 ok( r == MSICONDITION_FALSE, "wrong return val\n");
866 r = MsiEvaluateCondition(hpkg, " \"A\" = 1 ");
867 ok( r == MSICONDITION_FALSE, "wrong return val\n");
869 r = MsiEvaluateCondition(hpkg, " 1 ~= 1 ");
870 ok( r == MSICONDITION_TRUE, "wrong return val\n");
872 r = MsiEvaluateCondition(hpkg, " 1 ~= \"1\" ");
873 ok( r == MSICONDITION_FALSE, "wrong return val\n");
875 r = MsiEvaluateCondition(hpkg, " 1 = \"1\" ");
876 ok( r == MSICONDITION_FALSE, "wrong return val\n");
878 r = MsiEvaluateCondition(hpkg, " 0 = \"1\" ");
879 ok( r == MSICONDITION_FALSE, "wrong return val\n");
881 r = MsiEvaluateCondition(hpkg, " 0 < \"100\" ");
882 ok( r == MSICONDITION_FALSE, "wrong return val\n");
884 r = MsiEvaluateCondition(hpkg, " 100 > \"0\" ");
885 ok( r == MSICONDITION_FALSE, "wrong return val\n");
887 r = MsiEvaluateCondition(hpkg, "1 XOR 1");
888 ok( r == MSICONDITION_FALSE, "wrong return val\n");
890 r = MsiEvaluateCondition(hpkg, "1 IMP 1");
891 ok( r == MSICONDITION_TRUE, "wrong return val\n");
893 r = MsiEvaluateCondition(hpkg, "1 IMP 0");
894 ok( r == MSICONDITION_FALSE, "wrong return val\n");
896 r = MsiEvaluateCondition(hpkg, "0 IMP 0");
897 ok( r == MSICONDITION_TRUE, "wrong return val\n");
899 r = MsiEvaluateCondition(hpkg, "0 EQV 0");
900 ok( r == MSICONDITION_TRUE, "wrong return val\n");
902 r = MsiEvaluateCondition(hpkg, "0 EQV 1");
903 ok( r == MSICONDITION_FALSE, "wrong return val\n");
905 r = MsiEvaluateCondition(hpkg, "1 IMP 1 OR 0");
906 ok( r == MSICONDITION_TRUE, "wrong return val\n");
908 r = MsiEvaluateCondition(hpkg, "1 IMPL 1");
909 ok( r == MSICONDITION_ERROR, "wrong return val\n");
911 r = MsiEvaluateCondition(hpkg, "\"ASFD\" >< \"S\" ");
912 ok( r == MSICONDITION_TRUE, "wrong return val\n");
914 r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"s\" ");
915 ok( r == MSICONDITION_TRUE, "wrong return val\n");
917 r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"\" ");
918 ok( r == MSICONDITION_TRUE, "wrong return val\n");
920 r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"sss\" ");
921 ok( r == MSICONDITION_FALSE, "wrong return val\n");
923 MsiSetProperty(hpkg, "mm", "5" );
925 r = MsiEvaluateCondition(hpkg, "mm = 5");
926 ok( r == MSICONDITION_TRUE, "wrong return val\n");
928 r = MsiEvaluateCondition(hpkg, "mm < 6");
929 ok( r == MSICONDITION_TRUE, "wrong return val\n");
931 r = MsiEvaluateCondition(hpkg, "mm <= 5");
932 ok( r == MSICONDITION_TRUE, "wrong return val\n");
934 r = MsiEvaluateCondition(hpkg, "mm > 4");
935 ok( r == MSICONDITION_TRUE, "wrong return val\n");
937 r = MsiEvaluateCondition(hpkg, "mm < 12");
938 ok( r == MSICONDITION_TRUE, "wrong return val\n");
940 r = MsiEvaluateCondition(hpkg, "mm = \"5\"");
941 ok( r == MSICONDITION_TRUE, "wrong return val\n");
943 r = MsiEvaluateCondition(hpkg, "0 = \"\"");
944 ok( r == MSICONDITION_FALSE, "wrong return val\n");
946 r = MsiEvaluateCondition(hpkg, "0 AND \"\"");
947 ok( r == MSICONDITION_FALSE, "wrong return val\n");
949 r = MsiEvaluateCondition(hpkg, "1 AND \"\"");
950 ok( r == MSICONDITION_FALSE, "wrong return val\n");
952 r = MsiEvaluateCondition(hpkg, "1 AND \"1\"");
953 ok( r == MSICONDITION_TRUE, "wrong return val\n");
955 r = MsiEvaluateCondition(hpkg, "3 >< 1");
956 ok( r == MSICONDITION_TRUE, "wrong return val\n");
958 r = MsiEvaluateCondition(hpkg, "3 >< 4");
959 ok( r == MSICONDITION_FALSE, "wrong return val\n");
961 r = MsiEvaluateCondition(hpkg, "NOT 0 AND 0");
962 ok( r == MSICONDITION_FALSE, "wrong return val\n");
964 r = MsiEvaluateCondition(hpkg, "NOT 0 AND 1");
965 ok( r == MSICONDITION_TRUE, "wrong return val\n");
967 r = MsiEvaluateCondition(hpkg, "NOT 1 OR 0");
968 ok( r == MSICONDITION_FALSE, "wrong return val\n");
970 r = MsiEvaluateCondition(hpkg, "0 AND 1 OR 1");
971 ok( r == MSICONDITION_TRUE, "wrong return val\n");
973 r = MsiEvaluateCondition(hpkg, "0 AND 0 OR 1");
974 ok( r == MSICONDITION_TRUE, "wrong return val\n");
976 r = MsiEvaluateCondition(hpkg, "NOT 0 AND 1 OR 0");
977 ok( r == MSICONDITION_TRUE, "wrong return val\n");
979 r = MsiEvaluateCondition(hpkg, "_1 = _1");
980 ok( r == MSICONDITION_TRUE, "wrong return val\n");
982 r = MsiEvaluateCondition(hpkg, "( 1 AND 1 ) = 2");
983 ok( r == MSICONDITION_ERROR, "wrong return val\n");
985 r = MsiEvaluateCondition(hpkg, "NOT ( 1 AND 1 )");
986 ok( r == MSICONDITION_FALSE, "wrong return val\n");
988 r = MsiEvaluateCondition(hpkg, "NOT A AND (BBBBBBBBBB=2 OR CCC=1) AND Ddddddddd");
989 ok( r == MSICONDITION_FALSE, "wrong return val\n");
991 r = MsiEvaluateCondition(hpkg, "Installed<>\"\"");
992 ok( r == MSICONDITION_FALSE, "wrong return val\n");
994 r = MsiEvaluateCondition(hpkg, "NOT 1 AND 0");
995 ok( r == MSICONDITION_FALSE, "wrong return val\n");
997 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
998 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1000 r = MsiEvaluateCondition(hpkg, "bandalmael<>0");
1001 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1003 r = MsiEvaluateCondition(hpkg, "bandalmael<0");
1004 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1006 r = MsiEvaluateCondition(hpkg, "bandalmael>0");
1007 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1009 r = MsiEvaluateCondition(hpkg, "bandalmael>=0");
1010 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1012 r = MsiEvaluateCondition(hpkg, "bandalmael<=0");
1013 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1015 r = MsiEvaluateCondition(hpkg, "bandalmael~<>0");
1016 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1018 MsiSetProperty(hpkg, "bandalmael", "0" );
1019 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1020 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1022 MsiSetProperty(hpkg, "bandalmael", "" );
1023 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1024 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1026 MsiSetProperty(hpkg, "bandalmael", "asdf" );
1027 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1028 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1030 MsiSetProperty(hpkg, "bandalmael", "0asdf" );
1031 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1032 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1034 MsiSetProperty(hpkg, "bandalmael", "0 " );
1035 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1036 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1038 MsiSetProperty(hpkg, "bandalmael", "-0" );
1039 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1040 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1042 MsiSetProperty(hpkg, "bandalmael", "0000000000000" );
1043 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1044 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1046 MsiSetProperty(hpkg, "bandalmael", "--0" );
1047 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1048 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1050 MsiSetProperty(hpkg, "bandalmael", "0x00" );
1051 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1052 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1054 MsiSetProperty(hpkg, "bandalmael", "-" );
1055 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1056 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1058 MsiSetProperty(hpkg, "bandalmael", "+0" );
1059 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1060 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1062 MsiSetProperty(hpkg, "bandalmael", "0.0" );
1063 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1064 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1065 r = MsiEvaluateCondition(hpkg, "bandalmael<>0");
1066 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1068 MsiSetProperty(hpkg, "one", "hi");
1069 MsiSetProperty(hpkg, "two", "hithere");
1070 r = MsiEvaluateCondition(hpkg, "one >< two");
1071 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1073 MsiSetProperty(hpkg, "one", "hithere");
1074 MsiSetProperty(hpkg, "two", "hi");
1075 r = MsiEvaluateCondition(hpkg, "one >< two");
1076 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1078 MsiSetProperty(hpkg, "one", "hello");
1079 MsiSetProperty(hpkg, "two", "hi");
1080 r = MsiEvaluateCondition(hpkg, "one >< two");
1081 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1083 MsiSetProperty(hpkg, "one", "hellohithere");
1084 MsiSetProperty(hpkg, "two", "hi");
1085 r = MsiEvaluateCondition(hpkg, "one >< two");
1086 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1088 MsiSetProperty(hpkg, "one", "");
1089 MsiSetProperty(hpkg, "two", "hi");
1090 r = MsiEvaluateCondition(hpkg, "one >< two");
1091 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1093 MsiSetProperty(hpkg, "one", "hi");
1094 MsiSetProperty(hpkg, "two", "");
1095 r = MsiEvaluateCondition(hpkg, "one >< two");
1096 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1098 MsiSetProperty(hpkg, "one", "");
1099 MsiSetProperty(hpkg, "two", "");
1100 r = MsiEvaluateCondition(hpkg, "one >< two");
1101 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1103 MsiSetProperty(hpkg, "one", "1234");
1104 MsiSetProperty(hpkg, "two", "1");
1105 r = MsiEvaluateCondition(hpkg, "one >< two");
1106 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1108 MsiSetProperty(hpkg, "one", "one 1234");
1109 MsiSetProperty(hpkg, "two", "1");
1110 r = MsiEvaluateCondition(hpkg, "one >< two");
1111 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1113 MsiSetProperty(hpkg, "one", "hithere");
1114 MsiSetProperty(hpkg, "two", "hi");
1115 r = MsiEvaluateCondition(hpkg, "one << two");
1116 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1118 MsiSetProperty(hpkg, "one", "hi");
1119 MsiSetProperty(hpkg, "two", "hithere");
1120 r = MsiEvaluateCondition(hpkg, "one << two");
1121 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1123 MsiSetProperty(hpkg, "one", "hi");
1124 MsiSetProperty(hpkg, "two", "hi");
1125 r = MsiEvaluateCondition(hpkg, "one << two");
1126 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1128 MsiSetProperty(hpkg, "one", "abcdhithere");
1129 MsiSetProperty(hpkg, "two", "hi");
1130 r = MsiEvaluateCondition(hpkg, "one << two");
1131 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1133 MsiSetProperty(hpkg, "one", "");
1134 MsiSetProperty(hpkg, "two", "hi");
1135 r = MsiEvaluateCondition(hpkg, "one << two");
1136 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1138 MsiSetProperty(hpkg, "one", "hithere");
1139 MsiSetProperty(hpkg, "two", "");
1140 r = MsiEvaluateCondition(hpkg, "one << two");
1141 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1143 MsiSetProperty(hpkg, "one", "");
1144 MsiSetProperty(hpkg, "two", "");
1145 r = MsiEvaluateCondition(hpkg, "one << two");
1146 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1148 MsiSetProperty(hpkg, "one", "1234");
1149 MsiSetProperty(hpkg, "two", "1");
1150 r = MsiEvaluateCondition(hpkg, "one << two");
1151 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1153 MsiSetProperty(hpkg, "one", "1234 one");
1154 MsiSetProperty(hpkg, "two", "1");
1155 r = MsiEvaluateCondition(hpkg, "one << two");
1156 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1158 MsiSetProperty(hpkg, "one", "hithere");
1159 MsiSetProperty(hpkg, "two", "there");
1160 r = MsiEvaluateCondition(hpkg, "one >> two");
1161 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1163 MsiSetProperty(hpkg, "one", "hithere");
1164 MsiSetProperty(hpkg, "two", "hi");
1165 r = MsiEvaluateCondition(hpkg, "one >> two");
1166 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1168 MsiSetProperty(hpkg, "one", "there");
1169 MsiSetProperty(hpkg, "two", "hithere");
1170 r = MsiEvaluateCondition(hpkg, "one >> two");
1171 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1173 MsiSetProperty(hpkg, "one", "there");
1174 MsiSetProperty(hpkg, "two", "there");
1175 r = MsiEvaluateCondition(hpkg, "one >> two");
1176 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1178 MsiSetProperty(hpkg, "one", "abcdhithere");
1179 MsiSetProperty(hpkg, "two", "hi");
1180 r = MsiEvaluateCondition(hpkg, "one >> two");
1181 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1183 MsiSetProperty(hpkg, "one", "");
1184 MsiSetProperty(hpkg, "two", "there");
1185 r = MsiEvaluateCondition(hpkg, "one >> two");
1186 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1188 MsiSetProperty(hpkg, "one", "there");
1189 MsiSetProperty(hpkg, "two", "");
1190 r = MsiEvaluateCondition(hpkg, "one >> two");
1191 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1193 MsiSetProperty(hpkg, "one", "");
1194 MsiSetProperty(hpkg, "two", "");
1195 r = MsiEvaluateCondition(hpkg, "one >> two");
1196 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1198 MsiSetProperty(hpkg, "one", "1234");
1199 MsiSetProperty(hpkg, "two", "4");
1200 r = MsiEvaluateCondition(hpkg, "one >> two");
1201 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1203 MsiSetProperty(hpkg, "one", "one 1234");
1204 MsiSetProperty(hpkg, "two", "4");
1205 r = MsiEvaluateCondition(hpkg, "one >> two");
1206 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1208 MsiCloseHandle( hpkg );
1209 DeleteFile(msifile);
1212 static BOOL check_prop_empty( MSIHANDLE hpkg, const char * prop)
1220 r = MsiGetProperty( hpkg, prop, buffer, &sz );
1221 return r == ERROR_SUCCESS && buffer[0] == 0 && sz == 0;
1224 static void test_props(void)
1231 hpkg = package_from_db(create_package_db());
1232 ok( hpkg, "failed to create package\n");
1234 /* test invalid values */
1235 r = MsiGetProperty( 0, NULL, NULL, NULL );
1236 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1238 r = MsiGetProperty( hpkg, NULL, NULL, NULL );
1239 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1241 r = MsiGetProperty( hpkg, "boo", NULL, NULL );
1242 ok( r == ERROR_SUCCESS, "wrong return val\n");
1244 r = MsiGetProperty( hpkg, "boo", buffer, NULL );
1245 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1247 /* test retrieving an empty/nonexistent property */
1249 r = MsiGetProperty( hpkg, "boo", NULL, &sz );
1250 ok( r == ERROR_SUCCESS, "wrong return val\n");
1251 ok( sz == 0, "wrong size returned\n");
1253 check_prop_empty( hpkg, "boo");
1256 r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1257 ok( r == ERROR_MORE_DATA, "wrong return val\n");
1258 ok( !strcmp(buffer,"x"), "buffer was changed\n");
1259 ok( sz == 0, "wrong size returned\n");
1263 r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1264 ok( r == ERROR_SUCCESS, "wrong return val\n");
1265 ok( buffer[0] == 0, "buffer was not changed\n");
1266 ok( sz == 0, "wrong size returned\n");
1268 /* set the property to something */
1269 r = MsiSetProperty( 0, NULL, NULL );
1270 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
1272 r = MsiSetProperty( hpkg, NULL, NULL );
1273 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1275 r = MsiSetProperty( hpkg, "", NULL );
1276 ok( r == ERROR_SUCCESS, "wrong return val\n");
1278 /* try set and get some illegal property identifiers */
1279 r = MsiSetProperty( hpkg, "", "asdf" );
1280 ok( r == ERROR_FUNCTION_FAILED, "wrong return val\n");
1282 r = MsiSetProperty( hpkg, "=", "asdf" );
1283 ok( r == ERROR_SUCCESS, "wrong return val\n");
1285 r = MsiSetProperty( hpkg, " ", "asdf" );
1286 ok( r == ERROR_SUCCESS, "wrong return val\n");
1288 r = MsiSetProperty( hpkg, "'", "asdf" );
1289 ok( r == ERROR_SUCCESS, "wrong return val\n");
1293 r = MsiGetProperty( hpkg, "'", buffer, &sz );
1294 ok( r == ERROR_SUCCESS, "wrong return val\n");
1295 ok( !strcmp(buffer,"asdf"), "buffer was not changed\n");
1297 /* set empty values */
1298 r = MsiSetProperty( hpkg, "boo", NULL );
1299 ok( r == ERROR_SUCCESS, "wrong return val\n");
1300 ok( check_prop_empty( hpkg, "boo"), "prop wasn't empty\n");
1302 r = MsiSetProperty( hpkg, "boo", "" );
1303 ok( r == ERROR_SUCCESS, "wrong return val\n");
1304 ok( check_prop_empty( hpkg, "boo"), "prop wasn't empty\n");
1306 /* set a non-empty value */
1307 r = MsiSetProperty( hpkg, "boo", "xyz" );
1308 ok( r == ERROR_SUCCESS, "wrong return val\n");
1312 r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1313 ok( r == ERROR_MORE_DATA, "wrong return val\n");
1314 ok( buffer[0] == 0, "buffer was not changed\n");
1315 ok( sz == 3, "wrong size returned\n");
1319 r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1320 ok( r == ERROR_SUCCESS, "wrong return val\n");
1321 ok( !strcmp(buffer,"xyz"), "buffer was not changed\n");
1322 ok( sz == 3, "wrong size returned\n");
1326 r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1327 ok( r == ERROR_MORE_DATA, "wrong return val\n");
1328 ok( !strcmp(buffer,"xy"), "buffer was not changed\n");
1329 ok( sz == 3, "wrong size returned\n");
1331 r = MsiSetProperty(hpkg, "SourceDir", "foo");
1332 ok( r == ERROR_SUCCESS, "wrong return val\n");
1335 r = MsiGetProperty(hpkg, "SOURCEDIR", buffer, &sz);
1336 ok( r == ERROR_SUCCESS, "wrong return val\n");
1337 ok( !strcmp(buffer,""), "buffer wrong\n");
1338 ok( sz == 0, "wrong size returned\n");
1341 r = MsiGetProperty(hpkg, "SOMERANDOMNAME", buffer, &sz);
1342 ok( r == ERROR_SUCCESS, "wrong return val\n");
1343 ok( !strcmp(buffer,""), "buffer wrong\n");
1344 ok( sz == 0, "wrong size returned\n");
1347 r = MsiGetProperty(hpkg, "SourceDir", buffer, &sz);
1348 ok( r == ERROR_SUCCESS, "wrong return val\n");
1349 ok( !strcmp(buffer,"foo"), "buffer wrong\n");
1350 ok( sz == 3, "wrong size returned\n");
1352 MsiCloseHandle( hpkg );
1353 DeleteFile(msifile);
1356 static UINT try_query_param( MSIHANDLE hdb, LPCSTR szQuery, MSIHANDLE hrec )
1361 res = MsiDatabaseOpenView( hdb, szQuery, &htab );
1362 if( res == ERROR_SUCCESS )
1366 r = MsiViewExecute( htab, hrec );
1367 if( r != ERROR_SUCCESS )
1370 fprintf(stderr,"MsiViewExecute failed %08x\n", res);
1373 r = MsiViewClose( htab );
1374 if( r != ERROR_SUCCESS )
1377 r = MsiCloseHandle( htab );
1378 if( r != ERROR_SUCCESS )
1384 static UINT try_query( MSIHANDLE hdb, LPCSTR szQuery )
1386 return try_query_param( hdb, szQuery, 0 );
1389 static void test_msipackage(void)
1391 MSIHANDLE hdb = 0, hpack = 100;
1396 DeleteFile(msifile);
1400 r = MsiOpenPackage(name, &hpack);
1401 ok(r == ERROR_SUCCESS, "failed to open package with no name\n");
1402 r = MsiCloseHandle(hpack);
1403 ok(r == ERROR_SUCCESS, "failed to close package\n");
1406 /* just MsiOpenDatabase should not create a file */
1407 r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
1408 ok(r == ERROR_SUCCESS, "MsiOpenDatabase failed\n");
1412 r = MsiOpenPackage(name, &hpack);
1413 ok(r == ERROR_INVALID_HANDLE, "MsiOpenPackage returned wrong code\n");
1416 /* now try again with our empty database */
1417 sprintf(name, "#%ld", hdb);
1418 r = MsiOpenPackage(name, &hpack);
1419 ok(r == ERROR_INSTALL_PACKAGE_INVALID, "MsiOpenPackage returned wrong code\n");
1420 if (!r) MsiCloseHandle(hpack);
1423 /* create a table */
1424 query = "CREATE TABLE `Property` ( "
1425 "`Property` CHAR(72), `Value` CHAR(0) "
1426 "PRIMARY KEY `Property`)";
1427 r = try_query(hdb, query);
1428 ok(r == ERROR_SUCCESS, "failed to create Properties table\n");
1431 query = "CREATE TABLE `InstallExecuteSequence` ("
1432 "`Action` CHAR(72), `Condition` CHAR(0), `Sequence` INTEGER "
1433 "PRIMARY KEY `Action`)";
1434 r = try_query(hdb, query);
1435 ok(r == ERROR_SUCCESS, "failed to create InstallExecuteSequence table\n");
1437 sprintf(name, "#%ld", hdb);
1438 r = MsiOpenPackage(name, &hpack);
1439 ok(r == ERROR_INSTALL_PACKAGE_INVALID, "MsiOpenPackage returned wrong code\n");
1440 if (!r) MsiCloseHandle(hpack);
1443 r = MsiCloseHandle(hdb);
1444 ok(r == ERROR_SUCCESS, "MsiCloseHandle(database) failed\n");
1445 DeleteFile(msifile);
1448 static void test_formatrecord2(void)
1450 MSIHANDLE hpkg, hrec ;
1455 hpkg = package_from_db(create_package_db());
1456 ok( hpkg, "failed to create package\n");
1458 r = MsiSetProperty(hpkg, "Manufacturer", " " );
1459 ok( r == ERROR_SUCCESS, "set property failed\n");
1461 hrec = MsiCreateRecord(2);
1462 ok(hrec, "create record failed\n");
1464 r = MsiRecordSetString( hrec, 0, "[ProgramFilesFolder][Manufacturer]\\asdf");
1465 ok( r == ERROR_SUCCESS, "format record failed\n");
1469 r = MsiFormatRecord( hpkg, hrec, buffer, &sz );
1471 r = MsiRecordSetString(hrec, 0, "[foo][1]");
1472 r = MsiRecordSetString(hrec, 1, "hoo");
1474 r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
1475 ok( sz == 3, "size wrong\n");
1476 ok( 0 == strcmp(buffer,"hoo"), "wrong output %s\n",buffer);
1477 ok( r == ERROR_SUCCESS, "format failed\n");
1479 r = MsiRecordSetString(hrec, 0, "x[~]x");
1481 r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
1482 ok( sz == 3, "size wrong\n");
1483 ok( 0 == strcmp(buffer,"x"), "wrong output %s\n",buffer);
1484 ok( r == ERROR_SUCCESS, "format failed\n");
1486 r = MsiRecordSetString(hrec, 0, "[foo.$%}][1]");
1487 r = MsiRecordSetString(hrec, 1, "hoo");
1489 r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
1490 ok( sz == 3, "size wrong\n");
1491 ok( 0 == strcmp(buffer,"hoo"), "wrong output %s\n",buffer);
1492 ok( r == ERROR_SUCCESS, "format failed\n");
1494 r = MsiRecordSetString(hrec, 0, "[\\[]");
1496 r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
1497 ok( sz == 1, "size wrong\n");
1498 ok( 0 == strcmp(buffer,"["), "wrong output %s\n",buffer);
1499 ok( r == ERROR_SUCCESS, "format failed\n");
1501 SetEnvironmentVariable("FOO", "BAR");
1502 r = MsiRecordSetString(hrec, 0, "[%FOO]");
1504 r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
1505 ok( sz == 3, "size wrong\n");
1506 ok( 0 == strcmp(buffer,"BAR"), "wrong output %s\n",buffer);
1507 ok( r == ERROR_SUCCESS, "format failed\n");
1509 r = MsiRecordSetString(hrec, 0, "[[1]]");
1510 r = MsiRecordSetString(hrec, 1, "%FOO");
1512 r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
1513 ok( sz == 3, "size wrong\n");
1514 ok( 0 == strcmp(buffer,"BAR"), "wrong output %s\n",buffer);
1515 ok( r == ERROR_SUCCESS, "format failed\n");
1517 MsiCloseHandle( hrec );
1518 MsiCloseHandle( hpkg );
1519 DeleteFile(msifile);
1522 static void test_states(void)
1527 INSTALLSTATE state, action;
1529 hdb = create_package_db();
1530 ok ( hdb, "failed to create package database\n" );
1532 r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
1533 ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
1535 r = create_feature_table( hdb );
1536 ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
1538 r = create_component_table( hdb );
1539 ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
1541 /* msidbFeatureAttributesFavorLocal */
1542 r = add_feature_entry( hdb, "'one', '', '', '', 2, 1, '', 0" );
1543 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
1545 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
1546 r = add_component_entry( hdb, "'alpha', '{467EC132-739D-4784-A37B-677AA43DBC94}', 'TARGETDIR', 0, '', 'alpha_file'" );
1547 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
1549 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
1550 r = add_component_entry( hdb, "'beta', '{2C1F189C-24A6-4C34-B26B-994A6C026506}', 'TARGETDIR', 1, '', 'beta_file'" );
1551 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
1553 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
1554 r = add_component_entry( hdb, "'gamma', '{C271E2A4-DE2E-4F70-86D1-6984AF7DE2CA}', 'TARGETDIR', 2, '', 'gamma_file'" );
1555 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
1557 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSharedDllRefCount */
1558 r = add_component_entry( hdb, "'theta', '{4EB3129D-81A8-48D5-9801-75600FED3DD9}', 'TARGETDIR', 8, '', 'theta_file'" );
1559 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
1561 /* msidbFeatureAttributesFavorSource */
1562 r = add_feature_entry( hdb, "'two', '', '', '', 2, 1, '', 1" );
1563 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
1565 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
1566 r = add_component_entry( hdb, "'delta', '{938FD4F2-C648-4259-A03C-7AA3B45643F3}', 'TARGETDIR', 0, '', 'delta_file'" );
1567 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
1569 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
1570 r = add_component_entry( hdb, "'epsilon', '{D59713B6-C11D-47F2-A395-1E5321781190}', 'TARGETDIR', 1, '', 'epsilon_file'" );
1571 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
1573 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
1574 r = add_component_entry( hdb, "'zeta', '{377D33AB-2FAA-42B9-A629-0C0DAE9B9C7A}', 'TARGETDIR', 2, '', 'zeta_file'" );
1575 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
1577 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSharedDllRefCount */
1578 r = add_component_entry( hdb, "'iota', '{5D36F871-B5ED-4801-9E0F-C46B9E5C9669}', 'TARGETDIR', 8, '', 'iota_file'" );
1579 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
1581 /* msidbFeatureAttributesFavorSource */
1582 r = add_feature_entry( hdb, "'three', '', '', '', 2, 1, '', 1" );
1583 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
1585 /* msidbFeatureAttributesFavorLocal */
1586 r = add_feature_entry( hdb, "'four', '', '', '', 2, 1, '', 0" );
1587 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
1590 r = add_feature_entry( hdb, "'five', '', '', '', 2, 0, '', 1" );
1591 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
1593 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
1594 r = add_component_entry( hdb, "'eta', '{DD89003F-0DD4-41B8-81C0-3411A7DA2695}', 'TARGETDIR', 1, '', 'eta_file'" );
1595 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
1597 r = create_feature_components_table( hdb );
1598 ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
1600 r = add_feature_components_entry( hdb, "'one', 'alpha'" );
1601 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
1603 r = add_feature_components_entry( hdb, "'one', 'beta'" );
1604 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
1606 r = add_feature_components_entry( hdb, "'one', 'gamma'" );
1607 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
1609 r = add_feature_components_entry( hdb, "'one', 'theta'" );
1610 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
1612 r = add_feature_components_entry( hdb, "'two', 'delta'" );
1613 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
1615 r = add_feature_components_entry( hdb, "'two', 'epsilon'" );
1616 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
1618 r = add_feature_components_entry( hdb, "'two', 'zeta'" );
1619 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
1621 r = add_feature_components_entry( hdb, "'two', 'iota'" );
1622 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
1624 r = add_feature_components_entry( hdb, "'three', 'eta'" );
1625 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
1627 r = add_feature_components_entry( hdb, "'four', 'eta'" );
1628 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
1630 r = add_feature_components_entry( hdb, "'five', 'eta'" );
1631 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
1633 r = create_file_table( hdb );
1634 ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
1636 r = add_file_entry( hdb, "'alpha_file', 'alpha', 'alpha.txt', 100, '', '1033', 8192, 1" );
1637 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
1639 r = add_file_entry( hdb, "'beta_file', 'beta', 'beta.txt', 0, '', '1033', 8192, 1" );
1640 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
1642 r = add_file_entry( hdb, "'gamma_file', 'gamma', 'gamma.txt', 0, '', '1033', 8192, 1" );
1643 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
1645 r = add_file_entry( hdb, "'theta_file', 'theta', 'theta.txt', 0, '', '1033', 8192, 1" );
1646 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
1648 r = add_file_entry( hdb, "'delta_file', 'delta', 'delta.txt', 0, '', '1033', 8192, 1" );
1649 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
1651 r = add_file_entry( hdb, "'epsilon_file', 'epsilon', 'epsilon.txt', 0, '', '1033', 8192, 1" );
1652 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
1654 r = add_file_entry( hdb, "'zeta_file', 'zeta', 'zeta.txt', 0, '', '1033', 8192, 1" );
1655 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
1657 r = add_file_entry( hdb, "'iota_file', 'iota', 'iota.txt', 0, '', '1033', 8192, 1" );
1658 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
1660 /* compressed file */
1661 r = add_file_entry( hdb, "'eta_file', 'eta', 'eta.txt', 0, '', '1033', 16384, 1" );
1662 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
1664 hpkg = package_from_db( hdb );
1665 ok( hpkg, "failed to create package\n");
1669 r = MsiGetFeatureState(hpkg, "one", &state, &action);
1670 ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
1671 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
1672 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
1676 r = MsiGetFeatureState(hpkg, "two", &state, &action);
1677 ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
1678 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
1679 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
1683 r = MsiGetFeatureState(hpkg, "three", &state, &action);
1684 ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
1685 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
1686 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
1690 r = MsiGetFeatureState(hpkg, "four", &state, &action);
1691 ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
1692 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
1693 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
1697 r = MsiGetFeatureState(hpkg, "five", &state, &action);
1698 ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
1699 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
1700 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
1704 r = MsiGetComponentState(hpkg, "alpha", &state, &action);
1705 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
1706 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
1707 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
1711 r = MsiGetComponentState(hpkg, "beta", &state, &action);
1712 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
1713 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
1714 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
1718 r = MsiGetComponentState(hpkg, "gamma", &state, &action);
1719 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
1720 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
1721 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
1725 r = MsiGetComponentState(hpkg, "theta", &state, &action);
1726 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
1727 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
1728 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
1732 r = MsiGetComponentState(hpkg, "delta", &state, &action);
1733 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
1734 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
1735 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
1739 r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
1740 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
1741 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
1742 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
1746 r = MsiGetComponentState(hpkg, "zeta", &state, &action);
1747 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
1748 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
1749 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
1753 r = MsiGetComponentState(hpkg, "iota", &state, &action);
1754 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
1755 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
1756 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
1760 r = MsiGetComponentState(hpkg, "eta", &state, &action);
1761 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
1762 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
1763 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
1765 r = MsiDoAction( hpkg, "CostInitialize");
1766 ok( r == ERROR_SUCCESS, "cost init failed\n");
1770 r = MsiGetFeatureState(hpkg, "one", &state, &action);
1771 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
1772 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1773 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
1777 r = MsiGetFeatureState(hpkg, "two", &state, &action);
1778 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
1779 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1780 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
1784 r = MsiGetFeatureState(hpkg, "three", &state, &action);
1785 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
1786 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1787 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
1791 r = MsiGetFeatureState(hpkg, "four", &state, &action);
1792 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
1793 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1794 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
1798 r = MsiGetFeatureState(hpkg, "five", &state, &action);
1799 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
1800 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1801 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
1805 r = MsiGetComponentState(hpkg, "alpha", &state, &action);
1806 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
1807 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1808 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
1812 r = MsiGetComponentState(hpkg, "beta", &state, &action);
1813 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
1814 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1815 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
1819 r = MsiGetComponentState(hpkg, "gamma", &state, &action);
1820 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
1821 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1822 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
1826 r = MsiGetComponentState(hpkg, "theta", &state, &action);
1827 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
1828 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1829 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
1833 r = MsiGetComponentState(hpkg, "delta", &state, &action);
1834 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
1835 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1836 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
1840 r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
1841 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
1842 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1843 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
1847 r = MsiGetComponentState(hpkg, "zeta", &state, &action);
1848 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
1849 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1850 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
1854 r = MsiGetComponentState(hpkg, "iota", &state, &action);
1855 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
1856 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1857 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
1861 r = MsiGetComponentState(hpkg, "eta", &state, &action);
1862 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
1863 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1864 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
1866 r = MsiDoAction( hpkg, "FileCost");
1867 ok( r == ERROR_SUCCESS, "file cost failed\n");
1871 r = MsiGetFeatureState(hpkg, "one", &state, &action);
1872 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
1873 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1874 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
1878 r = MsiGetFeatureState(hpkg, "two", &state, &action);
1879 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
1880 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1881 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
1885 r = MsiGetFeatureState(hpkg, "three", &state, &action);
1886 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
1887 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1888 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
1892 r = MsiGetFeatureState(hpkg, "four", &state, &action);
1893 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
1894 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1895 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
1899 r = MsiGetFeatureState(hpkg, "five", &state, &action);
1900 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
1901 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1902 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
1906 r = MsiGetComponentState(hpkg, "alpha", &state, &action);
1907 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
1908 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1909 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
1913 r = MsiGetComponentState(hpkg, "beta", &state, &action);
1914 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
1915 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1916 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
1920 r = MsiGetComponentState(hpkg, "gamma", &state, &action);
1921 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
1922 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1923 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
1927 r = MsiGetComponentState(hpkg, "theta", &state, &action);
1928 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
1929 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1930 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
1934 r = MsiGetComponentState(hpkg, "delta", &state, &action);
1935 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
1936 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1937 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
1941 r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
1942 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
1943 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1944 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
1948 r = MsiGetComponentState(hpkg, "zeta", &state, &action);
1949 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
1950 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1951 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
1955 r = MsiGetComponentState(hpkg, "iota", &state, &action);
1956 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
1957 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1958 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
1962 r = MsiGetComponentState(hpkg, "eta", &state, &action);
1963 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
1964 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1965 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
1967 r = MsiDoAction( hpkg, "CostFinalize");
1968 ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
1972 r = MsiGetFeatureState(hpkg, "one", &state, &action);
1973 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
1974 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
1975 ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
1979 r = MsiGetFeatureState(hpkg, "two", &state, &action);
1980 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
1981 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
1982 ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
1986 r = MsiGetFeatureState(hpkg, "three", &state, &action);
1987 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
1988 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
1989 ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
1993 r = MsiGetFeatureState(hpkg, "four", &state, &action);
1994 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
1995 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
1996 ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
2000 r = MsiGetFeatureState(hpkg, "five", &state, &action);
2001 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2002 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2003 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2007 r = MsiGetComponentState(hpkg, "alpha", &state, &action);
2008 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2009 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2010 ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
2014 r = MsiGetComponentState(hpkg, "beta", &state, &action);
2015 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2016 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2017 ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
2021 r = MsiGetComponentState(hpkg, "gamma", &state, &action);
2022 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2023 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2024 ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
2028 r = MsiGetComponentState(hpkg, "theta", &state, &action);
2029 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2030 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2031 ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
2035 r = MsiGetComponentState(hpkg, "delta", &state, &action);
2036 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2037 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2038 ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
2042 r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
2043 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2044 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2045 ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
2049 r = MsiGetComponentState(hpkg, "zeta", &state, &action);
2050 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2051 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2052 ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
2056 r = MsiGetComponentState(hpkg, "iota", &state, &action);
2057 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2058 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2059 ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
2063 r = MsiGetComponentState(hpkg, "eta", &state, &action);
2064 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2065 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2066 ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
2068 MsiCloseHandle( hpkg );
2071 static void test_getproperty(void)
2073 MSIHANDLE hPackage = 0;
2075 static CHAR empty[] = "";
2079 hPackage = package_from_db(create_package_db());
2080 ok( hPackage != 0, " Failed to create package\n");
2082 /* set the property */
2083 r = MsiSetProperty(hPackage, "Name", "Value");
2084 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2086 /* retrieve the size, NULL pointer */
2088 r = MsiGetProperty(hPackage, "Name", NULL, &size);
2089 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2090 ok( size == 5, "Expected 5, got %ld\n", size);
2092 /* retrieve the size, empty string */
2094 r = MsiGetProperty(hPackage, "Name", empty, &size);
2095 ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
2096 ok( size == 5, "Expected 5, got %ld\n", size);
2098 /* don't change size */
2099 r = MsiGetProperty(hPackage, "Name", prop, &size);
2100 ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
2101 ok( size == 5, "Expected 5, got %ld\n", size);
2102 ok( !lstrcmp(prop, "Valu"), "Expected Valu, got %s\n", prop);
2104 /* increase the size by 1 */
2106 r = MsiGetProperty(hPackage, "Name", prop, &size);
2107 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2108 ok( size == 5, "Expected 5, got %ld\n", size);
2109 ok( !lstrcmp(prop, "Value"), "Expected Value, got %s\n", prop);
2111 r = MsiCloseHandle( hPackage);
2112 ok( r == ERROR_SUCCESS , "Failed to close package\n" );
2113 DeleteFile(msifile);
2116 static void test_removefiles(void)
2121 char CURR_DIR[MAX_PATH];
2123 GetCurrentDirectoryA(MAX_PATH, CURR_DIR);
2125 hdb = create_package_db();
2126 ok ( hdb, "failed to create package database\n" );
2128 r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
2129 ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
2131 r = create_feature_table( hdb );
2132 ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
2134 r = create_component_table( hdb );
2135 ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
2137 r = add_feature_entry( hdb, "'one', '', '', '', 2, 1, '', 0" );
2138 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2140 r = add_component_entry( hdb, "'hydrogen', '', 'TARGETDIR', 0, '', 'hydrogen_file'" );
2141 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2143 r = add_component_entry( hdb, "'helium', '', 'TARGETDIR', 0, '', 'helium_file'" );
2144 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2146 r = add_component_entry( hdb, "'lithium', '', 'TARGETDIR', 0, '', 'lithium_file'" );
2147 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2149 r = add_component_entry( hdb, "'beryllium', '', 'TARGETDIR', 0, '', 'beryllium_file'" );
2150 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2152 r = add_component_entry( hdb, "'boron', '', 'TARGETDIR', 0, '', 'boron_file'" );
2153 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2155 r = add_component_entry( hdb, "'carbon', '', 'TARGETDIR', 0, '', 'carbon_file'" );
2156 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2158 r = create_feature_components_table( hdb );
2159 ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
2161 r = add_feature_components_entry( hdb, "'one', 'hydrogen'" );
2162 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2164 r = add_feature_components_entry( hdb, "'one', 'helium'" );
2165 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2167 r = add_feature_components_entry( hdb, "'one', 'lithium'" );
2168 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2170 r = add_feature_components_entry( hdb, "'one', 'beryllium'" );
2171 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2173 r = add_feature_components_entry( hdb, "'one', 'boron'" );
2174 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2176 r = add_feature_components_entry( hdb, "'one', 'carbon'" );
2177 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2179 r = create_file_table( hdb );
2180 ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
2182 r = add_file_entry( hdb, "'hydrogen_file', 'hydrogen', 'hydrogen.txt', 0, '', '1033', 8192, 1" );
2183 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2185 r = add_file_entry( hdb, "'helium_file', 'helium', 'helium.txt', 0, '', '1033', 8192, 1" );
2186 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2188 r = add_file_entry( hdb, "'lithium_file', 'lithium', 'lithium.txt', 0, '', '1033', 8192, 1" );
2189 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2191 r = add_file_entry( hdb, "'beryllium_file', 'beryllium', 'beryllium.txt', 0, '', '1033', 16384, 1" );
2192 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2194 r = add_file_entry( hdb, "'boron_file', 'boron', 'boron.txt', 0, '', '1033', 16384, 1" );
2195 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2197 r = add_file_entry( hdb, "'carbon_file', 'carbon', 'carbon.txt', 0, '', '1033', 16384, 1" );
2198 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2200 r = create_remove_file_table( hdb );
2201 ok( r == ERROR_SUCCESS, "cannot create Remove File table: %d\n", r);
2203 hpkg = package_from_db( hdb );
2204 ok( hpkg, "failed to create package\n");
2206 create_test_file( "hydrogen.txt" );
2207 create_test_file( "helium.txt" );
2208 create_test_file( "lithium.txt" );
2209 create_test_file( "beryllium.txt" );
2210 create_test_file( "boron.txt" );
2211 create_test_file( "carbon.txt" );
2213 r = MsiSetProperty( hpkg, "TARGETDIR", CURR_DIR );
2214 ok( r == ERROR_SUCCESS, "set property failed\n");
2216 r = MsiDoAction( hpkg, "CostInitialize");
2217 ok( r == ERROR_SUCCESS, "cost init failed\n");
2219 r = MsiDoAction( hpkg, "FileCost");
2220 ok( r == ERROR_SUCCESS, "cost finalize failed\n");
2222 r = MsiDoAction( hpkg, "CostFinalize");
2223 ok( r == ERROR_SUCCESS, "cost finalize failed\n");
2225 r = MsiDoAction( hpkg, "InstallValidate");
2226 ok( r == ERROR_SUCCESS, "cost finalize failed\n");
2228 r = MsiSetComponentState( hpkg, "hydrogen", INSTALLSTATE_ABSENT );
2229 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
2231 r = MsiSetComponentState( hpkg, "helium", INSTALLSTATE_LOCAL );
2232 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
2234 r = MsiSetComponentState( hpkg, "lithium", INSTALLSTATE_SOURCE );
2235 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
2237 r = MsiSetComponentState( hpkg, "beryllium", INSTALLSTATE_ABSENT );
2238 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
2240 r = MsiSetComponentState( hpkg, "boron", INSTALLSTATE_LOCAL );
2241 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
2243 r = MsiSetComponentState( hpkg, "carbon", INSTALLSTATE_SOURCE );
2244 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
2246 r = MsiDoAction( hpkg, "RemoveFiles");
2247 ok( r == ERROR_SUCCESS, "remove files failed\n");
2249 ok(DeleteFileA("hydrogen.txt"), "Expected hydrogen.txt to exist\n");
2250 ok(DeleteFileA("lithium.txt"), "Expected lithium.txt to exist\n");
2251 ok(DeleteFileA("beryllium.txt"), "Expected beryllium.txt to exist\n");
2252 ok(DeleteFileA("carbon.txt"), "Expected carbon.txt to exist\n");
2253 ok(DeleteFileA("helium.txt"), "Expected helium.txt to exist\n");
2254 ok(DeleteFileA("boron.txt"), "Expected boron.txt to exist\n");
2256 MsiCloseHandle( hpkg );
2257 DeleteFileA(msifile);
2260 static void test_appsearch(void)
2265 CHAR prop[MAX_PATH];
2266 DWORD size = MAX_PATH;
2268 hdb = create_package_db();
2269 ok ( hdb, "failed to create package database\n" );
2271 r = create_appsearch_table( hdb );
2272 ok( r == ERROR_SUCCESS, "cannot create AppSearch table: %d\n", r );
2274 r = add_appsearch_entry( hdb, "'WEBBROWSERPROG', 'NewSignature1'" );
2275 ok( r == ERROR_SUCCESS, "cannot add entry: %d\n", r );
2277 r = create_reglocator_table( hdb );
2278 ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
2280 r = add_reglocator_entry( hdb, "'NewSignature1', 0, 'htmlfile\\shell\\open\\command', '', 1" );
2281 ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
2283 r = create_signature_table( hdb );
2284 ok( r == ERROR_SUCCESS, "cannot create Signature table: %d\n", r );
2286 r = add_signature_entry( hdb, "'NewSignature1', 'FileName', '', '', '', '', '', '', ''" );
2287 ok( r == ERROR_SUCCESS, "cannot create Signature table: %d\n", r );
2289 hpkg = package_from_db( hdb );
2290 ok( hpkg, "failed to create package\n");
2292 r = MsiDoAction( hpkg, "AppSearch" );
2293 ok( r == ERROR_SUCCESS, "AppSearch failed: %d\n", r);
2295 r = MsiGetPropertyA( hpkg, "WEBBROWSERPROG", prop, &size );
2296 ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
2299 ok( lstrlenA(prop) != 0, "Expected non-zero length\n");
2302 MsiCloseHandle( hpkg );
2303 DeleteFileA(msifile);
2306 static void test_featureparents(void)
2311 INSTALLSTATE state, action;
2313 hdb = create_package_db();
2314 ok ( hdb, "failed to create package database\n" );
2316 r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
2317 ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
2319 r = create_feature_table( hdb );
2320 ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
2322 r = create_component_table( hdb );
2323 ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
2325 r = create_feature_components_table( hdb );
2326 ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
2328 r = create_file_table( hdb );
2329 ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
2331 /* msidbFeatureAttributesFavorLocal */
2332 r = add_feature_entry( hdb, "'zodiac', '', '', '', 2, 1, '', 0" );
2333 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2335 /* msidbFeatureAttributesFavorSource */
2336 r = add_feature_entry( hdb, "'perseus', '', '', '', 2, 1, '', 1" );
2337 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2339 /* msidbFeatureAttributesFavorLocal */
2340 r = add_feature_entry( hdb, "'orion', '', '', '', 2, 1, '', 0" );
2341 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2343 /* disabled because of install level */
2344 r = add_feature_entry( hdb, "'waters', '', '', '', 15, 101, '', 9" );
2345 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2347 /* child feature of disabled feature */
2348 r = add_feature_entry( hdb, "'bayer', 'waters', '', '', 14, 1, '', 9" );
2349 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2351 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
2352 r = add_component_entry( hdb, "'leo', '', 'TARGETDIR', 0, '', 'leo_file'" );
2353 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2355 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
2356 r = add_component_entry( hdb, "'virgo', '', 'TARGETDIR', 1, '', 'virgo_file'" );
2357 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2359 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
2360 r = add_component_entry( hdb, "'libra', '', 'TARGETDIR', 2, '', 'libra_file'" );
2361 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2363 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
2364 r = add_component_entry( hdb, "'cassiopeia', '', 'TARGETDIR', 0, '', 'cassiopeia_file'" );
2365 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2367 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
2368 r = add_component_entry( hdb, "'cepheus', '', 'TARGETDIR', 1, '', 'cepheus_file'" );
2369 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2371 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
2372 r = add_component_entry( hdb, "'andromeda', '', 'TARGETDIR', 2, '', 'andromeda_file'" );
2373 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2375 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
2376 r = add_component_entry( hdb, "'canis', '', 'TARGETDIR', 0, '', 'canis_file'" );
2377 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2379 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
2380 r = add_component_entry( hdb, "'monoceros', '', 'TARGETDIR', 1, '', 'monoceros_file'" );
2381 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2383 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
2384 r = add_component_entry( hdb, "'lepus', '', 'TARGETDIR', 2, '', 'lepus_file'" );
2386 r = add_feature_components_entry( hdb, "'zodiac', 'leo'" );
2387 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2389 r = add_feature_components_entry( hdb, "'zodiac', 'virgo'" );
2390 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2392 r = add_feature_components_entry( hdb, "'zodiac', 'libra'" );
2393 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2395 r = add_feature_components_entry( hdb, "'perseus', 'cassiopeia'" );
2396 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2398 r = add_feature_components_entry( hdb, "'perseus', 'cepheus'" );
2399 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2401 r = add_feature_components_entry( hdb, "'perseus', 'andromeda'" );
2402 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2404 r = add_feature_components_entry( hdb, "'orion', 'leo'" );
2405 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2407 r = add_feature_components_entry( hdb, "'orion', 'virgo'" );
2408 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2410 r = add_feature_components_entry( hdb, "'orion', 'libra'" );
2411 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2413 r = add_feature_components_entry( hdb, "'orion', 'cassiopeia'" );
2414 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2416 r = add_feature_components_entry( hdb, "'orion', 'cepheus'" );
2417 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2419 r = add_feature_components_entry( hdb, "'orion', 'andromeda'" );
2420 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2422 r = add_feature_components_entry( hdb, "'orion', 'canis'" );
2423 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2425 r = add_feature_components_entry( hdb, "'orion', 'monoceros'" );
2426 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2428 r = add_feature_components_entry( hdb, "'orion', 'lepus'" );
2429 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2431 r = add_file_entry( hdb, "'leo_file', 'leo', 'leo.txt', 100, '', '1033', 8192, 1" );
2432 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2434 r = add_file_entry( hdb, "'virgo_file', 'virgo', 'virgo.txt', 0, '', '1033', 8192, 1" );
2435 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2437 r = add_file_entry( hdb, "'libra_file', 'libra', 'libra.txt', 0, '', '1033', 8192, 1" );
2438 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2440 r = add_file_entry( hdb, "'cassiopeia_file', 'cassiopeia', 'cassiopeia.txt', 0, '', '1033', 8192, 1" );
2441 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2443 r = add_file_entry( hdb, "'cepheus_file', 'cepheus', 'cepheus.txt', 0, '', '1033', 8192, 1" );
2444 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2446 r = add_file_entry( hdb, "'andromeda_file', 'andromeda', 'andromeda.txt', 0, '', '1033', 8192, 1" );
2447 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2449 r = add_file_entry( hdb, "'canis_file', 'canis', 'canis.txt', 0, '', '1033', 8192, 1" );
2450 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2452 r = add_file_entry( hdb, "'monoceros_file', 'monoceros', 'monoceros.txt', 0, '', '1033', 8192, 1" );
2453 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2455 r = add_file_entry( hdb, "'lepus_file', 'lepus', 'lepus.txt', 0, '', '1033', 8192, 1" );
2456 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2458 hpkg = package_from_db( hdb );
2459 ok( hpkg, "failed to create package\n");
2461 r = MsiDoAction( hpkg, "CostInitialize");
2462 ok( r == ERROR_SUCCESS, "cost init failed\n");
2464 r = MsiDoAction( hpkg, "FileCost");
2465 ok( r == ERROR_SUCCESS, "file cost failed\n");
2467 r = MsiDoAction( hpkg, "CostFinalize");
2468 ok( r == ERROR_SUCCESS, "cost finalize failed\n");
2472 r = MsiGetFeatureState(hpkg, "zodiac", &state, &action);
2473 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2474 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2475 ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
2479 r = MsiGetFeatureState(hpkg, "perseus", &state, &action);
2480 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2481 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2482 ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
2486 r = MsiGetFeatureState(hpkg, "orion", &state, &action);
2487 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2488 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2489 ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
2493 r = MsiGetFeatureState(hpkg, "waters", &state, &action);
2494 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2495 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2496 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2500 r = MsiGetFeatureState(hpkg, "bayer", &state, &action);
2501 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2502 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2503 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2507 r = MsiGetComponentState(hpkg, "leo", &state, &action);
2508 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2509 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2510 ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
2514 r = MsiGetComponentState(hpkg, "virgo", &state, &action);
2515 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2516 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2517 ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
2521 r = MsiGetComponentState(hpkg, "libra", &state, &action);
2522 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2523 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2524 ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
2528 r = MsiGetComponentState(hpkg, "cassiopeia", &state, &action);
2529 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2530 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2531 ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
2535 r = MsiGetComponentState(hpkg, "cepheus", &state, &action);
2536 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2537 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2538 ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
2542 r = MsiGetComponentState(hpkg, "andromeda", &state, &action);
2543 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2544 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2545 ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
2549 r = MsiGetComponentState(hpkg, "canis", &state, &action);
2550 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2551 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2552 ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
2556 r = MsiGetComponentState(hpkg, "monoceros", &state, &action);
2557 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2558 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2559 ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
2563 r = MsiGetComponentState(hpkg, "lepus", &state, &action);
2564 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2565 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2566 ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
2568 r = MsiSetFeatureState(hpkg, "orion", INSTALLSTATE_ABSENT);
2569 ok( r == ERROR_SUCCESS, "failed to set feature state: %d\n", r);
2573 r = MsiGetFeatureState(hpkg, "zodiac", &state, &action);
2574 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2575 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2576 ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
2580 r = MsiGetFeatureState(hpkg, "perseus", &state, &action);
2581 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2582 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2583 ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
2587 r = MsiGetFeatureState(hpkg, "orion", &state, &action);
2588 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2589 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2590 ok( action == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", action);
2594 r = MsiGetComponentState(hpkg, "leo", &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_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
2601 r = MsiGetComponentState(hpkg, "virgo", &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);
2606 ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
2611 r = MsiGetComponentState(hpkg, "libra", &state, &action);
2612 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2613 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2614 ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
2618 r = MsiGetComponentState(hpkg, "cassiopeia", &state, &action);
2619 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2620 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2623 ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
2628 r = MsiGetComponentState(hpkg, "cepheus", &state, &action);
2629 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2630 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2631 ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
2635 r = MsiGetComponentState(hpkg, "andromeda", &state, &action);
2636 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2637 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2638 ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
2642 r = MsiGetComponentState(hpkg, "canis", &state, &action);
2643 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2644 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2647 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2652 r = MsiGetComponentState(hpkg, "monoceros", &state, &action);
2653 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2654 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2657 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2662 r = MsiGetComponentState(hpkg, "lepus", &state, &action);
2663 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2664 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2667 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2670 MsiCloseHandle(hpkg);
2673 static void test_installprops(void)
2675 MSIHANDLE hpkg, hdb;
2676 CHAR path[MAX_PATH];
2681 GetCurrentDirectory(MAX_PATH, path);
2682 lstrcat(path, "\\");
2683 lstrcat(path, msifile);
2685 hdb = create_package_db();
2686 ok( hdb, "failed to create database\n");
2688 hpkg = package_from_db(hdb);
2689 ok( hpkg, "failed to create package\n");
2691 MsiCloseHandle(hdb);
2694 r = MsiGetProperty(hpkg, "DATABASE", buf, &size);
2695 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
2696 ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
2701 test_createpackage();
2702 test_getsourcepath_bad();
2703 test_getsourcepath();
2705 test_gettargetpath_bad();
2706 test_settargetpath();
2710 test_formatrecord2();
2715 test_featureparents();
2716 test_installprops();