2 * tests for Microsoft Installer functionality
4 * Copyright 2005 Mike McCormack for CodeWeavers
5 * Copyright 2005 Aric Stewart for CodeWeavers
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
30 #include <srrestoreptapi.h>
33 #include "wine/test.h"
36 static const char msifile
[] = "winetest-package.msi";
37 static const WCHAR msifileW
[] =
38 {'w','i','n','e','t','e','s','t','-','p','a','c','k','a','g','e','.','m','s','i',0};
39 static char CURR_DIR
[MAX_PATH
];
41 static INSTALLSTATE (WINAPI
*pMsiGetComponentPathExA
)(LPCSTR
, LPCSTR
, LPCSTR
, MSIINSTALLCONTEXT
, LPSTR
, LPDWORD
);
42 static HRESULT (WINAPI
*pSHGetFolderPathA
)(HWND
, int, HANDLE
, DWORD
, LPSTR
);
44 static BOOL (WINAPI
*pCheckTokenMembership
)(HANDLE
,PSID
,PBOOL
);
45 static BOOL (WINAPI
*pConvertSidToStringSidA
)(PSID
, LPSTR
*);
46 static BOOL (WINAPI
*pOpenProcessToken
)( HANDLE
, DWORD
, PHANDLE
);
47 static LONG (WINAPI
*pRegDeleteKeyExA
)(HKEY
, LPCSTR
, REGSAM
, DWORD
);
48 static LONG (WINAPI
*pRegDeleteKeyExW
)(HKEY
, LPCWSTR
, REGSAM
, DWORD
);
49 static BOOL (WINAPI
*pIsWow64Process
)(HANDLE
, PBOOL
);
50 static void (WINAPI
*pGetSystemInfo
)(LPSYSTEM_INFO
);
51 static void (WINAPI
*pGetNativeSystemInfo
)(LPSYSTEM_INFO
);
52 static UINT (WINAPI
*pGetSystemWow64DirectoryA
)(LPSTR
, UINT
);
54 static BOOL (WINAPI
*pSRRemoveRestorePoint
)(DWORD
);
55 static BOOL (WINAPI
*pSRSetRestorePointA
)(RESTOREPOINTINFOA
*, STATEMGRSTATUS
*);
57 static void init_functionpointers(void)
59 HMODULE hmsi
= GetModuleHandleA("msi.dll");
60 HMODULE hadvapi32
= GetModuleHandleA("advapi32.dll");
61 HMODULE hkernel32
= GetModuleHandleA("kernel32.dll");
62 HMODULE hshell32
= GetModuleHandleA("shell32.dll");
65 #define GET_PROC(mod, func) \
66 p ## func = (void*)GetProcAddress(mod, #func);
68 GET_PROC(hmsi
, MsiGetComponentPathExA
);
69 GET_PROC(hshell32
, SHGetFolderPathA
);
71 GET_PROC(hadvapi32
, CheckTokenMembership
);
72 GET_PROC(hadvapi32
, ConvertSidToStringSidA
);
73 GET_PROC(hadvapi32
, OpenProcessToken
);
74 GET_PROC(hadvapi32
, RegDeleteKeyExA
)
75 GET_PROC(hadvapi32
, RegDeleteKeyExW
)
76 GET_PROC(hkernel32
, IsWow64Process
)
77 GET_PROC(hkernel32
, GetNativeSystemInfo
)
78 GET_PROC(hkernel32
, GetSystemInfo
)
79 GET_PROC(hkernel32
, GetSystemWow64DirectoryA
)
81 hsrclient
= LoadLibraryA("srclient.dll");
82 GET_PROC(hsrclient
, SRRemoveRestorePoint
);
83 GET_PROC(hsrclient
, SRSetRestorePointA
);
87 static BOOL
is_process_limited(void)
89 SID_IDENTIFIER_AUTHORITY NtAuthority
= {SECURITY_NT_AUTHORITY
};
94 if (!pCheckTokenMembership
|| !pOpenProcessToken
) return FALSE
;
96 if (!AllocateAndInitializeSid(&NtAuthority
, 2, SECURITY_BUILTIN_DOMAIN_RID
,
97 DOMAIN_ALIAS_RID_ADMINS
, 0, 0, 0, 0, 0, 0, &Group
) ||
98 !pCheckTokenMembership(NULL
, Group
, &IsInGroup
))
100 trace("Could not check if the current user is an administrator\n");
108 if (!AllocateAndInitializeSid(&NtAuthority
, 2,
109 SECURITY_BUILTIN_DOMAIN_RID
,
110 DOMAIN_ALIAS_RID_POWER_USERS
,
111 0, 0, 0, 0, 0, 0, &Group
) ||
112 !pCheckTokenMembership(NULL
, Group
, &IsInGroup
))
114 trace("Could not check if the current user is a power user\n");
119 /* Only administrators and power users can be powerful */
124 if (pOpenProcessToken(GetCurrentProcess(), TOKEN_QUERY
, &token
))
127 TOKEN_ELEVATION_TYPE type
= TokenElevationTypeDefault
;
130 ret
= GetTokenInformation(token
, TokenElevationType
, &type
, sizeof(type
), &size
);
132 return (ret
&& type
== TokenElevationTypeLimited
);
137 static LONG
delete_key( HKEY key
, LPCSTR subkey
, REGSAM access
)
139 if (pRegDeleteKeyExA
)
140 return pRegDeleteKeyExA( key
, subkey
, access
, 0 );
141 return RegDeleteKeyA( key
, subkey
);
144 static char *get_user_sid(void)
149 char *usersid
= NULL
;
151 if (!pConvertSidToStringSidA
)
153 win_skip("ConvertSidToStringSidA is not available\n");
156 OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY
, &token
);
157 GetTokenInformation(token
, TokenUser
, NULL
, size
, &size
);
159 user
= HeapAlloc(GetProcessHeap(), 0, size
);
160 GetTokenInformation(token
, TokenUser
, user
, size
, &size
);
161 pConvertSidToStringSidA(user
->User
.Sid
, &usersid
);
162 HeapFree(GetProcessHeap(), 0, user
);
168 /* RegDeleteTreeW from dlls/advapi32/registry.c */
169 static LSTATUS
package_RegDeleteTreeW(HKEY hKey
, LPCWSTR lpszSubKey
, REGSAM access
)
172 DWORD dwMaxSubkeyLen
, dwMaxValueLen
;
173 DWORD dwMaxLen
, dwSize
;
174 WCHAR szNameBuf
[MAX_PATH
], *lpszName
= szNameBuf
;
179 ret
= RegOpenKeyExW(hKey
, lpszSubKey
, 0, access
, &hSubKey
);
183 ret
= RegQueryInfoKeyW(hSubKey
, NULL
, NULL
, NULL
, NULL
,
184 &dwMaxSubkeyLen
, NULL
, NULL
, &dwMaxValueLen
, NULL
, NULL
, NULL
);
185 if (ret
) goto cleanup
;
189 dwMaxLen
= max(dwMaxSubkeyLen
, dwMaxValueLen
);
190 if (dwMaxLen
> sizeof(szNameBuf
)/sizeof(WCHAR
))
192 /* Name too big: alloc a buffer for it */
193 if (!(lpszName
= HeapAlloc( GetProcessHeap(), 0, dwMaxLen
*sizeof(WCHAR
))))
195 ret
= ERROR_NOT_ENOUGH_MEMORY
;
200 /* Recursively delete all the subkeys */
204 if (RegEnumKeyExW(hSubKey
, 0, lpszName
, &dwSize
, NULL
,
205 NULL
, NULL
, NULL
)) break;
207 ret
= package_RegDeleteTreeW(hSubKey
, lpszName
, access
);
208 if (ret
) goto cleanup
;
213 if (pRegDeleteKeyExW
)
214 ret
= pRegDeleteKeyExW(hKey
, lpszSubKey
, access
, 0);
216 ret
= RegDeleteKeyW(hKey
, lpszSubKey
);
222 if (RegEnumValueW(hKey
, 0, lpszName
, &dwSize
,
223 NULL
, NULL
, NULL
, NULL
)) break;
225 ret
= RegDeleteValueW(hKey
, lpszName
);
226 if (ret
) goto cleanup
;
230 if (lpszName
!= szNameBuf
)
231 HeapFree(GetProcessHeap(), 0, lpszName
);
233 RegCloseKey(hSubKey
);
237 static BOOL
squash_guid(LPCWSTR in
, LPWSTR out
)
242 if (FAILED(CLSIDFromString((LPCOLESTR
)in
, &guid
)))
256 out
[17+i
*2] = in
[n
++];
257 out
[16+i
*2] = in
[n
++];
262 out
[17+i
*2] = in
[n
++];
263 out
[16+i
*2] = in
[n
++];
269 static void create_test_guid(LPSTR prodcode
, LPSTR squashed
)
271 WCHAR guidW
[MAX_PATH
];
272 WCHAR squashedW
[MAX_PATH
];
277 hr
= CoCreateGuid(&guid
);
278 ok(hr
== S_OK
, "Expected S_OK, got %d\n", hr
);
280 size
= StringFromGUID2(&guid
, guidW
, MAX_PATH
);
281 ok(size
== 39, "Expected 39, got %d\n", hr
);
283 WideCharToMultiByte(CP_ACP
, 0, guidW
, size
, prodcode
, MAX_PATH
, NULL
, NULL
);
284 squash_guid(guidW
, squashedW
);
285 WideCharToMultiByte(CP_ACP
, 0, squashedW
, -1, squashed
, MAX_PATH
, NULL
, NULL
);
288 static void set_component_path(LPCSTR filename
, MSIINSTALLCONTEXT context
,
289 LPCSTR guid
, LPSTR usersid
, BOOL dir
)
291 WCHAR guidW
[MAX_PATH
];
292 WCHAR squashedW
[MAX_PATH
];
293 CHAR squashed
[MAX_PATH
];
294 CHAR comppath
[MAX_PATH
];
295 CHAR prodpath
[MAX_PATH
];
299 REGSAM access
= KEY_ALL_ACCESS
;
302 access
|= KEY_WOW64_64KEY
;
304 MultiByteToWideChar(CP_ACP
, 0, guid
, -1, guidW
, MAX_PATH
);
305 squash_guid(guidW
, squashedW
);
306 WideCharToMultiByte(CP_ACP
, 0, squashedW
, -1, squashed
, MAX_PATH
, NULL
, NULL
);
308 if (context
== MSIINSTALLCONTEXT_MACHINE
)
310 prod
= "3D0DAE300FACA1300AD792060BCDAA92";
312 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
313 "Installer\\UserData\\S-1-5-18\\Components\\%s", squashed
);
315 "SOFTWARE\\Classes\\Installer\\"
316 "Products\\3D0DAE300FACA1300AD792060BCDAA92");
318 else if (context
== MSIINSTALLCONTEXT_USERUNMANAGED
)
320 prod
= "7D2F387510109040002000060BECB6AB";
322 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
323 "Installer\\UserData\\%s\\Components\\%s", usersid
, squashed
);
325 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
326 "Installer\\%s\\Installer\\Products\\"
327 "7D2F387510109040002000060BECB6AB", usersid
);
329 else if (context
== MSIINSTALLCONTEXT_USERMANAGED
)
331 prod
= "7D2F387510109040002000060BECB6AB";
333 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
334 "Installer\\UserData\\%s\\Components\\%s", usersid
, squashed
);
336 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
337 "Installer\\Managed\\%s\\Installer\\Products\\"
338 "7D2F387510109040002000060BECB6AB", usersid
);
341 RegCreateKeyExA(HKEY_LOCAL_MACHINE
, comppath
, 0, NULL
, 0, access
, NULL
, &hkey
, NULL
);
343 lstrcpyA(path
, CURR_DIR
);
344 lstrcatA(path
, "\\");
345 if (!dir
) lstrcatA(path
, filename
);
347 RegSetValueExA(hkey
, prod
, 0, REG_SZ
, (LPBYTE
)path
, lstrlenA(path
));
350 RegCreateKeyExA(HKEY_LOCAL_MACHINE
, prodpath
, 0, NULL
, 0, access
, NULL
, &hkey
, NULL
);
354 static void delete_component_path(LPCSTR guid
, MSIINSTALLCONTEXT context
, LPSTR usersid
)
356 WCHAR guidW
[MAX_PATH
];
357 WCHAR squashedW
[MAX_PATH
];
358 WCHAR substrW
[MAX_PATH
];
359 CHAR squashed
[MAX_PATH
];
360 CHAR comppath
[MAX_PATH
];
361 CHAR prodpath
[MAX_PATH
];
362 REGSAM access
= KEY_ALL_ACCESS
;
365 access
|= KEY_WOW64_64KEY
;
367 MultiByteToWideChar(CP_ACP
, 0, guid
, -1, guidW
, MAX_PATH
);
368 squash_guid(guidW
, squashedW
);
369 WideCharToMultiByte(CP_ACP
, 0, squashedW
, -1, squashed
, MAX_PATH
, NULL
, NULL
);
371 if (context
== MSIINSTALLCONTEXT_MACHINE
)
374 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
375 "Installer\\UserData\\S-1-5-18\\Components\\%s", squashed
);
377 "SOFTWARE\\Classes\\Installer\\"
378 "Products\\3D0DAE300FACA1300AD792060BCDAA92");
380 else if (context
== MSIINSTALLCONTEXT_USERUNMANAGED
)
383 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
384 "Installer\\UserData\\%s\\Components\\%s", usersid
, squashed
);
386 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
387 "Installer\\%s\\Installer\\Products\\"
388 "7D2F387510109040002000060BECB6AB", usersid
);
390 else if (context
== MSIINSTALLCONTEXT_USERMANAGED
)
393 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
394 "Installer\\UserData\\%s\\Components\\%s", usersid
, squashed
);
396 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
397 "Installer\\Managed\\%s\\Installer\\Products\\"
398 "7D2F387510109040002000060BECB6AB", usersid
);
401 MultiByteToWideChar(CP_ACP
, 0, comppath
, -1, substrW
, MAX_PATH
);
402 package_RegDeleteTreeW(HKEY_LOCAL_MACHINE
, substrW
, access
);
404 MultiByteToWideChar(CP_ACP
, 0, prodpath
, -1, substrW
, MAX_PATH
);
405 package_RegDeleteTreeW(HKEY_LOCAL_MACHINE
, substrW
, access
);
408 static UINT
do_query(MSIHANDLE hdb
, const char *query
, MSIHANDLE
*phrec
)
413 /* open a select query */
414 r
= MsiDatabaseOpenViewA(hdb
, query
, &hview
);
415 if (r
!= ERROR_SUCCESS
)
417 r
= MsiViewExecute(hview
, 0);
418 if (r
!= ERROR_SUCCESS
)
420 ret
= MsiViewFetch(hview
, phrec
);
421 r
= MsiViewClose(hview
);
422 if (r
!= ERROR_SUCCESS
)
424 r
= MsiCloseHandle(hview
);
425 if (r
!= ERROR_SUCCESS
)
430 static UINT
run_query( MSIHANDLE hdb
, const char *query
)
435 r
= MsiDatabaseOpenViewA(hdb
, query
, &hview
);
436 if( r
!= ERROR_SUCCESS
)
439 r
= MsiViewExecute(hview
, 0);
440 if( r
== ERROR_SUCCESS
)
441 r
= MsiViewClose(hview
);
442 MsiCloseHandle(hview
);
446 static UINT
create_component_table( MSIHANDLE hdb
)
448 return 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`)" );
459 static UINT
create_feature_table( MSIHANDLE hdb
)
461 return run_query( hdb
,
462 "CREATE TABLE `Feature` ( "
463 "`Feature` CHAR(38) NOT NULL, "
464 "`Feature_Parent` CHAR(38), "
466 "`Description` CHAR(255), "
467 "`Display` SHORT NOT NULL, "
468 "`Level` SHORT NOT NULL, "
469 "`Directory_` CHAR(72), "
470 "`Attributes` SHORT NOT NULL "
471 "PRIMARY KEY `Feature`)" );
474 static UINT
create_feature_components_table( MSIHANDLE hdb
)
476 return run_query( hdb
,
477 "CREATE TABLE `FeatureComponents` ( "
478 "`Feature_` CHAR(38) NOT NULL, "
479 "`Component_` CHAR(72) NOT NULL "
480 "PRIMARY KEY `Feature_`, `Component_` )" );
483 static UINT
create_file_table( MSIHANDLE hdb
)
485 return run_query( hdb
,
486 "CREATE TABLE `File` ("
487 "`File` CHAR(72) NOT NULL, "
488 "`Component_` CHAR(72) NOT NULL, "
489 "`FileName` CHAR(255) NOT NULL, "
490 "`FileSize` LONG NOT NULL, "
491 "`Version` CHAR(72), "
492 "`Language` CHAR(20), "
493 "`Attributes` SHORT, "
494 "`Sequence` SHORT NOT NULL "
495 "PRIMARY KEY `File`)" );
498 static UINT
create_remove_file_table( MSIHANDLE hdb
)
500 return run_query( hdb
,
501 "CREATE TABLE `RemoveFile` ("
502 "`FileKey` CHAR(72) NOT NULL, "
503 "`Component_` CHAR(72) NOT NULL, "
504 "`FileName` CHAR(255) LOCALIZABLE, "
505 "`DirProperty` CHAR(72) NOT NULL, "
506 "`InstallMode` SHORT NOT NULL "
507 "PRIMARY KEY `FileKey`)" );
510 static UINT
create_appsearch_table( MSIHANDLE hdb
)
512 return run_query( hdb
,
513 "CREATE TABLE `AppSearch` ("
514 "`Property` CHAR(72) NOT NULL, "
515 "`Signature_` CHAR(72) NOT NULL "
516 "PRIMARY KEY `Property`, `Signature_`)" );
519 static UINT
create_reglocator_table( MSIHANDLE hdb
)
521 return run_query( hdb
,
522 "CREATE TABLE `RegLocator` ("
523 "`Signature_` CHAR(72) NOT NULL, "
524 "`Root` SHORT NOT NULL, "
525 "`Key` CHAR(255) NOT NULL, "
528 "PRIMARY KEY `Signature_`)" );
531 static UINT
create_signature_table( MSIHANDLE hdb
)
533 return run_query( hdb
,
534 "CREATE TABLE `Signature` ("
535 "`Signature` CHAR(72) NOT NULL, "
536 "`FileName` CHAR(255) NOT NULL, "
537 "`MinVersion` CHAR(20), "
538 "`MaxVersion` CHAR(20), "
543 "`Languages` CHAR(255) "
544 "PRIMARY KEY `Signature`)" );
547 static UINT
create_launchcondition_table( MSIHANDLE hdb
)
549 return run_query( hdb
,
550 "CREATE TABLE `LaunchCondition` ("
551 "`Condition` CHAR(255) NOT NULL, "
552 "`Description` CHAR(255) NOT NULL "
553 "PRIMARY KEY `Condition`)" );
556 static UINT
create_property_table( MSIHANDLE hdb
)
558 return run_query( hdb
,
559 "CREATE TABLE `Property` ("
560 "`Property` CHAR(72) NOT NULL, "
562 "PRIMARY KEY `Property`)" );
565 static UINT
create_install_execute_sequence_table( MSIHANDLE hdb
)
567 return run_query( hdb
,
568 "CREATE TABLE `InstallExecuteSequence` ("
569 "`Action` CHAR(72) NOT NULL, "
570 "`Condition` CHAR(255), "
572 "PRIMARY KEY `Action`)" );
575 static UINT
create_media_table( MSIHANDLE hdb
)
577 return run_query( hdb
,
578 "CREATE TABLE `Media` ("
579 "`DiskId` SHORT NOT NULL, "
580 "`LastSequence` SHORT NOT NULL, "
581 "`DiskPrompt` CHAR(64), "
582 "`Cabinet` CHAR(255), "
583 "`VolumeLabel` CHAR(32), "
585 "PRIMARY KEY `DiskId`)" );
588 static UINT
create_ccpsearch_table( MSIHANDLE hdb
)
590 return run_query( hdb
,
591 "CREATE TABLE `CCPSearch` ("
592 "`Signature_` CHAR(72) NOT NULL "
593 "PRIMARY KEY `Signature_`)" );
596 static UINT
create_drlocator_table( MSIHANDLE hdb
)
598 return run_query( hdb
,
599 "CREATE TABLE `DrLocator` ("
600 "`Signature_` CHAR(72) NOT NULL, "
601 "`Parent` CHAR(72), "
604 "PRIMARY KEY `Signature_`, `Parent`, `Path`)" );
607 static UINT
create_complocator_table( MSIHANDLE hdb
)
609 return run_query( hdb
,
610 "CREATE TABLE `CompLocator` ("
611 "`Signature_` CHAR(72) NOT NULL, "
612 "`ComponentId` CHAR(38) NOT NULL, "
614 "PRIMARY KEY `Signature_`)" );
617 static UINT
create_inilocator_table( MSIHANDLE hdb
)
619 return run_query( hdb
,
620 "CREATE TABLE `IniLocator` ("
621 "`Signature_` CHAR(72) NOT NULL, "
622 "`FileName` CHAR(255) NOT NULL, "
623 "`Section` CHAR(96)NOT NULL, "
624 "`Key` CHAR(128)NOT NULL, "
627 "PRIMARY KEY `Signature_`)" );
630 static UINT
create_custom_action_table( MSIHANDLE hdb
)
632 return run_query( hdb
,
633 "CREATE TABLE `CustomAction` ("
634 "`Action` CHAR(72) NOT NULL, "
635 "`Type` SHORT NOT NULL, "
636 "`Source` CHAR(75), "
637 "`Target` CHAR(255) "
638 "PRIMARY KEY `Action`)" );
641 static UINT
create_dialog_table( MSIHANDLE hdb
)
643 return run_query(hdb
,
644 "CREATE TABLE `Dialog` ("
645 "`Dialog` CHAR(72) NOT NULL, "
646 "`HCentering` SHORT NOT NULL, "
647 "`VCentering` SHORT NOT NULL, "
648 "`Width` SHORT NOT NULL, "
649 "`Height` SHORT NOT NULL, "
650 "`Attributes` LONG, "
651 "`Title` CHAR(128) LOCALIZABLE, "
652 "`Control_First` CHAR(50) NOT NULL, "
653 "`Control_Default` CHAR(50), "
654 "`Control_Cancel` CHAR(50) "
655 "PRIMARY KEY `Dialog`)");
658 static UINT
create_control_table( MSIHANDLE hdb
)
660 return run_query(hdb
,
661 "CREATE TABLE `Control` ("
662 "`Dialog_` CHAR(72) NOT NULL, "
663 "`Control` CHAR(50) NOT NULL, "
664 "`Type` CHAR(20) NOT NULL, "
665 "`X` SHORT NOT NULL, "
666 "`Y` SHORT NOT NULL, "
667 "`Width` SHORT NOT NULL, "
668 "`Height` SHORT NOT NULL, "
669 "`Attributes` LONG, "
670 "`Property` CHAR(50), "
671 "`Text` CHAR(0) LOCALIZABLE, "
672 "`Control_Next` CHAR(50), "
673 "`Help` CHAR(255) LOCALIZABLE "
674 "PRIMARY KEY `Dialog_`, `Control`)");
677 static UINT
create_controlevent_table( MSIHANDLE hdb
)
679 return run_query(hdb
,
680 "CREATE TABLE `ControlEvent` ("
681 "`Dialog_` CHAR(72) NOT NULL, "
682 "`Control_` CHAR(50) NOT NULL, "
683 "`Event` CHAR(50) NOT NULL, "
684 "`Argument` CHAR(255) NOT NULL, "
685 "`Condition` CHAR(255), "
687 "PRIMARY KEY `Dialog_`, `Control_`, `Event`, `Argument`, `Condition`)");
690 static UINT
create_actiontext_table( MSIHANDLE hdb
)
692 return run_query(hdb
,
693 "CREATE TABLE `ActionText` ("
694 "`Action` CHAR(72) NOT NULL, "
695 "`Description` CHAR(64) LOCALIZABLE, "
696 "`Template` CHAR(128) LOCALIZABLE "
697 "PRIMARY KEY `Action`)");
700 #define make_add_entry(type, qtext) \
701 static UINT add##_##type##_##entry( MSIHANDLE hdb, const char *values ) \
703 char insert[] = qtext; \
706 sz = strlen(values) + sizeof insert; \
707 query = HeapAlloc(GetProcessHeap(),0,sz); \
708 sprintf(query,insert,values); \
709 r = run_query( hdb, query ); \
710 HeapFree(GetProcessHeap(), 0, query); \
714 make_add_entry(component
,
715 "INSERT INTO `Component` "
716 "(`Component`, `ComponentId`, `Directory_`, "
717 "`Attributes`, `Condition`, `KeyPath`) VALUES( %s )")
719 make_add_entry(directory
,
720 "INSERT INTO `Directory` "
721 "(`Directory`,`Directory_Parent`,`DefaultDir`) VALUES( %s )")
723 make_add_entry(feature
,
724 "INSERT INTO `Feature` "
725 "(`Feature`, `Feature_Parent`, `Title`, `Description`, "
726 "`Display`, `Level`, `Directory_`, `Attributes`) VALUES( %s )")
728 make_add_entry(feature_components
,
729 "INSERT INTO `FeatureComponents` "
730 "(`Feature_`, `Component_`) VALUES( %s )")
733 "INSERT INTO `File` "
734 "(`File`, `Component_`, `FileName`, `FileSize`, "
735 "`Version`, `Language`, `Attributes`, `Sequence`) VALUES( %s )")
737 make_add_entry(appsearch
,
738 "INSERT INTO `AppSearch` "
739 "(`Property`, `Signature_`) VALUES( %s )")
741 make_add_entry(signature
,
742 "INSERT INTO `Signature` "
743 "(`Signature`, `FileName`, `MinVersion`, `MaxVersion`,"
744 " `MinSize`, `MaxSize`, `MinDate`, `MaxDate`, `Languages`) "
747 make_add_entry(launchcondition
,
748 "INSERT INTO `LaunchCondition` "
749 "(`Condition`, `Description`) VALUES( %s )")
751 make_add_entry(property
,
752 "INSERT INTO `Property` (`Property`, `Value`) VALUES( %s )")
754 make_add_entry(install_execute_sequence
,
755 "INSERT INTO `InstallExecuteSequence` "
756 "(`Action`, `Condition`, `Sequence`) VALUES( %s )")
758 make_add_entry(media
,
759 "INSERT INTO `Media` "
760 "(`DiskId`, `LastSequence`, `DiskPrompt`, "
761 "`Cabinet`, `VolumeLabel`, `Source`) VALUES( %s )")
763 make_add_entry(ccpsearch
,
764 "INSERT INTO `CCPSearch` (`Signature_`) VALUES( %s )")
766 make_add_entry(drlocator
,
767 "INSERT INTO `DrLocator` "
768 "(`Signature_`, `Parent`, `Path`, `Depth`) VALUES( %s )")
770 make_add_entry(complocator
,
771 "INSERT INTO `CompLocator` "
772 "(`Signature_`, `ComponentId`, `Type`) VALUES( %s )")
774 make_add_entry(inilocator
,
775 "INSERT INTO `IniLocator` "
776 "(`Signature_`, `FileName`, `Section`, `Key`, `Field`, `Type`) "
779 make_add_entry(custom_action
,
780 "INSERT INTO `CustomAction` "
781 "(`Action`, `Type`, `Source`, `Target`) VALUES( %s )")
783 make_add_entry(dialog
,
784 "INSERT INTO `Dialog` "
785 "(`Dialog`, `HCentering`, `VCentering`, `Width`, `Height`, `Attributes`, `Control_First`) VALUES ( %s )")
787 make_add_entry(control
,
788 "INSERT INTO `Control` "
789 "(`Dialog_`, `Control`, `Type`, `X`, `Y`, `Width`, `Height`, `Attributes`, `Text`) VALUES( %s )");
791 make_add_entry(controlevent
,
792 "INSERT INTO `ControlEvent` "
793 "(`Dialog_`, `Control_`, `Event`, `Argument`, `Condition`, `Ordering`) VALUES( %s )");
795 make_add_entry(actiontext
,
796 "INSERT INTO `ActionText` "
797 "(`Action`, `Description`, `Template`) VALUES( %s )");
799 static UINT
add_reglocator_entry( MSIHANDLE hdb
, const char *sig
, UINT root
, const char *path
,
800 const char *name
, UINT type
)
802 const char insert
[] =
803 "INSERT INTO `RegLocator` (`Signature_`, `Root`, `Key`, `Name`, `Type`) "
804 "VALUES( '%s', %u, '%s', '%s', %u )";
808 sz
= strlen( sig
) + 10 + strlen( path
) + strlen( name
) + 10 + sizeof( insert
);
809 query
= HeapAlloc( GetProcessHeap(), 0, sz
);
810 sprintf( query
, insert
, sig
, root
, path
, name
, type
);
811 r
= run_query( hdb
, query
);
812 HeapFree( GetProcessHeap(), 0, query
);
816 static UINT
set_summary_info(MSIHANDLE hdb
)
821 /* build summary info */
822 res
= MsiGetSummaryInformationA(hdb
, NULL
, 7, &suminfo
);
823 ok( res
== ERROR_SUCCESS
, "Failed to open summaryinfo\n" );
825 res
= MsiSummaryInfoSetPropertyA(suminfo
,2, VT_LPSTR
, 0,NULL
,
826 "Installation Database");
827 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
829 res
= MsiSummaryInfoSetPropertyA(suminfo
,3, VT_LPSTR
, 0,NULL
,
830 "Installation Database");
831 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
833 res
= MsiSummaryInfoSetPropertyA(suminfo
,4, VT_LPSTR
, 0,NULL
,
835 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
837 res
= MsiSummaryInfoSetPropertyA(suminfo
,7, VT_LPSTR
, 0,NULL
,
839 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
841 res
= MsiSummaryInfoSetPropertyA(suminfo
,9, VT_LPSTR
, 0,NULL
,
842 "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}");
843 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
845 res
= MsiSummaryInfoSetPropertyA(suminfo
, 14, VT_I4
, 100, NULL
, NULL
);
846 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
848 res
= MsiSummaryInfoSetPropertyA(suminfo
, 15, VT_I4
, 0, NULL
, NULL
);
849 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
851 res
= MsiSummaryInfoPersist(suminfo
);
852 ok( res
== ERROR_SUCCESS
, "Failed to make summary info persist\n" );
854 res
= MsiCloseHandle( suminfo
);
855 ok( res
== ERROR_SUCCESS
, "Failed to close suminfo\n" );
861 static MSIHANDLE
create_package_db(void)
866 DeleteFileA(msifile
);
868 /* create an empty database */
869 res
= MsiOpenDatabaseW(msifileW
, MSIDBOPEN_CREATE
, &hdb
);
870 ok( res
== ERROR_SUCCESS
, "Failed to create database %u\n", res
);
871 if( res
!= ERROR_SUCCESS
)
874 res
= MsiDatabaseCommit( hdb
);
875 ok( res
== ERROR_SUCCESS
, "Failed to commit database\n" );
877 res
= set_summary_info(hdb
);
878 ok( res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", res
);
880 res
= run_query( hdb
,
881 "CREATE TABLE `Directory` ( "
882 "`Directory` CHAR(255) NOT NULL, "
883 "`Directory_Parent` CHAR(255), "
884 "`DefaultDir` CHAR(255) NOT NULL "
885 "PRIMARY KEY `Directory`)" );
886 ok( res
== ERROR_SUCCESS
, "Failed to create directory table\n" );
891 static UINT
package_from_db(MSIHANDLE hdb
, MSIHANDLE
*handle
)
897 sprintf(szPackage
, "#%u", hdb
);
898 res
= MsiOpenPackageA(szPackage
, &hPackage
);
899 if (res
!= ERROR_SUCCESS
)
905 res
= MsiCloseHandle(hdb
);
906 if (res
!= ERROR_SUCCESS
)
908 MsiCloseHandle(hPackage
);
913 return ERROR_SUCCESS
;
916 static void create_file_data(LPCSTR name
, LPCSTR data
)
921 file
= CreateFileA(name
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, 0, NULL
);
922 ok(file
!= INVALID_HANDLE_VALUE
, "Failure to open file %s\n", name
);
923 if (file
== INVALID_HANDLE_VALUE
)
926 WriteFile(file
, data
, strlen(data
), &written
, NULL
);
927 WriteFile(file
, "\n", strlen("\n"), &written
, NULL
);
932 static void create_test_file(const CHAR
*name
)
934 create_file_data(name
, name
);
937 typedef struct _tagVS_VERSIONINFO
944 VS_FIXEDFILEINFO Value
;
949 #define roundoffs(a, b, r) (((BYTE *)(b) - (BYTE *)(a) + ((r) - 1)) & ~((r) - 1))
950 #define roundpos(a, b, r) (((BYTE *)(a)) + roundoffs(a, b, r))
952 static BOOL
create_file_with_version(const CHAR
*name
, LONG ms
, LONG ls
)
954 VS_VERSIONINFO
*pVerInfo
;
955 VS_FIXEDFILEINFO
*pFixedInfo
;
962 GetSystemDirectoryA(path
, MAX_PATH
);
963 /* Some dlls can't be updated on Vista/W2K8 */
964 lstrcatA(path
, "\\version.dll");
966 CopyFileA(path
, name
, FALSE
);
968 size
= GetFileVersionInfoSizeA(path
, &handle
);
969 buffer
= HeapAlloc(GetProcessHeap(), 0, size
);
971 GetFileVersionInfoA(path
, 0, size
, buffer
);
973 pVerInfo
= (VS_VERSIONINFO
*)buffer
;
974 ofs
= (BYTE
*)&pVerInfo
->szKey
[lstrlenW(pVerInfo
->szKey
) + 1];
975 pFixedInfo
= (VS_FIXEDFILEINFO
*)roundpos(pVerInfo
, ofs
, 4);
977 pFixedInfo
->dwFileVersionMS
= ms
;
978 pFixedInfo
->dwFileVersionLS
= ls
;
979 pFixedInfo
->dwProductVersionMS
= ms
;
980 pFixedInfo
->dwProductVersionLS
= ls
;
982 resource
= BeginUpdateResourceA(name
, FALSE
);
986 if (!UpdateResourceA(resource
, (LPCSTR
)RT_VERSION
, (LPCSTR
)MAKEINTRESOURCE(VS_VERSION_INFO
),
987 MAKELANGID(LANG_NEUTRAL
, SUBLANG_NEUTRAL
), buffer
, size
))
990 if (!EndUpdateResourceA(resource
, FALSE
))
996 HeapFree(GetProcessHeap(), 0, buffer
);
1000 static BOOL
notify_system_change(DWORD event_type
, STATEMGRSTATUS
*status
)
1002 RESTOREPOINTINFOA spec
;
1004 spec
.dwEventType
= event_type
;
1005 spec
.dwRestorePtType
= APPLICATION_INSTALL
;
1006 spec
.llSequenceNumber
= status
->llSequenceNumber
;
1007 lstrcpyA(spec
.szDescription
, "msitest restore point");
1009 return pSRSetRestorePointA(&spec
, status
);
1012 static void remove_restore_point(DWORD seq_number
)
1016 res
= pSRRemoveRestorePoint(seq_number
);
1017 if (res
!= ERROR_SUCCESS
)
1018 trace("Failed to remove the restore point : %08x\n", res
);
1021 static BOOL
is_root(const char *path
)
1023 return (isalpha(path
[0]) && path
[1] == ':' && path
[2] == '\\' && !path
[3]);
1026 static void test_createpackage(void)
1028 MSIHANDLE hPackage
= 0;
1031 res
= package_from_db(create_package_db(), &hPackage
);
1032 if (res
== ERROR_INSTALL_PACKAGE_REJECTED
)
1034 skip("Not enough rights to perform tests\n");
1035 DeleteFileA(msifile
);
1038 ok( res
== ERROR_SUCCESS
, " Failed to create package %u\n", res
);
1040 res
= MsiCloseHandle( hPackage
);
1041 ok( res
== ERROR_SUCCESS
, "Failed to close package\n" );
1042 DeleteFileA(msifile
);
1045 static void test_doaction( void )
1050 r
= MsiDoActionA( -1, NULL
);
1051 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
1053 r
= package_from_db(create_package_db(), &hpkg
);
1054 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
1056 skip("Not enough rights to perform tests\n");
1057 DeleteFileA(msifile
);
1060 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
1062 r
= MsiDoActionA(hpkg
, NULL
);
1063 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
1065 r
= MsiDoActionA(0, "boo");
1066 ok( r
== ERROR_INVALID_HANDLE
, "wrong return val\n");
1068 r
= MsiDoActionA(hpkg
, "boo");
1069 ok( r
== ERROR_FUNCTION_NOT_CALLED
, "wrong return val\n");
1071 MsiCloseHandle( hpkg
);
1072 DeleteFileA(msifile
);
1075 static void test_gettargetpath_bad(void)
1077 static const WCHAR boo
[] = {'b','o','o',0};
1078 static const WCHAR empty
[] = {0};
1080 WCHAR bufferW
[0x80];
1085 r
= package_from_db(create_package_db(), &hpkg
);
1086 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
1088 skip("Not enough rights to perform tests\n");
1089 DeleteFileA(msifile
);
1092 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
1094 r
= MsiGetTargetPathA( 0, NULL
, NULL
, NULL
);
1095 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
1097 r
= MsiGetTargetPathA( 0, NULL
, NULL
, &sz
);
1098 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
1100 r
= MsiGetTargetPathA( 0, "boo", NULL
, NULL
);
1101 ok( r
== ERROR_INVALID_HANDLE
, "wrong return val\n");
1103 r
= MsiGetTargetPathA( 0, "boo", NULL
, NULL
);
1104 ok( r
== ERROR_INVALID_HANDLE
, "wrong return val\n");
1106 r
= MsiGetTargetPathA( hpkg
, "boo", NULL
, NULL
);
1107 ok( r
== ERROR_DIRECTORY
, "wrong return val\n");
1109 r
= MsiGetTargetPathA( hpkg
, "boo", buffer
, NULL
);
1110 ok( r
== ERROR_DIRECTORY
, "wrong return val\n");
1113 r
= MsiGetTargetPathA( hpkg
, "", buffer
, &sz
);
1114 ok( r
== ERROR_DIRECTORY
, "wrong return val\n");
1116 r
= MsiGetTargetPathW( 0, NULL
, NULL
, NULL
);
1117 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
1119 r
= MsiGetTargetPathW( 0, NULL
, NULL
, &sz
);
1120 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
1122 r
= MsiGetTargetPathW( 0, boo
, NULL
, NULL
);
1123 ok( r
== ERROR_INVALID_HANDLE
, "wrong return val\n");
1125 r
= MsiGetTargetPathW( 0, boo
, NULL
, NULL
);
1126 ok( r
== ERROR_INVALID_HANDLE
, "wrong return val\n");
1128 r
= MsiGetTargetPathW( hpkg
, boo
, NULL
, NULL
);
1129 ok( r
== ERROR_DIRECTORY
, "wrong return val\n");
1131 r
= MsiGetTargetPathW( hpkg
, boo
, bufferW
, NULL
);
1132 ok( r
== ERROR_DIRECTORY
, "wrong return val\n");
1135 r
= MsiGetTargetPathW( hpkg
, empty
, bufferW
, &sz
);
1136 ok( r
== ERROR_DIRECTORY
, "wrong return val\n");
1138 MsiCloseHandle( hpkg
);
1139 DeleteFileA(msifile
);
1142 static void query_file_path(MSIHANDLE hpkg
, LPCSTR file
, LPSTR buff
)
1148 rec
= MsiCreateRecord( 1 );
1149 ok(rec
, "MsiCreate record failed\n");
1151 r
= MsiRecordSetStringA( rec
, 0, file
);
1152 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
1155 r
= MsiFormatRecordA( hpkg
, rec
, buff
, &size
);
1156 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
1158 MsiCloseHandle( rec
);
1161 static void test_settargetpath(void)
1163 char tempdir
[MAX_PATH
+8], buffer
[MAX_PATH
], file
[MAX_PATH
];
1169 hdb
= create_package_db();
1170 ok ( hdb
, "failed to create package database\n" );
1172 r
= add_directory_entry( hdb
, "'TARGETDIR', '', 'SourceDir'" );
1173 ok( r
== S_OK
, "failed to add directory entry: %d\n" , r
);
1175 r
= create_component_table( hdb
);
1176 ok( r
== S_OK
, "cannot create Component table: %d\n", r
);
1178 r
= add_component_entry( hdb
, "'RootComp', '{83e2694d-0864-4124-9323-6d37630912a1}', 'TARGETDIR', 8, '', 'RootFile'" );
1179 ok( r
== S_OK
, "cannot add dummy component: %d\n", r
);
1181 r
= add_component_entry( hdb
, "'TestComp', '{A3FB59C8-C293-4F7E-B8C5-F0E1D8EEE4E5}', 'TestDir', 0, '', 'TestFile'" );
1182 ok( r
== S_OK
, "cannot add test component: %d\n", r
);
1184 r
= create_feature_table( hdb
);
1185 ok( r
== S_OK
, "cannot create Feature table: %d\n", r
);
1187 r
= add_feature_entry( hdb
, "'TestFeature', '', '', '', 0, 1, '', 0" );
1188 ok( r
== ERROR_SUCCESS
, "cannot add TestFeature to Feature table: %d\n", r
);
1190 r
= create_feature_components_table( hdb
);
1191 ok( r
== S_OK
, "cannot create FeatureComponents table: %d\n", r
);
1193 r
= add_feature_components_entry( hdb
, "'TestFeature', 'RootComp'" );
1194 ok( r
== S_OK
, "cannot insert component into FeatureComponents table: %d\n", r
);
1196 r
= add_feature_components_entry( hdb
, "'TestFeature', 'TestComp'" );
1197 ok( r
== S_OK
, "cannot insert component into FeatureComponents table: %d\n", r
);
1199 add_directory_entry( hdb
, "'TestParent', 'TARGETDIR', 'TestParent'" );
1200 add_directory_entry( hdb
, "'TestDir', 'TestParent', 'TestDir'" );
1202 r
= create_file_table( hdb
);
1203 ok( r
== S_OK
, "cannot create File table: %d\n", r
);
1205 r
= add_file_entry( hdb
, "'RootFile', 'RootComp', 'rootfile.txt', 0, '', '1033', 8192, 1" );
1206 ok( r
== S_OK
, "cannot add file to the File table: %d\n", r
);
1208 r
= add_file_entry( hdb
, "'TestFile', 'TestComp', 'testfile.txt', 0, '', '1033', 8192, 1" );
1209 ok( r
== S_OK
, "cannot add file to the File table: %d\n", r
);
1211 r
= package_from_db( hdb
, &hpkg
);
1212 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
1214 skip("Not enough rights to perform tests\n");
1215 DeleteFileA(msifile
);
1218 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
1220 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
1222 r
= MsiDoActionA( hpkg
, "CostInitialize");
1223 ok( r
== ERROR_SUCCESS
, "cost init failed\n");
1225 r
= MsiDoActionA( hpkg
, "FileCost");
1226 ok( r
== ERROR_SUCCESS
, "file cost failed\n");
1228 r
= MsiDoActionA( hpkg
, "CostFinalize");
1229 ok( r
== ERROR_SUCCESS
, "cost finalize failed\n");
1232 sz
= sizeof(buffer
);
1233 r
= MsiGetPropertyA( hpkg
, "OutOfNoRbDiskSpace", buffer
, &sz
);
1234 ok( r
== ERROR_SUCCESS
, "MsiGetProperty returned %u\n", r
);
1235 trace( "OutOfNoRbDiskSpace = \"%s\"\n", buffer
);
1237 r
= MsiSetTargetPathA( 0, NULL
, NULL
);
1238 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
1240 r
= MsiSetTargetPathA( 0, "boo", "C:\\bogusx" );
1241 ok( r
== ERROR_INVALID_HANDLE
, "wrong return val\n");
1243 r
= MsiSetTargetPathA( hpkg
, "boo", NULL
);
1244 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
1246 r
= MsiSetTargetPathA( hpkg
, "boo", "c:\\bogusx" );
1247 ok( r
== ERROR_DIRECTORY
, "wrong return val\n");
1249 sz
= sizeof tempdir
- 1;
1250 r
= MsiGetTargetPathA( hpkg
, "TARGETDIR", tempdir
, &sz
);
1251 sprintf( file
, "%srootfile.txt", tempdir
);
1253 query_file_path( hpkg
, "[#RootFile]", buffer
);
1254 ok( r
== ERROR_SUCCESS
, "failed to get target path: %d\n", r
);
1255 ok( !lstrcmpA(buffer
, file
), "Expected %s, got %s\n", file
, buffer
);
1257 GetTempFileNameA( tempdir
, "_wt", 0, buffer
);
1258 sprintf( tempdir
, "%s\\subdir", buffer
);
1260 r
= MsiSetTargetPathA( hpkg
, "TARGETDIR", buffer
);
1261 ok( r
== ERROR_SUCCESS
|| r
== ERROR_DIRECTORY
,
1262 "MsiSetTargetPath on file returned %d\n", r
);
1264 r
= MsiSetTargetPathA( hpkg
, "TARGETDIR", tempdir
);
1265 ok( r
== ERROR_SUCCESS
|| r
== ERROR_DIRECTORY
,
1266 "MsiSetTargetPath on 'subdir' of file returned %d\n", r
);
1268 DeleteFileA( buffer
);
1270 r
= MsiSetTargetPathA( hpkg
, "TARGETDIR", buffer
);
1271 ok( r
== ERROR_SUCCESS
, "MsiSetTargetPath returned %d\n", r
);
1273 r
= GetFileAttributesA( buffer
);
1274 ok ( r
== INVALID_FILE_ATTRIBUTES
, "file/directory exists after MsiSetTargetPath. Attributes: %08X\n", r
);
1276 r
= MsiSetTargetPathA( hpkg
, "TARGETDIR", tempdir
);
1277 ok( r
== ERROR_SUCCESS
, "MsiSetTargetPath on subsubdir returned %d\n", r
);
1280 sz
= sizeof buffer
- 1;
1281 lstrcatA( tempdir
, "\\" );
1282 r
= MsiGetTargetPathA( hpkg
, "TARGETDIR", buffer
, &sz
);
1283 ok( r
== ERROR_SUCCESS
, "failed to get target path: %d\n", r
);
1284 ok( !lstrcmpA(buffer
, tempdir
), "Expected %s, got %s\n", tempdir
, buffer
);
1286 sprintf( file
, "%srootfile.txt", tempdir
);
1287 query_file_path( hpkg
, "[#RootFile]", buffer
);
1288 ok( !lstrcmpA(buffer
, file
), "Expected %s, got %s\n", file
, buffer
);
1291 sz
= sizeof(buffer
);
1292 r
= MsiGetPropertyA( hpkg
, "TestParent", buffer
, &sz
);
1293 ok( r
== ERROR_SUCCESS
, "MsiGetProperty returned %u\n", r
);
1294 lstrcatA( tempdir
, "TestParent\\" );
1295 ok( !lstrcmpiA(buffer
, tempdir
), "Expected \"%s\", got \"%s\"\n", tempdir
, buffer
);
1297 r
= MsiSetTargetPathA( hpkg
, "TestParent", "C:\\one\\two" );
1298 ok( r
== ERROR_SUCCESS
, "MsiSetTargetPath returned %d\n", r
);
1301 sz
= sizeof(buffer
);
1302 r
= MsiGetPropertyA( hpkg
, "TestParent", buffer
, &sz
);
1303 ok( r
== ERROR_SUCCESS
, "MsiGetProperty returned %u\n", r
);
1304 ok( lstrcmpiA(buffer
, "C:\\one\\two\\TestDir\\"),
1305 "Expected \"C:\\one\\two\\TestDir\\\", got \"%s\"\n", buffer
);
1308 query_file_path( hpkg
, "[#TestFile]", buffer
);
1309 ok( !lstrcmpiA(buffer
, "C:\\one\\two\\TestDir\\testfile.txt"),
1310 "Expected C:\\one\\two\\TestDir\\testfile.txt, got %s\n", buffer
);
1313 sz
= sizeof buffer
- 1;
1314 r
= MsiGetTargetPathA( hpkg
, "TestParent", buffer
, &sz
);
1315 ok( r
== ERROR_SUCCESS
, "failed to get target path: %d\n", r
);
1316 ok( !lstrcmpiA(buffer
, "C:\\one\\two\\"), "Expected C:\\one\\two\\, got %s\n", buffer
);
1318 r
= MsiSetTargetPathA( hpkg
, "TestParent", "C:\\one\\two\\three" );
1319 ok( r
== ERROR_SUCCESS
, "MsiSetTargetPath returned %d\n", r
);
1322 sz
= sizeof buffer
- 1;
1323 r
= MsiGetTargetPathA( hpkg
, "TestParent", buffer
, &sz
);
1324 ok( r
== ERROR_SUCCESS
, "failed to get target path: %d\n", r
);
1325 ok( !lstrcmpiA(buffer
, "C:\\one\\two\\three\\"), "Expected C:\\one\\two\\three\\, got %s\n", buffer
);
1327 r
= MsiSetTargetPathA( hpkg
, "TestParent", "C:\\\\one\\\\two " );
1328 ok( r
== ERROR_SUCCESS
, "MsiSetTargetPath returned %d\n", r
);
1331 sz
= sizeof buffer
- 1;
1332 r
= MsiGetTargetPathA( hpkg
, "TestParent", buffer
, &sz
);
1333 ok( r
== ERROR_SUCCESS
, "failed to get target path: %d\n", r
);
1334 ok( !lstrcmpiA(buffer
, "C:\\one\\two\\"), "Expected \"C:\\one\\two\\\", got %s\n", buffer
);
1336 r
= MsiSetTargetPathA( hpkg
, "TestParent", "C:\\\\ Program Files \\\\ " );
1337 ok( r
== ERROR_SUCCESS
, "MsiSetTargetPath returned %d\n", r
);
1340 sz
= sizeof buffer
- 1;
1341 r
= MsiGetTargetPathA( hpkg
, "TestParent", buffer
, &sz
);
1342 ok( r
== ERROR_SUCCESS
, "failed to get target path: %d\n", r
);
1343 ok( !lstrcmpiA(buffer
, "C:\\Program Files\\"), "Expected \"C:\\Program Files\\\", got %s\n", buffer
);
1345 MsiCloseHandle( hpkg
);
1348 static void test_condition(void)
1350 static const WCHAR cond1
[] = {'\"','a',0x30a,'\"','<','\"',0xe5,'\"',0};
1351 static const WCHAR cond2
[] = {'\"','a',0x30a,'\"','>','\"',0xe5,'\"',0};
1352 static const WCHAR cond3
[] = {'\"','a',0x30a,'\"','<','>','\"',0xe5,'\"',0};
1353 static const WCHAR cond4
[] = {'\"','a',0x30a,'\"','=','\"',0xe5,'\"',0};
1357 r
= package_from_db(create_package_db(), &hpkg
);
1358 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
1360 skip("Not enough rights to perform tests\n");
1361 DeleteFileA(msifile
);
1364 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
1366 r
= MsiEvaluateConditionA(0, NULL
);
1367 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
1369 r
= MsiEvaluateConditionA(hpkg
, NULL
);
1370 ok( r
== MSICONDITION_NONE
, "wrong return val\n");
1372 r
= MsiEvaluateConditionA(hpkg
, "");
1373 ok( r
== MSICONDITION_NONE
, "wrong return val\n");
1375 r
= MsiEvaluateConditionA(hpkg
, "1");
1376 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1378 r
= MsiEvaluateConditionA(hpkg
, "0");
1379 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1381 r
= MsiEvaluateConditionA(hpkg
, "-1");
1382 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1384 r
= MsiEvaluateConditionA(hpkg
, "0 = 0");
1385 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1387 r
= MsiEvaluateConditionA(hpkg
, "0 <> 0");
1388 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1390 r
= MsiEvaluateConditionA(hpkg
, "0 = 1");
1391 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1393 r
= MsiEvaluateConditionA(hpkg
, "0 > 1");
1394 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1396 r
= MsiEvaluateConditionA(hpkg
, "0 ~> 1");
1397 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1399 r
= MsiEvaluateConditionA(hpkg
, "1 > 1");
1400 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1402 r
= MsiEvaluateConditionA(hpkg
, "1 ~> 1");
1403 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1405 r
= MsiEvaluateConditionA(hpkg
, "0 >= 1");
1406 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1408 r
= MsiEvaluateConditionA(hpkg
, "0 ~>= 1");
1409 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1411 r
= MsiEvaluateConditionA(hpkg
, "1 >= 1");
1412 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1414 r
= MsiEvaluateConditionA(hpkg
, "1 ~>= 1");
1415 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1417 r
= MsiEvaluateConditionA(hpkg
, "0 < 1");
1418 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1420 r
= MsiEvaluateConditionA(hpkg
, "0 ~< 1");
1421 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1423 r
= MsiEvaluateConditionA(hpkg
, "1 < 1");
1424 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1426 r
= MsiEvaluateConditionA(hpkg
, "1 ~< 1");
1427 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1429 r
= MsiEvaluateConditionA(hpkg
, "0 <= 1");
1430 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1432 r
= MsiEvaluateConditionA(hpkg
, "0 ~<= 1");
1433 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1435 r
= MsiEvaluateConditionA(hpkg
, "1 <= 1");
1436 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1438 r
= MsiEvaluateConditionA(hpkg
, "1 ~<= 1");
1439 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1441 r
= MsiEvaluateConditionA(hpkg
, "0 >=");
1442 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
1444 r
= MsiEvaluateConditionA(hpkg
, " ");
1445 ok( r
== MSICONDITION_NONE
, "wrong return val\n");
1447 r
= MsiEvaluateConditionA(hpkg
, "LicView <> \"1\"");
1448 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1450 r
= MsiEvaluateConditionA(hpkg
, "LicView <> \"0\"");
1451 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1453 r
= MsiEvaluateConditionA(hpkg
, "LicView <> LicView");
1454 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1456 r
= MsiEvaluateConditionA(hpkg
, "not 0");
1457 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1459 r
= MsiEvaluateConditionA(hpkg
, "not LicView");
1460 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1462 r
= MsiEvaluateConditionA(hpkg
, "\"Testing\" ~<< \"Testing\"");
1463 ok (r
== MSICONDITION_TRUE
, "wrong return val\n");
1465 r
= MsiEvaluateConditionA(hpkg
, "LicView ~<< \"Testing\"");
1466 ok (r
== MSICONDITION_FALSE
, "wrong return val\n");
1468 r
= MsiEvaluateConditionA(hpkg
, "Not LicView ~<< \"Testing\"");
1469 ok (r
== MSICONDITION_TRUE
, "wrong return val\n");
1471 r
= MsiEvaluateConditionA(hpkg
, "not \"A\"");
1472 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1474 r
= MsiEvaluateConditionA(hpkg
, "~not \"A\"");
1475 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
1477 r
= MsiEvaluateConditionA(hpkg
, "\"0\"");
1478 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1480 r
= MsiEvaluateConditionA(hpkg
, "1 and 2");
1481 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1483 r
= MsiEvaluateConditionA(hpkg
, "not 0 and 3");
1484 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1486 r
= MsiEvaluateConditionA(hpkg
, "not 0 and 0");
1487 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1489 r
= MsiEvaluateConditionA(hpkg
, "not 0 or 1");
1490 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1492 r
= MsiEvaluateConditionA(hpkg
, "(0)");
1493 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1495 r
= MsiEvaluateConditionA(hpkg
, "(((((1))))))");
1496 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
1498 r
= MsiEvaluateConditionA(hpkg
, "(((((1)))))");
1499 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1501 r
= MsiEvaluateConditionA(hpkg
, " \"A\" < \"B\" ");
1502 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1504 r
= MsiEvaluateConditionA(hpkg
, " \"A\" > \"B\" ");
1505 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1507 r
= MsiEvaluateConditionA(hpkg
, " \"1\" > \"12\" ");
1508 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1510 r
= MsiEvaluateConditionA(hpkg
, " \"100\" < \"21\" ");
1511 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1513 r
= MsiEvaluateConditionA(hpkg
, "0 < > 0");
1514 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
1516 r
= MsiEvaluateConditionA(hpkg
, "(1<<1) == 2");
1517 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
1519 r
= MsiEvaluateConditionA(hpkg
, " \"A\" = \"a\" ");
1520 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1522 r
= MsiEvaluateConditionA(hpkg
, " \"A\" ~ = \"a\" ");
1523 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
1525 r
= MsiEvaluateConditionA(hpkg
, " \"A\" ~= \"a\" ");
1526 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1528 r
= MsiEvaluateConditionA(hpkg
, " \"A\" ~= 1 ");
1529 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1531 r
= MsiEvaluateConditionA(hpkg
, " \"A\" = 1 ");
1532 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1534 r
= MsiEvaluateConditionA(hpkg
, " 1 ~= 1 ");
1535 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1537 r
= MsiEvaluateConditionA(hpkg
, " 1 ~= \"1\" ");
1538 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1540 r
= MsiEvaluateConditionA(hpkg
, " 1 = \"1\" ");
1541 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1543 r
= MsiEvaluateConditionA(hpkg
, " 0 = \"1\" ");
1544 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1546 r
= MsiEvaluateConditionA(hpkg
, " 0 < \"100\" ");
1547 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1549 r
= MsiEvaluateConditionA(hpkg
, " 100 > \"0\" ");
1550 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1552 r
= MsiEvaluateConditionA(hpkg
, "1 XOR 1");
1553 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1555 r
= MsiEvaluateConditionA(hpkg
, "1 IMP 1");
1556 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1558 r
= MsiEvaluateConditionA(hpkg
, "1 IMP 0");
1559 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1561 r
= MsiEvaluateConditionA(hpkg
, "0 IMP 0");
1562 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1564 r
= MsiEvaluateConditionA(hpkg
, "0 EQV 0");
1565 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1567 r
= MsiEvaluateConditionA(hpkg
, "0 EQV 1");
1568 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1570 r
= MsiEvaluateConditionA(hpkg
, "1 IMP 1 OR 0");
1571 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1573 r
= MsiEvaluateConditionA(hpkg
, "1 IMPL 1");
1574 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
1576 r
= MsiEvaluateConditionA(hpkg
, "\"ASFD\" >< \"S\" ");
1577 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1579 r
= MsiEvaluateConditionA(hpkg
, "\"ASFD\" ~>< \"s\" ");
1580 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1582 r
= MsiEvaluateConditionA(hpkg
, "\"ASFD\" ~>< \"\" ");
1583 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1585 r
= MsiEvaluateConditionA(hpkg
, "\"ASFD\" ~>< \"sss\" ");
1586 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1588 MsiSetPropertyA(hpkg
, "mm", "5" );
1590 r
= MsiEvaluateConditionA(hpkg
, "mm = 5");
1591 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1593 r
= MsiEvaluateConditionA(hpkg
, "mm < 6");
1594 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1596 r
= MsiEvaluateConditionA(hpkg
, "mm <= 5");
1597 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1599 r
= MsiEvaluateConditionA(hpkg
, "mm > 4");
1600 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1602 r
= MsiEvaluateConditionA(hpkg
, "mm < 12");
1603 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1605 r
= MsiEvaluateConditionA(hpkg
, "mm = \"5\"");
1606 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1608 r
= MsiEvaluateConditionA(hpkg
, "0 = \"\"");
1609 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1611 r
= MsiEvaluateConditionA(hpkg
, "0 AND \"\"");
1612 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1614 r
= MsiEvaluateConditionA(hpkg
, "1 AND \"\"");
1615 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1617 r
= MsiEvaluateConditionA(hpkg
, "1 AND \"1\"");
1618 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1620 r
= MsiEvaluateConditionA(hpkg
, "3 >< 1");
1621 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1623 r
= MsiEvaluateConditionA(hpkg
, "3 >< 4");
1624 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1626 r
= MsiEvaluateConditionA(hpkg
, "NOT 0 AND 0");
1627 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1629 r
= MsiEvaluateConditionA(hpkg
, "NOT 0 AND 1");
1630 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1632 r
= MsiEvaluateConditionA(hpkg
, "NOT 1 OR 0");
1633 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1635 r
= MsiEvaluateConditionA(hpkg
, "0 AND 1 OR 1");
1636 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1638 r
= MsiEvaluateConditionA(hpkg
, "0 AND 0 OR 1");
1639 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1641 r
= MsiEvaluateConditionA(hpkg
, "NOT 0 AND 1 OR 0");
1642 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1644 r
= MsiEvaluateConditionA(hpkg
, "_1 = _1");
1645 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1647 r
= MsiEvaluateConditionA(hpkg
, "( 1 AND 1 ) = 2");
1648 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
1650 r
= MsiEvaluateConditionA(hpkg
, "NOT ( 1 AND 1 )");
1651 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1653 r
= MsiEvaluateConditionA(hpkg
, "NOT A AND (BBBBBBBBBB=2 OR CCC=1) AND Ddddddddd");
1654 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1656 r
= MsiEvaluateConditionA(hpkg
, "Installed<>\"\"");
1657 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1659 r
= MsiEvaluateConditionA(hpkg
, "NOT 1 AND 0");
1660 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1662 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1663 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1665 r
= MsiEvaluateConditionA(hpkg
, "bandalmael<>0");
1666 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1668 r
= MsiEvaluateConditionA(hpkg
, "bandalmael<0");
1669 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1671 r
= MsiEvaluateConditionA(hpkg
, "bandalmael>0");
1672 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1674 r
= MsiEvaluateConditionA(hpkg
, "bandalmael>=0");
1675 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1677 r
= MsiEvaluateConditionA(hpkg
, "bandalmael<=0");
1678 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1680 r
= MsiEvaluateConditionA(hpkg
, "bandalmael~<>0");
1681 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1683 MsiSetPropertyA(hpkg
, "bandalmael", "0" );
1684 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1685 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1687 MsiSetPropertyA(hpkg
, "bandalmael", "" );
1688 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1689 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1691 MsiSetPropertyA(hpkg
, "bandalmael", "asdf" );
1692 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1693 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1695 MsiSetPropertyA(hpkg
, "bandalmael", "0asdf" );
1696 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1697 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1699 MsiSetPropertyA(hpkg
, "bandalmael", "0 " );
1700 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1701 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1703 MsiSetPropertyA(hpkg
, "bandalmael", "-0" );
1704 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1705 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1707 MsiSetPropertyA(hpkg
, "bandalmael", "0000000000000" );
1708 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1709 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1711 MsiSetPropertyA(hpkg
, "bandalmael", "--0" );
1712 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1713 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1715 MsiSetPropertyA(hpkg
, "bandalmael", "0x00" );
1716 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1717 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1719 MsiSetPropertyA(hpkg
, "bandalmael", "-" );
1720 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1721 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1723 MsiSetPropertyA(hpkg
, "bandalmael", "+0" );
1724 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1725 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1727 MsiSetPropertyA(hpkg
, "bandalmael", "0.0" );
1728 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1729 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1730 r
= MsiEvaluateConditionA(hpkg
, "bandalmael<>0");
1731 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1733 MsiSetPropertyA(hpkg
, "one", "hi");
1734 MsiSetPropertyA(hpkg
, "two", "hithere");
1735 r
= MsiEvaluateConditionA(hpkg
, "one >< two");
1736 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1738 MsiSetPropertyA(hpkg
, "one", "hithere");
1739 MsiSetPropertyA(hpkg
, "two", "hi");
1740 r
= MsiEvaluateConditionA(hpkg
, "one >< two");
1741 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1743 MsiSetPropertyA(hpkg
, "one", "hello");
1744 MsiSetPropertyA(hpkg
, "two", "hi");
1745 r
= MsiEvaluateConditionA(hpkg
, "one >< two");
1746 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1748 MsiSetPropertyA(hpkg
, "one", "hellohithere");
1749 MsiSetPropertyA(hpkg
, "two", "hi");
1750 r
= MsiEvaluateConditionA(hpkg
, "one >< two");
1751 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1753 MsiSetPropertyA(hpkg
, "one", "");
1754 MsiSetPropertyA(hpkg
, "two", "hi");
1755 r
= MsiEvaluateConditionA(hpkg
, "one >< two");
1756 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1758 MsiSetPropertyA(hpkg
, "one", "hi");
1759 MsiSetPropertyA(hpkg
, "two", "");
1760 r
= MsiEvaluateConditionA(hpkg
, "one >< two");
1761 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1763 MsiSetPropertyA(hpkg
, "one", "");
1764 MsiSetPropertyA(hpkg
, "two", "");
1765 r
= MsiEvaluateConditionA(hpkg
, "one >< two");
1766 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1768 MsiSetPropertyA(hpkg
, "one", "1234");
1769 MsiSetPropertyA(hpkg
, "two", "1");
1770 r
= MsiEvaluateConditionA(hpkg
, "one >< two");
1771 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1773 MsiSetPropertyA(hpkg
, "one", "one 1234");
1774 MsiSetPropertyA(hpkg
, "two", "1");
1775 r
= MsiEvaluateConditionA(hpkg
, "one >< two");
1776 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1778 MsiSetPropertyA(hpkg
, "one", "hithere");
1779 MsiSetPropertyA(hpkg
, "two", "hi");
1780 r
= MsiEvaluateConditionA(hpkg
, "one << two");
1781 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1783 MsiSetPropertyA(hpkg
, "one", "hi");
1784 MsiSetPropertyA(hpkg
, "two", "hithere");
1785 r
= MsiEvaluateConditionA(hpkg
, "one << two");
1786 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1788 MsiSetPropertyA(hpkg
, "one", "hi");
1789 MsiSetPropertyA(hpkg
, "two", "hi");
1790 r
= MsiEvaluateConditionA(hpkg
, "one << two");
1791 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1793 MsiSetPropertyA(hpkg
, "one", "abcdhithere");
1794 MsiSetPropertyA(hpkg
, "two", "hi");
1795 r
= MsiEvaluateConditionA(hpkg
, "one << two");
1796 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1798 MsiSetPropertyA(hpkg
, "one", "");
1799 MsiSetPropertyA(hpkg
, "two", "hi");
1800 r
= MsiEvaluateConditionA(hpkg
, "one << two");
1801 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1803 MsiSetPropertyA(hpkg
, "one", "hithere");
1804 MsiSetPropertyA(hpkg
, "two", "");
1805 r
= MsiEvaluateConditionA(hpkg
, "one << two");
1806 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1808 MsiSetPropertyA(hpkg
, "one", "");
1809 MsiSetPropertyA(hpkg
, "two", "");
1810 r
= MsiEvaluateConditionA(hpkg
, "one << two");
1811 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1813 MsiSetPropertyA(hpkg
, "one", "1234");
1814 MsiSetPropertyA(hpkg
, "two", "1");
1815 r
= MsiEvaluateConditionA(hpkg
, "one << two");
1816 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1818 MsiSetPropertyA(hpkg
, "one", "1234 one");
1819 MsiSetPropertyA(hpkg
, "two", "1");
1820 r
= MsiEvaluateConditionA(hpkg
, "one << two");
1821 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1823 MsiSetPropertyA(hpkg
, "one", "hithere");
1824 MsiSetPropertyA(hpkg
, "two", "there");
1825 r
= MsiEvaluateConditionA(hpkg
, "one >> two");
1826 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1828 MsiSetPropertyA(hpkg
, "one", "hithere");
1829 MsiSetPropertyA(hpkg
, "two", "hi");
1830 r
= MsiEvaluateConditionA(hpkg
, "one >> two");
1831 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1833 MsiSetPropertyA(hpkg
, "one", "there");
1834 MsiSetPropertyA(hpkg
, "two", "hithere");
1835 r
= MsiEvaluateConditionA(hpkg
, "one >> two");
1836 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1838 MsiSetPropertyA(hpkg
, "one", "there");
1839 MsiSetPropertyA(hpkg
, "two", "there");
1840 r
= MsiEvaluateConditionA(hpkg
, "one >> two");
1841 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1843 MsiSetPropertyA(hpkg
, "one", "abcdhithere");
1844 MsiSetPropertyA(hpkg
, "two", "hi");
1845 r
= MsiEvaluateConditionA(hpkg
, "one >> two");
1846 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1848 MsiSetPropertyA(hpkg
, "one", "");
1849 MsiSetPropertyA(hpkg
, "two", "there");
1850 r
= MsiEvaluateConditionA(hpkg
, "one >> two");
1851 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1853 MsiSetPropertyA(hpkg
, "one", "there");
1854 MsiSetPropertyA(hpkg
, "two", "");
1855 r
= MsiEvaluateConditionA(hpkg
, "one >> two");
1856 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1858 MsiSetPropertyA(hpkg
, "one", "");
1859 MsiSetPropertyA(hpkg
, "two", "");
1860 r
= MsiEvaluateConditionA(hpkg
, "one >> two");
1861 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1863 MsiSetPropertyA(hpkg
, "one", "1234");
1864 MsiSetPropertyA(hpkg
, "two", "4");
1865 r
= MsiEvaluateConditionA(hpkg
, "one >> two");
1866 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1868 MsiSetPropertyA(hpkg
, "one", "one 1234");
1869 MsiSetPropertyA(hpkg
, "two", "4");
1870 r
= MsiEvaluateConditionA(hpkg
, "one >> two");
1871 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1873 MsiSetPropertyA(hpkg
, "MsiNetAssemblySupport", NULL
); /* make sure it's empty */
1875 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1.1.4322\"");
1876 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1878 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport > \"1.1.4322\"");
1879 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1881 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport >= \"1.1.4322\"");
1882 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1884 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport <= \"1.1.4322\"");
1885 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1887 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport <> \"1.1.4322\"");
1888 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1890 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport ~< \"1.1.4322\"");
1891 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1893 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"abcd\"");
1894 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1896 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"a1.1.4322\"");
1897 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1899 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1.1.4322a\"");
1900 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1902 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"0000001.1.4322\"");
1903 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1905 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1.1.4322.1\"");
1906 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1908 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1.1.4322.1.1\"");
1909 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1911 r
= MsiEvaluateConditionA(hpkg
, "\"2\" < \"1.1");
1912 ok( r
== MSICONDITION_ERROR
, "wrong return val (%d)\n", r
);
1914 r
= MsiEvaluateConditionA(hpkg
, "\"2\" < \"1.1\"");
1915 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1917 r
= MsiEvaluateConditionA(hpkg
, "\"2\" < \"12.1\"");
1918 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1920 r
= MsiEvaluateConditionA(hpkg
, "\"02.1\" < \"2.11\"");
1921 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1923 r
= MsiEvaluateConditionA(hpkg
, "\"02.1.1\" < \"2.1\"");
1924 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1926 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1.1\"");
1927 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1929 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1\"");
1930 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1932 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"0\"");
1933 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1935 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"-1\"");
1936 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1938 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"a\"");
1939 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1941 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"!\"");
1942 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1944 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"!\"");
1945 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1947 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"/\"");
1948 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1950 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \" \"");
1951 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1953 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"azAZ_\"");
1954 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1956 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"a[a]\"");
1957 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1959 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"a[a]a\"");
1960 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1962 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"[a]\"");
1963 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1965 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"[a]a\"");
1966 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1968 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"{a}\"");
1969 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1971 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"{a\"");
1972 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1974 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"[a\"");
1975 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1977 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"a{\"");
1978 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1980 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"a]\"");
1981 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1983 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"A\"");
1984 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1986 MsiSetPropertyA(hpkg
, "MsiNetAssemblySupport", "1.1.4322");
1987 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1.1.4322\"");
1988 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1990 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1.1.14322\"");
1991 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1993 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1.1.5\"");
1994 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1996 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1.1\"");
1997 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1999 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1\"");
2000 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
2002 MsiSetPropertyA(hpkg
, "one", "1");
2003 r
= MsiEvaluateConditionA(hpkg
, "one < \"1\"");
2004 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
2006 MsiSetPropertyA(hpkg
, "X", "5.0");
2008 r
= MsiEvaluateConditionA(hpkg
, "X != \"\"");
2009 ok( r
== MSICONDITION_ERROR
, "wrong return val (%d)\n", r
);
2011 r
= MsiEvaluateConditionA(hpkg
, "X =\"5.0\"");
2012 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2014 r
= MsiEvaluateConditionA(hpkg
, "X =\"5.1\"");
2015 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
2017 r
= MsiEvaluateConditionA(hpkg
, "X =\"6.0\"");
2018 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
2020 r
= MsiEvaluateConditionA(hpkg
, "X =\"5.0\" or X =\"5.1\" or X =\"6.0\"");
2021 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2023 r
= MsiEvaluateConditionA(hpkg
, "(X =\"5.0\" or X =\"5.1\" or X =\"6.0\")");
2024 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2026 r
= MsiEvaluateConditionA(hpkg
, "X !=\"\" and (X =\"5.0\" or X =\"5.1\" or X =\"6.0\")");
2027 ok( r
== MSICONDITION_ERROR
, "wrong return val (%d)\n", r
);
2029 /* feature doesn't exist */
2030 r
= MsiEvaluateConditionA(hpkg
, "&nofeature");
2031 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
2033 MsiSetPropertyA(hpkg
, "A", "2");
2034 MsiSetPropertyA(hpkg
, "X", "50");
2036 r
= MsiEvaluateConditionA(hpkg
, "2 <= X");
2037 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2039 r
= MsiEvaluateConditionA(hpkg
, "A <= X");
2040 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2042 r
= MsiEvaluateConditionA(hpkg
, "A <= 50");
2043 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2045 MsiSetPropertyA(hpkg
, "X", "50val");
2047 r
= MsiEvaluateConditionA(hpkg
, "2 <= X");
2048 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
2050 r
= MsiEvaluateConditionA(hpkg
, "A <= X");
2051 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2053 MsiSetPropertyA(hpkg
, "A", "7");
2054 MsiSetPropertyA(hpkg
, "X", "50");
2056 r
= MsiEvaluateConditionA(hpkg
, "7 <= X");
2057 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2059 r
= MsiEvaluateConditionA(hpkg
, "A <= X");
2060 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2062 r
= MsiEvaluateConditionA(hpkg
, "A <= 50");
2063 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
2065 MsiSetPropertyA(hpkg
, "X", "50val");
2067 r
= MsiEvaluateConditionA(hpkg
, "2 <= X");
2068 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
2070 r
= MsiEvaluateConditionA(hpkg
, "A <= X");
2071 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
2073 r
= MsiEvaluateConditionW(hpkg
, cond1
);
2074 ok( r
== MSICONDITION_TRUE
|| broken(r
== MSICONDITION_FALSE
),
2075 "wrong return val (%d)\n", r
);
2077 r
= MsiEvaluateConditionW(hpkg
, cond2
);
2078 ok( r
== MSICONDITION_FALSE
|| broken(r
== MSICONDITION_TRUE
),
2079 "wrong return val (%d)\n", r
);
2081 r
= MsiEvaluateConditionW(hpkg
, cond3
);
2082 ok( r
== MSICONDITION_TRUE
|| broken(r
== MSICONDITION_FALSE
),
2083 "wrong return val (%d)\n", r
);
2085 r
= MsiEvaluateConditionW(hpkg
, cond4
);
2086 ok( r
== MSICONDITION_FALSE
|| broken(r
== MSICONDITION_TRUE
),
2087 "wrong return val (%d)\n", r
);
2089 MsiCloseHandle( hpkg
);
2090 DeleteFileA(msifile
);
2093 static BOOL
check_prop_empty( MSIHANDLE hpkg
, const char * prop
)
2101 r
= MsiGetPropertyA( hpkg
, prop
, buffer
, &sz
);
2102 return r
== ERROR_SUCCESS
&& buffer
[0] == 0 && sz
== 0;
2105 static void test_props(void)
2107 MSIHANDLE hpkg
, hdb
;
2112 hdb
= create_package_db();
2114 "CREATE TABLE `Property` ( "
2115 "`Property` CHAR(255) NOT NULL, "
2116 "`Value` CHAR(255) "
2117 "PRIMARY KEY `Property`)" );
2118 ok( r
== ERROR_SUCCESS
, "Failed\n" );
2121 "INSERT INTO `Property` "
2122 "(`Property`, `Value`) "
2123 "VALUES( 'MetadataCompName', 'Photoshop.dll' )");
2124 ok( r
== ERROR_SUCCESS
, "Failed\n" );
2126 r
= package_from_db( hdb
, &hpkg
);
2127 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
2129 skip("Not enough rights to perform tests\n");
2130 DeleteFileA(msifile
);
2133 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
2135 /* test invalid values */
2136 r
= MsiGetPropertyA( 0, NULL
, NULL
, NULL
);
2137 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
2139 r
= MsiGetPropertyA( hpkg
, NULL
, NULL
, NULL
);
2140 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
2142 r
= MsiGetPropertyA( hpkg
, "boo", NULL
, NULL
);
2143 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2145 r
= MsiGetPropertyA( hpkg
, "boo", buffer
, NULL
);
2146 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
2148 /* test retrieving an empty/nonexistent property */
2150 r
= MsiGetPropertyA( hpkg
, "boo", NULL
, &sz
);
2151 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2152 ok( sz
== 0, "wrong size returned\n");
2154 check_prop_empty( hpkg
, "boo");
2157 r
= MsiGetPropertyA( hpkg
, "boo", buffer
, &sz
);
2158 ok( r
== ERROR_MORE_DATA
, "wrong return val\n");
2159 ok( !strcmp(buffer
,"x"), "buffer was changed\n");
2160 ok( sz
== 0, "wrong size returned\n");
2164 r
= MsiGetPropertyA( hpkg
, "boo", buffer
, &sz
);
2165 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2166 ok( buffer
[0] == 0, "buffer was not changed\n");
2167 ok( sz
== 0, "wrong size returned\n");
2169 /* set the property to something */
2170 r
= MsiSetPropertyA( 0, NULL
, NULL
);
2171 ok( r
== ERROR_INVALID_HANDLE
, "wrong return val\n");
2173 r
= MsiSetPropertyA( hpkg
, NULL
, NULL
);
2174 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
2176 r
= MsiSetPropertyA( hpkg
, "", NULL
);
2177 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2179 /* try set and get some illegal property identifiers */
2180 r
= MsiSetPropertyA( hpkg
, "", "asdf" );
2181 ok( r
== ERROR_FUNCTION_FAILED
, "wrong return val\n");
2183 r
= MsiSetPropertyA( hpkg
, "=", "asdf" );
2184 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2186 r
= MsiSetPropertyA( hpkg
, " ", "asdf" );
2187 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2189 r
= MsiSetPropertyA( hpkg
, "'", "asdf" );
2190 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2194 r
= MsiGetPropertyA( hpkg
, "'", buffer
, &sz
);
2195 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2196 ok( !strcmp(buffer
,"asdf"), "buffer was not changed\n");
2198 /* set empty values */
2199 r
= MsiSetPropertyA( hpkg
, "boo", NULL
);
2200 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2201 ok( check_prop_empty( hpkg
, "boo"), "prop wasn't empty\n");
2203 r
= MsiSetPropertyA( hpkg
, "boo", "" );
2204 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2205 ok( check_prop_empty( hpkg
, "boo"), "prop wasn't empty\n");
2207 /* set a non-empty value */
2208 r
= MsiSetPropertyA( hpkg
, "boo", "xyz" );
2209 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2213 r
= MsiGetPropertyA( hpkg
, "boo", buffer
, &sz
);
2214 ok( r
== ERROR_MORE_DATA
, "wrong return val\n");
2215 ok( buffer
[0] == 0, "buffer was not changed\n");
2216 ok( sz
== 3, "wrong size returned\n");
2220 r
= MsiGetPropertyA( hpkg
, "boo", buffer
, &sz
);
2221 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2222 ok( !strcmp(buffer
,"xyz"), "buffer was not changed\n");
2223 ok( sz
== 3, "wrong size returned\n");
2227 r
= MsiGetPropertyA( hpkg
, "boo", buffer
, &sz
);
2228 ok( r
== ERROR_MORE_DATA
, "wrong return val\n");
2229 ok( !strcmp(buffer
,"xy"), "buffer was not changed\n");
2230 ok( sz
== 3, "wrong size returned\n");
2232 r
= MsiSetPropertyA(hpkg
, "SourceDir", "foo");
2233 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2236 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", buffer
, &sz
);
2237 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2238 ok( !strcmp(buffer
,""), "buffer wrong\n");
2239 ok( sz
== 0, "wrong size returned\n");
2242 r
= MsiGetPropertyA(hpkg
, "SOMERANDOMNAME", buffer
, &sz
);
2243 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2244 ok( !strcmp(buffer
,""), "buffer wrong\n");
2245 ok( sz
== 0, "wrong size returned\n");
2248 r
= MsiGetPropertyA(hpkg
, "SourceDir", buffer
, &sz
);
2249 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2250 ok( !strcmp(buffer
,"foo"), "buffer wrong\n");
2251 ok( sz
== 3, "wrong size returned\n");
2253 r
= MsiSetPropertyA(hpkg
, "MetadataCompName", "Photoshop.dll");
2254 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2257 r
= MsiGetPropertyA(hpkg
, "MetadataCompName", NULL
, &sz
);
2258 ok( r
== ERROR_SUCCESS
, "return wrong\n");
2259 ok( sz
== 13, "size wrong (%d)\n", sz
);
2262 r
= MsiGetPropertyA(hpkg
, "MetadataCompName", buffer
, &sz
);
2263 ok( r
== ERROR_MORE_DATA
, "return wrong\n");
2264 ok( !strcmp(buffer
,"Photoshop.dl"), "buffer wrong\n");
2266 r
= MsiSetPropertyA(hpkg
, "property", "value");
2267 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2270 r
= MsiGetPropertyA(hpkg
, "property", buffer
, &sz
);
2271 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2272 ok( !strcmp(buffer
, "value"), "Expected value, got %s\n", buffer
);
2274 r
= MsiSetPropertyA(hpkg
, "property", NULL
);
2275 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2278 r
= MsiGetPropertyA(hpkg
, "property", buffer
, &sz
);
2279 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2280 ok(!buffer
[0], "Expected empty string, got %s\n", buffer
);
2282 MsiCloseHandle( hpkg
);
2283 DeleteFileA(msifile
);
2286 static BOOL
find_prop_in_property(MSIHANDLE hdb
, LPCSTR prop
, LPCSTR val
, int len
)
2288 MSIHANDLE hview
, hrec
;
2290 CHAR buffer
[MAX_PATH
];
2294 r
= MsiDatabaseOpenViewA(hdb
, "SELECT * FROM `_Property`", &hview
);
2295 ok(r
== ERROR_SUCCESS
, "MsiDatabaseOpenView failed\n");
2296 r
= MsiViewExecute(hview
, 0);
2297 ok(r
== ERROR_SUCCESS
, "MsiViewExecute failed\n");
2299 if (len
< 0) len
= lstrlenA(val
);
2301 while (r
== ERROR_SUCCESS
&& !found
)
2303 r
= MsiViewFetch(hview
, &hrec
);
2304 if (r
!= ERROR_SUCCESS
) break;
2307 r
= MsiRecordGetStringA(hrec
, 1, buffer
, &sz
);
2308 if (r
== ERROR_SUCCESS
&& !lstrcmpA(buffer
, prop
))
2311 r
= MsiRecordGetStringA(hrec
, 2, buffer
, &sz
);
2312 if (r
== ERROR_SUCCESS
&& !memcmp(buffer
, val
, len
) && !buffer
[len
])
2314 ok(sz
== len
, "wrong size %u\n", sz
);
2319 MsiCloseHandle(hrec
);
2321 MsiViewClose(hview
);
2322 MsiCloseHandle(hview
);
2326 static void test_property_table(void)
2330 MSIHANDLE hpkg
, hdb
, hrec
;
2331 char buffer
[MAX_PATH
], package
[10];
2335 hdb
= create_package_db();
2336 ok( hdb
, "failed to create package\n");
2338 r
= package_from_db(hdb
, &hpkg
);
2339 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
2341 skip("Not enough rights to perform tests\n");
2342 DeleteFileA(msifile
);
2345 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
2347 MsiCloseHandle(hdb
);
2349 hdb
= MsiGetActiveDatabase(hpkg
);
2351 query
= "CREATE TABLE `_Property` ( "
2352 "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
2353 r
= run_query(hdb
, query
);
2354 ok(r
== ERROR_BAD_QUERY_SYNTAX
, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r
);
2356 MsiCloseHandle(hdb
);
2357 MsiCloseHandle(hpkg
);
2358 DeleteFileA(msifile
);
2360 hdb
= create_package_db();
2361 ok( hdb
, "failed to create package\n");
2363 query
= "CREATE TABLE `_Property` ( "
2364 "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
2365 r
= run_query(hdb
, query
);
2366 ok(r
== ERROR_SUCCESS
, "failed to create table\n");
2368 query
= "ALTER `_Property` ADD `foo` INTEGER";
2369 r
= run_query(hdb
, query
);
2370 ok(r
== ERROR_BAD_QUERY_SYNTAX
, "failed to add column\n");
2372 query
= "ALTER TABLE `_Property` ADD `foo` INTEGER";
2373 r
= run_query(hdb
, query
);
2374 ok(r
== ERROR_BAD_QUERY_SYNTAX
, "failed to add column\n");
2376 query
= "ALTER TABLE `_Property` ADD `extra` INTEGER";
2377 r
= run_query(hdb
, query
);
2378 ok(r
== ERROR_SUCCESS
, "failed to add column\n");
2380 sprintf(package
, "#%i", hdb
);
2381 r
= MsiOpenPackageA(package
, &hpkg
);
2382 ok(r
!= ERROR_SUCCESS
, "MsiOpenPackage succeeded\n");
2383 if (r
== ERROR_SUCCESS
)
2384 MsiCloseHandle(hpkg
);
2386 r
= MsiCloseHandle(hdb
);
2387 ok(r
== ERROR_SUCCESS
, "MsiCloseHandle failed %u\n", r
);
2389 hdb
= create_package_db();
2390 ok (hdb
, "failed to create package database\n");
2392 r
= create_property_table(hdb
);
2393 ok(r
== ERROR_SUCCESS
, "cannot create Property table: %d\n", r
);
2395 r
= add_property_entry(hdb
, "'prop', 'val'");
2396 ok(r
== ERROR_SUCCESS
, "cannot add property: %d\n", r
);
2398 r
= create_custom_action_table(hdb
);
2399 ok(r
== ERROR_SUCCESS
, "cannot create CustomAction table: %d\n", r
);
2401 r
= add_custom_action_entry( hdb
, "'EmbedNull', 51, 'prop2', '[~]np'" );
2402 ok( r
== ERROR_SUCCESS
, "cannot add custom action: %d\n", r
);
2404 r
= package_from_db(hdb
, &hpkg
);
2405 ok(r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
2407 MsiCloseHandle(hdb
);
2410 r
= MsiGetPropertyA(hpkg
, "prop", buffer
, &sz
);
2411 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2412 ok(!lstrcmpA(buffer
, "val"), "Expected val, got %s\n", buffer
);
2414 hdb
= MsiGetActiveDatabase(hpkg
);
2416 found
= find_prop_in_property(hdb
, "prop", "val", -1);
2417 ok(found
, "prop should be in the _Property table\n");
2419 r
= add_property_entry(hdb
, "'dantes', 'mercedes'");
2420 ok(r
== ERROR_SUCCESS
, "cannot add property: %d\n", r
);
2422 query
= "SELECT * FROM `_Property` WHERE `Property` = 'dantes'";
2423 r
= do_query(hdb
, query
, &hrec
);
2424 ok(r
== ERROR_BAD_QUERY_SYNTAX
, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r
);
2426 found
= find_prop_in_property(hdb
, "dantes", "mercedes", -1);
2427 ok(found
== FALSE
, "dantes should not be in the _Property table\n");
2430 lstrcpyA(buffer
, "aaa");
2431 r
= MsiGetPropertyA(hpkg
, "dantes", buffer
, &sz
);
2432 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2433 ok(!buffer
[0], "Expected empty string, got %s\n", buffer
);
2435 r
= MsiSetPropertyA(hpkg
, "dantes", "mercedes");
2436 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2438 found
= find_prop_in_property(hdb
, "dantes", "mercedes", -1);
2439 ok(found
== TRUE
, "dantes should be in the _Property table\n");
2441 r
= MsiDoActionA( hpkg
, "EmbedNull" );
2442 ok( r
== ERROR_SUCCESS
, "EmbedNull failed: %d\n", r
);
2445 memset( buffer
, 'a', sizeof(buffer
) );
2446 r
= MsiGetPropertyA( hpkg
, "prop2", buffer
, &sz
);
2447 ok( r
== ERROR_SUCCESS
, "get property failed: %d\n", r
);
2448 ok( !memcmp( buffer
, "\0np", sizeof("\0np") ), "wrong value\n");
2449 ok( sz
== sizeof("\0np") - 1, "got %u\n", sz
);
2451 found
= find_prop_in_property(hdb
, "prop2", "\0np", 3);
2452 ok(found
== TRUE
, "prop2 should be in the _Property table\n");
2454 MsiCloseHandle(hdb
);
2455 MsiCloseHandle(hpkg
);
2456 DeleteFileA(msifile
);
2459 static UINT
try_query_param( MSIHANDLE hdb
, LPCSTR szQuery
, MSIHANDLE hrec
)
2464 res
= MsiDatabaseOpenViewA( hdb
, szQuery
, &htab
);
2465 if( res
== ERROR_SUCCESS
)
2469 r
= MsiViewExecute( htab
, hrec
);
2470 if( r
!= ERROR_SUCCESS
)
2473 fprintf(stderr
,"MsiViewExecute failed %08x\n", res
);
2476 r
= MsiViewClose( htab
);
2477 if( r
!= ERROR_SUCCESS
)
2480 r
= MsiCloseHandle( htab
);
2481 if( r
!= ERROR_SUCCESS
)
2487 static UINT
try_query( MSIHANDLE hdb
, LPCSTR szQuery
)
2489 return try_query_param( hdb
, szQuery
, 0 );
2492 static void set_summary_str(MSIHANDLE hdb
, DWORD pid
, LPCSTR value
)
2497 r
= MsiGetSummaryInformationA(hdb
, NULL
, 1, &summary
);
2498 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2500 r
= MsiSummaryInfoSetPropertyA(summary
, pid
, VT_LPSTR
, 0, NULL
, value
);
2501 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
2503 r
= MsiSummaryInfoPersist(summary
);
2504 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
2506 MsiCloseHandle(summary
);
2509 static void set_summary_dword(MSIHANDLE hdb
, DWORD pid
, DWORD value
)
2514 r
= MsiGetSummaryInformationA(hdb
, NULL
, 1, &summary
);
2515 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2517 r
= MsiSummaryInfoSetPropertyA(summary
, pid
, VT_I4
, value
, NULL
, NULL
);
2518 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
2520 r
= MsiSummaryInfoPersist(summary
);
2521 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
2523 MsiCloseHandle(summary
);
2526 static void test_msipackage(void)
2528 MSIHANDLE hdb
= 0, hpack
= 100;
2533 /* NULL szPackagePath */
2534 r
= MsiOpenPackageA(NULL
, &hpack
);
2535 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
2537 /* empty szPackagePath */
2538 r
= MsiOpenPackageA("", &hpack
);
2539 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
2541 skip("Not enough rights to perform tests\n");
2546 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2549 if (r
== ERROR_SUCCESS
)
2550 MsiCloseHandle(hpack
);
2552 /* nonexistent szPackagePath */
2553 r
= MsiOpenPackageA("nonexistent", &hpack
);
2554 ok(r
== ERROR_FILE_NOT_FOUND
, "Expected ERROR_FILE_NOT_FOUND, got %d\n", r
);
2557 r
= MsiOpenPackageA(msifile
, NULL
);
2558 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
2562 r
= MsiOpenPackageA(name
, &hpack
);
2563 ok(r
== ERROR_INVALID_HANDLE
, "Expected ERROR_INVALID_HANDLE, got %d\n", r
);
2565 r
= MsiOpenDatabaseW(msifileW
, MSIDBOPEN_CREATE
, &hdb
);
2566 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2568 /* database exists, but is empty */
2569 sprintf(name
, "#%d", hdb
);
2570 r
= MsiOpenPackageA(name
, &hpack
);
2571 ok(r
== ERROR_INSTALL_PACKAGE_INVALID
,
2572 "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r
);
2574 query
= "CREATE TABLE `Property` ( "
2575 "`Property` CHAR(72), `Value` CHAR(0) "
2576 "PRIMARY KEY `Property`)";
2577 r
= try_query(hdb
, query
);
2578 ok(r
== ERROR_SUCCESS
, "failed to create Properties table\n");
2580 query
= "CREATE TABLE `InstallExecuteSequence` ("
2581 "`Action` CHAR(72), `Condition` CHAR(0), `Sequence` INTEGER "
2582 "PRIMARY KEY `Action`)";
2583 r
= try_query(hdb
, query
);
2584 ok(r
== ERROR_SUCCESS
, "failed to create InstallExecuteSequence table\n");
2586 /* a few key tables exist */
2587 sprintf(name
, "#%d", hdb
);
2588 r
= MsiOpenPackageA(name
, &hpack
);
2589 ok(r
== ERROR_INSTALL_PACKAGE_INVALID
,
2590 "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r
);
2592 MsiCloseHandle(hdb
);
2593 DeleteFileA(msifile
);
2595 /* start with a clean database to show what constitutes a valid package */
2596 r
= MsiOpenDatabaseW(msifileW
, MSIDBOPEN_CREATE
, &hdb
);
2597 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2599 sprintf(name
, "#%d", hdb
);
2601 /* The following summary information props must exist:
2606 set_summary_dword(hdb
, PID_PAGECOUNT
, 100);
2607 r
= MsiOpenPackageA(name
, &hpack
);
2608 ok(r
== ERROR_INSTALL_PACKAGE_INVALID
,
2609 "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r
);
2611 set_summary_str(hdb
, PID_REVNUMBER
, "{004757CD-5092-49C2-AD20-28E1CE0DF5F2}");
2612 r
= MsiOpenPackageA(name
, &hpack
);
2613 ok(r
== ERROR_SUCCESS
,
2614 "Expected ERROR_SUCCESS, got %d\n", r
);
2616 MsiCloseHandle(hpack
);
2617 MsiCloseHandle(hdb
);
2618 DeleteFileA(msifile
);
2621 static void test_formatrecord2(void)
2623 MSIHANDLE hpkg
, hrec
;
2628 r
= package_from_db(create_package_db(), &hpkg
);
2629 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
2631 skip("Not enough rights to perform tests\n");
2632 DeleteFileA(msifile
);
2635 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
2637 r
= MsiSetPropertyA(hpkg
, "Manufacturer", " " );
2638 ok( r
== ERROR_SUCCESS
, "set property failed\n");
2640 hrec
= MsiCreateRecord(2);
2641 ok(hrec
, "create record failed\n");
2643 r
= MsiRecordSetStringA( hrec
, 0, "[ProgramFilesFolder][Manufacturer]\\asdf");
2644 ok( r
== ERROR_SUCCESS
, "format record failed\n");
2648 r
= MsiFormatRecordA( hpkg
, hrec
, buffer
, &sz
);
2649 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
2651 r
= MsiRecordSetStringA(hrec
, 0, "[foo][1]");
2652 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
2653 r
= MsiRecordSetStringA(hrec
, 1, "hoo");
2654 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
2656 r
= MsiFormatRecordA(hpkg
, hrec
, buffer
, &sz
);
2657 ok( sz
== 3, "size wrong\n");
2658 ok( 0 == strcmp(buffer
,"hoo"), "wrong output %s\n",buffer
);
2659 ok( r
== ERROR_SUCCESS
, "format failed\n");
2661 r
= MsiRecordSetStringA(hrec
, 0, "x[~]x");
2662 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
2664 r
= MsiFormatRecordA(hpkg
, hrec
, buffer
, &sz
);
2665 ok( sz
== 3, "size wrong\n");
2666 ok( 0 == strcmp(buffer
,"x"), "wrong output %s\n",buffer
);
2667 ok( r
== ERROR_SUCCESS
, "format failed\n");
2669 r
= MsiRecordSetStringA(hrec
, 0, "[foo.$%}][1]");
2670 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
2671 r
= MsiRecordSetStringA(hrec
, 1, "hoo");
2672 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
2674 r
= MsiFormatRecordA(hpkg
, hrec
, buffer
, &sz
);
2675 ok( sz
== 3, "size wrong\n");
2676 ok( 0 == strcmp(buffer
,"hoo"), "wrong output %s\n",buffer
);
2677 ok( r
== ERROR_SUCCESS
, "format failed\n");
2679 r
= MsiRecordSetStringA(hrec
, 0, "[\\[]");
2680 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
2682 r
= MsiFormatRecordA(hpkg
, hrec
, buffer
, &sz
);
2683 ok( sz
== 1, "size wrong\n");
2684 ok( 0 == strcmp(buffer
,"["), "wrong output %s\n",buffer
);
2685 ok( r
== ERROR_SUCCESS
, "format failed\n");
2687 SetEnvironmentVariableA("FOO", "BAR");
2688 r
= MsiRecordSetStringA(hrec
, 0, "[%FOO]");
2689 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
2691 r
= MsiFormatRecordA(hpkg
, hrec
, buffer
, &sz
);
2692 ok( sz
== 3, "size wrong\n");
2693 ok( 0 == strcmp(buffer
,"BAR"), "wrong output %s\n",buffer
);
2694 ok( r
== ERROR_SUCCESS
, "format failed\n");
2696 r
= MsiRecordSetStringA(hrec
, 0, "[[1]]");
2697 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
2698 r
= MsiRecordSetStringA(hrec
, 1, "%FOO");
2699 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
2701 r
= MsiFormatRecordA(hpkg
, hrec
, buffer
, &sz
);
2702 ok( sz
== 3, "size wrong\n");
2703 ok( 0 == strcmp(buffer
,"BAR"), "wrong output %s\n",buffer
);
2704 ok( r
== ERROR_SUCCESS
, "format failed\n");
2706 MsiCloseHandle( hrec
);
2707 MsiCloseHandle( hpkg
);
2708 DeleteFileA(msifile
);
2711 static void test_feature_states( UINT line
, MSIHANDLE package
, const char *feature
, UINT error
,
2712 INSTALLSTATE expected_state
, INSTALLSTATE expected_action
, BOOL todo
)
2715 INSTALLSTATE state
= 0xdeadbee;
2716 INSTALLSTATE action
= 0xdeadbee;
2718 r
= MsiGetFeatureStateA( package
, feature
, &state
, &action
);
2719 ok( r
== error
, "%u: expected %d got %d\n", line
, error
, r
);
2720 if (r
== ERROR_SUCCESS
)
2722 ok( state
== expected_state
, "%u: expected state %d got %d\n",
2723 line
, expected_state
, state
);
2725 ok( action
== expected_action
, "%u: expected action %d got %d\n",
2726 line
, expected_action
, action
);
2730 ok( state
== 0xdeadbee, "%u: expected state 0xdeadbee got %d\n", line
, state
);
2732 ok( action
== 0xdeadbee, "%u: expected action 0xdeadbee got %d\n", line
, action
);
2737 static void test_component_states( UINT line
, MSIHANDLE package
, const char *component
, UINT error
,
2738 INSTALLSTATE expected_state
, INSTALLSTATE expected_action
, BOOL todo
)
2741 INSTALLSTATE state
= 0xdeadbee;
2742 INSTALLSTATE action
= 0xdeadbee;
2744 r
= MsiGetComponentStateA( package
, component
, &state
, &action
);
2745 ok( r
== error
, "%u: expected %d got %d\n", line
, error
, r
);
2746 if (r
== ERROR_SUCCESS
)
2748 ok( state
== expected_state
, "%u: expected state %d got %d\n",
2749 line
, expected_state
, state
);
2751 ok( action
== expected_action
, "%u: expected action %d got %d\n",
2752 line
, expected_action
, action
);
2756 ok( state
== 0xdeadbee, "%u: expected state 0xdeadbee got %d\n",
2759 ok( action
== 0xdeadbee, "%u: expected action 0xdeadbee got %d\n",
2764 static void test_states(void)
2766 static const char msifile2
[] = "winetest2-package.msi";
2767 static const char msifile3
[] = "winetest3-package.msi";
2768 static const char msifile4
[] = "winetest4-package.msi";
2769 static const WCHAR msifile2W
[] =
2770 {'w','i','n','e','t','e','s','t','2','-','p','a','c','k','a','g','e','.','m','s','i',0};
2771 static const WCHAR msifile3W
[] =
2772 {'w','i','n','e','t','e','s','t','3','-','p','a','c','k','a','g','e','.','m','s','i',0};
2773 static const WCHAR msifile4W
[] =
2774 {'w','i','n','e','t','e','s','t','4','-','p','a','c','k','a','g','e','.','m','s','i',0};
2780 if (is_process_limited())
2782 skip("process is limited\n");
2786 hdb
= create_package_db();
2787 ok ( hdb
, "failed to create package database\n" );
2789 r
= add_directory_entry( hdb
, "'TARGETDIR', '', 'SourceDir'");
2790 ok( r
== ERROR_SUCCESS
, "cannot add directory: %d\n", r
);
2792 r
= create_property_table( hdb
);
2793 ok( r
== ERROR_SUCCESS
, "cannot create Property table: %d\n", r
);
2795 r
= add_property_entry( hdb
, "'ProductCode', '{7262AC98-EEBD-4364-8CE3-D654F6A425B9}'" );
2796 ok( r
== ERROR_SUCCESS
, "cannot add property entry: %d\n", r
);
2798 r
= add_property_entry( hdb
, "'ProductLanguage', '1033'" );
2799 ok( r
== ERROR_SUCCESS
, "cannot add property entry: %d\n", r
);
2801 r
= add_property_entry( hdb
, "'ProductName', 'MSITEST'" );
2802 ok( r
== ERROR_SUCCESS
, "cannot add property entry: %d\n", r
);
2804 r
= add_property_entry( hdb
, "'ProductVersion', '1.1.1'" );
2805 ok( r
== ERROR_SUCCESS
, "cannot add property entry: %d\n", r
);
2807 r
= add_property_entry( hdb
, "'MSIFASTINSTALL', '1'" );
2808 ok( r
== ERROR_SUCCESS
, "cannot add property entry: %d\n", r
);
2810 r
= create_install_execute_sequence_table( hdb
);
2811 ok( r
== ERROR_SUCCESS
, "cannot create InstallExecuteSequence table: %d\n", r
);
2813 r
= add_install_execute_sequence_entry( hdb
, "'CostInitialize', '', '800'" );
2814 ok( r
== ERROR_SUCCESS
, "cannot add install execute sequence entry: %d\n", r
);
2816 r
= add_install_execute_sequence_entry( hdb
, "'FileCost', '', '900'" );
2817 ok( r
== ERROR_SUCCESS
, "cannot add install execute sequence entry: %d\n", r
);
2819 r
= add_install_execute_sequence_entry( hdb
, "'CostFinalize', '', '1000'" );
2820 ok( r
== ERROR_SUCCESS
, "cannot add install execute sequence entry: %d\n", r
);
2822 r
= add_install_execute_sequence_entry( hdb
, "'InstallValidate', '', '1400'" );
2823 ok( r
== ERROR_SUCCESS
, "cannot add install execute sequence entry: %d\n", r
);
2825 r
= add_install_execute_sequence_entry( hdb
, "'InstallInitialize', '', '1500'" );
2826 ok( r
== ERROR_SUCCESS
, "cannot add install execute sequence entry: %d\n", r
);
2828 r
= add_install_execute_sequence_entry( hdb
, "'ProcessComponents', '', '1600'" );
2829 ok( r
== ERROR_SUCCESS
, "cannot add install execute sequence entry: %d\n", r
);
2831 r
= add_install_execute_sequence_entry( hdb
, "'UnpublishFeatures', '', '1800'" );
2832 ok( r
== ERROR_SUCCESS
, "cannot add install execute sequence entry: %d\n", r
);
2834 r
= add_install_execute_sequence_entry( hdb
, "'RegisterProduct', '', '6100'" );
2835 ok( r
== ERROR_SUCCESS
, "cannot add install execute sequence entry: %d\n", r
);
2837 r
= add_install_execute_sequence_entry( hdb
, "'PublishFeatures', '', '6300'" );
2838 ok( r
== ERROR_SUCCESS
, "cannot add install execute sequence entry: %d\n", r
);
2840 r
= add_install_execute_sequence_entry( hdb
, "'PublishProduct', '', '6400'" );
2841 ok( r
== ERROR_SUCCESS
, "cannot add install execute sequence entry: %d\n", r
);
2843 r
= add_install_execute_sequence_entry( hdb
, "'InstallFinalize', '', '6600'" );
2844 ok( r
== ERROR_SUCCESS
, "cannot add install execute sequence entry: %d\n", r
);
2846 r
= create_media_table( hdb
);
2847 ok( r
== ERROR_SUCCESS
, "cannot create media table: %d\n", r
);
2849 r
= add_media_entry( hdb
, "'1', '3', '', '', 'DISK1', ''");
2850 ok( r
== ERROR_SUCCESS
, "cannot add media entry: %d\n", r
);
2852 r
= create_feature_table( hdb
);
2853 ok( r
== ERROR_SUCCESS
, "cannot create Feature table: %d\n", r
);
2855 r
= create_component_table( hdb
);
2856 ok( r
== ERROR_SUCCESS
, "cannot create Component table: %d\n", r
);
2858 /* msidbFeatureAttributesFavorLocal */
2859 r
= add_feature_entry( hdb
, "'one', '', '', '', 2, 1, '', 0" );
2860 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
2862 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
2863 r
= add_component_entry( hdb
, "'alpha', '{467EC132-739D-4784-A37B-677AA43DBC94}', 'TARGETDIR', 0, '', 'alpha_file'" );
2864 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2866 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
2867 r
= add_component_entry( hdb
, "'beta', '{2C1F189C-24A6-4C34-B26B-994A6C026506}', 'TARGETDIR', 1, '', 'beta_file'" );
2868 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2870 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
2871 r
= add_component_entry( hdb
, "'gamma', '{C271E2A4-DE2E-4F70-86D1-6984AF7DE2CA}', 'TARGETDIR', 2, '', 'gamma_file'" );
2872 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2874 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSharedDllRefCount */
2875 r
= add_component_entry( hdb
, "'theta', '{4EB3129D-81A8-48D5-9801-75600FED3DD9}', 'TARGETDIR', 8, '', 'theta_file'" );
2876 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2878 /* msidbFeatureAttributesFavorSource */
2879 r
= add_feature_entry( hdb
, "'two', '', '', '', 2, 1, '', 1" );
2880 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
2882 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
2883 r
= add_component_entry( hdb
, "'delta', '{938FD4F2-C648-4259-A03C-7AA3B45643F3}', 'TARGETDIR', 0, '', 'delta_file'" );
2884 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2886 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
2887 r
= add_component_entry( hdb
, "'epsilon', '{D59713B6-C11D-47F2-A395-1E5321781190}', 'TARGETDIR', 1, '', 'epsilon_file'" );
2888 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2890 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
2891 r
= add_component_entry( hdb
, "'zeta', '{377D33AB-2FAA-42B9-A629-0C0DAE9B9C7A}', 'TARGETDIR', 2, '', 'zeta_file'" );
2892 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2894 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSharedDllRefCount */
2895 r
= add_component_entry( hdb
, "'iota', '{5D36F871-B5ED-4801-9E0F-C46B9E5C9669}', 'TARGETDIR', 8, '', 'iota_file'" );
2896 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2898 /* msidbFeatureAttributesFavorSource */
2899 r
= add_feature_entry( hdb
, "'three', '', '', '', 2, 1, '', 1" );
2900 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
2902 /* msidbFeatureAttributesFavorLocal */
2903 r
= add_feature_entry( hdb
, "'four', '', '', '', 2, 1, '', 0" );
2904 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
2907 r
= add_feature_entry( hdb
, "'five', '', '', '', 2, 0, '', 1" );
2908 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
2910 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
2911 r
= add_component_entry( hdb
, "'eta', '{DD89003F-0DD4-41B8-81C0-3411A7DA2695}', 'TARGETDIR', 1, '', 'eta_file'" );
2912 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2914 /* no feature parent:msidbComponentAttributesLocalOnly */
2915 r
= add_component_entry( hdb
, "'kappa', '{D6B93DC3-8DA5-4769-9888-42BFE156BB8B}', 'TARGETDIR', 1, '', 'kappa_file'" );
2916 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2918 /* msidbFeatureAttributesFavorLocal:removed */
2919 r
= add_feature_entry( hdb
, "'six', '', '', '', 2, 1, '', 0" );
2920 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
2922 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesLocalOnly */
2923 r
= add_component_entry( hdb
, "'lambda', '{6528C5E4-02A4-4636-A214-7A66A6C35B64}', 'TARGETDIR', 0, '', 'lambda_file'" );
2924 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2926 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesSourceOnly */
2927 r
= add_component_entry( hdb
, "'mu', '{97014BAB-6C56-4013-9A63-2BF913B42519}', 'TARGETDIR', 1, '', 'mu_file'" );
2928 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2930 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesOptional */
2931 r
= add_component_entry( hdb
, "'nu', '{943DD0D8-5808-4954-8526-3B8493FEDDCD}', 'TARGETDIR', 2, '', 'nu_file'" );
2932 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2934 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesSharedDllRefCount */
2935 r
= add_component_entry( hdb
, "'xi', '{D6CF9EF7-6FCF-4930-B34B-F938AEFF9BDB}', 'TARGETDIR', 8, '', 'xi_file'" );
2936 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2938 /* msidbFeatureAttributesFavorSource:removed */
2939 r
= add_feature_entry( hdb
, "'seven', '', '', '', 2, 1, '', 1" );
2940 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
2942 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesLocalOnly */
2943 r
= add_component_entry( hdb
, "'omicron', '{7B57521D-15DB-4141-9AA6-01D934A4433F}', 'TARGETDIR', 0, '', 'omicron_file'" );
2944 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2946 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesSourceOnly */
2947 r
= add_component_entry( hdb
, "'pi', '{FB85346B-378E-4492-8769-792305471C81}', 'TARGETDIR', 1, '', 'pi_file'" );
2948 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2950 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesOptional */
2951 r
= add_component_entry( hdb
, "'rho', '{798F2047-7B0C-4783-8BB0-D703E554114B}', 'TARGETDIR', 2, '', 'rho_file'" );
2952 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2954 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesSharedDllRefCount */
2955 r
= add_component_entry( hdb
, "'sigma', '{5CE9DDA8-B67B-4736-9D93-99D61C5B93E7}', 'TARGETDIR', 8, '', 'sigma_file'" );
2956 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2958 /* msidbFeatureAttributesFavorLocal */
2959 r
= add_feature_entry( hdb
, "'eight', '', '', '', 2, 1, '', 0" );
2960 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
2962 r
= add_component_entry( hdb
, "'tau', '{07DEB510-677C-4A6F-A0A6-7CD8EFEA77ED}', 'TARGETDIR', 1, '', 'tau_file'" );
2963 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2965 /* msidbFeatureAttributesFavorSource */
2966 r
= add_feature_entry( hdb
, "'nine', '', '', '', 2, 1, '', 1" );
2967 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
2969 r
= add_component_entry( hdb
, "'phi', '{9F0594C5-35AD-43EA-94DD-8DF73FAA664D}', 'TARGETDIR', 1, '', 'phi_file'" );
2970 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2972 /* msidbFeatureAttributesFavorAdvertise */
2973 r
= add_feature_entry( hdb
, "'ten', '', '', '', 2, 1, '', 4" );
2974 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
2976 r
= add_component_entry( hdb
, "'chi', '{E6B539AB-5DA9-4236-A2D2-E341A50B4C38}', 'TARGETDIR', 1, '', 'chi_file'" );
2977 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2979 /* msidbFeatureAttributesUIDisallowAbsent */
2980 r
= add_feature_entry( hdb
, "'eleven', '', '', '', 2, 1, '', 16" );
2981 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
2983 r
= add_component_entry( hdb
, "'psi', '{A06B23B5-746B-427A-8A6E-FD6AC8F46A95}', 'TARGETDIR', 1, '', 'psi_file'" );
2984 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2986 /* high install level */
2987 r
= add_feature_entry( hdb
, "'twelve', '', '', '', 2, 2, '', 0" );
2988 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
2990 r
= add_component_entry( hdb
, "'upsilon', '{557e0c04-ceba-4c58-86a9-4a73352e8cf6}', 'TARGETDIR', 1, '', 'upsilon_file'" );
2991 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2993 /* msidbFeatureAttributesFollowParent */
2994 r
= add_feature_entry( hdb
, "'thirteen', '', '', '', 2, 2, '', 2" );
2995 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
2997 r
= create_feature_components_table( hdb
);
2998 ok( r
== ERROR_SUCCESS
, "cannot create FeatureComponents table: %d\n", r
);
3000 r
= add_feature_components_entry( hdb
, "'one', 'alpha'" );
3001 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
3003 r
= add_feature_components_entry( hdb
, "'one', 'beta'" );
3004 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
3006 r
= add_feature_components_entry( hdb
, "'one', 'gamma'" );
3007 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
3009 r
= add_feature_components_entry( hdb
, "'one', 'theta'" );
3010 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
3012 r
= add_feature_components_entry( hdb
, "'two', 'delta'" );
3013 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
3015 r
= add_feature_components_entry( hdb
, "'two', 'epsilon'" );
3016 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
3018 r
= add_feature_components_entry( hdb
, "'two', 'zeta'" );
3019 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
3021 r
= add_feature_components_entry( hdb
, "'two', 'iota'" );
3022 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
3024 r
= add_feature_components_entry( hdb
, "'three', 'eta'" );
3025 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
3027 r
= add_feature_components_entry( hdb
, "'four', 'eta'" );
3028 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
3030 r
= add_feature_components_entry( hdb
, "'five', 'eta'" );
3031 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
3033 r
= add_feature_components_entry( hdb
, "'six', 'lambda'" );
3034 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
3036 r
= add_feature_components_entry( hdb
, "'six', 'mu'" );
3037 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
3039 r
= add_feature_components_entry( hdb
, "'six', 'nu'" );
3040 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
3042 r
= add_feature_components_entry( hdb
, "'six', 'xi'" );
3043 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
3045 r
= add_feature_components_entry( hdb
, "'seven', 'omicron'" );
3046 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
3048 r
= add_feature_components_entry( hdb
, "'seven', 'pi'" );
3049 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
3051 r
= add_feature_components_entry( hdb
, "'seven', 'rho'" );
3052 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
3054 r
= add_feature_components_entry( hdb
, "'seven', 'sigma'" );
3055 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
3057 r
= add_feature_components_entry( hdb
, "'eight', 'tau'" );
3058 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
3060 r
= add_feature_components_entry( hdb
, "'nine', 'phi'" );
3061 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
3063 r
= add_feature_components_entry( hdb
, "'ten', 'chi'" );
3064 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
3066 r
= add_feature_components_entry( hdb
, "'eleven', 'psi'" );
3067 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
3069 r
= add_feature_components_entry( hdb
, "'twelve', 'upsilon'" );
3070 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
3072 r
= add_feature_components_entry( hdb
, "'thirteen', 'upsilon'" );
3073 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
3075 r
= create_file_table( hdb
);
3076 ok( r
== ERROR_SUCCESS
, "cannot create File table: %d\n", r
);
3078 r
= add_file_entry( hdb
, "'alpha_file', 'alpha', 'alpha.txt', 100, '', '1033', 8192, 1" );
3079 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3081 r
= add_file_entry( hdb
, "'beta_file', 'beta', 'beta.txt', 0, '', '1033', 8192, 1" );
3082 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3084 r
= add_file_entry( hdb
, "'gamma_file', 'gamma', 'gamma.txt', 0, '', '1033', 8192, 1" );
3085 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3087 r
= add_file_entry( hdb
, "'theta_file', 'theta', 'theta.txt', 0, '', '1033', 8192, 1" );
3088 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3090 r
= add_file_entry( hdb
, "'delta_file', 'delta', 'delta.txt', 0, '', '1033', 8192, 1" );
3091 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3093 r
= add_file_entry( hdb
, "'epsilon_file', 'epsilon', 'epsilon.txt', 0, '', '1033', 8192, 1" );
3094 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3096 r
= add_file_entry( hdb
, "'zeta_file', 'zeta', 'zeta.txt', 0, '', '1033', 8192, 1" );
3097 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3099 r
= add_file_entry( hdb
, "'iota_file', 'iota', 'iota.txt', 0, '', '1033', 8192, 1" );
3100 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3102 /* compressed file */
3103 r
= add_file_entry( hdb
, "'eta_file', 'eta', 'eta.txt', 0, '', '1033', 16384, 1" );
3104 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3106 r
= add_file_entry( hdb
, "'kappa_file', 'kappa', 'kappa.txt', 0, '', '1033', 8192, 1" );
3107 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3109 r
= add_file_entry( hdb
, "'lambda_file', 'lambda', 'lambda.txt', 100, '', '1033', 8192, 1" );
3110 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3112 r
= add_file_entry( hdb
, "'mu_file', 'mu', 'mu.txt', 100, '', '1033', 8192, 1" );
3113 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3115 r
= add_file_entry( hdb
, "'nu_file', 'nu', 'nu.txt', 100, '', '1033', 8192, 1" );
3116 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3118 r
= add_file_entry( hdb
, "'xi_file', 'xi', 'xi.txt', 100, '', '1033', 8192, 1" );
3119 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3121 r
= add_file_entry( hdb
, "'omicron_file', 'omicron', 'omicron.txt', 100, '', '1033', 8192, 1" );
3122 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3124 r
= add_file_entry( hdb
, "'pi_file', 'pi', 'pi.txt', 100, '', '1033', 8192, 1" );
3125 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3127 r
= add_file_entry( hdb
, "'rho_file', 'rho', 'rho.txt', 100, '', '1033', 8192, 1" );
3128 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3130 r
= add_file_entry( hdb
, "'sigma_file', 'sigma', 'sigma.txt', 100, '', '1033', 8192, 1" );
3131 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3133 r
= add_file_entry( hdb
, "'tau_file', 'tau', 'tau.txt', 100, '', '1033', 8192, 1" );
3134 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3136 r
= add_file_entry( hdb
, "'phi_file', 'phi', 'phi.txt', 100, '', '1033', 8192, 1" );
3137 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3139 r
= add_file_entry( hdb
, "'chi_file', 'chi', 'chi.txt', 100, '', '1033', 8192, 1" );
3140 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3142 r
= add_file_entry( hdb
, "'psi_file', 'psi', 'psi.txt', 100, '', '1033', 8192, 1" );
3143 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3145 r
= add_file_entry( hdb
, "'upsilon_file', 'upsilon', 'upsilon.txt', 0, '', '1033', 16384, 1" );
3146 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3148 MsiDatabaseCommit(hdb
);
3150 /* these properties must not be in the saved msi file */
3151 r
= add_property_entry( hdb
, "'ADDLOCAL', 'one,four'");
3152 ok( r
== ERROR_SUCCESS
, "cannot add property: %d\n", r
);
3154 r
= add_property_entry( hdb
, "'ADDSOURCE', 'two,three'");
3155 ok( r
== ERROR_SUCCESS
, "cannot add property: %d\n", r
);
3157 r
= add_property_entry( hdb
, "'REMOVE', 'six,seven'");
3158 ok( r
== ERROR_SUCCESS
, "cannot add property: %d\n", r
);
3160 r
= add_property_entry( hdb
, "'REINSTALL', 'eight,nine,ten'");
3161 ok( r
== ERROR_SUCCESS
, "cannot add property: %d\n", r
);
3163 r
= add_property_entry( hdb
, "'REINSTALLMODE', 'omus'");
3164 ok( r
== ERROR_SUCCESS
, "cannot add property: %d\n", r
);
3166 r
= package_from_db( hdb
, &hpkg
);
3167 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
3169 skip("Not enough rights to perform tests\n");
3170 DeleteFileA(msifile
);
3173 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
3175 MsiCloseHandle(hdb
);
3177 CopyFileA(msifile
, msifile2
, FALSE
);
3178 CopyFileA(msifile
, msifile3
, FALSE
);
3179 CopyFileA(msifile
, msifile4
, FALSE
);
3181 test_feature_states( __LINE__
, hpkg
, "one", ERROR_UNKNOWN_FEATURE
, 0, 0, FALSE
);
3182 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_UNKNOWN_COMPONENT
, 0, 0, FALSE
);
3184 r
= MsiDoActionA( hpkg
, "CostInitialize");
3185 ok( r
== ERROR_SUCCESS
, "cost init failed\n");
3187 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3188 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3190 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
3192 r
= MsiDoActionA( hpkg
, "FileCost");
3193 ok( r
== ERROR_SUCCESS
, "file cost failed\n");
3195 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3196 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3198 r
= MsiDoActionA( hpkg
, "CostFinalize");
3199 ok( r
== ERROR_SUCCESS
, "cost finalize failed: %d\n", r
);
3201 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
3202 test_feature_states( __LINE__
, hpkg
, "two", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_SOURCE
, FALSE
);
3203 test_feature_states( __LINE__
, hpkg
, "three", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
3204 test_feature_states( __LINE__
, hpkg
, "four", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
3205 test_feature_states( __LINE__
, hpkg
, "five", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3206 test_feature_states( __LINE__
, hpkg
, "six", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3207 test_feature_states( __LINE__
, hpkg
, "seven", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3208 test_feature_states( __LINE__
, hpkg
, "eight", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3209 test_feature_states( __LINE__
, hpkg
, "nine", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3210 test_feature_states( __LINE__
, hpkg
, "ten", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3211 test_feature_states( __LINE__
, hpkg
, "eleven", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3212 test_feature_states( __LINE__
, hpkg
, "twelve", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3213 test_feature_states( __LINE__
, hpkg
, "thirteen", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3215 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
3216 test_component_states( __LINE__
, hpkg
, "beta", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_SOURCE
, FALSE
);
3217 test_component_states( __LINE__
, hpkg
, "gamma", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
3218 test_component_states( __LINE__
, hpkg
, "theta", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
3219 test_component_states( __LINE__
, hpkg
, "delta", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
3220 test_component_states( __LINE__
, hpkg
, "epsilon", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_SOURCE
, FALSE
);
3221 test_component_states( __LINE__
, hpkg
, "zeta", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_SOURCE
, FALSE
);
3222 test_component_states( __LINE__
, hpkg
, "iota", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
3223 test_component_states( __LINE__
, hpkg
, "eta", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
3224 test_component_states( __LINE__
, hpkg
, "kappa", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3225 test_component_states( __LINE__
, hpkg
, "lambda", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3226 test_component_states( __LINE__
, hpkg
, "mu", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3227 test_component_states( __LINE__
, hpkg
, "nu", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3228 test_component_states( __LINE__
, hpkg
, "xi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3229 test_component_states( __LINE__
, hpkg
, "omicron", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3230 test_component_states( __LINE__
, hpkg
, "pi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3231 test_component_states( __LINE__
, hpkg
, "rho", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3232 test_component_states( __LINE__
, hpkg
, "sigma", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3233 test_component_states( __LINE__
, hpkg
, "tau", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3234 test_component_states( __LINE__
, hpkg
, "phi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3235 test_component_states( __LINE__
, hpkg
, "chi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3236 test_component_states( __LINE__
, hpkg
, "psi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3237 test_component_states( __LINE__
, hpkg
, "upsilon", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3239 MsiCloseHandle( hpkg
);
3241 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
3243 /* publish the features and components */
3244 r
= MsiInstallProductA(msifile
, "ADDLOCAL=one,four ADDSOURCE=two,three REMOVE=six,seven REINSTALL=eight,nine,ten");
3245 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3247 r
= MsiOpenDatabaseW(msifileW
, MSIDBOPEN_DIRECT
, &hdb
);
3248 ok(r
== ERROR_SUCCESS
, "failed to open database: %d\n", r
);
3250 /* these properties must not be in the saved msi file */
3251 r
= add_property_entry( hdb
, "'ADDLOCAL', 'one,four'");
3252 ok( r
== ERROR_SUCCESS
, "cannot add property: %d\n", r
);
3254 r
= add_property_entry( hdb
, "'ADDSOURCE', 'two,three'");
3255 ok( r
== ERROR_SUCCESS
, "cannot add property: %d\n", r
);
3257 r
= add_property_entry( hdb
, "'REMOVE', 'six,seven'");
3258 ok( r
== ERROR_SUCCESS
, "cannot add property: %d\n", r
);
3260 r
= add_property_entry( hdb
, "'REINSTALL', 'eight,nine,ten'");
3261 ok( r
== ERROR_SUCCESS
, "cannot add property: %d\n", r
);
3263 r
= package_from_db( hdb
, &hpkg
);
3264 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
3266 MsiCloseHandle(hdb
);
3268 test_feature_states( __LINE__
, hpkg
, "one", ERROR_UNKNOWN_FEATURE
, 0, 0, FALSE
);
3269 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_UNKNOWN_COMPONENT
, 0, 0, FALSE
);
3271 r
= MsiDoActionA( hpkg
, "CostInitialize");
3272 ok( r
== ERROR_SUCCESS
, "cost init failed\n");
3274 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3275 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3277 r
= MsiDoActionA( hpkg
, "FileCost");
3278 ok( r
== ERROR_SUCCESS
, "file cost failed\n");
3280 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3281 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3283 r
= MsiDoActionA( hpkg
, "CostFinalize");
3284 ok( r
== ERROR_SUCCESS
, "cost finalize failed: %d\n", r
);
3286 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_LOCAL
, FALSE
);
3287 test_feature_states( __LINE__
, hpkg
, "two", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3288 test_feature_states( __LINE__
, hpkg
, "three", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3289 test_feature_states( __LINE__
, hpkg
, "four", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3290 test_feature_states( __LINE__
, hpkg
, "five", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3291 test_feature_states( __LINE__
, hpkg
, "six", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3292 test_feature_states( __LINE__
, hpkg
, "seven", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3293 test_feature_states( __LINE__
, hpkg
, "eight", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3294 test_feature_states( __LINE__
, hpkg
, "nine", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3295 test_feature_states( __LINE__
, hpkg
, "ten", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3296 test_feature_states( __LINE__
, hpkg
, "eleven", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3297 test_feature_states( __LINE__
, hpkg
, "twelve", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3298 test_feature_states( __LINE__
, hpkg
, "thirteen", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3300 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3301 test_component_states( __LINE__
, hpkg
, "beta", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3302 test_component_states( __LINE__
, hpkg
, "gamma", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3303 test_component_states( __LINE__
, hpkg
, "theta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3304 test_component_states( __LINE__
, hpkg
, "delta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3305 test_component_states( __LINE__
, hpkg
, "epsilon", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3306 test_component_states( __LINE__
, hpkg
, "zeta", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3307 test_component_states( __LINE__
, hpkg
, "iota", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3308 test_component_states( __LINE__
, hpkg
, "eta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3309 test_component_states( __LINE__
, hpkg
, "kappa", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3310 test_component_states( __LINE__
, hpkg
, "lambda", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3311 test_component_states( __LINE__
, hpkg
, "mu", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3312 test_component_states( __LINE__
, hpkg
, "nu", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3313 test_component_states( __LINE__
, hpkg
, "xi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3314 test_component_states( __LINE__
, hpkg
, "omicron", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3315 test_component_states( __LINE__
, hpkg
, "pi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3316 test_component_states( __LINE__
, hpkg
, "rho", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3317 test_component_states( __LINE__
, hpkg
, "sigma", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3318 test_component_states( __LINE__
, hpkg
, "tau", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3319 test_component_states( __LINE__
, hpkg
, "phi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3320 test_component_states( __LINE__
, hpkg
, "chi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3321 test_component_states( __LINE__
, hpkg
, "psi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3322 test_component_states( __LINE__
, hpkg
, "upsilon", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3324 MsiCloseHandle(hpkg
);
3326 /* uninstall the product */
3327 r
= MsiInstallProductA(msifile
, "REMOVE=ALL");
3328 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3330 state
= MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "five");
3331 ok(state
== INSTALLSTATE_UNKNOWN
, "state = %d\n", state
);
3332 state
= MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "twelve");
3333 ok(state
== INSTALLSTATE_UNKNOWN
, "state = %d\n", state
);
3335 /* all features installed locally */
3336 r
= MsiInstallProductA(msifile2
, "ADDLOCAL=ALL");
3337 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3339 state
= MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "five");
3340 ok(state
== INSTALLSTATE_UNKNOWN
, "state = %d\n", state
);
3341 state
= MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "twelve");
3342 ok(state
== INSTALLSTATE_LOCAL
, "state = %d\n", state
);
3344 r
= MsiOpenDatabaseW(msifile2W
, MSIDBOPEN_DIRECT
, &hdb
);
3345 ok(r
== ERROR_SUCCESS
, "failed to open database: %d\n", r
);
3347 /* these properties must not be in the saved msi file */
3348 r
= add_property_entry( hdb
, "'ADDLOCAL', 'one,two,three,four,five,six,seven,eight,nine,ten,twelve'");
3349 ok( r
== ERROR_SUCCESS
, "cannot add property: %d\n", r
);
3351 r
= package_from_db( hdb
, &hpkg
);
3352 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
3354 test_feature_states( __LINE__
, hpkg
, "one", ERROR_UNKNOWN_FEATURE
, 0, 0, FALSE
);
3355 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_UNKNOWN_COMPONENT
, 0, 0, FALSE
);
3357 r
= MsiDoActionA( hpkg
, "CostInitialize");
3358 ok( r
== ERROR_SUCCESS
, "cost init failed\n");
3360 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3361 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3363 r
= MsiDoActionA( hpkg
, "CostFinalize");
3364 ok( r
== ERROR_SUCCESS
, "cost finalize failed: %d\n", r
);
3366 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_LOCAL
, FALSE
);
3367 test_feature_states( __LINE__
, hpkg
, "two", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_LOCAL
, FALSE
);
3368 test_feature_states( __LINE__
, hpkg
, "three", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3369 test_feature_states( __LINE__
, hpkg
, "four", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3370 test_feature_states( __LINE__
, hpkg
, "five", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3371 test_feature_states( __LINE__
, hpkg
, "six", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_LOCAL
, FALSE
);
3372 test_feature_states( __LINE__
, hpkg
, "seven", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_LOCAL
, FALSE
);
3373 test_feature_states( __LINE__
, hpkg
, "eight", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, TRUE
);
3374 test_feature_states( __LINE__
, hpkg
, "nine", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, TRUE
);
3375 test_feature_states( __LINE__
, hpkg
, "ten", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, TRUE
);
3376 test_feature_states( __LINE__
, hpkg
, "eleven", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, TRUE
);
3377 test_feature_states( __LINE__
, hpkg
, "twelve", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3378 test_feature_states( __LINE__
, hpkg
, "thirteen", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_UNKNOWN
, FALSE
);
3380 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3381 test_component_states( __LINE__
, hpkg
, "beta", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3382 test_component_states( __LINE__
, hpkg
, "gamma", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3383 test_component_states( __LINE__
, hpkg
, "theta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3384 test_component_states( __LINE__
, hpkg
, "delta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3385 test_component_states( __LINE__
, hpkg
, "epsilon", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3386 test_component_states( __LINE__
, hpkg
, "zeta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3387 test_component_states( __LINE__
, hpkg
, "iota", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3388 test_component_states( __LINE__
, hpkg
, "eta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3389 test_component_states( __LINE__
, hpkg
, "kappa", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3390 test_component_states( __LINE__
, hpkg
, "lambda", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3391 test_component_states( __LINE__
, hpkg
, "mu", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3392 test_component_states( __LINE__
, hpkg
, "nu", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3393 test_component_states( __LINE__
, hpkg
, "xi", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3394 test_component_states( __LINE__
, hpkg
, "omicron", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3395 test_component_states( __LINE__
, hpkg
, "pi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3396 test_component_states( __LINE__
, hpkg
, "rho", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3397 test_component_states( __LINE__
, hpkg
, "sigma", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3398 test_component_states( __LINE__
, hpkg
, "tau", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, TRUE
);
3399 test_component_states( __LINE__
, hpkg
, "phi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, TRUE
);
3400 test_component_states( __LINE__
, hpkg
, "chi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, TRUE
);
3401 test_component_states( __LINE__
, hpkg
, "psi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3402 test_component_states( __LINE__
, hpkg
, "upsilon", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3404 MsiCloseHandle(hpkg
);
3406 /* uninstall the product */
3407 r
= MsiInstallProductA(msifile2
, "REMOVE=ALL");
3408 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3410 /* all features installed from source */
3411 r
= MsiInstallProductA(msifile3
, "ADDSOURCE=ALL");
3412 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3414 state
= MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "five");
3415 ok(state
== INSTALLSTATE_UNKNOWN
, "state = %d\n", state
);
3416 state
= MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "twelve");
3417 ok(state
== INSTALLSTATE_LOCAL
, "state = %d\n", state
);
3419 r
= MsiOpenDatabaseW(msifile3W
, MSIDBOPEN_DIRECT
, &hdb
);
3420 ok(r
== ERROR_SUCCESS
, "failed to open database: %d\n", r
);
3422 /* this property must not be in the saved msi file */
3423 r
= add_property_entry( hdb
, "'ADDSOURCE', 'one,two,three,four,five,six,seven,eight,nine,ten'");
3424 ok( r
== ERROR_SUCCESS
, "cannot add property: %d\n", r
);
3426 r
= package_from_db( hdb
, &hpkg
);
3427 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
3429 test_feature_states( __LINE__
, hpkg
, "one", ERROR_UNKNOWN_FEATURE
, 0, 0, FALSE
);
3430 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_UNKNOWN_COMPONENT
, 0, 0, FALSE
);
3432 r
= MsiDoActionA( hpkg
, "CostInitialize");
3433 ok( r
== ERROR_SUCCESS
, "cost init failed\n");
3435 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3436 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3438 r
= MsiDoActionA( hpkg
, "FileCost");
3439 ok( r
== ERROR_SUCCESS
, "file cost failed\n");
3441 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3442 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3444 r
= MsiDoActionA( hpkg
, "CostFinalize");
3445 ok( r
== ERROR_SUCCESS
, "cost finalize failed: %d\n", r
);
3447 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3448 test_feature_states( __LINE__
, hpkg
, "two", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3449 test_feature_states( __LINE__
, hpkg
, "three", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3450 test_feature_states( __LINE__
, hpkg
, "four", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3451 test_feature_states( __LINE__
, hpkg
, "five", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3452 test_feature_states( __LINE__
, hpkg
, "six", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3453 test_feature_states( __LINE__
, hpkg
, "seven", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3454 test_feature_states( __LINE__
, hpkg
, "eight", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3455 test_feature_states( __LINE__
, hpkg
, "nine", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3456 test_feature_states( __LINE__
, hpkg
, "ten", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3457 test_feature_states( __LINE__
, hpkg
, "eleven", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, TRUE
);
3458 test_feature_states( __LINE__
, hpkg
, "twelve", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_UNKNOWN
, FALSE
);
3459 test_feature_states( __LINE__
, hpkg
, "thirteen", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_UNKNOWN
, FALSE
);
3461 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3462 test_component_states( __LINE__
, hpkg
, "beta", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3463 test_component_states( __LINE__
, hpkg
, "gamma", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3464 test_component_states( __LINE__
, hpkg
, "theta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3465 test_component_states( __LINE__
, hpkg
, "delta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3466 test_component_states( __LINE__
, hpkg
, "epsilon", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3467 test_component_states( __LINE__
, hpkg
, "zeta", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3468 test_component_states( __LINE__
, hpkg
, "iota", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3469 test_component_states( __LINE__
, hpkg
, "eta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3470 test_component_states( __LINE__
, hpkg
, "kappa", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3471 test_component_states( __LINE__
, hpkg
, "lambda", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3472 test_component_states( __LINE__
, hpkg
, "mu", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3473 test_component_states( __LINE__
, hpkg
, "nu", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3474 test_component_states( __LINE__
, hpkg
, "xi", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3475 test_component_states( __LINE__
, hpkg
, "omicron", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3476 test_component_states( __LINE__
, hpkg
, "pi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3477 test_component_states( __LINE__
, hpkg
, "rho", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3478 test_component_states( __LINE__
, hpkg
, "sigma", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3479 test_component_states( __LINE__
, hpkg
, "tau", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3480 test_component_states( __LINE__
, hpkg
, "phi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3481 test_component_states( __LINE__
, hpkg
, "chi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3482 test_component_states( __LINE__
, hpkg
, "psi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3483 test_component_states( __LINE__
, hpkg
, "upsilon", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, TRUE
);
3485 MsiCloseHandle(hpkg
);
3487 /* reinstall the product */
3488 r
= MsiInstallProductA(msifile3
, "REINSTALL=ALL");
3489 ok(r
== ERROR_SUCCESS
|| broken(r
== ERROR_INSTALL_FAILURE
) /* win2k3 */, "Expected ERROR_SUCCESS, got %d\n", r
);
3491 state
= MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "five");
3492 ok(state
== INSTALLSTATE_UNKNOWN
, "state = %d\n", state
);
3493 state
= MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "twelve");
3494 ok(state
== INSTALLSTATE_LOCAL
, "state = %d\n", state
);
3496 r
= MsiOpenDatabaseW(msifile4W
, MSIDBOPEN_DIRECT
, &hdb
);
3497 ok(r
== ERROR_SUCCESS
, "failed to open database: %d\n", r
);
3499 /* this property must not be in the saved msi file */
3500 r
= add_property_entry( hdb
, "'ADDSOURCE', 'one,two,three,four,five,six,seven,eight,nine,ten'");
3501 ok( r
== ERROR_SUCCESS
, "cannot add property: %d\n", r
);
3503 r
= package_from_db( hdb
, &hpkg
);
3504 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
3506 test_feature_states( __LINE__
, hpkg
, "one", ERROR_UNKNOWN_FEATURE
, 0, 0, FALSE
);
3507 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_UNKNOWN_COMPONENT
, 0, 0, FALSE
);
3509 r
= MsiDoActionA( hpkg
, "CostInitialize");
3510 ok( r
== ERROR_SUCCESS
, "cost init failed\n");
3512 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3513 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3515 r
= MsiDoActionA( hpkg
, "FileCost");
3516 ok( r
== ERROR_SUCCESS
, "file cost failed\n");
3518 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3519 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3521 r
= MsiDoActionA( hpkg
, "CostFinalize");
3522 ok( r
== ERROR_SUCCESS
, "cost finalize failed: %d\n", r
);
3524 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3525 test_feature_states( __LINE__
, hpkg
, "two", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3526 test_feature_states( __LINE__
, hpkg
, "three", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3527 test_feature_states( __LINE__
, hpkg
, "four", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3528 test_feature_states( __LINE__
, hpkg
, "five", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3529 test_feature_states( __LINE__
, hpkg
, "six", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3530 test_feature_states( __LINE__
, hpkg
, "seven", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3531 test_feature_states( __LINE__
, hpkg
, "eight", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3532 test_feature_states( __LINE__
, hpkg
, "nine", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3533 test_feature_states( __LINE__
, hpkg
, "ten", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3534 test_feature_states( __LINE__
, hpkg
, "eleven", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, TRUE
);
3535 test_feature_states( __LINE__
, hpkg
, "twelve", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_UNKNOWN
, FALSE
);
3536 test_feature_states( __LINE__
, hpkg
, "thirteen", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_UNKNOWN
, FALSE
);
3538 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3539 test_component_states( __LINE__
, hpkg
, "beta", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3540 test_component_states( __LINE__
, hpkg
, "gamma", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3541 test_component_states( __LINE__
, hpkg
, "theta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3542 test_component_states( __LINE__
, hpkg
, "delta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3543 test_component_states( __LINE__
, hpkg
, "epsilon", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3544 test_component_states( __LINE__
, hpkg
, "zeta", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3545 test_component_states( __LINE__
, hpkg
, "iota", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3546 test_component_states( __LINE__
, hpkg
, "eta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3547 test_component_states( __LINE__
, hpkg
, "kappa", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3548 test_component_states( __LINE__
, hpkg
, "lambda", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3549 test_component_states( __LINE__
, hpkg
, "mu", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3550 test_component_states( __LINE__
, hpkg
, "nu", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3551 test_component_states( __LINE__
, hpkg
, "xi", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3552 test_component_states( __LINE__
, hpkg
, "omicron", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3553 test_component_states( __LINE__
, hpkg
, "pi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3554 test_component_states( __LINE__
, hpkg
, "rho", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3555 test_component_states( __LINE__
, hpkg
, "sigma", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3556 test_component_states( __LINE__
, hpkg
, "tau", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3557 test_component_states( __LINE__
, hpkg
, "phi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3558 test_component_states( __LINE__
, hpkg
, "chi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3559 test_component_states( __LINE__
, hpkg
, "psi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3560 test_component_states( __LINE__
, hpkg
, "upsilon", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, TRUE
);
3562 MsiCloseHandle(hpkg
);
3564 /* uninstall the product */
3565 r
= MsiInstallProductA(msifile4
, "REMOVE=ALL");
3566 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3568 DeleteFileA(msifile
);
3569 DeleteFileA(msifile2
);
3570 DeleteFileA(msifile3
);
3571 DeleteFileA(msifile4
);
3574 static void test_getproperty(void)
3576 MSIHANDLE hPackage
= 0;
3578 static CHAR empty
[] = "";
3582 r
= package_from_db(create_package_db(), &hPackage
);
3583 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
3585 skip("Not enough rights to perform tests\n");
3586 DeleteFileA(msifile
);
3589 ok( r
== ERROR_SUCCESS
, "Failed to create package %u\n", r
);
3591 /* set the property */
3592 r
= MsiSetPropertyA(hPackage
, "Name", "Value");
3593 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3595 /* retrieve the size, NULL pointer */
3597 r
= MsiGetPropertyA(hPackage
, "Name", NULL
, &size
);
3598 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3599 ok( size
== 5, "Expected 5, got %d\n", size
);
3601 /* retrieve the size, empty string */
3603 r
= MsiGetPropertyA(hPackage
, "Name", empty
, &size
);
3604 ok( r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
3605 ok( size
== 5, "Expected 5, got %d\n", size
);
3607 /* don't change size */
3608 r
= MsiGetPropertyA(hPackage
, "Name", prop
, &size
);
3609 ok( r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
3610 ok( size
== 5, "Expected 5, got %d\n", size
);
3611 ok( !lstrcmpA(prop
, "Valu"), "Expected Valu, got %s\n", prop
);
3613 /* increase the size by 1 */
3615 r
= MsiGetPropertyA(hPackage
, "Name", prop
, &size
);
3616 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3617 ok( size
== 5, "Expected 5, got %d\n", size
);
3618 ok( !lstrcmpA(prop
, "Value"), "Expected Value, got %s\n", prop
);
3620 r
= MsiCloseHandle( hPackage
);
3621 ok( r
== ERROR_SUCCESS
, "Failed to close package\n" );
3622 DeleteFileA(msifile
);
3625 static void test_removefiles(void)
3630 INSTALLSTATE installed
, action
;
3632 hdb
= create_package_db();
3633 ok ( hdb
, "failed to create package database\n" );
3635 r
= add_directory_entry( hdb
, "'TARGETDIR', '', 'SourceDir'");
3636 ok( r
== ERROR_SUCCESS
, "cannot add directory: %d\n", r
);
3638 r
= create_feature_table( hdb
);
3639 ok( r
== ERROR_SUCCESS
, "cannot create Feature table: %d\n", r
);
3641 r
= create_component_table( hdb
);
3642 ok( r
== ERROR_SUCCESS
, "cannot create Component table: %d\n", r
);
3644 r
= add_feature_entry( hdb
, "'one', '', '', '', 2, 1, '', 0" );
3645 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
3647 r
= add_component_entry( hdb
, "'hydrogen', '', 'TARGETDIR', 0, '', 'hydrogen_file'" );
3648 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
3650 r
= add_component_entry( hdb
, "'helium', '', 'TARGETDIR', 0, '', 'helium_file'" );
3651 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
3653 r
= add_component_entry( hdb
, "'lithium', '', 'TARGETDIR', 0, '', 'lithium_file'" );
3654 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
3656 r
= add_component_entry( hdb
, "'beryllium', '', 'TARGETDIR', 0, '', 'beryllium_file'" );
3657 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
3659 r
= add_component_entry( hdb
, "'boron', '', 'TARGETDIR', 0, '', 'boron_file'" );
3660 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
3662 r
= add_component_entry( hdb
, "'carbon', '', 'TARGETDIR', 0, '', 'carbon_file'" );
3663 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
3665 r
= add_component_entry( hdb
, "'oxygen', '', 'TARGETDIR', 0, '0', 'oxygen_file'" );
3666 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
3668 r
= create_feature_components_table( hdb
);
3669 ok( r
== ERROR_SUCCESS
, "cannot create FeatureComponents table: %d\n", r
);
3671 r
= add_feature_components_entry( hdb
, "'one', 'hydrogen'" );
3672 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
3674 r
= add_feature_components_entry( hdb
, "'one', 'helium'" );
3675 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
3677 r
= add_feature_components_entry( hdb
, "'one', 'lithium'" );
3678 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
3680 r
= add_feature_components_entry( hdb
, "'one', 'beryllium'" );
3681 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
3683 r
= add_feature_components_entry( hdb
, "'one', 'boron'" );
3684 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
3686 r
= add_feature_components_entry( hdb
, "'one', 'carbon'" );
3687 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
3689 r
= add_feature_components_entry( hdb
, "'one', 'oxygen'" );
3690 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
3692 r
= create_file_table( hdb
);
3693 ok( r
== ERROR_SUCCESS
, "cannot create File table: %d\n", r
);
3695 r
= add_file_entry( hdb
, "'hydrogen_file', 'hydrogen', 'hydrogen.txt', 0, '', '1033', 8192, 1" );
3696 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3698 r
= add_file_entry( hdb
, "'helium_file', 'helium', 'helium.txt', 0, '', '1033', 8192, 1" );
3699 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3701 r
= add_file_entry( hdb
, "'lithium_file', 'lithium', 'lithium.txt', 0, '', '1033', 8192, 1" );
3702 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3704 r
= add_file_entry( hdb
, "'beryllium_file', 'beryllium', 'beryllium.txt', 0, '', '1033', 16384, 1" );
3705 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3707 r
= add_file_entry( hdb
, "'boron_file', 'boron', 'boron.txt', 0, '', '1033', 16384, 1" );
3708 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3710 r
= add_file_entry( hdb
, "'carbon_file', 'carbon', 'carbon.txt', 0, '', '1033', 16384, 1" );
3711 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3713 r
= add_file_entry( hdb
, "'oxygen_file', 'oxygen', 'oxygen.txt', 0, '', '1033', 16384, 1" );
3714 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3716 r
= create_remove_file_table( hdb
);
3717 ok( r
== ERROR_SUCCESS
, "cannot create Remove File table: %d\n", r
);
3719 r
= package_from_db( hdb
, &hpkg
);
3720 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
3722 skip("Not enough rights to perform tests\n");
3723 DeleteFileA(msifile
);
3726 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
3728 MsiCloseHandle( hdb
);
3730 create_test_file( "hydrogen.txt" );
3731 create_test_file( "helium.txt" );
3732 create_test_file( "lithium.txt" );
3733 create_test_file( "beryllium.txt" );
3734 create_test_file( "boron.txt" );
3735 create_test_file( "carbon.txt" );
3736 create_test_file( "oxygen.txt" );
3738 r
= MsiSetPropertyA( hpkg
, "TARGETDIR", CURR_DIR
);
3739 ok( r
== ERROR_SUCCESS
, "set property failed\n");
3741 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
3743 r
= MsiGetComponentStateA( hpkg
, "oxygen", &installed
, &action
);
3744 ok( r
== ERROR_UNKNOWN_COMPONENT
, "expected ERROR_UNKNOWN_COMPONENT, got %u\n", r
);
3746 r
= MsiDoActionA( hpkg
, "CostInitialize");
3747 ok( r
== ERROR_SUCCESS
, "cost init failed\n");
3749 r
= MsiDoActionA( hpkg
, "FileCost");
3750 ok( r
== ERROR_SUCCESS
, "file cost failed\n");
3752 installed
= action
= 0xdeadbeef;
3753 r
= MsiGetComponentStateA( hpkg
, "oxygen", &installed
, &action
);
3754 ok( r
== ERROR_SUCCESS
, "failed to get component state %u\n", r
);
3755 ok( installed
== INSTALLSTATE_UNKNOWN
, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed
);
3756 ok( action
== INSTALLSTATE_UNKNOWN
, "expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
3758 r
= MsiDoActionA( hpkg
, "CostFinalize");
3759 ok( r
== ERROR_SUCCESS
, "cost finalize failed\n");
3761 r
= MsiDoActionA( hpkg
, "InstallValidate");
3762 ok( r
== ERROR_SUCCESS
, "install validate failed\n");
3764 r
= MsiSetComponentStateA( hpkg
, "hydrogen", INSTALLSTATE_ABSENT
);
3765 ok( r
== ERROR_SUCCESS
, "failed to set component state: %d\n", r
);
3767 installed
= action
= 0xdeadbeef;
3768 r
= MsiGetComponentStateA( hpkg
, "hydrogen", &installed
, &action
);
3769 ok( r
== ERROR_SUCCESS
, "failed to get component state %u\n", r
);
3770 ok( installed
== INSTALLSTATE_UNKNOWN
, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed
);
3771 todo_wine
ok( action
== INSTALLSTATE_UNKNOWN
, "expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
3773 r
= MsiSetComponentStateA( hpkg
, "helium", INSTALLSTATE_LOCAL
);
3774 ok( r
== ERROR_SUCCESS
, "failed to set component state: %d\n", r
);
3776 r
= MsiSetComponentStateA( hpkg
, "lithium", INSTALLSTATE_SOURCE
);
3777 ok( r
== ERROR_SUCCESS
, "failed to set component state: %d\n", r
);
3779 r
= MsiSetComponentStateA( hpkg
, "beryllium", INSTALLSTATE_ABSENT
);
3780 ok( r
== ERROR_SUCCESS
, "failed to set component state: %d\n", r
);
3782 r
= MsiSetComponentStateA( hpkg
, "boron", INSTALLSTATE_LOCAL
);
3783 ok( r
== ERROR_SUCCESS
, "failed to set component state: %d\n", r
);
3785 r
= MsiSetComponentStateA( hpkg
, "carbon", INSTALLSTATE_SOURCE
);
3786 ok( r
== ERROR_SUCCESS
, "failed to set component state: %d\n", r
);
3788 installed
= action
= 0xdeadbeef;
3789 r
= MsiGetComponentStateA( hpkg
, "oxygen", &installed
, &action
);
3790 ok( r
== ERROR_SUCCESS
, "failed to get component state %u\n", r
);
3791 ok( installed
== INSTALLSTATE_UNKNOWN
, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed
);
3792 ok( action
== INSTALLSTATE_UNKNOWN
, "expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
3794 r
= MsiSetComponentStateA( hpkg
, "oxygen", INSTALLSTATE_ABSENT
);
3795 ok( r
== ERROR_SUCCESS
, "failed to set component state: %d\n", r
);
3797 installed
= action
= 0xdeadbeef;
3798 r
= MsiGetComponentStateA( hpkg
, "oxygen", &installed
, &action
);
3799 ok( r
== ERROR_SUCCESS
, "failed to get component state %u\n", r
);
3800 ok( installed
== INSTALLSTATE_UNKNOWN
, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed
);
3801 ok( action
== INSTALLSTATE_UNKNOWN
, "expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
3803 r
= MsiDoActionA( hpkg
, "RemoveFiles");
3804 ok( r
== ERROR_SUCCESS
, "remove files failed\n");
3806 installed
= action
= 0xdeadbeef;
3807 r
= MsiGetComponentStateA( hpkg
, "oxygen", &installed
, &action
);
3808 ok( r
== ERROR_SUCCESS
, "failed to get component state %u\n", r
);
3809 ok( installed
== INSTALLSTATE_UNKNOWN
, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed
);
3810 ok( action
== INSTALLSTATE_UNKNOWN
, "expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
3812 ok(DeleteFileA("hydrogen.txt"), "Expected hydrogen.txt to exist\n");
3813 ok(DeleteFileA("lithium.txt"), "Expected lithium.txt to exist\n");
3814 ok(DeleteFileA("beryllium.txt"), "Expected beryllium.txt to exist\n");
3815 ok(DeleteFileA("carbon.txt"), "Expected carbon.txt to exist\n");
3816 ok(DeleteFileA("helium.txt"), "Expected helium.txt to exist\n");
3817 ok(DeleteFileA("boron.txt"), "Expected boron.txt to exist\n");
3818 ok(DeleteFileA("oxygen.txt"), "Expected oxygen.txt to exist\n");
3820 MsiCloseHandle( hpkg
);
3821 DeleteFileA(msifile
);
3824 static void test_appsearch(void)
3829 CHAR prop
[MAX_PATH
];
3832 const char reg_expand_value
[] = "%systemroot%\\system32\\notepad.exe";
3834 hdb
= create_package_db();
3835 ok ( hdb
, "failed to create package database\n" );
3837 r
= create_appsearch_table( hdb
);
3838 ok( r
== ERROR_SUCCESS
, "cannot create AppSearch table: %d\n", r
);
3840 r
= add_appsearch_entry( hdb
, "'WEBBROWSERPROG', 'NewSignature1'" );
3841 ok( r
== ERROR_SUCCESS
, "cannot add entry: %d\n", r
);
3843 r
= add_appsearch_entry( hdb
, "'NOTEPAD', 'NewSignature2'" );
3844 ok( r
== ERROR_SUCCESS
, "cannot add entry: %d\n", r
);
3846 r
= add_appsearch_entry( hdb
, "'REGEXPANDVAL', 'NewSignature3'" );
3847 ok( r
== ERROR_SUCCESS
, "cannot add entry: %d\n", r
);
3849 r
= create_reglocator_table( hdb
);
3850 ok( r
== ERROR_SUCCESS
, "cannot create RegLocator table: %d\n", r
);
3852 r
= add_reglocator_entry( hdb
, "NewSignature1", 0, "htmlfile\\shell\\open\\command", "", 1 );
3853 ok( r
== ERROR_SUCCESS
, "cannot create RegLocator table: %d\n", r
);
3855 r
= RegCreateKeyExA(HKEY_CURRENT_USER
, "Software\\Winetest_msi", 0, NULL
, 0, KEY_ALL_ACCESS
, NULL
, &hkey
, NULL
);
3856 ok( r
== ERROR_SUCCESS
, "Could not create key: %d.\n", r
);
3857 r
= RegSetValueExA(hkey
, NULL
, 0, REG_EXPAND_SZ
, (const BYTE
*)reg_expand_value
, strlen(reg_expand_value
) + 1);
3858 ok( r
== ERROR_SUCCESS
, "Could not set key value: %d.\n", r
);
3860 r
= add_reglocator_entry( hdb
, "NewSignature3", 1, "Software\\Winetest_msi", "", 1 );
3861 ok( r
== ERROR_SUCCESS
, "cannot create RegLocator table: %d\n", r
);
3863 r
= create_drlocator_table( hdb
);
3864 ok( r
== ERROR_SUCCESS
, "cannot create DrLocator table: %d\n", r
);
3866 r
= add_drlocator_entry( hdb
, "'NewSignature2', 0, 'c:\\windows\\system32', 0" );
3867 ok( r
== ERROR_SUCCESS
, "cannot create RegLocator table: %d\n", r
);
3869 r
= create_signature_table( hdb
);
3870 ok( r
== ERROR_SUCCESS
, "cannot create Signature table: %d\n", r
);
3872 r
= add_signature_entry( hdb
, "'NewSignature1', 'FileName', '', '', '', '', '', '', ''" );
3873 ok( r
== ERROR_SUCCESS
, "cannot add signature: %d\n", r
);
3875 r
= add_signature_entry( hdb
, "'NewSignature2', 'NOTEPAD.EXE|notepad.exe', '', '', '', '', '', '', ''" );
3876 ok( r
== ERROR_SUCCESS
, "cannot add signature: %d\n", r
);
3878 r
= add_signature_entry( hdb
, "'NewSignature3', 'NOTEPAD.EXE|notepad.exe', '', '', '', '', '', '', ''" );
3879 ok( r
== ERROR_SUCCESS
, "cannot add signature: %d\n", r
);
3881 r
= package_from_db( hdb
, &hpkg
);
3882 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
3884 skip("Not enough rights to perform tests\n");
3885 DeleteFileA(msifile
);
3888 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
3889 MsiCloseHandle( hdb
);
3890 if (r
!= ERROR_SUCCESS
)
3893 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
3895 r
= MsiDoActionA( hpkg
, "AppSearch" );
3896 ok( r
== ERROR_SUCCESS
, "AppSearch failed: %d\n", r
);
3898 size
= sizeof(prop
);
3899 r
= MsiGetPropertyA( hpkg
, "WEBBROWSERPROG", prop
, &size
);
3900 ok( r
== ERROR_SUCCESS
, "get property failed: %d\n", r
);
3901 ok( lstrlenA(prop
) != 0, "Expected non-zero length\n");
3903 size
= sizeof(prop
);
3904 r
= MsiGetPropertyA( hpkg
, "NOTEPAD", prop
, &size
);
3905 ok( r
== ERROR_SUCCESS
, "get property failed: %d\n", r
);
3907 size
= sizeof(prop
);
3908 r
= MsiGetPropertyA( hpkg
, "REGEXPANDVAL", prop
, &size
);
3909 ok( r
== ERROR_SUCCESS
, "get property failed: %d\n", r
);
3910 ok( lstrlenA(prop
) != 0, "Expected non-zero length\n");
3913 MsiCloseHandle( hpkg
);
3914 DeleteFileA(msifile
);
3915 RegDeleteKeyA(HKEY_CURRENT_USER
, "Software\\Winetest_msi");
3918 static void test_appsearch_complocator(void)
3920 MSIHANDLE hpkg
, hdb
;
3921 char path
[MAX_PATH
], expected
[MAX_PATH
], prop
[MAX_PATH
];
3926 if (!(usersid
= get_user_sid()))
3929 if (is_process_limited())
3931 skip("process is limited\n");
3935 create_test_file("FileName1");
3936 create_test_file("FileName4");
3937 set_component_path("FileName1", MSIINSTALLCONTEXT_MACHINE
,
3938 "{A8AE6692-96BA-4198-8399-145D7D1D0D0E}", NULL
, FALSE
);
3940 create_test_file("FileName2");
3941 set_component_path("FileName2", MSIINSTALLCONTEXT_USERUNMANAGED
,
3942 "{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}", usersid
, FALSE
);
3944 create_test_file("FileName3");
3945 set_component_path("FileName3", MSIINSTALLCONTEXT_USERMANAGED
,
3946 "{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}", usersid
, FALSE
);
3948 create_test_file("FileName5");
3949 set_component_path("FileName5", MSIINSTALLCONTEXT_MACHINE
,
3950 "{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}", NULL
, TRUE
);
3952 create_test_file("FileName6");
3953 set_component_path("FileName6", MSIINSTALLCONTEXT_MACHINE
,
3954 "{C0ECD96F-7898-4410-9667-194BD8C1B648}", NULL
, TRUE
);
3956 create_test_file("FileName7");
3957 set_component_path("FileName7", MSIINSTALLCONTEXT_MACHINE
,
3958 "{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}", NULL
, FALSE
);
3960 /* dir is FALSE, but we're pretending it's a directory */
3961 set_component_path("IDontExist\\", MSIINSTALLCONTEXT_MACHINE
,
3962 "{91B7359B-07F2-4221-AA8D-DE102BB87A5F}", NULL
, FALSE
);
3964 create_file_with_version("FileName8.dll", MAKELONG(2, 1), MAKELONG(4, 3));
3965 set_component_path("FileName8.dll", MSIINSTALLCONTEXT_MACHINE
,
3966 "{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}", NULL
, FALSE
);
3968 create_file_with_version("FileName9.dll", MAKELONG(1, 2), MAKELONG(3, 4));
3969 set_component_path("FileName9.dll", MSIINSTALLCONTEXT_MACHINE
,
3970 "{A204DF48-7346-4635-BA2E-66247DBAC9DF}", NULL
, FALSE
);
3972 create_file_with_version("FileName10.dll", MAKELONG(2, 1), MAKELONG(4, 3));
3973 set_component_path("FileName10.dll", MSIINSTALLCONTEXT_MACHINE
,
3974 "{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}", NULL
, FALSE
);
3976 hdb
= create_package_db();
3977 ok(hdb
, "Expected a valid database handle\n");
3979 r
= create_appsearch_table(hdb
);
3980 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3982 r
= add_appsearch_entry(hdb
, "'SIGPROP1', 'NewSignature1'");
3983 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3985 r
= add_appsearch_entry(hdb
, "'SIGPROP2', 'NewSignature2'");
3986 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3988 r
= add_appsearch_entry(hdb
, "'SIGPROP3', 'NewSignature3'");
3989 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3991 r
= add_appsearch_entry(hdb
, "'SIGPROP4', 'NewSignature4'");
3992 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3994 r
= add_appsearch_entry(hdb
, "'SIGPROP5', 'NewSignature5'");
3995 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3997 r
= add_appsearch_entry(hdb
, "'SIGPROP6', 'NewSignature6'");
3998 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4000 r
= add_appsearch_entry(hdb
, "'SIGPROP7', 'NewSignature7'");
4001 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4003 r
= add_appsearch_entry(hdb
, "'SIGPROP8', 'NewSignature8'");
4004 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4006 r
= add_appsearch_entry(hdb
, "'SIGPROP9', 'NewSignature9'");
4007 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4009 r
= add_appsearch_entry(hdb
, "'SIGPROP10', 'NewSignature10'");
4010 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4012 r
= add_appsearch_entry(hdb
, "'SIGPROP11', 'NewSignature11'");
4013 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4015 r
= add_appsearch_entry(hdb
, "'SIGPROP12', 'NewSignature12'");
4016 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4018 r
= create_complocator_table(hdb
);
4019 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4021 /* published component, machine, file, signature, misdbLocatorTypeFile */
4022 r
= add_complocator_entry(hdb
, "'NewSignature1', '{A8AE6692-96BA-4198-8399-145D7D1D0D0E}', 1");
4023 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4025 /* published component, user-unmanaged, file, signature, misdbLocatorTypeFile */
4026 r
= add_complocator_entry(hdb
, "'NewSignature2', '{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}', 1");
4027 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4029 /* published component, user-managed, file, signature, misdbLocatorTypeFile */
4030 r
= add_complocator_entry(hdb
, "'NewSignature3', '{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}', 1");
4031 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4033 /* published component, machine, file, signature, misdbLocatorTypeDirectory */
4034 r
= add_complocator_entry(hdb
, "'NewSignature4', '{A8AE6692-96BA-4198-8399-145D7D1D0D0E}', 0");
4035 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4037 /* published component, machine, dir, signature, misdbLocatorTypeDirectory */
4038 r
= add_complocator_entry(hdb
, "'NewSignature5', '{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}', 0");
4039 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4041 /* published component, machine, dir, no signature, misdbLocatorTypeDirectory */
4042 r
= add_complocator_entry(hdb
, "'NewSignature6', '{C0ECD96F-7898-4410-9667-194BD8C1B648}', 0");
4043 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4045 /* published component, machine, file, no signature, misdbLocatorTypeFile */
4046 r
= add_complocator_entry(hdb
, "'NewSignature7', '{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}', 1");
4047 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4049 /* unpublished component, no signature, misdbLocatorTypeDir */
4050 r
= add_complocator_entry(hdb
, "'NewSignature8', '{FB671D5B-5083-4048-90E0-481C48D8F3A5}', 0");
4051 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4053 /* published component, no signature, dir does not exist misdbLocatorTypeDir */
4054 r
= add_complocator_entry(hdb
, "'NewSignature9', '{91B7359B-07F2-4221-AA8D-DE102BB87A5F}', 0");
4055 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4057 /* published component, signature w/ ver, misdbLocatorTypeFile */
4058 r
= add_complocator_entry(hdb
, "'NewSignature10', '{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}', 1");
4059 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4061 /* published component, signature w/ ver, ver > max, misdbLocatorTypeFile */
4062 r
= add_complocator_entry(hdb
, "'NewSignature11', '{A204DF48-7346-4635-BA2E-66247DBAC9DF}', 1");
4063 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4065 /* published component, signature w/ ver, sig->name ignored, misdbLocatorTypeFile */
4066 r
= add_complocator_entry(hdb
, "'NewSignature12', '{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}', 1");
4067 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4069 r
= create_signature_table(hdb
);
4070 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4072 r
= add_signature_entry(hdb
, "'NewSignature1', 'FileName1', '', '', '', '', '', '', ''");
4073 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4075 r
= add_signature_entry(hdb
, "'NewSignature2', 'FileName2', '', '', '', '', '', '', ''");
4076 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4078 r
= add_signature_entry(hdb
, "'NewSignature3', 'FileName3', '', '', '', '', '', '', ''");
4079 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4081 r
= add_signature_entry(hdb
, "'NewSignature4', 'FileName4', '', '', '', '', '', '', ''");
4082 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4084 r
= add_signature_entry(hdb
, "'NewSignature5', 'FileName5', '', '', '', '', '', '', ''");
4085 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4087 r
= add_signature_entry(hdb
, "'NewSignature10', 'FileName8.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
4088 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4090 r
= add_signature_entry(hdb
, "'NewSignature11', 'FileName9.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
4091 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4093 r
= add_signature_entry(hdb
, "'NewSignature12', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
4094 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4096 r
= package_from_db(hdb
, &hpkg
);
4097 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
4099 skip("Not enough rights to perform tests\n");
4102 ok(r
== ERROR_SUCCESS
, "Expected a valid package handle %u\n", r
);
4104 r
= MsiSetPropertyA(hpkg
, "SIGPROP8", "october");
4105 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4107 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
4109 r
= MsiDoActionA(hpkg
, "AppSearch");
4110 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4112 strcpy(expected
, CURR_DIR
);
4113 if (is_root(CURR_DIR
)) expected
[2] = 0;
4116 sprintf(path
, "%s\\FileName1", expected
);
4117 r
= MsiGetPropertyA(hpkg
, "SIGPROP1", prop
, &size
);
4118 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4119 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4122 sprintf(path
, "%s\\FileName2", expected
);
4123 r
= MsiGetPropertyA(hpkg
, "SIGPROP2", prop
, &size
);
4124 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4125 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4128 sprintf(path
, "%s\\FileName3", expected
);
4129 r
= MsiGetPropertyA(hpkg
, "SIGPROP3", prop
, &size
);
4130 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4131 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4134 sprintf(path
, "%s\\FileName4", expected
);
4135 r
= MsiGetPropertyA(hpkg
, "SIGPROP4", prop
, &size
);
4136 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4137 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4140 sprintf(path
, "%s\\FileName5", expected
);
4141 r
= MsiGetPropertyA(hpkg
, "SIGPROP5", prop
, &size
);
4142 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4143 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4146 sprintf(path
, "%s\\", expected
);
4147 r
= MsiGetPropertyA(hpkg
, "SIGPROP6", prop
, &size
);
4148 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4149 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4152 sprintf(path
, "%s\\", expected
);
4153 r
= MsiGetPropertyA(hpkg
, "SIGPROP7", prop
, &size
);
4154 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4155 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4158 r
= MsiGetPropertyA(hpkg
, "SIGPROP8", prop
, &size
);
4159 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4160 ok(!lstrcmpA(prop
, "october"), "Expected \"october\", got \"%s\"\n", prop
);
4163 r
= MsiGetPropertyA(hpkg
, "SIGPROP9", prop
, &size
);
4164 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4165 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4168 sprintf(path
, "%s\\FileName8.dll", expected
);
4169 r
= MsiGetPropertyA(hpkg
, "SIGPROP10", prop
, &size
);
4170 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4171 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4174 r
= MsiGetPropertyA(hpkg
, "SIGPROP11", prop
, &size
);
4175 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4176 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4179 sprintf(path
, "%s\\FileName10.dll", expected
);
4180 r
= MsiGetPropertyA(hpkg
, "SIGPROP12", prop
, &size
);
4181 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4182 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4184 delete_component_path("{A8AE6692-96BA-4198-8399-145D7D1D0D0E}",
4185 MSIINSTALLCONTEXT_MACHINE
, NULL
);
4186 delete_component_path("{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}",
4187 MSIINSTALLCONTEXT_USERUNMANAGED
, usersid
);
4188 delete_component_path("{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}",
4189 MSIINSTALLCONTEXT_USERMANAGED
, usersid
);
4190 delete_component_path("{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}",
4191 MSIINSTALLCONTEXT_MACHINE
, NULL
);
4192 delete_component_path("{C0ECD96F-7898-4410-9667-194BD8C1B648}",
4193 MSIINSTALLCONTEXT_MACHINE
, NULL
);
4194 delete_component_path("{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}",
4195 MSIINSTALLCONTEXT_MACHINE
, NULL
);
4196 delete_component_path("{91B7359B-07F2-4221-AA8D-DE102BB87A5F}",
4197 MSIINSTALLCONTEXT_MACHINE
, NULL
);
4198 delete_component_path("{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}",
4199 MSIINSTALLCONTEXT_MACHINE
, NULL
);
4200 delete_component_path("{A204DF48-7346-4635-BA2E-66247DBAC9DF}",
4201 MSIINSTALLCONTEXT_MACHINE
, NULL
);
4202 delete_component_path("{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}",
4203 MSIINSTALLCONTEXT_MACHINE
, NULL
);
4205 MsiCloseHandle(hpkg
);
4208 DeleteFileA("FileName1");
4209 DeleteFileA("FileName2");
4210 DeleteFileA("FileName3");
4211 DeleteFileA("FileName4");
4212 DeleteFileA("FileName5");
4213 DeleteFileA("FileName6");
4214 DeleteFileA("FileName7");
4215 DeleteFileA("FileName8.dll");
4216 DeleteFileA("FileName9.dll");
4217 DeleteFileA("FileName10.dll");
4218 DeleteFileA(msifile
);
4222 static void test_appsearch_reglocator(void)
4224 MSIHANDLE hpkg
, hdb
;
4225 char path
[MAX_PATH
], expected
[MAX_PATH
], prop
[MAX_PATH
];
4226 DWORD binary
[2], size
, val
;
4227 BOOL space
, version
, is_64bit
= sizeof(void *) > sizeof(int);
4228 HKEY hklm
, classes
, hkcu
, users
;
4229 LPSTR pathdata
, pathvar
, ptr
;
4236 if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
4239 DeleteFileA("test.dll");
4241 res
= RegCreateKeyA(HKEY_CLASSES_ROOT
, "Software\\Wine", &classes
);
4242 if (res
== ERROR_ACCESS_DENIED
)
4244 skip("Not enough rights to perform tests\n");
4247 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4249 res
= RegSetValueExA(classes
, "Value1", 0, REG_SZ
,
4250 (const BYTE
*)"regszdata", 10);
4251 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4253 res
= RegCreateKeyA(HKEY_CURRENT_USER
, "Software\\Wine", &hkcu
);
4254 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4256 res
= RegSetValueExA(hkcu
, "Value1", 0, REG_SZ
,
4257 (const BYTE
*)"regszdata", 10);
4258 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4261 res
= RegCreateKeyA(HKEY_USERS
, "S-1-5-18\\Software\\Wine", &users
);
4262 ok(res
== ERROR_SUCCESS
||
4263 broken(res
== ERROR_INVALID_PARAMETER
),
4264 "Expected ERROR_SUCCESS, got %d\n", res
);
4266 if (res
== ERROR_SUCCESS
)
4268 res
= RegSetValueExA(users
, "Value1", 0, REG_SZ
,
4269 (const BYTE
*)"regszdata", 10);
4270 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4273 res
= RegCreateKeyA(HKEY_LOCAL_MACHINE
, "Software\\Wine", &hklm
);
4274 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4276 res
= RegSetValueA(hklm
, NULL
, REG_SZ
, "defvalue", 8);
4277 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4279 res
= RegSetValueExA(hklm
, "Value1", 0, REG_SZ
,
4280 (const BYTE
*)"regszdata", 10);
4281 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4284 res
= RegSetValueExA(hklm
, "Value2", 0, REG_DWORD
,
4285 (const BYTE
*)&val
, sizeof(DWORD
));
4286 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4289 res
= RegSetValueExA(hklm
, "Value3", 0, REG_DWORD
,
4290 (const BYTE
*)&val
, sizeof(DWORD
));
4291 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4293 res
= RegSetValueExA(hklm
, "Value4", 0, REG_EXPAND_SZ
,
4294 (const BYTE
*)"%PATH%", 7);
4295 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4297 res
= RegSetValueExA(hklm
, "Value5", 0, REG_EXPAND_SZ
,
4298 (const BYTE
*)"my%NOVAR%", 10);
4299 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4301 res
= RegSetValueExA(hklm
, "Value6", 0, REG_MULTI_SZ
,
4302 (const BYTE
*)"one\0two\0", 9);
4303 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4305 binary
[0] = 0x1234abcd;
4306 binary
[1] = 0x567890ef;
4307 res
= RegSetValueExA(hklm
, "Value7", 0, REG_BINARY
,
4308 (const BYTE
*)binary
, sizeof(binary
));
4309 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4311 res
= RegSetValueExA(hklm
, "Value8", 0, REG_SZ
,
4312 (const BYTE
*)"#regszdata", 11);
4313 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4315 strcpy(expected
, CURR_DIR
);
4316 if (is_root(CURR_DIR
)) expected
[2] = 0;
4318 create_test_file("FileName1");
4319 sprintf(path
, "%s\\FileName1", expected
);
4320 res
= RegSetValueExA(hklm
, "Value9", 0, REG_SZ
,
4321 (const BYTE
*)path
, lstrlenA(path
) + 1);
4322 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4324 sprintf(path
, "%s\\FileName2", expected
);
4325 res
= RegSetValueExA(hklm
, "Value10", 0, REG_SZ
,
4326 (const BYTE
*)path
, lstrlenA(path
) + 1);
4327 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4329 lstrcpyA(path
, expected
);
4330 res
= RegSetValueExA(hklm
, "Value11", 0, REG_SZ
,
4331 (const BYTE
*)path
, lstrlenA(path
) + 1);
4332 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4334 res
= RegSetValueExA(hklm
, "Value12", 0, REG_SZ
,
4335 (const BYTE
*)"", 1);
4336 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4338 create_file_with_version("FileName3.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4339 sprintf(path
, "%s\\FileName3.dll", expected
);
4340 res
= RegSetValueExA(hklm
, "Value13", 0, REG_SZ
,
4341 (const BYTE
*)path
, lstrlenA(path
) + 1);
4342 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4344 create_file_with_version("FileName4.dll", MAKELONG(1, 2), MAKELONG(3, 4));
4345 sprintf(path
, "%s\\FileName4.dll", expected
);
4346 res
= RegSetValueExA(hklm
, "Value14", 0, REG_SZ
,
4347 (const BYTE
*)path
, lstrlenA(path
) + 1);
4348 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4350 create_file_with_version("FileName5.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4351 sprintf(path
, "%s\\FileName5.dll", expected
);
4352 res
= RegSetValueExA(hklm
, "Value15", 0, REG_SZ
,
4353 (const BYTE
*)path
, lstrlenA(path
) + 1);
4354 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4356 sprintf(path
, "\"%s\\FileName1\" -option", expected
);
4357 res
= RegSetValueExA(hklm
, "value16", 0, REG_SZ
,
4358 (const BYTE
*)path
, lstrlenA(path
) + 1);
4359 ok( res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", res
);
4361 space
= strchr(expected
, ' ') != NULL
;
4362 sprintf(path
, "%s\\FileName1 -option", expected
);
4363 res
= RegSetValueExA(hklm
, "value17", 0, REG_SZ
,
4364 (const BYTE
*)path
, lstrlenA(path
) + 1);
4365 ok( res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", res
);
4367 hdb
= create_package_db();
4368 ok(hdb
, "Expected a valid database handle\n");
4370 r
= create_appsearch_table(hdb
);
4371 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4373 r
= add_appsearch_entry(hdb
, "'SIGPROP1', 'NewSignature1'");
4374 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4376 r
= add_appsearch_entry(hdb
, "'SIGPROP2', 'NewSignature2'");
4377 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4379 r
= add_appsearch_entry(hdb
, "'SIGPROP3', 'NewSignature3'");
4380 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4382 r
= add_appsearch_entry(hdb
, "'SIGPROP4', 'NewSignature4'");
4383 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4385 r
= add_appsearch_entry(hdb
, "'SIGPROP5', 'NewSignature5'");
4386 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4388 r
= add_appsearch_entry(hdb
, "'SIGPROP6', 'NewSignature6'");
4389 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4391 r
= add_appsearch_entry(hdb
, "'SIGPROP7', 'NewSignature7'");
4392 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4394 r
= add_appsearch_entry(hdb
, "'SIGPROP8', 'NewSignature8'");
4395 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4397 r
= add_appsearch_entry(hdb
, "'SIGPROP9', 'NewSignature9'");
4398 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4400 r
= add_appsearch_entry(hdb
, "'SIGPROP10', 'NewSignature10'");
4401 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4403 r
= add_appsearch_entry(hdb
, "'SIGPROP11', 'NewSignature11'");
4404 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4406 r
= add_appsearch_entry(hdb
, "'SIGPROP12', 'NewSignature12'");
4407 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4409 r
= add_appsearch_entry(hdb
, "'SIGPROP13', 'NewSignature13'");
4410 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4412 r
= add_appsearch_entry(hdb
, "'SIGPROP14', 'NewSignature14'");
4413 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4415 r
= add_appsearch_entry(hdb
, "'SIGPROP15', 'NewSignature15'");
4416 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4418 r
= add_appsearch_entry(hdb
, "'SIGPROP16', 'NewSignature16'");
4419 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4421 r
= add_appsearch_entry(hdb
, "'SIGPROP17', 'NewSignature17'");
4422 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4424 r
= add_appsearch_entry(hdb
, "'SIGPROP18', 'NewSignature18'");
4425 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4427 r
= add_appsearch_entry(hdb
, "'SIGPROP19', 'NewSignature19'");
4428 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4430 r
= add_appsearch_entry(hdb
, "'SIGPROP20', 'NewSignature20'");
4431 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4433 r
= add_appsearch_entry(hdb
, "'SIGPROP21', 'NewSignature21'");
4434 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4436 r
= add_appsearch_entry(hdb
, "'SIGPROP22', 'NewSignature22'");
4437 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4439 r
= add_appsearch_entry(hdb
, "'SIGPROP23', 'NewSignature23'");
4440 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4442 r
= add_appsearch_entry(hdb
, "'SIGPROP24', 'NewSignature24'");
4443 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4445 r
= add_appsearch_entry(hdb
, "'SIGPROP25', 'NewSignature25'");
4446 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4448 r
= add_appsearch_entry(hdb
, "'SIGPROP26', 'NewSignature26'");
4449 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4451 r
= add_appsearch_entry(hdb
, "'SIGPROP27', 'NewSignature27'");
4452 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4454 r
= add_appsearch_entry(hdb
, "'SIGPROP28', 'NewSignature28'");
4455 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4457 r
= add_appsearch_entry(hdb
, "'SIGPROP29', 'NewSignature29'");
4458 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4460 r
= add_appsearch_entry(hdb
, "'SIGPROP30', 'NewSignature30'");
4461 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4463 r
= create_reglocator_table(hdb
);
4464 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4466 type
= msidbLocatorTypeRawValue
;
4468 type
|= msidbLocatorType64bit
;
4470 /* HKLM, msidbLocatorTypeRawValue, REG_SZ */
4471 r
= add_reglocator_entry(hdb
, "NewSignature1", 2, "Software\\Wine", "Value1", type
);
4472 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4474 /* HKLM, msidbLocatorTypeRawValue, positive DWORD */
4475 r
= add_reglocator_entry(hdb
, "NewSignature2", 2, "Software\\Wine", "Value2", type
);
4476 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4478 /* HKLM, msidbLocatorTypeRawValue, negative DWORD */
4479 r
= add_reglocator_entry(hdb
, "NewSignature3", 2, "Software\\Wine", "Value3", type
);
4480 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4482 /* HKLM, msidbLocatorTypeRawValue, REG_EXPAND_SZ */
4483 r
= add_reglocator_entry(hdb
, "NewSignature4", 2, "Software\\Wine", "Value4", type
);
4484 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4486 /* HKLM, msidbLocatorTypeRawValue, REG_EXPAND_SZ */
4487 r
= add_reglocator_entry(hdb
, "NewSignature5", 2, "Software\\Wine", "Value5", type
);
4488 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4490 /* HKLM, msidbLocatorTypeRawValue, REG_MULTI_SZ */
4491 r
= add_reglocator_entry(hdb
, "NewSignature6", 2, "Software\\Wine", "Value6", type
);
4492 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4494 /* HKLM, msidbLocatorTypeRawValue, REG_BINARY */
4495 r
= add_reglocator_entry(hdb
, "NewSignature7", 2, "Software\\Wine", "Value7", type
);
4496 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4498 /* HKLM, msidbLocatorTypeRawValue, REG_SZ first char is # */
4499 r
= add_reglocator_entry(hdb
, "NewSignature8", 2, "Software\\Wine", "Value8", type
);
4500 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4502 type
= msidbLocatorTypeFileName
;
4504 type
|= msidbLocatorType64bit
;
4506 /* HKLM, msidbLocatorTypeFileName, signature, file exists */
4507 r
= add_reglocator_entry(hdb
, "NewSignature9", 2, "Software\\Wine", "Value9", type
);
4508 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4510 /* HKLM, msidbLocatorTypeFileName, signature, file does not exist */
4511 r
= add_reglocator_entry(hdb
, "NewSignature10", 2, "Software\\Wine", "Value10", type
);
4512 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4514 /* HKLM, msidbLocatorTypeFileName, no signature */
4515 r
= add_reglocator_entry(hdb
, "NewSignature11", 2, "Software\\Wine", "Value9", type
);
4516 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4518 type
= msidbLocatorTypeDirectory
;
4520 type
|= msidbLocatorType64bit
;
4522 /* HKLM, msidbLocatorTypeDirectory, no signature, file exists */
4523 r
= add_reglocator_entry(hdb
, "NewSignature12", 2, "Software\\Wine", "Value9", type
);
4524 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4526 /* HKLM, msidbLocatorTypeDirectory, no signature, directory exists */
4527 r
= add_reglocator_entry(hdb
, "NewSignature13", 2, "Software\\Wine", "Value11", type
);
4528 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4530 /* HKLM, msidbLocatorTypeDirectory, signature, file exists */
4531 r
= add_reglocator_entry(hdb
, "NewSignature14", 2, "Software\\Wine", "Value9", type
);
4532 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4534 type
= msidbLocatorTypeRawValue
;
4536 type
|= msidbLocatorType64bit
;
4538 /* HKCR, msidbLocatorTypeRawValue, REG_SZ */
4539 r
= add_reglocator_entry(hdb
, "NewSignature15", 0, "Software\\Wine", "Value1", type
);
4540 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4542 /* HKCU, msidbLocatorTypeRawValue, REG_SZ */
4543 r
= add_reglocator_entry(hdb
, "NewSignature16", 1, "Software\\Wine", "Value1", type
);
4544 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4546 /* HKU, msidbLocatorTypeRawValue, REG_SZ */
4547 r
= add_reglocator_entry(hdb
, "NewSignature17", 3, "S-1-5-18\\Software\\Wine", "Value1", type
);
4548 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4550 /* HKLM, msidbLocatorTypeRawValue, REG_SZ, NULL Name */
4551 r
= add_reglocator_entry(hdb
, "NewSignature18", 2, "Software\\Wine", "", type
);
4552 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4554 /* HKLM, msidbLocatorTypeRawValue, REG_SZ, key does not exist */
4555 r
= add_reglocator_entry(hdb
, "NewSignature19", 2, "Software\\IDontExist", "", type
);
4556 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4558 /* HKLM, msidbLocatorTypeRawValue, REG_SZ, value is empty */
4559 r
= add_reglocator_entry(hdb
, "NewSignature20", 2, "Software\\Wine", "Value12", type
);
4560 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4562 type
= msidbLocatorTypeFileName
;
4564 type
|= msidbLocatorType64bit
;
4566 /* HKLM, msidbLocatorTypeFileName, signature, file exists w/ version */
4567 r
= add_reglocator_entry(hdb
, "NewSignature21", 2, "Software\\Wine", "Value13", type
);
4568 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4570 /* HKLM, msidbLocatorTypeFileName, file exists w/ version, version > max */
4571 r
= add_reglocator_entry(hdb
, "NewSignature22", 2, "Software\\Wine", "Value14", type
);
4572 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4574 /* HKLM, msidbLocatorTypeFileName, file exists w/ version, sig->name ignored */
4575 r
= add_reglocator_entry(hdb
, "NewSignature23", 2, "Software\\Wine", "Value15", type
);
4576 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4578 /* HKLM, msidbLocatorTypeFileName, no signature, directory exists */
4579 r
= add_reglocator_entry(hdb
, "NewSignature24", 2, "Software\\Wine", "Value11", type
);
4580 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4582 /* HKLM, msidbLocatorTypeFileName, no signature, file does not exist */
4583 r
= add_reglocator_entry(hdb
, "NewSignature25", 2, "Software\\Wine", "Value10", type
);
4584 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4586 type
= msidbLocatorTypeDirectory
;
4588 type
|= msidbLocatorType64bit
;
4590 /* HKLM, msidbLocatorTypeDirectory, signature, directory exists */
4591 r
= add_reglocator_entry(hdb
, "NewSignature26", 2, "Software\\Wine", "Value11", type
);
4592 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4594 /* HKLM, msidbLocatorTypeDirectory, signature, file does not exist */
4595 r
= add_reglocator_entry(hdb
, "NewSignature27", 2, "Software\\Wine", "Value10", type
);
4596 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4598 /* HKLM, msidbLocatorTypeDirectory, no signature, file does not exist */
4599 r
= add_reglocator_entry(hdb
, "NewSignature28", 2, "Software\\Wine", "Value10", type
);
4600 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4602 type
= msidbLocatorTypeFileName
;
4604 type
|= msidbLocatorType64bit
;
4606 /* HKLM, msidbLocatorTypeFile, file exists, in quotes */
4607 r
= add_reglocator_entry(hdb
, "NewSignature29", 2, "Software\\Wine", "Value16", type
);
4608 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4610 /* HKLM, msidbLocatorTypeFile, file exists, no quotes */
4611 r
= add_reglocator_entry(hdb
, "NewSignature30", 2, "Software\\Wine", "Value17", type
);
4612 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4614 r
= create_signature_table(hdb
);
4615 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4617 str
= "'NewSignature9', 'FileName1', '', '', '', '', '', '', ''";
4618 r
= add_signature_entry(hdb
, str
);
4619 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4621 str
= "'NewSignature10', 'FileName2', '', '', '', '', '', '', ''";
4622 r
= add_signature_entry(hdb
, str
);
4623 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4625 str
= "'NewSignature14', 'FileName1', '', '', '', '', '', '', ''";
4626 r
= add_signature_entry(hdb
, str
);
4627 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4629 str
= "'NewSignature21', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
4630 r
= add_signature_entry(hdb
, str
);
4631 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4633 str
= "'NewSignature22', 'FileName4.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
4634 r
= add_signature_entry(hdb
, str
);
4635 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4637 str
= "'NewSignature23', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
4638 r
= add_signature_entry(hdb
, str
);
4639 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4641 if (!is_root(CURR_DIR
))
4643 ptr
= strrchr(expected
, '\\') + 1;
4644 sprintf(path
, "'NewSignature26', '%s', '', '', '', '', '', '', ''", ptr
);
4645 r
= add_signature_entry(hdb
, path
);
4646 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4648 str
= "'NewSignature27', 'FileName2', '', '', '', '', '', '', ''";
4649 r
= add_signature_entry(hdb
, str
);
4650 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4652 str
= "'NewSignature29', 'FileName1', '', '', '', '', '', '', ''";
4653 r
= add_signature_entry(hdb
, str
);
4654 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4656 str
= "'NewSignature30', 'FileName1', '', '', '', '', '', '', ''";
4657 r
= add_signature_entry(hdb
, str
);
4658 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4660 r
= package_from_db(hdb
, &hpkg
);
4661 ok(r
== ERROR_SUCCESS
, "Expected a valid package handle %u\n", r
);
4663 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
4665 r
= MsiDoActionA(hpkg
, "AppSearch");
4666 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4669 r
= MsiGetPropertyA(hpkg
, "SIGPROP1", prop
, &size
);
4670 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4671 ok(!lstrcmpA(prop
, "regszdata"),
4672 "Expected \"regszdata\", got \"%s\"\n", prop
);
4675 r
= MsiGetPropertyA(hpkg
, "SIGPROP2", prop
, &size
);
4676 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4677 ok(!lstrcmpA(prop
, "#42"), "Expected \"#42\", got \"%s\"\n", prop
);
4680 r
= MsiGetPropertyA(hpkg
, "SIGPROP3", prop
, &size
);
4681 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4682 ok(!lstrcmpA(prop
, "#-42"), "Expected \"#-42\", got \"%s\"\n", prop
);
4684 memset(&si
, 0, sizeof(si
));
4685 if (pGetNativeSystemInfo
) pGetNativeSystemInfo(&si
);
4687 if (S(U(si
)).wProcessorArchitecture
== PROCESSOR_ARCHITECTURE_INTEL
)
4689 size
= ExpandEnvironmentStringsA("%PATH%", NULL
, 0);
4690 pathvar
= HeapAlloc(GetProcessHeap(), 0, size
);
4691 ExpandEnvironmentStringsA("%PATH%", pathvar
, size
);
4694 r
= MsiGetPropertyA(hpkg
, "SIGPROP4", NULL
, &size
);
4695 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4697 pathdata
= HeapAlloc(GetProcessHeap(), 0, ++size
);
4698 r
= MsiGetPropertyA(hpkg
, "SIGPROP4", pathdata
, &size
);
4699 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4700 ok(!lstrcmpA(pathdata
, pathvar
),
4701 "Expected \"%s\", got \"%s\"\n", pathvar
, pathdata
);
4703 HeapFree(GetProcessHeap(), 0, pathvar
);
4704 HeapFree(GetProcessHeap(), 0, pathdata
);
4708 r
= MsiGetPropertyA(hpkg
, "SIGPROP5", prop
, &size
);
4709 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4711 "my%NOVAR%"), "Expected \"my%%NOVAR%%\", got \"%s\"\n", prop
);
4714 r
= MsiGetPropertyA(hpkg
, "SIGPROP6", prop
, &size
);
4715 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4718 ok(!memcmp(prop
, "\0one\0two\0\0", 10),
4719 "Expected \"\\0one\\0two\\0\\0\"\n");
4723 lstrcpyA(path
, "#xCDAB3412EF907856");
4724 r
= MsiGetPropertyA(hpkg
, "SIGPROP7", prop
, &size
);
4725 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4726 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4729 r
= MsiGetPropertyA(hpkg
, "SIGPROP8", prop
, &size
);
4730 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4731 ok(!lstrcmpA(prop
, "##regszdata"),
4732 "Expected \"##regszdata\", got \"%s\"\n", prop
);
4735 sprintf(path
, "%s\\FileName1", expected
);
4736 r
= MsiGetPropertyA(hpkg
, "SIGPROP9", prop
, &size
);
4737 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4738 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4741 r
= MsiGetPropertyA(hpkg
, "SIGPROP10", prop
, &size
);
4742 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4743 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4746 sprintf(path
, "%s\\", expected
);
4747 r
= MsiGetPropertyA(hpkg
, "SIGPROP11", prop
, &size
);
4748 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4749 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4752 r
= MsiGetPropertyA(hpkg
, "SIGPROP12", prop
, &size
);
4753 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4754 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4757 sprintf(path
, "%s\\", expected
);
4758 r
= MsiGetPropertyA(hpkg
, "SIGPROP13", prop
, &size
);
4759 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4760 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4763 r
= MsiGetPropertyA(hpkg
, "SIGPROP14", prop
, &size
);
4764 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4765 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4768 r
= MsiGetPropertyA(hpkg
, "SIGPROP15", prop
, &size
);
4769 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4770 ok(!lstrcmpA(prop
, "regszdata"),
4771 "Expected \"regszdata\", got \"%s\"\n", prop
);
4774 r
= MsiGetPropertyA(hpkg
, "SIGPROP16", prop
, &size
);
4775 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4776 ok(!lstrcmpA(prop
, "regszdata"),
4777 "Expected \"regszdata\", got \"%s\"\n", prop
);
4782 r
= MsiGetPropertyA(hpkg
, "SIGPROP17", prop
, &size
);
4783 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4784 ok(!lstrcmpA(prop
, "regszdata"),
4785 "Expected \"regszdata\", got \"%s\"\n", prop
);
4789 r
= MsiGetPropertyA(hpkg
, "SIGPROP18", prop
, &size
);
4790 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4791 ok(!lstrcmpA(prop
, "defvalue"),
4792 "Expected \"defvalue\", got \"%s\"\n", prop
);
4795 r
= MsiGetPropertyA(hpkg
, "SIGPROP19", prop
, &size
);
4796 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4797 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4800 r
= MsiGetPropertyA(hpkg
, "SIGPROP20", prop
, &size
);
4801 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4802 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4807 sprintf(path
, "%s\\FileName3.dll", expected
);
4808 r
= MsiGetPropertyA(hpkg
, "SIGPROP21", prop
, &size
);
4809 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4810 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4813 r
= MsiGetPropertyA(hpkg
, "SIGPROP22", prop
, &size
);
4814 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4815 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4818 sprintf(path
, "%s\\FileName5.dll", expected
);
4819 r
= MsiGetPropertyA(hpkg
, "SIGPROP23", prop
, &size
);
4820 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4821 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4824 if (!is_root(CURR_DIR
))
4827 lstrcpyA(path
, expected
);
4828 ptr
= strrchr(path
, '\\') + 1;
4830 r
= MsiGetPropertyA(hpkg
, "SIGPROP24", prop
, &size
);
4831 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4832 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4835 sprintf(path
, "%s\\", expected
);
4836 r
= MsiGetPropertyA(hpkg
, "SIGPROP25", prop
, &size
);
4837 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4838 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4841 r
= MsiGetPropertyA(hpkg
, "SIGPROP26", prop
, &size
);
4842 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4843 if (is_root(CURR_DIR
))
4844 ok(!lstrcmpA(prop
, CURR_DIR
), "Expected \"%s\", got \"%s\"\n", CURR_DIR
, prop
);
4846 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4849 r
= MsiGetPropertyA(hpkg
, "SIGPROP27", prop
, &size
);
4850 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4851 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4854 r
= MsiGetPropertyA(hpkg
, "SIGPROP28", prop
, &size
);
4855 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4856 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4859 sprintf(path
, "%s\\FileName1", expected
);
4860 r
= MsiGetPropertyA(hpkg
, "SIGPROP29", prop
, &size
);
4861 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4862 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4865 sprintf(path
, "%s\\FileName1", expected
);
4866 r
= MsiGetPropertyA(hpkg
, "SIGPROP30", prop
, &size
);
4867 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4869 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4871 todo_wine
ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4873 RegSetValueA(hklm
, NULL
, REG_SZ
, "", 0);
4874 RegDeleteValueA(hklm
, "Value1");
4875 RegDeleteValueA(hklm
, "Value2");
4876 RegDeleteValueA(hklm
, "Value3");
4877 RegDeleteValueA(hklm
, "Value4");
4878 RegDeleteValueA(hklm
, "Value5");
4879 RegDeleteValueA(hklm
, "Value6");
4880 RegDeleteValueA(hklm
, "Value7");
4881 RegDeleteValueA(hklm
, "Value8");
4882 RegDeleteValueA(hklm
, "Value9");
4883 RegDeleteValueA(hklm
, "Value10");
4884 RegDeleteValueA(hklm
, "Value11");
4885 RegDeleteValueA(hklm
, "Value12");
4886 RegDeleteValueA(hklm
, "Value13");
4887 RegDeleteValueA(hklm
, "Value14");
4888 RegDeleteValueA(hklm
, "Value15");
4889 RegDeleteValueA(hklm
, "Value16");
4890 RegDeleteValueA(hklm
, "Value17");
4891 RegDeleteKeyA(hklm
, "");
4894 RegDeleteValueA(classes
, "Value1");
4895 RegDeleteKeyA(classes
, "");
4896 RegCloseKey(classes
);
4898 RegDeleteValueA(hkcu
, "Value1");
4899 RegDeleteKeyA(hkcu
, "");
4902 RegDeleteValueA(users
, "Value1");
4903 RegDeleteKeyA(users
, "");
4906 DeleteFileA("FileName1");
4907 DeleteFileA("FileName3.dll");
4908 DeleteFileA("FileName4.dll");
4909 DeleteFileA("FileName5.dll");
4910 MsiCloseHandle(hpkg
);
4911 DeleteFileA(msifile
);
4914 static void delete_win_ini(LPCSTR file
)
4916 CHAR path
[MAX_PATH
];
4918 GetWindowsDirectoryA(path
, MAX_PATH
);
4919 lstrcatA(path
, "\\");
4920 lstrcatA(path
, file
);
4925 static void test_appsearch_inilocator(void)
4927 MSIHANDLE hpkg
, hdb
;
4928 char path
[MAX_PATH
], expected
[MAX_PATH
], prop
[MAX_PATH
];
4936 if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
4939 DeleteFileA("test.dll");
4941 WritePrivateProfileStringA("Section", "Key", "keydata,field2", "IniFile.ini");
4943 strcpy(expected
, CURR_DIR
);
4944 if (is_root(CURR_DIR
)) expected
[2] = 0;
4946 create_test_file("FileName1");
4947 sprintf(path
, "%s\\FileName1", expected
);
4948 WritePrivateProfileStringA("Section", "Key2", path
, "IniFile.ini");
4950 WritePrivateProfileStringA("Section", "Key3", expected
, "IniFile.ini");
4952 sprintf(path
, "%s\\IDontExist", expected
);
4953 WritePrivateProfileStringA("Section", "Key4", path
, "IniFile.ini");
4955 create_file_with_version("FileName2.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4956 sprintf(path
, "%s\\FileName2.dll", expected
);
4957 WritePrivateProfileStringA("Section", "Key5", path
, "IniFile.ini");
4959 create_file_with_version("FileName3.dll", MAKELONG(1, 2), MAKELONG(3, 4));
4960 sprintf(path
, "%s\\FileName3.dll", expected
);
4961 WritePrivateProfileStringA("Section", "Key6", path
, "IniFile.ini");
4963 create_file_with_version("FileName4.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4964 sprintf(path
, "%s\\FileName4.dll", expected
);
4965 WritePrivateProfileStringA("Section", "Key7", path
, "IniFile.ini");
4967 hdb
= create_package_db();
4968 ok(hdb
, "Expected a valid database handle\n");
4970 r
= create_appsearch_table(hdb
);
4971 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4973 r
= add_appsearch_entry(hdb
, "'SIGPROP1', 'NewSignature1'");
4974 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4976 r
= add_appsearch_entry(hdb
, "'SIGPROP2', 'NewSignature2'");
4977 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4979 r
= add_appsearch_entry(hdb
, "'SIGPROP3', 'NewSignature3'");
4980 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4982 r
= add_appsearch_entry(hdb
, "'SIGPROP4', 'NewSignature4'");
4983 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4985 r
= add_appsearch_entry(hdb
, "'SIGPROP5', 'NewSignature5'");
4986 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4988 r
= add_appsearch_entry(hdb
, "'SIGPROP6', 'NewSignature6'");
4989 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4991 r
= add_appsearch_entry(hdb
, "'SIGPROP7', 'NewSignature7'");
4992 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4994 r
= add_appsearch_entry(hdb
, "'SIGPROP8', 'NewSignature8'");
4995 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4997 r
= add_appsearch_entry(hdb
, "'SIGPROP9', 'NewSignature9'");
4998 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5000 r
= add_appsearch_entry(hdb
, "'SIGPROP10', 'NewSignature10'");
5001 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5003 r
= add_appsearch_entry(hdb
, "'SIGPROP11', 'NewSignature11'");
5004 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5006 r
= add_appsearch_entry(hdb
, "'SIGPROP12', 'NewSignature12'");
5007 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5009 r
= create_inilocator_table(hdb
);
5010 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5012 /* msidbLocatorTypeRawValue, field 1 */
5013 str
= "'NewSignature1', 'IniFile.ini', 'Section', 'Key', 1, 2";
5014 r
= add_inilocator_entry(hdb
, str
);
5015 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5017 /* msidbLocatorTypeRawValue, field 2 */
5018 str
= "'NewSignature2', 'IniFile.ini', 'Section', 'Key', 2, 2";
5019 r
= add_inilocator_entry(hdb
, str
);
5020 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5022 /* msidbLocatorTypeRawValue, entire field */
5023 str
= "'NewSignature3', 'IniFile.ini', 'Section', 'Key', 0, 2";
5024 r
= add_inilocator_entry(hdb
, str
);
5025 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5027 /* msidbLocatorTypeFile */
5028 str
= "'NewSignature4', 'IniFile.ini', 'Section', 'Key2', 1, 1";
5029 r
= add_inilocator_entry(hdb
, str
);
5030 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5032 /* msidbLocatorTypeDirectory, file */
5033 str
= "'NewSignature5', 'IniFile.ini', 'Section', 'Key2', 1, 0";
5034 r
= add_inilocator_entry(hdb
, str
);
5035 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5037 /* msidbLocatorTypeDirectory, directory */
5038 str
= "'NewSignature6', 'IniFile.ini', 'Section', 'Key3', 1, 0";
5039 r
= add_inilocator_entry(hdb
, str
);
5040 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5042 /* msidbLocatorTypeFile, file, no signature */
5043 str
= "'NewSignature7', 'IniFile.ini', 'Section', 'Key2', 1, 1";
5044 r
= add_inilocator_entry(hdb
, str
);
5045 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5047 /* msidbLocatorTypeFile, dir, no signature */
5048 str
= "'NewSignature8', 'IniFile.ini', 'Section', 'Key3', 1, 1";
5049 r
= add_inilocator_entry(hdb
, str
);
5050 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5052 /* msidbLocatorTypeFile, file does not exist */
5053 str
= "'NewSignature9', 'IniFile.ini', 'Section', 'Key4', 1, 1";
5054 r
= add_inilocator_entry(hdb
, str
);
5055 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5057 /* msidbLocatorTypeFile, signature with version */
5058 str
= "'NewSignature10', 'IniFile.ini', 'Section', 'Key5', 1, 1";
5059 r
= add_inilocator_entry(hdb
, str
);
5060 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5062 /* msidbLocatorTypeFile, signature with version, ver > max */
5063 str
= "'NewSignature11', 'IniFile.ini', 'Section', 'Key6', 1, 1";
5064 r
= add_inilocator_entry(hdb
, str
);
5065 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5067 /* msidbLocatorTypeFile, signature with version, sig->name ignored */
5068 str
= "'NewSignature12', 'IniFile.ini', 'Section', 'Key7', 1, 1";
5069 r
= add_inilocator_entry(hdb
, str
);
5070 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5072 r
= create_signature_table(hdb
);
5073 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5075 r
= add_signature_entry(hdb
, "'NewSignature4', 'FileName1', '', '', '', '', '', '', ''");
5076 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5078 r
= add_signature_entry(hdb
, "'NewSignature9', 'IDontExist', '', '', '', '', '', '', ''");
5079 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5081 r
= add_signature_entry(hdb
, "'NewSignature10', 'FileName2.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
5082 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5084 r
= add_signature_entry(hdb
, "'NewSignature11', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
5085 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5087 r
= add_signature_entry(hdb
, "'NewSignature12', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
5088 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5090 r
= package_from_db(hdb
, &hpkg
);
5091 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
5093 skip("Not enough rights to perform tests\n");
5096 ok(r
== ERROR_SUCCESS
, "Expected a valid package handle %u\n", r
);
5098 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
5100 r
= MsiDoActionA(hpkg
, "AppSearch");
5101 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5104 r
= MsiGetPropertyA(hpkg
, "SIGPROP1", prop
, &size
);
5105 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5106 ok(!lstrcmpA(prop
, "keydata"), "Expected \"keydata\", got \"%s\"\n", prop
);
5109 r
= MsiGetPropertyA(hpkg
, "SIGPROP2", prop
, &size
);
5110 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5111 ok(!lstrcmpA(prop
, "field2"), "Expected \"field2\", got \"%s\"\n", prop
);
5114 r
= MsiGetPropertyA(hpkg
, "SIGPROP3", prop
, &size
);
5115 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5116 ok(!lstrcmpA(prop
, "keydata,field2"),
5117 "Expected \"keydata,field2\", got \"%s\"\n", prop
);
5120 sprintf(path
, "%s\\FileName1", expected
);
5121 r
= MsiGetPropertyA(hpkg
, "SIGPROP4", prop
, &size
);
5122 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5123 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5126 r
= MsiGetPropertyA(hpkg
, "SIGPROP5", prop
, &size
);
5127 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5128 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
5131 sprintf(path
, "%s\\", expected
);
5132 r
= MsiGetPropertyA(hpkg
, "SIGPROP6", prop
, &size
);
5133 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5134 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5137 sprintf(path
, "%s\\", expected
);
5138 r
= MsiGetPropertyA(hpkg
, "SIGPROP7", prop
, &size
);
5139 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5140 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5142 if (!is_root(CURR_DIR
))
5145 lstrcpyA(path
, expected
);
5146 ptr
= strrchr(path
, '\\');
5148 r
= MsiGetPropertyA(hpkg
, "SIGPROP8", prop
, &size
);
5149 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5150 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5153 r
= MsiGetPropertyA(hpkg
, "SIGPROP9", prop
, &size
);
5154 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5155 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
5160 sprintf(path
, "%s\\FileName2.dll", expected
);
5161 r
= MsiGetPropertyA(hpkg
, "SIGPROP10", prop
, &size
);
5162 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5163 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5166 r
= MsiGetPropertyA(hpkg
, "SIGPROP11", prop
, &size
);
5167 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5168 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
5171 sprintf(path
, "%s\\FileName4.dll", expected
);
5172 r
= MsiGetPropertyA(hpkg
, "SIGPROP12", prop
, &size
);
5173 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5174 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5177 MsiCloseHandle(hpkg
);
5180 delete_win_ini("IniFile.ini");
5181 DeleteFileA("FileName1");
5182 DeleteFileA("FileName2.dll");
5183 DeleteFileA("FileName3.dll");
5184 DeleteFileA("FileName4.dll");
5185 DeleteFileA(msifile
);
5189 * MSI AppSearch action on DrLocator table always returns absolute paths.
5190 * If a relative path was set, it returns the first absolute path that
5191 * matches or an empty string if it didn't find anything.
5192 * This helper function replicates this behaviour.
5194 static void search_absolute_directory(LPSTR absolute
, LPCSTR relative
)
5199 size
= lstrlenA(relative
);
5200 drives
= GetLogicalDrives();
5201 lstrcpyA(absolute
, "A:\\");
5202 for (i
= 0; i
< 26; absolute
[0] = '\0', i
++)
5204 if (!(drives
& (1 << i
)))
5207 absolute
[0] = 'A' + i
;
5208 if (GetDriveTypeA(absolute
) != DRIVE_FIXED
)
5211 lstrcpynA(absolute
+ 3, relative
, size
+ 1);
5212 attr
= GetFileAttributesA(absolute
);
5213 if (attr
!= INVALID_FILE_ATTRIBUTES
&&
5214 (attr
& FILE_ATTRIBUTE_DIRECTORY
))
5216 if (absolute
[3 + size
- 1] != '\\')
5217 lstrcatA(absolute
, "\\");
5224 static void test_appsearch_drlocator(void)
5226 MSIHANDLE hpkg
, hdb
;
5227 char path
[MAX_PATH
], expected
[MAX_PATH
], prop
[MAX_PATH
];
5234 if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
5237 DeleteFileA("test.dll");
5239 create_test_file("FileName1");
5240 CreateDirectoryA("one", NULL
);
5241 CreateDirectoryA("one\\two", NULL
);
5242 CreateDirectoryA("one\\two\\three", NULL
);
5243 create_test_file("one\\two\\three\\FileName2");
5244 CreateDirectoryA("another", NULL
);
5245 create_file_with_version("FileName3.dll", MAKELONG(2, 1), MAKELONG(4, 3));
5246 create_file_with_version("FileName4.dll", MAKELONG(1, 2), MAKELONG(3, 4));
5247 create_file_with_version("FileName5.dll", MAKELONG(2, 1), MAKELONG(4, 3));
5249 hdb
= create_package_db();
5250 ok(hdb
, "Expected a valid database handle\n");
5252 r
= create_appsearch_table(hdb
);
5253 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5255 r
= add_appsearch_entry(hdb
, "'SIGPROP1', 'NewSignature1'");
5256 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5258 r
= add_appsearch_entry(hdb
, "'SIGPROP2', 'NewSignature2'");
5259 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5261 r
= add_appsearch_entry(hdb
, "'SIGPROP3', 'NewSignature3'");
5262 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5264 r
= add_appsearch_entry(hdb
, "'SIGPROP4', 'NewSignature4'");
5265 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5267 r
= add_appsearch_entry(hdb
, "'SIGPROP5', 'NewSignature5'");
5268 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5270 r
= add_appsearch_entry(hdb
, "'SIGPROP6', 'NewSignature6'");
5271 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5273 r
= add_appsearch_entry(hdb
, "'SIGPROP7', 'NewSignature7'");
5274 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5276 r
= add_appsearch_entry(hdb
, "'SIGPROP8', 'NewSignature8'");
5277 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5279 r
= add_appsearch_entry(hdb
, "'SIGPROP9', 'NewSignature9'");
5280 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5282 r
= add_appsearch_entry(hdb
, "'SIGPROP10', 'NewSignature10'");
5283 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5285 r
= add_appsearch_entry(hdb
, "'SIGPROP11', 'NewSignature11'");
5286 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5288 r
= add_appsearch_entry(hdb
, "'SIGPROP13', 'NewSignature13'");
5289 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5291 r
= create_drlocator_table(hdb
);
5292 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5294 strcpy(expected
, CURR_DIR
);
5295 if (is_root(CURR_DIR
)) expected
[2] = 0;
5297 /* no parent, full path, depth 0, signature */
5298 sprintf(path
, "'NewSignature1', '', '%s', 0", expected
);
5299 r
= add_drlocator_entry(hdb
, path
);
5300 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5302 /* no parent, full path, depth 0, no signature */
5303 sprintf(path
, "'NewSignature2', '', '%s', 0", expected
);
5304 r
= add_drlocator_entry(hdb
, path
);
5305 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5307 /* no parent, relative path, depth 0, no signature */
5308 sprintf(path
, "'NewSignature3', '', '%s', 0", expected
+ 3);
5309 r
= add_drlocator_entry(hdb
, path
);
5310 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5312 /* no parent, full path, depth 2, signature */
5313 sprintf(path
, "'NewSignature4', '', '%s', 2", expected
);
5314 r
= add_drlocator_entry(hdb
, path
);
5315 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5317 /* no parent, full path, depth 3, signature */
5318 sprintf(path
, "'NewSignature5', '', '%s', 3", expected
);
5319 r
= add_drlocator_entry(hdb
, path
);
5320 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5322 /* no parent, full path, depth 1, signature is dir */
5323 sprintf(path
, "'NewSignature6', '', '%s', 1", expected
);
5324 r
= add_drlocator_entry(hdb
, path
);
5325 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5327 /* parent is in DrLocator, relative path, depth 0, signature */
5328 sprintf(path
, "'NewSignature7', 'NewSignature1', 'one\\two\\three', 1");
5329 r
= add_drlocator_entry(hdb
, path
);
5330 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5332 /* no parent, full path, depth 0, signature w/ version */
5333 sprintf(path
, "'NewSignature8', '', '%s', 0", expected
);
5334 r
= add_drlocator_entry(hdb
, path
);
5335 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5337 /* no parent, full path, depth 0, signature w/ version, ver > max */
5338 sprintf(path
, "'NewSignature9', '', '%s', 0", expected
);
5339 r
= add_drlocator_entry(hdb
, path
);
5340 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5342 /* no parent, full path, depth 0, signature w/ version, sig->name not ignored */
5343 sprintf(path
, "'NewSignature10', '', '%s', 0", expected
);
5344 r
= add_drlocator_entry(hdb
, path
);
5345 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5347 /* no parent, relative empty path, depth 0, no signature */
5348 sprintf(path
, "'NewSignature11', '', '', 0");
5349 r
= add_drlocator_entry(hdb
, path
);
5350 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5352 r
= create_reglocator_table(hdb
);
5353 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5356 r
= add_reglocator_entry(hdb
, "NewSignature12", 2, "htmlfile\\shell\\open\\nonexistent", "", 1);
5357 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5359 /* parent is in RegLocator, no path, depth 0, no signature */
5360 sprintf(path
, "'NewSignature13', 'NewSignature12', '', 0");
5361 r
= add_drlocator_entry(hdb
, path
);
5362 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5364 r
= create_signature_table(hdb
);
5365 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5367 str
= "'NewSignature1', 'FileName1', '', '', '', '', '', '', ''";
5368 r
= add_signature_entry(hdb
, str
);
5369 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5371 str
= "'NewSignature4', 'FileName2', '', '', '', '', '', '', ''";
5372 r
= add_signature_entry(hdb
, str
);
5373 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5375 str
= "'NewSignature5', 'FileName2', '', '', '', '', '', '', ''";
5376 r
= add_signature_entry(hdb
, str
);
5377 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5379 str
= "'NewSignature6', 'another', '', '', '', '', '', '', ''";
5380 r
= add_signature_entry(hdb
, str
);
5381 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5383 str
= "'NewSignature7', 'FileName2', '', '', '', '', '', '', ''";
5384 r
= add_signature_entry(hdb
, str
);
5385 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5387 str
= "'NewSignature8', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
5388 r
= add_signature_entry(hdb
, str
);
5389 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5391 str
= "'NewSignature9', 'FileName4.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
5392 r
= add_signature_entry(hdb
, str
);
5393 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5395 str
= "'NewSignature10', 'necessary', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
5396 r
= add_signature_entry(hdb
, str
);
5397 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5399 r
= package_from_db(hdb
, &hpkg
);
5400 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
5402 skip("Not enough rights to perform tests\n");
5405 ok(r
== ERROR_SUCCESS
, "Expected a valid package handle %u\n", r
);
5407 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
5409 r
= MsiDoActionA(hpkg
, "AppSearch");
5410 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5413 sprintf(path
, "%s\\FileName1", expected
);
5414 r
= MsiGetPropertyA(hpkg
, "SIGPROP1", prop
, &size
);
5415 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5416 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5419 sprintf(path
, "%s\\", expected
);
5420 r
= MsiGetPropertyA(hpkg
, "SIGPROP2", prop
, &size
);
5421 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5422 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5425 search_absolute_directory(path
, expected
+ 3);
5426 r
= MsiGetPropertyA(hpkg
, "SIGPROP3", prop
, &size
);
5427 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5428 ok(!lstrcmpiA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5431 r
= MsiGetPropertyA(hpkg
, "SIGPROP4", prop
, &size
);
5432 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5433 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
5436 sprintf(path
, "%s\\one\\two\\three\\FileName2", expected
);
5437 r
= MsiGetPropertyA(hpkg
, "SIGPROP5", prop
, &size
);
5438 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5439 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5442 r
= MsiGetPropertyA(hpkg
, "SIGPROP6", prop
, &size
);
5443 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5444 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
5447 sprintf(path
, "%s\\one\\two\\three\\FileName2", expected
);
5448 r
= MsiGetPropertyA(hpkg
, "SIGPROP7", prop
, &size
);
5449 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5450 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5455 sprintf(path
, "%s\\FileName3.dll", expected
);
5456 r
= MsiGetPropertyA(hpkg
, "SIGPROP8", prop
, &size
);
5457 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5458 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5461 r
= MsiGetPropertyA(hpkg
, "SIGPROP9", prop
, &size
);
5462 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5463 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
5466 r
= MsiGetPropertyA(hpkg
, "SIGPROP10", prop
, &size
);
5467 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5468 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
5472 search_absolute_directory(path
, "");
5473 r
= MsiGetPropertyA(hpkg
, "SIGPROP11", prop
, &size
);
5474 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5475 ok(!lstrcmpiA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5478 strcpy(path
, "c:\\");
5479 r
= MsiGetPropertyA(hpkg
, "SIGPROP13", prop
, &size
);
5480 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5481 ok(!prop
[0], "Expected \"\", got \"%s\"\n", prop
);
5483 MsiCloseHandle(hpkg
);
5486 DeleteFileA("FileName1");
5487 DeleteFileA("FileName3.dll");
5488 DeleteFileA("FileName4.dll");
5489 DeleteFileA("FileName5.dll");
5490 DeleteFileA("one\\two\\three\\FileName2");
5491 RemoveDirectoryA("one\\two\\three");
5492 RemoveDirectoryA("one\\two");
5493 RemoveDirectoryA("one");
5494 RemoveDirectoryA("another");
5495 DeleteFileA(msifile
);
5498 static void test_featureparents(void)
5504 hdb
= create_package_db();
5505 ok ( hdb
, "failed to create package database\n" );
5507 r
= add_directory_entry( hdb
, "'TARGETDIR', '', 'SourceDir'");
5508 ok( r
== ERROR_SUCCESS
, "cannot add directory: %d\n", r
);
5510 r
= create_feature_table( hdb
);
5511 ok( r
== ERROR_SUCCESS
, "cannot create Feature table: %d\n", r
);
5513 r
= create_component_table( hdb
);
5514 ok( r
== ERROR_SUCCESS
, "cannot create Component table: %d\n", r
);
5516 r
= create_feature_components_table( hdb
);
5517 ok( r
== ERROR_SUCCESS
, "cannot create FeatureComponents table: %d\n", r
);
5519 r
= create_file_table( hdb
);
5520 ok( r
== ERROR_SUCCESS
, "cannot create File table: %d\n", r
);
5522 /* msidbFeatureAttributesFavorLocal */
5523 r
= add_feature_entry( hdb
, "'zodiac', '', '', '', 2, 1, '', 0" );
5524 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
5526 /* msidbFeatureAttributesFavorSource */
5527 r
= add_feature_entry( hdb
, "'perseus', '', '', '', 2, 1, '', 1" );
5528 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
5530 /* msidbFeatureAttributesFavorLocal */
5531 r
= add_feature_entry( hdb
, "'orion', '', '', '', 2, 1, '', 0" );
5532 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
5534 /* msidbFeatureAttributesUIDisallowAbsent */
5535 r
= add_feature_entry( hdb
, "'lyra', '', '', '', 2, 1, '', 16" );
5536 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
5538 /* disabled because of install level */
5539 r
= add_feature_entry( hdb
, "'waters', '', '', '', 15, 101, '', 9" );
5540 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
5542 /* child feature of disabled feature */
5543 r
= add_feature_entry( hdb
, "'bayer', 'waters', '', '', 14, 1, '', 9" );
5544 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
5546 /* component of disabled feature (install level) */
5547 r
= add_component_entry( hdb
, "'delphinus', '', 'TARGETDIR', 0, '', 'delphinus_file'" );
5548 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
5550 /* component of disabled child feature (install level) */
5551 r
= add_component_entry( hdb
, "'hydrus', '', 'TARGETDIR', 0, '', 'hydrus_file'" );
5552 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
5554 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
5555 r
= add_component_entry( hdb
, "'leo', '', 'TARGETDIR', 0, '', 'leo_file'" );
5556 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
5558 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
5559 r
= add_component_entry( hdb
, "'virgo', '', 'TARGETDIR', 1, '', 'virgo_file'" );
5560 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
5562 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
5563 r
= add_component_entry( hdb
, "'libra', '', 'TARGETDIR', 2, '', 'libra_file'" );
5564 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
5566 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
5567 r
= add_component_entry( hdb
, "'cassiopeia', '', 'TARGETDIR', 0, '', 'cassiopeia_file'" );
5568 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
5570 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
5571 r
= add_component_entry( hdb
, "'cepheus', '', 'TARGETDIR', 1, '', 'cepheus_file'" );
5572 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
5574 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
5575 r
= add_component_entry( hdb
, "'andromeda', '', 'TARGETDIR', 2, '', 'andromeda_file'" );
5576 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
5578 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
5579 r
= add_component_entry( hdb
, "'canis', '', 'TARGETDIR', 0, '', 'canis_file'" );
5580 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
5582 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
5583 r
= add_component_entry( hdb
, "'monoceros', '', 'TARGETDIR', 1, '', 'monoceros_file'" );
5584 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
5586 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
5587 r
= add_component_entry( hdb
, "'lepus', '', 'TARGETDIR', 2, '', 'lepus_file'" );
5588 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
5590 r
= add_feature_components_entry( hdb
, "'zodiac', 'leo'" );
5591 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
5593 r
= add_feature_components_entry( hdb
, "'zodiac', 'virgo'" );
5594 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
5596 r
= add_feature_components_entry( hdb
, "'zodiac', 'libra'" );
5597 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
5599 r
= add_feature_components_entry( hdb
, "'perseus', 'cassiopeia'" );
5600 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
5602 r
= add_feature_components_entry( hdb
, "'perseus', 'cepheus'" );
5603 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
5605 r
= add_feature_components_entry( hdb
, "'perseus', 'andromeda'" );
5606 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
5608 r
= add_feature_components_entry( hdb
, "'orion', 'leo'" );
5609 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
5611 r
= add_feature_components_entry( hdb
, "'orion', 'virgo'" );
5612 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
5614 r
= add_feature_components_entry( hdb
, "'orion', 'libra'" );
5615 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
5617 r
= add_feature_components_entry( hdb
, "'orion', 'cassiopeia'" );
5618 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
5620 r
= add_feature_components_entry( hdb
, "'orion', 'cepheus'" );
5621 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
5623 r
= add_feature_components_entry( hdb
, "'orion', 'andromeda'" );
5624 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
5626 r
= add_feature_components_entry( hdb
, "'orion', 'canis'" );
5627 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
5629 r
= add_feature_components_entry( hdb
, "'orion', 'monoceros'" );
5630 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
5632 r
= add_feature_components_entry( hdb
, "'orion', 'lepus'" );
5633 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
5635 r
= add_feature_components_entry( hdb
, "'waters', 'delphinus'" );
5636 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
5638 r
= add_feature_components_entry( hdb
, "'bayer', 'hydrus'" );
5639 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
5641 r
= add_file_entry( hdb
, "'leo_file', 'leo', 'leo.txt', 100, '', '1033', 8192, 1" );
5642 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
5644 r
= add_file_entry( hdb
, "'virgo_file', 'virgo', 'virgo.txt', 0, '', '1033', 8192, 1" );
5645 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
5647 r
= add_file_entry( hdb
, "'libra_file', 'libra', 'libra.txt', 0, '', '1033', 8192, 1" );
5648 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
5650 r
= add_file_entry( hdb
, "'cassiopeia_file', 'cassiopeia', 'cassiopeia.txt', 0, '', '1033', 8192, 1" );
5651 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
5653 r
= add_file_entry( hdb
, "'cepheus_file', 'cepheus', 'cepheus.txt', 0, '', '1033', 8192, 1" );
5654 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
5656 r
= add_file_entry( hdb
, "'andromeda_file', 'andromeda', 'andromeda.txt', 0, '', '1033', 8192, 1" );
5657 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
5659 r
= add_file_entry( hdb
, "'canis_file', 'canis', 'canis.txt', 0, '', '1033', 8192, 1" );
5660 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
5662 r
= add_file_entry( hdb
, "'monoceros_file', 'monoceros', 'monoceros.txt', 0, '', '1033', 8192, 1" );
5663 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
5665 r
= add_file_entry( hdb
, "'lepus_file', 'lepus', 'lepus.txt', 0, '', '1033', 8192, 1" );
5666 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
5668 r
= add_file_entry( hdb
, "'delphinus_file', 'delphinus', 'delphinus.txt', 0, '', '1033', 8192, 1" );
5669 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
5671 r
= add_file_entry( hdb
, "'hydrus_file', 'hydrus', 'hydrus.txt', 0, '', '1033', 8192, 1" );
5672 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
5674 r
= package_from_db( hdb
, &hpkg
);
5675 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
5677 skip("Not enough rights to perform tests\n");
5678 DeleteFileA(msifile
);
5681 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
5683 MsiCloseHandle( hdb
);
5685 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
5687 r
= MsiDoActionA( hpkg
, "CostInitialize");
5688 ok( r
== ERROR_SUCCESS
, "cost init failed\n");
5690 r
= MsiDoActionA( hpkg
, "FileCost");
5691 ok( r
== ERROR_SUCCESS
, "file cost failed\n");
5693 r
= MsiDoActionA( hpkg
, "CostFinalize");
5694 ok( r
== ERROR_SUCCESS
, "cost finalize failed\n");
5696 test_feature_states( __LINE__
, hpkg
, "zodiac", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
5697 test_feature_states( __LINE__
, hpkg
, "perseus", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_SOURCE
, FALSE
);
5698 test_feature_states( __LINE__
, hpkg
, "orion", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
5699 test_feature_states( __LINE__
, hpkg
, "lyra", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
5700 test_feature_states( __LINE__
, hpkg
, "waters", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
5701 test_feature_states( __LINE__
, hpkg
, "bayer", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
5703 test_component_states( __LINE__
, hpkg
, "leo", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_LOCAL
, FALSE
);
5704 test_component_states( __LINE__
, hpkg
, "virgo", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_SOURCE
, FALSE
);
5705 test_component_states( __LINE__
, hpkg
, "libra", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_LOCAL
, FALSE
);
5706 test_component_states( __LINE__
, hpkg
, "cassiopeia", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_LOCAL
, FALSE
);
5707 test_component_states( __LINE__
, hpkg
, "cepheus", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_SOURCE
, FALSE
);
5708 test_component_states( __LINE__
, hpkg
, "andromeda", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_LOCAL
, FALSE
);
5709 test_component_states( __LINE__
, hpkg
, "canis", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_LOCAL
, FALSE
);
5710 test_component_states( __LINE__
, hpkg
, "monoceros", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_SOURCE
, FALSE
);
5711 test_component_states( __LINE__
, hpkg
, "lepus", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_LOCAL
, FALSE
);
5712 test_component_states( __LINE__
, hpkg
, "delphinus", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
5713 test_component_states( __LINE__
, hpkg
, "hydrus", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
5715 r
= MsiSetFeatureStateA(hpkg
, "orion", INSTALLSTATE_ABSENT
);
5716 ok( r
== ERROR_SUCCESS
, "failed to set feature state: %d\n", r
);
5718 r
= MsiSetFeatureStateA(hpkg
, "lyra", INSTALLSTATE_ABSENT
);
5719 ok( r
== ERROR_SUCCESS
, "failed to set feature state: %d\n", r
);
5721 r
= MsiSetFeatureStateA(hpkg
, "nosuchfeature", INSTALLSTATE_ABSENT
);
5722 ok( r
== ERROR_UNKNOWN_FEATURE
, "Expected ERROR_UNKNOWN_FEATURE, got %u\n", r
);
5724 test_feature_states( __LINE__
, hpkg
, "zodiac", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
5725 test_feature_states( __LINE__
, hpkg
, "perseus", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_SOURCE
, FALSE
);
5726 test_feature_states( __LINE__
, hpkg
, "orion", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_ABSENT
, FALSE
);
5727 test_feature_states( __LINE__
, hpkg
, "lyra", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_ABSENT
, FALSE
);
5728 test_feature_states( __LINE__
, hpkg
, "waters", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
5729 test_feature_states( __LINE__
, hpkg
, "bayer", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
5731 test_component_states( __LINE__
, hpkg
, "leo", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_LOCAL
, FALSE
);
5732 test_component_states( __LINE__
, hpkg
, "virgo", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_SOURCE
, FALSE
);
5733 test_component_states( __LINE__
, hpkg
, "libra", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_LOCAL
, FALSE
);
5734 test_component_states( __LINE__
, hpkg
, "cassiopeia", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_LOCAL
, FALSE
);
5735 test_component_states( __LINE__
, hpkg
, "cepheus", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_SOURCE
, FALSE
);
5736 test_component_states( __LINE__
, hpkg
, "andromeda", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_SOURCE
, FALSE
);
5737 test_component_states( __LINE__
, hpkg
, "canis", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
5738 test_component_states( __LINE__
, hpkg
, "monoceros", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
5739 test_component_states( __LINE__
, hpkg
, "lepus", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
5740 test_component_states( __LINE__
, hpkg
, "delphinus", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
5741 test_component_states( __LINE__
, hpkg
, "hydrus", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
5743 MsiCloseHandle(hpkg
);
5744 DeleteFileA(msifile
);
5747 static void test_installprops(void)
5749 MSIHANDLE hpkg
, hdb
;
5750 CHAR path
[MAX_PATH
], buf
[MAX_PATH
];
5756 REGSAM access
= KEY_ALL_ACCESS
;
5758 INSTALLUILEVEL uilevel
;
5761 access
|= KEY_WOW64_64KEY
;
5763 lstrcpyA(path
, CURR_DIR
);
5764 if (!is_root(CURR_DIR
)) lstrcatA(path
, "\\");
5765 lstrcatA(path
, msifile
);
5767 uilevel
= MsiSetInternalUI(INSTALLUILEVEL_BASIC
|INSTALLUILEVEL_SOURCERESONLY
, NULL
);
5769 hdb
= create_package_db();
5770 ok( hdb
, "failed to create database\n");
5772 r
= package_from_db(hdb
, &hpkg
);
5773 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
5775 skip("Not enough rights to perform tests\n");
5776 MsiSetInternalUI(uilevel
, NULL
);
5777 DeleteFileA(msifile
);
5780 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
5782 MsiCloseHandle(hdb
);
5786 r
= MsiGetPropertyA(hpkg
, "UILevel", buf
, &size
);
5787 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5788 ok( !lstrcmpA(buf
, "3"), "Expected \"3\", got \"%s\"\n", buf
);
5790 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
5794 r
= MsiGetPropertyA(hpkg
, "UILevel", buf
, &size
);
5795 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5796 ok( !lstrcmpA(buf
, "3"), "Expected \"3\", got \"%s\"\n", buf
);
5800 r
= MsiGetPropertyA(hpkg
, "DATABASE", buf
, &size
);
5801 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5802 ok( !lstrcmpA(buf
, path
), "Expected %s, got %s\n", path
, buf
);
5804 RegOpenKeyA(HKEY_CURRENT_USER
, "SOFTWARE\\Microsoft\\MS Setup (ACME)\\User Info", &hkey1
);
5805 RegOpenKeyExA(HKEY_LOCAL_MACHINE
, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, access
, &hkey2
);
5810 if (RegQueryValueExA(hkey1
, "DefName", NULL
, &type
, (LPBYTE
)path
, &size
) != ERROR_SUCCESS
)
5814 RegQueryValueExA(hkey2
, "RegisteredOwner", NULL
, &type
, (LPBYTE
)path
, &size
);
5819 r
= MsiGetPropertyA(hpkg
, "USERNAME", buf
, &size
);
5820 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5821 ok( !lstrcmpA(buf
, path
), "Expected %s, got %s\n", path
, buf
);
5826 if (RegQueryValueExA(hkey1
, "DefCompany", NULL
, &type
, (LPBYTE
)path
, &size
) != ERROR_SUCCESS
)
5830 RegQueryValueExA(hkey2
, "RegisteredOrganization", NULL
, &type
, (LPBYTE
)path
, &size
);
5837 r
= MsiGetPropertyA(hpkg
, "COMPANYNAME", buf
, &size
);
5838 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5839 ok( !lstrcmpA(buf
, path
), "Expected %s, got %s\n", path
, buf
);
5844 r
= MsiGetPropertyA(hpkg
, "VersionDatabase", buf
, &size
);
5845 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5846 trace("VersionDatabase = %s\n", buf
);
5850 r
= MsiGetPropertyA(hpkg
, "VersionMsi", buf
, &size
);
5851 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5852 trace("VersionMsi = %s\n", buf
);
5856 r
= MsiGetPropertyA(hpkg
, "Date", buf
, &size
);
5857 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5858 trace("Date = %s\n", buf
);
5862 r
= MsiGetPropertyA(hpkg
, "Time", buf
, &size
);
5863 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5864 trace("Time = %s\n", buf
);
5868 r
= MsiGetPropertyA(hpkg
, "PackageCode", buf
, &size
);
5869 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5870 trace("PackageCode = %s\n", buf
);
5874 r
= MsiGetPropertyA(hpkg
, "ComputerName", buf
, &size
);
5875 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
5876 trace("ComputerName = %s\n", buf
);
5878 langid
= GetUserDefaultLangID();
5879 sprintf(path
, "%d", langid
);
5883 r
= MsiGetPropertyA(hpkg
, "UserLanguageID", buf
, &size
);
5884 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
5885 ok( !lstrcmpA(buf
, path
), "Expected \"%s\", got \"%s\"\n", path
, buf
);
5887 res
= GetSystemMetrics(SM_CXSCREEN
);
5890 r
= MsiGetPropertyA(hpkg
, "ScreenX", buf
, &size
);
5891 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
5892 ok(atol(buf
) == res
, "Expected %d, got %ld\n", res
, atol(buf
));
5894 res
= GetSystemMetrics(SM_CYSCREEN
);
5897 r
= MsiGetPropertyA(hpkg
, "ScreenY", buf
, &size
);
5898 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
5899 ok(atol(buf
) == res
, "Expected %d, got %ld\n", res
, atol(buf
));
5901 if (pGetSystemInfo
&& pSHGetFolderPathA
)
5903 pGetSystemInfo(&si
);
5904 if (S(U(si
)).wProcessorArchitecture
== PROCESSOR_ARCHITECTURE_AMD64
)
5908 r
= MsiGetPropertyA(hpkg
, "Intel", buf
, &size
);
5909 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5910 ok(buf
[0], "property not set\n");
5914 r
= MsiGetPropertyA(hpkg
, "MsiAMD64", buf
, &size
);
5915 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5916 ok(buf
[0], "property not set\n");
5920 r
= MsiGetPropertyA(hpkg
, "Msix64", buf
, &size
);
5921 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5922 ok(buf
[0], "property not set\n");
5926 r
= MsiGetPropertyA(hpkg
, "System64Folder", buf
, &size
);
5927 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5928 GetSystemDirectoryA(path
, MAX_PATH
);
5929 if (size
) buf
[size
- 1] = 0;
5930 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
5934 r
= MsiGetPropertyA(hpkg
, "SystemFolder", buf
, &size
);
5935 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5936 pGetSystemWow64DirectoryA(path
, MAX_PATH
);
5937 if (size
) buf
[size
- 1] = 0;
5938 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
5942 r
= MsiGetPropertyA(hpkg
, "ProgramFiles64Folder", buf
, &size
);
5943 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5944 pSHGetFolderPathA(NULL
, CSIDL_PROGRAM_FILES
, NULL
, 0, path
);
5945 if (size
) buf
[size
- 1] = 0;
5946 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
5950 r
= MsiGetPropertyA(hpkg
, "ProgramFilesFolder", buf
, &size
);
5951 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5952 pSHGetFolderPathA(NULL
, CSIDL_PROGRAM_FILESX86
, NULL
, 0, path
);
5953 if (size
) buf
[size
- 1] = 0;
5954 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
5958 r
= MsiGetPropertyA(hpkg
, "CommonFiles64Folder", buf
, &size
);
5959 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5960 pSHGetFolderPathA(NULL
, CSIDL_PROGRAM_FILES_COMMON
, NULL
, 0, path
);
5961 if (size
) buf
[size
- 1] = 0;
5962 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
5966 r
= MsiGetPropertyA(hpkg
, "CommonFilesFolder", buf
, &size
);
5967 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5968 pSHGetFolderPathA(NULL
, CSIDL_PROGRAM_FILES_COMMONX86
, NULL
, 0, path
);
5969 if (size
) buf
[size
- 1] = 0;
5970 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
5974 r
= MsiGetPropertyA(hpkg
, "VersionNT64", buf
, &size
);
5975 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5976 ok(buf
[0], "property not set\n");
5978 else if (S(U(si
)).wProcessorArchitecture
== PROCESSOR_ARCHITECTURE_INTEL
)
5984 r
= MsiGetPropertyA(hpkg
, "Intel", buf
, &size
);
5985 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5986 ok(buf
[0], "property not set\n");
5990 r
= MsiGetPropertyA(hpkg
, "MsiAMD64", buf
, &size
);
5991 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5992 ok(!buf
[0], "property set\n");
5996 r
= MsiGetPropertyA(hpkg
, "Msix64", buf
, &size
);
5997 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5998 ok(!buf
[0], "property set\n");
6002 r
= MsiGetPropertyA(hpkg
, "System64Folder", buf
, &size
);
6003 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
6004 ok(!buf
[0], "property set\n");
6008 r
= MsiGetPropertyA(hpkg
, "SystemFolder", buf
, &size
);
6009 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
6010 GetSystemDirectoryA(path
, MAX_PATH
);
6011 if (size
) buf
[size
- 1] = 0;
6012 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
6016 r
= MsiGetPropertyA(hpkg
, "ProgramFiles64Folder", buf
, &size
);
6017 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
6018 ok(!buf
[0], "property set\n");
6022 r
= MsiGetPropertyA(hpkg
, "ProgramFilesFolder", buf
, &size
);
6023 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
6024 pSHGetFolderPathA(NULL
, CSIDL_PROGRAM_FILES
, NULL
, 0, path
);
6025 if (size
) buf
[size
- 1] = 0;
6026 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
6030 r
= MsiGetPropertyA(hpkg
, "CommonFiles64Folder", buf
, &size
);
6031 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
6032 ok(!buf
[0], "property set\n");
6036 r
= MsiGetPropertyA(hpkg
, "CommonFilesFolder", buf
, &size
);
6037 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
6038 pSHGetFolderPathA(NULL
, CSIDL_PROGRAM_FILES_COMMON
, NULL
, 0, path
);
6039 if (size
) buf
[size
- 1] = 0;
6040 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
6044 r
= MsiGetPropertyA(hpkg
, "VersionNT64", buf
, &size
);
6045 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
6046 ok(!buf
[0], "property set\n");
6052 r
= MsiGetPropertyA(hpkg
, "Intel", buf
, &size
);
6053 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
6054 ok(buf
[0], "property not set\n");
6058 r
= MsiGetPropertyA(hpkg
, "MsiAMD64", buf
, &size
);
6059 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
6060 ok(buf
[0], "property not set\n");
6064 r
= MsiGetPropertyA(hpkg
, "Msix64", buf
, &size
);
6065 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
6066 ok(buf
[0], "property not set\n");
6070 r
= MsiGetPropertyA(hpkg
, "System64Folder", buf
, &size
);
6071 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
6072 GetSystemDirectoryA(path
, MAX_PATH
);
6073 if (size
) buf
[size
- 1] = 0;
6074 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
6078 r
= MsiGetPropertyA(hpkg
, "SystemFolder", buf
, &size
);
6079 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
6080 pGetSystemWow64DirectoryA(path
, MAX_PATH
);
6081 if (size
) buf
[size
- 1] = 0;
6082 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
6086 r
= MsiGetPropertyA(hpkg
, "ProgramFilesFolder64", buf
, &size
);
6087 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
6088 ok(!buf
[0], "property set\n");
6092 r
= MsiGetPropertyA(hpkg
, "ProgramFilesFolder", buf
, &size
);
6093 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
6094 pSHGetFolderPathA(NULL
, CSIDL_PROGRAM_FILESX86
, NULL
, 0, path
);
6095 if (size
) buf
[size
- 1] = 0;
6096 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
6100 r
= MsiGetPropertyA(hpkg
, "CommonFilesFolder64", buf
, &size
);
6101 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
6102 ok(!buf
[0], "property set\n");
6106 r
= MsiGetPropertyA(hpkg
, "CommonFilesFolder", buf
, &size
);
6107 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
6108 pSHGetFolderPathA(NULL
, CSIDL_PROGRAM_FILES_COMMONX86
, NULL
, 0, path
);
6109 if (size
) buf
[size
- 1] = 0;
6110 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
6114 r
= MsiGetPropertyA(hpkg
, "VersionNT64", buf
, &size
);
6115 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
6116 ok(buf
[0], "property not set\n");
6123 MsiCloseHandle(hpkg
);
6124 DeleteFileA(msifile
);
6125 MsiSetInternalUI(uilevel
, NULL
);
6128 static void test_launchconditions(void)
6134 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
6136 hdb
= create_package_db();
6137 ok( hdb
, "failed to create package database\n" );
6139 r
= create_launchcondition_table( hdb
);
6140 ok( r
== ERROR_SUCCESS
, "cannot create LaunchCondition table: %d\n", r
);
6142 r
= add_launchcondition_entry( hdb
, "'X = \"1\"', 'one'" );
6143 ok( r
== ERROR_SUCCESS
, "cannot add launch condition: %d\n", r
);
6145 /* invalid condition */
6146 r
= add_launchcondition_entry( hdb
, "'X != \"1\"', 'one'" );
6147 ok( r
== ERROR_SUCCESS
, "cannot add launch condition: %d\n", r
);
6149 r
= package_from_db( hdb
, &hpkg
);
6150 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
6152 skip("Not enough rights to perform tests\n");
6153 DeleteFileA(msifile
);
6156 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
6158 MsiCloseHandle( hdb
);
6160 r
= MsiSetPropertyA( hpkg
, "X", "1" );
6161 ok( r
== ERROR_SUCCESS
, "failed to set property\n" );
6163 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
6165 /* invalid conditions are ignored */
6166 r
= MsiDoActionA( hpkg
, "LaunchConditions" );
6167 ok( r
== ERROR_SUCCESS
, "cost init failed\n" );
6169 /* verify LaunchConditions still does some verification */
6170 r
= MsiSetPropertyA( hpkg
, "X", "2" );
6171 ok( r
== ERROR_SUCCESS
, "failed to set property\n" );
6173 r
= MsiDoActionA( hpkg
, "LaunchConditions" );
6174 ok( r
== ERROR_INSTALL_FAILURE
, "Expected ERROR_INSTALL_FAILURE, got %d\n", r
);
6176 MsiCloseHandle( hpkg
);
6177 DeleteFileA( msifile
);
6180 static void test_ccpsearch(void)
6182 MSIHANDLE hdb
, hpkg
;
6183 CHAR prop
[MAX_PATH
];
6184 DWORD size
= MAX_PATH
;
6187 hdb
= create_package_db();
6188 ok(hdb
, "failed to create package database\n");
6190 r
= create_ccpsearch_table(hdb
);
6191 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6193 r
= add_ccpsearch_entry(hdb
, "'CCP_random'");
6194 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6196 r
= add_ccpsearch_entry(hdb
, "'RMCCP_random'");
6197 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6199 r
= create_reglocator_table(hdb
);
6200 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6202 r
= add_reglocator_entry(hdb
, "CCP_random", 0, "htmlfile\\shell\\open\\nonexistent", "", 1);
6203 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6205 r
= create_drlocator_table(hdb
);
6206 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6208 r
= add_drlocator_entry(hdb
, "'RMCCP_random', '', 'C:\\', '0'");
6209 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6211 r
= create_signature_table(hdb
);
6212 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6214 r
= package_from_db(hdb
, &hpkg
);
6215 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
6217 skip("Not enough rights to perform tests\n");
6218 DeleteFileA(msifile
);
6221 ok(r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
6223 MsiCloseHandle(hdb
);
6225 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
6227 r
= MsiDoActionA(hpkg
, "CCPSearch");
6228 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6230 r
= MsiGetPropertyA(hpkg
, "CCP_Success", prop
, &size
);
6231 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6232 ok(!lstrcmpA(prop
, "1"), "Expected 1, got %s\n", prop
);
6234 MsiCloseHandle(hpkg
);
6235 DeleteFileA(msifile
);
6238 static void test_complocator(void)
6240 MSIHANDLE hdb
, hpkg
;
6242 CHAR prop
[MAX_PATH
];
6243 CHAR expected
[MAX_PATH
];
6244 DWORD size
= MAX_PATH
;
6246 hdb
= create_package_db();
6247 ok(hdb
, "failed to create package database\n");
6249 r
= create_appsearch_table(hdb
);
6250 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6252 r
= add_appsearch_entry(hdb
, "'ABELISAURUS', 'abelisaurus'");
6253 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6255 r
= add_appsearch_entry(hdb
, "'BACTROSAURUS', 'bactrosaurus'");
6256 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6258 r
= add_appsearch_entry(hdb
, "'CAMELOTIA', 'camelotia'");
6259 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6261 r
= add_appsearch_entry(hdb
, "'DICLONIUS', 'diclonius'");
6262 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6264 r
= add_appsearch_entry(hdb
, "'ECHINODON', 'echinodon'");
6265 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6267 r
= add_appsearch_entry(hdb
, "'FALCARIUS', 'falcarius'");
6268 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6270 r
= add_appsearch_entry(hdb
, "'GALLIMIMUS', 'gallimimus'");
6271 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6273 r
= add_appsearch_entry(hdb
, "'HAGRYPHUS', 'hagryphus'");
6274 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6276 r
= add_appsearch_entry(hdb
, "'IGUANODON', 'iguanodon'");
6277 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6279 r
= add_appsearch_entry(hdb
, "'JOBARIA', 'jobaria'");
6280 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6282 r
= add_appsearch_entry(hdb
, "'KAKURU', 'kakuru'");
6283 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6285 r
= add_appsearch_entry(hdb
, "'LABOCANIA', 'labocania'");
6286 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6288 r
= add_appsearch_entry(hdb
, "'MEGARAPTOR', 'megaraptor'");
6289 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6291 r
= add_appsearch_entry(hdb
, "'NEOSODON', 'neosodon'");
6292 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6294 r
= add_appsearch_entry(hdb
, "'OLOROTITAN', 'olorotitan'");
6295 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6297 r
= add_appsearch_entry(hdb
, "'PANTYDRACO', 'pantydraco'");
6298 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6300 r
= create_complocator_table(hdb
);
6301 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6303 r
= add_complocator_entry(hdb
, "'abelisaurus', '{E3619EED-305A-418C-B9C7-F7D7377F0934}', 1");
6304 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6306 r
= add_complocator_entry(hdb
, "'bactrosaurus', '{D56B688D-542F-42Ef-90FD-B6DA76EE8119}', 0");
6307 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6309 r
= add_complocator_entry(hdb
, "'camelotia', '{8211BE36-2466-47E3-AFB7-6AC72E51AED2}', 1");
6310 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6312 r
= add_complocator_entry(hdb
, "'diclonius', '{5C767B20-A33C-45A4-B80B-555E512F01AE}', 0");
6313 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6315 r
= add_complocator_entry(hdb
, "'echinodon', '{A19E16C5-C75D-4699-8111-C4338C40C3CB}', 1");
6316 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6318 r
= add_complocator_entry(hdb
, "'falcarius', '{17762FA1-A7AE-4CC6-8827-62873C35361D}', 0");
6319 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6321 r
= add_complocator_entry(hdb
, "'gallimimus', '{75EBF568-C959-41E0-A99E-9050638CF5FB}', 1");
6322 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6324 r
= add_complocator_entry(hdb
, "'hagrphus', '{D4969B72-17D9-4AB6-BE49-78F2FEE857AC}', 0");
6325 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6327 r
= add_complocator_entry(hdb
, "'iguanodon', '{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}', 1");
6328 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6330 r
= add_complocator_entry(hdb
, "'jobaria', '{243C22B1-8C51-4151-B9D1-1AE5265E079E}', 0");
6331 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6333 r
= add_complocator_entry(hdb
, "'kakuru', '{5D0F03BA-50BC-44F2-ABB1-72C972F4E514}', 1");
6334 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6336 r
= add_complocator_entry(hdb
, "'labocania', '{C7DDB60C-7828-4046-A6F8-699D5E92F1ED}', 0");
6337 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6339 r
= add_complocator_entry(hdb
, "'megaraptor', '{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}', 1");
6340 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6342 r
= add_complocator_entry(hdb
, "'neosodon', '{0B499649-197A-48EF-93D2-AF1C17ED6E90}', 0");
6343 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6345 r
= add_complocator_entry(hdb
, "'olorotitan', '{54E9E91F-AED2-46D5-A25A-7E50AFA24513}', 1");
6346 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6348 r
= add_complocator_entry(hdb
, "'pantydraco', '{2A989951-5565-4FA7-93A7-E800A3E67D71}', 0");
6349 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6351 r
= create_signature_table(hdb
);
6352 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6354 r
= add_signature_entry(hdb
, "'abelisaurus', 'abelisaurus', '', '', '', '', '', '', ''");
6355 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6357 r
= add_signature_entry(hdb
, "'bactrosaurus', 'bactrosaurus', '', '', '', '', '', '', ''");
6358 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6360 r
= add_signature_entry(hdb
, "'camelotia', 'camelotia', '', '', '', '', '', '', ''");
6361 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6363 r
= add_signature_entry(hdb
, "'diclonius', 'diclonius', '', '', '', '', '', '', ''");
6364 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6366 r
= add_signature_entry(hdb
, "'iguanodon', 'iguanodon', '', '', '', '', '', '', ''");
6367 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6369 r
= add_signature_entry(hdb
, "'jobaria', 'jobaria', '', '', '', '', '', '', ''");
6370 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6372 r
= add_signature_entry(hdb
, "'kakuru', 'kakuru', '', '', '', '', '', '', ''");
6373 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6375 r
= add_signature_entry(hdb
, "'labocania', 'labocania', '', '', '', '', '', '', ''");
6376 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6378 r
= package_from_db(hdb
, &hpkg
);
6379 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
6381 skip("Not enough rights to perform tests\n");
6382 DeleteFileA(msifile
);
6385 ok(r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
6387 MsiCloseHandle(hdb
);
6389 create_test_file("abelisaurus");
6390 create_test_file("bactrosaurus");
6391 create_test_file("camelotia");
6392 create_test_file("diclonius");
6393 create_test_file("echinodon");
6394 create_test_file("falcarius");
6395 create_test_file("gallimimus");
6396 create_test_file("hagryphus");
6397 CreateDirectoryA("iguanodon", NULL
);
6398 CreateDirectoryA("jobaria", NULL
);
6399 CreateDirectoryA("kakuru", NULL
);
6400 CreateDirectoryA("labocania", NULL
);
6401 CreateDirectoryA("megaraptor", NULL
);
6402 CreateDirectoryA("neosodon", NULL
);
6403 CreateDirectoryA("olorotitan", NULL
);
6404 CreateDirectoryA("pantydraco", NULL
);
6406 set_component_path("abelisaurus", MSIINSTALLCONTEXT_MACHINE
,
6407 "{E3619EED-305A-418C-B9C7-F7D7377F0934}", NULL
, FALSE
);
6408 set_component_path("bactrosaurus", MSIINSTALLCONTEXT_MACHINE
,
6409 "{D56B688D-542F-42Ef-90FD-B6DA76EE8119}", NULL
, FALSE
);
6410 set_component_path("echinodon", MSIINSTALLCONTEXT_MACHINE
,
6411 "{A19E16C5-C75D-4699-8111-C4338C40C3CB}", NULL
, FALSE
);
6412 set_component_path("falcarius", MSIINSTALLCONTEXT_MACHINE
,
6413 "{17762FA1-A7AE-4CC6-8827-62873C35361D}", NULL
, FALSE
);
6414 set_component_path("iguanodon", MSIINSTALLCONTEXT_MACHINE
,
6415 "{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}", NULL
, FALSE
);
6416 set_component_path("jobaria", MSIINSTALLCONTEXT_MACHINE
,
6417 "{243C22B1-8C51-4151-B9D1-1AE5265E079E}", NULL
, FALSE
);
6418 set_component_path("megaraptor", MSIINSTALLCONTEXT_MACHINE
,
6419 "{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}", NULL
, FALSE
);
6420 set_component_path("neosodon", MSIINSTALLCONTEXT_MACHINE
,
6421 "{0B499649-197A-48EF-93D2-AF1C17ED6E90}", NULL
, FALSE
);
6423 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
6425 r
= MsiDoActionA(hpkg
, "AppSearch");
6426 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6429 r
= MsiGetPropertyA(hpkg
, "ABELISAURUS", prop
, &size
);
6430 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6432 lstrcpyA(expected
, CURR_DIR
);
6433 if (!is_root(CURR_DIR
)) lstrcatA(expected
, "\\");
6434 lstrcatA(expected
, "abelisaurus");
6435 ok(!lstrcmpA(prop
, expected
) || !lstrcmpA(prop
, ""),
6436 "Expected %s or empty string, got %s\n", expected
, prop
);
6439 r
= MsiGetPropertyA(hpkg
, "BACTROSAURUS", prop
, &size
);
6440 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6441 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6444 r
= MsiGetPropertyA(hpkg
, "CAMELOTIA", prop
, &size
);
6445 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6446 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6449 r
= MsiGetPropertyA(hpkg
, "DICLONIUS", prop
, &size
);
6450 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6451 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6454 r
= MsiGetPropertyA(hpkg
, "ECHINODON", prop
, &size
);
6455 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6457 lstrcpyA(expected
, CURR_DIR
);
6458 if (!is_root(CURR_DIR
)) lstrcatA(expected
, "\\");
6459 ok(!lstrcmpA(prop
, expected
) || !lstrcmpA(prop
, ""),
6460 "Expected %s or empty string, got %s\n", expected
, prop
);
6463 r
= MsiGetPropertyA(hpkg
, "FALCARIUS", prop
, &size
);
6464 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6465 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6468 r
= MsiGetPropertyA(hpkg
, "GALLIMIMUS", prop
, &size
);
6469 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6470 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6473 r
= MsiGetPropertyA(hpkg
, "HAGRYPHUS", prop
, &size
);
6474 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6475 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6478 r
= MsiGetPropertyA(hpkg
, "IGUANODON", prop
, &size
);
6479 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6480 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6483 r
= MsiGetPropertyA(hpkg
, "JOBARIA", prop
, &size
);
6484 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6485 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6488 r
= MsiGetPropertyA(hpkg
, "KAKURU", prop
, &size
);
6489 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6490 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6493 r
= MsiGetPropertyA(hpkg
, "LABOCANIA", prop
, &size
);
6494 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6495 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6498 r
= MsiGetPropertyA(hpkg
, "MEGARAPTOR", prop
, &size
);
6499 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6501 lstrcpyA(expected
, CURR_DIR
);
6502 if (!is_root(CURR_DIR
)) lstrcatA(expected
, "\\");
6503 ok(!lstrcmpA(prop
, expected
) || !lstrcmpA(prop
, ""),
6504 "Expected %s or empty string, got %s\n", expected
, prop
);
6507 r
= MsiGetPropertyA(hpkg
, "NEOSODON", prop
, &size
);
6508 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6510 lstrcpyA(expected
, CURR_DIR
);
6511 if (!is_root(CURR_DIR
)) lstrcatA(expected
, "\\");
6512 lstrcatA(expected
, "neosodon\\");
6513 ok(!lstrcmpA(prop
, expected
) || !lstrcmpA(prop
, ""),
6514 "Expected %s or empty string, got %s\n", expected
, prop
);
6517 r
= MsiGetPropertyA(hpkg
, "OLOROTITAN", prop
, &size
);
6518 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6519 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6522 r
= MsiGetPropertyA(hpkg
, "PANTYDRACO", prop
, &size
);
6523 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6524 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6526 MsiCloseHandle(hpkg
);
6527 DeleteFileA("abelisaurus");
6528 DeleteFileA("bactrosaurus");
6529 DeleteFileA("camelotia");
6530 DeleteFileA("diclonius");
6531 DeleteFileA("echinodon");
6532 DeleteFileA("falcarius");
6533 DeleteFileA("gallimimus");
6534 DeleteFileA("hagryphus");
6535 RemoveDirectoryA("iguanodon");
6536 RemoveDirectoryA("jobaria");
6537 RemoveDirectoryA("kakuru");
6538 RemoveDirectoryA("labocania");
6539 RemoveDirectoryA("megaraptor");
6540 RemoveDirectoryA("neosodon");
6541 RemoveDirectoryA("olorotitan");
6542 RemoveDirectoryA("pantydraco");
6543 delete_component_path("{E3619EED-305A-418C-B9C7-F7D7377F0934}",
6544 MSIINSTALLCONTEXT_MACHINE
, NULL
);
6545 delete_component_path("{D56B688D-542F-42Ef-90FD-B6DA76EE8119}",
6546 MSIINSTALLCONTEXT_MACHINE
, NULL
);
6547 delete_component_path("{A19E16C5-C75D-4699-8111-C4338C40C3CB}",
6548 MSIINSTALLCONTEXT_MACHINE
, NULL
);
6549 delete_component_path("{17762FA1-A7AE-4CC6-8827-62873C35361D}",
6550 MSIINSTALLCONTEXT_MACHINE
, NULL
);
6551 delete_component_path("{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}",
6552 MSIINSTALLCONTEXT_MACHINE
, NULL
);
6553 delete_component_path("{243C22B1-8C51-4151-B9D1-1AE5265E079E}",
6554 MSIINSTALLCONTEXT_MACHINE
, NULL
);
6555 delete_component_path("{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}",
6556 MSIINSTALLCONTEXT_MACHINE
, NULL
);
6557 delete_component_path("{0B499649-197A-48EF-93D2-AF1C17ED6E90}",
6558 MSIINSTALLCONTEXT_MACHINE
, NULL
);
6559 DeleteFileA(msifile
);
6562 static void set_suminfo_prop(MSIHANDLE db
, DWORD prop
, DWORD val
)
6567 r
= MsiGetSummaryInformationA(db
, NULL
, 1, &summary
);
6568 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6570 r
= MsiSummaryInfoSetPropertyA(summary
, prop
, VT_I4
, val
, NULL
, NULL
);
6571 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6573 r
= MsiSummaryInfoPersist(summary
);
6574 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
6576 MsiCloseHandle(summary
);
6579 static void test_MsiGetSourcePath(void)
6581 MSIHANDLE hdb
, hpkg
;
6582 CHAR path
[MAX_PATH
];
6584 CHAR subsrc
[MAX_PATH
];
6585 CHAR sub2
[MAX_PATH
];
6589 lstrcpyA(cwd
, CURR_DIR
);
6590 if (!is_root(CURR_DIR
)) lstrcatA(cwd
, "\\");
6592 lstrcpyA(subsrc
, cwd
);
6593 lstrcatA(subsrc
, "subsource");
6594 lstrcatA(subsrc
, "\\");
6596 lstrcpyA(sub2
, subsrc
);
6597 lstrcatA(sub2
, "sub2");
6598 lstrcatA(sub2
, "\\");
6600 /* uncompressed source */
6602 hdb
= create_package_db();
6603 ok( hdb
, "failed to create database\n");
6605 set_suminfo_prop(hdb
, PID_WORDCOUNT
, 0);
6607 r
= add_directory_entry(hdb
, "'TARGETDIR', '', 'SourceDir'");
6608 ok(r
== S_OK
, "failed\n");
6610 r
= add_directory_entry(hdb
, "'SubDir', 'TARGETDIR', 'subtarget:subsource'");
6611 ok(r
== S_OK
, "failed\n");
6613 r
= add_directory_entry(hdb
, "'SubDir2', 'SubDir', 'sub2'");
6614 ok(r
== S_OK
, "failed\n");
6616 r
= MsiDatabaseCommit(hdb
);
6617 ok(r
== ERROR_SUCCESS
, "Failed to commit database\n");
6619 r
= package_from_db(hdb
, &hpkg
);
6620 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
6622 skip("Not enough rights to perform tests\n");
6623 DeleteFileA(msifile
);
6626 ok(r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
6628 MsiCloseHandle(hdb
);
6630 /* invalid database handle */
6632 lstrcpyA(path
, "kiwi");
6633 r
= MsiGetSourcePathA(-1, "TARGETDIR", path
, &size
);
6634 ok(r
== ERROR_INVALID_HANDLE
,
6635 "Expected ERROR_INVALID_HANDLE, got %d\n", r
);
6636 ok(!lstrcmpA(path
, "kiwi"),
6637 "Expected path to be unchanged, got \"%s\"\n", path
);
6638 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6642 lstrcpyA(path
, "kiwi");
6643 r
= MsiGetSourcePathA(hpkg
, NULL
, path
, &size
);
6644 ok(r
== ERROR_INVALID_PARAMETER
,
6645 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
6646 ok(!lstrcmpA(path
, "kiwi"),
6647 "Expected path to be unchanged, got \"%s\"\n", path
);
6648 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6650 /* empty szFolder */
6652 lstrcpyA(path
, "kiwi");
6653 r
= MsiGetSourcePathA(hpkg
, "", path
, &size
);
6654 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6655 ok(!lstrcmpA(path
, "kiwi"),
6656 "Expected path to be unchanged, got \"%s\"\n", path
);
6657 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6661 lstrcpyA(path
, "kiwi");
6662 r
= MsiGetSourcePathA(hpkg
, "TARGETDIR", path
, &size
);
6663 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6664 ok(!lstrcmpA(path
, "kiwi"),
6665 "Expected path to be unchanged, got \"%s\"\n", path
);
6666 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6669 lstrcpyA(path
, "kiwi");
6670 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
6671 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6672 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
6673 ok(size
== 0, "Expected 0, got %d\n", size
);
6676 lstrcpyA(path
, "kiwi");
6677 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
6678 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6679 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
6680 ok(size
== 0, "Expected 0, got %d\n", size
);
6684 lstrcpyA(path
, "kiwi");
6685 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6686 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6687 ok(!lstrcmpA(path
, "kiwi"),
6688 "Expected path to be unchanged, got \"%s\"\n", path
);
6689 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6693 lstrcpyA(path
, "kiwi");
6694 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
6695 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6696 ok(!lstrcmpA(path
, "kiwi"),
6697 "Expected path to be unchanged, got \"%s\"\n", path
);
6698 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6700 /* source path does not exist, but the property exists */
6702 lstrcpyA(path
, "kiwi");
6703 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
6704 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6705 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
6706 ok(size
== 0, "Expected 0, got %d\n", size
);
6709 lstrcpyA(path
, "kiwi");
6710 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
6711 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6712 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
6713 ok(size
== 0, "Expected 0, got %d\n", size
);
6717 lstrcpyA(path
, "kiwi");
6718 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
6719 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6720 ok(!lstrcmpA(path
, "kiwi"),
6721 "Expected path to be unchanged, got \"%s\"\n", path
);
6722 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6726 lstrcpyA(path
, "kiwi");
6727 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
6728 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6729 ok(!lstrcmpA(path
, "kiwi"),
6730 "Expected path to be unchanged, got \"%s\"\n", path
);
6731 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6733 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
6735 r
= MsiDoActionA(hpkg
, "CostInitialize");
6736 ok(r
== ERROR_SUCCESS
, "cost init failed\n");
6738 /* try TARGETDIR after CostInitialize */
6740 lstrcpyA(path
, "kiwi");
6741 r
= MsiGetSourcePathA(hpkg
, "TARGETDIR", path
, &size
);
6742 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6743 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6744 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6746 /* try SourceDir after CostInitialize */
6748 lstrcpyA(path
, "kiwi");
6749 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6750 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6751 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6752 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6754 /* try SOURCEDIR after CostInitialize */
6756 lstrcpyA(path
, "kiwi");
6757 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
6758 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6759 ok(!lstrcmpA(path
, "kiwi"),
6760 "Expected path to be unchanged, got \"%s\"\n", path
);
6761 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6763 /* source path does not exist, but the property exists */
6765 lstrcpyA(path
, "kiwi");
6766 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
6767 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6768 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6769 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6772 lstrcpyA(path
, "kiwi");
6773 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
6774 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6775 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6776 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6778 /* try SubDir after CostInitialize */
6780 lstrcpyA(path
, "kiwi");
6781 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
6782 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6783 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
6784 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
6786 /* try SubDir2 after CostInitialize */
6788 lstrcpyA(path
, "kiwi");
6789 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
6790 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6791 ok(!lstrcmpA(path
, sub2
), "Expected \"%s\", got \"%s\"\n", sub2
, path
);
6792 ok(size
== lstrlenA(sub2
), "Expected %d, got %d\n", lstrlenA(sub2
), size
);
6794 r
= MsiDoActionA(hpkg
, "ResolveSource");
6795 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
6797 /* try TARGETDIR after ResolveSource */
6799 lstrcpyA(path
, "kiwi");
6800 r
= MsiGetSourcePathA(hpkg
, "TARGETDIR", path
, &size
);
6801 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6802 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6803 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6805 /* try SourceDir after ResolveSource */
6807 lstrcpyA(path
, "kiwi");
6808 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6809 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6810 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6811 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6813 /* try SOURCEDIR after ResolveSource */
6815 lstrcpyA(path
, "kiwi");
6816 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
6817 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6818 ok(!lstrcmpA(path
, "kiwi"),
6819 "Expected path to be unchanged, got \"%s\"\n", path
);
6820 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6822 /* source path does not exist, but the property exists */
6824 lstrcpyA(path
, "kiwi");
6825 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
6826 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6827 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6828 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6831 lstrcpyA(path
, "kiwi");
6832 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
6833 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6834 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6835 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6837 /* try SubDir after ResolveSource */
6839 lstrcpyA(path
, "kiwi");
6840 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
6841 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6842 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
6843 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
6845 /* try SubDir2 after ResolveSource */
6847 lstrcpyA(path
, "kiwi");
6848 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
6849 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6850 ok(!lstrcmpA(path
, sub2
), "Expected \"%s\", got \"%s\"\n", sub2
, path
);
6851 ok(size
== lstrlenA(sub2
), "Expected %d, got %d\n", lstrlenA(sub2
), size
);
6853 r
= MsiDoActionA(hpkg
, "FileCost");
6854 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
6856 /* try TARGETDIR after FileCost */
6858 lstrcpyA(path
, "kiwi");
6859 r
= MsiGetSourcePathA(hpkg
, "TARGETDIR", path
, &size
);
6860 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6861 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6862 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6864 /* try SourceDir after FileCost */
6866 lstrcpyA(path
, "kiwi");
6867 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6868 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6869 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6870 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6872 /* try SOURCEDIR after FileCost */
6874 lstrcpyA(path
, "kiwi");
6875 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
6876 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6877 ok(!lstrcmpA(path
, "kiwi"),
6878 "Expected path to be unchanged, got \"%s\"\n", path
);
6879 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6881 /* source path does not exist, but the property exists */
6883 lstrcpyA(path
, "kiwi");
6884 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
6885 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6886 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6887 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6890 lstrcpyA(path
, "kiwi");
6891 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
6892 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6893 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6894 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6896 /* try SubDir after FileCost */
6898 lstrcpyA(path
, "kiwi");
6899 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
6900 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6901 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
6902 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
6904 /* try SubDir2 after FileCost */
6906 lstrcpyA(path
, "kiwi");
6907 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
6908 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6909 ok(!lstrcmpA(path
, sub2
), "Expected \"%s\", got \"%s\"\n", sub2
, path
);
6910 ok(size
== lstrlenA(sub2
), "Expected %d, got %d\n", lstrlenA(sub2
), size
);
6912 r
= MsiDoActionA(hpkg
, "CostFinalize");
6913 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
6915 /* try TARGETDIR after CostFinalize */
6917 lstrcpyA(path
, "kiwi");
6918 r
= MsiGetSourcePathA(hpkg
, "TARGETDIR", path
, &size
);
6919 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6920 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6921 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6923 /* try SourceDir after CostFinalize */
6925 lstrcpyA(path
, "kiwi");
6926 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6927 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6928 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6929 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6931 /* try SOURCEDIR after CostFinalize */
6933 lstrcpyA(path
, "kiwi");
6934 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
6935 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6936 ok(!lstrcmpA(path
, "kiwi"),
6937 "Expected path to be unchanged, got \"%s\"\n", path
);
6938 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6940 /* source path does not exist, but the property exists */
6942 lstrcpyA(path
, "kiwi");
6943 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
6944 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6945 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6946 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6949 lstrcpyA(path
, "kiwi");
6950 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
6951 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6952 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6953 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6955 /* try SubDir after CostFinalize */
6957 lstrcpyA(path
, "kiwi");
6958 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
6959 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6960 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
6961 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
6963 /* try SubDir2 after CostFinalize */
6965 lstrcpyA(path
, "kiwi");
6966 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
6967 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6968 ok(!lstrcmpA(path
, sub2
), "Expected \"%s\", got \"%s\"\n", sub2
, path
);
6969 ok(size
== lstrlenA(sub2
), "Expected %d, got %d\n", lstrlenA(sub2
), size
);
6971 /* nonexistent directory */
6973 lstrcpyA(path
, "kiwi");
6974 r
= MsiGetSourcePathA(hpkg
, "IDontExist", path
, &size
);
6975 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6976 ok(!lstrcmpA(path
, "kiwi"),
6977 "Expected path to be unchanged, got \"%s\"\n", path
);
6978 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6980 /* NULL szPathBuf */
6982 r
= MsiGetSourcePathA(hpkg
, "SourceDir", NULL
, &size
);
6983 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6984 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6986 /* NULL pcchPathBuf */
6987 lstrcpyA(path
, "kiwi");
6988 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, NULL
);
6989 ok(r
== ERROR_INVALID_PARAMETER
,
6990 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
6991 ok(!lstrcmpA(path
, "kiwi"),
6992 "Expected path to be unchanged, got \"%s\"\n", path
);
6994 /* pcchPathBuf is 0 */
6996 lstrcpyA(path
, "kiwi");
6997 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6998 ok(r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
6999 ok(!lstrcmpA(path
, "kiwi"),
7000 "Expected path to be unchanged, got \"%s\"\n", path
);
7001 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7003 /* pcchPathBuf does not have room for NULL terminator */
7004 size
= lstrlenA(cwd
);
7005 lstrcpyA(path
, "kiwi");
7006 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
7007 ok(r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
7008 ok(!strncmp(path
, cwd
, lstrlenA(cwd
) - 1),
7009 "Expected path with no backslash, got \"%s\"\n", path
);
7010 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7012 /* pcchPathBuf has room for NULL terminator */
7013 size
= lstrlenA(cwd
) + 1;
7014 lstrcpyA(path
, "kiwi");
7015 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
7016 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7017 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7018 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7020 /* remove property */
7021 r
= MsiSetPropertyA(hpkg
, "SourceDir", NULL
);
7022 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7024 /* try SourceDir again */
7026 lstrcpyA(path
, "kiwi");
7027 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
7028 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7029 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7030 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7032 /* set property to a valid directory */
7033 r
= MsiSetPropertyA(hpkg
, "SOURCEDIR", cwd
);
7034 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7036 /* try SOURCEDIR again */
7038 lstrcpyA(path
, "kiwi");
7039 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
7040 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
7041 ok(!lstrcmpA(path
, "kiwi"),
7042 "Expected path to be unchanged, got \"%s\"\n", path
);
7043 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
7045 MsiCloseHandle(hpkg
);
7047 /* compressed source */
7049 r
= MsiOpenDatabaseW(msifileW
, MSIDBOPEN_DIRECT
, &hdb
);
7050 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7052 set_suminfo_prop(hdb
, PID_WORDCOUNT
, msidbSumInfoSourceTypeCompressed
);
7054 r
= package_from_db(hdb
, &hpkg
);
7055 ok(r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
7059 lstrcpyA(path
, "kiwi");
7060 r
= MsiGetSourcePathA(hpkg
, "TARGETDIR", path
, &size
);
7061 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
7062 ok(!lstrcmpA(path
, "kiwi"),
7063 "Expected path to be unchanged, got \"%s\"\n", path
);
7064 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
7068 lstrcpyA(path
, "kiwi");
7069 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
7070 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
7071 ok(!lstrcmpA(path
, "kiwi"),
7072 "Expected path to be unchanged, got \"%s\"\n", path
);
7073 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
7077 lstrcpyA(path
, "kiwi");
7078 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
7079 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
7080 ok(!lstrcmpA(path
, "kiwi"),
7081 "Expected path to be unchanged, got \"%s\"\n", path
);
7082 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
7084 /* source path nor the property exist */
7086 lstrcpyA(path
, "kiwi");
7087 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7088 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7089 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7090 ok(size
== 0, "Expected 0, got %d\n", size
);
7093 lstrcpyA(path
, "kiwi");
7094 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7095 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7096 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7097 ok(size
== 0, "Expected 0, got %d\n", size
);
7101 lstrcpyA(path
, "kiwi");
7102 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
7103 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
7104 ok(!lstrcmpA(path
, "kiwi"),
7105 "Expected path to be unchanged, got \"%s\"\n", path
);
7106 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
7110 lstrcpyA(path
, "kiwi");
7111 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
7112 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
7113 ok(!lstrcmpA(path
, "kiwi"),
7114 "Expected path to be unchanged, got \"%s\"\n", path
);
7115 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
7117 r
= MsiDoActionA(hpkg
, "CostInitialize");
7118 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7120 /* try TARGETDIR after CostInitialize */
7122 lstrcpyA(path
, "kiwi");
7123 r
= MsiGetSourcePathA(hpkg
, "TARGETDIR", path
, &size
);
7124 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7125 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7126 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7128 /* try SourceDir after CostInitialize */
7130 lstrcpyA(path
, "kiwi");
7131 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
7132 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7133 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7134 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7136 /* try SOURCEDIR after CostInitialize */
7138 lstrcpyA(path
, "kiwi");
7139 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
7142 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7143 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7144 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7147 /* source path does not exist, but the property exists */
7149 lstrcpyA(path
, "kiwi");
7150 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7151 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7152 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7153 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7156 lstrcpyA(path
, "kiwi");
7157 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7158 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7159 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7160 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7162 /* try SubDir after CostInitialize */
7164 lstrcpyA(path
, "kiwi");
7165 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
7166 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7167 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7168 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7170 /* try SubDir2 after CostInitialize */
7172 lstrcpyA(path
, "kiwi");
7173 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
7174 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7175 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7176 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7178 r
= MsiDoActionA(hpkg
, "ResolveSource");
7179 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7181 /* try TARGETDIR after ResolveSource */
7183 lstrcpyA(path
, "kiwi");
7184 r
= MsiGetSourcePathA(hpkg
, "TARGETDIR", path
, &size
);
7185 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7186 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7187 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7189 /* try SourceDir after ResolveSource */
7191 lstrcpyA(path
, "kiwi");
7192 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
7193 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7194 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7195 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7197 /* try SOURCEDIR after ResolveSource */
7199 lstrcpyA(path
, "kiwi");
7200 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
7203 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7204 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7205 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7208 /* source path and the property exist */
7210 lstrcpyA(path
, "kiwi");
7211 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7212 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7213 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7214 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7217 lstrcpyA(path
, "kiwi");
7218 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7219 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7220 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7221 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7223 /* try SubDir after ResolveSource */
7225 lstrcpyA(path
, "kiwi");
7226 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
7227 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7228 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7229 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7231 /* try SubDir2 after ResolveSource */
7233 lstrcpyA(path
, "kiwi");
7234 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
7235 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7236 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7237 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7239 r
= MsiDoActionA(hpkg
, "FileCost");
7240 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7242 /* try TARGETDIR after CostFinalize */
7244 lstrcpyA(path
, "kiwi");
7245 r
= MsiGetSourcePathA(hpkg
, "TARGETDIR", path
, &size
);
7246 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7247 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7248 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7250 /* try SourceDir after CostFinalize */
7252 lstrcpyA(path
, "kiwi");
7253 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
7254 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7255 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7256 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7258 /* try SOURCEDIR after CostFinalize */
7260 lstrcpyA(path
, "kiwi");
7261 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
7264 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7265 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7266 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7269 /* source path and the property exist */
7271 lstrcpyA(path
, "kiwi");
7272 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7273 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7274 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7275 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7278 lstrcpyA(path
, "kiwi");
7279 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7280 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7281 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7282 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7284 /* try SubDir after CostFinalize */
7286 lstrcpyA(path
, "kiwi");
7287 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
7288 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7289 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7290 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7292 /* try SubDir2 after CostFinalize */
7294 lstrcpyA(path
, "kiwi");
7295 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
7296 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7297 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7298 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7300 r
= MsiDoActionA(hpkg
, "CostFinalize");
7301 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7303 /* try TARGETDIR after CostFinalize */
7305 lstrcpyA(path
, "kiwi");
7306 r
= MsiGetSourcePathA(hpkg
, "TARGETDIR", path
, &size
);
7307 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7308 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7309 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7311 /* try SourceDir after CostFinalize */
7313 lstrcpyA(path
, "kiwi");
7314 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
7315 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7316 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7317 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7319 /* try SOURCEDIR after CostFinalize */
7321 lstrcpyA(path
, "kiwi");
7322 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
7325 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7326 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7327 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7330 /* source path and the property exist */
7332 lstrcpyA(path
, "kiwi");
7333 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7334 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7335 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7336 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7339 lstrcpyA(path
, "kiwi");
7340 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7341 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7342 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7343 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7345 /* try SubDir after CostFinalize */
7347 lstrcpyA(path
, "kiwi");
7348 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
7349 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7350 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7351 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7353 /* try SubDir2 after CostFinalize */
7355 lstrcpyA(path
, "kiwi");
7356 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
7357 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7358 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7359 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7361 MsiCloseHandle(hpkg
);
7362 DeleteFileA(msifile
);
7365 static void test_shortlongsource(void)
7367 MSIHANDLE hdb
, hpkg
;
7368 CHAR path
[MAX_PATH
];
7370 CHAR subsrc
[MAX_PATH
];
7374 lstrcpyA(cwd
, CURR_DIR
);
7375 if (!is_root(CURR_DIR
)) lstrcatA(cwd
, "\\");
7377 lstrcpyA(subsrc
, cwd
);
7378 lstrcatA(subsrc
, "long");
7379 lstrcatA(subsrc
, "\\");
7381 /* long file names */
7383 hdb
= create_package_db();
7384 ok( hdb
, "failed to create database\n");
7386 set_suminfo_prop(hdb
, PID_WORDCOUNT
, 0);
7388 r
= add_directory_entry(hdb
, "'TARGETDIR', '', 'SourceDir'");
7389 ok(r
== S_OK
, "failed\n");
7391 r
= add_directory_entry(hdb
, "'SubDir', 'TARGETDIR', 'short|long'");
7392 ok(r
== S_OK
, "failed\n");
7394 /* CostInitialize:short */
7395 r
= add_directory_entry(hdb
, "'SubDir2', 'TARGETDIR', 'one|two'");
7396 ok(r
== S_OK
, "failed\n");
7398 /* CostInitialize:long */
7399 r
= add_directory_entry(hdb
, "'SubDir3', 'TARGETDIR', 'three|four'");
7400 ok(r
== S_OK
, "failed\n");
7402 /* FileCost:short */
7403 r
= add_directory_entry(hdb
, "'SubDir4', 'TARGETDIR', 'five|six'");
7404 ok(r
== S_OK
, "failed\n");
7407 r
= add_directory_entry(hdb
, "'SubDir5', 'TARGETDIR', 'seven|eight'");
7408 ok(r
== S_OK
, "failed\n");
7410 /* CostFinalize:short */
7411 r
= add_directory_entry(hdb
, "'SubDir6', 'TARGETDIR', 'nine|ten'");
7412 ok(r
== S_OK
, "failed\n");
7414 /* CostFinalize:long */
7415 r
= add_directory_entry(hdb
, "'SubDir7', 'TARGETDIR', 'eleven|twelve'");
7416 ok(r
== S_OK
, "failed\n");
7418 MsiDatabaseCommit(hdb
);
7420 r
= package_from_db(hdb
, &hpkg
);
7421 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
7423 skip("Not enough rights to perform tests\n");
7424 DeleteFileA(msifile
);
7427 ok(r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
7429 MsiCloseHandle(hdb
);
7431 CreateDirectoryA("one", NULL
);
7432 CreateDirectoryA("four", NULL
);
7434 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
7436 r
= MsiDoActionA(hpkg
, "CostInitialize");
7437 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7439 CreateDirectoryA("five", NULL
);
7440 CreateDirectoryA("eight", NULL
);
7442 r
= MsiDoActionA(hpkg
, "FileCost");
7443 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7445 CreateDirectoryA("nine", NULL
);
7446 CreateDirectoryA("twelve", NULL
);
7448 r
= MsiDoActionA(hpkg
, "CostFinalize");
7449 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7451 /* neither short nor long source directories exist */
7453 lstrcpyA(path
, "kiwi");
7454 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
7455 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7456 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7457 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7459 CreateDirectoryA("short", NULL
);
7461 /* short source directory exists */
7463 lstrcpyA(path
, "kiwi");
7464 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
7465 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7466 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7467 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7469 CreateDirectoryA("long", NULL
);
7471 /* both short and long source directories exist */
7473 lstrcpyA(path
, "kiwi");
7474 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
7475 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7476 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7477 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7479 lstrcpyA(subsrc
, cwd
);
7480 lstrcatA(subsrc
, "two");
7481 lstrcatA(subsrc
, "\\");
7483 /* short dir exists before CostInitialize */
7485 lstrcpyA(path
, "kiwi");
7486 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
7487 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7488 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7489 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7491 lstrcpyA(subsrc
, cwd
);
7492 lstrcatA(subsrc
, "four");
7493 lstrcatA(subsrc
, "\\");
7495 /* long dir exists before CostInitialize */
7497 lstrcpyA(path
, "kiwi");
7498 r
= MsiGetSourcePathA(hpkg
, "SubDir3", path
, &size
);
7499 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7500 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7501 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7503 lstrcpyA(subsrc
, cwd
);
7504 lstrcatA(subsrc
, "six");
7505 lstrcatA(subsrc
, "\\");
7507 /* short dir exists before FileCost */
7509 lstrcpyA(path
, "kiwi");
7510 r
= MsiGetSourcePathA(hpkg
, "SubDir4", path
, &size
);
7511 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7512 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7513 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7515 lstrcpyA(subsrc
, cwd
);
7516 lstrcatA(subsrc
, "eight");
7517 lstrcatA(subsrc
, "\\");
7519 /* long dir exists before FileCost */
7521 lstrcpyA(path
, "kiwi");
7522 r
= MsiGetSourcePathA(hpkg
, "SubDir5", path
, &size
);
7523 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7524 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7525 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7527 lstrcpyA(subsrc
, cwd
);
7528 lstrcatA(subsrc
, "ten");
7529 lstrcatA(subsrc
, "\\");
7531 /* short dir exists before CostFinalize */
7533 lstrcpyA(path
, "kiwi");
7534 r
= MsiGetSourcePathA(hpkg
, "SubDir6", path
, &size
);
7535 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7536 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7537 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7539 lstrcpyA(subsrc
, cwd
);
7540 lstrcatA(subsrc
, "twelve");
7541 lstrcatA(subsrc
, "\\");
7543 /* long dir exists before CostFinalize */
7545 lstrcpyA(path
, "kiwi");
7546 r
= MsiGetSourcePathA(hpkg
, "SubDir7", path
, &size
);
7547 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7548 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7549 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7551 MsiCloseHandle(hpkg
);
7552 RemoveDirectoryA("short");
7553 RemoveDirectoryA("long");
7554 RemoveDirectoryA("one");
7555 RemoveDirectoryA("four");
7556 RemoveDirectoryA("five");
7557 RemoveDirectoryA("eight");
7558 RemoveDirectoryA("nine");
7559 RemoveDirectoryA("twelve");
7561 /* short file names */
7563 r
= MsiOpenDatabaseW(msifileW
, MSIDBOPEN_DIRECT
, &hdb
);
7564 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7566 set_suminfo_prop(hdb
, PID_WORDCOUNT
, msidbSumInfoSourceTypeSFN
);
7568 r
= package_from_db(hdb
, &hpkg
);
7569 ok(r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
7571 MsiCloseHandle(hdb
);
7573 CreateDirectoryA("one", NULL
);
7574 CreateDirectoryA("four", NULL
);
7576 r
= MsiDoActionA(hpkg
, "CostInitialize");
7577 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7579 CreateDirectoryA("five", NULL
);
7580 CreateDirectoryA("eight", NULL
);
7582 r
= MsiDoActionA(hpkg
, "FileCost");
7583 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7585 CreateDirectoryA("nine", NULL
);
7586 CreateDirectoryA("twelve", NULL
);
7588 r
= MsiDoActionA(hpkg
, "CostFinalize");
7589 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7591 lstrcpyA(subsrc
, cwd
);
7592 lstrcatA(subsrc
, "short");
7593 lstrcatA(subsrc
, "\\");
7595 /* neither short nor long source directories exist */
7597 lstrcpyA(path
, "kiwi");
7598 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
7599 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7600 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7601 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7603 CreateDirectoryA("short", NULL
);
7605 /* short source directory exists */
7607 lstrcpyA(path
, "kiwi");
7608 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
7609 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7610 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7611 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7613 CreateDirectoryA("long", NULL
);
7615 /* both short and long source directories exist */
7617 lstrcpyA(path
, "kiwi");
7618 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
7619 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7620 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7621 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7623 lstrcpyA(subsrc
, cwd
);
7624 lstrcatA(subsrc
, "one");
7625 lstrcatA(subsrc
, "\\");
7627 /* short dir exists before CostInitialize */
7629 lstrcpyA(path
, "kiwi");
7630 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
7631 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7632 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7633 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7635 lstrcpyA(subsrc
, cwd
);
7636 lstrcatA(subsrc
, "three");
7637 lstrcatA(subsrc
, "\\");
7639 /* long dir exists before CostInitialize */
7641 lstrcpyA(path
, "kiwi");
7642 r
= MsiGetSourcePathA(hpkg
, "SubDir3", path
, &size
);
7643 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7644 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7645 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7647 lstrcpyA(subsrc
, cwd
);
7648 lstrcatA(subsrc
, "five");
7649 lstrcatA(subsrc
, "\\");
7651 /* short dir exists before FileCost */
7653 lstrcpyA(path
, "kiwi");
7654 r
= MsiGetSourcePathA(hpkg
, "SubDir4", path
, &size
);
7655 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7656 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7657 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7659 lstrcpyA(subsrc
, cwd
);
7660 lstrcatA(subsrc
, "seven");
7661 lstrcatA(subsrc
, "\\");
7663 /* long dir exists before FileCost */
7665 lstrcpyA(path
, "kiwi");
7666 r
= MsiGetSourcePathA(hpkg
, "SubDir5", path
, &size
);
7667 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7668 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7669 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7671 lstrcpyA(subsrc
, cwd
);
7672 lstrcatA(subsrc
, "nine");
7673 lstrcatA(subsrc
, "\\");
7675 /* short dir exists before CostFinalize */
7677 lstrcpyA(path
, "kiwi");
7678 r
= MsiGetSourcePathA(hpkg
, "SubDir6", path
, &size
);
7679 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7680 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7681 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7683 lstrcpyA(subsrc
, cwd
);
7684 lstrcatA(subsrc
, "eleven");
7685 lstrcatA(subsrc
, "\\");
7687 /* long dir exists before CostFinalize */
7689 lstrcpyA(path
, "kiwi");
7690 r
= MsiGetSourcePathA(hpkg
, "SubDir7", path
, &size
);
7691 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7692 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7693 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7695 MsiCloseHandle(hpkg
);
7696 RemoveDirectoryA("short");
7697 RemoveDirectoryA("long");
7698 RemoveDirectoryA("one");
7699 RemoveDirectoryA("four");
7700 RemoveDirectoryA("five");
7701 RemoveDirectoryA("eight");
7702 RemoveDirectoryA("nine");
7703 RemoveDirectoryA("twelve");
7704 DeleteFileA(msifile
);
7707 static void test_sourcedir(void)
7709 MSIHANDLE hdb
, hpkg
;
7711 CHAR path
[MAX_PATH
];
7713 CHAR subsrc
[MAX_PATH
];
7717 lstrcpyA(cwd
, CURR_DIR
);
7718 if (!is_root(CURR_DIR
)) lstrcatA(cwd
, "\\");
7720 lstrcpyA(subsrc
, cwd
);
7721 lstrcatA(subsrc
, "long");
7722 lstrcatA(subsrc
, "\\");
7724 hdb
= create_package_db();
7725 ok( hdb
, "failed to create database\n");
7727 r
= add_directory_entry(hdb
, "'TARGETDIR', '', 'SourceDir'");
7728 ok(r
== S_OK
, "failed\n");
7730 sprintf(package
, "#%u", hdb
);
7731 r
= MsiOpenPackageA(package
, &hpkg
);
7732 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
7734 skip("Not enough rights to perform tests\n");
7737 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7739 /* properties only */
7741 /* SourceDir prop */
7743 lstrcpyA(path
, "kiwi");
7744 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7745 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7746 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7747 ok(size
== 0, "Expected 0, got %d\n", size
);
7749 /* SOURCEDIR prop */
7751 lstrcpyA(path
, "kiwi");
7752 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7753 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7754 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7755 ok(size
== 0, "Expected 0, got %d\n", size
);
7757 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
7759 r
= MsiDoActionA(hpkg
, "CostInitialize");
7760 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7762 /* SourceDir after CostInitialize */
7764 lstrcpyA(path
, "kiwi");
7765 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7766 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7767 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7768 ok(size
== 0, "Expected 0, got %d\n", size
);
7770 /* SOURCEDIR after CostInitialize */
7772 lstrcpyA(path
, "kiwi");
7773 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7774 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7775 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7776 ok(size
== 0, "Expected 0, got %d\n", size
);
7778 r
= MsiDoActionA(hpkg
, "FileCost");
7779 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7781 /* SourceDir after FileCost */
7783 lstrcpyA(path
, "kiwi");
7784 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7785 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7786 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7787 ok(size
== 0, "Expected 0, got %d\n", size
);
7789 /* SOURCEDIR after FileCost */
7791 lstrcpyA(path
, "kiwi");
7792 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7793 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7794 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7795 ok(size
== 0, "Expected 0, got %d\n", size
);
7797 r
= MsiDoActionA(hpkg
, "CostFinalize");
7798 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7800 /* SourceDir after CostFinalize */
7802 lstrcpyA(path
, "kiwi");
7803 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7804 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7805 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7806 ok(size
== 0, "Expected 0, got %d\n", size
);
7808 /* SOURCEDIR after CostFinalize */
7810 lstrcpyA(path
, "kiwi");
7811 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7812 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7813 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7814 ok(size
== 0, "Expected 0, got %d\n", size
);
7817 lstrcpyA(path
, "kiwi");
7818 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
7819 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
7820 ok(!lstrcmpA(path
, "kiwi"), "Expected \"kiwi\", got \"%s\"\n", path
);
7821 ok(size
== MAX_PATH
, "Expected %d, got %d\n", MAX_PATH
, size
);
7823 /* SOURCEDIR after calling MsiGetSourcePath */
7825 lstrcpyA(path
, "kiwi");
7826 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7827 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7829 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7830 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7833 r
= MsiDoActionA(hpkg
, "ResolveSource");
7834 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7836 /* SourceDir after ResolveSource */
7838 lstrcpyA(path
, "kiwi");
7839 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7840 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7841 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7842 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7844 /* SOURCEDIR after ResolveSource */
7846 lstrcpyA(path
, "kiwi");
7847 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7848 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7849 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7850 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7854 lstrcpyA(path
, "kiwi");
7855 r
= MsiGetPropertyA(hpkg
, "SoUrCeDiR", path
, &size
);
7856 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7857 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7858 ok(size
== 0, "Expected 0, got %d\n", size
);
7860 MsiCloseHandle(hpkg
);
7862 /* reset the package state */
7863 sprintf(package
, "#%i", hdb
);
7864 r
= MsiOpenPackageA(package
, &hpkg
);
7865 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7867 /* test how MsiGetSourcePath affects the properties */
7869 /* SourceDir prop */
7871 lstrcpyA(path
, "kiwi");
7872 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7873 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7876 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7877 ok(size
== 0, "Expected 0, got %d\n", size
);
7881 lstrcpyA(path
, "kiwi");
7882 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
7883 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
7884 ok(!lstrcmpA(path
, "kiwi"),
7885 "Expected path to be unchanged, got \"%s\"\n", path
);
7886 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
7888 /* SourceDir after MsiGetSourcePath */
7890 lstrcpyA(path
, "kiwi");
7891 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7892 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7895 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7896 ok(size
== 0, "Expected 0, got %d\n", size
);
7899 /* SOURCEDIR prop */
7901 lstrcpyA(path
, "kiwi");
7902 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7903 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7906 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7907 ok(size
== 0, "Expected 0, got %d\n", size
);
7911 lstrcpyA(path
, "kiwi");
7912 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
7913 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
7914 ok(!lstrcmpA(path
, "kiwi"),
7915 "Expected path to be unchanged, got \"%s\"\n", path
);
7916 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
7918 /* SOURCEDIR prop after MsiGetSourcePath */
7920 lstrcpyA(path
, "kiwi");
7921 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7922 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7925 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7926 ok(size
== 0, "Expected 0, got %d\n", size
);
7929 r
= MsiDoActionA(hpkg
, "CostInitialize");
7930 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7932 /* SourceDir after CostInitialize */
7934 lstrcpyA(path
, "kiwi");
7935 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7936 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7939 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7940 ok(size
== 0, "Expected 0, got %d\n", size
);
7944 lstrcpyA(path
, "kiwi");
7945 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
7946 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7947 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7948 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7950 /* SourceDir after MsiGetSourcePath */
7952 lstrcpyA(path
, "kiwi");
7953 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7954 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7955 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7956 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7958 /* SOURCEDIR after CostInitialize */
7960 lstrcpyA(path
, "kiwi");
7961 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7962 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7963 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7964 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7966 /* SOURCEDIR source path still does not exist */
7968 lstrcpyA(path
, "kiwi");
7969 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
7970 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
7971 ok(!lstrcmpA(path
, "kiwi"),
7972 "Expected path to be unchanged, got \"%s\"\n", path
);
7973 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
7975 r
= MsiDoActionA(hpkg
, "FileCost");
7976 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7978 /* SourceDir after FileCost */
7980 lstrcpyA(path
, "kiwi");
7981 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7982 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7983 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7984 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7986 /* SOURCEDIR after FileCost */
7988 lstrcpyA(path
, "kiwi");
7989 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7990 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7991 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7992 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7994 /* SOURCEDIR source path still does not exist */
7996 lstrcpyA(path
, "kiwi");
7997 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
7998 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
7999 ok(!lstrcmpA(path
, "kiwi"),
8000 "Expected path to be unchanged, got \"%s\"\n", path
);
8001 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
8003 r
= MsiDoActionA(hpkg
, "CostFinalize");
8004 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
8006 /* SourceDir after CostFinalize */
8008 lstrcpyA(path
, "kiwi");
8009 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
8010 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8011 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
8012 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
8014 /* SOURCEDIR after CostFinalize */
8016 lstrcpyA(path
, "kiwi");
8017 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
8018 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8019 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
8020 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
8022 /* SOURCEDIR source path still does not exist */
8024 lstrcpyA(path
, "kiwi");
8025 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
8026 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
8027 ok(!lstrcmpA(path
, "kiwi"),
8028 "Expected path to be unchanged, got \"%s\"\n", path
);
8029 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
8031 r
= MsiDoActionA(hpkg
, "ResolveSource");
8032 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
8034 /* SourceDir after ResolveSource */
8036 lstrcpyA(path
, "kiwi");
8037 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
8038 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8039 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
8040 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
8042 /* SOURCEDIR after ResolveSource */
8044 lstrcpyA(path
, "kiwi");
8045 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
8046 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8047 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
8048 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
8050 /* SOURCEDIR source path still does not exist */
8052 lstrcpyA(path
, "kiwi");
8053 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
8054 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
8055 ok(!lstrcmpA(path
, "kiwi"),
8056 "Expected path to be unchanged, got \"%s\"\n", path
);
8057 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
8059 MsiCloseHandle(hpkg
);
8062 MsiCloseHandle(hdb
);
8063 DeleteFileA(msifile
);
8073 static const struct access_res create
[16] =
8075 { TRUE
, ERROR_SUCCESS
, TRUE
},
8076 { TRUE
, ERROR_SUCCESS
, TRUE
},
8077 { TRUE
, ERROR_SUCCESS
, FALSE
},
8078 { TRUE
, ERROR_SUCCESS
, FALSE
},
8079 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
8080 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
8081 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
8082 { TRUE
, ERROR_SUCCESS
, FALSE
},
8083 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
8084 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
8085 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
8086 { TRUE
, ERROR_SUCCESS
, TRUE
},
8087 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
8088 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
8089 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
8090 { TRUE
, ERROR_SUCCESS
, TRUE
}
8093 static const struct access_res create_commit
[16] =
8095 { TRUE
, ERROR_SUCCESS
, TRUE
},
8096 { TRUE
, ERROR_SUCCESS
, TRUE
},
8097 { TRUE
, ERROR_SUCCESS
, FALSE
},
8098 { TRUE
, ERROR_SUCCESS
, FALSE
},
8099 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
8100 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
8101 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
8102 { TRUE
, ERROR_SUCCESS
, FALSE
},
8103 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
8104 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
8105 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
8106 { TRUE
, ERROR_SUCCESS
, TRUE
},
8107 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
8108 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
8109 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
8110 { TRUE
, ERROR_SUCCESS
, TRUE
}
8113 static const struct access_res create_close
[16] =
8115 { TRUE
, ERROR_SUCCESS
, FALSE
},
8116 { TRUE
, ERROR_SUCCESS
, FALSE
},
8117 { TRUE
, ERROR_SUCCESS
, FALSE
},
8118 { TRUE
, ERROR_SUCCESS
, FALSE
},
8119 { TRUE
, ERROR_SUCCESS
, FALSE
},
8120 { TRUE
, ERROR_SUCCESS
, FALSE
},
8121 { TRUE
, ERROR_SUCCESS
, FALSE
},
8122 { TRUE
, ERROR_SUCCESS
, FALSE
},
8123 { TRUE
, ERROR_SUCCESS
, FALSE
},
8124 { TRUE
, ERROR_SUCCESS
, FALSE
},
8125 { TRUE
, ERROR_SUCCESS
, FALSE
},
8126 { TRUE
, ERROR_SUCCESS
, FALSE
},
8127 { TRUE
, ERROR_SUCCESS
, FALSE
},
8128 { TRUE
, ERROR_SUCCESS
, FALSE
},
8129 { TRUE
, ERROR_SUCCESS
, FALSE
},
8130 { TRUE
, ERROR_SUCCESS
}
8133 static void _test_file_access(LPCSTR file
, const struct access_res
*ares
, DWORD line
)
8135 DWORD access
= 0, share
= 0;
8140 for (i
= 0; i
< 4; i
++)
8142 if (i
== 0) access
= 0;
8143 if (i
== 1) access
= GENERIC_READ
;
8144 if (i
== 2) access
= GENERIC_WRITE
;
8145 if (i
== 3) access
= GENERIC_READ
| GENERIC_WRITE
;
8147 for (j
= 0; j
< 4; j
++)
8149 if (ares
[idx
].ignore
)
8152 if (j
== 0) share
= 0;
8153 if (j
== 1) share
= FILE_SHARE_READ
;
8154 if (j
== 2) share
= FILE_SHARE_WRITE
;
8155 if (j
== 3) share
= FILE_SHARE_READ
| FILE_SHARE_WRITE
;
8157 SetLastError(0xdeadbeef);
8158 hfile
= CreateFileA(file
, access
, share
, NULL
, OPEN_EXISTING
,
8159 FILE_ATTRIBUTE_NORMAL
, 0);
8160 lasterr
= GetLastError();
8162 ok((hfile
!= INVALID_HANDLE_VALUE
) == ares
[idx
].gothandle
,
8163 "(%d, handle, %d): Expected %d, got %d\n",
8164 line
, idx
, ares
[idx
].gothandle
,
8165 (hfile
!= INVALID_HANDLE_VALUE
));
8167 ok(lasterr
== ares
[idx
].lasterr
, "(%d, lasterr, %d): Expected %d, got %d\n",
8168 line
, idx
, ares
[idx
].lasterr
, lasterr
);
8176 #define test_file_access(file, ares) _test_file_access(file, ares, __LINE__)
8178 static void test_access(void)
8183 r
= MsiOpenDatabaseW(msifileW
, MSIDBOPEN_CREATE
, &hdb
);
8184 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8186 test_file_access(msifile
, create
);
8188 r
= MsiDatabaseCommit(hdb
);
8189 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8191 test_file_access(msifile
, create_commit
);
8192 MsiCloseHandle(hdb
);
8194 test_file_access(msifile
, create_close
);
8195 DeleteFileA(msifile
);
8197 r
= MsiOpenDatabaseW(msifileW
, MSIDBOPEN_CREATEDIRECT
, &hdb
);
8198 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8200 test_file_access(msifile
, create
);
8202 r
= MsiDatabaseCommit(hdb
);
8203 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8205 test_file_access(msifile
, create_commit
);
8206 MsiCloseHandle(hdb
);
8208 test_file_access(msifile
, create_close
);
8209 DeleteFileA(msifile
);
8212 static void test_emptypackage(void)
8214 MSIHANDLE hpkg
= 0, hdb
= 0, hsuminfo
= 0;
8215 MSIHANDLE hview
= 0, hrec
= 0;
8216 MSICONDITION condition
;
8217 CHAR buffer
[MAX_PATH
];
8221 r
= MsiOpenPackageA("", &hpkg
);
8222 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
8224 skip("Not enough rights to perform tests\n");
8229 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8232 hdb
= MsiGetActiveDatabase(hpkg
);
8235 ok(hdb
!= 0, "Expected a valid database handle\n");
8238 r
= MsiDatabaseOpenViewA(hdb
, "SELECT * FROM `_Tables`", &hview
);
8241 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8243 r
= MsiViewExecute(hview
, 0);
8246 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8249 r
= MsiViewFetch(hview
, &hrec
);
8252 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8257 r
= MsiRecordGetStringA(hrec
, 1, buffer
, &size
);
8260 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8261 ok(!lstrcmpA(buffer
, "_Property"),
8262 "Expected \"_Property\", got \"%s\"\n", buffer
);
8265 MsiCloseHandle(hrec
);
8267 r
= MsiViewFetch(hview
, &hrec
);
8270 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8274 r
= MsiRecordGetStringA(hrec
, 1, buffer
, &size
);
8277 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8278 ok(!lstrcmpA(buffer
, "#_FolderCache"),
8279 "Expected \"_Property\", got \"%s\"\n", buffer
);
8282 MsiCloseHandle(hrec
);
8283 MsiViewClose(hview
);
8284 MsiCloseHandle(hview
);
8286 condition
= MsiDatabaseIsTablePersistentA(hdb
, "_Property");
8289 ok(condition
== MSICONDITION_FALSE
,
8290 "Expected MSICONDITION_FALSE, got %d\n", condition
);
8293 r
= MsiDatabaseOpenViewA(hdb
, "SELECT * FROM `_Property`", &hview
);
8296 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8298 r
= MsiViewExecute(hview
, 0);
8301 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8304 /* _Property table is not empty */
8305 r
= MsiViewFetch(hview
, &hrec
);
8308 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8311 MsiCloseHandle(hrec
);
8312 MsiViewClose(hview
);
8313 MsiCloseHandle(hview
);
8315 condition
= MsiDatabaseIsTablePersistentA(hdb
, "#_FolderCache");
8318 ok(condition
== MSICONDITION_FALSE
,
8319 "Expected MSICONDITION_FALSE, got %d\n", condition
);
8322 r
= MsiDatabaseOpenViewA(hdb
, "SELECT * FROM `#_FolderCache`", &hview
);
8325 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8327 r
= MsiViewExecute(hview
, 0);
8330 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8333 /* #_FolderCache is not empty */
8334 r
= MsiViewFetch(hview
, &hrec
);
8337 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8340 MsiCloseHandle(hrec
);
8341 MsiViewClose(hview
);
8342 MsiCloseHandle(hview
);
8344 r
= MsiDatabaseOpenViewA(hdb
, "SELECT * FROM `_Streams`", &hview
);
8347 ok(r
== ERROR_BAD_QUERY_SYNTAX
,
8348 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r
);
8351 r
= MsiDatabaseOpenViewA(hdb
, "SELECT * FROM `_Storages`", &hview
);
8354 ok(r
== ERROR_BAD_QUERY_SYNTAX
,
8355 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r
);
8358 r
= MsiGetSummaryInformationA(hdb
, NULL
, 0, &hsuminfo
);
8361 ok(r
== ERROR_INSTALL_PACKAGE_INVALID
,
8362 "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r
);
8365 MsiCloseHandle(hsuminfo
);
8367 r
= MsiDatabaseCommit(hdb
);
8370 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8373 MsiCloseHandle(hdb
);
8374 MsiCloseHandle(hpkg
);
8377 static void test_MsiGetProductProperty(void)
8379 static const WCHAR prodcode_propW
[] = {'P','r','o','d','u','c','t','C','o','d','e',0};
8380 static const WCHAR nonexistentW
[] = {'I','D','o','n','t','E','x','i','s','t',0};
8381 static const WCHAR newpropW
[] = {'N','e','w','P','r','o','p','e','r','t','y',0};
8382 static const WCHAR appleW
[] = {'a','p','p','l','e',0};
8383 static const WCHAR emptyW
[] = {0};
8384 WCHAR valW
[MAX_PATH
];
8385 MSIHANDLE hprod
, hdb
;
8387 CHAR path
[MAX_PATH
];
8388 CHAR query
[MAX_PATH
];
8389 CHAR keypath
[MAX_PATH
*2];
8390 CHAR prodcode
[MAX_PATH
];
8391 WCHAR prodcodeW
[MAX_PATH
];
8392 CHAR prod_squashed
[MAX_PATH
];
8393 WCHAR prod_squashedW
[MAX_PATH
];
8394 HKEY prodkey
, userkey
, props
;
8398 REGSAM access
= KEY_ALL_ACCESS
;
8400 GetCurrentDirectoryA(MAX_PATH
, path
);
8401 lstrcatA(path
, "\\");
8403 create_test_guid(prodcode
, prod_squashed
);
8404 MultiByteToWideChar(CP_ACP
, 0, prodcode
, -1, prodcodeW
, MAX_PATH
);
8405 squash_guid(prodcodeW
, prod_squashedW
);
8408 access
|= KEY_WOW64_64KEY
;
8410 r
= MsiOpenDatabaseW(msifileW
, MSIDBOPEN_CREATE
, &hdb
);
8411 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8413 r
= MsiDatabaseCommit(hdb
);
8414 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8416 r
= set_summary_info(hdb
);
8417 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8420 "CREATE TABLE `Directory` ( "
8421 "`Directory` CHAR(255) NOT NULL, "
8422 "`Directory_Parent` CHAR(255), "
8423 "`DefaultDir` CHAR(255) NOT NULL "
8424 "PRIMARY KEY `Directory`)");
8425 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8428 "CREATE TABLE `Property` ( "
8429 "`Property` CHAR(72) NOT NULL, "
8430 "`Value` CHAR(255) "
8431 "PRIMARY KEY `Property`)");
8432 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8434 sprintf(query
, "INSERT INTO `Property` "
8435 "(`Property`, `Value`) "
8436 "VALUES( 'ProductCode', '%s' )", prodcode
);
8437 r
= run_query(hdb
, query
);
8438 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8440 r
= MsiDatabaseCommit(hdb
);
8441 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8443 MsiCloseHandle(hdb
);
8445 lstrcpyA(keypath
, "Software\\Classes\\Installer\\Products\\");
8446 lstrcatA(keypath
, prod_squashed
);
8448 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
8449 if (res
== ERROR_ACCESS_DENIED
)
8451 skip("Not enough rights to perform tests\n");
8452 DeleteFileA(msifile
);
8455 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8457 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
8458 lstrcatA(keypath
, "Installer\\UserData\\S-1-5-18\\Products\\");
8459 lstrcatA(keypath
, prod_squashed
);
8461 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &userkey
, NULL
);
8462 if (res
== ERROR_ACCESS_DENIED
)
8464 skip("Not enough rights to perform tests\n");
8465 RegDeleteKeyA(prodkey
, "");
8466 RegCloseKey(prodkey
);
8469 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8471 res
= RegCreateKeyExA(userkey
, "InstallProperties", 0, NULL
, 0, access
, NULL
, &props
, NULL
);
8472 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8474 lstrcpyA(val
, path
);
8475 lstrcatA(val
, "\\");
8476 lstrcatA(val
, msifile
);
8477 res
= RegSetValueExA(props
, "LocalPackage", 0, REG_SZ
,
8478 (const BYTE
*)val
, lstrlenA(val
) + 1);
8479 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8482 r
= MsiOpenProductA(prodcode
, &hprod
);
8483 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8484 ok(hprod
!= 0 && hprod
!= 0xdeadbeef, "Expected a valid product handle\n");
8486 /* hProduct is invalid */
8488 lstrcpyA(val
, "apple");
8489 r
= MsiGetProductPropertyA(0xdeadbeef, "ProductCode", val
, &size
);
8490 ok(r
== ERROR_INVALID_HANDLE
,
8491 "Expected ERROR_INVALID_HANDLE, got %d\n", r
);
8492 ok(!lstrcmpA(val
, "apple"),
8493 "Expected val to be unchanged, got \"%s\"\n", val
);
8494 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
8497 lstrcpyW(valW
, appleW
);
8498 r
= MsiGetProductPropertyW(0xdeadbeef, prodcode_propW
, valW
, &size
);
8499 ok(r
== ERROR_INVALID_HANDLE
,
8500 "Expected ERROR_INVALID_HANDLE, got %d\n", r
);
8501 ok(!lstrcmpW(valW
, appleW
),
8502 "Expected val to be unchanged, got %s\n", wine_dbgstr_w(valW
));
8503 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
8505 /* szProperty is NULL */
8507 lstrcpyA(val
, "apple");
8508 r
= MsiGetProductPropertyA(hprod
, NULL
, val
, &size
);
8509 ok(r
== ERROR_INVALID_PARAMETER
,
8510 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
8511 ok(!lstrcmpA(val
, "apple"),
8512 "Expected val to be unchanged, got \"%s\"\n", val
);
8513 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
8516 lstrcpyW(valW
, appleW
);
8517 r
= MsiGetProductPropertyW(hprod
, NULL
, valW
, &size
);
8518 ok(r
== ERROR_INVALID_PARAMETER
,
8519 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
8520 ok(!lstrcmpW(valW
, appleW
),
8521 "Expected val to be unchanged, got %s\n", wine_dbgstr_w(valW
));
8522 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
8524 /* szProperty is empty */
8526 lstrcpyA(val
, "apple");
8527 r
= MsiGetProductPropertyA(hprod
, "", val
, &size
);
8528 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8529 ok(!lstrcmpA(val
, ""), "Expected \"\", got \"%s\"\n", val
);
8530 ok(size
== 0, "Expected 0, got %d\n", size
);
8533 lstrcpyW(valW
, appleW
);
8534 r
= MsiGetProductPropertyW(hprod
, emptyW
, valW
, &size
);
8535 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8536 ok(*valW
== 0, "Expected \"\", got %s\n", wine_dbgstr_w(valW
));
8537 ok(size
== 0, "Expected 0, got %d\n", size
);
8539 /* get the property */
8541 lstrcpyA(val
, "apple");
8542 r
= MsiGetProductPropertyA(hprod
, "ProductCode", val
, &size
);
8543 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8544 ok(!lstrcmpA(val
, prodcode
),
8545 "Expected \"%s\", got \"%s\"\n", prodcode
, val
);
8546 ok(size
== lstrlenA(prodcode
),
8547 "Expected %d, got %d\n", lstrlenA(prodcode
), size
);
8550 lstrcpyW(valW
, appleW
);
8551 r
= MsiGetProductPropertyW(hprod
, prodcode_propW
, valW
, &size
);
8552 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8553 ok(!lstrcmpW(valW
, prodcodeW
),
8554 "Expected %s, got %s\n", wine_dbgstr_w(prodcodeW
), wine_dbgstr_w(valW
));
8555 ok(size
== lstrlenW(prodcodeW
),
8556 "Expected %d, got %d\n", lstrlenW(prodcodeW
), size
);
8558 /* lpValueBuf is NULL */
8560 r
= MsiGetProductPropertyA(hprod
, "ProductCode", NULL
, &size
);
8561 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8562 ok(size
== lstrlenA(prodcode
),
8563 "Expected %d, got %d\n", lstrlenA(prodcode
), size
);
8566 r
= MsiGetProductPropertyW(hprod
, prodcode_propW
, NULL
, &size
);
8567 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8568 ok(size
== lstrlenW(prodcodeW
),
8569 "Expected %d, got %d\n", lstrlenW(prodcodeW
), size
);
8571 /* pcchValueBuf is NULL */
8572 lstrcpyA(val
, "apple");
8573 r
= MsiGetProductPropertyA(hprod
, "ProductCode", val
, NULL
);
8574 ok(r
== ERROR_INVALID_PARAMETER
,
8575 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
8576 ok(!lstrcmpA(val
, "apple"),
8577 "Expected val to be unchanged, got \"%s\"\n", val
);
8578 ok(size
== lstrlenA(prodcode
),
8579 "Expected %d, got %d\n", lstrlenA(prodcode
), size
);
8581 lstrcpyW(valW
, appleW
);
8582 r
= MsiGetProductPropertyW(hprod
, prodcode_propW
, valW
, NULL
);
8583 ok(r
== ERROR_INVALID_PARAMETER
,
8584 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
8585 ok(!lstrcmpW(valW
, appleW
),
8586 "Expected val to be unchanged, got %s\n", wine_dbgstr_w(valW
));
8587 ok(size
== lstrlenW(prodcodeW
),
8588 "Expected %d, got %d\n", lstrlenW(prodcodeW
), size
);
8590 /* pcchValueBuf is too small */
8592 lstrcpyA(val
, "apple");
8593 r
= MsiGetProductPropertyA(hprod
, "ProductCode", val
, &size
);
8594 ok(r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
8595 ok(!strncmp(val
, prodcode
, 3),
8596 "Expected first 3 chars of \"%s\", got \"%s\"\n", prodcode
, val
);
8597 ok(size
== lstrlenA(prodcode
),
8598 "Expected %d, got %d\n", lstrlenA(prodcode
), size
);
8601 lstrcpyW(valW
, appleW
);
8602 r
= MsiGetProductPropertyW(hprod
, prodcode_propW
, valW
, &size
);
8603 ok(r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
8604 ok(!memcmp(valW
, prodcodeW
, 3 * sizeof(WCHAR
)),
8605 "Expected first 3 chars of %s, got %s\n", wine_dbgstr_w(prodcodeW
), wine_dbgstr_w(valW
));
8606 ok(size
== lstrlenW(prodcodeW
),
8607 "Expected %d, got %d\n", lstrlenW(prodcodeW
), size
);
8609 /* pcchValueBuf does not leave room for NULL terminator */
8610 size
= lstrlenA(prodcode
);
8611 lstrcpyA(val
, "apple");
8612 r
= MsiGetProductPropertyA(hprod
, "ProductCode", val
, &size
);
8613 ok(r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
8614 ok(!strncmp(val
, prodcode
, lstrlenA(prodcode
) - 1),
8615 "Expected first 37 chars of \"%s\", got \"%s\"\n", prodcode
, val
);
8616 ok(size
== lstrlenA(prodcode
),
8617 "Expected %d, got %d\n", lstrlenA(prodcode
), size
);
8619 size
= lstrlenW(prodcodeW
);
8620 lstrcpyW(valW
, appleW
);
8621 r
= MsiGetProductPropertyW(hprod
, prodcode_propW
, valW
, &size
);
8622 ok(r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
8623 ok(!memcmp(valW
, prodcodeW
, lstrlenW(prodcodeW
) - 1),
8624 "Expected first 37 chars of %s, got %s\n", wine_dbgstr_w(prodcodeW
), wine_dbgstr_w(valW
));
8625 ok(size
== lstrlenW(prodcodeW
),
8626 "Expected %d, got %d\n", lstrlenW(prodcodeW
), size
);
8628 /* pcchValueBuf has enough room for NULL terminator */
8629 size
= lstrlenA(prodcode
) + 1;
8630 lstrcpyA(val
, "apple");
8631 r
= MsiGetProductPropertyA(hprod
, "ProductCode", val
, &size
);
8632 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8633 ok(!lstrcmpA(val
, prodcode
),
8634 "Expected \"%s\", got \"%s\"\n", prodcode
, val
);
8635 ok(size
== lstrlenA(prodcode
),
8636 "Expected %d, got %d\n", lstrlenA(prodcode
), size
);
8638 size
= lstrlenW(prodcodeW
) + 1;
8639 lstrcpyW(valW
, appleW
);
8640 r
= MsiGetProductPropertyW(hprod
, prodcode_propW
, valW
, &size
);
8641 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8642 ok(!lstrcmpW(valW
, prodcodeW
),
8643 "Expected %s, got %s\n", wine_dbgstr_w(prodcodeW
), wine_dbgstr_w(valW
));
8644 ok(size
== lstrlenW(prodcodeW
),
8645 "Expected %d, got %d\n", lstrlenW(prodcodeW
), size
);
8647 /* nonexistent property */
8649 lstrcpyA(val
, "apple");
8650 r
= MsiGetProductPropertyA(hprod
, "IDontExist", val
, &size
);
8651 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8652 ok(!lstrcmpA(val
, ""), "Expected \"\", got \"%s\"\n", val
);
8653 ok(size
== 0, "Expected 0, got %d\n", size
);
8656 lstrcpyW(valW
, appleW
);
8657 r
= MsiGetProductPropertyW(hprod
, nonexistentW
, valW
, &size
);
8658 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8659 ok(!lstrcmpW(valW
, emptyW
), "Expected \"\", got %s\n", wine_dbgstr_w(valW
));
8660 ok(size
== 0, "Expected 0, got %d\n", size
);
8662 r
= MsiSetPropertyA(hprod
, "NewProperty", "value");
8663 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8665 /* non-product property set */
8667 lstrcpyA(val
, "apple");
8668 r
= MsiGetProductPropertyA(hprod
, "NewProperty", val
, &size
);
8669 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8670 ok(!lstrcmpA(val
, ""), "Expected \"\", got \"%s\"\n", val
);
8671 ok(size
== 0, "Expected 0, got %d\n", size
);
8674 lstrcpyW(valW
, appleW
);
8675 r
= MsiGetProductPropertyW(hprod
, newpropW
, valW
, &size
);
8676 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8677 ok(!lstrcmpW(valW
, emptyW
), "Expected \"\", got %s\n", wine_dbgstr_w(valW
));
8678 ok(size
== 0, "Expected 0, got %d\n", size
);
8680 r
= MsiSetPropertyA(hprod
, "ProductCode", "value");
8681 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8683 /* non-product property that is also a product property set */
8685 lstrcpyA(val
, "apple");
8686 r
= MsiGetProductPropertyA(hprod
, "ProductCode", val
, &size
);
8687 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8688 ok(!lstrcmpA(val
, prodcode
),
8689 "Expected \"%s\", got \"%s\"\n", prodcode
, val
);
8690 ok(size
== lstrlenA(prodcode
),
8691 "Expected %d, got %d\n", lstrlenA(prodcode
), size
);
8694 lstrcpyW(valW
, appleW
);
8695 r
= MsiGetProductPropertyW(hprod
, prodcode_propW
, valW
, &size
);
8696 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8697 ok(!lstrcmpW(valW
, prodcodeW
),
8698 "Expected %s, got %s\n", wine_dbgstr_w(prodcodeW
), wine_dbgstr_w(valW
));
8699 ok(size
== lstrlenW(prodcodeW
),
8700 "Expected %d, got %d\n", lstrlenW(prodcodeW
), size
);
8702 MsiCloseHandle(hprod
);
8704 RegDeleteValueA(props
, "LocalPackage");
8705 delete_key(props
, "", access
);
8707 delete_key(userkey
, "", access
);
8708 RegCloseKey(userkey
);
8709 delete_key(prodkey
, "", access
);
8710 RegCloseKey(prodkey
);
8711 DeleteFileA(msifile
);
8714 static void test_MsiSetProperty(void)
8716 MSIHANDLE hpkg
, hdb
, hrec
;
8722 r
= package_from_db(create_package_db(), &hpkg
);
8723 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
8725 skip("Not enough rights to perform tests\n");
8726 DeleteFileA(msifile
);
8729 ok(r
== ERROR_SUCCESS
, "Expected a valid package %u\n", r
);
8731 /* invalid hInstall */
8732 r
= MsiSetPropertyA(0, "Prop", "Val");
8733 ok(r
== ERROR_INVALID_HANDLE
,
8734 "Expected ERROR_INVALID_HANDLE, got %d\n", r
);
8736 /* invalid hInstall */
8737 r
= MsiSetPropertyA(0xdeadbeef, "Prop", "Val");
8738 ok(r
== ERROR_INVALID_HANDLE
,
8739 "Expected ERROR_INVALID_HANDLE, got %d\n", r
);
8741 /* szName is NULL */
8742 r
= MsiSetPropertyA(hpkg
, NULL
, "Val");
8743 ok(r
== ERROR_INVALID_PARAMETER
,
8744 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
8746 /* both szName and szValue are NULL */
8747 r
= MsiSetPropertyA(hpkg
, NULL
, NULL
);
8748 ok(r
== ERROR_INVALID_PARAMETER
,
8749 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
8751 /* szName is empty */
8752 r
= MsiSetPropertyA(hpkg
, "", "Val");
8753 ok(r
== ERROR_FUNCTION_FAILED
,
8754 "Expected ERROR_FUNCTION_FAILED, got %d\n", r
);
8756 /* szName is empty and szValue is NULL */
8757 r
= MsiSetPropertyA(hpkg
, "", NULL
);
8758 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8760 /* set a property */
8761 r
= MsiSetPropertyA(hpkg
, "Prop", "Val");
8762 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8764 /* get the property */
8766 r
= MsiGetPropertyA(hpkg
, "Prop", buf
, &size
);
8767 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8768 ok(!lstrcmpA(buf
, "Val"), "Expected \"Val\", got \"%s\"\n", buf
);
8769 ok(size
== 3, "Expected 3, got %d\n", size
);
8771 /* update the property */
8772 r
= MsiSetPropertyA(hpkg
, "Prop", "Nuvo");
8773 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8775 /* get the property */
8777 r
= MsiGetPropertyA(hpkg
, "Prop", buf
, &size
);
8778 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8779 ok(!lstrcmpA(buf
, "Nuvo"), "Expected \"Nuvo\", got \"%s\"\n", buf
);
8780 ok(size
== 4, "Expected 4, got %d\n", size
);
8782 hdb
= MsiGetActiveDatabase(hpkg
);
8783 ok(hdb
!= 0, "Expected a valid database handle\n");
8785 /* set prop is not in the _Property table */
8786 query
= "SELECT * FROM `_Property` WHERE `Property` = 'Prop'";
8787 r
= do_query(hdb
, query
, &hrec
);
8788 ok(r
== ERROR_BAD_QUERY_SYNTAX
,
8789 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r
);
8791 /* set prop is not in the Property table */
8792 query
= "SELECT * FROM `Property` WHERE `Property` = 'Prop'";
8793 r
= do_query(hdb
, query
, &hrec
);
8794 ok(r
== ERROR_BAD_QUERY_SYNTAX
,
8795 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r
);
8797 MsiCloseHandle(hdb
);
8799 /* szValue is an empty string */
8800 r
= MsiSetPropertyA(hpkg
, "Prop", "");
8801 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8803 /* try to get the property */
8805 r
= MsiGetPropertyA(hpkg
, "Prop", buf
, &size
);
8806 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8807 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
8808 ok(size
== 0, "Expected 0, got %d\n", size
);
8810 /* reset the property */
8811 r
= MsiSetPropertyA(hpkg
, "Prop", "BlueTap");
8812 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8814 /* delete the property */
8815 r
= MsiSetPropertyA(hpkg
, "Prop", NULL
);
8816 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8818 /* try to get the property */
8820 r
= MsiGetPropertyA(hpkg
, "Prop", buf
, &size
);
8821 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8822 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
8823 ok(size
== 0, "Expected 0, got %d\n", size
);
8825 MsiCloseHandle(hpkg
);
8826 DeleteFileA(msifile
);
8829 static void test_MsiApplyMultiplePatches(void)
8831 UINT r
, type
= GetDriveTypeW(NULL
);
8833 r
= MsiApplyMultiplePatchesA(NULL
, NULL
, NULL
);
8834 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8836 r
= MsiApplyMultiplePatchesA("", NULL
, NULL
);
8837 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8839 r
= MsiApplyMultiplePatchesA(";", NULL
, NULL
);
8840 if (type
== DRIVE_FIXED
)
8841 todo_wine
ok(r
== ERROR_PATH_NOT_FOUND
, "Expected ERROR_PATH_NOT_FOUND, got %u\n", r
);
8843 ok(r
== ERROR_INVALID_NAME
, "Expected ERROR_INVALID_NAME, got %u\n", r
);
8845 r
= MsiApplyMultiplePatchesA(" ;", NULL
, NULL
);
8846 if (type
== DRIVE_FIXED
)
8847 todo_wine
ok(r
== ERROR_PATCH_PACKAGE_OPEN_FAILED
, "Expected ERROR_PATCH_PACKAGE_OPEN_FAILED, got %u\n", r
);
8849 ok(r
== ERROR_INVALID_NAME
, "Expected ERROR_INVALID_NAME, got %u\n", r
);
8851 r
= MsiApplyMultiplePatchesA(";;", NULL
, NULL
);
8852 if (type
== DRIVE_FIXED
)
8853 todo_wine
ok(r
== ERROR_PATH_NOT_FOUND
, "Expected ERROR_PATH_NOT_FOUND, got %u\n", r
);
8855 ok(r
== ERROR_INVALID_NAME
, "Expected ERROR_INVALID_NAME, got %u\n", r
);
8857 r
= MsiApplyMultiplePatchesA("nosuchpatchpackage;", NULL
, NULL
);
8858 todo_wine
ok(r
== ERROR_FILE_NOT_FOUND
, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r
);
8860 r
= MsiApplyMultiplePatchesA(";nosuchpatchpackage", NULL
, NULL
);
8861 if (type
== DRIVE_FIXED
)
8862 todo_wine
ok(r
== ERROR_PATH_NOT_FOUND
, "Expected ERROR_PATH_NOT_FOUND, got %u\n", r
);
8864 ok(r
== ERROR_INVALID_NAME
, "Expected ERROR_INVALID_NAME, got %u\n", r
);
8866 r
= MsiApplyMultiplePatchesA("nosuchpatchpackage;nosuchpatchpackage", NULL
, NULL
);
8867 todo_wine
ok(r
== ERROR_FILE_NOT_FOUND
, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r
);
8869 r
= MsiApplyMultiplePatchesA(" nosuchpatchpackage ; nosuchpatchpackage ", NULL
, NULL
);
8870 todo_wine
ok(r
== ERROR_FILE_NOT_FOUND
, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r
);
8873 static void test_MsiApplyPatch(void)
8877 r
= MsiApplyPatchA(NULL
, NULL
, INSTALLTYPE_DEFAULT
, NULL
);
8878 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8880 r
= MsiApplyPatchA("", NULL
, INSTALLTYPE_DEFAULT
, NULL
);
8881 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8884 static void test_MsiEnumComponentCosts(void)
8886 MSIHANDLE hdb
, hpkg
;
8887 char package
[12], drive
[3];
8892 hdb
= create_package_db();
8893 ok( hdb
, "failed to create database\n" );
8895 r
= create_property_table( hdb
);
8896 ok( r
== ERROR_SUCCESS
, "cannot create Property table %u\n", r
);
8898 r
= add_property_entry( hdb
, "'ProductCode', '{379B1C47-40C1-42FA-A9BB-BEBB6F1B0172}'" );
8899 ok( r
== ERROR_SUCCESS
, "cannot add property entry %u\n", r
);
8901 r
= add_property_entry( hdb
, "'MSIFASTINSTALL', '1'" );
8902 ok( r
== ERROR_SUCCESS
, "cannot add property entry %u\n", r
);
8904 r
= add_directory_entry( hdb
, "'TARGETDIR', '', 'SourceDir'" );
8905 ok( r
== ERROR_SUCCESS
, "failed to add directory entry %u\n" , r
);
8907 r
= create_media_table( hdb
);
8908 ok( r
== ERROR_SUCCESS
, "cannot create Media table %u\n", r
);
8910 r
= add_media_entry( hdb
, "'1', '2', 'cabinet', '', '', ''");
8911 ok( r
== ERROR_SUCCESS
, "cannot add media entry %u\n", r
);
8913 r
= create_file_table( hdb
);
8914 ok( r
== ERROR_SUCCESS
, "cannot create File table %u\n", r
);
8916 r
= add_file_entry( hdb
, "'one.txt', 'one', 'one.txt', 4096, '', '', 8192, 1" );
8917 ok( r
== ERROR_SUCCESS
, "cannot add file %u\n", r
);
8919 r
= create_component_table( hdb
);
8920 ok( r
== ERROR_SUCCESS
, "cannot create Component table %u\n", r
);
8922 r
= add_component_entry( hdb
, "'one', '{B2F86B9D-8447-4BC5-8883-750C45AA31CA}', 'TARGETDIR', 0, '', 'one.txt'" );
8923 ok( r
== ERROR_SUCCESS
, "cannot add component %u\n", r
);
8925 r
= add_component_entry( hdb
, "'two', '{62A09F6E-0B74-4829-BDB7-CAB66F42CCE8}', 'TARGETDIR', 0, '', ''" );
8926 ok( r
== ERROR_SUCCESS
, "cannot add component %u\n", r
);
8928 r
= create_feature_table( hdb
);
8929 ok( r
== ERROR_SUCCESS
, "cannot create Feature table %u\n", r
);
8931 r
= add_feature_entry( hdb
, "'one', '', '', '', 0, 1, '', 0" );
8932 ok( r
== ERROR_SUCCESS
, "cannot add feature %u\n", r
);
8934 r
= add_feature_entry( hdb
, "'two', '', '', '', 0, 1, '', 0" );
8935 ok( r
== ERROR_SUCCESS
, "cannot add feature %u\n", r
);
8937 r
= create_feature_components_table( hdb
);
8938 ok( r
== ERROR_SUCCESS
, "cannot create FeatureComponents table %u\n", r
);
8940 r
= add_feature_components_entry( hdb
, "'one', 'one'" );
8941 ok( r
== ERROR_SUCCESS
, "cannot add feature/component pair %u\n", r
);
8943 r
= add_feature_components_entry( hdb
, "'two', 'two'" );
8944 ok( r
== ERROR_SUCCESS
, "cannot add feature/component pair %u\n", r
);
8946 r
= create_install_execute_sequence_table( hdb
);
8947 ok( r
== ERROR_SUCCESS
, "cannot create InstallExecuteSequence table %u\n", r
);
8949 r
= add_install_execute_sequence_entry( hdb
, "'CostInitialize', '', '800'" );
8950 ok( r
== ERROR_SUCCESS
, "cannot add install execute sequence entry %u\n", r
);
8952 r
= add_install_execute_sequence_entry( hdb
, "'FileCost', '', '900'" );
8953 ok( r
== ERROR_SUCCESS
, "cannot add install execute sequence entry %u\n", r
);
8955 r
= add_install_execute_sequence_entry( hdb
, "'CostFinalize', '', '1000'" );
8956 ok( r
== ERROR_SUCCESS
, "cannot add install execute sequence entry %u\n", r
);
8958 r
= add_install_execute_sequence_entry( hdb
, "'InstallValidate', '', '1100'" );
8959 ok( r
== ERROR_SUCCESS
, "cannot add install execute sequence entry %u\n", r
);
8961 MsiDatabaseCommit( hdb
);
8963 sprintf( package
, "#%u", hdb
);
8964 r
= MsiOpenPackageA( package
, &hpkg
);
8965 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
8967 skip("Not enough rights to perform tests\n");
8970 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
8972 r
= MsiEnumComponentCostsA( 0, NULL
, 0, INSTALLSTATE_UNKNOWN
, NULL
, NULL
, NULL
, NULL
);
8973 ok( r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8975 r
= MsiEnumComponentCostsA( hpkg
, NULL
, 0, INSTALLSTATE_UNKNOWN
, NULL
, NULL
, NULL
, NULL
);
8976 ok( r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8978 r
= MsiEnumComponentCostsA( hpkg
, NULL
, 0, INSTALLSTATE_UNKNOWN
, NULL
, NULL
, NULL
, NULL
);
8979 ok( r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8981 r
= MsiEnumComponentCostsA( hpkg
, "", 0, INSTALLSTATE_UNKNOWN
, NULL
, NULL
, NULL
, NULL
);
8982 ok( r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8984 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_UNKNOWN
, NULL
, NULL
, NULL
, NULL
);
8985 ok( r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8987 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, NULL
, NULL
, NULL
, NULL
);
8988 ok( r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8990 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, drive
, NULL
, NULL
, NULL
);
8991 ok( r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8993 len
= sizeof(drive
);
8994 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, drive
, &len
, NULL
, NULL
);
8995 ok( r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8997 len
= sizeof(drive
);
8998 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, drive
, &len
, &cost
, NULL
);
8999 ok( r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
9001 len
= sizeof(drive
);
9002 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, drive
, &len
, &cost
, &temp
);
9003 todo_wine
ok( r
== ERROR_INVALID_HANDLE_STATE
, "Expected ERROR_INVALID_HANDLE_STATE, got %u\n", r
);
9005 len
= sizeof(drive
);
9006 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, NULL
, &len
, &cost
, &temp
);
9007 ok( r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
9009 MsiSetInternalUI( INSTALLUILEVEL_NONE
, NULL
);
9011 r
= MsiDoActionA( hpkg
, "CostInitialize" );
9012 ok( r
== ERROR_SUCCESS
, "CostInitialize failed %u\n", r
);
9014 r
= MsiDoActionA( hpkg
, "FileCost" );
9015 ok( r
== ERROR_SUCCESS
, "FileCost failed %u\n", r
);
9017 len
= sizeof(drive
);
9018 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, drive
, &len
, &cost
, &temp
);
9019 ok( r
== ERROR_FUNCTION_NOT_CALLED
, "Expected ERROR_FUNCTION_NOT_CALLED, got %u\n", r
);
9021 r
= MsiDoActionA( hpkg
, "CostFinalize" );
9022 ok( r
== ERROR_SUCCESS
, "CostFinalize failed %u\n", r
);
9024 /* contrary to what msdn says InstallValidate must be called too */
9025 len
= sizeof(drive
);
9026 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, drive
, &len
, &cost
, &temp
);
9027 todo_wine
ok( r
== ERROR_FUNCTION_NOT_CALLED
, "Expected ERROR_FUNCTION_NOT_CALLED, got %u\n", r
);
9029 r
= MsiDoActionA( hpkg
, "InstallValidate" );
9030 ok( r
== ERROR_SUCCESS
, "InstallValidate failed %u\n", r
);
9033 r
= MsiEnumComponentCostsA( hpkg
, "three", 0, INSTALLSTATE_LOCAL
, drive
, &len
, &cost
, &temp
);
9034 ok( r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %u\n", r
);
9037 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, drive
, &len
, &cost
, &temp
);
9038 ok( r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %u\n", r
);
9039 ok( len
== 2, "expected len == 2, got %u\n", len
);
9042 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, drive
, &len
, &cost
, &temp
);
9043 ok( r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %u\n", r
);
9044 ok( len
== 2, "expected len == 2, got %u\n", len
);
9047 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_UNKNOWN
, drive
, &len
, &cost
, &temp
);
9048 ok( r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %u\n", r
);
9049 ok( len
== 2, "expected len == 2, got %u\n", len
);
9051 /* install state doesn't seem to matter */
9052 len
= sizeof(drive
);
9053 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_UNKNOWN
, drive
, &len
, &cost
, &temp
);
9054 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
9056 len
= sizeof(drive
);
9057 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_ABSENT
, drive
, &len
, &cost
, &temp
);
9058 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
9060 len
= sizeof(drive
);
9061 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_SOURCE
, drive
, &len
, &cost
, &temp
);
9062 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
9064 len
= sizeof(drive
);
9066 cost
= temp
= 0xdead;
9067 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, drive
, &len
, &cost
, &temp
);
9068 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
9069 ok( len
== 2, "expected len == 2, got %u\n", len
);
9070 ok( drive
[0], "expected a drive\n" );
9071 ok( cost
&& cost
!= 0xdead, "expected cost > 0, got %d\n", cost
);
9072 ok( !temp
, "expected temp == 0, got %d\n", temp
);
9074 len
= sizeof(drive
);
9076 cost
= temp
= 0xdead;
9077 r
= MsiEnumComponentCostsA( hpkg
, "two", 0, INSTALLSTATE_LOCAL
, drive
, &len
, &cost
, &temp
);
9078 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
9079 ok( len
== 2, "expected len == 2, got %u\n", len
);
9080 ok( drive
[0], "expected a drive\n" );
9081 ok( !cost
, "expected cost == 0, got %d\n", cost
);
9082 ok( !temp
, "expected temp == 0, got %d\n", temp
);
9084 len
= sizeof(drive
);
9086 cost
= temp
= 0xdead;
9087 r
= MsiEnumComponentCostsA( hpkg
, "", 0, INSTALLSTATE_UNKNOWN
, drive
, &len
, &cost
, &temp
);
9088 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
9089 ok( len
== 2, "expected len == 2, got %u\n", len
);
9090 ok( drive
[0], "expected a drive\n" );
9091 ok( !cost
, "expected cost == 0, got %d\n", cost
);
9092 ok( temp
&& temp
!= 0xdead, "expected temp > 0, got %d\n", temp
);
9094 /* increased index */
9095 len
= sizeof(drive
);
9096 r
= MsiEnumComponentCostsA( hpkg
, "one", 1, INSTALLSTATE_LOCAL
, drive
, &len
, &cost
, &temp
);
9097 ok( r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %u\n", r
);
9099 len
= sizeof(drive
);
9100 r
= MsiEnumComponentCostsA( hpkg
, "", 1, INSTALLSTATE_UNKNOWN
, drive
, &len
, &cost
, &temp
);
9101 ok( r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %u\n", r
);
9103 MsiCloseHandle( hpkg
);
9105 MsiCloseHandle( hdb
);
9106 DeleteFileA( msifile
);
9109 static void test_MsiDatabaseCommit(void)
9112 MSIHANDLE hdb
, hpkg
= 0;
9113 char buf
[32], package
[12];
9116 hdb
= create_package_db();
9117 ok( hdb
, "failed to create database\n" );
9119 r
= create_property_table( hdb
);
9120 ok( r
== ERROR_SUCCESS
, "can't create Property table %u\n", r
);
9122 sprintf( package
, "#%u", hdb
);
9123 r
= MsiOpenPackageA( package
, &hpkg
);
9124 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
9126 skip("Not enough rights to perform tests\n");
9129 ok( r
== ERROR_SUCCESS
, "got %u\n", r
);
9131 r
= MsiSetPropertyA( hpkg
, "PROP", "value" );
9132 ok( r
== ERROR_SUCCESS
, "got %u\n", r
);
9136 r
= MsiGetPropertyA( hpkg
, "PROP", buf
, &sz
);
9137 ok( r
== ERROR_SUCCESS
, "MsiGetPropertyA returned %u\n", r
);
9138 ok( !lstrcmpA( buf
, "value" ), "got \"%s\"\n", buf
);
9140 r
= MsiDatabaseCommit( hdb
);
9141 ok( r
== ERROR_SUCCESS
, "MsiDatabaseCommit returned %u\n", r
);
9145 r
= MsiGetPropertyA( hpkg
, "PROP", buf
, &sz
);
9146 ok( r
== ERROR_SUCCESS
, "MsiGetPropertyA returned %u\n", r
);
9147 ok( !lstrcmpA( buf
, "value" ), "got \"%s\"\n", buf
);
9149 MsiCloseHandle( hpkg
);
9151 MsiCloseHandle( hdb
);
9152 DeleteFileA( msifile
);
9155 static int externalui_ran
;
9157 static INT CALLBACK
externalui_callback(void *context
, UINT message_type
, LPCSTR message
)
9160 ok(message_type
== INSTALLMESSAGE_USER
, "expected INSTALLMESSAGE_USER, got %08x\n", message_type
);
9164 static int externalui_record_ran
;
9166 static INT CALLBACK
externalui_record_callback(void *context
, UINT message_type
, MSIHANDLE hrecord
)
9168 INT retval
= context
? *((INT
*)context
) : 0;
9170 externalui_record_ran
= 1;
9171 ok(message_type
== INSTALLMESSAGE_USER
, "expected INSTALLMESSAGE_USER, got %08x\n", message_type
);
9172 r
= MsiRecordGetFieldCount(hrecord
);
9173 ok(r
== 1, "expected 1, got %u\n", r
);
9174 r
= MsiRecordGetInteger(hrecord
, 1);
9175 ok(r
== 12345, "expected 12345, got %u\n", r
);
9179 static void test_externalui(void)
9181 /* test that external UI handlers work correctly */
9183 INSTALLUI_HANDLERA prev
;
9184 INSTALLUI_HANDLER_RECORD prev_record
;
9185 MSIHANDLE hpkg
, hrecord
;
9189 prev
= MsiSetExternalUIA(externalui_callback
, INSTALLLOGMODE_USER
, NULL
);
9191 r
= package_from_db(create_package_db(), &hpkg
);
9192 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
9194 skip("Not enough rights to perform tests\n");
9195 DeleteFileA(msifile
);
9198 ok(r
== ERROR_SUCCESS
, "Expected a valid package %u\n", r
);
9200 hrecord
= MsiCreateRecord(1);
9201 ok(hrecord
, "Expected a valid record\n");
9202 r
= MsiRecordSetStringA(hrecord
, 0, "test message [1]");
9203 ok(r
== ERROR_SUCCESS
, "MsiSetString failed %u\n", r
);
9204 r
= MsiRecordSetInteger(hrecord
, 1, 12345);
9205 ok(r
== ERROR_SUCCESS
, "MsiSetInteger failed %u\n", r
);
9208 r
= MsiProcessMessage(hpkg
, INSTALLMESSAGE_USER
, hrecord
);
9209 ok(r
== 0, "expected 0, got %u\n", r
);
9210 ok(externalui_ran
== 1, "external UI callback did not run\n");
9212 prev
= MsiSetExternalUIA(prev
, 0, NULL
);
9213 ok(prev
== externalui_callback
, "wrong callback function %p\n", prev
);
9214 r
= MsiSetExternalUIRecord(externalui_record_callback
, INSTALLLOGMODE_USER
, &retval
, &prev_record
);
9215 ok(r
== ERROR_SUCCESS
, "MsiSetExternalUIRecord failed %u\n", r
);
9217 externalui_ran
= externalui_record_ran
= 0;
9218 r
= MsiProcessMessage(hpkg
, INSTALLMESSAGE_USER
, hrecord
);
9219 ok(r
== 0, "expected 0, got %u\n", r
);
9220 ok(externalui_ran
== 0, "external UI callback should not have run\n");
9221 ok(externalui_record_ran
== 1, "external UI record callback did not run\n");
9223 MsiSetExternalUIA(externalui_callback
, INSTALLLOGMODE_USER
, NULL
);
9225 externalui_ran
= externalui_record_ran
= 0;
9226 r
= MsiProcessMessage(hpkg
, INSTALLMESSAGE_USER
, hrecord
);
9227 ok(r
== 0, "expected 0, got %u\n", r
);
9228 ok(externalui_ran
== 1, "external UI callback did not run\n");
9229 ok(externalui_record_ran
== 1, "external UI record callback did not run\n");
9232 externalui_ran
= externalui_record_ran
= 0;
9233 r
= MsiProcessMessage(hpkg
, INSTALLMESSAGE_USER
, hrecord
);
9234 ok(r
== 1, "expected 1, got %u\n", r
);
9235 ok(externalui_ran
== 0, "external UI callback should not have run\n");
9236 ok(externalui_record_ran
== 1, "external UI record callback did not run\n");
9238 /* filter and context should be kept separately */
9239 r
= MsiSetExternalUIRecord(externalui_record_callback
, INSTALLLOGMODE_ERROR
, &retval
, &prev_record
);
9240 ok(r
== ERROR_SUCCESS
, "MsiSetExternalUIRecord failed %u\n", r
);
9242 externalui_ran
= externalui_record_ran
= 0;
9243 r
= MsiProcessMessage(hpkg
, INSTALLMESSAGE_USER
, hrecord
);
9244 ok(r
== 0, "expected 0, got %u\n", r
);
9245 ok(externalui_ran
== 1, "external UI callback did not run\n");
9246 ok(externalui_record_ran
== 0, "external UI record callback should not have run\n");
9248 MsiCloseHandle(hpkg
);
9249 DeleteFileA(msifile
);
9252 struct externalui_message
{
9256 int match
[4]; /* should we test for a match */
9260 static struct externalui_message
*sequence
;
9261 static int sequence_count
, sequence_size
;
9263 static void add_message(const struct externalui_message
*msg
)
9268 sequence
= HeapAlloc(GetProcessHeap(), 0, sequence_size
* sizeof(*sequence
));
9270 if (sequence_count
== sequence_size
)
9273 sequence
= HeapReAlloc(GetProcessHeap(), 0, sequence
, sequence_size
* sizeof(*sequence
));
9278 sequence
[sequence_count
++] = *msg
;
9281 static void flush_sequence(void)
9283 HeapFree(GetProcessHeap(), 0, sequence
);
9285 sequence_count
= sequence_size
= 0;
9288 static void ok_sequence_(const struct externalui_message
*expected
, const char *context
, BOOL todo
,
9289 const char *file
, int line
)
9291 static const struct externalui_message end_of_sequence
= {0};
9292 const struct externalui_message
*actual
;
9296 add_message(&end_of_sequence
);
9300 while (expected
->message
&& actual
->message
)
9302 if (expected
->message
== actual
->message
)
9304 if (expected
->field_count
!= actual
->field_count
)
9307 ok_(file
, line
) (FALSE
, "%s: in msg 0x%08x expecting field count %d got %d\n",
9308 context
, expected
->message
, expected
->field_count
, actual
->field_count
);
9312 for (i
= 0; i
<= actual
->field_count
; i
++)
9314 if (expected
->match
[i
] && strcmp(expected
->field
[i
], actual
->field
[i
]))
9317 ok_(file
, line
) (FALSE
, "%s: in msg 0x%08x field %d: expected \"%s\", got \"%s\"\n",
9318 context
, expected
->message
, i
, expected
->field
[i
], actual
->field
[i
]);
9329 ok_(file
, line
) (FALSE
, "%s: the msg 0x%08x was expected, but got msg 0x%08x instead\n",
9330 context
, expected
->message
, actual
->message
);
9339 if (expected
->message
|| actual
->message
)
9342 ok_(file
, line
) (FALSE
, "%s: the msg sequence is not complete: expected %08x - actual %08x\n",
9343 context
, expected
->message
, actual
->message
);
9347 if(todo
&& !failcount
) /* succeeded yet marked todo */
9350 ok_(file
, line
)(TRUE
, "%s: marked \"todo_wine\" but succeeds\n", context
);
9357 #define ok_sequence(exp, contx, todo) \
9358 ok_sequence_((exp), (contx), (todo), __FILE__, __LINE__)
9360 static const struct externalui_message empty_sequence
[] = {
9364 static const struct externalui_message openpackage_nonexistent_sequence
[] = {
9365 {INSTALLMESSAGE_INITIALIZE
, -1},
9366 {INSTALLMESSAGE_TERMINATE
, -1},
9370 static const struct externalui_message openpackage_sequence
[] = {
9371 {INSTALLMESSAGE_INITIALIZE
, -1},
9372 {INSTALLMESSAGE_COMMONDATA
, 3, {"", "0", "1033", "1252"}, {1, 1, 1, 1}},
9373 {INSTALLMESSAGE_INFO
|MB_ICONHAND
, 0, {""}, {0}},
9374 {INSTALLMESSAGE_COMMONDATA
, 3, {"", "0", "1033", "1252"}, {0, 1, 1, 1}},
9375 {INSTALLMESSAGE_COMMONDATA
, 3, {"", "1", "", ""}, {0, 1, 0, 0}},
9379 static const struct externalui_message processmessage_info_sequence
[] = {
9380 {INSTALLMESSAGE_INFO
, 3, {"zero", "one", "two", "three"}, {1, 1, 1, 1}},
9384 static const struct externalui_message processmessage_actionstart_sequence
[] = {
9385 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "name", "description", "template"}, {0, 1, 1, 1}},
9389 static const struct externalui_message processmessage_actiondata_sequence
[] = {
9390 {INSTALLMESSAGE_ACTIONDATA
, 3, {"{{name: }}template", "cherry", "banana", "guava"}, {1, 1, 1, 1}},
9394 static const struct externalui_message processmessage_error_sequence
[] = {
9395 {INSTALLMESSAGE_USER
, 3, {"", "1311", "banana", "guava"}, {0, 1, 1, 1}},
9399 static const struct externalui_message processmessage_internal_error_sequence
[] = {
9400 {INSTALLMESSAGE_INFO
, 3, {"DEBUG: Error [1]: Action not found: [2]", "2726", "banana", "guava"}, {1, 1, 1, 1}},
9401 {INSTALLMESSAGE_USER
, 3, {"internal error", "2726", "banana", "guava"}, {1, 1, 1, 1}},
9405 static const struct externalui_message processmessage_error_format_sequence
[] = {
9406 {INSTALLMESSAGE_USER
, 3, {"", "2726", "banana", "guava"}, {0, 1, 1, 1}},
9410 static const struct externalui_message doaction_costinitialize_sequence
[] = {
9411 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "CostInitialize", "cost description", "cost template"}, {0, 1, 1, 1}},
9412 {INSTALLMESSAGE_INFO
, 2, {"", "CostInitialize", ""}, {0, 1, 1}},
9413 {INSTALLMESSAGE_INFO
, 2, {"", "CostInitialize", "1"}, {0, 1, 1}},
9417 static const struct externalui_message doaction_custom_sequence
[] = {
9418 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "custom", "description", "template"}, {0, 1, 1, 1}},
9419 {INSTALLMESSAGE_INFO
, 2, {"", "custom", "1"}, {0, 1, 1}},
9420 {INSTALLMESSAGE_INFO
, 2, {"", "custom", "0"}, {0, 1, 1}},
9424 static const struct externalui_message doaction_custom_fullui_sequence
[] = {
9425 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "custom", "", ""}, {0, 1, 1, 1}},
9426 {INSTALLMESSAGE_INFO
, 2, {"", "custom", ""}, {0, 1, 1}},
9427 {INSTALLMESSAGE_SHOWDIALOG
, 0, {"custom"}, {1}},
9428 {INSTALLMESSAGE_INFO
, 2, {"", "custom", "1"}, {0, 1, 1}},
9432 static const struct externalui_message doaction_custom_cancel_sequence
[] = {
9433 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "custom", "", ""}, {0, 1, 1, 1}},
9437 static const struct externalui_message doaction_dialog_nonexistent_sequence
[] = {
9438 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "custom", "", ""}, {0, 1, 1, 1}},
9439 {INSTALLMESSAGE_INFO
, 2, {"", "custom", "1"}, {0, 1, 1}},
9440 {INSTALLMESSAGE_SHOWDIALOG
, 0, {"custom"}, {1}},
9441 {INSTALLMESSAGE_INFO
, 2, {"DEBUG: Error [1]: Action not found: [2]", "2726", "custom"}, {1, 1, 1}},
9442 {INSTALLMESSAGE_INFO
, 2, {"", "2726", "custom"}, {0, 1, 1}},
9443 {INSTALLMESSAGE_INFO
, 2, {"", "custom", "0"}, {0, 1, 1}},
9447 static const struct externalui_message doaction_dialog_sequence
[] = {
9448 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "dialog", "", ""}, {0, 1, 1, 1}},
9449 {INSTALLMESSAGE_INFO
, 2, {"", "dialog", "0"}, {0, 1, 1}},
9450 {INSTALLMESSAGE_SHOWDIALOG
, 0, {"dialog"}, {1}},
9451 {INSTALLMESSAGE_ACTIONSTART
, 2, {"", "dialog", "Dialog created"}, {0, 1, 1}},
9452 {INSTALLMESSAGE_INFO
, 2, {"", "dialog", "1"}, {0, 1, 1}},
9456 static const struct externalui_message doaction_dialog_error_sequence
[] = {
9457 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "error", "", ""}, {0, 1, 1, 1}},
9458 {INSTALLMESSAGE_INFO
, 2, {"", "error", "1"}, {0, 1, 1}},
9459 {INSTALLMESSAGE_SHOWDIALOG
, 0, {"error"}, {1}},
9463 static const struct externalui_message doaction_dialog_3_sequence
[] = {
9464 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "dialog", "", ""}, {0, 1, 1, 1}},
9465 {INSTALLMESSAGE_INFO
, 2, {"", "dialog", "0"}, {0, 1, 1}},
9466 {INSTALLMESSAGE_SHOWDIALOG
, 0, {"dialog"}, {1}},
9467 {INSTALLMESSAGE_INFO
, 2, {"", "dialog", "3"}, {0, 1, 1}},
9471 static const struct externalui_message doaction_dialog_12345_sequence
[] = {
9472 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "dialog", "", ""}, {0, 1, 1, 1}},
9473 {INSTALLMESSAGE_INFO
, 2, {"", "dialog", "3"}, {0, 1, 1}},
9474 {INSTALLMESSAGE_SHOWDIALOG
, 0, {"dialog"}, {1}},
9475 {INSTALLMESSAGE_INFO
, 2, {"", "dialog", "12345"}, {0, 1, 1}},
9479 static const struct externalui_message closehandle_sequence
[] = {
9480 {INSTALLMESSAGE_TERMINATE
, -1},
9484 static INT CALLBACK
externalui_message_string_callback(void *context
, UINT message
, LPCSTR string
)
9486 INT retval
= context
? *((INT
*)context
) : 0;
9487 struct externalui_message msg
;
9489 msg
.message
= message
;
9490 msg
.field_count
= 0;
9491 strcpy(msg
.field
[0], string
);
9497 static INT CALLBACK
externalui_message_callback(void *context
, UINT message
, MSIHANDLE hrecord
)
9499 INT retval
= context
? *((INT
*)context
) : 0;
9500 struct externalui_message msg
;
9505 msg
.message
= message
;
9506 if (message
== INSTALLMESSAGE_TERMINATE
)
9508 /* trying to access the record seems to hang on some versions of Windows */
9509 msg
.field_count
= -1;
9513 msg
.field_count
= MsiRecordGetFieldCount(hrecord
);
9514 for (i
= 0; i
<= msg
.field_count
; i
++)
9517 MsiRecordGetStringA(hrecord
, i
, buffer
, &length
);
9518 memcpy(msg
.field
[i
], buffer
, min(100, length
+1));
9526 static void test_externalui_message(void)
9528 /* test that events trigger the correct sequence of messages */
9530 INSTALLUI_HANDLER_RECORD prev
;
9531 MSIHANDLE hdb
, hpkg
, hrecord
;
9535 MsiSetInternalUI(INSTALLUILEVEL_FULL
, NULL
);
9537 /* processing SHOWDIALOG with a record handler causes a crash on XP */
9538 MsiSetExternalUIA(externalui_message_string_callback
, INSTALLLOGMODE_SHOWDIALOG
, &retval
);
9539 r
= MsiSetExternalUIRecord(externalui_message_callback
, 0xffffffff ^ INSTALLLOGMODE_PROGRESS
^ INSTALLLOGMODE_SHOWDIALOG
, &retval
, &prev
);
9545 hdb
= create_package_db();
9546 ok(hdb
, "failed to create database\n");
9548 create_file_data("forcecodepage.idt", "\r\n\r\n1252\t_ForceCodepage\r\n");
9549 r
= MsiDatabaseImportA(hdb
, CURR_DIR
, "forcecodepage.idt");
9550 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9552 r
= run_query(hdb
, "CREATE TABLE `Error` (`Error` SHORT NOT NULL, `Message` CHAR(0) PRIMARY KEY `Error`)");
9553 ok(r
== ERROR_SUCCESS
, "Failed to create Error table: %u\n", r
);
9554 r
= run_query(hdb
, "INSERT INTO `Error` (`Error`, `Message`) VALUES (5, 'internal error')");
9555 ok(r
== ERROR_SUCCESS
, "Failed to insert into Error table: %u\n", r
);
9557 r
= create_actiontext_table(hdb
);
9558 ok(r
== ERROR_SUCCESS
, "Failed to create ActionText table: %u\n", r
);
9559 r
= add_actiontext_entry(hdb
, "'custom', 'description', 'template'");
9560 ok(r
== ERROR_SUCCESS
, "Failed to insert into ActionText table: %u\n", r
);
9561 r
= add_actiontext_entry(hdb
, "'CostInitialize', 'cost description', 'cost template'");
9562 ok(r
== ERROR_SUCCESS
, "Failed to insert into ActionText table: %u\n", r
);
9564 r
= MsiOpenPackageA(NULL
, &hpkg
);
9565 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
9566 ok_sequence(empty_sequence
, "MsiOpenPackage with NULL db", FALSE
);
9568 r
= MsiOpenPackageA("nonexistent", &hpkg
);
9569 ok(r
== ERROR_FILE_NOT_FOUND
, "Expected ERROR_FILE_NOT_FOUND, got %d\n", r
);
9570 ok_sequence(openpackage_nonexistent_sequence
, "MsiOpenPackage with nonexistent db", FALSE
);
9572 r
= package_from_db(hdb
, &hpkg
);
9573 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
9575 skip("Not enough rights to perform tests\n");
9576 DeleteFileA(msifile
);
9579 ok(r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
9580 ok_sequence(openpackage_sequence
, "MsiOpenPackage with valid db", FALSE
);
9582 /* Test MsiProcessMessage */
9583 hrecord
= MsiCreateRecord(3);
9584 ok(hrecord
, "failed to create record\n");
9586 MsiRecordSetStringA(hrecord
, 0, "zero");
9587 MsiRecordSetStringA(hrecord
, 1, "one");
9588 MsiRecordSetStringA(hrecord
, 2, "two");
9589 MsiRecordSetStringA(hrecord
, 3, "three");
9590 r
= MsiProcessMessage(hpkg
, INSTALLMESSAGE_INFO
, hrecord
);
9591 ok(r
== 1, "Expected 1, got %d\n", r
);
9592 ok_sequence(processmessage_info_sequence
, "MsiProcessMessage(INSTALLMESSAGE_INFO)", FALSE
);
9594 MsiRecordSetStringA(hrecord
, 1, "name");
9595 MsiRecordSetStringA(hrecord
, 2, "description");
9596 MsiRecordSetStringA(hrecord
, 3, "template");
9597 r
= MsiProcessMessage(hpkg
, INSTALLMESSAGE_ACTIONSTART
, hrecord
);
9598 ok(r
== 1, "Expected 1, got %d\n", r
);
9599 ok_sequence(processmessage_actionstart_sequence
, "MsiProcessMessage(INSTALLMESSAGE_ACTIONSTART)", FALSE
);
9601 MsiRecordSetStringA(hrecord
, 0, "apple");
9602 MsiRecordSetStringA(hrecord
, 1, "cherry");
9603 MsiRecordSetStringA(hrecord
, 2, "banana");
9604 MsiRecordSetStringA(hrecord
, 3, "guava");
9605 r
= MsiProcessMessage(hpkg
, INSTALLMESSAGE_ACTIONDATA
, hrecord
);
9606 ok(r
== 1, "Expected 1, got %d\n", r
);
9607 ok_sequence(processmessage_actiondata_sequence
, "MsiProcessMessage(INSTALLMESSAGE_ACTIONDATA)", FALSE
);
9609 /* non-internal error */
9610 MsiRecordSetStringA(hrecord
, 0, NULL
);
9611 MsiRecordSetInteger(hrecord
, 1, 1311);
9612 r
= MsiProcessMessage(hpkg
, INSTALLMESSAGE_USER
, hrecord
);
9613 ok(r
== 1, "Expected 1, got %d\n", r
);
9614 ok_sequence(processmessage_error_sequence
, "MsiProcessMessage non-internal error", FALSE
);
9616 /* internal error */
9617 MsiRecordSetStringA(hrecord
, 0, NULL
);
9618 MsiRecordSetInteger(hrecord
, 1, 2726);
9619 r
= MsiProcessMessage(hpkg
, INSTALLMESSAGE_USER
, hrecord
);
9620 ok(r
== 0, "Expected 0, got %d\n", r
);
9621 ok_sequence(processmessage_internal_error_sequence
, "MsiProcessMessage internal error", FALSE
);
9623 /* with format field */
9624 MsiRecordSetStringA(hrecord
, 0, "starfruit");
9625 r
= MsiProcessMessage(hpkg
, INSTALLMESSAGE_USER
, hrecord
);
9626 ok(r
== 1, "Expected 1, got %d\n", r
);
9627 ok_sequence(processmessage_error_format_sequence
, "MsiProcessMessage error", FALSE
);
9629 /* Test a standard action */
9630 r
= MsiDoActionA(hpkg
, "CostInitialize");
9631 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9632 ok_sequence(doaction_costinitialize_sequence
, "MsiDoAction(\"CostInitialize\")", FALSE
);
9634 /* Test a custom action */
9635 r
= MsiDoActionA(hpkg
, "custom");
9636 ok(r
== ERROR_FUNCTION_NOT_CALLED
, "Expected ERROR_FUNCTION_NOT_CALLED, got %d\n", r
);
9637 ok_sequence(doaction_custom_sequence
, "MsiDoAction(\"custom\")", FALSE
);
9639 /* close the package */
9640 MsiCloseHandle(hpkg
);
9641 ok_sequence(closehandle_sequence
, "MsiCloseHandle()", FALSE
);
9644 hdb
= create_package_db();
9645 ok(hdb
, "failed to create database\n");
9647 r
= MsiDatabaseImportA(hdb
, CURR_DIR
, "forcecodepage.idt");
9648 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9650 r
= create_dialog_table(hdb
);
9651 ok(r
== ERROR_SUCCESS
, "failed to create dialog table %u\n", r
);
9652 r
= add_dialog_entry(hdb
, "'dialog', 50, 50, 100, 100, 0, 'dummy'");
9653 ok(r
== ERROR_SUCCESS
, "failed to insert into dialog table %u\n", r
);
9655 r
= create_control_table(hdb
);
9656 ok(r
== ERROR_SUCCESS
, "failed to create control table %u\n", r
);
9657 r
= add_control_entry(hdb
, "'dialog', 'dummy', 'Text', 5, 5, 5, 5, 3, 'dummy'");
9658 ok(r
== ERROR_SUCCESS
, "failed to insert into control table %u\n", r
);
9660 r
= package_from_db(hdb
, &hpkg
);
9661 ok(r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
9662 ok_sequence(openpackage_sequence
, "MsiOpenPackage with valid db", FALSE
);
9664 /* Test a custom action */
9665 r
= MsiDoActionA(hpkg
, "custom");
9666 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9667 ok_sequence(doaction_custom_fullui_sequence
, "MsiDoAction(\"custom\")", FALSE
);
9670 r
= MsiDoActionA(hpkg
, "custom");
9671 ok(r
== ERROR_INSTALL_USEREXIT
, "Expected ERROR_INSTALL_USEREXIT, got %d\n", r
);
9672 ok_sequence(doaction_custom_cancel_sequence
, "MsiDoAction(\"custom\")", FALSE
);
9675 r
= MsiDoActionA(hpkg
, "custom");
9676 ok(r
== ERROR_FUNCTION_NOT_CALLED
, "Expected ERROR_FUNCTION_NOT_CALLED, got %d\n", r
);
9677 ok_sequence(doaction_dialog_nonexistent_sequence
, "MsiDoAction(\"custom\")", FALSE
);
9679 r
= MsiDoActionA(hpkg
, "dialog");
9680 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9681 ok_sequence(doaction_dialog_sequence
, "MsiDoAction(\"dialog\")", FALSE
);
9684 r
= MsiDoActionA(hpkg
, "error");
9685 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9686 ok_sequence(doaction_dialog_error_sequence
, "MsiDoAction(\"error\")", FALSE
);
9688 r
= MsiDoActionA(hpkg
, "error");
9689 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9690 ok_sequence(doaction_dialog_error_sequence
, "MsiDoAction(\"error\")", FALSE
);
9693 r
= MsiDoActionA(hpkg
, "custom");
9694 ok(r
== ERROR_FUNCTION_NOT_CALLED
, "Expected ERROR_FUNCTION_NOT_CALLED, got %d\n", r
);
9695 ok_sequence(doaction_dialog_nonexistent_sequence
, "MsiDoAction(\"custom\")", FALSE
);
9698 r
= MsiDoActionA(hpkg
, "dialog");
9699 ok(r
== ERROR_INSTALL_FAILURE
, "Expected ERROR_INSTALL_FAILURE, got %d\n", r
);
9700 ok_sequence(doaction_dialog_3_sequence
, "MsiDoAction(\"dialog\")", FALSE
);
9703 r
= MsiDoActionA(hpkg
, "dialog");
9704 ok(r
== ERROR_FUNCTION_FAILED
, "Expected ERROR_INSTALL_FAILURE, got %d\n", r
);
9705 ok_sequence(doaction_dialog_12345_sequence
, "MsiDoAction(\"dialog\")", FALSE
);
9707 MsiCloseHandle(hpkg
);
9708 ok_sequence(closehandle_sequence
, "MsiCloseHandle()", FALSE
);
9710 MsiCloseHandle(hrecord
);
9712 DeleteFileA(msifile
);
9713 DeleteFileA("forcecodepage.idt");
9716 static const struct externalui_message controlevent_spawn_sequence
[] = {
9717 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "spawn", "", ""}, {0, 1, 1, 1}},
9718 {INSTALLMESSAGE_INFO
, 2, {"", "spawn", ""}, {0, 1, 1}},
9719 {INSTALLMESSAGE_SHOWDIALOG
, 0, {"spawn"}, {1}},
9720 {INSTALLMESSAGE_ACTIONSTART
, 2, {"", "spawn", "Dialog created"}, {0, 1, 1}},
9722 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "custom", "", ""}, {0, 1, 1, 1}},
9723 {INSTALLMESSAGE_INFO
, 2, {"", "custom", ""}, {0, 1, 1}},
9724 {INSTALLMESSAGE_INFO
, 2, {"", "custom", "1"}, {0, 1, 1}},
9726 {INSTALLMESSAGE_ACTIONSTART
, 2, {"", "child1", "Dialog created"}, {0, 1, 1}},
9728 {INSTALLMESSAGE_INFO
, 2, {"", "spawn", "2"}, {0, 1, 1}},
9732 static const struct externalui_message controlevent_spawn2_sequence
[] = {
9733 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "spawn2", "", ""}, {0, 1, 1, 1}},
9734 {INSTALLMESSAGE_INFO
, 2, {"", "spawn2", "2"}, {0, 1, 1}},
9735 {INSTALLMESSAGE_SHOWDIALOG
, 0, {"spawn2"}, {1}},
9736 {INSTALLMESSAGE_ACTIONSTART
, 2, {"", "spawn2", "Dialog created"}, {0, 1, 1}},
9738 {INSTALLMESSAGE_ACTIONSTART
, 3, {"", "custom", "", ""}, {0, 1, 1, 1}},
9739 {INSTALLMESSAGE_INFO
, 2, {"", "custom", "2"}, {0, 1, 1}},
9740 {INSTALLMESSAGE_INFO
, 2, {"", "custom", "1"}, {0, 1, 1}},
9742 {INSTALLMESSAGE_ACTIONSTART
, 2, {"", "child2", "Dialog created"}, {0, 1, 1}},
9744 {INSTALLMESSAGE_INFO
, 2, {"", "spawn2", "2"}, {0, 1, 1}},
9748 static void test_controlevent(void)
9750 INSTALLUI_HANDLER_RECORD prev
;
9751 MSIHANDLE hdb
, hpkg
;
9754 if (!winetest_interactive
)
9756 skip("interactive ControlEvent tests\n");
9760 MsiSetInternalUI(INSTALLUILEVEL_FULL
, NULL
);
9762 /* processing SHOWDIALOG with a record handler causes a crash on XP */
9763 MsiSetExternalUIA(externalui_message_string_callback
, INSTALLLOGMODE_SHOWDIALOG
, NULL
);
9764 r
= MsiSetExternalUIRecord(externalui_message_callback
, 0xffffffff ^ INSTALLLOGMODE_PROGRESS
^ INSTALLLOGMODE_SHOWDIALOG
, NULL
, &prev
);
9770 hdb
= create_package_db();
9771 ok(hdb
, "failed to create database\n");
9773 create_file_data("forcecodepage.idt", "\r\n\r\n1252\t_ForceCodepage\r\n");
9774 r
= MsiDatabaseImportA(hdb
, CURR_DIR
, "forcecodepage.idt");
9775 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9777 r
= create_dialog_table(hdb
);
9778 ok(r
== ERROR_SUCCESS
, "failed to create Dialog table: %u\n", r
);
9779 r
= add_dialog_entry(hdb
, "'spawn', 50, 50, 100, 100, 3, 'button'");
9780 ok(r
== ERROR_SUCCESS
, "failed to insert into Dialog table: %u\n", r
);
9781 r
= add_dialog_entry(hdb
, "'spawn2', 50, 50, 100, 100, 3, 'button'");
9782 ok(r
== ERROR_SUCCESS
, "failed to insert into Dialog table: %u\n", r
);
9783 r
= add_dialog_entry(hdb
, "'child1', 50, 50, 80, 40, 3, 'exit'");
9784 ok(r
== ERROR_SUCCESS
, "failed to insert into Dialog table: %u\n", r
);
9785 r
= add_dialog_entry(hdb
, "'child2', 50, 50, 80, 40, 3, 'exit'");
9786 ok(r
== ERROR_SUCCESS
, "failed to insert into Dialog table: %u\n", r
);
9788 r
= create_control_table(hdb
);
9789 ok(r
== ERROR_SUCCESS
, "failed to create Control table: %u\n", r
);
9790 r
= add_control_entry(hdb
, "'spawn', 'button', 'PushButton', 10, 10, 66, 17, 3, 'Click me'");
9791 ok(r
== ERROR_SUCCESS
, "failed to insert into Control table: %u\n", r
);
9792 r
= add_control_entry(hdb
, "'spawn2', 'button', 'PushButton', 10, 10, 66, 17, 3, 'Click me'");
9793 ok(r
== ERROR_SUCCESS
, "failed to insert into Control table: %u\n", r
);
9794 r
= add_control_entry(hdb
, "'child1', 'exit', 'PushButton', 10, 10, 66, 17, 3, 'Click me'");
9795 ok(r
== ERROR_SUCCESS
, "failed to insert into Control table: %u\n", r
);
9796 r
= add_control_entry(hdb
, "'child2', 'exit', 'PushButton', 10, 10, 66, 17, 3, 'Click me'");
9797 ok(r
== ERROR_SUCCESS
, "failed to insert into Control table: %u\n", r
);
9799 r
= create_controlevent_table(hdb
);
9800 ok(r
== ERROR_SUCCESS
, "failed to create ControlEvent table: %u\n", r
);
9801 r
= add_controlevent_entry(hdb
, "'child1', 'exit', 'EndDialog', 'Exit', 1, 1");
9802 ok(r
== ERROR_SUCCESS
, "failed to insert into ControlEvent table: %u\n", r
);
9803 r
= add_controlevent_entry(hdb
, "'child2', 'exit', 'EndDialog', 'Exit', 1, 1");
9804 ok(r
== ERROR_SUCCESS
, "failed to insert into ControlEvent table: %u\n", r
);
9806 r
= create_custom_action_table(hdb
);
9807 ok(r
== ERROR_SUCCESS
, "failed to create CustomAction table: %u\n", r
);
9808 r
= add_custom_action_entry(hdb
, "'custom', 51, 'dummy', 'dummy value'");
9809 ok(r
== ERROR_SUCCESS
, "failed to insert into CustomAction table: %u\n", r
);
9811 /* SpawnDialog and EndDialog should trigger after all other events */
9812 r
= add_controlevent_entry(hdb
, "'spawn', 'button', 'SpawnDialog', 'child1', 1, 1");
9813 ok(r
== ERROR_SUCCESS
, "failed to insert into ControlEvent table: %u\n", r
);
9814 r
= add_controlevent_entry(hdb
, "'spawn', 'button', 'DoAction', 'custom', 1, 2");
9815 ok(r
== ERROR_SUCCESS
, "failed to insert into ControlEvent table: %u\n", r
);
9817 /* Multiple dialog events cause only the last one to be triggered */
9818 r
= add_controlevent_entry(hdb
, "'spawn2', 'button', 'SpawnDialog', 'child1', 1, 1");
9819 ok(r
== ERROR_SUCCESS
, "failed to insert into ControlEvent table: %u\n", r
);
9820 r
= add_controlevent_entry(hdb
, "'spawn2', 'button', 'SpawnDialog', 'child2', 1, 2");
9821 ok(r
== ERROR_SUCCESS
, "failed to insert into ControlEvent table: %u\n", r
);
9822 r
= add_controlevent_entry(hdb
, "'spawn2', 'button', 'DoAction', 'custom', 1, 3");
9823 ok(r
== ERROR_SUCCESS
, "failed to insert into ControlEvent table: %u\n", r
);
9825 r
= package_from_db(hdb
, &hpkg
);
9826 ok(r
== ERROR_SUCCESS
, "failed to create package: %u\n", r
);
9827 ok_sequence(openpackage_sequence
, "MsiOpenPackage()", FALSE
);
9829 r
= MsiDoActionA(hpkg
, "spawn");
9830 ok(r
== ERROR_INSTALL_USEREXIT
, "expected ERROR_INSTALL_USEREXIT, got %u\n", r
);
9831 ok_sequence(controlevent_spawn_sequence
, "control event: spawn", FALSE
);
9833 r
= MsiDoActionA(hpkg
, "spawn2");
9834 ok(r
== ERROR_INSTALL_USEREXIT
, "expected ERROR_INSTALL_USEREXIT, got %u\n", r
);
9835 ok_sequence(controlevent_spawn2_sequence
, "control event: spawn2", FALSE
);
9837 MsiCloseHandle(hpkg
);
9838 ok_sequence(closehandle_sequence
, "MsiCloseHandle()", FALSE
);
9841 DeleteFileA(msifile
);
9842 DeleteFileA("forcecodepage.idt");
9847 STATEMGRSTATUS status
;
9850 init_functionpointers();
9852 if (pIsWow64Process
)
9853 pIsWow64Process(GetCurrentProcess(), &is_wow64
);
9855 GetCurrentDirectoryA(MAX_PATH
, CURR_DIR
);
9857 /* Create a restore point ourselves so we circumvent the multitude of restore points
9858 * that would have been created by all the installation and removal tests.
9860 * This is not needed on version 5.0 where setting MSIFASTINSTALL prevents the
9861 * creation of restore points.
9863 if (pSRSetRestorePointA
&& !pMsiGetComponentPathExA
)
9865 memset(&status
, 0, sizeof(status
));
9866 ret
= notify_system_change(BEGIN_NESTED_SYSTEM_CHANGE
, &status
);
9869 test_createpackage();
9871 test_gettargetpath_bad();
9872 test_settargetpath();
9874 test_property_table();
9877 test_formatrecord2();
9882 test_appsearch_complocator();
9883 test_appsearch_reglocator();
9884 test_appsearch_inilocator();
9885 test_appsearch_drlocator();
9886 test_featureparents();
9887 test_installprops();
9888 test_launchconditions();
9891 test_MsiGetSourcePath();
9892 test_shortlongsource();
9895 test_emptypackage();
9896 test_MsiGetProductProperty();
9897 test_MsiSetProperty();
9898 test_MsiApplyMultiplePatches();
9899 test_MsiApplyPatch();
9900 test_MsiEnumComponentCosts();
9901 test_MsiDatabaseCommit();
9903 test_externalui_message();
9904 test_controlevent();
9906 if (pSRSetRestorePointA
&& !pMsiGetComponentPathExA
&& ret
)
9908 ret
= notify_system_change(END_NESTED_SYSTEM_CHANGE
, &status
);
9910 remove_restore_point(status
.llSequenceNumber
);