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
do_query(MSIHANDLE hdb
, const char *query
, MSIHANDLE
*phrec
)
38 /* open a select query */
39 r
= MsiDatabaseOpenView(hdb
, query
, &hview
);
40 if (r
!= ERROR_SUCCESS
)
42 r
= MsiViewExecute(hview
, 0);
43 if (r
!= ERROR_SUCCESS
)
45 ret
= MsiViewFetch(hview
, phrec
);
46 r
= MsiViewClose(hview
);
47 if (r
!= ERROR_SUCCESS
)
49 r
= MsiCloseHandle(hview
);
50 if (r
!= ERROR_SUCCESS
)
55 static UINT
run_query( MSIHANDLE hdb
, const char *query
)
60 r
= MsiDatabaseOpenView(hdb
, query
, &hview
);
61 if( r
!= ERROR_SUCCESS
)
64 r
= MsiViewExecute(hview
, 0);
65 if( r
== ERROR_SUCCESS
)
66 r
= MsiViewClose(hview
);
67 MsiCloseHandle(hview
);
71 static UINT
create_component_table( MSIHANDLE hdb
)
73 return run_query( hdb
,
74 "CREATE TABLE `Component` ( "
75 "`Component` CHAR(72) NOT NULL, "
76 "`ComponentId` CHAR(38), "
77 "`Directory_` CHAR(72) NOT NULL, "
78 "`Attributes` SHORT NOT NULL, "
79 "`Condition` CHAR(255), "
81 "PRIMARY KEY `Component`)" );
84 static UINT
create_feature_table( MSIHANDLE hdb
)
86 return run_query( hdb
,
87 "CREATE TABLE `Feature` ( "
88 "`Feature` CHAR(38) NOT NULL, "
89 "`Feature_Parent` CHAR(38), "
91 "`Description` CHAR(255), "
92 "`Display` SHORT NOT NULL, "
93 "`Level` SHORT NOT NULL, "
94 "`Directory_` CHAR(72), "
95 "`Attributes` SHORT NOT NULL "
96 "PRIMARY KEY `Feature`)" );
99 static UINT
create_feature_components_table( MSIHANDLE hdb
)
101 return run_query( hdb
,
102 "CREATE TABLE `FeatureComponents` ( "
103 "`Feature_` CHAR(38) NOT NULL, "
104 "`Component_` CHAR(72) NOT NULL "
105 "PRIMARY KEY `Feature_`, `Component_` )" );
108 static UINT
create_file_table( MSIHANDLE hdb
)
110 return run_query( hdb
,
111 "CREATE TABLE `File` ("
112 "`File` CHAR(72) NOT NULL, "
113 "`Component_` CHAR(72) NOT NULL, "
114 "`FileName` CHAR(255) NOT NULL, "
115 "`FileSize` LONG NOT NULL, "
116 "`Version` CHAR(72), "
117 "`Language` CHAR(20), "
118 "`Attributes` SHORT, "
119 "`Sequence` SHORT NOT NULL "
120 "PRIMARY KEY `File`)" );
123 static UINT
create_remove_file_table( MSIHANDLE hdb
)
125 return run_query( hdb
,
126 "CREATE TABLE `RemoveFile` ("
127 "`FileKey` CHAR(72) NOT NULL, "
128 "`Component_` CHAR(72) NOT NULL, "
129 "`FileName` CHAR(255) LOCALIZABLE, "
130 "`DirProperty` CHAR(72) NOT NULL, "
131 "`InstallMode` SHORT NOT NULL "
132 "PRIMARY KEY `FileKey`)" );
135 static UINT
create_appsearch_table( MSIHANDLE hdb
)
137 return run_query( hdb
,
138 "CREATE TABLE `AppSearch` ("
139 "`Property` CHAR(72) NOT NULL, "
140 "`Signature_` CHAR(72) NOT NULL "
141 "PRIMARY KEY `Property`, `Signature_`)" );
144 static UINT
create_reglocator_table( MSIHANDLE hdb
)
146 return run_query( hdb
,
147 "CREATE TABLE `RegLocator` ("
148 "`Signature_` CHAR(72) NOT NULL, "
149 "`Root` SHORT NOT NULL, "
150 "`Key` CHAR(255) NOT NULL, "
153 "PRIMARY KEY `Signature_`)" );
156 static UINT
create_signature_table( MSIHANDLE hdb
)
158 return run_query( hdb
,
159 "CREATE TABLE `Signature` ("
160 "`Signature` CHAR(72) NOT NULL, "
161 "`FileName` CHAR(255) NOT NULL, "
162 "`MinVersion` CHAR(20), "
163 "`MaxVersion` CHAR(20), "
168 "`Languages` CHAR(255) "
169 "PRIMARY KEY `Signature`)" );
172 static UINT
create_launchcondition_table( MSIHANDLE hdb
)
174 return run_query( hdb
,
175 "CREATE TABLE `LaunchCondition` ("
176 "`Condition` CHAR(255) NOT NULL, "
177 "`Description` CHAR(255) NOT NULL "
178 "PRIMARY KEY `Condition`)" );
181 static UINT
create_property_table( MSIHANDLE hdb
)
183 return run_query( hdb
,
184 "CREATE TABLE `Property` ("
185 "`Property` CHAR(72) NOT NULL, "
187 "PRIMARY KEY `Property`)" );
190 static UINT
add_component_entry( MSIHANDLE hdb
, const char *values
)
192 char insert
[] = "INSERT INTO `Component` "
193 "(`Component`, `ComponentId`, `Directory_`, `Attributes`, `Condition`, `KeyPath`) "
198 sz
= strlen(values
) + sizeof insert
;
199 query
= HeapAlloc(GetProcessHeap(),0,sz
);
200 sprintf(query
,insert
,values
);
201 r
= run_query( hdb
, query
);
202 HeapFree(GetProcessHeap(), 0, query
);
206 static UINT
add_feature_entry( MSIHANDLE hdb
, const char *values
)
208 char insert
[] = "INSERT INTO `Feature` (`Feature`, `Feature_Parent`, "
209 "`Title`, `Description`, `Display`, `Level`, `Directory_`, `Attributes`) VALUES( %s )";
213 sz
= strlen(values
) + sizeof insert
;
214 query
= HeapAlloc(GetProcessHeap(),0,sz
);
215 sprintf(query
,insert
,values
);
216 r
= run_query( hdb
, query
);
217 HeapFree(GetProcessHeap(), 0, query
);
221 static UINT
add_feature_components_entry( MSIHANDLE hdb
, const char *values
)
223 char insert
[] = "INSERT INTO `FeatureComponents` "
224 "(`Feature_`, `Component_`) "
229 sz
= strlen(values
) + sizeof insert
;
230 query
= HeapAlloc(GetProcessHeap(),0,sz
);
231 sprintf(query
,insert
,values
);
232 r
= run_query( hdb
, query
);
233 HeapFree(GetProcessHeap(), 0, query
);
237 static UINT
add_file_entry( MSIHANDLE hdb
, const char *values
)
239 char insert
[] = "INSERT INTO `File` "
240 "(`File`, `Component_`, `FileName`, `FileSize`, `Version`, `Language`, `Attributes`, `Sequence`) "
245 sz
= strlen(values
) + sizeof insert
;
246 query
= HeapAlloc(GetProcessHeap(),0,sz
);
247 sprintf(query
,insert
,values
);
248 r
= run_query( hdb
, query
);
249 HeapFree(GetProcessHeap(), 0, query
);
253 static UINT
add_appsearch_entry( MSIHANDLE hdb
, const char *values
)
255 char insert
[] = "INSERT INTO `AppSearch` "
256 "(`Property`, `Signature_`) "
261 sz
= strlen(values
) + sizeof insert
;
262 query
= HeapAlloc(GetProcessHeap(),0,sz
);
263 sprintf(query
,insert
,values
);
264 r
= run_query( hdb
, query
);
265 HeapFree(GetProcessHeap(), 0, query
);
269 static UINT
add_reglocator_entry( MSIHANDLE hdb
, const char *values
)
271 char insert
[] = "INSERT INTO `RegLocator` "
272 "(`Signature_`, `Root`, `Key`, `Name`, `Type`) "
277 sz
= strlen(values
) + sizeof insert
;
278 query
= HeapAlloc(GetProcessHeap(),0,sz
);
279 sprintf(query
,insert
,values
);
280 r
= run_query( hdb
, query
);
281 HeapFree(GetProcessHeap(), 0, query
);
285 static UINT
add_signature_entry( MSIHANDLE hdb
, const char *values
)
287 char insert
[] = "INSERT INTO `Signature` "
288 "(`Signature`, `FileName`, `MinVersion`, `MaxVersion`,"
289 " `MinSize`, `MaxSize`, `MinDate`, `MaxDate`, `Languages`) "
294 sz
= strlen(values
) + sizeof insert
;
295 query
= HeapAlloc(GetProcessHeap(),0,sz
);
296 sprintf(query
,insert
,values
);
297 r
= run_query( hdb
, query
);
298 HeapFree(GetProcessHeap(), 0, query
);
302 static UINT
add_launchcondition_entry( MSIHANDLE hdb
, const char *values
)
304 char insert
[] = "INSERT INTO `LaunchCondition` "
305 "(`Condition`, `Description`) "
310 sz
= strlen(values
) + sizeof insert
;
311 query
= HeapAlloc(GetProcessHeap(),0,sz
);
312 sprintf(query
,insert
,values
);
313 r
= run_query( hdb
, query
);
314 HeapFree(GetProcessHeap(), 0, query
);
318 static UINT
add_property_entry( MSIHANDLE hdb
, const char *values
)
320 char insert
[] = "INSERT INTO `Property` "
321 "(`Property`, `Value`) "
326 sz
= strlen(values
) + sizeof insert
;
327 query
= HeapAlloc(GetProcessHeap(),0,sz
);
328 sprintf(query
,insert
,values
);
329 r
= run_query( hdb
, query
);
330 HeapFree(GetProcessHeap(), 0, query
);
334 static UINT
set_summary_info(MSIHANDLE hdb
)
339 /* build summmary info */
340 res
= MsiGetSummaryInformation(hdb
, NULL
, 7, &suminfo
);
341 ok( res
== ERROR_SUCCESS
, "Failed to open summaryinfo\n" );
343 res
= MsiSummaryInfoSetProperty(suminfo
,2, VT_LPSTR
, 0,NULL
,
344 "Installation Database");
345 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
347 res
= MsiSummaryInfoSetProperty(suminfo
,3, VT_LPSTR
, 0,NULL
,
348 "Installation Database");
349 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
351 res
= MsiSummaryInfoSetProperty(suminfo
,4, VT_LPSTR
, 0,NULL
,
353 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
355 res
= MsiSummaryInfoSetProperty(suminfo
,7, VT_LPSTR
, 0,NULL
,
357 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
359 res
= MsiSummaryInfoSetProperty(suminfo
,9, VT_LPSTR
, 0,NULL
,
360 "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}");
361 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
363 res
= MsiSummaryInfoSetProperty(suminfo
, 14, VT_I4
, 100, NULL
, NULL
);
364 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
366 res
= MsiSummaryInfoSetProperty(suminfo
, 15, VT_I4
, 0, NULL
, NULL
);
367 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
369 res
= MsiSummaryInfoPersist(suminfo
);
370 ok( res
== ERROR_SUCCESS
, "Failed to make summary info persist\n" );
372 res
= MsiCloseHandle( suminfo
);
373 ok( res
== ERROR_SUCCESS
, "Failed to close suminfo\n" );
379 static MSIHANDLE
create_package_db(void)
386 /* create an empty database */
387 res
= MsiOpenDatabase(msifile
, MSIDBOPEN_CREATE
, &hdb
);
388 ok( res
== ERROR_SUCCESS
, "Failed to create database\n" );
389 if( res
!= ERROR_SUCCESS
)
392 res
= MsiDatabaseCommit( hdb
);
393 ok( res
== ERROR_SUCCESS
, "Failed to commit database\n" );
395 res
= set_summary_info(hdb
);
397 res
= run_query( hdb
,
398 "CREATE TABLE `Directory` ( "
399 "`Directory` CHAR(255) NOT NULL, "
400 "`Directory_Parent` CHAR(255), "
401 "`DefaultDir` CHAR(255) NOT NULL "
402 "PRIMARY KEY `Directory`)" );
403 ok( res
== ERROR_SUCCESS
, "Failed to create directory table\n" );
408 static MSIHANDLE
package_from_db(MSIHANDLE hdb
)
414 sprintf(szPackage
,"#%li",hdb
);
415 res
= MsiOpenPackage(szPackage
,&hPackage
);
416 if (res
!= ERROR_SUCCESS
)
419 res
= MsiCloseHandle(hdb
);
420 if (res
!= ERROR_SUCCESS
)
426 static void create_test_file(const CHAR
*name
)
431 file
= CreateFileA(name
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, 0, NULL
);
432 ok(file
!= INVALID_HANDLE_VALUE
, "Failure to open file %s\n", name
);
433 WriteFile(file
, name
, strlen(name
), &written
, NULL
);
434 WriteFile(file
, "\n", strlen("\n"), &written
, NULL
);
438 static void test_createpackage(void)
440 MSIHANDLE hPackage
= 0;
443 hPackage
= package_from_db(create_package_db());
444 ok( hPackage
!= 0, " Failed to create package\n");
446 res
= MsiCloseHandle( hPackage
);
447 ok( res
== ERROR_SUCCESS
, "Failed to close package\n" );
451 static void test_getsourcepath_bad( void )
453 static const char str
[] = { 0 };
458 r
= MsiGetSourcePath( -1, NULL
, NULL
, NULL
);
459 ok( r
== ERROR_INVALID_PARAMETER
, "return value wrong\n");
462 r
= MsiGetSourcePath( -1, NULL
, buffer
, &sz
);
463 ok( r
== ERROR_INVALID_PARAMETER
, "return value wrong\n");
466 r
= MsiGetSourcePath( -1, str
, NULL
, &sz
);
467 ok( r
== ERROR_INVALID_HANDLE
, "return value wrong\n");
470 r
= MsiGetSourcePath( -1, str
, NULL
, NULL
);
471 ok( r
== ERROR_INVALID_HANDLE
, "return value wrong\n");
474 r
= MsiGetSourcePath( -1, str
, buffer
, &sz
);
475 ok( r
== ERROR_INVALID_HANDLE
, "return value wrong\n");
478 static UINT
add_directory_entry( MSIHANDLE hdb
, const char *values
)
480 char insert
[] = "INSERT INTO `Directory` (`Directory`,`Directory_Parent`,`DefaultDir`) VALUES( %s )";
484 sz
= strlen(values
) + sizeof insert
;
485 query
= HeapAlloc(GetProcessHeap(),0,sz
);
486 sprintf(query
,insert
,values
);
487 r
= run_query( hdb
, query
);
488 HeapFree(GetProcessHeap(), 0, query
);
492 static void test_getsourcepath( void )
494 static const char str
[] = { 0 };
500 hpkg
= package_from_db(create_package_db());
501 ok( hpkg
, "failed to create package\n");
505 r
= MsiGetSourcePath( hpkg
, str
, buffer
, &sz
);
506 ok( r
== ERROR_DIRECTORY
, "return value wrong\n");
507 ok( buffer
[0] == 'x', "buffer modified\n");
511 r
= MsiGetSourcePath( hpkg
, str
, buffer
, &sz
);
512 ok( r
== ERROR_DIRECTORY
, "return value wrong\n");
513 ok( buffer
[0] == 'x', "buffer modified\n");
515 MsiCloseHandle( hpkg
);
518 /* another test but try create a directory this time */
519 hdb
= create_package_db();
520 ok( hdb
, "failed to create database\n");
522 r
= add_directory_entry( hdb
, "'TARGETDIR', '', 'SourceDir'");
523 ok( r
== S_OK
, "failed\n");
525 hpkg
= package_from_db(hdb
);
526 ok( hpkg
, "failed to create package\n");
528 sz
= sizeof buffer
-1;
529 strcpy(buffer
,"x bad");
530 r
= MsiGetSourcePath( hpkg
, "TARGETDIR", buffer
, &sz
);
531 ok( r
== ERROR_DIRECTORY
, "return value wrong\n");
533 r
= MsiDoAction( hpkg
, "CostInitialize");
534 ok( r
== ERROR_SUCCESS
, "cost init failed\n");
535 r
= MsiDoAction( hpkg
, "CostFinalize");
536 ok( r
== ERROR_SUCCESS
, "cost finalize failed\n");
538 sz
= sizeof buffer
-1;
540 r
= MsiGetSourcePath( hpkg
, "TARGETDIR", buffer
, &sz
);
541 ok( r
== ERROR_SUCCESS
, "return value wrong\n");
542 ok( sz
== strlen(buffer
), "returned length wrong\n");
545 strcpy(buffer
,"x bad");
546 r
= MsiGetSourcePath( hpkg
, "TARGETDIR", buffer
, &sz
);
547 ok( r
== ERROR_MORE_DATA
, "return value wrong\n");
548 ok( buffer
[0] == 'x', "buffer modified\n");
550 r
= MsiGetSourcePath( hpkg
, "TARGETDIR", NULL
, NULL
);
551 ok( r
== ERROR_SUCCESS
, "return value wrong\n");
553 r
= MsiGetSourcePath( hpkg
, "TARGETDIR ", NULL
, NULL
);
554 ok( r
== ERROR_DIRECTORY
, "return value wrong\n");
556 r
= MsiGetSourcePath( hpkg
, "targetdir", NULL
, NULL
);
557 ok( r
== ERROR_DIRECTORY
, "return value wrong\n");
559 r
= MsiGetSourcePath( hpkg
, "TARGETDIR", buffer
, NULL
);
560 ok( r
== ERROR_INVALID_PARAMETER
, "return value wrong\n");
562 r
= MsiGetSourcePath( hpkg
, "TARGETDIR", NULL
, &sz
);
563 ok( r
== ERROR_SUCCESS
, "return value wrong\n");
565 MsiCloseHandle( hpkg
);
569 static void test_doaction( void )
574 r
= MsiDoAction( -1, NULL
);
575 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
577 hpkg
= package_from_db(create_package_db());
578 ok( hpkg
, "failed to create package\n");
580 r
= MsiDoAction(hpkg
, NULL
);
581 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
583 r
= MsiDoAction(0, "boo");
584 ok( r
== ERROR_INVALID_HANDLE
, "wrong return val\n");
586 r
= MsiDoAction(hpkg
, "boo");
587 ok( r
== ERROR_FUNCTION_NOT_CALLED
, "wrong return val\n");
589 MsiCloseHandle( hpkg
);
593 static void test_gettargetpath_bad(void)
600 hpkg
= package_from_db(create_package_db());
601 ok( hpkg
, "failed to create package\n");
603 r
= MsiGetTargetPath( 0, NULL
, NULL
, NULL
);
604 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
606 r
= MsiGetTargetPath( 0, NULL
, NULL
, &sz
);
607 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
609 r
= MsiGetTargetPath( 0, "boo", NULL
, NULL
);
610 ok( r
== ERROR_INVALID_HANDLE
, "wrong return val\n");
612 r
= MsiGetTargetPath( 0, "boo", NULL
, NULL
);
613 ok( r
== ERROR_INVALID_HANDLE
, "wrong return val\n");
615 r
= MsiGetTargetPath( hpkg
, "boo", NULL
, NULL
);
616 ok( r
== ERROR_DIRECTORY
, "wrong return val\n");
618 r
= MsiGetTargetPath( hpkg
, "boo", buffer
, NULL
);
619 ok( r
== ERROR_DIRECTORY
, "wrong return val\n");
621 MsiCloseHandle( hpkg
);
625 static void query_file_path(MSIHANDLE hpkg
, LPCSTR file
, LPSTR buff
)
631 rec
= MsiCreateRecord( 1 );
632 ok(rec
, "MsiCreate record failed\n");
634 r
= MsiRecordSetString( rec
, 0, file
);
635 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
638 r
= MsiFormatRecord( hpkg
, rec
, buff
, &size
);
639 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
641 MsiCloseHandle( rec
);
644 static void test_settargetpath(void)
646 char tempdir
[MAX_PATH
+8], buffer
[MAX_PATH
], file
[MAX_PATH
];
652 hdb
= create_package_db();
653 ok ( hdb
, "failed to create package database\n" );
655 r
= add_directory_entry( hdb
, "'TARGETDIR', '', 'SourceDir'" );
656 ok( r
== S_OK
, "failed to add directory entry: %d\n" , r
);
658 r
= create_component_table( hdb
);
659 ok( r
== S_OK
, "cannot create Component table: %d\n", r
);
661 r
= add_component_entry( hdb
, "'RootComp', '{83e2694d-0864-4124-9323-6d37630912a1}', 'TARGETDIR', 8, '', 'RootFile'" );
662 ok( r
== S_OK
, "cannot add dummy component: %d\n", r
);
664 r
= add_component_entry( hdb
, "'TestComp', '{A3FB59C8-C293-4F7E-B8C5-F0E1D8EEE4E5}', 'TestDir', 0, '', 'TestFile'" );
665 ok( r
== S_OK
, "cannot add test component: %d\n", r
);
667 r
= create_feature_table( hdb
);
668 ok( r
== S_OK
, "cannot create Feature table: %d\n", r
);
670 r
= add_feature_entry( hdb
, "'TestFeature', '', '', '', 0, 1, '', 0" );
671 ok( r
== ERROR_SUCCESS
, "cannot add TestFeature to Feature table: %d\n", r
);
673 r
= create_feature_components_table( hdb
);
674 ok( r
== S_OK
, "cannot create FeatureComponents table: %d\n", r
);
676 r
= add_feature_components_entry( hdb
, "'TestFeature', 'RootComp'" );
677 ok( r
== S_OK
, "cannot insert component into FeatureComponents table: %d\n", r
);
679 r
= add_feature_components_entry( hdb
, "'TestFeature', 'TestComp'" );
680 ok( r
== S_OK
, "cannot insert component into FeatureComponents table: %d\n", r
);
682 add_directory_entry( hdb
, "'TestParent', 'TARGETDIR', 'TestParent'" );
683 add_directory_entry( hdb
, "'TestDir', 'TestParent', 'TestDir'" );
685 r
= create_file_table( hdb
);
686 ok( r
== S_OK
, "cannot create File table: %d\n", r
);
688 r
= add_file_entry( hdb
, "'RootFile', 'RootComp', 'rootfile.txt', 0, '', '1033', 8192, 1" );
689 ok( r
== S_OK
, "cannot add file to the File table: %d\n", r
);
691 r
= add_file_entry( hdb
, "'TestFile', 'TestComp', 'testfile.txt', 0, '', '1033', 8192, 1" );
692 ok( r
== S_OK
, "cannot add file to the File table: %d\n", r
);
694 hpkg
= package_from_db( hdb
);
695 ok( hpkg
, "failed to create package\n");
697 r
= MsiDoAction( hpkg
, "CostInitialize");
698 ok( r
== ERROR_SUCCESS
, "cost init failed\n");
700 r
= MsiDoAction( hpkg
, "FileCost");
701 ok( r
== ERROR_SUCCESS
, "file cost failed\n");
703 r
= MsiDoAction( hpkg
, "CostFinalize");
704 ok( r
== ERROR_SUCCESS
, "cost finalize failed\n");
706 r
= MsiSetTargetPath( 0, NULL
, NULL
);
707 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
709 r
= MsiSetTargetPath( 0, "boo", "C:\\bogusx" );
710 ok( r
== ERROR_INVALID_HANDLE
, "wrong return val\n");
712 r
= MsiSetTargetPath( hpkg
, "boo", NULL
);
713 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
715 r
= MsiSetTargetPath( hpkg
, "boo", "c:\\bogusx" );
716 ok( r
== ERROR_DIRECTORY
, "wrong return val\n");
718 sz
= sizeof tempdir
- 1;
719 r
= MsiGetTargetPath( hpkg
, "TARGETDIR", tempdir
, &sz
);
720 sprintf( file
, "%srootfile.txt", tempdir
);
721 query_file_path( hpkg
, "[#RootFile]", buffer
);
722 ok( r
== ERROR_SUCCESS
, "failed to get target path: %d\n", r
);
723 ok( !lstrcmp(buffer
, file
), "Expected %s, got %s\n", file
, buffer
);
725 GetTempFileName( tempdir
, "_wt", 0, buffer
);
726 sprintf( tempdir
, "%s\\subdir", buffer
);
728 r
= MsiSetTargetPath( hpkg
, "TARGETDIR", buffer
);
729 ok( r
== ERROR_SUCCESS
, "MsiSetTargetPath on file returned %d\n", r
);
731 r
= MsiSetTargetPath( hpkg
, "TARGETDIR", tempdir
);
732 ok( r
== ERROR_SUCCESS
, "MsiSetTargetPath on 'subdir' of file returned %d\n", r
);
734 DeleteFile( buffer
);
736 r
= MsiSetTargetPath( hpkg
, "TARGETDIR", buffer
);
737 ok( r
== ERROR_SUCCESS
, "MsiSetTargetPath returned %d\n", r
);
739 r
= GetFileAttributes( buffer
);
740 ok ( r
== INVALID_FILE_ATTRIBUTES
, "file/directory exists after MsiSetTargetPath. Attributes: %08X\n", r
);
742 r
= MsiSetTargetPath( hpkg
, "TARGETDIR", tempdir
);
743 ok( r
== ERROR_SUCCESS
, "MsiSetTargetPath on subsubdir returned %d\n", r
);
745 sz
= sizeof buffer
- 1;
746 lstrcat( tempdir
, "\\" );
747 r
= MsiGetTargetPath( hpkg
, "TARGETDIR", buffer
, &sz
);
748 ok( r
== ERROR_SUCCESS
, "failed to get target path: %d\n", r
);
749 ok( !lstrcmp(buffer
, tempdir
), "Expected %s, got %s\n", tempdir
, buffer
);
751 sprintf( file
, "%srootfile.txt", tempdir
);
752 query_file_path( hpkg
, "[#RootFile]", buffer
);
753 ok( !lstrcmp(buffer
, file
), "Expected %s, got %s\n", file
, buffer
);
755 r
= MsiSetTargetPath( hpkg
, "TestParent", "C:\\one\\two" );
756 ok( r
== ERROR_SUCCESS
, "MsiSetTargetPath returned %d\n", r
);
758 query_file_path( hpkg
, "[#TestFile]", buffer
);
759 ok( !lstrcmp(buffer
, "C:\\one\\two\\TestDir\\testfile.txt"),
760 "Expected C:\\one\\two\\TestDir\\testfile.txt, got %s\n", buffer
);
762 sz
= sizeof buffer
- 1;
763 r
= MsiGetTargetPath( hpkg
, "TestParent", buffer
, &sz
);
764 ok( r
== ERROR_SUCCESS
, "failed to get target path: %d\n", r
);
765 ok( !lstrcmp(buffer
, "C:\\one\\two\\"), "Expected C:\\one\\two\\, got %s\n", buffer
);
767 MsiCloseHandle( hpkg
);
770 static void test_condition(void)
775 hpkg
= package_from_db(create_package_db());
776 ok( hpkg
, "failed to create package\n");
778 r
= MsiEvaluateCondition(0, NULL
);
779 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
781 r
= MsiEvaluateCondition(hpkg
, NULL
);
782 ok( r
== MSICONDITION_NONE
, "wrong return val\n");
784 r
= MsiEvaluateCondition(hpkg
, "");
785 ok( r
== MSICONDITION_NONE
, "wrong return val\n");
787 r
= MsiEvaluateCondition(hpkg
, "1");
788 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
790 r
= MsiEvaluateCondition(hpkg
, "0");
791 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
793 r
= MsiEvaluateCondition(hpkg
, "0 = 0");
794 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
796 r
= MsiEvaluateCondition(hpkg
, "0 <> 0");
797 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
799 r
= MsiEvaluateCondition(hpkg
, "0 = 1");
800 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
802 r
= MsiEvaluateCondition(hpkg
, "0 > 1");
803 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
805 r
= MsiEvaluateCondition(hpkg
, "0 ~> 1");
806 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
808 r
= MsiEvaluateCondition(hpkg
, "1 > 1");
809 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
811 r
= MsiEvaluateCondition(hpkg
, "1 ~> 1");
812 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
814 r
= MsiEvaluateCondition(hpkg
, "0 >= 1");
815 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
817 r
= MsiEvaluateCondition(hpkg
, "0 ~>= 1");
818 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
820 r
= MsiEvaluateCondition(hpkg
, "1 >= 1");
821 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
823 r
= MsiEvaluateCondition(hpkg
, "1 ~>= 1");
824 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
826 r
= MsiEvaluateCondition(hpkg
, "0 < 1");
827 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
829 r
= MsiEvaluateCondition(hpkg
, "0 ~< 1");
830 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
832 r
= MsiEvaluateCondition(hpkg
, "1 < 1");
833 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
835 r
= MsiEvaluateCondition(hpkg
, "1 ~< 1");
836 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
838 r
= MsiEvaluateCondition(hpkg
, "0 <= 1");
839 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
841 r
= MsiEvaluateCondition(hpkg
, "0 ~<= 1");
842 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
844 r
= MsiEvaluateCondition(hpkg
, "1 <= 1");
845 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
847 r
= MsiEvaluateCondition(hpkg
, "1 ~<= 1");
848 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
850 r
= MsiEvaluateCondition(hpkg
, "0 >=");
851 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
853 r
= MsiEvaluateCondition(hpkg
, " ");
854 ok( r
== MSICONDITION_NONE
, "wrong return val\n");
856 r
= MsiEvaluateCondition(hpkg
, "LicView <> \"1\"");
857 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
859 r
= MsiEvaluateCondition(hpkg
, "LicView <> \"0\"");
860 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
862 r
= MsiEvaluateCondition(hpkg
, "LicView <> LicView");
863 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
865 r
= MsiEvaluateCondition(hpkg
, "not 0");
866 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
868 r
= MsiEvaluateCondition(hpkg
, "not LicView");
869 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
871 r
= MsiEvaluateCondition(hpkg
, "not \"A\"");
872 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
874 r
= MsiEvaluateCondition(hpkg
, "~not \"A\"");
875 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
877 r
= MsiEvaluateCondition(hpkg
, "\"0\"");
878 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
880 r
= MsiEvaluateCondition(hpkg
, "1 and 2");
881 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
883 r
= MsiEvaluateCondition(hpkg
, "not 0 and 3");
884 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
886 r
= MsiEvaluateCondition(hpkg
, "not 0 and 0");
887 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
889 r
= MsiEvaluateCondition(hpkg
, "not 0 or 1");
890 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
892 r
= MsiEvaluateCondition(hpkg
, "(0)");
893 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
895 r
= MsiEvaluateCondition(hpkg
, "(((((1))))))");
896 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
898 r
= MsiEvaluateCondition(hpkg
, "(((((1)))))");
899 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
901 r
= MsiEvaluateCondition(hpkg
, " \"A\" < \"B\" ");
902 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
904 r
= MsiEvaluateCondition(hpkg
, " \"A\" > \"B\" ");
905 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
907 r
= MsiEvaluateCondition(hpkg
, " \"1\" > \"12\" ");
908 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
910 r
= MsiEvaluateCondition(hpkg
, " \"100\" < \"21\" ");
911 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
913 r
= MsiEvaluateCondition(hpkg
, "0 < > 0");
914 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
916 r
= MsiEvaluateCondition(hpkg
, "(1<<1) == 2");
917 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
919 r
= MsiEvaluateCondition(hpkg
, " \"A\" = \"a\" ");
920 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
922 r
= MsiEvaluateCondition(hpkg
, " \"A\" ~ = \"a\" ");
923 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
925 r
= MsiEvaluateCondition(hpkg
, " \"A\" ~= \"a\" ");
926 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
928 r
= MsiEvaluateCondition(hpkg
, " \"A\" ~= 1 ");
929 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
931 r
= MsiEvaluateCondition(hpkg
, " \"A\" = 1 ");
932 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
934 r
= MsiEvaluateCondition(hpkg
, " 1 ~= 1 ");
935 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
937 r
= MsiEvaluateCondition(hpkg
, " 1 ~= \"1\" ");
938 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
940 r
= MsiEvaluateCondition(hpkg
, " 1 = \"1\" ");
941 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
943 r
= MsiEvaluateCondition(hpkg
, " 0 = \"1\" ");
944 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
946 r
= MsiEvaluateCondition(hpkg
, " 0 < \"100\" ");
947 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
949 r
= MsiEvaluateCondition(hpkg
, " 100 > \"0\" ");
950 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
952 r
= MsiEvaluateCondition(hpkg
, "1 XOR 1");
953 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
955 r
= MsiEvaluateCondition(hpkg
, "1 IMP 1");
956 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
958 r
= MsiEvaluateCondition(hpkg
, "1 IMP 0");
959 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
961 r
= MsiEvaluateCondition(hpkg
, "0 IMP 0");
962 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
964 r
= MsiEvaluateCondition(hpkg
, "0 EQV 0");
965 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
967 r
= MsiEvaluateCondition(hpkg
, "0 EQV 1");
968 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
970 r
= MsiEvaluateCondition(hpkg
, "1 IMP 1 OR 0");
971 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
973 r
= MsiEvaluateCondition(hpkg
, "1 IMPL 1");
974 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
976 r
= MsiEvaluateCondition(hpkg
, "\"ASFD\" >< \"S\" ");
977 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
979 r
= MsiEvaluateCondition(hpkg
, "\"ASFD\" ~>< \"s\" ");
980 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
982 r
= MsiEvaluateCondition(hpkg
, "\"ASFD\" ~>< \"\" ");
983 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
985 r
= MsiEvaluateCondition(hpkg
, "\"ASFD\" ~>< \"sss\" ");
986 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
988 MsiSetProperty(hpkg
, "mm", "5" );
990 r
= MsiEvaluateCondition(hpkg
, "mm = 5");
991 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
993 r
= MsiEvaluateCondition(hpkg
, "mm < 6");
994 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
996 r
= MsiEvaluateCondition(hpkg
, "mm <= 5");
997 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
999 r
= MsiEvaluateCondition(hpkg
, "mm > 4");
1000 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1002 r
= MsiEvaluateCondition(hpkg
, "mm < 12");
1003 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1005 r
= MsiEvaluateCondition(hpkg
, "mm = \"5\"");
1006 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1008 r
= MsiEvaluateCondition(hpkg
, "0 = \"\"");
1009 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1011 r
= MsiEvaluateCondition(hpkg
, "0 AND \"\"");
1012 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1014 r
= MsiEvaluateCondition(hpkg
, "1 AND \"\"");
1015 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1017 r
= MsiEvaluateCondition(hpkg
, "1 AND \"1\"");
1018 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1020 r
= MsiEvaluateCondition(hpkg
, "3 >< 1");
1021 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1023 r
= MsiEvaluateCondition(hpkg
, "3 >< 4");
1024 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1026 r
= MsiEvaluateCondition(hpkg
, "NOT 0 AND 0");
1027 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1029 r
= MsiEvaluateCondition(hpkg
, "NOT 0 AND 1");
1030 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1032 r
= MsiEvaluateCondition(hpkg
, "NOT 1 OR 0");
1033 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1035 r
= MsiEvaluateCondition(hpkg
, "0 AND 1 OR 1");
1036 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1038 r
= MsiEvaluateCondition(hpkg
, "0 AND 0 OR 1");
1039 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1041 r
= MsiEvaluateCondition(hpkg
, "NOT 0 AND 1 OR 0");
1042 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1044 r
= MsiEvaluateCondition(hpkg
, "_1 = _1");
1045 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1047 r
= MsiEvaluateCondition(hpkg
, "( 1 AND 1 ) = 2");
1048 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
1050 r
= MsiEvaluateCondition(hpkg
, "NOT ( 1 AND 1 )");
1051 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1053 r
= MsiEvaluateCondition(hpkg
, "NOT A AND (BBBBBBBBBB=2 OR CCC=1) AND Ddddddddd");
1054 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1056 r
= MsiEvaluateCondition(hpkg
, "Installed<>\"\"");
1057 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1059 r
= MsiEvaluateCondition(hpkg
, "NOT 1 AND 0");
1060 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1062 r
= MsiEvaluateCondition(hpkg
, "bandalmael=0");
1063 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1065 r
= MsiEvaluateCondition(hpkg
, "bandalmael<>0");
1066 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1068 r
= MsiEvaluateCondition(hpkg
, "bandalmael<0");
1069 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1071 r
= MsiEvaluateCondition(hpkg
, "bandalmael>0");
1072 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1074 r
= MsiEvaluateCondition(hpkg
, "bandalmael>=0");
1075 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1077 r
= MsiEvaluateCondition(hpkg
, "bandalmael<=0");
1078 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1080 r
= MsiEvaluateCondition(hpkg
, "bandalmael~<>0");
1081 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1083 MsiSetProperty(hpkg
, "bandalmael", "0" );
1084 r
= MsiEvaluateCondition(hpkg
, "bandalmael=0");
1085 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1087 MsiSetProperty(hpkg
, "bandalmael", "" );
1088 r
= MsiEvaluateCondition(hpkg
, "bandalmael=0");
1089 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1091 MsiSetProperty(hpkg
, "bandalmael", "asdf" );
1092 r
= MsiEvaluateCondition(hpkg
, "bandalmael=0");
1093 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1095 MsiSetProperty(hpkg
, "bandalmael", "0asdf" );
1096 r
= MsiEvaluateCondition(hpkg
, "bandalmael=0");
1097 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1099 MsiSetProperty(hpkg
, "bandalmael", "0 " );
1100 r
= MsiEvaluateCondition(hpkg
, "bandalmael=0");
1101 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1103 MsiSetProperty(hpkg
, "bandalmael", "-0" );
1104 r
= MsiEvaluateCondition(hpkg
, "bandalmael=0");
1105 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1107 MsiSetProperty(hpkg
, "bandalmael", "0000000000000" );
1108 r
= MsiEvaluateCondition(hpkg
, "bandalmael=0");
1109 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1111 MsiSetProperty(hpkg
, "bandalmael", "--0" );
1112 r
= MsiEvaluateCondition(hpkg
, "bandalmael=0");
1113 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1115 MsiSetProperty(hpkg
, "bandalmael", "0x00" );
1116 r
= MsiEvaluateCondition(hpkg
, "bandalmael=0");
1117 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1119 MsiSetProperty(hpkg
, "bandalmael", "-" );
1120 r
= MsiEvaluateCondition(hpkg
, "bandalmael=0");
1121 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1123 MsiSetProperty(hpkg
, "bandalmael", "+0" );
1124 r
= MsiEvaluateCondition(hpkg
, "bandalmael=0");
1125 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1127 MsiSetProperty(hpkg
, "bandalmael", "0.0" );
1128 r
= MsiEvaluateCondition(hpkg
, "bandalmael=0");
1129 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1130 r
= MsiEvaluateCondition(hpkg
, "bandalmael<>0");
1131 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1133 MsiSetProperty(hpkg
, "one", "hi");
1134 MsiSetProperty(hpkg
, "two", "hithere");
1135 r
= MsiEvaluateCondition(hpkg
, "one >< two");
1136 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1138 MsiSetProperty(hpkg
, "one", "hithere");
1139 MsiSetProperty(hpkg
, "two", "hi");
1140 r
= MsiEvaluateCondition(hpkg
, "one >< two");
1141 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1143 MsiSetProperty(hpkg
, "one", "hello");
1144 MsiSetProperty(hpkg
, "two", "hi");
1145 r
= MsiEvaluateCondition(hpkg
, "one >< two");
1146 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1148 MsiSetProperty(hpkg
, "one", "hellohithere");
1149 MsiSetProperty(hpkg
, "two", "hi");
1150 r
= MsiEvaluateCondition(hpkg
, "one >< two");
1151 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1153 MsiSetProperty(hpkg
, "one", "");
1154 MsiSetProperty(hpkg
, "two", "hi");
1155 r
= MsiEvaluateCondition(hpkg
, "one >< two");
1156 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1158 MsiSetProperty(hpkg
, "one", "hi");
1159 MsiSetProperty(hpkg
, "two", "");
1160 r
= MsiEvaluateCondition(hpkg
, "one >< two");
1161 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1163 MsiSetProperty(hpkg
, "one", "");
1164 MsiSetProperty(hpkg
, "two", "");
1165 r
= MsiEvaluateCondition(hpkg
, "one >< two");
1166 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1168 MsiSetProperty(hpkg
, "one", "1234");
1169 MsiSetProperty(hpkg
, "two", "1");
1170 r
= MsiEvaluateCondition(hpkg
, "one >< two");
1171 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1173 MsiSetProperty(hpkg
, "one", "one 1234");
1174 MsiSetProperty(hpkg
, "two", "1");
1175 r
= MsiEvaluateCondition(hpkg
, "one >< two");
1176 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1178 MsiSetProperty(hpkg
, "one", "hithere");
1179 MsiSetProperty(hpkg
, "two", "hi");
1180 r
= MsiEvaluateCondition(hpkg
, "one << two");
1181 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1183 MsiSetProperty(hpkg
, "one", "hi");
1184 MsiSetProperty(hpkg
, "two", "hithere");
1185 r
= MsiEvaluateCondition(hpkg
, "one << two");
1186 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1188 MsiSetProperty(hpkg
, "one", "hi");
1189 MsiSetProperty(hpkg
, "two", "hi");
1190 r
= MsiEvaluateCondition(hpkg
, "one << two");
1191 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1193 MsiSetProperty(hpkg
, "one", "abcdhithere");
1194 MsiSetProperty(hpkg
, "two", "hi");
1195 r
= MsiEvaluateCondition(hpkg
, "one << two");
1196 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1198 MsiSetProperty(hpkg
, "one", "");
1199 MsiSetProperty(hpkg
, "two", "hi");
1200 r
= MsiEvaluateCondition(hpkg
, "one << two");
1201 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1203 MsiSetProperty(hpkg
, "one", "hithere");
1204 MsiSetProperty(hpkg
, "two", "");
1205 r
= MsiEvaluateCondition(hpkg
, "one << two");
1206 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1208 MsiSetProperty(hpkg
, "one", "");
1209 MsiSetProperty(hpkg
, "two", "");
1210 r
= MsiEvaluateCondition(hpkg
, "one << two");
1211 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1213 MsiSetProperty(hpkg
, "one", "1234");
1214 MsiSetProperty(hpkg
, "two", "1");
1215 r
= MsiEvaluateCondition(hpkg
, "one << two");
1216 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1218 MsiSetProperty(hpkg
, "one", "1234 one");
1219 MsiSetProperty(hpkg
, "two", "1");
1220 r
= MsiEvaluateCondition(hpkg
, "one << two");
1221 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1223 MsiSetProperty(hpkg
, "one", "hithere");
1224 MsiSetProperty(hpkg
, "two", "there");
1225 r
= MsiEvaluateCondition(hpkg
, "one >> two");
1226 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1228 MsiSetProperty(hpkg
, "one", "hithere");
1229 MsiSetProperty(hpkg
, "two", "hi");
1230 r
= MsiEvaluateCondition(hpkg
, "one >> two");
1231 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1233 MsiSetProperty(hpkg
, "one", "there");
1234 MsiSetProperty(hpkg
, "two", "hithere");
1235 r
= MsiEvaluateCondition(hpkg
, "one >> two");
1236 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1238 MsiSetProperty(hpkg
, "one", "there");
1239 MsiSetProperty(hpkg
, "two", "there");
1240 r
= MsiEvaluateCondition(hpkg
, "one >> two");
1241 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1243 MsiSetProperty(hpkg
, "one", "abcdhithere");
1244 MsiSetProperty(hpkg
, "two", "hi");
1245 r
= MsiEvaluateCondition(hpkg
, "one >> two");
1246 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1248 MsiSetProperty(hpkg
, "one", "");
1249 MsiSetProperty(hpkg
, "two", "there");
1250 r
= MsiEvaluateCondition(hpkg
, "one >> two");
1251 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1253 MsiSetProperty(hpkg
, "one", "there");
1254 MsiSetProperty(hpkg
, "two", "");
1255 r
= MsiEvaluateCondition(hpkg
, "one >> two");
1256 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1258 MsiSetProperty(hpkg
, "one", "");
1259 MsiSetProperty(hpkg
, "two", "");
1260 r
= MsiEvaluateCondition(hpkg
, "one >> two");
1261 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1263 MsiSetProperty(hpkg
, "one", "1234");
1264 MsiSetProperty(hpkg
, "two", "4");
1265 r
= MsiEvaluateCondition(hpkg
, "one >> two");
1266 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1268 MsiSetProperty(hpkg
, "one", "one 1234");
1269 MsiSetProperty(hpkg
, "two", "4");
1270 r
= MsiEvaluateCondition(hpkg
, "one >> two");
1271 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1273 MsiSetProperty(hpkg
, "MsiNetAssemblySupport", NULL
); /* make sure it's empty */
1275 r
= MsiEvaluateCondition(hpkg
, "MsiNetAssemblySupport < \"1.1.4322\"");
1276 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1278 r
= MsiEvaluateCondition(hpkg
, "MsiNetAssemblySupport > \"1.1.4322\"");
1279 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1281 r
= MsiEvaluateCondition(hpkg
, "MsiNetAssemblySupport >= \"1.1.4322\"");
1282 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1284 r
= MsiEvaluateCondition(hpkg
, "MsiNetAssemblySupport <= \"1.1.4322\"");
1285 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1287 r
= MsiEvaluateCondition(hpkg
, "MsiNetAssemblySupport <> \"1.1.4322\"");
1288 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1290 r
= MsiEvaluateCondition(hpkg
, "MsiNetAssemblySupport ~< \"1.1.4322\"");
1291 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1293 r
= MsiEvaluateCondition(hpkg
, "MsiNetAssemblySupport < \"abcd\"");
1294 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1296 r
= MsiEvaluateCondition(hpkg
, "MsiNetAssemblySupport < \"a1.1.4322\"");
1297 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1299 r
= MsiEvaluateCondition(hpkg
, "MsiNetAssemblySupport < \"1.1.4322a\"");
1300 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1302 r
= MsiEvaluateCondition(hpkg
, "MsiNetAssemblySupport < \"0000001.1.4322\"");
1303 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1305 r
= MsiEvaluateCondition(hpkg
, "MsiNetAssemblySupport < \"1.1.4322.1\"");
1306 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1308 r
= MsiEvaluateCondition(hpkg
, "MsiNetAssemblySupport < \"1.1.4322.1.1\"");
1309 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1311 r
= MsiEvaluateCondition(hpkg
, "\"2\" < \"1.1");
1312 ok( r
== MSICONDITION_ERROR
, "wrong return val (%d)\n", r
);
1314 r
= MsiEvaluateCondition(hpkg
, "\"2\" < \"1.1\"");
1315 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1317 r
= MsiEvaluateCondition(hpkg
, "\"2\" < \"12.1\"");
1318 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1320 r
= MsiEvaluateCondition(hpkg
, "\"02.1\" < \"2.11\"");
1321 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1323 r
= MsiEvaluateCondition(hpkg
, "\"02.1.1\" < \"2.1\"");
1324 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1326 r
= MsiEvaluateCondition(hpkg
, "MsiNetAssemblySupport < \"1.1\"");
1327 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1329 r
= MsiEvaluateCondition(hpkg
, "MsiNetAssemblySupport < \"1\"");
1330 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1332 r
= MsiEvaluateCondition(hpkg
, "MsiNetAssemblySupport < \"0\"");
1333 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1335 r
= MsiEvaluateCondition(hpkg
, "MsiNetAssemblySupport < \"-1\"");
1336 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1338 r
= MsiEvaluateCondition(hpkg
, "MsiNetAssemblySupport < \"a\"");
1339 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1341 r
= MsiEvaluateCondition(hpkg
, "MsiNetAssemblySupport < \"!\"");
1342 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1344 r
= MsiEvaluateCondition(hpkg
, "MsiNetAssemblySupport < \"!\"");
1345 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1347 r
= MsiEvaluateCondition(hpkg
, "MsiNetAssemblySupport < \"/\"");
1348 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1350 r
= MsiEvaluateCondition(hpkg
, "MsiNetAssemblySupport < \" \"");
1351 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1353 r
= MsiEvaluateCondition(hpkg
, "MsiNetAssemblySupport < \"azAZ_\"");
1354 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1356 r
= MsiEvaluateCondition(hpkg
, "MsiNetAssemblySupport < \"a[a]\"");
1357 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1359 r
= MsiEvaluateCondition(hpkg
, "MsiNetAssemblySupport < \"a[a]a\"");
1360 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1362 r
= MsiEvaluateCondition(hpkg
, "MsiNetAssemblySupport < \"[a]\"");
1363 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1365 r
= MsiEvaluateCondition(hpkg
, "MsiNetAssemblySupport < \"[a]a\"");
1366 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1368 r
= MsiEvaluateCondition(hpkg
, "MsiNetAssemblySupport < \"{a}\"");
1369 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1371 r
= MsiEvaluateCondition(hpkg
, "MsiNetAssemblySupport < \"{a\"");
1372 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1374 r
= MsiEvaluateCondition(hpkg
, "MsiNetAssemblySupport < \"[a\"");
1375 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1377 r
= MsiEvaluateCondition(hpkg
, "MsiNetAssemblySupport < \"a{\"");
1378 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1380 r
= MsiEvaluateCondition(hpkg
, "MsiNetAssemblySupport < \"a]\"");
1381 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1383 r
= MsiEvaluateCondition(hpkg
, "MsiNetAssemblySupport < \"A\"");
1384 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1386 MsiSetProperty(hpkg
, "MsiNetAssemblySupport", "1.1.4322");
1387 r
= MsiEvaluateCondition(hpkg
, "MsiNetAssemblySupport < \"1.1.4322\"");
1388 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1390 r
= MsiEvaluateCondition(hpkg
, "MsiNetAssemblySupport < \"1.1.14322\"");
1391 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1393 r
= MsiEvaluateCondition(hpkg
, "MsiNetAssemblySupport < \"1.1.5\"");
1394 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1396 r
= MsiEvaluateCondition(hpkg
, "MsiNetAssemblySupport < \"1.1\"");
1397 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1399 r
= MsiEvaluateCondition(hpkg
, "MsiNetAssemblySupport < \"1\"");
1400 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1402 MsiSetProperty(hpkg
, "one", "1");
1403 r
= MsiEvaluateCondition(hpkg
, "one < \"1\"");
1404 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1406 MsiSetProperty(hpkg
, "X", "5.0");
1408 r
= MsiEvaluateCondition(hpkg
, "X != \"\"");
1409 ok( r
== MSICONDITION_ERROR
, "wrong return val (%d)\n", r
);
1411 r
= MsiEvaluateCondition(hpkg
, "X =\"5.0\"");
1412 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1414 r
= MsiEvaluateCondition(hpkg
, "X =\"5.1\"");
1415 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1417 r
= MsiEvaluateCondition(hpkg
, "X =\"6.0\"");
1418 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1420 r
= MsiEvaluateCondition(hpkg
, "X =\"5.0\" or X =\"5.1\" or X =\"6.0\"");
1421 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1423 r
= MsiEvaluateCondition(hpkg
, "(X =\"5.0\" or X =\"5.1\" or X =\"6.0\")");
1424 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1426 r
= MsiEvaluateCondition(hpkg
, "X !=\"\" and (X =\"5.0\" or X =\"5.1\" or X =\"6.0\")");
1427 ok( r
== MSICONDITION_ERROR
, "wrong return val (%d)\n", r
);
1429 MsiCloseHandle( hpkg
);
1430 DeleteFile(msifile
);
1433 static BOOL
check_prop_empty( MSIHANDLE hpkg
, const char * prop
)
1441 r
= MsiGetProperty( hpkg
, prop
, buffer
, &sz
);
1442 return r
== ERROR_SUCCESS
&& buffer
[0] == 0 && sz
== 0;
1445 static void test_props(void)
1447 MSIHANDLE hpkg
, hdb
;
1452 hdb
= create_package_db();
1454 "CREATE TABLE `Property` ( "
1455 "`Property` CHAR(255) NOT NULL, "
1456 "`Value` CHAR(255) "
1457 "PRIMARY KEY `Property`)" );
1458 ok( r
== ERROR_SUCCESS
, "Failed\n" );
1461 "INSERT INTO `Property` "
1462 "(`Property`, `Value`) "
1463 "VALUES( 'MetadataCompName', 'Photoshop.dll' )");
1464 ok( r
== ERROR_SUCCESS
, "Failed\n" );
1466 hpkg
= package_from_db( hdb
);
1467 ok( hpkg
, "failed to create package\n");
1469 /* test invalid values */
1470 r
= MsiGetProperty( 0, NULL
, NULL
, NULL
);
1471 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
1473 r
= MsiGetProperty( hpkg
, NULL
, NULL
, NULL
);
1474 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
1476 r
= MsiGetProperty( hpkg
, "boo", NULL
, NULL
);
1477 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
1479 r
= MsiGetProperty( hpkg
, "boo", buffer
, NULL
);
1480 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
1482 /* test retrieving an empty/nonexistent property */
1484 r
= MsiGetProperty( hpkg
, "boo", NULL
, &sz
);
1485 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
1486 ok( sz
== 0, "wrong size returned\n");
1488 check_prop_empty( hpkg
, "boo");
1491 r
= MsiGetProperty( hpkg
, "boo", buffer
, &sz
);
1492 ok( r
== ERROR_MORE_DATA
, "wrong return val\n");
1493 ok( !strcmp(buffer
,"x"), "buffer was changed\n");
1494 ok( sz
== 0, "wrong size returned\n");
1498 r
= MsiGetProperty( hpkg
, "boo", buffer
, &sz
);
1499 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
1500 ok( buffer
[0] == 0, "buffer was not changed\n");
1501 ok( sz
== 0, "wrong size returned\n");
1503 /* set the property to something */
1504 r
= MsiSetProperty( 0, NULL
, NULL
);
1505 ok( r
== ERROR_INVALID_HANDLE
, "wrong return val\n");
1507 r
= MsiSetProperty( hpkg
, NULL
, NULL
);
1508 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
1510 r
= MsiSetProperty( hpkg
, "", NULL
);
1511 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
1513 /* try set and get some illegal property identifiers */
1514 r
= MsiSetProperty( hpkg
, "", "asdf" );
1515 ok( r
== ERROR_FUNCTION_FAILED
, "wrong return val\n");
1517 r
= MsiSetProperty( hpkg
, "=", "asdf" );
1518 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
1520 r
= MsiSetProperty( hpkg
, " ", "asdf" );
1521 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
1523 r
= MsiSetProperty( hpkg
, "'", "asdf" );
1524 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
1528 r
= MsiGetProperty( hpkg
, "'", buffer
, &sz
);
1529 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
1530 ok( !strcmp(buffer
,"asdf"), "buffer was not changed\n");
1532 /* set empty values */
1533 r
= MsiSetProperty( hpkg
, "boo", NULL
);
1534 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
1535 ok( check_prop_empty( hpkg
, "boo"), "prop wasn't empty\n");
1537 r
= MsiSetProperty( hpkg
, "boo", "" );
1538 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
1539 ok( check_prop_empty( hpkg
, "boo"), "prop wasn't empty\n");
1541 /* set a non-empty value */
1542 r
= MsiSetProperty( hpkg
, "boo", "xyz" );
1543 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
1547 r
= MsiGetProperty( hpkg
, "boo", buffer
, &sz
);
1548 ok( r
== ERROR_MORE_DATA
, "wrong return val\n");
1549 ok( buffer
[0] == 0, "buffer was not changed\n");
1550 ok( sz
== 3, "wrong size returned\n");
1554 r
= MsiGetProperty( hpkg
, "boo", buffer
, &sz
);
1555 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
1556 ok( !strcmp(buffer
,"xyz"), "buffer was not changed\n");
1557 ok( sz
== 3, "wrong size returned\n");
1561 r
= MsiGetProperty( hpkg
, "boo", buffer
, &sz
);
1562 ok( r
== ERROR_MORE_DATA
, "wrong return val\n");
1563 ok( !strcmp(buffer
,"xy"), "buffer was not changed\n");
1564 ok( sz
== 3, "wrong size returned\n");
1566 r
= MsiSetProperty(hpkg
, "SourceDir", "foo");
1567 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
1570 r
= MsiGetProperty(hpkg
, "SOURCEDIR", buffer
, &sz
);
1571 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
1572 ok( !strcmp(buffer
,""), "buffer wrong\n");
1573 ok( sz
== 0, "wrong size returned\n");
1576 r
= MsiGetProperty(hpkg
, "SOMERANDOMNAME", buffer
, &sz
);
1577 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
1578 ok( !strcmp(buffer
,""), "buffer wrong\n");
1579 ok( sz
== 0, "wrong size returned\n");
1582 r
= MsiGetProperty(hpkg
, "SourceDir", buffer
, &sz
);
1583 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
1584 ok( !strcmp(buffer
,"foo"), "buffer wrong\n");
1585 ok( sz
== 3, "wrong size returned\n");
1587 r
= MsiSetProperty(hpkg
, "MetadataCompName", "Photoshop.dll");
1588 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
1591 r
= MsiGetProperty(hpkg
, "MetadataCompName", NULL
, &sz
);
1592 ok( r
== ERROR_SUCCESS
, "return wrong\n");
1593 ok( sz
== 13, "size wrong (%d)\n", sz
);
1596 r
= MsiGetProperty(hpkg
, "MetadataCompName", buffer
, &sz
);
1597 ok( r
== ERROR_MORE_DATA
, "return wrong\n");
1598 ok( !strcmp(buffer
,"Photoshop.dl"), "buffer wrong\n");
1600 r
= MsiSetProperty(hpkg
, "property", "value");
1601 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1604 r
= MsiGetProperty(hpkg
, "property", buffer
, &sz
);
1605 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1606 ok( !strcmp(buffer
, "value"), "Expected value, got %s\n", buffer
);
1608 r
= MsiSetProperty(hpkg
, "property", NULL
);
1609 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1612 r
= MsiGetProperty(hpkg
, "property", buffer
, &sz
);
1613 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1614 ok( !strlen(buffer
), "Expected empty string, got %s\n", buffer
);
1616 MsiCloseHandle( hpkg
);
1617 DeleteFile(msifile
);
1620 static BOOL
find_prop_in_property(MSIHANDLE hdb
, LPCSTR prop
, LPCSTR val
)
1622 MSIHANDLE hview
, hrec
;
1624 CHAR buffer
[MAX_PATH
];
1628 r
= MsiDatabaseOpenView(hdb
, "SELECT * FROM `_Property`", &hview
);
1629 ok(r
== ERROR_SUCCESS
, "MsiDatabaseOpenView failed\n");
1630 r
= MsiViewExecute(hview
, 0);
1631 ok(r
== ERROR_SUCCESS
, "MsiViewExecute failed\n");
1634 while (r
== ERROR_SUCCESS
&& !found
)
1636 r
= MsiViewFetch(hview
, &hrec
);
1637 if (r
!= ERROR_SUCCESS
) break;
1640 r
= MsiRecordGetString(hrec
, 1, buffer
, &sz
);
1641 if (r
== ERROR_SUCCESS
&& !lstrcmpA(buffer
, prop
))
1644 r
= MsiRecordGetString(hrec
, 2, buffer
, &sz
);
1645 if (r
== ERROR_SUCCESS
&& !lstrcmpA(buffer
, val
))
1649 MsiCloseHandle(hrec
);
1652 MsiViewClose(hview
);
1653 MsiCloseHandle(hview
);
1658 static void test_property_table(void)
1662 MSIHANDLE hpkg
, hdb
, hrec
;
1663 char buffer
[MAX_PATH
];
1667 hdb
= create_package_db();
1668 ok( hdb
, "failed to create package\n");
1670 hpkg
= package_from_db(hdb
);
1671 ok( hpkg
, "failed to create package\n");
1673 MsiCloseHandle(hdb
);
1675 hdb
= MsiGetActiveDatabase(hpkg
);
1677 query
= "CREATE TABLE `_Property` ( "
1678 "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
1679 r
= run_query(hdb
, query
);
1680 ok(r
== ERROR_BAD_QUERY_SYNTAX
, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r
);
1682 MsiCloseHandle(hdb
);
1683 MsiCloseHandle(hpkg
);
1684 DeleteFile(msifile
);
1686 hdb
= create_package_db();
1687 ok( hdb
, "failed to create package\n");
1689 query
= "CREATE TABLE `_Property` ( "
1690 "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
1691 r
= run_query(hdb
, query
);
1692 ok(r
== ERROR_SUCCESS
, "failed to create table\n");
1694 query
= "ALTER `_Property` ADD `foo` INTEGER";
1695 r
= run_query(hdb
, query
);
1696 ok(r
== ERROR_BAD_QUERY_SYNTAX
, "failed to add column\n");
1698 query
= "ALTER TABLE `_Property` ADD `foo` INTEGER";
1699 r
= run_query(hdb
, query
);
1700 ok(r
== ERROR_BAD_QUERY_SYNTAX
, "failed to add column\n");
1702 query
= "ALTER TABLE `_Property` ADD `extra` INTEGER";
1703 r
= run_query(hdb
, query
);
1704 ok(r
== ERROR_SUCCESS
, "failed to add column\n");
1706 hpkg
= package_from_db(hdb
);
1709 ok(!hpkg
, "package should not be created\n");
1712 MsiCloseHandle(hdb
);
1713 MsiCloseHandle(hpkg
);
1714 DeleteFile(msifile
);
1716 hdb
= create_package_db();
1717 ok (hdb
, "failed to create package database\n");
1719 r
= create_property_table(hdb
);
1720 ok(r
== ERROR_SUCCESS
, "cannot create Property table: %d\n", r
);
1722 r
= add_property_entry(hdb
, "'prop', 'val'");
1723 ok(r
== ERROR_SUCCESS
, "cannot add property: %d\n", r
);
1725 hpkg
= package_from_db(hdb
);
1726 ok(hpkg
, "failed to create package\n");
1728 MsiCloseHandle(hdb
);
1731 r
= MsiGetProperty(hpkg
, "prop", buffer
, &sz
);
1732 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1733 ok(!lstrcmp(buffer
, "val"), "Expected val, got %s\n", buffer
);
1735 hdb
= MsiGetActiveDatabase(hpkg
);
1737 found
= find_prop_in_property(hdb
, "prop", "val");
1738 ok(found
, "prop should be in the _Property table\n");
1740 r
= add_property_entry(hdb
, "'dantes', 'mercedes'");
1741 ok(r
== ERROR_SUCCESS
, "cannot add property: %d\n", r
);
1743 query
= "SELECT * FROM `_Property` WHERE `Property` = 'dantes'";
1744 r
= do_query(hdb
, query
, &hrec
);
1745 ok(r
== ERROR_BAD_QUERY_SYNTAX
, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r
);
1747 found
= find_prop_in_property(hdb
, "dantes", "mercedes");
1748 ok(found
== FALSE
, "dantes should not be in the _Property table\n");
1751 lstrcpy(buffer
, "aaa");
1752 r
= MsiGetProperty(hpkg
, "dantes", buffer
, &sz
);
1753 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1754 ok(lstrlenA(buffer
) == 0, "Expected empty string, got %s\n", buffer
);
1756 r
= MsiSetProperty(hpkg
, "dantes", "mercedes");
1757 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1759 found
= find_prop_in_property(hdb
, "dantes", "mercedes");
1760 ok(found
== TRUE
, "dantes should be in the _Property table\n");
1762 MsiCloseHandle(hdb
);
1763 MsiCloseHandle(hrec
);
1764 MsiCloseHandle(hpkg
);
1765 DeleteFile(msifile
);
1768 static UINT
try_query_param( MSIHANDLE hdb
, LPCSTR szQuery
, MSIHANDLE hrec
)
1773 res
= MsiDatabaseOpenView( hdb
, szQuery
, &htab
);
1774 if( res
== ERROR_SUCCESS
)
1778 r
= MsiViewExecute( htab
, hrec
);
1779 if( r
!= ERROR_SUCCESS
)
1782 fprintf(stderr
,"MsiViewExecute failed %08x\n", res
);
1785 r
= MsiViewClose( htab
);
1786 if( r
!= ERROR_SUCCESS
)
1789 r
= MsiCloseHandle( htab
);
1790 if( r
!= ERROR_SUCCESS
)
1796 static UINT
try_query( MSIHANDLE hdb
, LPCSTR szQuery
)
1798 return try_query_param( hdb
, szQuery
, 0 );
1801 static void test_msipackage(void)
1803 MSIHANDLE hdb
= 0, hpack
= 100;
1808 DeleteFile(msifile
);
1812 r
= MsiOpenPackage(name
, &hpack
);
1813 ok(r
== ERROR_SUCCESS
, "failed to open package with no name\n");
1814 r
= MsiCloseHandle(hpack
);
1815 ok(r
== ERROR_SUCCESS
, "failed to close package\n");
1818 /* just MsiOpenDatabase should not create a file */
1819 r
= MsiOpenDatabase(msifile
, MSIDBOPEN_CREATE
, &hdb
);
1820 ok(r
== ERROR_SUCCESS
, "MsiOpenDatabase failed\n");
1824 r
= MsiOpenPackage(name
, &hpack
);
1825 ok(r
== ERROR_INVALID_HANDLE
, "MsiOpenPackage returned wrong code\n");
1828 /* now try again with our empty database */
1829 sprintf(name
, "#%ld", hdb
);
1830 r
= MsiOpenPackage(name
, &hpack
);
1831 ok(r
== ERROR_INSTALL_PACKAGE_INVALID
, "MsiOpenPackage returned wrong code\n");
1832 if (!r
) MsiCloseHandle(hpack
);
1835 /* create a table */
1836 query
= "CREATE TABLE `Property` ( "
1837 "`Property` CHAR(72), `Value` CHAR(0) "
1838 "PRIMARY KEY `Property`)";
1839 r
= try_query(hdb
, query
);
1840 ok(r
== ERROR_SUCCESS
, "failed to create Properties table\n");
1842 query
= "CREATE TABLE `InstallExecuteSequence` ("
1843 "`Action` CHAR(72), `Condition` CHAR(0), `Sequence` INTEGER "
1844 "PRIMARY KEY `Action`)";
1845 r
= try_query(hdb
, query
);
1846 ok(r
== ERROR_SUCCESS
, "failed to create InstallExecuteSequence table\n");
1849 sprintf(name
, "#%ld", hdb
);
1850 r
= MsiOpenPackage(name
, &hpack
);
1851 ok(r
== ERROR_INSTALL_PACKAGE_INVALID
, "MsiOpenPackage returned wrong code\n");
1852 if (!r
) MsiCloseHandle(hpack
);
1855 r
= MsiCloseHandle(hdb
);
1856 ok(r
== ERROR_SUCCESS
, "MsiCloseHandle(database) failed\n");
1857 DeleteFile(msifile
);
1860 static void test_formatrecord2(void)
1862 MSIHANDLE hpkg
, hrec
;
1867 hpkg
= package_from_db(create_package_db());
1868 ok( hpkg
, "failed to create package\n");
1870 r
= MsiSetProperty(hpkg
, "Manufacturer", " " );
1871 ok( r
== ERROR_SUCCESS
, "set property failed\n");
1873 hrec
= MsiCreateRecord(2);
1874 ok(hrec
, "create record failed\n");
1876 r
= MsiRecordSetString( hrec
, 0, "[ProgramFilesFolder][Manufacturer]\\asdf");
1877 ok( r
== ERROR_SUCCESS
, "format record failed\n");
1881 r
= MsiFormatRecord( hpkg
, hrec
, buffer
, &sz
);
1883 r
= MsiRecordSetString(hrec
, 0, "[foo][1]");
1884 r
= MsiRecordSetString(hrec
, 1, "hoo");
1886 r
= MsiFormatRecord(hpkg
, hrec
, buffer
, &sz
);
1887 ok( sz
== 3, "size wrong\n");
1888 ok( 0 == strcmp(buffer
,"hoo"), "wrong output %s\n",buffer
);
1889 ok( r
== ERROR_SUCCESS
, "format failed\n");
1891 r
= MsiRecordSetString(hrec
, 0, "x[~]x");
1893 r
= MsiFormatRecord(hpkg
, hrec
, buffer
, &sz
);
1894 ok( sz
== 3, "size wrong\n");
1895 ok( 0 == strcmp(buffer
,"x"), "wrong output %s\n",buffer
);
1896 ok( r
== ERROR_SUCCESS
, "format failed\n");
1898 r
= MsiRecordSetString(hrec
, 0, "[foo.$%}][1]");
1899 r
= MsiRecordSetString(hrec
, 1, "hoo");
1901 r
= MsiFormatRecord(hpkg
, hrec
, buffer
, &sz
);
1902 ok( sz
== 3, "size wrong\n");
1903 ok( 0 == strcmp(buffer
,"hoo"), "wrong output %s\n",buffer
);
1904 ok( r
== ERROR_SUCCESS
, "format failed\n");
1906 r
= MsiRecordSetString(hrec
, 0, "[\\[]");
1908 r
= MsiFormatRecord(hpkg
, hrec
, buffer
, &sz
);
1909 ok( sz
== 1, "size wrong\n");
1910 ok( 0 == strcmp(buffer
,"["), "wrong output %s\n",buffer
);
1911 ok( r
== ERROR_SUCCESS
, "format failed\n");
1913 SetEnvironmentVariable("FOO", "BAR");
1914 r
= MsiRecordSetString(hrec
, 0, "[%FOO]");
1916 r
= MsiFormatRecord(hpkg
, hrec
, buffer
, &sz
);
1917 ok( sz
== 3, "size wrong\n");
1918 ok( 0 == strcmp(buffer
,"BAR"), "wrong output %s\n",buffer
);
1919 ok( r
== ERROR_SUCCESS
, "format failed\n");
1921 r
= MsiRecordSetString(hrec
, 0, "[[1]]");
1922 r
= MsiRecordSetString(hrec
, 1, "%FOO");
1924 r
= MsiFormatRecord(hpkg
, hrec
, buffer
, &sz
);
1925 ok( sz
== 3, "size wrong\n");
1926 ok( 0 == strcmp(buffer
,"BAR"), "wrong output %s\n",buffer
);
1927 ok( r
== ERROR_SUCCESS
, "format failed\n");
1929 MsiCloseHandle( hrec
);
1930 MsiCloseHandle( hpkg
);
1931 DeleteFile(msifile
);
1934 static void test_states(void)
1939 INSTALLSTATE state
, action
;
1941 hdb
= create_package_db();
1942 ok ( hdb
, "failed to create package database\n" );
1944 r
= add_directory_entry( hdb
, "'TARGETDIR', '', 'SourceDir'");
1945 ok( r
== ERROR_SUCCESS
, "cannot add directory: %d\n", r
);
1947 r
= create_feature_table( hdb
);
1948 ok( r
== ERROR_SUCCESS
, "cannot create Feature table: %d\n", r
);
1950 r
= create_component_table( hdb
);
1951 ok( r
== ERROR_SUCCESS
, "cannot create Component table: %d\n", r
);
1953 /* msidbFeatureAttributesFavorLocal */
1954 r
= add_feature_entry( hdb
, "'one', '', '', '', 2, 1, '', 0" );
1955 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
1957 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
1958 r
= add_component_entry( hdb
, "'alpha', '{467EC132-739D-4784-A37B-677AA43DBC94}', 'TARGETDIR', 0, '', 'alpha_file'" );
1959 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
1961 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
1962 r
= add_component_entry( hdb
, "'beta', '{2C1F189C-24A6-4C34-B26B-994A6C026506}', 'TARGETDIR', 1, '', 'beta_file'" );
1963 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
1965 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
1966 r
= add_component_entry( hdb
, "'gamma', '{C271E2A4-DE2E-4F70-86D1-6984AF7DE2CA}', 'TARGETDIR', 2, '', 'gamma_file'" );
1967 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
1969 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSharedDllRefCount */
1970 r
= add_component_entry( hdb
, "'theta', '{4EB3129D-81A8-48D5-9801-75600FED3DD9}', 'TARGETDIR', 8, '', 'theta_file'" );
1971 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
1973 /* msidbFeatureAttributesFavorSource */
1974 r
= add_feature_entry( hdb
, "'two', '', '', '', 2, 1, '', 1" );
1975 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
1977 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
1978 r
= add_component_entry( hdb
, "'delta', '{938FD4F2-C648-4259-A03C-7AA3B45643F3}', 'TARGETDIR', 0, '', 'delta_file'" );
1979 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
1981 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
1982 r
= add_component_entry( hdb
, "'epsilon', '{D59713B6-C11D-47F2-A395-1E5321781190}', 'TARGETDIR', 1, '', 'epsilon_file'" );
1983 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
1985 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
1986 r
= add_component_entry( hdb
, "'zeta', '{377D33AB-2FAA-42B9-A629-0C0DAE9B9C7A}', 'TARGETDIR', 2, '', 'zeta_file'" );
1987 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
1989 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSharedDllRefCount */
1990 r
= add_component_entry( hdb
, "'iota', '{5D36F871-B5ED-4801-9E0F-C46B9E5C9669}', 'TARGETDIR', 8, '', 'iota_file'" );
1991 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
1993 /* msidbFeatureAttributesFavorSource */
1994 r
= add_feature_entry( hdb
, "'three', '', '', '', 2, 1, '', 1" );
1995 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
1997 /* msidbFeatureAttributesFavorLocal */
1998 r
= add_feature_entry( hdb
, "'four', '', '', '', 2, 1, '', 0" );
1999 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
2002 r
= add_feature_entry( hdb
, "'five', '', '', '', 2, 0, '', 1" );
2003 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
2005 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
2006 r
= add_component_entry( hdb
, "'eta', '{DD89003F-0DD4-41B8-81C0-3411A7DA2695}', 'TARGETDIR', 1, '', 'eta_file'" );
2007 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2009 /* no feature parent:msidbComponentAttributesLocalOnly */
2010 r
= add_component_entry( hdb
, "'kappa', '{D6B93DC3-8DA5-4769-9888-42BFE156BB8B}', 'TARGETDIR', 1, '', 'kappa_file'" );
2011 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2013 r
= create_feature_components_table( hdb
);
2014 ok( r
== ERROR_SUCCESS
, "cannot create FeatureComponents table: %d\n", r
);
2016 r
= add_feature_components_entry( hdb
, "'one', 'alpha'" );
2017 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2019 r
= add_feature_components_entry( hdb
, "'one', 'beta'" );
2020 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2022 r
= add_feature_components_entry( hdb
, "'one', 'gamma'" );
2023 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2025 r
= add_feature_components_entry( hdb
, "'one', 'theta'" );
2026 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2028 r
= add_feature_components_entry( hdb
, "'two', 'delta'" );
2029 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2031 r
= add_feature_components_entry( hdb
, "'two', 'epsilon'" );
2032 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2034 r
= add_feature_components_entry( hdb
, "'two', 'zeta'" );
2035 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2037 r
= add_feature_components_entry( hdb
, "'two', 'iota'" );
2038 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2040 r
= add_feature_components_entry( hdb
, "'three', 'eta'" );
2041 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2043 r
= add_feature_components_entry( hdb
, "'four', 'eta'" );
2044 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2046 r
= add_feature_components_entry( hdb
, "'five', 'eta'" );
2047 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2049 r
= create_file_table( hdb
);
2050 ok( r
== ERROR_SUCCESS
, "cannot create File table: %d\n", r
);
2052 r
= add_file_entry( hdb
, "'alpha_file', 'alpha', 'alpha.txt', 100, '', '1033', 8192, 1" );
2053 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
2055 r
= add_file_entry( hdb
, "'beta_file', 'beta', 'beta.txt', 0, '', '1033', 8192, 1" );
2056 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
2058 r
= add_file_entry( hdb
, "'gamma_file', 'gamma', 'gamma.txt', 0, '', '1033', 8192, 1" );
2059 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
2061 r
= add_file_entry( hdb
, "'theta_file', 'theta', 'theta.txt', 0, '', '1033', 8192, 1" );
2062 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
2064 r
= add_file_entry( hdb
, "'delta_file', 'delta', 'delta.txt', 0, '', '1033', 8192, 1" );
2065 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
2067 r
= add_file_entry( hdb
, "'epsilon_file', 'epsilon', 'epsilon.txt', 0, '', '1033', 8192, 1" );
2068 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
2070 r
= add_file_entry( hdb
, "'zeta_file', 'zeta', 'zeta.txt', 0, '', '1033', 8192, 1" );
2071 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
2073 r
= add_file_entry( hdb
, "'iota_file', 'iota', 'iota.txt', 0, '', '1033', 8192, 1" );
2074 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
2076 /* compressed file */
2077 r
= add_file_entry( hdb
, "'eta_file', 'eta', 'eta.txt', 0, '', '1033', 16384, 1" );
2078 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
2080 r
= add_file_entry( hdb
, "'kappa_file', 'kappa', 'kappa.txt', 0, '', '1033', 8192, 1" );
2081 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
2083 hpkg
= package_from_db( hdb
);
2084 ok( hpkg
, "failed to create package\n");
2086 MsiCloseHandle( hdb
);
2090 r
= MsiGetFeatureState(hpkg
, "one", &state
, &action
);
2091 ok( r
== ERROR_UNKNOWN_FEATURE
, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r
);
2092 ok( state
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", state
);
2093 ok( action
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", action
);
2097 r
= MsiGetFeatureState(hpkg
, "two", &state
, &action
);
2098 ok( r
== ERROR_UNKNOWN_FEATURE
, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r
);
2099 ok( state
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", state
);
2100 ok( action
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", action
);
2104 r
= MsiGetFeatureState(hpkg
, "three", &state
, &action
);
2105 ok( r
== ERROR_UNKNOWN_FEATURE
, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r
);
2106 ok( state
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", state
);
2107 ok( action
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", action
);
2111 r
= MsiGetFeatureState(hpkg
, "four", &state
, &action
);
2112 ok( r
== ERROR_UNKNOWN_FEATURE
, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r
);
2113 ok( state
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", state
);
2114 ok( action
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", action
);
2118 r
= MsiGetFeatureState(hpkg
, "five", &state
, &action
);
2119 ok( r
== ERROR_UNKNOWN_FEATURE
, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r
);
2120 ok( state
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", state
);
2121 ok( action
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", action
);
2125 r
= MsiGetComponentState(hpkg
, "alpha", &state
, &action
);
2126 ok( r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r
);
2127 ok( state
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", state
);
2128 ok( action
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", action
);
2132 r
= MsiGetComponentState(hpkg
, "beta", &state
, &action
);
2133 ok( r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r
);
2134 ok( state
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", state
);
2135 ok( action
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", action
);
2139 r
= MsiGetComponentState(hpkg
, "gamma", &state
, &action
);
2140 ok( r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r
);
2141 ok( state
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", state
);
2142 ok( action
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", action
);
2146 r
= MsiGetComponentState(hpkg
, "theta", &state
, &action
);
2147 ok( r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r
);
2148 ok( state
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", state
);
2149 ok( action
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", action
);
2153 r
= MsiGetComponentState(hpkg
, "delta", &state
, &action
);
2154 ok( r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r
);
2155 ok( state
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", state
);
2156 ok( action
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", action
);
2160 r
= MsiGetComponentState(hpkg
, "epsilon", &state
, &action
);
2161 ok( r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r
);
2162 ok( state
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", state
);
2163 ok( action
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", action
);
2167 r
= MsiGetComponentState(hpkg
, "zeta", &state
, &action
);
2168 ok( r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r
);
2169 ok( state
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", state
);
2170 ok( action
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", action
);
2174 r
= MsiGetComponentState(hpkg
, "iota", &state
, &action
);
2175 ok( r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r
);
2176 ok( state
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", state
);
2177 ok( action
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", action
);
2181 r
= MsiGetComponentState(hpkg
, "eta", &state
, &action
);
2182 ok( r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r
);
2183 ok( state
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", state
);
2184 ok( action
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", action
);
2188 r
= MsiGetComponentState(hpkg
, "kappa", &state
, &action
);
2189 ok( r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r
);
2190 ok( state
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", state
);
2191 ok( action
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", action
);
2193 r
= MsiDoAction( hpkg
, "CostInitialize");
2194 ok( r
== ERROR_SUCCESS
, "cost init failed\n");
2198 r
= MsiGetFeatureState(hpkg
, "one", &state
, &action
);
2199 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2200 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2201 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
2205 r
= MsiGetFeatureState(hpkg
, "two", &state
, &action
);
2206 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2207 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2208 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
2212 r
= MsiGetFeatureState(hpkg
, "three", &state
, &action
);
2213 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2214 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2215 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
2219 r
= MsiGetFeatureState(hpkg
, "four", &state
, &action
);
2220 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2221 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2222 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
2226 r
= MsiGetFeatureState(hpkg
, "five", &state
, &action
);
2227 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2228 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2229 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
2233 r
= MsiGetComponentState(hpkg
, "alpha", &state
, &action
);
2234 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2235 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2236 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
2240 r
= MsiGetComponentState(hpkg
, "beta", &state
, &action
);
2241 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2242 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2243 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
2247 r
= MsiGetComponentState(hpkg
, "gamma", &state
, &action
);
2248 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2249 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2250 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
2254 r
= MsiGetComponentState(hpkg
, "theta", &state
, &action
);
2255 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2256 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2257 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
2261 r
= MsiGetComponentState(hpkg
, "delta", &state
, &action
);
2262 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2263 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2264 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
2268 r
= MsiGetComponentState(hpkg
, "epsilon", &state
, &action
);
2269 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2270 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2271 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
2275 r
= MsiGetComponentState(hpkg
, "zeta", &state
, &action
);
2276 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2277 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2278 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
2282 r
= MsiGetComponentState(hpkg
, "iota", &state
, &action
);
2283 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2284 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2285 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
2289 r
= MsiGetComponentState(hpkg
, "eta", &state
, &action
);
2290 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2291 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2292 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
2296 r
= MsiGetComponentState(hpkg
, "kappa", &state
, &action
);
2297 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2298 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2299 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
2301 r
= MsiDoAction( hpkg
, "FileCost");
2302 ok( r
== ERROR_SUCCESS
, "file cost failed\n");
2306 r
= MsiGetFeatureState(hpkg
, "one", &state
, &action
);
2307 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2308 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2309 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
2313 r
= MsiGetFeatureState(hpkg
, "two", &state
, &action
);
2314 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2315 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2316 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
2320 r
= MsiGetFeatureState(hpkg
, "three", &state
, &action
);
2321 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2322 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2323 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
2327 r
= MsiGetFeatureState(hpkg
, "four", &state
, &action
);
2328 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2329 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2330 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
2334 r
= MsiGetFeatureState(hpkg
, "five", &state
, &action
);
2335 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2336 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2337 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
2341 r
= MsiGetComponentState(hpkg
, "alpha", &state
, &action
);
2342 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2343 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2344 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
2348 r
= MsiGetComponentState(hpkg
, "beta", &state
, &action
);
2349 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2350 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2351 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
2355 r
= MsiGetComponentState(hpkg
, "gamma", &state
, &action
);
2356 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2357 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2358 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
2362 r
= MsiGetComponentState(hpkg
, "theta", &state
, &action
);
2363 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2364 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2365 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
2369 r
= MsiGetComponentState(hpkg
, "delta", &state
, &action
);
2370 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2371 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2372 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
2376 r
= MsiGetComponentState(hpkg
, "epsilon", &state
, &action
);
2377 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2378 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2379 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
2383 r
= MsiGetComponentState(hpkg
, "zeta", &state
, &action
);
2384 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2385 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2386 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
2390 r
= MsiGetComponentState(hpkg
, "iota", &state
, &action
);
2391 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2392 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2393 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
2397 r
= MsiGetComponentState(hpkg
, "eta", &state
, &action
);
2398 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2399 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2400 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
2404 r
= MsiGetComponentState(hpkg
, "kappa", &state
, &action
);
2405 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2406 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2407 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
2409 r
= MsiDoAction( hpkg
, "CostFinalize");
2410 ok( r
== ERROR_SUCCESS
, "cost finalize failed: %d\n", r
);
2414 r
= MsiGetFeatureState(hpkg
, "one", &state
, &action
);
2415 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2416 ok( state
== INSTALLSTATE_ABSENT
, "Expected one INSTALLSTATE_ABSENT, got %d\n", state
);
2417 ok( action
== INSTALLSTATE_LOCAL
, "Expected one INSTALLSTATE_LOCAL, got %d\n", action
);
2421 r
= MsiGetFeatureState(hpkg
, "two", &state
, &action
);
2422 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2423 ok( state
== INSTALLSTATE_ABSENT
, "Expected two INSTALLSTATE_ABSENT, got %d\n", state
);
2424 ok( action
== INSTALLSTATE_SOURCE
, "Expected two INSTALLSTATE_SOURCE, got %d\n", action
);
2428 r
= MsiGetFeatureState(hpkg
, "three", &state
, &action
);
2429 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2430 ok( state
== INSTALLSTATE_ABSENT
, "Expected three INSTALLSTATE_ABSENT, got %d\n", state
);
2431 ok( action
== INSTALLSTATE_LOCAL
, "Expected three INSTALLSTATE_LOCAL, got %d\n", action
);
2435 r
= MsiGetFeatureState(hpkg
, "four", &state
, &action
);
2436 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2437 ok( state
== INSTALLSTATE_ABSENT
, "Expected four INSTALLSTATE_ABSENT, got %d\n", state
);
2438 ok( action
== INSTALLSTATE_LOCAL
, "Expected four INSTALLSTATE_LOCAL, got %d\n", action
);
2442 r
= MsiGetFeatureState(hpkg
, "five", &state
, &action
);
2443 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2444 ok( state
== INSTALLSTATE_ABSENT
, "Expected five INSTALLSTATE_ABSENT, got %d\n", state
);
2445 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected five INSTALLSTATE_UNKNOWN, got %d\n", action
);
2449 r
= MsiGetComponentState(hpkg
, "alpha", &state
, &action
);
2450 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2451 ok( state
== INSTALLSTATE_ABSENT
, "Expected alpha INSTALLSTATE_ABSENT, got %d\n", state
);
2452 ok( action
== INSTALLSTATE_LOCAL
, "Expected alpha INSTALLSTATE_LOCAL, got %d\n", action
);
2456 r
= MsiGetComponentState(hpkg
, "beta", &state
, &action
);
2457 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2458 ok( state
== INSTALLSTATE_ABSENT
, "Expected beta INSTALLSTATE_ABSENT, got %d\n", state
);
2459 ok( action
== INSTALLSTATE_SOURCE
, "Expected beta INSTALLSTATE_SOURCE, got %d\n", action
);
2463 r
= MsiGetComponentState(hpkg
, "gamma", &state
, &action
);
2464 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2465 ok( state
== INSTALLSTATE_ABSENT
, "Expected gamma INSTALLSTATE_ABSENT, got %d\n", state
);
2466 ok( action
== INSTALLSTATE_LOCAL
, "Expected gamma INSTALLSTATE_LOCAL, got %d\n", action
);
2470 r
= MsiGetComponentState(hpkg
, "theta", &state
, &action
);
2471 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2472 ok( state
== INSTALLSTATE_ABSENT
, "Expected theta INSTALLSTATE_ABSENT, got %d\n", state
);
2473 ok( action
== INSTALLSTATE_LOCAL
, "Expected theta INSTALLSTATE_LOCAL, got %d\n", action
);
2477 r
= MsiGetComponentState(hpkg
, "delta", &state
, &action
);
2478 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2479 ok( state
== INSTALLSTATE_ABSENT
, "Expected delta INSTALLSTATE_ABSENT, got %d\n", state
);
2480 ok( action
== INSTALLSTATE_LOCAL
, "Expected delta INSTALLSTATE_LOCAL, got %d\n", action
);
2484 r
= MsiGetComponentState(hpkg
, "epsilon", &state
, &action
);
2485 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2486 ok( state
== INSTALLSTATE_ABSENT
, "Expected epsilon INSTALLSTATE_ABSENT, got %d\n", state
);
2487 ok( action
== INSTALLSTATE_SOURCE
, "Expected epsilon INSTALLSTATE_SOURCE, got %d\n", action
);
2491 r
= MsiGetComponentState(hpkg
, "zeta", &state
, &action
);
2492 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2493 ok( state
== INSTALLSTATE_ABSENT
, "Expected zeta INSTALLSTATE_ABSENT, got %d\n", state
);
2494 ok( action
== INSTALLSTATE_SOURCE
, "Expected zeta INSTALLSTATE_SOURCE, got %d\n", action
);
2498 r
= MsiGetComponentState(hpkg
, "iota", &state
, &action
);
2499 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2500 ok( state
== INSTALLSTATE_ABSENT
, "Expected iota INSTALLSTATE_ABSENT, got %d\n", state
);
2501 ok( action
== INSTALLSTATE_LOCAL
, "Expected iota INSTALLSTATE_LOCAL, got %d\n", action
);
2505 r
= MsiGetComponentState(hpkg
, "eta", &state
, &action
);
2506 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2507 ok( state
== INSTALLSTATE_ABSENT
, "Expected eta INSTALLSTATE_ABSENT, got %d\n", state
);
2508 ok( action
== INSTALLSTATE_LOCAL
, "Expected eta INSTALLSTATE_LOCAL, got %d\n", action
);
2512 r
= MsiGetComponentState(hpkg
, "kappa", &state
, &action
);
2513 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2514 ok( state
== INSTALLSTATE_ABSENT
, "Expected kappa INSTALLSTATE_ABSENT, got %d\n", state
);
2515 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected kappa INSTALLSTATE_UNKNOWN, got %d\n", action
);
2517 MsiCloseHandle( hpkg
);
2518 DeleteFileA( msifile
);
2521 static void test_getproperty(void)
2523 MSIHANDLE hPackage
= 0;
2525 static CHAR empty
[] = "";
2529 hPackage
= package_from_db(create_package_db());
2530 ok( hPackage
!= 0, " Failed to create package\n");
2532 /* set the property */
2533 r
= MsiSetProperty(hPackage
, "Name", "Value");
2534 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2536 /* retrieve the size, NULL pointer */
2538 r
= MsiGetProperty(hPackage
, "Name", NULL
, &size
);
2539 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2540 ok( size
== 5, "Expected 5, got %d\n", size
);
2542 /* retrieve the size, empty string */
2544 r
= MsiGetProperty(hPackage
, "Name", empty
, &size
);
2545 ok( r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
2546 ok( size
== 5, "Expected 5, got %d\n", size
);
2548 /* don't change size */
2549 r
= MsiGetProperty(hPackage
, "Name", prop
, &size
);
2550 ok( r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
2551 ok( size
== 5, "Expected 5, got %d\n", size
);
2552 ok( !lstrcmp(prop
, "Valu"), "Expected Valu, got %s\n", prop
);
2554 /* increase the size by 1 */
2556 r
= MsiGetProperty(hPackage
, "Name", prop
, &size
);
2557 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2558 ok( size
== 5, "Expected 5, got %d\n", size
);
2559 ok( !lstrcmp(prop
, "Value"), "Expected Value, got %s\n", prop
);
2561 r
= MsiCloseHandle( hPackage
);
2562 ok( r
== ERROR_SUCCESS
, "Failed to close package\n" );
2563 DeleteFile(msifile
);
2566 static void test_removefiles(void)
2571 char CURR_DIR
[MAX_PATH
];
2573 GetCurrentDirectoryA(MAX_PATH
, CURR_DIR
);
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
= add_feature_entry( hdb
, "'one', '', '', '', 2, 1, '', 0" );
2588 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
2590 r
= add_component_entry( hdb
, "'hydrogen', '', 'TARGETDIR', 0, '', 'hydrogen_file'" );
2591 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2593 r
= add_component_entry( hdb
, "'helium', '', 'TARGETDIR', 0, '', 'helium_file'" );
2594 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2596 r
= add_component_entry( hdb
, "'lithium', '', 'TARGETDIR', 0, '', 'lithium_file'" );
2597 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2599 r
= add_component_entry( hdb
, "'beryllium', '', 'TARGETDIR', 0, '', 'beryllium_file'" );
2600 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2602 r
= add_component_entry( hdb
, "'boron', '', 'TARGETDIR', 0, '', 'boron_file'" );
2603 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2605 r
= add_component_entry( hdb
, "'carbon', '', 'TARGETDIR', 0, '', 'carbon_file'" );
2606 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2608 r
= create_feature_components_table( hdb
);
2609 ok( r
== ERROR_SUCCESS
, "cannot create FeatureComponents table: %d\n", r
);
2611 r
= add_feature_components_entry( hdb
, "'one', 'hydrogen'" );
2612 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2614 r
= add_feature_components_entry( hdb
, "'one', 'helium'" );
2615 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2617 r
= add_feature_components_entry( hdb
, "'one', 'lithium'" );
2618 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2620 r
= add_feature_components_entry( hdb
, "'one', 'beryllium'" );
2621 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2623 r
= add_feature_components_entry( hdb
, "'one', 'boron'" );
2624 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2626 r
= add_feature_components_entry( hdb
, "'one', 'carbon'" );
2627 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2629 r
= create_file_table( hdb
);
2630 ok( r
== ERROR_SUCCESS
, "cannot create File table: %d\n", r
);
2632 r
= add_file_entry( hdb
, "'hydrogen_file', 'hydrogen', 'hydrogen.txt', 0, '', '1033', 8192, 1" );
2633 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
2635 r
= add_file_entry( hdb
, "'helium_file', 'helium', 'helium.txt', 0, '', '1033', 8192, 1" );
2636 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
2638 r
= add_file_entry( hdb
, "'lithium_file', 'lithium', 'lithium.txt', 0, '', '1033', 8192, 1" );
2639 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
2641 r
= add_file_entry( hdb
, "'beryllium_file', 'beryllium', 'beryllium.txt', 0, '', '1033', 16384, 1" );
2642 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
2644 r
= add_file_entry( hdb
, "'boron_file', 'boron', 'boron.txt', 0, '', '1033', 16384, 1" );
2645 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
2647 r
= add_file_entry( hdb
, "'carbon_file', 'carbon', 'carbon.txt', 0, '', '1033', 16384, 1" );
2648 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
2650 r
= create_remove_file_table( hdb
);
2651 ok( r
== ERROR_SUCCESS
, "cannot create Remove File table: %d\n", r
);
2653 hpkg
= package_from_db( hdb
);
2654 ok( hpkg
, "failed to create package\n");
2656 MsiCloseHandle( hdb
);
2658 create_test_file( "hydrogen.txt" );
2659 create_test_file( "helium.txt" );
2660 create_test_file( "lithium.txt" );
2661 create_test_file( "beryllium.txt" );
2662 create_test_file( "boron.txt" );
2663 create_test_file( "carbon.txt" );
2665 r
= MsiSetProperty( hpkg
, "TARGETDIR", CURR_DIR
);
2666 ok( r
== ERROR_SUCCESS
, "set property failed\n");
2668 r
= MsiDoAction( hpkg
, "CostInitialize");
2669 ok( r
== ERROR_SUCCESS
, "cost init failed\n");
2671 r
= MsiDoAction( hpkg
, "FileCost");
2672 ok( r
== ERROR_SUCCESS
, "cost finalize failed\n");
2674 r
= MsiDoAction( hpkg
, "CostFinalize");
2675 ok( r
== ERROR_SUCCESS
, "cost finalize failed\n");
2677 r
= MsiDoAction( hpkg
, "InstallValidate");
2678 ok( r
== ERROR_SUCCESS
, "cost finalize failed\n");
2680 r
= MsiSetComponentState( hpkg
, "hydrogen", INSTALLSTATE_ABSENT
);
2681 ok( r
== ERROR_SUCCESS
, "failed to set component state: %d\n", r
);
2683 r
= MsiSetComponentState( hpkg
, "helium", INSTALLSTATE_LOCAL
);
2684 ok( r
== ERROR_SUCCESS
, "failed to set component state: %d\n", r
);
2686 r
= MsiSetComponentState( hpkg
, "lithium", INSTALLSTATE_SOURCE
);
2687 ok( r
== ERROR_SUCCESS
, "failed to set component state: %d\n", r
);
2689 r
= MsiSetComponentState( hpkg
, "beryllium", INSTALLSTATE_ABSENT
);
2690 ok( r
== ERROR_SUCCESS
, "failed to set component state: %d\n", r
);
2692 r
= MsiSetComponentState( hpkg
, "boron", INSTALLSTATE_LOCAL
);
2693 ok( r
== ERROR_SUCCESS
, "failed to set component state: %d\n", r
);
2695 r
= MsiSetComponentState( hpkg
, "carbon", INSTALLSTATE_SOURCE
);
2696 ok( r
== ERROR_SUCCESS
, "failed to set component state: %d\n", r
);
2698 r
= MsiDoAction( hpkg
, "RemoveFiles");
2699 ok( r
== ERROR_SUCCESS
, "remove files failed\n");
2701 ok(DeleteFileA("hydrogen.txt"), "Expected hydrogen.txt to exist\n");
2702 ok(DeleteFileA("lithium.txt"), "Expected lithium.txt to exist\n");
2703 ok(DeleteFileA("beryllium.txt"), "Expected beryllium.txt to exist\n");
2704 ok(DeleteFileA("carbon.txt"), "Expected carbon.txt to exist\n");
2705 ok(DeleteFileA("helium.txt"), "Expected helium.txt to exist\n");
2706 ok(DeleteFileA("boron.txt"), "Expected boron.txt to exist\n");
2708 MsiCloseHandle( hpkg
);
2709 DeleteFileA(msifile
);
2712 static void test_appsearch(void)
2717 CHAR prop
[MAX_PATH
];
2718 DWORD size
= MAX_PATH
;
2720 hdb
= create_package_db();
2721 ok ( hdb
, "failed to create package database\n" );
2723 r
= create_appsearch_table( hdb
);
2724 ok( r
== ERROR_SUCCESS
, "cannot create AppSearch table: %d\n", r
);
2726 r
= add_appsearch_entry( hdb
, "'WEBBROWSERPROG', 'NewSignature1'" );
2727 ok( r
== ERROR_SUCCESS
, "cannot add entry: %d\n", r
);
2729 r
= create_reglocator_table( hdb
);
2730 ok( r
== ERROR_SUCCESS
, "cannot create RegLocator table: %d\n", r
);
2732 r
= add_reglocator_entry( hdb
, "'NewSignature1', 0, 'htmlfile\\shell\\open\\command', '', 1" );
2733 ok( r
== ERROR_SUCCESS
, "cannot create RegLocator table: %d\n", r
);
2735 r
= create_signature_table( hdb
);
2736 ok( r
== ERROR_SUCCESS
, "cannot create Signature table: %d\n", r
);
2738 r
= add_signature_entry( hdb
, "'NewSignature1', 'FileName', '', '', '', '', '', '', ''" );
2739 ok( r
== ERROR_SUCCESS
, "cannot create Signature table: %d\n", r
);
2741 hpkg
= package_from_db( hdb
);
2742 ok( hpkg
, "failed to create package\n");
2744 MsiCloseHandle( hdb
);
2746 r
= MsiDoAction( hpkg
, "AppSearch" );
2747 ok( r
== ERROR_SUCCESS
, "AppSearch failed: %d\n", r
);
2749 r
= MsiGetPropertyA( hpkg
, "WEBBROWSERPROG", prop
, &size
);
2750 ok( r
== ERROR_SUCCESS
, "get property failed: %d\n", r
);
2751 ok( lstrlenA(prop
) != 0, "Expected non-zero length\n");
2753 MsiCloseHandle( hpkg
);
2754 DeleteFileA(msifile
);
2757 static void test_featureparents(void)
2762 INSTALLSTATE state
, action
;
2764 hdb
= create_package_db();
2765 ok ( hdb
, "failed to create package database\n" );
2767 r
= add_directory_entry( hdb
, "'TARGETDIR', '', 'SourceDir'");
2768 ok( r
== ERROR_SUCCESS
, "cannot add directory: %d\n", r
);
2770 r
= create_feature_table( hdb
);
2771 ok( r
== ERROR_SUCCESS
, "cannot create Feature table: %d\n", r
);
2773 r
= create_component_table( hdb
);
2774 ok( r
== ERROR_SUCCESS
, "cannot create Component table: %d\n", r
);
2776 r
= create_feature_components_table( hdb
);
2777 ok( r
== ERROR_SUCCESS
, "cannot create FeatureComponents table: %d\n", r
);
2779 r
= create_file_table( hdb
);
2780 ok( r
== ERROR_SUCCESS
, "cannot create File table: %d\n", r
);
2782 /* msidbFeatureAttributesFavorLocal */
2783 r
= add_feature_entry( hdb
, "'zodiac', '', '', '', 2, 1, '', 0" );
2784 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
2786 /* msidbFeatureAttributesFavorSource */
2787 r
= add_feature_entry( hdb
, "'perseus', '', '', '', 2, 1, '', 1" );
2788 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
2790 /* msidbFeatureAttributesFavorLocal */
2791 r
= add_feature_entry( hdb
, "'orion', '', '', '', 2, 1, '', 0" );
2792 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
2794 /* disabled because of install level */
2795 r
= add_feature_entry( hdb
, "'waters', '', '', '', 15, 101, '', 9" );
2796 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
2798 /* child feature of disabled feature */
2799 r
= add_feature_entry( hdb
, "'bayer', 'waters', '', '', 14, 1, '', 9" );
2800 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
2802 /* component of disabled feature (install level) */
2803 r
= add_component_entry( hdb
, "'delphinus', '', 'TARGETDIR', 0, '', 'delphinus_file'" );
2804 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2806 /* component of disabled child feature (install level) */
2807 r
= add_component_entry( hdb
, "'hydrus', '', 'TARGETDIR', 0, '', 'hydrus_file'" );
2808 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2810 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
2811 r
= add_component_entry( hdb
, "'leo', '', 'TARGETDIR', 0, '', 'leo_file'" );
2812 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2814 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
2815 r
= add_component_entry( hdb
, "'virgo', '', 'TARGETDIR', 1, '', 'virgo_file'" );
2816 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2818 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
2819 r
= add_component_entry( hdb
, "'libra', '', 'TARGETDIR', 2, '', 'libra_file'" );
2820 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2822 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
2823 r
= add_component_entry( hdb
, "'cassiopeia', '', 'TARGETDIR', 0, '', 'cassiopeia_file'" );
2824 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2826 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
2827 r
= add_component_entry( hdb
, "'cepheus', '', 'TARGETDIR', 1, '', 'cepheus_file'" );
2828 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2830 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
2831 r
= add_component_entry( hdb
, "'andromeda', '', 'TARGETDIR', 2, '', 'andromeda_file'" );
2832 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2834 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
2835 r
= add_component_entry( hdb
, "'canis', '', 'TARGETDIR', 0, '', 'canis_file'" );
2836 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2838 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
2839 r
= add_component_entry( hdb
, "'monoceros', '', 'TARGETDIR', 1, '', 'monoceros_file'" );
2840 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2842 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
2843 r
= add_component_entry( hdb
, "'lepus', '', 'TARGETDIR', 2, '', 'lepus_file'" );
2845 r
= add_feature_components_entry( hdb
, "'zodiac', 'leo'" );
2846 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2848 r
= add_feature_components_entry( hdb
, "'zodiac', 'virgo'" );
2849 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2851 r
= add_feature_components_entry( hdb
, "'zodiac', 'libra'" );
2852 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2854 r
= add_feature_components_entry( hdb
, "'perseus', 'cassiopeia'" );
2855 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2857 r
= add_feature_components_entry( hdb
, "'perseus', 'cepheus'" );
2858 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2860 r
= add_feature_components_entry( hdb
, "'perseus', 'andromeda'" );
2861 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2863 r
= add_feature_components_entry( hdb
, "'orion', 'leo'" );
2864 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2866 r
= add_feature_components_entry( hdb
, "'orion', 'virgo'" );
2867 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2869 r
= add_feature_components_entry( hdb
, "'orion', 'libra'" );
2870 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2872 r
= add_feature_components_entry( hdb
, "'orion', 'cassiopeia'" );
2873 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2875 r
= add_feature_components_entry( hdb
, "'orion', 'cepheus'" );
2876 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2878 r
= add_feature_components_entry( hdb
, "'orion', 'andromeda'" );
2879 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2881 r
= add_feature_components_entry( hdb
, "'orion', 'canis'" );
2882 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2884 r
= add_feature_components_entry( hdb
, "'orion', 'monoceros'" );
2885 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2887 r
= add_feature_components_entry( hdb
, "'orion', 'lepus'" );
2888 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2890 r
= add_feature_components_entry( hdb
, "'waters', 'delphinus'" );
2891 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2893 r
= add_feature_components_entry( hdb
, "'bayer', 'hydrus'" );
2894 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2896 r
= add_file_entry( hdb
, "'leo_file', 'leo', 'leo.txt', 100, '', '1033', 8192, 1" );
2897 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
2899 r
= add_file_entry( hdb
, "'virgo_file', 'virgo', 'virgo.txt', 0, '', '1033', 8192, 1" );
2900 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
2902 r
= add_file_entry( hdb
, "'libra_file', 'libra', 'libra.txt', 0, '', '1033', 8192, 1" );
2903 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
2905 r
= add_file_entry( hdb
, "'cassiopeia_file', 'cassiopeia', 'cassiopeia.txt', 0, '', '1033', 8192, 1" );
2906 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
2908 r
= add_file_entry( hdb
, "'cepheus_file', 'cepheus', 'cepheus.txt', 0, '', '1033', 8192, 1" );
2909 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
2911 r
= add_file_entry( hdb
, "'andromeda_file', 'andromeda', 'andromeda.txt', 0, '', '1033', 8192, 1" );
2912 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
2914 r
= add_file_entry( hdb
, "'canis_file', 'canis', 'canis.txt', 0, '', '1033', 8192, 1" );
2915 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
2917 r
= add_file_entry( hdb
, "'monoceros_file', 'monoceros', 'monoceros.txt', 0, '', '1033', 8192, 1" );
2918 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
2920 r
= add_file_entry( hdb
, "'lepus_file', 'lepus', 'lepus.txt', 0, '', '1033', 8192, 1" );
2921 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
2923 r
= add_file_entry( hdb
, "'delphinus_file', 'delphinus', 'delphinus.txt', 0, '', '1033', 8192, 1" );
2924 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
2926 r
= add_file_entry( hdb
, "'hydrus_file', 'hydrus', 'hydrus.txt', 0, '', '1033', 8192, 1" );
2927 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
2929 hpkg
= package_from_db( hdb
);
2930 ok( hpkg
, "failed to create package\n");
2932 MsiCloseHandle( hdb
);
2934 r
= MsiDoAction( hpkg
, "CostInitialize");
2935 ok( r
== ERROR_SUCCESS
, "cost init failed\n");
2937 r
= MsiDoAction( hpkg
, "FileCost");
2938 ok( r
== ERROR_SUCCESS
, "file cost failed\n");
2940 r
= MsiDoAction( hpkg
, "CostFinalize");
2941 ok( r
== ERROR_SUCCESS
, "cost finalize failed\n");
2945 r
= MsiGetFeatureState(hpkg
, "zodiac", &state
, &action
);
2946 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2947 ok( state
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", state
);
2948 ok( action
== INSTALLSTATE_LOCAL
, "Expected INSTALLSTATE_LOCAL, got %d\n", action
);
2952 r
= MsiGetFeatureState(hpkg
, "perseus", &state
, &action
);
2953 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2954 ok( state
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", state
);
2955 ok( action
== INSTALLSTATE_SOURCE
, "Expected INSTALLSTATE_SOURCE, got %d\n", action
);
2959 r
= MsiGetFeatureState(hpkg
, "orion", &state
, &action
);
2960 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2961 ok( state
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", state
);
2962 ok( action
== INSTALLSTATE_LOCAL
, "Expected INSTALLSTATE_LOCAL, got %d\n", action
);
2966 r
= MsiGetFeatureState(hpkg
, "waters", &state
, &action
);
2967 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2968 ok( state
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", state
);
2969 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
2973 r
= MsiGetFeatureState(hpkg
, "bayer", &state
, &action
);
2974 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2975 ok( state
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", state
);
2976 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
2980 r
= MsiGetComponentState(hpkg
, "leo", &state
, &action
);
2981 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2982 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2983 ok( action
== INSTALLSTATE_LOCAL
, "Expected INSTALLSTATE_LOCAL, got %d\n", action
);
2987 r
= MsiGetComponentState(hpkg
, "virgo", &state
, &action
);
2988 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2989 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected virgo INSTALLSTATE_UNKNOWN, got %d\n", state
);
2990 ok( action
== INSTALLSTATE_SOURCE
, "Expected virgo INSTALLSTATE_SOURCE, got %d\n", action
);
2994 r
= MsiGetComponentState(hpkg
, "libra", &state
, &action
);
2995 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2996 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected libra INSTALLSTATE_UNKNOWN, got %d\n", state
);
2997 ok( action
== INSTALLSTATE_LOCAL
, "Expected libra INSTALLSTATE_LOCAL, got %d\n", action
);
3001 r
= MsiGetComponentState(hpkg
, "cassiopeia", &state
, &action
);
3002 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3003 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected cassiopeia INSTALLSTATE_UNKNOWN, got %d\n", state
);
3004 ok( action
== INSTALLSTATE_LOCAL
, "Expected cassiopeia INSTALLSTATE_LOCAL, got %d\n", action
);
3008 r
= MsiGetComponentState(hpkg
, "cepheus", &state
, &action
);
3009 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3010 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected cepheus INSTALLSTATE_UNKNOWN, got %d\n", state
);
3011 ok( action
== INSTALLSTATE_SOURCE
, "Expected cepheus INSTALLSTATE_SOURCE, got %d\n", action
);
3015 r
= MsiGetComponentState(hpkg
, "andromeda", &state
, &action
);
3016 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3017 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected andromeda INSTALLSTATE_UNKNOWN, got %d\n", state
);
3018 ok( action
== INSTALLSTATE_LOCAL
, "Expected andromeda INSTALLSTATE_LOCAL, got %d\n", action
);
3022 r
= MsiGetComponentState(hpkg
, "canis", &state
, &action
);
3023 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3024 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected canis INSTALLSTATE_UNKNOWN, got %d\n", state
);
3025 ok( action
== INSTALLSTATE_LOCAL
, "Expected canis INSTALLSTATE_LOCAL, got %d\n", action
);
3029 r
= MsiGetComponentState(hpkg
, "monoceros", &state
, &action
);
3030 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3031 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected monoceros INSTALLSTATE_UNKNOWN, got %d\n", state
);
3032 ok( action
== INSTALLSTATE_SOURCE
, "Expected monoceros INSTALLSTATE_SOURCE, got %d\n", action
);
3036 r
= MsiGetComponentState(hpkg
, "lepus", &state
, &action
);
3037 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3038 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected lepus INSTALLSTATE_UNKNOWN, got %d\n", state
);
3039 ok( action
== INSTALLSTATE_LOCAL
, "Expected lepus INSTALLSTATE_LOCAL, got %d\n", action
);
3043 r
= MsiGetComponentState(hpkg
, "delphinus", &state
, &action
);
3044 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3045 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", state
);
3046 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", action
);
3050 r
= MsiGetComponentState(hpkg
, "hydrus", &state
, &action
);
3051 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3052 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", state
);
3053 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", action
);
3055 r
= MsiSetFeatureState(hpkg
, "orion", INSTALLSTATE_ABSENT
);
3056 ok( r
== ERROR_SUCCESS
, "failed to set feature state: %d\n", r
);
3060 r
= MsiGetFeatureState(hpkg
, "zodiac", &state
, &action
);
3061 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3062 ok( state
== INSTALLSTATE_ABSENT
, "Expected zodiac INSTALLSTATE_ABSENT, got %d\n", state
);
3063 ok( action
== INSTALLSTATE_LOCAL
, "Expected zodiac INSTALLSTATE_LOCAL, got %d\n", action
);
3067 r
= MsiGetFeatureState(hpkg
, "perseus", &state
, &action
);
3068 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3069 ok( state
== INSTALLSTATE_ABSENT
, "Expected perseus INSTALLSTATE_ABSENT, got %d\n", state
);
3070 ok( action
== INSTALLSTATE_SOURCE
, "Expected perseus INSTALLSTATE_SOURCE, got %d\n", action
);
3074 r
= MsiGetFeatureState(hpkg
, "orion", &state
, &action
);
3075 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3076 ok( state
== INSTALLSTATE_ABSENT
, "Expected orion INSTALLSTATE_ABSENT, got %d\n", state
);
3077 ok( action
== INSTALLSTATE_ABSENT
, "Expected orion INSTALLSTATE_ABSENT, got %d\n", action
);
3081 r
= MsiGetComponentState(hpkg
, "leo", &state
, &action
);
3082 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3083 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected leo INSTALLSTATE_UNKNOWN, got %d\n", state
);
3084 ok( action
== INSTALLSTATE_LOCAL
, "Expected leo INSTALLSTATE_LOCAL, got %d\n", action
);
3088 r
= MsiGetComponentState(hpkg
, "virgo", &state
, &action
);
3089 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3090 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected virgo INSTALLSTATE_UNKNOWN, got %d\n", state
);
3091 ok( action
== INSTALLSTATE_SOURCE
, "Expected virgo INSTALLSTATE_SOURCE, got %d\n", action
);
3095 r
= MsiGetComponentState(hpkg
, "libra", &state
, &action
);
3096 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3097 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected libra INSTALLSTATE_UNKNOWN, got %d\n", state
);
3098 ok( action
== INSTALLSTATE_LOCAL
, "Expected libra INSTALLSTATE_LOCAL, got %d\n", action
);
3102 r
= MsiGetComponentState(hpkg
, "cassiopeia", &state
, &action
);
3103 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3104 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected cassiopeia INSTALLSTATE_UNKNOWN, got %d\n", state
);
3105 ok( action
== INSTALLSTATE_LOCAL
, "Expected cassiopeia INSTALLSTATE_LOCAL, got %d\n", action
);
3109 r
= MsiGetComponentState(hpkg
, "cepheus", &state
, &action
);
3110 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3111 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected cepheus INSTALLSTATE_UNKNOWN, got %d\n", state
);
3112 ok( action
== INSTALLSTATE_SOURCE
, "Expected cepheus INSTALLSTATE_SOURCE, got %d\n", action
);
3116 r
= MsiGetComponentState(hpkg
, "andromeda", &state
, &action
);
3117 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3118 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected andromeda INSTALLSTATE_UNKNOWN, got %d\n", state
);
3119 ok( action
== INSTALLSTATE_SOURCE
, "Expected andromeda INSTALLSTATE_SOURCE, got %d\n", action
);
3123 r
= MsiGetComponentState(hpkg
, "canis", &state
, &action
);
3124 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3125 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected canis INSTALLSTATE_UNKNOWN, got %d\n", state
);
3126 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected canis INSTALLSTATE_UNKNOWN, got %d\n", action
);
3130 r
= MsiGetComponentState(hpkg
, "monoceros", &state
, &action
);
3131 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3132 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected monoceros INSTALLSTATE_UNKNOWN, got %d\n", state
);
3133 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected monoceros INSTALLSTATE_UNKNOWN, got %d\n", action
);
3137 r
= MsiGetComponentState(hpkg
, "lepus", &state
, &action
);
3138 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3139 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected lepus INSTALLSTATE_UNKNOWN, got %d\n", state
);
3140 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected lepus INSTALLSTATE_UNKNOWN, got %d\n", action
);
3144 r
= MsiGetComponentState(hpkg
, "delphinus", &state
, &action
);
3145 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3146 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", state
);
3147 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", action
);
3151 r
= MsiGetComponentState(hpkg
, "hydrus", &state
, &action
);
3152 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3153 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", state
);
3154 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", action
);
3156 MsiCloseHandle(hpkg
);
3157 DeleteFileA(msifile
);
3160 static void test_installprops(void)
3162 MSIHANDLE hpkg
, hdb
;
3163 CHAR path
[MAX_PATH
];
3169 GetCurrentDirectory(MAX_PATH
, path
);
3170 lstrcat(path
, "\\");
3171 lstrcat(path
, msifile
);
3173 hdb
= create_package_db();
3174 ok( hdb
, "failed to create database\n");
3176 hpkg
= package_from_db(hdb
);
3177 ok( hpkg
, "failed to create package\n");
3179 MsiCloseHandle(hdb
);
3182 r
= MsiGetProperty(hpkg
, "DATABASE", buf
, &size
);
3183 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
3184 ok( !lstrcmp(buf
, path
), "Expected %s, got %s\n", path
, buf
);
3186 RegOpenKey(HKEY_LOCAL_MACHINE
, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", &hkey
);
3190 RegQueryValueEx(hkey
, "RegisteredOwner", NULL
, &type
, (LPBYTE
)path
, &size
);
3193 r
= MsiGetProperty(hpkg
, "USERNAME", buf
, &size
);
3194 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
3195 ok( !lstrcmp(buf
, path
), "Expected %s, got %s\n", path
, buf
);
3199 RegQueryValueEx(hkey
, "RegisteredOrganization", NULL
, &type
, (LPBYTE
)path
, &size
);
3202 r
= MsiGetProperty(hpkg
, "COMPANYNAME", buf
, &size
);
3203 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
3204 ok( !lstrcmp(buf
, path
), "Expected %s, got %s\n", path
, buf
);
3207 r
= MsiGetProperty(hpkg
, "VersionDatabase", buf
, &size
);
3208 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
3209 trace("VersionDatabase = %s\n", buf
);
3212 r
= MsiGetProperty(hpkg
, "VersionMsi", buf
, &size
);
3213 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
3214 trace("VersionMsi = %s\n", buf
);
3217 r
= MsiGetProperty(hpkg
, "Date", buf
, &size
);
3218 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
3219 trace("Date = %s\n", buf
);
3222 r
= MsiGetProperty(hpkg
, "Time", buf
, &size
);
3223 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
3224 trace("Time = %s\n", buf
);
3227 r
= MsiGetProperty(hpkg
, "PackageCode", buf
, &size
);
3228 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
3229 trace("PackageCode = %s\n", buf
);
3232 MsiCloseHandle(hpkg
);
3233 DeleteFile(msifile
);
3236 static void test_sourcedirprop(void)
3238 MSIHANDLE hpkg
, hdb
;
3239 CHAR source_dir
[MAX_PATH
];
3240 CHAR path
[MAX_PATH
];
3244 hdb
= create_package_db();
3245 ok ( hdb
, "failed to create package database\n" );
3247 r
= add_directory_entry( hdb
, "'TARGETDIR', '', 'SourceDir'");
3248 ok( r
== ERROR_SUCCESS
, "cannot add directory: %d\n", r
);
3250 hpkg
= package_from_db( hdb
);
3251 ok( hpkg
, "failed to create package\n");
3253 MsiCloseHandle( hdb
);
3256 r
= MsiGetProperty( hpkg
, "SourceDir", source_dir
, &size
);
3257 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
3258 ok( !lstrlenA(source_dir
), "Expected emtpy source dir, got %s\n", source_dir
);
3261 r
= MsiGetProperty( hpkg
, "SOURCEDIR", source_dir
, &size
);
3262 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
3263 ok( !lstrlenA(source_dir
), "Expected emtpy source dir, got %s\n", source_dir
);
3265 r
= MsiDoAction( hpkg
, "CostInitialize");
3266 ok( r
== ERROR_SUCCESS
, "cost init failed\n");
3269 r
= MsiGetProperty( hpkg
, "SourceDir", source_dir
, &size
);
3270 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
3271 ok( !lstrlenA(source_dir
), "Expected emtpy source dir, got %s\n", source_dir
);
3274 r
= MsiGetProperty( hpkg
, "SOURCEDIR", source_dir
, &size
);
3275 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
3276 ok( !lstrlenA(source_dir
), "Expected emtpy source dir, got %s\n", source_dir
);
3278 r
= MsiDoAction( hpkg
, "ResolveSource");
3279 ok( r
== ERROR_SUCCESS
, "file cost failed\n");
3281 GetCurrentDirectory(MAX_PATH
, path
);
3282 lstrcatA(path
, "\\");
3285 r
= MsiGetProperty( hpkg
, "SourceDir", source_dir
, &size
);
3286 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
3287 ok( !lstrcmpA(source_dir
, path
), "Expected %s, got %s\n", path
, source_dir
);
3290 r
= MsiGetProperty( hpkg
, "SOURCEDIR", source_dir
, &size
);
3291 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
3292 ok( !lstrcmpA(source_dir
, path
), "Expected %s, got %s\n", path
, source_dir
);
3295 r
= MsiGetProperty( hpkg
, "SoUrCeDiR", source_dir
, &size
);
3296 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
3297 ok( !lstrlenA(source_dir
), "Expected emtpy source dir, got %s\n", source_dir
);
3299 MsiCloseHandle(hpkg
);
3300 DeleteFileA(msifile
);
3303 static void test_prop_path(void)
3305 MSIHANDLE hpkg
, hdb
;
3306 char buffer
[MAX_PATH
], cwd
[MAX_PATH
];
3310 GetCurrentDirectory(MAX_PATH
, cwd
);
3313 hdb
= create_package_db();
3314 ok( hdb
, "failed to create database\n");
3316 r
= add_directory_entry( hdb
, "'TARGETDIR','','SourceDir'" );
3317 ok( r
== ERROR_SUCCESS
, "cannot add directory: %d\n", r
);
3319 r
= add_directory_entry( hdb
, "'foo','TARGETDIR','foosrc:footgt'" );
3320 ok( r
== ERROR_SUCCESS
, "cannot add directory: %d\n", r
);
3322 hpkg
= package_from_db(hdb
);
3323 ok( hpkg
, "failed to create package\n");
3325 r
= MsiGetSourcePath(hpkg
, "SourceDir", buffer
, &sz
);
3326 ok( r
== ERROR_DIRECTORY
, "failed to get source path\n");
3328 r
= MsiGetSourcePath(hpkg
, "SOURCEDIR", buffer
, &sz
);
3329 ok( r
== ERROR_DIRECTORY
, "failed to get source path\n");
3331 r
= MsiDoAction( hpkg
, "CostInitialize");
3332 ok( r
== ERROR_SUCCESS
, "cost init failed\n");
3336 r
= MsiGetProperty(hpkg
, "SourceDir", buffer
, &sz
);
3337 ok( r
== ERROR_SUCCESS
, "property not set\n");
3338 ok( !buffer
[0], "SourceDir should be empty\n");
3342 r
= MsiGetProperty(hpkg
, "SOURCEDIR", buffer
, &sz
);
3343 ok( r
== ERROR_SUCCESS
, "property not set\n");
3344 ok( !buffer
[0], "SourceDir should be empty\n");
3348 r
= MsiGetSourcePath(hpkg
, "SourceDir", buffer
, &sz
);
3349 ok( r
== ERROR_SUCCESS
, "failed to get source path\n");
3350 ok( !lstrcmpi(cwd
, buffer
), "SourceDir (%s) should be current dir (%s)\n", buffer
, cwd
);
3354 r
= MsiGetProperty(hpkg
, "SourceDir", buffer
, &sz
);
3355 ok( r
== ERROR_SUCCESS
, "property not set\n");
3357 ok( !lstrcmpi(cwd
, buffer
), "SourceDir (%s) should be current dir (%s)\n", buffer
, cwd
);
3362 r
= MsiGetSourcePath(hpkg
, "SOURCEDIR", buffer
, &sz
);
3363 ok( r
== ERROR_DIRECTORY
, "failed to get source path\n");
3367 r
= MsiGetProperty(hpkg
, "SOURCEDIR", buffer
, &sz
);
3368 ok( r
== ERROR_SUCCESS
, "property not set\n");
3370 ok( !lstrcmpi(cwd
, buffer
), "SourceDir (%s) should be current dir (%s)\n", buffer
, cwd
);
3373 r
= MsiSetProperty(hpkg
, "SourceDir", "goo");
3374 ok( r
== ERROR_SUCCESS
, "property not set\n");
3378 r
= MsiGetProperty(hpkg
, "SourceDir", buffer
, &sz
);
3379 ok( r
== ERROR_SUCCESS
, "property not set\n");
3380 ok( !lstrcmpi(buffer
, "goo"), "SourceDir (%s) should be goo\n", buffer
);
3384 r
= MsiGetSourcePath(hpkg
, "SourceDir", buffer
, &sz
);
3385 ok( r
== ERROR_SUCCESS
, "failed to get source path\n");
3386 ok( !lstrcmpi(buffer
, cwd
), "SourceDir (%s) should be goo\n", buffer
);
3390 r
= MsiGetProperty(hpkg
, "SourceDir", buffer
, &sz
);
3391 ok( r
== ERROR_SUCCESS
, "property not set\n");
3392 ok( !lstrcmpi(buffer
, "goo"), "SourceDir (%s) should be goo\n", buffer
);
3394 MsiCloseHandle( hpkg
);
3395 DeleteFile(msifile
);
3398 static void test_launchconditions(void)
3404 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
3406 hdb
= create_package_db();
3407 ok( hdb
, "failed to create package database\n" );
3409 r
= create_launchcondition_table( hdb
);
3410 ok( r
== ERROR_SUCCESS
, "cannot create LaunchCondition table: %d\n", r
);
3412 r
= add_launchcondition_entry( hdb
, "'X = \"1\"', 'one'" );
3413 ok( r
== ERROR_SUCCESS
, "cannot add launch condition: %d\n", r
);
3415 /* invalid condition */
3416 r
= add_launchcondition_entry( hdb
, "'X != \"1\"', 'one'" );
3417 ok( r
== ERROR_SUCCESS
, "cannot add launch condition: %d\n", r
);
3419 hpkg
= package_from_db( hdb
);
3420 ok( hpkg
, "failed to create package\n");
3422 MsiCloseHandle( hdb
);
3424 r
= MsiSetProperty( hpkg
, "X", "1" );
3425 ok( r
== ERROR_SUCCESS
, "failed to set property\n" );
3427 /* invalid conditions are ignored */
3428 r
= MsiDoAction( hpkg
, "LaunchConditions" );
3429 ok( r
== ERROR_SUCCESS
, "cost init failed\n" );
3431 /* verify LaunchConditions still does some verification */
3432 r
= MsiSetProperty( hpkg
, "X", "2" );
3433 ok( r
== ERROR_SUCCESS
, "failed to set property\n" );
3435 r
= MsiDoAction( hpkg
, "LaunchConditions" );
3436 ok( r
== ERROR_INSTALL_FAILURE
, "Expected ERROR_INSTALL_FAILURE, got %d\n", r
);
3438 MsiCloseHandle( hpkg
);
3439 DeleteFile( msifile
);
3444 test_createpackage();
3445 test_getsourcepath_bad();
3446 test_getsourcepath();
3448 test_gettargetpath_bad();
3449 test_settargetpath();
3451 test_property_table();
3454 test_formatrecord2();
3459 test_featureparents();
3460 test_installprops();
3461 test_sourcedirprop();
3463 test_launchconditions();