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
> ARRAY_SIZE(szNameBuf
))
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 UINT
create_upgrade_table( MSIHANDLE hdb
)
756 UINT r
= run_query( hdb
,
757 "CREATE TABLE `Upgrade` ("
758 "`UpgradeCode` CHAR(38) NOT NULL, "
759 "`VersionMin` CHAR(20), "
760 "`VersionMax` CHAR(20), "
761 "`Language` CHAR(255), "
762 "`Attributes` SHORT, "
763 "`Remove` CHAR(255), "
764 "`ActionProperty` CHAR(72) NOT NULL "
765 "PRIMARY KEY `UpgradeCode`, `VersionMin`, `VersionMax`, `Language`)" );
766 ok(r
== ERROR_SUCCESS
, "Failed to create Upgrade table: %u\n", r
);
770 static inline UINT
add_entry(const char *file
, int line
, const char *type
, MSIHANDLE hdb
, const char *values
, const char *insert
)
775 sz
= strlen(values
) + strlen(insert
) + 1;
776 query
= HeapAlloc(GetProcessHeap(), 0, sz
);
777 sprintf(query
, insert
, values
);
778 r
= run_query(hdb
, query
);
779 HeapFree(GetProcessHeap(), 0, query
);
780 ok_(file
, line
)(r
== ERROR_SUCCESS
, "failed to insert into %s table: %u\n", type
, r
);
784 #define add_component_entry(hdb, values) add_entry(__FILE__, __LINE__, "Component", hdb, values, \
785 "INSERT INTO `Component` " \
786 "(`Component`, `ComponentId`, `Directory_`, " \
787 "`Attributes`, `Condition`, `KeyPath`) VALUES( %s )")
789 #define add_directory_entry(hdb, values) add_entry(__FILE__, __LINE__, "Directory", hdb, values, \
790 "INSERT INTO `Directory` " \
791 "(`Directory`,`Directory_Parent`,`DefaultDir`) VALUES( %s )")
793 #define add_feature_entry(hdb, values) add_entry(__FILE__, __LINE__, "Feature", hdb, values, \
794 "INSERT INTO `Feature` " \
795 "(`Feature`, `Feature_Parent`, `Title`, `Description`, " \
796 "`Display`, `Level`, `Directory_`, `Attributes`) VALUES( %s )")
798 #define add_feature_components_entry(hdb, values) add_entry(__FILE__, __LINE__, "FeatureComponents", hdb, values, \
799 "INSERT INTO `FeatureComponents` " \
800 "(`Feature_`, `Component_`) VALUES( %s )")
802 #define add_file_entry(hdb, values) add_entry(__FILE__, __LINE__, "File", hdb, values, \
803 "INSERT INTO `File` " \
804 "(`File`, `Component_`, `FileName`, `FileSize`, " \
805 "`Version`, `Language`, `Attributes`, `Sequence`) VALUES( %s )")
807 #define add_appsearch_entry(hdb, values) add_entry(__FILE__, __LINE__, "AppSearch", hdb, values, \
808 "INSERT INTO `AppSearch` " \
809 "(`Property`, `Signature_`) VALUES( %s )")
811 #define add_signature_entry(hdb, values) add_entry(__FILE__, __LINE__, "Signature", hdb, values, \
812 "INSERT INTO `Signature` " \
813 "(`Signature`, `FileName`, `MinVersion`, `MaxVersion`," \
814 " `MinSize`, `MaxSize`, `MinDate`, `MaxDate`, `Languages`) " \
817 #define add_launchcondition_entry(hdb, values) add_entry(__FILE__, __LINE__, "LaunchCondition", hdb, values, \
818 "INSERT INTO `LaunchCondition` " \
819 "(`Condition`, `Description`) VALUES( %s )")
821 #define add_property_entry(hdb, values) add_entry(__FILE__, __LINE__, "Property", hdb, values, \
822 "INSERT INTO `Property` (`Property`, `Value`) VALUES( %s )")
824 #define update_ProductVersion_property(hdb, value) add_entry(__FILE__, __LINE__, "Property", hdb, value, \
825 "UPDATE `Property` SET `Value` = '%s' WHERE `Property` = 'ProductVersion'")
827 #define update_ProductCode_property(hdb, value) add_entry(__FILE__, __LINE__, "Property", hdb, value, \
828 "UPDATE `Property` SET `Value` = '%s' WHERE `Property` = 'ProductCode'")
830 #define add_install_execute_sequence_entry(hdb, values) add_entry(__FILE__, __LINE__, "InstallExecuteSequence", hdb, values, \
831 "INSERT INTO `InstallExecuteSequence` " \
832 "(`Action`, `Condition`, `Sequence`) VALUES( %s )")
834 #define add_install_ui_sequence_entry(hdb, values) add_entry(__FILE__, __LINE__, "InstallUISequence", hdb, values, \
835 "INSERT INTO `InstallUISequence` " \
836 "(`Action`, `Condition`, `Sequence`) VALUES( %s )")
838 #define add_media_entry(hdb, values) add_entry(__FILE__, __LINE__, "Media", hdb, values, \
839 "INSERT INTO `Media` " \
840 "(`DiskId`, `LastSequence`, `DiskPrompt`, " \
841 "`Cabinet`, `VolumeLabel`, `Source`) VALUES( %s )")
843 #define add_ccpsearch_entry(hdb, values) add_entry(__FILE__, __LINE__, "CCPSearch", hdb, values, \
844 "INSERT INTO `CCPSearch` (`Signature_`) VALUES( %s )")
846 #define add_drlocator_entry(hdb, values) add_entry(__FILE__, __LINE__, "DrLocator", hdb, values, \
847 "INSERT INTO `DrLocator` " \
848 "(`Signature_`, `Parent`, `Path`, `Depth`) VALUES( %s )")
850 #define add_complocator_entry(hdb, values) add_entry(__FILE__, __LINE__, "CompLocator", hdb, values, \
851 "INSERT INTO `CompLocator` " \
852 "(`Signature_`, `ComponentId`, `Type`) VALUES( %s )")
854 #define add_inilocator_entry(hdb, values) add_entry(__FILE__, __LINE__, "IniLocator", hdb, values, \
855 "INSERT INTO `IniLocator` " \
856 "(`Signature_`, `FileName`, `Section`, `Key`, `Field`, `Type`) " \
859 #define add_custom_action_entry(hdb, values) add_entry(__FILE__, __LINE__, "CustomAction", hdb, values, \
860 "INSERT INTO `CustomAction` " \
861 "(`Action`, `Type`, `Source`, `Target`) VALUES( %s )")
863 #define add_dialog_entry(hdb, values) add_entry(__FILE__, __LINE__, "Dialog", hdb, values, \
864 "INSERT INTO `Dialog` " \
865 "(`Dialog`, `HCentering`, `VCentering`, `Width`, `Height`, `Attributes`, `Control_First`) VALUES ( %s )")
867 #define add_control_entry(hdb, values) add_entry(__FILE__, __LINE__, "Control", hdb, values, \
868 "INSERT INTO `Control` " \
869 "(`Dialog_`, `Control`, `Type`, `X`, `Y`, `Width`, `Height`, `Attributes`, `Text`) VALUES( %s )");
871 #define add_controlevent_entry(hdb, values) add_entry(__FILE__, __LINE__, "ControlEvent", hdb, values, \
872 "INSERT INTO `ControlEvent` " \
873 "(`Dialog_`, `Control_`, `Event`, `Argument`, `Condition`, `Ordering`) VALUES( %s )");
875 #define add_actiontext_entry(hdb, values) add_entry(__FILE__, __LINE__, "ActionText", hdb, values, \
876 "INSERT INTO `ActionText` " \
877 "(`Action`, `Description`, `Template`) VALUES( %s )");
879 #define add_upgrade_entry(hdb, values) add_entry(__FILE__, __LINE__, "Upgrade", hdb, values, \
880 "INSERT INTO `Upgrade` " \
881 "(`UpgradeCode`, `VersionMin`, `VersionMax`, `Language`, `Attributes`, `Remove`, `ActionProperty`) VALUES( %s )");
883 static UINT
add_reglocator_entry( MSIHANDLE hdb
, const char *sig
, UINT root
, const char *path
,
884 const char *name
, UINT type
)
886 const char insert
[] =
887 "INSERT INTO `RegLocator` (`Signature_`, `Root`, `Key`, `Name`, `Type`) "
888 "VALUES( '%s', %u, '%s', '%s', %u )";
892 sz
= strlen( sig
) + 10 + strlen( path
) + strlen( name
) + 10 + sizeof( insert
);
893 query
= HeapAlloc( GetProcessHeap(), 0, sz
);
894 sprintf( query
, insert
, sig
, root
, path
, name
, type
);
895 r
= run_query( hdb
, query
);
896 HeapFree( GetProcessHeap(), 0, query
);
897 ok(r
== ERROR_SUCCESS
, "failed to insert into reglocator table: %u\n", r
); \
901 static UINT
set_summary_info(MSIHANDLE hdb
)
906 /* build summary info */
907 res
= MsiGetSummaryInformationA(hdb
, NULL
, 7, &suminfo
);
908 ok( res
== ERROR_SUCCESS
, "Failed to open summaryinfo\n" );
910 res
= MsiSummaryInfoSetPropertyA(suminfo
,2, VT_LPSTR
, 0,NULL
,
911 "Installation Database");
912 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
914 res
= MsiSummaryInfoSetPropertyA(suminfo
,3, VT_LPSTR
, 0,NULL
,
915 "Installation Database");
916 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
918 res
= MsiSummaryInfoSetPropertyA(suminfo
,4, VT_LPSTR
, 0,NULL
,
920 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
922 res
= MsiSummaryInfoSetPropertyA(suminfo
,7, VT_LPSTR
, 0,NULL
,
924 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
926 res
= MsiSummaryInfoSetPropertyA(suminfo
,9, VT_LPSTR
, 0,NULL
,
927 "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}");
928 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
930 res
= MsiSummaryInfoSetPropertyA(suminfo
, 14, VT_I4
, 100, NULL
, NULL
);
931 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
933 res
= MsiSummaryInfoSetPropertyA(suminfo
, 15, VT_I4
, 0, NULL
, NULL
);
934 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
936 res
= MsiSummaryInfoPersist(suminfo
);
937 ok( res
== ERROR_SUCCESS
, "Failed to make summary info persist\n" );
939 res
= MsiCloseHandle( suminfo
);
940 ok( res
== ERROR_SUCCESS
, "Failed to close suminfo\n" );
946 static MSIHANDLE
create_package_db(void)
951 DeleteFileA(msifile
);
953 /* create an empty database */
954 res
= MsiOpenDatabaseW(msifileW
, MSIDBOPEN_CREATE
, &hdb
);
955 ok( res
== ERROR_SUCCESS
, "Failed to create database %u\n", res
);
956 if( res
!= ERROR_SUCCESS
)
959 res
= MsiDatabaseCommit( hdb
);
960 ok( res
== ERROR_SUCCESS
, "Failed to commit database\n" );
962 res
= set_summary_info(hdb
);
963 ok( res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", res
);
965 res
= run_query( hdb
,
966 "CREATE TABLE `Directory` ( "
967 "`Directory` CHAR(255) NOT NULL, "
968 "`Directory_Parent` CHAR(255), "
969 "`DefaultDir` CHAR(255) NOT NULL "
970 "PRIMARY KEY `Directory`)" );
971 ok( res
== ERROR_SUCCESS
, "Failed to create directory table\n" );
976 static UINT
package_from_db(MSIHANDLE hdb
, MSIHANDLE
*handle
)
982 sprintf(szPackage
, "#%u", hdb
);
983 res
= MsiOpenPackageA(szPackage
, &hPackage
);
984 if (res
!= ERROR_SUCCESS
)
990 res
= MsiCloseHandle(hdb
);
991 if (res
!= ERROR_SUCCESS
)
993 MsiCloseHandle(hPackage
);
998 return ERROR_SUCCESS
;
1001 static void create_file_data(LPCSTR name
, LPCSTR data
)
1006 file
= CreateFileA(name
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, 0, NULL
);
1007 ok(file
!= INVALID_HANDLE_VALUE
, "Failure to open file %s\n", name
);
1008 if (file
== INVALID_HANDLE_VALUE
)
1011 WriteFile(file
, data
, strlen(data
), &written
, NULL
);
1012 WriteFile(file
, "\n", strlen("\n"), &written
, NULL
);
1017 static void create_test_file(const CHAR
*name
)
1019 create_file_data(name
, name
);
1022 typedef struct _tagVS_VERSIONINFO
1029 VS_FIXEDFILEINFO Value
;
1034 #define roundoffs(a, b, r) (((BYTE *)(b) - (BYTE *)(a) + ((r) - 1)) & ~((r) - 1))
1035 #define roundpos(a, b, r) (((BYTE *)(a)) + roundoffs(a, b, r))
1037 static BOOL
create_file_with_version(const CHAR
*name
, LONG ms
, LONG ls
)
1039 VS_VERSIONINFO
*pVerInfo
;
1040 VS_FIXEDFILEINFO
*pFixedInfo
;
1042 CHAR path
[MAX_PATH
];
1047 GetSystemDirectoryA(path
, MAX_PATH
);
1048 /* Some dlls can't be updated on Vista/W2K8 */
1049 lstrcatA(path
, "\\version.dll");
1051 CopyFileA(path
, name
, FALSE
);
1053 size
= GetFileVersionInfoSizeA(path
, &handle
);
1054 buffer
= HeapAlloc(GetProcessHeap(), 0, size
);
1056 GetFileVersionInfoA(path
, 0, size
, buffer
);
1058 pVerInfo
= (VS_VERSIONINFO
*)buffer
;
1059 ofs
= (BYTE
*)&pVerInfo
->szKey
[lstrlenW(pVerInfo
->szKey
) + 1];
1060 pFixedInfo
= (VS_FIXEDFILEINFO
*)roundpos(pVerInfo
, ofs
, 4);
1062 pFixedInfo
->dwFileVersionMS
= ms
;
1063 pFixedInfo
->dwFileVersionLS
= ls
;
1064 pFixedInfo
->dwProductVersionMS
= ms
;
1065 pFixedInfo
->dwProductVersionLS
= ls
;
1067 resource
= BeginUpdateResourceA(name
, FALSE
);
1071 if (!UpdateResourceA(resource
, (LPCSTR
)RT_VERSION
, (LPCSTR
)MAKEINTRESOURCE(VS_VERSION_INFO
),
1072 MAKELANGID(LANG_NEUTRAL
, SUBLANG_NEUTRAL
), buffer
, size
))
1075 if (!EndUpdateResourceA(resource
, FALSE
))
1081 HeapFree(GetProcessHeap(), 0, buffer
);
1085 static BOOL
notify_system_change(DWORD event_type
, STATEMGRSTATUS
*status
)
1087 RESTOREPOINTINFOA spec
;
1089 spec
.dwEventType
= event_type
;
1090 spec
.dwRestorePtType
= APPLICATION_INSTALL
;
1091 spec
.llSequenceNumber
= status
->llSequenceNumber
;
1092 lstrcpyA(spec
.szDescription
, "msitest restore point");
1094 return pSRSetRestorePointA(&spec
, status
);
1097 static void remove_restore_point(DWORD seq_number
)
1101 res
= pSRRemoveRestorePoint(seq_number
);
1102 if (res
!= ERROR_SUCCESS
)
1103 trace("Failed to remove the restore point : %08x\n", res
);
1106 static BOOL
is_root(const char *path
)
1108 return (isalpha(path
[0]) && path
[1] == ':' && path
[2] == '\\' && !path
[3]);
1111 static void test_createpackage(void)
1113 MSIHANDLE hPackage
= 0;
1116 res
= package_from_db(create_package_db(), &hPackage
);
1117 if (res
== ERROR_INSTALL_PACKAGE_REJECTED
)
1119 skip("Not enough rights to perform tests\n");
1120 DeleteFileA(msifile
);
1123 ok( res
== ERROR_SUCCESS
, " Failed to create package %u\n", res
);
1125 res
= MsiCloseHandle( hPackage
);
1126 ok( res
== ERROR_SUCCESS
, "Failed to close package\n" );
1127 DeleteFileA(msifile
);
1130 static void test_doaction( void )
1135 r
= MsiDoActionA( -1, NULL
);
1136 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
1138 r
= package_from_db(create_package_db(), &hpkg
);
1139 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
1141 skip("Not enough rights to perform tests\n");
1142 DeleteFileA(msifile
);
1145 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
1147 r
= MsiDoActionA(hpkg
, NULL
);
1148 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
1150 r
= MsiDoActionA(0, "boo");
1151 ok( r
== ERROR_INVALID_HANDLE
, "wrong return val\n");
1153 r
= MsiDoActionA(hpkg
, "boo");
1154 ok( r
== ERROR_FUNCTION_NOT_CALLED
, "wrong return val\n");
1156 MsiCloseHandle( hpkg
);
1157 DeleteFileA(msifile
);
1160 static void test_gettargetpath_bad(void)
1162 static const WCHAR boo
[] = {'b','o','o',0};
1163 static const WCHAR empty
[] = {0};
1165 WCHAR bufferW
[0x80];
1170 r
= package_from_db(create_package_db(), &hpkg
);
1171 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
1173 skip("Not enough rights to perform tests\n");
1174 DeleteFileA(msifile
);
1177 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
1179 r
= MsiGetTargetPathA( 0, NULL
, NULL
, NULL
);
1180 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
1182 r
= MsiGetTargetPathA( 0, NULL
, NULL
, &sz
);
1183 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
1185 r
= MsiGetTargetPathA( 0, "boo", NULL
, NULL
);
1186 ok( r
== ERROR_INVALID_HANDLE
, "wrong return val\n");
1188 r
= MsiGetTargetPathA( 0, "boo", NULL
, NULL
);
1189 ok( r
== ERROR_INVALID_HANDLE
, "wrong return val\n");
1191 r
= MsiGetTargetPathA( hpkg
, "boo", NULL
, NULL
);
1192 ok( r
== ERROR_DIRECTORY
, "wrong return val\n");
1194 r
= MsiGetTargetPathA( hpkg
, "boo", buffer
, NULL
);
1195 ok( r
== ERROR_DIRECTORY
, "wrong return val\n");
1198 r
= MsiGetTargetPathA( hpkg
, "", buffer
, &sz
);
1199 ok( r
== ERROR_DIRECTORY
, "wrong return val\n");
1201 r
= MsiGetTargetPathW( 0, NULL
, NULL
, NULL
);
1202 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
1204 r
= MsiGetTargetPathW( 0, NULL
, NULL
, &sz
);
1205 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
1207 r
= MsiGetTargetPathW( 0, boo
, NULL
, NULL
);
1208 ok( r
== ERROR_INVALID_HANDLE
, "wrong return val\n");
1210 r
= MsiGetTargetPathW( 0, boo
, NULL
, NULL
);
1211 ok( r
== ERROR_INVALID_HANDLE
, "wrong return val\n");
1213 r
= MsiGetTargetPathW( hpkg
, boo
, NULL
, NULL
);
1214 ok( r
== ERROR_DIRECTORY
, "wrong return val\n");
1216 r
= MsiGetTargetPathW( hpkg
, boo
, bufferW
, NULL
);
1217 ok( r
== ERROR_DIRECTORY
, "wrong return val\n");
1220 r
= MsiGetTargetPathW( hpkg
, empty
, bufferW
, &sz
);
1221 ok( r
== ERROR_DIRECTORY
, "wrong return val\n");
1223 MsiCloseHandle( hpkg
);
1224 DeleteFileA(msifile
);
1227 static void query_file_path(MSIHANDLE hpkg
, LPCSTR file
, LPSTR buff
)
1233 rec
= MsiCreateRecord( 1 );
1234 ok(rec
, "MsiCreate record failed\n");
1236 r
= MsiRecordSetStringA( rec
, 0, file
);
1237 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
1240 r
= MsiFormatRecordA( hpkg
, rec
, buff
, &size
);
1241 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
1243 MsiCloseHandle( rec
);
1246 static void test_settargetpath(void)
1248 char tempdir
[MAX_PATH
+8], buffer
[MAX_PATH
], file
[MAX_PATH
];
1254 hdb
= create_package_db();
1255 ok ( hdb
, "failed to create package database\n" );
1257 add_directory_entry( hdb
, "'TARGETDIR', '', 'SourceDir'" );
1259 create_component_table( hdb
);
1260 add_component_entry( hdb
, "'RootComp', '{83e2694d-0864-4124-9323-6d37630912a1}', 'TARGETDIR', 8, '', 'RootFile'" );
1261 add_component_entry( hdb
, "'TestComp', '{A3FB59C8-C293-4F7E-B8C5-F0E1D8EEE4E5}', 'TestDir', 0, '', 'TestFile'" );
1263 create_feature_table( hdb
);
1264 add_feature_entry( hdb
, "'TestFeature', '', '', '', 0, 1, '', 0" );
1266 create_feature_components_table( hdb
);
1267 add_feature_components_entry( hdb
, "'TestFeature', 'RootComp'" );
1268 add_feature_components_entry( hdb
, "'TestFeature', 'TestComp'" );
1270 add_directory_entry( hdb
, "'TestParent', 'TARGETDIR', 'TestParent'" );
1271 add_directory_entry( hdb
, "'TestDir', 'TestParent', 'TestDir'" );
1273 create_file_table( hdb
);
1274 add_file_entry( hdb
, "'RootFile', 'RootComp', 'rootfile.txt', 0, '', '1033', 8192, 1" );
1275 add_file_entry( hdb
, "'TestFile', 'TestComp', 'testfile.txt', 0, '', '1033', 8192, 1" );
1277 r
= package_from_db( hdb
, &hpkg
);
1278 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
1280 skip("Not enough rights to perform tests\n");
1281 DeleteFileA(msifile
);
1284 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
1286 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
1288 r
= MsiDoActionA( hpkg
, "CostInitialize");
1289 ok( r
== ERROR_SUCCESS
, "cost init failed\n");
1291 r
= MsiDoActionA( hpkg
, "FileCost");
1292 ok( r
== ERROR_SUCCESS
, "file cost failed\n");
1294 r
= MsiDoActionA( hpkg
, "CostFinalize");
1295 ok( r
== ERROR_SUCCESS
, "cost finalize failed\n");
1298 sz
= sizeof(buffer
);
1299 r
= MsiGetPropertyA( hpkg
, "OutOfNoRbDiskSpace", buffer
, &sz
);
1300 ok( r
== ERROR_SUCCESS
, "MsiGetProperty returned %u\n", r
);
1301 trace( "OutOfNoRbDiskSpace = \"%s\"\n", buffer
);
1303 r
= MsiSetTargetPathA( 0, NULL
, NULL
);
1304 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
1306 r
= MsiSetTargetPathA( 0, "boo", "C:\\bogusx" );
1307 ok( r
== ERROR_INVALID_HANDLE
, "wrong return val\n");
1309 r
= MsiSetTargetPathA( hpkg
, "boo", NULL
);
1310 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
1312 r
= MsiSetTargetPathA( hpkg
, "boo", "c:\\bogusx" );
1313 ok( r
== ERROR_DIRECTORY
, "wrong return val\n");
1315 sz
= sizeof tempdir
- 1;
1316 r
= MsiGetTargetPathA( hpkg
, "TARGETDIR", tempdir
, &sz
);
1317 sprintf( file
, "%srootfile.txt", tempdir
);
1319 query_file_path( hpkg
, "[#RootFile]", buffer
);
1320 ok( r
== ERROR_SUCCESS
, "failed to get target path: %d\n", r
);
1321 ok( !lstrcmpA(buffer
, file
), "Expected %s, got %s\n", file
, buffer
);
1323 GetTempFileNameA( tempdir
, "_wt", 0, buffer
);
1324 sprintf( tempdir
, "%s\\subdir", buffer
);
1326 r
= MsiSetTargetPathA( hpkg
, "TARGETDIR", buffer
);
1327 ok( r
== ERROR_SUCCESS
|| r
== ERROR_DIRECTORY
,
1328 "MsiSetTargetPath on file returned %d\n", r
);
1330 r
= MsiSetTargetPathA( hpkg
, "TARGETDIR", tempdir
);
1331 ok( r
== ERROR_SUCCESS
|| r
== ERROR_DIRECTORY
,
1332 "MsiSetTargetPath on 'subdir' of file returned %d\n", r
);
1334 DeleteFileA( buffer
);
1336 r
= MsiSetTargetPathA( hpkg
, "TARGETDIR", buffer
);
1337 ok( r
== ERROR_SUCCESS
, "MsiSetTargetPath returned %d\n", r
);
1339 r
= GetFileAttributesA( buffer
);
1340 ok ( r
== INVALID_FILE_ATTRIBUTES
, "file/directory exists after MsiSetTargetPath. Attributes: %08X\n", r
);
1342 r
= MsiSetTargetPathA( hpkg
, "TARGETDIR", tempdir
);
1343 ok( r
== ERROR_SUCCESS
, "MsiSetTargetPath on subsubdir returned %d\n", r
);
1346 sz
= sizeof buffer
- 1;
1347 lstrcatA( tempdir
, "\\" );
1348 r
= MsiGetTargetPathA( hpkg
, "TARGETDIR", buffer
, &sz
);
1349 ok( r
== ERROR_SUCCESS
, "failed to get target path: %d\n", r
);
1350 ok( !lstrcmpA(buffer
, tempdir
), "Expected %s, got %s\n", tempdir
, buffer
);
1352 sprintf( file
, "%srootfile.txt", tempdir
);
1353 query_file_path( hpkg
, "[#RootFile]", buffer
);
1354 ok( !lstrcmpA(buffer
, file
), "Expected %s, got %s\n", file
, buffer
);
1357 sz
= sizeof(buffer
);
1358 r
= MsiGetPropertyA( hpkg
, "TestParent", buffer
, &sz
);
1359 ok( r
== ERROR_SUCCESS
, "MsiGetProperty returned %u\n", r
);
1360 lstrcatA( tempdir
, "TestParent\\" );
1361 ok( !lstrcmpiA(buffer
, tempdir
), "Expected \"%s\", got \"%s\"\n", tempdir
, buffer
);
1363 r
= MsiSetTargetPathA( hpkg
, "TestParent", "C:\\one\\two" );
1364 ok( r
== ERROR_SUCCESS
, "MsiSetTargetPath returned %d\n", r
);
1367 sz
= sizeof(buffer
);
1368 r
= MsiGetPropertyA( hpkg
, "TestParent", buffer
, &sz
);
1369 ok( r
== ERROR_SUCCESS
, "MsiGetProperty returned %u\n", r
);
1370 ok( lstrcmpiA(buffer
, "C:\\one\\two\\TestDir\\"),
1371 "Expected \"C:\\one\\two\\TestDir\\\", got \"%s\"\n", buffer
);
1374 query_file_path( hpkg
, "[#TestFile]", buffer
);
1375 ok( !lstrcmpiA(buffer
, "C:\\one\\two\\TestDir\\testfile.txt"),
1376 "Expected C:\\one\\two\\TestDir\\testfile.txt, got %s\n", buffer
);
1379 sz
= sizeof buffer
- 1;
1380 r
= MsiGetTargetPathA( hpkg
, "TestParent", buffer
, &sz
);
1381 ok( r
== ERROR_SUCCESS
, "failed to get target path: %d\n", r
);
1382 ok( !lstrcmpiA(buffer
, "C:\\one\\two\\"), "Expected C:\\one\\two\\, got %s\n", buffer
);
1384 r
= MsiSetTargetPathA( hpkg
, "TestParent", "C:\\one\\two\\three" );
1385 ok( r
== ERROR_SUCCESS
, "MsiSetTargetPath returned %d\n", r
);
1388 sz
= sizeof buffer
- 1;
1389 r
= MsiGetTargetPathA( hpkg
, "TestParent", buffer
, &sz
);
1390 ok( r
== ERROR_SUCCESS
, "failed to get target path: %d\n", r
);
1391 ok( !lstrcmpiA(buffer
, "C:\\one\\two\\three\\"), "Expected C:\\one\\two\\three\\, got %s\n", buffer
);
1393 r
= MsiSetTargetPathA( hpkg
, "TestParent", "C:\\\\one\\\\two " );
1394 ok( r
== ERROR_SUCCESS
, "MsiSetTargetPath returned %d\n", r
);
1397 sz
= sizeof buffer
- 1;
1398 r
= MsiGetTargetPathA( hpkg
, "TestParent", buffer
, &sz
);
1399 ok( r
== ERROR_SUCCESS
, "failed to get target path: %d\n", r
);
1400 ok( !lstrcmpiA(buffer
, "C:\\one\\two\\"), "Expected \"C:\\one\\two\\\", got %s\n", buffer
);
1402 r
= MsiSetTargetPathA( hpkg
, "TestParent", "C:\\\\ Program Files \\\\ " );
1403 ok( r
== ERROR_SUCCESS
, "MsiSetTargetPath returned %d\n", r
);
1406 sz
= sizeof buffer
- 1;
1407 r
= MsiGetTargetPathA( hpkg
, "TestParent", buffer
, &sz
);
1408 ok( r
== ERROR_SUCCESS
, "failed to get target path: %d\n", r
);
1409 ok( !lstrcmpiA(buffer
, "C:\\Program Files\\"), "Expected \"C:\\Program Files\\\", got %s\n", buffer
);
1411 MsiCloseHandle( hpkg
);
1414 static void test_condition(void)
1416 static const WCHAR cond1
[] = {'\"','a',0x30a,'\"','<','\"',0xe5,'\"',0};
1417 static const WCHAR cond2
[] = {'\"','a',0x30a,'\"','>','\"',0xe5,'\"',0};
1418 static const WCHAR cond3
[] = {'\"','a',0x30a,'\"','<','>','\"',0xe5,'\"',0};
1419 static const WCHAR cond4
[] = {'\"','a',0x30a,'\"','=','\"',0xe5,'\"',0};
1423 r
= package_from_db(create_package_db(), &hpkg
);
1424 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
1426 skip("Not enough rights to perform tests\n");
1427 DeleteFileA(msifile
);
1430 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
1432 r
= MsiEvaluateConditionA(0, NULL
);
1433 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
1435 r
= MsiEvaluateConditionA(hpkg
, NULL
);
1436 ok( r
== MSICONDITION_NONE
, "wrong return val\n");
1438 r
= MsiEvaluateConditionA(hpkg
, "");
1439 ok( r
== MSICONDITION_NONE
, "wrong return val\n");
1441 r
= MsiEvaluateConditionA(hpkg
, "1");
1442 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1444 r
= MsiEvaluateConditionA(hpkg
, "0");
1445 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1447 r
= MsiEvaluateConditionA(hpkg
, "-1");
1448 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1450 r
= MsiEvaluateConditionA(hpkg
, "0 = 0");
1451 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1453 r
= MsiEvaluateConditionA(hpkg
, "0 <> 0");
1454 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1456 r
= MsiEvaluateConditionA(hpkg
, "0 = 1");
1457 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1459 r
= MsiEvaluateConditionA(hpkg
, "0 > 1");
1460 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1462 r
= MsiEvaluateConditionA(hpkg
, "0 ~> 1");
1463 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1465 r
= MsiEvaluateConditionA(hpkg
, "1 > 1");
1466 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1468 r
= MsiEvaluateConditionA(hpkg
, "1 ~> 1");
1469 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1471 r
= MsiEvaluateConditionA(hpkg
, "0 >= 1");
1472 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1474 r
= MsiEvaluateConditionA(hpkg
, "0 ~>= 1");
1475 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1477 r
= MsiEvaluateConditionA(hpkg
, "1 >= 1");
1478 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1480 r
= MsiEvaluateConditionA(hpkg
, "1 ~>= 1");
1481 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1483 r
= MsiEvaluateConditionA(hpkg
, "0 < 1");
1484 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1486 r
= MsiEvaluateConditionA(hpkg
, "0 ~< 1");
1487 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1489 r
= MsiEvaluateConditionA(hpkg
, "1 < 1");
1490 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1492 r
= MsiEvaluateConditionA(hpkg
, "1 ~< 1");
1493 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1495 r
= MsiEvaluateConditionA(hpkg
, "0 <= 1");
1496 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1498 r
= MsiEvaluateConditionA(hpkg
, "0 ~<= 1");
1499 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1501 r
= MsiEvaluateConditionA(hpkg
, "1 <= 1");
1502 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1504 r
= MsiEvaluateConditionA(hpkg
, "1 ~<= 1");
1505 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1507 r
= MsiEvaluateConditionA(hpkg
, "0 >=");
1508 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
1510 r
= MsiEvaluateConditionA(hpkg
, " ");
1511 ok( r
== MSICONDITION_NONE
, "wrong return val\n");
1513 r
= MsiEvaluateConditionA(hpkg
, "LicView <> \"1\"");
1514 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1516 r
= MsiEvaluateConditionA(hpkg
, "LicView <> \"0\"");
1517 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1519 r
= MsiEvaluateConditionA(hpkg
, "LicView <> LicView");
1520 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1522 r
= MsiEvaluateConditionA(hpkg
, "not 0");
1523 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1525 r
= MsiEvaluateConditionA(hpkg
, "not LicView");
1526 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1528 r
= MsiEvaluateConditionA(hpkg
, "\"Testing\" ~<< \"Testing\"");
1529 ok (r
== MSICONDITION_TRUE
, "wrong return val\n");
1531 r
= MsiEvaluateConditionA(hpkg
, "LicView ~<< \"Testing\"");
1532 ok (r
== MSICONDITION_FALSE
, "wrong return val\n");
1534 r
= MsiEvaluateConditionA(hpkg
, "Not LicView ~<< \"Testing\"");
1535 ok (r
== MSICONDITION_TRUE
, "wrong return val\n");
1537 r
= MsiEvaluateConditionA(hpkg
, "not \"A\"");
1538 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1540 r
= MsiEvaluateConditionA(hpkg
, "~not \"A\"");
1541 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
1543 r
= MsiEvaluateConditionA(hpkg
, "\"0\"");
1544 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1546 r
= MsiEvaluateConditionA(hpkg
, "1 and 2");
1547 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1549 r
= MsiEvaluateConditionA(hpkg
, "not 0 and 3");
1550 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1552 r
= MsiEvaluateConditionA(hpkg
, "not 0 and 0");
1553 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1555 r
= MsiEvaluateConditionA(hpkg
, "not 0 or 1");
1556 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1558 r
= MsiEvaluateConditionA(hpkg
, "(0)");
1559 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1561 r
= MsiEvaluateConditionA(hpkg
, "(((((1))))))");
1562 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
1564 r
= MsiEvaluateConditionA(hpkg
, "(((((1)))))");
1565 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1567 r
= MsiEvaluateConditionA(hpkg
, " \"A\" < \"B\" ");
1568 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1570 r
= MsiEvaluateConditionA(hpkg
, " \"A\" > \"B\" ");
1571 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1573 r
= MsiEvaluateConditionA(hpkg
, " \"1\" > \"12\" ");
1574 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1576 r
= MsiEvaluateConditionA(hpkg
, " \"100\" < \"21\" ");
1577 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1579 r
= MsiEvaluateConditionA(hpkg
, "0 < > 0");
1580 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
1582 r
= MsiEvaluateConditionA(hpkg
, "(1<<1) == 2");
1583 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
1585 r
= MsiEvaluateConditionA(hpkg
, " \"A\" = \"a\" ");
1586 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1588 r
= MsiEvaluateConditionA(hpkg
, " \"A\" ~ = \"a\" ");
1589 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
1591 r
= MsiEvaluateConditionA(hpkg
, " \"A\" ~= \"a\" ");
1592 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1594 r
= MsiEvaluateConditionA(hpkg
, " \"A\" ~= 1 ");
1595 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1597 r
= MsiEvaluateConditionA(hpkg
, " \"A\" = 1 ");
1598 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1600 r
= MsiEvaluateConditionA(hpkg
, " 1 ~= 1 ");
1601 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1603 r
= MsiEvaluateConditionA(hpkg
, " 1 ~= \"1\" ");
1604 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1606 r
= MsiEvaluateConditionA(hpkg
, " 1 = \"1\" ");
1607 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1609 r
= MsiEvaluateConditionA(hpkg
, " 0 = \"1\" ");
1610 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1612 r
= MsiEvaluateConditionA(hpkg
, " 0 < \"100\" ");
1613 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1615 r
= MsiEvaluateConditionA(hpkg
, " 100 > \"0\" ");
1616 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1618 r
= MsiEvaluateConditionA(hpkg
, "1 XOR 1");
1619 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1621 r
= MsiEvaluateConditionA(hpkg
, "1 IMP 1");
1622 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1624 r
= MsiEvaluateConditionA(hpkg
, "1 IMP 0");
1625 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1627 r
= MsiEvaluateConditionA(hpkg
, "0 IMP 0");
1628 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1630 r
= MsiEvaluateConditionA(hpkg
, "0 EQV 0");
1631 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1633 r
= MsiEvaluateConditionA(hpkg
, "0 EQV 1");
1634 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1636 r
= MsiEvaluateConditionA(hpkg
, "1 IMP 1 OR 0");
1637 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1639 r
= MsiEvaluateConditionA(hpkg
, "1 IMPL 1");
1640 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
1642 r
= MsiEvaluateConditionA(hpkg
, "\"ASFD\" >< \"S\" ");
1643 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1645 r
= MsiEvaluateConditionA(hpkg
, "\"ASFD\" ~>< \"s\" ");
1646 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1648 r
= MsiEvaluateConditionA(hpkg
, "\"ASFD\" ~>< \"\" ");
1649 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1651 r
= MsiEvaluateConditionA(hpkg
, "\"ASFD\" ~>< \"sss\" ");
1652 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1654 MsiSetPropertyA(hpkg
, "mm", "5" );
1656 r
= MsiEvaluateConditionA(hpkg
, "mm = 5");
1657 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1659 r
= MsiEvaluateConditionA(hpkg
, "mm < 6");
1660 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1662 r
= MsiEvaluateConditionA(hpkg
, "mm <= 5");
1663 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1665 r
= MsiEvaluateConditionA(hpkg
, "mm > 4");
1666 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1668 r
= MsiEvaluateConditionA(hpkg
, "mm < 12");
1669 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1671 r
= MsiEvaluateConditionA(hpkg
, "mm = \"5\"");
1672 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1674 r
= MsiEvaluateConditionA(hpkg
, "0 = \"\"");
1675 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1677 r
= MsiEvaluateConditionA(hpkg
, "0 AND \"\"");
1678 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1680 r
= MsiEvaluateConditionA(hpkg
, "1 AND \"\"");
1681 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1683 r
= MsiEvaluateConditionA(hpkg
, "1 AND \"1\"");
1684 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1686 r
= MsiEvaluateConditionA(hpkg
, "3 >< 1");
1687 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1689 r
= MsiEvaluateConditionA(hpkg
, "3 >< 4");
1690 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1692 r
= MsiEvaluateConditionA(hpkg
, "NOT 0 AND 0");
1693 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1695 r
= MsiEvaluateConditionA(hpkg
, "NOT 0 AND 1");
1696 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1698 r
= MsiEvaluateConditionA(hpkg
, "NOT 1 OR 0");
1699 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1701 r
= MsiEvaluateConditionA(hpkg
, "0 AND 1 OR 1");
1702 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1704 r
= MsiEvaluateConditionA(hpkg
, "0 AND 0 OR 1");
1705 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1707 r
= MsiEvaluateConditionA(hpkg
, "NOT 0 AND 1 OR 0");
1708 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1710 r
= MsiEvaluateConditionA(hpkg
, "_1 = _1");
1711 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1713 r
= MsiEvaluateConditionA(hpkg
, "( 1 AND 1 ) = 2");
1714 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
1716 r
= MsiEvaluateConditionA(hpkg
, "NOT ( 1 AND 1 )");
1717 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1719 r
= MsiEvaluateConditionA(hpkg
, "NOT A AND (BBBBBBBBBB=2 OR CCC=1) AND Ddddddddd");
1720 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1722 r
= MsiEvaluateConditionA(hpkg
, "Installed<>\"\"");
1723 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1725 r
= MsiEvaluateConditionA(hpkg
, "NOT 1 AND 0");
1726 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1728 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1729 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1731 r
= MsiEvaluateConditionA(hpkg
, "bandalmael<>0");
1732 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1734 r
= MsiEvaluateConditionA(hpkg
, "bandalmael<0");
1735 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1737 r
= MsiEvaluateConditionA(hpkg
, "bandalmael>0");
1738 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1740 r
= MsiEvaluateConditionA(hpkg
, "bandalmael>=0");
1741 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1743 r
= MsiEvaluateConditionA(hpkg
, "bandalmael<=0");
1744 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1746 r
= MsiEvaluateConditionA(hpkg
, "bandalmael~<>0");
1747 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1749 MsiSetPropertyA(hpkg
, "bandalmael", "0" );
1750 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1751 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1753 MsiSetPropertyA(hpkg
, "bandalmael", "" );
1754 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1755 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1757 MsiSetPropertyA(hpkg
, "bandalmael", "asdf" );
1758 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1759 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1761 MsiSetPropertyA(hpkg
, "bandalmael", "0asdf" );
1762 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1763 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1765 MsiSetPropertyA(hpkg
, "bandalmael", "0 " );
1766 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1767 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1769 MsiSetPropertyA(hpkg
, "bandalmael", "-0" );
1770 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1771 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1773 MsiSetPropertyA(hpkg
, "bandalmael", "0000000000000" );
1774 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1775 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1777 MsiSetPropertyA(hpkg
, "bandalmael", "--0" );
1778 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1779 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1781 MsiSetPropertyA(hpkg
, "bandalmael", "0x00" );
1782 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1783 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1785 MsiSetPropertyA(hpkg
, "bandalmael", "-" );
1786 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1787 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1789 MsiSetPropertyA(hpkg
, "bandalmael", "+0" );
1790 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1791 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1793 MsiSetPropertyA(hpkg
, "bandalmael", "0.0" );
1794 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1795 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1796 r
= MsiEvaluateConditionA(hpkg
, "bandalmael<>0");
1797 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1799 MsiSetPropertyA(hpkg
, "one", "hi");
1800 MsiSetPropertyA(hpkg
, "two", "hithere");
1801 r
= MsiEvaluateConditionA(hpkg
, "one >< two");
1802 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1804 MsiSetPropertyA(hpkg
, "one", "hithere");
1805 MsiSetPropertyA(hpkg
, "two", "hi");
1806 r
= MsiEvaluateConditionA(hpkg
, "one >< two");
1807 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1809 MsiSetPropertyA(hpkg
, "one", "hello");
1810 MsiSetPropertyA(hpkg
, "two", "hi");
1811 r
= MsiEvaluateConditionA(hpkg
, "one >< two");
1812 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1814 MsiSetPropertyA(hpkg
, "one", "hellohithere");
1815 MsiSetPropertyA(hpkg
, "two", "hi");
1816 r
= MsiEvaluateConditionA(hpkg
, "one >< two");
1817 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1819 MsiSetPropertyA(hpkg
, "one", "");
1820 MsiSetPropertyA(hpkg
, "two", "hi");
1821 r
= MsiEvaluateConditionA(hpkg
, "one >< two");
1822 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1824 MsiSetPropertyA(hpkg
, "one", "hi");
1825 MsiSetPropertyA(hpkg
, "two", "");
1826 r
= MsiEvaluateConditionA(hpkg
, "one >< two");
1827 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1829 MsiSetPropertyA(hpkg
, "one", "");
1830 MsiSetPropertyA(hpkg
, "two", "");
1831 r
= MsiEvaluateConditionA(hpkg
, "one >< two");
1832 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1834 MsiSetPropertyA(hpkg
, "one", "1234");
1835 MsiSetPropertyA(hpkg
, "two", "1");
1836 r
= MsiEvaluateConditionA(hpkg
, "one >< two");
1837 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1839 MsiSetPropertyA(hpkg
, "one", "one 1234");
1840 MsiSetPropertyA(hpkg
, "two", "1");
1841 r
= MsiEvaluateConditionA(hpkg
, "one >< two");
1842 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1844 MsiSetPropertyA(hpkg
, "one", "hithere");
1845 MsiSetPropertyA(hpkg
, "two", "hi");
1846 r
= MsiEvaluateConditionA(hpkg
, "one << two");
1847 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1849 MsiSetPropertyA(hpkg
, "one", "hi");
1850 MsiSetPropertyA(hpkg
, "two", "hithere");
1851 r
= MsiEvaluateConditionA(hpkg
, "one << two");
1852 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1854 MsiSetPropertyA(hpkg
, "one", "hi");
1855 MsiSetPropertyA(hpkg
, "two", "hi");
1856 r
= MsiEvaluateConditionA(hpkg
, "one << two");
1857 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1859 MsiSetPropertyA(hpkg
, "one", "abcdhithere");
1860 MsiSetPropertyA(hpkg
, "two", "hi");
1861 r
= MsiEvaluateConditionA(hpkg
, "one << two");
1862 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1864 MsiSetPropertyA(hpkg
, "one", "");
1865 MsiSetPropertyA(hpkg
, "two", "hi");
1866 r
= MsiEvaluateConditionA(hpkg
, "one << two");
1867 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1869 MsiSetPropertyA(hpkg
, "one", "hithere");
1870 MsiSetPropertyA(hpkg
, "two", "");
1871 r
= MsiEvaluateConditionA(hpkg
, "one << two");
1872 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1874 MsiSetPropertyA(hpkg
, "one", "");
1875 MsiSetPropertyA(hpkg
, "two", "");
1876 r
= MsiEvaluateConditionA(hpkg
, "one << two");
1877 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1879 MsiSetPropertyA(hpkg
, "one", "1234");
1880 MsiSetPropertyA(hpkg
, "two", "1");
1881 r
= MsiEvaluateConditionA(hpkg
, "one << two");
1882 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1884 MsiSetPropertyA(hpkg
, "one", "1234 one");
1885 MsiSetPropertyA(hpkg
, "two", "1");
1886 r
= MsiEvaluateConditionA(hpkg
, "one << two");
1887 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1889 MsiSetPropertyA(hpkg
, "one", "hithere");
1890 MsiSetPropertyA(hpkg
, "two", "there");
1891 r
= MsiEvaluateConditionA(hpkg
, "one >> two");
1892 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1894 MsiSetPropertyA(hpkg
, "one", "hithere");
1895 MsiSetPropertyA(hpkg
, "two", "hi");
1896 r
= MsiEvaluateConditionA(hpkg
, "one >> two");
1897 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1899 MsiSetPropertyA(hpkg
, "one", "there");
1900 MsiSetPropertyA(hpkg
, "two", "hithere");
1901 r
= MsiEvaluateConditionA(hpkg
, "one >> two");
1902 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1904 MsiSetPropertyA(hpkg
, "one", "there");
1905 MsiSetPropertyA(hpkg
, "two", "there");
1906 r
= MsiEvaluateConditionA(hpkg
, "one >> two");
1907 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1909 MsiSetPropertyA(hpkg
, "one", "abcdhithere");
1910 MsiSetPropertyA(hpkg
, "two", "hi");
1911 r
= MsiEvaluateConditionA(hpkg
, "one >> two");
1912 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1914 MsiSetPropertyA(hpkg
, "one", "");
1915 MsiSetPropertyA(hpkg
, "two", "there");
1916 r
= MsiEvaluateConditionA(hpkg
, "one >> two");
1917 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1919 MsiSetPropertyA(hpkg
, "one", "there");
1920 MsiSetPropertyA(hpkg
, "two", "");
1921 r
= MsiEvaluateConditionA(hpkg
, "one >> two");
1922 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1924 MsiSetPropertyA(hpkg
, "one", "");
1925 MsiSetPropertyA(hpkg
, "two", "");
1926 r
= MsiEvaluateConditionA(hpkg
, "one >> two");
1927 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1929 MsiSetPropertyA(hpkg
, "one", "1234");
1930 MsiSetPropertyA(hpkg
, "two", "4");
1931 r
= MsiEvaluateConditionA(hpkg
, "one >> two");
1932 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1934 MsiSetPropertyA(hpkg
, "one", "one 1234");
1935 MsiSetPropertyA(hpkg
, "two", "4");
1936 r
= MsiEvaluateConditionA(hpkg
, "one >> two");
1937 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1939 MsiSetPropertyA(hpkg
, "MsiNetAssemblySupport", NULL
); /* make sure it's empty */
1941 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1.1.4322\"");
1942 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1944 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport > \"1.1.4322\"");
1945 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1947 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport >= \"1.1.4322\"");
1948 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1950 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport <= \"1.1.4322\"");
1951 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1953 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport <> \"1.1.4322\"");
1954 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1956 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport ~< \"1.1.4322\"");
1957 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1959 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"abcd\"");
1960 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1962 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"a1.1.4322\"");
1963 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1965 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1.1.4322a\"");
1966 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1968 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"0000001.1.4322\"");
1969 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1971 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1.1.4322.1\"");
1972 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1974 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1.1.4322.1.1\"");
1975 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1977 r
= MsiEvaluateConditionA(hpkg
, "\"2\" < \"1.1");
1978 ok( r
== MSICONDITION_ERROR
, "wrong return val (%d)\n", r
);
1980 r
= MsiEvaluateConditionA(hpkg
, "\"2\" < \"1.1\"");
1981 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1983 r
= MsiEvaluateConditionA(hpkg
, "\"2\" < \"12.1\"");
1984 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1986 r
= MsiEvaluateConditionA(hpkg
, "\"02.1\" < \"2.11\"");
1987 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1989 r
= MsiEvaluateConditionA(hpkg
, "\"02.1.1\" < \"2.1\"");
1990 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1992 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1.1\"");
1993 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1995 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1\"");
1996 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1998 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"0\"");
1999 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2001 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"-1\"");
2002 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2004 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"a\"");
2005 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2007 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"!\"");
2008 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2010 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"!\"");
2011 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2013 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"/\"");
2014 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2016 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \" \"");
2017 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2019 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"azAZ_\"");
2020 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2022 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"a[a]\"");
2023 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2025 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"a[a]a\"");
2026 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2028 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"[a]\"");
2029 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2031 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"[a]a\"");
2032 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2034 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"{a}\"");
2035 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2037 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"{a\"");
2038 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2040 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"[a\"");
2041 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2043 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"a{\"");
2044 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2046 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"a]\"");
2047 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2049 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"A\"");
2050 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2052 MsiSetPropertyA(hpkg
, "MsiNetAssemblySupport", "1.1.4322");
2053 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1.1.4322\"");
2054 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
2056 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1.1.14322\"");
2057 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
2059 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1.1.5\"");
2060 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2062 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1.1\"");
2063 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
2065 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1\"");
2066 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
2068 MsiSetPropertyA(hpkg
, "one", "1");
2069 r
= MsiEvaluateConditionA(hpkg
, "one < \"1\"");
2070 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
2072 MsiSetPropertyA(hpkg
, "X", "5.0");
2074 r
= MsiEvaluateConditionA(hpkg
, "X != \"\"");
2075 ok( r
== MSICONDITION_ERROR
, "wrong return val (%d)\n", r
);
2077 r
= MsiEvaluateConditionA(hpkg
, "X =\"5.0\"");
2078 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2080 r
= MsiEvaluateConditionA(hpkg
, "X =\"5.1\"");
2081 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
2083 r
= MsiEvaluateConditionA(hpkg
, "X =\"6.0\"");
2084 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
2086 r
= MsiEvaluateConditionA(hpkg
, "X =\"5.0\" or X =\"5.1\" or X =\"6.0\"");
2087 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2089 r
= MsiEvaluateConditionA(hpkg
, "(X =\"5.0\" or X =\"5.1\" or X =\"6.0\")");
2090 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2092 r
= MsiEvaluateConditionA(hpkg
, "X !=\"\" and (X =\"5.0\" or X =\"5.1\" or X =\"6.0\")");
2093 ok( r
== MSICONDITION_ERROR
, "wrong return val (%d)\n", r
);
2095 /* feature doesn't exist */
2096 r
= MsiEvaluateConditionA(hpkg
, "&nofeature");
2097 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
2098 r
= MsiEvaluateConditionA(hpkg
, "&nofeature=\"\"");
2099 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2100 r
= MsiEvaluateConditionA(hpkg
, "!nofeature=\"\"");
2101 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2102 MsiEvaluateConditionA(hpkg
, "$nocomponent=\"\"");
2103 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2104 MsiEvaluateConditionA(hpkg
, "?nocomponent=\"\"");
2105 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2107 MsiSetPropertyA(hpkg
, "A", "2");
2108 MsiSetPropertyA(hpkg
, "X", "50");
2110 r
= MsiEvaluateConditionA(hpkg
, "2 <= X");
2111 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2113 r
= MsiEvaluateConditionA(hpkg
, "A <= X");
2114 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2116 r
= MsiEvaluateConditionA(hpkg
, "A <= 50");
2117 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2119 MsiSetPropertyA(hpkg
, "X", "50val");
2121 r
= MsiEvaluateConditionA(hpkg
, "2 <= X");
2122 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
2124 r
= MsiEvaluateConditionA(hpkg
, "A <= X");
2125 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2127 MsiSetPropertyA(hpkg
, "A", "7");
2128 MsiSetPropertyA(hpkg
, "X", "50");
2130 r
= MsiEvaluateConditionA(hpkg
, "7 <= X");
2131 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2133 r
= MsiEvaluateConditionA(hpkg
, "A <= X");
2134 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2136 r
= MsiEvaluateConditionA(hpkg
, "A <= 50");
2137 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2139 MsiSetPropertyA(hpkg
, "X", "50val");
2141 r
= MsiEvaluateConditionA(hpkg
, "2 <= X");
2142 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
2144 r
= MsiEvaluateConditionA(hpkg
, "A <= X");
2145 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
2147 r
= MsiEvaluateConditionW(hpkg
, cond1
);
2148 ok( r
== MSICONDITION_TRUE
|| broken(r
== MSICONDITION_FALSE
),
2149 "wrong return val (%d)\n", r
);
2151 r
= MsiEvaluateConditionW(hpkg
, cond2
);
2152 ok( r
== MSICONDITION_FALSE
|| broken(r
== MSICONDITION_TRUE
),
2153 "wrong return val (%d)\n", r
);
2155 r
= MsiEvaluateConditionW(hpkg
, cond3
);
2156 ok( r
== MSICONDITION_TRUE
|| broken(r
== MSICONDITION_FALSE
),
2157 "wrong return val (%d)\n", r
);
2159 r
= MsiEvaluateConditionW(hpkg
, cond4
);
2160 ok( r
== MSICONDITION_FALSE
|| broken(r
== MSICONDITION_TRUE
),
2161 "wrong return val (%d)\n", r
);
2163 MsiCloseHandle( hpkg
);
2164 DeleteFileA(msifile
);
2167 static void check_prop(MSIHANDLE hpkg
, const char *prop
, const char *expect
)
2169 char buffer
[MAX_PATH
] = "x";
2170 DWORD sz
= sizeof(buffer
);
2171 UINT r
= MsiGetPropertyA(hpkg
, prop
, buffer
, &sz
);
2172 ok(!r
, "'%s': got %u\n", prop
, r
);
2173 ok(sz
== lstrlenA(buffer
), "'%s': expected %u, got %u\n", prop
, lstrlenA(buffer
), sz
);
2174 ok(!strcmp(buffer
, expect
), "'%s': expected '%s', got '%s'\n", prop
, expect
, buffer
);
2177 static void test_props(void)
2179 static const WCHAR booW
[] = {'b','o','o',0};
2180 static const WCHAR xyzW
[] = {'x','y','z',0};
2181 static const WCHAR xyW
[] = {'x','y',0};
2182 MSIHANDLE hpkg
, hdb
;
2188 hdb
= create_package_db();
2190 create_property_table(hdb
);
2191 add_property_entry(hdb
, "'MetadataCompName', 'Photoshop.dll'");
2193 r
= package_from_db( hdb
, &hpkg
);
2194 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
2196 skip("Not enough rights to perform tests\n");
2197 DeleteFileA(msifile
);
2200 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
2202 /* test invalid values */
2203 r
= MsiGetPropertyA( 0, NULL
, NULL
, NULL
);
2204 ok(r
== ERROR_INVALID_PARAMETER
, "got %u\n", r
);
2206 r
= MsiGetPropertyA( hpkg
, NULL
, NULL
, NULL
);
2207 ok(r
== ERROR_INVALID_PARAMETER
, "got %u\n", r
);
2209 r
= MsiGetPropertyA( hpkg
, "boo", NULL
, NULL
);
2210 ok(!r
, "got %u\n", r
);
2212 r
= MsiGetPropertyA( hpkg
, "boo", buffer
, NULL
);
2213 ok(r
== ERROR_INVALID_PARAMETER
, "got %u\n", r
);
2215 /* test retrieving an empty/nonexistent property */
2217 r
= MsiGetPropertyA( hpkg
, "boo", NULL
, &sz
);
2218 ok(!r
, "got %u\n", r
);
2219 ok(sz
== 0, "got size %d\n", sz
);
2223 r
= MsiGetPropertyA( hpkg
, "boo", buffer
, &sz
);
2224 ok(r
== ERROR_MORE_DATA
, "got %u\n", r
);
2225 ok(!strcmp(buffer
,"x"), "got \"%s\"\n", buffer
);
2226 ok(sz
== 0, "got size %u\n", sz
);
2230 r
= MsiGetPropertyA( hpkg
, "boo", buffer
, &sz
);
2231 ok(!r
, "got %u\n", r
);
2232 ok(!buffer
[0], "got \"%s\"\n", buffer
);
2233 ok(sz
== 0, "got size %u\n", sz
);
2235 /* set the property to something */
2236 r
= MsiSetPropertyA( 0, NULL
, NULL
);
2237 ok(r
== ERROR_INVALID_HANDLE
, "got %u\n", r
);
2239 r
= MsiSetPropertyA( hpkg
, NULL
, NULL
);
2240 ok(r
== ERROR_INVALID_PARAMETER
, "got %u\n", r
);
2242 r
= MsiSetPropertyA( hpkg
, "", NULL
);
2243 ok(!r
, "got %u\n", r
);
2245 r
= MsiSetPropertyA( hpkg
, "", "asdf" );
2246 ok(r
== ERROR_FUNCTION_FAILED
, "got %u\n", r
);
2248 r
= MsiSetPropertyA( hpkg
, "=", "asdf" );
2249 ok(!r
, "got %u\n", r
);
2250 check_prop(hpkg
, "=", "asdf");
2252 r
= MsiSetPropertyA( hpkg
, " ", "asdf" );
2253 ok(!r
, "got %u\n", r
);
2254 check_prop(hpkg
, " ", "asdf");
2256 r
= MsiSetPropertyA( hpkg
, "'", "asdf" );
2257 ok(!r
, "got %u\n", r
);
2258 check_prop(hpkg
, "'", "asdf");
2260 /* set empty values */
2261 r
= MsiSetPropertyA( hpkg
, "boo", NULL
);
2262 ok(!r
, "got %u\n", r
);
2263 check_prop(hpkg
, "boo", "");
2265 r
= MsiSetPropertyA( hpkg
, "boo", "" );
2266 ok(!r
, "got %u\n", r
);
2267 check_prop(hpkg
, "boo", "");
2269 /* set a non-empty value */
2270 r
= MsiSetPropertyA( hpkg
, "boo", "xyz" );
2271 ok(!r
, "got %u\n", r
);
2272 check_prop(hpkg
, "boo", "xyz");
2274 r
= MsiGetPropertyA(hpkg
, "boo", NULL
, NULL
);
2275 ok(!r
, "got %u\n", r
);
2277 r
= MsiGetPropertyA(hpkg
, "boo", buffer
, NULL
);
2278 ok(r
== ERROR_INVALID_PARAMETER
, "got %u\n", r
);
2281 r
= MsiGetPropertyA(hpkg
, "boo", NULL
, &sz
);
2282 ok(!r
, "got %u\n", r
);
2283 ok(sz
== 3, "got size %u\n", sz
);
2286 strcpy(buffer
, "q");
2287 r
= MsiGetPropertyA(hpkg
, "boo", buffer
, &sz
);
2288 ok(r
== ERROR_MORE_DATA
, "got %u\n", r
);
2289 ok(!strcmp(buffer
, "q"), "got \"%s\"", buffer
);
2290 ok(sz
== 3, "got size %u\n", sz
);
2294 r
= MsiGetPropertyA( hpkg
, "boo", buffer
, &sz
);
2295 ok(r
== ERROR_MORE_DATA
, "got %u\n", r
);
2296 ok(!buffer
[0], "got \"%s\"\n", buffer
);
2297 ok(sz
== 3, "got size %u\n", sz
);
2301 r
= MsiGetPropertyA( hpkg
, "boo", buffer
, &sz
);
2302 ok(r
== ERROR_MORE_DATA
, "got %u\n", r
);
2303 ok(!strcmp(buffer
,"xy"), "got \"%s\"\n", buffer
);
2304 ok(sz
== 3, "got size %u\n", sz
);
2308 r
= MsiGetPropertyA( hpkg
, "boo", buffer
, &sz
);
2309 ok(!r
, "got %u\n", r
);
2310 ok(!strcmp(buffer
,"xyz"), "got \"%s\"\n", buffer
);
2311 ok(sz
== 3, "got size %u\n", sz
);
2314 r
= MsiGetPropertyW(hpkg
, booW
, NULL
, &sz
);
2315 ok(!r
, "got %u\n", r
);
2316 ok(sz
== 3, "got size %u\n", sz
);
2319 lstrcpyW(bufferW
, booW
);
2320 r
= MsiGetPropertyW(hpkg
, booW
, bufferW
, &sz
);
2321 ok(r
== ERROR_MORE_DATA
, "got %u\n", r
);
2322 ok(!lstrcmpW(bufferW
, booW
), "got %s\n", wine_dbgstr_w(bufferW
));
2323 ok(sz
== 3, "got size %u\n", sz
);
2326 lstrcpyW(bufferW
, booW
);
2327 r
= MsiGetPropertyW(hpkg
, booW
, bufferW
, &sz
);
2328 ok(r
== ERROR_MORE_DATA
, "got %u\n", r
);
2329 ok(!bufferW
[0], "got %s\n", wine_dbgstr_w(bufferW
));
2330 ok(sz
== 3, "got size %u\n", sz
);
2333 lstrcpyW(bufferW
, booW
);
2334 r
= MsiGetPropertyW(hpkg
, booW
, bufferW
, &sz
);
2335 ok(r
== ERROR_MORE_DATA
, "got %u\n", r
);
2336 ok(!lstrcmpW(bufferW
, xyW
), "got %s\n", wine_dbgstr_w(bufferW
));
2337 ok(sz
== 3, "got size %u\n", sz
);
2340 lstrcpyW(bufferW
, booW
);
2341 r
= MsiGetPropertyW(hpkg
, booW
, bufferW
, &sz
);
2342 ok(!r
, "got %u\n", r
);
2343 ok(!lstrcmpW(bufferW
, xyzW
), "got %s\n", wine_dbgstr_w(bufferW
));
2344 ok(sz
== 3, "got size %u\n", sz
);
2346 /* properties are case-sensitive */
2347 check_prop(hpkg
, "BOO", "");
2349 /* properties set in Property table should work */
2350 check_prop(hpkg
, "MetadataCompName", "Photoshop.dll");
2352 MsiCloseHandle( hpkg
);
2353 DeleteFileA(msifile
);
2356 static BOOL
find_prop_in_property(MSIHANDLE hdb
, LPCSTR prop
, LPCSTR val
, int len
)
2358 MSIHANDLE hview
, hrec
;
2360 CHAR buffer
[MAX_PATH
];
2364 r
= MsiDatabaseOpenViewA(hdb
, "SELECT * FROM `_Property`", &hview
);
2365 ok(r
== ERROR_SUCCESS
, "MsiDatabaseOpenView failed\n");
2366 r
= MsiViewExecute(hview
, 0);
2367 ok(r
== ERROR_SUCCESS
, "MsiViewExecute failed\n");
2369 if (len
< 0) len
= lstrlenA(val
);
2371 while (r
== ERROR_SUCCESS
&& !found
)
2373 r
= MsiViewFetch(hview
, &hrec
);
2374 if (r
!= ERROR_SUCCESS
) break;
2377 r
= MsiRecordGetStringA(hrec
, 1, buffer
, &sz
);
2378 if (r
== ERROR_SUCCESS
&& !lstrcmpA(buffer
, prop
))
2381 r
= MsiRecordGetStringA(hrec
, 2, buffer
, &sz
);
2382 if (r
== ERROR_SUCCESS
&& !memcmp(buffer
, val
, len
) && !buffer
[len
])
2384 ok(sz
== len
, "wrong size %u\n", sz
);
2389 MsiCloseHandle(hrec
);
2391 MsiViewClose(hview
);
2392 MsiCloseHandle(hview
);
2396 static void test_property_table(void)
2400 MSIHANDLE hpkg
, hdb
, hrec
;
2401 char buffer
[MAX_PATH
], package
[10];
2405 hdb
= create_package_db();
2406 ok( hdb
, "failed to create package\n");
2408 r
= package_from_db(hdb
, &hpkg
);
2409 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
2411 skip("Not enough rights to perform tests\n");
2412 DeleteFileA(msifile
);
2415 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
2417 MsiCloseHandle(hdb
);
2419 hdb
= MsiGetActiveDatabase(hpkg
);
2421 query
= "CREATE TABLE `_Property` ( "
2422 "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
2423 r
= run_query(hdb
, query
);
2424 ok(r
== ERROR_BAD_QUERY_SYNTAX
, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r
);
2426 MsiCloseHandle(hdb
);
2427 MsiCloseHandle(hpkg
);
2428 DeleteFileA(msifile
);
2430 hdb
= create_package_db();
2431 ok( hdb
, "failed to create package\n");
2433 query
= "CREATE TABLE `_Property` ( "
2434 "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
2435 r
= run_query(hdb
, query
);
2436 ok(r
== ERROR_SUCCESS
, "failed to create table\n");
2438 query
= "ALTER `_Property` ADD `foo` INTEGER";
2439 r
= run_query(hdb
, query
);
2440 ok(r
== ERROR_BAD_QUERY_SYNTAX
, "failed to add column\n");
2442 query
= "ALTER TABLE `_Property` ADD `foo` INTEGER";
2443 r
= run_query(hdb
, query
);
2444 ok(r
== ERROR_BAD_QUERY_SYNTAX
, "failed to add column\n");
2446 query
= "ALTER TABLE `_Property` ADD `extra` INTEGER";
2447 r
= run_query(hdb
, query
);
2448 ok(r
== ERROR_SUCCESS
, "failed to add column\n");
2450 sprintf(package
, "#%i", hdb
);
2451 r
= MsiOpenPackageA(package
, &hpkg
);
2452 ok(r
!= ERROR_SUCCESS
, "MsiOpenPackage succeeded\n");
2453 if (r
== ERROR_SUCCESS
)
2454 MsiCloseHandle(hpkg
);
2456 r
= MsiCloseHandle(hdb
);
2457 ok(r
== ERROR_SUCCESS
, "MsiCloseHandle failed %u\n", r
);
2459 hdb
= create_package_db();
2460 ok (hdb
, "failed to create package database\n");
2462 create_property_table(hdb
);
2463 add_property_entry(hdb
, "'prop', 'val'");
2465 create_custom_action_table(hdb
);
2466 add_custom_action_entry( hdb
, "'EmbedNull', 51, 'prop2', '[~]np'" );
2468 r
= package_from_db(hdb
, &hpkg
);
2469 ok(r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
2471 MsiCloseHandle(hdb
);
2474 r
= MsiGetPropertyA(hpkg
, "prop", buffer
, &sz
);
2475 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2476 ok(!lstrcmpA(buffer
, "val"), "Expected val, got %s\n", buffer
);
2478 hdb
= MsiGetActiveDatabase(hpkg
);
2480 found
= find_prop_in_property(hdb
, "prop", "val", -1);
2481 ok(found
, "prop should be in the _Property table\n");
2483 add_property_entry(hdb
, "'dantes', 'mercedes'");
2485 query
= "SELECT * FROM `_Property` WHERE `Property` = 'dantes'";
2486 r
= do_query(hdb
, query
, &hrec
);
2487 ok(r
== ERROR_BAD_QUERY_SYNTAX
, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r
);
2489 found
= find_prop_in_property(hdb
, "dantes", "mercedes", -1);
2490 ok(found
== FALSE
, "dantes should not be in the _Property table\n");
2493 lstrcpyA(buffer
, "aaa");
2494 r
= MsiGetPropertyA(hpkg
, "dantes", buffer
, &sz
);
2495 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2496 ok(!buffer
[0], "Expected empty string, got %s\n", buffer
);
2498 r
= MsiSetPropertyA(hpkg
, "dantes", "mercedes");
2499 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2501 found
= find_prop_in_property(hdb
, "dantes", "mercedes", -1);
2502 ok(found
== TRUE
, "dantes should be in the _Property table\n");
2504 r
= MsiDoActionA( hpkg
, "EmbedNull" );
2505 ok( r
== ERROR_SUCCESS
, "EmbedNull failed: %d\n", r
);
2508 memset( buffer
, 'a', sizeof(buffer
) );
2509 r
= MsiGetPropertyA( hpkg
, "prop2", buffer
, &sz
);
2510 ok( r
== ERROR_SUCCESS
, "get property failed: %d\n", r
);
2511 ok( !memcmp( buffer
, "\0np", sizeof("\0np") ), "wrong value\n");
2512 ok( sz
== sizeof("\0np") - 1, "got %u\n", sz
);
2514 found
= find_prop_in_property(hdb
, "prop2", "\0np", 3);
2515 ok(found
== TRUE
, "prop2 should be in the _Property table\n");
2517 MsiCloseHandle(hdb
);
2518 MsiCloseHandle(hpkg
);
2519 DeleteFileA(msifile
);
2522 static UINT
try_query_param( MSIHANDLE hdb
, LPCSTR szQuery
, MSIHANDLE hrec
)
2527 res
= MsiDatabaseOpenViewA( hdb
, szQuery
, &htab
);
2528 if( res
== ERROR_SUCCESS
)
2532 r
= MsiViewExecute( htab
, hrec
);
2533 if( r
!= ERROR_SUCCESS
)
2536 fprintf(stderr
,"MsiViewExecute failed %08x\n", res
);
2539 r
= MsiViewClose( htab
);
2540 if( r
!= ERROR_SUCCESS
)
2543 r
= MsiCloseHandle( htab
);
2544 if( r
!= ERROR_SUCCESS
)
2550 static UINT
try_query( MSIHANDLE hdb
, LPCSTR szQuery
)
2552 return try_query_param( hdb
, szQuery
, 0 );
2555 static void set_summary_str(MSIHANDLE hdb
, DWORD pid
, LPCSTR value
)
2560 r
= MsiGetSummaryInformationA(hdb
, NULL
, 1, &summary
);
2561 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2563 r
= MsiSummaryInfoSetPropertyA(summary
, pid
, VT_LPSTR
, 0, NULL
, value
);
2564 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
2566 r
= MsiSummaryInfoPersist(summary
);
2567 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
2569 MsiCloseHandle(summary
);
2572 static void set_summary_dword(MSIHANDLE hdb
, DWORD pid
, DWORD value
)
2577 r
= MsiGetSummaryInformationA(hdb
, NULL
, 1, &summary
);
2578 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2580 r
= MsiSummaryInfoSetPropertyA(summary
, pid
, VT_I4
, value
, NULL
, NULL
);
2581 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
2583 r
= MsiSummaryInfoPersist(summary
);
2584 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
2586 MsiCloseHandle(summary
);
2589 static void test_msipackage(void)
2591 MSIHANDLE hdb
= 0, hpack
= 100;
2596 /* NULL szPackagePath */
2597 r
= MsiOpenPackageA(NULL
, &hpack
);
2598 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
2600 /* empty szPackagePath */
2601 r
= MsiOpenPackageA("", &hpack
);
2602 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
2604 skip("Not enough rights to perform tests\n");
2609 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2612 if (r
== ERROR_SUCCESS
)
2613 MsiCloseHandle(hpack
);
2615 /* nonexistent szPackagePath */
2616 r
= MsiOpenPackageA("nonexistent", &hpack
);
2617 ok(r
== ERROR_FILE_NOT_FOUND
, "Expected ERROR_FILE_NOT_FOUND, got %d\n", r
);
2620 r
= MsiOpenPackageA(msifile
, NULL
);
2621 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
2625 r
= MsiOpenPackageA(name
, &hpack
);
2626 ok(r
== ERROR_INVALID_HANDLE
, "Expected ERROR_INVALID_HANDLE, got %d\n", r
);
2628 r
= MsiOpenDatabaseW(msifileW
, MSIDBOPEN_CREATE
, &hdb
);
2629 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2631 /* database exists, but is empty */
2632 sprintf(name
, "#%d", hdb
);
2633 r
= MsiOpenPackageA(name
, &hpack
);
2634 ok(r
== ERROR_INSTALL_PACKAGE_INVALID
,
2635 "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r
);
2637 query
= "CREATE TABLE `Property` ( "
2638 "`Property` CHAR(72), `Value` CHAR(0) "
2639 "PRIMARY KEY `Property`)";
2640 r
= try_query(hdb
, query
);
2641 ok(r
== ERROR_SUCCESS
, "failed to create Properties table\n");
2643 query
= "CREATE TABLE `InstallExecuteSequence` ("
2644 "`Action` CHAR(72), `Condition` CHAR(0), `Sequence` INTEGER "
2645 "PRIMARY KEY `Action`)";
2646 r
= try_query(hdb
, query
);
2647 ok(r
== ERROR_SUCCESS
, "failed to create InstallExecuteSequence table\n");
2649 /* a few key tables exist */
2650 sprintf(name
, "#%d", hdb
);
2651 r
= MsiOpenPackageA(name
, &hpack
);
2652 ok(r
== ERROR_INSTALL_PACKAGE_INVALID
,
2653 "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r
);
2655 MsiCloseHandle(hdb
);
2656 DeleteFileA(msifile
);
2658 /* start with a clean database to show what constitutes a valid package */
2659 r
= MsiOpenDatabaseW(msifileW
, MSIDBOPEN_CREATE
, &hdb
);
2660 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2662 sprintf(name
, "#%d", hdb
);
2664 /* The following summary information props must exist:
2669 set_summary_dword(hdb
, PID_PAGECOUNT
, 100);
2670 r
= MsiOpenPackageA(name
, &hpack
);
2671 ok(r
== ERROR_INSTALL_PACKAGE_INVALID
,
2672 "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r
);
2674 set_summary_str(hdb
, PID_REVNUMBER
, "{004757CD-5092-49C2-AD20-28E1CE0DF5F2}");
2675 r
= MsiOpenPackageA(name
, &hpack
);
2676 ok(r
== ERROR_SUCCESS
,
2677 "Expected ERROR_SUCCESS, got %d\n", r
);
2679 MsiCloseHandle(hpack
);
2680 MsiCloseHandle(hdb
);
2681 DeleteFileA(msifile
);
2684 static void test_formatrecord2(void)
2686 MSIHANDLE hpkg
, hrec
;
2691 r
= package_from_db(create_package_db(), &hpkg
);
2692 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
2694 skip("Not enough rights to perform tests\n");
2695 DeleteFileA(msifile
);
2698 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
2700 r
= MsiSetPropertyA(hpkg
, "Manufacturer", " " );
2701 ok( r
== ERROR_SUCCESS
, "set property failed\n");
2703 hrec
= MsiCreateRecord(2);
2704 ok(hrec
, "create record failed\n");
2706 r
= MsiRecordSetStringA( hrec
, 0, "[ProgramFilesFolder][Manufacturer]\\asdf");
2707 ok( r
== ERROR_SUCCESS
, "format record failed\n");
2711 r
= MsiFormatRecordA( hpkg
, hrec
, buffer
, &sz
);
2712 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
2714 r
= MsiRecordSetStringA(hrec
, 0, "[foo][1]");
2715 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
2716 r
= MsiRecordSetStringA(hrec
, 1, "hoo");
2717 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
2719 r
= MsiFormatRecordA(hpkg
, hrec
, buffer
, &sz
);
2720 ok( sz
== 3, "size wrong\n");
2721 ok( 0 == strcmp(buffer
,"hoo"), "wrong output %s\n",buffer
);
2722 ok( r
== ERROR_SUCCESS
, "format failed\n");
2724 r
= MsiRecordSetStringA(hrec
, 0, "x[~]x");
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
,"x"), "wrong output %s\n",buffer
);
2730 ok( r
== ERROR_SUCCESS
, "format failed\n");
2732 r
= MsiRecordSetStringA(hrec
, 0, "[foo.$%}][1]");
2733 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
2734 r
= MsiRecordSetStringA(hrec
, 1, "hoo");
2735 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
2737 r
= MsiFormatRecordA(hpkg
, hrec
, buffer
, &sz
);
2738 ok( sz
== 3, "size wrong\n");
2739 ok( 0 == strcmp(buffer
,"hoo"), "wrong output %s\n",buffer
);
2740 ok( r
== ERROR_SUCCESS
, "format failed\n");
2742 r
= MsiRecordSetStringA(hrec
, 0, "[\\[]");
2743 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
2745 r
= MsiFormatRecordA(hpkg
, hrec
, buffer
, &sz
);
2746 ok( sz
== 1, "size wrong\n");
2747 ok( 0 == strcmp(buffer
,"["), "wrong output %s\n",buffer
);
2748 ok( r
== ERROR_SUCCESS
, "format failed\n");
2750 SetEnvironmentVariableA("FOO", "BAR");
2751 r
= MsiRecordSetStringA(hrec
, 0, "[%FOO]");
2752 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
2754 r
= MsiFormatRecordA(hpkg
, hrec
, buffer
, &sz
);
2755 ok( sz
== 3, "size wrong\n");
2756 ok( 0 == strcmp(buffer
,"BAR"), "wrong output %s\n",buffer
);
2757 ok( r
== ERROR_SUCCESS
, "format failed\n");
2759 r
= MsiRecordSetStringA(hrec
, 0, "[[1]]");
2760 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
2761 r
= MsiRecordSetStringA(hrec
, 1, "%FOO");
2762 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
2764 r
= MsiFormatRecordA(hpkg
, hrec
, buffer
, &sz
);
2765 ok( sz
== 3, "size wrong\n");
2766 ok( 0 == strcmp(buffer
,"BAR"), "wrong output %s\n",buffer
);
2767 ok( r
== ERROR_SUCCESS
, "format failed\n");
2769 MsiCloseHandle( hrec
);
2770 MsiCloseHandle( hpkg
);
2771 DeleteFileA(msifile
);
2774 static void test_formatrecord_tables(void)
2776 MSIHANDLE hdb
, hrec
, hpkg
= 0;
2778 CHAR curr_dir
[MAX_PATH
];
2779 CHAR expected
[MAX_PATH
];
2780 CHAR root
[MAX_PATH
];
2784 GetCurrentDirectoryA( MAX_PATH
, curr_dir
);
2786 hdb
= create_package_db();
2787 ok ( hdb
, "failed to create package database\n");
2789 add_directory_entry( hdb
, "'TARGETDIR', '', 'SourceDir'" );
2790 add_directory_entry( hdb
, "'ReallyLongDir', 'TARGETDIR', "
2791 "'I am a really long directory'" );
2793 create_feature_table( hdb
);
2794 add_feature_entry( hdb
, "'occipitofrontalis', '', '', '', 2, 1, '', 0" );
2796 create_component_table( hdb
);
2797 add_component_entry( hdb
, "'frontal', '', 'TARGETDIR', 0, '', 'frontal_file'" );
2798 add_component_entry( hdb
, "'parietal', '', 'TARGETDIR', 1, '', 'parietal_file'" );
2799 add_component_entry( hdb
, "'temporal', '', 'ReallyLongDir', 0, '', 'temporal_file'" );
2801 create_feature_components_table( hdb
);
2802 add_feature_components_entry( hdb
, "'occipitofrontalis', 'frontal'" );
2803 add_feature_components_entry( hdb
, "'occipitofrontalis', 'parietal'" );
2804 add_feature_components_entry( hdb
, "'occipitofrontalis', 'temporal'" );
2806 create_file_table( hdb
);
2807 add_file_entry( hdb
, "'frontal_file', 'frontal', 'frontal.txt', 0, '', '1033', 8192, 1" );
2808 add_file_entry( hdb
, "'parietal_file', 'parietal', 'parietal.txt', 0, '', '1033', 8192, 1" );
2809 add_file_entry( hdb
, "'temporal_file', 'temporal', 'temporal.txt', 0, '', '1033', 8192, 1" );
2811 create_custom_action_table( hdb
);
2812 add_custom_action_entry( hdb
, "'MyCustom', 51, 'prop', '[!temporal_file]'" );
2813 add_custom_action_entry( hdb
, "'EscapeIt1', 51, 'prop', '[\\[]Bracket Text[\\]]'" );
2814 add_custom_action_entry( hdb
, "'EscapeIt2', 51, 'prop', '[\\xabcd]'" );
2815 add_custom_action_entry( hdb
, "'EscapeIt3', 51, 'prop', '[abcd\\xefgh]'" );
2816 add_custom_action_entry( hdb
, "'EmbedNull', 51, 'prop', '[~]np'" );
2818 r
= package_from_db( hdb
, &hpkg
);
2819 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
2821 skip("Not enough rights to perform tests\n");
2822 MsiCloseHandle( hdb
);
2823 DeleteFileA( msifile
);
2826 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
2828 MsiCloseHandle( hdb
);
2830 r
= MsiSetPropertyA( hpkg
, "imaprop", "ringer" );
2831 ok( r
== ERROR_SUCCESS
, "cannot set property: %d\n", r
);
2833 hrec
= MsiCreateRecord( 1 );
2835 /* property doesn't exist */
2837 /*MsiRecordSetStringA( hrec, 0, "[1]" ); */
2838 MsiRecordSetStringA( hrec
, 1, "[idontexist]" );
2839 r
= MsiFormatRecordA( hpkg
, hrec
, buf
, &size
);
2840 ok( r
== ERROR_SUCCESS
, "format record failed: %d\n", r
);
2841 ok( !lstrcmpA( buf
, "1: " ), "Expected '1: ', got %s\n", buf
);
2843 /* property exists */
2845 MsiRecordSetStringA( hrec
, 1, "[imaprop]" );
2846 r
= MsiFormatRecordA( hpkg
, hrec
, buf
, &size
);
2847 ok( r
== ERROR_SUCCESS
, "format record failed: %d\n", r
);
2848 ok( !lstrcmpA( buf
, "1: ringer " ), "Expected '1: ringer ', got %s\n", buf
);
2851 MsiRecordSetStringA( hrec
, 0, "1: [1] " );
2852 r
= MsiFormatRecordA( hpkg
, hrec
, buf
, &size
);
2853 ok( r
== ERROR_SUCCESS
, "format record failed: %d\n", r
);
2854 ok( !lstrcmpA( buf
, "1: ringer " ), "Expected '1: ringer ', got %s\n", buf
);
2856 /* environment variable doesn't exist */
2858 MsiRecordSetStringA( hrec
, 1, "[%idontexist]" );
2859 r
= MsiFormatRecordA( hpkg
, hrec
, buf
, &size
);
2860 ok( r
== ERROR_SUCCESS
, "format record failed: %d\n", r
);
2861 ok( !lstrcmpA( buf
, "1: " ), "Expected '1: ', got %s\n", buf
);
2863 /* environment variable exists */
2865 SetEnvironmentVariableA( "crazyvar", "crazyval" );
2866 MsiRecordSetStringA( hrec
, 1, "[%crazyvar]" );
2867 r
= MsiFormatRecordA( hpkg
, hrec
, buf
, &size
);
2868 ok( r
== ERROR_SUCCESS
, "format record failed: %d\n", r
);
2869 ok( !lstrcmpA( buf
, "1: crazyval " ), "Expected '1: crazyval ', got %s\n", buf
);
2871 /* file key before CostInitialize */
2873 MsiRecordSetStringA( hrec
, 1, "[#frontal_file]" );
2874 r
= MsiFormatRecordA( hpkg
, hrec
, buf
, &size
);
2875 ok( r
== ERROR_SUCCESS
, "format record failed: %d\n", r
);
2876 ok( !lstrcmpA( buf
, "1: " ), "Expected '1: ', got %s\n", buf
);
2878 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
2880 r
= MsiDoActionA(hpkg
, "CostInitialize");
2881 ok( r
== ERROR_SUCCESS
, "CostInitialize failed: %d\n", r
);
2883 r
= MsiDoActionA(hpkg
, "FileCost");
2884 ok( r
== ERROR_SUCCESS
, "FileCost failed: %d\n", r
);
2886 r
= MsiDoActionA(hpkg
, "CostFinalize");
2887 ok( r
== ERROR_SUCCESS
, "CostFinalize failed: %d\n", r
);
2890 MsiGetPropertyA( hpkg
, "ROOTDRIVE", root
, &size
);
2892 sprintf( expected
, "1: %sfrontal.txt ", root
);
2894 /* frontal full file key */
2896 MsiRecordSetStringA( hrec
, 1, "[#frontal_file]" );
2897 r
= MsiFormatRecordA( hpkg
, hrec
, buf
, &size
);
2898 ok( r
== ERROR_SUCCESS
, "format record failed: %d\n", r
);
2899 ok( !lstrcmpA( buf
, expected
), "Expected \"%s\", got \"%s\"\n", expected
, buf
);
2901 /* frontal short file key */
2903 MsiRecordSetStringA( hrec
, 1, "[!frontal_file]" );
2904 r
= MsiFormatRecordA( hpkg
, hrec
, buf
, &size
);
2905 ok( r
== ERROR_SUCCESS
, "format record failed: %d\n", r
);
2906 ok( !lstrcmpA( buf
, expected
), "Expected \"%s\", got \"%s\"\n", expected
, buf
);
2908 sprintf( expected
, "1: %sI am a really long directory\\temporal.txt ", root
);
2910 /* temporal full file key */
2912 MsiRecordSetStringA( hrec
, 1, "[#temporal_file]" );
2913 r
= MsiFormatRecordA( hpkg
, hrec
, buf
, &size
);
2914 ok( r
== ERROR_SUCCESS
, "format record failed: %d\n", r
);
2915 ok( !lstrcmpA( buf
, expected
), "Expected \"%s\", got \"%s\"\n", expected
, buf
);
2917 /* temporal short file key */
2919 MsiRecordSetStringA( hrec
, 1, "[!temporal_file]" );
2920 r
= MsiFormatRecordA( hpkg
, hrec
, buf
, &size
);
2921 ok( r
== ERROR_SUCCESS
, "format record failed: %d\n", r
);
2922 ok( !lstrcmpA( buf
, expected
), "Expected \"%s\", got \"%s\"\n", expected
, buf
);
2924 /* custom action 51, files don't exist */
2925 r
= MsiDoActionA( hpkg
, "MyCustom" );
2926 ok( r
== ERROR_SUCCESS
, "MyCustom failed: %d\n", r
);
2928 sprintf( expected
, "%sI am a really long directory\\temporal.txt", root
);
2931 r
= MsiGetPropertyA( hpkg
, "prop", buf
, &size
);
2932 ok( r
== ERROR_SUCCESS
, "get property failed: %d\n", r
);
2933 ok( !lstrcmpA( buf
, expected
), "Expected \"%s\", got \"%s\"\n", expected
, buf
);
2935 sprintf( buf
, "%sI am a really long directory", root
);
2936 CreateDirectoryA( buf
, NULL
);
2938 lstrcatA( buf
, "\\temporal.txt" );
2939 create_test_file( buf
);
2941 /* custom action 51, files exist */
2942 r
= MsiDoActionA( hpkg
, "MyCustom" );
2943 ok( r
== ERROR_SUCCESS
, "MyCustom failed: %d\n", r
);
2946 r
= MsiGetPropertyA( hpkg
, "prop", buf
, &size
);
2947 ok( r
== ERROR_SUCCESS
, "get property failed: %d\n", r
);
2950 ok( !lstrcmpA( buf
, expected
), "Expected \"%s\", got \"%s\"\n", expected
, buf
);
2953 /* custom action 51, escaped text 1 */
2954 r
= MsiDoActionA( hpkg
, "EscapeIt1" );
2955 ok( r
== ERROR_SUCCESS
, "EscapeIt1 failed: %d\n", r
);
2958 r
= MsiGetPropertyA( hpkg
, "prop", buf
, &size
);
2959 ok( r
== ERROR_SUCCESS
, "get property failed: %d\n", r
);
2960 ok( !lstrcmpA( buf
, "[Bracket Text]" ), "Expected '[Bracket Text]', got %s\n", buf
);
2962 /* custom action 51, escaped text 2 */
2963 r
= MsiDoActionA( hpkg
, "EscapeIt2" );
2964 ok( r
== ERROR_SUCCESS
, "EscapeIt2 failed: %d\n", r
);
2967 r
= MsiGetPropertyA( hpkg
, "prop", buf
, &size
);
2968 ok( r
== ERROR_SUCCESS
, "get property failed: %d\n", r
);
2969 ok( !lstrcmpA( buf
, "x" ), "Expected 'x', got %s\n", buf
);
2971 /* custom action 51, escaped text 3 */
2972 r
= MsiDoActionA( hpkg
, "EscapeIt3" );
2973 ok( r
== ERROR_SUCCESS
, "EscapeIt3 failed: %d\n", r
);
2976 r
= MsiGetPropertyA( hpkg
, "prop", buf
, &size
);
2977 ok( r
== ERROR_SUCCESS
, "get property failed: %d\n", r
);
2978 ok( !lstrcmpA( buf
, "" ), "Expected '', got %s\n", buf
);
2980 /* custom action 51, embedded null */
2981 r
= MsiDoActionA( hpkg
, "EmbedNull" );
2982 ok( r
== ERROR_SUCCESS
, "EmbedNull failed: %d\n", r
);
2985 memset( buf
, 'a', sizeof(buf
) );
2986 r
= MsiGetPropertyA( hpkg
, "prop", buf
, &size
);
2987 ok( r
== ERROR_SUCCESS
, "get property failed: %d\n", r
);
2988 ok( !memcmp( buf
, "\0np", sizeof("\0np") ), "wrong value\n");
2989 ok( size
== sizeof("\0np") - 1, "got %u\n", size
);
2991 r
= MsiSetPropertyA( hpkg
, "prop", "[~]np" );
2992 ok( r
== ERROR_SUCCESS
, "cannot set property: %d\n", r
);
2995 memset( buf
, 'a', sizeof(buf
) );
2996 r
= MsiGetPropertyA( hpkg
, "prop", buf
, &size
);
2997 ok( r
== ERROR_SUCCESS
, "get property failed: %d\n", r
);
2998 ok( !lstrcmpA( buf
, "[~]np" ), "Expected '[~]np', got %s\n", buf
);
3000 sprintf( expected
, "1: %sI am a really long directory\\ ", root
);
3002 /* component with INSTALLSTATE_LOCAL */
3004 MsiRecordSetStringA( hrec
, 1, "[$temporal]" );
3005 r
= MsiFormatRecordA( hpkg
, hrec
, buf
, &size
);
3006 ok( r
== ERROR_SUCCESS
, "format record failed: %d\n", r
);
3007 ok( !lstrcmpA( buf
, expected
), "Expected \"%s\", got \"%s\"\n", expected
, buf
);
3009 r
= MsiSetComponentStateA( hpkg
, "temporal", INSTALLSTATE_SOURCE
);
3010 ok( r
== ERROR_SUCCESS
, "failed to set install state: %d\n", r
);
3012 /* component with INSTALLSTATE_SOURCE */
3013 lstrcpyA( expected
, "1: " );
3014 lstrcatA( expected
, curr_dir
);
3015 if (strlen(curr_dir
) > 3) lstrcatA( expected
, "\\" );
3016 lstrcatA( expected
, " " );
3018 MsiRecordSetStringA( hrec
, 1, "[$parietal]" );
3019 r
= MsiFormatRecordA( hpkg
, hrec
, buf
, &size
);
3020 ok( r
== ERROR_SUCCESS
, "format record failed: %d\n", r
);
3021 ok( !lstrcmpA( buf
, expected
), "Expected '%s', got '%s'\n", expected
, buf
);
3023 sprintf( buf
, "%sI am a really long directory\\temporal.txt", root
);
3026 sprintf( buf
, "%sI am a really long directory", root
);
3027 RemoveDirectoryA( buf
);
3029 MsiCloseHandle( hrec
);
3030 MsiCloseHandle( hpkg
);
3031 DeleteFileA( msifile
);
3034 static void test_feature_states( UINT line
, MSIHANDLE package
, const char *feature
, UINT error
,
3035 INSTALLSTATE expected_state
, INSTALLSTATE expected_action
, BOOL todo
)
3038 INSTALLSTATE state
= 0xdeadbee;
3039 INSTALLSTATE action
= 0xdeadbee;
3041 r
= MsiGetFeatureStateA( package
, feature
, &state
, &action
);
3042 ok( r
== error
, "%u: expected %d got %d\n", line
, error
, r
);
3043 if (r
== ERROR_SUCCESS
)
3045 ok( state
== expected_state
, "%u: expected state %d got %d\n",
3046 line
, expected_state
, state
);
3048 ok( action
== expected_action
, "%u: expected action %d got %d\n",
3049 line
, expected_action
, action
);
3053 ok( state
== 0xdeadbee, "%u: expected state 0xdeadbee got %d\n", line
, state
);
3055 ok( action
== 0xdeadbee, "%u: expected action 0xdeadbee got %d\n", line
, action
);
3060 static void test_component_states( UINT line
, MSIHANDLE package
, const char *component
, UINT error
,
3061 INSTALLSTATE expected_state
, INSTALLSTATE expected_action
, BOOL todo
)
3064 INSTALLSTATE state
= 0xdeadbee;
3065 INSTALLSTATE action
= 0xdeadbee;
3067 r
= MsiGetComponentStateA( package
, component
, &state
, &action
);
3068 ok( r
== error
, "%u: expected %d got %d\n", line
, error
, r
);
3069 if (r
== ERROR_SUCCESS
)
3071 ok( state
== expected_state
, "%u: expected state %d got %d\n",
3072 line
, expected_state
, state
);
3074 ok( action
== expected_action
, "%u: expected action %d got %d\n",
3075 line
, expected_action
, action
);
3079 ok( state
== 0xdeadbee, "%u: expected state 0xdeadbee got %d\n",
3082 ok( action
== 0xdeadbee, "%u: expected action 0xdeadbee got %d\n",
3087 static void test_states(void)
3089 static const char msifile2
[] = "winetest2-package.msi";
3090 static const char msifile3
[] = "winetest3-package.msi";
3091 static const char msifile4
[] = "winetest4-package.msi";
3092 static const WCHAR msifile2W
[] =
3093 {'w','i','n','e','t','e','s','t','2','-','p','a','c','k','a','g','e','.','m','s','i',0};
3094 static const WCHAR msifile3W
[] =
3095 {'w','i','n','e','t','e','s','t','3','-','p','a','c','k','a','g','e','.','m','s','i',0};
3096 static const WCHAR msifile4W
[] =
3097 {'w','i','n','e','t','e','s','t','4','-','p','a','c','k','a','g','e','.','m','s','i',0};
3098 char msi_cache_file
[MAX_PATH
];
3099 DWORD cache_file_name_len
;
3101 MSIHANDLE hpkg
, hprod
;
3105 char value
[MAX_PATH
];
3108 if (is_process_limited())
3110 skip("process is limited\n");
3114 hdb
= create_package_db();
3115 ok ( hdb
, "failed to create package database\n" );
3117 add_directory_entry( hdb
, "'TARGETDIR', '', 'SourceDir'");
3119 create_property_table( hdb
);
3120 add_property_entry( hdb
, "'ProductCode', '{7262AC98-EEBD-4364-8CE3-D654F6A425B9}'" );
3121 add_property_entry( hdb
, "'ProductLanguage', '1033'" );
3122 add_property_entry( hdb
, "'ProductName', 'MSITEST'" );
3123 add_property_entry( hdb
, "'ProductVersion', '1.1.1'" );
3124 add_property_entry( hdb
, "'MSIFASTINSTALL', '1'" );
3125 add_property_entry( hdb
, "'UpgradeCode', '{3494EEEA-4221-4A66-802E-DED8916BC5C5}'" );
3127 create_install_execute_sequence_table( hdb
);
3128 add_install_execute_sequence_entry( hdb
, "'CostInitialize', '', '800'" );
3129 add_install_execute_sequence_entry( hdb
, "'FileCost', '', '900'" );
3130 add_install_execute_sequence_entry( hdb
, "'CostFinalize', '', '1000'" );
3131 add_install_execute_sequence_entry( hdb
, "'InstallValidate', '', '1400'" );
3132 add_install_execute_sequence_entry( hdb
, "'InstallInitialize', '', '1500'" );
3133 add_install_execute_sequence_entry( hdb
, "'ProcessComponents', '', '1600'" );
3134 add_install_execute_sequence_entry( hdb
, "'UnpublishFeatures', '', '1800'" );
3135 add_install_execute_sequence_entry( hdb
, "'RegisterProduct', '', '6100'" );
3136 add_install_execute_sequence_entry( hdb
, "'PublishFeatures', '', '6300'" );
3137 add_install_execute_sequence_entry( hdb
, "'PublishProduct', '', '6400'" );
3138 add_install_execute_sequence_entry( hdb
, "'InstallFinalize', '', '6600'" );
3140 create_media_table( hdb
);
3141 add_media_entry( hdb
, "'1', '3', '', '', 'DISK1', ''");
3143 create_feature_table( hdb
);
3145 create_component_table( hdb
);
3147 /* msidbFeatureAttributesFavorLocal */
3148 add_feature_entry( hdb
, "'one', '', '', '', 2, 1, '', 0" );
3150 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
3151 add_component_entry( hdb
, "'alpha', '{467EC132-739D-4784-A37B-677AA43DBC94}', 'TARGETDIR', 0, '', 'alpha_file'" );
3153 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
3154 add_component_entry( hdb
, "'beta', '{2C1F189C-24A6-4C34-B26B-994A6C026506}', 'TARGETDIR', 1, '', 'beta_file'" );
3156 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
3157 add_component_entry( hdb
, "'gamma', '{C271E2A4-DE2E-4F70-86D1-6984AF7DE2CA}', 'TARGETDIR', 2, '', 'gamma_file'" );
3159 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSharedDllRefCount */
3160 add_component_entry( hdb
, "'theta', '{4EB3129D-81A8-48D5-9801-75600FED3DD9}', 'TARGETDIR', 8, '', 'theta_file'" );
3162 /* msidbFeatureAttributesFavorSource */
3163 add_feature_entry( hdb
, "'two', '', '', '', 2, 1, '', 1" );
3165 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
3166 add_component_entry( hdb
, "'delta', '{938FD4F2-C648-4259-A03C-7AA3B45643F3}', 'TARGETDIR', 0, '', 'delta_file'" );
3168 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
3169 add_component_entry( hdb
, "'epsilon', '{D59713B6-C11D-47F2-A395-1E5321781190}', 'TARGETDIR', 1, '', 'epsilon_file'" );
3171 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
3172 add_component_entry( hdb
, "'zeta', '{377D33AB-2FAA-42B9-A629-0C0DAE9B9C7A}', 'TARGETDIR', 2, '', 'zeta_file'" );
3174 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSharedDllRefCount */
3175 add_component_entry( hdb
, "'iota', '{5D36F871-B5ED-4801-9E0F-C46B9E5C9669}', 'TARGETDIR', 8, '', 'iota_file'" );
3177 /* msidbFeatureAttributesFavorSource */
3178 add_feature_entry( hdb
, "'three', '', '', '', 2, 1, '', 1" );
3180 /* msidbFeatureAttributesFavorLocal */
3181 add_feature_entry( hdb
, "'four', '', '', '', 2, 1, '', 0" );
3184 add_feature_entry( hdb
, "'five', '', '', '', 2, 0, '', 1" );
3186 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
3187 add_component_entry( hdb
, "'eta', '{DD89003F-0DD4-41B8-81C0-3411A7DA2695}', 'TARGETDIR', 1, '', 'eta_file'" );
3189 /* no feature parent:msidbComponentAttributesLocalOnly */
3190 add_component_entry( hdb
, "'kappa', '{D6B93DC3-8DA5-4769-9888-42BFE156BB8B}', 'TARGETDIR', 1, '', 'kappa_file'" );
3192 /* msidbFeatureAttributesFavorLocal:removed */
3193 add_feature_entry( hdb
, "'six', '', '', '', 2, 1, '', 0" );
3195 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesLocalOnly */
3196 add_component_entry( hdb
, "'lambda', '{6528C5E4-02A4-4636-A214-7A66A6C35B64}', 'TARGETDIR', 0, '', 'lambda_file'" );
3198 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesSourceOnly */
3199 add_component_entry( hdb
, "'mu', '{97014BAB-6C56-4013-9A63-2BF913B42519}', 'TARGETDIR', 1, '', 'mu_file'" );
3201 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesOptional */
3202 add_component_entry( hdb
, "'nu', '{943DD0D8-5808-4954-8526-3B8493FEDDCD}', 'TARGETDIR', 2, '', 'nu_file'" );
3204 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesSharedDllRefCount */
3205 add_component_entry( hdb
, "'xi', '{D6CF9EF7-6FCF-4930-B34B-F938AEFF9BDB}', 'TARGETDIR', 8, '', 'xi_file'" );
3207 /* msidbFeatureAttributesFavorSource:removed */
3208 add_feature_entry( hdb
, "'seven', '', '', '', 2, 1, '', 1" );
3210 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesLocalOnly */
3211 add_component_entry( hdb
, "'omicron', '{7B57521D-15DB-4141-9AA6-01D934A4433F}', 'TARGETDIR', 0, '', 'omicron_file'" );
3213 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesSourceOnly */
3214 add_component_entry( hdb
, "'pi', '{FB85346B-378E-4492-8769-792305471C81}', 'TARGETDIR', 1, '', 'pi_file'" );
3216 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesOptional */
3217 add_component_entry( hdb
, "'rho', '{798F2047-7B0C-4783-8BB0-D703E554114B}', 'TARGETDIR', 2, '', 'rho_file'" );
3219 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesSharedDllRefCount */
3220 add_component_entry( hdb
, "'sigma', '{5CE9DDA8-B67B-4736-9D93-99D61C5B93E7}', 'TARGETDIR', 8, '', 'sigma_file'" );
3222 /* msidbFeatureAttributesFavorLocal */
3223 add_feature_entry( hdb
, "'eight', '', '', '', 2, 1, '', 0" );
3225 add_component_entry( hdb
, "'tau', '{07DEB510-677C-4A6F-A0A6-7CD8EFEA77ED}', 'TARGETDIR', 1, '', 'tau_file'" );
3227 /* msidbFeatureAttributesFavorSource */
3228 add_feature_entry( hdb
, "'nine', '', '', '', 2, 1, '', 1" );
3230 add_component_entry( hdb
, "'phi', '{9F0594C5-35AD-43EA-94DD-8DF73FAA664D}', 'TARGETDIR', 1, '', 'phi_file'" );
3232 /* msidbFeatureAttributesFavorAdvertise */
3233 add_feature_entry( hdb
, "'ten', '', '', '', 2, 1, '', 4" );
3235 add_component_entry( hdb
, "'chi', '{E6B539AB-5DA9-4236-A2D2-E341A50B4C38}', 'TARGETDIR', 1, '', 'chi_file'" );
3237 /* msidbFeatureAttributesUIDisallowAbsent */
3238 add_feature_entry( hdb
, "'eleven', '', '', '', 2, 1, '', 16" );
3240 add_component_entry( hdb
, "'psi', '{A06B23B5-746B-427A-8A6E-FD6AC8F46A95}', 'TARGETDIR', 1, '', 'psi_file'" );
3242 /* high install level */
3243 add_feature_entry( hdb
, "'twelve', '', '', '', 2, 2, '', 0" );
3245 add_component_entry( hdb
, "'upsilon', '{557e0c04-ceba-4c58-86a9-4a73352e8cf6}', 'TARGETDIR', 1, '', 'upsilon_file'" );
3247 /* msidbFeatureAttributesFollowParent */
3248 add_feature_entry( hdb
, "'thirteen', '', '', '', 2, 2, '', 2" );
3250 create_feature_components_table( hdb
);
3251 add_feature_components_entry( hdb
, "'one', 'alpha'" );
3252 add_feature_components_entry( hdb
, "'one', 'beta'" );
3253 add_feature_components_entry( hdb
, "'one', 'gamma'" );
3254 add_feature_components_entry( hdb
, "'one', 'theta'" );
3255 add_feature_components_entry( hdb
, "'two', 'delta'" );
3256 add_feature_components_entry( hdb
, "'two', 'epsilon'" );
3257 add_feature_components_entry( hdb
, "'two', 'zeta'" );
3258 add_feature_components_entry( hdb
, "'two', 'iota'" );
3259 add_feature_components_entry( hdb
, "'three', 'eta'" );
3260 add_feature_components_entry( hdb
, "'four', 'eta'" );
3261 add_feature_components_entry( hdb
, "'five', 'eta'" );
3262 add_feature_components_entry( hdb
, "'six', 'lambda'" );
3263 add_feature_components_entry( hdb
, "'six', 'mu'" );
3264 add_feature_components_entry( hdb
, "'six', 'nu'" );
3265 add_feature_components_entry( hdb
, "'six', 'xi'" );
3266 add_feature_components_entry( hdb
, "'seven', 'omicron'" );
3267 add_feature_components_entry( hdb
, "'seven', 'pi'" );
3268 add_feature_components_entry( hdb
, "'seven', 'rho'" );
3269 add_feature_components_entry( hdb
, "'seven', 'sigma'" );
3270 add_feature_components_entry( hdb
, "'eight', 'tau'" );
3271 add_feature_components_entry( hdb
, "'nine', 'phi'" );
3272 add_feature_components_entry( hdb
, "'ten', 'chi'" );
3273 add_feature_components_entry( hdb
, "'eleven', 'psi'" );
3274 add_feature_components_entry( hdb
, "'twelve', 'upsilon'" );
3275 add_feature_components_entry( hdb
, "'thirteen', 'upsilon'" );
3277 create_file_table( hdb
);
3278 add_file_entry( hdb
, "'alpha_file', 'alpha', 'alpha.txt', 100, '', '1033', 8192, 1" );
3279 add_file_entry( hdb
, "'beta_file', 'beta', 'beta.txt', 0, '', '1033', 8192, 1" );
3280 add_file_entry( hdb
, "'gamma_file', 'gamma', 'gamma.txt', 0, '', '1033', 8192, 1" );
3281 add_file_entry( hdb
, "'theta_file', 'theta', 'theta.txt', 0, '', '1033', 8192, 1" );
3282 add_file_entry( hdb
, "'delta_file', 'delta', 'delta.txt', 0, '', '1033', 8192, 1" );
3283 add_file_entry( hdb
, "'epsilon_file', 'epsilon', 'epsilon.txt', 0, '', '1033', 8192, 1" );
3284 add_file_entry( hdb
, "'zeta_file', 'zeta', 'zeta.txt', 0, '', '1033', 8192, 1" );
3285 add_file_entry( hdb
, "'iota_file', 'iota', 'iota.txt', 0, '', '1033', 8192, 1" );
3287 /* compressed file */
3288 add_file_entry( hdb
, "'eta_file', 'eta', 'eta.txt', 0, '', '1033', 16384, 1" );
3290 add_file_entry( hdb
, "'kappa_file', 'kappa', 'kappa.txt', 0, '', '1033', 8192, 1" );
3291 add_file_entry( hdb
, "'lambda_file', 'lambda', 'lambda.txt', 100, '', '1033', 8192, 1" );
3292 add_file_entry( hdb
, "'mu_file', 'mu', 'mu.txt', 100, '', '1033', 8192, 1" );
3293 add_file_entry( hdb
, "'nu_file', 'nu', 'nu.txt', 100, '', '1033', 8192, 1" );
3294 add_file_entry( hdb
, "'xi_file', 'xi', 'xi.txt', 100, '', '1033', 8192, 1" );
3295 add_file_entry( hdb
, "'omicron_file', 'omicron', 'omicron.txt', 100, '', '1033', 8192, 1" );
3296 add_file_entry( hdb
, "'pi_file', 'pi', 'pi.txt', 100, '', '1033', 8192, 1" );
3297 add_file_entry( hdb
, "'rho_file', 'rho', 'rho.txt', 100, '', '1033', 8192, 1" );
3298 add_file_entry( hdb
, "'sigma_file', 'sigma', 'sigma.txt', 100, '', '1033', 8192, 1" );
3299 add_file_entry( hdb
, "'tau_file', 'tau', 'tau.txt', 100, '', '1033', 8192, 1" );
3300 add_file_entry( hdb
, "'phi_file', 'phi', 'phi.txt', 100, '', '1033', 8192, 1" );
3301 add_file_entry( hdb
, "'chi_file', 'chi', 'chi.txt', 100, '', '1033', 8192, 1" );
3302 add_file_entry( hdb
, "'psi_file', 'psi', 'psi.txt', 100, '', '1033', 8192, 1" );
3303 add_file_entry( hdb
, "'upsilon_file', 'upsilon', 'upsilon.txt', 0, '', '1033', 16384, 1" );
3305 r
= MsiDatabaseCommit(hdb
);
3306 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3308 /* these properties must not be in the saved msi file */
3309 add_property_entry( hdb
, "'ADDLOCAL', 'one,four'");
3310 add_property_entry( hdb
, "'ADDSOURCE', 'two,three'");
3311 add_property_entry( hdb
, "'REMOVE', 'six,seven'");
3312 add_property_entry( hdb
, "'REINSTALL', 'eight,nine,ten'");
3313 add_property_entry( hdb
, "'REINSTALLMODE', 'omus'");
3315 r
= package_from_db( hdb
, &hpkg
);
3316 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
3318 skip("Not enough rights to perform tests\n");
3319 DeleteFileA(msifile
);
3322 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
3324 MsiCloseHandle(hdb
);
3326 CopyFileA(msifile
, msifile2
, FALSE
);
3327 CopyFileA(msifile
, msifile3
, FALSE
);
3328 CopyFileA(msifile
, msifile4
, FALSE
);
3330 test_feature_states( __LINE__
, hpkg
, "one", ERROR_UNKNOWN_FEATURE
, 0, 0, FALSE
);
3331 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_UNKNOWN_COMPONENT
, 0, 0, FALSE
);
3333 r
= MsiDoActionA( hpkg
, "CostInitialize");
3334 ok( r
== ERROR_SUCCESS
, "cost init failed\n");
3336 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3337 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3339 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
3341 r
= MsiDoActionA( hpkg
, "FileCost");
3342 ok( r
== ERROR_SUCCESS
, "file cost failed\n");
3344 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3345 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3347 r
= MsiDoActionA( hpkg
, "CostFinalize");
3348 ok( r
== ERROR_SUCCESS
, "cost finalize failed: %d\n", r
);
3350 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
3351 test_feature_states( __LINE__
, hpkg
, "two", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_SOURCE
, FALSE
);
3352 test_feature_states( __LINE__
, hpkg
, "three", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
3353 test_feature_states( __LINE__
, hpkg
, "four", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
3354 test_feature_states( __LINE__
, hpkg
, "five", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3355 test_feature_states( __LINE__
, hpkg
, "six", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3356 test_feature_states( __LINE__
, hpkg
, "seven", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3357 test_feature_states( __LINE__
, hpkg
, "eight", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3358 test_feature_states( __LINE__
, hpkg
, "nine", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3359 test_feature_states( __LINE__
, hpkg
, "ten", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3360 test_feature_states( __LINE__
, hpkg
, "eleven", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3361 test_feature_states( __LINE__
, hpkg
, "twelve", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3362 test_feature_states( __LINE__
, hpkg
, "thirteen", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3364 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
3365 test_component_states( __LINE__
, hpkg
, "beta", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_SOURCE
, FALSE
);
3366 test_component_states( __LINE__
, hpkg
, "gamma", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
3367 test_component_states( __LINE__
, hpkg
, "theta", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
3368 test_component_states( __LINE__
, hpkg
, "delta", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
3369 test_component_states( __LINE__
, hpkg
, "epsilon", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_SOURCE
, FALSE
);
3370 test_component_states( __LINE__
, hpkg
, "zeta", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_SOURCE
, FALSE
);
3371 test_component_states( __LINE__
, hpkg
, "iota", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
3372 test_component_states( __LINE__
, hpkg
, "eta", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
3373 test_component_states( __LINE__
, hpkg
, "kappa", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3374 test_component_states( __LINE__
, hpkg
, "lambda", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3375 test_component_states( __LINE__
, hpkg
, "mu", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3376 test_component_states( __LINE__
, hpkg
, "nu", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3377 test_component_states( __LINE__
, hpkg
, "xi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3378 test_component_states( __LINE__
, hpkg
, "omicron", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3379 test_component_states( __LINE__
, hpkg
, "pi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3380 test_component_states( __LINE__
, hpkg
, "rho", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3381 test_component_states( __LINE__
, hpkg
, "sigma", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3382 test_component_states( __LINE__
, hpkg
, "tau", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3383 test_component_states( __LINE__
, hpkg
, "phi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3384 test_component_states( __LINE__
, hpkg
, "chi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3385 test_component_states( __LINE__
, hpkg
, "psi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3386 test_component_states( __LINE__
, hpkg
, "upsilon", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3388 MsiCloseHandle( hpkg
);
3390 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
3392 /* publish the features and components */
3393 r
= MsiInstallProductA(msifile
, "ADDLOCAL=one,four ADDSOURCE=two,three REMOVE=six,seven REINSTALL=eight,nine,ten");
3394 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3396 r
= MsiOpenDatabaseW(msifileW
, MSIDBOPEN_DIRECT
, &hdb
);
3397 ok(r
== ERROR_SUCCESS
, "failed to open database: %d\n", r
);
3399 /* these properties must not be in the saved msi file */
3400 add_property_entry( hdb
, "'ADDLOCAL', 'one,four'");
3401 add_property_entry( hdb
, "'ADDSOURCE', 'two,three'");
3402 add_property_entry( hdb
, "'REMOVE', 'six,seven'");
3403 add_property_entry( hdb
, "'REINSTALL', 'eight,nine,ten'");
3405 r
= package_from_db( hdb
, &hpkg
);
3406 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
3408 MsiCloseHandle(hdb
);
3410 test_feature_states( __LINE__
, hpkg
, "one", ERROR_UNKNOWN_FEATURE
, 0, 0, FALSE
);
3411 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_UNKNOWN_COMPONENT
, 0, 0, FALSE
);
3413 r
= MsiDoActionA( hpkg
, "CostInitialize");
3414 ok( r
== ERROR_SUCCESS
, "cost init failed\n");
3416 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3417 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3419 r
= MsiDoActionA( hpkg
, "FileCost");
3420 ok( r
== ERROR_SUCCESS
, "file cost failed\n");
3422 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3423 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3425 r
= MsiDoActionA( hpkg
, "CostFinalize");
3426 ok( r
== ERROR_SUCCESS
, "cost finalize failed: %d\n", r
);
3428 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_LOCAL
, FALSE
);
3429 test_feature_states( __LINE__
, hpkg
, "two", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3430 test_feature_states( __LINE__
, hpkg
, "three", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3431 test_feature_states( __LINE__
, hpkg
, "four", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3432 test_feature_states( __LINE__
, hpkg
, "five", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3433 test_feature_states( __LINE__
, hpkg
, "six", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3434 test_feature_states( __LINE__
, hpkg
, "seven", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3435 test_feature_states( __LINE__
, hpkg
, "eight", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3436 test_feature_states( __LINE__
, hpkg
, "nine", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3437 test_feature_states( __LINE__
, hpkg
, "ten", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3438 test_feature_states( __LINE__
, hpkg
, "eleven", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3439 test_feature_states( __LINE__
, hpkg
, "twelve", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3440 test_feature_states( __LINE__
, hpkg
, "thirteen", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3442 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3443 test_component_states( __LINE__
, hpkg
, "beta", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3444 test_component_states( __LINE__
, hpkg
, "gamma", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3445 test_component_states( __LINE__
, hpkg
, "theta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3446 test_component_states( __LINE__
, hpkg
, "delta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3447 test_component_states( __LINE__
, hpkg
, "epsilon", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3448 test_component_states( __LINE__
, hpkg
, "zeta", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3449 test_component_states( __LINE__
, hpkg
, "iota", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3450 test_component_states( __LINE__
, hpkg
, "eta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3451 test_component_states( __LINE__
, hpkg
, "kappa", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3452 test_component_states( __LINE__
, hpkg
, "lambda", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3453 test_component_states( __LINE__
, hpkg
, "mu", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3454 test_component_states( __LINE__
, hpkg
, "nu", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3455 test_component_states( __LINE__
, hpkg
, "xi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3456 test_component_states( __LINE__
, hpkg
, "omicron", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3457 test_component_states( __LINE__
, hpkg
, "pi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3458 test_component_states( __LINE__
, hpkg
, "rho", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3459 test_component_states( __LINE__
, hpkg
, "sigma", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3460 test_component_states( __LINE__
, hpkg
, "tau", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3461 test_component_states( __LINE__
, hpkg
, "phi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3462 test_component_states( __LINE__
, hpkg
, "chi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3463 test_component_states( __LINE__
, hpkg
, "psi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3464 test_component_states( __LINE__
, hpkg
, "upsilon", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3466 MsiCloseHandle(hpkg
);
3468 /* uninstall the product */
3469 r
= MsiInstallProductA(msifile
, "REMOVE=ALL");
3470 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3472 state
= MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "five");
3473 ok(state
== INSTALLSTATE_UNKNOWN
, "state = %d\n", state
);
3474 state
= MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "twelve");
3475 ok(state
== INSTALLSTATE_UNKNOWN
, "state = %d\n", state
);
3477 /* all features installed locally */
3478 r
= MsiInstallProductA(msifile2
, "ADDLOCAL=ALL");
3479 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3481 state
= MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "five");
3482 ok(state
== INSTALLSTATE_UNKNOWN
, "state = %d\n", state
);
3483 state
= MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "twelve");
3484 ok(state
== INSTALLSTATE_LOCAL
, "state = %d\n", state
);
3486 r
= MsiOpenDatabaseW(msifile2W
, MSIDBOPEN_DIRECT
, &hdb
);
3487 ok(r
== ERROR_SUCCESS
, "failed to open database: %d\n", r
);
3489 /* these properties must not be in the saved msi file */
3490 add_property_entry( hdb
, "'ADDLOCAL', 'one,two,three,four,five,six,seven,eight,nine,ten,twelve'");
3492 r
= package_from_db( hdb
, &hpkg
);
3493 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
3495 test_feature_states( __LINE__
, hpkg
, "one", ERROR_UNKNOWN_FEATURE
, 0, 0, FALSE
);
3496 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_UNKNOWN_COMPONENT
, 0, 0, FALSE
);
3498 r
= MsiDoActionA( hpkg
, "CostInitialize");
3499 ok( r
== ERROR_SUCCESS
, "cost init failed\n");
3501 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3502 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3504 r
= MsiDoActionA( hpkg
, "CostFinalize");
3505 ok( r
== ERROR_SUCCESS
, "cost finalize failed: %d\n", r
);
3507 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_LOCAL
, FALSE
);
3508 test_feature_states( __LINE__
, hpkg
, "two", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_LOCAL
, FALSE
);
3509 test_feature_states( __LINE__
, hpkg
, "three", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3510 test_feature_states( __LINE__
, hpkg
, "four", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3511 test_feature_states( __LINE__
, hpkg
, "five", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3512 test_feature_states( __LINE__
, hpkg
, "six", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_LOCAL
, FALSE
);
3513 test_feature_states( __LINE__
, hpkg
, "seven", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_LOCAL
, FALSE
);
3514 test_feature_states( __LINE__
, hpkg
, "eight", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, TRUE
);
3515 test_feature_states( __LINE__
, hpkg
, "nine", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, TRUE
);
3516 test_feature_states( __LINE__
, hpkg
, "ten", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, TRUE
);
3517 test_feature_states( __LINE__
, hpkg
, "eleven", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, TRUE
);
3518 test_feature_states( __LINE__
, hpkg
, "twelve", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3519 test_feature_states( __LINE__
, hpkg
, "thirteen", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_UNKNOWN
, FALSE
);
3521 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3522 test_component_states( __LINE__
, hpkg
, "beta", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3523 test_component_states( __LINE__
, hpkg
, "gamma", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3524 test_component_states( __LINE__
, hpkg
, "theta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3525 test_component_states( __LINE__
, hpkg
, "delta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3526 test_component_states( __LINE__
, hpkg
, "epsilon", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3527 test_component_states( __LINE__
, hpkg
, "zeta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3528 test_component_states( __LINE__
, hpkg
, "iota", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3529 test_component_states( __LINE__
, hpkg
, "eta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3530 test_component_states( __LINE__
, hpkg
, "kappa", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3531 test_component_states( __LINE__
, hpkg
, "lambda", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3532 test_component_states( __LINE__
, hpkg
, "mu", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3533 test_component_states( __LINE__
, hpkg
, "nu", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3534 test_component_states( __LINE__
, hpkg
, "xi", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3535 test_component_states( __LINE__
, hpkg
, "omicron", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3536 test_component_states( __LINE__
, hpkg
, "pi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3537 test_component_states( __LINE__
, hpkg
, "rho", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3538 test_component_states( __LINE__
, hpkg
, "sigma", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3539 test_component_states( __LINE__
, hpkg
, "tau", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, TRUE
);
3540 test_component_states( __LINE__
, hpkg
, "phi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, TRUE
);
3541 test_component_states( __LINE__
, hpkg
, "chi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, TRUE
);
3542 test_component_states( __LINE__
, hpkg
, "psi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3543 test_component_states( __LINE__
, hpkg
, "upsilon", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3545 MsiCloseHandle(hpkg
);
3547 /* uninstall the product */
3548 r
= MsiInstallProductA(msifile2
, "REMOVE=ALL");
3549 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3551 /* all features installed from source */
3552 r
= MsiInstallProductA(msifile3
, "ADDSOURCE=ALL");
3553 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3555 state
= MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "five");
3556 ok(state
== INSTALLSTATE_UNKNOWN
, "state = %d\n", state
);
3557 state
= MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "twelve");
3558 ok(state
== INSTALLSTATE_LOCAL
, "state = %d\n", state
);
3560 r
= MsiOpenDatabaseW(msifile3W
, MSIDBOPEN_DIRECT
, &hdb
);
3561 ok(r
== ERROR_SUCCESS
, "failed to open database: %d\n", r
);
3563 /* this property must not be in the saved msi file */
3564 add_property_entry( hdb
, "'ADDSOURCE', 'one,two,three,four,five,six,seven,eight,nine,ten'");
3566 r
= package_from_db( hdb
, &hpkg
);
3567 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
3569 test_feature_states( __LINE__
, hpkg
, "one", ERROR_UNKNOWN_FEATURE
, 0, 0, FALSE
);
3570 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_UNKNOWN_COMPONENT
, 0, 0, FALSE
);
3572 r
= MsiDoActionA( hpkg
, "CostInitialize");
3573 ok( r
== ERROR_SUCCESS
, "cost init failed\n");
3575 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3576 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3578 r
= MsiDoActionA( hpkg
, "FileCost");
3579 ok( r
== ERROR_SUCCESS
, "file cost failed\n");
3581 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3582 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3584 r
= MsiDoActionA( hpkg
, "CostFinalize");
3585 ok( r
== ERROR_SUCCESS
, "cost finalize failed: %d\n", r
);
3587 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3588 test_feature_states( __LINE__
, hpkg
, "two", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3589 test_feature_states( __LINE__
, hpkg
, "three", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3590 test_feature_states( __LINE__
, hpkg
, "four", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3591 test_feature_states( __LINE__
, hpkg
, "five", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3592 test_feature_states( __LINE__
, hpkg
, "six", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3593 test_feature_states( __LINE__
, hpkg
, "seven", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3594 test_feature_states( __LINE__
, hpkg
, "eight", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3595 test_feature_states( __LINE__
, hpkg
, "nine", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3596 test_feature_states( __LINE__
, hpkg
, "ten", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3597 test_feature_states( __LINE__
, hpkg
, "eleven", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, TRUE
);
3598 test_feature_states( __LINE__
, hpkg
, "twelve", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_UNKNOWN
, FALSE
);
3599 test_feature_states( __LINE__
, hpkg
, "thirteen", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_UNKNOWN
, FALSE
);
3601 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3602 test_component_states( __LINE__
, hpkg
, "beta", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3603 test_component_states( __LINE__
, hpkg
, "gamma", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3604 test_component_states( __LINE__
, hpkg
, "theta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3605 test_component_states( __LINE__
, hpkg
, "delta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3606 test_component_states( __LINE__
, hpkg
, "epsilon", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3607 test_component_states( __LINE__
, hpkg
, "zeta", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3608 test_component_states( __LINE__
, hpkg
, "iota", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3609 test_component_states( __LINE__
, hpkg
, "eta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3610 test_component_states( __LINE__
, hpkg
, "kappa", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3611 test_component_states( __LINE__
, hpkg
, "lambda", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3612 test_component_states( __LINE__
, hpkg
, "mu", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3613 test_component_states( __LINE__
, hpkg
, "nu", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3614 test_component_states( __LINE__
, hpkg
, "xi", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3615 test_component_states( __LINE__
, hpkg
, "omicron", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3616 test_component_states( __LINE__
, hpkg
, "pi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3617 test_component_states( __LINE__
, hpkg
, "rho", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3618 test_component_states( __LINE__
, hpkg
, "sigma", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3619 test_component_states( __LINE__
, hpkg
, "tau", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3620 test_component_states( __LINE__
, hpkg
, "phi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3621 test_component_states( __LINE__
, hpkg
, "chi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3622 test_component_states( __LINE__
, hpkg
, "psi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3623 test_component_states( __LINE__
, hpkg
, "upsilon", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3625 MsiCloseHandle(hpkg
);
3627 /* reinstall the product */
3628 r
= MsiInstallProductA(msifile3
, "REINSTALL=ALL");
3629 is_broken
= (r
== ERROR_INSTALL_FAILURE
);
3630 ok(r
== ERROR_SUCCESS
|| broken(is_broken
) /* win2k3 */, "Expected ERROR_SUCCESS, got %d\n", r
);
3632 state
= MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "five");
3633 ok(state
== INSTALLSTATE_UNKNOWN
, "state = %d\n", state
);
3634 state
= MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "twelve");
3635 ok(state
== INSTALLSTATE_LOCAL
, "state = %d\n", state
);
3637 r
= MsiOpenDatabaseW(msifile4W
, MSIDBOPEN_DIRECT
, &hdb
);
3638 ok(r
== ERROR_SUCCESS
, "failed to open database: %d\n", r
);
3640 /* this property must not be in the saved msi file */
3641 add_property_entry( hdb
, "'ADDSOURCE', 'one,two,three,four,five,six,seven,eight,nine,ten'");
3643 r
= package_from_db( hdb
, &hpkg
);
3644 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
3646 test_feature_states( __LINE__
, hpkg
, "one", ERROR_UNKNOWN_FEATURE
, 0, 0, FALSE
);
3647 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_UNKNOWN_COMPONENT
, 0, 0, FALSE
);
3649 r
= MsiDoActionA( hpkg
, "CostInitialize");
3650 ok( r
== ERROR_SUCCESS
, "cost init failed\n");
3652 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3653 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3655 r
= MsiDoActionA( hpkg
, "FileCost");
3656 ok( r
== ERROR_SUCCESS
, "file cost failed\n");
3658 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3659 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3661 r
= MsiDoActionA( hpkg
, "CostFinalize");
3662 ok( r
== ERROR_SUCCESS
, "cost finalize failed: %d\n", r
);
3664 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3665 test_feature_states( __LINE__
, hpkg
, "two", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3666 test_feature_states( __LINE__
, hpkg
, "three", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3667 test_feature_states( __LINE__
, hpkg
, "four", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3668 test_feature_states( __LINE__
, hpkg
, "five", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3669 test_feature_states( __LINE__
, hpkg
, "six", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3670 test_feature_states( __LINE__
, hpkg
, "seven", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3671 test_feature_states( __LINE__
, hpkg
, "eight", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3672 test_feature_states( __LINE__
, hpkg
, "nine", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3673 test_feature_states( __LINE__
, hpkg
, "ten", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3674 test_feature_states( __LINE__
, hpkg
, "eleven", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, TRUE
);
3675 test_feature_states( __LINE__
, hpkg
, "twelve", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_UNKNOWN
, FALSE
);
3676 test_feature_states( __LINE__
, hpkg
, "thirteen", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_UNKNOWN
, FALSE
);
3678 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3679 test_component_states( __LINE__
, hpkg
, "beta", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3680 test_component_states( __LINE__
, hpkg
, "gamma", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3681 test_component_states( __LINE__
, hpkg
, "theta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3682 test_component_states( __LINE__
, hpkg
, "delta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3683 test_component_states( __LINE__
, hpkg
, "epsilon", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3684 test_component_states( __LINE__
, hpkg
, "zeta", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3685 test_component_states( __LINE__
, hpkg
, "iota", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3686 test_component_states( __LINE__
, hpkg
, "eta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3687 test_component_states( __LINE__
, hpkg
, "kappa", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3688 test_component_states( __LINE__
, hpkg
, "lambda", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3689 test_component_states( __LINE__
, hpkg
, "mu", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3690 test_component_states( __LINE__
, hpkg
, "nu", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3691 test_component_states( __LINE__
, hpkg
, "xi", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3692 test_component_states( __LINE__
, hpkg
, "omicron", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3693 test_component_states( __LINE__
, hpkg
, "pi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3694 test_component_states( __LINE__
, hpkg
, "rho", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3695 test_component_states( __LINE__
, hpkg
, "sigma", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3696 test_component_states( __LINE__
, hpkg
, "tau", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3697 test_component_states( __LINE__
, hpkg
, "phi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3698 test_component_states( __LINE__
, hpkg
, "chi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3699 test_component_states( __LINE__
, hpkg
, "psi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3700 test_component_states( __LINE__
, hpkg
, "upsilon", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3702 MsiCloseHandle(hpkg
);
3704 /* test source only install */
3705 r
= MsiInstallProductA(msifile
, "REMOVE=ALL");
3706 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3707 state
= MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "one");
3708 ok(state
== INSTALLSTATE_UNKNOWN
, "state = %d\n", state
);
3709 state
= MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "two");
3710 ok(state
== INSTALLSTATE_UNKNOWN
, "state = %d\n", state
);
3712 r
= MsiInstallProductA(msifile
, "ADDSOURCE=one");
3713 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3714 state
= MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "one");
3715 ok(state
== INSTALLSTATE_SOURCE
, "state = %d\n", state
);
3716 state
= MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "two");
3717 ok(state
== INSTALLSTATE_ABSENT
, "state = %d\n", state
);
3719 /* no arguments test */
3720 cache_file_name_len
= sizeof(msi_cache_file
);
3721 r
= MsiGetProductInfoA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}",
3722 INSTALLPROPERTY_LOCALPACKAGEA
, msi_cache_file
, &cache_file_name_len
);
3723 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3724 r
= MsiOpenDatabaseA(msi_cache_file
, (const char*)MSIDBOPEN_DIRECT
, &hdb
);
3725 ok(r
== ERROR_SUCCESS
, "failed to open database: %d\n", r
);
3727 create_custom_action_table( hdb
);
3728 add_custom_action_entry( hdb
, "'ConditionCheck1', 19, '', 'Condition check failed (1)'" );
3729 add_custom_action_entry( hdb
, "'ConditionCheck2', 19, '', 'Condition check failed (2)'" );
3730 add_custom_action_entry( hdb
, "'ConditionCheck3', 19, '', 'Condition check failed (3)'" );
3731 add_custom_action_entry( hdb
, "'ConditionCheck4', 19, '', 'Condition check failed (4)'" );
3732 add_custom_action_entry( hdb
, "'ConditionCheck5', 19, '', 'Condition check failed (5)'" );
3733 add_custom_action_entry( hdb
, "'ConditionCheck6', 19, '', 'Condition check failed (6)'" );
3734 add_custom_action_entry( hdb
, "'ConditionCheck7', 19, '', 'Condition check failed (7)'" );
3735 add_custom_action_entry( hdb
, "'ConditionCheck8', 19, '', 'Condition check failed (8)'" );
3736 add_custom_action_entry( hdb
,
3737 "'VBFeatureRequest', 38, NULL, 'Session.FeatureRequestState(\"three\") = 3'" );
3739 add_install_execute_sequence_entry( hdb
, "'ConditionCheck1', 'REINSTALL', '798'" );
3740 add_install_execute_sequence_entry( hdb
, "'ConditionCheck2', 'NOT REMOVE AND Preselected', '799'" );
3741 add_install_execute_sequence_entry( hdb
, "'VBFeatureRequest', 'NOT REMOVE', '1001'" );
3742 add_install_execute_sequence_entry( hdb
, "'ConditionCheck3', 'REINSTALL', '6598'" );
3743 add_install_execute_sequence_entry( hdb
, "'ConditionCheck4', 'NOT REMOVE AND Preselected', '6599'" );
3744 add_install_execute_sequence_entry( hdb
, "'ConditionCheck5', 'REINSTALL', '6601'" );
3745 add_install_execute_sequence_entry( hdb
, "'ConditionCheck6', 'NOT REMOVE AND Preselected', '6601'" );
3746 /* Add "one" feature action tests */
3747 add_install_execute_sequence_entry( hdb
, "'ConditionCheck7', 'NOT REMOVE AND NOT(&one=-1)', '1501'" );
3748 add_install_execute_sequence_entry( hdb
, "'ConditionCheck8', 'NOT REMOVE AND NOT(&one=-1)', '6602'" );
3749 r
= MsiDatabaseCommit(hdb
);
3750 ok(r
== ERROR_SUCCESS
, "MsiDatabaseCommit failed: %d\n", r
);
3751 r
= package_from_db( hdb
, &hpkg
);
3752 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
3753 MsiCloseHandle(hdb
);
3755 test_feature_states( __LINE__
, hpkg
, "one", ERROR_UNKNOWN_FEATURE
, 0, 0, FALSE
);
3756 test_feature_states( __LINE__
, hpkg
, "two", ERROR_UNKNOWN_FEATURE
, 0, 0, FALSE
);
3757 r
= MsiDoActionA( hpkg
, "CostInitialize");
3758 ok( r
== ERROR_SUCCESS
, "CostInitialize failed\n");
3759 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3760 test_feature_states( __LINE__
, hpkg
, "two", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3762 r
= MsiDoActionA( hpkg
, "FileCost");
3763 ok( r
== ERROR_SUCCESS
, "FileCost failed\n");
3764 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3765 test_feature_states( __LINE__
, hpkg
, "two", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3767 r
= MsiDoActionA( hpkg
, "CostFinalize");
3768 ok( r
== ERROR_SUCCESS
, "CostFinalize failed\n");
3769 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3770 test_feature_states( __LINE__
, hpkg
, "two", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3771 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3772 test_component_states( __LINE__
, hpkg
, "beta", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3773 test_component_states( __LINE__
, hpkg
, "gamma", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3774 test_component_states( __LINE__
, hpkg
, "theta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3775 test_component_states( __LINE__
, hpkg
, "delta", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3776 test_component_states( __LINE__
, hpkg
, "epsilon", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3777 test_component_states( __LINE__
, hpkg
, "zeta", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3778 test_component_states( __LINE__
, hpkg
, "iota", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3779 test_component_states( __LINE__
, hpkg
, "eta", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3780 test_component_states( __LINE__
, hpkg
, "kappa", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3781 test_component_states( __LINE__
, hpkg
, "lambda", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3782 test_component_states( __LINE__
, hpkg
, "mu", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3783 test_component_states( __LINE__
, hpkg
, "nu", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3784 test_component_states( __LINE__
, hpkg
, "xi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3785 test_component_states( __LINE__
, hpkg
, "omicron", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3786 test_component_states( __LINE__
, hpkg
, "pi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3787 test_component_states( __LINE__
, hpkg
, "rho", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3788 test_component_states( __LINE__
, hpkg
, "sigma", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3789 test_component_states( __LINE__
, hpkg
, "tau", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3790 test_component_states( __LINE__
, hpkg
, "phi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3791 test_component_states( __LINE__
, hpkg
, "chi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3792 test_component_states( __LINE__
, hpkg
, "psi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3793 test_component_states( __LINE__
, hpkg
, "upsilon", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3795 r
= MsiDoActionA( hpkg
, "InstallValidate");
3796 ok( r
== ERROR_SUCCESS
, "InstallValidate failed %d\n", r
);
3797 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3798 test_feature_states( __LINE__
, hpkg
, "two", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3799 MsiCloseHandle( hpkg
);
3801 r
= MsiInstallProductA(msifile
, "");
3802 ok(r
== ERROR_SUCCESS
|| (is_broken
&& r
== ERROR_INSTALL_FAILURE
) /* win2k3 */,
3803 "Expected ERROR_SUCCESS, got %d\n", r
);
3804 state
= MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "one");
3805 ok(state
== INSTALLSTATE_SOURCE
, "state = %d\n", state
);
3806 state
= MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "two");
3807 ok(state
== INSTALLSTATE_ABSENT
, "state = %d\n", state
);
3808 state
= MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "three");
3809 ok(state
== INSTALLSTATE_LOCAL
, "state = %d\n", state
);
3811 /* minor upgrade test with no REINSTALL argument */
3812 r
= MsiOpenProductA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", &hprod
);
3813 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3815 r
= MsiGetProductPropertyA(hprod
, "ProductVersion", value
, &size
);
3816 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3817 ok(!strcmp(value
, "1.1.1"), "ProductVersion = %s\n", value
);
3818 MsiCloseHandle(hprod
);
3820 r
= MsiOpenDatabaseA(msifile2
, (const char*)MSIDBOPEN_DIRECT
, &hdb
);
3821 ok(r
== ERROR_SUCCESS
, "failed to open database: %d\n", r
);
3822 update_ProductVersion_property( hdb
, "1.1.2" );
3823 set_summary_str(hdb
, PID_REVNUMBER
, "{A219A62A-D931-4F1B-89DB-FF1C300A8D43}");
3824 r
= MsiDatabaseCommit(hdb
);
3825 ok(r
== ERROR_SUCCESS
, "MsiDatabaseCommit failed: %d\n", r
);
3826 MsiCloseHandle(hdb
);
3828 r
= MsiInstallProductA(msifile2
, "");
3829 todo_wine
ok(r
== ERROR_PRODUCT_VERSION
, "Expected ERROR_PRODUCT_VERSION, got %d\n", r
);
3831 r
= MsiInstallProductA(msifile2
, "REINSTALLMODE=v");
3832 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3834 r
= MsiOpenProductA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", &hprod
);
3835 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3837 r
= MsiGetProductPropertyA(hprod
, "ProductVersion", value
, &size
);
3838 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3839 ok(!strcmp(value
, "1.1.2"), "ProductVersion = %s\n", value
);
3840 MsiCloseHandle(hprod
);
3842 /* major upgrade test */
3843 r
= MsiOpenDatabaseA(msifile2
, (const char*)MSIDBOPEN_DIRECT
, &hdb
);
3844 ok(r
== ERROR_SUCCESS
, "failed to open database: %d\n", r
);
3845 add_install_execute_sequence_entry( hdb
, "'FindRelatedProducts', '', '100'" );
3846 add_install_execute_sequence_entry( hdb
, "'RemoveExistingProducts', '', '1401'" );
3847 create_upgrade_table( hdb
);
3848 add_upgrade_entry( hdb
, "'{3494EEEA-4221-4A66-802E-DED8916BC5C5}', NULL, '1.1.3', NULL, 0, NULL, 'OLDERVERSIONBEINGUPGRADED'");
3849 update_ProductCode_property( hdb
, "{333DB27A-C25E-4EBC-9BEC-0F49546C19A6}" );
3850 update_ProductVersion_property( hdb
, "1.1.3" );
3851 set_summary_str(hdb
, PID_REVNUMBER
, "{5F99011C-02E6-48BD-8B8D-DE7CFABC7A09}");
3852 r
= MsiDatabaseCommit(hdb
);
3853 ok(r
== ERROR_SUCCESS
, "MsiDatabaseCommit failed: %d\n", r
);
3854 MsiCloseHandle(hdb
);
3856 r
= MsiInstallProductA(msifile2
, "");
3857 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3859 r
= MsiOpenProductA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", &hprod
);
3860 ok(r
== ERROR_UNKNOWN_PRODUCT
, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
3861 r
= MsiOpenProductA("{333DB27A-C25E-4EBC-9BEC-0F49546C19A6}", &hprod
);
3862 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3864 r
= MsiGetProductPropertyA(hprod
, "ProductVersion", value
, &size
);
3865 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3866 ok(!strcmp(value
, "1.1.3"), "ProductVersion = %s\n", value
);
3867 MsiCloseHandle(hprod
);
3869 /* uninstall the product */
3870 r
= MsiInstallProductA(msifile2
, "REMOVE=ALL");
3871 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3873 DeleteFileA(msifile
);
3874 DeleteFileA(msifile2
);
3875 DeleteFileA(msifile3
);
3876 DeleteFileA(msifile4
);
3879 static void test_removefiles(void)
3884 INSTALLSTATE installed
, action
;
3886 hdb
= create_package_db();
3887 ok ( hdb
, "failed to create package database\n" );
3889 add_directory_entry( hdb
, "'TARGETDIR', '', 'SourceDir'");
3891 create_feature_table( hdb
);
3892 add_feature_entry( hdb
, "'one', '', '', '', 2, 1, '', 0" );
3894 create_component_table( hdb
);
3895 add_component_entry( hdb
, "'hydrogen', '', 'TARGETDIR', 0, '', 'hydrogen_file'" );
3896 add_component_entry( hdb
, "'helium', '', 'TARGETDIR', 0, '', 'helium_file'" );
3897 add_component_entry( hdb
, "'lithium', '', 'TARGETDIR', 0, '', 'lithium_file'" );
3898 add_component_entry( hdb
, "'beryllium', '', 'TARGETDIR', 0, '', 'beryllium_file'" );
3899 add_component_entry( hdb
, "'boron', '', 'TARGETDIR', 0, '', 'boron_file'" );
3900 add_component_entry( hdb
, "'carbon', '', 'TARGETDIR', 0, '', 'carbon_file'" );
3901 add_component_entry( hdb
, "'oxygen', '', 'TARGETDIR', 0, '0', 'oxygen_file'" );
3903 create_feature_components_table( hdb
);
3904 add_feature_components_entry( hdb
, "'one', 'hydrogen'" );
3905 add_feature_components_entry( hdb
, "'one', 'helium'" );
3906 add_feature_components_entry( hdb
, "'one', 'lithium'" );
3907 add_feature_components_entry( hdb
, "'one', 'beryllium'" );
3908 add_feature_components_entry( hdb
, "'one', 'boron'" );
3909 add_feature_components_entry( hdb
, "'one', 'carbon'" );
3910 add_feature_components_entry( hdb
, "'one', 'oxygen'" );
3912 create_file_table( hdb
);
3913 add_file_entry( hdb
, "'hydrogen_file', 'hydrogen', 'hydrogen.txt', 0, '', '1033', 8192, 1" );
3914 add_file_entry( hdb
, "'helium_file', 'helium', 'helium.txt', 0, '', '1033', 8192, 1" );
3915 add_file_entry( hdb
, "'lithium_file', 'lithium', 'lithium.txt', 0, '', '1033', 8192, 1" );
3916 add_file_entry( hdb
, "'beryllium_file', 'beryllium', 'beryllium.txt', 0, '', '1033', 16384, 1" );
3917 add_file_entry( hdb
, "'boron_file', 'boron', 'boron.txt', 0, '', '1033', 16384, 1" );
3918 add_file_entry( hdb
, "'carbon_file', 'carbon', 'carbon.txt', 0, '', '1033', 16384, 1" );
3919 add_file_entry( hdb
, "'oxygen_file', 'oxygen', 'oxygen.txt', 0, '', '1033', 16384, 1" );
3921 create_remove_file_table( hdb
);
3923 r
= package_from_db( hdb
, &hpkg
);
3924 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
3926 skip("Not enough rights to perform tests\n");
3927 DeleteFileA(msifile
);
3930 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
3932 MsiCloseHandle( hdb
);
3934 create_test_file( "hydrogen.txt" );
3935 create_test_file( "helium.txt" );
3936 create_test_file( "lithium.txt" );
3937 create_test_file( "beryllium.txt" );
3938 create_test_file( "boron.txt" );
3939 create_test_file( "carbon.txt" );
3940 create_test_file( "oxygen.txt" );
3942 r
= MsiSetPropertyA( hpkg
, "TARGETDIR", CURR_DIR
);
3943 ok( r
== ERROR_SUCCESS
, "set property failed\n");
3945 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
3947 r
= MsiGetComponentStateA( hpkg
, "oxygen", &installed
, &action
);
3948 ok( r
== ERROR_UNKNOWN_COMPONENT
, "expected ERROR_UNKNOWN_COMPONENT, got %u\n", r
);
3950 r
= MsiDoActionA( hpkg
, "CostInitialize");
3951 ok( r
== ERROR_SUCCESS
, "cost init failed\n");
3953 r
= MsiDoActionA( hpkg
, "FileCost");
3954 ok( r
== ERROR_SUCCESS
, "file cost failed\n");
3956 installed
= action
= 0xdeadbeef;
3957 r
= MsiGetComponentStateA( hpkg
, "oxygen", &installed
, &action
);
3958 ok( r
== ERROR_SUCCESS
, "failed to get component state %u\n", r
);
3959 ok( installed
== INSTALLSTATE_UNKNOWN
, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed
);
3960 ok( action
== INSTALLSTATE_UNKNOWN
, "expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
3962 r
= MsiDoActionA( hpkg
, "CostFinalize");
3963 ok( r
== ERROR_SUCCESS
, "cost finalize failed\n");
3965 r
= MsiDoActionA( hpkg
, "InstallValidate");
3966 ok( r
== ERROR_SUCCESS
, "install validate failed\n");
3968 r
= MsiSetComponentStateA( hpkg
, "hydrogen", INSTALLSTATE_ABSENT
);
3969 ok( r
== ERROR_SUCCESS
, "failed to set component state: %d\n", r
);
3971 installed
= action
= 0xdeadbeef;
3972 r
= MsiGetComponentStateA( hpkg
, "hydrogen", &installed
, &action
);
3973 ok( r
== ERROR_SUCCESS
, "failed to get component state %u\n", r
);
3974 ok( installed
== INSTALLSTATE_UNKNOWN
, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed
);
3975 todo_wine
ok( action
== INSTALLSTATE_UNKNOWN
, "expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
3977 r
= MsiSetComponentStateA( hpkg
, "helium", INSTALLSTATE_LOCAL
);
3978 ok( r
== ERROR_SUCCESS
, "failed to set component state: %d\n", r
);
3980 r
= MsiSetComponentStateA( hpkg
, "lithium", INSTALLSTATE_SOURCE
);
3981 ok( r
== ERROR_SUCCESS
, "failed to set component state: %d\n", r
);
3983 r
= MsiSetComponentStateA( hpkg
, "beryllium", INSTALLSTATE_ABSENT
);
3984 ok( r
== ERROR_SUCCESS
, "failed to set component state: %d\n", r
);
3986 r
= MsiSetComponentStateA( hpkg
, "boron", INSTALLSTATE_LOCAL
);
3987 ok( r
== ERROR_SUCCESS
, "failed to set component state: %d\n", r
);
3989 r
= MsiSetComponentStateA( hpkg
, "carbon", INSTALLSTATE_SOURCE
);
3990 ok( r
== ERROR_SUCCESS
, "failed to set component state: %d\n", r
);
3992 installed
= action
= 0xdeadbeef;
3993 r
= MsiGetComponentStateA( hpkg
, "oxygen", &installed
, &action
);
3994 ok( r
== ERROR_SUCCESS
, "failed to get component state %u\n", r
);
3995 ok( installed
== INSTALLSTATE_UNKNOWN
, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed
);
3996 ok( action
== INSTALLSTATE_UNKNOWN
, "expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
3998 r
= MsiSetComponentStateA( hpkg
, "oxygen", INSTALLSTATE_ABSENT
);
3999 ok( r
== ERROR_SUCCESS
, "failed to set component state: %d\n", r
);
4001 installed
= action
= 0xdeadbeef;
4002 r
= MsiGetComponentStateA( hpkg
, "oxygen", &installed
, &action
);
4003 ok( r
== ERROR_SUCCESS
, "failed to get component state %u\n", r
);
4004 ok( installed
== INSTALLSTATE_UNKNOWN
, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed
);
4005 ok( action
== INSTALLSTATE_UNKNOWN
, "expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
4007 r
= MsiDoActionA( hpkg
, "RemoveFiles");
4008 ok( r
== ERROR_SUCCESS
, "remove files failed\n");
4010 installed
= action
= 0xdeadbeef;
4011 r
= MsiGetComponentStateA( hpkg
, "oxygen", &installed
, &action
);
4012 ok( r
== ERROR_SUCCESS
, "failed to get component state %u\n", r
);
4013 ok( installed
== INSTALLSTATE_UNKNOWN
, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed
);
4014 ok( action
== INSTALLSTATE_UNKNOWN
, "expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
4016 ok(DeleteFileA("hydrogen.txt"), "Expected hydrogen.txt to exist\n");
4017 ok(DeleteFileA("lithium.txt"), "Expected lithium.txt to exist\n");
4018 ok(DeleteFileA("beryllium.txt"), "Expected beryllium.txt to exist\n");
4019 ok(DeleteFileA("carbon.txt"), "Expected carbon.txt to exist\n");
4020 ok(DeleteFileA("helium.txt"), "Expected helium.txt to exist\n");
4021 ok(DeleteFileA("boron.txt"), "Expected boron.txt to exist\n");
4022 ok(DeleteFileA("oxygen.txt"), "Expected oxygen.txt to exist\n");
4024 MsiCloseHandle( hpkg
);
4025 DeleteFileA(msifile
);
4028 static void test_appsearch(void)
4033 CHAR prop
[MAX_PATH
];
4036 const char reg_expand_value
[] = "%systemroot%\\system32\\notepad.exe";
4038 hdb
= create_package_db();
4039 ok ( hdb
, "failed to create package database\n" );
4041 create_appsearch_table( hdb
);
4042 add_appsearch_entry( hdb
, "'WEBBROWSERPROG', 'NewSignature1'" );
4043 add_appsearch_entry( hdb
, "'NOTEPAD', 'NewSignature2'" );
4044 add_appsearch_entry( hdb
, "'REGEXPANDVAL', 'NewSignature3'" );
4046 create_reglocator_table( hdb
);
4047 add_reglocator_entry( hdb
, "NewSignature1", 0, "htmlfile\\shell\\open\\command", "", 1 );
4049 r
= RegCreateKeyExA(HKEY_CURRENT_USER
, "Software\\Winetest_msi", 0, NULL
, 0, KEY_ALL_ACCESS
, NULL
, &hkey
, NULL
);
4050 ok( r
== ERROR_SUCCESS
, "Could not create key: %d.\n", r
);
4051 r
= RegSetValueExA(hkey
, NULL
, 0, REG_EXPAND_SZ
, (const BYTE
*)reg_expand_value
, strlen(reg_expand_value
) + 1);
4052 ok( r
== ERROR_SUCCESS
, "Could not set key value: %d.\n", r
);
4054 add_reglocator_entry( hdb
, "NewSignature3", 1, "Software\\Winetest_msi", "", 1 );
4056 create_drlocator_table( hdb
);
4057 add_drlocator_entry( hdb
, "'NewSignature2', 0, 'c:\\windows\\system32', 0" );
4059 create_signature_table( hdb
);
4060 add_signature_entry( hdb
, "'NewSignature1', 'FileName', '', '', '', '', '', '', ''" );
4061 add_signature_entry( hdb
, "'NewSignature2', 'NOTEPAD.EXE|notepad.exe', '', '', '', '', '', '', ''" );
4062 add_signature_entry( hdb
, "'NewSignature3', 'NOTEPAD.EXE|notepad.exe', '', '', '', '', '', '', ''" );
4064 r
= package_from_db( hdb
, &hpkg
);
4065 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
4067 skip("Not enough rights to perform tests\n");
4068 DeleteFileA(msifile
);
4071 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
4072 MsiCloseHandle( hdb
);
4073 if (r
!= ERROR_SUCCESS
)
4076 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
4078 r
= MsiDoActionA( hpkg
, "AppSearch" );
4079 ok( r
== ERROR_SUCCESS
, "AppSearch failed: %d\n", r
);
4081 size
= sizeof(prop
);
4082 r
= MsiGetPropertyA( hpkg
, "WEBBROWSERPROG", prop
, &size
);
4083 ok( r
== ERROR_SUCCESS
, "get property failed: %d\n", r
);
4084 ok( lstrlenA(prop
) != 0, "Expected non-zero length\n");
4086 size
= sizeof(prop
);
4087 r
= MsiGetPropertyA( hpkg
, "NOTEPAD", prop
, &size
);
4088 ok( r
== ERROR_SUCCESS
, "get property failed: %d\n", r
);
4090 size
= sizeof(prop
);
4091 r
= MsiGetPropertyA( hpkg
, "REGEXPANDVAL", prop
, &size
);
4092 ok( r
== ERROR_SUCCESS
, "get property failed: %d\n", r
);
4093 ok( lstrlenA(prop
) != 0, "Expected non-zero length\n");
4096 MsiCloseHandle( hpkg
);
4097 DeleteFileA(msifile
);
4098 RegDeleteKeyA(HKEY_CURRENT_USER
, "Software\\Winetest_msi");
4101 static void test_appsearch_complocator(void)
4103 MSIHANDLE hpkg
, hdb
;
4104 char path
[MAX_PATH
], expected
[MAX_PATH
], prop
[MAX_PATH
];
4109 if (!(usersid
= get_user_sid()))
4112 if (is_process_limited())
4114 skip("process is limited\n");
4118 create_test_file("FileName1");
4119 create_test_file("FileName4");
4120 set_component_path("FileName1", MSIINSTALLCONTEXT_MACHINE
,
4121 "{A8AE6692-96BA-4198-8399-145D7D1D0D0E}", NULL
, FALSE
);
4123 create_test_file("FileName2");
4124 set_component_path("FileName2", MSIINSTALLCONTEXT_USERUNMANAGED
,
4125 "{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}", usersid
, FALSE
);
4127 create_test_file("FileName3");
4128 set_component_path("FileName3", MSIINSTALLCONTEXT_USERMANAGED
,
4129 "{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}", usersid
, FALSE
);
4131 create_test_file("FileName5");
4132 set_component_path("FileName5", MSIINSTALLCONTEXT_MACHINE
,
4133 "{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}", NULL
, TRUE
);
4135 create_test_file("FileName6");
4136 set_component_path("FileName6", MSIINSTALLCONTEXT_MACHINE
,
4137 "{C0ECD96F-7898-4410-9667-194BD8C1B648}", NULL
, TRUE
);
4139 create_test_file("FileName7");
4140 set_component_path("FileName7", MSIINSTALLCONTEXT_MACHINE
,
4141 "{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}", NULL
, FALSE
);
4143 /* dir is FALSE, but we're pretending it's a directory */
4144 set_component_path("IDontExist\\", MSIINSTALLCONTEXT_MACHINE
,
4145 "{91B7359B-07F2-4221-AA8D-DE102BB87A5F}", NULL
, FALSE
);
4147 create_file_with_version("FileName8.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4148 set_component_path("FileName8.dll", MSIINSTALLCONTEXT_MACHINE
,
4149 "{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}", NULL
, FALSE
);
4151 create_file_with_version("FileName9.dll", MAKELONG(1, 2), MAKELONG(3, 4));
4152 set_component_path("FileName9.dll", MSIINSTALLCONTEXT_MACHINE
,
4153 "{A204DF48-7346-4635-BA2E-66247DBAC9DF}", NULL
, FALSE
);
4155 create_file_with_version("FileName10.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4156 set_component_path("FileName10.dll", MSIINSTALLCONTEXT_MACHINE
,
4157 "{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}", NULL
, FALSE
);
4159 hdb
= create_package_db();
4160 ok(hdb
, "Expected a valid database handle\n");
4162 create_appsearch_table(hdb
);
4163 add_appsearch_entry(hdb
, "'SIGPROP1', 'NewSignature1'");
4164 add_appsearch_entry(hdb
, "'SIGPROP2', 'NewSignature2'");
4165 add_appsearch_entry(hdb
, "'SIGPROP3', 'NewSignature3'");
4166 add_appsearch_entry(hdb
, "'SIGPROP4', 'NewSignature4'");
4167 add_appsearch_entry(hdb
, "'SIGPROP5', 'NewSignature5'");
4168 add_appsearch_entry(hdb
, "'SIGPROP6', 'NewSignature6'");
4169 add_appsearch_entry(hdb
, "'SIGPROP7', 'NewSignature7'");
4170 add_appsearch_entry(hdb
, "'SIGPROP8', 'NewSignature8'");
4171 add_appsearch_entry(hdb
, "'SIGPROP9', 'NewSignature9'");
4172 add_appsearch_entry(hdb
, "'SIGPROP10', 'NewSignature10'");
4173 add_appsearch_entry(hdb
, "'SIGPROP11', 'NewSignature11'");
4174 add_appsearch_entry(hdb
, "'SIGPROP12', 'NewSignature12'");
4176 create_complocator_table(hdb
);
4178 /* published component, machine, file, signature, misdbLocatorTypeFile */
4179 add_complocator_entry(hdb
, "'NewSignature1', '{A8AE6692-96BA-4198-8399-145D7D1D0D0E}', 1");
4181 /* published component, user-unmanaged, file, signature, misdbLocatorTypeFile */
4182 add_complocator_entry(hdb
, "'NewSignature2', '{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}', 1");
4184 /* published component, user-managed, file, signature, misdbLocatorTypeFile */
4185 add_complocator_entry(hdb
, "'NewSignature3', '{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}', 1");
4187 /* published component, machine, file, signature, misdbLocatorTypeDirectory */
4188 add_complocator_entry(hdb
, "'NewSignature4', '{A8AE6692-96BA-4198-8399-145D7D1D0D0E}', 0");
4190 /* published component, machine, dir, signature, misdbLocatorTypeDirectory */
4191 add_complocator_entry(hdb
, "'NewSignature5', '{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}', 0");
4193 /* published component, machine, dir, no signature, misdbLocatorTypeDirectory */
4194 add_complocator_entry(hdb
, "'NewSignature6', '{C0ECD96F-7898-4410-9667-194BD8C1B648}', 0");
4196 /* published component, machine, file, no signature, misdbLocatorTypeFile */
4197 add_complocator_entry(hdb
, "'NewSignature7', '{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}', 1");
4199 /* unpublished component, no signature, misdbLocatorTypeDir */
4200 add_complocator_entry(hdb
, "'NewSignature8', '{FB671D5B-5083-4048-90E0-481C48D8F3A5}', 0");
4202 /* published component, no signature, dir does not exist misdbLocatorTypeDir */
4203 add_complocator_entry(hdb
, "'NewSignature9', '{91B7359B-07F2-4221-AA8D-DE102BB87A5F}', 0");
4205 /* published component, signature w/ ver, misdbLocatorTypeFile */
4206 add_complocator_entry(hdb
, "'NewSignature10', '{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}', 1");
4208 /* published component, signature w/ ver, ver > max, misdbLocatorTypeFile */
4209 add_complocator_entry(hdb
, "'NewSignature11', '{A204DF48-7346-4635-BA2E-66247DBAC9DF}', 1");
4211 /* published component, signature w/ ver, sig->name ignored, misdbLocatorTypeFile */
4212 add_complocator_entry(hdb
, "'NewSignature12', '{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}', 1");
4214 create_signature_table(hdb
);
4215 add_signature_entry(hdb
, "'NewSignature1', 'FileName1', '', '', '', '', '', '', ''");
4216 add_signature_entry(hdb
, "'NewSignature2', 'FileName2', '', '', '', '', '', '', ''");
4217 add_signature_entry(hdb
, "'NewSignature3', 'FileName3', '', '', '', '', '', '', ''");
4218 add_signature_entry(hdb
, "'NewSignature4', 'FileName4', '', '', '', '', '', '', ''");
4219 add_signature_entry(hdb
, "'NewSignature5', 'FileName5', '', '', '', '', '', '', ''");
4220 add_signature_entry(hdb
, "'NewSignature10', 'FileName8.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
4221 add_signature_entry(hdb
, "'NewSignature11', 'FileName9.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
4222 add_signature_entry(hdb
, "'NewSignature12', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
4224 r
= package_from_db(hdb
, &hpkg
);
4225 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
4227 skip("Not enough rights to perform tests\n");
4230 ok(r
== ERROR_SUCCESS
, "Expected a valid package handle %u\n", r
);
4232 r
= MsiSetPropertyA(hpkg
, "SIGPROP8", "october");
4233 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4235 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
4237 r
= MsiDoActionA(hpkg
, "AppSearch");
4238 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4240 strcpy(expected
, CURR_DIR
);
4241 if (is_root(CURR_DIR
)) expected
[2] = 0;
4244 sprintf(path
, "%s\\FileName1", expected
);
4245 r
= MsiGetPropertyA(hpkg
, "SIGPROP1", prop
, &size
);
4246 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4247 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4250 sprintf(path
, "%s\\FileName2", expected
);
4251 r
= MsiGetPropertyA(hpkg
, "SIGPROP2", prop
, &size
);
4252 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4253 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4256 sprintf(path
, "%s\\FileName3", expected
);
4257 r
= MsiGetPropertyA(hpkg
, "SIGPROP3", prop
, &size
);
4258 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4259 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4262 sprintf(path
, "%s\\FileName4", expected
);
4263 r
= MsiGetPropertyA(hpkg
, "SIGPROP4", prop
, &size
);
4264 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4265 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4268 sprintf(path
, "%s\\FileName5", expected
);
4269 r
= MsiGetPropertyA(hpkg
, "SIGPROP5", prop
, &size
);
4270 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4271 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4274 sprintf(path
, "%s\\", expected
);
4275 r
= MsiGetPropertyA(hpkg
, "SIGPROP6", prop
, &size
);
4276 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4277 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4280 sprintf(path
, "%s\\", expected
);
4281 r
= MsiGetPropertyA(hpkg
, "SIGPROP7", prop
, &size
);
4282 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4283 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4286 r
= MsiGetPropertyA(hpkg
, "SIGPROP8", prop
, &size
);
4287 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4288 ok(!lstrcmpA(prop
, "october"), "Expected \"october\", got \"%s\"\n", prop
);
4291 r
= MsiGetPropertyA(hpkg
, "SIGPROP9", prop
, &size
);
4292 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4293 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4296 sprintf(path
, "%s\\FileName8.dll", expected
);
4297 r
= MsiGetPropertyA(hpkg
, "SIGPROP10", prop
, &size
);
4298 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4299 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4302 r
= MsiGetPropertyA(hpkg
, "SIGPROP11", prop
, &size
);
4303 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4304 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4307 sprintf(path
, "%s\\FileName10.dll", expected
);
4308 r
= MsiGetPropertyA(hpkg
, "SIGPROP12", prop
, &size
);
4309 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4310 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4312 delete_component_path("{A8AE6692-96BA-4198-8399-145D7D1D0D0E}",
4313 MSIINSTALLCONTEXT_MACHINE
, NULL
);
4314 delete_component_path("{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}",
4315 MSIINSTALLCONTEXT_USERUNMANAGED
, usersid
);
4316 delete_component_path("{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}",
4317 MSIINSTALLCONTEXT_USERMANAGED
, usersid
);
4318 delete_component_path("{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}",
4319 MSIINSTALLCONTEXT_MACHINE
, NULL
);
4320 delete_component_path("{C0ECD96F-7898-4410-9667-194BD8C1B648}",
4321 MSIINSTALLCONTEXT_MACHINE
, NULL
);
4322 delete_component_path("{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}",
4323 MSIINSTALLCONTEXT_MACHINE
, NULL
);
4324 delete_component_path("{91B7359B-07F2-4221-AA8D-DE102BB87A5F}",
4325 MSIINSTALLCONTEXT_MACHINE
, NULL
);
4326 delete_component_path("{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}",
4327 MSIINSTALLCONTEXT_MACHINE
, NULL
);
4328 delete_component_path("{A204DF48-7346-4635-BA2E-66247DBAC9DF}",
4329 MSIINSTALLCONTEXT_MACHINE
, NULL
);
4330 delete_component_path("{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}",
4331 MSIINSTALLCONTEXT_MACHINE
, NULL
);
4333 MsiCloseHandle(hpkg
);
4336 DeleteFileA("FileName1");
4337 DeleteFileA("FileName2");
4338 DeleteFileA("FileName3");
4339 DeleteFileA("FileName4");
4340 DeleteFileA("FileName5");
4341 DeleteFileA("FileName6");
4342 DeleteFileA("FileName7");
4343 DeleteFileA("FileName8.dll");
4344 DeleteFileA("FileName9.dll");
4345 DeleteFileA("FileName10.dll");
4346 DeleteFileA(msifile
);
4350 static void test_appsearch_reglocator(void)
4352 MSIHANDLE hpkg
, hdb
;
4353 char path
[MAX_PATH
], expected
[MAX_PATH
], prop
[MAX_PATH
];
4354 DWORD binary
[2], size
, val
;
4355 BOOL space
, version
, is_64bit
= sizeof(void *) > sizeof(int);
4356 HKEY hklm
, classes
, hkcu
, users
;
4357 LPSTR pathdata
, pathvar
, ptr
;
4363 if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
4366 DeleteFileA("test.dll");
4368 res
= RegCreateKeyA(HKEY_CLASSES_ROOT
, "Software\\Wine", &classes
);
4369 if (res
== ERROR_ACCESS_DENIED
)
4371 skip("Not enough rights to perform tests\n");
4374 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4376 res
= RegSetValueExA(classes
, "Value1", 0, REG_SZ
,
4377 (const BYTE
*)"regszdata", 10);
4378 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4380 res
= RegCreateKeyA(HKEY_CURRENT_USER
, "Software\\Wine", &hkcu
);
4381 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4383 res
= RegSetValueExA(hkcu
, "Value1", 0, REG_SZ
,
4384 (const BYTE
*)"regszdata", 10);
4385 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4388 res
= RegCreateKeyA(HKEY_USERS
, "S-1-5-18\\Software\\Wine", &users
);
4389 ok(res
== ERROR_SUCCESS
||
4390 broken(res
== ERROR_INVALID_PARAMETER
),
4391 "Expected ERROR_SUCCESS, got %d\n", res
);
4393 if (res
== ERROR_SUCCESS
)
4395 res
= RegSetValueExA(users
, "Value1", 0, REG_SZ
,
4396 (const BYTE
*)"regszdata", 10);
4397 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4400 res
= RegCreateKeyA(HKEY_LOCAL_MACHINE
, "Software\\Wine", &hklm
);
4401 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4403 res
= RegSetValueA(hklm
, NULL
, REG_SZ
, "defvalue", 8);
4404 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4406 res
= RegSetValueExA(hklm
, "Value1", 0, REG_SZ
,
4407 (const BYTE
*)"regszdata", 10);
4408 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4411 res
= RegSetValueExA(hklm
, "Value2", 0, REG_DWORD
,
4412 (const BYTE
*)&val
, sizeof(DWORD
));
4413 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4416 res
= RegSetValueExA(hklm
, "Value3", 0, REG_DWORD
,
4417 (const BYTE
*)&val
, sizeof(DWORD
));
4418 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4420 res
= RegSetValueExA(hklm
, "Value4", 0, REG_EXPAND_SZ
,
4421 (const BYTE
*)"%PATH%", 7);
4422 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4424 res
= RegSetValueExA(hklm
, "Value5", 0, REG_EXPAND_SZ
,
4425 (const BYTE
*)"my%NOVAR%", 10);
4426 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4428 res
= RegSetValueExA(hklm
, "Value6", 0, REG_MULTI_SZ
,
4429 (const BYTE
*)"one\0two\0", 9);
4430 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4432 binary
[0] = 0x1234abcd;
4433 binary
[1] = 0x567890ef;
4434 res
= RegSetValueExA(hklm
, "Value7", 0, REG_BINARY
,
4435 (const BYTE
*)binary
, sizeof(binary
));
4436 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4438 res
= RegSetValueExA(hklm
, "Value8", 0, REG_SZ
,
4439 (const BYTE
*)"#regszdata", 11);
4440 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4442 strcpy(expected
, CURR_DIR
);
4443 if (is_root(CURR_DIR
)) expected
[2] = 0;
4445 create_test_file("FileName1");
4446 sprintf(path
, "%s\\FileName1", expected
);
4447 res
= RegSetValueExA(hklm
, "Value9", 0, REG_SZ
,
4448 (const BYTE
*)path
, lstrlenA(path
) + 1);
4449 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4451 sprintf(path
, "%s\\FileName2", expected
);
4452 res
= RegSetValueExA(hklm
, "Value10", 0, REG_SZ
,
4453 (const BYTE
*)path
, lstrlenA(path
) + 1);
4454 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4456 lstrcpyA(path
, expected
);
4457 res
= RegSetValueExA(hklm
, "Value11", 0, REG_SZ
,
4458 (const BYTE
*)path
, lstrlenA(path
) + 1);
4459 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4461 res
= RegSetValueExA(hklm
, "Value12", 0, REG_SZ
,
4462 (const BYTE
*)"", 1);
4463 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4465 create_file_with_version("FileName3.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4466 sprintf(path
, "%s\\FileName3.dll", expected
);
4467 res
= RegSetValueExA(hklm
, "Value13", 0, REG_SZ
,
4468 (const BYTE
*)path
, lstrlenA(path
) + 1);
4469 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4471 create_file_with_version("FileName4.dll", MAKELONG(1, 2), MAKELONG(3, 4));
4472 sprintf(path
, "%s\\FileName4.dll", expected
);
4473 res
= RegSetValueExA(hklm
, "Value14", 0, REG_SZ
,
4474 (const BYTE
*)path
, lstrlenA(path
) + 1);
4475 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4477 create_file_with_version("FileName5.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4478 sprintf(path
, "%s\\FileName5.dll", expected
);
4479 res
= RegSetValueExA(hklm
, "Value15", 0, REG_SZ
,
4480 (const BYTE
*)path
, lstrlenA(path
) + 1);
4481 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4483 sprintf(path
, "\"%s\\FileName1\" -option", expected
);
4484 res
= RegSetValueExA(hklm
, "value16", 0, REG_SZ
,
4485 (const BYTE
*)path
, lstrlenA(path
) + 1);
4486 ok( res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", res
);
4488 space
= strchr(expected
, ' ') != NULL
;
4489 sprintf(path
, "%s\\FileName1 -option", expected
);
4490 res
= RegSetValueExA(hklm
, "value17", 0, REG_SZ
,
4491 (const BYTE
*)path
, lstrlenA(path
) + 1);
4492 ok( res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", res
);
4494 hdb
= create_package_db();
4495 ok(hdb
, "Expected a valid database handle\n");
4497 create_appsearch_table(hdb
);
4498 add_appsearch_entry(hdb
, "'SIGPROP1', 'NewSignature1'");
4499 add_appsearch_entry(hdb
, "'SIGPROP2', 'NewSignature2'");
4500 add_appsearch_entry(hdb
, "'SIGPROP3', 'NewSignature3'");
4501 add_appsearch_entry(hdb
, "'SIGPROP4', 'NewSignature4'");
4502 add_appsearch_entry(hdb
, "'SIGPROP5', 'NewSignature5'");
4503 add_appsearch_entry(hdb
, "'SIGPROP6', 'NewSignature6'");
4504 add_appsearch_entry(hdb
, "'SIGPROP7', 'NewSignature7'");
4505 add_appsearch_entry(hdb
, "'SIGPROP8', 'NewSignature8'");
4506 add_appsearch_entry(hdb
, "'SIGPROP9', 'NewSignature9'");
4507 add_appsearch_entry(hdb
, "'SIGPROP10', 'NewSignature10'");
4508 add_appsearch_entry(hdb
, "'SIGPROP11', 'NewSignature11'");
4509 add_appsearch_entry(hdb
, "'SIGPROP12', 'NewSignature12'");
4510 add_appsearch_entry(hdb
, "'SIGPROP13', 'NewSignature13'");
4511 add_appsearch_entry(hdb
, "'SIGPROP14', 'NewSignature14'");
4512 add_appsearch_entry(hdb
, "'SIGPROP15', 'NewSignature15'");
4513 add_appsearch_entry(hdb
, "'SIGPROP16', 'NewSignature16'");
4514 add_appsearch_entry(hdb
, "'SIGPROP17', 'NewSignature17'");
4515 add_appsearch_entry(hdb
, "'SIGPROP18', 'NewSignature18'");
4516 add_appsearch_entry(hdb
, "'SIGPROP19', 'NewSignature19'");
4517 add_appsearch_entry(hdb
, "'SIGPROP20', 'NewSignature20'");
4518 add_appsearch_entry(hdb
, "'SIGPROP21', 'NewSignature21'");
4519 add_appsearch_entry(hdb
, "'SIGPROP22', 'NewSignature22'");
4520 add_appsearch_entry(hdb
, "'SIGPROP23', 'NewSignature23'");
4521 add_appsearch_entry(hdb
, "'SIGPROP24', 'NewSignature24'");
4522 add_appsearch_entry(hdb
, "'SIGPROP25', 'NewSignature25'");
4523 add_appsearch_entry(hdb
, "'SIGPROP26', 'NewSignature26'");
4524 add_appsearch_entry(hdb
, "'SIGPROP27', 'NewSignature27'");
4525 add_appsearch_entry(hdb
, "'SIGPROP28', 'NewSignature28'");
4526 add_appsearch_entry(hdb
, "'SIGPROP29', 'NewSignature29'");
4527 add_appsearch_entry(hdb
, "'SIGPROP30', 'NewSignature30'");
4529 create_reglocator_table(hdb
);
4531 type
= msidbLocatorTypeRawValue
;
4533 type
|= msidbLocatorType64bit
;
4535 /* HKLM, msidbLocatorTypeRawValue, REG_SZ */
4536 add_reglocator_entry(hdb
, "NewSignature1", 2, "Software\\Wine", "Value1", type
);
4538 /* HKLM, msidbLocatorTypeRawValue, positive DWORD */
4539 add_reglocator_entry(hdb
, "NewSignature2", 2, "Software\\Wine", "Value2", type
);
4541 /* HKLM, msidbLocatorTypeRawValue, negative DWORD */
4542 add_reglocator_entry(hdb
, "NewSignature3", 2, "Software\\Wine", "Value3", type
);
4544 /* HKLM, msidbLocatorTypeRawValue, REG_EXPAND_SZ */
4545 add_reglocator_entry(hdb
, "NewSignature4", 2, "Software\\Wine", "Value4", type
);
4547 /* HKLM, msidbLocatorTypeRawValue, REG_EXPAND_SZ */
4548 add_reglocator_entry(hdb
, "NewSignature5", 2, "Software\\Wine", "Value5", type
);
4550 /* HKLM, msidbLocatorTypeRawValue, REG_MULTI_SZ */
4551 add_reglocator_entry(hdb
, "NewSignature6", 2, "Software\\Wine", "Value6", type
);
4553 /* HKLM, msidbLocatorTypeRawValue, REG_BINARY */
4554 add_reglocator_entry(hdb
, "NewSignature7", 2, "Software\\Wine", "Value7", type
);
4556 /* HKLM, msidbLocatorTypeRawValue, REG_SZ first char is # */
4557 add_reglocator_entry(hdb
, "NewSignature8", 2, "Software\\Wine", "Value8", type
);
4559 type
= msidbLocatorTypeFileName
;
4561 type
|= msidbLocatorType64bit
;
4563 /* HKLM, msidbLocatorTypeFileName, signature, file exists */
4564 add_reglocator_entry(hdb
, "NewSignature9", 2, "Software\\Wine", "Value9", type
);
4566 /* HKLM, msidbLocatorTypeFileName, signature, file does not exist */
4567 add_reglocator_entry(hdb
, "NewSignature10", 2, "Software\\Wine", "Value10", type
);
4569 /* HKLM, msidbLocatorTypeFileName, no signature */
4570 add_reglocator_entry(hdb
, "NewSignature11", 2, "Software\\Wine", "Value9", type
);
4572 type
= msidbLocatorTypeDirectory
;
4574 type
|= msidbLocatorType64bit
;
4576 /* HKLM, msidbLocatorTypeDirectory, no signature, file exists */
4577 add_reglocator_entry(hdb
, "NewSignature12", 2, "Software\\Wine", "Value9", type
);
4579 /* HKLM, msidbLocatorTypeDirectory, no signature, directory exists */
4580 add_reglocator_entry(hdb
, "NewSignature13", 2, "Software\\Wine", "Value11", type
);
4582 /* HKLM, msidbLocatorTypeDirectory, signature, file exists */
4583 add_reglocator_entry(hdb
, "NewSignature14", 2, "Software\\Wine", "Value9", type
);
4585 type
= msidbLocatorTypeRawValue
;
4587 type
|= msidbLocatorType64bit
;
4589 /* HKCR, msidbLocatorTypeRawValue, REG_SZ */
4590 add_reglocator_entry(hdb
, "NewSignature15", 0, "Software\\Wine", "Value1", type
);
4592 /* HKCU, msidbLocatorTypeRawValue, REG_SZ */
4593 add_reglocator_entry(hdb
, "NewSignature16", 1, "Software\\Wine", "Value1", type
);
4595 /* HKU, msidbLocatorTypeRawValue, REG_SZ */
4596 add_reglocator_entry(hdb
, "NewSignature17", 3, "S-1-5-18\\Software\\Wine", "Value1", type
);
4598 /* HKLM, msidbLocatorTypeRawValue, REG_SZ, NULL Name */
4599 add_reglocator_entry(hdb
, "NewSignature18", 2, "Software\\Wine", "", type
);
4601 /* HKLM, msidbLocatorTypeRawValue, REG_SZ, key does not exist */
4602 add_reglocator_entry(hdb
, "NewSignature19", 2, "Software\\IDontExist", "", type
);
4604 /* HKLM, msidbLocatorTypeRawValue, REG_SZ, value is empty */
4605 add_reglocator_entry(hdb
, "NewSignature20", 2, "Software\\Wine", "Value12", type
);
4607 type
= msidbLocatorTypeFileName
;
4609 type
|= msidbLocatorType64bit
;
4611 /* HKLM, msidbLocatorTypeFileName, signature, file exists w/ version */
4612 add_reglocator_entry(hdb
, "NewSignature21", 2, "Software\\Wine", "Value13", type
);
4614 /* HKLM, msidbLocatorTypeFileName, file exists w/ version, version > max */
4615 add_reglocator_entry(hdb
, "NewSignature22", 2, "Software\\Wine", "Value14", type
);
4617 /* HKLM, msidbLocatorTypeFileName, file exists w/ version, sig->name ignored */
4618 add_reglocator_entry(hdb
, "NewSignature23", 2, "Software\\Wine", "Value15", type
);
4620 /* HKLM, msidbLocatorTypeFileName, no signature, directory exists */
4621 add_reglocator_entry(hdb
, "NewSignature24", 2, "Software\\Wine", "Value11", type
);
4623 /* HKLM, msidbLocatorTypeFileName, no signature, file does not exist */
4624 add_reglocator_entry(hdb
, "NewSignature25", 2, "Software\\Wine", "Value10", type
);
4626 type
= msidbLocatorTypeDirectory
;
4628 type
|= msidbLocatorType64bit
;
4630 /* HKLM, msidbLocatorTypeDirectory, signature, directory exists */
4631 add_reglocator_entry(hdb
, "NewSignature26", 2, "Software\\Wine", "Value11", type
);
4633 /* HKLM, msidbLocatorTypeDirectory, signature, file does not exist */
4634 add_reglocator_entry(hdb
, "NewSignature27", 2, "Software\\Wine", "Value10", type
);
4636 /* HKLM, msidbLocatorTypeDirectory, no signature, file does not exist */
4637 add_reglocator_entry(hdb
, "NewSignature28", 2, "Software\\Wine", "Value10", type
);
4639 type
= msidbLocatorTypeFileName
;
4641 type
|= msidbLocatorType64bit
;
4643 /* HKLM, msidbLocatorTypeFile, file exists, in quotes */
4644 add_reglocator_entry(hdb
, "NewSignature29", 2, "Software\\Wine", "Value16", type
);
4646 /* HKLM, msidbLocatorTypeFile, file exists, no quotes */
4647 add_reglocator_entry(hdb
, "NewSignature30", 2, "Software\\Wine", "Value17", type
);
4649 create_signature_table(hdb
);
4650 add_signature_entry(hdb
, "'NewSignature9', 'FileName1', '', '', '', '', '', '', ''");
4651 add_signature_entry(hdb
, "'NewSignature10', 'FileName2', '', '', '', '', '', '', ''");
4652 add_signature_entry(hdb
, "'NewSignature14', 'FileName1', '', '', '', '', '', '', ''");
4653 add_signature_entry(hdb
, "'NewSignature21', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
4654 add_signature_entry(hdb
, "'NewSignature22', 'FileName4.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
4655 add_signature_entry(hdb
, "'NewSignature23', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
4657 if (!is_root(CURR_DIR
))
4659 ptr
= strrchr(expected
, '\\') + 1;
4660 sprintf(path
, "'NewSignature26', '%s', '', '', '', '', '', '', ''", ptr
);
4661 add_signature_entry(hdb
, path
);
4663 add_signature_entry(hdb
, "'NewSignature27', 'FileName2', '', '', '', '', '', '', ''");
4664 add_signature_entry(hdb
, "'NewSignature29', 'FileName1', '', '', '', '', '', '', ''");
4665 add_signature_entry(hdb
, "'NewSignature30', 'FileName1', '', '', '', '', '', '', ''");
4667 r
= package_from_db(hdb
, &hpkg
);
4668 ok(r
== ERROR_SUCCESS
, "Expected a valid package handle %u\n", r
);
4670 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
4672 r
= MsiDoActionA(hpkg
, "AppSearch");
4673 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4676 r
= MsiGetPropertyA(hpkg
, "SIGPROP1", prop
, &size
);
4677 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4678 ok(!lstrcmpA(prop
, "regszdata"),
4679 "Expected \"regszdata\", got \"%s\"\n", prop
);
4682 r
= MsiGetPropertyA(hpkg
, "SIGPROP2", prop
, &size
);
4683 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4684 ok(!lstrcmpA(prop
, "#42"), "Expected \"#42\", got \"%s\"\n", prop
);
4687 r
= MsiGetPropertyA(hpkg
, "SIGPROP3", prop
, &size
);
4688 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4689 ok(!lstrcmpA(prop
, "#-42"), "Expected \"#-42\", got \"%s\"\n", prop
);
4691 memset(&si
, 0, sizeof(si
));
4692 if (pGetNativeSystemInfo
) pGetNativeSystemInfo(&si
);
4694 if (S(U(si
)).wProcessorArchitecture
== PROCESSOR_ARCHITECTURE_INTEL
)
4696 size
= ExpandEnvironmentStringsA("%PATH%", NULL
, 0);
4697 pathvar
= HeapAlloc(GetProcessHeap(), 0, size
);
4698 ExpandEnvironmentStringsA("%PATH%", pathvar
, size
);
4701 r
= MsiGetPropertyA(hpkg
, "SIGPROP4", NULL
, &size
);
4702 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4704 pathdata
= HeapAlloc(GetProcessHeap(), 0, ++size
);
4705 r
= MsiGetPropertyA(hpkg
, "SIGPROP4", pathdata
, &size
);
4706 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4707 ok(!lstrcmpA(pathdata
, pathvar
),
4708 "Expected \"%s\", got \"%s\"\n", pathvar
, pathdata
);
4710 HeapFree(GetProcessHeap(), 0, pathvar
);
4711 HeapFree(GetProcessHeap(), 0, pathdata
);
4715 r
= MsiGetPropertyA(hpkg
, "SIGPROP5", prop
, &size
);
4716 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4718 "my%NOVAR%"), "Expected \"my%%NOVAR%%\", got \"%s\"\n", prop
);
4721 r
= MsiGetPropertyA(hpkg
, "SIGPROP6", prop
, &size
);
4722 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4725 ok(!memcmp(prop
, "\0one\0two\0\0", 10),
4726 "Expected \"\\0one\\0two\\0\\0\"\n");
4730 lstrcpyA(path
, "#xCDAB3412EF907856");
4731 r
= MsiGetPropertyA(hpkg
, "SIGPROP7", prop
, &size
);
4732 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4733 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4736 r
= MsiGetPropertyA(hpkg
, "SIGPROP8", 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
);
4742 sprintf(path
, "%s\\FileName1", expected
);
4743 r
= MsiGetPropertyA(hpkg
, "SIGPROP9", prop
, &size
);
4744 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4745 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4748 r
= MsiGetPropertyA(hpkg
, "SIGPROP10", prop
, &size
);
4749 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4750 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4753 sprintf(path
, "%s\\", expected
);
4754 r
= MsiGetPropertyA(hpkg
, "SIGPROP11", prop
, &size
);
4755 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4756 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4759 r
= MsiGetPropertyA(hpkg
, "SIGPROP12", prop
, &size
);
4760 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4761 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4764 sprintf(path
, "%s\\", expected
);
4765 r
= MsiGetPropertyA(hpkg
, "SIGPROP13", prop
, &size
);
4766 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4767 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4770 r
= MsiGetPropertyA(hpkg
, "SIGPROP14", prop
, &size
);
4771 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4772 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4775 r
= MsiGetPropertyA(hpkg
, "SIGPROP15", prop
, &size
);
4776 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4777 ok(!lstrcmpA(prop
, "regszdata"),
4778 "Expected \"regszdata\", got \"%s\"\n", prop
);
4781 r
= MsiGetPropertyA(hpkg
, "SIGPROP16", prop
, &size
);
4782 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4783 ok(!lstrcmpA(prop
, "regszdata"),
4784 "Expected \"regszdata\", got \"%s\"\n", prop
);
4789 r
= MsiGetPropertyA(hpkg
, "SIGPROP17", prop
, &size
);
4790 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4791 ok(!lstrcmpA(prop
, "regszdata"),
4792 "Expected \"regszdata\", got \"%s\"\n", prop
);
4796 r
= MsiGetPropertyA(hpkg
, "SIGPROP18", prop
, &size
);
4797 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4798 ok(!lstrcmpA(prop
, "defvalue"),
4799 "Expected \"defvalue\", got \"%s\"\n", prop
);
4802 r
= MsiGetPropertyA(hpkg
, "SIGPROP19", prop
, &size
);
4803 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4804 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4807 r
= MsiGetPropertyA(hpkg
, "SIGPROP20", prop
, &size
);
4808 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4809 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4814 sprintf(path
, "%s\\FileName3.dll", expected
);
4815 r
= MsiGetPropertyA(hpkg
, "SIGPROP21", prop
, &size
);
4816 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4817 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4820 r
= MsiGetPropertyA(hpkg
, "SIGPROP22", prop
, &size
);
4821 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4822 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4825 sprintf(path
, "%s\\FileName5.dll", expected
);
4826 r
= MsiGetPropertyA(hpkg
, "SIGPROP23", prop
, &size
);
4827 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4828 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4831 if (!is_root(CURR_DIR
))
4834 lstrcpyA(path
, expected
);
4835 ptr
= strrchr(path
, '\\') + 1;
4837 r
= MsiGetPropertyA(hpkg
, "SIGPROP24", prop
, &size
);
4838 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4839 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4842 sprintf(path
, "%s\\", expected
);
4843 r
= MsiGetPropertyA(hpkg
, "SIGPROP25", prop
, &size
);
4844 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4845 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4848 r
= MsiGetPropertyA(hpkg
, "SIGPROP26", prop
, &size
);
4849 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4850 if (is_root(CURR_DIR
))
4851 ok(!lstrcmpA(prop
, CURR_DIR
), "Expected \"%s\", got \"%s\"\n", CURR_DIR
, prop
);
4853 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4856 r
= MsiGetPropertyA(hpkg
, "SIGPROP27", prop
, &size
);
4857 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4858 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4861 r
= MsiGetPropertyA(hpkg
, "SIGPROP28", prop
, &size
);
4862 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4863 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4866 sprintf(path
, "%s\\FileName1", expected
);
4867 r
= MsiGetPropertyA(hpkg
, "SIGPROP29", prop
, &size
);
4868 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4869 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4872 sprintf(path
, "%s\\FileName1", expected
);
4873 r
= MsiGetPropertyA(hpkg
, "SIGPROP30", prop
, &size
);
4874 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4876 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4878 todo_wine
ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4880 RegSetValueA(hklm
, NULL
, REG_SZ
, "", 0);
4881 RegDeleteValueA(hklm
, "Value1");
4882 RegDeleteValueA(hklm
, "Value2");
4883 RegDeleteValueA(hklm
, "Value3");
4884 RegDeleteValueA(hklm
, "Value4");
4885 RegDeleteValueA(hklm
, "Value5");
4886 RegDeleteValueA(hklm
, "Value6");
4887 RegDeleteValueA(hklm
, "Value7");
4888 RegDeleteValueA(hklm
, "Value8");
4889 RegDeleteValueA(hklm
, "Value9");
4890 RegDeleteValueA(hklm
, "Value10");
4891 RegDeleteValueA(hklm
, "Value11");
4892 RegDeleteValueA(hklm
, "Value12");
4893 RegDeleteValueA(hklm
, "Value13");
4894 RegDeleteValueA(hklm
, "Value14");
4895 RegDeleteValueA(hklm
, "Value15");
4896 RegDeleteValueA(hklm
, "Value16");
4897 RegDeleteValueA(hklm
, "Value17");
4898 RegDeleteKeyA(hklm
, "");
4901 RegDeleteValueA(classes
, "Value1");
4902 RegDeleteKeyA(classes
, "");
4903 RegCloseKey(classes
);
4905 RegDeleteValueA(hkcu
, "Value1");
4906 RegDeleteKeyA(hkcu
, "");
4909 RegDeleteValueA(users
, "Value1");
4910 RegDeleteKeyA(users
, "");
4913 DeleteFileA("FileName1");
4914 DeleteFileA("FileName3.dll");
4915 DeleteFileA("FileName4.dll");
4916 DeleteFileA("FileName5.dll");
4917 MsiCloseHandle(hpkg
);
4918 DeleteFileA(msifile
);
4921 static void delete_win_ini(LPCSTR file
)
4923 CHAR path
[MAX_PATH
];
4925 GetWindowsDirectoryA(path
, MAX_PATH
);
4926 lstrcatA(path
, "\\");
4927 lstrcatA(path
, file
);
4932 static void test_appsearch_inilocator(void)
4934 MSIHANDLE hpkg
, hdb
;
4935 char path
[MAX_PATH
], expected
[MAX_PATH
], prop
[MAX_PATH
];
4942 if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
4945 DeleteFileA("test.dll");
4947 WritePrivateProfileStringA("Section", "Key", "keydata,field2", "IniFile.ini");
4949 strcpy(expected
, CURR_DIR
);
4950 if (is_root(CURR_DIR
)) expected
[2] = 0;
4952 create_test_file("FileName1");
4953 sprintf(path
, "%s\\FileName1", expected
);
4954 WritePrivateProfileStringA("Section", "Key2", path
, "IniFile.ini");
4956 WritePrivateProfileStringA("Section", "Key3", expected
, "IniFile.ini");
4958 sprintf(path
, "%s\\IDontExist", expected
);
4959 WritePrivateProfileStringA("Section", "Key4", path
, "IniFile.ini");
4961 create_file_with_version("FileName2.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4962 sprintf(path
, "%s\\FileName2.dll", expected
);
4963 WritePrivateProfileStringA("Section", "Key5", path
, "IniFile.ini");
4965 create_file_with_version("FileName3.dll", MAKELONG(1, 2), MAKELONG(3, 4));
4966 sprintf(path
, "%s\\FileName3.dll", expected
);
4967 WritePrivateProfileStringA("Section", "Key6", path
, "IniFile.ini");
4969 create_file_with_version("FileName4.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4970 sprintf(path
, "%s\\FileName4.dll", expected
);
4971 WritePrivateProfileStringA("Section", "Key7", path
, "IniFile.ini");
4973 hdb
= create_package_db();
4974 ok(hdb
, "Expected a valid database handle\n");
4976 create_appsearch_table(hdb
);
4977 add_appsearch_entry(hdb
, "'SIGPROP1', 'NewSignature1'");
4978 add_appsearch_entry(hdb
, "'SIGPROP2', 'NewSignature2'");
4979 add_appsearch_entry(hdb
, "'SIGPROP3', 'NewSignature3'");
4980 add_appsearch_entry(hdb
, "'SIGPROP4', 'NewSignature4'");
4981 add_appsearch_entry(hdb
, "'SIGPROP5', 'NewSignature5'");
4982 add_appsearch_entry(hdb
, "'SIGPROP6', 'NewSignature6'");
4983 add_appsearch_entry(hdb
, "'SIGPROP7', 'NewSignature7'");
4984 add_appsearch_entry(hdb
, "'SIGPROP8', 'NewSignature8'");
4985 add_appsearch_entry(hdb
, "'SIGPROP9', 'NewSignature9'");
4986 add_appsearch_entry(hdb
, "'SIGPROP10', 'NewSignature10'");
4987 add_appsearch_entry(hdb
, "'SIGPROP11', 'NewSignature11'");
4988 add_appsearch_entry(hdb
, "'SIGPROP12', 'NewSignature12'");
4990 create_inilocator_table(hdb
);
4992 /* msidbLocatorTypeRawValue, field 1 */
4993 add_inilocator_entry(hdb
, "'NewSignature1', 'IniFile.ini', 'Section', 'Key', 1, 2");
4995 /* msidbLocatorTypeRawValue, field 2 */
4996 add_inilocator_entry(hdb
, "'NewSignature2', 'IniFile.ini', 'Section', 'Key', 2, 2");
4998 /* msidbLocatorTypeRawValue, entire field */
4999 add_inilocator_entry(hdb
, "'NewSignature3', 'IniFile.ini', 'Section', 'Key', 0, 2");
5001 /* msidbLocatorTypeFile */
5002 add_inilocator_entry(hdb
, "'NewSignature4', 'IniFile.ini', 'Section', 'Key2', 1, 1");
5004 /* msidbLocatorTypeDirectory, file */
5005 add_inilocator_entry(hdb
, "'NewSignature5', 'IniFile.ini', 'Section', 'Key2', 1, 0");
5007 /* msidbLocatorTypeDirectory, directory */
5008 add_inilocator_entry(hdb
, "'NewSignature6', 'IniFile.ini', 'Section', 'Key3', 1, 0");
5010 /* msidbLocatorTypeFile, file, no signature */
5011 add_inilocator_entry(hdb
, "'NewSignature7', 'IniFile.ini', 'Section', 'Key2', 1, 1");
5013 /* msidbLocatorTypeFile, dir, no signature */
5014 add_inilocator_entry(hdb
, "'NewSignature8', 'IniFile.ini', 'Section', 'Key3', 1, 1");
5016 /* msidbLocatorTypeFile, file does not exist */
5017 add_inilocator_entry(hdb
, "'NewSignature9', 'IniFile.ini', 'Section', 'Key4', 1, 1");
5019 /* msidbLocatorTypeFile, signature with version */
5020 add_inilocator_entry(hdb
, "'NewSignature10', 'IniFile.ini', 'Section', 'Key5', 1, 1");
5022 /* msidbLocatorTypeFile, signature with version, ver > max */
5023 add_inilocator_entry(hdb
, "'NewSignature11', 'IniFile.ini', 'Section', 'Key6', 1, 1");
5025 /* msidbLocatorTypeFile, signature with version, sig->name ignored */
5026 add_inilocator_entry(hdb
, "'NewSignature12', 'IniFile.ini', 'Section', 'Key7', 1, 1");
5028 create_signature_table(hdb
);
5029 add_signature_entry(hdb
, "'NewSignature4', 'FileName1', '', '', '', '', '', '', ''");
5030 add_signature_entry(hdb
, "'NewSignature9', 'IDontExist', '', '', '', '', '', '', ''");
5031 add_signature_entry(hdb
, "'NewSignature10', 'FileName2.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
5032 add_signature_entry(hdb
, "'NewSignature11', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
5033 add_signature_entry(hdb
, "'NewSignature12', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
5035 r
= package_from_db(hdb
, &hpkg
);
5036 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
5038 skip("Not enough rights to perform tests\n");
5041 ok(r
== ERROR_SUCCESS
, "Expected a valid package handle %u\n", r
);
5043 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
5045 r
= MsiDoActionA(hpkg
, "AppSearch");
5046 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5049 r
= MsiGetPropertyA(hpkg
, "SIGPROP1", prop
, &size
);
5050 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5051 ok(!lstrcmpA(prop
, "keydata"), "Expected \"keydata\", got \"%s\"\n", prop
);
5054 r
= MsiGetPropertyA(hpkg
, "SIGPROP2", prop
, &size
);
5055 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5056 ok(!lstrcmpA(prop
, "field2"), "Expected \"field2\", got \"%s\"\n", prop
);
5059 r
= MsiGetPropertyA(hpkg
, "SIGPROP3", prop
, &size
);
5060 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5061 ok(!lstrcmpA(prop
, "keydata,field2"),
5062 "Expected \"keydata,field2\", got \"%s\"\n", prop
);
5065 sprintf(path
, "%s\\FileName1", expected
);
5066 r
= MsiGetPropertyA(hpkg
, "SIGPROP4", prop
, &size
);
5067 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5068 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5071 r
= MsiGetPropertyA(hpkg
, "SIGPROP5", prop
, &size
);
5072 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5073 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
5076 sprintf(path
, "%s\\", expected
);
5077 r
= MsiGetPropertyA(hpkg
, "SIGPROP6", prop
, &size
);
5078 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5079 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5082 sprintf(path
, "%s\\", expected
);
5083 r
= MsiGetPropertyA(hpkg
, "SIGPROP7", prop
, &size
);
5084 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5085 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5087 if (!is_root(CURR_DIR
))
5090 lstrcpyA(path
, expected
);
5091 ptr
= strrchr(path
, '\\');
5093 r
= MsiGetPropertyA(hpkg
, "SIGPROP8", prop
, &size
);
5094 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5095 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5098 r
= MsiGetPropertyA(hpkg
, "SIGPROP9", prop
, &size
);
5099 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5100 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
5105 sprintf(path
, "%s\\FileName2.dll", expected
);
5106 r
= MsiGetPropertyA(hpkg
, "SIGPROP10", prop
, &size
);
5107 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5108 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5111 r
= MsiGetPropertyA(hpkg
, "SIGPROP11", prop
, &size
);
5112 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5113 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
5116 sprintf(path
, "%s\\FileName4.dll", expected
);
5117 r
= MsiGetPropertyA(hpkg
, "SIGPROP12", prop
, &size
);
5118 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5119 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5122 MsiCloseHandle(hpkg
);
5125 delete_win_ini("IniFile.ini");
5126 DeleteFileA("FileName1");
5127 DeleteFileA("FileName2.dll");
5128 DeleteFileA("FileName3.dll");
5129 DeleteFileA("FileName4.dll");
5130 DeleteFileA(msifile
);
5134 * MSI AppSearch action on DrLocator table always returns absolute paths.
5135 * If a relative path was set, it returns the first absolute path that
5136 * matches or an empty string if it didn't find anything.
5137 * This helper function replicates this behaviour.
5139 static void search_absolute_directory(LPSTR absolute
, LPCSTR relative
)
5144 size
= lstrlenA(relative
);
5145 drives
= GetLogicalDrives();
5146 lstrcpyA(absolute
, "A:\\");
5147 for (i
= 0; i
< 26; absolute
[0] = '\0', i
++)
5149 if (!(drives
& (1 << i
)))
5152 absolute
[0] = 'A' + i
;
5153 if (GetDriveTypeA(absolute
) != DRIVE_FIXED
)
5156 lstrcpynA(absolute
+ 3, relative
, size
+ 1);
5157 attr
= GetFileAttributesA(absolute
);
5158 if (attr
!= INVALID_FILE_ATTRIBUTES
&&
5159 (attr
& FILE_ATTRIBUTE_DIRECTORY
))
5161 if (absolute
[3 + size
- 1] != '\\')
5162 lstrcatA(absolute
, "\\");
5169 static void test_appsearch_drlocator(void)
5171 MSIHANDLE hpkg
, hdb
;
5172 char path
[MAX_PATH
], expected
[MAX_PATH
], prop
[MAX_PATH
];
5178 if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
5181 DeleteFileA("test.dll");
5183 create_test_file("FileName1");
5184 CreateDirectoryA("one", NULL
);
5185 CreateDirectoryA("one\\two", NULL
);
5186 CreateDirectoryA("one\\two\\three", NULL
);
5187 create_test_file("one\\two\\three\\FileName2");
5188 CreateDirectoryA("another", NULL
);
5189 create_file_with_version("FileName3.dll", MAKELONG(2, 1), MAKELONG(4, 3));
5190 create_file_with_version("FileName4.dll", MAKELONG(1, 2), MAKELONG(3, 4));
5191 create_file_with_version("FileName5.dll", MAKELONG(2, 1), MAKELONG(4, 3));
5193 hdb
= create_package_db();
5194 ok(hdb
, "Expected a valid database handle\n");
5196 create_appsearch_table(hdb
);
5197 add_appsearch_entry(hdb
, "'SIGPROP1', 'NewSignature1'");
5198 add_appsearch_entry(hdb
, "'SIGPROP2', 'NewSignature2'");
5199 add_appsearch_entry(hdb
, "'SIGPROP3', 'NewSignature3'");
5200 add_appsearch_entry(hdb
, "'SIGPROP4', 'NewSignature4'");
5201 add_appsearch_entry(hdb
, "'SIGPROP5', 'NewSignature5'");
5202 add_appsearch_entry(hdb
, "'SIGPROP6', 'NewSignature6'");
5203 add_appsearch_entry(hdb
, "'SIGPROP7', 'NewSignature7'");
5204 add_appsearch_entry(hdb
, "'SIGPROP8', 'NewSignature8'");
5205 add_appsearch_entry(hdb
, "'SIGPROP9', 'NewSignature9'");
5206 add_appsearch_entry(hdb
, "'SIGPROP10', 'NewSignature10'");
5207 add_appsearch_entry(hdb
, "'SIGPROP11', 'NewSignature11'");
5208 add_appsearch_entry(hdb
, "'SIGPROP13', 'NewSignature13'");
5210 create_drlocator_table(hdb
);
5212 strcpy(expected
, CURR_DIR
);
5213 if (is_root(CURR_DIR
)) expected
[2] = 0;
5215 /* no parent, full path, depth 0, signature */
5216 sprintf(path
, "'NewSignature1', '', '%s', 0", expected
);
5217 add_drlocator_entry(hdb
, path
);
5219 /* no parent, full path, depth 0, no signature */
5220 sprintf(path
, "'NewSignature2', '', '%s', 0", expected
);
5221 add_drlocator_entry(hdb
, path
);
5223 /* no parent, relative path, depth 0, no signature */
5224 sprintf(path
, "'NewSignature3', '', '%s', 0", expected
+ 3);
5225 add_drlocator_entry(hdb
, path
);
5227 /* no parent, full path, depth 2, signature */
5228 sprintf(path
, "'NewSignature4', '', '%s', 2", expected
);
5229 add_drlocator_entry(hdb
, path
);
5231 /* no parent, full path, depth 3, signature */
5232 sprintf(path
, "'NewSignature5', '', '%s', 3", expected
);
5233 add_drlocator_entry(hdb
, path
);
5235 /* no parent, full path, depth 1, signature is dir */
5236 sprintf(path
, "'NewSignature6', '', '%s', 1", expected
);
5237 add_drlocator_entry(hdb
, path
);
5239 /* parent is in DrLocator, relative path, depth 0, signature */
5240 sprintf(path
, "'NewSignature7', 'NewSignature1', 'one\\two\\three', 1");
5241 add_drlocator_entry(hdb
, path
);
5243 /* no parent, full path, depth 0, signature w/ version */
5244 sprintf(path
, "'NewSignature8', '', '%s', 0", expected
);
5245 add_drlocator_entry(hdb
, path
);
5247 /* no parent, full path, depth 0, signature w/ version, ver > max */
5248 sprintf(path
, "'NewSignature9', '', '%s', 0", expected
);
5249 add_drlocator_entry(hdb
, path
);
5251 /* no parent, full path, depth 0, signature w/ version, sig->name not ignored */
5252 sprintf(path
, "'NewSignature10', '', '%s', 0", expected
);
5253 add_drlocator_entry(hdb
, path
);
5255 /* no parent, relative empty path, depth 0, no signature */
5256 sprintf(path
, "'NewSignature11', '', '', 0");
5257 add_drlocator_entry(hdb
, path
);
5259 create_reglocator_table(hdb
);
5262 add_reglocator_entry(hdb
, "NewSignature12", 2, "htmlfile\\shell\\open\\nonexistent", "", 1);
5264 /* parent is in RegLocator, no path, depth 0, no signature */
5265 sprintf(path
, "'NewSignature13', 'NewSignature12', '', 0");
5266 add_drlocator_entry(hdb
, path
);
5268 create_signature_table(hdb
);
5269 add_signature_entry(hdb
, "'NewSignature1', 'FileName1', '', '', '', '', '', '', ''");
5270 add_signature_entry(hdb
, "'NewSignature4', 'FileName2', '', '', '', '', '', '', ''");
5271 add_signature_entry(hdb
, "'NewSignature5', 'FileName2', '', '', '', '', '', '', ''");
5272 add_signature_entry(hdb
, "'NewSignature6', 'another', '', '', '', '', '', '', ''");
5273 add_signature_entry(hdb
, "'NewSignature7', 'FileName2', '', '', '', '', '', '', ''");
5274 add_signature_entry(hdb
, "'NewSignature8', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
5275 add_signature_entry(hdb
, "'NewSignature9', 'FileName4.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
5276 add_signature_entry(hdb
, "'NewSignature10', 'necessary', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
5278 r
= package_from_db(hdb
, &hpkg
);
5279 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
5281 skip("Not enough rights to perform tests\n");
5284 ok(r
== ERROR_SUCCESS
, "Expected a valid package handle %u\n", r
);
5286 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
5288 r
= MsiDoActionA(hpkg
, "AppSearch");
5289 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5292 sprintf(path
, "%s\\FileName1", expected
);
5293 r
= MsiGetPropertyA(hpkg
, "SIGPROP1", prop
, &size
);
5294 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5295 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5298 sprintf(path
, "%s\\", expected
);
5299 r
= MsiGetPropertyA(hpkg
, "SIGPROP2", prop
, &size
);
5300 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5301 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5304 search_absolute_directory(path
, expected
+ 3);
5305 r
= MsiGetPropertyA(hpkg
, "SIGPROP3", prop
, &size
);
5306 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5307 ok(!lstrcmpiA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5310 r
= MsiGetPropertyA(hpkg
, "SIGPROP4", prop
, &size
);
5311 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5312 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
5315 sprintf(path
, "%s\\one\\two\\three\\FileName2", expected
);
5316 r
= MsiGetPropertyA(hpkg
, "SIGPROP5", prop
, &size
);
5317 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5318 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5321 r
= MsiGetPropertyA(hpkg
, "SIGPROP6", prop
, &size
);
5322 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5323 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
5326 sprintf(path
, "%s\\one\\two\\three\\FileName2", expected
);
5327 r
= MsiGetPropertyA(hpkg
, "SIGPROP7", prop
, &size
);
5328 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5329 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5334 sprintf(path
, "%s\\FileName3.dll", expected
);
5335 r
= MsiGetPropertyA(hpkg
, "SIGPROP8", prop
, &size
);
5336 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5337 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5340 r
= MsiGetPropertyA(hpkg
, "SIGPROP9", prop
, &size
);
5341 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5342 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
5345 r
= MsiGetPropertyA(hpkg
, "SIGPROP10", prop
, &size
);
5346 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5347 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
5351 search_absolute_directory(path
, "");
5352 r
= MsiGetPropertyA(hpkg
, "SIGPROP11", prop
, &size
);
5353 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5354 ok(!lstrcmpiA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5357 strcpy(path
, "c:\\");
5358 r
= MsiGetPropertyA(hpkg
, "SIGPROP13", prop
, &size
);
5359 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5360 ok(!prop
[0], "Expected \"\", got \"%s\"\n", prop
);
5362 MsiCloseHandle(hpkg
);
5365 DeleteFileA("FileName1");
5366 DeleteFileA("FileName3.dll");
5367 DeleteFileA("FileName4.dll");
5368 DeleteFileA("FileName5.dll");
5369 DeleteFileA("one\\two\\three\\FileName2");
5370 RemoveDirectoryA("one\\two\\three");
5371 RemoveDirectoryA("one\\two");
5372 RemoveDirectoryA("one");
5373 RemoveDirectoryA("another");
5374 DeleteFileA(msifile
);
5377 static void test_featureparents(void)
5383 hdb
= create_package_db();
5384 ok ( hdb
, "failed to create package database\n" );
5386 add_directory_entry(hdb
, "'TARGETDIR', '', 'SourceDir'");
5388 create_feature_table( hdb
);
5389 create_component_table( hdb
);
5390 create_feature_components_table( hdb
);
5391 create_file_table( hdb
);
5393 /* msidbFeatureAttributesFavorLocal */
5394 add_feature_entry( hdb
, "'zodiac', '', '', '', 2, 1, '', 0" );
5396 /* msidbFeatureAttributesFavorSource */
5397 add_feature_entry( hdb
, "'perseus', '', '', '', 2, 1, '', 1" );
5399 /* msidbFeatureAttributesFavorLocal */
5400 add_feature_entry( hdb
, "'orion', '', '', '', 2, 1, '', 0" );
5402 /* msidbFeatureAttributesUIDisallowAbsent */
5403 add_feature_entry( hdb
, "'lyra', '', '', '', 2, 1, '', 16" );
5405 /* disabled because of install level */
5406 add_feature_entry( hdb
, "'waters', '', '', '', 15, 101, '', 9" );
5408 /* child feature of disabled feature */
5409 add_feature_entry( hdb
, "'bayer', 'waters', '', '', 14, 1, '', 9" );
5411 /* component of disabled feature (install level) */
5412 add_component_entry( hdb
, "'delphinus', '', 'TARGETDIR', 0, '', 'delphinus_file'" );
5414 /* component of disabled child feature (install level) */
5415 add_component_entry( hdb
, "'hydrus', '', 'TARGETDIR', 0, '', 'hydrus_file'" );
5417 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
5418 add_component_entry( hdb
, "'leo', '', 'TARGETDIR', 0, '', 'leo_file'" );
5420 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
5421 add_component_entry( hdb
, "'virgo', '', 'TARGETDIR', 1, '', 'virgo_file'" );
5423 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
5424 add_component_entry( hdb
, "'libra', '', 'TARGETDIR', 2, '', 'libra_file'" );
5426 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
5427 add_component_entry( hdb
, "'cassiopeia', '', 'TARGETDIR', 0, '', 'cassiopeia_file'" );
5429 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
5430 add_component_entry( hdb
, "'cepheus', '', 'TARGETDIR', 1, '', 'cepheus_file'" );
5432 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
5433 add_component_entry( hdb
, "'andromeda', '', 'TARGETDIR', 2, '', 'andromeda_file'" );
5435 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
5436 add_component_entry( hdb
, "'canis', '', 'TARGETDIR', 0, '', 'canis_file'" );
5438 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
5439 add_component_entry( hdb
, "'monoceros', '', 'TARGETDIR', 1, '', 'monoceros_file'" );
5441 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
5442 add_component_entry( hdb
, "'lepus', '', 'TARGETDIR', 2, '', 'lepus_file'" );
5444 add_feature_components_entry( hdb
, "'zodiac', 'leo'" );
5445 add_feature_components_entry( hdb
, "'zodiac', 'virgo'" );
5446 add_feature_components_entry( hdb
, "'zodiac', 'libra'" );
5447 add_feature_components_entry( hdb
, "'perseus', 'cassiopeia'" );
5448 add_feature_components_entry( hdb
, "'perseus', 'cepheus'" );
5449 add_feature_components_entry( hdb
, "'perseus', 'andromeda'" );
5450 add_feature_components_entry( hdb
, "'orion', 'leo'" );
5451 add_feature_components_entry( hdb
, "'orion', 'virgo'" );
5452 add_feature_components_entry( hdb
, "'orion', 'libra'" );
5453 add_feature_components_entry( hdb
, "'orion', 'cassiopeia'" );
5454 add_feature_components_entry( hdb
, "'orion', 'cepheus'" );
5455 add_feature_components_entry( hdb
, "'orion', 'andromeda'" );
5456 add_feature_components_entry( hdb
, "'orion', 'canis'" );
5457 add_feature_components_entry( hdb
, "'orion', 'monoceros'" );
5458 add_feature_components_entry( hdb
, "'orion', 'lepus'" );
5459 add_feature_components_entry( hdb
, "'waters', 'delphinus'" );
5460 add_feature_components_entry( hdb
, "'bayer', 'hydrus'" );
5462 add_file_entry( hdb
, "'leo_file', 'leo', 'leo.txt', 100, '', '1033', 8192, 1" );
5463 add_file_entry( hdb
, "'virgo_file', 'virgo', 'virgo.txt', 0, '', '1033', 8192, 1" );
5464 add_file_entry( hdb
, "'libra_file', 'libra', 'libra.txt', 0, '', '1033', 8192, 1" );
5465 add_file_entry( hdb
, "'cassiopeia_file', 'cassiopeia', 'cassiopeia.txt', 0, '', '1033', 8192, 1" );
5466 add_file_entry( hdb
, "'cepheus_file', 'cepheus', 'cepheus.txt', 0, '', '1033', 8192, 1" );
5467 add_file_entry( hdb
, "'andromeda_file', 'andromeda', 'andromeda.txt', 0, '', '1033', 8192, 1" );
5468 add_file_entry( hdb
, "'canis_file', 'canis', 'canis.txt', 0, '', '1033', 8192, 1" );
5469 add_file_entry( hdb
, "'monoceros_file', 'monoceros', 'monoceros.txt', 0, '', '1033', 8192, 1" );
5470 add_file_entry( hdb
, "'lepus_file', 'lepus', 'lepus.txt', 0, '', '1033', 8192, 1" );
5471 add_file_entry( hdb
, "'delphinus_file', 'delphinus', 'delphinus.txt', 0, '', '1033', 8192, 1" );
5472 add_file_entry( hdb
, "'hydrus_file', 'hydrus', 'hydrus.txt', 0, '', '1033', 8192, 1" );
5474 r
= package_from_db( hdb
, &hpkg
);
5475 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
5477 skip("Not enough rights to perform tests\n");
5478 DeleteFileA(msifile
);
5481 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
5483 MsiCloseHandle( hdb
);
5485 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
5487 r
= MsiDoActionA( hpkg
, "CostInitialize");
5488 ok( r
== ERROR_SUCCESS
, "cost init failed\n");
5490 r
= MsiDoActionA( hpkg
, "FileCost");
5491 ok( r
== ERROR_SUCCESS
, "file cost failed\n");
5493 r
= MsiDoActionA( hpkg
, "CostFinalize");
5494 ok( r
== ERROR_SUCCESS
, "cost finalize failed\n");
5496 test_feature_states( __LINE__
, hpkg
, "zodiac", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
5497 test_feature_states( __LINE__
, hpkg
, "perseus", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_SOURCE
, FALSE
);
5498 test_feature_states( __LINE__
, hpkg
, "orion", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
5499 test_feature_states( __LINE__
, hpkg
, "lyra", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
5500 test_feature_states( __LINE__
, hpkg
, "waters", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
5501 test_feature_states( __LINE__
, hpkg
, "bayer", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
5503 test_component_states( __LINE__
, hpkg
, "leo", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_LOCAL
, FALSE
);
5504 test_component_states( __LINE__
, hpkg
, "virgo", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_SOURCE
, FALSE
);
5505 test_component_states( __LINE__
, hpkg
, "libra", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_LOCAL
, FALSE
);
5506 test_component_states( __LINE__
, hpkg
, "cassiopeia", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_LOCAL
, FALSE
);
5507 test_component_states( __LINE__
, hpkg
, "cepheus", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_SOURCE
, FALSE
);
5508 test_component_states( __LINE__
, hpkg
, "andromeda", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_LOCAL
, FALSE
);
5509 test_component_states( __LINE__
, hpkg
, "canis", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_LOCAL
, FALSE
);
5510 test_component_states( __LINE__
, hpkg
, "monoceros", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_SOURCE
, FALSE
);
5511 test_component_states( __LINE__
, hpkg
, "lepus", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_LOCAL
, FALSE
);
5512 test_component_states( __LINE__
, hpkg
, "delphinus", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
5513 test_component_states( __LINE__
, hpkg
, "hydrus", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
5515 r
= MsiSetFeatureStateA(hpkg
, "orion", INSTALLSTATE_ABSENT
);
5516 ok( r
== ERROR_SUCCESS
, "failed to set feature state: %d\n", r
);
5518 r
= MsiSetFeatureStateA(hpkg
, "lyra", INSTALLSTATE_ABSENT
);
5519 ok( r
== ERROR_SUCCESS
, "failed to set feature state: %d\n", r
);
5521 r
= MsiSetFeatureStateA(hpkg
, "nosuchfeature", INSTALLSTATE_ABSENT
);
5522 ok( r
== ERROR_UNKNOWN_FEATURE
, "Expected ERROR_UNKNOWN_FEATURE, got %u\n", r
);
5524 test_feature_states( __LINE__
, hpkg
, "zodiac", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
5525 test_feature_states( __LINE__
, hpkg
, "perseus", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_SOURCE
, FALSE
);
5526 test_feature_states( __LINE__
, hpkg
, "orion", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_ABSENT
, FALSE
);
5527 test_feature_states( __LINE__
, hpkg
, "lyra", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_ABSENT
, FALSE
);
5528 test_feature_states( __LINE__
, hpkg
, "waters", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
5529 test_feature_states( __LINE__
, hpkg
, "bayer", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
5531 test_component_states( __LINE__
, hpkg
, "leo", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_LOCAL
, FALSE
);
5532 test_component_states( __LINE__
, hpkg
, "virgo", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_SOURCE
, FALSE
);
5533 test_component_states( __LINE__
, hpkg
, "libra", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_LOCAL
, FALSE
);
5534 test_component_states( __LINE__
, hpkg
, "cassiopeia", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_LOCAL
, FALSE
);
5535 test_component_states( __LINE__
, hpkg
, "cepheus", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_SOURCE
, FALSE
);
5536 test_component_states( __LINE__
, hpkg
, "andromeda", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_SOURCE
, FALSE
);
5537 test_component_states( __LINE__
, hpkg
, "canis", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
5538 test_component_states( __LINE__
, hpkg
, "monoceros", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
5539 test_component_states( __LINE__
, hpkg
, "lepus", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
5540 test_component_states( __LINE__
, hpkg
, "delphinus", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
5541 test_component_states( __LINE__
, hpkg
, "hydrus", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
5543 MsiCloseHandle(hpkg
);
5544 DeleteFileA(msifile
);
5547 static void test_installprops(void)
5549 MSIHANDLE hpkg
, hdb
;
5550 CHAR path
[MAX_PATH
], buf
[MAX_PATH
];
5553 HKEY hkey1
, hkey2
, pathkey
;
5556 REGSAM access
= KEY_ALL_ACCESS
;
5558 INSTALLUILEVEL uilevel
;
5561 access
|= KEY_WOW64_64KEY
;
5563 lstrcpyA(path
, CURR_DIR
);
5564 if (!is_root(CURR_DIR
)) lstrcatA(path
, "\\");
5565 lstrcatA(path
, msifile
);
5567 uilevel
= MsiSetInternalUI(INSTALLUILEVEL_BASIC
|INSTALLUILEVEL_SOURCERESONLY
, NULL
);
5569 hdb
= create_package_db();
5570 ok( hdb
, "failed to create database\n");
5572 r
= package_from_db(hdb
, &hpkg
);
5573 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
5575 skip("Not enough rights to perform tests\n");
5576 MsiSetInternalUI(uilevel
, NULL
);
5577 DeleteFileA(msifile
);
5580 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
5582 MsiCloseHandle(hdb
);
5586 r
= MsiGetPropertyA(hpkg
, "UILevel", buf
, &size
);
5587 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5588 ok( !lstrcmpA(buf
, "3"), "Expected \"3\", got \"%s\"\n", buf
);
5590 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
5594 r
= MsiGetPropertyA(hpkg
, "UILevel", buf
, &size
);
5595 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5596 ok( !lstrcmpA(buf
, "3"), "Expected \"3\", got \"%s\"\n", buf
);
5600 r
= MsiGetPropertyA(hpkg
, "DATABASE", buf
, &size
);
5601 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5602 ok( !lstrcmpA(buf
, path
), "Expected %s, got %s\n", path
, buf
);
5604 RegOpenKeyA(HKEY_CURRENT_USER
, "SOFTWARE\\Microsoft\\MS Setup (ACME)\\User Info", &hkey1
);
5605 RegOpenKeyExA(HKEY_LOCAL_MACHINE
, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, access
, &hkey2
);
5606 RegOpenKeyExA(HKEY_LOCAL_MACHINE
, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion",
5607 0, KEY_QUERY_VALUE
| KEY_WOW64_64KEY
, &pathkey
);
5612 if (RegQueryValueExA(hkey1
, "DefName", NULL
, &type
, (LPBYTE
)path
, &size
) != ERROR_SUCCESS
)
5616 RegQueryValueExA(hkey2
, "RegisteredOwner", NULL
, &type
, (LPBYTE
)path
, &size
);
5621 r
= MsiGetPropertyA(hpkg
, "USERNAME", buf
, &size
);
5622 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5623 ok( !lstrcmpA(buf
, path
), "Expected %s, got %s\n", path
, buf
);
5628 if (RegQueryValueExA(hkey1
, "DefCompany", NULL
, &type
, (LPBYTE
)path
, &size
) != ERROR_SUCCESS
)
5632 RegQueryValueExA(hkey2
, "RegisteredOrganization", NULL
, &type
, (LPBYTE
)path
, &size
);
5639 r
= MsiGetPropertyA(hpkg
, "COMPANYNAME", buf
, &size
);
5640 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5641 ok( !lstrcmpA(buf
, path
), "Expected %s, got %s\n", path
, buf
);
5646 r
= MsiGetPropertyA(hpkg
, "VersionDatabase", buf
, &size
);
5647 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5648 trace("VersionDatabase = %s\n", buf
);
5652 r
= MsiGetPropertyA(hpkg
, "VersionMsi", buf
, &size
);
5653 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5654 trace("VersionMsi = %s\n", buf
);
5658 r
= MsiGetPropertyA(hpkg
, "Date", buf
, &size
);
5659 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5660 trace("Date = %s\n", buf
);
5664 r
= MsiGetPropertyA(hpkg
, "Time", buf
, &size
);
5665 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5666 trace("Time = %s\n", buf
);
5670 r
= MsiGetPropertyA(hpkg
, "PackageCode", buf
, &size
);
5671 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5672 trace("PackageCode = %s\n", buf
);
5676 r
= MsiGetPropertyA(hpkg
, "ComputerName", buf
, &size
);
5677 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
5678 trace("ComputerName = %s\n", buf
);
5680 langid
= GetUserDefaultLangID();
5681 sprintf(path
, "%d", langid
);
5685 r
= MsiGetPropertyA(hpkg
, "UserLanguageID", buf
, &size
);
5686 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
5687 ok( !lstrcmpA(buf
, path
), "Expected \"%s\", got \"%s\"\n", path
, buf
);
5689 res
= GetSystemMetrics(SM_CXSCREEN
);
5692 r
= MsiGetPropertyA(hpkg
, "ScreenX", buf
, &size
);
5693 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
5694 ok(atol(buf
) == res
, "Expected %d, got %ld\n", res
, atol(buf
));
5696 res
= GetSystemMetrics(SM_CYSCREEN
);
5699 r
= MsiGetPropertyA(hpkg
, "ScreenY", buf
, &size
);
5700 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
5701 ok(atol(buf
) == res
, "Expected %d, got %ld\n", res
, atol(buf
));
5705 r
= MsiGetPropertyA(hpkg
, "MsiNetAssemblySupport", buf
, &size
);
5706 if (r
== ERROR_SUCCESS
) trace( "MsiNetAssemblySupport \"%s\"\n", buf
);
5708 if (pGetNativeSystemInfo
)
5709 pGetNativeSystemInfo(&si
);
5711 pGetSystemInfo(&si
);
5713 if (S(U(si
)).wProcessorArchitecture
== PROCESSOR_ARCHITECTURE_AMD64
)
5715 sprintf(buf
, "%d", si
.wProcessorLevel
);
5716 check_prop(hpkg
, "Intel", buf
);
5717 check_prop(hpkg
, "MsiAMD64", buf
);
5718 check_prop(hpkg
, "Msix64", buf
);
5719 sprintf(buf
, "%d", LOBYTE(LOWORD(GetVersion())) * 100 + HIBYTE(LOWORD(GetVersion())));
5720 check_prop(hpkg
, "VersionNT64", buf
);
5722 GetSystemDirectoryA(path
, MAX_PATH
);
5724 check_prop(hpkg
, "System64Folder", path
);
5726 pGetSystemWow64DirectoryA(path
, MAX_PATH
);
5728 check_prop(hpkg
, "SystemFolder", path
);
5731 r
= RegQueryValueExA(pathkey
, "ProgramFilesDir (x86)", 0, &type
, (BYTE
*)path
, &size
);
5733 check_prop(hpkg
, "ProgramFilesFolder", path
);
5736 RegQueryValueExA(pathkey
, "ProgramFilesDir", 0, &type
, (BYTE
*)path
, &size
);
5738 check_prop(hpkg
, "ProgramFiles64Folder", path
);
5741 RegQueryValueExA(pathkey
, "CommonFilesDir (x86)", 0, &type
, (BYTE
*)path
, &size
);
5743 check_prop(hpkg
, "CommonFilesFolder", path
);
5746 RegQueryValueExA(pathkey
, "CommonFilesDir", 0, &type
, (BYTE
*)path
, &size
);
5748 check_prop(hpkg
, "CommonFiles64Folder", path
);
5750 else if (S(U(si
)).wProcessorArchitecture
== PROCESSOR_ARCHITECTURE_INTEL
)
5752 sprintf(buf
, "%d", si
.wProcessorLevel
);
5753 check_prop(hpkg
, "Intel", buf
);
5755 GetSystemDirectoryA(path
, MAX_PATH
);
5757 check_prop(hpkg
, "SystemFolder", path
);
5760 RegQueryValueExA(pathkey
, "ProgramFilesDir", 0, &type
, (BYTE
*)path
, &size
);
5762 check_prop(hpkg
, "ProgramFilesFolder", path
);
5765 RegQueryValueExA(pathkey
, "CommonFilesDir", 0, &type
, (BYTE
*)path
, &size
);
5767 check_prop(hpkg
, "CommonFilesFolder", path
);
5769 check_prop(hpkg
, "MsiAMD64", "");
5770 check_prop(hpkg
, "Msix64", "");
5771 check_prop(hpkg
, "VersionNT64", "");
5772 check_prop(hpkg
, "System64Folder", "");
5773 check_prop(hpkg
, "ProgramFiles64Dir", "");
5774 check_prop(hpkg
, "CommonFiles64Dir", "");
5779 RegCloseKey(pathkey
);
5780 MsiCloseHandle(hpkg
);
5781 DeleteFileA(msifile
);
5782 MsiSetInternalUI(uilevel
, NULL
);
5785 static void test_launchconditions(void)
5791 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
5793 hdb
= create_package_db();
5794 ok( hdb
, "failed to create package database\n" );
5796 create_launchcondition_table( hdb
);
5798 add_launchcondition_entry( hdb
, "'X = \"1\"', 'one'" );
5800 /* invalid condition */
5801 add_launchcondition_entry( hdb
, "'X != \"1\"', 'one'" );
5803 r
= package_from_db( hdb
, &hpkg
);
5804 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
5806 skip("Not enough rights to perform tests\n");
5807 DeleteFileA(msifile
);
5810 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
5812 MsiCloseHandle( hdb
);
5814 r
= MsiSetPropertyA( hpkg
, "X", "1" );
5815 ok( r
== ERROR_SUCCESS
, "failed to set property\n" );
5817 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
5819 /* invalid conditions are ignored */
5820 r
= MsiDoActionA( hpkg
, "LaunchConditions" );
5821 ok( r
== ERROR_SUCCESS
, "cost init failed\n" );
5823 /* verify LaunchConditions still does some verification */
5824 r
= MsiSetPropertyA( hpkg
, "X", "2" );
5825 ok( r
== ERROR_SUCCESS
, "failed to set property\n" );
5827 r
= MsiDoActionA( hpkg
, "LaunchConditions" );
5828 ok( r
== ERROR_INSTALL_FAILURE
, "Expected ERROR_INSTALL_FAILURE, got %d\n", r
);
5830 MsiCloseHandle( hpkg
);
5831 DeleteFileA( msifile
);
5834 static void test_ccpsearch(void)
5836 MSIHANDLE hdb
, hpkg
;
5837 CHAR prop
[MAX_PATH
];
5838 DWORD size
= MAX_PATH
;
5841 hdb
= create_package_db();
5842 ok(hdb
, "failed to create package database\n");
5844 create_ccpsearch_table(hdb
);
5845 add_ccpsearch_entry(hdb
, "'CCP_random'");
5846 add_ccpsearch_entry(hdb
, "'RMCCP_random'");
5848 create_reglocator_table(hdb
);
5849 add_reglocator_entry(hdb
, "CCP_random", 0, "htmlfile\\shell\\open\\nonexistent", "", 1);
5851 create_drlocator_table(hdb
);
5852 add_drlocator_entry(hdb
, "'RMCCP_random', '', 'C:\\', '0'");
5854 create_signature_table(hdb
);
5856 r
= package_from_db(hdb
, &hpkg
);
5857 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
5859 skip("Not enough rights to perform tests\n");
5860 DeleteFileA(msifile
);
5863 ok(r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
5865 MsiCloseHandle(hdb
);
5867 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
5869 r
= MsiDoActionA(hpkg
, "CCPSearch");
5870 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5872 r
= MsiGetPropertyA(hpkg
, "CCP_Success", prop
, &size
);
5873 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5874 ok(!lstrcmpA(prop
, "1"), "Expected 1, got %s\n", prop
);
5876 MsiCloseHandle(hpkg
);
5877 DeleteFileA(msifile
);
5880 static void test_complocator(void)
5882 MSIHANDLE hdb
, hpkg
;
5884 CHAR prop
[MAX_PATH
];
5885 CHAR expected
[MAX_PATH
];
5886 DWORD size
= MAX_PATH
;
5888 hdb
= create_package_db();
5889 ok(hdb
, "failed to create package database\n");
5891 create_appsearch_table(hdb
);
5892 add_appsearch_entry(hdb
, "'ABELISAURUS', 'abelisaurus'");
5893 add_appsearch_entry(hdb
, "'BACTROSAURUS', 'bactrosaurus'");
5894 add_appsearch_entry(hdb
, "'CAMELOTIA', 'camelotia'");
5895 add_appsearch_entry(hdb
, "'DICLONIUS', 'diclonius'");
5896 add_appsearch_entry(hdb
, "'ECHINODON', 'echinodon'");
5897 add_appsearch_entry(hdb
, "'FALCARIUS', 'falcarius'");
5898 add_appsearch_entry(hdb
, "'GALLIMIMUS', 'gallimimus'");
5899 add_appsearch_entry(hdb
, "'HAGRYPHUS', 'hagryphus'");
5900 add_appsearch_entry(hdb
, "'IGUANODON', 'iguanodon'");
5901 add_appsearch_entry(hdb
, "'JOBARIA', 'jobaria'");
5902 add_appsearch_entry(hdb
, "'KAKURU', 'kakuru'");
5903 add_appsearch_entry(hdb
, "'LABOCANIA', 'labocania'");
5904 add_appsearch_entry(hdb
, "'MEGARAPTOR', 'megaraptor'");
5905 add_appsearch_entry(hdb
, "'NEOSODON', 'neosodon'");
5906 add_appsearch_entry(hdb
, "'OLOROTITAN', 'olorotitan'");
5907 add_appsearch_entry(hdb
, "'PANTYDRACO', 'pantydraco'");
5909 create_complocator_table(hdb
);
5910 add_complocator_entry(hdb
, "'abelisaurus', '{E3619EED-305A-418C-B9C7-F7D7377F0934}', 1");
5911 add_complocator_entry(hdb
, "'bactrosaurus', '{D56B688D-542F-42Ef-90FD-B6DA76EE8119}', 0");
5912 add_complocator_entry(hdb
, "'camelotia', '{8211BE36-2466-47E3-AFB7-6AC72E51AED2}', 1");
5913 add_complocator_entry(hdb
, "'diclonius', '{5C767B20-A33C-45A4-B80B-555E512F01AE}', 0");
5914 add_complocator_entry(hdb
, "'echinodon', '{A19E16C5-C75D-4699-8111-C4338C40C3CB}', 1");
5915 add_complocator_entry(hdb
, "'falcarius', '{17762FA1-A7AE-4CC6-8827-62873C35361D}', 0");
5916 add_complocator_entry(hdb
, "'gallimimus', '{75EBF568-C959-41E0-A99E-9050638CF5FB}', 1");
5917 add_complocator_entry(hdb
, "'hagrphus', '{D4969B72-17D9-4AB6-BE49-78F2FEE857AC}', 0");
5918 add_complocator_entry(hdb
, "'iguanodon', '{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}', 1");
5919 add_complocator_entry(hdb
, "'jobaria', '{243C22B1-8C51-4151-B9D1-1AE5265E079E}', 0");
5920 add_complocator_entry(hdb
, "'kakuru', '{5D0F03BA-50BC-44F2-ABB1-72C972F4E514}', 1");
5921 add_complocator_entry(hdb
, "'labocania', '{C7DDB60C-7828-4046-A6F8-699D5E92F1ED}', 0");
5922 add_complocator_entry(hdb
, "'megaraptor', '{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}', 1");
5923 add_complocator_entry(hdb
, "'neosodon', '{0B499649-197A-48EF-93D2-AF1C17ED6E90}', 0");
5924 add_complocator_entry(hdb
, "'olorotitan', '{54E9E91F-AED2-46D5-A25A-7E50AFA24513}', 1");
5925 add_complocator_entry(hdb
, "'pantydraco', '{2A989951-5565-4FA7-93A7-E800A3E67D71}', 0");
5927 create_signature_table(hdb
);
5928 add_signature_entry(hdb
, "'abelisaurus', 'abelisaurus', '', '', '', '', '', '', ''");
5929 add_signature_entry(hdb
, "'bactrosaurus', 'bactrosaurus', '', '', '', '', '', '', ''");
5930 add_signature_entry(hdb
, "'camelotia', 'camelotia', '', '', '', '', '', '', ''");
5931 add_signature_entry(hdb
, "'diclonius', 'diclonius', '', '', '', '', '', '', ''");
5932 add_signature_entry(hdb
, "'iguanodon', 'iguanodon', '', '', '', '', '', '', ''");
5933 add_signature_entry(hdb
, "'jobaria', 'jobaria', '', '', '', '', '', '', ''");
5934 add_signature_entry(hdb
, "'kakuru', 'kakuru', '', '', '', '', '', '', ''");
5935 add_signature_entry(hdb
, "'labocania', 'labocania', '', '', '', '', '', '', ''");
5937 r
= package_from_db(hdb
, &hpkg
);
5938 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
5940 skip("Not enough rights to perform tests\n");
5941 DeleteFileA(msifile
);
5944 ok(r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
5946 MsiCloseHandle(hdb
);
5948 create_test_file("abelisaurus");
5949 create_test_file("bactrosaurus");
5950 create_test_file("camelotia");
5951 create_test_file("diclonius");
5952 create_test_file("echinodon");
5953 create_test_file("falcarius");
5954 create_test_file("gallimimus");
5955 create_test_file("hagryphus");
5956 CreateDirectoryA("iguanodon", NULL
);
5957 CreateDirectoryA("jobaria", NULL
);
5958 CreateDirectoryA("kakuru", NULL
);
5959 CreateDirectoryA("labocania", NULL
);
5960 CreateDirectoryA("megaraptor", NULL
);
5961 CreateDirectoryA("neosodon", NULL
);
5962 CreateDirectoryA("olorotitan", NULL
);
5963 CreateDirectoryA("pantydraco", NULL
);
5965 set_component_path("abelisaurus", MSIINSTALLCONTEXT_MACHINE
,
5966 "{E3619EED-305A-418C-B9C7-F7D7377F0934}", NULL
, FALSE
);
5967 set_component_path("bactrosaurus", MSIINSTALLCONTEXT_MACHINE
,
5968 "{D56B688D-542F-42Ef-90FD-B6DA76EE8119}", NULL
, FALSE
);
5969 set_component_path("echinodon", MSIINSTALLCONTEXT_MACHINE
,
5970 "{A19E16C5-C75D-4699-8111-C4338C40C3CB}", NULL
, FALSE
);
5971 set_component_path("falcarius", MSIINSTALLCONTEXT_MACHINE
,
5972 "{17762FA1-A7AE-4CC6-8827-62873C35361D}", NULL
, FALSE
);
5973 set_component_path("iguanodon", MSIINSTALLCONTEXT_MACHINE
,
5974 "{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}", NULL
, FALSE
);
5975 set_component_path("jobaria", MSIINSTALLCONTEXT_MACHINE
,
5976 "{243C22B1-8C51-4151-B9D1-1AE5265E079E}", NULL
, FALSE
);
5977 set_component_path("megaraptor", MSIINSTALLCONTEXT_MACHINE
,
5978 "{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}", NULL
, FALSE
);
5979 set_component_path("neosodon", MSIINSTALLCONTEXT_MACHINE
,
5980 "{0B499649-197A-48EF-93D2-AF1C17ED6E90}", NULL
, FALSE
);
5982 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
5984 r
= MsiDoActionA(hpkg
, "AppSearch");
5985 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5988 r
= MsiGetPropertyA(hpkg
, "ABELISAURUS", prop
, &size
);
5989 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5991 lstrcpyA(expected
, CURR_DIR
);
5992 if (!is_root(CURR_DIR
)) lstrcatA(expected
, "\\");
5993 lstrcatA(expected
, "abelisaurus");
5994 ok(!lstrcmpA(prop
, expected
) || !lstrcmpA(prop
, ""),
5995 "Expected %s or empty string, got %s\n", expected
, prop
);
5998 r
= MsiGetPropertyA(hpkg
, "BACTROSAURUS", prop
, &size
);
5999 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6000 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6003 r
= MsiGetPropertyA(hpkg
, "CAMELOTIA", prop
, &size
);
6004 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6005 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6008 r
= MsiGetPropertyA(hpkg
, "DICLONIUS", prop
, &size
);
6009 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6010 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6013 r
= MsiGetPropertyA(hpkg
, "ECHINODON", prop
, &size
);
6014 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6016 lstrcpyA(expected
, CURR_DIR
);
6017 if (!is_root(CURR_DIR
)) lstrcatA(expected
, "\\");
6018 ok(!lstrcmpA(prop
, expected
) || !lstrcmpA(prop
, ""),
6019 "Expected %s or empty string, got %s\n", expected
, prop
);
6022 r
= MsiGetPropertyA(hpkg
, "FALCARIUS", prop
, &size
);
6023 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6024 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6027 r
= MsiGetPropertyA(hpkg
, "GALLIMIMUS", prop
, &size
);
6028 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6029 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6032 r
= MsiGetPropertyA(hpkg
, "HAGRYPHUS", prop
, &size
);
6033 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6034 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6037 r
= MsiGetPropertyA(hpkg
, "IGUANODON", prop
, &size
);
6038 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6039 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6042 r
= MsiGetPropertyA(hpkg
, "JOBARIA", prop
, &size
);
6043 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6044 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6047 r
= MsiGetPropertyA(hpkg
, "KAKURU", prop
, &size
);
6048 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6049 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6052 r
= MsiGetPropertyA(hpkg
, "LABOCANIA", prop
, &size
);
6053 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6054 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6057 r
= MsiGetPropertyA(hpkg
, "MEGARAPTOR", prop
, &size
);
6058 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6060 lstrcpyA(expected
, CURR_DIR
);
6061 if (!is_root(CURR_DIR
)) lstrcatA(expected
, "\\");
6062 ok(!lstrcmpA(prop
, expected
) || !lstrcmpA(prop
, ""),
6063 "Expected %s or empty string, got %s\n", expected
, prop
);
6066 r
= MsiGetPropertyA(hpkg
, "NEOSODON", prop
, &size
);
6067 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6069 lstrcpyA(expected
, CURR_DIR
);
6070 if (!is_root(CURR_DIR
)) lstrcatA(expected
, "\\");
6071 lstrcatA(expected
, "neosodon\\");
6072 ok(!lstrcmpA(prop
, expected
) || !lstrcmpA(prop
, ""),
6073 "Expected %s or empty string, got %s\n", expected
, prop
);
6076 r
= MsiGetPropertyA(hpkg
, "OLOROTITAN", prop
, &size
);
6077 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6078 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6081 r
= MsiGetPropertyA(hpkg
, "PANTYDRACO", prop
, &size
);
6082 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6083 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6085 MsiCloseHandle(hpkg
);
6086 DeleteFileA("abelisaurus");
6087 DeleteFileA("bactrosaurus");
6088 DeleteFileA("camelotia");
6089 DeleteFileA("diclonius");
6090 DeleteFileA("echinodon");
6091 DeleteFileA("falcarius");
6092 DeleteFileA("gallimimus");
6093 DeleteFileA("hagryphus");
6094 RemoveDirectoryA("iguanodon");
6095 RemoveDirectoryA("jobaria");
6096 RemoveDirectoryA("kakuru");
6097 RemoveDirectoryA("labocania");
6098 RemoveDirectoryA("megaraptor");
6099 RemoveDirectoryA("neosodon");
6100 RemoveDirectoryA("olorotitan");
6101 RemoveDirectoryA("pantydraco");
6102 delete_component_path("{E3619EED-305A-418C-B9C7-F7D7377F0934}",
6103 MSIINSTALLCONTEXT_MACHINE
, NULL
);
6104 delete_component_path("{D56B688D-542F-42Ef-90FD-B6DA76EE8119}",
6105 MSIINSTALLCONTEXT_MACHINE
, NULL
);
6106 delete_component_path("{A19E16C5-C75D-4699-8111-C4338C40C3CB}",
6107 MSIINSTALLCONTEXT_MACHINE
, NULL
);
6108 delete_component_path("{17762FA1-A7AE-4CC6-8827-62873C35361D}",
6109 MSIINSTALLCONTEXT_MACHINE
, NULL
);
6110 delete_component_path("{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}",
6111 MSIINSTALLCONTEXT_MACHINE
, NULL
);
6112 delete_component_path("{243C22B1-8C51-4151-B9D1-1AE5265E079E}",
6113 MSIINSTALLCONTEXT_MACHINE
, NULL
);
6114 delete_component_path("{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}",
6115 MSIINSTALLCONTEXT_MACHINE
, NULL
);
6116 delete_component_path("{0B499649-197A-48EF-93D2-AF1C17ED6E90}",
6117 MSIINSTALLCONTEXT_MACHINE
, NULL
);
6118 DeleteFileA(msifile
);
6121 static void set_suminfo_prop(MSIHANDLE db
, DWORD prop
, DWORD val
)
6126 r
= MsiGetSummaryInformationA(db
, NULL
, 1, &summary
);
6127 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6129 r
= MsiSummaryInfoSetPropertyA(summary
, prop
, VT_I4
, val
, NULL
, NULL
);
6130 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6132 r
= MsiSummaryInfoPersist(summary
);
6133 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
6135 MsiCloseHandle(summary
);
6138 static void test_MsiGetSourcePath(void)
6140 MSIHANDLE hdb
, hpkg
;
6141 CHAR path
[MAX_PATH
];
6143 CHAR subsrc
[MAX_PATH
];
6144 CHAR sub2
[MAX_PATH
];
6148 lstrcpyA(cwd
, CURR_DIR
);
6149 if (!is_root(CURR_DIR
)) lstrcatA(cwd
, "\\");
6151 lstrcpyA(subsrc
, cwd
);
6152 lstrcatA(subsrc
, "subsource");
6153 lstrcatA(subsrc
, "\\");
6155 lstrcpyA(sub2
, subsrc
);
6156 lstrcatA(sub2
, "sub2");
6157 lstrcatA(sub2
, "\\");
6159 /* uncompressed source */
6161 hdb
= create_package_db();
6162 ok( hdb
, "failed to create database\n");
6164 set_suminfo_prop(hdb
, PID_WORDCOUNT
, 0);
6166 add_directory_entry(hdb
, "'TARGETDIR', '', 'SourceDir'");
6167 add_directory_entry(hdb
, "'SubDir', 'TARGETDIR', 'subtarget:subsource'");
6168 add_directory_entry(hdb
, "'SubDir2', 'SubDir', 'sub2'");
6170 r
= MsiDatabaseCommit(hdb
);
6171 ok(r
== ERROR_SUCCESS
, "Failed to commit database\n");
6173 r
= package_from_db(hdb
, &hpkg
);
6174 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
6176 skip("Not enough rights to perform tests\n");
6177 DeleteFileA(msifile
);
6180 ok(r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
6182 MsiCloseHandle(hdb
);
6184 /* invalid database handle */
6186 lstrcpyA(path
, "kiwi");
6187 r
= MsiGetSourcePathA(-1, "TARGETDIR", path
, &size
);
6188 ok(r
== ERROR_INVALID_HANDLE
,
6189 "Expected ERROR_INVALID_HANDLE, got %d\n", r
);
6190 ok(!lstrcmpA(path
, "kiwi"),
6191 "Expected path to be unchanged, got \"%s\"\n", path
);
6192 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6196 lstrcpyA(path
, "kiwi");
6197 r
= MsiGetSourcePathA(hpkg
, NULL
, path
, &size
);
6198 ok(r
== ERROR_INVALID_PARAMETER
,
6199 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
6200 ok(!lstrcmpA(path
, "kiwi"),
6201 "Expected path to be unchanged, got \"%s\"\n", path
);
6202 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6204 /* empty szFolder */
6206 lstrcpyA(path
, "kiwi");
6207 r
= MsiGetSourcePathA(hpkg
, "", path
, &size
);
6208 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6209 ok(!lstrcmpA(path
, "kiwi"),
6210 "Expected path to be unchanged, got \"%s\"\n", path
);
6211 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6215 lstrcpyA(path
, "kiwi");
6216 r
= MsiGetSourcePathA(hpkg
, "TARGETDIR", path
, &size
);
6217 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6218 ok(!lstrcmpA(path
, "kiwi"),
6219 "Expected path to be unchanged, got \"%s\"\n", path
);
6220 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6223 lstrcpyA(path
, "kiwi");
6224 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
6225 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6226 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
6227 ok(size
== 0, "Expected 0, got %d\n", size
);
6230 lstrcpyA(path
, "kiwi");
6231 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
6232 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6233 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
6234 ok(size
== 0, "Expected 0, got %d\n", size
);
6238 lstrcpyA(path
, "kiwi");
6239 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6240 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6241 ok(!lstrcmpA(path
, "kiwi"),
6242 "Expected path to be unchanged, got \"%s\"\n", path
);
6243 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6247 lstrcpyA(path
, "kiwi");
6248 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
6249 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6250 ok(!lstrcmpA(path
, "kiwi"),
6251 "Expected path to be unchanged, got \"%s\"\n", path
);
6252 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6254 /* source path does not exist, but the property exists */
6256 lstrcpyA(path
, "kiwi");
6257 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
6258 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6259 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
6260 ok(size
== 0, "Expected 0, got %d\n", size
);
6263 lstrcpyA(path
, "kiwi");
6264 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
6265 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6266 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
6267 ok(size
== 0, "Expected 0, got %d\n", size
);
6271 lstrcpyA(path
, "kiwi");
6272 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
6273 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6274 ok(!lstrcmpA(path
, "kiwi"),
6275 "Expected path to be unchanged, got \"%s\"\n", path
);
6276 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6280 lstrcpyA(path
, "kiwi");
6281 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
6282 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6283 ok(!lstrcmpA(path
, "kiwi"),
6284 "Expected path to be unchanged, got \"%s\"\n", path
);
6285 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6287 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
6289 r
= MsiDoActionA(hpkg
, "CostInitialize");
6290 ok(r
== ERROR_SUCCESS
, "cost init failed\n");
6292 /* try TARGETDIR after CostInitialize */
6294 lstrcpyA(path
, "kiwi");
6295 r
= MsiGetSourcePathA(hpkg
, "TARGETDIR", path
, &size
);
6296 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6297 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6298 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6300 /* try SourceDir after CostInitialize */
6302 lstrcpyA(path
, "kiwi");
6303 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6304 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6305 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6306 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6308 /* try SOURCEDIR after CostInitialize */
6310 lstrcpyA(path
, "kiwi");
6311 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
6312 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6313 ok(!lstrcmpA(path
, "kiwi"),
6314 "Expected path to be unchanged, got \"%s\"\n", path
);
6315 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6317 /* source path does not exist, but the property exists */
6319 lstrcpyA(path
, "kiwi");
6320 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
6321 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6322 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6323 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6326 lstrcpyA(path
, "kiwi");
6327 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
6328 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6329 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6330 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6332 /* try SubDir after CostInitialize */
6334 lstrcpyA(path
, "kiwi");
6335 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
6336 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6337 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
6338 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
6340 /* try SubDir2 after CostInitialize */
6342 lstrcpyA(path
, "kiwi");
6343 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
6344 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6345 ok(!lstrcmpA(path
, sub2
), "Expected \"%s\", got \"%s\"\n", sub2
, path
);
6346 ok(size
== lstrlenA(sub2
), "Expected %d, got %d\n", lstrlenA(sub2
), size
);
6348 r
= MsiDoActionA(hpkg
, "ResolveSource");
6349 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
6351 /* try TARGETDIR after ResolveSource */
6353 lstrcpyA(path
, "kiwi");
6354 r
= MsiGetSourcePathA(hpkg
, "TARGETDIR", path
, &size
);
6355 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6356 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6357 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6359 /* try SourceDir after ResolveSource */
6361 lstrcpyA(path
, "kiwi");
6362 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6363 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6364 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6365 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6367 /* try SOURCEDIR after ResolveSource */
6369 lstrcpyA(path
, "kiwi");
6370 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
6371 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6372 ok(!lstrcmpA(path
, "kiwi"),
6373 "Expected path to be unchanged, got \"%s\"\n", path
);
6374 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6376 /* source path does not exist, but the property exists */
6378 lstrcpyA(path
, "kiwi");
6379 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
6380 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6381 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6382 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6385 lstrcpyA(path
, "kiwi");
6386 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
6387 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6388 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6389 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6391 /* try SubDir after ResolveSource */
6393 lstrcpyA(path
, "kiwi");
6394 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
6395 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6396 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
6397 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
6399 /* try SubDir2 after ResolveSource */
6401 lstrcpyA(path
, "kiwi");
6402 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
6403 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6404 ok(!lstrcmpA(path
, sub2
), "Expected \"%s\", got \"%s\"\n", sub2
, path
);
6405 ok(size
== lstrlenA(sub2
), "Expected %d, got %d\n", lstrlenA(sub2
), size
);
6407 r
= MsiDoActionA(hpkg
, "FileCost");
6408 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
6410 /* try TARGETDIR after FileCost */
6412 lstrcpyA(path
, "kiwi");
6413 r
= MsiGetSourcePathA(hpkg
, "TARGETDIR", path
, &size
);
6414 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6415 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6416 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6418 /* try SourceDir after FileCost */
6420 lstrcpyA(path
, "kiwi");
6421 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6422 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6423 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6424 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6426 /* try SOURCEDIR after FileCost */
6428 lstrcpyA(path
, "kiwi");
6429 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
6430 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6431 ok(!lstrcmpA(path
, "kiwi"),
6432 "Expected path to be unchanged, got \"%s\"\n", path
);
6433 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6435 /* source path does not exist, but the property exists */
6437 lstrcpyA(path
, "kiwi");
6438 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
6439 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6440 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6441 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6444 lstrcpyA(path
, "kiwi");
6445 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
6446 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6447 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6448 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6450 /* try SubDir after FileCost */
6452 lstrcpyA(path
, "kiwi");
6453 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
6454 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6455 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
6456 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
6458 /* try SubDir2 after FileCost */
6460 lstrcpyA(path
, "kiwi");
6461 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
6462 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6463 ok(!lstrcmpA(path
, sub2
), "Expected \"%s\", got \"%s\"\n", sub2
, path
);
6464 ok(size
== lstrlenA(sub2
), "Expected %d, got %d\n", lstrlenA(sub2
), size
);
6466 r
= MsiDoActionA(hpkg
, "CostFinalize");
6467 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
6469 /* try TARGETDIR after CostFinalize */
6471 lstrcpyA(path
, "kiwi");
6472 r
= MsiGetSourcePathA(hpkg
, "TARGETDIR", path
, &size
);
6473 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6474 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6475 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6477 /* try SourceDir after CostFinalize */
6479 lstrcpyA(path
, "kiwi");
6480 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6481 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6482 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6483 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6485 /* try SOURCEDIR after CostFinalize */
6487 lstrcpyA(path
, "kiwi");
6488 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
6489 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6490 ok(!lstrcmpA(path
, "kiwi"),
6491 "Expected path to be unchanged, got \"%s\"\n", path
);
6492 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6494 /* source path does not exist, but the property exists */
6496 lstrcpyA(path
, "kiwi");
6497 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
6498 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6499 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6500 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6503 lstrcpyA(path
, "kiwi");
6504 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
6505 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6506 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6507 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6509 /* try SubDir after CostFinalize */
6511 lstrcpyA(path
, "kiwi");
6512 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
6513 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6514 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
6515 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
6517 /* try SubDir2 after CostFinalize */
6519 lstrcpyA(path
, "kiwi");
6520 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
6521 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6522 ok(!lstrcmpA(path
, sub2
), "Expected \"%s\", got \"%s\"\n", sub2
, path
);
6523 ok(size
== lstrlenA(sub2
), "Expected %d, got %d\n", lstrlenA(sub2
), size
);
6525 /* nonexistent directory */
6527 lstrcpyA(path
, "kiwi");
6528 r
= MsiGetSourcePathA(hpkg
, "IDontExist", path
, &size
);
6529 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6530 ok(!lstrcmpA(path
, "kiwi"),
6531 "Expected path to be unchanged, got \"%s\"\n", path
);
6532 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6534 /* NULL szPathBuf */
6536 r
= MsiGetSourcePathA(hpkg
, "SourceDir", NULL
, &size
);
6537 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6538 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6540 /* NULL pcchPathBuf */
6541 lstrcpyA(path
, "kiwi");
6542 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, NULL
);
6543 ok(r
== ERROR_INVALID_PARAMETER
,
6544 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
6545 ok(!lstrcmpA(path
, "kiwi"),
6546 "Expected path to be unchanged, got \"%s\"\n", path
);
6548 /* pcchPathBuf is 0 */
6550 lstrcpyA(path
, "kiwi");
6551 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6552 ok(r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
6553 ok(!lstrcmpA(path
, "kiwi"),
6554 "Expected path to be unchanged, got \"%s\"\n", path
);
6555 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6557 /* pcchPathBuf does not have room for NULL terminator */
6558 size
= lstrlenA(cwd
);
6559 lstrcpyA(path
, "kiwi");
6560 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6561 ok(r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
6562 ok(!strncmp(path
, cwd
, lstrlenA(cwd
) - 1),
6563 "Expected path with no backslash, got \"%s\"\n", path
);
6564 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6566 /* pcchPathBuf has room for NULL terminator */
6567 size
= lstrlenA(cwd
) + 1;
6568 lstrcpyA(path
, "kiwi");
6569 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6570 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6571 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6572 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6574 /* remove property */
6575 r
= MsiSetPropertyA(hpkg
, "SourceDir", NULL
);
6576 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6578 /* try SourceDir again */
6580 lstrcpyA(path
, "kiwi");
6581 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6582 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6583 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6584 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6586 /* set property to a valid directory */
6587 r
= MsiSetPropertyA(hpkg
, "SOURCEDIR", cwd
);
6588 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6590 /* try SOURCEDIR again */
6592 lstrcpyA(path
, "kiwi");
6593 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
6594 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6595 ok(!lstrcmpA(path
, "kiwi"),
6596 "Expected path to be unchanged, got \"%s\"\n", path
);
6597 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6599 MsiCloseHandle(hpkg
);
6601 /* compressed source */
6603 r
= MsiOpenDatabaseW(msifileW
, MSIDBOPEN_DIRECT
, &hdb
);
6604 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6606 set_suminfo_prop(hdb
, PID_WORDCOUNT
, msidbSumInfoSourceTypeCompressed
);
6608 r
= package_from_db(hdb
, &hpkg
);
6609 ok(r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
6613 lstrcpyA(path
, "kiwi");
6614 r
= MsiGetSourcePathA(hpkg
, "TARGETDIR", path
, &size
);
6615 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6616 ok(!lstrcmpA(path
, "kiwi"),
6617 "Expected path to be unchanged, got \"%s\"\n", path
);
6618 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6622 lstrcpyA(path
, "kiwi");
6623 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6624 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6625 ok(!lstrcmpA(path
, "kiwi"),
6626 "Expected path to be unchanged, got \"%s\"\n", path
);
6627 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6631 lstrcpyA(path
, "kiwi");
6632 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
6633 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6634 ok(!lstrcmpA(path
, "kiwi"),
6635 "Expected path to be unchanged, got \"%s\"\n", path
);
6636 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6638 /* source path nor the property exist */
6640 lstrcpyA(path
, "kiwi");
6641 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
6642 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6643 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
6644 ok(size
== 0, "Expected 0, got %d\n", size
);
6647 lstrcpyA(path
, "kiwi");
6648 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
6649 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6650 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
6651 ok(size
== 0, "Expected 0, got %d\n", size
);
6655 lstrcpyA(path
, "kiwi");
6656 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
6657 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6658 ok(!lstrcmpA(path
, "kiwi"),
6659 "Expected path to be unchanged, got \"%s\"\n", path
);
6660 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6664 lstrcpyA(path
, "kiwi");
6665 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
6666 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6667 ok(!lstrcmpA(path
, "kiwi"),
6668 "Expected path to be unchanged, got \"%s\"\n", path
);
6669 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6671 r
= MsiDoActionA(hpkg
, "CostInitialize");
6672 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6674 /* try TARGETDIR after CostInitialize */
6676 lstrcpyA(path
, "kiwi");
6677 r
= MsiGetSourcePathA(hpkg
, "TARGETDIR", path
, &size
);
6678 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6679 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6680 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6682 /* try SourceDir after CostInitialize */
6684 lstrcpyA(path
, "kiwi");
6685 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6686 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6687 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6688 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6690 /* try SOURCEDIR after CostInitialize */
6692 lstrcpyA(path
, "kiwi");
6693 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
6696 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6697 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6698 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6701 /* source path does not exist, but the property exists */
6703 lstrcpyA(path
, "kiwi");
6704 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
6705 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6706 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6707 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6710 lstrcpyA(path
, "kiwi");
6711 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
6712 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6713 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6714 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6716 /* try SubDir after CostInitialize */
6718 lstrcpyA(path
, "kiwi");
6719 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
6720 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6721 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6722 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6724 /* try SubDir2 after CostInitialize */
6726 lstrcpyA(path
, "kiwi");
6727 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
6728 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6729 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6730 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6732 r
= MsiDoActionA(hpkg
, "ResolveSource");
6733 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
6735 /* try TARGETDIR after ResolveSource */
6737 lstrcpyA(path
, "kiwi");
6738 r
= MsiGetSourcePathA(hpkg
, "TARGETDIR", path
, &size
);
6739 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6740 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6741 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6743 /* try SourceDir after ResolveSource */
6745 lstrcpyA(path
, "kiwi");
6746 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6747 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6748 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6749 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6751 /* try SOURCEDIR after ResolveSource */
6753 lstrcpyA(path
, "kiwi");
6754 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
6757 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6758 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6759 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6762 /* source path and the property exist */
6764 lstrcpyA(path
, "kiwi");
6765 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
6766 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6767 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6768 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6771 lstrcpyA(path
, "kiwi");
6772 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
6773 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6774 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6775 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6777 /* try SubDir after ResolveSource */
6779 lstrcpyA(path
, "kiwi");
6780 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
6781 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6782 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6783 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6785 /* try SubDir2 after ResolveSource */
6787 lstrcpyA(path
, "kiwi");
6788 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
6789 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6790 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6791 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6793 r
= MsiDoActionA(hpkg
, "FileCost");
6794 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6796 /* try TARGETDIR after CostFinalize */
6798 lstrcpyA(path
, "kiwi");
6799 r
= MsiGetSourcePathA(hpkg
, "TARGETDIR", path
, &size
);
6800 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6801 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6802 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6804 /* try SourceDir after CostFinalize */
6806 lstrcpyA(path
, "kiwi");
6807 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6808 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6809 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6810 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6812 /* try SOURCEDIR after CostFinalize */
6814 lstrcpyA(path
, "kiwi");
6815 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", 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
);
6823 /* source path and the property exist */
6825 lstrcpyA(path
, "kiwi");
6826 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
6827 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6828 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6829 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6832 lstrcpyA(path
, "kiwi");
6833 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
6834 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6835 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6836 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6838 /* try SubDir after CostFinalize */
6840 lstrcpyA(path
, "kiwi");
6841 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
6842 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6843 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6844 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6846 /* try SubDir2 after CostFinalize */
6848 lstrcpyA(path
, "kiwi");
6849 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
6850 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6851 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6852 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6854 r
= MsiDoActionA(hpkg
, "CostFinalize");
6855 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6857 /* try TARGETDIR after CostFinalize */
6859 lstrcpyA(path
, "kiwi");
6860 r
= MsiGetSourcePathA(hpkg
, "TARGETDIR", path
, &size
);
6861 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6862 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6863 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6865 /* try SourceDir after CostFinalize */
6867 lstrcpyA(path
, "kiwi");
6868 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6869 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6870 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6871 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6873 /* try SOURCEDIR after CostFinalize */
6875 lstrcpyA(path
, "kiwi");
6876 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", 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
);
6884 /* source path and the property exist */
6886 lstrcpyA(path
, "kiwi");
6887 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
6888 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6889 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6890 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6893 lstrcpyA(path
, "kiwi");
6894 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
6895 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6896 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6897 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6899 /* try SubDir after CostFinalize */
6901 lstrcpyA(path
, "kiwi");
6902 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
6903 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6904 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6905 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6907 /* try SubDir2 after CostFinalize */
6909 lstrcpyA(path
, "kiwi");
6910 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
6911 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6912 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6913 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6915 MsiCloseHandle(hpkg
);
6916 DeleteFileA(msifile
);
6919 static void test_shortlongsource(void)
6921 MSIHANDLE hdb
, hpkg
;
6922 CHAR path
[MAX_PATH
];
6924 CHAR subsrc
[MAX_PATH
];
6928 lstrcpyA(cwd
, CURR_DIR
);
6929 if (!is_root(CURR_DIR
)) lstrcatA(cwd
, "\\");
6931 lstrcpyA(subsrc
, cwd
);
6932 lstrcatA(subsrc
, "long");
6933 lstrcatA(subsrc
, "\\");
6935 /* long file names */
6937 hdb
= create_package_db();
6938 ok( hdb
, "failed to create database\n");
6940 set_suminfo_prop(hdb
, PID_WORDCOUNT
, 0);
6942 add_directory_entry(hdb
, "'TARGETDIR', '', 'SourceDir'");
6943 add_directory_entry(hdb
, "'SubDir', 'TARGETDIR', 'short|long'");
6945 /* CostInitialize:short */
6946 add_directory_entry(hdb
, "'SubDir2', 'TARGETDIR', 'one|two'");
6948 /* CostInitialize:long */
6949 add_directory_entry(hdb
, "'SubDir3', 'TARGETDIR', 'three|four'");
6951 /* FileCost:short */
6952 add_directory_entry(hdb
, "'SubDir4', 'TARGETDIR', 'five|six'");
6955 add_directory_entry(hdb
, "'SubDir5', 'TARGETDIR', 'seven|eight'");
6957 /* CostFinalize:short */
6958 add_directory_entry(hdb
, "'SubDir6', 'TARGETDIR', 'nine|ten'");
6960 /* CostFinalize:long */
6961 add_directory_entry(hdb
, "'SubDir7', 'TARGETDIR', 'eleven|twelve'");
6963 r
= MsiDatabaseCommit(hdb
);
6964 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
6966 r
= package_from_db(hdb
, &hpkg
);
6967 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
6969 skip("Not enough rights to perform tests\n");
6970 DeleteFileA(msifile
);
6973 ok(r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
6975 MsiCloseHandle(hdb
);
6977 CreateDirectoryA("one", NULL
);
6978 CreateDirectoryA("four", NULL
);
6980 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
6982 r
= MsiDoActionA(hpkg
, "CostInitialize");
6983 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
6985 CreateDirectoryA("five", NULL
);
6986 CreateDirectoryA("eight", NULL
);
6988 r
= MsiDoActionA(hpkg
, "FileCost");
6989 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
6991 CreateDirectoryA("nine", NULL
);
6992 CreateDirectoryA("twelve", NULL
);
6994 r
= MsiDoActionA(hpkg
, "CostFinalize");
6995 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
6997 /* neither short nor long source directories exist */
6999 lstrcpyA(path
, "kiwi");
7000 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
7001 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7002 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7003 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7005 CreateDirectoryA("short", NULL
);
7007 /* short source directory exists */
7009 lstrcpyA(path
, "kiwi");
7010 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
7011 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7012 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7013 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7015 CreateDirectoryA("long", NULL
);
7017 /* both short and long source directories exist */
7019 lstrcpyA(path
, "kiwi");
7020 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
7021 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7022 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7023 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7025 lstrcpyA(subsrc
, cwd
);
7026 lstrcatA(subsrc
, "two");
7027 lstrcatA(subsrc
, "\\");
7029 /* short dir exists before CostInitialize */
7031 lstrcpyA(path
, "kiwi");
7032 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
7033 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7034 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7035 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7037 lstrcpyA(subsrc
, cwd
);
7038 lstrcatA(subsrc
, "four");
7039 lstrcatA(subsrc
, "\\");
7041 /* long dir exists before CostInitialize */
7043 lstrcpyA(path
, "kiwi");
7044 r
= MsiGetSourcePathA(hpkg
, "SubDir3", path
, &size
);
7045 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7046 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7047 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7049 lstrcpyA(subsrc
, cwd
);
7050 lstrcatA(subsrc
, "six");
7051 lstrcatA(subsrc
, "\\");
7053 /* short dir exists before FileCost */
7055 lstrcpyA(path
, "kiwi");
7056 r
= MsiGetSourcePathA(hpkg
, "SubDir4", path
, &size
);
7057 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7058 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7059 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7061 lstrcpyA(subsrc
, cwd
);
7062 lstrcatA(subsrc
, "eight");
7063 lstrcatA(subsrc
, "\\");
7065 /* long dir exists before FileCost */
7067 lstrcpyA(path
, "kiwi");
7068 r
= MsiGetSourcePathA(hpkg
, "SubDir5", path
, &size
);
7069 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7070 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7071 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7073 lstrcpyA(subsrc
, cwd
);
7074 lstrcatA(subsrc
, "ten");
7075 lstrcatA(subsrc
, "\\");
7077 /* short dir exists before CostFinalize */
7079 lstrcpyA(path
, "kiwi");
7080 r
= MsiGetSourcePathA(hpkg
, "SubDir6", path
, &size
);
7081 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7082 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7083 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7085 lstrcpyA(subsrc
, cwd
);
7086 lstrcatA(subsrc
, "twelve");
7087 lstrcatA(subsrc
, "\\");
7089 /* long dir exists before CostFinalize */
7091 lstrcpyA(path
, "kiwi");
7092 r
= MsiGetSourcePathA(hpkg
, "SubDir7", path
, &size
);
7093 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7094 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7095 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7097 MsiCloseHandle(hpkg
);
7098 RemoveDirectoryA("short");
7099 RemoveDirectoryA("long");
7100 RemoveDirectoryA("one");
7101 RemoveDirectoryA("four");
7102 RemoveDirectoryA("five");
7103 RemoveDirectoryA("eight");
7104 RemoveDirectoryA("nine");
7105 RemoveDirectoryA("twelve");
7107 /* short file names */
7109 r
= MsiOpenDatabaseW(msifileW
, MSIDBOPEN_DIRECT
, &hdb
);
7110 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7112 set_suminfo_prop(hdb
, PID_WORDCOUNT
, msidbSumInfoSourceTypeSFN
);
7114 r
= package_from_db(hdb
, &hpkg
);
7115 ok(r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
7117 MsiCloseHandle(hdb
);
7119 CreateDirectoryA("one", NULL
);
7120 CreateDirectoryA("four", NULL
);
7122 r
= MsiDoActionA(hpkg
, "CostInitialize");
7123 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7125 CreateDirectoryA("five", NULL
);
7126 CreateDirectoryA("eight", NULL
);
7128 r
= MsiDoActionA(hpkg
, "FileCost");
7129 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7131 CreateDirectoryA("nine", NULL
);
7132 CreateDirectoryA("twelve", NULL
);
7134 r
= MsiDoActionA(hpkg
, "CostFinalize");
7135 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7137 lstrcpyA(subsrc
, cwd
);
7138 lstrcatA(subsrc
, "short");
7139 lstrcatA(subsrc
, "\\");
7141 /* neither short nor long source directories exist */
7143 lstrcpyA(path
, "kiwi");
7144 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
7145 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7146 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7147 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7149 CreateDirectoryA("short", NULL
);
7151 /* short source directory exists */
7153 lstrcpyA(path
, "kiwi");
7154 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
7155 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7156 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7157 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7159 CreateDirectoryA("long", NULL
);
7161 /* both short and long source directories exist */
7163 lstrcpyA(path
, "kiwi");
7164 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
7165 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7166 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7167 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7169 lstrcpyA(subsrc
, cwd
);
7170 lstrcatA(subsrc
, "one");
7171 lstrcatA(subsrc
, "\\");
7173 /* short dir exists before CostInitialize */
7175 lstrcpyA(path
, "kiwi");
7176 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
7177 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7178 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7179 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7181 lstrcpyA(subsrc
, cwd
);
7182 lstrcatA(subsrc
, "three");
7183 lstrcatA(subsrc
, "\\");
7185 /* long dir exists before CostInitialize */
7187 lstrcpyA(path
, "kiwi");
7188 r
= MsiGetSourcePathA(hpkg
, "SubDir3", path
, &size
);
7189 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7190 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7191 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7193 lstrcpyA(subsrc
, cwd
);
7194 lstrcatA(subsrc
, "five");
7195 lstrcatA(subsrc
, "\\");
7197 /* short dir exists before FileCost */
7199 lstrcpyA(path
, "kiwi");
7200 r
= MsiGetSourcePathA(hpkg
, "SubDir4", path
, &size
);
7201 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7202 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7203 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7205 lstrcpyA(subsrc
, cwd
);
7206 lstrcatA(subsrc
, "seven");
7207 lstrcatA(subsrc
, "\\");
7209 /* long dir exists before FileCost */
7211 lstrcpyA(path
, "kiwi");
7212 r
= MsiGetSourcePathA(hpkg
, "SubDir5", path
, &size
);
7213 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7214 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7215 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7217 lstrcpyA(subsrc
, cwd
);
7218 lstrcatA(subsrc
, "nine");
7219 lstrcatA(subsrc
, "\\");
7221 /* short dir exists before CostFinalize */
7223 lstrcpyA(path
, "kiwi");
7224 r
= MsiGetSourcePathA(hpkg
, "SubDir6", path
, &size
);
7225 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7226 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7227 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7229 lstrcpyA(subsrc
, cwd
);
7230 lstrcatA(subsrc
, "eleven");
7231 lstrcatA(subsrc
, "\\");
7233 /* long dir exists before CostFinalize */
7235 lstrcpyA(path
, "kiwi");
7236 r
= MsiGetSourcePathA(hpkg
, "SubDir7", path
, &size
);
7237 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7238 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7239 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7241 MsiCloseHandle(hpkg
);
7242 RemoveDirectoryA("short");
7243 RemoveDirectoryA("long");
7244 RemoveDirectoryA("one");
7245 RemoveDirectoryA("four");
7246 RemoveDirectoryA("five");
7247 RemoveDirectoryA("eight");
7248 RemoveDirectoryA("nine");
7249 RemoveDirectoryA("twelve");
7250 DeleteFileA(msifile
);
7253 static void test_sourcedir(void)
7255 MSIHANDLE hdb
, hpkg
;
7257 CHAR path
[MAX_PATH
];
7259 CHAR subsrc
[MAX_PATH
];
7263 lstrcpyA(cwd
, CURR_DIR
);
7264 if (!is_root(CURR_DIR
)) lstrcatA(cwd
, "\\");
7266 lstrcpyA(subsrc
, cwd
);
7267 lstrcatA(subsrc
, "long");
7268 lstrcatA(subsrc
, "\\");
7270 hdb
= create_package_db();
7271 ok( hdb
, "failed to create database\n");
7273 add_directory_entry(hdb
, "'TARGETDIR', '', 'SourceDir'");
7275 sprintf(package
, "#%u", hdb
);
7276 r
= MsiOpenPackageA(package
, &hpkg
);
7277 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
7279 skip("Not enough rights to perform tests\n");
7282 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7284 /* properties only */
7286 /* SourceDir prop */
7288 lstrcpyA(path
, "kiwi");
7289 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7290 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7291 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7292 ok(size
== 0, "Expected 0, got %d\n", size
);
7294 /* SOURCEDIR prop */
7296 lstrcpyA(path
, "kiwi");
7297 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7298 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7299 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7300 ok(size
== 0, "Expected 0, got %d\n", size
);
7302 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
7304 r
= MsiDoActionA(hpkg
, "CostInitialize");
7305 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7307 /* SourceDir after CostInitialize */
7309 lstrcpyA(path
, "kiwi");
7310 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7311 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7312 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7313 ok(size
== 0, "Expected 0, got %d\n", size
);
7315 /* SOURCEDIR after CostInitialize */
7317 lstrcpyA(path
, "kiwi");
7318 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7319 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7320 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7321 ok(size
== 0, "Expected 0, got %d\n", size
);
7323 r
= MsiDoActionA(hpkg
, "FileCost");
7324 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7326 /* SourceDir after FileCost */
7328 lstrcpyA(path
, "kiwi");
7329 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7330 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7331 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7332 ok(size
== 0, "Expected 0, got %d\n", size
);
7334 /* SOURCEDIR after FileCost */
7336 lstrcpyA(path
, "kiwi");
7337 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7338 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7339 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7340 ok(size
== 0, "Expected 0, got %d\n", size
);
7342 r
= MsiDoActionA(hpkg
, "CostFinalize");
7343 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7345 /* SourceDir after CostFinalize */
7347 lstrcpyA(path
, "kiwi");
7348 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7349 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7350 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7351 ok(size
== 0, "Expected 0, got %d\n", size
);
7353 /* SOURCEDIR after CostFinalize */
7355 lstrcpyA(path
, "kiwi");
7356 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7357 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7358 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7359 ok(size
== 0, "Expected 0, got %d\n", size
);
7362 lstrcpyA(path
, "kiwi");
7363 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
7364 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
7365 ok(!lstrcmpA(path
, "kiwi"), "Expected \"kiwi\", got \"%s\"\n", path
);
7366 ok(size
== MAX_PATH
, "Expected %d, got %d\n", MAX_PATH
, size
);
7368 /* SOURCEDIR after calling MsiGetSourcePath */
7370 lstrcpyA(path
, "kiwi");
7371 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7372 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7374 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7375 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7378 r
= MsiDoActionA(hpkg
, "ResolveSource");
7379 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7381 /* SourceDir after ResolveSource */
7383 lstrcpyA(path
, "kiwi");
7384 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7385 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7386 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7387 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7389 /* SOURCEDIR after ResolveSource */
7391 lstrcpyA(path
, "kiwi");
7392 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7393 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7394 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7395 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7399 lstrcpyA(path
, "kiwi");
7400 r
= MsiGetPropertyA(hpkg
, "SoUrCeDiR", path
, &size
);
7401 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7402 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7403 ok(size
== 0, "Expected 0, got %d\n", size
);
7405 MsiCloseHandle(hpkg
);
7407 /* reset the package state */
7408 sprintf(package
, "#%i", hdb
);
7409 r
= MsiOpenPackageA(package
, &hpkg
);
7410 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7412 /* test how MsiGetSourcePath affects the properties */
7414 /* SourceDir prop */
7416 lstrcpyA(path
, "kiwi");
7417 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7418 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7421 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7422 ok(size
== 0, "Expected 0, got %d\n", size
);
7426 lstrcpyA(path
, "kiwi");
7427 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
7428 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
7429 ok(!lstrcmpA(path
, "kiwi"),
7430 "Expected path to be unchanged, got \"%s\"\n", path
);
7431 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
7433 /* SourceDir after MsiGetSourcePath */
7435 lstrcpyA(path
, "kiwi");
7436 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7437 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7440 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7441 ok(size
== 0, "Expected 0, got %d\n", size
);
7444 /* SOURCEDIR prop */
7446 lstrcpyA(path
, "kiwi");
7447 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7448 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7451 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7452 ok(size
== 0, "Expected 0, got %d\n", size
);
7456 lstrcpyA(path
, "kiwi");
7457 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
7458 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
7459 ok(!lstrcmpA(path
, "kiwi"),
7460 "Expected path to be unchanged, got \"%s\"\n", path
);
7461 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
7463 /* SOURCEDIR prop after MsiGetSourcePath */
7465 lstrcpyA(path
, "kiwi");
7466 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7467 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7470 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7471 ok(size
== 0, "Expected 0, got %d\n", size
);
7474 r
= MsiDoActionA(hpkg
, "CostInitialize");
7475 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7477 /* SourceDir after CostInitialize */
7479 lstrcpyA(path
, "kiwi");
7480 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7481 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7484 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7485 ok(size
== 0, "Expected 0, got %d\n", size
);
7489 lstrcpyA(path
, "kiwi");
7490 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
7491 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7492 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7493 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7495 /* SourceDir after MsiGetSourcePath */
7497 lstrcpyA(path
, "kiwi");
7498 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7499 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7500 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7501 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7503 /* SOURCEDIR after CostInitialize */
7505 lstrcpyA(path
, "kiwi");
7506 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7507 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7508 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7509 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7511 /* SOURCEDIR source path still does not exist */
7513 lstrcpyA(path
, "kiwi");
7514 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
7515 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
7516 ok(!lstrcmpA(path
, "kiwi"),
7517 "Expected path to be unchanged, got \"%s\"\n", path
);
7518 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
7520 r
= MsiDoActionA(hpkg
, "FileCost");
7521 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7523 /* SourceDir after FileCost */
7525 lstrcpyA(path
, "kiwi");
7526 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7527 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7528 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7529 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7531 /* SOURCEDIR after FileCost */
7533 lstrcpyA(path
, "kiwi");
7534 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7535 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7536 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7537 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7539 /* SOURCEDIR source path still does not exist */
7541 lstrcpyA(path
, "kiwi");
7542 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
7543 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
7544 ok(!lstrcmpA(path
, "kiwi"),
7545 "Expected path to be unchanged, got \"%s\"\n", path
);
7546 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
7548 r
= MsiDoActionA(hpkg
, "CostFinalize");
7549 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7551 /* SourceDir after CostFinalize */
7553 lstrcpyA(path
, "kiwi");
7554 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7555 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7556 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7557 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7559 /* SOURCEDIR after CostFinalize */
7561 lstrcpyA(path
, "kiwi");
7562 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7563 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7564 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7565 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7567 /* SOURCEDIR source path still does not exist */
7569 lstrcpyA(path
, "kiwi");
7570 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
7571 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
7572 ok(!lstrcmpA(path
, "kiwi"),
7573 "Expected path to be unchanged, got \"%s\"\n", path
);
7574 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
7576 r
= MsiDoActionA(hpkg
, "ResolveSource");
7577 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7579 /* SourceDir after ResolveSource */
7581 lstrcpyA(path
, "kiwi");
7582 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7583 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7584 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7585 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7587 /* SOURCEDIR after ResolveSource */
7589 lstrcpyA(path
, "kiwi");
7590 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7591 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7592 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7593 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7595 /* SOURCEDIR source path still does not exist */
7597 lstrcpyA(path
, "kiwi");
7598 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
7599 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
7600 ok(!lstrcmpA(path
, "kiwi"),
7601 "Expected path to be unchanged, got \"%s\"\n", path
);
7602 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
7604 MsiCloseHandle(hpkg
);
7607 MsiCloseHandle(hdb
);
7608 DeleteFileA(msifile
);
7618 static const struct access_res create
[16] =
7620 { TRUE
, ERROR_SUCCESS
, TRUE
},
7621 { TRUE
, ERROR_SUCCESS
, TRUE
},
7622 { TRUE
, ERROR_SUCCESS
, FALSE
},
7623 { TRUE
, ERROR_SUCCESS
, FALSE
},
7624 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7625 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7626 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7627 { TRUE
, ERROR_SUCCESS
, FALSE
},
7628 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7629 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7630 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7631 { TRUE
, ERROR_SUCCESS
, TRUE
},
7632 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7633 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7634 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7635 { TRUE
, ERROR_SUCCESS
, TRUE
}
7638 static const struct access_res create_commit
[16] =
7640 { TRUE
, ERROR_SUCCESS
, TRUE
},
7641 { TRUE
, ERROR_SUCCESS
, TRUE
},
7642 { TRUE
, ERROR_SUCCESS
, FALSE
},
7643 { TRUE
, ERROR_SUCCESS
, FALSE
},
7644 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7645 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7646 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7647 { TRUE
, ERROR_SUCCESS
, FALSE
},
7648 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7649 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7650 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7651 { TRUE
, ERROR_SUCCESS
, TRUE
},
7652 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7653 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7654 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7655 { TRUE
, ERROR_SUCCESS
, TRUE
}
7658 static const struct access_res create_close
[16] =
7660 { TRUE
, ERROR_SUCCESS
, FALSE
},
7661 { TRUE
, ERROR_SUCCESS
, FALSE
},
7662 { TRUE
, ERROR_SUCCESS
, FALSE
},
7663 { TRUE
, ERROR_SUCCESS
, FALSE
},
7664 { TRUE
, ERROR_SUCCESS
, FALSE
},
7665 { TRUE
, ERROR_SUCCESS
, FALSE
},
7666 { TRUE
, ERROR_SUCCESS
, FALSE
},
7667 { TRUE
, ERROR_SUCCESS
, FALSE
},
7668 { TRUE
, ERROR_SUCCESS
, FALSE
},
7669 { TRUE
, ERROR_SUCCESS
, FALSE
},
7670 { TRUE
, ERROR_SUCCESS
, FALSE
},
7671 { TRUE
, ERROR_SUCCESS
, FALSE
},
7672 { TRUE
, ERROR_SUCCESS
, FALSE
},
7673 { TRUE
, ERROR_SUCCESS
, FALSE
},
7674 { TRUE
, ERROR_SUCCESS
, FALSE
},
7675 { TRUE
, ERROR_SUCCESS
}
7678 static void _test_file_access(LPCSTR file
, const struct access_res
*ares
, DWORD line
)
7680 DWORD access
= 0, share
= 0;
7685 for (i
= 0; i
< 4; i
++)
7687 if (i
== 0) access
= 0;
7688 if (i
== 1) access
= GENERIC_READ
;
7689 if (i
== 2) access
= GENERIC_WRITE
;
7690 if (i
== 3) access
= GENERIC_READ
| GENERIC_WRITE
;
7692 for (j
= 0; j
< 4; j
++)
7694 if (ares
[idx
].ignore
)
7697 if (j
== 0) share
= 0;
7698 if (j
== 1) share
= FILE_SHARE_READ
;
7699 if (j
== 2) share
= FILE_SHARE_WRITE
;
7700 if (j
== 3) share
= FILE_SHARE_READ
| FILE_SHARE_WRITE
;
7702 SetLastError(0xdeadbeef);
7703 hfile
= CreateFileA(file
, access
, share
, NULL
, OPEN_EXISTING
,
7704 FILE_ATTRIBUTE_NORMAL
, 0);
7705 lasterr
= GetLastError();
7707 ok((hfile
!= INVALID_HANDLE_VALUE
) == ares
[idx
].gothandle
,
7708 "(%d, handle, %d): Expected %d, got %d\n",
7709 line
, idx
, ares
[idx
].gothandle
,
7710 (hfile
!= INVALID_HANDLE_VALUE
));
7712 ok(lasterr
== ares
[idx
].lasterr
, "(%d, lasterr, %d): Expected %d, got %d\n",
7713 line
, idx
, ares
[idx
].lasterr
, lasterr
);
7721 #define test_file_access(file, ares) _test_file_access(file, ares, __LINE__)
7723 static void test_access(void)
7728 r
= MsiOpenDatabaseW(msifileW
, MSIDBOPEN_CREATE
, &hdb
);
7729 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7731 test_file_access(msifile
, create
);
7733 r
= MsiDatabaseCommit(hdb
);
7734 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7736 test_file_access(msifile
, create_commit
);
7737 MsiCloseHandle(hdb
);
7739 test_file_access(msifile
, create_close
);
7740 DeleteFileA(msifile
);
7742 r
= MsiOpenDatabaseW(msifileW
, MSIDBOPEN_CREATEDIRECT
, &hdb
);
7743 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7745 test_file_access(msifile
, create
);
7747 r
= MsiDatabaseCommit(hdb
);
7748 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7750 test_file_access(msifile
, create_commit
);
7751 MsiCloseHandle(hdb
);
7753 test_file_access(msifile
, create_close
);
7754 DeleteFileA(msifile
);
7757 static void test_emptypackage(void)
7759 MSIHANDLE hpkg
= 0, hdb
= 0, hsuminfo
= 0;
7760 MSIHANDLE hview
= 0, hrec
= 0;
7761 MSICONDITION condition
;
7762 CHAR buffer
[MAX_PATH
];
7766 r
= MsiOpenPackageA("", &hpkg
);
7767 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
7769 skip("Not enough rights to perform tests\n");
7774 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7777 hdb
= MsiGetActiveDatabase(hpkg
);
7780 ok(hdb
!= 0, "Expected a valid database handle\n");
7783 r
= MsiDatabaseOpenViewA(hdb
, "SELECT * FROM `_Tables`", &hview
);
7786 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7788 r
= MsiViewExecute(hview
, 0);
7791 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7794 r
= MsiViewFetch(hview
, &hrec
);
7797 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7802 r
= MsiRecordGetStringA(hrec
, 1, buffer
, &size
);
7805 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7806 ok(!lstrcmpA(buffer
, "_Property"),
7807 "Expected \"_Property\", got \"%s\"\n", buffer
);
7810 MsiCloseHandle(hrec
);
7812 r
= MsiViewFetch(hview
, &hrec
);
7815 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7819 r
= MsiRecordGetStringA(hrec
, 1, buffer
, &size
);
7822 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7823 ok(!lstrcmpA(buffer
, "#_FolderCache"),
7824 "Expected \"_Property\", got \"%s\"\n", buffer
);
7827 MsiCloseHandle(hrec
);
7828 MsiViewClose(hview
);
7829 MsiCloseHandle(hview
);
7831 condition
= MsiDatabaseIsTablePersistentA(hdb
, "_Property");
7834 ok(condition
== MSICONDITION_FALSE
,
7835 "Expected MSICONDITION_FALSE, got %d\n", condition
);
7838 r
= MsiDatabaseOpenViewA(hdb
, "SELECT * FROM `_Property`", &hview
);
7841 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7843 r
= MsiViewExecute(hview
, 0);
7846 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7849 /* _Property table is not empty */
7850 r
= MsiViewFetch(hview
, &hrec
);
7853 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7856 MsiCloseHandle(hrec
);
7857 MsiViewClose(hview
);
7858 MsiCloseHandle(hview
);
7860 condition
= MsiDatabaseIsTablePersistentA(hdb
, "#_FolderCache");
7863 ok(condition
== MSICONDITION_FALSE
,
7864 "Expected MSICONDITION_FALSE, got %d\n", condition
);
7867 r
= MsiDatabaseOpenViewA(hdb
, "SELECT * FROM `#_FolderCache`", &hview
);
7870 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7872 r
= MsiViewExecute(hview
, 0);
7875 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7878 /* #_FolderCache is not empty */
7879 r
= MsiViewFetch(hview
, &hrec
);
7882 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7885 MsiCloseHandle(hrec
);
7886 MsiViewClose(hview
);
7887 MsiCloseHandle(hview
);
7889 r
= MsiDatabaseOpenViewA(hdb
, "SELECT * FROM `_Streams`", &hview
);
7892 ok(r
== ERROR_BAD_QUERY_SYNTAX
,
7893 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r
);
7896 r
= MsiDatabaseOpenViewA(hdb
, "SELECT * FROM `_Storages`", &hview
);
7899 ok(r
== ERROR_BAD_QUERY_SYNTAX
,
7900 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r
);
7903 r
= MsiGetSummaryInformationA(hdb
, NULL
, 0, &hsuminfo
);
7906 ok(r
== ERROR_INSTALL_PACKAGE_INVALID
,
7907 "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r
);
7910 MsiCloseHandle(hsuminfo
);
7912 r
= MsiDatabaseCommit(hdb
);
7915 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7918 MsiCloseHandle(hdb
);
7919 MsiCloseHandle(hpkg
);
7922 static void test_MsiGetProductProperty(void)
7924 static const WCHAR prodcode_propW
[] = {'P','r','o','d','u','c','t','C','o','d','e',0};
7925 static const WCHAR nonexistentW
[] = {'I','D','o','n','t','E','x','i','s','t',0};
7926 static const WCHAR newpropW
[] = {'N','e','w','P','r','o','p','e','r','t','y',0};
7927 static const WCHAR appleW
[] = {'a','p','p','l','e',0};
7928 static const WCHAR emptyW
[] = {0};
7929 WCHAR valW
[MAX_PATH
];
7930 MSIHANDLE hprod
, hdb
;
7932 CHAR path
[MAX_PATH
];
7933 CHAR query
[MAX_PATH
];
7934 CHAR keypath
[MAX_PATH
*2];
7935 CHAR prodcode
[MAX_PATH
];
7936 WCHAR prodcodeW
[MAX_PATH
];
7937 CHAR prod_squashed
[MAX_PATH
];
7938 WCHAR prod_squashedW
[MAX_PATH
];
7939 HKEY prodkey
, userkey
, props
;
7943 REGSAM access
= KEY_ALL_ACCESS
;
7945 GetCurrentDirectoryA(MAX_PATH
, path
);
7946 lstrcatA(path
, "\\");
7948 create_test_guid(prodcode
, prod_squashed
);
7949 MultiByteToWideChar(CP_ACP
, 0, prodcode
, -1, prodcodeW
, MAX_PATH
);
7950 squash_guid(prodcodeW
, prod_squashedW
);
7953 access
|= KEY_WOW64_64KEY
;
7955 r
= MsiOpenDatabaseW(msifileW
, MSIDBOPEN_CREATE
, &hdb
);
7956 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7958 r
= MsiDatabaseCommit(hdb
);
7959 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7961 r
= set_summary_info(hdb
);
7962 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7965 "CREATE TABLE `Directory` ( "
7966 "`Directory` CHAR(255) NOT NULL, "
7967 "`Directory_Parent` CHAR(255), "
7968 "`DefaultDir` CHAR(255) NOT NULL "
7969 "PRIMARY KEY `Directory`)");
7970 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7972 create_property_table(hdb
);
7974 sprintf(query
, "'ProductCode', '%s'", prodcode
);
7975 r
= add_property_entry(hdb
, query
);
7977 r
= MsiDatabaseCommit(hdb
);
7978 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7980 MsiCloseHandle(hdb
);
7982 lstrcpyA(keypath
, "Software\\Classes\\Installer\\Products\\");
7983 lstrcatA(keypath
, prod_squashed
);
7985 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
7986 if (res
== ERROR_ACCESS_DENIED
)
7988 skip("Not enough rights to perform tests\n");
7989 DeleteFileA(msifile
);
7992 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7994 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
7995 lstrcatA(keypath
, "Installer\\UserData\\S-1-5-18\\Products\\");
7996 lstrcatA(keypath
, prod_squashed
);
7998 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &userkey
, NULL
);
7999 if (res
== ERROR_ACCESS_DENIED
)
8001 skip("Not enough rights to perform tests\n");
8002 RegDeleteKeyA(prodkey
, "");
8003 RegCloseKey(prodkey
);
8006 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8008 res
= RegCreateKeyExA(userkey
, "InstallProperties", 0, NULL
, 0, access
, NULL
, &props
, NULL
);
8009 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8011 lstrcpyA(val
, path
);
8012 lstrcatA(val
, "\\");
8013 lstrcatA(val
, msifile
);
8014 res
= RegSetValueExA(props
, "LocalPackage", 0, REG_SZ
,
8015 (const BYTE
*)val
, lstrlenA(val
) + 1);
8016 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8019 r
= MsiOpenProductA(prodcode
, &hprod
);
8020 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8021 ok(hprod
!= 0 && hprod
!= 0xdeadbeef, "Expected a valid product handle\n");
8023 /* hProduct is invalid */
8025 lstrcpyA(val
, "apple");
8026 r
= MsiGetProductPropertyA(0xdeadbeef, "ProductCode", val
, &size
);
8027 ok(r
== ERROR_INVALID_HANDLE
,
8028 "Expected ERROR_INVALID_HANDLE, got %d\n", r
);
8029 ok(!lstrcmpA(val
, "apple"),
8030 "Expected val to be unchanged, got \"%s\"\n", val
);
8031 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
8034 lstrcpyW(valW
, appleW
);
8035 r
= MsiGetProductPropertyW(0xdeadbeef, prodcode_propW
, valW
, &size
);
8036 ok(r
== ERROR_INVALID_HANDLE
,
8037 "Expected ERROR_INVALID_HANDLE, got %d\n", r
);
8038 ok(!lstrcmpW(valW
, appleW
),
8039 "Expected val to be unchanged, got %s\n", wine_dbgstr_w(valW
));
8040 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
8042 /* szProperty is NULL */
8044 lstrcpyA(val
, "apple");
8045 r
= MsiGetProductPropertyA(hprod
, NULL
, val
, &size
);
8046 ok(r
== ERROR_INVALID_PARAMETER
,
8047 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
8048 ok(!lstrcmpA(val
, "apple"),
8049 "Expected val to be unchanged, got \"%s\"\n", val
);
8050 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
8053 lstrcpyW(valW
, appleW
);
8054 r
= MsiGetProductPropertyW(hprod
, NULL
, valW
, &size
);
8055 ok(r
== ERROR_INVALID_PARAMETER
,
8056 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
8057 ok(!lstrcmpW(valW
, appleW
),
8058 "Expected val to be unchanged, got %s\n", wine_dbgstr_w(valW
));
8059 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
8061 /* szProperty is empty */
8063 lstrcpyA(val
, "apple");
8064 r
= MsiGetProductPropertyA(hprod
, "", val
, &size
);
8065 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8066 ok(!lstrcmpA(val
, ""), "Expected \"\", got \"%s\"\n", val
);
8067 ok(size
== 0, "Expected 0, got %d\n", size
);
8070 lstrcpyW(valW
, appleW
);
8071 r
= MsiGetProductPropertyW(hprod
, emptyW
, valW
, &size
);
8072 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8073 ok(*valW
== 0, "Expected \"\", got %s\n", wine_dbgstr_w(valW
));
8074 ok(size
== 0, "Expected 0, got %d\n", size
);
8076 /* get the property */
8078 lstrcpyA(val
, "apple");
8079 r
= MsiGetProductPropertyA(hprod
, "ProductCode", val
, &size
);
8080 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8081 ok(!lstrcmpA(val
, prodcode
),
8082 "Expected \"%s\", got \"%s\"\n", prodcode
, val
);
8083 ok(size
== lstrlenA(prodcode
),
8084 "Expected %d, got %d\n", lstrlenA(prodcode
), size
);
8087 lstrcpyW(valW
, appleW
);
8088 r
= MsiGetProductPropertyW(hprod
, prodcode_propW
, valW
, &size
);
8089 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8090 ok(!lstrcmpW(valW
, prodcodeW
),
8091 "Expected %s, got %s\n", wine_dbgstr_w(prodcodeW
), wine_dbgstr_w(valW
));
8092 ok(size
== lstrlenW(prodcodeW
),
8093 "Expected %d, got %d\n", lstrlenW(prodcodeW
), size
);
8095 /* lpValueBuf is NULL */
8097 r
= MsiGetProductPropertyA(hprod
, "ProductCode", NULL
, &size
);
8098 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8099 ok(size
== lstrlenA(prodcode
),
8100 "Expected %d, got %d\n", lstrlenA(prodcode
), size
);
8103 r
= MsiGetProductPropertyW(hprod
, prodcode_propW
, NULL
, &size
);
8104 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8105 ok(size
== lstrlenW(prodcodeW
),
8106 "Expected %d, got %d\n", lstrlenW(prodcodeW
), size
);
8108 /* pcchValueBuf is NULL */
8109 lstrcpyA(val
, "apple");
8110 r
= MsiGetProductPropertyA(hprod
, "ProductCode", val
, NULL
);
8111 ok(r
== ERROR_INVALID_PARAMETER
,
8112 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
8113 ok(!lstrcmpA(val
, "apple"),
8114 "Expected val to be unchanged, got \"%s\"\n", val
);
8115 ok(size
== lstrlenA(prodcode
),
8116 "Expected %d, got %d\n", lstrlenA(prodcode
), size
);
8118 lstrcpyW(valW
, appleW
);
8119 r
= MsiGetProductPropertyW(hprod
, prodcode_propW
, valW
, NULL
);
8120 ok(r
== ERROR_INVALID_PARAMETER
,
8121 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
8122 ok(!lstrcmpW(valW
, appleW
),
8123 "Expected val to be unchanged, got %s\n", wine_dbgstr_w(valW
));
8124 ok(size
== lstrlenW(prodcodeW
),
8125 "Expected %d, got %d\n", lstrlenW(prodcodeW
), size
);
8127 /* pcchValueBuf is too small */
8129 lstrcpyA(val
, "apple");
8130 r
= MsiGetProductPropertyA(hprod
, "ProductCode", val
, &size
);
8131 ok(r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
8132 ok(!strncmp(val
, prodcode
, 3),
8133 "Expected first 3 chars of \"%s\", got \"%s\"\n", prodcode
, val
);
8134 ok(size
== lstrlenA(prodcode
),
8135 "Expected %d, got %d\n", lstrlenA(prodcode
), size
);
8138 lstrcpyW(valW
, appleW
);
8139 r
= MsiGetProductPropertyW(hprod
, prodcode_propW
, valW
, &size
);
8140 ok(r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
8141 ok(!memcmp(valW
, prodcodeW
, 3 * sizeof(WCHAR
)),
8142 "Expected first 3 chars of %s, got %s\n", wine_dbgstr_w(prodcodeW
), wine_dbgstr_w(valW
));
8143 ok(size
== lstrlenW(prodcodeW
),
8144 "Expected %d, got %d\n", lstrlenW(prodcodeW
), size
);
8146 /* pcchValueBuf does not leave room for NULL terminator */
8147 size
= lstrlenA(prodcode
);
8148 lstrcpyA(val
, "apple");
8149 r
= MsiGetProductPropertyA(hprod
, "ProductCode", val
, &size
);
8150 ok(r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
8151 ok(!strncmp(val
, prodcode
, lstrlenA(prodcode
) - 1),
8152 "Expected first 37 chars of \"%s\", got \"%s\"\n", prodcode
, val
);
8153 ok(size
== lstrlenA(prodcode
),
8154 "Expected %d, got %d\n", lstrlenA(prodcode
), size
);
8156 size
= lstrlenW(prodcodeW
);
8157 lstrcpyW(valW
, appleW
);
8158 r
= MsiGetProductPropertyW(hprod
, prodcode_propW
, valW
, &size
);
8159 ok(r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
8160 ok(!memcmp(valW
, prodcodeW
, lstrlenW(prodcodeW
) - 1),
8161 "Expected first 37 chars of %s, got %s\n", wine_dbgstr_w(prodcodeW
), wine_dbgstr_w(valW
));
8162 ok(size
== lstrlenW(prodcodeW
),
8163 "Expected %d, got %d\n", lstrlenW(prodcodeW
), size
);
8165 /* pcchValueBuf has enough room for NULL terminator */
8166 size
= lstrlenA(prodcode
) + 1;
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
);
8175 size
= lstrlenW(prodcodeW
) + 1;
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 /* nonexistent property */
8186 lstrcpyA(val
, "apple");
8187 r
= MsiGetProductPropertyA(hprod
, "IDontExist", val
, &size
);
8188 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8189 ok(!lstrcmpA(val
, ""), "Expected \"\", got \"%s\"\n", val
);
8190 ok(size
== 0, "Expected 0, got %d\n", size
);
8193 lstrcpyW(valW
, appleW
);
8194 r
= MsiGetProductPropertyW(hprod
, nonexistentW
, valW
, &size
);
8195 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8196 ok(!lstrcmpW(valW
, emptyW
), "Expected \"\", got %s\n", wine_dbgstr_w(valW
));
8197 ok(size
== 0, "Expected 0, got %d\n", size
);
8199 r
= MsiSetPropertyA(hprod
, "NewProperty", "value");
8200 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8202 /* non-product property set */
8204 lstrcpyA(val
, "apple");
8205 r
= MsiGetProductPropertyA(hprod
, "NewProperty", val
, &size
);
8206 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8207 ok(!lstrcmpA(val
, ""), "Expected \"\", got \"%s\"\n", val
);
8208 ok(size
== 0, "Expected 0, got %d\n", size
);
8211 lstrcpyW(valW
, appleW
);
8212 r
= MsiGetProductPropertyW(hprod
, newpropW
, valW
, &size
);
8213 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8214 ok(!lstrcmpW(valW
, emptyW
), "Expected \"\", got %s\n", wine_dbgstr_w(valW
));
8215 ok(size
== 0, "Expected 0, got %d\n", size
);
8217 r
= MsiSetPropertyA(hprod
, "ProductCode", "value");
8218 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8220 /* non-product property that is also a product property set */
8222 lstrcpyA(val
, "apple");
8223 r
= MsiGetProductPropertyA(hprod
, "ProductCode", val
, &size
);
8224 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8225 ok(!lstrcmpA(val
, prodcode
),
8226 "Expected \"%s\", got \"%s\"\n", prodcode
, val
);
8227 ok(size
== lstrlenA(prodcode
),
8228 "Expected %d, got %d\n", lstrlenA(prodcode
), size
);
8231 lstrcpyW(valW
, appleW
);
8232 r
= MsiGetProductPropertyW(hprod
, prodcode_propW
, valW
, &size
);
8233 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8234 ok(!lstrcmpW(valW
, prodcodeW
),
8235 "Expected %s, got %s\n", wine_dbgstr_w(prodcodeW
), wine_dbgstr_w(valW
));
8236 ok(size
== lstrlenW(prodcodeW
),
8237 "Expected %d, got %d\n", lstrlenW(prodcodeW
), size
);
8239 MsiCloseHandle(hprod
);
8241 RegDeleteValueA(props
, "LocalPackage");
8242 delete_key(props
, "", access
);
8244 delete_key(userkey
, "", access
);
8245 RegCloseKey(userkey
);
8246 delete_key(prodkey
, "", access
);
8247 RegCloseKey(prodkey
);
8248 DeleteFileA(msifile
);
8251 static void test_MsiSetProperty(void)
8253 MSIHANDLE hpkg
, hdb
, hrec
;
8259 r
= package_from_db(create_package_db(), &hpkg
);
8260 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
8262 skip("Not enough rights to perform tests\n");
8263 DeleteFileA(msifile
);
8266 ok(r
== ERROR_SUCCESS
, "Expected a valid package %u\n", r
);
8268 /* invalid hInstall */
8269 r
= MsiSetPropertyA(0, "Prop", "Val");
8270 ok(r
== ERROR_INVALID_HANDLE
,
8271 "Expected ERROR_INVALID_HANDLE, got %d\n", r
);
8273 /* invalid hInstall */
8274 r
= MsiSetPropertyA(0xdeadbeef, "Prop", "Val");
8275 ok(r
== ERROR_INVALID_HANDLE
,
8276 "Expected ERROR_INVALID_HANDLE, got %d\n", r
);
8278 /* szName is NULL */
8279 r
= MsiSetPropertyA(hpkg
, NULL
, "Val");
8280 ok(r
== ERROR_INVALID_PARAMETER
,
8281 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
8283 /* both szName and szValue are NULL */
8284 r
= MsiSetPropertyA(hpkg
, NULL
, NULL
);
8285 ok(r
== ERROR_INVALID_PARAMETER
,
8286 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
8288 /* szName is empty */
8289 r
= MsiSetPropertyA(hpkg
, "", "Val");
8290 ok(r
== ERROR_FUNCTION_FAILED
,
8291 "Expected ERROR_FUNCTION_FAILED, got %d\n", r
);
8293 /* szName is empty and szValue is NULL */
8294 r
= MsiSetPropertyA(hpkg
, "", NULL
);
8295 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8297 /* set a property */
8298 r
= MsiSetPropertyA(hpkg
, "Prop", "Val");
8299 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8301 /* get the property */
8303 r
= MsiGetPropertyA(hpkg
, "Prop", buf
, &size
);
8304 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8305 ok(!lstrcmpA(buf
, "Val"), "Expected \"Val\", got \"%s\"\n", buf
);
8306 ok(size
== 3, "Expected 3, got %d\n", size
);
8308 /* update the property */
8309 r
= MsiSetPropertyA(hpkg
, "Prop", "Nuvo");
8310 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8312 /* get the property */
8314 r
= MsiGetPropertyA(hpkg
, "Prop", buf
, &size
);
8315 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8316 ok(!lstrcmpA(buf
, "Nuvo"), "Expected \"Nuvo\", got \"%s\"\n", buf
);
8317 ok(size
== 4, "Expected 4, got %d\n", size
);
8319 hdb
= MsiGetActiveDatabase(hpkg
);
8320 ok(hdb
!= 0, "Expected a valid database handle\n");
8322 /* set prop is not in the _Property table */
8323 query
= "SELECT * FROM `_Property` WHERE `Property` = 'Prop'";
8324 r
= do_query(hdb
, query
, &hrec
);
8325 ok(r
== ERROR_BAD_QUERY_SYNTAX
,
8326 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r
);
8328 /* set prop is not in the Property table */
8329 query
= "SELECT * FROM `Property` WHERE `Property` = 'Prop'";
8330 r
= do_query(hdb
, query
, &hrec
);
8331 ok(r
== ERROR_BAD_QUERY_SYNTAX
,
8332 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r
);
8334 MsiCloseHandle(hdb
);
8336 /* szValue is an empty string */
8337 r
= MsiSetPropertyA(hpkg
, "Prop", "");
8338 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8340 /* try to get the property */
8342 r
= MsiGetPropertyA(hpkg
, "Prop", buf
, &size
);
8343 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8344 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
8345 ok(size
== 0, "Expected 0, got %d\n", size
);
8347 /* reset the property */
8348 r
= MsiSetPropertyA(hpkg
, "Prop", "BlueTap");
8349 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8351 /* delete the property */
8352 r
= MsiSetPropertyA(hpkg
, "Prop", NULL
);
8353 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8355 /* try to get the property */
8357 r
= MsiGetPropertyA(hpkg
, "Prop", buf
, &size
);
8358 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8359 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
8360 ok(size
== 0, "Expected 0, got %d\n", size
);
8362 MsiCloseHandle(hpkg
);
8363 DeleteFileA(msifile
);
8366 static void test_MsiApplyMultiplePatches(void)
8368 UINT r
, type
= GetDriveTypeW(NULL
);
8370 r
= MsiApplyMultiplePatchesA(NULL
, NULL
, NULL
);
8371 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8373 r
= MsiApplyMultiplePatchesA("", NULL
, NULL
);
8374 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8376 r
= MsiApplyMultiplePatchesA(";", NULL
, NULL
);
8377 if (type
== DRIVE_FIXED
)
8378 todo_wine
ok(r
== ERROR_PATH_NOT_FOUND
, "Expected ERROR_PATH_NOT_FOUND, got %u\n", r
);
8380 ok(r
== ERROR_INVALID_NAME
, "Expected ERROR_INVALID_NAME, got %u\n", r
);
8382 r
= MsiApplyMultiplePatchesA(" ;", NULL
, NULL
);
8383 if (type
== DRIVE_FIXED
)
8384 todo_wine
ok(r
== ERROR_PATCH_PACKAGE_OPEN_FAILED
, "Expected ERROR_PATCH_PACKAGE_OPEN_FAILED, got %u\n", r
);
8386 ok(r
== ERROR_INVALID_NAME
, "Expected ERROR_INVALID_NAME, got %u\n", r
);
8388 r
= MsiApplyMultiplePatchesA(";;", NULL
, NULL
);
8389 if (type
== DRIVE_FIXED
)
8390 todo_wine
ok(r
== ERROR_PATH_NOT_FOUND
, "Expected ERROR_PATH_NOT_FOUND, got %u\n", r
);
8392 ok(r
== ERROR_INVALID_NAME
, "Expected ERROR_INVALID_NAME, got %u\n", r
);
8394 r
= MsiApplyMultiplePatchesA("nosuchpatchpackage;", NULL
, NULL
);
8395 todo_wine
ok(r
== ERROR_FILE_NOT_FOUND
, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r
);
8397 r
= MsiApplyMultiplePatchesA(";nosuchpatchpackage", NULL
, NULL
);
8398 if (type
== DRIVE_FIXED
)
8399 todo_wine
ok(r
== ERROR_PATH_NOT_FOUND
, "Expected ERROR_PATH_NOT_FOUND, got %u\n", r
);
8401 ok(r
== ERROR_INVALID_NAME
, "Expected ERROR_INVALID_NAME, got %u\n", r
);
8403 r
= MsiApplyMultiplePatchesA("nosuchpatchpackage;nosuchpatchpackage", NULL
, NULL
);
8404 todo_wine
ok(r
== ERROR_FILE_NOT_FOUND
, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r
);
8406 r
= MsiApplyMultiplePatchesA(" nosuchpatchpackage ; nosuchpatchpackage ", NULL
, NULL
);
8407 todo_wine
ok(r
== ERROR_FILE_NOT_FOUND
, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r
);
8410 static void test_MsiApplyPatch(void)
8414 r
= MsiApplyPatchA(NULL
, NULL
, INSTALLTYPE_DEFAULT
, NULL
);
8415 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8417 r
= MsiApplyPatchA("", NULL
, INSTALLTYPE_DEFAULT
, NULL
);
8418 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8421 static void test_costs(void)
8423 MSIHANDLE hdb
, hpkg
;
8424 char package
[12], drive
[3];
8429 hdb
= create_package_db();
8430 ok( hdb
, "failed to create database\n" );
8432 create_property_table( hdb
);
8433 add_property_entry( hdb
, "'ProductCode', '{379B1C47-40C1-42FA-A9BB-BEBB6F1B0172}'" );
8434 add_property_entry( hdb
, "'MSIFASTINSTALL', '1'" );
8435 add_directory_entry( hdb
, "'TARGETDIR', '', 'SourceDir'" );
8437 create_media_table( hdb
);
8438 add_media_entry( hdb
, "'1', '2', 'cabinet', '', '', ''");
8440 create_file_table( hdb
);
8441 add_file_entry( hdb
, "'one.txt', 'one', 'one.txt', 4096, '', '', 8192, 1" );
8443 create_component_table( hdb
);
8444 add_component_entry( hdb
, "'one', '{B2F86B9D-8447-4BC5-8883-750C45AA31CA}', 'TARGETDIR', 0, '', 'one.txt'" );
8445 add_component_entry( hdb
, "'two', '{62A09F6E-0B74-4829-BDB7-CAB66F42CCE8}', 'TARGETDIR', 0, '', ''" );
8447 create_feature_table( hdb
);
8448 add_feature_entry( hdb
, "'one', '', '', '', 0, 1, '', 0" );
8449 add_feature_entry( hdb
, "'two', '', '', '', 0, 1, '', 0" );
8451 create_feature_components_table( hdb
);
8452 add_feature_components_entry( hdb
, "'one', 'one'" );
8453 add_feature_components_entry( hdb
, "'two', 'two'" );
8455 create_install_execute_sequence_table( hdb
);
8456 add_install_execute_sequence_entry( hdb
, "'CostInitialize', '', '800'" );
8457 add_install_execute_sequence_entry( hdb
, "'FileCost', '', '900'" );
8458 add_install_execute_sequence_entry( hdb
, "'CostFinalize', '', '1000'" );
8459 add_install_execute_sequence_entry( hdb
, "'InstallValidate', '', '1100'" );
8461 r
= MsiDatabaseCommit( hdb
);
8462 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
8464 sprintf( package
, "#%u", hdb
);
8465 r
= MsiOpenPackageA( package
, &hpkg
);
8466 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
8468 skip("Not enough rights to perform tests\n");
8471 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
8473 r
= MsiEnumComponentCostsA( 0, NULL
, 0, INSTALLSTATE_UNKNOWN
, NULL
, NULL
, NULL
, NULL
);
8474 ok( r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8476 r
= MsiEnumComponentCostsA( hpkg
, NULL
, 0, INSTALLSTATE_UNKNOWN
, NULL
, NULL
, NULL
, NULL
);
8477 ok( r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8479 r
= MsiEnumComponentCostsA( hpkg
, NULL
, 0, INSTALLSTATE_UNKNOWN
, NULL
, NULL
, NULL
, NULL
);
8480 ok( r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8482 r
= MsiEnumComponentCostsA( hpkg
, "", 0, INSTALLSTATE_UNKNOWN
, NULL
, NULL
, NULL
, NULL
);
8483 ok( r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8485 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_UNKNOWN
, NULL
, NULL
, NULL
, NULL
);
8486 ok( r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8488 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, NULL
, NULL
, NULL
, NULL
);
8489 ok( r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8491 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, drive
, NULL
, NULL
, NULL
);
8492 ok( r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8494 len
= sizeof(drive
);
8495 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, drive
, &len
, NULL
, NULL
);
8496 ok( r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8498 len
= sizeof(drive
);
8499 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, drive
, &len
, &cost
, NULL
);
8500 ok( r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8502 len
= sizeof(drive
);
8503 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, drive
, &len
, &cost
, &temp
);
8504 todo_wine
ok( r
== ERROR_INVALID_HANDLE_STATE
, "Expected ERROR_INVALID_HANDLE_STATE, got %u\n", r
);
8506 len
= sizeof(drive
);
8507 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, NULL
, &len
, &cost
, &temp
);
8508 ok( r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8510 MsiSetInternalUI( INSTALLUILEVEL_NONE
, NULL
);
8512 r
= MsiDoActionA( hpkg
, "CostInitialize" );
8513 ok( r
== ERROR_SUCCESS
, "CostInitialize failed %u\n", r
);
8515 r
= MsiDoActionA( hpkg
, "FileCost" );
8516 ok( r
== ERROR_SUCCESS
, "FileCost failed %u\n", r
);
8518 len
= sizeof(drive
);
8519 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, drive
, &len
, &cost
, &temp
);
8520 ok( r
== ERROR_FUNCTION_NOT_CALLED
, "Expected ERROR_FUNCTION_NOT_CALLED, got %u\n", r
);
8522 r
= MsiDoActionA( hpkg
, "CostFinalize" );
8523 ok( r
== ERROR_SUCCESS
, "CostFinalize failed %u\n", r
);
8525 /* contrary to what msdn says InstallValidate must be called too */
8526 len
= sizeof(drive
);
8527 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, drive
, &len
, &cost
, &temp
);
8528 todo_wine
ok( r
== ERROR_FUNCTION_NOT_CALLED
, "Expected ERROR_FUNCTION_NOT_CALLED, got %u\n", r
);
8530 r
= MsiDoActionA( hpkg
, "InstallValidate" );
8531 ok( r
== ERROR_SUCCESS
, "InstallValidate failed %u\n", r
);
8534 r
= MsiEnumComponentCostsA( hpkg
, "three", 0, INSTALLSTATE_LOCAL
, drive
, &len
, &cost
, &temp
);
8535 ok( r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %u\n", r
);
8538 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, drive
, &len
, &cost
, &temp
);
8539 ok( r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %u\n", r
);
8540 ok( len
== 2, "expected len == 2, got %u\n", len
);
8543 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, drive
, &len
, &cost
, &temp
);
8544 ok( r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %u\n", r
);
8545 ok( len
== 2, "expected len == 2, got %u\n", len
);
8548 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_UNKNOWN
, drive
, &len
, &cost
, &temp
);
8549 ok( r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %u\n", r
);
8550 ok( len
== 2, "expected len == 2, got %u\n", len
);
8552 /* install state doesn't seem to matter */
8553 len
= sizeof(drive
);
8554 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_UNKNOWN
, drive
, &len
, &cost
, &temp
);
8555 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
8557 len
= sizeof(drive
);
8558 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_ABSENT
, drive
, &len
, &cost
, &temp
);
8559 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
8561 len
= sizeof(drive
);
8562 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_SOURCE
, drive
, &len
, &cost
, &temp
);
8563 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
8565 len
= sizeof(drive
);
8567 cost
= temp
= 0xdead;
8568 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, drive
, &len
, &cost
, &temp
);
8569 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
8570 ok( len
== 2, "expected len == 2, got %u\n", len
);
8571 ok( drive
[0], "expected a drive\n" );
8572 ok( cost
&& cost
!= 0xdead, "expected cost > 0, got %d\n", cost
);
8573 ok( !temp
, "expected temp == 0, got %d\n", temp
);
8575 len
= sizeof(drive
);
8577 cost
= temp
= 0xdead;
8578 r
= MsiEnumComponentCostsA( hpkg
, "two", 0, INSTALLSTATE_LOCAL
, drive
, &len
, &cost
, &temp
);
8579 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
8580 ok( len
== 2, "expected len == 2, got %u\n", len
);
8581 ok( drive
[0], "expected a drive\n" );
8582 ok( !cost
, "expected cost == 0, got %d\n", cost
);
8583 ok( !temp
, "expected temp == 0, got %d\n", temp
);
8585 len
= sizeof(drive
);
8587 cost
= temp
= 0xdead;
8588 r
= MsiEnumComponentCostsA( hpkg
, "", 0, INSTALLSTATE_UNKNOWN
, drive
, &len
, &cost
, &temp
);
8589 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
8590 ok( len
== 2, "expected len == 2, got %u\n", len
);
8591 ok( drive
[0], "expected a drive\n" );
8592 ok( !cost
, "expected cost == 0, got %d\n", cost
);
8593 ok( temp
&& temp
!= 0xdead, "expected temp > 0, got %d\n", temp
);
8595 /* increased index */
8596 len
= sizeof(drive
);
8597 r
= MsiEnumComponentCostsA( hpkg
, "one", 1, INSTALLSTATE_LOCAL
, drive
, &len
, &cost
, &temp
);
8598 ok( r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %u\n", r
);
8600 len
= sizeof(drive
);
8601 r
= MsiEnumComponentCostsA( hpkg
, "", 1, INSTALLSTATE_UNKNOWN
, drive
, &len
, &cost
, &temp
);
8602 ok( r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %u\n", r
);
8604 /* test MsiGetFeatureCost */
8606 r
= MsiGetFeatureCostA( hpkg
, NULL
, MSICOSTTREE_SELFONLY
, INSTALLSTATE_LOCAL
, &cost
);
8607 ok( r
== ERROR_INVALID_PARAMETER
, "got %u\n", r
);
8608 ok( cost
== 0xdead, "got %d\n", cost
);
8610 r
= MsiGetFeatureCostA( hpkg
, "one", MSICOSTTREE_SELFONLY
, INSTALLSTATE_LOCAL
, NULL
);
8611 ok( r
== ERROR_INVALID_PARAMETER
, "got %u\n", r
);
8614 r
= MsiGetFeatureCostA( hpkg
, "one", MSICOSTTREE_SELFONLY
, INSTALLSTATE_LOCAL
, &cost
);
8615 ok( !r
, "got %u\n", r
);
8616 ok( cost
== 8, "got %d\n", cost
);
8618 MsiCloseHandle( hpkg
);
8620 MsiCloseHandle( hdb
);
8621 DeleteFileA( msifile
);
8624 static void test_MsiDatabaseCommit(void)
8627 MSIHANDLE hdb
, hpkg
= 0;
8628 char buf
[32], package
[12];
8631 hdb
= create_package_db();
8632 ok( hdb
, "failed to create database\n" );
8634 create_property_table( hdb
);
8636 sprintf( package
, "#%u", hdb
);
8637 r
= MsiOpenPackageA( package
, &hpkg
);
8638 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
8640 skip("Not enough rights to perform tests\n");
8643 ok( r
== ERROR_SUCCESS
, "got %u\n", r
);
8645 r
= MsiSetPropertyA( hpkg
, "PROP", "value" );
8646 ok( r
== ERROR_SUCCESS
, "got %u\n", r
);
8650 r
= MsiGetPropertyA( hpkg
, "PROP", buf
, &sz
);
8651 ok( r
== ERROR_SUCCESS
, "MsiGetPropertyA returned %u\n", r
);
8652 ok( !lstrcmpA( buf
, "value" ), "got \"%s\"\n", buf
);
8654 r
= MsiDatabaseCommit( hdb
);
8655 ok( r
== ERROR_SUCCESS
, "MsiDatabaseCommit returned %u\n", r
);
8659 r
= MsiGetPropertyA( hpkg
, "PROP", buf
, &sz
);
8660 ok( r
== ERROR_SUCCESS
, "MsiGetPropertyA returned %u\n", r
);
8661 ok( !lstrcmpA( buf
, "value" ), "got \"%s\"\n", buf
);
8663 MsiCloseHandle( hpkg
);
8665 MsiCloseHandle( hdb
);
8666 DeleteFileA( msifile
);
8669 static int externalui_ran
;
8671 static INT CALLBACK
externalui_callback(void *context
, UINT message_type
, LPCSTR message
)
8674 ok(message_type
== INSTALLMESSAGE_USER
, "expected INSTALLMESSAGE_USER, got %08x\n", message_type
);
8678 static int externalui_record_ran
;
8680 static INT CALLBACK
externalui_record_callback(void *context
, UINT message_type
, MSIHANDLE hrecord
)
8682 INT retval
= context
? *((INT
*)context
) : 0;
8684 externalui_record_ran
= 1;
8685 ok(message_type
== INSTALLMESSAGE_USER
, "expected INSTALLMESSAGE_USER, got %08x\n", message_type
);
8686 r
= MsiRecordGetFieldCount(hrecord
);
8687 ok(r
== 1, "expected 1, got %u\n", r
);
8688 r
= MsiRecordGetInteger(hrecord
, 1);
8689 ok(r
== 12345, "expected 12345, got %u\n", r
);
8693 static void test_externalui(void)
8695 /* test that external UI handlers work correctly */
8697 INSTALLUI_HANDLERA prev
;
8698 INSTALLUI_HANDLER_RECORD prev_record
;
8699 MSIHANDLE hpkg
, hrecord
;
8703 prev
= MsiSetExternalUIA(externalui_callback
, INSTALLLOGMODE_USER
, NULL
);
8705 r
= package_from_db(create_package_db(), &hpkg
);
8706 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
8708 skip("Not enough rights to perform tests\n");
8709 DeleteFileA(msifile
);
8712 ok(r
== ERROR_SUCCESS
, "Expected a valid package %u\n", r
);
8714 hrecord
= MsiCreateRecord(1);
8715 ok(hrecord
, "Expected a valid record\n");
8716 r
= MsiRecordSetStringA(hrecord
, 0, "test message [1]");
8717 ok(r
== ERROR_SUCCESS
, "MsiSetString failed %u\n", r
);
8718 r
= MsiRecordSetInteger(hrecord
, 1, 12345);
8719 ok(r
== ERROR_SUCCESS
, "MsiSetInteger failed %u\n", r
);
8722 r
= MsiProcessMessage(hpkg
, INSTALLMESSAGE_USER
, hrecord
);
8723 ok(r
== 0, "expected 0, got %u\n", r
);
8724 ok(externalui_ran
== 1, "external UI callback did not run\n");
8726 prev
= MsiSetExternalUIA(prev
, 0, NULL
);
8727 ok(prev
== externalui_callback
, "wrong callback function %p\n", prev
);
8728 r
= MsiSetExternalUIRecord(externalui_record_callback
, INSTALLLOGMODE_USER
, &retval
, &prev_record
);
8729 ok(r
== ERROR_SUCCESS
, "MsiSetExternalUIRecord failed %u\n", r
);
8731 externalui_ran
= externalui_record_ran
= 0;
8732 r
= MsiProcessMessage(hpkg
, INSTALLMESSAGE_USER
, hrecord
);
8733 ok(r
== 0, "expected 0, got %u\n", r
);
8734 ok(externalui_ran
== 0, "external UI callback should not have run\n");
8735 ok(externalui_record_ran
== 1, "external UI record callback did not run\n");
8737 MsiSetExternalUIA(externalui_callback
, INSTALLLOGMODE_USER
, NULL
);
8739 externalui_ran
= externalui_record_ran
= 0;
8740 r
= MsiProcessMessage(hpkg
, INSTALLMESSAGE_USER
, hrecord
);
8741 ok(r
== 0, "expected 0, got %u\n", r
);
8742 ok(externalui_ran
== 1, "external UI callback did not run\n");
8743 ok(externalui_record_ran
== 1, "external UI record callback did not run\n");
8746 externalui_ran
= externalui_record_ran
= 0;
8747 r
= MsiProcessMessage(hpkg
, INSTALLMESSAGE_USER
, hrecord
);
8748 ok(r
== 1, "expected 1, got %u\n", r
);
8749 ok(externalui_ran
== 0, "external UI callback should not have run\n");
8750 ok(externalui_record_ran
== 1, "external UI record callback did not run\n");
8752 /* filter and context should be kept separately */
8753 r
= MsiSetExternalUIRecord(externalui_record_callback
, INSTALLLOGMODE_ERROR
, &retval
, &prev_record
);
8754 ok(r
== ERROR_SUCCESS
, "MsiSetExternalUIRecord failed %u\n", r
);
8756 externalui_ran
= externalui_record_ran
= 0;
8757 r
= MsiProcessMessage(hpkg
, INSTALLMESSAGE_USER
, hrecord
);
8758 ok(r
== 0, "expected 0, got %u\n", r
);
8759 ok(externalui_ran
== 1, "external UI callback did not run\n");
8760 ok(externalui_record_ran
== 0, "external UI record callback should not have run\n");
8762 MsiCloseHandle(hpkg
);
8763 DeleteFileA(msifile
);
8766 struct externalui_message
{
8770 int match
[4]; /* should we test for a match */
8774 static struct externalui_message
*sequence
;
8775 static int sequence_count
, sequence_size
;
8777 static void add_message(const struct externalui_message
*msg
)
8782 sequence
= HeapAlloc(GetProcessHeap(), 0, sequence_size
* sizeof(*sequence
));
8784 if (sequence_count
== sequence_size
)
8787 sequence
= HeapReAlloc(GetProcessHeap(), 0, sequence
, sequence_size
* sizeof(*sequence
));
8792 sequence
[sequence_count
++] = *msg
;
8795 static void flush_sequence(void)
8797 HeapFree(GetProcessHeap(), 0, sequence
);
8799 sequence_count
= sequence_size
= 0;
8802 static void ok_sequence_(const struct externalui_message
*expected
, const char *context
, BOOL todo
,
8803 const char *file
, int line
)
8805 static const struct externalui_message end_of_sequence
= {0};
8806 const struct externalui_message
*actual
;
8810 add_message(&end_of_sequence
);
8814 while (expected
->message
&& actual
->message
)
8816 if (expected
->message
== actual
->message
)
8818 if (expected
->field_count
< actual
->field_count
)
8821 ok_(file
, line
) (FALSE
, "%s: in msg 0x%08x expecting field count %d got %d\n",
8822 context
, expected
->message
, expected
->field_count
, actual
->field_count
);
8826 for (i
= 0; i
<= actual
->field_count
; i
++)
8828 if (expected
->match
[i
] && strcmp(expected
->field
[i
], actual
->field
[i
]))
8831 ok_(file
, line
) (FALSE
, "%s: in msg 0x%08x field %d: expected \"%s\", got \"%s\"\n",
8832 context
, expected
->message
, i
, expected
->field
[i
], actual
->field
[i
]);
8840 else if (expected
->optional
)
8847 ok_(file
, line
) (FALSE
, "%s: the msg 0x%08x was expected, but got msg 0x%08x instead\n",
8848 context
, expected
->message
, actual
->message
);
8857 if (expected
->message
|| actual
->message
)
8860 ok_(file
, line
) (FALSE
, "%s: the msg sequence is not complete: expected %08x - actual %08x\n",
8861 context
, expected
->message
, actual
->message
);
8865 if(todo
&& !failcount
) /* succeeded yet marked todo */
8868 ok_(file
, line
)(TRUE
, "%s: marked \"todo_wine\" but succeeds\n", context
);
8875 #define ok_sequence(exp, contx, todo) \
8876 ok_sequence_((exp), (contx), (todo), __FILE__, __LINE__)
8878 /* don't use PROGRESS, which is timing-dependent,
8879 * or SHOWDIALOG, which due to a bug causes a hang on XP */
8880 static const INSTALLLOGMODE MSITEST_INSTALLLOGMODE
=
8881 INSTALLLOGMODE_FATALEXIT
|
8882 INSTALLLOGMODE_ERROR
|
8883 INSTALLLOGMODE_WARNING
|
8884 INSTALLLOGMODE_USER
|
8885 INSTALLLOGMODE_INFO
|
8886 INSTALLLOGMODE_FILESINUSE
|
8887 INSTALLLOGMODE_RESOLVESOURCE
|
8888 INSTALLLOGMODE_OUTOFDISKSPACE
|
8889 INSTALLLOGMODE_ACTIONSTART
|
8890 INSTALLLOGMODE_ACTIONDATA
|
8891 INSTALLLOGMODE_COMMONDATA
|
8892 INSTALLLOGMODE_INITIALIZE
|
8893 INSTALLLOGMODE_TERMINATE
|
8894 INSTALLLOGMODE_RMFILESINUSE
|
8895 INSTALLLOGMODE_INSTALLSTART
|
8896 INSTALLLOGMODE_INSTALLEND
;
8898 static const struct externalui_message empty_sequence
[] = {
8902 static const struct externalui_message openpackage_nonexistent_sequence
[] = {
8903 {INSTALLMESSAGE_INITIALIZE
, -1},
8904 {INSTALLMESSAGE_TERMINATE
, -1},
8908 static const struct externalui_message openpackage_sequence
[] = {
8909 {INSTALLMESSAGE_INITIALIZE
, -1},
8910 {INSTALLMESSAGE_COMMONDATA
, 3, {"", "0", "1033", "1252"}, {1, 1, 1, 1}},
8911 {INSTALLMESSAGE_INFO
|MB_ICONHAND
, 0, {""}, {0}},
8912 {INSTALLMESSAGE_COMMONDATA
, 3, {"", "0", "1033", "1252"}, {0, 1, 1, 1}},
8913 {INSTALLMESSAGE_COMMONDATA
, 3, {"", "1", "", ""}, {0, 1, 0, 0}},
8917 static const struct externalui_message processmessage_info_sequence
[] = {
8918 {INSTALLMESSAGE_INFO
, 3, {"zero", "one", "two", "three"}, {1, 1, 1, 1}},
8922 static const struct externalui_message processmessage_actionstart_sequence
[] = {
8923 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "name", "description", "template"}, {0, 1, 1, 1}},
8927 static const struct externalui_message processmessage_actiondata_sequence
[] = {
8928 {INSTALLMESSAGE_ACTIONDATA
, 3, {"{{name: }}template", "cherry", "banana", "guava"}, {1, 1, 1, 1}},
8932 static const struct externalui_message processmessage_error_sequence
[] = {
8933 {INSTALLMESSAGE_USER
, 3, {"", "1311", "banana", "guava"}, {0, 1, 1, 1}},
8937 static const struct externalui_message processmessage_internal_error_sequence
[] = {
8938 {INSTALLMESSAGE_INFO
, 3, {"DEBUG: Error [1]: Action not found: [2]", "2726", "banana", "guava"}, {1, 1, 1, 1}},
8939 {INSTALLMESSAGE_USER
, 3, {"internal error", "2726", "banana", "guava"}, {1, 1, 1, 1}},
8943 static const struct externalui_message processmessage_error_format_sequence
[] = {
8944 {INSTALLMESSAGE_USER
, 3, {"", "2726", "banana", "guava"}, {0, 1, 1, 1}},
8948 static const struct externalui_message doaction_costinitialize_sequence
[] = {
8949 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "CostInitialize", "cost description", "cost template"}, {0, 1, 1, 1}},
8950 {INSTALLMESSAGE_INFO
, 2, {"", "CostInitialize", ""}, {0, 1, 1}},
8951 {INSTALLMESSAGE_INFO
, 2, {"", "CostInitialize", "1"}, {0, 1, 1}},
8955 static const struct externalui_message doaction_custom_sequence
[] = {
8956 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "custom", "description", "template"}, {0, 1, 1, 1}},
8957 {INSTALLMESSAGE_INFO
, 2, {"", "custom", "1"}, {0, 1, 1}},
8958 {INSTALLMESSAGE_INFO
, 2, {"", "custom", "0"}, {0, 1, 1}},
8962 static const struct externalui_message doaction_custom_fullui_sequence
[] = {
8963 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "custom", "", ""}, {0, 1, 1, 1}},
8964 {INSTALLMESSAGE_INFO
, 2, {"", "custom", ""}, {0, 1, 1}},
8965 {INSTALLMESSAGE_SHOWDIALOG
, 0, {"custom"}, {1}},
8966 {INSTALLMESSAGE_INFO
, 2, {"", "custom", "1"}, {0, 1, 1}},
8970 static const struct externalui_message doaction_custom_cancel_sequence
[] = {
8971 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "custom", "", ""}, {0, 1, 1, 1}},
8975 static const struct externalui_message doaction_dialog_nonexistent_sequence
[] = {
8976 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "custom", "", ""}, {0, 1, 1, 1}},
8977 {INSTALLMESSAGE_INFO
, 2, {"", "custom", "1"}, {0, 1, 1}},
8978 {INSTALLMESSAGE_SHOWDIALOG
, 0, {"custom"}, {1}},
8979 {INSTALLMESSAGE_INFO
, 2, {"DEBUG: Error [1]: Action not found: [2]", "2726", "custom"}, {1, 1, 1}},
8980 {INSTALLMESSAGE_INFO
, 2, {"", "2726", "custom"}, {0, 1, 1}},
8981 {INSTALLMESSAGE_INFO
, 2, {"", "custom", "0"}, {0, 1, 1}},
8985 static const struct externalui_message doaction_dialog_sequence
[] = {
8986 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "dialog", "", ""}, {0, 1, 1, 1}},
8987 {INSTALLMESSAGE_INFO
, 2, {"", "dialog", "0"}, {0, 1, 1}},
8988 {INSTALLMESSAGE_SHOWDIALOG
, 0, {"dialog"}, {1}},
8989 {INSTALLMESSAGE_ACTIONSTART
, 2, {"", "dialog", "Dialog created"}, {0, 1, 1}},
8990 {INSTALLMESSAGE_INFO
, 2, {"", "dialog", "1"}, {0, 1, 1}},
8994 static const struct externalui_message doaction_dialog_error_sequence
[] = {
8995 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "error", "", ""}, {0, 1, 1, 1}},
8996 {INSTALLMESSAGE_INFO
, 2, {"", "error", "1"}, {0, 1, 1}},
8997 {INSTALLMESSAGE_SHOWDIALOG
, 0, {"error"}, {1}},
9001 static const struct externalui_message doaction_dialog_3_sequence
[] = {
9002 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "dialog", "", ""}, {0, 1, 1, 1}},
9003 {INSTALLMESSAGE_INFO
, 2, {"", "dialog", "0"}, {0, 1, 1}},
9004 {INSTALLMESSAGE_SHOWDIALOG
, 0, {"dialog"}, {1}},
9005 {INSTALLMESSAGE_INFO
, 2, {"", "dialog", "3"}, {0, 1, 1}},
9009 static const struct externalui_message doaction_dialog_12345_sequence
[] = {
9010 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "dialog", "", ""}, {0, 1, 1, 1}},
9011 {INSTALLMESSAGE_INFO
, 2, {"", "dialog", "3"}, {0, 1, 1}},
9012 {INSTALLMESSAGE_SHOWDIALOG
, 0, {"dialog"}, {1}},
9013 {INSTALLMESSAGE_INFO
, 2, {"", "dialog", "12345"}, {0, 1, 1}},
9017 static const struct externalui_message closehandle_sequence
[] = {
9018 {INSTALLMESSAGE_TERMINATE
, -1},
9022 static INT CALLBACK
externalui_message_string_callback(void *context
, UINT message
, LPCSTR string
)
9024 INT retval
= context
? *((INT
*)context
) : 0;
9025 struct externalui_message msg
;
9027 msg
.message
= message
;
9028 msg
.field_count
= 0;
9029 strcpy(msg
.field
[0], string
);
9035 static INT CALLBACK
externalui_message_callback(void *context
, UINT message
, MSIHANDLE hrecord
)
9037 INT retval
= context
? *((INT
*)context
) : 0;
9038 struct externalui_message msg
;
9044 msg
.message
= message
;
9045 if (message
== INSTALLMESSAGE_TERMINATE
)
9047 /* trying to access the record seems to hang on some versions of Windows */
9048 msg
.field_count
= -1;
9052 msg
.field_count
= MsiRecordGetFieldCount(hrecord
);
9053 for (i
= 0; i
<= msg
.field_count
; i
++)
9055 length
= sizeof(buffer
);
9056 r
= MsiRecordGetStringA(hrecord
, i
, buffer
, &length
);
9057 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
9058 memcpy(msg
.field
[i
], buffer
, min(100, length
+1));
9061 /* top-level actions dump a list of all set properties; skip them since they're inconsistent */
9062 if (message
== (INSTALLMESSAGE_INFO
|MB_ICONHAND
) && msg
.field_count
> 0 && !strncmp(msg
.field
[0], "Property", 8))
9070 static void test_externalui_message(void)
9072 /* test that events trigger the correct sequence of messages */
9074 INSTALLUI_HANDLER_RECORD prev
;
9075 MSIHANDLE hdb
, hpkg
, hrecord
;
9079 MsiSetInternalUI(INSTALLUILEVEL_FULL
, NULL
);
9081 MsiSetExternalUIA(externalui_message_string_callback
, INSTALLLOGMODE_SHOWDIALOG
, &retval
);
9082 r
= MsiSetExternalUIRecord(externalui_message_callback
, MSITEST_INSTALLLOGMODE
, &retval
, &prev
);
9088 hdb
= create_package_db();
9089 ok(hdb
, "failed to create database\n");
9091 create_file_data("forcecodepage.idt", "\r\n\r\n1252\t_ForceCodepage\r\n");
9092 r
= MsiDatabaseImportA(hdb
, CURR_DIR
, "forcecodepage.idt");
9093 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9095 r
= run_query(hdb
, "CREATE TABLE `Error` (`Error` SHORT NOT NULL, `Message` CHAR(0) PRIMARY KEY `Error`)");
9096 ok(r
== ERROR_SUCCESS
, "Failed to create Error table: %u\n", r
);
9097 r
= run_query(hdb
, "INSERT INTO `Error` (`Error`, `Message`) VALUES (5, 'internal error')");
9098 ok(r
== ERROR_SUCCESS
, "Failed to insert into Error table: %u\n", r
);
9100 create_actiontext_table(hdb
);
9101 add_actiontext_entry(hdb
, "'custom', 'description', 'template'");
9102 add_actiontext_entry(hdb
, "'CostInitialize', 'cost description', 'cost template'");
9104 r
= MsiOpenPackageA(NULL
, &hpkg
);
9105 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
9106 ok_sequence(empty_sequence
, "MsiOpenPackage with NULL db", FALSE
);
9108 r
= MsiOpenPackageA("nonexistent", &hpkg
);
9109 ok(r
== ERROR_FILE_NOT_FOUND
, "Expected ERROR_FILE_NOT_FOUND, got %d\n", r
);
9110 ok_sequence(openpackage_nonexistent_sequence
, "MsiOpenPackage with nonexistent db", FALSE
);
9112 r
= package_from_db(hdb
, &hpkg
);
9113 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
9115 skip("Not enough rights to perform tests\n");
9116 DeleteFileA(msifile
);
9119 ok(r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
9120 ok_sequence(openpackage_sequence
, "MsiOpenPackage with valid db", FALSE
);
9122 /* Test MsiProcessMessage */
9123 hrecord
= MsiCreateRecord(3);
9124 ok(hrecord
, "failed to create record\n");
9126 MsiRecordSetStringA(hrecord
, 0, "zero");
9127 MsiRecordSetStringA(hrecord
, 1, "one");
9128 MsiRecordSetStringA(hrecord
, 2, "two");
9129 MsiRecordSetStringA(hrecord
, 3, "three");
9130 r
= MsiProcessMessage(hpkg
, INSTALLMESSAGE_INFO
, hrecord
);
9131 ok(r
== 1, "Expected 1, got %d\n", r
);
9132 ok_sequence(processmessage_info_sequence
, "MsiProcessMessage(INSTALLMESSAGE_INFO)", FALSE
);
9134 MsiRecordSetStringA(hrecord
, 1, "name");
9135 MsiRecordSetStringA(hrecord
, 2, "description");
9136 MsiRecordSetStringA(hrecord
, 3, "template");
9137 r
= MsiProcessMessage(hpkg
, INSTALLMESSAGE_ACTIONSTART
, hrecord
);
9138 ok(r
== 1, "Expected 1, got %d\n", r
);
9139 ok_sequence(processmessage_actionstart_sequence
, "MsiProcessMessage(INSTALLMESSAGE_ACTIONSTART)", FALSE
);
9141 MsiRecordSetStringA(hrecord
, 0, "apple");
9142 MsiRecordSetStringA(hrecord
, 1, "cherry");
9143 MsiRecordSetStringA(hrecord
, 2, "banana");
9144 MsiRecordSetStringA(hrecord
, 3, "guava");
9145 r
= MsiProcessMessage(hpkg
, INSTALLMESSAGE_ACTIONDATA
, hrecord
);
9146 ok(r
== 1, "Expected 1, got %d\n", r
);
9147 ok_sequence(processmessage_actiondata_sequence
, "MsiProcessMessage(INSTALLMESSAGE_ACTIONDATA)", FALSE
);
9149 /* non-internal error */
9150 MsiRecordSetStringA(hrecord
, 0, NULL
);
9151 MsiRecordSetInteger(hrecord
, 1, 1311);
9152 r
= MsiProcessMessage(hpkg
, INSTALLMESSAGE_USER
, hrecord
);
9153 ok(r
== 1, "Expected 1, got %d\n", r
);
9154 ok_sequence(processmessage_error_sequence
, "MsiProcessMessage non-internal error", FALSE
);
9156 /* internal error */
9157 MsiRecordSetStringA(hrecord
, 0, NULL
);
9158 MsiRecordSetInteger(hrecord
, 1, 2726);
9159 r
= MsiProcessMessage(hpkg
, INSTALLMESSAGE_USER
, hrecord
);
9160 ok(r
== 0, "Expected 0, got %d\n", r
);
9161 ok_sequence(processmessage_internal_error_sequence
, "MsiProcessMessage internal error", FALSE
);
9163 /* with format field */
9164 MsiRecordSetStringA(hrecord
, 0, "starfruit");
9165 r
= MsiProcessMessage(hpkg
, INSTALLMESSAGE_USER
, hrecord
);
9166 ok(r
== 1, "Expected 1, got %d\n", r
);
9167 ok_sequence(processmessage_error_format_sequence
, "MsiProcessMessage error", FALSE
);
9169 /* Test a standard action */
9170 r
= MsiDoActionA(hpkg
, "CostInitialize");
9171 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9172 ok_sequence(doaction_costinitialize_sequence
, "MsiDoAction(\"CostInitialize\")", FALSE
);
9174 /* Test a custom action */
9175 r
= MsiDoActionA(hpkg
, "custom");
9176 ok(r
== ERROR_FUNCTION_NOT_CALLED
, "Expected ERROR_FUNCTION_NOT_CALLED, got %d\n", r
);
9177 ok_sequence(doaction_custom_sequence
, "MsiDoAction(\"custom\")", FALSE
);
9179 /* close the package */
9180 MsiCloseHandle(hpkg
);
9181 ok_sequence(closehandle_sequence
, "MsiCloseHandle()", FALSE
);
9184 hdb
= create_package_db();
9185 ok(hdb
, "failed to create database\n");
9187 r
= MsiDatabaseImportA(hdb
, CURR_DIR
, "forcecodepage.idt");
9188 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9190 create_dialog_table(hdb
);
9191 add_dialog_entry(hdb
, "'dialog', 50, 50, 100, 100, 0, 'dummy'");
9193 create_control_table(hdb
);
9194 add_control_entry(hdb
, "'dialog', 'dummy', 'Text', 5, 5, 5, 5, 3, 'dummy'");
9196 r
= package_from_db(hdb
, &hpkg
);
9197 ok(r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
9198 ok_sequence(openpackage_sequence
, "MsiOpenPackage with valid db", FALSE
);
9200 /* Test a custom action */
9201 r
= MsiDoActionA(hpkg
, "custom");
9202 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9203 ok_sequence(doaction_custom_fullui_sequence
, "MsiDoAction(\"custom\")", FALSE
);
9206 r
= MsiDoActionA(hpkg
, "custom");
9207 ok(r
== ERROR_INSTALL_USEREXIT
, "Expected ERROR_INSTALL_USEREXIT, got %d\n", r
);
9208 ok_sequence(doaction_custom_cancel_sequence
, "MsiDoAction(\"custom\")", FALSE
);
9211 r
= MsiDoActionA(hpkg
, "custom");
9212 ok(r
== ERROR_FUNCTION_NOT_CALLED
, "Expected ERROR_FUNCTION_NOT_CALLED, got %d\n", r
);
9213 ok_sequence(doaction_dialog_nonexistent_sequence
, "MsiDoAction(\"custom\")", FALSE
);
9215 r
= MsiDoActionA(hpkg
, "dialog");
9216 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9217 ok_sequence(doaction_dialog_sequence
, "MsiDoAction(\"dialog\")", FALSE
);
9220 r
= MsiDoActionA(hpkg
, "error");
9221 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9222 ok_sequence(doaction_dialog_error_sequence
, "MsiDoAction(\"error\")", FALSE
);
9224 r
= MsiDoActionA(hpkg
, "error");
9225 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9226 ok_sequence(doaction_dialog_error_sequence
, "MsiDoAction(\"error\")", FALSE
);
9229 r
= MsiDoActionA(hpkg
, "custom");
9230 ok(r
== ERROR_FUNCTION_NOT_CALLED
, "Expected ERROR_FUNCTION_NOT_CALLED, got %d\n", r
);
9231 ok_sequence(doaction_dialog_nonexistent_sequence
, "MsiDoAction(\"custom\")", FALSE
);
9234 r
= MsiDoActionA(hpkg
, "dialog");
9235 ok(r
== ERROR_INSTALL_FAILURE
, "Expected ERROR_INSTALL_FAILURE, got %d\n", r
);
9236 ok_sequence(doaction_dialog_3_sequence
, "MsiDoAction(\"dialog\")", FALSE
);
9239 r
= MsiDoActionA(hpkg
, "dialog");
9240 ok(r
== ERROR_FUNCTION_FAILED
, "Expected ERROR_INSTALL_FAILURE, got %d\n", r
);
9241 ok_sequence(doaction_dialog_12345_sequence
, "MsiDoAction(\"dialog\")", FALSE
);
9243 MsiCloseHandle(hpkg
);
9244 ok_sequence(closehandle_sequence
, "MsiCloseHandle()", FALSE
);
9246 MsiCloseHandle(hrecord
);
9248 DeleteFileA(msifile
);
9249 DeleteFileA("forcecodepage.idt");
9252 static const struct externalui_message controlevent_spawn_sequence
[] = {
9253 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "spawn", "", ""}, {0, 1, 1, 1}},
9254 {INSTALLMESSAGE_INFO
, 2, {"", "spawn", ""}, {0, 1, 1}},
9255 {INSTALLMESSAGE_SHOWDIALOG
, 0, {"spawn"}, {1}},
9256 {INSTALLMESSAGE_ACTIONSTART
, 2, {"", "spawn", "Dialog created"}, {0, 1, 1}},
9258 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "custom", "", ""}, {0, 1, 1, 1}},
9259 {INSTALLMESSAGE_INFO
, 2, {"", "custom", ""}, {0, 1, 1}},
9260 {INSTALLMESSAGE_INFO
, 2, {"", "custom", "1"}, {0, 1, 1}},
9262 {INSTALLMESSAGE_ACTIONSTART
, 2, {"", "child1", "Dialog created"}, {0, 1, 1}},
9264 {INSTALLMESSAGE_INFO
, 2, {"", "spawn", "2"}, {0, 1, 1}},
9268 static const struct externalui_message controlevent_spawn2_sequence
[] = {
9269 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "spawn2", "", ""}, {0, 1, 1, 1}},
9270 {INSTALLMESSAGE_INFO
, 2, {"", "spawn2", "2"}, {0, 1, 1}},
9271 {INSTALLMESSAGE_SHOWDIALOG
, 0, {"spawn2"}, {1}},
9272 {INSTALLMESSAGE_ACTIONSTART
, 2, {"", "spawn2", "Dialog created"}, {0, 1, 1}},
9274 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "custom", "", ""}, {0, 1, 1, 1}},
9275 {INSTALLMESSAGE_INFO
, 2, {"", "custom", "2"}, {0, 1, 1}},
9276 {INSTALLMESSAGE_INFO
, 2, {"", "custom", "1"}, {0, 1, 1}},
9278 {INSTALLMESSAGE_ACTIONSTART
, 2, {"", "child2", "Dialog created"}, {0, 1, 1}},
9280 {INSTALLMESSAGE_INFO
, 2, {"", "spawn2", "2"}, {0, 1, 1}},
9284 static void test_controlevent(void)
9286 INSTALLUI_HANDLER_RECORD prev
;
9287 MSIHANDLE hdb
, hpkg
;
9290 if (!winetest_interactive
)
9292 skip("interactive ControlEvent tests\n");
9296 MsiSetInternalUI(INSTALLUILEVEL_FULL
, NULL
);
9298 MsiSetExternalUIA(externalui_message_string_callback
, INSTALLLOGMODE_SHOWDIALOG
, NULL
);
9299 r
= MsiSetExternalUIRecord(externalui_message_callback
, MSITEST_INSTALLLOGMODE
, NULL
, &prev
);
9305 hdb
= create_package_db();
9306 ok(hdb
, "failed to create database\n");
9308 create_file_data("forcecodepage.idt", "\r\n\r\n1252\t_ForceCodepage\r\n");
9309 r
= MsiDatabaseImportA(hdb
, CURR_DIR
, "forcecodepage.idt");
9310 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9312 create_dialog_table(hdb
);
9313 add_dialog_entry(hdb
, "'spawn', 50, 50, 100, 100, 3, 'button'");
9314 add_dialog_entry(hdb
, "'spawn2', 50, 50, 100, 100, 3, 'button'");
9315 add_dialog_entry(hdb
, "'child1', 50, 50, 80, 40, 3, 'exit'");
9316 add_dialog_entry(hdb
, "'child2', 50, 50, 80, 40, 3, 'exit'");
9318 create_control_table(hdb
);
9319 add_control_entry(hdb
, "'spawn', 'button', 'PushButton', 10, 10, 66, 17, 3, 'Click me'");
9320 add_control_entry(hdb
, "'spawn2', 'button', 'PushButton', 10, 10, 66, 17, 3, 'Click me'");
9321 add_control_entry(hdb
, "'child1', 'exit', 'PushButton', 10, 10, 66, 17, 3, 'Click me'");
9322 add_control_entry(hdb
, "'child2', 'exit', 'PushButton', 10, 10, 66, 17, 3, 'Click me'");
9324 create_controlevent_table(hdb
);
9325 add_controlevent_entry(hdb
, "'child1', 'exit', 'EndDialog', 'Exit', 1, 1");
9326 add_controlevent_entry(hdb
, "'child2', 'exit', 'EndDialog', 'Exit', 1, 1");
9328 create_custom_action_table(hdb
);
9329 add_custom_action_entry(hdb
, "'custom', 51, 'dummy', 'dummy value'");
9331 /* SpawnDialog and EndDialog should trigger after all other events */
9332 add_controlevent_entry(hdb
, "'spawn', 'button', 'SpawnDialog', 'child1', 1, 1");
9333 add_controlevent_entry(hdb
, "'spawn', 'button', 'DoAction', 'custom', 1, 2");
9335 /* Multiple dialog events cause only the last one to be triggered */
9336 add_controlevent_entry(hdb
, "'spawn2', 'button', 'SpawnDialog', 'child1', 1, 1");
9337 add_controlevent_entry(hdb
, "'spawn2', 'button', 'SpawnDialog', 'child2', 1, 2");
9338 add_controlevent_entry(hdb
, "'spawn2', 'button', 'DoAction', 'custom', 1, 3");
9340 r
= package_from_db(hdb
, &hpkg
);
9341 ok(r
== ERROR_SUCCESS
, "failed to create package: %u\n", r
);
9342 ok_sequence(openpackage_sequence
, "MsiOpenPackage()", FALSE
);
9344 r
= MsiDoActionA(hpkg
, "spawn");
9345 ok(r
== ERROR_INSTALL_USEREXIT
, "expected ERROR_INSTALL_USEREXIT, got %u\n", r
);
9346 ok_sequence(controlevent_spawn_sequence
, "control event: spawn", FALSE
);
9348 r
= MsiDoActionA(hpkg
, "spawn2");
9349 ok(r
== ERROR_INSTALL_USEREXIT
, "expected ERROR_INSTALL_USEREXIT, got %u\n", r
);
9350 ok_sequence(controlevent_spawn2_sequence
, "control event: spawn2", FALSE
);
9352 MsiCloseHandle(hpkg
);
9353 ok_sequence(closehandle_sequence
, "MsiCloseHandle()", FALSE
);
9356 DeleteFileA(msifile
);
9357 DeleteFileA("forcecodepage.idt");
9360 static const struct externalui_message toplevel_install_sequence
[] = {
9361 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "INSTALL", "", ""}, {0, 1, 1, 1}},
9362 {INSTALLMESSAGE_INFO
, 2, {"", "INSTALL", ""}, {0, 1, 1}},
9364 {INSTALLMESSAGE_COMMONDATA
, 3, {"", "0", "1033", "1252"}, {1, 1, 1, 1}},
9365 {INSTALLMESSAGE_COMMONDATA
, 3, {"", "0", "1033", "1252"}, {1, 1, 1, 1}},
9366 {INSTALLMESSAGE_INFO
|MB_ICONHAND
, 0, {""}, {0}},
9367 {INSTALLMESSAGE_COMMONDATA
, 3, {"", "0", "1033", "1252"}, {0, 1, 1, 1}},
9368 {INSTALLMESSAGE_COMMONDATA
, 3, {"", "1", "", ""}, {0, 1, 0, 0}},
9370 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "INSTALL", "", ""}, {0, 1, 1, 1}},
9371 {INSTALLMESSAGE_INFO
, 2, {"", "INSTALL", ""}, {0, 1, 1}},
9372 {INSTALLMESSAGE_INSTALLSTART
, 2, {"", "", "{7262AC98-EEBD-4364-8CE3-D654F6A425B9}"}, {1, 1, 1}, 1},
9374 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "CostInitialize", "", ""}, {0, 1, 0, 1}},
9375 {INSTALLMESSAGE_INFO
, 2, {"", "CostInitialize", ""}, {0, 1, 1}},
9376 {INSTALLMESSAGE_INFO
, 2, {"", "CostInitialize", "1"}, {0, 1, 1}},
9378 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "FileCost", "", ""}, {0, 1, 0, 1}},
9379 {INSTALLMESSAGE_INFO
, 2, {"", "FileCost", "1"}, {0, 1, 1}},
9380 {INSTALLMESSAGE_INFO
, 2, {"", "FileCost", "1"}, {0, 1, 1}},
9382 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "CostFinalize", "", ""}, {0, 1, 0, 1}},
9383 {INSTALLMESSAGE_INFO
, 2, {"", "CostFinalize", "1"}, {0, 1, 1}},
9384 {INSTALLMESSAGE_INFO
, 2, {"", "CostFinalize", "1"}, {0, 1, 1}},
9386 {INSTALLMESSAGE_INFO
, 2, {"", "INSTALL", "1"}, {0, 1, 1}},
9387 {INSTALLMESSAGE_INSTALLEND
, 3, {"", "", "{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "1"}, {1, 1, 1, 1}, 1},
9391 {INSTALLMESSAGE_COMMONDATA
, 2, {"", "2", "0"}, {0, 1, 1}, 1},
9392 {INSTALLMESSAGE_COMMONDATA
, 2, {"", "2", "1"}, {0, 1, 1}, 1},
9393 {INSTALLMESSAGE_INFO
, 2, {"", "INSTALL", "1"}, {0, 1, 1}},
9397 static const struct externalui_message toplevel_install_ui_sequence
[] = {
9398 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "INSTALL", "", ""}, {0, 1, 1, 1}},
9399 {INSTALLMESSAGE_INFO
, 2, {"", "INSTALL", ""}, {0, 1, 1}},
9401 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "AppSearch", "", ""}, {0, 1, 0, 0}},
9402 {INSTALLMESSAGE_INFO
, 2, {"", "AppSearch", ""}, {0, 1, 1}},
9403 {INSTALLMESSAGE_INFO
, 2, {"", "AppSearch", "0"}, {0, 1, 1}},
9405 {INSTALLMESSAGE_INFO
, 2, {"", "INSTALL", "1"}, {0, 1, 1}},
9409 static const struct externalui_message toplevel_executeaction_install_sequence
[] = {
9410 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "ExecuteAction", "", ""}, {0, 1, 1, 1}},
9411 {INSTALLMESSAGE_INFO
, 2, {"", "ExecuteAction", "1"}, {0, 1, 1}},
9413 {INSTALLMESSAGE_COMMONDATA
, 3, {"", "0", "1033", "1252"}, {1, 1, 1, 1}},
9414 {INSTALLMESSAGE_COMMONDATA
, 3, {"", "0", "1033", "1252"}, {1, 1, 1, 1}},
9415 {INSTALLMESSAGE_COMMONDATA
, 3, {"", "0", "1033", "1252"}, {0, 1, 1, 1}},
9416 {INSTALLMESSAGE_COMMONDATA
, 3, {"", "1", "", ""}, {0, 1, 0, 0}},
9418 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "INSTALL", "", ""}, {0, 1, 1, 1}},
9419 {INSTALLMESSAGE_INFO
, 2, {"", "INSTALL", ""}, {0, 1, 1}},
9420 {INSTALLMESSAGE_INSTALLSTART
, 2, {"", "", "{7262AC98-EEBD-4364-8CE3-D654F6A425B9}"}, {1, 1, 1}, 1},
9422 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "CostInitialize", "", ""}, {0, 1, 0, 1}},
9423 {INSTALLMESSAGE_INFO
, 2, {"", "CostInitialize"}, {0, 1}},
9424 {INSTALLMESSAGE_INFO
, 2, {"", "CostInitialize", "1"}, {0, 1, 1}},
9426 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "FileCost", "", ""}, {0, 1, 0, 1}},
9427 {INSTALLMESSAGE_INFO
, 2, {"", "FileCost", "1"}, {0, 1, 1}},
9428 {INSTALLMESSAGE_INFO
, 2, {"", "FileCost", "1"}, {0, 1, 1}},
9430 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "CostFinalize", "", ""}, {0, 1, 0, 1}},
9431 {INSTALLMESSAGE_INFO
, 2, {"", "CostFinalize", "1"}, {0, 1, 1}},
9432 {INSTALLMESSAGE_INFO
, 2, {"", "CostFinalize", "1"}, {0, 1, 1}},
9434 {INSTALLMESSAGE_INFO
, 2, {"", "INSTALL", "1"}, {0, 1, 1}},
9435 {INSTALLMESSAGE_INSTALLEND
, 3, {"", "", "{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "1"}, {1, 1, 1, 1}, 1},
9439 {INSTALLMESSAGE_COMMONDATA
, 2, {"", "2", "0"}, {0, 1, 1}, 1},
9440 {INSTALLMESSAGE_COMMONDATA
, 2, {"", "2", "1"}, {0, 1, 1}, 1},
9441 {INSTALLMESSAGE_INFO
, 2, {"", "ExecuteAction", "1"}, {0, 1, 1}},
9445 static const struct externalui_message toplevel_executeaction_costinitialize_sequence
[] = {
9446 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "ExecuteAction", "", ""}, {0, 1, 1, 1}},
9447 {INSTALLMESSAGE_INFO
, 2, {"", "ExecuteAction", "1"}, {0, 1, 1}},
9449 {INSTALLMESSAGE_COMMONDATA
, 3, {"", "0", "1033", "1252"}, {1, 1, 1, 1}},
9450 {INSTALLMESSAGE_COMMONDATA
, 3, {"", "0", "1033", "1252"}, {1, 1, 1, 1}},
9451 {INSTALLMESSAGE_COMMONDATA
, 3, {"", "0", "1033", "1252"}, {0, 1, 1, 1}},
9452 {INSTALLMESSAGE_COMMONDATA
, 3, {"", "1", "", ""}, {0, 1, 0, 0}},
9454 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "CostInitialize", "", ""}, {0, 1, 0, 1}},
9455 {INSTALLMESSAGE_INFO
, 2, {"", "CostInitialize", ""}, {0, 1}},
9456 {INSTALLMESSAGE_INFO
, 2, {"", "CostInitialize", "1"}, {0, 1, 1}},
9460 {INSTALLMESSAGE_COMMONDATA
, 2, {"", "2", "0"}, {0, 1, 1}, 1},
9461 {INSTALLMESSAGE_COMMONDATA
, 2, {"", "2", "1"}, {0, 1, 1}, 1},
9462 {INSTALLMESSAGE_INFO
, 2, {"", "ExecuteAction", "1"}, {0, 1, 1}},
9466 static const struct externalui_message toplevel_msiinstallproduct_sequence
[] = {
9467 {INSTALLMESSAGE_INITIALIZE
, -1},
9469 {INSTALLMESSAGE_COMMONDATA
, 3, {"", "0", "1033", "1252"}, {1, 1, 1, 1}},
9470 {INSTALLMESSAGE_COMMONDATA
, 3, {"", "0", "1033", "1252"}, {1, 1, 1, 1}},
9471 {INSTALLMESSAGE_INFO
|MB_ICONHAND
, 0, {""}, {0}},
9472 {INSTALLMESSAGE_COMMONDATA
, 3, {"", "0", "1033", "1252"}, {0, 1, 1, 1}},
9473 {INSTALLMESSAGE_COMMONDATA
, 3, {"", "1", "", ""}, {0, 1, 0, 0}},
9475 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "INSTALL", "", ""}, {0, 1, 1, 1}},
9476 {INSTALLMESSAGE_INFO
, 2, {"", "INSTALL", ""}, {0, 1, 1}},
9478 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "AppSearch", "", ""}, {0, 1, 0, 0}},
9479 {INSTALLMESSAGE_INFO
, 2, {"", "AppSearch", ""}, {0, 1, 1}},
9480 {INSTALLMESSAGE_INFO
, 2, {"", "AppSearch", "0"}, {0, 1, 1}},
9482 {INSTALLMESSAGE_INFO
, 2, {"", "INSTALL", "1"}, {0, 1, 1}},
9486 {INSTALLMESSAGE_INFO
|MB_ICONHAND
, 0, {""}, {0}},
9487 {INSTALLMESSAGE_TERMINATE
, -1},
9491 static const struct externalui_message toplevel_msiinstallproduct_custom_sequence
[] = {
9492 {INSTALLMESSAGE_INITIALIZE
, -1},
9494 {INSTALLMESSAGE_COMMONDATA
, 3, {"", "0", "1033", "1252"}, {1, 1, 1, 1}},
9495 {INSTALLMESSAGE_COMMONDATA
, 3, {"", "0", "1033", "1252"}, {1, 1, 1, 1}},
9496 {INSTALLMESSAGE_INFO
|MB_ICONHAND
, 0, {""}, {0}},
9497 {INSTALLMESSAGE_COMMONDATA
, 3, {"", "0", "1033", "1252"}, {0, 1, 1, 1}},
9498 {INSTALLMESSAGE_COMMONDATA
, 3, {"", "1", "", ""}, {0, 1, 0, 0}},
9500 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "CUSTOM", "", ""}, {0, 1, 1, 1}},
9501 {INSTALLMESSAGE_INFO
, 2, {"", "CUSTOM", ""}, {0, 1, 1}},
9502 {INSTALLMESSAGE_INFO
, 2, {"", "CUSTOM", "0"}, {0, 1, 1}},
9506 {INSTALLMESSAGE_INFO
|MB_ICONHAND
, 0, {""}, {0}},
9507 {INSTALLMESSAGE_TERMINATE
, -1},
9511 /* tests involving top-level actions: INSTALL, ExecuteAction */
9512 static void test_top_level_action(void)
9514 INSTALLUI_HANDLER_RECORD prev
;
9515 MSIHANDLE hdb
, hpkg
;
9517 char msifile_absolute
[MAX_PATH
];
9519 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
9521 MsiSetExternalUIA(externalui_message_string_callback
, INSTALLLOGMODE_SHOWDIALOG
, NULL
);
9522 r
= MsiSetExternalUIRecord(externalui_message_callback
, MSITEST_INSTALLLOGMODE
, NULL
, &prev
);
9528 hdb
= create_package_db();
9529 ok(hdb
, "failed to create database\n");
9531 create_file_data("forcecodepage.idt", "\r\n\r\n1252\t_ForceCodepage\r\n");
9532 r
= MsiDatabaseImportA(hdb
, CURR_DIR
, "forcecodepage.idt");
9533 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9535 create_property_table(hdb
);
9536 add_property_entry(hdb
, "'ProductCode', '{7262AC98-EEBD-4364-8CE3-D654F6A425B9}'");
9538 create_install_execute_sequence_table(hdb
);
9539 add_install_execute_sequence_entry(hdb
, "'CostInitialize', '', 1");
9540 add_install_execute_sequence_entry(hdb
, "'FileCost', '', 2");
9541 add_install_execute_sequence_entry(hdb
, "'CostFinalize', '', 3");
9543 create_install_ui_sequence_table(hdb
);
9544 add_install_ui_sequence_entry(hdb
, "'AppSearch', '', 1");
9546 MsiDatabaseCommit(hdb
);
9548 /* for some reason we have to open the package from file using an absolute path */
9549 MsiCloseHandle(hdb
);
9550 GetFullPathNameA(msifile
, MAX_PATH
, msifile_absolute
, NULL
);
9551 r
= MsiOpenPackageA(msifile_absolute
, &hpkg
);
9552 ok(r
== ERROR_SUCCESS
, "failed to create package: %u\n", r
);
9553 ok_sequence(openpackage_sequence
, "MsiOpenPackage()", FALSE
);
9556 r
= MsiDoActionA(hpkg
, "INSTALL");
9557 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
9558 ok_sequence(toplevel_install_sequence
, "INSTALL (no UI)", FALSE
);
9560 /* test INSTALL with reduced+ UI */
9561 /* for some reason we need to re-open the package to change the internal UI */
9562 MsiCloseHandle(hpkg
);
9563 ok_sequence(closehandle_sequence
, "MsiCloseHandle()", FALSE
);
9564 MsiSetInternalUI(INSTALLUILEVEL_REDUCED
, NULL
);
9565 r
= MsiOpenPackageA(msifile_absolute
, &hpkg
);
9566 ok(r
== ERROR_SUCCESS
, "failed to create package: %u\n", r
);
9567 ok_sequence(openpackage_sequence
, "MsiOpenPackage()", FALSE
);
9569 r
= MsiDoActionA(hpkg
, "INSTALL");
9570 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
9571 ok_sequence(toplevel_install_ui_sequence
, "INSTALL (reduced+ UI)", TRUE
);
9573 /* test ExecuteAction with EXECUTEACTION property unset */
9574 MsiSetPropertyA(hpkg
, "EXECUTEACTION", NULL
);
9575 r
= MsiDoActionA(hpkg
, "ExecuteAction");
9576 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
9577 ok_sequence(toplevel_executeaction_install_sequence
, "ExecuteAction: INSTALL", FALSE
);
9579 /* test ExecuteAction with EXECUTEACTION property set */
9580 MsiSetPropertyA(hpkg
, "EXECUTEACTION", "CostInitialize");
9581 r
= MsiDoActionA(hpkg
, "ExecuteAction");
9582 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
9583 ok_sequence(toplevel_executeaction_costinitialize_sequence
, "ExecuteAction: CostInitialize", FALSE
);
9585 MsiCloseHandle(hpkg
);
9586 ok_sequence(closehandle_sequence
, "MsiCloseHandle()", FALSE
);
9588 /* test MsiInstallProduct() */
9589 r
= MsiInstallProductA(msifile_absolute
, NULL
);
9590 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
9591 ok_sequence(toplevel_msiinstallproduct_sequence
, "MsiInstallProduct()", TRUE
);
9593 r
= MsiInstallProductA(msifile_absolute
, "ACTION=custom");
9595 ok(r
== ERROR_INSTALL_FAILURE
, "expected ERROR_INSTALL_FAILURE, got %u\n", r
);
9596 ok_sequence(toplevel_msiinstallproduct_custom_sequence
, "MsiInstallProduct(ACTION=custom)", TRUE
);
9599 DeleteFileA(msifile
);
9600 DeleteFileA("forcecodepage.idt");
9605 STATEMGRSTATUS status
;
9608 init_functionpointers();
9610 if (pIsWow64Process
)
9611 pIsWow64Process(GetCurrentProcess(), &is_wow64
);
9613 GetCurrentDirectoryA(MAX_PATH
, CURR_DIR
);
9615 /* Create a restore point ourselves so we circumvent the multitude of restore points
9616 * that would have been created by all the installation and removal tests.
9618 * This is not needed on version 5.0 where setting MSIFASTINSTALL prevents the
9619 * creation of restore points.
9621 if (pSRSetRestorePointA
&& !pMsiGetComponentPathExA
)
9623 memset(&status
, 0, sizeof(status
));
9624 ret
= notify_system_change(BEGIN_NESTED_SYSTEM_CHANGE
, &status
);
9627 test_createpackage();
9629 test_gettargetpath_bad();
9630 test_settargetpath();
9632 test_property_table();
9635 test_formatrecord2();
9636 test_formatrecord_tables();
9640 test_appsearch_complocator();
9641 test_appsearch_reglocator();
9642 test_appsearch_inilocator();
9643 test_appsearch_drlocator();
9644 test_featureparents();
9645 test_installprops();
9646 test_launchconditions();
9649 test_MsiGetSourcePath();
9650 test_shortlongsource();
9653 test_emptypackage();
9654 test_MsiGetProductProperty();
9655 test_MsiSetProperty();
9656 test_MsiApplyMultiplePatches();
9657 test_MsiApplyPatch();
9659 test_MsiDatabaseCommit();
9661 test_externalui_message();
9662 test_controlevent();
9663 test_top_level_action();
9665 if (pSRSetRestorePointA
&& !pMsiGetComponentPathExA
&& ret
)
9667 ret
= notify_system_change(END_NESTED_SYSTEM_CHANGE
, &status
);
9669 remove_restore_point(status
.llSequenceNumber
);