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 );
457 ok( r == ERROR_DIRECTORY, "return value wrong\n");
459 r = MsiDoAction( hpkg, "CostInitialize");
460 ok( r == ERROR_SUCCESS, "cost init failed\n");
461 r = MsiDoAction( hpkg, "CostFinalize");
462 ok( r == ERROR_SUCCESS, "cost finalize failed\n");
464 sz = sizeof buffer -1;
466 r = MsiGetSourcePath( hpkg, "TARGETDIR", buffer, &sz );
467 ok( r == ERROR_SUCCESS, "return value wrong\n");
468 ok( sz == strlen(buffer), "returned length wrong\n");
471 strcpy(buffer,"x bad");
472 r = MsiGetSourcePath( hpkg, "TARGETDIR", buffer, &sz );
473 ok( r == ERROR_MORE_DATA, "return value wrong\n");
474 ok( buffer[0] == 'x', "buffer modified\n");
476 r = MsiGetSourcePath( hpkg, "TARGETDIR", NULL, NULL );
477 ok( r == ERROR_SUCCESS, "return value wrong\n");
479 r = MsiGetSourcePath( hpkg, "TARGETDIR ", NULL, NULL );
480 ok( r == ERROR_DIRECTORY, "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", buffer, NULL );
486 ok( r == ERROR_INVALID_PARAMETER, "return value wrong\n");
488 r = MsiGetSourcePath( hpkg, "TARGETDIR", NULL, &sz );
489 ok( r == ERROR_SUCCESS, "return value wrong\n");
491 MsiCloseHandle( hpkg );
495 static void test_doaction( void )
500 r = MsiDoAction( -1, NULL );
501 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
503 hpkg = package_from_db(create_package_db());
504 ok( hpkg, "failed to create package\n");
506 r = MsiDoAction(hpkg, NULL);
507 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
509 r = MsiDoAction(0, "boo");
510 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
512 r = MsiDoAction(hpkg, "boo");
513 ok( r == ERROR_FUNCTION_NOT_CALLED, "wrong return val\n");
515 MsiCloseHandle( hpkg );
519 static void test_gettargetpath_bad(void)
526 hpkg = package_from_db(create_package_db());
527 ok( hpkg, "failed to create package\n");
529 r = MsiGetTargetPath( 0, NULL, NULL, NULL );
530 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
532 r = MsiGetTargetPath( 0, NULL, NULL, &sz );
533 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
535 r = MsiGetTargetPath( 0, "boo", NULL, NULL );
536 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
538 r = MsiGetTargetPath( 0, "boo", NULL, NULL );
539 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
541 r = MsiGetTargetPath( hpkg, "boo", NULL, NULL );
542 ok( r == ERROR_DIRECTORY, "wrong return val\n");
544 r = MsiGetTargetPath( hpkg, "boo", buffer, NULL );
545 ok( r == ERROR_DIRECTORY, "wrong return val\n");
547 MsiCloseHandle( hpkg );
551 static void query_file_path(MSIHANDLE hpkg, LPCSTR file, LPSTR buff)
557 rec = MsiCreateRecord( 1 );
558 ok(rec, "MsiCreate record failed\n");
560 r = MsiRecordSetString( rec, 0, file );
561 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
564 r = MsiFormatRecord( hpkg, rec, buff, &size );
565 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
567 MsiCloseHandle( rec );
570 static void test_settargetpath(void)
572 char tempdir[MAX_PATH+8], buffer[MAX_PATH], file[MAX_PATH];
578 hdb = create_package_db();
579 ok ( hdb, "failed to create package database\n" );
581 r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'" );
582 ok( r == S_OK, "failed to add directory entry: %d\n" , r );
584 r = create_component_table( hdb );
585 ok( r == S_OK, "cannot create Component table: %d\n", r );
587 r = add_component_entry( hdb, "'RootComp', '{83e2694d-0864-4124-9323-6d37630912a1}', 'TARGETDIR', 8, '', 'RootFile'" );
588 ok( r == S_OK, "cannot add dummy component: %d\n", r );
590 r = add_component_entry( hdb, "'TestComp', '{A3FB59C8-C293-4F7E-B8C5-F0E1D8EEE4E5}', 'TestDir', 0, '', 'TestFile'" );
591 ok( r == S_OK, "cannot add test component: %d\n", r );
593 r = create_feature_table( hdb );
594 ok( r == S_OK, "cannot create Feature table: %d\n", r );
596 r = add_feature_entry( hdb, "'TestFeature', '', '', '', 0, 1, '', 0" );
597 ok( r == ERROR_SUCCESS, "cannot add TestFeature to Feature table: %d\n", r );
599 r = create_feature_components_table( hdb );
600 ok( r == S_OK, "cannot create FeatureComponents table: %d\n", r );
602 r = add_feature_components_entry( hdb, "'TestFeature', 'RootComp'" );
603 ok( r == S_OK, "cannot insert component into FeatureComponents table: %d\n", r );
605 r = add_feature_components_entry( hdb, "'TestFeature', 'TestComp'" );
606 ok( r == S_OK, "cannot insert component into FeatureComponents table: %d\n", r );
608 add_directory_entry( hdb, "'TestParent', 'TARGETDIR', 'TestParent'" );
609 add_directory_entry( hdb, "'TestDir', 'TestParent', 'TestDir'" );
611 r = create_file_table( hdb );
612 ok( r == S_OK, "cannot create File table: %d\n", r );
614 r = add_file_entry( hdb, "'RootFile', 'RootComp', 'rootfile.txt', 0, '', '1033', 8192, 1" );
615 ok( r == S_OK, "cannot add file to the File table: %d\n", r );
617 r = add_file_entry( hdb, "'TestFile', 'TestComp', 'testfile.txt', 0, '', '1033', 8192, 1" );
618 ok( r == S_OK, "cannot add file to the File table: %d\n", r );
620 hpkg = package_from_db( hdb );
621 ok( hpkg, "failed to create package\n");
623 r = MsiDoAction( hpkg, "CostInitialize");
624 ok( r == ERROR_SUCCESS, "cost init failed\n");
626 r = MsiDoAction( hpkg, "FileCost");
627 ok( r == ERROR_SUCCESS, "file cost failed\n");
629 r = MsiDoAction( hpkg, "CostFinalize");
630 ok( r == ERROR_SUCCESS, "cost finalize failed\n");
632 r = MsiSetTargetPath( 0, NULL, NULL );
633 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
635 r = MsiSetTargetPath( 0, "boo", "C:\\bogusx" );
636 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
638 r = MsiSetTargetPath( hpkg, "boo", NULL );
639 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
641 r = MsiSetTargetPath( hpkg, "boo", "c:\\bogusx" );
642 ok( r == ERROR_DIRECTORY, "wrong return val\n");
644 sz = sizeof tempdir - 1;
645 r = MsiGetTargetPath( hpkg, "TARGETDIR", tempdir, &sz );
646 sprintf( file, "%srootfile.txt", tempdir );
647 query_file_path( hpkg, "[#RootFile]", buffer );
648 ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
649 ok( !lstrcmp(buffer, file), "Expected %s, got %s\n", file, buffer );
651 GetTempFileName( tempdir, "_wt", 0, buffer );
652 sprintf( tempdir, "%s\\subdir", buffer );
654 r = MsiSetTargetPath( hpkg, "TARGETDIR", buffer );
655 ok( r == ERROR_SUCCESS, "MsiSetTargetPath on file returned %d\n", r );
657 r = MsiSetTargetPath( hpkg, "TARGETDIR", tempdir );
658 ok( r == ERROR_SUCCESS, "MsiSetTargetPath on 'subdir' of file returned %d\n", r );
660 DeleteFile( buffer );
662 r = MsiSetTargetPath( hpkg, "TARGETDIR", buffer );
663 ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
665 r = GetFileAttributes( buffer );
666 ok ( r == INVALID_FILE_ATTRIBUTES, "file/directory exists after MsiSetTargetPath. Attributes: %08X\n", r );
668 r = MsiSetTargetPath( hpkg, "TARGETDIR", tempdir );
669 ok( r == ERROR_SUCCESS, "MsiSetTargetPath on subsubdir returned %d\n", r );
671 sz = sizeof buffer - 1;
672 lstrcat( tempdir, "\\" );
673 r = MsiGetTargetPath( hpkg, "TARGETDIR", buffer, &sz );
674 ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
675 ok( !lstrcmp(buffer, tempdir), "Expected %s, got %s\n", tempdir, buffer);
677 sprintf( file, "%srootfile.txt", tempdir );
678 query_file_path( hpkg, "[#RootFile]", buffer );
679 ok( !lstrcmp(buffer, file), "Expected %s, got %s\n", file, buffer);
681 r = MsiSetTargetPath( hpkg, "TestParent", "C:\\one\\two" );
682 ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
684 query_file_path( hpkg, "[#TestFile]", buffer );
685 ok( !lstrcmp(buffer, "C:\\one\\two\\TestDir\\testfile.txt"),
686 "Expected C:\\one\\two\\TestDir\\testfile.txt, got %s\n", buffer );
688 sz = sizeof buffer - 1;
689 r = MsiGetTargetPath( hpkg, "TestParent", buffer, &sz );
690 ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
691 ok( !lstrcmp(buffer, "C:\\one\\two\\"), "Expected C:\\one\\two\\, got %s\n", buffer);
693 MsiCloseHandle( hpkg );
696 static void test_condition(void)
701 hpkg = package_from_db(create_package_db());
702 ok( hpkg, "failed to create package\n");
704 r = MsiEvaluateCondition(0, NULL);
705 ok( r == MSICONDITION_ERROR, "wrong return val\n");
707 r = MsiEvaluateCondition(hpkg, NULL);
708 ok( r == MSICONDITION_NONE, "wrong return val\n");
710 r = MsiEvaluateCondition(hpkg, "");
711 ok( r == MSICONDITION_NONE, "wrong return val\n");
713 r = MsiEvaluateCondition(hpkg, "1");
714 ok( r == MSICONDITION_TRUE, "wrong return val\n");
716 r = MsiEvaluateCondition(hpkg, "0");
717 ok( r == MSICONDITION_FALSE, "wrong return val\n");
719 r = MsiEvaluateCondition(hpkg, "0 = 0");
720 ok( r == MSICONDITION_TRUE, "wrong return val\n");
722 r = MsiEvaluateCondition(hpkg, "0 <> 0");
723 ok( r == MSICONDITION_FALSE, "wrong return val\n");
725 r = MsiEvaluateCondition(hpkg, "0 = 1");
726 ok( r == MSICONDITION_FALSE, "wrong return val\n");
728 r = MsiEvaluateCondition(hpkg, "0 > 1");
729 ok( r == MSICONDITION_FALSE, "wrong return val\n");
731 r = MsiEvaluateCondition(hpkg, "0 ~> 1");
732 ok( r == MSICONDITION_FALSE, "wrong return val\n");
734 r = MsiEvaluateCondition(hpkg, "1 > 1");
735 ok( r == MSICONDITION_FALSE, "wrong return val\n");
737 r = MsiEvaluateCondition(hpkg, "1 ~> 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, "0 ~>= 1");
744 ok( r == MSICONDITION_FALSE, "wrong return val\n");
746 r = MsiEvaluateCondition(hpkg, "1 >= 1");
747 ok( r == MSICONDITION_TRUE, "wrong return val\n");
749 r = MsiEvaluateCondition(hpkg, "1 ~>= 1");
750 ok( r == MSICONDITION_TRUE, "wrong return val\n");
752 r = MsiEvaluateCondition(hpkg, "0 < 1");
753 ok( r == MSICONDITION_TRUE, "wrong return val\n");
755 r = MsiEvaluateCondition(hpkg, "0 ~< 1");
756 ok( r == MSICONDITION_TRUE, "wrong return val\n");
758 r = MsiEvaluateCondition(hpkg, "1 < 1");
759 ok( r == MSICONDITION_FALSE, "wrong return val\n");
761 r = MsiEvaluateCondition(hpkg, "1 ~< 1");
762 ok( r == MSICONDITION_FALSE, "wrong return val\n");
764 r = MsiEvaluateCondition(hpkg, "0 <= 1");
765 ok( r == MSICONDITION_TRUE, "wrong return val\n");
767 r = MsiEvaluateCondition(hpkg, "0 ~<= 1");
768 ok( r == MSICONDITION_TRUE, "wrong return val\n");
770 r = MsiEvaluateCondition(hpkg, "1 <= 1");
771 ok( r == MSICONDITION_TRUE, "wrong return val\n");
773 r = MsiEvaluateCondition(hpkg, "1 ~<= 1");
774 ok( r == MSICONDITION_TRUE, "wrong return val\n");
776 r = MsiEvaluateCondition(hpkg, "0 >=");
777 ok( r == MSICONDITION_ERROR, "wrong return val\n");
779 r = MsiEvaluateCondition(hpkg, " ");
780 ok( r == MSICONDITION_NONE, "wrong return val\n");
782 r = MsiEvaluateCondition(hpkg, "LicView <> \"1\"");
783 ok( r == MSICONDITION_TRUE, "wrong return val\n");
785 r = MsiEvaluateCondition(hpkg, "LicView <> \"0\"");
786 ok( r == MSICONDITION_TRUE, "wrong return val\n");
788 r = MsiEvaluateCondition(hpkg, "LicView <> LicView");
789 ok( r == MSICONDITION_FALSE, "wrong return val\n");
791 r = MsiEvaluateCondition(hpkg, "not 0");
792 ok( r == MSICONDITION_TRUE, "wrong return val\n");
794 r = MsiEvaluateCondition(hpkg, "not LicView");
795 ok( r == MSICONDITION_TRUE, "wrong return val\n");
797 r = MsiEvaluateCondition(hpkg, "not \"A\"");
798 ok( r == MSICONDITION_FALSE, "wrong return val\n");
800 r = MsiEvaluateCondition(hpkg, "~not \"A\"");
801 ok( r == MSICONDITION_ERROR, "wrong return val\n");
803 r = MsiEvaluateCondition(hpkg, "\"0\"");
804 ok( r == MSICONDITION_TRUE, "wrong return val\n");
806 r = MsiEvaluateCondition(hpkg, "1 and 2");
807 ok( r == MSICONDITION_TRUE, "wrong return val\n");
809 r = MsiEvaluateCondition(hpkg, "not 0 and 3");
810 ok( r == MSICONDITION_TRUE, "wrong return val\n");
812 r = MsiEvaluateCondition(hpkg, "not 0 and 0");
813 ok( r == MSICONDITION_FALSE, "wrong return val\n");
815 r = MsiEvaluateCondition(hpkg, "not 0 or 1");
816 ok( r == MSICONDITION_TRUE, "wrong return val\n");
818 r = MsiEvaluateCondition(hpkg, "(0)");
819 ok( r == MSICONDITION_FALSE, "wrong return val\n");
821 r = MsiEvaluateCondition(hpkg, "(((((1))))))");
822 ok( r == MSICONDITION_ERROR, "wrong return val\n");
824 r = MsiEvaluateCondition(hpkg, "(((((1)))))");
825 ok( r == MSICONDITION_TRUE, "wrong return val\n");
827 r = MsiEvaluateCondition(hpkg, " \"A\" < \"B\" ");
828 ok( r == MSICONDITION_TRUE, "wrong return val\n");
830 r = MsiEvaluateCondition(hpkg, " \"A\" > \"B\" ");
831 ok( r == MSICONDITION_FALSE, "wrong return val\n");
833 r = MsiEvaluateCondition(hpkg, " \"1\" > \"12\" ");
834 ok( r == MSICONDITION_FALSE, "wrong return val\n");
836 r = MsiEvaluateCondition(hpkg, " \"100\" < \"21\" ");
837 ok( r == MSICONDITION_TRUE, "wrong return val\n");
839 r = MsiEvaluateCondition(hpkg, "0 < > 0");
840 ok( r == MSICONDITION_ERROR, "wrong return val\n");
842 r = MsiEvaluateCondition(hpkg, "(1<<1) == 2");
843 ok( r == MSICONDITION_ERROR, "wrong return val\n");
845 r = MsiEvaluateCondition(hpkg, " \"A\" = \"a\" ");
846 ok( r == MSICONDITION_FALSE, "wrong return val\n");
848 r = MsiEvaluateCondition(hpkg, " \"A\" ~ = \"a\" ");
849 ok( r == MSICONDITION_ERROR, "wrong return val\n");
851 r = MsiEvaluateCondition(hpkg, " \"A\" ~= \"a\" ");
852 ok( r == MSICONDITION_TRUE, "wrong return val\n");
854 r = MsiEvaluateCondition(hpkg, " \"A\" ~= 1 ");
855 ok( r == MSICONDITION_FALSE, "wrong return val\n");
857 r = MsiEvaluateCondition(hpkg, " \"A\" = 1 ");
858 ok( r == MSICONDITION_FALSE, "wrong return val\n");
860 r = MsiEvaluateCondition(hpkg, " 1 ~= 1 ");
861 ok( r == MSICONDITION_TRUE, "wrong return val\n");
863 r = MsiEvaluateCondition(hpkg, " 1 ~= \"1\" ");
864 ok( r == MSICONDITION_FALSE, "wrong return val\n");
866 r = MsiEvaluateCondition(hpkg, " 1 = \"1\" ");
867 ok( r == MSICONDITION_FALSE, "wrong return val\n");
869 r = MsiEvaluateCondition(hpkg, " 0 = \"1\" ");
870 ok( r == MSICONDITION_FALSE, "wrong return val\n");
872 r = MsiEvaluateCondition(hpkg, " 0 < \"100\" ");
873 ok( r == MSICONDITION_FALSE, "wrong return val\n");
875 r = MsiEvaluateCondition(hpkg, " 100 > \"0\" ");
876 ok( r == MSICONDITION_FALSE, "wrong return val\n");
878 r = MsiEvaluateCondition(hpkg, "1 XOR 1");
879 ok( r == MSICONDITION_FALSE, "wrong return val\n");
881 r = MsiEvaluateCondition(hpkg, "1 IMP 1");
882 ok( r == MSICONDITION_TRUE, "wrong return val\n");
884 r = MsiEvaluateCondition(hpkg, "1 IMP 0");
885 ok( r == MSICONDITION_FALSE, "wrong return val\n");
887 r = MsiEvaluateCondition(hpkg, "0 IMP 0");
888 ok( r == MSICONDITION_TRUE, "wrong return val\n");
890 r = MsiEvaluateCondition(hpkg, "0 EQV 0");
891 ok( r == MSICONDITION_TRUE, "wrong return val\n");
893 r = MsiEvaluateCondition(hpkg, "0 EQV 1");
894 ok( r == MSICONDITION_FALSE, "wrong return val\n");
896 r = MsiEvaluateCondition(hpkg, "1 IMP 1 OR 0");
897 ok( r == MSICONDITION_TRUE, "wrong return val\n");
899 r = MsiEvaluateCondition(hpkg, "1 IMPL 1");
900 ok( r == MSICONDITION_ERROR, "wrong return val\n");
902 r = MsiEvaluateCondition(hpkg, "\"ASFD\" >< \"S\" ");
903 ok( r == MSICONDITION_TRUE, "wrong return val\n");
905 r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"s\" ");
906 ok( r == MSICONDITION_TRUE, "wrong return val\n");
908 r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"\" ");
909 ok( r == MSICONDITION_TRUE, "wrong return val\n");
911 r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"sss\" ");
912 ok( r == MSICONDITION_FALSE, "wrong return val\n");
914 MsiSetProperty(hpkg, "mm", "5" );
916 r = MsiEvaluateCondition(hpkg, "mm = 5");
917 ok( r == MSICONDITION_TRUE, "wrong return val\n");
919 r = MsiEvaluateCondition(hpkg, "mm < 6");
920 ok( r == MSICONDITION_TRUE, "wrong return val\n");
922 r = MsiEvaluateCondition(hpkg, "mm <= 5");
923 ok( r == MSICONDITION_TRUE, "wrong return val\n");
925 r = MsiEvaluateCondition(hpkg, "mm > 4");
926 ok( r == MSICONDITION_TRUE, "wrong return val\n");
928 r = MsiEvaluateCondition(hpkg, "mm < 12");
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, "0 = \"\"");
935 ok( r == MSICONDITION_FALSE, "wrong return val\n");
937 r = MsiEvaluateCondition(hpkg, "0 AND \"\"");
938 ok( r == MSICONDITION_FALSE, "wrong return val\n");
940 r = MsiEvaluateCondition(hpkg, "1 AND \"\"");
941 ok( r == MSICONDITION_FALSE, "wrong return val\n");
943 r = MsiEvaluateCondition(hpkg, "1 AND \"1\"");
944 ok( r == MSICONDITION_TRUE, "wrong return val\n");
946 r = MsiEvaluateCondition(hpkg, "3 >< 1");
947 ok( r == MSICONDITION_TRUE, "wrong return val\n");
949 r = MsiEvaluateCondition(hpkg, "3 >< 4");
950 ok( r == MSICONDITION_FALSE, "wrong return val\n");
952 r = MsiEvaluateCondition(hpkg, "NOT 0 AND 0");
953 ok( r == MSICONDITION_FALSE, "wrong return val\n");
955 r = MsiEvaluateCondition(hpkg, "NOT 0 AND 1");
956 ok( r == MSICONDITION_TRUE, "wrong return val\n");
958 r = MsiEvaluateCondition(hpkg, "NOT 1 OR 0");
959 ok( r == MSICONDITION_FALSE, "wrong return val\n");
961 r = MsiEvaluateCondition(hpkg, "0 AND 1 OR 1");
962 ok( r == MSICONDITION_TRUE, "wrong return val\n");
964 r = MsiEvaluateCondition(hpkg, "0 AND 0 OR 1");
965 ok( r == MSICONDITION_TRUE, "wrong return val\n");
967 r = MsiEvaluateCondition(hpkg, "NOT 0 AND 1 OR 0");
968 ok( r == MSICONDITION_TRUE, "wrong return val\n");
970 r = MsiEvaluateCondition(hpkg, "_1 = _1");
971 ok( r == MSICONDITION_TRUE, "wrong return val\n");
973 r = MsiEvaluateCondition(hpkg, "( 1 AND 1 ) = 2");
974 ok( r == MSICONDITION_ERROR, "wrong return val\n");
976 r = MsiEvaluateCondition(hpkg, "NOT ( 1 AND 1 )");
977 ok( r == MSICONDITION_FALSE, "wrong return val\n");
979 r = MsiEvaluateCondition(hpkg, "NOT A AND (BBBBBBBBBB=2 OR CCC=1) AND Ddddddddd");
980 ok( r == MSICONDITION_FALSE, "wrong return val\n");
982 r = MsiEvaluateCondition(hpkg, "Installed<>\"\"");
983 ok( r == MSICONDITION_FALSE, "wrong return val\n");
985 r = MsiEvaluateCondition(hpkg, "NOT 1 AND 0");
986 ok( r == MSICONDITION_FALSE, "wrong return val\n");
988 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
989 ok( r == MSICONDITION_FALSE, "wrong return val\n");
991 r = MsiEvaluateCondition(hpkg, "bandalmael<>0");
992 ok( r == MSICONDITION_TRUE, "wrong return val\n");
994 r = MsiEvaluateCondition(hpkg, "bandalmael<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_FALSE, "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_TRUE, "wrong return val\n");
1009 MsiSetProperty(hpkg, "bandalmael", "0" );
1010 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1011 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1013 MsiSetProperty(hpkg, "bandalmael", "" );
1014 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1015 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1017 MsiSetProperty(hpkg, "bandalmael", "asdf" );
1018 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1019 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1021 MsiSetProperty(hpkg, "bandalmael", "0asdf" );
1022 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1023 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1025 MsiSetProperty(hpkg, "bandalmael", "0 " );
1026 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1027 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1029 MsiSetProperty(hpkg, "bandalmael", "-0" );
1030 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1031 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1033 MsiSetProperty(hpkg, "bandalmael", "0000000000000" );
1034 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1035 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1037 MsiSetProperty(hpkg, "bandalmael", "--0" );
1038 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1039 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1041 MsiSetProperty(hpkg, "bandalmael", "0x00" );
1042 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1043 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1045 MsiSetProperty(hpkg, "bandalmael", "-" );
1046 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1047 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1049 MsiSetProperty(hpkg, "bandalmael", "+0" );
1050 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1051 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1053 MsiSetProperty(hpkg, "bandalmael", "0.0" );
1054 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1055 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1056 r = MsiEvaluateCondition(hpkg, "bandalmael<>0");
1057 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1059 MsiSetProperty(hpkg, "one", "hi");
1060 MsiSetProperty(hpkg, "two", "hithere");
1061 r = MsiEvaluateCondition(hpkg, "one >< two");
1062 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1064 MsiSetProperty(hpkg, "one", "hithere");
1065 MsiSetProperty(hpkg, "two", "hi");
1066 r = MsiEvaluateCondition(hpkg, "one >< two");
1067 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1069 MsiSetProperty(hpkg, "one", "hello");
1070 MsiSetProperty(hpkg, "two", "hi");
1071 r = MsiEvaluateCondition(hpkg, "one >< two");
1072 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1074 MsiSetProperty(hpkg, "one", "hellohithere");
1075 MsiSetProperty(hpkg, "two", "hi");
1076 r = MsiEvaluateCondition(hpkg, "one >< two");
1077 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1079 MsiSetProperty(hpkg, "one", "");
1080 MsiSetProperty(hpkg, "two", "hi");
1081 r = MsiEvaluateCondition(hpkg, "one >< two");
1082 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1084 MsiSetProperty(hpkg, "one", "hi");
1085 MsiSetProperty(hpkg, "two", "");
1086 r = MsiEvaluateCondition(hpkg, "one >< two");
1087 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1089 MsiSetProperty(hpkg, "one", "");
1090 MsiSetProperty(hpkg, "two", "");
1091 r = MsiEvaluateCondition(hpkg, "one >< two");
1092 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1094 MsiSetProperty(hpkg, "one", "1234");
1095 MsiSetProperty(hpkg, "two", "1");
1096 r = MsiEvaluateCondition(hpkg, "one >< two");
1097 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1099 MsiSetProperty(hpkg, "one", "one 1234");
1100 MsiSetProperty(hpkg, "two", "1");
1101 r = MsiEvaluateCondition(hpkg, "one >< two");
1102 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1104 MsiSetProperty(hpkg, "one", "hithere");
1105 MsiSetProperty(hpkg, "two", "hi");
1106 r = MsiEvaluateCondition(hpkg, "one << two");
1107 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1109 MsiSetProperty(hpkg, "one", "hi");
1110 MsiSetProperty(hpkg, "two", "hithere");
1111 r = MsiEvaluateCondition(hpkg, "one << two");
1112 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1114 MsiSetProperty(hpkg, "one", "hi");
1115 MsiSetProperty(hpkg, "two", "hi");
1116 r = MsiEvaluateCondition(hpkg, "one << two");
1117 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1119 MsiSetProperty(hpkg, "one", "abcdhithere");
1120 MsiSetProperty(hpkg, "two", "hi");
1121 r = MsiEvaluateCondition(hpkg, "one << two");
1122 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1124 MsiSetProperty(hpkg, "one", "");
1125 MsiSetProperty(hpkg, "two", "hi");
1126 r = MsiEvaluateCondition(hpkg, "one << two");
1127 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1129 MsiSetProperty(hpkg, "one", "hithere");
1130 MsiSetProperty(hpkg, "two", "");
1131 r = MsiEvaluateCondition(hpkg, "one << two");
1132 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1134 MsiSetProperty(hpkg, "one", "");
1135 MsiSetProperty(hpkg, "two", "");
1136 r = MsiEvaluateCondition(hpkg, "one << two");
1137 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1139 MsiSetProperty(hpkg, "one", "1234");
1140 MsiSetProperty(hpkg, "two", "1");
1141 r = MsiEvaluateCondition(hpkg, "one << two");
1142 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1144 MsiSetProperty(hpkg, "one", "1234 one");
1145 MsiSetProperty(hpkg, "two", "1");
1146 r = MsiEvaluateCondition(hpkg, "one << two");
1147 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1149 MsiSetProperty(hpkg, "one", "hithere");
1150 MsiSetProperty(hpkg, "two", "there");
1151 r = MsiEvaluateCondition(hpkg, "one >> two");
1152 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1154 MsiSetProperty(hpkg, "one", "hithere");
1155 MsiSetProperty(hpkg, "two", "hi");
1156 r = MsiEvaluateCondition(hpkg, "one >> two");
1157 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1159 MsiSetProperty(hpkg, "one", "there");
1160 MsiSetProperty(hpkg, "two", "hithere");
1161 r = MsiEvaluateCondition(hpkg, "one >> two");
1162 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1164 MsiSetProperty(hpkg, "one", "there");
1165 MsiSetProperty(hpkg, "two", "there");
1166 r = MsiEvaluateCondition(hpkg, "one >> two");
1167 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1169 MsiSetProperty(hpkg, "one", "abcdhithere");
1170 MsiSetProperty(hpkg, "two", "hi");
1171 r = MsiEvaluateCondition(hpkg, "one >> two");
1172 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1174 MsiSetProperty(hpkg, "one", "");
1175 MsiSetProperty(hpkg, "two", "there");
1176 r = MsiEvaluateCondition(hpkg, "one >> two");
1177 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1179 MsiSetProperty(hpkg, "one", "there");
1180 MsiSetProperty(hpkg, "two", "");
1181 r = MsiEvaluateCondition(hpkg, "one >> two");
1182 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1184 MsiSetProperty(hpkg, "one", "");
1185 MsiSetProperty(hpkg, "two", "");
1186 r = MsiEvaluateCondition(hpkg, "one >> two");
1187 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1189 MsiSetProperty(hpkg, "one", "1234");
1190 MsiSetProperty(hpkg, "two", "4");
1191 r = MsiEvaluateCondition(hpkg, "one >> two");
1192 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1194 MsiSetProperty(hpkg, "one", "one 1234");
1195 MsiSetProperty(hpkg, "two", "4");
1196 r = MsiEvaluateCondition(hpkg, "one >> two");
1197 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1199 MsiSetProperty(hpkg, "MsiNetAssemblySupport", NULL); /* make sure it's empty */
1201 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322\"");
1202 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1204 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport > \"1.1.4322\"");
1205 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1207 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport >= \"1.1.4322\"");
1208 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1210 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport <= \"1.1.4322\"");
1211 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1213 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport <> \"1.1.4322\"");
1214 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1216 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport ~< \"1.1.4322\"");
1217 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1219 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"abcd\"");
1220 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1222 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a1.1.4322\"");
1223 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1225 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322a\"");
1226 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1228 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"0000001.1.4322\"");
1229 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1231 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322.1\"");
1232 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1234 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322.1.1\"");
1235 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1237 r = MsiEvaluateCondition(hpkg, "\"2\" < \"1.1");
1238 ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1240 r = MsiEvaluateCondition(hpkg, "\"2\" < \"1.1\"");
1241 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1243 r = MsiEvaluateCondition(hpkg, "\"2\" < \"12.1\"");
1244 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1246 r = MsiEvaluateCondition(hpkg, "\"02.1\" < \"2.11\"");
1247 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1249 r = MsiEvaluateCondition(hpkg, "\"02.1.1\" < \"2.1\"");
1250 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1252 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1\"");
1253 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1255 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1\"");
1256 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1258 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"0\"");
1259 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1261 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"-1\"");
1262 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1264 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a\"");
1265 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1267 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"!\"");
1268 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1270 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"!\"");
1271 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1273 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"/\"");
1274 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1276 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \" \"");
1277 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1279 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"azAZ_\"");
1280 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1282 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a[a]\"");
1283 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1285 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a[a]a\"");
1286 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1288 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[a]\"");
1289 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1291 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[a]a\"");
1292 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1294 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"{a}\"");
1295 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1297 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"{a\"");
1298 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1300 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[a\"");
1301 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1303 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a{\"");
1304 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1306 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a]\"");
1307 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1309 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"A\"");
1310 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1312 MsiSetProperty(hpkg, "MsiNetAssemblySupport", "1.1.4322");
1313 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322\"");
1314 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1316 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.14322\"");
1317 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1319 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.5\"");
1320 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1322 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1\"");
1323 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1325 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1\"");
1326 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1328 MsiSetProperty(hpkg, "one", "1");
1329 r = MsiEvaluateCondition(hpkg, "one < \"1\"");
1330 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1332 MsiCloseHandle( hpkg );
1333 DeleteFile(msifile);
1336 static BOOL check_prop_empty( MSIHANDLE hpkg, const char * prop)
1344 r = MsiGetProperty( hpkg, prop, buffer, &sz );
1345 return r == ERROR_SUCCESS && buffer[0] == 0 && sz == 0;
1348 static void test_props(void)
1350 MSIHANDLE hpkg, hdb;
1355 hdb = create_package_db();
1357 "CREATE TABLE `Property` ( "
1358 "`Property` CHAR(255) NOT NULL, "
1359 "`Value` CHAR(255) "
1360 "PRIMARY KEY `Property`)" );
1361 ok( r == ERROR_SUCCESS , "Failed\n" );
1364 "INSERT INTO `Property` "
1365 "(`Property`, `Value`) "
1366 "VALUES( 'MetadataCompName', 'Photoshop.dll' )");
1367 ok( r == ERROR_SUCCESS , "Failed\n" );
1369 hpkg = package_from_db( hdb );
1370 ok( hpkg, "failed to create package\n");
1372 /* test invalid values */
1373 r = MsiGetProperty( 0, NULL, NULL, NULL );
1374 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1376 r = MsiGetProperty( hpkg, NULL, NULL, NULL );
1377 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1379 r = MsiGetProperty( hpkg, "boo", NULL, NULL );
1380 ok( r == ERROR_SUCCESS, "wrong return val\n");
1382 r = MsiGetProperty( hpkg, "boo", buffer, NULL );
1383 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1385 /* test retrieving an empty/nonexistent property */
1387 r = MsiGetProperty( hpkg, "boo", NULL, &sz );
1388 ok( r == ERROR_SUCCESS, "wrong return val\n");
1389 ok( sz == 0, "wrong size returned\n");
1391 check_prop_empty( hpkg, "boo");
1394 r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1395 ok( r == ERROR_MORE_DATA, "wrong return val\n");
1396 ok( !strcmp(buffer,"x"), "buffer was changed\n");
1397 ok( sz == 0, "wrong size returned\n");
1401 r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1402 ok( r == ERROR_SUCCESS, "wrong return val\n");
1403 ok( buffer[0] == 0, "buffer was not changed\n");
1404 ok( sz == 0, "wrong size returned\n");
1406 /* set the property to something */
1407 r = MsiSetProperty( 0, NULL, NULL );
1408 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
1410 r = MsiSetProperty( hpkg, NULL, NULL );
1411 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1413 r = MsiSetProperty( hpkg, "", NULL );
1414 ok( r == ERROR_SUCCESS, "wrong return val\n");
1416 /* try set and get some illegal property identifiers */
1417 r = MsiSetProperty( hpkg, "", "asdf" );
1418 ok( r == ERROR_FUNCTION_FAILED, "wrong return val\n");
1420 r = MsiSetProperty( hpkg, "=", "asdf" );
1421 ok( r == ERROR_SUCCESS, "wrong return val\n");
1423 r = MsiSetProperty( hpkg, " ", "asdf" );
1424 ok( r == ERROR_SUCCESS, "wrong return val\n");
1426 r = MsiSetProperty( hpkg, "'", "asdf" );
1427 ok( r == ERROR_SUCCESS, "wrong return val\n");
1431 r = MsiGetProperty( hpkg, "'", buffer, &sz );
1432 ok( r == ERROR_SUCCESS, "wrong return val\n");
1433 ok( !strcmp(buffer,"asdf"), "buffer was not changed\n");
1435 /* set empty values */
1436 r = MsiSetProperty( hpkg, "boo", NULL );
1437 ok( r == ERROR_SUCCESS, "wrong return val\n");
1438 ok( check_prop_empty( hpkg, "boo"), "prop wasn't empty\n");
1440 r = MsiSetProperty( hpkg, "boo", "" );
1441 ok( r == ERROR_SUCCESS, "wrong return val\n");
1442 ok( check_prop_empty( hpkg, "boo"), "prop wasn't empty\n");
1444 /* set a non-empty value */
1445 r = MsiSetProperty( hpkg, "boo", "xyz" );
1446 ok( r == ERROR_SUCCESS, "wrong return val\n");
1450 r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1451 ok( r == ERROR_MORE_DATA, "wrong return val\n");
1452 ok( buffer[0] == 0, "buffer was not changed\n");
1453 ok( sz == 3, "wrong size returned\n");
1457 r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1458 ok( r == ERROR_SUCCESS, "wrong return val\n");
1459 ok( !strcmp(buffer,"xyz"), "buffer was not changed\n");
1460 ok( sz == 3, "wrong size returned\n");
1464 r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1465 ok( r == ERROR_MORE_DATA, "wrong return val\n");
1466 ok( !strcmp(buffer,"xy"), "buffer was not changed\n");
1467 ok( sz == 3, "wrong size returned\n");
1469 r = MsiSetProperty(hpkg, "SourceDir", "foo");
1470 ok( r == ERROR_SUCCESS, "wrong return val\n");
1473 r = MsiGetProperty(hpkg, "SOURCEDIR", buffer, &sz);
1474 ok( r == ERROR_SUCCESS, "wrong return val\n");
1475 ok( !strcmp(buffer,""), "buffer wrong\n");
1476 ok( sz == 0, "wrong size returned\n");
1479 r = MsiGetProperty(hpkg, "SOMERANDOMNAME", buffer, &sz);
1480 ok( r == ERROR_SUCCESS, "wrong return val\n");
1481 ok( !strcmp(buffer,""), "buffer wrong\n");
1482 ok( sz == 0, "wrong size returned\n");
1485 r = MsiGetProperty(hpkg, "SourceDir", buffer, &sz);
1486 ok( r == ERROR_SUCCESS, "wrong return val\n");
1487 ok( !strcmp(buffer,"foo"), "buffer wrong\n");
1488 ok( sz == 3, "wrong size returned\n");
1490 r = MsiSetProperty(hpkg, "MetadataCompName", "Photoshop.dll");
1491 ok( r == ERROR_SUCCESS, "wrong return val\n");
1494 r = MsiGetProperty(hpkg, "MetadataCompName", NULL, &sz );
1495 ok( r == ERROR_SUCCESS, "return wrong\n");
1496 ok( sz == 13, "size wrong (%d)\n", sz);
1499 r = MsiGetProperty(hpkg, "MetadataCompName", buffer, &sz );
1500 ok( r == ERROR_MORE_DATA, "return wrong\n");
1501 ok( !strcmp(buffer,"Photoshop.dl"), "buffer wrong\n");
1503 r = MsiSetProperty(hpkg, "property", "value");
1504 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1507 r = MsiGetProperty(hpkg, "property", buffer, &sz);
1508 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1509 ok( !strcmp(buffer, "value"), "Expected value, got %s\n", buffer);
1511 r = MsiSetProperty(hpkg, "property", NULL);
1512 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1515 r = MsiGetProperty(hpkg, "property", buffer, &sz);
1516 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1517 ok( !strlen(buffer), "Expected empty string, got %s\n", buffer);
1519 MsiCloseHandle( hpkg );
1520 DeleteFile(msifile);
1523 static void test_properties_table(void)
1527 MSIHANDLE hpkg, hdb;
1531 hdb = create_package_db();
1532 ok( hdb, "failed to create package\n");
1534 hpkg = package_from_db(hdb);
1535 ok( hpkg, "failed to create package\n");
1537 query = "CREATE TABLE `_Properties` ( "
1538 "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
1539 r = run_query(hdb, query);
1540 ok(r == ERROR_INVALID_HANDLE, "failed to create table\n");
1542 MsiCloseHandle( hpkg );
1543 DeleteFile(msifile);
1545 hdb = create_package_db();
1546 ok( hdb, "failed to create package\n");
1548 query = "CREATE TABLE `_Properties` ( "
1549 "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
1550 r = run_query(hdb, query);
1551 ok(r == ERROR_SUCCESS, "failed to create table\n");
1553 query = "ALTER `_Properties` ADD `foo` INTEGER";
1554 r = run_query(hdb, query);
1555 ok(r == ERROR_BAD_QUERY_SYNTAX, "failed to add column\n");
1557 query = "ALTER TABLE `_Properties` ADD `foo` INTEGER";
1558 r = run_query(hdb, query);
1559 ok(r == ERROR_BAD_QUERY_SYNTAX, "failed to add column\n");
1561 query = "ALTER TABLE `_Properties` ADD `extra` INTEGER";
1562 r = run_query(hdb, query);
1563 todo_wine ok(r == ERROR_SUCCESS, "failed to add column\n");
1565 hpkg = package_from_db(hdb);
1566 ok( hpkg, "failed to create package\n");
1568 r = MsiSetProperty( hpkg, "foo", "bar");
1569 ok(r == ERROR_SUCCESS, "failed to create table\n");
1572 r = MsiGetProperty( hpkg, "foo", buffer, &sz);
1573 ok(r == ERROR_SUCCESS, "failed to create table\n");
1575 MsiCloseHandle( hpkg );
1576 DeleteFile(msifile);
1579 static UINT try_query_param( MSIHANDLE hdb, LPCSTR szQuery, MSIHANDLE hrec )
1584 res = MsiDatabaseOpenView( hdb, szQuery, &htab );
1585 if( res == ERROR_SUCCESS )
1589 r = MsiViewExecute( htab, hrec );
1590 if( r != ERROR_SUCCESS )
1593 fprintf(stderr,"MsiViewExecute failed %08x\n", res);
1596 r = MsiViewClose( htab );
1597 if( r != ERROR_SUCCESS )
1600 r = MsiCloseHandle( htab );
1601 if( r != ERROR_SUCCESS )
1607 static UINT try_query( MSIHANDLE hdb, LPCSTR szQuery )
1609 return try_query_param( hdb, szQuery, 0 );
1612 static void test_msipackage(void)
1614 MSIHANDLE hdb = 0, hpack = 100;
1619 DeleteFile(msifile);
1623 r = MsiOpenPackage(name, &hpack);
1624 ok(r == ERROR_SUCCESS, "failed to open package with no name\n");
1625 r = MsiCloseHandle(hpack);
1626 ok(r == ERROR_SUCCESS, "failed to close package\n");
1629 /* just MsiOpenDatabase should not create a file */
1630 r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
1631 ok(r == ERROR_SUCCESS, "MsiOpenDatabase failed\n");
1635 r = MsiOpenPackage(name, &hpack);
1636 ok(r == ERROR_INVALID_HANDLE, "MsiOpenPackage returned wrong code\n");
1639 /* now try again with our empty database */
1640 sprintf(name, "#%ld", hdb);
1641 r = MsiOpenPackage(name, &hpack);
1642 ok(r == ERROR_INSTALL_PACKAGE_INVALID, "MsiOpenPackage returned wrong code\n");
1643 if (!r) MsiCloseHandle(hpack);
1646 /* create a table */
1647 query = "CREATE TABLE `Property` ( "
1648 "`Property` CHAR(72), `Value` CHAR(0) "
1649 "PRIMARY KEY `Property`)";
1650 r = try_query(hdb, query);
1651 ok(r == ERROR_SUCCESS, "failed to create Properties table\n");
1653 query = "CREATE TABLE `InstallExecuteSequence` ("
1654 "`Action` CHAR(72), `Condition` CHAR(0), `Sequence` INTEGER "
1655 "PRIMARY KEY `Action`)";
1656 r = try_query(hdb, query);
1657 ok(r == ERROR_SUCCESS, "failed to create InstallExecuteSequence table\n");
1660 sprintf(name, "#%ld", hdb);
1661 r = MsiOpenPackage(name, &hpack);
1662 ok(r == ERROR_INSTALL_PACKAGE_INVALID, "MsiOpenPackage returned wrong code\n");
1663 if (!r) MsiCloseHandle(hpack);
1666 r = MsiCloseHandle(hdb);
1667 ok(r == ERROR_SUCCESS, "MsiCloseHandle(database) failed\n");
1668 DeleteFile(msifile);
1671 static void test_formatrecord2(void)
1673 MSIHANDLE hpkg, hrec ;
1678 hpkg = package_from_db(create_package_db());
1679 ok( hpkg, "failed to create package\n");
1681 r = MsiSetProperty(hpkg, "Manufacturer", " " );
1682 ok( r == ERROR_SUCCESS, "set property failed\n");
1684 hrec = MsiCreateRecord(2);
1685 ok(hrec, "create record failed\n");
1687 r = MsiRecordSetString( hrec, 0, "[ProgramFilesFolder][Manufacturer]\\asdf");
1688 ok( r == ERROR_SUCCESS, "format record failed\n");
1692 r = MsiFormatRecord( hpkg, hrec, buffer, &sz );
1694 r = MsiRecordSetString(hrec, 0, "[foo][1]");
1695 r = MsiRecordSetString(hrec, 1, "hoo");
1697 r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
1698 ok( sz == 3, "size wrong\n");
1699 ok( 0 == strcmp(buffer,"hoo"), "wrong output %s\n",buffer);
1700 ok( r == ERROR_SUCCESS, "format failed\n");
1702 r = MsiRecordSetString(hrec, 0, "x[~]x");
1704 r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
1705 ok( sz == 3, "size wrong\n");
1706 ok( 0 == strcmp(buffer,"x"), "wrong output %s\n",buffer);
1707 ok( r == ERROR_SUCCESS, "format failed\n");
1709 r = MsiRecordSetString(hrec, 0, "[foo.$%}][1]");
1710 r = MsiRecordSetString(hrec, 1, "hoo");
1712 r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
1713 ok( sz == 3, "size wrong\n");
1714 ok( 0 == strcmp(buffer,"hoo"), "wrong output %s\n",buffer);
1715 ok( r == ERROR_SUCCESS, "format failed\n");
1717 r = MsiRecordSetString(hrec, 0, "[\\[]");
1719 r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
1720 ok( sz == 1, "size wrong\n");
1721 ok( 0 == strcmp(buffer,"["), "wrong output %s\n",buffer);
1722 ok( r == ERROR_SUCCESS, "format failed\n");
1724 SetEnvironmentVariable("FOO", "BAR");
1725 r = MsiRecordSetString(hrec, 0, "[%FOO]");
1727 r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
1728 ok( sz == 3, "size wrong\n");
1729 ok( 0 == strcmp(buffer,"BAR"), "wrong output %s\n",buffer);
1730 ok( r == ERROR_SUCCESS, "format failed\n");
1732 r = MsiRecordSetString(hrec, 0, "[[1]]");
1733 r = MsiRecordSetString(hrec, 1, "%FOO");
1735 r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
1736 ok( sz == 3, "size wrong\n");
1737 ok( 0 == strcmp(buffer,"BAR"), "wrong output %s\n",buffer);
1738 ok( r == ERROR_SUCCESS, "format failed\n");
1740 MsiCloseHandle( hrec );
1741 MsiCloseHandle( hpkg );
1742 DeleteFile(msifile);
1745 static void test_states(void)
1750 INSTALLSTATE state, action;
1752 hdb = create_package_db();
1753 ok ( hdb, "failed to create package database\n" );
1755 r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
1756 ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
1758 r = create_feature_table( hdb );
1759 ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
1761 r = create_component_table( hdb );
1762 ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
1764 /* msidbFeatureAttributesFavorLocal */
1765 r = add_feature_entry( hdb, "'one', '', '', '', 2, 1, '', 0" );
1766 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
1768 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
1769 r = add_component_entry( hdb, "'alpha', '{467EC132-739D-4784-A37B-677AA43DBC94}', 'TARGETDIR', 0, '', 'alpha_file'" );
1770 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
1772 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
1773 r = add_component_entry( hdb, "'beta', '{2C1F189C-24A6-4C34-B26B-994A6C026506}', 'TARGETDIR', 1, '', 'beta_file'" );
1774 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
1776 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
1777 r = add_component_entry( hdb, "'gamma', '{C271E2A4-DE2E-4F70-86D1-6984AF7DE2CA}', 'TARGETDIR', 2, '', 'gamma_file'" );
1778 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
1780 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSharedDllRefCount */
1781 r = add_component_entry( hdb, "'theta', '{4EB3129D-81A8-48D5-9801-75600FED3DD9}', 'TARGETDIR', 8, '', 'theta_file'" );
1782 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
1784 /* msidbFeatureAttributesFavorSource */
1785 r = add_feature_entry( hdb, "'two', '', '', '', 2, 1, '', 1" );
1786 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
1788 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
1789 r = add_component_entry( hdb, "'delta', '{938FD4F2-C648-4259-A03C-7AA3B45643F3}', 'TARGETDIR', 0, '', 'delta_file'" );
1790 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
1792 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
1793 r = add_component_entry( hdb, "'epsilon', '{D59713B6-C11D-47F2-A395-1E5321781190}', 'TARGETDIR', 1, '', 'epsilon_file'" );
1794 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
1796 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
1797 r = add_component_entry( hdb, "'zeta', '{377D33AB-2FAA-42B9-A629-0C0DAE9B9C7A}', 'TARGETDIR', 2, '', 'zeta_file'" );
1798 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
1800 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSharedDllRefCount */
1801 r = add_component_entry( hdb, "'iota', '{5D36F871-B5ED-4801-9E0F-C46B9E5C9669}', 'TARGETDIR', 8, '', 'iota_file'" );
1802 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
1804 /* msidbFeatureAttributesFavorSource */
1805 r = add_feature_entry( hdb, "'three', '', '', '', 2, 1, '', 1" );
1806 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
1808 /* msidbFeatureAttributesFavorLocal */
1809 r = add_feature_entry( hdb, "'four', '', '', '', 2, 1, '', 0" );
1810 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
1813 r = add_feature_entry( hdb, "'five', '', '', '', 2, 0, '', 1" );
1814 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
1816 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
1817 r = add_component_entry( hdb, "'eta', '{DD89003F-0DD4-41B8-81C0-3411A7DA2695}', 'TARGETDIR', 1, '', 'eta_file'" );
1818 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
1820 /* no feature parent:msidbComponentAttributesLocalOnly */
1821 r = add_component_entry( hdb, "'kappa', '{D6B93DC3-8DA5-4769-9888-42BFE156BB8B}', 'TARGETDIR', 1, '', 'kappa_file'" );
1822 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
1824 r = create_feature_components_table( hdb );
1825 ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
1827 r = add_feature_components_entry( hdb, "'one', 'alpha'" );
1828 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
1830 r = add_feature_components_entry( hdb, "'one', 'beta'" );
1831 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
1833 r = add_feature_components_entry( hdb, "'one', 'gamma'" );
1834 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
1836 r = add_feature_components_entry( hdb, "'one', 'theta'" );
1837 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
1839 r = add_feature_components_entry( hdb, "'two', 'delta'" );
1840 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
1842 r = add_feature_components_entry( hdb, "'two', 'epsilon'" );
1843 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
1845 r = add_feature_components_entry( hdb, "'two', 'zeta'" );
1846 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
1848 r = add_feature_components_entry( hdb, "'two', 'iota'" );
1849 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
1851 r = add_feature_components_entry( hdb, "'three', 'eta'" );
1852 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
1854 r = add_feature_components_entry( hdb, "'four', 'eta'" );
1855 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
1857 r = add_feature_components_entry( hdb, "'five', 'eta'" );
1858 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
1860 r = create_file_table( hdb );
1861 ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
1863 r = add_file_entry( hdb, "'alpha_file', 'alpha', 'alpha.txt', 100, '', '1033', 8192, 1" );
1864 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
1866 r = add_file_entry( hdb, "'beta_file', 'beta', 'beta.txt', 0, '', '1033', 8192, 1" );
1867 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
1869 r = add_file_entry( hdb, "'gamma_file', 'gamma', 'gamma.txt', 0, '', '1033', 8192, 1" );
1870 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
1872 r = add_file_entry( hdb, "'theta_file', 'theta', 'theta.txt', 0, '', '1033', 8192, 1" );
1873 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
1875 r = add_file_entry( hdb, "'delta_file', 'delta', 'delta.txt', 0, '', '1033', 8192, 1" );
1876 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
1878 r = add_file_entry( hdb, "'epsilon_file', 'epsilon', 'epsilon.txt', 0, '', '1033', 8192, 1" );
1879 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
1881 r = add_file_entry( hdb, "'zeta_file', 'zeta', 'zeta.txt', 0, '', '1033', 8192, 1" );
1882 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
1884 r = add_file_entry( hdb, "'iota_file', 'iota', 'iota.txt', 0, '', '1033', 8192, 1" );
1885 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
1887 /* compressed file */
1888 r = add_file_entry( hdb, "'eta_file', 'eta', 'eta.txt', 0, '', '1033', 16384, 1" );
1889 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
1891 r = add_file_entry( hdb, "'kappa_file', 'kappa', 'kappa.txt', 0, '', '1033', 8192, 1" );
1892 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
1894 hpkg = package_from_db( hdb );
1895 ok( hpkg, "failed to create package\n");
1897 MsiCloseHandle( hdb );
1901 r = MsiGetFeatureState(hpkg, "one", &state, &action);
1902 ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
1903 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
1904 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
1908 r = MsiGetFeatureState(hpkg, "two", &state, &action);
1909 ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
1910 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
1911 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
1915 r = MsiGetFeatureState(hpkg, "three", &state, &action);
1916 ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
1917 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
1918 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
1922 r = MsiGetFeatureState(hpkg, "four", &state, &action);
1923 ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
1924 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
1925 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
1929 r = MsiGetFeatureState(hpkg, "five", &state, &action);
1930 ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
1931 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
1932 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
1936 r = MsiGetComponentState(hpkg, "alpha", &state, &action);
1937 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
1938 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
1939 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
1943 r = MsiGetComponentState(hpkg, "beta", &state, &action);
1944 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
1945 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
1946 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
1950 r = MsiGetComponentState(hpkg, "gamma", &state, &action);
1951 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
1952 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
1953 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
1957 r = MsiGetComponentState(hpkg, "theta", &state, &action);
1958 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
1959 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
1960 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
1964 r = MsiGetComponentState(hpkg, "delta", &state, &action);
1965 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
1966 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
1967 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
1971 r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
1972 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
1973 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
1974 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
1978 r = MsiGetComponentState(hpkg, "zeta", &state, &action);
1979 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
1980 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
1981 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
1985 r = MsiGetComponentState(hpkg, "iota", &state, &action);
1986 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
1987 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
1988 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
1992 r = MsiGetComponentState(hpkg, "eta", &state, &action);
1993 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
1994 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
1995 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
1999 r = MsiGetComponentState(hpkg, "kappa", &state, &action);
2000 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2001 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2002 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2004 r = MsiDoAction( hpkg, "CostInitialize");
2005 ok( r == ERROR_SUCCESS, "cost init failed\n");
2009 r = MsiGetFeatureState(hpkg, "one", &state, &action);
2010 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2011 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2012 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2016 r = MsiGetFeatureState(hpkg, "two", &state, &action);
2017 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2018 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2019 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2023 r = MsiGetFeatureState(hpkg, "three", &state, &action);
2024 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2025 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2026 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2030 r = MsiGetFeatureState(hpkg, "four", &state, &action);
2031 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2032 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2033 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2037 r = MsiGetFeatureState(hpkg, "five", &state, &action);
2038 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2039 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2040 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2044 r = MsiGetComponentState(hpkg, "alpha", &state, &action);
2045 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2046 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2047 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2051 r = MsiGetComponentState(hpkg, "beta", &state, &action);
2052 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2053 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2054 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2058 r = MsiGetComponentState(hpkg, "gamma", &state, &action);
2059 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2060 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2061 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2065 r = MsiGetComponentState(hpkg, "theta", &state, &action);
2066 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2067 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2068 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2072 r = MsiGetComponentState(hpkg, "delta", &state, &action);
2073 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2074 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2075 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2079 r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
2080 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2081 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2082 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2086 r = MsiGetComponentState(hpkg, "zeta", &state, &action);
2087 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2088 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2089 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2093 r = MsiGetComponentState(hpkg, "iota", &state, &action);
2094 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2095 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2096 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2100 r = MsiGetComponentState(hpkg, "eta", &state, &action);
2101 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2102 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2103 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2107 r = MsiGetComponentState(hpkg, "kappa", &state, &action);
2108 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2109 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2110 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2112 r = MsiDoAction( hpkg, "FileCost");
2113 ok( r == ERROR_SUCCESS, "file cost failed\n");
2117 r = MsiGetFeatureState(hpkg, "one", &state, &action);
2118 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2119 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2120 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2124 r = MsiGetFeatureState(hpkg, "two", &state, &action);
2125 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2126 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2127 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2131 r = MsiGetFeatureState(hpkg, "three", &state, &action);
2132 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2133 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2134 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2138 r = MsiGetFeatureState(hpkg, "four", &state, &action);
2139 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2140 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2141 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2145 r = MsiGetFeatureState(hpkg, "five", &state, &action);
2146 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2147 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2148 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2152 r = MsiGetComponentState(hpkg, "alpha", &state, &action);
2153 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2154 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2155 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2159 r = MsiGetComponentState(hpkg, "beta", &state, &action);
2160 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2161 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2162 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2166 r = MsiGetComponentState(hpkg, "gamma", &state, &action);
2167 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2168 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2169 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2173 r = MsiGetComponentState(hpkg, "theta", &state, &action);
2174 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2175 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2176 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2180 r = MsiGetComponentState(hpkg, "delta", &state, &action);
2181 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2182 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2183 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2187 r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
2188 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2189 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2190 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2194 r = MsiGetComponentState(hpkg, "zeta", &state, &action);
2195 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2196 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2197 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2201 r = MsiGetComponentState(hpkg, "iota", &state, &action);
2202 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2203 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2204 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2208 r = MsiGetComponentState(hpkg, "eta", &state, &action);
2209 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2210 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2211 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2215 r = MsiGetComponentState(hpkg, "kappa", &state, &action);
2216 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2217 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2218 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2220 r = MsiDoAction( hpkg, "CostFinalize");
2221 ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
2225 r = MsiGetFeatureState(hpkg, "one", &state, &action);
2226 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2227 ok( state == INSTALLSTATE_ABSENT, "Expected one INSTALLSTATE_ABSENT, got %d\n", state);
2228 ok( action == INSTALLSTATE_LOCAL, "Expected one INSTALLSTATE_LOCAL, got %d\n", action);
2232 r = MsiGetFeatureState(hpkg, "two", &state, &action);
2233 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2234 ok( state == INSTALLSTATE_ABSENT, "Expected two INSTALLSTATE_ABSENT, got %d\n", state);
2235 ok( action == INSTALLSTATE_SOURCE, "Expected two INSTALLSTATE_SOURCE, got %d\n", action);
2239 r = MsiGetFeatureState(hpkg, "three", &state, &action);
2240 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2241 ok( state == INSTALLSTATE_ABSENT, "Expected three INSTALLSTATE_ABSENT, got %d\n", state);
2242 ok( action == INSTALLSTATE_LOCAL, "Expected three INSTALLSTATE_LOCAL, got %d\n", action);
2246 r = MsiGetFeatureState(hpkg, "four", &state, &action);
2247 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2248 ok( state == INSTALLSTATE_ABSENT, "Expected four INSTALLSTATE_ABSENT, got %d\n", state);
2249 ok( action == INSTALLSTATE_LOCAL, "Expected four INSTALLSTATE_LOCAL, got %d\n", action);
2253 r = MsiGetFeatureState(hpkg, "five", &state, &action);
2254 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2255 ok( state == INSTALLSTATE_ABSENT, "Expected five INSTALLSTATE_ABSENT, got %d\n", state);
2256 ok( action == INSTALLSTATE_UNKNOWN, "Expected five INSTALLSTATE_UNKNOWN, got %d\n", action);
2260 r = MsiGetComponentState(hpkg, "alpha", &state, &action);
2261 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2262 ok( state == INSTALLSTATE_ABSENT, "Expected alpha INSTALLSTATE_ABSENT, got %d\n", state);
2263 ok( action == INSTALLSTATE_LOCAL, "Expected alpha INSTALLSTATE_LOCAL, got %d\n", action);
2267 r = MsiGetComponentState(hpkg, "beta", &state, &action);
2268 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2269 ok( state == INSTALLSTATE_ABSENT, "Expected beta INSTALLSTATE_ABSENT, got %d\n", state);
2270 ok( action == INSTALLSTATE_SOURCE, "Expected beta INSTALLSTATE_SOURCE, got %d\n", action);
2274 r = MsiGetComponentState(hpkg, "gamma", &state, &action);
2275 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2276 ok( state == INSTALLSTATE_ABSENT, "Expected gamma INSTALLSTATE_ABSENT, got %d\n", state);
2277 ok( action == INSTALLSTATE_LOCAL, "Expected gamma INSTALLSTATE_LOCAL, got %d\n", action);
2281 r = MsiGetComponentState(hpkg, "theta", &state, &action);
2282 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2283 ok( state == INSTALLSTATE_ABSENT, "Expected theta INSTALLSTATE_ABSENT, got %d\n", state);
2284 ok( action == INSTALLSTATE_LOCAL, "Expected theta INSTALLSTATE_LOCAL, got %d\n", action);
2288 r = MsiGetComponentState(hpkg, "delta", &state, &action);
2289 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2290 ok( state == INSTALLSTATE_ABSENT, "Expected delta INSTALLSTATE_ABSENT, got %d\n", state);
2291 ok( action == INSTALLSTATE_LOCAL, "Expected delta INSTALLSTATE_LOCAL, got %d\n", action);
2295 r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
2296 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2297 ok( state == INSTALLSTATE_ABSENT, "Expected epsilon INSTALLSTATE_ABSENT, got %d\n", state);
2298 ok( action == INSTALLSTATE_SOURCE, "Expected epsilon INSTALLSTATE_SOURCE, got %d\n", action);
2302 r = MsiGetComponentState(hpkg, "zeta", &state, &action);
2303 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2304 ok( state == INSTALLSTATE_ABSENT, "Expected zeta INSTALLSTATE_ABSENT, got %d\n", state);
2305 ok( action == INSTALLSTATE_SOURCE, "Expected zeta INSTALLSTATE_SOURCE, got %d\n", action);
2309 r = MsiGetComponentState(hpkg, "iota", &state, &action);
2310 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2311 ok( state == INSTALLSTATE_ABSENT, "Expected iota INSTALLSTATE_ABSENT, got %d\n", state);
2312 ok( action == INSTALLSTATE_LOCAL, "Expected iota INSTALLSTATE_LOCAL, got %d\n", action);
2316 r = MsiGetComponentState(hpkg, "eta", &state, &action);
2317 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2318 ok( state == INSTALLSTATE_ABSENT, "Expected eta INSTALLSTATE_ABSENT, got %d\n", state);
2319 ok( action == INSTALLSTATE_LOCAL, "Expected eta INSTALLSTATE_LOCAL, got %d\n", action);
2323 r = MsiGetComponentState(hpkg, "kappa", &state, &action);
2324 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2325 ok( state == INSTALLSTATE_ABSENT, "Expected kappa INSTALLSTATE_ABSENT, got %d\n", state);
2326 ok( action == INSTALLSTATE_UNKNOWN, "Expected kappa INSTALLSTATE_UNKNOWN, got %d\n", action);
2328 MsiCloseHandle( hpkg );
2329 DeleteFileA( msifile );
2332 static void test_getproperty(void)
2334 MSIHANDLE hPackage = 0;
2336 static CHAR empty[] = "";
2340 hPackage = package_from_db(create_package_db());
2341 ok( hPackage != 0, " Failed to create package\n");
2343 /* set the property */
2344 r = MsiSetProperty(hPackage, "Name", "Value");
2345 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2347 /* retrieve the size, NULL pointer */
2349 r = MsiGetProperty(hPackage, "Name", NULL, &size);
2350 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2351 ok( size == 5, "Expected 5, got %d\n", size);
2353 /* retrieve the size, empty string */
2355 r = MsiGetProperty(hPackage, "Name", empty, &size);
2356 ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
2357 ok( size == 5, "Expected 5, got %d\n", size);
2359 /* don't change size */
2360 r = MsiGetProperty(hPackage, "Name", prop, &size);
2361 ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
2362 ok( size == 5, "Expected 5, got %d\n", size);
2363 ok( !lstrcmp(prop, "Valu"), "Expected Valu, got %s\n", prop);
2365 /* increase the size by 1 */
2367 r = MsiGetProperty(hPackage, "Name", prop, &size);
2368 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2369 ok( size == 5, "Expected 5, got %d\n", size);
2370 ok( !lstrcmp(prop, "Value"), "Expected Value, got %s\n", prop);
2372 r = MsiCloseHandle( hPackage);
2373 ok( r == ERROR_SUCCESS , "Failed to close package\n" );
2374 DeleteFile(msifile);
2377 static void test_removefiles(void)
2382 char CURR_DIR[MAX_PATH];
2384 GetCurrentDirectoryA(MAX_PATH, CURR_DIR);
2386 hdb = create_package_db();
2387 ok ( hdb, "failed to create package database\n" );
2389 r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
2390 ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
2392 r = create_feature_table( hdb );
2393 ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
2395 r = create_component_table( hdb );
2396 ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
2398 r = add_feature_entry( hdb, "'one', '', '', '', 2, 1, '', 0" );
2399 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2401 r = add_component_entry( hdb, "'hydrogen', '', 'TARGETDIR', 0, '', 'hydrogen_file'" );
2402 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2404 r = add_component_entry( hdb, "'helium', '', 'TARGETDIR', 0, '', 'helium_file'" );
2405 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2407 r = add_component_entry( hdb, "'lithium', '', 'TARGETDIR', 0, '', 'lithium_file'" );
2408 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2410 r = add_component_entry( hdb, "'beryllium', '', 'TARGETDIR', 0, '', 'beryllium_file'" );
2411 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2413 r = add_component_entry( hdb, "'boron', '', 'TARGETDIR', 0, '', 'boron_file'" );
2414 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2416 r = add_component_entry( hdb, "'carbon', '', 'TARGETDIR', 0, '', 'carbon_file'" );
2417 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2419 r = create_feature_components_table( hdb );
2420 ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
2422 r = add_feature_components_entry( hdb, "'one', 'hydrogen'" );
2423 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2425 r = add_feature_components_entry( hdb, "'one', 'helium'" );
2426 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2428 r = add_feature_components_entry( hdb, "'one', 'lithium'" );
2429 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2431 r = add_feature_components_entry( hdb, "'one', 'beryllium'" );
2432 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2434 r = add_feature_components_entry( hdb, "'one', 'boron'" );
2435 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2437 r = add_feature_components_entry( hdb, "'one', 'carbon'" );
2438 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2440 r = create_file_table( hdb );
2441 ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
2443 r = add_file_entry( hdb, "'hydrogen_file', 'hydrogen', 'hydrogen.txt', 0, '', '1033', 8192, 1" );
2444 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2446 r = add_file_entry( hdb, "'helium_file', 'helium', 'helium.txt', 0, '', '1033', 8192, 1" );
2447 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2449 r = add_file_entry( hdb, "'lithium_file', 'lithium', 'lithium.txt', 0, '', '1033', 8192, 1" );
2450 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2452 r = add_file_entry( hdb, "'beryllium_file', 'beryllium', 'beryllium.txt', 0, '', '1033', 16384, 1" );
2453 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2455 r = add_file_entry( hdb, "'boron_file', 'boron', 'boron.txt', 0, '', '1033', 16384, 1" );
2456 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2458 r = add_file_entry( hdb, "'carbon_file', 'carbon', 'carbon.txt', 0, '', '1033', 16384, 1" );
2459 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2461 r = create_remove_file_table( hdb );
2462 ok( r == ERROR_SUCCESS, "cannot create Remove File table: %d\n", r);
2464 hpkg = package_from_db( hdb );
2465 ok( hpkg, "failed to create package\n");
2467 MsiCloseHandle( hdb );
2469 create_test_file( "hydrogen.txt" );
2470 create_test_file( "helium.txt" );
2471 create_test_file( "lithium.txt" );
2472 create_test_file( "beryllium.txt" );
2473 create_test_file( "boron.txt" );
2474 create_test_file( "carbon.txt" );
2476 r = MsiSetProperty( hpkg, "TARGETDIR", CURR_DIR );
2477 ok( r == ERROR_SUCCESS, "set property failed\n");
2479 r = MsiDoAction( hpkg, "CostInitialize");
2480 ok( r == ERROR_SUCCESS, "cost init failed\n");
2482 r = MsiDoAction( hpkg, "FileCost");
2483 ok( r == ERROR_SUCCESS, "cost finalize failed\n");
2485 r = MsiDoAction( hpkg, "CostFinalize");
2486 ok( r == ERROR_SUCCESS, "cost finalize failed\n");
2488 r = MsiDoAction( hpkg, "InstallValidate");
2489 ok( r == ERROR_SUCCESS, "cost finalize failed\n");
2491 r = MsiSetComponentState( hpkg, "hydrogen", INSTALLSTATE_ABSENT );
2492 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
2494 r = MsiSetComponentState( hpkg, "helium", INSTALLSTATE_LOCAL );
2495 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
2497 r = MsiSetComponentState( hpkg, "lithium", INSTALLSTATE_SOURCE );
2498 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
2500 r = MsiSetComponentState( hpkg, "beryllium", INSTALLSTATE_ABSENT );
2501 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
2503 r = MsiSetComponentState( hpkg, "boron", INSTALLSTATE_LOCAL );
2504 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
2506 r = MsiSetComponentState( hpkg, "carbon", INSTALLSTATE_SOURCE );
2507 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
2509 r = MsiDoAction( hpkg, "RemoveFiles");
2510 ok( r == ERROR_SUCCESS, "remove files failed\n");
2512 ok(DeleteFileA("hydrogen.txt"), "Expected hydrogen.txt to exist\n");
2513 ok(DeleteFileA("lithium.txt"), "Expected lithium.txt to exist\n");
2514 ok(DeleteFileA("beryllium.txt"), "Expected beryllium.txt to exist\n");
2515 ok(DeleteFileA("carbon.txt"), "Expected carbon.txt to exist\n");
2516 ok(DeleteFileA("helium.txt"), "Expected helium.txt to exist\n");
2517 ok(DeleteFileA("boron.txt"), "Expected boron.txt to exist\n");
2519 MsiCloseHandle( hpkg );
2520 DeleteFileA(msifile);
2523 static void test_appsearch(void)
2528 CHAR prop[MAX_PATH];
2529 DWORD size = MAX_PATH;
2531 hdb = create_package_db();
2532 ok ( hdb, "failed to create package database\n" );
2534 r = create_appsearch_table( hdb );
2535 ok( r == ERROR_SUCCESS, "cannot create AppSearch table: %d\n", r );
2537 r = add_appsearch_entry( hdb, "'WEBBROWSERPROG', 'NewSignature1'" );
2538 ok( r == ERROR_SUCCESS, "cannot add entry: %d\n", r );
2540 r = create_reglocator_table( hdb );
2541 ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
2543 r = add_reglocator_entry( hdb, "'NewSignature1', 0, 'htmlfile\\shell\\open\\command', '', 1" );
2544 ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
2546 r = create_signature_table( hdb );
2547 ok( r == ERROR_SUCCESS, "cannot create Signature table: %d\n", r );
2549 r = add_signature_entry( hdb, "'NewSignature1', 'FileName', '', '', '', '', '', '', ''" );
2550 ok( r == ERROR_SUCCESS, "cannot create Signature table: %d\n", r );
2552 hpkg = package_from_db( hdb );
2553 ok( hpkg, "failed to create package\n");
2555 MsiCloseHandle( hdb );
2557 r = MsiDoAction( hpkg, "AppSearch" );
2558 ok( r == ERROR_SUCCESS, "AppSearch failed: %d\n", r);
2560 r = MsiGetPropertyA( hpkg, "WEBBROWSERPROG", prop, &size );
2561 ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
2562 ok( lstrlenA(prop) != 0, "Expected non-zero length\n");
2564 MsiCloseHandle( hpkg );
2565 DeleteFileA(msifile);
2568 static void test_featureparents(void)
2573 INSTALLSTATE state, action;
2575 hdb = create_package_db();
2576 ok ( hdb, "failed to create package database\n" );
2578 r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
2579 ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
2581 r = create_feature_table( hdb );
2582 ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
2584 r = create_component_table( hdb );
2585 ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
2587 r = create_feature_components_table( hdb );
2588 ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
2590 r = create_file_table( hdb );
2591 ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
2593 /* msidbFeatureAttributesFavorLocal */
2594 r = add_feature_entry( hdb, "'zodiac', '', '', '', 2, 1, '', 0" );
2595 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2597 /* msidbFeatureAttributesFavorSource */
2598 r = add_feature_entry( hdb, "'perseus', '', '', '', 2, 1, '', 1" );
2599 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2601 /* msidbFeatureAttributesFavorLocal */
2602 r = add_feature_entry( hdb, "'orion', '', '', '', 2, 1, '', 0" );
2603 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2605 /* disabled because of install level */
2606 r = add_feature_entry( hdb, "'waters', '', '', '', 15, 101, '', 9" );
2607 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2609 /* child feature of disabled feature */
2610 r = add_feature_entry( hdb, "'bayer', 'waters', '', '', 14, 1, '', 9" );
2611 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2613 /* component of disabled feature (install level) */
2614 r = add_component_entry( hdb, "'delphinus', '', 'TARGETDIR', 0, '', 'delphinus_file'" );
2615 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2617 /* component of disabled child feature (install level) */
2618 r = add_component_entry( hdb, "'hydrus', '', 'TARGETDIR', 0, '', 'hydrus_file'" );
2619 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2621 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
2622 r = add_component_entry( hdb, "'leo', '', 'TARGETDIR', 0, '', 'leo_file'" );
2623 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2625 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
2626 r = add_component_entry( hdb, "'virgo', '', 'TARGETDIR', 1, '', 'virgo_file'" );
2627 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2629 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
2630 r = add_component_entry( hdb, "'libra', '', 'TARGETDIR', 2, '', 'libra_file'" );
2631 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2633 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
2634 r = add_component_entry( hdb, "'cassiopeia', '', 'TARGETDIR', 0, '', 'cassiopeia_file'" );
2635 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2637 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
2638 r = add_component_entry( hdb, "'cepheus', '', 'TARGETDIR', 1, '', 'cepheus_file'" );
2639 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2641 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
2642 r = add_component_entry( hdb, "'andromeda', '', 'TARGETDIR', 2, '', 'andromeda_file'" );
2643 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2645 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
2646 r = add_component_entry( hdb, "'canis', '', 'TARGETDIR', 0, '', 'canis_file'" );
2647 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2649 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
2650 r = add_component_entry( hdb, "'monoceros', '', 'TARGETDIR', 1, '', 'monoceros_file'" );
2651 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2653 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
2654 r = add_component_entry( hdb, "'lepus', '', 'TARGETDIR', 2, '', 'lepus_file'" );
2656 r = add_feature_components_entry( hdb, "'zodiac', 'leo'" );
2657 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2659 r = add_feature_components_entry( hdb, "'zodiac', 'virgo'" );
2660 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2662 r = add_feature_components_entry( hdb, "'zodiac', 'libra'" );
2663 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2665 r = add_feature_components_entry( hdb, "'perseus', 'cassiopeia'" );
2666 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2668 r = add_feature_components_entry( hdb, "'perseus', 'cepheus'" );
2669 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2671 r = add_feature_components_entry( hdb, "'perseus', 'andromeda'" );
2672 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2674 r = add_feature_components_entry( hdb, "'orion', 'leo'" );
2675 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2677 r = add_feature_components_entry( hdb, "'orion', 'virgo'" );
2678 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2680 r = add_feature_components_entry( hdb, "'orion', 'libra'" );
2681 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2683 r = add_feature_components_entry( hdb, "'orion', 'cassiopeia'" );
2684 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2686 r = add_feature_components_entry( hdb, "'orion', 'cepheus'" );
2687 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2689 r = add_feature_components_entry( hdb, "'orion', 'andromeda'" );
2690 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2692 r = add_feature_components_entry( hdb, "'orion', 'canis'" );
2693 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2695 r = add_feature_components_entry( hdb, "'orion', 'monoceros'" );
2696 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2698 r = add_feature_components_entry( hdb, "'orion', 'lepus'" );
2699 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2701 r = add_feature_components_entry( hdb, "'waters', 'delphinus'" );
2702 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2704 r = add_feature_components_entry( hdb, "'bayer', 'hydrus'" );
2705 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2707 r = add_file_entry( hdb, "'leo_file', 'leo', 'leo.txt', 100, '', '1033', 8192, 1" );
2708 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2710 r = add_file_entry( hdb, "'virgo_file', 'virgo', 'virgo.txt', 0, '', '1033', 8192, 1" );
2711 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2713 r = add_file_entry( hdb, "'libra_file', 'libra', 'libra.txt', 0, '', '1033', 8192, 1" );
2714 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2716 r = add_file_entry( hdb, "'cassiopeia_file', 'cassiopeia', 'cassiopeia.txt', 0, '', '1033', 8192, 1" );
2717 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2719 r = add_file_entry( hdb, "'cepheus_file', 'cepheus', 'cepheus.txt', 0, '', '1033', 8192, 1" );
2720 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2722 r = add_file_entry( hdb, "'andromeda_file', 'andromeda', 'andromeda.txt', 0, '', '1033', 8192, 1" );
2723 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2725 r = add_file_entry( hdb, "'canis_file', 'canis', 'canis.txt', 0, '', '1033', 8192, 1" );
2726 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2728 r = add_file_entry( hdb, "'monoceros_file', 'monoceros', 'monoceros.txt', 0, '', '1033', 8192, 1" );
2729 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2731 r = add_file_entry( hdb, "'lepus_file', 'lepus', 'lepus.txt', 0, '', '1033', 8192, 1" );
2732 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2734 r = add_file_entry( hdb, "'delphinus_file', 'delphinus', 'delphinus.txt', 0, '', '1033', 8192, 1" );
2735 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2737 r = add_file_entry( hdb, "'hydrus_file', 'hydrus', 'hydrus.txt', 0, '', '1033', 8192, 1" );
2738 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2740 hpkg = package_from_db( hdb );
2741 ok( hpkg, "failed to create package\n");
2743 MsiCloseHandle( hdb );
2745 r = MsiDoAction( hpkg, "CostInitialize");
2746 ok( r == ERROR_SUCCESS, "cost init failed\n");
2748 r = MsiDoAction( hpkg, "FileCost");
2749 ok( r == ERROR_SUCCESS, "file cost failed\n");
2751 r = MsiDoAction( hpkg, "CostFinalize");
2752 ok( r == ERROR_SUCCESS, "cost finalize failed\n");
2756 r = MsiGetFeatureState(hpkg, "zodiac", &state, &action);
2757 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2758 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2759 ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
2763 r = MsiGetFeatureState(hpkg, "perseus", &state, &action);
2764 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2765 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2766 ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
2770 r = MsiGetFeatureState(hpkg, "orion", &state, &action);
2771 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2772 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2773 ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
2777 r = MsiGetFeatureState(hpkg, "waters", &state, &action);
2778 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2779 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2780 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2784 r = MsiGetFeatureState(hpkg, "bayer", &state, &action);
2785 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2786 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2787 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2791 r = MsiGetComponentState(hpkg, "leo", &state, &action);
2792 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2793 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2794 ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
2798 r = MsiGetComponentState(hpkg, "virgo", &state, &action);
2799 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2800 ok( state == INSTALLSTATE_UNKNOWN, "Expected virgo INSTALLSTATE_UNKNOWN, got %d\n", state);
2801 ok( action == INSTALLSTATE_SOURCE, "Expected virgo INSTALLSTATE_SOURCE, got %d\n", action);
2805 r = MsiGetComponentState(hpkg, "libra", &state, &action);
2806 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2807 ok( state == INSTALLSTATE_UNKNOWN, "Expected libra INSTALLSTATE_UNKNOWN, got %d\n", state);
2808 ok( action == INSTALLSTATE_LOCAL, "Expected libra INSTALLSTATE_LOCAL, got %d\n", action);
2812 r = MsiGetComponentState(hpkg, "cassiopeia", &state, &action);
2813 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2814 ok( state == INSTALLSTATE_UNKNOWN, "Expected cassiopeia INSTALLSTATE_UNKNOWN, got %d\n", state);
2815 ok( action == INSTALLSTATE_LOCAL, "Expected cassiopeia INSTALLSTATE_LOCAL, got %d\n", action);
2819 r = MsiGetComponentState(hpkg, "cepheus", &state, &action);
2820 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2821 ok( state == INSTALLSTATE_UNKNOWN, "Expected cepheus INSTALLSTATE_UNKNOWN, got %d\n", state);
2822 ok( action == INSTALLSTATE_SOURCE, "Expected cepheus INSTALLSTATE_SOURCE, got %d\n", action);
2826 r = MsiGetComponentState(hpkg, "andromeda", &state, &action);
2827 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2828 ok( state == INSTALLSTATE_UNKNOWN, "Expected andromeda INSTALLSTATE_UNKNOWN, got %d\n", state);
2829 ok( action == INSTALLSTATE_LOCAL, "Expected andromeda INSTALLSTATE_LOCAL, got %d\n", action);
2833 r = MsiGetComponentState(hpkg, "canis", &state, &action);
2834 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2835 ok( state == INSTALLSTATE_UNKNOWN, "Expected canis INSTALLSTATE_UNKNOWN, got %d\n", state);
2836 ok( action == INSTALLSTATE_LOCAL, "Expected canis INSTALLSTATE_LOCAL, got %d\n", action);
2840 r = MsiGetComponentState(hpkg, "monoceros", &state, &action);
2841 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2842 ok( state == INSTALLSTATE_UNKNOWN, "Expected monoceros INSTALLSTATE_UNKNOWN, got %d\n", state);
2843 ok( action == INSTALLSTATE_SOURCE, "Expected monoceros INSTALLSTATE_SOURCE, got %d\n", action);
2847 r = MsiGetComponentState(hpkg, "lepus", &state, &action);
2848 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2849 ok( state == INSTALLSTATE_UNKNOWN, "Expected lepus INSTALLSTATE_UNKNOWN, got %d\n", state);
2850 ok( action == INSTALLSTATE_LOCAL, "Expected lepus INSTALLSTATE_LOCAL, got %d\n", action);
2854 r = MsiGetComponentState(hpkg, "delphinus", &state, &action);
2855 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2856 ok( state == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", state);
2857 ok( action == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", action);
2861 r = MsiGetComponentState(hpkg, "hydrus", &state, &action);
2862 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2863 ok( state == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", state);
2864 ok( action == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", action);
2866 r = MsiSetFeatureState(hpkg, "orion", INSTALLSTATE_ABSENT);
2867 ok( r == ERROR_SUCCESS, "failed to set feature state: %d\n", r);
2871 r = MsiGetFeatureState(hpkg, "zodiac", &state, &action);
2872 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2873 ok( state == INSTALLSTATE_ABSENT, "Expected zodiac INSTALLSTATE_ABSENT, got %d\n", state);
2874 ok( action == INSTALLSTATE_LOCAL, "Expected zodiac INSTALLSTATE_LOCAL, got %d\n", action);
2878 r = MsiGetFeatureState(hpkg, "perseus", &state, &action);
2879 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2880 ok( state == INSTALLSTATE_ABSENT, "Expected perseus INSTALLSTATE_ABSENT, got %d\n", state);
2881 ok( action == INSTALLSTATE_SOURCE, "Expected perseus INSTALLSTATE_SOURCE, got %d\n", action);
2885 r = MsiGetFeatureState(hpkg, "orion", &state, &action);
2886 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2887 ok( state == INSTALLSTATE_ABSENT, "Expected orion INSTALLSTATE_ABSENT, got %d\n", state);
2888 ok( action == INSTALLSTATE_ABSENT, "Expected orion INSTALLSTATE_ABSENT, got %d\n", action);
2892 r = MsiGetComponentState(hpkg, "leo", &state, &action);
2893 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2894 ok( state == INSTALLSTATE_UNKNOWN, "Expected leo INSTALLSTATE_UNKNOWN, got %d\n", state);
2895 ok( action == INSTALLSTATE_LOCAL, "Expected leo INSTALLSTATE_LOCAL, got %d\n", action);
2899 r = MsiGetComponentState(hpkg, "virgo", &state, &action);
2900 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2901 ok( state == INSTALLSTATE_UNKNOWN, "Expected virgo INSTALLSTATE_UNKNOWN, got %d\n", state);
2902 ok( action == INSTALLSTATE_SOURCE, "Expected virgo INSTALLSTATE_SOURCE, got %d\n", action);
2906 r = MsiGetComponentState(hpkg, "libra", &state, &action);
2907 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2908 ok( state == INSTALLSTATE_UNKNOWN, "Expected libra INSTALLSTATE_UNKNOWN, got %d\n", state);
2909 ok( action == INSTALLSTATE_LOCAL, "Expected libra INSTALLSTATE_LOCAL, got %d\n", action);
2913 r = MsiGetComponentState(hpkg, "cassiopeia", &state, &action);
2914 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2915 ok( state == INSTALLSTATE_UNKNOWN, "Expected cassiopeia INSTALLSTATE_UNKNOWN, got %d\n", state);
2916 ok( action == INSTALLSTATE_LOCAL, "Expected cassiopeia INSTALLSTATE_LOCAL, got %d\n", action);
2920 r = MsiGetComponentState(hpkg, "cepheus", &state, &action);
2921 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2922 ok( state == INSTALLSTATE_UNKNOWN, "Expected cepheus INSTALLSTATE_UNKNOWN, got %d\n", state);
2923 ok( action == INSTALLSTATE_SOURCE, "Expected cepheus INSTALLSTATE_SOURCE, got %d\n", action);
2927 r = MsiGetComponentState(hpkg, "andromeda", &state, &action);
2928 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2929 ok( state == INSTALLSTATE_UNKNOWN, "Expected andromeda INSTALLSTATE_UNKNOWN, got %d\n", state);
2930 ok( action == INSTALLSTATE_SOURCE, "Expected andromeda INSTALLSTATE_SOURCE, got %d\n", action);
2934 r = MsiGetComponentState(hpkg, "canis", &state, &action);
2935 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2936 ok( state == INSTALLSTATE_UNKNOWN, "Expected canis INSTALLSTATE_UNKNOWN, got %d\n", state);
2937 ok( action == INSTALLSTATE_UNKNOWN, "Expected canis INSTALLSTATE_UNKNOWN, got %d\n", action);
2941 r = MsiGetComponentState(hpkg, "monoceros", &state, &action);
2942 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2943 ok( state == INSTALLSTATE_UNKNOWN, "Expected monoceros INSTALLSTATE_UNKNOWN, got %d\n", state);
2944 ok( action == INSTALLSTATE_UNKNOWN, "Expected monoceros INSTALLSTATE_UNKNOWN, got %d\n", action);
2948 r = MsiGetComponentState(hpkg, "lepus", &state, &action);
2949 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2950 ok( state == INSTALLSTATE_UNKNOWN, "Expected lepus INSTALLSTATE_UNKNOWN, got %d\n", state);
2951 ok( action == INSTALLSTATE_UNKNOWN, "Expected lepus INSTALLSTATE_UNKNOWN, got %d\n", action);
2955 r = MsiGetComponentState(hpkg, "delphinus", &state, &action);
2956 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2957 ok( state == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", state);
2958 ok( action == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", action);
2962 r = MsiGetComponentState(hpkg, "hydrus", &state, &action);
2963 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2964 ok( state == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", state);
2965 ok( action == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", action);
2967 MsiCloseHandle(hpkg);
2968 DeleteFileA(msifile);
2971 static void test_installprops(void)
2973 MSIHANDLE hpkg, hdb;
2974 CHAR path[MAX_PATH];
2980 GetCurrentDirectory(MAX_PATH, path);
2981 lstrcat(path, "\\");
2982 lstrcat(path, msifile);
2984 hdb = create_package_db();
2985 ok( hdb, "failed to create database\n");
2987 hpkg = package_from_db(hdb);
2988 ok( hpkg, "failed to create package\n");
2990 MsiCloseHandle(hdb);
2993 r = MsiGetProperty(hpkg, "DATABASE", buf, &size);
2994 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
2995 ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
2997 RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", &hkey);
3001 RegQueryValueEx(hkey, "RegisteredOwner", NULL, &type, (LPBYTE)path, &size);
3004 r = MsiGetProperty(hpkg, "USERNAME", buf, &size);
3005 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
3006 ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
3010 RegQueryValueEx(hkey, "RegisteredOrganization", NULL, &type, (LPBYTE)path, &size);
3013 r = MsiGetProperty(hpkg, "COMPANYNAME", buf, &size);
3014 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
3015 ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
3018 r = MsiGetProperty(hpkg, "VersionDatabase", buf, &size);
3019 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
3020 trace("VersionDatabase = %s\n", buf);
3023 r = MsiGetProperty(hpkg, "VersionMsi", buf, &size);
3024 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
3025 trace("VersionMsi = %s\n", buf);
3028 r = MsiGetProperty(hpkg, "Date", buf, &size);
3029 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
3030 trace("Date = %s\n", buf);
3033 r = MsiGetProperty(hpkg, "Time", buf, &size);
3034 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
3035 trace("Time = %s\n", buf);
3038 r = MsiGetProperty(hpkg, "PackageCode", buf, &size);
3039 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
3040 trace("PackageCode = %s\n", buf);
3043 MsiCloseHandle(hpkg);
3044 DeleteFile(msifile);
3047 static void test_sourcedirprop(void)
3049 MSIHANDLE hpkg, hdb;
3050 CHAR source_dir[MAX_PATH];
3051 CHAR path[MAX_PATH];
3055 hdb = create_package_db();
3056 ok ( hdb, "failed to create package database\n" );
3058 r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
3059 ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
3061 hpkg = package_from_db( hdb );
3062 ok( hpkg, "failed to create package\n");
3064 MsiCloseHandle( hdb );
3067 r = MsiGetProperty( hpkg, "SourceDir", source_dir, &size );
3068 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
3069 ok( !lstrlenA(source_dir), "Expected emtpy source dir, got %s\n", source_dir);
3072 r = MsiGetProperty( hpkg, "SOURCEDIR", source_dir, &size );
3073 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
3074 ok( !lstrlenA(source_dir), "Expected emtpy source dir, got %s\n", source_dir);
3076 r = MsiDoAction( hpkg, "CostInitialize");
3077 ok( r == ERROR_SUCCESS, "cost init failed\n");
3080 r = MsiGetProperty( hpkg, "SourceDir", source_dir, &size );
3081 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
3082 ok( !lstrlenA(source_dir), "Expected emtpy source dir, got %s\n", source_dir);
3085 r = MsiGetProperty( hpkg, "SOURCEDIR", source_dir, &size );
3086 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
3087 ok( !lstrlenA(source_dir), "Expected emtpy source dir, got %s\n", source_dir);
3089 r = MsiDoAction( hpkg, "ResolveSource");
3090 ok( r == ERROR_SUCCESS, "file cost failed\n");
3092 GetCurrentDirectory(MAX_PATH, path);
3093 lstrcatA(path, "\\");
3096 r = MsiGetProperty( hpkg, "SourceDir", source_dir, &size );
3097 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
3098 ok( !lstrcmpA(source_dir, path), "Expected %s, got %s\n", path, source_dir);
3101 r = MsiGetProperty( hpkg, "SOURCEDIR", source_dir, &size );
3102 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
3103 ok( !lstrcmpA(source_dir, path), "Expected %s, got %s\n", path, source_dir);
3106 r = MsiGetProperty( hpkg, "SoUrCeDiR", source_dir, &size );
3107 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
3108 ok( !lstrlenA(source_dir), "Expected emtpy source dir, got %s\n", source_dir);
3110 MsiCloseHandle(hpkg);
3111 DeleteFileA(msifile);
3114 static void test_prop_path(void)
3116 MSIHANDLE hpkg, hdb;
3117 char buffer[MAX_PATH], cwd[MAX_PATH];
3121 GetCurrentDirectory(MAX_PATH, cwd);
3124 hdb = create_package_db();
3125 ok( hdb, "failed to create database\n");
3127 r = add_directory_entry( hdb, "'TARGETDIR','','SourceDir'" );
3128 ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
3130 r = add_directory_entry( hdb, "'foo','TARGETDIR','foosrc:footgt'" );
3131 ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
3133 hpkg = package_from_db(hdb);
3134 ok( hpkg, "failed to create package\n");
3136 r = MsiGetSourcePath(hpkg, "SourceDir", buffer, &sz );
3137 ok( r == ERROR_DIRECTORY, "failed to get source path\n");
3139 r = MsiGetSourcePath(hpkg, "SOURCEDIR", buffer, &sz );
3140 ok( r == ERROR_DIRECTORY, "failed to get source path\n");
3142 r = MsiDoAction( hpkg, "CostInitialize");
3143 ok( r == ERROR_SUCCESS, "cost init failed\n");
3147 r = MsiGetProperty(hpkg, "SourceDir", buffer, &sz);
3148 ok( r == ERROR_SUCCESS, "property not set\n");
3149 ok( !buffer[0], "SourceDir should be empty\n");
3153 r = MsiGetProperty(hpkg, "SOURCEDIR", buffer, &sz);
3154 ok( r == ERROR_SUCCESS, "property not set\n");
3155 ok( !buffer[0], "SourceDir should be empty\n");
3159 r = MsiGetSourcePath(hpkg, "SourceDir", buffer, &sz );
3160 ok( r == ERROR_SUCCESS, "failed to get source path\n");
3161 ok( !lstrcmpi(cwd, buffer), "SourceDir (%s) should be current dir (%s)\n", buffer, cwd);
3165 r = MsiGetProperty(hpkg, "SourceDir", buffer, &sz);
3166 ok( r == ERROR_SUCCESS, "property not set\n");
3168 ok( !lstrcmpi(cwd, buffer), "SourceDir (%s) should be current dir (%s)\n", buffer, cwd);
3173 r = MsiGetSourcePath(hpkg, "SOURCEDIR", buffer, &sz );
3174 ok( r == ERROR_DIRECTORY, "failed to get source path\n");
3178 r = MsiGetProperty(hpkg, "SOURCEDIR", buffer, &sz);
3179 ok( r == ERROR_SUCCESS, "property not set\n");
3181 ok( !lstrcmpi(cwd, buffer), "SourceDir (%s) should be current dir (%s)\n", buffer, cwd);
3184 r = MsiSetProperty(hpkg, "SourceDir", "goo");
3185 ok( r == ERROR_SUCCESS, "property not set\n");
3189 r = MsiGetProperty(hpkg, "SourceDir", buffer, &sz);
3190 ok( r == ERROR_SUCCESS, "property not set\n");
3191 ok( !lstrcmpi(buffer, "goo"), "SourceDir (%s) should be goo\n", buffer);
3195 r = MsiGetSourcePath(hpkg, "SourceDir", buffer, &sz );
3196 ok( r == ERROR_SUCCESS, "failed to get source path\n");
3197 ok( !lstrcmpi(buffer, cwd), "SourceDir (%s) should be goo\n", buffer);
3201 r = MsiGetProperty(hpkg, "SourceDir", buffer, &sz);
3202 ok( r == ERROR_SUCCESS, "property not set\n");
3203 ok( !lstrcmpi(buffer, "goo"), "SourceDir (%s) should be goo\n", buffer);
3205 MsiCloseHandle( hpkg );
3206 DeleteFile(msifile);
3211 test_createpackage();
3212 test_getsourcepath_bad();
3213 test_getsourcepath();
3215 test_gettargetpath_bad();
3216 test_settargetpath();
3218 test_properties_table();
3221 test_formatrecord2();
3226 test_featureparents();
3227 test_installprops();
3228 test_sourcedirprop();