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
30 #include <srrestoreptapi.h>
33 #include "wine/test.h"
36 static const char msifile
[] = "winetest-package.msi";
37 static const WCHAR msifileW
[] =
38 {'w','i','n','e','t','e','s','t','-','p','a','c','k','a','g','e','.','m','s','i',0};
39 static char CURR_DIR
[MAX_PATH
];
41 static INSTALLSTATE (WINAPI
*pMsiGetComponentPathExA
)(LPCSTR
, LPCSTR
, LPCSTR
, MSIINSTALLCONTEXT
, LPSTR
, LPDWORD
);
42 static HRESULT (WINAPI
*pSHGetFolderPathA
)(HWND
, int, HANDLE
, DWORD
, LPSTR
);
44 static BOOL (WINAPI
*pCheckTokenMembership
)(HANDLE
,PSID
,PBOOL
);
45 static BOOL (WINAPI
*pConvertSidToStringSidA
)(PSID
, LPSTR
*);
46 static BOOL (WINAPI
*pOpenProcessToken
)( HANDLE
, DWORD
, PHANDLE
);
47 static LONG (WINAPI
*pRegDeleteKeyExA
)(HKEY
, LPCSTR
, REGSAM
, DWORD
);
48 static LONG (WINAPI
*pRegDeleteKeyExW
)(HKEY
, LPCWSTR
, REGSAM
, DWORD
);
49 static BOOL (WINAPI
*pIsWow64Process
)(HANDLE
, PBOOL
);
50 static void (WINAPI
*pGetSystemInfo
)(LPSYSTEM_INFO
);
51 static void (WINAPI
*pGetNativeSystemInfo
)(LPSYSTEM_INFO
);
52 static UINT (WINAPI
*pGetSystemWow64DirectoryA
)(LPSTR
, UINT
);
54 static BOOL (WINAPI
*pSRRemoveRestorePoint
)(DWORD
);
55 static BOOL (WINAPI
*pSRSetRestorePointA
)(RESTOREPOINTINFOA
*, STATEMGRSTATUS
*);
57 static void init_functionpointers(void)
59 HMODULE hmsi
= GetModuleHandleA("msi.dll");
60 HMODULE hadvapi32
= GetModuleHandleA("advapi32.dll");
61 HMODULE hkernel32
= GetModuleHandleA("kernel32.dll");
62 HMODULE hshell32
= GetModuleHandleA("shell32.dll");
65 #define GET_PROC(mod, func) \
66 p ## func = (void*)GetProcAddress(mod, #func);
68 GET_PROC(hmsi
, MsiGetComponentPathExA
);
69 GET_PROC(hshell32
, SHGetFolderPathA
);
71 GET_PROC(hadvapi32
, CheckTokenMembership
);
72 GET_PROC(hadvapi32
, ConvertSidToStringSidA
);
73 GET_PROC(hadvapi32
, OpenProcessToken
);
74 GET_PROC(hadvapi32
, RegDeleteKeyExA
)
75 GET_PROC(hadvapi32
, RegDeleteKeyExW
)
76 GET_PROC(hkernel32
, IsWow64Process
)
77 GET_PROC(hkernel32
, GetNativeSystemInfo
)
78 GET_PROC(hkernel32
, GetSystemInfo
)
79 GET_PROC(hkernel32
, GetSystemWow64DirectoryA
)
81 hsrclient
= LoadLibraryA("srclient.dll");
82 GET_PROC(hsrclient
, SRRemoveRestorePoint
);
83 GET_PROC(hsrclient
, SRSetRestorePointA
);
87 static BOOL
is_process_limited(void)
89 SID_IDENTIFIER_AUTHORITY NtAuthority
= {SECURITY_NT_AUTHORITY
};
94 if (!pCheckTokenMembership
|| !pOpenProcessToken
) return FALSE
;
96 if (!AllocateAndInitializeSid(&NtAuthority
, 2, SECURITY_BUILTIN_DOMAIN_RID
,
97 DOMAIN_ALIAS_RID_ADMINS
, 0, 0, 0, 0, 0, 0, &Group
) ||
98 !pCheckTokenMembership(NULL
, Group
, &IsInGroup
))
100 trace("Could not check if the current user is an administrator\n");
108 if (!AllocateAndInitializeSid(&NtAuthority
, 2,
109 SECURITY_BUILTIN_DOMAIN_RID
,
110 DOMAIN_ALIAS_RID_POWER_USERS
,
111 0, 0, 0, 0, 0, 0, &Group
) ||
112 !pCheckTokenMembership(NULL
, Group
, &IsInGroup
))
114 trace("Could not check if the current user is a power user\n");
119 /* Only administrators and power users can be powerful */
124 if (pOpenProcessToken(GetCurrentProcess(), TOKEN_QUERY
, &token
))
127 TOKEN_ELEVATION_TYPE type
= TokenElevationTypeDefault
;
130 ret
= GetTokenInformation(token
, TokenElevationType
, &type
, sizeof(type
), &size
);
132 return (ret
&& type
== TokenElevationTypeLimited
);
137 static LONG
delete_key( HKEY key
, LPCSTR subkey
, REGSAM access
)
139 if (pRegDeleteKeyExA
)
140 return pRegDeleteKeyExA( key
, subkey
, access
, 0 );
141 return RegDeleteKeyA( key
, subkey
);
144 static char *get_user_sid(void)
149 char *usersid
= NULL
;
151 if (!pConvertSidToStringSidA
)
153 win_skip("ConvertSidToStringSidA is not available\n");
156 OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY
, &token
);
157 GetTokenInformation(token
, TokenUser
, NULL
, size
, &size
);
159 user
= HeapAlloc(GetProcessHeap(), 0, size
);
160 GetTokenInformation(token
, TokenUser
, user
, size
, &size
);
161 pConvertSidToStringSidA(user
->User
.Sid
, &usersid
);
162 HeapFree(GetProcessHeap(), 0, user
);
168 /* RegDeleteTreeW from dlls/advapi32/registry.c */
169 static LSTATUS
package_RegDeleteTreeW(HKEY hKey
, LPCWSTR lpszSubKey
, REGSAM access
)
172 DWORD dwMaxSubkeyLen
, dwMaxValueLen
;
173 DWORD dwMaxLen
, dwSize
;
174 WCHAR szNameBuf
[MAX_PATH
], *lpszName
= szNameBuf
;
179 ret
= RegOpenKeyExW(hKey
, lpszSubKey
, 0, access
, &hSubKey
);
183 ret
= RegQueryInfoKeyW(hSubKey
, NULL
, NULL
, NULL
, NULL
,
184 &dwMaxSubkeyLen
, NULL
, NULL
, &dwMaxValueLen
, NULL
, NULL
, NULL
);
185 if (ret
) goto cleanup
;
189 dwMaxLen
= max(dwMaxSubkeyLen
, dwMaxValueLen
);
190 if (dwMaxLen
> sizeof(szNameBuf
)/sizeof(WCHAR
))
192 /* Name too big: alloc a buffer for it */
193 if (!(lpszName
= HeapAlloc( GetProcessHeap(), 0, dwMaxLen
*sizeof(WCHAR
))))
195 ret
= ERROR_NOT_ENOUGH_MEMORY
;
200 /* Recursively delete all the subkeys */
204 if (RegEnumKeyExW(hSubKey
, 0, lpszName
, &dwSize
, NULL
,
205 NULL
, NULL
, NULL
)) break;
207 ret
= package_RegDeleteTreeW(hSubKey
, lpszName
, access
);
208 if (ret
) goto cleanup
;
213 if (pRegDeleteKeyExW
)
214 ret
= pRegDeleteKeyExW(hKey
, lpszSubKey
, access
, 0);
216 ret
= RegDeleteKeyW(hKey
, lpszSubKey
);
222 if (RegEnumValueW(hKey
, 0, lpszName
, &dwSize
,
223 NULL
, NULL
, NULL
, NULL
)) break;
225 ret
= RegDeleteValueW(hKey
, lpszName
);
226 if (ret
) goto cleanup
;
230 if (lpszName
!= szNameBuf
)
231 HeapFree(GetProcessHeap(), 0, lpszName
);
233 RegCloseKey(hSubKey
);
237 static BOOL
squash_guid(LPCWSTR in
, LPWSTR out
)
242 if (FAILED(CLSIDFromString((LPCOLESTR
)in
, &guid
)))
256 out
[17+i
*2] = in
[n
++];
257 out
[16+i
*2] = in
[n
++];
262 out
[17+i
*2] = in
[n
++];
263 out
[16+i
*2] = in
[n
++];
269 static void create_test_guid(LPSTR prodcode
, LPSTR squashed
)
271 WCHAR guidW
[MAX_PATH
];
272 WCHAR squashedW
[MAX_PATH
];
277 hr
= CoCreateGuid(&guid
);
278 ok(hr
== S_OK
, "Expected S_OK, got %d\n", hr
);
280 size
= StringFromGUID2(&guid
, guidW
, MAX_PATH
);
281 ok(size
== 39, "Expected 39, got %d\n", hr
);
283 WideCharToMultiByte(CP_ACP
, 0, guidW
, size
, prodcode
, MAX_PATH
, NULL
, NULL
);
284 squash_guid(guidW
, squashedW
);
285 WideCharToMultiByte(CP_ACP
, 0, squashedW
, -1, squashed
, MAX_PATH
, NULL
, NULL
);
288 static void set_component_path(LPCSTR filename
, MSIINSTALLCONTEXT context
,
289 LPCSTR guid
, LPSTR usersid
, BOOL dir
)
291 WCHAR guidW
[MAX_PATH
];
292 WCHAR squashedW
[MAX_PATH
];
293 CHAR squashed
[MAX_PATH
];
294 CHAR comppath
[MAX_PATH
];
295 CHAR prodpath
[MAX_PATH
];
299 REGSAM access
= KEY_ALL_ACCESS
;
302 access
|= KEY_WOW64_64KEY
;
304 MultiByteToWideChar(CP_ACP
, 0, guid
, -1, guidW
, MAX_PATH
);
305 squash_guid(guidW
, squashedW
);
306 WideCharToMultiByte(CP_ACP
, 0, squashedW
, -1, squashed
, MAX_PATH
, NULL
, NULL
);
308 if (context
== MSIINSTALLCONTEXT_MACHINE
)
310 prod
= "3D0DAE300FACA1300AD792060BCDAA92";
312 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
313 "Installer\\UserData\\S-1-5-18\\Components\\%s", squashed
);
315 "SOFTWARE\\Classes\\Installer\\"
316 "Products\\3D0DAE300FACA1300AD792060BCDAA92");
318 else if (context
== MSIINSTALLCONTEXT_USERUNMANAGED
)
320 prod
= "7D2F387510109040002000060BECB6AB";
322 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
323 "Installer\\UserData\\%s\\Components\\%s", usersid
, squashed
);
325 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
326 "Installer\\%s\\Installer\\Products\\"
327 "7D2F387510109040002000060BECB6AB", usersid
);
329 else if (context
== MSIINSTALLCONTEXT_USERMANAGED
)
331 prod
= "7D2F387510109040002000060BECB6AB";
333 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
334 "Installer\\UserData\\%s\\Components\\%s", usersid
, squashed
);
336 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
337 "Installer\\Managed\\%s\\Installer\\Products\\"
338 "7D2F387510109040002000060BECB6AB", usersid
);
341 RegCreateKeyExA(HKEY_LOCAL_MACHINE
, comppath
, 0, NULL
, 0, access
, NULL
, &hkey
, NULL
);
343 lstrcpyA(path
, CURR_DIR
);
344 lstrcatA(path
, "\\");
345 if (!dir
) lstrcatA(path
, filename
);
347 RegSetValueExA(hkey
, prod
, 0, REG_SZ
, (LPBYTE
)path
, lstrlenA(path
));
350 RegCreateKeyExA(HKEY_LOCAL_MACHINE
, prodpath
, 0, NULL
, 0, access
, NULL
, &hkey
, NULL
);
354 static void delete_component_path(LPCSTR guid
, MSIINSTALLCONTEXT context
, LPSTR usersid
)
356 WCHAR guidW
[MAX_PATH
];
357 WCHAR squashedW
[MAX_PATH
];
358 WCHAR substrW
[MAX_PATH
];
359 CHAR squashed
[MAX_PATH
];
360 CHAR comppath
[MAX_PATH
];
361 CHAR prodpath
[MAX_PATH
];
362 REGSAM access
= KEY_ALL_ACCESS
;
365 access
|= KEY_WOW64_64KEY
;
367 MultiByteToWideChar(CP_ACP
, 0, guid
, -1, guidW
, MAX_PATH
);
368 squash_guid(guidW
, squashedW
);
369 WideCharToMultiByte(CP_ACP
, 0, squashedW
, -1, squashed
, MAX_PATH
, NULL
, NULL
);
371 if (context
== MSIINSTALLCONTEXT_MACHINE
)
374 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
375 "Installer\\UserData\\S-1-5-18\\Components\\%s", squashed
);
377 "SOFTWARE\\Classes\\Installer\\"
378 "Products\\3D0DAE300FACA1300AD792060BCDAA92");
380 else if (context
== MSIINSTALLCONTEXT_USERUNMANAGED
)
383 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
384 "Installer\\UserData\\%s\\Components\\%s", usersid
, squashed
);
386 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
387 "Installer\\%s\\Installer\\Products\\"
388 "7D2F387510109040002000060BECB6AB", usersid
);
390 else if (context
== MSIINSTALLCONTEXT_USERMANAGED
)
393 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
394 "Installer\\UserData\\%s\\Components\\%s", usersid
, squashed
);
396 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
397 "Installer\\Managed\\%s\\Installer\\Products\\"
398 "7D2F387510109040002000060BECB6AB", usersid
);
401 MultiByteToWideChar(CP_ACP
, 0, comppath
, -1, substrW
, MAX_PATH
);
402 package_RegDeleteTreeW(HKEY_LOCAL_MACHINE
, substrW
, access
);
404 MultiByteToWideChar(CP_ACP
, 0, prodpath
, -1, substrW
, MAX_PATH
);
405 package_RegDeleteTreeW(HKEY_LOCAL_MACHINE
, substrW
, access
);
408 static UINT
do_query(MSIHANDLE hdb
, const char *query
, MSIHANDLE
*phrec
)
413 /* open a select query */
414 r
= MsiDatabaseOpenViewA(hdb
, query
, &hview
);
415 if (r
!= ERROR_SUCCESS
)
417 r
= MsiViewExecute(hview
, 0);
418 if (r
!= ERROR_SUCCESS
)
420 ret
= MsiViewFetch(hview
, phrec
);
421 r
= MsiViewClose(hview
);
422 if (r
!= ERROR_SUCCESS
)
424 r
= MsiCloseHandle(hview
);
425 if (r
!= ERROR_SUCCESS
)
430 static UINT
run_query( MSIHANDLE hdb
, const char *query
)
435 r
= MsiDatabaseOpenViewA(hdb
, query
, &hview
);
436 if( r
!= ERROR_SUCCESS
)
439 r
= MsiViewExecute(hview
, 0);
440 if( r
== ERROR_SUCCESS
)
441 r
= MsiViewClose(hview
);
442 MsiCloseHandle(hview
);
446 static UINT
create_component_table( MSIHANDLE hdb
)
448 UINT r
= run_query( hdb
,
449 "CREATE TABLE `Component` ( "
450 "`Component` CHAR(72) NOT NULL, "
451 "`ComponentId` CHAR(38), "
452 "`Directory_` CHAR(72) NOT NULL, "
453 "`Attributes` SHORT NOT NULL, "
454 "`Condition` CHAR(255), "
455 "`KeyPath` CHAR(72) "
456 "PRIMARY KEY `Component`)" );
457 ok(r
== ERROR_SUCCESS
, "Failed to create Component table: %u\n", r
);
461 static UINT
create_feature_table( MSIHANDLE hdb
)
463 UINT r
= run_query( hdb
,
464 "CREATE TABLE `Feature` ( "
465 "`Feature` CHAR(38) NOT NULL, "
466 "`Feature_Parent` CHAR(38), "
468 "`Description` CHAR(255), "
469 "`Display` SHORT NOT NULL, "
470 "`Level` SHORT NOT NULL, "
471 "`Directory_` CHAR(72), "
472 "`Attributes` SHORT NOT NULL "
473 "PRIMARY KEY `Feature`)" );
474 ok(r
== ERROR_SUCCESS
, "Failed to create Feature table: %u\n", r
);
478 static UINT
create_feature_components_table( MSIHANDLE hdb
)
480 UINT r
= run_query( hdb
,
481 "CREATE TABLE `FeatureComponents` ( "
482 "`Feature_` CHAR(38) NOT NULL, "
483 "`Component_` CHAR(72) NOT NULL "
484 "PRIMARY KEY `Feature_`, `Component_` )" );
485 ok(r
== ERROR_SUCCESS
, "Failed to create FeatureComponents table: %u\n", r
);
489 static UINT
create_file_table( MSIHANDLE hdb
)
491 UINT r
= run_query( hdb
,
492 "CREATE TABLE `File` ("
493 "`File` CHAR(72) NOT NULL, "
494 "`Component_` CHAR(72) NOT NULL, "
495 "`FileName` CHAR(255) NOT NULL, "
496 "`FileSize` LONG NOT NULL, "
497 "`Version` CHAR(72), "
498 "`Language` CHAR(20), "
499 "`Attributes` SHORT, "
500 "`Sequence` SHORT NOT NULL "
501 "PRIMARY KEY `File`)" );
502 ok(r
== ERROR_SUCCESS
, "Failed to create File table: %u\n", r
);
506 static UINT
create_remove_file_table( MSIHANDLE hdb
)
508 UINT r
= run_query( hdb
,
509 "CREATE TABLE `RemoveFile` ("
510 "`FileKey` CHAR(72) NOT NULL, "
511 "`Component_` CHAR(72) NOT NULL, "
512 "`FileName` CHAR(255) LOCALIZABLE, "
513 "`DirProperty` CHAR(72) NOT NULL, "
514 "`InstallMode` SHORT NOT NULL "
515 "PRIMARY KEY `FileKey`)" );
516 ok(r
== ERROR_SUCCESS
, "Failed to create RemoveFile table: %u\n", r
);
520 static UINT
create_appsearch_table( MSIHANDLE hdb
)
522 UINT r
= run_query( hdb
,
523 "CREATE TABLE `AppSearch` ("
524 "`Property` CHAR(72) NOT NULL, "
525 "`Signature_` CHAR(72) NOT NULL "
526 "PRIMARY KEY `Property`, `Signature_`)" );
527 ok(r
== ERROR_SUCCESS
, "Failed to create AppSearch table: %u\n", r
);
531 static UINT
create_reglocator_table( MSIHANDLE hdb
)
533 UINT r
= run_query( hdb
,
534 "CREATE TABLE `RegLocator` ("
535 "`Signature_` CHAR(72) NOT NULL, "
536 "`Root` SHORT NOT NULL, "
537 "`Key` CHAR(255) NOT NULL, "
540 "PRIMARY KEY `Signature_`)" );
541 ok(r
== ERROR_SUCCESS
, "Failed to create RegLocator table: %u\n", r
);
545 static UINT
create_signature_table( MSIHANDLE hdb
)
547 UINT r
= run_query( hdb
,
548 "CREATE TABLE `Signature` ("
549 "`Signature` CHAR(72) NOT NULL, "
550 "`FileName` CHAR(255) NOT NULL, "
551 "`MinVersion` CHAR(20), "
552 "`MaxVersion` CHAR(20), "
557 "`Languages` CHAR(255) "
558 "PRIMARY KEY `Signature`)" );
559 ok(r
== ERROR_SUCCESS
, "Failed to create Signature table: %u\n", r
);
563 static UINT
create_launchcondition_table( MSIHANDLE hdb
)
565 UINT r
= run_query( hdb
,
566 "CREATE TABLE `LaunchCondition` ("
567 "`Condition` CHAR(255) NOT NULL, "
568 "`Description` CHAR(255) NOT NULL "
569 "PRIMARY KEY `Condition`)" );
570 ok(r
== ERROR_SUCCESS
, "Failed to create LaunchCondition table: %u\n", r
);
574 static UINT
create_property_table( MSIHANDLE hdb
)
576 UINT r
= run_query( hdb
,
577 "CREATE TABLE `Property` ("
578 "`Property` CHAR(72) NOT NULL, "
580 "PRIMARY KEY `Property`)" );
581 ok(r
== ERROR_SUCCESS
, "Failed to create Property table: %u\n", r
);
585 static UINT
create_install_execute_sequence_table( MSIHANDLE hdb
)
587 UINT r
= run_query( hdb
,
588 "CREATE TABLE `InstallExecuteSequence` ("
589 "`Action` CHAR(72) NOT NULL, "
590 "`Condition` CHAR(255), "
592 "PRIMARY KEY `Action`)" );
593 ok(r
== ERROR_SUCCESS
, "Failed to create InstallExecuteSequence table: %u\n", r
);
597 static UINT
create_install_ui_sequence_table( MSIHANDLE hdb
)
599 UINT r
= run_query( hdb
,
600 "CREATE TABLE `InstallUISequence` ("
601 "`Action` CHAR(72) NOT NULL, "
602 "`Condition` CHAR(255), "
604 "PRIMARY KEY `Action`)" );
605 ok(r
== ERROR_SUCCESS
, "Failed to create InstallUISequence table: %u\n", r
);
609 static UINT
create_media_table( MSIHANDLE hdb
)
611 UINT r
= run_query( hdb
,
612 "CREATE TABLE `Media` ("
613 "`DiskId` SHORT NOT NULL, "
614 "`LastSequence` SHORT NOT NULL, "
615 "`DiskPrompt` CHAR(64), "
616 "`Cabinet` CHAR(255), "
617 "`VolumeLabel` CHAR(32), "
619 "PRIMARY KEY `DiskId`)" );
620 ok(r
== ERROR_SUCCESS
, "Failed to create Media table: %u\n", r
);
624 static UINT
create_ccpsearch_table( MSIHANDLE hdb
)
626 UINT r
= run_query( hdb
,
627 "CREATE TABLE `CCPSearch` ("
628 "`Signature_` CHAR(72) NOT NULL "
629 "PRIMARY KEY `Signature_`)" );
630 ok(r
== ERROR_SUCCESS
, "Failed to create CCPSearch table: %u\n", r
);
634 static UINT
create_drlocator_table( MSIHANDLE hdb
)
636 UINT r
= run_query( hdb
,
637 "CREATE TABLE `DrLocator` ("
638 "`Signature_` CHAR(72) NOT NULL, "
639 "`Parent` CHAR(72), "
642 "PRIMARY KEY `Signature_`, `Parent`, `Path`)" );
643 ok(r
== ERROR_SUCCESS
, "Failed to create DrLocator table: %u\n", r
);
647 static UINT
create_complocator_table( MSIHANDLE hdb
)
649 UINT r
= run_query( hdb
,
650 "CREATE TABLE `CompLocator` ("
651 "`Signature_` CHAR(72) NOT NULL, "
652 "`ComponentId` CHAR(38) NOT NULL, "
654 "PRIMARY KEY `Signature_`)" );
655 ok(r
== ERROR_SUCCESS
, "Failed to create CompLocator table: %u\n", r
);
659 static UINT
create_inilocator_table( MSIHANDLE hdb
)
661 UINT r
= run_query( hdb
,
662 "CREATE TABLE `IniLocator` ("
663 "`Signature_` CHAR(72) NOT NULL, "
664 "`FileName` CHAR(255) NOT NULL, "
665 "`Section` CHAR(96)NOT NULL, "
666 "`Key` CHAR(128)NOT NULL, "
669 "PRIMARY KEY `Signature_`)" );
670 ok(r
== ERROR_SUCCESS
, "Failed to create IniLocator table: %u\n", r
);
674 static UINT
create_custom_action_table( MSIHANDLE hdb
)
676 UINT r
= run_query( hdb
,
677 "CREATE TABLE `CustomAction` ("
678 "`Action` CHAR(72) NOT NULL, "
679 "`Type` SHORT NOT NULL, "
680 "`Source` CHAR(75), "
681 "`Target` CHAR(255) "
682 "PRIMARY KEY `Action`)" );
683 ok(r
== ERROR_SUCCESS
, "Failed to create CustomAction table: %u\n", r
);
687 static UINT
create_dialog_table( MSIHANDLE hdb
)
689 UINT r
= run_query(hdb
,
690 "CREATE TABLE `Dialog` ("
691 "`Dialog` CHAR(72) NOT NULL, "
692 "`HCentering` SHORT NOT NULL, "
693 "`VCentering` SHORT NOT NULL, "
694 "`Width` SHORT NOT NULL, "
695 "`Height` SHORT NOT NULL, "
696 "`Attributes` LONG, "
697 "`Title` CHAR(128) LOCALIZABLE, "
698 "`Control_First` CHAR(50) NOT NULL, "
699 "`Control_Default` CHAR(50), "
700 "`Control_Cancel` CHAR(50) "
701 "PRIMARY KEY `Dialog`)");
702 ok(r
== ERROR_SUCCESS
, "Failed to create Dialog table: %u\n", r
);
706 static UINT
create_control_table( MSIHANDLE hdb
)
708 UINT r
= run_query(hdb
,
709 "CREATE TABLE `Control` ("
710 "`Dialog_` CHAR(72) NOT NULL, "
711 "`Control` CHAR(50) NOT NULL, "
712 "`Type` CHAR(20) NOT NULL, "
713 "`X` SHORT NOT NULL, "
714 "`Y` SHORT NOT NULL, "
715 "`Width` SHORT NOT NULL, "
716 "`Height` SHORT NOT NULL, "
717 "`Attributes` LONG, "
718 "`Property` CHAR(50), "
719 "`Text` CHAR(0) LOCALIZABLE, "
720 "`Control_Next` CHAR(50), "
721 "`Help` CHAR(255) LOCALIZABLE "
722 "PRIMARY KEY `Dialog_`, `Control`)");
723 ok(r
== ERROR_SUCCESS
, "Failed to create Control table: %u\n", r
);
727 static UINT
create_controlevent_table( MSIHANDLE hdb
)
729 UINT r
= run_query(hdb
,
730 "CREATE TABLE `ControlEvent` ("
731 "`Dialog_` CHAR(72) NOT NULL, "
732 "`Control_` CHAR(50) NOT NULL, "
733 "`Event` CHAR(50) NOT NULL, "
734 "`Argument` CHAR(255) NOT NULL, "
735 "`Condition` CHAR(255), "
737 "PRIMARY KEY `Dialog_`, `Control_`, `Event`, `Argument`, `Condition`)");
738 ok(r
== ERROR_SUCCESS
, "Failed to create ControlEvent table: %u\n", r
);
742 static UINT
create_actiontext_table( MSIHANDLE hdb
)
744 UINT r
= run_query(hdb
,
745 "CREATE TABLE `ActionText` ("
746 "`Action` CHAR(72) NOT NULL, "
747 "`Description` CHAR(64) LOCALIZABLE, "
748 "`Template` CHAR(128) LOCALIZABLE "
749 "PRIMARY KEY `Action`)");
750 ok(r
== ERROR_SUCCESS
, "Failed to create ActionText table: %u\n", r
);
754 static inline UINT
add_entry(const char *file
, int line
, const char *type
, MSIHANDLE hdb
, const char *values
, const char *insert
)
759 sz
= strlen(values
) + strlen(insert
) + 1;
760 query
= HeapAlloc(GetProcessHeap(), 0, sz
);
761 sprintf(query
, insert
, values
);
762 r
= run_query(hdb
, query
);
763 HeapFree(GetProcessHeap(), 0, query
);
764 ok_(file
, line
)(r
== ERROR_SUCCESS
, "failed to insert into %s table: %u\n", type
, r
);
768 #define add_component_entry(hdb, values) add_entry(__FILE__, __LINE__, "Component", hdb, values, \
769 "INSERT INTO `Component` " \
770 "(`Component`, `ComponentId`, `Directory_`, " \
771 "`Attributes`, `Condition`, `KeyPath`) VALUES( %s )")
773 #define add_directory_entry(hdb, values) add_entry(__FILE__, __LINE__, "Directory", hdb, values, \
774 "INSERT INTO `Directory` " \
775 "(`Directory`,`Directory_Parent`,`DefaultDir`) VALUES( %s )")
777 #define add_feature_entry(hdb, values) add_entry(__FILE__, __LINE__, "Feature", hdb, values, \
778 "INSERT INTO `Feature` " \
779 "(`Feature`, `Feature_Parent`, `Title`, `Description`, " \
780 "`Display`, `Level`, `Directory_`, `Attributes`) VALUES( %s )")
782 #define add_feature_components_entry(hdb, values) add_entry(__FILE__, __LINE__, "FeatureComponents", hdb, values, \
783 "INSERT INTO `FeatureComponents` " \
784 "(`Feature_`, `Component_`) VALUES( %s )")
786 #define add_file_entry(hdb, values) add_entry(__FILE__, __LINE__, "File", hdb, values, \
787 "INSERT INTO `File` " \
788 "(`File`, `Component_`, `FileName`, `FileSize`, " \
789 "`Version`, `Language`, `Attributes`, `Sequence`) VALUES( %s )")
791 #define add_appsearch_entry(hdb, values) add_entry(__FILE__, __LINE__, "AppSearch", hdb, values, \
792 "INSERT INTO `AppSearch` " \
793 "(`Property`, `Signature_`) VALUES( %s )")
795 #define add_signature_entry(hdb, values) add_entry(__FILE__, __LINE__, "Signature", hdb, values, \
796 "INSERT INTO `Signature` " \
797 "(`Signature`, `FileName`, `MinVersion`, `MaxVersion`," \
798 " `MinSize`, `MaxSize`, `MinDate`, `MaxDate`, `Languages`) " \
801 #define add_launchcondition_entry(hdb, values) add_entry(__FILE__, __LINE__, "LaunchCondition", hdb, values, \
802 "INSERT INTO `LaunchCondition` " \
803 "(`Condition`, `Description`) VALUES( %s )")
805 #define add_property_entry(hdb, values) add_entry(__FILE__, __LINE__, "Property", hdb, values, \
806 "INSERT INTO `Property` (`Property`, `Value`) VALUES( %s )")
808 #define add_install_execute_sequence_entry(hdb, values) add_entry(__FILE__, __LINE__, "InstallExecuteSequence", hdb, values, \
809 "INSERT INTO `InstallExecuteSequence` " \
810 "(`Action`, `Condition`, `Sequence`) VALUES( %s )")
812 #define add_install_ui_sequence_entry(hdb, values) add_entry(__FILE__, __LINE__, "InstallUISequence", hdb, values, \
813 "INSERT INTO `InstallUISequence` " \
814 "(`Action`, `Condition`, `Sequence`) VALUES( %s )")
816 #define add_media_entry(hdb, values) add_entry(__FILE__, __LINE__, "Media", hdb, values, \
817 "INSERT INTO `Media` " \
818 "(`DiskId`, `LastSequence`, `DiskPrompt`, " \
819 "`Cabinet`, `VolumeLabel`, `Source`) VALUES( %s )")
821 #define add_ccpsearch_entry(hdb, values) add_entry(__FILE__, __LINE__, "CCPSearch", hdb, values, \
822 "INSERT INTO `CCPSearch` (`Signature_`) VALUES( %s )")
824 #define add_drlocator_entry(hdb, values) add_entry(__FILE__, __LINE__, "DrLocator", hdb, values, \
825 "INSERT INTO `DrLocator` " \
826 "(`Signature_`, `Parent`, `Path`, `Depth`) VALUES( %s )")
828 #define add_complocator_entry(hdb, values) add_entry(__FILE__, __LINE__, "CompLocator", hdb, values, \
829 "INSERT INTO `CompLocator` " \
830 "(`Signature_`, `ComponentId`, `Type`) VALUES( %s )")
832 #define add_inilocator_entry(hdb, values) add_entry(__FILE__, __LINE__, "IniLocator", hdb, values, \
833 "INSERT INTO `IniLocator` " \
834 "(`Signature_`, `FileName`, `Section`, `Key`, `Field`, `Type`) " \
837 #define add_custom_action_entry(hdb, values) add_entry(__FILE__, __LINE__, "CustomAction", hdb, values, \
838 "INSERT INTO `CustomAction` " \
839 "(`Action`, `Type`, `Source`, `Target`) VALUES( %s )")
841 #define add_dialog_entry(hdb, values) add_entry(__FILE__, __LINE__, "Dialog", hdb, values, \
842 "INSERT INTO `Dialog` " \
843 "(`Dialog`, `HCentering`, `VCentering`, `Width`, `Height`, `Attributes`, `Control_First`) VALUES ( %s )")
845 #define add_control_entry(hdb, values) add_entry(__FILE__, __LINE__, "Control", hdb, values, \
846 "INSERT INTO `Control` " \
847 "(`Dialog_`, `Control`, `Type`, `X`, `Y`, `Width`, `Height`, `Attributes`, `Text`) VALUES( %s )");
849 #define add_controlevent_entry(hdb, values) add_entry(__FILE__, __LINE__, "ControlEvent", hdb, values, \
850 "INSERT INTO `ControlEvent` " \
851 "(`Dialog_`, `Control_`, `Event`, `Argument`, `Condition`, `Ordering`) VALUES( %s )");
853 #define add_actiontext_entry(hdb, values) add_entry(__FILE__, __LINE__, "ActionText", hdb, values, \
854 "INSERT INTO `ActionText` " \
855 "(`Action`, `Description`, `Template`) VALUES( %s )");
857 static UINT
add_reglocator_entry( MSIHANDLE hdb
, const char *sig
, UINT root
, const char *path
,
858 const char *name
, UINT type
)
860 const char insert
[] =
861 "INSERT INTO `RegLocator` (`Signature_`, `Root`, `Key`, `Name`, `Type`) "
862 "VALUES( '%s', %u, '%s', '%s', %u )";
866 sz
= strlen( sig
) + 10 + strlen( path
) + strlen( name
) + 10 + sizeof( insert
);
867 query
= HeapAlloc( GetProcessHeap(), 0, sz
);
868 sprintf( query
, insert
, sig
, root
, path
, name
, type
);
869 r
= run_query( hdb
, query
);
870 HeapFree( GetProcessHeap(), 0, query
);
871 ok(r
== ERROR_SUCCESS
, "failed to insert into reglocator table: %u\n", r
); \
875 static UINT
set_summary_info(MSIHANDLE hdb
)
880 /* build summary info */
881 res
= MsiGetSummaryInformationA(hdb
, NULL
, 7, &suminfo
);
882 ok( res
== ERROR_SUCCESS
, "Failed to open summaryinfo\n" );
884 res
= MsiSummaryInfoSetPropertyA(suminfo
,2, VT_LPSTR
, 0,NULL
,
885 "Installation Database");
886 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
888 res
= MsiSummaryInfoSetPropertyA(suminfo
,3, VT_LPSTR
, 0,NULL
,
889 "Installation Database");
890 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
892 res
= MsiSummaryInfoSetPropertyA(suminfo
,4, VT_LPSTR
, 0,NULL
,
894 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
896 res
= MsiSummaryInfoSetPropertyA(suminfo
,7, VT_LPSTR
, 0,NULL
,
898 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
900 res
= MsiSummaryInfoSetPropertyA(suminfo
,9, VT_LPSTR
, 0,NULL
,
901 "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}");
902 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
904 res
= MsiSummaryInfoSetPropertyA(suminfo
, 14, VT_I4
, 100, NULL
, NULL
);
905 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
907 res
= MsiSummaryInfoSetPropertyA(suminfo
, 15, VT_I4
, 0, NULL
, NULL
);
908 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
910 res
= MsiSummaryInfoPersist(suminfo
);
911 ok( res
== ERROR_SUCCESS
, "Failed to make summary info persist\n" );
913 res
= MsiCloseHandle( suminfo
);
914 ok( res
== ERROR_SUCCESS
, "Failed to close suminfo\n" );
920 static MSIHANDLE
create_package_db(void)
925 DeleteFileA(msifile
);
927 /* create an empty database */
928 res
= MsiOpenDatabaseW(msifileW
, MSIDBOPEN_CREATE
, &hdb
);
929 ok( res
== ERROR_SUCCESS
, "Failed to create database %u\n", res
);
930 if( res
!= ERROR_SUCCESS
)
933 res
= MsiDatabaseCommit( hdb
);
934 ok( res
== ERROR_SUCCESS
, "Failed to commit database\n" );
936 res
= set_summary_info(hdb
);
937 ok( res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", res
);
939 res
= run_query( hdb
,
940 "CREATE TABLE `Directory` ( "
941 "`Directory` CHAR(255) NOT NULL, "
942 "`Directory_Parent` CHAR(255), "
943 "`DefaultDir` CHAR(255) NOT NULL "
944 "PRIMARY KEY `Directory`)" );
945 ok( res
== ERROR_SUCCESS
, "Failed to create directory table\n" );
950 static UINT
package_from_db(MSIHANDLE hdb
, MSIHANDLE
*handle
)
956 sprintf(szPackage
, "#%u", hdb
);
957 res
= MsiOpenPackageA(szPackage
, &hPackage
);
958 if (res
!= ERROR_SUCCESS
)
964 res
= MsiCloseHandle(hdb
);
965 if (res
!= ERROR_SUCCESS
)
967 MsiCloseHandle(hPackage
);
972 return ERROR_SUCCESS
;
975 static void create_file_data(LPCSTR name
, LPCSTR data
)
980 file
= CreateFileA(name
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, 0, NULL
);
981 ok(file
!= INVALID_HANDLE_VALUE
, "Failure to open file %s\n", name
);
982 if (file
== INVALID_HANDLE_VALUE
)
985 WriteFile(file
, data
, strlen(data
), &written
, NULL
);
986 WriteFile(file
, "\n", strlen("\n"), &written
, NULL
);
991 static void create_test_file(const CHAR
*name
)
993 create_file_data(name
, name
);
996 typedef struct _tagVS_VERSIONINFO
1003 VS_FIXEDFILEINFO Value
;
1008 #define roundoffs(a, b, r) (((BYTE *)(b) - (BYTE *)(a) + ((r) - 1)) & ~((r) - 1))
1009 #define roundpos(a, b, r) (((BYTE *)(a)) + roundoffs(a, b, r))
1011 static BOOL
create_file_with_version(const CHAR
*name
, LONG ms
, LONG ls
)
1013 VS_VERSIONINFO
*pVerInfo
;
1014 VS_FIXEDFILEINFO
*pFixedInfo
;
1016 CHAR path
[MAX_PATH
];
1021 GetSystemDirectoryA(path
, MAX_PATH
);
1022 /* Some dlls can't be updated on Vista/W2K8 */
1023 lstrcatA(path
, "\\version.dll");
1025 CopyFileA(path
, name
, FALSE
);
1027 size
= GetFileVersionInfoSizeA(path
, &handle
);
1028 buffer
= HeapAlloc(GetProcessHeap(), 0, size
);
1030 GetFileVersionInfoA(path
, 0, size
, buffer
);
1032 pVerInfo
= (VS_VERSIONINFO
*)buffer
;
1033 ofs
= (BYTE
*)&pVerInfo
->szKey
[lstrlenW(pVerInfo
->szKey
) + 1];
1034 pFixedInfo
= (VS_FIXEDFILEINFO
*)roundpos(pVerInfo
, ofs
, 4);
1036 pFixedInfo
->dwFileVersionMS
= ms
;
1037 pFixedInfo
->dwFileVersionLS
= ls
;
1038 pFixedInfo
->dwProductVersionMS
= ms
;
1039 pFixedInfo
->dwProductVersionLS
= ls
;
1041 resource
= BeginUpdateResourceA(name
, FALSE
);
1045 if (!UpdateResourceA(resource
, (LPCSTR
)RT_VERSION
, (LPCSTR
)MAKEINTRESOURCE(VS_VERSION_INFO
),
1046 MAKELANGID(LANG_NEUTRAL
, SUBLANG_NEUTRAL
), buffer
, size
))
1049 if (!EndUpdateResourceA(resource
, FALSE
))
1055 HeapFree(GetProcessHeap(), 0, buffer
);
1059 static BOOL
notify_system_change(DWORD event_type
, STATEMGRSTATUS
*status
)
1061 RESTOREPOINTINFOA spec
;
1063 spec
.dwEventType
= event_type
;
1064 spec
.dwRestorePtType
= APPLICATION_INSTALL
;
1065 spec
.llSequenceNumber
= status
->llSequenceNumber
;
1066 lstrcpyA(spec
.szDescription
, "msitest restore point");
1068 return pSRSetRestorePointA(&spec
, status
);
1071 static void remove_restore_point(DWORD seq_number
)
1075 res
= pSRRemoveRestorePoint(seq_number
);
1076 if (res
!= ERROR_SUCCESS
)
1077 trace("Failed to remove the restore point : %08x\n", res
);
1080 static BOOL
is_root(const char *path
)
1082 return (isalpha(path
[0]) && path
[1] == ':' && path
[2] == '\\' && !path
[3]);
1085 static void test_createpackage(void)
1087 MSIHANDLE hPackage
= 0;
1090 res
= package_from_db(create_package_db(), &hPackage
);
1091 if (res
== ERROR_INSTALL_PACKAGE_REJECTED
)
1093 skip("Not enough rights to perform tests\n");
1094 DeleteFileA(msifile
);
1097 ok( res
== ERROR_SUCCESS
, " Failed to create package %u\n", res
);
1099 res
= MsiCloseHandle( hPackage
);
1100 ok( res
== ERROR_SUCCESS
, "Failed to close package\n" );
1101 DeleteFileA(msifile
);
1104 static void test_doaction( void )
1109 r
= MsiDoActionA( -1, NULL
);
1110 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
1112 r
= package_from_db(create_package_db(), &hpkg
);
1113 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
1115 skip("Not enough rights to perform tests\n");
1116 DeleteFileA(msifile
);
1119 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
1121 r
= MsiDoActionA(hpkg
, NULL
);
1122 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
1124 r
= MsiDoActionA(0, "boo");
1125 ok( r
== ERROR_INVALID_HANDLE
, "wrong return val\n");
1127 r
= MsiDoActionA(hpkg
, "boo");
1128 ok( r
== ERROR_FUNCTION_NOT_CALLED
, "wrong return val\n");
1130 MsiCloseHandle( hpkg
);
1131 DeleteFileA(msifile
);
1134 static void test_gettargetpath_bad(void)
1136 static const WCHAR boo
[] = {'b','o','o',0};
1137 static const WCHAR empty
[] = {0};
1139 WCHAR bufferW
[0x80];
1144 r
= package_from_db(create_package_db(), &hpkg
);
1145 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
1147 skip("Not enough rights to perform tests\n");
1148 DeleteFileA(msifile
);
1151 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
1153 r
= MsiGetTargetPathA( 0, NULL
, NULL
, NULL
);
1154 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
1156 r
= MsiGetTargetPathA( 0, NULL
, NULL
, &sz
);
1157 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
1159 r
= MsiGetTargetPathA( 0, "boo", NULL
, NULL
);
1160 ok( r
== ERROR_INVALID_HANDLE
, "wrong return val\n");
1162 r
= MsiGetTargetPathA( 0, "boo", NULL
, NULL
);
1163 ok( r
== ERROR_INVALID_HANDLE
, "wrong return val\n");
1165 r
= MsiGetTargetPathA( hpkg
, "boo", NULL
, NULL
);
1166 ok( r
== ERROR_DIRECTORY
, "wrong return val\n");
1168 r
= MsiGetTargetPathA( hpkg
, "boo", buffer
, NULL
);
1169 ok( r
== ERROR_DIRECTORY
, "wrong return val\n");
1172 r
= MsiGetTargetPathA( hpkg
, "", buffer
, &sz
);
1173 ok( r
== ERROR_DIRECTORY
, "wrong return val\n");
1175 r
= MsiGetTargetPathW( 0, NULL
, NULL
, NULL
);
1176 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
1178 r
= MsiGetTargetPathW( 0, NULL
, NULL
, &sz
);
1179 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
1181 r
= MsiGetTargetPathW( 0, boo
, NULL
, NULL
);
1182 ok( r
== ERROR_INVALID_HANDLE
, "wrong return val\n");
1184 r
= MsiGetTargetPathW( 0, boo
, NULL
, NULL
);
1185 ok( r
== ERROR_INVALID_HANDLE
, "wrong return val\n");
1187 r
= MsiGetTargetPathW( hpkg
, boo
, NULL
, NULL
);
1188 ok( r
== ERROR_DIRECTORY
, "wrong return val\n");
1190 r
= MsiGetTargetPathW( hpkg
, boo
, bufferW
, NULL
);
1191 ok( r
== ERROR_DIRECTORY
, "wrong return val\n");
1194 r
= MsiGetTargetPathW( hpkg
, empty
, bufferW
, &sz
);
1195 ok( r
== ERROR_DIRECTORY
, "wrong return val\n");
1197 MsiCloseHandle( hpkg
);
1198 DeleteFileA(msifile
);
1201 static void query_file_path(MSIHANDLE hpkg
, LPCSTR file
, LPSTR buff
)
1207 rec
= MsiCreateRecord( 1 );
1208 ok(rec
, "MsiCreate record failed\n");
1210 r
= MsiRecordSetStringA( rec
, 0, file
);
1211 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
1214 r
= MsiFormatRecordA( hpkg
, rec
, buff
, &size
);
1215 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
1217 MsiCloseHandle( rec
);
1220 static void test_settargetpath(void)
1222 char tempdir
[MAX_PATH
+8], buffer
[MAX_PATH
], file
[MAX_PATH
];
1228 hdb
= create_package_db();
1229 ok ( hdb
, "failed to create package database\n" );
1231 add_directory_entry( hdb
, "'TARGETDIR', '', 'SourceDir'" );
1233 create_component_table( hdb
);
1234 add_component_entry( hdb
, "'RootComp', '{83e2694d-0864-4124-9323-6d37630912a1}', 'TARGETDIR', 8, '', 'RootFile'" );
1235 add_component_entry( hdb
, "'TestComp', '{A3FB59C8-C293-4F7E-B8C5-F0E1D8EEE4E5}', 'TestDir', 0, '', 'TestFile'" );
1237 create_feature_table( hdb
);
1238 add_feature_entry( hdb
, "'TestFeature', '', '', '', 0, 1, '', 0" );
1240 create_feature_components_table( hdb
);
1241 add_feature_components_entry( hdb
, "'TestFeature', 'RootComp'" );
1242 add_feature_components_entry( hdb
, "'TestFeature', 'TestComp'" );
1244 add_directory_entry( hdb
, "'TestParent', 'TARGETDIR', 'TestParent'" );
1245 add_directory_entry( hdb
, "'TestDir', 'TestParent', 'TestDir'" );
1247 create_file_table( hdb
);
1248 add_file_entry( hdb
, "'RootFile', 'RootComp', 'rootfile.txt', 0, '', '1033', 8192, 1" );
1249 add_file_entry( hdb
, "'TestFile', 'TestComp', 'testfile.txt', 0, '', '1033', 8192, 1" );
1251 r
= package_from_db( hdb
, &hpkg
);
1252 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
1254 skip("Not enough rights to perform tests\n");
1255 DeleteFileA(msifile
);
1258 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
1260 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
1262 r
= MsiDoActionA( hpkg
, "CostInitialize");
1263 ok( r
== ERROR_SUCCESS
, "cost init failed\n");
1265 r
= MsiDoActionA( hpkg
, "FileCost");
1266 ok( r
== ERROR_SUCCESS
, "file cost failed\n");
1268 r
= MsiDoActionA( hpkg
, "CostFinalize");
1269 ok( r
== ERROR_SUCCESS
, "cost finalize failed\n");
1272 sz
= sizeof(buffer
);
1273 r
= MsiGetPropertyA( hpkg
, "OutOfNoRbDiskSpace", buffer
, &sz
);
1274 ok( r
== ERROR_SUCCESS
, "MsiGetProperty returned %u\n", r
);
1275 trace( "OutOfNoRbDiskSpace = \"%s\"\n", buffer
);
1277 r
= MsiSetTargetPathA( 0, NULL
, NULL
);
1278 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
1280 r
= MsiSetTargetPathA( 0, "boo", "C:\\bogusx" );
1281 ok( r
== ERROR_INVALID_HANDLE
, "wrong return val\n");
1283 r
= MsiSetTargetPathA( hpkg
, "boo", NULL
);
1284 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
1286 r
= MsiSetTargetPathA( hpkg
, "boo", "c:\\bogusx" );
1287 ok( r
== ERROR_DIRECTORY
, "wrong return val\n");
1289 sz
= sizeof tempdir
- 1;
1290 r
= MsiGetTargetPathA( hpkg
, "TARGETDIR", tempdir
, &sz
);
1291 sprintf( file
, "%srootfile.txt", tempdir
);
1293 query_file_path( hpkg
, "[#RootFile]", buffer
);
1294 ok( r
== ERROR_SUCCESS
, "failed to get target path: %d\n", r
);
1295 ok( !lstrcmpA(buffer
, file
), "Expected %s, got %s\n", file
, buffer
);
1297 GetTempFileNameA( tempdir
, "_wt", 0, buffer
);
1298 sprintf( tempdir
, "%s\\subdir", buffer
);
1300 r
= MsiSetTargetPathA( hpkg
, "TARGETDIR", buffer
);
1301 ok( r
== ERROR_SUCCESS
|| r
== ERROR_DIRECTORY
,
1302 "MsiSetTargetPath on file returned %d\n", r
);
1304 r
= MsiSetTargetPathA( hpkg
, "TARGETDIR", tempdir
);
1305 ok( r
== ERROR_SUCCESS
|| r
== ERROR_DIRECTORY
,
1306 "MsiSetTargetPath on 'subdir' of file returned %d\n", r
);
1308 DeleteFileA( buffer
);
1310 r
= MsiSetTargetPathA( hpkg
, "TARGETDIR", buffer
);
1311 ok( r
== ERROR_SUCCESS
, "MsiSetTargetPath returned %d\n", r
);
1313 r
= GetFileAttributesA( buffer
);
1314 ok ( r
== INVALID_FILE_ATTRIBUTES
, "file/directory exists after MsiSetTargetPath. Attributes: %08X\n", r
);
1316 r
= MsiSetTargetPathA( hpkg
, "TARGETDIR", tempdir
);
1317 ok( r
== ERROR_SUCCESS
, "MsiSetTargetPath on subsubdir returned %d\n", r
);
1320 sz
= sizeof buffer
- 1;
1321 lstrcatA( tempdir
, "\\" );
1322 r
= MsiGetTargetPathA( hpkg
, "TARGETDIR", buffer
, &sz
);
1323 ok( r
== ERROR_SUCCESS
, "failed to get target path: %d\n", r
);
1324 ok( !lstrcmpA(buffer
, tempdir
), "Expected %s, got %s\n", tempdir
, buffer
);
1326 sprintf( file
, "%srootfile.txt", tempdir
);
1327 query_file_path( hpkg
, "[#RootFile]", buffer
);
1328 ok( !lstrcmpA(buffer
, file
), "Expected %s, got %s\n", file
, buffer
);
1331 sz
= sizeof(buffer
);
1332 r
= MsiGetPropertyA( hpkg
, "TestParent", buffer
, &sz
);
1333 ok( r
== ERROR_SUCCESS
, "MsiGetProperty returned %u\n", r
);
1334 lstrcatA( tempdir
, "TestParent\\" );
1335 ok( !lstrcmpiA(buffer
, tempdir
), "Expected \"%s\", got \"%s\"\n", tempdir
, buffer
);
1337 r
= MsiSetTargetPathA( hpkg
, "TestParent", "C:\\one\\two" );
1338 ok( r
== ERROR_SUCCESS
, "MsiSetTargetPath returned %d\n", r
);
1341 sz
= sizeof(buffer
);
1342 r
= MsiGetPropertyA( hpkg
, "TestParent", buffer
, &sz
);
1343 ok( r
== ERROR_SUCCESS
, "MsiGetProperty returned %u\n", r
);
1344 ok( lstrcmpiA(buffer
, "C:\\one\\two\\TestDir\\"),
1345 "Expected \"C:\\one\\two\\TestDir\\\", got \"%s\"\n", buffer
);
1348 query_file_path( hpkg
, "[#TestFile]", buffer
);
1349 ok( !lstrcmpiA(buffer
, "C:\\one\\two\\TestDir\\testfile.txt"),
1350 "Expected C:\\one\\two\\TestDir\\testfile.txt, got %s\n", buffer
);
1353 sz
= sizeof buffer
- 1;
1354 r
= MsiGetTargetPathA( hpkg
, "TestParent", buffer
, &sz
);
1355 ok( r
== ERROR_SUCCESS
, "failed to get target path: %d\n", r
);
1356 ok( !lstrcmpiA(buffer
, "C:\\one\\two\\"), "Expected C:\\one\\two\\, got %s\n", buffer
);
1358 r
= MsiSetTargetPathA( hpkg
, "TestParent", "C:\\one\\two\\three" );
1359 ok( r
== ERROR_SUCCESS
, "MsiSetTargetPath returned %d\n", r
);
1362 sz
= sizeof buffer
- 1;
1363 r
= MsiGetTargetPathA( hpkg
, "TestParent", buffer
, &sz
);
1364 ok( r
== ERROR_SUCCESS
, "failed to get target path: %d\n", r
);
1365 ok( !lstrcmpiA(buffer
, "C:\\one\\two\\three\\"), "Expected C:\\one\\two\\three\\, got %s\n", buffer
);
1367 r
= MsiSetTargetPathA( hpkg
, "TestParent", "C:\\\\one\\\\two " );
1368 ok( r
== ERROR_SUCCESS
, "MsiSetTargetPath returned %d\n", r
);
1371 sz
= sizeof buffer
- 1;
1372 r
= MsiGetTargetPathA( hpkg
, "TestParent", buffer
, &sz
);
1373 ok( r
== ERROR_SUCCESS
, "failed to get target path: %d\n", r
);
1374 ok( !lstrcmpiA(buffer
, "C:\\one\\two\\"), "Expected \"C:\\one\\two\\\", got %s\n", buffer
);
1376 r
= MsiSetTargetPathA( hpkg
, "TestParent", "C:\\\\ Program Files \\\\ " );
1377 ok( r
== ERROR_SUCCESS
, "MsiSetTargetPath returned %d\n", r
);
1380 sz
= sizeof buffer
- 1;
1381 r
= MsiGetTargetPathA( hpkg
, "TestParent", buffer
, &sz
);
1382 ok( r
== ERROR_SUCCESS
, "failed to get target path: %d\n", r
);
1383 ok( !lstrcmpiA(buffer
, "C:\\Program Files\\"), "Expected \"C:\\Program Files\\\", got %s\n", buffer
);
1385 MsiCloseHandle( hpkg
);
1388 static void test_condition(void)
1390 static const WCHAR cond1
[] = {'\"','a',0x30a,'\"','<','\"',0xe5,'\"',0};
1391 static const WCHAR cond2
[] = {'\"','a',0x30a,'\"','>','\"',0xe5,'\"',0};
1392 static const WCHAR cond3
[] = {'\"','a',0x30a,'\"','<','>','\"',0xe5,'\"',0};
1393 static const WCHAR cond4
[] = {'\"','a',0x30a,'\"','=','\"',0xe5,'\"',0};
1397 r
= package_from_db(create_package_db(), &hpkg
);
1398 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
1400 skip("Not enough rights to perform tests\n");
1401 DeleteFileA(msifile
);
1404 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
1406 r
= MsiEvaluateConditionA(0, NULL
);
1407 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
1409 r
= MsiEvaluateConditionA(hpkg
, NULL
);
1410 ok( r
== MSICONDITION_NONE
, "wrong return val\n");
1412 r
= MsiEvaluateConditionA(hpkg
, "");
1413 ok( r
== MSICONDITION_NONE
, "wrong return val\n");
1415 r
= MsiEvaluateConditionA(hpkg
, "1");
1416 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1418 r
= MsiEvaluateConditionA(hpkg
, "0");
1419 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1421 r
= MsiEvaluateConditionA(hpkg
, "-1");
1422 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1424 r
= MsiEvaluateConditionA(hpkg
, "0 = 0");
1425 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1427 r
= MsiEvaluateConditionA(hpkg
, "0 <> 0");
1428 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1430 r
= MsiEvaluateConditionA(hpkg
, "0 = 1");
1431 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1433 r
= MsiEvaluateConditionA(hpkg
, "0 > 1");
1434 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1436 r
= MsiEvaluateConditionA(hpkg
, "0 ~> 1");
1437 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1439 r
= MsiEvaluateConditionA(hpkg
, "1 > 1");
1440 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1442 r
= MsiEvaluateConditionA(hpkg
, "1 ~> 1");
1443 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1445 r
= MsiEvaluateConditionA(hpkg
, "0 >= 1");
1446 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1448 r
= MsiEvaluateConditionA(hpkg
, "0 ~>= 1");
1449 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1451 r
= MsiEvaluateConditionA(hpkg
, "1 >= 1");
1452 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1454 r
= MsiEvaluateConditionA(hpkg
, "1 ~>= 1");
1455 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1457 r
= MsiEvaluateConditionA(hpkg
, "0 < 1");
1458 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1460 r
= MsiEvaluateConditionA(hpkg
, "0 ~< 1");
1461 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1463 r
= MsiEvaluateConditionA(hpkg
, "1 < 1");
1464 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1466 r
= MsiEvaluateConditionA(hpkg
, "1 ~< 1");
1467 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1469 r
= MsiEvaluateConditionA(hpkg
, "0 <= 1");
1470 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1472 r
= MsiEvaluateConditionA(hpkg
, "0 ~<= 1");
1473 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1475 r
= MsiEvaluateConditionA(hpkg
, "1 <= 1");
1476 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1478 r
= MsiEvaluateConditionA(hpkg
, "1 ~<= 1");
1479 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1481 r
= MsiEvaluateConditionA(hpkg
, "0 >=");
1482 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
1484 r
= MsiEvaluateConditionA(hpkg
, " ");
1485 ok( r
== MSICONDITION_NONE
, "wrong return val\n");
1487 r
= MsiEvaluateConditionA(hpkg
, "LicView <> \"1\"");
1488 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1490 r
= MsiEvaluateConditionA(hpkg
, "LicView <> \"0\"");
1491 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1493 r
= MsiEvaluateConditionA(hpkg
, "LicView <> LicView");
1494 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1496 r
= MsiEvaluateConditionA(hpkg
, "not 0");
1497 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1499 r
= MsiEvaluateConditionA(hpkg
, "not LicView");
1500 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1502 r
= MsiEvaluateConditionA(hpkg
, "\"Testing\" ~<< \"Testing\"");
1503 ok (r
== MSICONDITION_TRUE
, "wrong return val\n");
1505 r
= MsiEvaluateConditionA(hpkg
, "LicView ~<< \"Testing\"");
1506 ok (r
== MSICONDITION_FALSE
, "wrong return val\n");
1508 r
= MsiEvaluateConditionA(hpkg
, "Not LicView ~<< \"Testing\"");
1509 ok (r
== MSICONDITION_TRUE
, "wrong return val\n");
1511 r
= MsiEvaluateConditionA(hpkg
, "not \"A\"");
1512 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1514 r
= MsiEvaluateConditionA(hpkg
, "~not \"A\"");
1515 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
1517 r
= MsiEvaluateConditionA(hpkg
, "\"0\"");
1518 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1520 r
= MsiEvaluateConditionA(hpkg
, "1 and 2");
1521 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1523 r
= MsiEvaluateConditionA(hpkg
, "not 0 and 3");
1524 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1526 r
= MsiEvaluateConditionA(hpkg
, "not 0 and 0");
1527 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1529 r
= MsiEvaluateConditionA(hpkg
, "not 0 or 1");
1530 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1532 r
= MsiEvaluateConditionA(hpkg
, "(0)");
1533 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1535 r
= MsiEvaluateConditionA(hpkg
, "(((((1))))))");
1536 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
1538 r
= MsiEvaluateConditionA(hpkg
, "(((((1)))))");
1539 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1541 r
= MsiEvaluateConditionA(hpkg
, " \"A\" < \"B\" ");
1542 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1544 r
= MsiEvaluateConditionA(hpkg
, " \"A\" > \"B\" ");
1545 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1547 r
= MsiEvaluateConditionA(hpkg
, " \"1\" > \"12\" ");
1548 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1550 r
= MsiEvaluateConditionA(hpkg
, " \"100\" < \"21\" ");
1551 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1553 r
= MsiEvaluateConditionA(hpkg
, "0 < > 0");
1554 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
1556 r
= MsiEvaluateConditionA(hpkg
, "(1<<1) == 2");
1557 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
1559 r
= MsiEvaluateConditionA(hpkg
, " \"A\" = \"a\" ");
1560 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1562 r
= MsiEvaluateConditionA(hpkg
, " \"A\" ~ = \"a\" ");
1563 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
1565 r
= MsiEvaluateConditionA(hpkg
, " \"A\" ~= \"a\" ");
1566 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1568 r
= MsiEvaluateConditionA(hpkg
, " \"A\" ~= 1 ");
1569 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1571 r
= MsiEvaluateConditionA(hpkg
, " \"A\" = 1 ");
1572 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1574 r
= MsiEvaluateConditionA(hpkg
, " 1 ~= 1 ");
1575 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1577 r
= MsiEvaluateConditionA(hpkg
, " 1 ~= \"1\" ");
1578 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1580 r
= MsiEvaluateConditionA(hpkg
, " 1 = \"1\" ");
1581 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1583 r
= MsiEvaluateConditionA(hpkg
, " 0 = \"1\" ");
1584 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1586 r
= MsiEvaluateConditionA(hpkg
, " 0 < \"100\" ");
1587 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1589 r
= MsiEvaluateConditionA(hpkg
, " 100 > \"0\" ");
1590 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1592 r
= MsiEvaluateConditionA(hpkg
, "1 XOR 1");
1593 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1595 r
= MsiEvaluateConditionA(hpkg
, "1 IMP 1");
1596 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1598 r
= MsiEvaluateConditionA(hpkg
, "1 IMP 0");
1599 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1601 r
= MsiEvaluateConditionA(hpkg
, "0 IMP 0");
1602 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1604 r
= MsiEvaluateConditionA(hpkg
, "0 EQV 0");
1605 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1607 r
= MsiEvaluateConditionA(hpkg
, "0 EQV 1");
1608 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1610 r
= MsiEvaluateConditionA(hpkg
, "1 IMP 1 OR 0");
1611 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1613 r
= MsiEvaluateConditionA(hpkg
, "1 IMPL 1");
1614 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
1616 r
= MsiEvaluateConditionA(hpkg
, "\"ASFD\" >< \"S\" ");
1617 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1619 r
= MsiEvaluateConditionA(hpkg
, "\"ASFD\" ~>< \"s\" ");
1620 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1622 r
= MsiEvaluateConditionA(hpkg
, "\"ASFD\" ~>< \"\" ");
1623 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1625 r
= MsiEvaluateConditionA(hpkg
, "\"ASFD\" ~>< \"sss\" ");
1626 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1628 MsiSetPropertyA(hpkg
, "mm", "5" );
1630 r
= MsiEvaluateConditionA(hpkg
, "mm = 5");
1631 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1633 r
= MsiEvaluateConditionA(hpkg
, "mm < 6");
1634 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1636 r
= MsiEvaluateConditionA(hpkg
, "mm <= 5");
1637 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1639 r
= MsiEvaluateConditionA(hpkg
, "mm > 4");
1640 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1642 r
= MsiEvaluateConditionA(hpkg
, "mm < 12");
1643 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1645 r
= MsiEvaluateConditionA(hpkg
, "mm = \"5\"");
1646 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1648 r
= MsiEvaluateConditionA(hpkg
, "0 = \"\"");
1649 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1651 r
= MsiEvaluateConditionA(hpkg
, "0 AND \"\"");
1652 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1654 r
= MsiEvaluateConditionA(hpkg
, "1 AND \"\"");
1655 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1657 r
= MsiEvaluateConditionA(hpkg
, "1 AND \"1\"");
1658 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1660 r
= MsiEvaluateConditionA(hpkg
, "3 >< 1");
1661 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1663 r
= MsiEvaluateConditionA(hpkg
, "3 >< 4");
1664 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1666 r
= MsiEvaluateConditionA(hpkg
, "NOT 0 AND 0");
1667 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1669 r
= MsiEvaluateConditionA(hpkg
, "NOT 0 AND 1");
1670 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1672 r
= MsiEvaluateConditionA(hpkg
, "NOT 1 OR 0");
1673 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1675 r
= MsiEvaluateConditionA(hpkg
, "0 AND 1 OR 1");
1676 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1678 r
= MsiEvaluateConditionA(hpkg
, "0 AND 0 OR 1");
1679 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1681 r
= MsiEvaluateConditionA(hpkg
, "NOT 0 AND 1 OR 0");
1682 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1684 r
= MsiEvaluateConditionA(hpkg
, "_1 = _1");
1685 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1687 r
= MsiEvaluateConditionA(hpkg
, "( 1 AND 1 ) = 2");
1688 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
1690 r
= MsiEvaluateConditionA(hpkg
, "NOT ( 1 AND 1 )");
1691 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1693 r
= MsiEvaluateConditionA(hpkg
, "NOT A AND (BBBBBBBBBB=2 OR CCC=1) AND Ddddddddd");
1694 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1696 r
= MsiEvaluateConditionA(hpkg
, "Installed<>\"\"");
1697 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1699 r
= MsiEvaluateConditionA(hpkg
, "NOT 1 AND 0");
1700 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1702 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1703 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1705 r
= MsiEvaluateConditionA(hpkg
, "bandalmael<>0");
1706 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1708 r
= MsiEvaluateConditionA(hpkg
, "bandalmael<0");
1709 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1711 r
= MsiEvaluateConditionA(hpkg
, "bandalmael>0");
1712 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1714 r
= MsiEvaluateConditionA(hpkg
, "bandalmael>=0");
1715 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1717 r
= MsiEvaluateConditionA(hpkg
, "bandalmael<=0");
1718 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1720 r
= MsiEvaluateConditionA(hpkg
, "bandalmael~<>0");
1721 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1723 MsiSetPropertyA(hpkg
, "bandalmael", "0" );
1724 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1725 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1727 MsiSetPropertyA(hpkg
, "bandalmael", "" );
1728 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1729 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1731 MsiSetPropertyA(hpkg
, "bandalmael", "asdf" );
1732 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1733 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1735 MsiSetPropertyA(hpkg
, "bandalmael", "0asdf" );
1736 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1737 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1739 MsiSetPropertyA(hpkg
, "bandalmael", "0 " );
1740 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1741 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1743 MsiSetPropertyA(hpkg
, "bandalmael", "-0" );
1744 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1745 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1747 MsiSetPropertyA(hpkg
, "bandalmael", "0000000000000" );
1748 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1749 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1751 MsiSetPropertyA(hpkg
, "bandalmael", "--0" );
1752 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1753 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1755 MsiSetPropertyA(hpkg
, "bandalmael", "0x00" );
1756 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1757 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1759 MsiSetPropertyA(hpkg
, "bandalmael", "-" );
1760 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1761 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1763 MsiSetPropertyA(hpkg
, "bandalmael", "+0" );
1764 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1765 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1767 MsiSetPropertyA(hpkg
, "bandalmael", "0.0" );
1768 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1769 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1770 r
= MsiEvaluateConditionA(hpkg
, "bandalmael<>0");
1771 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1773 MsiSetPropertyA(hpkg
, "one", "hi");
1774 MsiSetPropertyA(hpkg
, "two", "hithere");
1775 r
= MsiEvaluateConditionA(hpkg
, "one >< two");
1776 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1778 MsiSetPropertyA(hpkg
, "one", "hithere");
1779 MsiSetPropertyA(hpkg
, "two", "hi");
1780 r
= MsiEvaluateConditionA(hpkg
, "one >< two");
1781 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1783 MsiSetPropertyA(hpkg
, "one", "hello");
1784 MsiSetPropertyA(hpkg
, "two", "hi");
1785 r
= MsiEvaluateConditionA(hpkg
, "one >< two");
1786 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1788 MsiSetPropertyA(hpkg
, "one", "hellohithere");
1789 MsiSetPropertyA(hpkg
, "two", "hi");
1790 r
= MsiEvaluateConditionA(hpkg
, "one >< two");
1791 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1793 MsiSetPropertyA(hpkg
, "one", "");
1794 MsiSetPropertyA(hpkg
, "two", "hi");
1795 r
= MsiEvaluateConditionA(hpkg
, "one >< two");
1796 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1798 MsiSetPropertyA(hpkg
, "one", "hi");
1799 MsiSetPropertyA(hpkg
, "two", "");
1800 r
= MsiEvaluateConditionA(hpkg
, "one >< two");
1801 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1803 MsiSetPropertyA(hpkg
, "one", "");
1804 MsiSetPropertyA(hpkg
, "two", "");
1805 r
= MsiEvaluateConditionA(hpkg
, "one >< two");
1806 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1808 MsiSetPropertyA(hpkg
, "one", "1234");
1809 MsiSetPropertyA(hpkg
, "two", "1");
1810 r
= MsiEvaluateConditionA(hpkg
, "one >< two");
1811 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1813 MsiSetPropertyA(hpkg
, "one", "one 1234");
1814 MsiSetPropertyA(hpkg
, "two", "1");
1815 r
= MsiEvaluateConditionA(hpkg
, "one >< two");
1816 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1818 MsiSetPropertyA(hpkg
, "one", "hithere");
1819 MsiSetPropertyA(hpkg
, "two", "hi");
1820 r
= MsiEvaluateConditionA(hpkg
, "one << two");
1821 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1823 MsiSetPropertyA(hpkg
, "one", "hi");
1824 MsiSetPropertyA(hpkg
, "two", "hithere");
1825 r
= MsiEvaluateConditionA(hpkg
, "one << two");
1826 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1828 MsiSetPropertyA(hpkg
, "one", "hi");
1829 MsiSetPropertyA(hpkg
, "two", "hi");
1830 r
= MsiEvaluateConditionA(hpkg
, "one << two");
1831 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1833 MsiSetPropertyA(hpkg
, "one", "abcdhithere");
1834 MsiSetPropertyA(hpkg
, "two", "hi");
1835 r
= MsiEvaluateConditionA(hpkg
, "one << two");
1836 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1838 MsiSetPropertyA(hpkg
, "one", "");
1839 MsiSetPropertyA(hpkg
, "two", "hi");
1840 r
= MsiEvaluateConditionA(hpkg
, "one << two");
1841 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1843 MsiSetPropertyA(hpkg
, "one", "hithere");
1844 MsiSetPropertyA(hpkg
, "two", "");
1845 r
= MsiEvaluateConditionA(hpkg
, "one << two");
1846 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1848 MsiSetPropertyA(hpkg
, "one", "");
1849 MsiSetPropertyA(hpkg
, "two", "");
1850 r
= MsiEvaluateConditionA(hpkg
, "one << two");
1851 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1853 MsiSetPropertyA(hpkg
, "one", "1234");
1854 MsiSetPropertyA(hpkg
, "two", "1");
1855 r
= MsiEvaluateConditionA(hpkg
, "one << two");
1856 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1858 MsiSetPropertyA(hpkg
, "one", "1234 one");
1859 MsiSetPropertyA(hpkg
, "two", "1");
1860 r
= MsiEvaluateConditionA(hpkg
, "one << two");
1861 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1863 MsiSetPropertyA(hpkg
, "one", "hithere");
1864 MsiSetPropertyA(hpkg
, "two", "there");
1865 r
= MsiEvaluateConditionA(hpkg
, "one >> two");
1866 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1868 MsiSetPropertyA(hpkg
, "one", "hithere");
1869 MsiSetPropertyA(hpkg
, "two", "hi");
1870 r
= MsiEvaluateConditionA(hpkg
, "one >> two");
1871 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1873 MsiSetPropertyA(hpkg
, "one", "there");
1874 MsiSetPropertyA(hpkg
, "two", "hithere");
1875 r
= MsiEvaluateConditionA(hpkg
, "one >> two");
1876 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1878 MsiSetPropertyA(hpkg
, "one", "there");
1879 MsiSetPropertyA(hpkg
, "two", "there");
1880 r
= MsiEvaluateConditionA(hpkg
, "one >> two");
1881 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1883 MsiSetPropertyA(hpkg
, "one", "abcdhithere");
1884 MsiSetPropertyA(hpkg
, "two", "hi");
1885 r
= MsiEvaluateConditionA(hpkg
, "one >> two");
1886 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1888 MsiSetPropertyA(hpkg
, "one", "");
1889 MsiSetPropertyA(hpkg
, "two", "there");
1890 r
= MsiEvaluateConditionA(hpkg
, "one >> two");
1891 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1893 MsiSetPropertyA(hpkg
, "one", "there");
1894 MsiSetPropertyA(hpkg
, "two", "");
1895 r
= MsiEvaluateConditionA(hpkg
, "one >> two");
1896 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1898 MsiSetPropertyA(hpkg
, "one", "");
1899 MsiSetPropertyA(hpkg
, "two", "");
1900 r
= MsiEvaluateConditionA(hpkg
, "one >> two");
1901 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1903 MsiSetPropertyA(hpkg
, "one", "1234");
1904 MsiSetPropertyA(hpkg
, "two", "4");
1905 r
= MsiEvaluateConditionA(hpkg
, "one >> two");
1906 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1908 MsiSetPropertyA(hpkg
, "one", "one 1234");
1909 MsiSetPropertyA(hpkg
, "two", "4");
1910 r
= MsiEvaluateConditionA(hpkg
, "one >> two");
1911 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1913 MsiSetPropertyA(hpkg
, "MsiNetAssemblySupport", NULL
); /* make sure it's empty */
1915 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1.1.4322\"");
1916 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1918 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport > \"1.1.4322\"");
1919 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1921 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport >= \"1.1.4322\"");
1922 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1924 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport <= \"1.1.4322\"");
1925 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1927 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport <> \"1.1.4322\"");
1928 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1930 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport ~< \"1.1.4322\"");
1931 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1933 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"abcd\"");
1934 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1936 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"a1.1.4322\"");
1937 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1939 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1.1.4322a\"");
1940 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1942 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"0000001.1.4322\"");
1943 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1945 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1.1.4322.1\"");
1946 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1948 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1.1.4322.1.1\"");
1949 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1951 r
= MsiEvaluateConditionA(hpkg
, "\"2\" < \"1.1");
1952 ok( r
== MSICONDITION_ERROR
, "wrong return val (%d)\n", r
);
1954 r
= MsiEvaluateConditionA(hpkg
, "\"2\" < \"1.1\"");
1955 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1957 r
= MsiEvaluateConditionA(hpkg
, "\"2\" < \"12.1\"");
1958 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1960 r
= MsiEvaluateConditionA(hpkg
, "\"02.1\" < \"2.11\"");
1961 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1963 r
= MsiEvaluateConditionA(hpkg
, "\"02.1.1\" < \"2.1\"");
1964 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1966 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1.1\"");
1967 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1969 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1\"");
1970 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1972 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"0\"");
1973 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1975 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"-1\"");
1976 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1978 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"a\"");
1979 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1981 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"!\"");
1982 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1984 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"!\"");
1985 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1987 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"/\"");
1988 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1990 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \" \"");
1991 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1993 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"azAZ_\"");
1994 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1996 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"a[a]\"");
1997 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1999 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"a[a]a\"");
2000 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2002 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"[a]\"");
2003 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2005 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"[a]a\"");
2006 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2008 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"{a}\"");
2009 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2011 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"{a\"");
2012 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2014 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"[a\"");
2015 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2017 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"a{\"");
2018 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2020 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"a]\"");
2021 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2023 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"A\"");
2024 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2026 MsiSetPropertyA(hpkg
, "MsiNetAssemblySupport", "1.1.4322");
2027 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1.1.4322\"");
2028 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
2030 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1.1.14322\"");
2031 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
2033 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1.1.5\"");
2034 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2036 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1.1\"");
2037 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
2039 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1\"");
2040 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
2042 MsiSetPropertyA(hpkg
, "one", "1");
2043 r
= MsiEvaluateConditionA(hpkg
, "one < \"1\"");
2044 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
2046 MsiSetPropertyA(hpkg
, "X", "5.0");
2048 r
= MsiEvaluateConditionA(hpkg
, "X != \"\"");
2049 ok( r
== MSICONDITION_ERROR
, "wrong return val (%d)\n", r
);
2051 r
= MsiEvaluateConditionA(hpkg
, "X =\"5.0\"");
2052 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2054 r
= MsiEvaluateConditionA(hpkg
, "X =\"5.1\"");
2055 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
2057 r
= MsiEvaluateConditionA(hpkg
, "X =\"6.0\"");
2058 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
2060 r
= MsiEvaluateConditionA(hpkg
, "X =\"5.0\" or X =\"5.1\" or X =\"6.0\"");
2061 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2063 r
= MsiEvaluateConditionA(hpkg
, "(X =\"5.0\" or X =\"5.1\" or X =\"6.0\")");
2064 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2066 r
= MsiEvaluateConditionA(hpkg
, "X !=\"\" and (X =\"5.0\" or X =\"5.1\" or X =\"6.0\")");
2067 ok( r
== MSICONDITION_ERROR
, "wrong return val (%d)\n", r
);
2069 /* feature doesn't exist */
2070 r
= MsiEvaluateConditionA(hpkg
, "&nofeature");
2071 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
2072 r
= MsiEvaluateConditionA(hpkg
, "&nofeature=\"\"");
2073 todo_wine
ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2075 MsiSetPropertyA(hpkg
, "A", "2");
2076 MsiSetPropertyA(hpkg
, "X", "50");
2078 r
= MsiEvaluateConditionA(hpkg
, "2 <= X");
2079 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2081 r
= MsiEvaluateConditionA(hpkg
, "A <= X");
2082 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2084 r
= MsiEvaluateConditionA(hpkg
, "A <= 50");
2085 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2087 MsiSetPropertyA(hpkg
, "X", "50val");
2089 r
= MsiEvaluateConditionA(hpkg
, "2 <= X");
2090 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
2092 r
= MsiEvaluateConditionA(hpkg
, "A <= X");
2093 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2095 MsiSetPropertyA(hpkg
, "A", "7");
2096 MsiSetPropertyA(hpkg
, "X", "50");
2098 r
= MsiEvaluateConditionA(hpkg
, "7 <= X");
2099 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2101 r
= MsiEvaluateConditionA(hpkg
, "A <= X");
2102 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2104 r
= MsiEvaluateConditionA(hpkg
, "A <= 50");
2105 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2107 MsiSetPropertyA(hpkg
, "X", "50val");
2109 r
= MsiEvaluateConditionA(hpkg
, "2 <= X");
2110 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
2112 r
= MsiEvaluateConditionA(hpkg
, "A <= X");
2113 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
2115 r
= MsiEvaluateConditionW(hpkg
, cond1
);
2116 ok( r
== MSICONDITION_TRUE
|| broken(r
== MSICONDITION_FALSE
),
2117 "wrong return val (%d)\n", r
);
2119 r
= MsiEvaluateConditionW(hpkg
, cond2
);
2120 ok( r
== MSICONDITION_FALSE
|| broken(r
== MSICONDITION_TRUE
),
2121 "wrong return val (%d)\n", r
);
2123 r
= MsiEvaluateConditionW(hpkg
, cond3
);
2124 ok( r
== MSICONDITION_TRUE
|| broken(r
== MSICONDITION_FALSE
),
2125 "wrong return val (%d)\n", r
);
2127 r
= MsiEvaluateConditionW(hpkg
, cond4
);
2128 ok( r
== MSICONDITION_FALSE
|| broken(r
== MSICONDITION_TRUE
),
2129 "wrong return val (%d)\n", r
);
2131 MsiCloseHandle( hpkg
);
2132 DeleteFileA(msifile
);
2135 static BOOL
check_prop_empty( MSIHANDLE hpkg
, const char * prop
)
2143 r
= MsiGetPropertyA( hpkg
, prop
, buffer
, &sz
);
2144 return r
== ERROR_SUCCESS
&& buffer
[0] == 0 && sz
== 0;
2147 static void test_props(void)
2149 MSIHANDLE hpkg
, hdb
;
2154 hdb
= create_package_db();
2156 create_property_table(hdb
);
2157 add_property_entry(hdb
, "'MetadataCompName', 'Photoshop.dll'");
2159 r
= package_from_db( hdb
, &hpkg
);
2160 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
2162 skip("Not enough rights to perform tests\n");
2163 DeleteFileA(msifile
);
2166 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
2168 /* test invalid values */
2169 r
= MsiGetPropertyA( 0, NULL
, NULL
, NULL
);
2170 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
2172 r
= MsiGetPropertyA( hpkg
, NULL
, NULL
, NULL
);
2173 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
2175 r
= MsiGetPropertyA( hpkg
, "boo", NULL
, NULL
);
2176 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2178 r
= MsiGetPropertyA( hpkg
, "boo", buffer
, NULL
);
2179 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
2181 /* test retrieving an empty/nonexistent property */
2183 r
= MsiGetPropertyA( hpkg
, "boo", NULL
, &sz
);
2184 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2185 ok( sz
== 0, "wrong size returned\n");
2187 check_prop_empty( hpkg
, "boo");
2190 r
= MsiGetPropertyA( hpkg
, "boo", buffer
, &sz
);
2191 ok( r
== ERROR_MORE_DATA
, "wrong return val\n");
2192 ok( !strcmp(buffer
,"x"), "buffer was changed\n");
2193 ok( sz
== 0, "wrong size returned\n");
2197 r
= MsiGetPropertyA( hpkg
, "boo", buffer
, &sz
);
2198 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2199 ok( buffer
[0] == 0, "buffer was not changed\n");
2200 ok( sz
== 0, "wrong size returned\n");
2202 /* set the property to something */
2203 r
= MsiSetPropertyA( 0, NULL
, NULL
);
2204 ok( r
== ERROR_INVALID_HANDLE
, "wrong return val\n");
2206 r
= MsiSetPropertyA( hpkg
, NULL
, NULL
);
2207 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
2209 r
= MsiSetPropertyA( hpkg
, "", NULL
);
2210 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2212 /* try set and get some illegal property identifiers */
2213 r
= MsiSetPropertyA( hpkg
, "", "asdf" );
2214 ok( r
== ERROR_FUNCTION_FAILED
, "wrong return val\n");
2216 r
= MsiSetPropertyA( hpkg
, "=", "asdf" );
2217 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2219 r
= MsiSetPropertyA( hpkg
, " ", "asdf" );
2220 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2222 r
= MsiSetPropertyA( hpkg
, "'", "asdf" );
2223 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2227 r
= MsiGetPropertyA( hpkg
, "'", buffer
, &sz
);
2228 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2229 ok( !strcmp(buffer
,"asdf"), "buffer was not changed\n");
2231 /* set empty values */
2232 r
= MsiSetPropertyA( hpkg
, "boo", NULL
);
2233 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2234 ok( check_prop_empty( hpkg
, "boo"), "prop wasn't empty\n");
2236 r
= MsiSetPropertyA( hpkg
, "boo", "" );
2237 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2238 ok( check_prop_empty( hpkg
, "boo"), "prop wasn't empty\n");
2240 /* set a non-empty value */
2241 r
= MsiSetPropertyA( hpkg
, "boo", "xyz" );
2242 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2246 r
= MsiGetPropertyA( hpkg
, "boo", buffer
, &sz
);
2247 ok( r
== ERROR_MORE_DATA
, "wrong return val\n");
2248 ok( buffer
[0] == 0, "buffer was not changed\n");
2249 ok( sz
== 3, "wrong size returned\n");
2253 r
= MsiGetPropertyA( hpkg
, "boo", buffer
, &sz
);
2254 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2255 ok( !strcmp(buffer
,"xyz"), "buffer was not changed\n");
2256 ok( sz
== 3, "wrong size returned\n");
2260 r
= MsiGetPropertyA( hpkg
, "boo", buffer
, &sz
);
2261 ok( r
== ERROR_MORE_DATA
, "wrong return val\n");
2262 ok( !strcmp(buffer
,"xy"), "buffer was not changed\n");
2263 ok( sz
== 3, "wrong size returned\n");
2265 r
= MsiSetPropertyA(hpkg
, "SourceDir", "foo");
2266 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2269 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", buffer
, &sz
);
2270 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2271 ok( !strcmp(buffer
,""), "buffer wrong\n");
2272 ok( sz
== 0, "wrong size returned\n");
2275 r
= MsiGetPropertyA(hpkg
, "SOMERANDOMNAME", buffer
, &sz
);
2276 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2277 ok( !strcmp(buffer
,""), "buffer wrong\n");
2278 ok( sz
== 0, "wrong size returned\n");
2281 r
= MsiGetPropertyA(hpkg
, "SourceDir", buffer
, &sz
);
2282 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2283 ok( !strcmp(buffer
,"foo"), "buffer wrong\n");
2284 ok( sz
== 3, "wrong size returned\n");
2286 r
= MsiSetPropertyA(hpkg
, "MetadataCompName", "Photoshop.dll");
2287 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2290 r
= MsiGetPropertyA(hpkg
, "MetadataCompName", NULL
, &sz
);
2291 ok( r
== ERROR_SUCCESS
, "return wrong\n");
2292 ok( sz
== 13, "size wrong (%d)\n", sz
);
2295 r
= MsiGetPropertyA(hpkg
, "MetadataCompName", buffer
, &sz
);
2296 ok( r
== ERROR_MORE_DATA
, "return wrong\n");
2297 ok( !strcmp(buffer
,"Photoshop.dl"), "buffer wrong\n");
2299 r
= MsiSetPropertyA(hpkg
, "property", "value");
2300 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2303 r
= MsiGetPropertyA(hpkg
, "property", buffer
, &sz
);
2304 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2305 ok( !strcmp(buffer
, "value"), "Expected value, got %s\n", buffer
);
2307 r
= MsiSetPropertyA(hpkg
, "property", NULL
);
2308 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2311 r
= MsiGetPropertyA(hpkg
, "property", buffer
, &sz
);
2312 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2313 ok(!buffer
[0], "Expected empty string, got %s\n", buffer
);
2315 MsiCloseHandle( hpkg
);
2316 DeleteFileA(msifile
);
2319 static BOOL
find_prop_in_property(MSIHANDLE hdb
, LPCSTR prop
, LPCSTR val
, int len
)
2321 MSIHANDLE hview
, hrec
;
2323 CHAR buffer
[MAX_PATH
];
2327 r
= MsiDatabaseOpenViewA(hdb
, "SELECT * FROM `_Property`", &hview
);
2328 ok(r
== ERROR_SUCCESS
, "MsiDatabaseOpenView failed\n");
2329 r
= MsiViewExecute(hview
, 0);
2330 ok(r
== ERROR_SUCCESS
, "MsiViewExecute failed\n");
2332 if (len
< 0) len
= lstrlenA(val
);
2334 while (r
== ERROR_SUCCESS
&& !found
)
2336 r
= MsiViewFetch(hview
, &hrec
);
2337 if (r
!= ERROR_SUCCESS
) break;
2340 r
= MsiRecordGetStringA(hrec
, 1, buffer
, &sz
);
2341 if (r
== ERROR_SUCCESS
&& !lstrcmpA(buffer
, prop
))
2344 r
= MsiRecordGetStringA(hrec
, 2, buffer
, &sz
);
2345 if (r
== ERROR_SUCCESS
&& !memcmp(buffer
, val
, len
) && !buffer
[len
])
2347 ok(sz
== len
, "wrong size %u\n", sz
);
2352 MsiCloseHandle(hrec
);
2354 MsiViewClose(hview
);
2355 MsiCloseHandle(hview
);
2359 static void test_property_table(void)
2363 MSIHANDLE hpkg
, hdb
, hrec
;
2364 char buffer
[MAX_PATH
], package
[10];
2368 hdb
= create_package_db();
2369 ok( hdb
, "failed to create package\n");
2371 r
= package_from_db(hdb
, &hpkg
);
2372 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
2374 skip("Not enough rights to perform tests\n");
2375 DeleteFileA(msifile
);
2378 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
2380 MsiCloseHandle(hdb
);
2382 hdb
= MsiGetActiveDatabase(hpkg
);
2384 query
= "CREATE TABLE `_Property` ( "
2385 "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
2386 r
= run_query(hdb
, query
);
2387 ok(r
== ERROR_BAD_QUERY_SYNTAX
, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r
);
2389 MsiCloseHandle(hdb
);
2390 MsiCloseHandle(hpkg
);
2391 DeleteFileA(msifile
);
2393 hdb
= create_package_db();
2394 ok( hdb
, "failed to create package\n");
2396 query
= "CREATE TABLE `_Property` ( "
2397 "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
2398 r
= run_query(hdb
, query
);
2399 ok(r
== ERROR_SUCCESS
, "failed to create table\n");
2401 query
= "ALTER `_Property` ADD `foo` INTEGER";
2402 r
= run_query(hdb
, query
);
2403 ok(r
== ERROR_BAD_QUERY_SYNTAX
, "failed to add column\n");
2405 query
= "ALTER TABLE `_Property` ADD `foo` INTEGER";
2406 r
= run_query(hdb
, query
);
2407 ok(r
== ERROR_BAD_QUERY_SYNTAX
, "failed to add column\n");
2409 query
= "ALTER TABLE `_Property` ADD `extra` INTEGER";
2410 r
= run_query(hdb
, query
);
2411 ok(r
== ERROR_SUCCESS
, "failed to add column\n");
2413 sprintf(package
, "#%i", hdb
);
2414 r
= MsiOpenPackageA(package
, &hpkg
);
2415 ok(r
!= ERROR_SUCCESS
, "MsiOpenPackage succeeded\n");
2416 if (r
== ERROR_SUCCESS
)
2417 MsiCloseHandle(hpkg
);
2419 r
= MsiCloseHandle(hdb
);
2420 ok(r
== ERROR_SUCCESS
, "MsiCloseHandle failed %u\n", r
);
2422 hdb
= create_package_db();
2423 ok (hdb
, "failed to create package database\n");
2425 create_property_table(hdb
);
2426 add_property_entry(hdb
, "'prop', 'val'");
2428 create_custom_action_table(hdb
);
2429 add_custom_action_entry( hdb
, "'EmbedNull', 51, 'prop2', '[~]np'" );
2431 r
= package_from_db(hdb
, &hpkg
);
2432 ok(r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
2434 MsiCloseHandle(hdb
);
2437 r
= MsiGetPropertyA(hpkg
, "prop", buffer
, &sz
);
2438 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2439 ok(!lstrcmpA(buffer
, "val"), "Expected val, got %s\n", buffer
);
2441 hdb
= MsiGetActiveDatabase(hpkg
);
2443 found
= find_prop_in_property(hdb
, "prop", "val", -1);
2444 ok(found
, "prop should be in the _Property table\n");
2446 add_property_entry(hdb
, "'dantes', 'mercedes'");
2448 query
= "SELECT * FROM `_Property` WHERE `Property` = 'dantes'";
2449 r
= do_query(hdb
, query
, &hrec
);
2450 ok(r
== ERROR_BAD_QUERY_SYNTAX
, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r
);
2452 found
= find_prop_in_property(hdb
, "dantes", "mercedes", -1);
2453 ok(found
== FALSE
, "dantes should not be in the _Property table\n");
2456 lstrcpyA(buffer
, "aaa");
2457 r
= MsiGetPropertyA(hpkg
, "dantes", buffer
, &sz
);
2458 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2459 ok(!buffer
[0], "Expected empty string, got %s\n", buffer
);
2461 r
= MsiSetPropertyA(hpkg
, "dantes", "mercedes");
2462 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2464 found
= find_prop_in_property(hdb
, "dantes", "mercedes", -1);
2465 ok(found
== TRUE
, "dantes should be in the _Property table\n");
2467 r
= MsiDoActionA( hpkg
, "EmbedNull" );
2468 ok( r
== ERROR_SUCCESS
, "EmbedNull failed: %d\n", r
);
2471 memset( buffer
, 'a', sizeof(buffer
) );
2472 r
= MsiGetPropertyA( hpkg
, "prop2", buffer
, &sz
);
2473 ok( r
== ERROR_SUCCESS
, "get property failed: %d\n", r
);
2474 ok( !memcmp( buffer
, "\0np", sizeof("\0np") ), "wrong value\n");
2475 ok( sz
== sizeof("\0np") - 1, "got %u\n", sz
);
2477 found
= find_prop_in_property(hdb
, "prop2", "\0np", 3);
2478 ok(found
== TRUE
, "prop2 should be in the _Property table\n");
2480 MsiCloseHandle(hdb
);
2481 MsiCloseHandle(hpkg
);
2482 DeleteFileA(msifile
);
2485 static UINT
try_query_param( MSIHANDLE hdb
, LPCSTR szQuery
, MSIHANDLE hrec
)
2490 res
= MsiDatabaseOpenViewA( hdb
, szQuery
, &htab
);
2491 if( res
== ERROR_SUCCESS
)
2495 r
= MsiViewExecute( htab
, hrec
);
2496 if( r
!= ERROR_SUCCESS
)
2499 fprintf(stderr
,"MsiViewExecute failed %08x\n", res
);
2502 r
= MsiViewClose( htab
);
2503 if( r
!= ERROR_SUCCESS
)
2506 r
= MsiCloseHandle( htab
);
2507 if( r
!= ERROR_SUCCESS
)
2513 static UINT
try_query( MSIHANDLE hdb
, LPCSTR szQuery
)
2515 return try_query_param( hdb
, szQuery
, 0 );
2518 static void set_summary_str(MSIHANDLE hdb
, DWORD pid
, LPCSTR value
)
2523 r
= MsiGetSummaryInformationA(hdb
, NULL
, 1, &summary
);
2524 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2526 r
= MsiSummaryInfoSetPropertyA(summary
, pid
, VT_LPSTR
, 0, NULL
, value
);
2527 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
2529 r
= MsiSummaryInfoPersist(summary
);
2530 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
2532 MsiCloseHandle(summary
);
2535 static void set_summary_dword(MSIHANDLE hdb
, DWORD pid
, DWORD value
)
2540 r
= MsiGetSummaryInformationA(hdb
, NULL
, 1, &summary
);
2541 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2543 r
= MsiSummaryInfoSetPropertyA(summary
, pid
, VT_I4
, value
, NULL
, NULL
);
2544 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
2546 r
= MsiSummaryInfoPersist(summary
);
2547 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
2549 MsiCloseHandle(summary
);
2552 static void test_msipackage(void)
2554 MSIHANDLE hdb
= 0, hpack
= 100;
2559 /* NULL szPackagePath */
2560 r
= MsiOpenPackageA(NULL
, &hpack
);
2561 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
2563 /* empty szPackagePath */
2564 r
= MsiOpenPackageA("", &hpack
);
2565 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
2567 skip("Not enough rights to perform tests\n");
2572 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2575 if (r
== ERROR_SUCCESS
)
2576 MsiCloseHandle(hpack
);
2578 /* nonexistent szPackagePath */
2579 r
= MsiOpenPackageA("nonexistent", &hpack
);
2580 ok(r
== ERROR_FILE_NOT_FOUND
, "Expected ERROR_FILE_NOT_FOUND, got %d\n", r
);
2583 r
= MsiOpenPackageA(msifile
, NULL
);
2584 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
2588 r
= MsiOpenPackageA(name
, &hpack
);
2589 ok(r
== ERROR_INVALID_HANDLE
, "Expected ERROR_INVALID_HANDLE, got %d\n", r
);
2591 r
= MsiOpenDatabaseW(msifileW
, MSIDBOPEN_CREATE
, &hdb
);
2592 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2594 /* database exists, but is empty */
2595 sprintf(name
, "#%d", hdb
);
2596 r
= MsiOpenPackageA(name
, &hpack
);
2597 ok(r
== ERROR_INSTALL_PACKAGE_INVALID
,
2598 "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r
);
2600 query
= "CREATE TABLE `Property` ( "
2601 "`Property` CHAR(72), `Value` CHAR(0) "
2602 "PRIMARY KEY `Property`)";
2603 r
= try_query(hdb
, query
);
2604 ok(r
== ERROR_SUCCESS
, "failed to create Properties table\n");
2606 query
= "CREATE TABLE `InstallExecuteSequence` ("
2607 "`Action` CHAR(72), `Condition` CHAR(0), `Sequence` INTEGER "
2608 "PRIMARY KEY `Action`)";
2609 r
= try_query(hdb
, query
);
2610 ok(r
== ERROR_SUCCESS
, "failed to create InstallExecuteSequence table\n");
2612 /* a few key tables exist */
2613 sprintf(name
, "#%d", hdb
);
2614 r
= MsiOpenPackageA(name
, &hpack
);
2615 ok(r
== ERROR_INSTALL_PACKAGE_INVALID
,
2616 "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r
);
2618 MsiCloseHandle(hdb
);
2619 DeleteFileA(msifile
);
2621 /* start with a clean database to show what constitutes a valid package */
2622 r
= MsiOpenDatabaseW(msifileW
, MSIDBOPEN_CREATE
, &hdb
);
2623 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2625 sprintf(name
, "#%d", hdb
);
2627 /* The following summary information props must exist:
2632 set_summary_dword(hdb
, PID_PAGECOUNT
, 100);
2633 r
= MsiOpenPackageA(name
, &hpack
);
2634 ok(r
== ERROR_INSTALL_PACKAGE_INVALID
,
2635 "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r
);
2637 set_summary_str(hdb
, PID_REVNUMBER
, "{004757CD-5092-49C2-AD20-28E1CE0DF5F2}");
2638 r
= MsiOpenPackageA(name
, &hpack
);
2639 ok(r
== ERROR_SUCCESS
,
2640 "Expected ERROR_SUCCESS, got %d\n", r
);
2642 MsiCloseHandle(hpack
);
2643 MsiCloseHandle(hdb
);
2644 DeleteFileA(msifile
);
2647 static void test_formatrecord2(void)
2649 MSIHANDLE hpkg
, hrec
;
2654 r
= package_from_db(create_package_db(), &hpkg
);
2655 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
2657 skip("Not enough rights to perform tests\n");
2658 DeleteFileA(msifile
);
2661 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
2663 r
= MsiSetPropertyA(hpkg
, "Manufacturer", " " );
2664 ok( r
== ERROR_SUCCESS
, "set property failed\n");
2666 hrec
= MsiCreateRecord(2);
2667 ok(hrec
, "create record failed\n");
2669 r
= MsiRecordSetStringA( hrec
, 0, "[ProgramFilesFolder][Manufacturer]\\asdf");
2670 ok( r
== ERROR_SUCCESS
, "format record failed\n");
2674 r
= MsiFormatRecordA( hpkg
, hrec
, buffer
, &sz
);
2675 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
2677 r
= MsiRecordSetStringA(hrec
, 0, "[foo][1]");
2678 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
2679 r
= MsiRecordSetStringA(hrec
, 1, "hoo");
2680 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
2682 r
= MsiFormatRecordA(hpkg
, hrec
, buffer
, &sz
);
2683 ok( sz
== 3, "size wrong\n");
2684 ok( 0 == strcmp(buffer
,"hoo"), "wrong output %s\n",buffer
);
2685 ok( r
== ERROR_SUCCESS
, "format failed\n");
2687 r
= MsiRecordSetStringA(hrec
, 0, "x[~]x");
2688 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
2690 r
= MsiFormatRecordA(hpkg
, hrec
, buffer
, &sz
);
2691 ok( sz
== 3, "size wrong\n");
2692 ok( 0 == strcmp(buffer
,"x"), "wrong output %s\n",buffer
);
2693 ok( r
== ERROR_SUCCESS
, "format failed\n");
2695 r
= MsiRecordSetStringA(hrec
, 0, "[foo.$%}][1]");
2696 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
2697 r
= MsiRecordSetStringA(hrec
, 1, "hoo");
2698 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
2700 r
= MsiFormatRecordA(hpkg
, hrec
, buffer
, &sz
);
2701 ok( sz
== 3, "size wrong\n");
2702 ok( 0 == strcmp(buffer
,"hoo"), "wrong output %s\n",buffer
);
2703 ok( r
== ERROR_SUCCESS
, "format failed\n");
2705 r
= MsiRecordSetStringA(hrec
, 0, "[\\[]");
2706 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
2708 r
= MsiFormatRecordA(hpkg
, hrec
, buffer
, &sz
);
2709 ok( sz
== 1, "size wrong\n");
2710 ok( 0 == strcmp(buffer
,"["), "wrong output %s\n",buffer
);
2711 ok( r
== ERROR_SUCCESS
, "format failed\n");
2713 SetEnvironmentVariableA("FOO", "BAR");
2714 r
= MsiRecordSetStringA(hrec
, 0, "[%FOO]");
2715 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
2717 r
= MsiFormatRecordA(hpkg
, hrec
, buffer
, &sz
);
2718 ok( sz
== 3, "size wrong\n");
2719 ok( 0 == strcmp(buffer
,"BAR"), "wrong output %s\n",buffer
);
2720 ok( r
== ERROR_SUCCESS
, "format failed\n");
2722 r
= MsiRecordSetStringA(hrec
, 0, "[[1]]");
2723 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
2724 r
= MsiRecordSetStringA(hrec
, 1, "%FOO");
2725 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
2727 r
= MsiFormatRecordA(hpkg
, hrec
, buffer
, &sz
);
2728 ok( sz
== 3, "size wrong\n");
2729 ok( 0 == strcmp(buffer
,"BAR"), "wrong output %s\n",buffer
);
2730 ok( r
== ERROR_SUCCESS
, "format failed\n");
2732 MsiCloseHandle( hrec
);
2733 MsiCloseHandle( hpkg
);
2734 DeleteFileA(msifile
);
2737 static void test_formatrecord_tables(void)
2739 MSIHANDLE hdb
, hrec
, hpkg
= 0;
2741 CHAR curr_dir
[MAX_PATH
];
2742 CHAR expected
[MAX_PATH
];
2743 CHAR root
[MAX_PATH
];
2747 GetCurrentDirectoryA( MAX_PATH
, curr_dir
);
2749 hdb
= create_package_db();
2750 ok ( hdb
, "failed to create package database\n");
2752 add_directory_entry( hdb
, "'TARGETDIR', '', 'SourceDir'" );
2753 add_directory_entry( hdb
, "'ReallyLongDir', 'TARGETDIR', "
2754 "'I am a really long directory'" );
2756 create_feature_table( hdb
);
2757 add_feature_entry( hdb
, "'occipitofrontalis', '', '', '', 2, 1, '', 0" );
2759 create_component_table( hdb
);
2760 add_component_entry( hdb
, "'frontal', '', 'TARGETDIR', 0, '', 'frontal_file'" );
2761 add_component_entry( hdb
, "'parietal', '', 'TARGETDIR', 1, '', 'parietal_file'" );
2762 add_component_entry( hdb
, "'temporal', '', 'ReallyLongDir', 0, '', 'temporal_file'" );
2764 create_feature_components_table( hdb
);
2765 add_feature_components_entry( hdb
, "'occipitofrontalis', 'frontal'" );
2766 add_feature_components_entry( hdb
, "'occipitofrontalis', 'parietal'" );
2767 add_feature_components_entry( hdb
, "'occipitofrontalis', 'temporal'" );
2769 create_file_table( hdb
);
2770 add_file_entry( hdb
, "'frontal_file', 'frontal', 'frontal.txt', 0, '', '1033', 8192, 1" );
2771 add_file_entry( hdb
, "'parietal_file', 'parietal', 'parietal.txt', 0, '', '1033', 8192, 1" );
2772 add_file_entry( hdb
, "'temporal_file', 'temporal', 'temporal.txt', 0, '', '1033', 8192, 1" );
2774 create_custom_action_table( hdb
);
2775 add_custom_action_entry( hdb
, "'MyCustom', 51, 'prop', '[!temporal_file]'" );
2776 add_custom_action_entry( hdb
, "'EscapeIt1', 51, 'prop', '[\\[]Bracket Text[\\]]'" );
2777 add_custom_action_entry( hdb
, "'EscapeIt2', 51, 'prop', '[\\xabcd]'" );
2778 add_custom_action_entry( hdb
, "'EscapeIt3', 51, 'prop', '[abcd\\xefgh]'" );
2779 add_custom_action_entry( hdb
, "'EmbedNull', 51, 'prop', '[~]np'" );
2781 r
= package_from_db( hdb
, &hpkg
);
2782 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
2784 skip("Not enough rights to perform tests\n");
2785 MsiCloseHandle( hdb
);
2786 DeleteFileA( msifile
);
2789 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
2791 MsiCloseHandle( hdb
);
2793 r
= MsiSetPropertyA( hpkg
, "imaprop", "ringer" );
2794 ok( r
== ERROR_SUCCESS
, "cannot set property: %d\n", r
);
2796 hrec
= MsiCreateRecord( 1 );
2798 /* property doesn't exist */
2800 /*MsiRecordSetStringA( hrec, 0, "[1]" ); */
2801 MsiRecordSetStringA( hrec
, 1, "[idontexist]" );
2802 r
= MsiFormatRecordA( hpkg
, hrec
, buf
, &size
);
2803 ok( r
== ERROR_SUCCESS
, "format record failed: %d\n", r
);
2804 ok( !lstrcmpA( buf
, "1: " ), "Expected '1: ', got %s\n", buf
);
2806 /* property exists */
2808 MsiRecordSetStringA( hrec
, 1, "[imaprop]" );
2809 r
= MsiFormatRecordA( hpkg
, hrec
, buf
, &size
);
2810 ok( r
== ERROR_SUCCESS
, "format record failed: %d\n", r
);
2811 ok( !lstrcmpA( buf
, "1: ringer " ), "Expected '1: ringer ', got %s\n", buf
);
2814 MsiRecordSetStringA( hrec
, 0, "1: [1] " );
2815 r
= MsiFormatRecordA( hpkg
, hrec
, buf
, &size
);
2816 ok( r
== ERROR_SUCCESS
, "format record failed: %d\n", r
);
2817 ok( !lstrcmpA( buf
, "1: ringer " ), "Expected '1: ringer ', got %s\n", buf
);
2819 /* environment variable doesn't exist */
2821 MsiRecordSetStringA( hrec
, 1, "[%idontexist]" );
2822 r
= MsiFormatRecordA( hpkg
, hrec
, buf
, &size
);
2823 ok( r
== ERROR_SUCCESS
, "format record failed: %d\n", r
);
2824 ok( !lstrcmpA( buf
, "1: " ), "Expected '1: ', got %s\n", buf
);
2826 /* environment variable exists */
2828 SetEnvironmentVariableA( "crazyvar", "crazyval" );
2829 MsiRecordSetStringA( hrec
, 1, "[%crazyvar]" );
2830 r
= MsiFormatRecordA( hpkg
, hrec
, buf
, &size
);
2831 ok( r
== ERROR_SUCCESS
, "format record failed: %d\n", r
);
2832 ok( !lstrcmpA( buf
, "1: crazyval " ), "Expected '1: crazyval ', got %s\n", buf
);
2834 /* file key before CostInitialize */
2836 MsiRecordSetStringA( hrec
, 1, "[#frontal_file]" );
2837 r
= MsiFormatRecordA( hpkg
, hrec
, buf
, &size
);
2838 ok( r
== ERROR_SUCCESS
, "format record failed: %d\n", r
);
2839 ok( !lstrcmpA( buf
, "1: " ), "Expected '1: ', got %s\n", buf
);
2841 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
2843 r
= MsiDoActionA(hpkg
, "CostInitialize");
2844 ok( r
== ERROR_SUCCESS
, "CostInitialize failed: %d\n", r
);
2846 r
= MsiDoActionA(hpkg
, "FileCost");
2847 ok( r
== ERROR_SUCCESS
, "FileCost failed: %d\n", r
);
2849 r
= MsiDoActionA(hpkg
, "CostFinalize");
2850 ok( r
== ERROR_SUCCESS
, "CostFinalize failed: %d\n", r
);
2853 MsiGetPropertyA( hpkg
, "ROOTDRIVE", root
, &size
);
2855 sprintf( expected
, "1: %sfrontal.txt ", root
);
2857 /* frontal full file key */
2859 MsiRecordSetStringA( hrec
, 1, "[#frontal_file]" );
2860 r
= MsiFormatRecordA( hpkg
, hrec
, buf
, &size
);
2861 ok( r
== ERROR_SUCCESS
, "format record failed: %d\n", r
);
2862 ok( !lstrcmpA( buf
, expected
), "Expected \"%s\", got \"%s\"\n", expected
, buf
);
2864 /* frontal short file key */
2866 MsiRecordSetStringA( hrec
, 1, "[!frontal_file]" );
2867 r
= MsiFormatRecordA( hpkg
, hrec
, buf
, &size
);
2868 ok( r
== ERROR_SUCCESS
, "format record failed: %d\n", r
);
2869 ok( !lstrcmpA( buf
, expected
), "Expected \"%s\", got \"%s\"\n", expected
, buf
);
2871 sprintf( expected
, "1: %sI am a really long directory\\temporal.txt ", root
);
2873 /* temporal full file key */
2875 MsiRecordSetStringA( hrec
, 1, "[#temporal_file]" );
2876 r
= MsiFormatRecordA( hpkg
, hrec
, buf
, &size
);
2877 ok( r
== ERROR_SUCCESS
, "format record failed: %d\n", r
);
2878 ok( !lstrcmpA( buf
, expected
), "Expected \"%s\", got \"%s\"\n", expected
, buf
);
2880 /* temporal short file key */
2882 MsiRecordSetStringA( hrec
, 1, "[!temporal_file]" );
2883 r
= MsiFormatRecordA( hpkg
, hrec
, buf
, &size
);
2884 ok( r
== ERROR_SUCCESS
, "format record failed: %d\n", r
);
2885 ok( !lstrcmpA( buf
, expected
), "Expected \"%s\", got \"%s\"\n", expected
, buf
);
2887 /* custom action 51, files don't exist */
2888 r
= MsiDoActionA( hpkg
, "MyCustom" );
2889 ok( r
== ERROR_SUCCESS
, "MyCustom failed: %d\n", r
);
2891 sprintf( expected
, "%sI am a really long directory\\temporal.txt", root
);
2894 r
= MsiGetPropertyA( hpkg
, "prop", buf
, &size
);
2895 ok( r
== ERROR_SUCCESS
, "get property failed: %d\n", r
);
2896 ok( !lstrcmpA( buf
, expected
), "Expected \"%s\", got \"%s\"\n", expected
, buf
);
2898 sprintf( buf
, "%sI am a really long directory", root
);
2899 CreateDirectoryA( buf
, NULL
);
2901 lstrcatA( buf
, "\\temporal.txt" );
2902 create_test_file( buf
);
2904 /* custom action 51, files exist */
2905 r
= MsiDoActionA( hpkg
, "MyCustom" );
2906 ok( r
== ERROR_SUCCESS
, "MyCustom failed: %d\n", r
);
2909 r
= MsiGetPropertyA( hpkg
, "prop", buf
, &size
);
2910 ok( r
== ERROR_SUCCESS
, "get property failed: %d\n", r
);
2913 ok( !lstrcmpA( buf
, expected
), "Expected \"%s\", got \"%s\"\n", expected
, buf
);
2916 /* custom action 51, escaped text 1 */
2917 r
= MsiDoActionA( hpkg
, "EscapeIt1" );
2918 ok( r
== ERROR_SUCCESS
, "EscapeIt1 failed: %d\n", r
);
2921 r
= MsiGetPropertyA( hpkg
, "prop", buf
, &size
);
2922 ok( r
== ERROR_SUCCESS
, "get property failed: %d\n", r
);
2923 ok( !lstrcmpA( buf
, "[Bracket Text]" ), "Expected '[Bracket Text]', got %s\n", buf
);
2925 /* custom action 51, escaped text 2 */
2926 r
= MsiDoActionA( hpkg
, "EscapeIt2" );
2927 ok( r
== ERROR_SUCCESS
, "EscapeIt2 failed: %d\n", r
);
2930 r
= MsiGetPropertyA( hpkg
, "prop", buf
, &size
);
2931 ok( r
== ERROR_SUCCESS
, "get property failed: %d\n", r
);
2932 ok( !lstrcmpA( buf
, "x" ), "Expected 'x', got %s\n", buf
);
2934 /* custom action 51, escaped text 3 */
2935 r
= MsiDoActionA( hpkg
, "EscapeIt3" );
2936 ok( r
== ERROR_SUCCESS
, "EscapeIt3 failed: %d\n", r
);
2939 r
= MsiGetPropertyA( hpkg
, "prop", buf
, &size
);
2940 ok( r
== ERROR_SUCCESS
, "get property failed: %d\n", r
);
2941 ok( !lstrcmpA( buf
, "" ), "Expected '', got %s\n", buf
);
2943 /* custom action 51, embedded null */
2944 r
= MsiDoActionA( hpkg
, "EmbedNull" );
2945 ok( r
== ERROR_SUCCESS
, "EmbedNull failed: %d\n", r
);
2948 memset( buf
, 'a', sizeof(buf
) );
2949 r
= MsiGetPropertyA( hpkg
, "prop", buf
, &size
);
2950 ok( r
== ERROR_SUCCESS
, "get property failed: %d\n", r
);
2951 ok( !memcmp( buf
, "\0np", sizeof("\0np") ), "wrong value\n");
2952 ok( size
== sizeof("\0np") - 1, "got %u\n", size
);
2954 r
= MsiSetPropertyA( hpkg
, "prop", "[~]np" );
2955 ok( r
== ERROR_SUCCESS
, "cannot set property: %d\n", r
);
2958 memset( buf
, 'a', sizeof(buf
) );
2959 r
= MsiGetPropertyA( hpkg
, "prop", buf
, &size
);
2960 ok( r
== ERROR_SUCCESS
, "get property failed: %d\n", r
);
2961 ok( !lstrcmpA( buf
, "[~]np" ), "Expected '[~]np', got %s\n", buf
);
2963 sprintf( expected
, "1: %sI am a really long directory\\ ", root
);
2965 /* component with INSTALLSTATE_LOCAL */
2967 MsiRecordSetStringA( hrec
, 1, "[$temporal]" );
2968 r
= MsiFormatRecordA( hpkg
, hrec
, buf
, &size
);
2969 ok( r
== ERROR_SUCCESS
, "format record failed: %d\n", r
);
2970 ok( !lstrcmpA( buf
, expected
), "Expected \"%s\", got \"%s\"\n", expected
, buf
);
2972 r
= MsiSetComponentStateA( hpkg
, "temporal", INSTALLSTATE_SOURCE
);
2973 ok( r
== ERROR_SUCCESS
, "failed to set install state: %d\n", r
);
2975 /* component with INSTALLSTATE_SOURCE */
2976 lstrcpyA( expected
, "1: " );
2977 lstrcatA( expected
, curr_dir
);
2978 if (strlen(curr_dir
) > 3) lstrcatA( expected
, "\\" );
2979 lstrcatA( expected
, " " );
2981 MsiRecordSetStringA( hrec
, 1, "[$parietal]" );
2982 r
= MsiFormatRecordA( hpkg
, hrec
, buf
, &size
);
2983 ok( r
== ERROR_SUCCESS
, "format record failed: %d\n", r
);
2984 ok( !lstrcmpA( buf
, expected
), "Expected '%s', got '%s'\n", expected
, buf
);
2986 sprintf( buf
, "%sI am a really long directory\\temporal.txt", root
);
2989 sprintf( buf
, "%sI am a really long directory", root
);
2990 RemoveDirectoryA( buf
);
2992 MsiCloseHandle( hrec
);
2993 MsiCloseHandle( hpkg
);
2994 DeleteFileA( msifile
);
2997 static void test_feature_states( UINT line
, MSIHANDLE package
, const char *feature
, UINT error
,
2998 INSTALLSTATE expected_state
, INSTALLSTATE expected_action
, BOOL todo
)
3001 INSTALLSTATE state
= 0xdeadbee;
3002 INSTALLSTATE action
= 0xdeadbee;
3004 r
= MsiGetFeatureStateA( package
, feature
, &state
, &action
);
3005 ok( r
== error
, "%u: expected %d got %d\n", line
, error
, r
);
3006 if (r
== ERROR_SUCCESS
)
3008 ok( state
== expected_state
, "%u: expected state %d got %d\n",
3009 line
, expected_state
, state
);
3011 ok( action
== expected_action
, "%u: expected action %d got %d\n",
3012 line
, expected_action
, action
);
3016 ok( state
== 0xdeadbee, "%u: expected state 0xdeadbee got %d\n", line
, state
);
3018 ok( action
== 0xdeadbee, "%u: expected action 0xdeadbee got %d\n", line
, action
);
3023 static void test_component_states( UINT line
, MSIHANDLE package
, const char *component
, UINT error
,
3024 INSTALLSTATE expected_state
, INSTALLSTATE expected_action
, BOOL todo
)
3027 INSTALLSTATE state
= 0xdeadbee;
3028 INSTALLSTATE action
= 0xdeadbee;
3030 r
= MsiGetComponentStateA( package
, component
, &state
, &action
);
3031 ok( r
== error
, "%u: expected %d got %d\n", line
, error
, r
);
3032 if (r
== ERROR_SUCCESS
)
3034 ok( state
== expected_state
, "%u: expected state %d got %d\n",
3035 line
, expected_state
, state
);
3037 ok( action
== expected_action
, "%u: expected action %d got %d\n",
3038 line
, expected_action
, action
);
3042 ok( state
== 0xdeadbee, "%u: expected state 0xdeadbee got %d\n",
3045 ok( action
== 0xdeadbee, "%u: expected action 0xdeadbee got %d\n",
3050 static void test_states(void)
3052 static const char msifile2
[] = "winetest2-package.msi";
3053 static const char msifile3
[] = "winetest3-package.msi";
3054 static const char msifile4
[] = "winetest4-package.msi";
3055 static const WCHAR msifile2W
[] =
3056 {'w','i','n','e','t','e','s','t','2','-','p','a','c','k','a','g','e','.','m','s','i',0};
3057 static const WCHAR msifile3W
[] =
3058 {'w','i','n','e','t','e','s','t','3','-','p','a','c','k','a','g','e','.','m','s','i',0};
3059 static const WCHAR msifile4W
[] =
3060 {'w','i','n','e','t','e','s','t','4','-','p','a','c','k','a','g','e','.','m','s','i',0};
3061 char msi_cache_file
[MAX_PATH
];
3062 DWORD cache_file_name_len
;
3069 if (is_process_limited())
3071 skip("process is limited\n");
3075 hdb
= create_package_db();
3076 ok ( hdb
, "failed to create package database\n" );
3078 add_directory_entry( hdb
, "'TARGETDIR', '', 'SourceDir'");
3080 create_property_table( hdb
);
3081 add_property_entry( hdb
, "'ProductCode', '{7262AC98-EEBD-4364-8CE3-D654F6A425B9}'" );
3082 add_property_entry( hdb
, "'ProductLanguage', '1033'" );
3083 add_property_entry( hdb
, "'ProductName', 'MSITEST'" );
3084 add_property_entry( hdb
, "'ProductVersion', '1.1.1'" );
3085 add_property_entry( hdb
, "'MSIFASTINSTALL', '1'" );
3087 create_install_execute_sequence_table( hdb
);
3088 add_install_execute_sequence_entry( hdb
, "'CostInitialize', '', '800'" );
3089 add_install_execute_sequence_entry( hdb
, "'FileCost', '', '900'" );
3090 add_install_execute_sequence_entry( hdb
, "'CostFinalize', '', '1000'" );
3091 add_install_execute_sequence_entry( hdb
, "'InstallValidate', '', '1400'" );
3092 add_install_execute_sequence_entry( hdb
, "'InstallInitialize', '', '1500'" );
3093 add_install_execute_sequence_entry( hdb
, "'ProcessComponents', '', '1600'" );
3094 add_install_execute_sequence_entry( hdb
, "'UnpublishFeatures', '', '1800'" );
3095 add_install_execute_sequence_entry( hdb
, "'RegisterProduct', '', '6100'" );
3096 add_install_execute_sequence_entry( hdb
, "'PublishFeatures', '', '6300'" );
3097 add_install_execute_sequence_entry( hdb
, "'PublishProduct', '', '6400'" );
3098 add_install_execute_sequence_entry( hdb
, "'InstallFinalize', '', '6600'" );
3100 create_media_table( hdb
);
3101 add_media_entry( hdb
, "'1', '3', '', '', 'DISK1', ''");
3103 create_feature_table( hdb
);
3105 create_component_table( hdb
);
3107 /* msidbFeatureAttributesFavorLocal */
3108 add_feature_entry( hdb
, "'one', '', '', '', 2, 1, '', 0" );
3110 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
3111 add_component_entry( hdb
, "'alpha', '{467EC132-739D-4784-A37B-677AA43DBC94}', 'TARGETDIR', 0, '', 'alpha_file'" );
3113 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
3114 add_component_entry( hdb
, "'beta', '{2C1F189C-24A6-4C34-B26B-994A6C026506}', 'TARGETDIR', 1, '', 'beta_file'" );
3116 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
3117 add_component_entry( hdb
, "'gamma', '{C271E2A4-DE2E-4F70-86D1-6984AF7DE2CA}', 'TARGETDIR', 2, '', 'gamma_file'" );
3119 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSharedDllRefCount */
3120 add_component_entry( hdb
, "'theta', '{4EB3129D-81A8-48D5-9801-75600FED3DD9}', 'TARGETDIR', 8, '', 'theta_file'" );
3122 /* msidbFeatureAttributesFavorSource */
3123 add_feature_entry( hdb
, "'two', '', '', '', 2, 1, '', 1" );
3125 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
3126 add_component_entry( hdb
, "'delta', '{938FD4F2-C648-4259-A03C-7AA3B45643F3}', 'TARGETDIR', 0, '', 'delta_file'" );
3128 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
3129 add_component_entry( hdb
, "'epsilon', '{D59713B6-C11D-47F2-A395-1E5321781190}', 'TARGETDIR', 1, '', 'epsilon_file'" );
3131 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
3132 add_component_entry( hdb
, "'zeta', '{377D33AB-2FAA-42B9-A629-0C0DAE9B9C7A}', 'TARGETDIR', 2, '', 'zeta_file'" );
3134 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSharedDllRefCount */
3135 add_component_entry( hdb
, "'iota', '{5D36F871-B5ED-4801-9E0F-C46B9E5C9669}', 'TARGETDIR', 8, '', 'iota_file'" );
3137 /* msidbFeatureAttributesFavorSource */
3138 add_feature_entry( hdb
, "'three', '', '', '', 2, 1, '', 1" );
3140 /* msidbFeatureAttributesFavorLocal */
3141 add_feature_entry( hdb
, "'four', '', '', '', 2, 1, '', 0" );
3144 add_feature_entry( hdb
, "'five', '', '', '', 2, 0, '', 1" );
3146 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
3147 add_component_entry( hdb
, "'eta', '{DD89003F-0DD4-41B8-81C0-3411A7DA2695}', 'TARGETDIR', 1, '', 'eta_file'" );
3149 /* no feature parent:msidbComponentAttributesLocalOnly */
3150 add_component_entry( hdb
, "'kappa', '{D6B93DC3-8DA5-4769-9888-42BFE156BB8B}', 'TARGETDIR', 1, '', 'kappa_file'" );
3152 /* msidbFeatureAttributesFavorLocal:removed */
3153 add_feature_entry( hdb
, "'six', '', '', '', 2, 1, '', 0" );
3155 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesLocalOnly */
3156 add_component_entry( hdb
, "'lambda', '{6528C5E4-02A4-4636-A214-7A66A6C35B64}', 'TARGETDIR', 0, '', 'lambda_file'" );
3158 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesSourceOnly */
3159 add_component_entry( hdb
, "'mu', '{97014BAB-6C56-4013-9A63-2BF913B42519}', 'TARGETDIR', 1, '', 'mu_file'" );
3161 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesOptional */
3162 add_component_entry( hdb
, "'nu', '{943DD0D8-5808-4954-8526-3B8493FEDDCD}', 'TARGETDIR', 2, '', 'nu_file'" );
3164 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesSharedDllRefCount */
3165 add_component_entry( hdb
, "'xi', '{D6CF9EF7-6FCF-4930-B34B-F938AEFF9BDB}', 'TARGETDIR', 8, '', 'xi_file'" );
3167 /* msidbFeatureAttributesFavorSource:removed */
3168 add_feature_entry( hdb
, "'seven', '', '', '', 2, 1, '', 1" );
3170 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesLocalOnly */
3171 add_component_entry( hdb
, "'omicron', '{7B57521D-15DB-4141-9AA6-01D934A4433F}', 'TARGETDIR', 0, '', 'omicron_file'" );
3173 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesSourceOnly */
3174 add_component_entry( hdb
, "'pi', '{FB85346B-378E-4492-8769-792305471C81}', 'TARGETDIR', 1, '', 'pi_file'" );
3176 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesOptional */
3177 add_component_entry( hdb
, "'rho', '{798F2047-7B0C-4783-8BB0-D703E554114B}', 'TARGETDIR', 2, '', 'rho_file'" );
3179 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesSharedDllRefCount */
3180 add_component_entry( hdb
, "'sigma', '{5CE9DDA8-B67B-4736-9D93-99D61C5B93E7}', 'TARGETDIR', 8, '', 'sigma_file'" );
3182 /* msidbFeatureAttributesFavorLocal */
3183 add_feature_entry( hdb
, "'eight', '', '', '', 2, 1, '', 0" );
3185 add_component_entry( hdb
, "'tau', '{07DEB510-677C-4A6F-A0A6-7CD8EFEA77ED}', 'TARGETDIR', 1, '', 'tau_file'" );
3187 /* msidbFeatureAttributesFavorSource */
3188 add_feature_entry( hdb
, "'nine', '', '', '', 2, 1, '', 1" );
3190 add_component_entry( hdb
, "'phi', '{9F0594C5-35AD-43EA-94DD-8DF73FAA664D}', 'TARGETDIR', 1, '', 'phi_file'" );
3192 /* msidbFeatureAttributesFavorAdvertise */
3193 add_feature_entry( hdb
, "'ten', '', '', '', 2, 1, '', 4" );
3195 add_component_entry( hdb
, "'chi', '{E6B539AB-5DA9-4236-A2D2-E341A50B4C38}', 'TARGETDIR', 1, '', 'chi_file'" );
3197 /* msidbFeatureAttributesUIDisallowAbsent */
3198 add_feature_entry( hdb
, "'eleven', '', '', '', 2, 1, '', 16" );
3200 add_component_entry( hdb
, "'psi', '{A06B23B5-746B-427A-8A6E-FD6AC8F46A95}', 'TARGETDIR', 1, '', 'psi_file'" );
3202 /* high install level */
3203 add_feature_entry( hdb
, "'twelve', '', '', '', 2, 2, '', 0" );
3205 add_component_entry( hdb
, "'upsilon', '{557e0c04-ceba-4c58-86a9-4a73352e8cf6}', 'TARGETDIR', 1, '', 'upsilon_file'" );
3207 /* msidbFeatureAttributesFollowParent */
3208 add_feature_entry( hdb
, "'thirteen', '', '', '', 2, 2, '', 2" );
3210 create_feature_components_table( hdb
);
3211 add_feature_components_entry( hdb
, "'one', 'alpha'" );
3212 add_feature_components_entry( hdb
, "'one', 'beta'" );
3213 add_feature_components_entry( hdb
, "'one', 'gamma'" );
3214 add_feature_components_entry( hdb
, "'one', 'theta'" );
3215 add_feature_components_entry( hdb
, "'two', 'delta'" );
3216 add_feature_components_entry( hdb
, "'two', 'epsilon'" );
3217 add_feature_components_entry( hdb
, "'two', 'zeta'" );
3218 add_feature_components_entry( hdb
, "'two', 'iota'" );
3219 add_feature_components_entry( hdb
, "'three', 'eta'" );
3220 add_feature_components_entry( hdb
, "'four', 'eta'" );
3221 add_feature_components_entry( hdb
, "'five', 'eta'" );
3222 add_feature_components_entry( hdb
, "'six', 'lambda'" );
3223 add_feature_components_entry( hdb
, "'six', 'mu'" );
3224 add_feature_components_entry( hdb
, "'six', 'nu'" );
3225 add_feature_components_entry( hdb
, "'six', 'xi'" );
3226 add_feature_components_entry( hdb
, "'seven', 'omicron'" );
3227 add_feature_components_entry( hdb
, "'seven', 'pi'" );
3228 add_feature_components_entry( hdb
, "'seven', 'rho'" );
3229 add_feature_components_entry( hdb
, "'seven', 'sigma'" );
3230 add_feature_components_entry( hdb
, "'eight', 'tau'" );
3231 add_feature_components_entry( hdb
, "'nine', 'phi'" );
3232 add_feature_components_entry( hdb
, "'ten', 'chi'" );
3233 add_feature_components_entry( hdb
, "'eleven', 'psi'" );
3234 add_feature_components_entry( hdb
, "'twelve', 'upsilon'" );
3235 add_feature_components_entry( hdb
, "'thirteen', 'upsilon'" );
3237 create_file_table( hdb
);
3238 add_file_entry( hdb
, "'alpha_file', 'alpha', 'alpha.txt', 100, '', '1033', 8192, 1" );
3239 add_file_entry( hdb
, "'beta_file', 'beta', 'beta.txt', 0, '', '1033', 8192, 1" );
3240 add_file_entry( hdb
, "'gamma_file', 'gamma', 'gamma.txt', 0, '', '1033', 8192, 1" );
3241 add_file_entry( hdb
, "'theta_file', 'theta', 'theta.txt', 0, '', '1033', 8192, 1" );
3242 add_file_entry( hdb
, "'delta_file', 'delta', 'delta.txt', 0, '', '1033', 8192, 1" );
3243 add_file_entry( hdb
, "'epsilon_file', 'epsilon', 'epsilon.txt', 0, '', '1033', 8192, 1" );
3244 add_file_entry( hdb
, "'zeta_file', 'zeta', 'zeta.txt', 0, '', '1033', 8192, 1" );
3245 add_file_entry( hdb
, "'iota_file', 'iota', 'iota.txt', 0, '', '1033', 8192, 1" );
3247 /* compressed file */
3248 add_file_entry( hdb
, "'eta_file', 'eta', 'eta.txt', 0, '', '1033', 16384, 1" );
3250 add_file_entry( hdb
, "'kappa_file', 'kappa', 'kappa.txt', 0, '', '1033', 8192, 1" );
3251 add_file_entry( hdb
, "'lambda_file', 'lambda', 'lambda.txt', 100, '', '1033', 8192, 1" );
3252 add_file_entry( hdb
, "'mu_file', 'mu', 'mu.txt', 100, '', '1033', 8192, 1" );
3253 add_file_entry( hdb
, "'nu_file', 'nu', 'nu.txt', 100, '', '1033', 8192, 1" );
3254 add_file_entry( hdb
, "'xi_file', 'xi', 'xi.txt', 100, '', '1033', 8192, 1" );
3255 add_file_entry( hdb
, "'omicron_file', 'omicron', 'omicron.txt', 100, '', '1033', 8192, 1" );
3256 add_file_entry( hdb
, "'pi_file', 'pi', 'pi.txt', 100, '', '1033', 8192, 1" );
3257 add_file_entry( hdb
, "'rho_file', 'rho', 'rho.txt', 100, '', '1033', 8192, 1" );
3258 add_file_entry( hdb
, "'sigma_file', 'sigma', 'sigma.txt', 100, '', '1033', 8192, 1" );
3259 add_file_entry( hdb
, "'tau_file', 'tau', 'tau.txt', 100, '', '1033', 8192, 1" );
3260 add_file_entry( hdb
, "'phi_file', 'phi', 'phi.txt', 100, '', '1033', 8192, 1" );
3261 add_file_entry( hdb
, "'chi_file', 'chi', 'chi.txt', 100, '', '1033', 8192, 1" );
3262 add_file_entry( hdb
, "'psi_file', 'psi', 'psi.txt', 100, '', '1033', 8192, 1" );
3263 add_file_entry( hdb
, "'upsilon_file', 'upsilon', 'upsilon.txt', 0, '', '1033', 16384, 1" );
3265 MsiDatabaseCommit(hdb
);
3267 /* these properties must not be in the saved msi file */
3268 add_property_entry( hdb
, "'ADDLOCAL', 'one,four'");
3269 add_property_entry( hdb
, "'ADDSOURCE', 'two,three'");
3270 add_property_entry( hdb
, "'REMOVE', 'six,seven'");
3271 add_property_entry( hdb
, "'REINSTALL', 'eight,nine,ten'");
3272 add_property_entry( hdb
, "'REINSTALLMODE', 'omus'");
3274 r
= package_from_db( hdb
, &hpkg
);
3275 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
3277 skip("Not enough rights to perform tests\n");
3278 DeleteFileA(msifile
);
3281 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
3283 MsiCloseHandle(hdb
);
3285 CopyFileA(msifile
, msifile2
, FALSE
);
3286 CopyFileA(msifile
, msifile3
, FALSE
);
3287 CopyFileA(msifile
, msifile4
, FALSE
);
3289 test_feature_states( __LINE__
, hpkg
, "one", ERROR_UNKNOWN_FEATURE
, 0, 0, FALSE
);
3290 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_UNKNOWN_COMPONENT
, 0, 0, FALSE
);
3292 r
= MsiDoActionA( hpkg
, "CostInitialize");
3293 ok( r
== ERROR_SUCCESS
, "cost init failed\n");
3295 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3296 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3298 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
3300 r
= MsiDoActionA( hpkg
, "FileCost");
3301 ok( r
== ERROR_SUCCESS
, "file cost failed\n");
3303 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3304 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3306 r
= MsiDoActionA( hpkg
, "CostFinalize");
3307 ok( r
== ERROR_SUCCESS
, "cost finalize failed: %d\n", r
);
3309 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
3310 test_feature_states( __LINE__
, hpkg
, "two", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_SOURCE
, FALSE
);
3311 test_feature_states( __LINE__
, hpkg
, "three", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
3312 test_feature_states( __LINE__
, hpkg
, "four", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
3313 test_feature_states( __LINE__
, hpkg
, "five", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3314 test_feature_states( __LINE__
, hpkg
, "six", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3315 test_feature_states( __LINE__
, hpkg
, "seven", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3316 test_feature_states( __LINE__
, hpkg
, "eight", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3317 test_feature_states( __LINE__
, hpkg
, "nine", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3318 test_feature_states( __LINE__
, hpkg
, "ten", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3319 test_feature_states( __LINE__
, hpkg
, "eleven", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3320 test_feature_states( __LINE__
, hpkg
, "twelve", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3321 test_feature_states( __LINE__
, hpkg
, "thirteen", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3323 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
3324 test_component_states( __LINE__
, hpkg
, "beta", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_SOURCE
, FALSE
);
3325 test_component_states( __LINE__
, hpkg
, "gamma", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
3326 test_component_states( __LINE__
, hpkg
, "theta", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
3327 test_component_states( __LINE__
, hpkg
, "delta", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
3328 test_component_states( __LINE__
, hpkg
, "epsilon", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_SOURCE
, FALSE
);
3329 test_component_states( __LINE__
, hpkg
, "zeta", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_SOURCE
, FALSE
);
3330 test_component_states( __LINE__
, hpkg
, "iota", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
3331 test_component_states( __LINE__
, hpkg
, "eta", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
3332 test_component_states( __LINE__
, hpkg
, "kappa", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3333 test_component_states( __LINE__
, hpkg
, "lambda", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3334 test_component_states( __LINE__
, hpkg
, "mu", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3335 test_component_states( __LINE__
, hpkg
, "nu", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3336 test_component_states( __LINE__
, hpkg
, "xi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3337 test_component_states( __LINE__
, hpkg
, "omicron", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3338 test_component_states( __LINE__
, hpkg
, "pi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3339 test_component_states( __LINE__
, hpkg
, "rho", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3340 test_component_states( __LINE__
, hpkg
, "sigma", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3341 test_component_states( __LINE__
, hpkg
, "tau", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3342 test_component_states( __LINE__
, hpkg
, "phi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3343 test_component_states( __LINE__
, hpkg
, "chi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3344 test_component_states( __LINE__
, hpkg
, "psi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3345 test_component_states( __LINE__
, hpkg
, "upsilon", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3347 MsiCloseHandle( hpkg
);
3349 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
3351 /* publish the features and components */
3352 r
= MsiInstallProductA(msifile
, "ADDLOCAL=one,four ADDSOURCE=two,three REMOVE=six,seven REINSTALL=eight,nine,ten");
3353 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3355 r
= MsiOpenDatabaseW(msifileW
, MSIDBOPEN_DIRECT
, &hdb
);
3356 ok(r
== ERROR_SUCCESS
, "failed to open database: %d\n", r
);
3358 /* these properties must not be in the saved msi file */
3359 add_property_entry( hdb
, "'ADDLOCAL', 'one,four'");
3360 add_property_entry( hdb
, "'ADDSOURCE', 'two,three'");
3361 add_property_entry( hdb
, "'REMOVE', 'six,seven'");
3362 add_property_entry( hdb
, "'REINSTALL', 'eight,nine,ten'");
3364 r
= package_from_db( hdb
, &hpkg
);
3365 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
3367 MsiCloseHandle(hdb
);
3369 test_feature_states( __LINE__
, hpkg
, "one", ERROR_UNKNOWN_FEATURE
, 0, 0, FALSE
);
3370 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_UNKNOWN_COMPONENT
, 0, 0, FALSE
);
3372 r
= MsiDoActionA( hpkg
, "CostInitialize");
3373 ok( r
== ERROR_SUCCESS
, "cost init failed\n");
3375 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3376 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3378 r
= MsiDoActionA( hpkg
, "FileCost");
3379 ok( r
== ERROR_SUCCESS
, "file cost failed\n");
3381 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3382 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3384 r
= MsiDoActionA( hpkg
, "CostFinalize");
3385 ok( r
== ERROR_SUCCESS
, "cost finalize failed: %d\n", r
);
3387 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_LOCAL
, FALSE
);
3388 test_feature_states( __LINE__
, hpkg
, "two", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3389 test_feature_states( __LINE__
, hpkg
, "three", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3390 test_feature_states( __LINE__
, hpkg
, "four", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3391 test_feature_states( __LINE__
, hpkg
, "five", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3392 test_feature_states( __LINE__
, hpkg
, "six", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3393 test_feature_states( __LINE__
, hpkg
, "seven", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3394 test_feature_states( __LINE__
, hpkg
, "eight", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3395 test_feature_states( __LINE__
, hpkg
, "nine", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3396 test_feature_states( __LINE__
, hpkg
, "ten", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3397 test_feature_states( __LINE__
, hpkg
, "eleven", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3398 test_feature_states( __LINE__
, hpkg
, "twelve", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3399 test_feature_states( __LINE__
, hpkg
, "thirteen", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3401 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3402 test_component_states( __LINE__
, hpkg
, "beta", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3403 test_component_states( __LINE__
, hpkg
, "gamma", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3404 test_component_states( __LINE__
, hpkg
, "theta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3405 test_component_states( __LINE__
, hpkg
, "delta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3406 test_component_states( __LINE__
, hpkg
, "epsilon", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3407 test_component_states( __LINE__
, hpkg
, "zeta", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3408 test_component_states( __LINE__
, hpkg
, "iota", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3409 test_component_states( __LINE__
, hpkg
, "eta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3410 test_component_states( __LINE__
, hpkg
, "kappa", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3411 test_component_states( __LINE__
, hpkg
, "lambda", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3412 test_component_states( __LINE__
, hpkg
, "mu", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3413 test_component_states( __LINE__
, hpkg
, "nu", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3414 test_component_states( __LINE__
, hpkg
, "xi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3415 test_component_states( __LINE__
, hpkg
, "omicron", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3416 test_component_states( __LINE__
, hpkg
, "pi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3417 test_component_states( __LINE__
, hpkg
, "rho", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3418 test_component_states( __LINE__
, hpkg
, "sigma", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3419 test_component_states( __LINE__
, hpkg
, "tau", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3420 test_component_states( __LINE__
, hpkg
, "phi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3421 test_component_states( __LINE__
, hpkg
, "chi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3422 test_component_states( __LINE__
, hpkg
, "psi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3423 test_component_states( __LINE__
, hpkg
, "upsilon", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3425 MsiCloseHandle(hpkg
);
3427 /* uninstall the product */
3428 r
= MsiInstallProductA(msifile
, "REMOVE=ALL");
3429 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3431 state
= MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "five");
3432 ok(state
== INSTALLSTATE_UNKNOWN
, "state = %d\n", state
);
3433 state
= MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "twelve");
3434 ok(state
== INSTALLSTATE_UNKNOWN
, "state = %d\n", state
);
3436 /* all features installed locally */
3437 r
= MsiInstallProductA(msifile2
, "ADDLOCAL=ALL");
3438 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3440 state
= MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "five");
3441 ok(state
== INSTALLSTATE_UNKNOWN
, "state = %d\n", state
);
3442 state
= MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "twelve");
3443 ok(state
== INSTALLSTATE_LOCAL
, "state = %d\n", state
);
3445 r
= MsiOpenDatabaseW(msifile2W
, MSIDBOPEN_DIRECT
, &hdb
);
3446 ok(r
== ERROR_SUCCESS
, "failed to open database: %d\n", r
);
3448 /* these properties must not be in the saved msi file */
3449 add_property_entry( hdb
, "'ADDLOCAL', 'one,two,three,four,five,six,seven,eight,nine,ten,twelve'");
3451 r
= package_from_db( hdb
, &hpkg
);
3452 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
3454 test_feature_states( __LINE__
, hpkg
, "one", ERROR_UNKNOWN_FEATURE
, 0, 0, FALSE
);
3455 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_UNKNOWN_COMPONENT
, 0, 0, FALSE
);
3457 r
= MsiDoActionA( hpkg
, "CostInitialize");
3458 ok( r
== ERROR_SUCCESS
, "cost init failed\n");
3460 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3461 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3463 r
= MsiDoActionA( hpkg
, "CostFinalize");
3464 ok( r
== ERROR_SUCCESS
, "cost finalize failed: %d\n", r
);
3466 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_LOCAL
, FALSE
);
3467 test_feature_states( __LINE__
, hpkg
, "two", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_LOCAL
, FALSE
);
3468 test_feature_states( __LINE__
, hpkg
, "three", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3469 test_feature_states( __LINE__
, hpkg
, "four", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3470 test_feature_states( __LINE__
, hpkg
, "five", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3471 test_feature_states( __LINE__
, hpkg
, "six", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_LOCAL
, FALSE
);
3472 test_feature_states( __LINE__
, hpkg
, "seven", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_LOCAL
, FALSE
);
3473 test_feature_states( __LINE__
, hpkg
, "eight", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, TRUE
);
3474 test_feature_states( __LINE__
, hpkg
, "nine", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, TRUE
);
3475 test_feature_states( __LINE__
, hpkg
, "ten", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, TRUE
);
3476 test_feature_states( __LINE__
, hpkg
, "eleven", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, TRUE
);
3477 test_feature_states( __LINE__
, hpkg
, "twelve", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3478 test_feature_states( __LINE__
, hpkg
, "thirteen", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_UNKNOWN
, FALSE
);
3480 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3481 test_component_states( __LINE__
, hpkg
, "beta", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3482 test_component_states( __LINE__
, hpkg
, "gamma", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3483 test_component_states( __LINE__
, hpkg
, "theta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3484 test_component_states( __LINE__
, hpkg
, "delta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3485 test_component_states( __LINE__
, hpkg
, "epsilon", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3486 test_component_states( __LINE__
, hpkg
, "zeta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3487 test_component_states( __LINE__
, hpkg
, "iota", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3488 test_component_states( __LINE__
, hpkg
, "eta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3489 test_component_states( __LINE__
, hpkg
, "kappa", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3490 test_component_states( __LINE__
, hpkg
, "lambda", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3491 test_component_states( __LINE__
, hpkg
, "mu", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3492 test_component_states( __LINE__
, hpkg
, "nu", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3493 test_component_states( __LINE__
, hpkg
, "xi", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3494 test_component_states( __LINE__
, hpkg
, "omicron", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3495 test_component_states( __LINE__
, hpkg
, "pi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3496 test_component_states( __LINE__
, hpkg
, "rho", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3497 test_component_states( __LINE__
, hpkg
, "sigma", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3498 test_component_states( __LINE__
, hpkg
, "tau", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, TRUE
);
3499 test_component_states( __LINE__
, hpkg
, "phi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, TRUE
);
3500 test_component_states( __LINE__
, hpkg
, "chi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, TRUE
);
3501 test_component_states( __LINE__
, hpkg
, "psi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3502 test_component_states( __LINE__
, hpkg
, "upsilon", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3504 MsiCloseHandle(hpkg
);
3506 /* uninstall the product */
3507 r
= MsiInstallProductA(msifile2
, "REMOVE=ALL");
3508 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3510 /* all features installed from source */
3511 r
= MsiInstallProductA(msifile3
, "ADDSOURCE=ALL");
3512 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3514 state
= MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "five");
3515 ok(state
== INSTALLSTATE_UNKNOWN
, "state = %d\n", state
);
3516 state
= MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "twelve");
3517 ok(state
== INSTALLSTATE_LOCAL
, "state = %d\n", state
);
3519 r
= MsiOpenDatabaseW(msifile3W
, MSIDBOPEN_DIRECT
, &hdb
);
3520 ok(r
== ERROR_SUCCESS
, "failed to open database: %d\n", r
);
3522 /* this property must not be in the saved msi file */
3523 add_property_entry( hdb
, "'ADDSOURCE', 'one,two,three,four,five,six,seven,eight,nine,ten'");
3525 r
= package_from_db( hdb
, &hpkg
);
3526 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
3528 test_feature_states( __LINE__
, hpkg
, "one", ERROR_UNKNOWN_FEATURE
, 0, 0, FALSE
);
3529 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_UNKNOWN_COMPONENT
, 0, 0, FALSE
);
3531 r
= MsiDoActionA( hpkg
, "CostInitialize");
3532 ok( r
== ERROR_SUCCESS
, "cost init failed\n");
3534 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3535 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3537 r
= MsiDoActionA( hpkg
, "FileCost");
3538 ok( r
== ERROR_SUCCESS
, "file cost failed\n");
3540 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3541 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3543 r
= MsiDoActionA( hpkg
, "CostFinalize");
3544 ok( r
== ERROR_SUCCESS
, "cost finalize failed: %d\n", r
);
3546 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3547 test_feature_states( __LINE__
, hpkg
, "two", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3548 test_feature_states( __LINE__
, hpkg
, "three", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3549 test_feature_states( __LINE__
, hpkg
, "four", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3550 test_feature_states( __LINE__
, hpkg
, "five", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3551 test_feature_states( __LINE__
, hpkg
, "six", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3552 test_feature_states( __LINE__
, hpkg
, "seven", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3553 test_feature_states( __LINE__
, hpkg
, "eight", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3554 test_feature_states( __LINE__
, hpkg
, "nine", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3555 test_feature_states( __LINE__
, hpkg
, "ten", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3556 test_feature_states( __LINE__
, hpkg
, "eleven", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, TRUE
);
3557 test_feature_states( __LINE__
, hpkg
, "twelve", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_UNKNOWN
, FALSE
);
3558 test_feature_states( __LINE__
, hpkg
, "thirteen", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_UNKNOWN
, FALSE
);
3560 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3561 test_component_states( __LINE__
, hpkg
, "beta", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3562 test_component_states( __LINE__
, hpkg
, "gamma", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3563 test_component_states( __LINE__
, hpkg
, "theta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3564 test_component_states( __LINE__
, hpkg
, "delta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3565 test_component_states( __LINE__
, hpkg
, "epsilon", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3566 test_component_states( __LINE__
, hpkg
, "zeta", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3567 test_component_states( __LINE__
, hpkg
, "iota", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3568 test_component_states( __LINE__
, hpkg
, "eta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3569 test_component_states( __LINE__
, hpkg
, "kappa", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3570 test_component_states( __LINE__
, hpkg
, "lambda", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3571 test_component_states( __LINE__
, hpkg
, "mu", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3572 test_component_states( __LINE__
, hpkg
, "nu", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3573 test_component_states( __LINE__
, hpkg
, "xi", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3574 test_component_states( __LINE__
, hpkg
, "omicron", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3575 test_component_states( __LINE__
, hpkg
, "pi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3576 test_component_states( __LINE__
, hpkg
, "rho", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3577 test_component_states( __LINE__
, hpkg
, "sigma", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3578 test_component_states( __LINE__
, hpkg
, "tau", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3579 test_component_states( __LINE__
, hpkg
, "phi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3580 test_component_states( __LINE__
, hpkg
, "chi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3581 test_component_states( __LINE__
, hpkg
, "psi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3582 test_component_states( __LINE__
, hpkg
, "upsilon", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3584 MsiCloseHandle(hpkg
);
3586 /* reinstall the product */
3587 r
= MsiInstallProductA(msifile3
, "REINSTALL=ALL");
3588 is_broken
= (r
== ERROR_INSTALL_FAILURE
);
3589 ok(r
== ERROR_SUCCESS
|| broken(is_broken
) /* win2k3 */, "Expected ERROR_SUCCESS, got %d\n", r
);
3591 state
= MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "five");
3592 ok(state
== INSTALLSTATE_UNKNOWN
, "state = %d\n", state
);
3593 state
= MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "twelve");
3594 ok(state
== INSTALLSTATE_LOCAL
, "state = %d\n", state
);
3596 r
= MsiOpenDatabaseW(msifile4W
, MSIDBOPEN_DIRECT
, &hdb
);
3597 ok(r
== ERROR_SUCCESS
, "failed to open database: %d\n", r
);
3599 /* this property must not be in the saved msi file */
3600 add_property_entry( hdb
, "'ADDSOURCE', 'one,two,three,four,five,six,seven,eight,nine,ten'");
3602 r
= package_from_db( hdb
, &hpkg
);
3603 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
3605 test_feature_states( __LINE__
, hpkg
, "one", ERROR_UNKNOWN_FEATURE
, 0, 0, FALSE
);
3606 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_UNKNOWN_COMPONENT
, 0, 0, FALSE
);
3608 r
= MsiDoActionA( hpkg
, "CostInitialize");
3609 ok( r
== ERROR_SUCCESS
, "cost init failed\n");
3611 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3612 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3614 r
= MsiDoActionA( hpkg
, "FileCost");
3615 ok( r
== ERROR_SUCCESS
, "file cost failed\n");
3617 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3618 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3620 r
= MsiDoActionA( hpkg
, "CostFinalize");
3621 ok( r
== ERROR_SUCCESS
, "cost finalize failed: %d\n", r
);
3623 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3624 test_feature_states( __LINE__
, hpkg
, "two", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3625 test_feature_states( __LINE__
, hpkg
, "three", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3626 test_feature_states( __LINE__
, hpkg
, "four", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3627 test_feature_states( __LINE__
, hpkg
, "five", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3628 test_feature_states( __LINE__
, hpkg
, "six", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3629 test_feature_states( __LINE__
, hpkg
, "seven", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3630 test_feature_states( __LINE__
, hpkg
, "eight", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3631 test_feature_states( __LINE__
, hpkg
, "nine", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3632 test_feature_states( __LINE__
, hpkg
, "ten", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3633 test_feature_states( __LINE__
, hpkg
, "eleven", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, TRUE
);
3634 test_feature_states( __LINE__
, hpkg
, "twelve", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_UNKNOWN
, FALSE
);
3635 test_feature_states( __LINE__
, hpkg
, "thirteen", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_UNKNOWN
, FALSE
);
3637 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3638 test_component_states( __LINE__
, hpkg
, "beta", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3639 test_component_states( __LINE__
, hpkg
, "gamma", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3640 test_component_states( __LINE__
, hpkg
, "theta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3641 test_component_states( __LINE__
, hpkg
, "delta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3642 test_component_states( __LINE__
, hpkg
, "epsilon", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3643 test_component_states( __LINE__
, hpkg
, "zeta", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3644 test_component_states( __LINE__
, hpkg
, "iota", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3645 test_component_states( __LINE__
, hpkg
, "eta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3646 test_component_states( __LINE__
, hpkg
, "kappa", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3647 test_component_states( __LINE__
, hpkg
, "lambda", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3648 test_component_states( __LINE__
, hpkg
, "mu", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3649 test_component_states( __LINE__
, hpkg
, "nu", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3650 test_component_states( __LINE__
, hpkg
, "xi", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3651 test_component_states( __LINE__
, hpkg
, "omicron", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3652 test_component_states( __LINE__
, hpkg
, "pi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3653 test_component_states( __LINE__
, hpkg
, "rho", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3654 test_component_states( __LINE__
, hpkg
, "sigma", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3655 test_component_states( __LINE__
, hpkg
, "tau", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3656 test_component_states( __LINE__
, hpkg
, "phi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3657 test_component_states( __LINE__
, hpkg
, "chi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3658 test_component_states( __LINE__
, hpkg
, "psi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3659 test_component_states( __LINE__
, hpkg
, "upsilon", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3661 MsiCloseHandle(hpkg
);
3663 /* test source only install */
3664 r
= MsiInstallProductA(msifile
, "REMOVE=ALL");
3665 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3666 state
= MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "one");
3667 ok(state
== INSTALLSTATE_UNKNOWN
, "state = %d\n", state
);
3668 state
= MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "two");
3669 ok(state
== INSTALLSTATE_UNKNOWN
, "state = %d\n", state
);
3671 r
= MsiInstallProductA(msifile
, "ADDSOURCE=one");
3672 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3673 state
= MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "one");
3674 ok(state
== INSTALLSTATE_SOURCE
, "state = %d\n", state
);
3675 state
= MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "two");
3676 ok(state
== INSTALLSTATE_ABSENT
, "state = %d\n", state
);
3678 /* no arguments test */
3679 cache_file_name_len
= sizeof(msi_cache_file
);
3680 r
= MsiGetProductInfoA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}",
3681 INSTALLPROPERTY_LOCALPACKAGEA
, msi_cache_file
, &cache_file_name_len
);
3682 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3683 r
= MsiOpenDatabaseA(msi_cache_file
, (const char*)MSIDBOPEN_DIRECT
, &hdb
);
3684 ok(r
== ERROR_SUCCESS
, "failed to open database: %d\n", r
);
3686 create_custom_action_table( hdb
);
3687 add_custom_action_entry( hdb
, "'ConditionCheck1', 19, '', 'Condition check failed (1)'" );
3688 add_custom_action_entry( hdb
, "'ConditionCheck2', 19, '', 'Condition check failed (2)'" );
3689 add_custom_action_entry( hdb
, "'ConditionCheck3', 19, '', 'Condition check failed (3)'" );
3690 add_custom_action_entry( hdb
, "'ConditionCheck4', 19, '', 'Condition check failed (4)'" );
3691 add_custom_action_entry( hdb
, "'ConditionCheck5', 19, '', 'Condition check failed (5)'" );
3692 add_custom_action_entry( hdb
, "'ConditionCheck6', 19, '', 'Condition check failed (6)'" );
3693 add_custom_action_entry( hdb
, "'ConditionCheck7', 19, '', 'Condition check failed (7)'" );
3694 add_custom_action_entry( hdb
, "'ConditionCheck8', 19, '', 'Condition check failed (8)'" );
3696 add_install_execute_sequence_entry( hdb
, "'ConditionCheck1', 'REINSTALL', '798'" );
3697 add_install_execute_sequence_entry( hdb
, "'ConditionCheck2', 'NOT REMOVE AND Preselected', '799'" );
3698 add_install_execute_sequence_entry( hdb
, "'ConditionCheck3', 'REINSTALL', '6598'" );
3699 add_install_execute_sequence_entry( hdb
, "'ConditionCheck4', 'NOT REMOVE AND Preselected', '6599'" );
3700 add_install_execute_sequence_entry( hdb
, "'ConditionCheck5', 'REINSTALL', '6601'" );
3701 add_install_execute_sequence_entry( hdb
, "'ConditionCheck6', 'NOT REMOVE AND Preselected', '6601'" );
3702 /* Add "one" feature action tests */
3703 add_install_execute_sequence_entry( hdb
, "'ConditionCheck7', 'NOT REMOVE AND NOT(&one=-1)', '1501'" );
3704 add_install_execute_sequence_entry( hdb
, "'ConditionCheck8', 'NOT REMOVE AND NOT(&one=-1)', '6602'" );
3705 r
= MsiDatabaseCommit(hdb
);
3706 ok(r
== ERROR_SUCCESS
, "MsiDatabaseCommit failed: %d\n", r
);
3707 r
= package_from_db( hdb
, &hpkg
);
3708 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
3709 MsiCloseHandle(hdb
);
3711 test_feature_states( __LINE__
, hpkg
, "one", ERROR_UNKNOWN_FEATURE
, 0, 0, FALSE
);
3712 test_feature_states( __LINE__
, hpkg
, "two", ERROR_UNKNOWN_FEATURE
, 0, 0, FALSE
);
3713 r
= MsiDoActionA( hpkg
, "CostInitialize");
3714 ok( r
== ERROR_SUCCESS
, "CostInitialize failed\n");
3715 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3716 test_feature_states( __LINE__
, hpkg
, "two", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3718 r
= MsiDoActionA( hpkg
, "FileCost");
3719 ok( r
== ERROR_SUCCESS
, "FileCost failed\n");
3720 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3721 test_feature_states( __LINE__
, hpkg
, "two", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3723 r
= MsiDoActionA( hpkg
, "CostFinalize");
3724 ok( r
== ERROR_SUCCESS
, "CostFinalize failed\n");
3725 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3726 test_feature_states( __LINE__
, hpkg
, "two", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3727 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3728 test_component_states( __LINE__
, hpkg
, "beta", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3729 test_component_states( __LINE__
, hpkg
, "gamma", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3730 test_component_states( __LINE__
, hpkg
, "theta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3731 test_component_states( __LINE__
, hpkg
, "delta", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3732 test_component_states( __LINE__
, hpkg
, "epsilon", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3733 test_component_states( __LINE__
, hpkg
, "zeta", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3734 test_component_states( __LINE__
, hpkg
, "iota", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3735 test_component_states( __LINE__
, hpkg
, "eta", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3736 test_component_states( __LINE__
, hpkg
, "kappa", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3737 test_component_states( __LINE__
, hpkg
, "lambda", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3738 test_component_states( __LINE__
, hpkg
, "mu", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3739 test_component_states( __LINE__
, hpkg
, "nu", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3740 test_component_states( __LINE__
, hpkg
, "xi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3741 test_component_states( __LINE__
, hpkg
, "omicron", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3742 test_component_states( __LINE__
, hpkg
, "pi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3743 test_component_states( __LINE__
, hpkg
, "rho", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3744 test_component_states( __LINE__
, hpkg
, "sigma", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3745 test_component_states( __LINE__
, hpkg
, "tau", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3746 test_component_states( __LINE__
, hpkg
, "phi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3747 test_component_states( __LINE__
, hpkg
, "chi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3748 test_component_states( __LINE__
, hpkg
, "psi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3749 test_component_states( __LINE__
, hpkg
, "upsilon", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3751 r
= MsiDoActionA( hpkg
, "InstallValidate");
3752 ok( r
== ERROR_SUCCESS
, "InstallValidate failed %d\n", r
);
3753 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3754 test_feature_states( __LINE__
, hpkg
, "two", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3755 MsiCloseHandle( hpkg
);
3757 r
= MsiInstallProductA(msifile
, "");
3758 ok(r
== ERROR_SUCCESS
|| (is_broken
&& r
== ERROR_INSTALL_FAILURE
) /* win2k3 */,
3759 "Expected ERROR_SUCCESS, got %d\n", r
);
3760 state
= MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "one");
3761 ok(state
== INSTALLSTATE_SOURCE
, "state = %d\n", state
);
3762 state
= MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "two");
3763 ok(state
== INSTALLSTATE_ABSENT
, "state = %d\n", state
);
3765 /* uninstall the product */
3766 r
= MsiInstallProductA(msifile4
, "REMOVE=ALL");
3767 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3769 DeleteFileA(msifile
);
3770 DeleteFileA(msifile2
);
3771 DeleteFileA(msifile3
);
3772 DeleteFileA(msifile4
);
3775 static void test_getproperty(void)
3777 MSIHANDLE hPackage
= 0;
3779 static CHAR empty
[] = "";
3783 r
= package_from_db(create_package_db(), &hPackage
);
3784 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
3786 skip("Not enough rights to perform tests\n");
3787 DeleteFileA(msifile
);
3790 ok( r
== ERROR_SUCCESS
, "Failed to create package %u\n", r
);
3792 /* set the property */
3793 r
= MsiSetPropertyA(hPackage
, "Name", "Value");
3794 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3796 /* retrieve the size, NULL pointer */
3798 r
= MsiGetPropertyA(hPackage
, "Name", NULL
, &size
);
3799 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3800 ok( size
== 5, "Expected 5, got %d\n", size
);
3802 /* retrieve the size, empty string */
3804 r
= MsiGetPropertyA(hPackage
, "Name", empty
, &size
);
3805 ok( r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
3806 ok( size
== 5, "Expected 5, got %d\n", size
);
3808 /* don't change size */
3809 r
= MsiGetPropertyA(hPackage
, "Name", prop
, &size
);
3810 ok( r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
3811 ok( size
== 5, "Expected 5, got %d\n", size
);
3812 ok( !lstrcmpA(prop
, "Valu"), "Expected Valu, got %s\n", prop
);
3814 /* increase the size by 1 */
3816 r
= MsiGetPropertyA(hPackage
, "Name", prop
, &size
);
3817 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3818 ok( size
== 5, "Expected 5, got %d\n", size
);
3819 ok( !lstrcmpA(prop
, "Value"), "Expected Value, got %s\n", prop
);
3821 r
= MsiCloseHandle( hPackage
);
3822 ok( r
== ERROR_SUCCESS
, "Failed to close package\n" );
3823 DeleteFileA(msifile
);
3826 static void test_removefiles(void)
3831 INSTALLSTATE installed
, action
;
3833 hdb
= create_package_db();
3834 ok ( hdb
, "failed to create package database\n" );
3836 add_directory_entry( hdb
, "'TARGETDIR', '', 'SourceDir'");
3838 create_feature_table( hdb
);
3839 add_feature_entry( hdb
, "'one', '', '', '', 2, 1, '', 0" );
3841 create_component_table( hdb
);
3842 add_component_entry( hdb
, "'hydrogen', '', 'TARGETDIR', 0, '', 'hydrogen_file'" );
3843 add_component_entry( hdb
, "'helium', '', 'TARGETDIR', 0, '', 'helium_file'" );
3844 add_component_entry( hdb
, "'lithium', '', 'TARGETDIR', 0, '', 'lithium_file'" );
3845 add_component_entry( hdb
, "'beryllium', '', 'TARGETDIR', 0, '', 'beryllium_file'" );
3846 add_component_entry( hdb
, "'boron', '', 'TARGETDIR', 0, '', 'boron_file'" );
3847 add_component_entry( hdb
, "'carbon', '', 'TARGETDIR', 0, '', 'carbon_file'" );
3848 add_component_entry( hdb
, "'oxygen', '', 'TARGETDIR', 0, '0', 'oxygen_file'" );
3850 create_feature_components_table( hdb
);
3851 add_feature_components_entry( hdb
, "'one', 'hydrogen'" );
3852 add_feature_components_entry( hdb
, "'one', 'helium'" );
3853 add_feature_components_entry( hdb
, "'one', 'lithium'" );
3854 add_feature_components_entry( hdb
, "'one', 'beryllium'" );
3855 add_feature_components_entry( hdb
, "'one', 'boron'" );
3856 add_feature_components_entry( hdb
, "'one', 'carbon'" );
3857 add_feature_components_entry( hdb
, "'one', 'oxygen'" );
3859 create_file_table( hdb
);
3860 add_file_entry( hdb
, "'hydrogen_file', 'hydrogen', 'hydrogen.txt', 0, '', '1033', 8192, 1" );
3861 add_file_entry( hdb
, "'helium_file', 'helium', 'helium.txt', 0, '', '1033', 8192, 1" );
3862 add_file_entry( hdb
, "'lithium_file', 'lithium', 'lithium.txt', 0, '', '1033', 8192, 1" );
3863 add_file_entry( hdb
, "'beryllium_file', 'beryllium', 'beryllium.txt', 0, '', '1033', 16384, 1" );
3864 add_file_entry( hdb
, "'boron_file', 'boron', 'boron.txt', 0, '', '1033', 16384, 1" );
3865 add_file_entry( hdb
, "'carbon_file', 'carbon', 'carbon.txt', 0, '', '1033', 16384, 1" );
3866 add_file_entry( hdb
, "'oxygen_file', 'oxygen', 'oxygen.txt', 0, '', '1033', 16384, 1" );
3868 create_remove_file_table( hdb
);
3870 r
= package_from_db( hdb
, &hpkg
);
3871 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
3873 skip("Not enough rights to perform tests\n");
3874 DeleteFileA(msifile
);
3877 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
3879 MsiCloseHandle( hdb
);
3881 create_test_file( "hydrogen.txt" );
3882 create_test_file( "helium.txt" );
3883 create_test_file( "lithium.txt" );
3884 create_test_file( "beryllium.txt" );
3885 create_test_file( "boron.txt" );
3886 create_test_file( "carbon.txt" );
3887 create_test_file( "oxygen.txt" );
3889 r
= MsiSetPropertyA( hpkg
, "TARGETDIR", CURR_DIR
);
3890 ok( r
== ERROR_SUCCESS
, "set property failed\n");
3892 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
3894 r
= MsiGetComponentStateA( hpkg
, "oxygen", &installed
, &action
);
3895 ok( r
== ERROR_UNKNOWN_COMPONENT
, "expected ERROR_UNKNOWN_COMPONENT, got %u\n", r
);
3897 r
= MsiDoActionA( hpkg
, "CostInitialize");
3898 ok( r
== ERROR_SUCCESS
, "cost init failed\n");
3900 r
= MsiDoActionA( hpkg
, "FileCost");
3901 ok( r
== ERROR_SUCCESS
, "file cost failed\n");
3903 installed
= action
= 0xdeadbeef;
3904 r
= MsiGetComponentStateA( hpkg
, "oxygen", &installed
, &action
);
3905 ok( r
== ERROR_SUCCESS
, "failed to get component state %u\n", r
);
3906 ok( installed
== INSTALLSTATE_UNKNOWN
, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed
);
3907 ok( action
== INSTALLSTATE_UNKNOWN
, "expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
3909 r
= MsiDoActionA( hpkg
, "CostFinalize");
3910 ok( r
== ERROR_SUCCESS
, "cost finalize failed\n");
3912 r
= MsiDoActionA( hpkg
, "InstallValidate");
3913 ok( r
== ERROR_SUCCESS
, "install validate failed\n");
3915 r
= MsiSetComponentStateA( hpkg
, "hydrogen", INSTALLSTATE_ABSENT
);
3916 ok( r
== ERROR_SUCCESS
, "failed to set component state: %d\n", r
);
3918 installed
= action
= 0xdeadbeef;
3919 r
= MsiGetComponentStateA( hpkg
, "hydrogen", &installed
, &action
);
3920 ok( r
== ERROR_SUCCESS
, "failed to get component state %u\n", r
);
3921 ok( installed
== INSTALLSTATE_UNKNOWN
, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed
);
3922 todo_wine
ok( action
== INSTALLSTATE_UNKNOWN
, "expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
3924 r
= MsiSetComponentStateA( hpkg
, "helium", INSTALLSTATE_LOCAL
);
3925 ok( r
== ERROR_SUCCESS
, "failed to set component state: %d\n", r
);
3927 r
= MsiSetComponentStateA( hpkg
, "lithium", INSTALLSTATE_SOURCE
);
3928 ok( r
== ERROR_SUCCESS
, "failed to set component state: %d\n", r
);
3930 r
= MsiSetComponentStateA( hpkg
, "beryllium", INSTALLSTATE_ABSENT
);
3931 ok( r
== ERROR_SUCCESS
, "failed to set component state: %d\n", r
);
3933 r
= MsiSetComponentStateA( hpkg
, "boron", INSTALLSTATE_LOCAL
);
3934 ok( r
== ERROR_SUCCESS
, "failed to set component state: %d\n", r
);
3936 r
= MsiSetComponentStateA( hpkg
, "carbon", INSTALLSTATE_SOURCE
);
3937 ok( r
== ERROR_SUCCESS
, "failed to set component state: %d\n", r
);
3939 installed
= action
= 0xdeadbeef;
3940 r
= MsiGetComponentStateA( hpkg
, "oxygen", &installed
, &action
);
3941 ok( r
== ERROR_SUCCESS
, "failed to get component state %u\n", r
);
3942 ok( installed
== INSTALLSTATE_UNKNOWN
, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed
);
3943 ok( action
== INSTALLSTATE_UNKNOWN
, "expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
3945 r
= MsiSetComponentStateA( hpkg
, "oxygen", INSTALLSTATE_ABSENT
);
3946 ok( r
== ERROR_SUCCESS
, "failed to set component state: %d\n", r
);
3948 installed
= action
= 0xdeadbeef;
3949 r
= MsiGetComponentStateA( hpkg
, "oxygen", &installed
, &action
);
3950 ok( r
== ERROR_SUCCESS
, "failed to get component state %u\n", r
);
3951 ok( installed
== INSTALLSTATE_UNKNOWN
, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed
);
3952 ok( action
== INSTALLSTATE_UNKNOWN
, "expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
3954 r
= MsiDoActionA( hpkg
, "RemoveFiles");
3955 ok( r
== ERROR_SUCCESS
, "remove files failed\n");
3957 installed
= action
= 0xdeadbeef;
3958 r
= MsiGetComponentStateA( hpkg
, "oxygen", &installed
, &action
);
3959 ok( r
== ERROR_SUCCESS
, "failed to get component state %u\n", r
);
3960 ok( installed
== INSTALLSTATE_UNKNOWN
, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed
);
3961 ok( action
== INSTALLSTATE_UNKNOWN
, "expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
3963 ok(DeleteFileA("hydrogen.txt"), "Expected hydrogen.txt to exist\n");
3964 ok(DeleteFileA("lithium.txt"), "Expected lithium.txt to exist\n");
3965 ok(DeleteFileA("beryllium.txt"), "Expected beryllium.txt to exist\n");
3966 ok(DeleteFileA("carbon.txt"), "Expected carbon.txt to exist\n");
3967 ok(DeleteFileA("helium.txt"), "Expected helium.txt to exist\n");
3968 ok(DeleteFileA("boron.txt"), "Expected boron.txt to exist\n");
3969 ok(DeleteFileA("oxygen.txt"), "Expected oxygen.txt to exist\n");
3971 MsiCloseHandle( hpkg
);
3972 DeleteFileA(msifile
);
3975 static void test_appsearch(void)
3980 CHAR prop
[MAX_PATH
];
3983 const char reg_expand_value
[] = "%systemroot%\\system32\\notepad.exe";
3985 hdb
= create_package_db();
3986 ok ( hdb
, "failed to create package database\n" );
3988 create_appsearch_table( hdb
);
3989 add_appsearch_entry( hdb
, "'WEBBROWSERPROG', 'NewSignature1'" );
3990 add_appsearch_entry( hdb
, "'NOTEPAD', 'NewSignature2'" );
3991 add_appsearch_entry( hdb
, "'REGEXPANDVAL', 'NewSignature3'" );
3993 create_reglocator_table( hdb
);
3994 add_reglocator_entry( hdb
, "NewSignature1", 0, "htmlfile\\shell\\open\\command", "", 1 );
3996 r
= RegCreateKeyExA(HKEY_CURRENT_USER
, "Software\\Winetest_msi", 0, NULL
, 0, KEY_ALL_ACCESS
, NULL
, &hkey
, NULL
);
3997 ok( r
== ERROR_SUCCESS
, "Could not create key: %d.\n", r
);
3998 r
= RegSetValueExA(hkey
, NULL
, 0, REG_EXPAND_SZ
, (const BYTE
*)reg_expand_value
, strlen(reg_expand_value
) + 1);
3999 ok( r
== ERROR_SUCCESS
, "Could not set key value: %d.\n", r
);
4001 add_reglocator_entry( hdb
, "NewSignature3", 1, "Software\\Winetest_msi", "", 1 );
4003 create_drlocator_table( hdb
);
4004 add_drlocator_entry( hdb
, "'NewSignature2', 0, 'c:\\windows\\system32', 0" );
4006 create_signature_table( hdb
);
4007 add_signature_entry( hdb
, "'NewSignature1', 'FileName', '', '', '', '', '', '', ''" );
4008 add_signature_entry( hdb
, "'NewSignature2', 'NOTEPAD.EXE|notepad.exe', '', '', '', '', '', '', ''" );
4009 add_signature_entry( hdb
, "'NewSignature3', 'NOTEPAD.EXE|notepad.exe', '', '', '', '', '', '', ''" );
4011 r
= package_from_db( hdb
, &hpkg
);
4012 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
4014 skip("Not enough rights to perform tests\n");
4015 DeleteFileA(msifile
);
4018 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
4019 MsiCloseHandle( hdb
);
4020 if (r
!= ERROR_SUCCESS
)
4023 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
4025 r
= MsiDoActionA( hpkg
, "AppSearch" );
4026 ok( r
== ERROR_SUCCESS
, "AppSearch failed: %d\n", r
);
4028 size
= sizeof(prop
);
4029 r
= MsiGetPropertyA( hpkg
, "WEBBROWSERPROG", prop
, &size
);
4030 ok( r
== ERROR_SUCCESS
, "get property failed: %d\n", r
);
4031 ok( lstrlenA(prop
) != 0, "Expected non-zero length\n");
4033 size
= sizeof(prop
);
4034 r
= MsiGetPropertyA( hpkg
, "NOTEPAD", prop
, &size
);
4035 ok( r
== ERROR_SUCCESS
, "get property failed: %d\n", r
);
4037 size
= sizeof(prop
);
4038 r
= MsiGetPropertyA( hpkg
, "REGEXPANDVAL", prop
, &size
);
4039 ok( r
== ERROR_SUCCESS
, "get property failed: %d\n", r
);
4040 ok( lstrlenA(prop
) != 0, "Expected non-zero length\n");
4043 MsiCloseHandle( hpkg
);
4044 DeleteFileA(msifile
);
4045 RegDeleteKeyA(HKEY_CURRENT_USER
, "Software\\Winetest_msi");
4048 static void test_appsearch_complocator(void)
4050 MSIHANDLE hpkg
, hdb
;
4051 char path
[MAX_PATH
], expected
[MAX_PATH
], prop
[MAX_PATH
];
4056 if (!(usersid
= get_user_sid()))
4059 if (is_process_limited())
4061 skip("process is limited\n");
4065 create_test_file("FileName1");
4066 create_test_file("FileName4");
4067 set_component_path("FileName1", MSIINSTALLCONTEXT_MACHINE
,
4068 "{A8AE6692-96BA-4198-8399-145D7D1D0D0E}", NULL
, FALSE
);
4070 create_test_file("FileName2");
4071 set_component_path("FileName2", MSIINSTALLCONTEXT_USERUNMANAGED
,
4072 "{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}", usersid
, FALSE
);
4074 create_test_file("FileName3");
4075 set_component_path("FileName3", MSIINSTALLCONTEXT_USERMANAGED
,
4076 "{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}", usersid
, FALSE
);
4078 create_test_file("FileName5");
4079 set_component_path("FileName5", MSIINSTALLCONTEXT_MACHINE
,
4080 "{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}", NULL
, TRUE
);
4082 create_test_file("FileName6");
4083 set_component_path("FileName6", MSIINSTALLCONTEXT_MACHINE
,
4084 "{C0ECD96F-7898-4410-9667-194BD8C1B648}", NULL
, TRUE
);
4086 create_test_file("FileName7");
4087 set_component_path("FileName7", MSIINSTALLCONTEXT_MACHINE
,
4088 "{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}", NULL
, FALSE
);
4090 /* dir is FALSE, but we're pretending it's a directory */
4091 set_component_path("IDontExist\\", MSIINSTALLCONTEXT_MACHINE
,
4092 "{91B7359B-07F2-4221-AA8D-DE102BB87A5F}", NULL
, FALSE
);
4094 create_file_with_version("FileName8.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4095 set_component_path("FileName8.dll", MSIINSTALLCONTEXT_MACHINE
,
4096 "{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}", NULL
, FALSE
);
4098 create_file_with_version("FileName9.dll", MAKELONG(1, 2), MAKELONG(3, 4));
4099 set_component_path("FileName9.dll", MSIINSTALLCONTEXT_MACHINE
,
4100 "{A204DF48-7346-4635-BA2E-66247DBAC9DF}", NULL
, FALSE
);
4102 create_file_with_version("FileName10.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4103 set_component_path("FileName10.dll", MSIINSTALLCONTEXT_MACHINE
,
4104 "{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}", NULL
, FALSE
);
4106 hdb
= create_package_db();
4107 ok(hdb
, "Expected a valid database handle\n");
4109 create_appsearch_table(hdb
);
4110 add_appsearch_entry(hdb
, "'SIGPROP1', 'NewSignature1'");
4111 add_appsearch_entry(hdb
, "'SIGPROP2', 'NewSignature2'");
4112 add_appsearch_entry(hdb
, "'SIGPROP3', 'NewSignature3'");
4113 add_appsearch_entry(hdb
, "'SIGPROP4', 'NewSignature4'");
4114 add_appsearch_entry(hdb
, "'SIGPROP5', 'NewSignature5'");
4115 add_appsearch_entry(hdb
, "'SIGPROP6', 'NewSignature6'");
4116 add_appsearch_entry(hdb
, "'SIGPROP7', 'NewSignature7'");
4117 add_appsearch_entry(hdb
, "'SIGPROP8', 'NewSignature8'");
4118 add_appsearch_entry(hdb
, "'SIGPROP9', 'NewSignature9'");
4119 add_appsearch_entry(hdb
, "'SIGPROP10', 'NewSignature10'");
4120 add_appsearch_entry(hdb
, "'SIGPROP11', 'NewSignature11'");
4121 add_appsearch_entry(hdb
, "'SIGPROP12', 'NewSignature12'");
4123 create_complocator_table(hdb
);
4125 /* published component, machine, file, signature, misdbLocatorTypeFile */
4126 add_complocator_entry(hdb
, "'NewSignature1', '{A8AE6692-96BA-4198-8399-145D7D1D0D0E}', 1");
4128 /* published component, user-unmanaged, file, signature, misdbLocatorTypeFile */
4129 add_complocator_entry(hdb
, "'NewSignature2', '{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}', 1");
4131 /* published component, user-managed, file, signature, misdbLocatorTypeFile */
4132 add_complocator_entry(hdb
, "'NewSignature3', '{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}', 1");
4134 /* published component, machine, file, signature, misdbLocatorTypeDirectory */
4135 add_complocator_entry(hdb
, "'NewSignature4', '{A8AE6692-96BA-4198-8399-145D7D1D0D0E}', 0");
4137 /* published component, machine, dir, signature, misdbLocatorTypeDirectory */
4138 add_complocator_entry(hdb
, "'NewSignature5', '{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}', 0");
4140 /* published component, machine, dir, no signature, misdbLocatorTypeDirectory */
4141 add_complocator_entry(hdb
, "'NewSignature6', '{C0ECD96F-7898-4410-9667-194BD8C1B648}', 0");
4143 /* published component, machine, file, no signature, misdbLocatorTypeFile */
4144 add_complocator_entry(hdb
, "'NewSignature7', '{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}', 1");
4146 /* unpublished component, no signature, misdbLocatorTypeDir */
4147 add_complocator_entry(hdb
, "'NewSignature8', '{FB671D5B-5083-4048-90E0-481C48D8F3A5}', 0");
4149 /* published component, no signature, dir does not exist misdbLocatorTypeDir */
4150 add_complocator_entry(hdb
, "'NewSignature9', '{91B7359B-07F2-4221-AA8D-DE102BB87A5F}', 0");
4152 /* published component, signature w/ ver, misdbLocatorTypeFile */
4153 add_complocator_entry(hdb
, "'NewSignature10', '{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}', 1");
4155 /* published component, signature w/ ver, ver > max, misdbLocatorTypeFile */
4156 add_complocator_entry(hdb
, "'NewSignature11', '{A204DF48-7346-4635-BA2E-66247DBAC9DF}', 1");
4158 /* published component, signature w/ ver, sig->name ignored, misdbLocatorTypeFile */
4159 add_complocator_entry(hdb
, "'NewSignature12', '{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}', 1");
4161 create_signature_table(hdb
);
4162 add_signature_entry(hdb
, "'NewSignature1', 'FileName1', '', '', '', '', '', '', ''");
4163 add_signature_entry(hdb
, "'NewSignature2', 'FileName2', '', '', '', '', '', '', ''");
4164 add_signature_entry(hdb
, "'NewSignature3', 'FileName3', '', '', '', '', '', '', ''");
4165 add_signature_entry(hdb
, "'NewSignature4', 'FileName4', '', '', '', '', '', '', ''");
4166 add_signature_entry(hdb
, "'NewSignature5', 'FileName5', '', '', '', '', '', '', ''");
4167 add_signature_entry(hdb
, "'NewSignature10', 'FileName8.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
4168 add_signature_entry(hdb
, "'NewSignature11', 'FileName9.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
4169 add_signature_entry(hdb
, "'NewSignature12', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
4171 r
= package_from_db(hdb
, &hpkg
);
4172 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
4174 skip("Not enough rights to perform tests\n");
4177 ok(r
== ERROR_SUCCESS
, "Expected a valid package handle %u\n", r
);
4179 r
= MsiSetPropertyA(hpkg
, "SIGPROP8", "october");
4180 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4182 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
4184 r
= MsiDoActionA(hpkg
, "AppSearch");
4185 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4187 strcpy(expected
, CURR_DIR
);
4188 if (is_root(CURR_DIR
)) expected
[2] = 0;
4191 sprintf(path
, "%s\\FileName1", expected
);
4192 r
= MsiGetPropertyA(hpkg
, "SIGPROP1", prop
, &size
);
4193 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4194 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4197 sprintf(path
, "%s\\FileName2", expected
);
4198 r
= MsiGetPropertyA(hpkg
, "SIGPROP2", prop
, &size
);
4199 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4200 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4203 sprintf(path
, "%s\\FileName3", expected
);
4204 r
= MsiGetPropertyA(hpkg
, "SIGPROP3", prop
, &size
);
4205 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4206 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4209 sprintf(path
, "%s\\FileName4", expected
);
4210 r
= MsiGetPropertyA(hpkg
, "SIGPROP4", prop
, &size
);
4211 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4212 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4215 sprintf(path
, "%s\\FileName5", expected
);
4216 r
= MsiGetPropertyA(hpkg
, "SIGPROP5", prop
, &size
);
4217 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4218 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4221 sprintf(path
, "%s\\", expected
);
4222 r
= MsiGetPropertyA(hpkg
, "SIGPROP6", prop
, &size
);
4223 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4224 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4227 sprintf(path
, "%s\\", expected
);
4228 r
= MsiGetPropertyA(hpkg
, "SIGPROP7", prop
, &size
);
4229 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4230 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4233 r
= MsiGetPropertyA(hpkg
, "SIGPROP8", prop
, &size
);
4234 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4235 ok(!lstrcmpA(prop
, "october"), "Expected \"october\", got \"%s\"\n", prop
);
4238 r
= MsiGetPropertyA(hpkg
, "SIGPROP9", prop
, &size
);
4239 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4240 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4243 sprintf(path
, "%s\\FileName8.dll", expected
);
4244 r
= MsiGetPropertyA(hpkg
, "SIGPROP10", prop
, &size
);
4245 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4246 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4249 r
= MsiGetPropertyA(hpkg
, "SIGPROP11", prop
, &size
);
4250 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4251 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4254 sprintf(path
, "%s\\FileName10.dll", expected
);
4255 r
= MsiGetPropertyA(hpkg
, "SIGPROP12", prop
, &size
);
4256 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4257 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4259 delete_component_path("{A8AE6692-96BA-4198-8399-145D7D1D0D0E}",
4260 MSIINSTALLCONTEXT_MACHINE
, NULL
);
4261 delete_component_path("{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}",
4262 MSIINSTALLCONTEXT_USERUNMANAGED
, usersid
);
4263 delete_component_path("{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}",
4264 MSIINSTALLCONTEXT_USERMANAGED
, usersid
);
4265 delete_component_path("{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}",
4266 MSIINSTALLCONTEXT_MACHINE
, NULL
);
4267 delete_component_path("{C0ECD96F-7898-4410-9667-194BD8C1B648}",
4268 MSIINSTALLCONTEXT_MACHINE
, NULL
);
4269 delete_component_path("{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}",
4270 MSIINSTALLCONTEXT_MACHINE
, NULL
);
4271 delete_component_path("{91B7359B-07F2-4221-AA8D-DE102BB87A5F}",
4272 MSIINSTALLCONTEXT_MACHINE
, NULL
);
4273 delete_component_path("{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}",
4274 MSIINSTALLCONTEXT_MACHINE
, NULL
);
4275 delete_component_path("{A204DF48-7346-4635-BA2E-66247DBAC9DF}",
4276 MSIINSTALLCONTEXT_MACHINE
, NULL
);
4277 delete_component_path("{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}",
4278 MSIINSTALLCONTEXT_MACHINE
, NULL
);
4280 MsiCloseHandle(hpkg
);
4283 DeleteFileA("FileName1");
4284 DeleteFileA("FileName2");
4285 DeleteFileA("FileName3");
4286 DeleteFileA("FileName4");
4287 DeleteFileA("FileName5");
4288 DeleteFileA("FileName6");
4289 DeleteFileA("FileName7");
4290 DeleteFileA("FileName8.dll");
4291 DeleteFileA("FileName9.dll");
4292 DeleteFileA("FileName10.dll");
4293 DeleteFileA(msifile
);
4297 static void test_appsearch_reglocator(void)
4299 MSIHANDLE hpkg
, hdb
;
4300 char path
[MAX_PATH
], expected
[MAX_PATH
], prop
[MAX_PATH
];
4301 DWORD binary
[2], size
, val
;
4302 BOOL space
, version
, is_64bit
= sizeof(void *) > sizeof(int);
4303 HKEY hklm
, classes
, hkcu
, users
;
4304 LPSTR pathdata
, pathvar
, ptr
;
4310 if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
4313 DeleteFileA("test.dll");
4315 res
= RegCreateKeyA(HKEY_CLASSES_ROOT
, "Software\\Wine", &classes
);
4316 if (res
== ERROR_ACCESS_DENIED
)
4318 skip("Not enough rights to perform tests\n");
4321 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4323 res
= RegSetValueExA(classes
, "Value1", 0, REG_SZ
,
4324 (const BYTE
*)"regszdata", 10);
4325 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4327 res
= RegCreateKeyA(HKEY_CURRENT_USER
, "Software\\Wine", &hkcu
);
4328 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4330 res
= RegSetValueExA(hkcu
, "Value1", 0, REG_SZ
,
4331 (const BYTE
*)"regszdata", 10);
4332 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4335 res
= RegCreateKeyA(HKEY_USERS
, "S-1-5-18\\Software\\Wine", &users
);
4336 ok(res
== ERROR_SUCCESS
||
4337 broken(res
== ERROR_INVALID_PARAMETER
),
4338 "Expected ERROR_SUCCESS, got %d\n", res
);
4340 if (res
== ERROR_SUCCESS
)
4342 res
= RegSetValueExA(users
, "Value1", 0, REG_SZ
,
4343 (const BYTE
*)"regszdata", 10);
4344 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4347 res
= RegCreateKeyA(HKEY_LOCAL_MACHINE
, "Software\\Wine", &hklm
);
4348 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4350 res
= RegSetValueA(hklm
, NULL
, REG_SZ
, "defvalue", 8);
4351 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4353 res
= RegSetValueExA(hklm
, "Value1", 0, REG_SZ
,
4354 (const BYTE
*)"regszdata", 10);
4355 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4358 res
= RegSetValueExA(hklm
, "Value2", 0, REG_DWORD
,
4359 (const BYTE
*)&val
, sizeof(DWORD
));
4360 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4363 res
= RegSetValueExA(hklm
, "Value3", 0, REG_DWORD
,
4364 (const BYTE
*)&val
, sizeof(DWORD
));
4365 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4367 res
= RegSetValueExA(hklm
, "Value4", 0, REG_EXPAND_SZ
,
4368 (const BYTE
*)"%PATH%", 7);
4369 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4371 res
= RegSetValueExA(hklm
, "Value5", 0, REG_EXPAND_SZ
,
4372 (const BYTE
*)"my%NOVAR%", 10);
4373 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4375 res
= RegSetValueExA(hklm
, "Value6", 0, REG_MULTI_SZ
,
4376 (const BYTE
*)"one\0two\0", 9);
4377 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4379 binary
[0] = 0x1234abcd;
4380 binary
[1] = 0x567890ef;
4381 res
= RegSetValueExA(hklm
, "Value7", 0, REG_BINARY
,
4382 (const BYTE
*)binary
, sizeof(binary
));
4383 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4385 res
= RegSetValueExA(hklm
, "Value8", 0, REG_SZ
,
4386 (const BYTE
*)"#regszdata", 11);
4387 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4389 strcpy(expected
, CURR_DIR
);
4390 if (is_root(CURR_DIR
)) expected
[2] = 0;
4392 create_test_file("FileName1");
4393 sprintf(path
, "%s\\FileName1", expected
);
4394 res
= RegSetValueExA(hklm
, "Value9", 0, REG_SZ
,
4395 (const BYTE
*)path
, lstrlenA(path
) + 1);
4396 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4398 sprintf(path
, "%s\\FileName2", expected
);
4399 res
= RegSetValueExA(hklm
, "Value10", 0, REG_SZ
,
4400 (const BYTE
*)path
, lstrlenA(path
) + 1);
4401 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4403 lstrcpyA(path
, expected
);
4404 res
= RegSetValueExA(hklm
, "Value11", 0, REG_SZ
,
4405 (const BYTE
*)path
, lstrlenA(path
) + 1);
4406 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4408 res
= RegSetValueExA(hklm
, "Value12", 0, REG_SZ
,
4409 (const BYTE
*)"", 1);
4410 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4412 create_file_with_version("FileName3.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4413 sprintf(path
, "%s\\FileName3.dll", expected
);
4414 res
= RegSetValueExA(hklm
, "Value13", 0, REG_SZ
,
4415 (const BYTE
*)path
, lstrlenA(path
) + 1);
4416 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4418 create_file_with_version("FileName4.dll", MAKELONG(1, 2), MAKELONG(3, 4));
4419 sprintf(path
, "%s\\FileName4.dll", expected
);
4420 res
= RegSetValueExA(hklm
, "Value14", 0, REG_SZ
,
4421 (const BYTE
*)path
, lstrlenA(path
) + 1);
4422 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4424 create_file_with_version("FileName5.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4425 sprintf(path
, "%s\\FileName5.dll", expected
);
4426 res
= RegSetValueExA(hklm
, "Value15", 0, REG_SZ
,
4427 (const BYTE
*)path
, lstrlenA(path
) + 1);
4428 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4430 sprintf(path
, "\"%s\\FileName1\" -option", expected
);
4431 res
= RegSetValueExA(hklm
, "value16", 0, REG_SZ
,
4432 (const BYTE
*)path
, lstrlenA(path
) + 1);
4433 ok( res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", res
);
4435 space
= strchr(expected
, ' ') != NULL
;
4436 sprintf(path
, "%s\\FileName1 -option", expected
);
4437 res
= RegSetValueExA(hklm
, "value17", 0, REG_SZ
,
4438 (const BYTE
*)path
, lstrlenA(path
) + 1);
4439 ok( res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", res
);
4441 hdb
= create_package_db();
4442 ok(hdb
, "Expected a valid database handle\n");
4444 create_appsearch_table(hdb
);
4445 add_appsearch_entry(hdb
, "'SIGPROP1', 'NewSignature1'");
4446 add_appsearch_entry(hdb
, "'SIGPROP2', 'NewSignature2'");
4447 add_appsearch_entry(hdb
, "'SIGPROP3', 'NewSignature3'");
4448 add_appsearch_entry(hdb
, "'SIGPROP4', 'NewSignature4'");
4449 add_appsearch_entry(hdb
, "'SIGPROP5', 'NewSignature5'");
4450 add_appsearch_entry(hdb
, "'SIGPROP6', 'NewSignature6'");
4451 add_appsearch_entry(hdb
, "'SIGPROP7', 'NewSignature7'");
4452 add_appsearch_entry(hdb
, "'SIGPROP8', 'NewSignature8'");
4453 add_appsearch_entry(hdb
, "'SIGPROP9', 'NewSignature9'");
4454 add_appsearch_entry(hdb
, "'SIGPROP10', 'NewSignature10'");
4455 add_appsearch_entry(hdb
, "'SIGPROP11', 'NewSignature11'");
4456 add_appsearch_entry(hdb
, "'SIGPROP12', 'NewSignature12'");
4457 add_appsearch_entry(hdb
, "'SIGPROP13', 'NewSignature13'");
4458 add_appsearch_entry(hdb
, "'SIGPROP14', 'NewSignature14'");
4459 add_appsearch_entry(hdb
, "'SIGPROP15', 'NewSignature15'");
4460 add_appsearch_entry(hdb
, "'SIGPROP16', 'NewSignature16'");
4461 add_appsearch_entry(hdb
, "'SIGPROP17', 'NewSignature17'");
4462 add_appsearch_entry(hdb
, "'SIGPROP18', 'NewSignature18'");
4463 add_appsearch_entry(hdb
, "'SIGPROP19', 'NewSignature19'");
4464 add_appsearch_entry(hdb
, "'SIGPROP20', 'NewSignature20'");
4465 add_appsearch_entry(hdb
, "'SIGPROP21', 'NewSignature21'");
4466 add_appsearch_entry(hdb
, "'SIGPROP22', 'NewSignature22'");
4467 add_appsearch_entry(hdb
, "'SIGPROP23', 'NewSignature23'");
4468 add_appsearch_entry(hdb
, "'SIGPROP24', 'NewSignature24'");
4469 add_appsearch_entry(hdb
, "'SIGPROP25', 'NewSignature25'");
4470 add_appsearch_entry(hdb
, "'SIGPROP26', 'NewSignature26'");
4471 add_appsearch_entry(hdb
, "'SIGPROP27', 'NewSignature27'");
4472 add_appsearch_entry(hdb
, "'SIGPROP28', 'NewSignature28'");
4473 add_appsearch_entry(hdb
, "'SIGPROP29', 'NewSignature29'");
4474 add_appsearch_entry(hdb
, "'SIGPROP30', 'NewSignature30'");
4476 create_reglocator_table(hdb
);
4478 type
= msidbLocatorTypeRawValue
;
4480 type
|= msidbLocatorType64bit
;
4482 /* HKLM, msidbLocatorTypeRawValue, REG_SZ */
4483 add_reglocator_entry(hdb
, "NewSignature1", 2, "Software\\Wine", "Value1", type
);
4485 /* HKLM, msidbLocatorTypeRawValue, positive DWORD */
4486 add_reglocator_entry(hdb
, "NewSignature2", 2, "Software\\Wine", "Value2", type
);
4488 /* HKLM, msidbLocatorTypeRawValue, negative DWORD */
4489 add_reglocator_entry(hdb
, "NewSignature3", 2, "Software\\Wine", "Value3", type
);
4491 /* HKLM, msidbLocatorTypeRawValue, REG_EXPAND_SZ */
4492 add_reglocator_entry(hdb
, "NewSignature4", 2, "Software\\Wine", "Value4", type
);
4494 /* HKLM, msidbLocatorTypeRawValue, REG_EXPAND_SZ */
4495 add_reglocator_entry(hdb
, "NewSignature5", 2, "Software\\Wine", "Value5", type
);
4497 /* HKLM, msidbLocatorTypeRawValue, REG_MULTI_SZ */
4498 add_reglocator_entry(hdb
, "NewSignature6", 2, "Software\\Wine", "Value6", type
);
4500 /* HKLM, msidbLocatorTypeRawValue, REG_BINARY */
4501 add_reglocator_entry(hdb
, "NewSignature7", 2, "Software\\Wine", "Value7", type
);
4503 /* HKLM, msidbLocatorTypeRawValue, REG_SZ first char is # */
4504 add_reglocator_entry(hdb
, "NewSignature8", 2, "Software\\Wine", "Value8", type
);
4506 type
= msidbLocatorTypeFileName
;
4508 type
|= msidbLocatorType64bit
;
4510 /* HKLM, msidbLocatorTypeFileName, signature, file exists */
4511 add_reglocator_entry(hdb
, "NewSignature9", 2, "Software\\Wine", "Value9", type
);
4513 /* HKLM, msidbLocatorTypeFileName, signature, file does not exist */
4514 add_reglocator_entry(hdb
, "NewSignature10", 2, "Software\\Wine", "Value10", type
);
4516 /* HKLM, msidbLocatorTypeFileName, no signature */
4517 add_reglocator_entry(hdb
, "NewSignature11", 2, "Software\\Wine", "Value9", type
);
4519 type
= msidbLocatorTypeDirectory
;
4521 type
|= msidbLocatorType64bit
;
4523 /* HKLM, msidbLocatorTypeDirectory, no signature, file exists */
4524 add_reglocator_entry(hdb
, "NewSignature12", 2, "Software\\Wine", "Value9", type
);
4526 /* HKLM, msidbLocatorTypeDirectory, no signature, directory exists */
4527 add_reglocator_entry(hdb
, "NewSignature13", 2, "Software\\Wine", "Value11", type
);
4529 /* HKLM, msidbLocatorTypeDirectory, signature, file exists */
4530 add_reglocator_entry(hdb
, "NewSignature14", 2, "Software\\Wine", "Value9", type
);
4532 type
= msidbLocatorTypeRawValue
;
4534 type
|= msidbLocatorType64bit
;
4536 /* HKCR, msidbLocatorTypeRawValue, REG_SZ */
4537 add_reglocator_entry(hdb
, "NewSignature15", 0, "Software\\Wine", "Value1", type
);
4539 /* HKCU, msidbLocatorTypeRawValue, REG_SZ */
4540 add_reglocator_entry(hdb
, "NewSignature16", 1, "Software\\Wine", "Value1", type
);
4542 /* HKU, msidbLocatorTypeRawValue, REG_SZ */
4543 add_reglocator_entry(hdb
, "NewSignature17", 3, "S-1-5-18\\Software\\Wine", "Value1", type
);
4545 /* HKLM, msidbLocatorTypeRawValue, REG_SZ, NULL Name */
4546 add_reglocator_entry(hdb
, "NewSignature18", 2, "Software\\Wine", "", type
);
4548 /* HKLM, msidbLocatorTypeRawValue, REG_SZ, key does not exist */
4549 add_reglocator_entry(hdb
, "NewSignature19", 2, "Software\\IDontExist", "", type
);
4551 /* HKLM, msidbLocatorTypeRawValue, REG_SZ, value is empty */
4552 add_reglocator_entry(hdb
, "NewSignature20", 2, "Software\\Wine", "Value12", type
);
4554 type
= msidbLocatorTypeFileName
;
4556 type
|= msidbLocatorType64bit
;
4558 /* HKLM, msidbLocatorTypeFileName, signature, file exists w/ version */
4559 add_reglocator_entry(hdb
, "NewSignature21", 2, "Software\\Wine", "Value13", type
);
4561 /* HKLM, msidbLocatorTypeFileName, file exists w/ version, version > max */
4562 add_reglocator_entry(hdb
, "NewSignature22", 2, "Software\\Wine", "Value14", type
);
4564 /* HKLM, msidbLocatorTypeFileName, file exists w/ version, sig->name ignored */
4565 add_reglocator_entry(hdb
, "NewSignature23", 2, "Software\\Wine", "Value15", type
);
4567 /* HKLM, msidbLocatorTypeFileName, no signature, directory exists */
4568 add_reglocator_entry(hdb
, "NewSignature24", 2, "Software\\Wine", "Value11", type
);
4570 /* HKLM, msidbLocatorTypeFileName, no signature, file does not exist */
4571 add_reglocator_entry(hdb
, "NewSignature25", 2, "Software\\Wine", "Value10", type
);
4573 type
= msidbLocatorTypeDirectory
;
4575 type
|= msidbLocatorType64bit
;
4577 /* HKLM, msidbLocatorTypeDirectory, signature, directory exists */
4578 add_reglocator_entry(hdb
, "NewSignature26", 2, "Software\\Wine", "Value11", type
);
4580 /* HKLM, msidbLocatorTypeDirectory, signature, file does not exist */
4581 add_reglocator_entry(hdb
, "NewSignature27", 2, "Software\\Wine", "Value10", type
);
4583 /* HKLM, msidbLocatorTypeDirectory, no signature, file does not exist */
4584 add_reglocator_entry(hdb
, "NewSignature28", 2, "Software\\Wine", "Value10", type
);
4586 type
= msidbLocatorTypeFileName
;
4588 type
|= msidbLocatorType64bit
;
4590 /* HKLM, msidbLocatorTypeFile, file exists, in quotes */
4591 add_reglocator_entry(hdb
, "NewSignature29", 2, "Software\\Wine", "Value16", type
);
4593 /* HKLM, msidbLocatorTypeFile, file exists, no quotes */
4594 add_reglocator_entry(hdb
, "NewSignature30", 2, "Software\\Wine", "Value17", type
);
4596 create_signature_table(hdb
);
4597 add_signature_entry(hdb
, "'NewSignature9', 'FileName1', '', '', '', '', '', '', ''");
4598 add_signature_entry(hdb
, "'NewSignature10', 'FileName2', '', '', '', '', '', '', ''");
4599 add_signature_entry(hdb
, "'NewSignature14', 'FileName1', '', '', '', '', '', '', ''");
4600 add_signature_entry(hdb
, "'NewSignature21', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
4601 add_signature_entry(hdb
, "'NewSignature22', 'FileName4.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
4602 add_signature_entry(hdb
, "'NewSignature23', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
4604 if (!is_root(CURR_DIR
))
4606 ptr
= strrchr(expected
, '\\') + 1;
4607 sprintf(path
, "'NewSignature26', '%s', '', '', '', '', '', '', ''", ptr
);
4608 add_signature_entry(hdb
, path
);
4610 add_signature_entry(hdb
, "'NewSignature27', 'FileName2', '', '', '', '', '', '', ''");
4611 add_signature_entry(hdb
, "'NewSignature29', 'FileName1', '', '', '', '', '', '', ''");
4612 add_signature_entry(hdb
, "'NewSignature30', 'FileName1', '', '', '', '', '', '', ''");
4614 r
= package_from_db(hdb
, &hpkg
);
4615 ok(r
== ERROR_SUCCESS
, "Expected a valid package handle %u\n", r
);
4617 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
4619 r
= MsiDoActionA(hpkg
, "AppSearch");
4620 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4623 r
= MsiGetPropertyA(hpkg
, "SIGPROP1", prop
, &size
);
4624 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4625 ok(!lstrcmpA(prop
, "regszdata"),
4626 "Expected \"regszdata\", got \"%s\"\n", prop
);
4629 r
= MsiGetPropertyA(hpkg
, "SIGPROP2", prop
, &size
);
4630 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4631 ok(!lstrcmpA(prop
, "#42"), "Expected \"#42\", got \"%s\"\n", prop
);
4634 r
= MsiGetPropertyA(hpkg
, "SIGPROP3", prop
, &size
);
4635 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4636 ok(!lstrcmpA(prop
, "#-42"), "Expected \"#-42\", got \"%s\"\n", prop
);
4638 memset(&si
, 0, sizeof(si
));
4639 if (pGetNativeSystemInfo
) pGetNativeSystemInfo(&si
);
4641 if (S(U(si
)).wProcessorArchitecture
== PROCESSOR_ARCHITECTURE_INTEL
)
4643 size
= ExpandEnvironmentStringsA("%PATH%", NULL
, 0);
4644 pathvar
= HeapAlloc(GetProcessHeap(), 0, size
);
4645 ExpandEnvironmentStringsA("%PATH%", pathvar
, size
);
4648 r
= MsiGetPropertyA(hpkg
, "SIGPROP4", NULL
, &size
);
4649 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4651 pathdata
= HeapAlloc(GetProcessHeap(), 0, ++size
);
4652 r
= MsiGetPropertyA(hpkg
, "SIGPROP4", pathdata
, &size
);
4653 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4654 ok(!lstrcmpA(pathdata
, pathvar
),
4655 "Expected \"%s\", got \"%s\"\n", pathvar
, pathdata
);
4657 HeapFree(GetProcessHeap(), 0, pathvar
);
4658 HeapFree(GetProcessHeap(), 0, pathdata
);
4662 r
= MsiGetPropertyA(hpkg
, "SIGPROP5", prop
, &size
);
4663 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4665 "my%NOVAR%"), "Expected \"my%%NOVAR%%\", got \"%s\"\n", prop
);
4668 r
= MsiGetPropertyA(hpkg
, "SIGPROP6", prop
, &size
);
4669 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4672 ok(!memcmp(prop
, "\0one\0two\0\0", 10),
4673 "Expected \"\\0one\\0two\\0\\0\"\n");
4677 lstrcpyA(path
, "#xCDAB3412EF907856");
4678 r
= MsiGetPropertyA(hpkg
, "SIGPROP7", prop
, &size
);
4679 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4680 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4683 r
= MsiGetPropertyA(hpkg
, "SIGPROP8", prop
, &size
);
4684 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4685 ok(!lstrcmpA(prop
, "##regszdata"),
4686 "Expected \"##regszdata\", got \"%s\"\n", prop
);
4689 sprintf(path
, "%s\\FileName1", expected
);
4690 r
= MsiGetPropertyA(hpkg
, "SIGPROP9", prop
, &size
);
4691 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4692 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4695 r
= MsiGetPropertyA(hpkg
, "SIGPROP10", prop
, &size
);
4696 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4697 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4700 sprintf(path
, "%s\\", expected
);
4701 r
= MsiGetPropertyA(hpkg
, "SIGPROP11", prop
, &size
);
4702 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4703 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4706 r
= MsiGetPropertyA(hpkg
, "SIGPROP12", prop
, &size
);
4707 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4708 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4711 sprintf(path
, "%s\\", expected
);
4712 r
= MsiGetPropertyA(hpkg
, "SIGPROP13", prop
, &size
);
4713 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4714 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4717 r
= MsiGetPropertyA(hpkg
, "SIGPROP14", prop
, &size
);
4718 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4719 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4722 r
= MsiGetPropertyA(hpkg
, "SIGPROP15", prop
, &size
);
4723 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4724 ok(!lstrcmpA(prop
, "regszdata"),
4725 "Expected \"regszdata\", got \"%s\"\n", prop
);
4728 r
= MsiGetPropertyA(hpkg
, "SIGPROP16", prop
, &size
);
4729 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4730 ok(!lstrcmpA(prop
, "regszdata"),
4731 "Expected \"regszdata\", got \"%s\"\n", prop
);
4736 r
= MsiGetPropertyA(hpkg
, "SIGPROP17", prop
, &size
);
4737 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4738 ok(!lstrcmpA(prop
, "regszdata"),
4739 "Expected \"regszdata\", got \"%s\"\n", prop
);
4743 r
= MsiGetPropertyA(hpkg
, "SIGPROP18", prop
, &size
);
4744 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4745 ok(!lstrcmpA(prop
, "defvalue"),
4746 "Expected \"defvalue\", got \"%s\"\n", prop
);
4749 r
= MsiGetPropertyA(hpkg
, "SIGPROP19", prop
, &size
);
4750 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4751 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4754 r
= MsiGetPropertyA(hpkg
, "SIGPROP20", prop
, &size
);
4755 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4756 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4761 sprintf(path
, "%s\\FileName3.dll", expected
);
4762 r
= MsiGetPropertyA(hpkg
, "SIGPROP21", prop
, &size
);
4763 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4764 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4767 r
= MsiGetPropertyA(hpkg
, "SIGPROP22", prop
, &size
);
4768 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4769 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4772 sprintf(path
, "%s\\FileName5.dll", expected
);
4773 r
= MsiGetPropertyA(hpkg
, "SIGPROP23", prop
, &size
);
4774 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4775 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4778 if (!is_root(CURR_DIR
))
4781 lstrcpyA(path
, expected
);
4782 ptr
= strrchr(path
, '\\') + 1;
4784 r
= MsiGetPropertyA(hpkg
, "SIGPROP24", prop
, &size
);
4785 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4786 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4789 sprintf(path
, "%s\\", expected
);
4790 r
= MsiGetPropertyA(hpkg
, "SIGPROP25", prop
, &size
);
4791 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4792 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4795 r
= MsiGetPropertyA(hpkg
, "SIGPROP26", prop
, &size
);
4796 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4797 if (is_root(CURR_DIR
))
4798 ok(!lstrcmpA(prop
, CURR_DIR
), "Expected \"%s\", got \"%s\"\n", CURR_DIR
, prop
);
4800 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4803 r
= MsiGetPropertyA(hpkg
, "SIGPROP27", prop
, &size
);
4804 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4805 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4808 r
= MsiGetPropertyA(hpkg
, "SIGPROP28", prop
, &size
);
4809 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4810 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4813 sprintf(path
, "%s\\FileName1", expected
);
4814 r
= MsiGetPropertyA(hpkg
, "SIGPROP29", prop
, &size
);
4815 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4816 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4819 sprintf(path
, "%s\\FileName1", expected
);
4820 r
= MsiGetPropertyA(hpkg
, "SIGPROP30", prop
, &size
);
4821 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4823 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4825 todo_wine
ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4827 RegSetValueA(hklm
, NULL
, REG_SZ
, "", 0);
4828 RegDeleteValueA(hklm
, "Value1");
4829 RegDeleteValueA(hklm
, "Value2");
4830 RegDeleteValueA(hklm
, "Value3");
4831 RegDeleteValueA(hklm
, "Value4");
4832 RegDeleteValueA(hklm
, "Value5");
4833 RegDeleteValueA(hklm
, "Value6");
4834 RegDeleteValueA(hklm
, "Value7");
4835 RegDeleteValueA(hklm
, "Value8");
4836 RegDeleteValueA(hklm
, "Value9");
4837 RegDeleteValueA(hklm
, "Value10");
4838 RegDeleteValueA(hklm
, "Value11");
4839 RegDeleteValueA(hklm
, "Value12");
4840 RegDeleteValueA(hklm
, "Value13");
4841 RegDeleteValueA(hklm
, "Value14");
4842 RegDeleteValueA(hklm
, "Value15");
4843 RegDeleteValueA(hklm
, "Value16");
4844 RegDeleteValueA(hklm
, "Value17");
4845 RegDeleteKeyA(hklm
, "");
4848 RegDeleteValueA(classes
, "Value1");
4849 RegDeleteKeyA(classes
, "");
4850 RegCloseKey(classes
);
4852 RegDeleteValueA(hkcu
, "Value1");
4853 RegDeleteKeyA(hkcu
, "");
4856 RegDeleteValueA(users
, "Value1");
4857 RegDeleteKeyA(users
, "");
4860 DeleteFileA("FileName1");
4861 DeleteFileA("FileName3.dll");
4862 DeleteFileA("FileName4.dll");
4863 DeleteFileA("FileName5.dll");
4864 MsiCloseHandle(hpkg
);
4865 DeleteFileA(msifile
);
4868 static void delete_win_ini(LPCSTR file
)
4870 CHAR path
[MAX_PATH
];
4872 GetWindowsDirectoryA(path
, MAX_PATH
);
4873 lstrcatA(path
, "\\");
4874 lstrcatA(path
, file
);
4879 static void test_appsearch_inilocator(void)
4881 MSIHANDLE hpkg
, hdb
;
4882 char path
[MAX_PATH
], expected
[MAX_PATH
], prop
[MAX_PATH
];
4889 if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
4892 DeleteFileA("test.dll");
4894 WritePrivateProfileStringA("Section", "Key", "keydata,field2", "IniFile.ini");
4896 strcpy(expected
, CURR_DIR
);
4897 if (is_root(CURR_DIR
)) expected
[2] = 0;
4899 create_test_file("FileName1");
4900 sprintf(path
, "%s\\FileName1", expected
);
4901 WritePrivateProfileStringA("Section", "Key2", path
, "IniFile.ini");
4903 WritePrivateProfileStringA("Section", "Key3", expected
, "IniFile.ini");
4905 sprintf(path
, "%s\\IDontExist", expected
);
4906 WritePrivateProfileStringA("Section", "Key4", path
, "IniFile.ini");
4908 create_file_with_version("FileName2.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4909 sprintf(path
, "%s\\FileName2.dll", expected
);
4910 WritePrivateProfileStringA("Section", "Key5", path
, "IniFile.ini");
4912 create_file_with_version("FileName3.dll", MAKELONG(1, 2), MAKELONG(3, 4));
4913 sprintf(path
, "%s\\FileName3.dll", expected
);
4914 WritePrivateProfileStringA("Section", "Key6", path
, "IniFile.ini");
4916 create_file_with_version("FileName4.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4917 sprintf(path
, "%s\\FileName4.dll", expected
);
4918 WritePrivateProfileStringA("Section", "Key7", path
, "IniFile.ini");
4920 hdb
= create_package_db();
4921 ok(hdb
, "Expected a valid database handle\n");
4923 create_appsearch_table(hdb
);
4924 add_appsearch_entry(hdb
, "'SIGPROP1', 'NewSignature1'");
4925 add_appsearch_entry(hdb
, "'SIGPROP2', 'NewSignature2'");
4926 add_appsearch_entry(hdb
, "'SIGPROP3', 'NewSignature3'");
4927 add_appsearch_entry(hdb
, "'SIGPROP4', 'NewSignature4'");
4928 add_appsearch_entry(hdb
, "'SIGPROP5', 'NewSignature5'");
4929 add_appsearch_entry(hdb
, "'SIGPROP6', 'NewSignature6'");
4930 add_appsearch_entry(hdb
, "'SIGPROP7', 'NewSignature7'");
4931 add_appsearch_entry(hdb
, "'SIGPROP8', 'NewSignature8'");
4932 add_appsearch_entry(hdb
, "'SIGPROP9', 'NewSignature9'");
4933 add_appsearch_entry(hdb
, "'SIGPROP10', 'NewSignature10'");
4934 add_appsearch_entry(hdb
, "'SIGPROP11', 'NewSignature11'");
4935 add_appsearch_entry(hdb
, "'SIGPROP12', 'NewSignature12'");
4937 create_inilocator_table(hdb
);
4939 /* msidbLocatorTypeRawValue, field 1 */
4940 add_inilocator_entry(hdb
, "'NewSignature1', 'IniFile.ini', 'Section', 'Key', 1, 2");
4942 /* msidbLocatorTypeRawValue, field 2 */
4943 add_inilocator_entry(hdb
, "'NewSignature2', 'IniFile.ini', 'Section', 'Key', 2, 2");
4945 /* msidbLocatorTypeRawValue, entire field */
4946 add_inilocator_entry(hdb
, "'NewSignature3', 'IniFile.ini', 'Section', 'Key', 0, 2");
4948 /* msidbLocatorTypeFile */
4949 add_inilocator_entry(hdb
, "'NewSignature4', 'IniFile.ini', 'Section', 'Key2', 1, 1");
4951 /* msidbLocatorTypeDirectory, file */
4952 add_inilocator_entry(hdb
, "'NewSignature5', 'IniFile.ini', 'Section', 'Key2', 1, 0");
4954 /* msidbLocatorTypeDirectory, directory */
4955 add_inilocator_entry(hdb
, "'NewSignature6', 'IniFile.ini', 'Section', 'Key3', 1, 0");
4957 /* msidbLocatorTypeFile, file, no signature */
4958 add_inilocator_entry(hdb
, "'NewSignature7', 'IniFile.ini', 'Section', 'Key2', 1, 1");
4960 /* msidbLocatorTypeFile, dir, no signature */
4961 add_inilocator_entry(hdb
, "'NewSignature8', 'IniFile.ini', 'Section', 'Key3', 1, 1");
4963 /* msidbLocatorTypeFile, file does not exist */
4964 add_inilocator_entry(hdb
, "'NewSignature9', 'IniFile.ini', 'Section', 'Key4', 1, 1");
4966 /* msidbLocatorTypeFile, signature with version */
4967 add_inilocator_entry(hdb
, "'NewSignature10', 'IniFile.ini', 'Section', 'Key5', 1, 1");
4969 /* msidbLocatorTypeFile, signature with version, ver > max */
4970 add_inilocator_entry(hdb
, "'NewSignature11', 'IniFile.ini', 'Section', 'Key6', 1, 1");
4972 /* msidbLocatorTypeFile, signature with version, sig->name ignored */
4973 add_inilocator_entry(hdb
, "'NewSignature12', 'IniFile.ini', 'Section', 'Key7', 1, 1");
4975 create_signature_table(hdb
);
4976 add_signature_entry(hdb
, "'NewSignature4', 'FileName1', '', '', '', '', '', '', ''");
4977 add_signature_entry(hdb
, "'NewSignature9', 'IDontExist', '', '', '', '', '', '', ''");
4978 add_signature_entry(hdb
, "'NewSignature10', 'FileName2.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
4979 add_signature_entry(hdb
, "'NewSignature11', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
4980 add_signature_entry(hdb
, "'NewSignature12', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
4982 r
= package_from_db(hdb
, &hpkg
);
4983 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
4985 skip("Not enough rights to perform tests\n");
4988 ok(r
== ERROR_SUCCESS
, "Expected a valid package handle %u\n", r
);
4990 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
4992 r
= MsiDoActionA(hpkg
, "AppSearch");
4993 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4996 r
= MsiGetPropertyA(hpkg
, "SIGPROP1", prop
, &size
);
4997 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4998 ok(!lstrcmpA(prop
, "keydata"), "Expected \"keydata\", got \"%s\"\n", prop
);
5001 r
= MsiGetPropertyA(hpkg
, "SIGPROP2", prop
, &size
);
5002 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5003 ok(!lstrcmpA(prop
, "field2"), "Expected \"field2\", got \"%s\"\n", prop
);
5006 r
= MsiGetPropertyA(hpkg
, "SIGPROP3", prop
, &size
);
5007 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5008 ok(!lstrcmpA(prop
, "keydata,field2"),
5009 "Expected \"keydata,field2\", got \"%s\"\n", prop
);
5012 sprintf(path
, "%s\\FileName1", expected
);
5013 r
= MsiGetPropertyA(hpkg
, "SIGPROP4", prop
, &size
);
5014 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5015 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5018 r
= MsiGetPropertyA(hpkg
, "SIGPROP5", prop
, &size
);
5019 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5020 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
5023 sprintf(path
, "%s\\", expected
);
5024 r
= MsiGetPropertyA(hpkg
, "SIGPROP6", prop
, &size
);
5025 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5026 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5029 sprintf(path
, "%s\\", expected
);
5030 r
= MsiGetPropertyA(hpkg
, "SIGPROP7", prop
, &size
);
5031 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5032 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5034 if (!is_root(CURR_DIR
))
5037 lstrcpyA(path
, expected
);
5038 ptr
= strrchr(path
, '\\');
5040 r
= MsiGetPropertyA(hpkg
, "SIGPROP8", prop
, &size
);
5041 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5042 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5045 r
= MsiGetPropertyA(hpkg
, "SIGPROP9", prop
, &size
);
5046 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5047 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
5052 sprintf(path
, "%s\\FileName2.dll", expected
);
5053 r
= MsiGetPropertyA(hpkg
, "SIGPROP10", prop
, &size
);
5054 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5055 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5058 r
= MsiGetPropertyA(hpkg
, "SIGPROP11", prop
, &size
);
5059 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5060 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
5063 sprintf(path
, "%s\\FileName4.dll", expected
);
5064 r
= MsiGetPropertyA(hpkg
, "SIGPROP12", prop
, &size
);
5065 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5066 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5069 MsiCloseHandle(hpkg
);
5072 delete_win_ini("IniFile.ini");
5073 DeleteFileA("FileName1");
5074 DeleteFileA("FileName2.dll");
5075 DeleteFileA("FileName3.dll");
5076 DeleteFileA("FileName4.dll");
5077 DeleteFileA(msifile
);
5081 * MSI AppSearch action on DrLocator table always returns absolute paths.
5082 * If a relative path was set, it returns the first absolute path that
5083 * matches or an empty string if it didn't find anything.
5084 * This helper function replicates this behaviour.
5086 static void search_absolute_directory(LPSTR absolute
, LPCSTR relative
)
5091 size
= lstrlenA(relative
);
5092 drives
= GetLogicalDrives();
5093 lstrcpyA(absolute
, "A:\\");
5094 for (i
= 0; i
< 26; absolute
[0] = '\0', i
++)
5096 if (!(drives
& (1 << i
)))
5099 absolute
[0] = 'A' + i
;
5100 if (GetDriveTypeA(absolute
) != DRIVE_FIXED
)
5103 lstrcpynA(absolute
+ 3, relative
, size
+ 1);
5104 attr
= GetFileAttributesA(absolute
);
5105 if (attr
!= INVALID_FILE_ATTRIBUTES
&&
5106 (attr
& FILE_ATTRIBUTE_DIRECTORY
))
5108 if (absolute
[3 + size
- 1] != '\\')
5109 lstrcatA(absolute
, "\\");
5116 static void test_appsearch_drlocator(void)
5118 MSIHANDLE hpkg
, hdb
;
5119 char path
[MAX_PATH
], expected
[MAX_PATH
], prop
[MAX_PATH
];
5125 if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
5128 DeleteFileA("test.dll");
5130 create_test_file("FileName1");
5131 CreateDirectoryA("one", NULL
);
5132 CreateDirectoryA("one\\two", NULL
);
5133 CreateDirectoryA("one\\two\\three", NULL
);
5134 create_test_file("one\\two\\three\\FileName2");
5135 CreateDirectoryA("another", NULL
);
5136 create_file_with_version("FileName3.dll", MAKELONG(2, 1), MAKELONG(4, 3));
5137 create_file_with_version("FileName4.dll", MAKELONG(1, 2), MAKELONG(3, 4));
5138 create_file_with_version("FileName5.dll", MAKELONG(2, 1), MAKELONG(4, 3));
5140 hdb
= create_package_db();
5141 ok(hdb
, "Expected a valid database handle\n");
5143 create_appsearch_table(hdb
);
5144 add_appsearch_entry(hdb
, "'SIGPROP1', 'NewSignature1'");
5145 add_appsearch_entry(hdb
, "'SIGPROP2', 'NewSignature2'");
5146 add_appsearch_entry(hdb
, "'SIGPROP3', 'NewSignature3'");
5147 add_appsearch_entry(hdb
, "'SIGPROP4', 'NewSignature4'");
5148 add_appsearch_entry(hdb
, "'SIGPROP5', 'NewSignature5'");
5149 add_appsearch_entry(hdb
, "'SIGPROP6', 'NewSignature6'");
5150 add_appsearch_entry(hdb
, "'SIGPROP7', 'NewSignature7'");
5151 add_appsearch_entry(hdb
, "'SIGPROP8', 'NewSignature8'");
5152 add_appsearch_entry(hdb
, "'SIGPROP9', 'NewSignature9'");
5153 add_appsearch_entry(hdb
, "'SIGPROP10', 'NewSignature10'");
5154 add_appsearch_entry(hdb
, "'SIGPROP11', 'NewSignature11'");
5155 add_appsearch_entry(hdb
, "'SIGPROP13', 'NewSignature13'");
5157 create_drlocator_table(hdb
);
5159 strcpy(expected
, CURR_DIR
);
5160 if (is_root(CURR_DIR
)) expected
[2] = 0;
5162 /* no parent, full path, depth 0, signature */
5163 sprintf(path
, "'NewSignature1', '', '%s', 0", expected
);
5164 add_drlocator_entry(hdb
, path
);
5166 /* no parent, full path, depth 0, no signature */
5167 sprintf(path
, "'NewSignature2', '', '%s', 0", expected
);
5168 add_drlocator_entry(hdb
, path
);
5170 /* no parent, relative path, depth 0, no signature */
5171 sprintf(path
, "'NewSignature3', '', '%s', 0", expected
+ 3);
5172 add_drlocator_entry(hdb
, path
);
5174 /* no parent, full path, depth 2, signature */
5175 sprintf(path
, "'NewSignature4', '', '%s', 2", expected
);
5176 add_drlocator_entry(hdb
, path
);
5178 /* no parent, full path, depth 3, signature */
5179 sprintf(path
, "'NewSignature5', '', '%s', 3", expected
);
5180 add_drlocator_entry(hdb
, path
);
5182 /* no parent, full path, depth 1, signature is dir */
5183 sprintf(path
, "'NewSignature6', '', '%s', 1", expected
);
5184 add_drlocator_entry(hdb
, path
);
5186 /* parent is in DrLocator, relative path, depth 0, signature */
5187 sprintf(path
, "'NewSignature7', 'NewSignature1', 'one\\two\\three', 1");
5188 add_drlocator_entry(hdb
, path
);
5190 /* no parent, full path, depth 0, signature w/ version */
5191 sprintf(path
, "'NewSignature8', '', '%s', 0", expected
);
5192 add_drlocator_entry(hdb
, path
);
5194 /* no parent, full path, depth 0, signature w/ version, ver > max */
5195 sprintf(path
, "'NewSignature9', '', '%s', 0", expected
);
5196 add_drlocator_entry(hdb
, path
);
5198 /* no parent, full path, depth 0, signature w/ version, sig->name not ignored */
5199 sprintf(path
, "'NewSignature10', '', '%s', 0", expected
);
5200 add_drlocator_entry(hdb
, path
);
5202 /* no parent, relative empty path, depth 0, no signature */
5203 sprintf(path
, "'NewSignature11', '', '', 0");
5204 add_drlocator_entry(hdb
, path
);
5206 create_reglocator_table(hdb
);
5209 add_reglocator_entry(hdb
, "NewSignature12", 2, "htmlfile\\shell\\open\\nonexistent", "", 1);
5211 /* parent is in RegLocator, no path, depth 0, no signature */
5212 sprintf(path
, "'NewSignature13', 'NewSignature12', '', 0");
5213 add_drlocator_entry(hdb
, path
);
5215 create_signature_table(hdb
);
5216 add_signature_entry(hdb
, "'NewSignature1', 'FileName1', '', '', '', '', '', '', ''");
5217 add_signature_entry(hdb
, "'NewSignature4', 'FileName2', '', '', '', '', '', '', ''");
5218 add_signature_entry(hdb
, "'NewSignature5', 'FileName2', '', '', '', '', '', '', ''");
5219 add_signature_entry(hdb
, "'NewSignature6', 'another', '', '', '', '', '', '', ''");
5220 add_signature_entry(hdb
, "'NewSignature7', 'FileName2', '', '', '', '', '', '', ''");
5221 add_signature_entry(hdb
, "'NewSignature8', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
5222 add_signature_entry(hdb
, "'NewSignature9', 'FileName4.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
5223 add_signature_entry(hdb
, "'NewSignature10', 'necessary', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
5225 r
= package_from_db(hdb
, &hpkg
);
5226 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
5228 skip("Not enough rights to perform tests\n");
5231 ok(r
== ERROR_SUCCESS
, "Expected a valid package handle %u\n", r
);
5233 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
5235 r
= MsiDoActionA(hpkg
, "AppSearch");
5236 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5239 sprintf(path
, "%s\\FileName1", expected
);
5240 r
= MsiGetPropertyA(hpkg
, "SIGPROP1", prop
, &size
);
5241 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5242 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5245 sprintf(path
, "%s\\", expected
);
5246 r
= MsiGetPropertyA(hpkg
, "SIGPROP2", prop
, &size
);
5247 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5248 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5251 search_absolute_directory(path
, expected
+ 3);
5252 r
= MsiGetPropertyA(hpkg
, "SIGPROP3", prop
, &size
);
5253 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5254 ok(!lstrcmpiA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5257 r
= MsiGetPropertyA(hpkg
, "SIGPROP4", prop
, &size
);
5258 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5259 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
5262 sprintf(path
, "%s\\one\\two\\three\\FileName2", expected
);
5263 r
= MsiGetPropertyA(hpkg
, "SIGPROP5", prop
, &size
);
5264 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5265 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5268 r
= MsiGetPropertyA(hpkg
, "SIGPROP6", prop
, &size
);
5269 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5270 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
5273 sprintf(path
, "%s\\one\\two\\three\\FileName2", expected
);
5274 r
= MsiGetPropertyA(hpkg
, "SIGPROP7", prop
, &size
);
5275 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5276 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5281 sprintf(path
, "%s\\FileName3.dll", expected
);
5282 r
= MsiGetPropertyA(hpkg
, "SIGPROP8", prop
, &size
);
5283 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5284 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5287 r
= MsiGetPropertyA(hpkg
, "SIGPROP9", prop
, &size
);
5288 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5289 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
5292 r
= MsiGetPropertyA(hpkg
, "SIGPROP10", prop
, &size
);
5293 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5294 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
5298 search_absolute_directory(path
, "");
5299 r
= MsiGetPropertyA(hpkg
, "SIGPROP11", prop
, &size
);
5300 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5301 ok(!lstrcmpiA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5304 strcpy(path
, "c:\\");
5305 r
= MsiGetPropertyA(hpkg
, "SIGPROP13", prop
, &size
);
5306 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5307 ok(!prop
[0], "Expected \"\", got \"%s\"\n", prop
);
5309 MsiCloseHandle(hpkg
);
5312 DeleteFileA("FileName1");
5313 DeleteFileA("FileName3.dll");
5314 DeleteFileA("FileName4.dll");
5315 DeleteFileA("FileName5.dll");
5316 DeleteFileA("one\\two\\three\\FileName2");
5317 RemoveDirectoryA("one\\two\\three");
5318 RemoveDirectoryA("one\\two");
5319 RemoveDirectoryA("one");
5320 RemoveDirectoryA("another");
5321 DeleteFileA(msifile
);
5324 static void test_featureparents(void)
5330 hdb
= create_package_db();
5331 ok ( hdb
, "failed to create package database\n" );
5333 add_directory_entry(hdb
, "'TARGETDIR', '', 'SourceDir'");
5335 create_feature_table( hdb
);
5336 create_component_table( hdb
);
5337 create_feature_components_table( hdb
);
5338 create_file_table( hdb
);
5340 /* msidbFeatureAttributesFavorLocal */
5341 add_feature_entry( hdb
, "'zodiac', '', '', '', 2, 1, '', 0" );
5343 /* msidbFeatureAttributesFavorSource */
5344 add_feature_entry( hdb
, "'perseus', '', '', '', 2, 1, '', 1" );
5346 /* msidbFeatureAttributesFavorLocal */
5347 add_feature_entry( hdb
, "'orion', '', '', '', 2, 1, '', 0" );
5349 /* msidbFeatureAttributesUIDisallowAbsent */
5350 add_feature_entry( hdb
, "'lyra', '', '', '', 2, 1, '', 16" );
5352 /* disabled because of install level */
5353 add_feature_entry( hdb
, "'waters', '', '', '', 15, 101, '', 9" );
5355 /* child feature of disabled feature */
5356 add_feature_entry( hdb
, "'bayer', 'waters', '', '', 14, 1, '', 9" );
5358 /* component of disabled feature (install level) */
5359 add_component_entry( hdb
, "'delphinus', '', 'TARGETDIR', 0, '', 'delphinus_file'" );
5361 /* component of disabled child feature (install level) */
5362 add_component_entry( hdb
, "'hydrus', '', 'TARGETDIR', 0, '', 'hydrus_file'" );
5364 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
5365 add_component_entry( hdb
, "'leo', '', 'TARGETDIR', 0, '', 'leo_file'" );
5367 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
5368 add_component_entry( hdb
, "'virgo', '', 'TARGETDIR', 1, '', 'virgo_file'" );
5370 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
5371 add_component_entry( hdb
, "'libra', '', 'TARGETDIR', 2, '', 'libra_file'" );
5373 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
5374 add_component_entry( hdb
, "'cassiopeia', '', 'TARGETDIR', 0, '', 'cassiopeia_file'" );
5376 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
5377 add_component_entry( hdb
, "'cepheus', '', 'TARGETDIR', 1, '', 'cepheus_file'" );
5379 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
5380 add_component_entry( hdb
, "'andromeda', '', 'TARGETDIR', 2, '', 'andromeda_file'" );
5382 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
5383 add_component_entry( hdb
, "'canis', '', 'TARGETDIR', 0, '', 'canis_file'" );
5385 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
5386 add_component_entry( hdb
, "'monoceros', '', 'TARGETDIR', 1, '', 'monoceros_file'" );
5388 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
5389 add_component_entry( hdb
, "'lepus', '', 'TARGETDIR', 2, '', 'lepus_file'" );
5391 add_feature_components_entry( hdb
, "'zodiac', 'leo'" );
5392 add_feature_components_entry( hdb
, "'zodiac', 'virgo'" );
5393 add_feature_components_entry( hdb
, "'zodiac', 'libra'" );
5394 add_feature_components_entry( hdb
, "'perseus', 'cassiopeia'" );
5395 add_feature_components_entry( hdb
, "'perseus', 'cepheus'" );
5396 add_feature_components_entry( hdb
, "'perseus', 'andromeda'" );
5397 add_feature_components_entry( hdb
, "'orion', 'leo'" );
5398 add_feature_components_entry( hdb
, "'orion', 'virgo'" );
5399 add_feature_components_entry( hdb
, "'orion', 'libra'" );
5400 add_feature_components_entry( hdb
, "'orion', 'cassiopeia'" );
5401 add_feature_components_entry( hdb
, "'orion', 'cepheus'" );
5402 add_feature_components_entry( hdb
, "'orion', 'andromeda'" );
5403 add_feature_components_entry( hdb
, "'orion', 'canis'" );
5404 add_feature_components_entry( hdb
, "'orion', 'monoceros'" );
5405 add_feature_components_entry( hdb
, "'orion', 'lepus'" );
5406 add_feature_components_entry( hdb
, "'waters', 'delphinus'" );
5407 add_feature_components_entry( hdb
, "'bayer', 'hydrus'" );
5409 add_file_entry( hdb
, "'leo_file', 'leo', 'leo.txt', 100, '', '1033', 8192, 1" );
5410 add_file_entry( hdb
, "'virgo_file', 'virgo', 'virgo.txt', 0, '', '1033', 8192, 1" );
5411 add_file_entry( hdb
, "'libra_file', 'libra', 'libra.txt', 0, '', '1033', 8192, 1" );
5412 add_file_entry( hdb
, "'cassiopeia_file', 'cassiopeia', 'cassiopeia.txt', 0, '', '1033', 8192, 1" );
5413 add_file_entry( hdb
, "'cepheus_file', 'cepheus', 'cepheus.txt', 0, '', '1033', 8192, 1" );
5414 add_file_entry( hdb
, "'andromeda_file', 'andromeda', 'andromeda.txt', 0, '', '1033', 8192, 1" );
5415 add_file_entry( hdb
, "'canis_file', 'canis', 'canis.txt', 0, '', '1033', 8192, 1" );
5416 add_file_entry( hdb
, "'monoceros_file', 'monoceros', 'monoceros.txt', 0, '', '1033', 8192, 1" );
5417 add_file_entry( hdb
, "'lepus_file', 'lepus', 'lepus.txt', 0, '', '1033', 8192, 1" );
5418 add_file_entry( hdb
, "'delphinus_file', 'delphinus', 'delphinus.txt', 0, '', '1033', 8192, 1" );
5419 add_file_entry( hdb
, "'hydrus_file', 'hydrus', 'hydrus.txt', 0, '', '1033', 8192, 1" );
5421 r
= package_from_db( hdb
, &hpkg
);
5422 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
5424 skip("Not enough rights to perform tests\n");
5425 DeleteFileA(msifile
);
5428 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
5430 MsiCloseHandle( hdb
);
5432 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
5434 r
= MsiDoActionA( hpkg
, "CostInitialize");
5435 ok( r
== ERROR_SUCCESS
, "cost init failed\n");
5437 r
= MsiDoActionA( hpkg
, "FileCost");
5438 ok( r
== ERROR_SUCCESS
, "file cost failed\n");
5440 r
= MsiDoActionA( hpkg
, "CostFinalize");
5441 ok( r
== ERROR_SUCCESS
, "cost finalize failed\n");
5443 test_feature_states( __LINE__
, hpkg
, "zodiac", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
5444 test_feature_states( __LINE__
, hpkg
, "perseus", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_SOURCE
, FALSE
);
5445 test_feature_states( __LINE__
, hpkg
, "orion", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
5446 test_feature_states( __LINE__
, hpkg
, "lyra", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
5447 test_feature_states( __LINE__
, hpkg
, "waters", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
5448 test_feature_states( __LINE__
, hpkg
, "bayer", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
5450 test_component_states( __LINE__
, hpkg
, "leo", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_LOCAL
, FALSE
);
5451 test_component_states( __LINE__
, hpkg
, "virgo", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_SOURCE
, FALSE
);
5452 test_component_states( __LINE__
, hpkg
, "libra", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_LOCAL
, FALSE
);
5453 test_component_states( __LINE__
, hpkg
, "cassiopeia", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_LOCAL
, FALSE
);
5454 test_component_states( __LINE__
, hpkg
, "cepheus", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_SOURCE
, FALSE
);
5455 test_component_states( __LINE__
, hpkg
, "andromeda", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_LOCAL
, FALSE
);
5456 test_component_states( __LINE__
, hpkg
, "canis", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_LOCAL
, FALSE
);
5457 test_component_states( __LINE__
, hpkg
, "monoceros", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_SOURCE
, FALSE
);
5458 test_component_states( __LINE__
, hpkg
, "lepus", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_LOCAL
, FALSE
);
5459 test_component_states( __LINE__
, hpkg
, "delphinus", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
5460 test_component_states( __LINE__
, hpkg
, "hydrus", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
5462 r
= MsiSetFeatureStateA(hpkg
, "orion", INSTALLSTATE_ABSENT
);
5463 ok( r
== ERROR_SUCCESS
, "failed to set feature state: %d\n", r
);
5465 r
= MsiSetFeatureStateA(hpkg
, "lyra", INSTALLSTATE_ABSENT
);
5466 ok( r
== ERROR_SUCCESS
, "failed to set feature state: %d\n", r
);
5468 r
= MsiSetFeatureStateA(hpkg
, "nosuchfeature", INSTALLSTATE_ABSENT
);
5469 ok( r
== ERROR_UNKNOWN_FEATURE
, "Expected ERROR_UNKNOWN_FEATURE, got %u\n", r
);
5471 test_feature_states( __LINE__
, hpkg
, "zodiac", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
5472 test_feature_states( __LINE__
, hpkg
, "perseus", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_SOURCE
, FALSE
);
5473 test_feature_states( __LINE__
, hpkg
, "orion", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_ABSENT
, FALSE
);
5474 test_feature_states( __LINE__
, hpkg
, "lyra", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_ABSENT
, FALSE
);
5475 test_feature_states( __LINE__
, hpkg
, "waters", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
5476 test_feature_states( __LINE__
, hpkg
, "bayer", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
5478 test_component_states( __LINE__
, hpkg
, "leo", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_LOCAL
, FALSE
);
5479 test_component_states( __LINE__
, hpkg
, "virgo", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_SOURCE
, FALSE
);
5480 test_component_states( __LINE__
, hpkg
, "libra", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_LOCAL
, FALSE
);
5481 test_component_states( __LINE__
, hpkg
, "cassiopeia", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_LOCAL
, FALSE
);
5482 test_component_states( __LINE__
, hpkg
, "cepheus", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_SOURCE
, FALSE
);
5483 test_component_states( __LINE__
, hpkg
, "andromeda", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_SOURCE
, FALSE
);
5484 test_component_states( __LINE__
, hpkg
, "canis", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
5485 test_component_states( __LINE__
, hpkg
, "monoceros", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
5486 test_component_states( __LINE__
, hpkg
, "lepus", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
5487 test_component_states( __LINE__
, hpkg
, "delphinus", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
5488 test_component_states( __LINE__
, hpkg
, "hydrus", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
5490 MsiCloseHandle(hpkg
);
5491 DeleteFileA(msifile
);
5494 static void test_installprops(void)
5496 MSIHANDLE hpkg
, hdb
;
5497 CHAR path
[MAX_PATH
], buf
[MAX_PATH
];
5503 REGSAM access
= KEY_ALL_ACCESS
;
5505 INSTALLUILEVEL uilevel
;
5508 access
|= KEY_WOW64_64KEY
;
5510 lstrcpyA(path
, CURR_DIR
);
5511 if (!is_root(CURR_DIR
)) lstrcatA(path
, "\\");
5512 lstrcatA(path
, msifile
);
5514 uilevel
= MsiSetInternalUI(INSTALLUILEVEL_BASIC
|INSTALLUILEVEL_SOURCERESONLY
, NULL
);
5516 hdb
= create_package_db();
5517 ok( hdb
, "failed to create database\n");
5519 r
= package_from_db(hdb
, &hpkg
);
5520 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
5522 skip("Not enough rights to perform tests\n");
5523 MsiSetInternalUI(uilevel
, NULL
);
5524 DeleteFileA(msifile
);
5527 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
5529 MsiCloseHandle(hdb
);
5533 r
= MsiGetPropertyA(hpkg
, "UILevel", buf
, &size
);
5534 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5535 ok( !lstrcmpA(buf
, "3"), "Expected \"3\", got \"%s\"\n", buf
);
5537 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
5541 r
= MsiGetPropertyA(hpkg
, "UILevel", buf
, &size
);
5542 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5543 ok( !lstrcmpA(buf
, "3"), "Expected \"3\", got \"%s\"\n", buf
);
5547 r
= MsiGetPropertyA(hpkg
, "DATABASE", buf
, &size
);
5548 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5549 ok( !lstrcmpA(buf
, path
), "Expected %s, got %s\n", path
, buf
);
5551 RegOpenKeyA(HKEY_CURRENT_USER
, "SOFTWARE\\Microsoft\\MS Setup (ACME)\\User Info", &hkey1
);
5552 RegOpenKeyExA(HKEY_LOCAL_MACHINE
, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, access
, &hkey2
);
5557 if (RegQueryValueExA(hkey1
, "DefName", NULL
, &type
, (LPBYTE
)path
, &size
) != ERROR_SUCCESS
)
5561 RegQueryValueExA(hkey2
, "RegisteredOwner", NULL
, &type
, (LPBYTE
)path
, &size
);
5566 r
= MsiGetPropertyA(hpkg
, "USERNAME", buf
, &size
);
5567 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5568 ok( !lstrcmpA(buf
, path
), "Expected %s, got %s\n", path
, buf
);
5573 if (RegQueryValueExA(hkey1
, "DefCompany", NULL
, &type
, (LPBYTE
)path
, &size
) != ERROR_SUCCESS
)
5577 RegQueryValueExA(hkey2
, "RegisteredOrganization", NULL
, &type
, (LPBYTE
)path
, &size
);
5584 r
= MsiGetPropertyA(hpkg
, "COMPANYNAME", buf
, &size
);
5585 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5586 ok( !lstrcmpA(buf
, path
), "Expected %s, got %s\n", path
, buf
);
5591 r
= MsiGetPropertyA(hpkg
, "VersionDatabase", buf
, &size
);
5592 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5593 trace("VersionDatabase = %s\n", buf
);
5597 r
= MsiGetPropertyA(hpkg
, "VersionMsi", buf
, &size
);
5598 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5599 trace("VersionMsi = %s\n", buf
);
5603 r
= MsiGetPropertyA(hpkg
, "Date", buf
, &size
);
5604 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5605 trace("Date = %s\n", buf
);
5609 r
= MsiGetPropertyA(hpkg
, "Time", buf
, &size
);
5610 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5611 trace("Time = %s\n", buf
);
5615 r
= MsiGetPropertyA(hpkg
, "PackageCode", buf
, &size
);
5616 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5617 trace("PackageCode = %s\n", buf
);
5621 r
= MsiGetPropertyA(hpkg
, "ComputerName", buf
, &size
);
5622 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
5623 trace("ComputerName = %s\n", buf
);
5625 langid
= GetUserDefaultLangID();
5626 sprintf(path
, "%d", langid
);
5630 r
= MsiGetPropertyA(hpkg
, "UserLanguageID", buf
, &size
);
5631 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
5632 ok( !lstrcmpA(buf
, path
), "Expected \"%s\", got \"%s\"\n", path
, buf
);
5634 res
= GetSystemMetrics(SM_CXSCREEN
);
5637 r
= MsiGetPropertyA(hpkg
, "ScreenX", buf
, &size
);
5638 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
5639 ok(atol(buf
) == res
, "Expected %d, got %ld\n", res
, atol(buf
));
5641 res
= GetSystemMetrics(SM_CYSCREEN
);
5644 r
= MsiGetPropertyA(hpkg
, "ScreenY", buf
, &size
);
5645 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
5646 ok(atol(buf
) == res
, "Expected %d, got %ld\n", res
, atol(buf
));
5648 if (pGetSystemInfo
&& pSHGetFolderPathA
)
5650 pGetSystemInfo(&si
);
5651 if (S(U(si
)).wProcessorArchitecture
== PROCESSOR_ARCHITECTURE_AMD64
)
5655 r
= MsiGetPropertyA(hpkg
, "Intel", buf
, &size
);
5656 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5657 ok(buf
[0], "property not set\n");
5661 r
= MsiGetPropertyA(hpkg
, "MsiAMD64", buf
, &size
);
5662 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5663 ok(buf
[0], "property not set\n");
5667 r
= MsiGetPropertyA(hpkg
, "Msix64", buf
, &size
);
5668 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5669 ok(buf
[0], "property not set\n");
5673 r
= MsiGetPropertyA(hpkg
, "System64Folder", buf
, &size
);
5674 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5675 GetSystemDirectoryA(path
, MAX_PATH
);
5676 if (size
) buf
[size
- 1] = 0;
5677 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
5681 r
= MsiGetPropertyA(hpkg
, "SystemFolder", buf
, &size
);
5682 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5683 pGetSystemWow64DirectoryA(path
, MAX_PATH
);
5684 if (size
) buf
[size
- 1] = 0;
5685 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
5689 r
= MsiGetPropertyA(hpkg
, "ProgramFiles64Folder", buf
, &size
);
5690 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5691 pSHGetFolderPathA(NULL
, CSIDL_PROGRAM_FILES
, NULL
, 0, path
);
5692 if (size
) buf
[size
- 1] = 0;
5693 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
5697 r
= MsiGetPropertyA(hpkg
, "ProgramFilesFolder", buf
, &size
);
5698 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5699 pSHGetFolderPathA(NULL
, CSIDL_PROGRAM_FILESX86
, NULL
, 0, path
);
5700 if (size
) buf
[size
- 1] = 0;
5701 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
5705 r
= MsiGetPropertyA(hpkg
, "CommonFiles64Folder", buf
, &size
);
5706 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5707 pSHGetFolderPathA(NULL
, CSIDL_PROGRAM_FILES_COMMON
, NULL
, 0, path
);
5708 if (size
) buf
[size
- 1] = 0;
5709 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
5713 r
= MsiGetPropertyA(hpkg
, "CommonFilesFolder", buf
, &size
);
5714 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5715 pSHGetFolderPathA(NULL
, CSIDL_PROGRAM_FILES_COMMONX86
, NULL
, 0, path
);
5716 if (size
) buf
[size
- 1] = 0;
5717 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
5721 r
= MsiGetPropertyA(hpkg
, "VersionNT64", buf
, &size
);
5722 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5723 ok(buf
[0], "property not set\n");
5725 else if (S(U(si
)).wProcessorArchitecture
== PROCESSOR_ARCHITECTURE_INTEL
)
5731 r
= MsiGetPropertyA(hpkg
, "Intel", buf
, &size
);
5732 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5733 ok(buf
[0], "property not set\n");
5737 r
= MsiGetPropertyA(hpkg
, "MsiAMD64", buf
, &size
);
5738 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5739 ok(!buf
[0], "property set\n");
5743 r
= MsiGetPropertyA(hpkg
, "Msix64", buf
, &size
);
5744 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5745 ok(!buf
[0], "property set\n");
5749 r
= MsiGetPropertyA(hpkg
, "System64Folder", buf
, &size
);
5750 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5751 ok(!buf
[0], "property set\n");
5755 r
= MsiGetPropertyA(hpkg
, "SystemFolder", buf
, &size
);
5756 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5757 GetSystemDirectoryA(path
, MAX_PATH
);
5758 if (size
) buf
[size
- 1] = 0;
5759 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
5763 r
= MsiGetPropertyA(hpkg
, "ProgramFiles64Folder", buf
, &size
);
5764 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5765 ok(!buf
[0], "property set\n");
5769 r
= MsiGetPropertyA(hpkg
, "ProgramFilesFolder", buf
, &size
);
5770 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5771 pSHGetFolderPathA(NULL
, CSIDL_PROGRAM_FILES
, NULL
, 0, path
);
5772 if (size
) buf
[size
- 1] = 0;
5773 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
5777 r
= MsiGetPropertyA(hpkg
, "CommonFiles64Folder", buf
, &size
);
5778 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5779 ok(!buf
[0], "property set\n");
5783 r
= MsiGetPropertyA(hpkg
, "CommonFilesFolder", buf
, &size
);
5784 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5785 pSHGetFolderPathA(NULL
, CSIDL_PROGRAM_FILES_COMMON
, NULL
, 0, path
);
5786 if (size
) buf
[size
- 1] = 0;
5787 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
5791 r
= MsiGetPropertyA(hpkg
, "VersionNT64", buf
, &size
);
5792 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5793 ok(!buf
[0], "property set\n");
5799 r
= MsiGetPropertyA(hpkg
, "Intel", buf
, &size
);
5800 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5801 ok(buf
[0], "property not set\n");
5805 r
= MsiGetPropertyA(hpkg
, "MsiAMD64", buf
, &size
);
5806 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5807 ok(buf
[0], "property not set\n");
5811 r
= MsiGetPropertyA(hpkg
, "Msix64", buf
, &size
);
5812 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5813 ok(buf
[0], "property not set\n");
5817 r
= MsiGetPropertyA(hpkg
, "System64Folder", buf
, &size
);
5818 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5819 GetSystemDirectoryA(path
, MAX_PATH
);
5820 if (size
) buf
[size
- 1] = 0;
5821 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
5825 r
= MsiGetPropertyA(hpkg
, "SystemFolder", buf
, &size
);
5826 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5827 pGetSystemWow64DirectoryA(path
, MAX_PATH
);
5828 if (size
) buf
[size
- 1] = 0;
5829 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
5833 r
= MsiGetPropertyA(hpkg
, "ProgramFilesFolder64", buf
, &size
);
5834 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5835 ok(!buf
[0], "property set\n");
5839 r
= MsiGetPropertyA(hpkg
, "ProgramFilesFolder", buf
, &size
);
5840 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5841 pSHGetFolderPathA(NULL
, CSIDL_PROGRAM_FILESX86
, NULL
, 0, path
);
5842 if (size
) buf
[size
- 1] = 0;
5843 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
5847 r
= MsiGetPropertyA(hpkg
, "CommonFilesFolder64", buf
, &size
);
5848 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5849 ok(!buf
[0], "property set\n");
5853 r
= MsiGetPropertyA(hpkg
, "CommonFilesFolder", buf
, &size
);
5854 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5855 pSHGetFolderPathA(NULL
, CSIDL_PROGRAM_FILES_COMMONX86
, NULL
, 0, path
);
5856 if (size
) buf
[size
- 1] = 0;
5857 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
5861 r
= MsiGetPropertyA(hpkg
, "VersionNT64", buf
, &size
);
5862 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5863 ok(buf
[0], "property not set\n");
5870 MsiCloseHandle(hpkg
);
5871 DeleteFileA(msifile
);
5872 MsiSetInternalUI(uilevel
, NULL
);
5875 static void test_launchconditions(void)
5881 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
5883 hdb
= create_package_db();
5884 ok( hdb
, "failed to create package database\n" );
5886 create_launchcondition_table( hdb
);
5888 add_launchcondition_entry( hdb
, "'X = \"1\"', 'one'" );
5890 /* invalid condition */
5891 add_launchcondition_entry( hdb
, "'X != \"1\"', 'one'" );
5893 r
= package_from_db( hdb
, &hpkg
);
5894 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
5896 skip("Not enough rights to perform tests\n");
5897 DeleteFileA(msifile
);
5900 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
5902 MsiCloseHandle( hdb
);
5904 r
= MsiSetPropertyA( hpkg
, "X", "1" );
5905 ok( r
== ERROR_SUCCESS
, "failed to set property\n" );
5907 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
5909 /* invalid conditions are ignored */
5910 r
= MsiDoActionA( hpkg
, "LaunchConditions" );
5911 ok( r
== ERROR_SUCCESS
, "cost init failed\n" );
5913 /* verify LaunchConditions still does some verification */
5914 r
= MsiSetPropertyA( hpkg
, "X", "2" );
5915 ok( r
== ERROR_SUCCESS
, "failed to set property\n" );
5917 r
= MsiDoActionA( hpkg
, "LaunchConditions" );
5918 ok( r
== ERROR_INSTALL_FAILURE
, "Expected ERROR_INSTALL_FAILURE, got %d\n", r
);
5920 MsiCloseHandle( hpkg
);
5921 DeleteFileA( msifile
);
5924 static void test_ccpsearch(void)
5926 MSIHANDLE hdb
, hpkg
;
5927 CHAR prop
[MAX_PATH
];
5928 DWORD size
= MAX_PATH
;
5931 hdb
= create_package_db();
5932 ok(hdb
, "failed to create package database\n");
5934 create_ccpsearch_table(hdb
);
5935 add_ccpsearch_entry(hdb
, "'CCP_random'");
5936 add_ccpsearch_entry(hdb
, "'RMCCP_random'");
5938 create_reglocator_table(hdb
);
5939 add_reglocator_entry(hdb
, "CCP_random", 0, "htmlfile\\shell\\open\\nonexistent", "", 1);
5941 create_drlocator_table(hdb
);
5942 add_drlocator_entry(hdb
, "'RMCCP_random', '', 'C:\\', '0'");
5944 create_signature_table(hdb
);
5946 r
= package_from_db(hdb
, &hpkg
);
5947 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
5949 skip("Not enough rights to perform tests\n");
5950 DeleteFileA(msifile
);
5953 ok(r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
5955 MsiCloseHandle(hdb
);
5957 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
5959 r
= MsiDoActionA(hpkg
, "CCPSearch");
5960 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5962 r
= MsiGetPropertyA(hpkg
, "CCP_Success", prop
, &size
);
5963 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5964 ok(!lstrcmpA(prop
, "1"), "Expected 1, got %s\n", prop
);
5966 MsiCloseHandle(hpkg
);
5967 DeleteFileA(msifile
);
5970 static void test_complocator(void)
5972 MSIHANDLE hdb
, hpkg
;
5974 CHAR prop
[MAX_PATH
];
5975 CHAR expected
[MAX_PATH
];
5976 DWORD size
= MAX_PATH
;
5978 hdb
= create_package_db();
5979 ok(hdb
, "failed to create package database\n");
5981 create_appsearch_table(hdb
);
5982 add_appsearch_entry(hdb
, "'ABELISAURUS', 'abelisaurus'");
5983 add_appsearch_entry(hdb
, "'BACTROSAURUS', 'bactrosaurus'");
5984 add_appsearch_entry(hdb
, "'CAMELOTIA', 'camelotia'");
5985 add_appsearch_entry(hdb
, "'DICLONIUS', 'diclonius'");
5986 add_appsearch_entry(hdb
, "'ECHINODON', 'echinodon'");
5987 add_appsearch_entry(hdb
, "'FALCARIUS', 'falcarius'");
5988 add_appsearch_entry(hdb
, "'GALLIMIMUS', 'gallimimus'");
5989 add_appsearch_entry(hdb
, "'HAGRYPHUS', 'hagryphus'");
5990 add_appsearch_entry(hdb
, "'IGUANODON', 'iguanodon'");
5991 add_appsearch_entry(hdb
, "'JOBARIA', 'jobaria'");
5992 add_appsearch_entry(hdb
, "'KAKURU', 'kakuru'");
5993 add_appsearch_entry(hdb
, "'LABOCANIA', 'labocania'");
5994 add_appsearch_entry(hdb
, "'MEGARAPTOR', 'megaraptor'");
5995 add_appsearch_entry(hdb
, "'NEOSODON', 'neosodon'");
5996 add_appsearch_entry(hdb
, "'OLOROTITAN', 'olorotitan'");
5997 add_appsearch_entry(hdb
, "'PANTYDRACO', 'pantydraco'");
5999 create_complocator_table(hdb
);
6000 add_complocator_entry(hdb
, "'abelisaurus', '{E3619EED-305A-418C-B9C7-F7D7377F0934}', 1");
6001 add_complocator_entry(hdb
, "'bactrosaurus', '{D56B688D-542F-42Ef-90FD-B6DA76EE8119}', 0");
6002 add_complocator_entry(hdb
, "'camelotia', '{8211BE36-2466-47E3-AFB7-6AC72E51AED2}', 1");
6003 add_complocator_entry(hdb
, "'diclonius', '{5C767B20-A33C-45A4-B80B-555E512F01AE}', 0");
6004 add_complocator_entry(hdb
, "'echinodon', '{A19E16C5-C75D-4699-8111-C4338C40C3CB}', 1");
6005 add_complocator_entry(hdb
, "'falcarius', '{17762FA1-A7AE-4CC6-8827-62873C35361D}', 0");
6006 add_complocator_entry(hdb
, "'gallimimus', '{75EBF568-C959-41E0-A99E-9050638CF5FB}', 1");
6007 add_complocator_entry(hdb
, "'hagrphus', '{D4969B72-17D9-4AB6-BE49-78F2FEE857AC}', 0");
6008 add_complocator_entry(hdb
, "'iguanodon', '{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}', 1");
6009 add_complocator_entry(hdb
, "'jobaria', '{243C22B1-8C51-4151-B9D1-1AE5265E079E}', 0");
6010 add_complocator_entry(hdb
, "'kakuru', '{5D0F03BA-50BC-44F2-ABB1-72C972F4E514}', 1");
6011 add_complocator_entry(hdb
, "'labocania', '{C7DDB60C-7828-4046-A6F8-699D5E92F1ED}', 0");
6012 add_complocator_entry(hdb
, "'megaraptor', '{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}', 1");
6013 add_complocator_entry(hdb
, "'neosodon', '{0B499649-197A-48EF-93D2-AF1C17ED6E90}', 0");
6014 add_complocator_entry(hdb
, "'olorotitan', '{54E9E91F-AED2-46D5-A25A-7E50AFA24513}', 1");
6015 add_complocator_entry(hdb
, "'pantydraco', '{2A989951-5565-4FA7-93A7-E800A3E67D71}', 0");
6017 create_signature_table(hdb
);
6018 add_signature_entry(hdb
, "'abelisaurus', 'abelisaurus', '', '', '', '', '', '', ''");
6019 add_signature_entry(hdb
, "'bactrosaurus', 'bactrosaurus', '', '', '', '', '', '', ''");
6020 add_signature_entry(hdb
, "'camelotia', 'camelotia', '', '', '', '', '', '', ''");
6021 add_signature_entry(hdb
, "'diclonius', 'diclonius', '', '', '', '', '', '', ''");
6022 add_signature_entry(hdb
, "'iguanodon', 'iguanodon', '', '', '', '', '', '', ''");
6023 add_signature_entry(hdb
, "'jobaria', 'jobaria', '', '', '', '', '', '', ''");
6024 add_signature_entry(hdb
, "'kakuru', 'kakuru', '', '', '', '', '', '', ''");
6025 add_signature_entry(hdb
, "'labocania', 'labocania', '', '', '', '', '', '', ''");
6027 r
= package_from_db(hdb
, &hpkg
);
6028 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
6030 skip("Not enough rights to perform tests\n");
6031 DeleteFileA(msifile
);
6034 ok(r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
6036 MsiCloseHandle(hdb
);
6038 create_test_file("abelisaurus");
6039 create_test_file("bactrosaurus");
6040 create_test_file("camelotia");
6041 create_test_file("diclonius");
6042 create_test_file("echinodon");
6043 create_test_file("falcarius");
6044 create_test_file("gallimimus");
6045 create_test_file("hagryphus");
6046 CreateDirectoryA("iguanodon", NULL
);
6047 CreateDirectoryA("jobaria", NULL
);
6048 CreateDirectoryA("kakuru", NULL
);
6049 CreateDirectoryA("labocania", NULL
);
6050 CreateDirectoryA("megaraptor", NULL
);
6051 CreateDirectoryA("neosodon", NULL
);
6052 CreateDirectoryA("olorotitan", NULL
);
6053 CreateDirectoryA("pantydraco", NULL
);
6055 set_component_path("abelisaurus", MSIINSTALLCONTEXT_MACHINE
,
6056 "{E3619EED-305A-418C-B9C7-F7D7377F0934}", NULL
, FALSE
);
6057 set_component_path("bactrosaurus", MSIINSTALLCONTEXT_MACHINE
,
6058 "{D56B688D-542F-42Ef-90FD-B6DA76EE8119}", NULL
, FALSE
);
6059 set_component_path("echinodon", MSIINSTALLCONTEXT_MACHINE
,
6060 "{A19E16C5-C75D-4699-8111-C4338C40C3CB}", NULL
, FALSE
);
6061 set_component_path("falcarius", MSIINSTALLCONTEXT_MACHINE
,
6062 "{17762FA1-A7AE-4CC6-8827-62873C35361D}", NULL
, FALSE
);
6063 set_component_path("iguanodon", MSIINSTALLCONTEXT_MACHINE
,
6064 "{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}", NULL
, FALSE
);
6065 set_component_path("jobaria", MSIINSTALLCONTEXT_MACHINE
,
6066 "{243C22B1-8C51-4151-B9D1-1AE5265E079E}", NULL
, FALSE
);
6067 set_component_path("megaraptor", MSIINSTALLCONTEXT_MACHINE
,
6068 "{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}", NULL
, FALSE
);
6069 set_component_path("neosodon", MSIINSTALLCONTEXT_MACHINE
,
6070 "{0B499649-197A-48EF-93D2-AF1C17ED6E90}", NULL
, FALSE
);
6072 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
6074 r
= MsiDoActionA(hpkg
, "AppSearch");
6075 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6078 r
= MsiGetPropertyA(hpkg
, "ABELISAURUS", prop
, &size
);
6079 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6081 lstrcpyA(expected
, CURR_DIR
);
6082 if (!is_root(CURR_DIR
)) lstrcatA(expected
, "\\");
6083 lstrcatA(expected
, "abelisaurus");
6084 ok(!lstrcmpA(prop
, expected
) || !lstrcmpA(prop
, ""),
6085 "Expected %s or empty string, got %s\n", expected
, prop
);
6088 r
= MsiGetPropertyA(hpkg
, "BACTROSAURUS", prop
, &size
);
6089 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6090 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6093 r
= MsiGetPropertyA(hpkg
, "CAMELOTIA", prop
, &size
);
6094 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6095 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6098 r
= MsiGetPropertyA(hpkg
, "DICLONIUS", prop
, &size
);
6099 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6100 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6103 r
= MsiGetPropertyA(hpkg
, "ECHINODON", prop
, &size
);
6104 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6106 lstrcpyA(expected
, CURR_DIR
);
6107 if (!is_root(CURR_DIR
)) lstrcatA(expected
, "\\");
6108 ok(!lstrcmpA(prop
, expected
) || !lstrcmpA(prop
, ""),
6109 "Expected %s or empty string, got %s\n", expected
, prop
);
6112 r
= MsiGetPropertyA(hpkg
, "FALCARIUS", prop
, &size
);
6113 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6114 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6117 r
= MsiGetPropertyA(hpkg
, "GALLIMIMUS", prop
, &size
);
6118 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6119 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6122 r
= MsiGetPropertyA(hpkg
, "HAGRYPHUS", prop
, &size
);
6123 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6124 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6127 r
= MsiGetPropertyA(hpkg
, "IGUANODON", prop
, &size
);
6128 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6129 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6132 r
= MsiGetPropertyA(hpkg
, "JOBARIA", prop
, &size
);
6133 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6134 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6137 r
= MsiGetPropertyA(hpkg
, "KAKURU", prop
, &size
);
6138 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6139 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6142 r
= MsiGetPropertyA(hpkg
, "LABOCANIA", prop
, &size
);
6143 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6144 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6147 r
= MsiGetPropertyA(hpkg
, "MEGARAPTOR", prop
, &size
);
6148 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6150 lstrcpyA(expected
, CURR_DIR
);
6151 if (!is_root(CURR_DIR
)) lstrcatA(expected
, "\\");
6152 ok(!lstrcmpA(prop
, expected
) || !lstrcmpA(prop
, ""),
6153 "Expected %s or empty string, got %s\n", expected
, prop
);
6156 r
= MsiGetPropertyA(hpkg
, "NEOSODON", prop
, &size
);
6157 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6159 lstrcpyA(expected
, CURR_DIR
);
6160 if (!is_root(CURR_DIR
)) lstrcatA(expected
, "\\");
6161 lstrcatA(expected
, "neosodon\\");
6162 ok(!lstrcmpA(prop
, expected
) || !lstrcmpA(prop
, ""),
6163 "Expected %s or empty string, got %s\n", expected
, prop
);
6166 r
= MsiGetPropertyA(hpkg
, "OLOROTITAN", prop
, &size
);
6167 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6168 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6171 r
= MsiGetPropertyA(hpkg
, "PANTYDRACO", prop
, &size
);
6172 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6173 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6175 MsiCloseHandle(hpkg
);
6176 DeleteFileA("abelisaurus");
6177 DeleteFileA("bactrosaurus");
6178 DeleteFileA("camelotia");
6179 DeleteFileA("diclonius");
6180 DeleteFileA("echinodon");
6181 DeleteFileA("falcarius");
6182 DeleteFileA("gallimimus");
6183 DeleteFileA("hagryphus");
6184 RemoveDirectoryA("iguanodon");
6185 RemoveDirectoryA("jobaria");
6186 RemoveDirectoryA("kakuru");
6187 RemoveDirectoryA("labocania");
6188 RemoveDirectoryA("megaraptor");
6189 RemoveDirectoryA("neosodon");
6190 RemoveDirectoryA("olorotitan");
6191 RemoveDirectoryA("pantydraco");
6192 delete_component_path("{E3619EED-305A-418C-B9C7-F7D7377F0934}",
6193 MSIINSTALLCONTEXT_MACHINE
, NULL
);
6194 delete_component_path("{D56B688D-542F-42Ef-90FD-B6DA76EE8119}",
6195 MSIINSTALLCONTEXT_MACHINE
, NULL
);
6196 delete_component_path("{A19E16C5-C75D-4699-8111-C4338C40C3CB}",
6197 MSIINSTALLCONTEXT_MACHINE
, NULL
);
6198 delete_component_path("{17762FA1-A7AE-4CC6-8827-62873C35361D}",
6199 MSIINSTALLCONTEXT_MACHINE
, NULL
);
6200 delete_component_path("{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}",
6201 MSIINSTALLCONTEXT_MACHINE
, NULL
);
6202 delete_component_path("{243C22B1-8C51-4151-B9D1-1AE5265E079E}",
6203 MSIINSTALLCONTEXT_MACHINE
, NULL
);
6204 delete_component_path("{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}",
6205 MSIINSTALLCONTEXT_MACHINE
, NULL
);
6206 delete_component_path("{0B499649-197A-48EF-93D2-AF1C17ED6E90}",
6207 MSIINSTALLCONTEXT_MACHINE
, NULL
);
6208 DeleteFileA(msifile
);
6211 static void set_suminfo_prop(MSIHANDLE db
, DWORD prop
, DWORD val
)
6216 r
= MsiGetSummaryInformationA(db
, NULL
, 1, &summary
);
6217 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6219 r
= MsiSummaryInfoSetPropertyA(summary
, prop
, VT_I4
, val
, NULL
, NULL
);
6220 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6222 r
= MsiSummaryInfoPersist(summary
);
6223 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
6225 MsiCloseHandle(summary
);
6228 static void test_MsiGetSourcePath(void)
6230 MSIHANDLE hdb
, hpkg
;
6231 CHAR path
[MAX_PATH
];
6233 CHAR subsrc
[MAX_PATH
];
6234 CHAR sub2
[MAX_PATH
];
6238 lstrcpyA(cwd
, CURR_DIR
);
6239 if (!is_root(CURR_DIR
)) lstrcatA(cwd
, "\\");
6241 lstrcpyA(subsrc
, cwd
);
6242 lstrcatA(subsrc
, "subsource");
6243 lstrcatA(subsrc
, "\\");
6245 lstrcpyA(sub2
, subsrc
);
6246 lstrcatA(sub2
, "sub2");
6247 lstrcatA(sub2
, "\\");
6249 /* uncompressed source */
6251 hdb
= create_package_db();
6252 ok( hdb
, "failed to create database\n");
6254 set_suminfo_prop(hdb
, PID_WORDCOUNT
, 0);
6256 add_directory_entry(hdb
, "'TARGETDIR', '', 'SourceDir'");
6257 add_directory_entry(hdb
, "'SubDir', 'TARGETDIR', 'subtarget:subsource'");
6258 add_directory_entry(hdb
, "'SubDir2', 'SubDir', 'sub2'");
6260 r
= MsiDatabaseCommit(hdb
);
6261 ok(r
== ERROR_SUCCESS
, "Failed to commit database\n");
6263 r
= package_from_db(hdb
, &hpkg
);
6264 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
6266 skip("Not enough rights to perform tests\n");
6267 DeleteFileA(msifile
);
6270 ok(r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
6272 MsiCloseHandle(hdb
);
6274 /* invalid database handle */
6276 lstrcpyA(path
, "kiwi");
6277 r
= MsiGetSourcePathA(-1, "TARGETDIR", path
, &size
);
6278 ok(r
== ERROR_INVALID_HANDLE
,
6279 "Expected ERROR_INVALID_HANDLE, got %d\n", r
);
6280 ok(!lstrcmpA(path
, "kiwi"),
6281 "Expected path to be unchanged, got \"%s\"\n", path
);
6282 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6286 lstrcpyA(path
, "kiwi");
6287 r
= MsiGetSourcePathA(hpkg
, NULL
, path
, &size
);
6288 ok(r
== ERROR_INVALID_PARAMETER
,
6289 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
6290 ok(!lstrcmpA(path
, "kiwi"),
6291 "Expected path to be unchanged, got \"%s\"\n", path
);
6292 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6294 /* empty szFolder */
6296 lstrcpyA(path
, "kiwi");
6297 r
= MsiGetSourcePathA(hpkg
, "", path
, &size
);
6298 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6299 ok(!lstrcmpA(path
, "kiwi"),
6300 "Expected path to be unchanged, got \"%s\"\n", path
);
6301 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6305 lstrcpyA(path
, "kiwi");
6306 r
= MsiGetSourcePathA(hpkg
, "TARGETDIR", path
, &size
);
6307 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6308 ok(!lstrcmpA(path
, "kiwi"),
6309 "Expected path to be unchanged, got \"%s\"\n", path
);
6310 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6313 lstrcpyA(path
, "kiwi");
6314 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
6315 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6316 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
6317 ok(size
== 0, "Expected 0, got %d\n", size
);
6320 lstrcpyA(path
, "kiwi");
6321 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
6322 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6323 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
6324 ok(size
== 0, "Expected 0, got %d\n", size
);
6328 lstrcpyA(path
, "kiwi");
6329 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6330 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6331 ok(!lstrcmpA(path
, "kiwi"),
6332 "Expected path to be unchanged, got \"%s\"\n", path
);
6333 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6337 lstrcpyA(path
, "kiwi");
6338 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
6339 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6340 ok(!lstrcmpA(path
, "kiwi"),
6341 "Expected path to be unchanged, got \"%s\"\n", path
);
6342 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6344 /* source path does not exist, but the property exists */
6346 lstrcpyA(path
, "kiwi");
6347 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
6348 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6349 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
6350 ok(size
== 0, "Expected 0, got %d\n", size
);
6353 lstrcpyA(path
, "kiwi");
6354 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
6355 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6356 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
6357 ok(size
== 0, "Expected 0, got %d\n", size
);
6361 lstrcpyA(path
, "kiwi");
6362 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
6363 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6364 ok(!lstrcmpA(path
, "kiwi"),
6365 "Expected path to be unchanged, got \"%s\"\n", path
);
6366 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6370 lstrcpyA(path
, "kiwi");
6371 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
6372 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6373 ok(!lstrcmpA(path
, "kiwi"),
6374 "Expected path to be unchanged, got \"%s\"\n", path
);
6375 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6377 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
6379 r
= MsiDoActionA(hpkg
, "CostInitialize");
6380 ok(r
== ERROR_SUCCESS
, "cost init failed\n");
6382 /* try TARGETDIR after CostInitialize */
6384 lstrcpyA(path
, "kiwi");
6385 r
= MsiGetSourcePathA(hpkg
, "TARGETDIR", path
, &size
);
6386 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6387 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6388 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6390 /* try SourceDir after CostInitialize */
6392 lstrcpyA(path
, "kiwi");
6393 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6394 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6395 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6396 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6398 /* try SOURCEDIR after CostInitialize */
6400 lstrcpyA(path
, "kiwi");
6401 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
6402 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6403 ok(!lstrcmpA(path
, "kiwi"),
6404 "Expected path to be unchanged, got \"%s\"\n", path
);
6405 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6407 /* source path does not exist, but the property exists */
6409 lstrcpyA(path
, "kiwi");
6410 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
6411 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6412 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6413 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6416 lstrcpyA(path
, "kiwi");
6417 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
6418 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6419 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6420 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6422 /* try SubDir after CostInitialize */
6424 lstrcpyA(path
, "kiwi");
6425 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
6426 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6427 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
6428 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
6430 /* try SubDir2 after CostInitialize */
6432 lstrcpyA(path
, "kiwi");
6433 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
6434 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6435 ok(!lstrcmpA(path
, sub2
), "Expected \"%s\", got \"%s\"\n", sub2
, path
);
6436 ok(size
== lstrlenA(sub2
), "Expected %d, got %d\n", lstrlenA(sub2
), size
);
6438 r
= MsiDoActionA(hpkg
, "ResolveSource");
6439 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
6441 /* try TARGETDIR after ResolveSource */
6443 lstrcpyA(path
, "kiwi");
6444 r
= MsiGetSourcePathA(hpkg
, "TARGETDIR", path
, &size
);
6445 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6446 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6447 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6449 /* try SourceDir after ResolveSource */
6451 lstrcpyA(path
, "kiwi");
6452 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6453 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6454 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6455 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6457 /* try SOURCEDIR after ResolveSource */
6459 lstrcpyA(path
, "kiwi");
6460 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
6461 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6462 ok(!lstrcmpA(path
, "kiwi"),
6463 "Expected path to be unchanged, got \"%s\"\n", path
);
6464 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6466 /* source path does not exist, but the property exists */
6468 lstrcpyA(path
, "kiwi");
6469 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
6470 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6471 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6472 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6475 lstrcpyA(path
, "kiwi");
6476 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
6477 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6478 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6479 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6481 /* try SubDir after ResolveSource */
6483 lstrcpyA(path
, "kiwi");
6484 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
6485 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6486 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
6487 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
6489 /* try SubDir2 after ResolveSource */
6491 lstrcpyA(path
, "kiwi");
6492 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
6493 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6494 ok(!lstrcmpA(path
, sub2
), "Expected \"%s\", got \"%s\"\n", sub2
, path
);
6495 ok(size
== lstrlenA(sub2
), "Expected %d, got %d\n", lstrlenA(sub2
), size
);
6497 r
= MsiDoActionA(hpkg
, "FileCost");
6498 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
6500 /* try TARGETDIR after FileCost */
6502 lstrcpyA(path
, "kiwi");
6503 r
= MsiGetSourcePathA(hpkg
, "TARGETDIR", path
, &size
);
6504 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6505 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6506 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6508 /* try SourceDir after FileCost */
6510 lstrcpyA(path
, "kiwi");
6511 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6512 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6513 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6514 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6516 /* try SOURCEDIR after FileCost */
6518 lstrcpyA(path
, "kiwi");
6519 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
6520 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6521 ok(!lstrcmpA(path
, "kiwi"),
6522 "Expected path to be unchanged, got \"%s\"\n", path
);
6523 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6525 /* source path does not exist, but the property exists */
6527 lstrcpyA(path
, "kiwi");
6528 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
6529 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6530 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6531 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6534 lstrcpyA(path
, "kiwi");
6535 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
6536 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6537 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6538 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6540 /* try SubDir after FileCost */
6542 lstrcpyA(path
, "kiwi");
6543 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
6544 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6545 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
6546 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
6548 /* try SubDir2 after FileCost */
6550 lstrcpyA(path
, "kiwi");
6551 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
6552 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6553 ok(!lstrcmpA(path
, sub2
), "Expected \"%s\", got \"%s\"\n", sub2
, path
);
6554 ok(size
== lstrlenA(sub2
), "Expected %d, got %d\n", lstrlenA(sub2
), size
);
6556 r
= MsiDoActionA(hpkg
, "CostFinalize");
6557 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
6559 /* try TARGETDIR after CostFinalize */
6561 lstrcpyA(path
, "kiwi");
6562 r
= MsiGetSourcePathA(hpkg
, "TARGETDIR", path
, &size
);
6563 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6564 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6565 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6567 /* try SourceDir after CostFinalize */
6569 lstrcpyA(path
, "kiwi");
6570 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6571 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6572 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6573 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6575 /* try SOURCEDIR after CostFinalize */
6577 lstrcpyA(path
, "kiwi");
6578 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
6579 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6580 ok(!lstrcmpA(path
, "kiwi"),
6581 "Expected path to be unchanged, got \"%s\"\n", path
);
6582 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6584 /* source path does not exist, but the property exists */
6586 lstrcpyA(path
, "kiwi");
6587 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
6588 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6589 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6590 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6593 lstrcpyA(path
, "kiwi");
6594 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
6595 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6596 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6597 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6599 /* try SubDir after CostFinalize */
6601 lstrcpyA(path
, "kiwi");
6602 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
6603 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6604 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
6605 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
6607 /* try SubDir2 after CostFinalize */
6609 lstrcpyA(path
, "kiwi");
6610 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
6611 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6612 ok(!lstrcmpA(path
, sub2
), "Expected \"%s\", got \"%s\"\n", sub2
, path
);
6613 ok(size
== lstrlenA(sub2
), "Expected %d, got %d\n", lstrlenA(sub2
), size
);
6615 /* nonexistent directory */
6617 lstrcpyA(path
, "kiwi");
6618 r
= MsiGetSourcePathA(hpkg
, "IDontExist", path
, &size
);
6619 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6620 ok(!lstrcmpA(path
, "kiwi"),
6621 "Expected path to be unchanged, got \"%s\"\n", path
);
6622 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6624 /* NULL szPathBuf */
6626 r
= MsiGetSourcePathA(hpkg
, "SourceDir", NULL
, &size
);
6627 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6628 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6630 /* NULL pcchPathBuf */
6631 lstrcpyA(path
, "kiwi");
6632 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, NULL
);
6633 ok(r
== ERROR_INVALID_PARAMETER
,
6634 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
6635 ok(!lstrcmpA(path
, "kiwi"),
6636 "Expected path to be unchanged, got \"%s\"\n", path
);
6638 /* pcchPathBuf is 0 */
6640 lstrcpyA(path
, "kiwi");
6641 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6642 ok(r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
6643 ok(!lstrcmpA(path
, "kiwi"),
6644 "Expected path to be unchanged, got \"%s\"\n", path
);
6645 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6647 /* pcchPathBuf does not have room for NULL terminator */
6648 size
= lstrlenA(cwd
);
6649 lstrcpyA(path
, "kiwi");
6650 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6651 ok(r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
6652 ok(!strncmp(path
, cwd
, lstrlenA(cwd
) - 1),
6653 "Expected path with no backslash, got \"%s\"\n", path
);
6654 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6656 /* pcchPathBuf has room for NULL terminator */
6657 size
= lstrlenA(cwd
) + 1;
6658 lstrcpyA(path
, "kiwi");
6659 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6660 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6661 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6662 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6664 /* remove property */
6665 r
= MsiSetPropertyA(hpkg
, "SourceDir", NULL
);
6666 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6668 /* try SourceDir again */
6670 lstrcpyA(path
, "kiwi");
6671 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6672 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6673 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6674 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6676 /* set property to a valid directory */
6677 r
= MsiSetPropertyA(hpkg
, "SOURCEDIR", cwd
);
6678 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6680 /* try SOURCEDIR again */
6682 lstrcpyA(path
, "kiwi");
6683 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
6684 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6685 ok(!lstrcmpA(path
, "kiwi"),
6686 "Expected path to be unchanged, got \"%s\"\n", path
);
6687 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6689 MsiCloseHandle(hpkg
);
6691 /* compressed source */
6693 r
= MsiOpenDatabaseW(msifileW
, MSIDBOPEN_DIRECT
, &hdb
);
6694 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6696 set_suminfo_prop(hdb
, PID_WORDCOUNT
, msidbSumInfoSourceTypeCompressed
);
6698 r
= package_from_db(hdb
, &hpkg
);
6699 ok(r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
6703 lstrcpyA(path
, "kiwi");
6704 r
= MsiGetSourcePathA(hpkg
, "TARGETDIR", path
, &size
);
6705 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6706 ok(!lstrcmpA(path
, "kiwi"),
6707 "Expected path to be unchanged, got \"%s\"\n", path
);
6708 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6712 lstrcpyA(path
, "kiwi");
6713 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6714 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6715 ok(!lstrcmpA(path
, "kiwi"),
6716 "Expected path to be unchanged, got \"%s\"\n", path
);
6717 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6721 lstrcpyA(path
, "kiwi");
6722 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
6723 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6724 ok(!lstrcmpA(path
, "kiwi"),
6725 "Expected path to be unchanged, got \"%s\"\n", path
);
6726 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6728 /* source path nor the property exist */
6730 lstrcpyA(path
, "kiwi");
6731 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
6732 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6733 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
6734 ok(size
== 0, "Expected 0, got %d\n", size
);
6737 lstrcpyA(path
, "kiwi");
6738 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
6739 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6740 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
6741 ok(size
== 0, "Expected 0, got %d\n", size
);
6745 lstrcpyA(path
, "kiwi");
6746 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
6747 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6748 ok(!lstrcmpA(path
, "kiwi"),
6749 "Expected path to be unchanged, got \"%s\"\n", path
);
6750 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6754 lstrcpyA(path
, "kiwi");
6755 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
6756 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6757 ok(!lstrcmpA(path
, "kiwi"),
6758 "Expected path to be unchanged, got \"%s\"\n", path
);
6759 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6761 r
= MsiDoActionA(hpkg
, "CostInitialize");
6762 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6764 /* try TARGETDIR after CostInitialize */
6766 lstrcpyA(path
, "kiwi");
6767 r
= MsiGetSourcePathA(hpkg
, "TARGETDIR", path
, &size
);
6768 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6769 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6770 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6772 /* try SourceDir after CostInitialize */
6774 lstrcpyA(path
, "kiwi");
6775 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6776 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6777 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6778 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6780 /* try SOURCEDIR after CostInitialize */
6782 lstrcpyA(path
, "kiwi");
6783 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
6786 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6787 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6788 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6791 /* source path does not exist, but the property exists */
6793 lstrcpyA(path
, "kiwi");
6794 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
6795 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6796 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6797 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6800 lstrcpyA(path
, "kiwi");
6801 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
6802 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6803 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6804 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6806 /* try SubDir after CostInitialize */
6808 lstrcpyA(path
, "kiwi");
6809 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
6810 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6811 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6812 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6814 /* try SubDir2 after CostInitialize */
6816 lstrcpyA(path
, "kiwi");
6817 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
6818 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6819 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6820 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6822 r
= MsiDoActionA(hpkg
, "ResolveSource");
6823 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
6825 /* try TARGETDIR after ResolveSource */
6827 lstrcpyA(path
, "kiwi");
6828 r
= MsiGetSourcePathA(hpkg
, "TARGETDIR", path
, &size
);
6829 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6830 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6831 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6833 /* try SourceDir after ResolveSource */
6835 lstrcpyA(path
, "kiwi");
6836 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6837 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6838 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6839 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6841 /* try SOURCEDIR after ResolveSource */
6843 lstrcpyA(path
, "kiwi");
6844 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
6847 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6848 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6849 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6852 /* source path and the property exist */
6854 lstrcpyA(path
, "kiwi");
6855 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
6856 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6857 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6858 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6861 lstrcpyA(path
, "kiwi");
6862 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
6863 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6864 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6865 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6867 /* try SubDir after ResolveSource */
6869 lstrcpyA(path
, "kiwi");
6870 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
6871 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6872 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6873 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6875 /* try SubDir2 after ResolveSource */
6877 lstrcpyA(path
, "kiwi");
6878 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
6879 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6880 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6881 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6883 r
= MsiDoActionA(hpkg
, "FileCost");
6884 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6886 /* try TARGETDIR after CostFinalize */
6888 lstrcpyA(path
, "kiwi");
6889 r
= MsiGetSourcePathA(hpkg
, "TARGETDIR", path
, &size
);
6890 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6891 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6892 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6894 /* try SourceDir after CostFinalize */
6896 lstrcpyA(path
, "kiwi");
6897 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6898 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6899 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6900 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6902 /* try SOURCEDIR after CostFinalize */
6904 lstrcpyA(path
, "kiwi");
6905 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
6908 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6909 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6910 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6913 /* source path and the property exist */
6915 lstrcpyA(path
, "kiwi");
6916 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
6917 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6918 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6919 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6922 lstrcpyA(path
, "kiwi");
6923 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
6924 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6925 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6926 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6928 /* try SubDir after CostFinalize */
6930 lstrcpyA(path
, "kiwi");
6931 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
6932 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6933 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6934 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6936 /* try SubDir2 after CostFinalize */
6938 lstrcpyA(path
, "kiwi");
6939 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
6940 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6941 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6942 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6944 r
= MsiDoActionA(hpkg
, "CostFinalize");
6945 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6947 /* try TARGETDIR after CostFinalize */
6949 lstrcpyA(path
, "kiwi");
6950 r
= MsiGetSourcePathA(hpkg
, "TARGETDIR", path
, &size
);
6951 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6952 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6953 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6955 /* try SourceDir after CostFinalize */
6957 lstrcpyA(path
, "kiwi");
6958 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6959 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6960 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6961 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6963 /* try SOURCEDIR after CostFinalize */
6965 lstrcpyA(path
, "kiwi");
6966 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
6969 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6970 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6971 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6974 /* source path and the property exist */
6976 lstrcpyA(path
, "kiwi");
6977 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
6978 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6979 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6980 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6983 lstrcpyA(path
, "kiwi");
6984 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
6985 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6986 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6987 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6989 /* try SubDir after CostFinalize */
6991 lstrcpyA(path
, "kiwi");
6992 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
6993 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6994 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6995 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6997 /* try SubDir2 after CostFinalize */
6999 lstrcpyA(path
, "kiwi");
7000 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
7001 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7002 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7003 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7005 MsiCloseHandle(hpkg
);
7006 DeleteFileA(msifile
);
7009 static void test_shortlongsource(void)
7011 MSIHANDLE hdb
, hpkg
;
7012 CHAR path
[MAX_PATH
];
7014 CHAR subsrc
[MAX_PATH
];
7018 lstrcpyA(cwd
, CURR_DIR
);
7019 if (!is_root(CURR_DIR
)) lstrcatA(cwd
, "\\");
7021 lstrcpyA(subsrc
, cwd
);
7022 lstrcatA(subsrc
, "long");
7023 lstrcatA(subsrc
, "\\");
7025 /* long file names */
7027 hdb
= create_package_db();
7028 ok( hdb
, "failed to create database\n");
7030 set_suminfo_prop(hdb
, PID_WORDCOUNT
, 0);
7032 add_directory_entry(hdb
, "'TARGETDIR', '', 'SourceDir'");
7033 add_directory_entry(hdb
, "'SubDir', 'TARGETDIR', 'short|long'");
7035 /* CostInitialize:short */
7036 add_directory_entry(hdb
, "'SubDir2', 'TARGETDIR', 'one|two'");
7038 /* CostInitialize:long */
7039 add_directory_entry(hdb
, "'SubDir3', 'TARGETDIR', 'three|four'");
7041 /* FileCost:short */
7042 add_directory_entry(hdb
, "'SubDir4', 'TARGETDIR', 'five|six'");
7045 add_directory_entry(hdb
, "'SubDir5', 'TARGETDIR', 'seven|eight'");
7047 /* CostFinalize:short */
7048 add_directory_entry(hdb
, "'SubDir6', 'TARGETDIR', 'nine|ten'");
7050 /* CostFinalize:long */
7051 add_directory_entry(hdb
, "'SubDir7', 'TARGETDIR', 'eleven|twelve'");
7053 MsiDatabaseCommit(hdb
);
7055 r
= package_from_db(hdb
, &hpkg
);
7056 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
7058 skip("Not enough rights to perform tests\n");
7059 DeleteFileA(msifile
);
7062 ok(r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
7064 MsiCloseHandle(hdb
);
7066 CreateDirectoryA("one", NULL
);
7067 CreateDirectoryA("four", NULL
);
7069 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
7071 r
= MsiDoActionA(hpkg
, "CostInitialize");
7072 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7074 CreateDirectoryA("five", NULL
);
7075 CreateDirectoryA("eight", NULL
);
7077 r
= MsiDoActionA(hpkg
, "FileCost");
7078 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7080 CreateDirectoryA("nine", NULL
);
7081 CreateDirectoryA("twelve", NULL
);
7083 r
= MsiDoActionA(hpkg
, "CostFinalize");
7084 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7086 /* neither short nor long source directories exist */
7088 lstrcpyA(path
, "kiwi");
7089 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
7090 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7091 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7092 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7094 CreateDirectoryA("short", NULL
);
7096 /* short source directory exists */
7098 lstrcpyA(path
, "kiwi");
7099 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
7100 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7101 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7102 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7104 CreateDirectoryA("long", NULL
);
7106 /* both short and long source directories exist */
7108 lstrcpyA(path
, "kiwi");
7109 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
7110 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7111 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7112 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7114 lstrcpyA(subsrc
, cwd
);
7115 lstrcatA(subsrc
, "two");
7116 lstrcatA(subsrc
, "\\");
7118 /* short dir exists before CostInitialize */
7120 lstrcpyA(path
, "kiwi");
7121 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
7122 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7123 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7124 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7126 lstrcpyA(subsrc
, cwd
);
7127 lstrcatA(subsrc
, "four");
7128 lstrcatA(subsrc
, "\\");
7130 /* long dir exists before CostInitialize */
7132 lstrcpyA(path
, "kiwi");
7133 r
= MsiGetSourcePathA(hpkg
, "SubDir3", path
, &size
);
7134 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7135 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7136 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7138 lstrcpyA(subsrc
, cwd
);
7139 lstrcatA(subsrc
, "six");
7140 lstrcatA(subsrc
, "\\");
7142 /* short dir exists before FileCost */
7144 lstrcpyA(path
, "kiwi");
7145 r
= MsiGetSourcePathA(hpkg
, "SubDir4", path
, &size
);
7146 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7147 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7148 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7150 lstrcpyA(subsrc
, cwd
);
7151 lstrcatA(subsrc
, "eight");
7152 lstrcatA(subsrc
, "\\");
7154 /* long dir exists before FileCost */
7156 lstrcpyA(path
, "kiwi");
7157 r
= MsiGetSourcePathA(hpkg
, "SubDir5", path
, &size
);
7158 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7159 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7160 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7162 lstrcpyA(subsrc
, cwd
);
7163 lstrcatA(subsrc
, "ten");
7164 lstrcatA(subsrc
, "\\");
7166 /* short dir exists before CostFinalize */
7168 lstrcpyA(path
, "kiwi");
7169 r
= MsiGetSourcePathA(hpkg
, "SubDir6", path
, &size
);
7170 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7171 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7172 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7174 lstrcpyA(subsrc
, cwd
);
7175 lstrcatA(subsrc
, "twelve");
7176 lstrcatA(subsrc
, "\\");
7178 /* long dir exists before CostFinalize */
7180 lstrcpyA(path
, "kiwi");
7181 r
= MsiGetSourcePathA(hpkg
, "SubDir7", path
, &size
);
7182 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7183 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7184 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7186 MsiCloseHandle(hpkg
);
7187 RemoveDirectoryA("short");
7188 RemoveDirectoryA("long");
7189 RemoveDirectoryA("one");
7190 RemoveDirectoryA("four");
7191 RemoveDirectoryA("five");
7192 RemoveDirectoryA("eight");
7193 RemoveDirectoryA("nine");
7194 RemoveDirectoryA("twelve");
7196 /* short file names */
7198 r
= MsiOpenDatabaseW(msifileW
, MSIDBOPEN_DIRECT
, &hdb
);
7199 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7201 set_suminfo_prop(hdb
, PID_WORDCOUNT
, msidbSumInfoSourceTypeSFN
);
7203 r
= package_from_db(hdb
, &hpkg
);
7204 ok(r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
7206 MsiCloseHandle(hdb
);
7208 CreateDirectoryA("one", NULL
);
7209 CreateDirectoryA("four", NULL
);
7211 r
= MsiDoActionA(hpkg
, "CostInitialize");
7212 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7214 CreateDirectoryA("five", NULL
);
7215 CreateDirectoryA("eight", NULL
);
7217 r
= MsiDoActionA(hpkg
, "FileCost");
7218 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7220 CreateDirectoryA("nine", NULL
);
7221 CreateDirectoryA("twelve", NULL
);
7223 r
= MsiDoActionA(hpkg
, "CostFinalize");
7224 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7226 lstrcpyA(subsrc
, cwd
);
7227 lstrcatA(subsrc
, "short");
7228 lstrcatA(subsrc
, "\\");
7230 /* neither short nor long source directories exist */
7232 lstrcpyA(path
, "kiwi");
7233 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
7234 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7235 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7236 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7238 CreateDirectoryA("short", NULL
);
7240 /* short source directory exists */
7242 lstrcpyA(path
, "kiwi");
7243 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
7244 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7245 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7246 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7248 CreateDirectoryA("long", NULL
);
7250 /* both short and long source directories exist */
7252 lstrcpyA(path
, "kiwi");
7253 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
7254 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7255 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7256 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7258 lstrcpyA(subsrc
, cwd
);
7259 lstrcatA(subsrc
, "one");
7260 lstrcatA(subsrc
, "\\");
7262 /* short dir exists before CostInitialize */
7264 lstrcpyA(path
, "kiwi");
7265 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
7266 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7267 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7268 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7270 lstrcpyA(subsrc
, cwd
);
7271 lstrcatA(subsrc
, "three");
7272 lstrcatA(subsrc
, "\\");
7274 /* long dir exists before CostInitialize */
7276 lstrcpyA(path
, "kiwi");
7277 r
= MsiGetSourcePathA(hpkg
, "SubDir3", path
, &size
);
7278 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7279 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7280 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7282 lstrcpyA(subsrc
, cwd
);
7283 lstrcatA(subsrc
, "five");
7284 lstrcatA(subsrc
, "\\");
7286 /* short dir exists before FileCost */
7288 lstrcpyA(path
, "kiwi");
7289 r
= MsiGetSourcePathA(hpkg
, "SubDir4", path
, &size
);
7290 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7291 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7292 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7294 lstrcpyA(subsrc
, cwd
);
7295 lstrcatA(subsrc
, "seven");
7296 lstrcatA(subsrc
, "\\");
7298 /* long dir exists before FileCost */
7300 lstrcpyA(path
, "kiwi");
7301 r
= MsiGetSourcePathA(hpkg
, "SubDir5", path
, &size
);
7302 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7303 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7304 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7306 lstrcpyA(subsrc
, cwd
);
7307 lstrcatA(subsrc
, "nine");
7308 lstrcatA(subsrc
, "\\");
7310 /* short dir exists before CostFinalize */
7312 lstrcpyA(path
, "kiwi");
7313 r
= MsiGetSourcePathA(hpkg
, "SubDir6", path
, &size
);
7314 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7315 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7316 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7318 lstrcpyA(subsrc
, cwd
);
7319 lstrcatA(subsrc
, "eleven");
7320 lstrcatA(subsrc
, "\\");
7322 /* long dir exists before CostFinalize */
7324 lstrcpyA(path
, "kiwi");
7325 r
= MsiGetSourcePathA(hpkg
, "SubDir7", path
, &size
);
7326 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7327 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7328 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7330 MsiCloseHandle(hpkg
);
7331 RemoveDirectoryA("short");
7332 RemoveDirectoryA("long");
7333 RemoveDirectoryA("one");
7334 RemoveDirectoryA("four");
7335 RemoveDirectoryA("five");
7336 RemoveDirectoryA("eight");
7337 RemoveDirectoryA("nine");
7338 RemoveDirectoryA("twelve");
7339 DeleteFileA(msifile
);
7342 static void test_sourcedir(void)
7344 MSIHANDLE hdb
, hpkg
;
7346 CHAR path
[MAX_PATH
];
7348 CHAR subsrc
[MAX_PATH
];
7352 lstrcpyA(cwd
, CURR_DIR
);
7353 if (!is_root(CURR_DIR
)) lstrcatA(cwd
, "\\");
7355 lstrcpyA(subsrc
, cwd
);
7356 lstrcatA(subsrc
, "long");
7357 lstrcatA(subsrc
, "\\");
7359 hdb
= create_package_db();
7360 ok( hdb
, "failed to create database\n");
7362 add_directory_entry(hdb
, "'TARGETDIR', '', 'SourceDir'");
7364 sprintf(package
, "#%u", hdb
);
7365 r
= MsiOpenPackageA(package
, &hpkg
);
7366 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
7368 skip("Not enough rights to perform tests\n");
7371 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7373 /* properties only */
7375 /* SourceDir prop */
7377 lstrcpyA(path
, "kiwi");
7378 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7379 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7380 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7381 ok(size
== 0, "Expected 0, got %d\n", size
);
7383 /* SOURCEDIR prop */
7385 lstrcpyA(path
, "kiwi");
7386 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7387 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7388 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7389 ok(size
== 0, "Expected 0, got %d\n", size
);
7391 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
7393 r
= MsiDoActionA(hpkg
, "CostInitialize");
7394 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7396 /* SourceDir after CostInitialize */
7398 lstrcpyA(path
, "kiwi");
7399 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7400 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7401 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7402 ok(size
== 0, "Expected 0, got %d\n", size
);
7404 /* SOURCEDIR after CostInitialize */
7406 lstrcpyA(path
, "kiwi");
7407 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7408 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7409 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7410 ok(size
== 0, "Expected 0, got %d\n", size
);
7412 r
= MsiDoActionA(hpkg
, "FileCost");
7413 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7415 /* SourceDir after FileCost */
7417 lstrcpyA(path
, "kiwi");
7418 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7419 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7420 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7421 ok(size
== 0, "Expected 0, got %d\n", size
);
7423 /* SOURCEDIR after FileCost */
7425 lstrcpyA(path
, "kiwi");
7426 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7427 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7428 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7429 ok(size
== 0, "Expected 0, got %d\n", size
);
7431 r
= MsiDoActionA(hpkg
, "CostFinalize");
7432 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7434 /* SourceDir after CostFinalize */
7436 lstrcpyA(path
, "kiwi");
7437 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7438 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7439 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7440 ok(size
== 0, "Expected 0, got %d\n", size
);
7442 /* SOURCEDIR after CostFinalize */
7444 lstrcpyA(path
, "kiwi");
7445 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7446 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7447 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7448 ok(size
== 0, "Expected 0, got %d\n", size
);
7451 lstrcpyA(path
, "kiwi");
7452 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
7453 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
7454 ok(!lstrcmpA(path
, "kiwi"), "Expected \"kiwi\", got \"%s\"\n", path
);
7455 ok(size
== MAX_PATH
, "Expected %d, got %d\n", MAX_PATH
, size
);
7457 /* SOURCEDIR after calling MsiGetSourcePath */
7459 lstrcpyA(path
, "kiwi");
7460 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7461 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7463 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7464 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7467 r
= MsiDoActionA(hpkg
, "ResolveSource");
7468 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7470 /* SourceDir after ResolveSource */
7472 lstrcpyA(path
, "kiwi");
7473 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7474 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7475 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7476 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7478 /* SOURCEDIR after ResolveSource */
7480 lstrcpyA(path
, "kiwi");
7481 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7482 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7483 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7484 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7488 lstrcpyA(path
, "kiwi");
7489 r
= MsiGetPropertyA(hpkg
, "SoUrCeDiR", path
, &size
);
7490 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7491 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7492 ok(size
== 0, "Expected 0, got %d\n", size
);
7494 MsiCloseHandle(hpkg
);
7496 /* reset the package state */
7497 sprintf(package
, "#%i", hdb
);
7498 r
= MsiOpenPackageA(package
, &hpkg
);
7499 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7501 /* test how MsiGetSourcePath affects the properties */
7503 /* SourceDir prop */
7505 lstrcpyA(path
, "kiwi");
7506 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7507 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7510 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7511 ok(size
== 0, "Expected 0, got %d\n", size
);
7515 lstrcpyA(path
, "kiwi");
7516 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
7517 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
7518 ok(!lstrcmpA(path
, "kiwi"),
7519 "Expected path to be unchanged, got \"%s\"\n", path
);
7520 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
7522 /* SourceDir after MsiGetSourcePath */
7524 lstrcpyA(path
, "kiwi");
7525 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7526 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7529 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7530 ok(size
== 0, "Expected 0, got %d\n", size
);
7533 /* SOURCEDIR prop */
7535 lstrcpyA(path
, "kiwi");
7536 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7537 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7540 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7541 ok(size
== 0, "Expected 0, got %d\n", size
);
7545 lstrcpyA(path
, "kiwi");
7546 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
7547 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
7548 ok(!lstrcmpA(path
, "kiwi"),
7549 "Expected path to be unchanged, got \"%s\"\n", path
);
7550 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
7552 /* SOURCEDIR prop after MsiGetSourcePath */
7554 lstrcpyA(path
, "kiwi");
7555 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7556 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7559 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7560 ok(size
== 0, "Expected 0, got %d\n", size
);
7563 r
= MsiDoActionA(hpkg
, "CostInitialize");
7564 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7566 /* SourceDir after CostInitialize */
7568 lstrcpyA(path
, "kiwi");
7569 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7570 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7573 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7574 ok(size
== 0, "Expected 0, got %d\n", size
);
7578 lstrcpyA(path
, "kiwi");
7579 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
7580 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7581 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7582 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7584 /* SourceDir after MsiGetSourcePath */
7586 lstrcpyA(path
, "kiwi");
7587 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7588 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7589 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7590 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7592 /* SOURCEDIR after CostInitialize */
7594 lstrcpyA(path
, "kiwi");
7595 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7596 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7597 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7598 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7600 /* SOURCEDIR source path still does not exist */
7602 lstrcpyA(path
, "kiwi");
7603 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
7604 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
7605 ok(!lstrcmpA(path
, "kiwi"),
7606 "Expected path to be unchanged, got \"%s\"\n", path
);
7607 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
7609 r
= MsiDoActionA(hpkg
, "FileCost");
7610 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7612 /* SourceDir after FileCost */
7614 lstrcpyA(path
, "kiwi");
7615 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7616 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7617 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7618 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7620 /* SOURCEDIR after FileCost */
7622 lstrcpyA(path
, "kiwi");
7623 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7624 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7625 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7626 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7628 /* SOURCEDIR source path still does not exist */
7630 lstrcpyA(path
, "kiwi");
7631 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
7632 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
7633 ok(!lstrcmpA(path
, "kiwi"),
7634 "Expected path to be unchanged, got \"%s\"\n", path
);
7635 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
7637 r
= MsiDoActionA(hpkg
, "CostFinalize");
7638 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7640 /* SourceDir after CostFinalize */
7642 lstrcpyA(path
, "kiwi");
7643 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7644 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7645 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7646 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7648 /* SOURCEDIR after CostFinalize */
7650 lstrcpyA(path
, "kiwi");
7651 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7652 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7653 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7654 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7656 /* SOURCEDIR source path still does not exist */
7658 lstrcpyA(path
, "kiwi");
7659 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
7660 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
7661 ok(!lstrcmpA(path
, "kiwi"),
7662 "Expected path to be unchanged, got \"%s\"\n", path
);
7663 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
7665 r
= MsiDoActionA(hpkg
, "ResolveSource");
7666 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7668 /* SourceDir after ResolveSource */
7670 lstrcpyA(path
, "kiwi");
7671 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7672 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7673 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7674 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7676 /* SOURCEDIR after ResolveSource */
7678 lstrcpyA(path
, "kiwi");
7679 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7680 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7681 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7682 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7684 /* SOURCEDIR source path still does not exist */
7686 lstrcpyA(path
, "kiwi");
7687 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
7688 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
7689 ok(!lstrcmpA(path
, "kiwi"),
7690 "Expected path to be unchanged, got \"%s\"\n", path
);
7691 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
7693 MsiCloseHandle(hpkg
);
7696 MsiCloseHandle(hdb
);
7697 DeleteFileA(msifile
);
7707 static const struct access_res create
[16] =
7709 { TRUE
, ERROR_SUCCESS
, TRUE
},
7710 { TRUE
, ERROR_SUCCESS
, TRUE
},
7711 { TRUE
, ERROR_SUCCESS
, FALSE
},
7712 { TRUE
, ERROR_SUCCESS
, FALSE
},
7713 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7714 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7715 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7716 { TRUE
, ERROR_SUCCESS
, FALSE
},
7717 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7718 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7719 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7720 { TRUE
, ERROR_SUCCESS
, TRUE
},
7721 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7722 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7723 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7724 { TRUE
, ERROR_SUCCESS
, TRUE
}
7727 static const struct access_res create_commit
[16] =
7729 { TRUE
, ERROR_SUCCESS
, TRUE
},
7730 { TRUE
, ERROR_SUCCESS
, TRUE
},
7731 { TRUE
, ERROR_SUCCESS
, FALSE
},
7732 { TRUE
, ERROR_SUCCESS
, FALSE
},
7733 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7734 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7735 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7736 { TRUE
, ERROR_SUCCESS
, FALSE
},
7737 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7738 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7739 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7740 { TRUE
, ERROR_SUCCESS
, TRUE
},
7741 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7742 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7743 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7744 { TRUE
, ERROR_SUCCESS
, TRUE
}
7747 static const struct access_res create_close
[16] =
7749 { TRUE
, ERROR_SUCCESS
, FALSE
},
7750 { TRUE
, ERROR_SUCCESS
, FALSE
},
7751 { TRUE
, ERROR_SUCCESS
, FALSE
},
7752 { TRUE
, ERROR_SUCCESS
, FALSE
},
7753 { TRUE
, ERROR_SUCCESS
, FALSE
},
7754 { TRUE
, ERROR_SUCCESS
, FALSE
},
7755 { TRUE
, ERROR_SUCCESS
, FALSE
},
7756 { TRUE
, ERROR_SUCCESS
, FALSE
},
7757 { TRUE
, ERROR_SUCCESS
, FALSE
},
7758 { TRUE
, ERROR_SUCCESS
, FALSE
},
7759 { TRUE
, ERROR_SUCCESS
, FALSE
},
7760 { TRUE
, ERROR_SUCCESS
, FALSE
},
7761 { TRUE
, ERROR_SUCCESS
, FALSE
},
7762 { TRUE
, ERROR_SUCCESS
, FALSE
},
7763 { TRUE
, ERROR_SUCCESS
, FALSE
},
7764 { TRUE
, ERROR_SUCCESS
}
7767 static void _test_file_access(LPCSTR file
, const struct access_res
*ares
, DWORD line
)
7769 DWORD access
= 0, share
= 0;
7774 for (i
= 0; i
< 4; i
++)
7776 if (i
== 0) access
= 0;
7777 if (i
== 1) access
= GENERIC_READ
;
7778 if (i
== 2) access
= GENERIC_WRITE
;
7779 if (i
== 3) access
= GENERIC_READ
| GENERIC_WRITE
;
7781 for (j
= 0; j
< 4; j
++)
7783 if (ares
[idx
].ignore
)
7786 if (j
== 0) share
= 0;
7787 if (j
== 1) share
= FILE_SHARE_READ
;
7788 if (j
== 2) share
= FILE_SHARE_WRITE
;
7789 if (j
== 3) share
= FILE_SHARE_READ
| FILE_SHARE_WRITE
;
7791 SetLastError(0xdeadbeef);
7792 hfile
= CreateFileA(file
, access
, share
, NULL
, OPEN_EXISTING
,
7793 FILE_ATTRIBUTE_NORMAL
, 0);
7794 lasterr
= GetLastError();
7796 ok((hfile
!= INVALID_HANDLE_VALUE
) == ares
[idx
].gothandle
,
7797 "(%d, handle, %d): Expected %d, got %d\n",
7798 line
, idx
, ares
[idx
].gothandle
,
7799 (hfile
!= INVALID_HANDLE_VALUE
));
7801 ok(lasterr
== ares
[idx
].lasterr
, "(%d, lasterr, %d): Expected %d, got %d\n",
7802 line
, idx
, ares
[idx
].lasterr
, lasterr
);
7810 #define test_file_access(file, ares) _test_file_access(file, ares, __LINE__)
7812 static void test_access(void)
7817 r
= MsiOpenDatabaseW(msifileW
, MSIDBOPEN_CREATE
, &hdb
);
7818 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7820 test_file_access(msifile
, create
);
7822 r
= MsiDatabaseCommit(hdb
);
7823 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7825 test_file_access(msifile
, create_commit
);
7826 MsiCloseHandle(hdb
);
7828 test_file_access(msifile
, create_close
);
7829 DeleteFileA(msifile
);
7831 r
= MsiOpenDatabaseW(msifileW
, MSIDBOPEN_CREATEDIRECT
, &hdb
);
7832 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7834 test_file_access(msifile
, create
);
7836 r
= MsiDatabaseCommit(hdb
);
7837 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7839 test_file_access(msifile
, create_commit
);
7840 MsiCloseHandle(hdb
);
7842 test_file_access(msifile
, create_close
);
7843 DeleteFileA(msifile
);
7846 static void test_emptypackage(void)
7848 MSIHANDLE hpkg
= 0, hdb
= 0, hsuminfo
= 0;
7849 MSIHANDLE hview
= 0, hrec
= 0;
7850 MSICONDITION condition
;
7851 CHAR buffer
[MAX_PATH
];
7855 r
= MsiOpenPackageA("", &hpkg
);
7856 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
7858 skip("Not enough rights to perform tests\n");
7863 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7866 hdb
= MsiGetActiveDatabase(hpkg
);
7869 ok(hdb
!= 0, "Expected a valid database handle\n");
7872 r
= MsiDatabaseOpenViewA(hdb
, "SELECT * FROM `_Tables`", &hview
);
7875 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7877 r
= MsiViewExecute(hview
, 0);
7880 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7883 r
= MsiViewFetch(hview
, &hrec
);
7886 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7891 r
= MsiRecordGetStringA(hrec
, 1, buffer
, &size
);
7894 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7895 ok(!lstrcmpA(buffer
, "_Property"),
7896 "Expected \"_Property\", got \"%s\"\n", buffer
);
7899 MsiCloseHandle(hrec
);
7901 r
= MsiViewFetch(hview
, &hrec
);
7904 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7908 r
= MsiRecordGetStringA(hrec
, 1, buffer
, &size
);
7911 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7912 ok(!lstrcmpA(buffer
, "#_FolderCache"),
7913 "Expected \"_Property\", got \"%s\"\n", buffer
);
7916 MsiCloseHandle(hrec
);
7917 MsiViewClose(hview
);
7918 MsiCloseHandle(hview
);
7920 condition
= MsiDatabaseIsTablePersistentA(hdb
, "_Property");
7923 ok(condition
== MSICONDITION_FALSE
,
7924 "Expected MSICONDITION_FALSE, got %d\n", condition
);
7927 r
= MsiDatabaseOpenViewA(hdb
, "SELECT * FROM `_Property`", &hview
);
7930 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7932 r
= MsiViewExecute(hview
, 0);
7935 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7938 /* _Property table is not empty */
7939 r
= MsiViewFetch(hview
, &hrec
);
7942 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7945 MsiCloseHandle(hrec
);
7946 MsiViewClose(hview
);
7947 MsiCloseHandle(hview
);
7949 condition
= MsiDatabaseIsTablePersistentA(hdb
, "#_FolderCache");
7952 ok(condition
== MSICONDITION_FALSE
,
7953 "Expected MSICONDITION_FALSE, got %d\n", condition
);
7956 r
= MsiDatabaseOpenViewA(hdb
, "SELECT * FROM `#_FolderCache`", &hview
);
7959 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7961 r
= MsiViewExecute(hview
, 0);
7964 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7967 /* #_FolderCache is not empty */
7968 r
= MsiViewFetch(hview
, &hrec
);
7971 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7974 MsiCloseHandle(hrec
);
7975 MsiViewClose(hview
);
7976 MsiCloseHandle(hview
);
7978 r
= MsiDatabaseOpenViewA(hdb
, "SELECT * FROM `_Streams`", &hview
);
7981 ok(r
== ERROR_BAD_QUERY_SYNTAX
,
7982 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r
);
7985 r
= MsiDatabaseOpenViewA(hdb
, "SELECT * FROM `_Storages`", &hview
);
7988 ok(r
== ERROR_BAD_QUERY_SYNTAX
,
7989 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r
);
7992 r
= MsiGetSummaryInformationA(hdb
, NULL
, 0, &hsuminfo
);
7995 ok(r
== ERROR_INSTALL_PACKAGE_INVALID
,
7996 "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r
);
7999 MsiCloseHandle(hsuminfo
);
8001 r
= MsiDatabaseCommit(hdb
);
8004 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8007 MsiCloseHandle(hdb
);
8008 MsiCloseHandle(hpkg
);
8011 static void test_MsiGetProductProperty(void)
8013 static const WCHAR prodcode_propW
[] = {'P','r','o','d','u','c','t','C','o','d','e',0};
8014 static const WCHAR nonexistentW
[] = {'I','D','o','n','t','E','x','i','s','t',0};
8015 static const WCHAR newpropW
[] = {'N','e','w','P','r','o','p','e','r','t','y',0};
8016 static const WCHAR appleW
[] = {'a','p','p','l','e',0};
8017 static const WCHAR emptyW
[] = {0};
8018 WCHAR valW
[MAX_PATH
];
8019 MSIHANDLE hprod
, hdb
;
8021 CHAR path
[MAX_PATH
];
8022 CHAR query
[MAX_PATH
];
8023 CHAR keypath
[MAX_PATH
*2];
8024 CHAR prodcode
[MAX_PATH
];
8025 WCHAR prodcodeW
[MAX_PATH
];
8026 CHAR prod_squashed
[MAX_PATH
];
8027 WCHAR prod_squashedW
[MAX_PATH
];
8028 HKEY prodkey
, userkey
, props
;
8032 REGSAM access
= KEY_ALL_ACCESS
;
8034 GetCurrentDirectoryA(MAX_PATH
, path
);
8035 lstrcatA(path
, "\\");
8037 create_test_guid(prodcode
, prod_squashed
);
8038 MultiByteToWideChar(CP_ACP
, 0, prodcode
, -1, prodcodeW
, MAX_PATH
);
8039 squash_guid(prodcodeW
, prod_squashedW
);
8042 access
|= KEY_WOW64_64KEY
;
8044 r
= MsiOpenDatabaseW(msifileW
, MSIDBOPEN_CREATE
, &hdb
);
8045 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8047 r
= MsiDatabaseCommit(hdb
);
8048 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8050 r
= set_summary_info(hdb
);
8051 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8054 "CREATE TABLE `Directory` ( "
8055 "`Directory` CHAR(255) NOT NULL, "
8056 "`Directory_Parent` CHAR(255), "
8057 "`DefaultDir` CHAR(255) NOT NULL "
8058 "PRIMARY KEY `Directory`)");
8059 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8061 create_property_table(hdb
);
8063 sprintf(query
, "'ProductCode', '%s'", prodcode
);
8064 r
= add_property_entry(hdb
, query
);
8066 r
= MsiDatabaseCommit(hdb
);
8067 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8069 MsiCloseHandle(hdb
);
8071 lstrcpyA(keypath
, "Software\\Classes\\Installer\\Products\\");
8072 lstrcatA(keypath
, prod_squashed
);
8074 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
8075 if (res
== ERROR_ACCESS_DENIED
)
8077 skip("Not enough rights to perform tests\n");
8078 DeleteFileA(msifile
);
8081 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8083 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
8084 lstrcatA(keypath
, "Installer\\UserData\\S-1-5-18\\Products\\");
8085 lstrcatA(keypath
, prod_squashed
);
8087 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &userkey
, NULL
);
8088 if (res
== ERROR_ACCESS_DENIED
)
8090 skip("Not enough rights to perform tests\n");
8091 RegDeleteKeyA(prodkey
, "");
8092 RegCloseKey(prodkey
);
8095 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8097 res
= RegCreateKeyExA(userkey
, "InstallProperties", 0, NULL
, 0, access
, NULL
, &props
, NULL
);
8098 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8100 lstrcpyA(val
, path
);
8101 lstrcatA(val
, "\\");
8102 lstrcatA(val
, msifile
);
8103 res
= RegSetValueExA(props
, "LocalPackage", 0, REG_SZ
,
8104 (const BYTE
*)val
, lstrlenA(val
) + 1);
8105 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8108 r
= MsiOpenProductA(prodcode
, &hprod
);
8109 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8110 ok(hprod
!= 0 && hprod
!= 0xdeadbeef, "Expected a valid product handle\n");
8112 /* hProduct is invalid */
8114 lstrcpyA(val
, "apple");
8115 r
= MsiGetProductPropertyA(0xdeadbeef, "ProductCode", val
, &size
);
8116 ok(r
== ERROR_INVALID_HANDLE
,
8117 "Expected ERROR_INVALID_HANDLE, got %d\n", r
);
8118 ok(!lstrcmpA(val
, "apple"),
8119 "Expected val to be unchanged, got \"%s\"\n", val
);
8120 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
8123 lstrcpyW(valW
, appleW
);
8124 r
= MsiGetProductPropertyW(0xdeadbeef, prodcode_propW
, valW
, &size
);
8125 ok(r
== ERROR_INVALID_HANDLE
,
8126 "Expected ERROR_INVALID_HANDLE, got %d\n", r
);
8127 ok(!lstrcmpW(valW
, appleW
),
8128 "Expected val to be unchanged, got %s\n", wine_dbgstr_w(valW
));
8129 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
8131 /* szProperty is NULL */
8133 lstrcpyA(val
, "apple");
8134 r
= MsiGetProductPropertyA(hprod
, NULL
, val
, &size
);
8135 ok(r
== ERROR_INVALID_PARAMETER
,
8136 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
8137 ok(!lstrcmpA(val
, "apple"),
8138 "Expected val to be unchanged, got \"%s\"\n", val
);
8139 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
8142 lstrcpyW(valW
, appleW
);
8143 r
= MsiGetProductPropertyW(hprod
, NULL
, valW
, &size
);
8144 ok(r
== ERROR_INVALID_PARAMETER
,
8145 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
8146 ok(!lstrcmpW(valW
, appleW
),
8147 "Expected val to be unchanged, got %s\n", wine_dbgstr_w(valW
));
8148 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
8150 /* szProperty is empty */
8152 lstrcpyA(val
, "apple");
8153 r
= MsiGetProductPropertyA(hprod
, "", val
, &size
);
8154 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8155 ok(!lstrcmpA(val
, ""), "Expected \"\", got \"%s\"\n", val
);
8156 ok(size
== 0, "Expected 0, got %d\n", size
);
8159 lstrcpyW(valW
, appleW
);
8160 r
= MsiGetProductPropertyW(hprod
, emptyW
, valW
, &size
);
8161 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8162 ok(*valW
== 0, "Expected \"\", got %s\n", wine_dbgstr_w(valW
));
8163 ok(size
== 0, "Expected 0, got %d\n", size
);
8165 /* get the property */
8167 lstrcpyA(val
, "apple");
8168 r
= MsiGetProductPropertyA(hprod
, "ProductCode", val
, &size
);
8169 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8170 ok(!lstrcmpA(val
, prodcode
),
8171 "Expected \"%s\", got \"%s\"\n", prodcode
, val
);
8172 ok(size
== lstrlenA(prodcode
),
8173 "Expected %d, got %d\n", lstrlenA(prodcode
), size
);
8176 lstrcpyW(valW
, appleW
);
8177 r
= MsiGetProductPropertyW(hprod
, prodcode_propW
, valW
, &size
);
8178 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8179 ok(!lstrcmpW(valW
, prodcodeW
),
8180 "Expected %s, got %s\n", wine_dbgstr_w(prodcodeW
), wine_dbgstr_w(valW
));
8181 ok(size
== lstrlenW(prodcodeW
),
8182 "Expected %d, got %d\n", lstrlenW(prodcodeW
), size
);
8184 /* lpValueBuf is NULL */
8186 r
= MsiGetProductPropertyA(hprod
, "ProductCode", NULL
, &size
);
8187 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8188 ok(size
== lstrlenA(prodcode
),
8189 "Expected %d, got %d\n", lstrlenA(prodcode
), size
);
8192 r
= MsiGetProductPropertyW(hprod
, prodcode_propW
, NULL
, &size
);
8193 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8194 ok(size
== lstrlenW(prodcodeW
),
8195 "Expected %d, got %d\n", lstrlenW(prodcodeW
), size
);
8197 /* pcchValueBuf is NULL */
8198 lstrcpyA(val
, "apple");
8199 r
= MsiGetProductPropertyA(hprod
, "ProductCode", val
, NULL
);
8200 ok(r
== ERROR_INVALID_PARAMETER
,
8201 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
8202 ok(!lstrcmpA(val
, "apple"),
8203 "Expected val to be unchanged, got \"%s\"\n", val
);
8204 ok(size
== lstrlenA(prodcode
),
8205 "Expected %d, got %d\n", lstrlenA(prodcode
), size
);
8207 lstrcpyW(valW
, appleW
);
8208 r
= MsiGetProductPropertyW(hprod
, prodcode_propW
, valW
, NULL
);
8209 ok(r
== ERROR_INVALID_PARAMETER
,
8210 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
8211 ok(!lstrcmpW(valW
, appleW
),
8212 "Expected val to be unchanged, got %s\n", wine_dbgstr_w(valW
));
8213 ok(size
== lstrlenW(prodcodeW
),
8214 "Expected %d, got %d\n", lstrlenW(prodcodeW
), size
);
8216 /* pcchValueBuf is too small */
8218 lstrcpyA(val
, "apple");
8219 r
= MsiGetProductPropertyA(hprod
, "ProductCode", val
, &size
);
8220 ok(r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
8221 ok(!strncmp(val
, prodcode
, 3),
8222 "Expected first 3 chars of \"%s\", got \"%s\"\n", prodcode
, val
);
8223 ok(size
== lstrlenA(prodcode
),
8224 "Expected %d, got %d\n", lstrlenA(prodcode
), size
);
8227 lstrcpyW(valW
, appleW
);
8228 r
= MsiGetProductPropertyW(hprod
, prodcode_propW
, valW
, &size
);
8229 ok(r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
8230 ok(!memcmp(valW
, prodcodeW
, 3 * sizeof(WCHAR
)),
8231 "Expected first 3 chars of %s, got %s\n", wine_dbgstr_w(prodcodeW
), wine_dbgstr_w(valW
));
8232 ok(size
== lstrlenW(prodcodeW
),
8233 "Expected %d, got %d\n", lstrlenW(prodcodeW
), size
);
8235 /* pcchValueBuf does not leave room for NULL terminator */
8236 size
= lstrlenA(prodcode
);
8237 lstrcpyA(val
, "apple");
8238 r
= MsiGetProductPropertyA(hprod
, "ProductCode", val
, &size
);
8239 ok(r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
8240 ok(!strncmp(val
, prodcode
, lstrlenA(prodcode
) - 1),
8241 "Expected first 37 chars of \"%s\", got \"%s\"\n", prodcode
, val
);
8242 ok(size
== lstrlenA(prodcode
),
8243 "Expected %d, got %d\n", lstrlenA(prodcode
), size
);
8245 size
= lstrlenW(prodcodeW
);
8246 lstrcpyW(valW
, appleW
);
8247 r
= MsiGetProductPropertyW(hprod
, prodcode_propW
, valW
, &size
);
8248 ok(r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
8249 ok(!memcmp(valW
, prodcodeW
, lstrlenW(prodcodeW
) - 1),
8250 "Expected first 37 chars of %s, got %s\n", wine_dbgstr_w(prodcodeW
), wine_dbgstr_w(valW
));
8251 ok(size
== lstrlenW(prodcodeW
),
8252 "Expected %d, got %d\n", lstrlenW(prodcodeW
), size
);
8254 /* pcchValueBuf has enough room for NULL terminator */
8255 size
= lstrlenA(prodcode
) + 1;
8256 lstrcpyA(val
, "apple");
8257 r
= MsiGetProductPropertyA(hprod
, "ProductCode", val
, &size
);
8258 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8259 ok(!lstrcmpA(val
, prodcode
),
8260 "Expected \"%s\", got \"%s\"\n", prodcode
, val
);
8261 ok(size
== lstrlenA(prodcode
),
8262 "Expected %d, got %d\n", lstrlenA(prodcode
), size
);
8264 size
= lstrlenW(prodcodeW
) + 1;
8265 lstrcpyW(valW
, appleW
);
8266 r
= MsiGetProductPropertyW(hprod
, prodcode_propW
, valW
, &size
);
8267 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8268 ok(!lstrcmpW(valW
, prodcodeW
),
8269 "Expected %s, got %s\n", wine_dbgstr_w(prodcodeW
), wine_dbgstr_w(valW
));
8270 ok(size
== lstrlenW(prodcodeW
),
8271 "Expected %d, got %d\n", lstrlenW(prodcodeW
), size
);
8273 /* nonexistent property */
8275 lstrcpyA(val
, "apple");
8276 r
= MsiGetProductPropertyA(hprod
, "IDontExist", val
, &size
);
8277 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8278 ok(!lstrcmpA(val
, ""), "Expected \"\", got \"%s\"\n", val
);
8279 ok(size
== 0, "Expected 0, got %d\n", size
);
8282 lstrcpyW(valW
, appleW
);
8283 r
= MsiGetProductPropertyW(hprod
, nonexistentW
, valW
, &size
);
8284 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8285 ok(!lstrcmpW(valW
, emptyW
), "Expected \"\", got %s\n", wine_dbgstr_w(valW
));
8286 ok(size
== 0, "Expected 0, got %d\n", size
);
8288 r
= MsiSetPropertyA(hprod
, "NewProperty", "value");
8289 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8291 /* non-product property set */
8293 lstrcpyA(val
, "apple");
8294 r
= MsiGetProductPropertyA(hprod
, "NewProperty", val
, &size
);
8295 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8296 ok(!lstrcmpA(val
, ""), "Expected \"\", got \"%s\"\n", val
);
8297 ok(size
== 0, "Expected 0, got %d\n", size
);
8300 lstrcpyW(valW
, appleW
);
8301 r
= MsiGetProductPropertyW(hprod
, newpropW
, valW
, &size
);
8302 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8303 ok(!lstrcmpW(valW
, emptyW
), "Expected \"\", got %s\n", wine_dbgstr_w(valW
));
8304 ok(size
== 0, "Expected 0, got %d\n", size
);
8306 r
= MsiSetPropertyA(hprod
, "ProductCode", "value");
8307 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8309 /* non-product property that is also a product property set */
8311 lstrcpyA(val
, "apple");
8312 r
= MsiGetProductPropertyA(hprod
, "ProductCode", val
, &size
);
8313 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8314 ok(!lstrcmpA(val
, prodcode
),
8315 "Expected \"%s\", got \"%s\"\n", prodcode
, val
);
8316 ok(size
== lstrlenA(prodcode
),
8317 "Expected %d, got %d\n", lstrlenA(prodcode
), size
);
8320 lstrcpyW(valW
, appleW
);
8321 r
= MsiGetProductPropertyW(hprod
, prodcode_propW
, valW
, &size
);
8322 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8323 ok(!lstrcmpW(valW
, prodcodeW
),
8324 "Expected %s, got %s\n", wine_dbgstr_w(prodcodeW
), wine_dbgstr_w(valW
));
8325 ok(size
== lstrlenW(prodcodeW
),
8326 "Expected %d, got %d\n", lstrlenW(prodcodeW
), size
);
8328 MsiCloseHandle(hprod
);
8330 RegDeleteValueA(props
, "LocalPackage");
8331 delete_key(props
, "", access
);
8333 delete_key(userkey
, "", access
);
8334 RegCloseKey(userkey
);
8335 delete_key(prodkey
, "", access
);
8336 RegCloseKey(prodkey
);
8337 DeleteFileA(msifile
);
8340 static void test_MsiSetProperty(void)
8342 MSIHANDLE hpkg
, hdb
, hrec
;
8348 r
= package_from_db(create_package_db(), &hpkg
);
8349 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
8351 skip("Not enough rights to perform tests\n");
8352 DeleteFileA(msifile
);
8355 ok(r
== ERROR_SUCCESS
, "Expected a valid package %u\n", r
);
8357 /* invalid hInstall */
8358 r
= MsiSetPropertyA(0, "Prop", "Val");
8359 ok(r
== ERROR_INVALID_HANDLE
,
8360 "Expected ERROR_INVALID_HANDLE, got %d\n", r
);
8362 /* invalid hInstall */
8363 r
= MsiSetPropertyA(0xdeadbeef, "Prop", "Val");
8364 ok(r
== ERROR_INVALID_HANDLE
,
8365 "Expected ERROR_INVALID_HANDLE, got %d\n", r
);
8367 /* szName is NULL */
8368 r
= MsiSetPropertyA(hpkg
, NULL
, "Val");
8369 ok(r
== ERROR_INVALID_PARAMETER
,
8370 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
8372 /* both szName and szValue are NULL */
8373 r
= MsiSetPropertyA(hpkg
, NULL
, NULL
);
8374 ok(r
== ERROR_INVALID_PARAMETER
,
8375 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
8377 /* szName is empty */
8378 r
= MsiSetPropertyA(hpkg
, "", "Val");
8379 ok(r
== ERROR_FUNCTION_FAILED
,
8380 "Expected ERROR_FUNCTION_FAILED, got %d\n", r
);
8382 /* szName is empty and szValue is NULL */
8383 r
= MsiSetPropertyA(hpkg
, "", NULL
);
8384 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8386 /* set a property */
8387 r
= MsiSetPropertyA(hpkg
, "Prop", "Val");
8388 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8390 /* get the property */
8392 r
= MsiGetPropertyA(hpkg
, "Prop", buf
, &size
);
8393 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8394 ok(!lstrcmpA(buf
, "Val"), "Expected \"Val\", got \"%s\"\n", buf
);
8395 ok(size
== 3, "Expected 3, got %d\n", size
);
8397 /* update the property */
8398 r
= MsiSetPropertyA(hpkg
, "Prop", "Nuvo");
8399 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8401 /* get the property */
8403 r
= MsiGetPropertyA(hpkg
, "Prop", buf
, &size
);
8404 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8405 ok(!lstrcmpA(buf
, "Nuvo"), "Expected \"Nuvo\", got \"%s\"\n", buf
);
8406 ok(size
== 4, "Expected 4, got %d\n", size
);
8408 hdb
= MsiGetActiveDatabase(hpkg
);
8409 ok(hdb
!= 0, "Expected a valid database handle\n");
8411 /* set prop is not in the _Property table */
8412 query
= "SELECT * FROM `_Property` WHERE `Property` = 'Prop'";
8413 r
= do_query(hdb
, query
, &hrec
);
8414 ok(r
== ERROR_BAD_QUERY_SYNTAX
,
8415 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r
);
8417 /* set prop is not in the Property table */
8418 query
= "SELECT * FROM `Property` WHERE `Property` = 'Prop'";
8419 r
= do_query(hdb
, query
, &hrec
);
8420 ok(r
== ERROR_BAD_QUERY_SYNTAX
,
8421 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r
);
8423 MsiCloseHandle(hdb
);
8425 /* szValue is an empty string */
8426 r
= MsiSetPropertyA(hpkg
, "Prop", "");
8427 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8429 /* try to get the property */
8431 r
= MsiGetPropertyA(hpkg
, "Prop", buf
, &size
);
8432 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8433 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
8434 ok(size
== 0, "Expected 0, got %d\n", size
);
8436 /* reset the property */
8437 r
= MsiSetPropertyA(hpkg
, "Prop", "BlueTap");
8438 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8440 /* delete the property */
8441 r
= MsiSetPropertyA(hpkg
, "Prop", NULL
);
8442 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8444 /* try to get the property */
8446 r
= MsiGetPropertyA(hpkg
, "Prop", buf
, &size
);
8447 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8448 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
8449 ok(size
== 0, "Expected 0, got %d\n", size
);
8451 MsiCloseHandle(hpkg
);
8452 DeleteFileA(msifile
);
8455 static void test_MsiApplyMultiplePatches(void)
8457 UINT r
, type
= GetDriveTypeW(NULL
);
8459 r
= MsiApplyMultiplePatchesA(NULL
, NULL
, NULL
);
8460 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8462 r
= MsiApplyMultiplePatchesA("", NULL
, NULL
);
8463 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8465 r
= MsiApplyMultiplePatchesA(";", NULL
, NULL
);
8466 if (type
== DRIVE_FIXED
)
8467 todo_wine
ok(r
== ERROR_PATH_NOT_FOUND
, "Expected ERROR_PATH_NOT_FOUND, got %u\n", r
);
8469 ok(r
== ERROR_INVALID_NAME
, "Expected ERROR_INVALID_NAME, got %u\n", r
);
8471 r
= MsiApplyMultiplePatchesA(" ;", NULL
, NULL
);
8472 if (type
== DRIVE_FIXED
)
8473 todo_wine
ok(r
== ERROR_PATCH_PACKAGE_OPEN_FAILED
, "Expected ERROR_PATCH_PACKAGE_OPEN_FAILED, got %u\n", r
);
8475 ok(r
== ERROR_INVALID_NAME
, "Expected ERROR_INVALID_NAME, got %u\n", r
);
8477 r
= MsiApplyMultiplePatchesA(";;", NULL
, NULL
);
8478 if (type
== DRIVE_FIXED
)
8479 todo_wine
ok(r
== ERROR_PATH_NOT_FOUND
, "Expected ERROR_PATH_NOT_FOUND, got %u\n", r
);
8481 ok(r
== ERROR_INVALID_NAME
, "Expected ERROR_INVALID_NAME, got %u\n", r
);
8483 r
= MsiApplyMultiplePatchesA("nosuchpatchpackage;", NULL
, NULL
);
8484 todo_wine
ok(r
== ERROR_FILE_NOT_FOUND
, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r
);
8486 r
= MsiApplyMultiplePatchesA(";nosuchpatchpackage", NULL
, NULL
);
8487 if (type
== DRIVE_FIXED
)
8488 todo_wine
ok(r
== ERROR_PATH_NOT_FOUND
, "Expected ERROR_PATH_NOT_FOUND, got %u\n", r
);
8490 ok(r
== ERROR_INVALID_NAME
, "Expected ERROR_INVALID_NAME, got %u\n", r
);
8492 r
= MsiApplyMultiplePatchesA("nosuchpatchpackage;nosuchpatchpackage", NULL
, NULL
);
8493 todo_wine
ok(r
== ERROR_FILE_NOT_FOUND
, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r
);
8495 r
= MsiApplyMultiplePatchesA(" nosuchpatchpackage ; nosuchpatchpackage ", NULL
, NULL
);
8496 todo_wine
ok(r
== ERROR_FILE_NOT_FOUND
, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r
);
8499 static void test_MsiApplyPatch(void)
8503 r
= MsiApplyPatchA(NULL
, NULL
, INSTALLTYPE_DEFAULT
, NULL
);
8504 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8506 r
= MsiApplyPatchA("", NULL
, INSTALLTYPE_DEFAULT
, NULL
);
8507 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8510 static void test_MsiEnumComponentCosts(void)
8512 MSIHANDLE hdb
, hpkg
;
8513 char package
[12], drive
[3];
8518 hdb
= create_package_db();
8519 ok( hdb
, "failed to create database\n" );
8521 create_property_table( hdb
);
8522 add_property_entry( hdb
, "'ProductCode', '{379B1C47-40C1-42FA-A9BB-BEBB6F1B0172}'" );
8523 add_property_entry( hdb
, "'MSIFASTINSTALL', '1'" );
8524 add_directory_entry( hdb
, "'TARGETDIR', '', 'SourceDir'" );
8526 create_media_table( hdb
);
8527 add_media_entry( hdb
, "'1', '2', 'cabinet', '', '', ''");
8529 create_file_table( hdb
);
8530 add_file_entry( hdb
, "'one.txt', 'one', 'one.txt', 4096, '', '', 8192, 1" );
8532 create_component_table( hdb
);
8533 add_component_entry( hdb
, "'one', '{B2F86B9D-8447-4BC5-8883-750C45AA31CA}', 'TARGETDIR', 0, '', 'one.txt'" );
8534 add_component_entry( hdb
, "'two', '{62A09F6E-0B74-4829-BDB7-CAB66F42CCE8}', 'TARGETDIR', 0, '', ''" );
8536 create_feature_table( hdb
);
8537 add_feature_entry( hdb
, "'one', '', '', '', 0, 1, '', 0" );
8538 add_feature_entry( hdb
, "'two', '', '', '', 0, 1, '', 0" );
8540 create_feature_components_table( hdb
);
8541 add_feature_components_entry( hdb
, "'one', 'one'" );
8542 add_feature_components_entry( hdb
, "'two', 'two'" );
8544 create_install_execute_sequence_table( hdb
);
8545 add_install_execute_sequence_entry( hdb
, "'CostInitialize', '', '800'" );
8546 add_install_execute_sequence_entry( hdb
, "'FileCost', '', '900'" );
8547 add_install_execute_sequence_entry( hdb
, "'CostFinalize', '', '1000'" );
8548 add_install_execute_sequence_entry( hdb
, "'InstallValidate', '', '1100'" );
8550 MsiDatabaseCommit( hdb
);
8552 sprintf( package
, "#%u", hdb
);
8553 r
= MsiOpenPackageA( package
, &hpkg
);
8554 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
8556 skip("Not enough rights to perform tests\n");
8559 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
8561 r
= MsiEnumComponentCostsA( 0, NULL
, 0, INSTALLSTATE_UNKNOWN
, NULL
, NULL
, NULL
, NULL
);
8562 ok( r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8564 r
= MsiEnumComponentCostsA( hpkg
, NULL
, 0, INSTALLSTATE_UNKNOWN
, NULL
, NULL
, NULL
, NULL
);
8565 ok( r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8567 r
= MsiEnumComponentCostsA( hpkg
, NULL
, 0, INSTALLSTATE_UNKNOWN
, NULL
, NULL
, NULL
, NULL
);
8568 ok( r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8570 r
= MsiEnumComponentCostsA( hpkg
, "", 0, INSTALLSTATE_UNKNOWN
, NULL
, NULL
, NULL
, NULL
);
8571 ok( r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8573 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_UNKNOWN
, NULL
, NULL
, NULL
, NULL
);
8574 ok( r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8576 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, NULL
, NULL
, NULL
, NULL
);
8577 ok( r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8579 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, drive
, NULL
, NULL
, NULL
);
8580 ok( r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8582 len
= sizeof(drive
);
8583 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, drive
, &len
, NULL
, NULL
);
8584 ok( r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8586 len
= sizeof(drive
);
8587 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, drive
, &len
, &cost
, NULL
);
8588 ok( r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8590 len
= sizeof(drive
);
8591 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, drive
, &len
, &cost
, &temp
);
8592 todo_wine
ok( r
== ERROR_INVALID_HANDLE_STATE
, "Expected ERROR_INVALID_HANDLE_STATE, got %u\n", r
);
8594 len
= sizeof(drive
);
8595 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, NULL
, &len
, &cost
, &temp
);
8596 ok( r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8598 MsiSetInternalUI( INSTALLUILEVEL_NONE
, NULL
);
8600 r
= MsiDoActionA( hpkg
, "CostInitialize" );
8601 ok( r
== ERROR_SUCCESS
, "CostInitialize failed %u\n", r
);
8603 r
= MsiDoActionA( hpkg
, "FileCost" );
8604 ok( r
== ERROR_SUCCESS
, "FileCost failed %u\n", r
);
8606 len
= sizeof(drive
);
8607 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, drive
, &len
, &cost
, &temp
);
8608 ok( r
== ERROR_FUNCTION_NOT_CALLED
, "Expected ERROR_FUNCTION_NOT_CALLED, got %u\n", r
);
8610 r
= MsiDoActionA( hpkg
, "CostFinalize" );
8611 ok( r
== ERROR_SUCCESS
, "CostFinalize failed %u\n", r
);
8613 /* contrary to what msdn says InstallValidate must be called too */
8614 len
= sizeof(drive
);
8615 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, drive
, &len
, &cost
, &temp
);
8616 todo_wine
ok( r
== ERROR_FUNCTION_NOT_CALLED
, "Expected ERROR_FUNCTION_NOT_CALLED, got %u\n", r
);
8618 r
= MsiDoActionA( hpkg
, "InstallValidate" );
8619 ok( r
== ERROR_SUCCESS
, "InstallValidate failed %u\n", r
);
8622 r
= MsiEnumComponentCostsA( hpkg
, "three", 0, INSTALLSTATE_LOCAL
, drive
, &len
, &cost
, &temp
);
8623 ok( r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %u\n", r
);
8626 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, drive
, &len
, &cost
, &temp
);
8627 ok( r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %u\n", r
);
8628 ok( len
== 2, "expected len == 2, got %u\n", len
);
8631 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, drive
, &len
, &cost
, &temp
);
8632 ok( r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %u\n", r
);
8633 ok( len
== 2, "expected len == 2, got %u\n", len
);
8636 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_UNKNOWN
, drive
, &len
, &cost
, &temp
);
8637 ok( r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %u\n", r
);
8638 ok( len
== 2, "expected len == 2, got %u\n", len
);
8640 /* install state doesn't seem to matter */
8641 len
= sizeof(drive
);
8642 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_UNKNOWN
, drive
, &len
, &cost
, &temp
);
8643 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
8645 len
= sizeof(drive
);
8646 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_ABSENT
, drive
, &len
, &cost
, &temp
);
8647 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
8649 len
= sizeof(drive
);
8650 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_SOURCE
, drive
, &len
, &cost
, &temp
);
8651 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
8653 len
= sizeof(drive
);
8655 cost
= temp
= 0xdead;
8656 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, drive
, &len
, &cost
, &temp
);
8657 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
8658 ok( len
== 2, "expected len == 2, got %u\n", len
);
8659 ok( drive
[0], "expected a drive\n" );
8660 ok( cost
&& cost
!= 0xdead, "expected cost > 0, got %d\n", cost
);
8661 ok( !temp
, "expected temp == 0, got %d\n", temp
);
8663 len
= sizeof(drive
);
8665 cost
= temp
= 0xdead;
8666 r
= MsiEnumComponentCostsA( hpkg
, "two", 0, INSTALLSTATE_LOCAL
, drive
, &len
, &cost
, &temp
);
8667 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
8668 ok( len
== 2, "expected len == 2, got %u\n", len
);
8669 ok( drive
[0], "expected a drive\n" );
8670 ok( !cost
, "expected cost == 0, got %d\n", cost
);
8671 ok( !temp
, "expected temp == 0, got %d\n", temp
);
8673 len
= sizeof(drive
);
8675 cost
= temp
= 0xdead;
8676 r
= MsiEnumComponentCostsA( hpkg
, "", 0, INSTALLSTATE_UNKNOWN
, drive
, &len
, &cost
, &temp
);
8677 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
8678 ok( len
== 2, "expected len == 2, got %u\n", len
);
8679 ok( drive
[0], "expected a drive\n" );
8680 ok( !cost
, "expected cost == 0, got %d\n", cost
);
8681 ok( temp
&& temp
!= 0xdead, "expected temp > 0, got %d\n", temp
);
8683 /* increased index */
8684 len
= sizeof(drive
);
8685 r
= MsiEnumComponentCostsA( hpkg
, "one", 1, INSTALLSTATE_LOCAL
, drive
, &len
, &cost
, &temp
);
8686 ok( r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %u\n", r
);
8688 len
= sizeof(drive
);
8689 r
= MsiEnumComponentCostsA( hpkg
, "", 1, INSTALLSTATE_UNKNOWN
, drive
, &len
, &cost
, &temp
);
8690 ok( r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %u\n", r
);
8692 MsiCloseHandle( hpkg
);
8694 MsiCloseHandle( hdb
);
8695 DeleteFileA( msifile
);
8698 static void test_MsiDatabaseCommit(void)
8701 MSIHANDLE hdb
, hpkg
= 0;
8702 char buf
[32], package
[12];
8705 hdb
= create_package_db();
8706 ok( hdb
, "failed to create database\n" );
8708 create_property_table( hdb
);
8710 sprintf( package
, "#%u", hdb
);
8711 r
= MsiOpenPackageA( package
, &hpkg
);
8712 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
8714 skip("Not enough rights to perform tests\n");
8717 ok( r
== ERROR_SUCCESS
, "got %u\n", r
);
8719 r
= MsiSetPropertyA( hpkg
, "PROP", "value" );
8720 ok( r
== ERROR_SUCCESS
, "got %u\n", r
);
8724 r
= MsiGetPropertyA( hpkg
, "PROP", buf
, &sz
);
8725 ok( r
== ERROR_SUCCESS
, "MsiGetPropertyA returned %u\n", r
);
8726 ok( !lstrcmpA( buf
, "value" ), "got \"%s\"\n", buf
);
8728 r
= MsiDatabaseCommit( hdb
);
8729 ok( r
== ERROR_SUCCESS
, "MsiDatabaseCommit returned %u\n", r
);
8733 r
= MsiGetPropertyA( hpkg
, "PROP", buf
, &sz
);
8734 ok( r
== ERROR_SUCCESS
, "MsiGetPropertyA returned %u\n", r
);
8735 ok( !lstrcmpA( buf
, "value" ), "got \"%s\"\n", buf
);
8737 MsiCloseHandle( hpkg
);
8739 MsiCloseHandle( hdb
);
8740 DeleteFileA( msifile
);
8743 static int externalui_ran
;
8745 static INT CALLBACK
externalui_callback(void *context
, UINT message_type
, LPCSTR message
)
8748 ok(message_type
== INSTALLMESSAGE_USER
, "expected INSTALLMESSAGE_USER, got %08x\n", message_type
);
8752 static int externalui_record_ran
;
8754 static INT CALLBACK
externalui_record_callback(void *context
, UINT message_type
, MSIHANDLE hrecord
)
8756 INT retval
= context
? *((INT
*)context
) : 0;
8758 externalui_record_ran
= 1;
8759 ok(message_type
== INSTALLMESSAGE_USER
, "expected INSTALLMESSAGE_USER, got %08x\n", message_type
);
8760 r
= MsiRecordGetFieldCount(hrecord
);
8761 ok(r
== 1, "expected 1, got %u\n", r
);
8762 r
= MsiRecordGetInteger(hrecord
, 1);
8763 ok(r
== 12345, "expected 12345, got %u\n", r
);
8767 static void test_externalui(void)
8769 /* test that external UI handlers work correctly */
8771 INSTALLUI_HANDLERA prev
;
8772 INSTALLUI_HANDLER_RECORD prev_record
;
8773 MSIHANDLE hpkg
, hrecord
;
8777 prev
= MsiSetExternalUIA(externalui_callback
, INSTALLLOGMODE_USER
, NULL
);
8779 r
= package_from_db(create_package_db(), &hpkg
);
8780 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
8782 skip("Not enough rights to perform tests\n");
8783 DeleteFileA(msifile
);
8786 ok(r
== ERROR_SUCCESS
, "Expected a valid package %u\n", r
);
8788 hrecord
= MsiCreateRecord(1);
8789 ok(hrecord
, "Expected a valid record\n");
8790 r
= MsiRecordSetStringA(hrecord
, 0, "test message [1]");
8791 ok(r
== ERROR_SUCCESS
, "MsiSetString failed %u\n", r
);
8792 r
= MsiRecordSetInteger(hrecord
, 1, 12345);
8793 ok(r
== ERROR_SUCCESS
, "MsiSetInteger failed %u\n", r
);
8796 r
= MsiProcessMessage(hpkg
, INSTALLMESSAGE_USER
, hrecord
);
8797 ok(r
== 0, "expected 0, got %u\n", r
);
8798 ok(externalui_ran
== 1, "external UI callback did not run\n");
8800 prev
= MsiSetExternalUIA(prev
, 0, NULL
);
8801 ok(prev
== externalui_callback
, "wrong callback function %p\n", prev
);
8802 r
= MsiSetExternalUIRecord(externalui_record_callback
, INSTALLLOGMODE_USER
, &retval
, &prev_record
);
8803 ok(r
== ERROR_SUCCESS
, "MsiSetExternalUIRecord failed %u\n", r
);
8805 externalui_ran
= externalui_record_ran
= 0;
8806 r
= MsiProcessMessage(hpkg
, INSTALLMESSAGE_USER
, hrecord
);
8807 ok(r
== 0, "expected 0, got %u\n", r
);
8808 ok(externalui_ran
== 0, "external UI callback should not have run\n");
8809 ok(externalui_record_ran
== 1, "external UI record callback did not run\n");
8811 MsiSetExternalUIA(externalui_callback
, INSTALLLOGMODE_USER
, NULL
);
8813 externalui_ran
= externalui_record_ran
= 0;
8814 r
= MsiProcessMessage(hpkg
, INSTALLMESSAGE_USER
, hrecord
);
8815 ok(r
== 0, "expected 0, got %u\n", r
);
8816 ok(externalui_ran
== 1, "external UI callback did not run\n");
8817 ok(externalui_record_ran
== 1, "external UI record callback did not run\n");
8820 externalui_ran
= externalui_record_ran
= 0;
8821 r
= MsiProcessMessage(hpkg
, INSTALLMESSAGE_USER
, hrecord
);
8822 ok(r
== 1, "expected 1, got %u\n", r
);
8823 ok(externalui_ran
== 0, "external UI callback should not have run\n");
8824 ok(externalui_record_ran
== 1, "external UI record callback did not run\n");
8826 /* filter and context should be kept separately */
8827 r
= MsiSetExternalUIRecord(externalui_record_callback
, INSTALLLOGMODE_ERROR
, &retval
, &prev_record
);
8828 ok(r
== ERROR_SUCCESS
, "MsiSetExternalUIRecord failed %u\n", r
);
8830 externalui_ran
= externalui_record_ran
= 0;
8831 r
= MsiProcessMessage(hpkg
, INSTALLMESSAGE_USER
, hrecord
);
8832 ok(r
== 0, "expected 0, got %u\n", r
);
8833 ok(externalui_ran
== 1, "external UI callback did not run\n");
8834 ok(externalui_record_ran
== 0, "external UI record callback should not have run\n");
8836 MsiCloseHandle(hpkg
);
8837 DeleteFileA(msifile
);
8840 struct externalui_message
{
8844 int match
[4]; /* should we test for a match */
8848 static struct externalui_message
*sequence
;
8849 static int sequence_count
, sequence_size
;
8851 static void add_message(const struct externalui_message
*msg
)
8856 sequence
= HeapAlloc(GetProcessHeap(), 0, sequence_size
* sizeof(*sequence
));
8858 if (sequence_count
== sequence_size
)
8861 sequence
= HeapReAlloc(GetProcessHeap(), 0, sequence
, sequence_size
* sizeof(*sequence
));
8866 sequence
[sequence_count
++] = *msg
;
8869 static void flush_sequence(void)
8871 HeapFree(GetProcessHeap(), 0, sequence
);
8873 sequence_count
= sequence_size
= 0;
8876 static void ok_sequence_(const struct externalui_message
*expected
, const char *context
, BOOL todo
,
8877 const char *file
, int line
)
8879 static const struct externalui_message end_of_sequence
= {0};
8880 const struct externalui_message
*actual
;
8884 add_message(&end_of_sequence
);
8888 while (expected
->message
&& actual
->message
)
8890 if (expected
->message
== actual
->message
)
8892 if (expected
->field_count
< actual
->field_count
)
8895 ok_(file
, line
) (FALSE
, "%s: in msg 0x%08x expecting field count %d got %d\n",
8896 context
, expected
->message
, expected
->field_count
, actual
->field_count
);
8900 for (i
= 0; i
<= actual
->field_count
; i
++)
8902 if (expected
->match
[i
] && strcmp(expected
->field
[i
], actual
->field
[i
]))
8905 ok_(file
, line
) (FALSE
, "%s: in msg 0x%08x field %d: expected \"%s\", got \"%s\"\n",
8906 context
, expected
->message
, i
, expected
->field
[i
], actual
->field
[i
]);
8914 else if (expected
->optional
)
8921 ok_(file
, line
) (FALSE
, "%s: the msg 0x%08x was expected, but got msg 0x%08x instead\n",
8922 context
, expected
->message
, actual
->message
);
8931 if (expected
->message
|| actual
->message
)
8934 ok_(file
, line
) (FALSE
, "%s: the msg sequence is not complete: expected %08x - actual %08x\n",
8935 context
, expected
->message
, actual
->message
);
8939 if(todo
&& !failcount
) /* succeeded yet marked todo */
8942 ok_(file
, line
)(TRUE
, "%s: marked \"todo_wine\" but succeeds\n", context
);
8949 #define ok_sequence(exp, contx, todo) \
8950 ok_sequence_((exp), (contx), (todo), __FILE__, __LINE__)
8952 /* don't use PROGRESS, which is timing-dependent,
8953 * or SHOWDIALOG, which due to a bug causes a hang on XP */
8954 static const INSTALLLOGMODE MSITEST_INSTALLLOGMODE
=
8955 INSTALLLOGMODE_FATALEXIT
|
8956 INSTALLLOGMODE_ERROR
|
8957 INSTALLLOGMODE_WARNING
|
8958 INSTALLLOGMODE_USER
|
8959 INSTALLLOGMODE_INFO
|
8960 INSTALLLOGMODE_FILESINUSE
|
8961 INSTALLLOGMODE_RESOLVESOURCE
|
8962 INSTALLLOGMODE_OUTOFDISKSPACE
|
8963 INSTALLLOGMODE_ACTIONSTART
|
8964 INSTALLLOGMODE_ACTIONDATA
|
8965 INSTALLLOGMODE_COMMONDATA
|
8966 INSTALLLOGMODE_INITIALIZE
|
8967 INSTALLLOGMODE_TERMINATE
|
8968 INSTALLLOGMODE_RMFILESINUSE
|
8969 INSTALLLOGMODE_INSTALLSTART
|
8970 INSTALLLOGMODE_INSTALLEND
;
8972 static const struct externalui_message empty_sequence
[] = {
8976 static const struct externalui_message openpackage_nonexistent_sequence
[] = {
8977 {INSTALLMESSAGE_INITIALIZE
, -1},
8978 {INSTALLMESSAGE_TERMINATE
, -1},
8982 static const struct externalui_message openpackage_sequence
[] = {
8983 {INSTALLMESSAGE_INITIALIZE
, -1},
8984 {INSTALLMESSAGE_COMMONDATA
, 3, {"", "0", "1033", "1252"}, {1, 1, 1, 1}},
8985 {INSTALLMESSAGE_INFO
|MB_ICONHAND
, 0, {""}, {0}},
8986 {INSTALLMESSAGE_COMMONDATA
, 3, {"", "0", "1033", "1252"}, {0, 1, 1, 1}},
8987 {INSTALLMESSAGE_COMMONDATA
, 3, {"", "1", "", ""}, {0, 1, 0, 0}},
8991 static const struct externalui_message processmessage_info_sequence
[] = {
8992 {INSTALLMESSAGE_INFO
, 3, {"zero", "one", "two", "three"}, {1, 1, 1, 1}},
8996 static const struct externalui_message processmessage_actionstart_sequence
[] = {
8997 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "name", "description", "template"}, {0, 1, 1, 1}},
9001 static const struct externalui_message processmessage_actiondata_sequence
[] = {
9002 {INSTALLMESSAGE_ACTIONDATA
, 3, {"{{name: }}template", "cherry", "banana", "guava"}, {1, 1, 1, 1}},
9006 static const struct externalui_message processmessage_error_sequence
[] = {
9007 {INSTALLMESSAGE_USER
, 3, {"", "1311", "banana", "guava"}, {0, 1, 1, 1}},
9011 static const struct externalui_message processmessage_internal_error_sequence
[] = {
9012 {INSTALLMESSAGE_INFO
, 3, {"DEBUG: Error [1]: Action not found: [2]", "2726", "banana", "guava"}, {1, 1, 1, 1}},
9013 {INSTALLMESSAGE_USER
, 3, {"internal error", "2726", "banana", "guava"}, {1, 1, 1, 1}},
9017 static const struct externalui_message processmessage_error_format_sequence
[] = {
9018 {INSTALLMESSAGE_USER
, 3, {"", "2726", "banana", "guava"}, {0, 1, 1, 1}},
9022 static const struct externalui_message doaction_costinitialize_sequence
[] = {
9023 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "CostInitialize", "cost description", "cost template"}, {0, 1, 1, 1}},
9024 {INSTALLMESSAGE_INFO
, 2, {"", "CostInitialize", ""}, {0, 1, 1}},
9025 {INSTALLMESSAGE_INFO
, 2, {"", "CostInitialize", "1"}, {0, 1, 1}},
9029 static const struct externalui_message doaction_custom_sequence
[] = {
9030 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "custom", "description", "template"}, {0, 1, 1, 1}},
9031 {INSTALLMESSAGE_INFO
, 2, {"", "custom", "1"}, {0, 1, 1}},
9032 {INSTALLMESSAGE_INFO
, 2, {"", "custom", "0"}, {0, 1, 1}},
9036 static const struct externalui_message doaction_custom_fullui_sequence
[] = {
9037 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "custom", "", ""}, {0, 1, 1, 1}},
9038 {INSTALLMESSAGE_INFO
, 2, {"", "custom", ""}, {0, 1, 1}},
9039 {INSTALLMESSAGE_SHOWDIALOG
, 0, {"custom"}, {1}},
9040 {INSTALLMESSAGE_INFO
, 2, {"", "custom", "1"}, {0, 1, 1}},
9044 static const struct externalui_message doaction_custom_cancel_sequence
[] = {
9045 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "custom", "", ""}, {0, 1, 1, 1}},
9049 static const struct externalui_message doaction_dialog_nonexistent_sequence
[] = {
9050 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "custom", "", ""}, {0, 1, 1, 1}},
9051 {INSTALLMESSAGE_INFO
, 2, {"", "custom", "1"}, {0, 1, 1}},
9052 {INSTALLMESSAGE_SHOWDIALOG
, 0, {"custom"}, {1}},
9053 {INSTALLMESSAGE_INFO
, 2, {"DEBUG: Error [1]: Action not found: [2]", "2726", "custom"}, {1, 1, 1}},
9054 {INSTALLMESSAGE_INFO
, 2, {"", "2726", "custom"}, {0, 1, 1}},
9055 {INSTALLMESSAGE_INFO
, 2, {"", "custom", "0"}, {0, 1, 1}},
9059 static const struct externalui_message doaction_dialog_sequence
[] = {
9060 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "dialog", "", ""}, {0, 1, 1, 1}},
9061 {INSTALLMESSAGE_INFO
, 2, {"", "dialog", "0"}, {0, 1, 1}},
9062 {INSTALLMESSAGE_SHOWDIALOG
, 0, {"dialog"}, {1}},
9063 {INSTALLMESSAGE_ACTIONSTART
, 2, {"", "dialog", "Dialog created"}, {0, 1, 1}},
9064 {INSTALLMESSAGE_INFO
, 2, {"", "dialog", "1"}, {0, 1, 1}},
9068 static const struct externalui_message doaction_dialog_error_sequence
[] = {
9069 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "error", "", ""}, {0, 1, 1, 1}},
9070 {INSTALLMESSAGE_INFO
, 2, {"", "error", "1"}, {0, 1, 1}},
9071 {INSTALLMESSAGE_SHOWDIALOG
, 0, {"error"}, {1}},
9075 static const struct externalui_message doaction_dialog_3_sequence
[] = {
9076 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "dialog", "", ""}, {0, 1, 1, 1}},
9077 {INSTALLMESSAGE_INFO
, 2, {"", "dialog", "0"}, {0, 1, 1}},
9078 {INSTALLMESSAGE_SHOWDIALOG
, 0, {"dialog"}, {1}},
9079 {INSTALLMESSAGE_INFO
, 2, {"", "dialog", "3"}, {0, 1, 1}},
9083 static const struct externalui_message doaction_dialog_12345_sequence
[] = {
9084 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "dialog", "", ""}, {0, 1, 1, 1}},
9085 {INSTALLMESSAGE_INFO
, 2, {"", "dialog", "3"}, {0, 1, 1}},
9086 {INSTALLMESSAGE_SHOWDIALOG
, 0, {"dialog"}, {1}},
9087 {INSTALLMESSAGE_INFO
, 2, {"", "dialog", "12345"}, {0, 1, 1}},
9091 static const struct externalui_message closehandle_sequence
[] = {
9092 {INSTALLMESSAGE_TERMINATE
, -1},
9096 static INT CALLBACK
externalui_message_string_callback(void *context
, UINT message
, LPCSTR string
)
9098 INT retval
= context
? *((INT
*)context
) : 0;
9099 struct externalui_message msg
;
9101 msg
.message
= message
;
9102 msg
.field_count
= 0;
9103 strcpy(msg
.field
[0], string
);
9109 static INT CALLBACK
externalui_message_callback(void *context
, UINT message
, MSIHANDLE hrecord
)
9111 INT retval
= context
? *((INT
*)context
) : 0;
9112 struct externalui_message msg
;
9117 msg
.message
= message
;
9118 if (message
== INSTALLMESSAGE_TERMINATE
)
9120 /* trying to access the record seems to hang on some versions of Windows */
9121 msg
.field_count
= -1;
9125 msg
.field_count
= MsiRecordGetFieldCount(hrecord
);
9126 for (i
= 0; i
<= msg
.field_count
; i
++)
9129 MsiRecordGetStringA(hrecord
, i
, buffer
, &length
);
9130 memcpy(msg
.field
[i
], buffer
, min(100, length
+1));
9133 /* top-level actions dump a list of all set properties; skip them since they're inconsistent */
9134 if (message
== (INSTALLMESSAGE_INFO
|MB_ICONHAND
) && msg
.field_count
> 0 && !strncmp(msg
.field
[0], "Property", 8))
9142 static void test_externalui_message(void)
9144 /* test that events trigger the correct sequence of messages */
9146 INSTALLUI_HANDLER_RECORD prev
;
9147 MSIHANDLE hdb
, hpkg
, hrecord
;
9151 MsiSetInternalUI(INSTALLUILEVEL_FULL
, NULL
);
9153 MsiSetExternalUIA(externalui_message_string_callback
, INSTALLLOGMODE_SHOWDIALOG
, &retval
);
9154 r
= MsiSetExternalUIRecord(externalui_message_callback
, MSITEST_INSTALLLOGMODE
, &retval
, &prev
);
9160 hdb
= create_package_db();
9161 ok(hdb
, "failed to create database\n");
9163 create_file_data("forcecodepage.idt", "\r\n\r\n1252\t_ForceCodepage\r\n");
9164 r
= MsiDatabaseImportA(hdb
, CURR_DIR
, "forcecodepage.idt");
9165 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9167 r
= run_query(hdb
, "CREATE TABLE `Error` (`Error` SHORT NOT NULL, `Message` CHAR(0) PRIMARY KEY `Error`)");
9168 ok(r
== ERROR_SUCCESS
, "Failed to create Error table: %u\n", r
);
9169 r
= run_query(hdb
, "INSERT INTO `Error` (`Error`, `Message`) VALUES (5, 'internal error')");
9170 ok(r
== ERROR_SUCCESS
, "Failed to insert into Error table: %u\n", r
);
9172 create_actiontext_table(hdb
);
9173 add_actiontext_entry(hdb
, "'custom', 'description', 'template'");
9174 add_actiontext_entry(hdb
, "'CostInitialize', 'cost description', 'cost template'");
9176 r
= MsiOpenPackageA(NULL
, &hpkg
);
9177 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
9178 ok_sequence(empty_sequence
, "MsiOpenPackage with NULL db", FALSE
);
9180 r
= MsiOpenPackageA("nonexistent", &hpkg
);
9181 ok(r
== ERROR_FILE_NOT_FOUND
, "Expected ERROR_FILE_NOT_FOUND, got %d\n", r
);
9182 ok_sequence(openpackage_nonexistent_sequence
, "MsiOpenPackage with nonexistent db", FALSE
);
9184 r
= package_from_db(hdb
, &hpkg
);
9185 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
9187 skip("Not enough rights to perform tests\n");
9188 DeleteFileA(msifile
);
9191 ok(r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
9192 ok_sequence(openpackage_sequence
, "MsiOpenPackage with valid db", FALSE
);
9194 /* Test MsiProcessMessage */
9195 hrecord
= MsiCreateRecord(3);
9196 ok(hrecord
, "failed to create record\n");
9198 MsiRecordSetStringA(hrecord
, 0, "zero");
9199 MsiRecordSetStringA(hrecord
, 1, "one");
9200 MsiRecordSetStringA(hrecord
, 2, "two");
9201 MsiRecordSetStringA(hrecord
, 3, "three");
9202 r
= MsiProcessMessage(hpkg
, INSTALLMESSAGE_INFO
, hrecord
);
9203 ok(r
== 1, "Expected 1, got %d\n", r
);
9204 ok_sequence(processmessage_info_sequence
, "MsiProcessMessage(INSTALLMESSAGE_INFO)", FALSE
);
9206 MsiRecordSetStringA(hrecord
, 1, "name");
9207 MsiRecordSetStringA(hrecord
, 2, "description");
9208 MsiRecordSetStringA(hrecord
, 3, "template");
9209 r
= MsiProcessMessage(hpkg
, INSTALLMESSAGE_ACTIONSTART
, hrecord
);
9210 ok(r
== 1, "Expected 1, got %d\n", r
);
9211 ok_sequence(processmessage_actionstart_sequence
, "MsiProcessMessage(INSTALLMESSAGE_ACTIONSTART)", FALSE
);
9213 MsiRecordSetStringA(hrecord
, 0, "apple");
9214 MsiRecordSetStringA(hrecord
, 1, "cherry");
9215 MsiRecordSetStringA(hrecord
, 2, "banana");
9216 MsiRecordSetStringA(hrecord
, 3, "guava");
9217 r
= MsiProcessMessage(hpkg
, INSTALLMESSAGE_ACTIONDATA
, hrecord
);
9218 ok(r
== 1, "Expected 1, got %d\n", r
);
9219 ok_sequence(processmessage_actiondata_sequence
, "MsiProcessMessage(INSTALLMESSAGE_ACTIONDATA)", FALSE
);
9221 /* non-internal error */
9222 MsiRecordSetStringA(hrecord
, 0, NULL
);
9223 MsiRecordSetInteger(hrecord
, 1, 1311);
9224 r
= MsiProcessMessage(hpkg
, INSTALLMESSAGE_USER
, hrecord
);
9225 ok(r
== 1, "Expected 1, got %d\n", r
);
9226 ok_sequence(processmessage_error_sequence
, "MsiProcessMessage non-internal error", FALSE
);
9228 /* internal error */
9229 MsiRecordSetStringA(hrecord
, 0, NULL
);
9230 MsiRecordSetInteger(hrecord
, 1, 2726);
9231 r
= MsiProcessMessage(hpkg
, INSTALLMESSAGE_USER
, hrecord
);
9232 ok(r
== 0, "Expected 0, got %d\n", r
);
9233 ok_sequence(processmessage_internal_error_sequence
, "MsiProcessMessage internal error", FALSE
);
9235 /* with format field */
9236 MsiRecordSetStringA(hrecord
, 0, "starfruit");
9237 r
= MsiProcessMessage(hpkg
, INSTALLMESSAGE_USER
, hrecord
);
9238 ok(r
== 1, "Expected 1, got %d\n", r
);
9239 ok_sequence(processmessage_error_format_sequence
, "MsiProcessMessage error", FALSE
);
9241 /* Test a standard action */
9242 r
= MsiDoActionA(hpkg
, "CostInitialize");
9243 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9244 ok_sequence(doaction_costinitialize_sequence
, "MsiDoAction(\"CostInitialize\")", FALSE
);
9246 /* Test a custom action */
9247 r
= MsiDoActionA(hpkg
, "custom");
9248 ok(r
== ERROR_FUNCTION_NOT_CALLED
, "Expected ERROR_FUNCTION_NOT_CALLED, got %d\n", r
);
9249 ok_sequence(doaction_custom_sequence
, "MsiDoAction(\"custom\")", FALSE
);
9251 /* close the package */
9252 MsiCloseHandle(hpkg
);
9253 ok_sequence(closehandle_sequence
, "MsiCloseHandle()", FALSE
);
9256 hdb
= create_package_db();
9257 ok(hdb
, "failed to create database\n");
9259 r
= MsiDatabaseImportA(hdb
, CURR_DIR
, "forcecodepage.idt");
9260 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9262 create_dialog_table(hdb
);
9263 add_dialog_entry(hdb
, "'dialog', 50, 50, 100, 100, 0, 'dummy'");
9265 create_control_table(hdb
);
9266 add_control_entry(hdb
, "'dialog', 'dummy', 'Text', 5, 5, 5, 5, 3, 'dummy'");
9268 r
= package_from_db(hdb
, &hpkg
);
9269 ok(r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
9270 ok_sequence(openpackage_sequence
, "MsiOpenPackage with valid db", FALSE
);
9272 /* Test a custom action */
9273 r
= MsiDoActionA(hpkg
, "custom");
9274 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9275 ok_sequence(doaction_custom_fullui_sequence
, "MsiDoAction(\"custom\")", FALSE
);
9278 r
= MsiDoActionA(hpkg
, "custom");
9279 ok(r
== ERROR_INSTALL_USEREXIT
, "Expected ERROR_INSTALL_USEREXIT, got %d\n", r
);
9280 ok_sequence(doaction_custom_cancel_sequence
, "MsiDoAction(\"custom\")", FALSE
);
9283 r
= MsiDoActionA(hpkg
, "custom");
9284 ok(r
== ERROR_FUNCTION_NOT_CALLED
, "Expected ERROR_FUNCTION_NOT_CALLED, got %d\n", r
);
9285 ok_sequence(doaction_dialog_nonexistent_sequence
, "MsiDoAction(\"custom\")", FALSE
);
9287 r
= MsiDoActionA(hpkg
, "dialog");
9288 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9289 ok_sequence(doaction_dialog_sequence
, "MsiDoAction(\"dialog\")", FALSE
);
9292 r
= MsiDoActionA(hpkg
, "error");
9293 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9294 ok_sequence(doaction_dialog_error_sequence
, "MsiDoAction(\"error\")", FALSE
);
9296 r
= MsiDoActionA(hpkg
, "error");
9297 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9298 ok_sequence(doaction_dialog_error_sequence
, "MsiDoAction(\"error\")", FALSE
);
9301 r
= MsiDoActionA(hpkg
, "custom");
9302 ok(r
== ERROR_FUNCTION_NOT_CALLED
, "Expected ERROR_FUNCTION_NOT_CALLED, got %d\n", r
);
9303 ok_sequence(doaction_dialog_nonexistent_sequence
, "MsiDoAction(\"custom\")", FALSE
);
9306 r
= MsiDoActionA(hpkg
, "dialog");
9307 ok(r
== ERROR_INSTALL_FAILURE
, "Expected ERROR_INSTALL_FAILURE, got %d\n", r
);
9308 ok_sequence(doaction_dialog_3_sequence
, "MsiDoAction(\"dialog\")", FALSE
);
9311 r
= MsiDoActionA(hpkg
, "dialog");
9312 ok(r
== ERROR_FUNCTION_FAILED
, "Expected ERROR_INSTALL_FAILURE, got %d\n", r
);
9313 ok_sequence(doaction_dialog_12345_sequence
, "MsiDoAction(\"dialog\")", FALSE
);
9315 MsiCloseHandle(hpkg
);
9316 ok_sequence(closehandle_sequence
, "MsiCloseHandle()", FALSE
);
9318 MsiCloseHandle(hrecord
);
9320 DeleteFileA(msifile
);
9321 DeleteFileA("forcecodepage.idt");
9324 static const struct externalui_message controlevent_spawn_sequence
[] = {
9325 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "spawn", "", ""}, {0, 1, 1, 1}},
9326 {INSTALLMESSAGE_INFO
, 2, {"", "spawn", ""}, {0, 1, 1}},
9327 {INSTALLMESSAGE_SHOWDIALOG
, 0, {"spawn"}, {1}},
9328 {INSTALLMESSAGE_ACTIONSTART
, 2, {"", "spawn", "Dialog created"}, {0, 1, 1}},
9330 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "custom", "", ""}, {0, 1, 1, 1}},
9331 {INSTALLMESSAGE_INFO
, 2, {"", "custom", ""}, {0, 1, 1}},
9332 {INSTALLMESSAGE_INFO
, 2, {"", "custom", "1"}, {0, 1, 1}},
9334 {INSTALLMESSAGE_ACTIONSTART
, 2, {"", "child1", "Dialog created"}, {0, 1, 1}},
9336 {INSTALLMESSAGE_INFO
, 2, {"", "spawn", "2"}, {0, 1, 1}},
9340 static const struct externalui_message controlevent_spawn2_sequence
[] = {
9341 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "spawn2", "", ""}, {0, 1, 1, 1}},
9342 {INSTALLMESSAGE_INFO
, 2, {"", "spawn2", "2"}, {0, 1, 1}},
9343 {INSTALLMESSAGE_SHOWDIALOG
, 0, {"spawn2"}, {1}},
9344 {INSTALLMESSAGE_ACTIONSTART
, 2, {"", "spawn2", "Dialog created"}, {0, 1, 1}},
9346 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "custom", "", ""}, {0, 1, 1, 1}},
9347 {INSTALLMESSAGE_INFO
, 2, {"", "custom", "2"}, {0, 1, 1}},
9348 {INSTALLMESSAGE_INFO
, 2, {"", "custom", "1"}, {0, 1, 1}},
9350 {INSTALLMESSAGE_ACTIONSTART
, 2, {"", "child2", "Dialog created"}, {0, 1, 1}},
9352 {INSTALLMESSAGE_INFO
, 2, {"", "spawn2", "2"}, {0, 1, 1}},
9356 static void test_controlevent(void)
9358 INSTALLUI_HANDLER_RECORD prev
;
9359 MSIHANDLE hdb
, hpkg
;
9362 if (!winetest_interactive
)
9364 skip("interactive ControlEvent tests\n");
9368 MsiSetInternalUI(INSTALLUILEVEL_FULL
, NULL
);
9370 MsiSetExternalUIA(externalui_message_string_callback
, INSTALLLOGMODE_SHOWDIALOG
, NULL
);
9371 r
= MsiSetExternalUIRecord(externalui_message_callback
, MSITEST_INSTALLLOGMODE
, NULL
, &prev
);
9377 hdb
= create_package_db();
9378 ok(hdb
, "failed to create database\n");
9380 create_file_data("forcecodepage.idt", "\r\n\r\n1252\t_ForceCodepage\r\n");
9381 r
= MsiDatabaseImportA(hdb
, CURR_DIR
, "forcecodepage.idt");
9382 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9384 create_dialog_table(hdb
);
9385 add_dialog_entry(hdb
, "'spawn', 50, 50, 100, 100, 3, 'button'");
9386 add_dialog_entry(hdb
, "'spawn2', 50, 50, 100, 100, 3, 'button'");
9387 add_dialog_entry(hdb
, "'child1', 50, 50, 80, 40, 3, 'exit'");
9388 add_dialog_entry(hdb
, "'child2', 50, 50, 80, 40, 3, 'exit'");
9390 create_control_table(hdb
);
9391 add_control_entry(hdb
, "'spawn', 'button', 'PushButton', 10, 10, 66, 17, 3, 'Click me'");
9392 add_control_entry(hdb
, "'spawn2', 'button', 'PushButton', 10, 10, 66, 17, 3, 'Click me'");
9393 add_control_entry(hdb
, "'child1', 'exit', 'PushButton', 10, 10, 66, 17, 3, 'Click me'");
9394 add_control_entry(hdb
, "'child2', 'exit', 'PushButton', 10, 10, 66, 17, 3, 'Click me'");
9396 create_controlevent_table(hdb
);
9397 add_controlevent_entry(hdb
, "'child1', 'exit', 'EndDialog', 'Exit', 1, 1");
9398 add_controlevent_entry(hdb
, "'child2', 'exit', 'EndDialog', 'Exit', 1, 1");
9400 create_custom_action_table(hdb
);
9401 add_custom_action_entry(hdb
, "'custom', 51, 'dummy', 'dummy value'");
9403 /* SpawnDialog and EndDialog should trigger after all other events */
9404 add_controlevent_entry(hdb
, "'spawn', 'button', 'SpawnDialog', 'child1', 1, 1");
9405 add_controlevent_entry(hdb
, "'spawn', 'button', 'DoAction', 'custom', 1, 2");
9407 /* Multiple dialog events cause only the last one to be triggered */
9408 add_controlevent_entry(hdb
, "'spawn2', 'button', 'SpawnDialog', 'child1', 1, 1");
9409 add_controlevent_entry(hdb
, "'spawn2', 'button', 'SpawnDialog', 'child2', 1, 2");
9410 add_controlevent_entry(hdb
, "'spawn2', 'button', 'DoAction', 'custom', 1, 3");
9412 r
= package_from_db(hdb
, &hpkg
);
9413 ok(r
== ERROR_SUCCESS
, "failed to create package: %u\n", r
);
9414 ok_sequence(openpackage_sequence
, "MsiOpenPackage()", FALSE
);
9416 r
= MsiDoActionA(hpkg
, "spawn");
9417 ok(r
== ERROR_INSTALL_USEREXIT
, "expected ERROR_INSTALL_USEREXIT, got %u\n", r
);
9418 ok_sequence(controlevent_spawn_sequence
, "control event: spawn", FALSE
);
9420 r
= MsiDoActionA(hpkg
, "spawn2");
9421 ok(r
== ERROR_INSTALL_USEREXIT
, "expected ERROR_INSTALL_USEREXIT, got %u\n", r
);
9422 ok_sequence(controlevent_spawn2_sequence
, "control event: spawn2", FALSE
);
9424 MsiCloseHandle(hpkg
);
9425 ok_sequence(closehandle_sequence
, "MsiCloseHandle()", FALSE
);
9428 DeleteFileA(msifile
);
9429 DeleteFileA("forcecodepage.idt");
9432 static const struct externalui_message toplevel_install_sequence
[] = {
9433 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "INSTALL", "", ""}, {0, 1, 1, 1}},
9434 {INSTALLMESSAGE_INFO
, 2, {"", "INSTALL", ""}, {0, 1, 1}},
9436 {INSTALLMESSAGE_COMMONDATA
, 3, {"", "0", "1033", "1252"}, {1, 1, 1, 1}},
9437 {INSTALLMESSAGE_COMMONDATA
, 3, {"", "0", "1033", "1252"}, {1, 1, 1, 1}},
9438 {INSTALLMESSAGE_INFO
|MB_ICONHAND
, 0, {""}, {0}},
9439 {INSTALLMESSAGE_COMMONDATA
, 3, {"", "0", "1033", "1252"}, {0, 1, 1, 1}},
9440 {INSTALLMESSAGE_COMMONDATA
, 3, {"", "1", "", ""}, {0, 1, 0, 0}},
9442 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "INSTALL", "", ""}, {0, 1, 1, 1}},
9443 {INSTALLMESSAGE_INFO
, 2, {"", "INSTALL", ""}, {0, 1, 1}},
9444 {INSTALLMESSAGE_INSTALLSTART
, 2, {"", "", "{7262AC98-EEBD-4364-8CE3-D654F6A425B9}"}, {1, 1, 1}, 1},
9446 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "CostInitialize", "", ""}, {0, 1, 0, 1}},
9447 {INSTALLMESSAGE_INFO
, 2, {"", "CostInitialize", ""}, {0, 1, 1}},
9448 {INSTALLMESSAGE_INFO
, 2, {"", "CostInitialize", "1"}, {0, 1, 1}},
9450 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "FileCost", "", ""}, {0, 1, 0, 1}},
9451 {INSTALLMESSAGE_INFO
, 2, {"", "FileCost", "1"}, {0, 1, 1}},
9452 {INSTALLMESSAGE_INFO
, 2, {"", "FileCost", "1"}, {0, 1, 1}},
9454 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "CostFinalize", "", ""}, {0, 1, 0, 1}},
9455 {INSTALLMESSAGE_INFO
, 2, {"", "CostFinalize", "1"}, {0, 1, 1}},
9456 {INSTALLMESSAGE_INFO
, 2, {"", "CostFinalize", "1"}, {0, 1, 1}},
9458 {INSTALLMESSAGE_INFO
, 2, {"", "INSTALL", "1"}, {0, 1, 1}},
9459 {INSTALLMESSAGE_INSTALLEND
, 3, {"", "", "{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "1"}, {1, 1, 1, 1}, 1},
9463 {INSTALLMESSAGE_COMMONDATA
, 2, {"", "2", "0"}, {0, 1, 1}, 1},
9464 {INSTALLMESSAGE_COMMONDATA
, 2, {"", "2", "1"}, {0, 1, 1}, 1},
9465 {INSTALLMESSAGE_INFO
, 2, {"", "INSTALL", "1"}, {0, 1, 1}},
9469 static const struct externalui_message toplevel_install_ui_sequence
[] = {
9470 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "INSTALL", "", ""}, {0, 1, 1, 1}},
9471 {INSTALLMESSAGE_INFO
, 2, {"", "INSTALL", ""}, {0, 1, 1}},
9473 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "AppSearch", "", ""}, {0, 1, 0, 0}},
9474 {INSTALLMESSAGE_INFO
, 2, {"", "AppSearch", ""}, {0, 1, 1}},
9475 {INSTALLMESSAGE_INFO
, 2, {"", "AppSearch", "0"}, {0, 1, 1}},
9477 {INSTALLMESSAGE_INFO
, 2, {"", "INSTALL", "1"}, {0, 1, 1}},
9481 static const struct externalui_message toplevel_executeaction_install_sequence
[] = {
9482 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "ExecuteAction", "", ""}, {0, 1, 1, 1}},
9483 {INSTALLMESSAGE_INFO
, 2, {"", "ExecuteAction", "1"}, {0, 1, 1}},
9485 {INSTALLMESSAGE_COMMONDATA
, 3, {"", "0", "1033", "1252"}, {1, 1, 1, 1}},
9486 {INSTALLMESSAGE_COMMONDATA
, 3, {"", "0", "1033", "1252"}, {1, 1, 1, 1}},
9487 {INSTALLMESSAGE_COMMONDATA
, 3, {"", "0", "1033", "1252"}, {0, 1, 1, 1}},
9488 {INSTALLMESSAGE_COMMONDATA
, 3, {"", "1", "", ""}, {0, 1, 0, 0}},
9490 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "INSTALL", "", ""}, {0, 1, 1, 1}},
9491 {INSTALLMESSAGE_INFO
, 2, {"", "INSTALL", ""}, {0, 1, 1}},
9492 {INSTALLMESSAGE_INSTALLSTART
, 2, {"", "", "{7262AC98-EEBD-4364-8CE3-D654F6A425B9}"}, {1, 1, 1}, 1},
9494 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "CostInitialize", "", ""}, {0, 1, 0, 1}},
9495 {INSTALLMESSAGE_INFO
, 2, {"", "CostInitialize"}, {0, 1}},
9496 {INSTALLMESSAGE_INFO
, 2, {"", "CostInitialize", "1"}, {0, 1, 1}},
9498 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "FileCost", "", ""}, {0, 1, 0, 1}},
9499 {INSTALLMESSAGE_INFO
, 2, {"", "FileCost", "1"}, {0, 1, 1}},
9500 {INSTALLMESSAGE_INFO
, 2, {"", "FileCost", "1"}, {0, 1, 1}},
9502 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "CostFinalize", "", ""}, {0, 1, 0, 1}},
9503 {INSTALLMESSAGE_INFO
, 2, {"", "CostFinalize", "1"}, {0, 1, 1}},
9504 {INSTALLMESSAGE_INFO
, 2, {"", "CostFinalize", "1"}, {0, 1, 1}},
9506 {INSTALLMESSAGE_INFO
, 2, {"", "INSTALL", "1"}, {0, 1, 1}},
9507 {INSTALLMESSAGE_INSTALLEND
, 3, {"", "", "{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "1"}, {1, 1, 1, 1}, 1},
9511 {INSTALLMESSAGE_COMMONDATA
, 2, {"", "2", "0"}, {0, 1, 1}, 1},
9512 {INSTALLMESSAGE_COMMONDATA
, 2, {"", "2", "1"}, {0, 1, 1}, 1},
9513 {INSTALLMESSAGE_INFO
, 2, {"", "ExecuteAction", "1"}, {0, 1, 1}},
9517 static const struct externalui_message toplevel_executeaction_costinitialize_sequence
[] = {
9518 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "ExecuteAction", "", ""}, {0, 1, 1, 1}},
9519 {INSTALLMESSAGE_INFO
, 2, {"", "ExecuteAction", "1"}, {0, 1, 1}},
9521 {INSTALLMESSAGE_COMMONDATA
, 3, {"", "0", "1033", "1252"}, {1, 1, 1, 1}},
9522 {INSTALLMESSAGE_COMMONDATA
, 3, {"", "0", "1033", "1252"}, {1, 1, 1, 1}},
9523 {INSTALLMESSAGE_COMMONDATA
, 3, {"", "0", "1033", "1252"}, {0, 1, 1, 1}},
9524 {INSTALLMESSAGE_COMMONDATA
, 3, {"", "1", "", ""}, {0, 1, 0, 0}},
9526 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "CostInitialize", "", ""}, {0, 1, 0, 1}},
9527 {INSTALLMESSAGE_INFO
, 2, {"", "CostInitialize", ""}, {0, 1}},
9528 {INSTALLMESSAGE_INFO
, 2, {"", "CostInitialize", "1"}, {0, 1, 1}},
9532 {INSTALLMESSAGE_COMMONDATA
, 2, {"", "2", "0"}, {0, 1, 1}, 1},
9533 {INSTALLMESSAGE_COMMONDATA
, 2, {"", "2", "1"}, {0, 1, 1}, 1},
9534 {INSTALLMESSAGE_INFO
, 2, {"", "ExecuteAction", "1"}, {0, 1, 1}},
9538 static const struct externalui_message toplevel_msiinstallproduct_sequence
[] = {
9539 {INSTALLMESSAGE_INITIALIZE
, -1},
9541 {INSTALLMESSAGE_COMMONDATA
, 3, {"", "0", "1033", "1252"}, {1, 1, 1, 1}},
9542 {INSTALLMESSAGE_COMMONDATA
, 3, {"", "0", "1033", "1252"}, {1, 1, 1, 1}},
9543 {INSTALLMESSAGE_INFO
|MB_ICONHAND
, 0, {""}, {0}},
9544 {INSTALLMESSAGE_COMMONDATA
, 3, {"", "0", "1033", "1252"}, {0, 1, 1, 1}},
9545 {INSTALLMESSAGE_COMMONDATA
, 3, {"", "1", "", ""}, {0, 1, 0, 0}},
9547 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "INSTALL", "", ""}, {0, 1, 1, 1}},
9548 {INSTALLMESSAGE_INFO
, 2, {"", "INSTALL", ""}, {0, 1, 1}},
9550 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "AppSearch", "", ""}, {0, 1, 0, 0}},
9551 {INSTALLMESSAGE_INFO
, 2, {"", "AppSearch", ""}, {0, 1, 1}},
9552 {INSTALLMESSAGE_INFO
, 2, {"", "AppSearch", "0"}, {0, 1, 1}},
9554 {INSTALLMESSAGE_INFO
, 2, {"", "INSTALL", "1"}, {0, 1, 1}},
9558 {INSTALLMESSAGE_INFO
|MB_ICONHAND
, 0, {""}, {0}},
9559 {INSTALLMESSAGE_TERMINATE
, -1},
9563 static const struct externalui_message toplevel_msiinstallproduct_custom_sequence
[] = {
9564 {INSTALLMESSAGE_INITIALIZE
, -1},
9566 {INSTALLMESSAGE_COMMONDATA
, 3, {"", "0", "1033", "1252"}, {1, 1, 1, 1}},
9567 {INSTALLMESSAGE_COMMONDATA
, 3, {"", "0", "1033", "1252"}, {1, 1, 1, 1}},
9568 {INSTALLMESSAGE_INFO
|MB_ICONHAND
, 0, {""}, {0}},
9569 {INSTALLMESSAGE_COMMONDATA
, 3, {"", "0", "1033", "1252"}, {0, 1, 1, 1}},
9570 {INSTALLMESSAGE_COMMONDATA
, 3, {"", "1", "", ""}, {0, 1, 0, 0}},
9572 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "CUSTOM", "", ""}, {0, 1, 1, 1}},
9573 {INSTALLMESSAGE_INFO
, 2, {"", "CUSTOM", ""}, {0, 1, 1}},
9574 {INSTALLMESSAGE_INFO
, 2, {"", "CUSTOM", "0"}, {0, 1, 1}},
9578 {INSTALLMESSAGE_INFO
|MB_ICONHAND
, 0, {""}, {0}},
9579 {INSTALLMESSAGE_TERMINATE
, -1},
9583 /* tests involving top-level actions: INSTALL, ExecuteAction */
9584 static void test_top_level_action(void)
9586 INSTALLUI_HANDLER_RECORD prev
;
9587 MSIHANDLE hdb
, hpkg
;
9589 char msifile_absolute
[MAX_PATH
];
9591 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
9593 MsiSetExternalUIA(externalui_message_string_callback
, INSTALLLOGMODE_SHOWDIALOG
, NULL
);
9594 r
= MsiSetExternalUIRecord(externalui_message_callback
, MSITEST_INSTALLLOGMODE
, NULL
, &prev
);
9600 hdb
= create_package_db();
9601 ok(hdb
, "failed to create database\n");
9603 create_file_data("forcecodepage.idt", "\r\n\r\n1252\t_ForceCodepage\r\n");
9604 r
= MsiDatabaseImportA(hdb
, CURR_DIR
, "forcecodepage.idt");
9605 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9607 create_property_table(hdb
);
9608 add_property_entry(hdb
, "'ProductCode', '{7262AC98-EEBD-4364-8CE3-D654F6A425B9}'");
9610 create_install_execute_sequence_table(hdb
);
9611 add_install_execute_sequence_entry(hdb
, "'CostInitialize', '', 1");
9612 add_install_execute_sequence_entry(hdb
, "'FileCost', '', 2");
9613 add_install_execute_sequence_entry(hdb
, "'CostFinalize', '', 3");
9615 create_install_ui_sequence_table(hdb
);
9616 add_install_ui_sequence_entry(hdb
, "'AppSearch', '', 1");
9618 MsiDatabaseCommit(hdb
);
9620 /* for some reason we have to open the package from file using an absolute path */
9621 MsiCloseHandle(hdb
);
9622 GetFullPathNameA(msifile
, MAX_PATH
, msifile_absolute
, NULL
);
9623 r
= MsiOpenPackageA(msifile_absolute
, &hpkg
);
9624 ok(r
== ERROR_SUCCESS
, "failed to create package: %u\n", r
);
9625 ok_sequence(openpackage_sequence
, "MsiOpenPackage()", FALSE
);
9628 r
= MsiDoActionA(hpkg
, "INSTALL");
9629 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
9630 ok_sequence(toplevel_install_sequence
, "INSTALL (no UI)", FALSE
);
9632 /* test INSTALL with reduced+ UI */
9633 /* for some reason we need to re-open the package to change the internal UI */
9634 MsiCloseHandle(hpkg
);
9635 ok_sequence(closehandle_sequence
, "MsiCloseHandle()", FALSE
);
9636 MsiSetInternalUI(INSTALLUILEVEL_REDUCED
, NULL
);
9637 r
= MsiOpenPackageA(msifile_absolute
, &hpkg
);
9638 ok(r
== ERROR_SUCCESS
, "failed to create package: %u\n", r
);
9639 ok_sequence(openpackage_sequence
, "MsiOpenPackage()", FALSE
);
9641 r
= MsiDoActionA(hpkg
, "INSTALL");
9642 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
9643 ok_sequence(toplevel_install_ui_sequence
, "INSTALL (reduced+ UI)", TRUE
);
9645 /* test ExecuteAction with EXECUTEACTION property unset */
9646 MsiSetPropertyA(hpkg
, "EXECUTEACTION", NULL
);
9647 r
= MsiDoActionA(hpkg
, "ExecuteAction");
9648 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
9649 ok_sequence(toplevel_executeaction_install_sequence
, "ExecuteAction: INSTALL", FALSE
);
9651 /* test ExecuteAction with EXECUTEACTION property set */
9652 MsiSetPropertyA(hpkg
, "EXECUTEACTION", "CostInitialize");
9653 r
= MsiDoActionA(hpkg
, "ExecuteAction");
9654 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
9655 ok_sequence(toplevel_executeaction_costinitialize_sequence
, "ExecuteAction: CostInitialize", FALSE
);
9657 MsiCloseHandle(hpkg
);
9658 ok_sequence(closehandle_sequence
, "MsiCloseHandle()", FALSE
);
9660 /* test MsiInstallProduct() */
9661 r
= MsiInstallProductA(msifile_absolute
, NULL
);
9662 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
9663 ok_sequence(toplevel_msiinstallproduct_sequence
, "MsiInstallProduct()", TRUE
);
9665 r
= MsiInstallProductA(msifile_absolute
, "ACTION=custom");
9667 ok(r
== ERROR_INSTALL_FAILURE
, "expected ERROR_INSTALL_FAILURE, got %u\n", r
);
9668 ok_sequence(toplevel_msiinstallproduct_custom_sequence
, "MsiInstallProduct(ACTION=custom)", TRUE
);
9671 DeleteFileA(msifile
);
9672 DeleteFileA("forcecodepage.idt");
9677 STATEMGRSTATUS status
;
9680 init_functionpointers();
9682 if (pIsWow64Process
)
9683 pIsWow64Process(GetCurrentProcess(), &is_wow64
);
9685 GetCurrentDirectoryA(MAX_PATH
, CURR_DIR
);
9687 /* Create a restore point ourselves so we circumvent the multitude of restore points
9688 * that would have been created by all the installation and removal tests.
9690 * This is not needed on version 5.0 where setting MSIFASTINSTALL prevents the
9691 * creation of restore points.
9693 if (pSRSetRestorePointA
&& !pMsiGetComponentPathExA
)
9695 memset(&status
, 0, sizeof(status
));
9696 ret
= notify_system_change(BEGIN_NESTED_SYSTEM_CHANGE
, &status
);
9699 test_createpackage();
9701 test_gettargetpath_bad();
9702 test_settargetpath();
9704 test_property_table();
9707 test_formatrecord2();
9708 test_formatrecord_tables();
9713 test_appsearch_complocator();
9714 test_appsearch_reglocator();
9715 test_appsearch_inilocator();
9716 test_appsearch_drlocator();
9717 test_featureparents();
9718 test_installprops();
9719 test_launchconditions();
9722 test_MsiGetSourcePath();
9723 test_shortlongsource();
9726 test_emptypackage();
9727 test_MsiGetProductProperty();
9728 test_MsiSetProperty();
9729 test_MsiApplyMultiplePatches();
9730 test_MsiApplyPatch();
9731 test_MsiEnumComponentCosts();
9732 test_MsiDatabaseCommit();
9734 test_externalui_message();
9735 test_controlevent();
9736 test_top_level_action();
9738 if (pSRSetRestorePointA
&& !pMsiGetComponentPathExA
&& ret
)
9740 ret
= notify_system_change(END_NESTED_SYSTEM_CHANGE
, &status
);
9742 remove_restore_point(status
.llSequenceNumber
);