msi: Only mark non-registered features as absent if we haven't done anything with...
[wine.git] / dlls / msi / tests / package.c
blobe3a08944d51eba7d407529e1dc461d3218597b57
1 /*
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
22 #define COBJMACROS
24 #include <assert.h>
25 #include <stdio.h>
26 #include <windows.h>
27 #include <msidefs.h>
28 #include <msi.h>
29 #include <msiquery.h>
30 #include <srrestoreptapi.h>
31 #include <shlobj.h>
33 #include "wine/test.h"
35 static BOOL is_wow64;
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");
63 HMODULE hsrclient;
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);
84 #undef GET_PROC
87 static BOOL is_process_limited(void)
89 SID_IDENTIFIER_AUTHORITY NtAuthority = {SECURITY_NT_AUTHORITY};
90 PSID Group = NULL;
91 BOOL IsInGroup;
92 HANDLE token;
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");
101 FreeSid(Group);
102 return FALSE;
104 FreeSid(Group);
106 if (!IsInGroup)
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");
115 return FALSE;
117 if (!IsInGroup)
119 /* Only administrators and power users can be powerful */
120 return TRUE;
124 if (pOpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token))
126 BOOL ret;
127 TOKEN_ELEVATION_TYPE type = TokenElevationTypeDefault;
128 DWORD size;
130 ret = GetTokenInformation(token, TokenElevationType, &type, sizeof(type), &size);
131 CloseHandle(token);
132 return (ret && type == TokenElevationTypeLimited);
134 return FALSE;
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)
146 HANDLE token;
147 DWORD size = 0;
148 TOKEN_USER *user;
149 char *usersid = NULL;
151 if (!pConvertSidToStringSidA)
153 win_skip("ConvertSidToStringSidA is not available\n");
154 return NULL;
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);
164 CloseHandle(token);
165 return usersid;
168 /* RegDeleteTreeW from dlls/advapi32/registry.c */
169 static LSTATUS package_RegDeleteTreeW(HKEY hKey, LPCWSTR lpszSubKey, REGSAM access)
171 LONG ret;
172 DWORD dwMaxSubkeyLen, dwMaxValueLen;
173 DWORD dwMaxLen, dwSize;
174 WCHAR szNameBuf[MAX_PATH], *lpszName = szNameBuf;
175 HKEY hSubKey = hKey;
177 if(lpszSubKey)
179 ret = RegOpenKeyExW(hKey, lpszSubKey, 0, access, &hSubKey);
180 if (ret) return ret;
183 ret = RegQueryInfoKeyW(hSubKey, NULL, NULL, NULL, NULL,
184 &dwMaxSubkeyLen, NULL, NULL, &dwMaxValueLen, NULL, NULL, NULL);
185 if (ret) goto cleanup;
187 dwMaxSubkeyLen++;
188 dwMaxValueLen++;
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;
196 goto cleanup;
200 /* Recursively delete all the subkeys */
201 while (TRUE)
203 dwSize = dwMaxLen;
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;
211 if (lpszSubKey)
213 if (pRegDeleteKeyExW)
214 ret = pRegDeleteKeyExW(hKey, lpszSubKey, access, 0);
215 else
216 ret = RegDeleteKeyW(hKey, lpszSubKey);
218 else
219 while (TRUE)
221 dwSize = dwMaxLen;
222 if (RegEnumValueW(hKey, 0, lpszName, &dwSize,
223 NULL, NULL, NULL, NULL)) break;
225 ret = RegDeleteValueW(hKey, lpszName);
226 if (ret) goto cleanup;
229 cleanup:
230 if (lpszName != szNameBuf)
231 HeapFree(GetProcessHeap(), 0, lpszName);
232 if(lpszSubKey)
233 RegCloseKey(hSubKey);
234 return ret;
237 static BOOL squash_guid(LPCWSTR in, LPWSTR out)
239 DWORD i,n=1;
240 GUID guid;
242 if (FAILED(CLSIDFromString((LPCOLESTR)in, &guid)))
243 return FALSE;
245 for(i=0; i<8; i++)
246 out[7-i] = in[n++];
247 n++;
248 for(i=0; i<4; i++)
249 out[11-i] = in[n++];
250 n++;
251 for(i=0; i<4; i++)
252 out[15-i] = in[n++];
253 n++;
254 for(i=0; i<2; i++)
256 out[17+i*2] = in[n++];
257 out[16+i*2] = in[n++];
259 n++;
260 for( ; i<8; i++)
262 out[17+i*2] = in[n++];
263 out[16+i*2] = in[n++];
265 out[32]=0;
266 return TRUE;
269 static void create_test_guid(LPSTR prodcode, LPSTR squashed)
271 WCHAR guidW[MAX_PATH];
272 WCHAR squashedW[MAX_PATH];
273 GUID guid;
274 HRESULT hr;
275 int size;
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];
296 CHAR path[MAX_PATH];
297 LPCSTR prod = NULL;
298 HKEY hkey;
299 REGSAM access = KEY_ALL_ACCESS;
301 if (is_wow64)
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";
311 sprintf(comppath,
312 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
313 "Installer\\UserData\\S-1-5-18\\Components\\%s", squashed);
314 lstrcpyA(prodpath,
315 "SOFTWARE\\Classes\\Installer\\"
316 "Products\\3D0DAE300FACA1300AD792060BCDAA92");
318 else if (context == MSIINSTALLCONTEXT_USERUNMANAGED)
320 prod = "7D2F387510109040002000060BECB6AB";
321 sprintf(comppath,
322 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
323 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
324 sprintf(prodpath,
325 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
326 "Installer\\%s\\Installer\\Products\\"
327 "7D2F387510109040002000060BECB6AB", usersid);
329 else if (context == MSIINSTALLCONTEXT_USERMANAGED)
331 prod = "7D2F387510109040002000060BECB6AB";
332 sprintf(comppath,
333 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
334 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
335 sprintf(prodpath,
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));
348 RegCloseKey(hkey);
350 RegCreateKeyExA(HKEY_LOCAL_MACHINE, prodpath, 0, NULL, 0, access, NULL, &hkey, NULL);
351 RegCloseKey(hkey);
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;
364 if (is_wow64)
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)
373 sprintf(comppath,
374 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
375 "Installer\\UserData\\S-1-5-18\\Components\\%s", squashed);
376 lstrcpyA(prodpath,
377 "SOFTWARE\\Classes\\Installer\\"
378 "Products\\3D0DAE300FACA1300AD792060BCDAA92");
380 else if (context == MSIINSTALLCONTEXT_USERUNMANAGED)
382 sprintf(comppath,
383 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
384 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
385 sprintf(prodpath,
386 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
387 "Installer\\%s\\Installer\\Products\\"
388 "7D2F387510109040002000060BECB6AB", usersid);
390 else if (context == MSIINSTALLCONTEXT_USERMANAGED)
392 sprintf(comppath,
393 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
394 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
395 sprintf(prodpath,
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)
410 MSIHANDLE hview = 0;
411 UINT r, ret;
413 /* open a select query */
414 r = MsiDatabaseOpenViewA(hdb, query, &hview);
415 if (r != ERROR_SUCCESS)
416 return r;
417 r = MsiViewExecute(hview, 0);
418 if (r != ERROR_SUCCESS)
419 return r;
420 ret = MsiViewFetch(hview, phrec);
421 r = MsiViewClose(hview);
422 if (r != ERROR_SUCCESS)
423 return r;
424 r = MsiCloseHandle(hview);
425 if (r != ERROR_SUCCESS)
426 return r;
427 return ret;
430 static UINT run_query( MSIHANDLE hdb, const char *query )
432 MSIHANDLE hview = 0;
433 UINT r;
435 r = MsiDatabaseOpenViewA(hdb, query, &hview);
436 if( r != ERROR_SUCCESS )
437 return r;
439 r = MsiViewExecute(hview, 0);
440 if( r == ERROR_SUCCESS )
441 r = MsiViewClose(hview);
442 MsiCloseHandle(hview);
443 return r;
446 static UINT create_component_table( MSIHANDLE hdb )
448 UINT r = run_query( hdb,
449 "CREATE TABLE `Component` ( "
450 "`Component` CHAR(72) NOT NULL, "
451 "`ComponentId` CHAR(38), "
452 "`Directory_` CHAR(72) NOT NULL, "
453 "`Attributes` SHORT NOT NULL, "
454 "`Condition` CHAR(255), "
455 "`KeyPath` CHAR(72) "
456 "PRIMARY KEY `Component`)" );
457 ok(r == ERROR_SUCCESS, "Failed to create Component table: %u\n", r);
458 return r;
461 static UINT create_feature_table( MSIHANDLE hdb )
463 UINT r = run_query( hdb,
464 "CREATE TABLE `Feature` ( "
465 "`Feature` CHAR(38) NOT NULL, "
466 "`Feature_Parent` CHAR(38), "
467 "`Title` CHAR(64), "
468 "`Description` CHAR(255), "
469 "`Display` SHORT NOT NULL, "
470 "`Level` SHORT NOT NULL, "
471 "`Directory_` CHAR(72), "
472 "`Attributes` SHORT NOT NULL "
473 "PRIMARY KEY `Feature`)" );
474 ok(r == ERROR_SUCCESS, "Failed to create Feature table: %u\n", r);
475 return r;
478 static UINT create_feature_components_table( MSIHANDLE hdb )
480 UINT r = run_query( hdb,
481 "CREATE TABLE `FeatureComponents` ( "
482 "`Feature_` CHAR(38) NOT NULL, "
483 "`Component_` CHAR(72) NOT NULL "
484 "PRIMARY KEY `Feature_`, `Component_` )" );
485 ok(r == ERROR_SUCCESS, "Failed to create FeatureComponents table: %u\n", r);
486 return r;
489 static UINT create_file_table( MSIHANDLE hdb )
491 UINT r = run_query( hdb,
492 "CREATE TABLE `File` ("
493 "`File` CHAR(72) NOT NULL, "
494 "`Component_` CHAR(72) NOT NULL, "
495 "`FileName` CHAR(255) NOT NULL, "
496 "`FileSize` LONG NOT NULL, "
497 "`Version` CHAR(72), "
498 "`Language` CHAR(20), "
499 "`Attributes` SHORT, "
500 "`Sequence` SHORT NOT NULL "
501 "PRIMARY KEY `File`)" );
502 ok(r == ERROR_SUCCESS, "Failed to create File table: %u\n", r);
503 return r;
506 static UINT create_remove_file_table( MSIHANDLE hdb )
508 UINT r = run_query( hdb,
509 "CREATE TABLE `RemoveFile` ("
510 "`FileKey` CHAR(72) NOT NULL, "
511 "`Component_` CHAR(72) NOT NULL, "
512 "`FileName` CHAR(255) LOCALIZABLE, "
513 "`DirProperty` CHAR(72) NOT NULL, "
514 "`InstallMode` SHORT NOT NULL "
515 "PRIMARY KEY `FileKey`)" );
516 ok(r == ERROR_SUCCESS, "Failed to create RemoveFile table: %u\n", r);
517 return r;
520 static UINT create_appsearch_table( MSIHANDLE hdb )
522 UINT r = run_query( hdb,
523 "CREATE TABLE `AppSearch` ("
524 "`Property` CHAR(72) NOT NULL, "
525 "`Signature_` CHAR(72) NOT NULL "
526 "PRIMARY KEY `Property`, `Signature_`)" );
527 ok(r == ERROR_SUCCESS, "Failed to create AppSearch table: %u\n", r);
528 return r;
531 static UINT create_reglocator_table( MSIHANDLE hdb )
533 UINT r = run_query( hdb,
534 "CREATE TABLE `RegLocator` ("
535 "`Signature_` CHAR(72) NOT NULL, "
536 "`Root` SHORT NOT NULL, "
537 "`Key` CHAR(255) NOT NULL, "
538 "`Name` CHAR(255), "
539 "`Type` SHORT "
540 "PRIMARY KEY `Signature_`)" );
541 ok(r == ERROR_SUCCESS, "Failed to create RegLocator table: %u\n", r);
542 return r;
545 static UINT create_signature_table( MSIHANDLE hdb )
547 UINT r = run_query( hdb,
548 "CREATE TABLE `Signature` ("
549 "`Signature` CHAR(72) NOT NULL, "
550 "`FileName` CHAR(255) NOT NULL, "
551 "`MinVersion` CHAR(20), "
552 "`MaxVersion` CHAR(20), "
553 "`MinSize` LONG, "
554 "`MaxSize` LONG, "
555 "`MinDate` LONG, "
556 "`MaxDate` LONG, "
557 "`Languages` CHAR(255) "
558 "PRIMARY KEY `Signature`)" );
559 ok(r == ERROR_SUCCESS, "Failed to create Signature table: %u\n", r);
560 return r;
563 static UINT create_launchcondition_table( MSIHANDLE hdb )
565 UINT r = run_query( hdb,
566 "CREATE TABLE `LaunchCondition` ("
567 "`Condition` CHAR(255) NOT NULL, "
568 "`Description` CHAR(255) NOT NULL "
569 "PRIMARY KEY `Condition`)" );
570 ok(r == ERROR_SUCCESS, "Failed to create LaunchCondition table: %u\n", r);
571 return r;
574 static UINT create_property_table( MSIHANDLE hdb )
576 UINT r = run_query( hdb,
577 "CREATE TABLE `Property` ("
578 "`Property` CHAR(72) NOT NULL, "
579 "`Value` CHAR(0) "
580 "PRIMARY KEY `Property`)" );
581 ok(r == ERROR_SUCCESS, "Failed to create Property table: %u\n", r);
582 return r;
585 static UINT create_install_execute_sequence_table( MSIHANDLE hdb )
587 UINT r = run_query( hdb,
588 "CREATE TABLE `InstallExecuteSequence` ("
589 "`Action` CHAR(72) NOT NULL, "
590 "`Condition` CHAR(255), "
591 "`Sequence` SHORT "
592 "PRIMARY KEY `Action`)" );
593 ok(r == ERROR_SUCCESS, "Failed to create InstallExecuteSequence table: %u\n", r);
594 return r;
597 static UINT create_install_ui_sequence_table( MSIHANDLE hdb )
599 UINT r = run_query( hdb,
600 "CREATE TABLE `InstallUISequence` ("
601 "`Action` CHAR(72) NOT NULL, "
602 "`Condition` CHAR(255), "
603 "`Sequence` SHORT "
604 "PRIMARY KEY `Action`)" );
605 ok(r == ERROR_SUCCESS, "Failed to create InstallUISequence table: %u\n", r);
606 return r;
609 static UINT create_media_table( MSIHANDLE hdb )
611 UINT r = run_query( hdb,
612 "CREATE TABLE `Media` ("
613 "`DiskId` SHORT NOT NULL, "
614 "`LastSequence` SHORT NOT NULL, "
615 "`DiskPrompt` CHAR(64), "
616 "`Cabinet` CHAR(255), "
617 "`VolumeLabel` CHAR(32), "
618 "`Source` CHAR(72) "
619 "PRIMARY KEY `DiskId`)" );
620 ok(r == ERROR_SUCCESS, "Failed to create Media table: %u\n", r);
621 return r;
624 static UINT create_ccpsearch_table( MSIHANDLE hdb )
626 UINT r = run_query( hdb,
627 "CREATE TABLE `CCPSearch` ("
628 "`Signature_` CHAR(72) NOT NULL "
629 "PRIMARY KEY `Signature_`)" );
630 ok(r == ERROR_SUCCESS, "Failed to create CCPSearch table: %u\n", r);
631 return r;
634 static UINT create_drlocator_table( MSIHANDLE hdb )
636 UINT r = run_query( hdb,
637 "CREATE TABLE `DrLocator` ("
638 "`Signature_` CHAR(72) NOT NULL, "
639 "`Parent` CHAR(72), "
640 "`Path` CHAR(255), "
641 "`Depth` SHORT "
642 "PRIMARY KEY `Signature_`, `Parent`, `Path`)" );
643 ok(r == ERROR_SUCCESS, "Failed to create DrLocator table: %u\n", r);
644 return r;
647 static UINT create_complocator_table( MSIHANDLE hdb )
649 UINT r = run_query( hdb,
650 "CREATE TABLE `CompLocator` ("
651 "`Signature_` CHAR(72) NOT NULL, "
652 "`ComponentId` CHAR(38) NOT NULL, "
653 "`Type` SHORT "
654 "PRIMARY KEY `Signature_`)" );
655 ok(r == ERROR_SUCCESS, "Failed to create CompLocator table: %u\n", r);
656 return r;
659 static UINT create_inilocator_table( MSIHANDLE hdb )
661 UINT r = run_query( hdb,
662 "CREATE TABLE `IniLocator` ("
663 "`Signature_` CHAR(72) NOT NULL, "
664 "`FileName` CHAR(255) NOT NULL, "
665 "`Section` CHAR(96)NOT NULL, "
666 "`Key` CHAR(128)NOT NULL, "
667 "`Field` SHORT, "
668 "`Type` SHORT "
669 "PRIMARY KEY `Signature_`)" );
670 ok(r == ERROR_SUCCESS, "Failed to create IniLocator table: %u\n", r);
671 return r;
674 static UINT create_custom_action_table( MSIHANDLE hdb )
676 UINT r = run_query( hdb,
677 "CREATE TABLE `CustomAction` ("
678 "`Action` CHAR(72) NOT NULL, "
679 "`Type` SHORT NOT NULL, "
680 "`Source` CHAR(75), "
681 "`Target` CHAR(255) "
682 "PRIMARY KEY `Action`)" );
683 ok(r == ERROR_SUCCESS, "Failed to create CustomAction table: %u\n", r);
684 return r;
687 static UINT create_dialog_table( MSIHANDLE hdb )
689 UINT r = run_query(hdb,
690 "CREATE TABLE `Dialog` ("
691 "`Dialog` CHAR(72) NOT NULL, "
692 "`HCentering` SHORT NOT NULL, "
693 "`VCentering` SHORT NOT NULL, "
694 "`Width` SHORT NOT NULL, "
695 "`Height` SHORT NOT NULL, "
696 "`Attributes` LONG, "
697 "`Title` CHAR(128) LOCALIZABLE, "
698 "`Control_First` CHAR(50) NOT NULL, "
699 "`Control_Default` CHAR(50), "
700 "`Control_Cancel` CHAR(50) "
701 "PRIMARY KEY `Dialog`)");
702 ok(r == ERROR_SUCCESS, "Failed to create Dialog table: %u\n", r);
703 return r;
706 static UINT create_control_table( MSIHANDLE hdb )
708 UINT r = run_query(hdb,
709 "CREATE TABLE `Control` ("
710 "`Dialog_` CHAR(72) NOT NULL, "
711 "`Control` CHAR(50) NOT NULL, "
712 "`Type` CHAR(20) NOT NULL, "
713 "`X` SHORT NOT NULL, "
714 "`Y` SHORT NOT NULL, "
715 "`Width` SHORT NOT NULL, "
716 "`Height` SHORT NOT NULL, "
717 "`Attributes` LONG, "
718 "`Property` CHAR(50), "
719 "`Text` CHAR(0) LOCALIZABLE, "
720 "`Control_Next` CHAR(50), "
721 "`Help` CHAR(255) LOCALIZABLE "
722 "PRIMARY KEY `Dialog_`, `Control`)");
723 ok(r == ERROR_SUCCESS, "Failed to create Control table: %u\n", r);
724 return r;
727 static UINT create_controlevent_table( MSIHANDLE hdb )
729 UINT r = run_query(hdb,
730 "CREATE TABLE `ControlEvent` ("
731 "`Dialog_` CHAR(72) NOT NULL, "
732 "`Control_` CHAR(50) NOT NULL, "
733 "`Event` CHAR(50) NOT NULL, "
734 "`Argument` CHAR(255) NOT NULL, "
735 "`Condition` CHAR(255), "
736 "`Ordering` SHORT "
737 "PRIMARY KEY `Dialog_`, `Control_`, `Event`, `Argument`, `Condition`)");
738 ok(r == ERROR_SUCCESS, "Failed to create ControlEvent table: %u\n", r);
739 return r;
742 static UINT create_actiontext_table( MSIHANDLE hdb )
744 UINT r = run_query(hdb,
745 "CREATE TABLE `ActionText` ("
746 "`Action` CHAR(72) NOT NULL, "
747 "`Description` CHAR(64) LOCALIZABLE, "
748 "`Template` CHAR(128) LOCALIZABLE "
749 "PRIMARY KEY `Action`)");
750 ok(r == ERROR_SUCCESS, "Failed to create ActionText table: %u\n", r);
751 return r;
754 static inline UINT add_entry(const char *file, int line, const char *type, MSIHANDLE hdb, const char *values, const char *insert)
756 char *query;
757 UINT sz, r;
759 sz = strlen(values) + strlen(insert) + 1;
760 query = HeapAlloc(GetProcessHeap(), 0, sz);
761 sprintf(query, insert, values);
762 r = run_query(hdb, query);
763 HeapFree(GetProcessHeap(), 0, query);
764 ok_(file, line)(r == ERROR_SUCCESS, "failed to insert into %s table: %u\n", type, r);
765 return r;
768 #define add_component_entry(hdb, values) add_entry(__FILE__, __LINE__, "Component", hdb, values, \
769 "INSERT INTO `Component` " \
770 "(`Component`, `ComponentId`, `Directory_`, " \
771 "`Attributes`, `Condition`, `KeyPath`) VALUES( %s )")
773 #define add_directory_entry(hdb, values) add_entry(__FILE__, __LINE__, "Directory", hdb, values, \
774 "INSERT INTO `Directory` " \
775 "(`Directory`,`Directory_Parent`,`DefaultDir`) VALUES( %s )")
777 #define add_feature_entry(hdb, values) add_entry(__FILE__, __LINE__, "Feature", hdb, values, \
778 "INSERT INTO `Feature` " \
779 "(`Feature`, `Feature_Parent`, `Title`, `Description`, " \
780 "`Display`, `Level`, `Directory_`, `Attributes`) VALUES( %s )")
782 #define add_feature_components_entry(hdb, values) add_entry(__FILE__, __LINE__, "FeatureComponents", hdb, values, \
783 "INSERT INTO `FeatureComponents` " \
784 "(`Feature_`, `Component_`) VALUES( %s )")
786 #define add_file_entry(hdb, values) add_entry(__FILE__, __LINE__, "File", hdb, values, \
787 "INSERT INTO `File` " \
788 "(`File`, `Component_`, `FileName`, `FileSize`, " \
789 "`Version`, `Language`, `Attributes`, `Sequence`) VALUES( %s )")
791 #define add_appsearch_entry(hdb, values) add_entry(__FILE__, __LINE__, "AppSearch", hdb, values, \
792 "INSERT INTO `AppSearch` " \
793 "(`Property`, `Signature_`) VALUES( %s )")
795 #define add_signature_entry(hdb, values) add_entry(__FILE__, __LINE__, "Signature", hdb, values, \
796 "INSERT INTO `Signature` " \
797 "(`Signature`, `FileName`, `MinVersion`, `MaxVersion`," \
798 " `MinSize`, `MaxSize`, `MinDate`, `MaxDate`, `Languages`) " \
799 "VALUES( %s )")
801 #define add_launchcondition_entry(hdb, values) add_entry(__FILE__, __LINE__, "LaunchCondition", hdb, values, \
802 "INSERT INTO `LaunchCondition` " \
803 "(`Condition`, `Description`) VALUES( %s )")
805 #define add_property_entry(hdb, values) add_entry(__FILE__, __LINE__, "Property", hdb, values, \
806 "INSERT INTO `Property` (`Property`, `Value`) VALUES( %s )")
808 #define add_install_execute_sequence_entry(hdb, values) add_entry(__FILE__, __LINE__, "InstallExecuteSequence", hdb, values, \
809 "INSERT INTO `InstallExecuteSequence` " \
810 "(`Action`, `Condition`, `Sequence`) VALUES( %s )")
812 #define add_install_ui_sequence_entry(hdb, values) add_entry(__FILE__, __LINE__, "InstallUISequence", hdb, values, \
813 "INSERT INTO `InstallUISequence` " \
814 "(`Action`, `Condition`, `Sequence`) VALUES( %s )")
816 #define add_media_entry(hdb, values) add_entry(__FILE__, __LINE__, "Media", hdb, values, \
817 "INSERT INTO `Media` " \
818 "(`DiskId`, `LastSequence`, `DiskPrompt`, " \
819 "`Cabinet`, `VolumeLabel`, `Source`) VALUES( %s )")
821 #define add_ccpsearch_entry(hdb, values) add_entry(__FILE__, __LINE__, "CCPSearch", hdb, values, \
822 "INSERT INTO `CCPSearch` (`Signature_`) VALUES( %s )")
824 #define add_drlocator_entry(hdb, values) add_entry(__FILE__, __LINE__, "DrLocator", hdb, values, \
825 "INSERT INTO `DrLocator` " \
826 "(`Signature_`, `Parent`, `Path`, `Depth`) VALUES( %s )")
828 #define add_complocator_entry(hdb, values) add_entry(__FILE__, __LINE__, "CompLocator", hdb, values, \
829 "INSERT INTO `CompLocator` " \
830 "(`Signature_`, `ComponentId`, `Type`) VALUES( %s )")
832 #define add_inilocator_entry(hdb, values) add_entry(__FILE__, __LINE__, "IniLocator", hdb, values, \
833 "INSERT INTO `IniLocator` " \
834 "(`Signature_`, `FileName`, `Section`, `Key`, `Field`, `Type`) " \
835 "VALUES( %s )")
837 #define add_custom_action_entry(hdb, values) add_entry(__FILE__, __LINE__, "CustomAction", hdb, values, \
838 "INSERT INTO `CustomAction` " \
839 "(`Action`, `Type`, `Source`, `Target`) VALUES( %s )")
841 #define add_dialog_entry(hdb, values) add_entry(__FILE__, __LINE__, "Dialog", hdb, values, \
842 "INSERT INTO `Dialog` " \
843 "(`Dialog`, `HCentering`, `VCentering`, `Width`, `Height`, `Attributes`, `Control_First`) VALUES ( %s )")
845 #define add_control_entry(hdb, values) add_entry(__FILE__, __LINE__, "Control", hdb, values, \
846 "INSERT INTO `Control` " \
847 "(`Dialog_`, `Control`, `Type`, `X`, `Y`, `Width`, `Height`, `Attributes`, `Text`) VALUES( %s )");
849 #define add_controlevent_entry(hdb, values) add_entry(__FILE__, __LINE__, "ControlEvent", hdb, values, \
850 "INSERT INTO `ControlEvent` " \
851 "(`Dialog_`, `Control_`, `Event`, `Argument`, `Condition`, `Ordering`) VALUES( %s )");
853 #define add_actiontext_entry(hdb, values) add_entry(__FILE__, __LINE__, "ActionText", hdb, values, \
854 "INSERT INTO `ActionText` " \
855 "(`Action`, `Description`, `Template`) VALUES( %s )");
857 static UINT add_reglocator_entry( MSIHANDLE hdb, const char *sig, UINT root, const char *path,
858 const char *name, UINT type )
860 const char insert[] =
861 "INSERT INTO `RegLocator` (`Signature_`, `Root`, `Key`, `Name`, `Type`) "
862 "VALUES( '%s', %u, '%s', '%s', %u )";
863 char *query;
864 UINT sz, r;
866 sz = strlen( sig ) + 10 + strlen( path ) + strlen( name ) + 10 + sizeof( insert );
867 query = HeapAlloc( GetProcessHeap(), 0, sz );
868 sprintf( query, insert, sig, root, path, name, type );
869 r = run_query( hdb, query );
870 HeapFree( GetProcessHeap(), 0, query );
871 ok(r == ERROR_SUCCESS, "failed to insert into reglocator table: %u\n", r); \
872 return r;
875 static UINT set_summary_info(MSIHANDLE hdb)
877 UINT res;
878 MSIHANDLE suminfo;
880 /* build summary info */
881 res = MsiGetSummaryInformationA(hdb, NULL, 7, &suminfo);
882 ok( res == ERROR_SUCCESS , "Failed to open summaryinfo\n" );
884 res = MsiSummaryInfoSetPropertyA(suminfo,2, VT_LPSTR, 0,NULL,
885 "Installation Database");
886 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
888 res = MsiSummaryInfoSetPropertyA(suminfo,3, VT_LPSTR, 0,NULL,
889 "Installation Database");
890 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
892 res = MsiSummaryInfoSetPropertyA(suminfo,4, VT_LPSTR, 0,NULL,
893 "Wine Hackers");
894 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
896 res = MsiSummaryInfoSetPropertyA(suminfo,7, VT_LPSTR, 0,NULL,
897 ";1033");
898 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
900 res = MsiSummaryInfoSetPropertyA(suminfo,9, VT_LPSTR, 0,NULL,
901 "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}");
902 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
904 res = MsiSummaryInfoSetPropertyA(suminfo, 14, VT_I4, 100, NULL, NULL);
905 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
907 res = MsiSummaryInfoSetPropertyA(suminfo, 15, VT_I4, 0, NULL, NULL);
908 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
910 res = MsiSummaryInfoPersist(suminfo);
911 ok( res == ERROR_SUCCESS , "Failed to make summary info persist\n" );
913 res = MsiCloseHandle( suminfo);
914 ok( res == ERROR_SUCCESS , "Failed to close suminfo\n" );
916 return res;
920 static MSIHANDLE create_package_db(void)
922 MSIHANDLE hdb = 0;
923 UINT res;
925 DeleteFileA(msifile);
927 /* create an empty database */
928 res = MsiOpenDatabaseW(msifileW, MSIDBOPEN_CREATE, &hdb );
929 ok( res == ERROR_SUCCESS , "Failed to create database %u\n", res );
930 if( res != ERROR_SUCCESS )
931 return hdb;
933 res = MsiDatabaseCommit( hdb );
934 ok( res == ERROR_SUCCESS , "Failed to commit database\n" );
936 res = set_summary_info(hdb);
937 ok( res == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", res);
939 res = run_query( hdb,
940 "CREATE TABLE `Directory` ( "
941 "`Directory` CHAR(255) NOT NULL, "
942 "`Directory_Parent` CHAR(255), "
943 "`DefaultDir` CHAR(255) NOT NULL "
944 "PRIMARY KEY `Directory`)" );
945 ok( res == ERROR_SUCCESS , "Failed to create directory table\n" );
947 return hdb;
950 static UINT package_from_db(MSIHANDLE hdb, MSIHANDLE *handle)
952 UINT res;
953 CHAR szPackage[12];
954 MSIHANDLE hPackage;
956 sprintf(szPackage, "#%u", hdb);
957 res = MsiOpenPackageA(szPackage, &hPackage);
958 if (res != ERROR_SUCCESS)
960 MsiCloseHandle(hdb);
961 return res;
964 res = MsiCloseHandle(hdb);
965 if (res != ERROR_SUCCESS)
967 MsiCloseHandle(hPackage);
968 return res;
971 *handle = hPackage;
972 return ERROR_SUCCESS;
975 static void create_file_data(LPCSTR name, LPCSTR data)
977 HANDLE file;
978 DWORD written;
980 file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
981 ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name);
982 if (file == INVALID_HANDLE_VALUE)
983 return;
985 WriteFile(file, data, strlen(data), &written, NULL);
986 WriteFile(file, "\n", strlen("\n"), &written, NULL);
988 CloseHandle(file);
991 static void create_test_file(const CHAR *name)
993 create_file_data(name, name);
996 typedef struct _tagVS_VERSIONINFO
998 WORD wLength;
999 WORD wValueLength;
1000 WORD wType;
1001 WCHAR szKey[1];
1002 WORD wPadding1[1];
1003 VS_FIXEDFILEINFO Value;
1004 WORD wPadding2[1];
1005 WORD wChildren[1];
1006 } VS_VERSIONINFO;
1008 #define roundoffs(a, b, r) (((BYTE *)(b) - (BYTE *)(a) + ((r) - 1)) & ~((r) - 1))
1009 #define roundpos(a, b, r) (((BYTE *)(a)) + roundoffs(a, b, r))
1011 static BOOL create_file_with_version(const CHAR *name, LONG ms, LONG ls)
1013 VS_VERSIONINFO *pVerInfo;
1014 VS_FIXEDFILEINFO *pFixedInfo;
1015 LPBYTE buffer, ofs;
1016 CHAR path[MAX_PATH];
1017 DWORD handle, size;
1018 HANDLE resource;
1019 BOOL ret = FALSE;
1021 GetSystemDirectoryA(path, MAX_PATH);
1022 /* Some dlls can't be updated on Vista/W2K8 */
1023 lstrcatA(path, "\\version.dll");
1025 CopyFileA(path, name, FALSE);
1027 size = GetFileVersionInfoSizeA(path, &handle);
1028 buffer = HeapAlloc(GetProcessHeap(), 0, size);
1030 GetFileVersionInfoA(path, 0, size, buffer);
1032 pVerInfo = (VS_VERSIONINFO *)buffer;
1033 ofs = (BYTE *)&pVerInfo->szKey[lstrlenW(pVerInfo->szKey) + 1];
1034 pFixedInfo = (VS_FIXEDFILEINFO *)roundpos(pVerInfo, ofs, 4);
1036 pFixedInfo->dwFileVersionMS = ms;
1037 pFixedInfo->dwFileVersionLS = ls;
1038 pFixedInfo->dwProductVersionMS = ms;
1039 pFixedInfo->dwProductVersionLS = ls;
1041 resource = BeginUpdateResourceA(name, FALSE);
1042 if (!resource)
1043 goto done;
1045 if (!UpdateResourceA(resource, (LPCSTR)RT_VERSION, (LPCSTR)MAKEINTRESOURCE(VS_VERSION_INFO),
1046 MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), buffer, size))
1047 goto done;
1049 if (!EndUpdateResourceA(resource, FALSE))
1050 goto done;
1052 ret = TRUE;
1054 done:
1055 HeapFree(GetProcessHeap(), 0, buffer);
1056 return ret;
1059 static BOOL notify_system_change(DWORD event_type, STATEMGRSTATUS *status)
1061 RESTOREPOINTINFOA spec;
1063 spec.dwEventType = event_type;
1064 spec.dwRestorePtType = APPLICATION_INSTALL;
1065 spec.llSequenceNumber = status->llSequenceNumber;
1066 lstrcpyA(spec.szDescription, "msitest restore point");
1068 return pSRSetRestorePointA(&spec, status);
1071 static void remove_restore_point(DWORD seq_number)
1073 DWORD res;
1075 res = pSRRemoveRestorePoint(seq_number);
1076 if (res != ERROR_SUCCESS)
1077 trace("Failed to remove the restore point : %08x\n", res);
1080 static BOOL is_root(const char *path)
1082 return (isalpha(path[0]) && path[1] == ':' && path[2] == '\\' && !path[3]);
1085 static void test_createpackage(void)
1087 MSIHANDLE hPackage = 0;
1088 UINT res;
1090 res = package_from_db(create_package_db(), &hPackage);
1091 if (res == ERROR_INSTALL_PACKAGE_REJECTED)
1093 skip("Not enough rights to perform tests\n");
1094 DeleteFileA(msifile);
1095 return;
1097 ok( res == ERROR_SUCCESS, " Failed to create package %u\n", res );
1099 res = MsiCloseHandle( hPackage);
1100 ok( res == ERROR_SUCCESS , "Failed to close package\n" );
1101 DeleteFileA(msifile);
1104 static void test_doaction( void )
1106 MSIHANDLE hpkg;
1107 UINT r;
1109 r = MsiDoActionA( -1, NULL );
1110 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1112 r = package_from_db(create_package_db(), &hpkg);
1113 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
1115 skip("Not enough rights to perform tests\n");
1116 DeleteFileA(msifile);
1117 return;
1119 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
1121 r = MsiDoActionA(hpkg, NULL);
1122 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1124 r = MsiDoActionA(0, "boo");
1125 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
1127 r = MsiDoActionA(hpkg, "boo");
1128 ok( r == ERROR_FUNCTION_NOT_CALLED, "wrong return val\n");
1130 MsiCloseHandle( hpkg );
1131 DeleteFileA(msifile);
1134 static void test_gettargetpath_bad(void)
1136 static const WCHAR boo[] = {'b','o','o',0};
1137 static const WCHAR empty[] = {0};
1138 char buffer[0x80];
1139 WCHAR bufferW[0x80];
1140 MSIHANDLE hpkg;
1141 DWORD sz;
1142 UINT r;
1144 r = package_from_db(create_package_db(), &hpkg);
1145 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
1147 skip("Not enough rights to perform tests\n");
1148 DeleteFileA(msifile);
1149 return;
1151 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
1153 r = MsiGetTargetPathA( 0, NULL, NULL, NULL );
1154 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1156 r = MsiGetTargetPathA( 0, NULL, NULL, &sz );
1157 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1159 r = MsiGetTargetPathA( 0, "boo", NULL, NULL );
1160 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
1162 r = MsiGetTargetPathA( 0, "boo", NULL, NULL );
1163 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
1165 r = MsiGetTargetPathA( hpkg, "boo", NULL, NULL );
1166 ok( r == ERROR_DIRECTORY, "wrong return val\n");
1168 r = MsiGetTargetPathA( hpkg, "boo", buffer, NULL );
1169 ok( r == ERROR_DIRECTORY, "wrong return val\n");
1171 sz = 0;
1172 r = MsiGetTargetPathA( hpkg, "", buffer, &sz );
1173 ok( r == ERROR_DIRECTORY, "wrong return val\n");
1175 r = MsiGetTargetPathW( 0, NULL, NULL, NULL );
1176 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1178 r = MsiGetTargetPathW( 0, NULL, NULL, &sz );
1179 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1181 r = MsiGetTargetPathW( 0, boo, NULL, NULL );
1182 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
1184 r = MsiGetTargetPathW( 0, boo, NULL, NULL );
1185 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
1187 r = MsiGetTargetPathW( hpkg, boo, NULL, NULL );
1188 ok( r == ERROR_DIRECTORY, "wrong return val\n");
1190 r = MsiGetTargetPathW( hpkg, boo, bufferW, NULL );
1191 ok( r == ERROR_DIRECTORY, "wrong return val\n");
1193 sz = 0;
1194 r = MsiGetTargetPathW( hpkg, empty, bufferW, &sz );
1195 ok( r == ERROR_DIRECTORY, "wrong return val\n");
1197 MsiCloseHandle( hpkg );
1198 DeleteFileA(msifile);
1201 static void query_file_path(MSIHANDLE hpkg, LPCSTR file, LPSTR buff)
1203 UINT r;
1204 DWORD size;
1205 MSIHANDLE rec;
1207 rec = MsiCreateRecord( 1 );
1208 ok(rec, "MsiCreate record failed\n");
1210 r = MsiRecordSetStringA( rec, 0, file );
1211 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
1213 size = MAX_PATH;
1214 r = MsiFormatRecordA( hpkg, rec, buff, &size );
1215 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
1217 MsiCloseHandle( rec );
1220 static void test_settargetpath(void)
1222 char tempdir[MAX_PATH+8], buffer[MAX_PATH], file[MAX_PATH];
1223 DWORD sz;
1224 MSIHANDLE hpkg;
1225 UINT r;
1226 MSIHANDLE hdb;
1228 hdb = create_package_db();
1229 ok ( hdb, "failed to create package database\n" );
1231 add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'" );
1233 create_component_table( hdb );
1234 add_component_entry( hdb, "'RootComp', '{83e2694d-0864-4124-9323-6d37630912a1}', 'TARGETDIR', 8, '', 'RootFile'" );
1235 add_component_entry( hdb, "'TestComp', '{A3FB59C8-C293-4F7E-B8C5-F0E1D8EEE4E5}', 'TestDir', 0, '', 'TestFile'" );
1237 create_feature_table( hdb );
1238 add_feature_entry( hdb, "'TestFeature', '', '', '', 0, 1, '', 0" );
1240 create_feature_components_table( hdb );
1241 add_feature_components_entry( hdb, "'TestFeature', 'RootComp'" );
1242 add_feature_components_entry( hdb, "'TestFeature', 'TestComp'" );
1244 add_directory_entry( hdb, "'TestParent', 'TARGETDIR', 'TestParent'" );
1245 add_directory_entry( hdb, "'TestDir', 'TestParent', 'TestDir'" );
1247 create_file_table( hdb );
1248 add_file_entry( hdb, "'RootFile', 'RootComp', 'rootfile.txt', 0, '', '1033', 8192, 1" );
1249 add_file_entry( hdb, "'TestFile', 'TestComp', 'testfile.txt', 0, '', '1033', 8192, 1" );
1251 r = package_from_db( hdb, &hpkg );
1252 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
1254 skip("Not enough rights to perform tests\n");
1255 DeleteFileA(msifile);
1256 return;
1258 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
1260 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1262 r = MsiDoActionA( hpkg, "CostInitialize");
1263 ok( r == ERROR_SUCCESS, "cost init failed\n");
1265 r = MsiDoActionA( hpkg, "FileCost");
1266 ok( r == ERROR_SUCCESS, "file cost failed\n");
1268 r = MsiDoActionA( hpkg, "CostFinalize");
1269 ok( r == ERROR_SUCCESS, "cost finalize failed\n");
1271 buffer[0] = 0;
1272 sz = sizeof(buffer);
1273 r = MsiGetPropertyA( hpkg, "OutOfNoRbDiskSpace", buffer, &sz );
1274 ok( r == ERROR_SUCCESS, "MsiGetProperty returned %u\n", r );
1275 trace( "OutOfNoRbDiskSpace = \"%s\"\n", buffer );
1277 r = MsiSetTargetPathA( 0, NULL, NULL );
1278 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1280 r = MsiSetTargetPathA( 0, "boo", "C:\\bogusx" );
1281 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
1283 r = MsiSetTargetPathA( hpkg, "boo", NULL );
1284 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1286 r = MsiSetTargetPathA( hpkg, "boo", "c:\\bogusx" );
1287 ok( r == ERROR_DIRECTORY, "wrong return val\n");
1289 sz = sizeof tempdir - 1;
1290 r = MsiGetTargetPathA( hpkg, "TARGETDIR", tempdir, &sz );
1291 sprintf( file, "%srootfile.txt", tempdir );
1292 buffer[0] = 0;
1293 query_file_path( hpkg, "[#RootFile]", buffer );
1294 ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1295 ok( !lstrcmpA(buffer, file), "Expected %s, got %s\n", file, buffer );
1297 GetTempFileNameA( tempdir, "_wt", 0, buffer );
1298 sprintf( tempdir, "%s\\subdir", buffer );
1300 r = MsiSetTargetPathA( hpkg, "TARGETDIR", buffer );
1301 ok( r == ERROR_SUCCESS || r == ERROR_DIRECTORY,
1302 "MsiSetTargetPath on file returned %d\n", r );
1304 r = MsiSetTargetPathA( hpkg, "TARGETDIR", tempdir );
1305 ok( r == ERROR_SUCCESS || r == ERROR_DIRECTORY,
1306 "MsiSetTargetPath on 'subdir' of file returned %d\n", r );
1308 DeleteFileA( buffer );
1310 r = MsiSetTargetPathA( hpkg, "TARGETDIR", buffer );
1311 ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1313 r = GetFileAttributesA( buffer );
1314 ok ( r == INVALID_FILE_ATTRIBUTES, "file/directory exists after MsiSetTargetPath. Attributes: %08X\n", r );
1316 r = MsiSetTargetPathA( hpkg, "TARGETDIR", tempdir );
1317 ok( r == ERROR_SUCCESS, "MsiSetTargetPath on subsubdir returned %d\n", r );
1319 buffer[0] = 0;
1320 sz = sizeof buffer - 1;
1321 lstrcatA( tempdir, "\\" );
1322 r = MsiGetTargetPathA( hpkg, "TARGETDIR", buffer, &sz );
1323 ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1324 ok( !lstrcmpA(buffer, tempdir), "Expected %s, got %s\n", tempdir, buffer);
1326 sprintf( file, "%srootfile.txt", tempdir );
1327 query_file_path( hpkg, "[#RootFile]", buffer );
1328 ok( !lstrcmpA(buffer, file), "Expected %s, got %s\n", file, buffer);
1330 buffer[0] = 0;
1331 sz = sizeof(buffer);
1332 r = MsiGetPropertyA( hpkg, "TestParent", buffer, &sz );
1333 ok( r == ERROR_SUCCESS, "MsiGetProperty returned %u\n", r );
1334 lstrcatA( tempdir, "TestParent\\" );
1335 ok( !lstrcmpiA(buffer, tempdir), "Expected \"%s\", got \"%s\"\n", tempdir, buffer );
1337 r = MsiSetTargetPathA( hpkg, "TestParent", "C:\\one\\two" );
1338 ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1340 buffer[0] = 0;
1341 sz = sizeof(buffer);
1342 r = MsiGetPropertyA( hpkg, "TestParent", buffer, &sz );
1343 ok( r == ERROR_SUCCESS, "MsiGetProperty returned %u\n", r );
1344 ok( lstrcmpiA(buffer, "C:\\one\\two\\TestDir\\"),
1345 "Expected \"C:\\one\\two\\TestDir\\\", got \"%s\"\n", buffer );
1347 buffer[0] = 0;
1348 query_file_path( hpkg, "[#TestFile]", buffer );
1349 ok( !lstrcmpiA(buffer, "C:\\one\\two\\TestDir\\testfile.txt"),
1350 "Expected C:\\one\\two\\TestDir\\testfile.txt, got %s\n", buffer );
1352 buffer[0] = 0;
1353 sz = sizeof buffer - 1;
1354 r = MsiGetTargetPathA( hpkg, "TestParent", buffer, &sz );
1355 ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1356 ok( !lstrcmpiA(buffer, "C:\\one\\two\\"), "Expected C:\\one\\two\\, got %s\n", buffer);
1358 r = MsiSetTargetPathA( hpkg, "TestParent", "C:\\one\\two\\three" );
1359 ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1361 buffer[0] = 0;
1362 sz = sizeof buffer - 1;
1363 r = MsiGetTargetPathA( hpkg, "TestParent", buffer, &sz );
1364 ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1365 ok( !lstrcmpiA(buffer, "C:\\one\\two\\three\\"), "Expected C:\\one\\two\\three\\, got %s\n", buffer);
1367 r = MsiSetTargetPathA( hpkg, "TestParent", "C:\\\\one\\\\two " );
1368 ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1370 buffer[0] = 0;
1371 sz = sizeof buffer - 1;
1372 r = MsiGetTargetPathA( hpkg, "TestParent", buffer, &sz );
1373 ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1374 ok( !lstrcmpiA(buffer, "C:\\one\\two\\"), "Expected \"C:\\one\\two\\\", got %s\n", buffer);
1376 r = MsiSetTargetPathA( hpkg, "TestParent", "C:\\\\ Program Files \\\\ " );
1377 ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1379 buffer[0] = 0;
1380 sz = sizeof buffer - 1;
1381 r = MsiGetTargetPathA( hpkg, "TestParent", buffer, &sz );
1382 ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1383 ok( !lstrcmpiA(buffer, "C:\\Program Files\\"), "Expected \"C:\\Program Files\\\", got %s\n", buffer);
1385 MsiCloseHandle( hpkg );
1388 static void test_condition(void)
1390 static const WCHAR cond1[] = {'\"','a',0x30a,'\"','<','\"',0xe5,'\"',0};
1391 static const WCHAR cond2[] = {'\"','a',0x30a,'\"','>','\"',0xe5,'\"',0};
1392 static const WCHAR cond3[] = {'\"','a',0x30a,'\"','<','>','\"',0xe5,'\"',0};
1393 static const WCHAR cond4[] = {'\"','a',0x30a,'\"','=','\"',0xe5,'\"',0};
1394 MSICONDITION r;
1395 MSIHANDLE hpkg;
1397 r = package_from_db(create_package_db(), &hpkg);
1398 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
1400 skip("Not enough rights to perform tests\n");
1401 DeleteFileA(msifile);
1402 return;
1404 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
1406 r = MsiEvaluateConditionA(0, NULL);
1407 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1409 r = MsiEvaluateConditionA(hpkg, NULL);
1410 ok( r == MSICONDITION_NONE, "wrong return val\n");
1412 r = MsiEvaluateConditionA(hpkg, "");
1413 ok( r == MSICONDITION_NONE, "wrong return val\n");
1415 r = MsiEvaluateConditionA(hpkg, "1");
1416 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1418 r = MsiEvaluateConditionA(hpkg, "0");
1419 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1421 r = MsiEvaluateConditionA(hpkg, "-1");
1422 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1424 r = MsiEvaluateConditionA(hpkg, "0 = 0");
1425 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1427 r = MsiEvaluateConditionA(hpkg, "0 <> 0");
1428 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1430 r = MsiEvaluateConditionA(hpkg, "0 = 1");
1431 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1433 r = MsiEvaluateConditionA(hpkg, "0 > 1");
1434 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1436 r = MsiEvaluateConditionA(hpkg, "0 ~> 1");
1437 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1439 r = MsiEvaluateConditionA(hpkg, "1 > 1");
1440 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1442 r = MsiEvaluateConditionA(hpkg, "1 ~> 1");
1443 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1445 r = MsiEvaluateConditionA(hpkg, "0 >= 1");
1446 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1448 r = MsiEvaluateConditionA(hpkg, "0 ~>= 1");
1449 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1451 r = MsiEvaluateConditionA(hpkg, "1 >= 1");
1452 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1454 r = MsiEvaluateConditionA(hpkg, "1 ~>= 1");
1455 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1457 r = MsiEvaluateConditionA(hpkg, "0 < 1");
1458 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1460 r = MsiEvaluateConditionA(hpkg, "0 ~< 1");
1461 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1463 r = MsiEvaluateConditionA(hpkg, "1 < 1");
1464 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1466 r = MsiEvaluateConditionA(hpkg, "1 ~< 1");
1467 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1469 r = MsiEvaluateConditionA(hpkg, "0 <= 1");
1470 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1472 r = MsiEvaluateConditionA(hpkg, "0 ~<= 1");
1473 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1475 r = MsiEvaluateConditionA(hpkg, "1 <= 1");
1476 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1478 r = MsiEvaluateConditionA(hpkg, "1 ~<= 1");
1479 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1481 r = MsiEvaluateConditionA(hpkg, "0 >=");
1482 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1484 r = MsiEvaluateConditionA(hpkg, " ");
1485 ok( r == MSICONDITION_NONE, "wrong return val\n");
1487 r = MsiEvaluateConditionA(hpkg, "LicView <> \"1\"");
1488 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1490 r = MsiEvaluateConditionA(hpkg, "LicView <> \"0\"");
1491 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1493 r = MsiEvaluateConditionA(hpkg, "LicView <> LicView");
1494 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1496 r = MsiEvaluateConditionA(hpkg, "not 0");
1497 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1499 r = MsiEvaluateConditionA(hpkg, "not LicView");
1500 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1502 r = MsiEvaluateConditionA(hpkg, "\"Testing\" ~<< \"Testing\"");
1503 ok (r == MSICONDITION_TRUE, "wrong return val\n");
1505 r = MsiEvaluateConditionA(hpkg, "LicView ~<< \"Testing\"");
1506 ok (r == MSICONDITION_FALSE, "wrong return val\n");
1508 r = MsiEvaluateConditionA(hpkg, "Not LicView ~<< \"Testing\"");
1509 ok (r == MSICONDITION_TRUE, "wrong return val\n");
1511 r = MsiEvaluateConditionA(hpkg, "not \"A\"");
1512 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1514 r = MsiEvaluateConditionA(hpkg, "~not \"A\"");
1515 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1517 r = MsiEvaluateConditionA(hpkg, "\"0\"");
1518 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1520 r = MsiEvaluateConditionA(hpkg, "1 and 2");
1521 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1523 r = MsiEvaluateConditionA(hpkg, "not 0 and 3");
1524 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1526 r = MsiEvaluateConditionA(hpkg, "not 0 and 0");
1527 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1529 r = MsiEvaluateConditionA(hpkg, "not 0 or 1");
1530 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1532 r = MsiEvaluateConditionA(hpkg, "(0)");
1533 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1535 r = MsiEvaluateConditionA(hpkg, "(((((1))))))");
1536 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1538 r = MsiEvaluateConditionA(hpkg, "(((((1)))))");
1539 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1541 r = MsiEvaluateConditionA(hpkg, " \"A\" < \"B\" ");
1542 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1544 r = MsiEvaluateConditionA(hpkg, " \"A\" > \"B\" ");
1545 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1547 r = MsiEvaluateConditionA(hpkg, " \"1\" > \"12\" ");
1548 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1550 r = MsiEvaluateConditionA(hpkg, " \"100\" < \"21\" ");
1551 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1553 r = MsiEvaluateConditionA(hpkg, "0 < > 0");
1554 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1556 r = MsiEvaluateConditionA(hpkg, "(1<<1) == 2");
1557 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1559 r = MsiEvaluateConditionA(hpkg, " \"A\" = \"a\" ");
1560 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1562 r = MsiEvaluateConditionA(hpkg, " \"A\" ~ = \"a\" ");
1563 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1565 r = MsiEvaluateConditionA(hpkg, " \"A\" ~= \"a\" ");
1566 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1568 r = MsiEvaluateConditionA(hpkg, " \"A\" ~= 1 ");
1569 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1571 r = MsiEvaluateConditionA(hpkg, " \"A\" = 1 ");
1572 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1574 r = MsiEvaluateConditionA(hpkg, " 1 ~= 1 ");
1575 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1577 r = MsiEvaluateConditionA(hpkg, " 1 ~= \"1\" ");
1578 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1580 r = MsiEvaluateConditionA(hpkg, " 1 = \"1\" ");
1581 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1583 r = MsiEvaluateConditionA(hpkg, " 0 = \"1\" ");
1584 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1586 r = MsiEvaluateConditionA(hpkg, " 0 < \"100\" ");
1587 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1589 r = MsiEvaluateConditionA(hpkg, " 100 > \"0\" ");
1590 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1592 r = MsiEvaluateConditionA(hpkg, "1 XOR 1");
1593 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1595 r = MsiEvaluateConditionA(hpkg, "1 IMP 1");
1596 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1598 r = MsiEvaluateConditionA(hpkg, "1 IMP 0");
1599 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1601 r = MsiEvaluateConditionA(hpkg, "0 IMP 0");
1602 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1604 r = MsiEvaluateConditionA(hpkg, "0 EQV 0");
1605 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1607 r = MsiEvaluateConditionA(hpkg, "0 EQV 1");
1608 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1610 r = MsiEvaluateConditionA(hpkg, "1 IMP 1 OR 0");
1611 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1613 r = MsiEvaluateConditionA(hpkg, "1 IMPL 1");
1614 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1616 r = MsiEvaluateConditionA(hpkg, "\"ASFD\" >< \"S\" ");
1617 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1619 r = MsiEvaluateConditionA(hpkg, "\"ASFD\" ~>< \"s\" ");
1620 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1622 r = MsiEvaluateConditionA(hpkg, "\"ASFD\" ~>< \"\" ");
1623 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1625 r = MsiEvaluateConditionA(hpkg, "\"ASFD\" ~>< \"sss\" ");
1626 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1628 MsiSetPropertyA(hpkg, "mm", "5" );
1630 r = MsiEvaluateConditionA(hpkg, "mm = 5");
1631 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1633 r = MsiEvaluateConditionA(hpkg, "mm < 6");
1634 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1636 r = MsiEvaluateConditionA(hpkg, "mm <= 5");
1637 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1639 r = MsiEvaluateConditionA(hpkg, "mm > 4");
1640 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1642 r = MsiEvaluateConditionA(hpkg, "mm < 12");
1643 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1645 r = MsiEvaluateConditionA(hpkg, "mm = \"5\"");
1646 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1648 r = MsiEvaluateConditionA(hpkg, "0 = \"\"");
1649 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1651 r = MsiEvaluateConditionA(hpkg, "0 AND \"\"");
1652 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1654 r = MsiEvaluateConditionA(hpkg, "1 AND \"\"");
1655 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1657 r = MsiEvaluateConditionA(hpkg, "1 AND \"1\"");
1658 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1660 r = MsiEvaluateConditionA(hpkg, "3 >< 1");
1661 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1663 r = MsiEvaluateConditionA(hpkg, "3 >< 4");
1664 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1666 r = MsiEvaluateConditionA(hpkg, "NOT 0 AND 0");
1667 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1669 r = MsiEvaluateConditionA(hpkg, "NOT 0 AND 1");
1670 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1672 r = MsiEvaluateConditionA(hpkg, "NOT 1 OR 0");
1673 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1675 r = MsiEvaluateConditionA(hpkg, "0 AND 1 OR 1");
1676 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1678 r = MsiEvaluateConditionA(hpkg, "0 AND 0 OR 1");
1679 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1681 r = MsiEvaluateConditionA(hpkg, "NOT 0 AND 1 OR 0");
1682 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1684 r = MsiEvaluateConditionA(hpkg, "_1 = _1");
1685 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1687 r = MsiEvaluateConditionA(hpkg, "( 1 AND 1 ) = 2");
1688 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1690 r = MsiEvaluateConditionA(hpkg, "NOT ( 1 AND 1 )");
1691 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1693 r = MsiEvaluateConditionA(hpkg, "NOT A AND (BBBBBBBBBB=2 OR CCC=1) AND Ddddddddd");
1694 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1696 r = MsiEvaluateConditionA(hpkg, "Installed<>\"\"");
1697 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1699 r = MsiEvaluateConditionA(hpkg, "NOT 1 AND 0");
1700 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1702 r = MsiEvaluateConditionA(hpkg, "bandalmael=0");
1703 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1705 r = MsiEvaluateConditionA(hpkg, "bandalmael<>0");
1706 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1708 r = MsiEvaluateConditionA(hpkg, "bandalmael<0");
1709 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1711 r = MsiEvaluateConditionA(hpkg, "bandalmael>0");
1712 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1714 r = MsiEvaluateConditionA(hpkg, "bandalmael>=0");
1715 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1717 r = MsiEvaluateConditionA(hpkg, "bandalmael<=0");
1718 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1720 r = MsiEvaluateConditionA(hpkg, "bandalmael~<>0");
1721 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1723 MsiSetPropertyA(hpkg, "bandalmael", "0" );
1724 r = MsiEvaluateConditionA(hpkg, "bandalmael=0");
1725 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1727 MsiSetPropertyA(hpkg, "bandalmael", "" );
1728 r = MsiEvaluateConditionA(hpkg, "bandalmael=0");
1729 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1731 MsiSetPropertyA(hpkg, "bandalmael", "asdf" );
1732 r = MsiEvaluateConditionA(hpkg, "bandalmael=0");
1733 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1735 MsiSetPropertyA(hpkg, "bandalmael", "0asdf" );
1736 r = MsiEvaluateConditionA(hpkg, "bandalmael=0");
1737 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1739 MsiSetPropertyA(hpkg, "bandalmael", "0 " );
1740 r = MsiEvaluateConditionA(hpkg, "bandalmael=0");
1741 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1743 MsiSetPropertyA(hpkg, "bandalmael", "-0" );
1744 r = MsiEvaluateConditionA(hpkg, "bandalmael=0");
1745 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1747 MsiSetPropertyA(hpkg, "bandalmael", "0000000000000" );
1748 r = MsiEvaluateConditionA(hpkg, "bandalmael=0");
1749 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1751 MsiSetPropertyA(hpkg, "bandalmael", "--0" );
1752 r = MsiEvaluateConditionA(hpkg, "bandalmael=0");
1753 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1755 MsiSetPropertyA(hpkg, "bandalmael", "0x00" );
1756 r = MsiEvaluateConditionA(hpkg, "bandalmael=0");
1757 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1759 MsiSetPropertyA(hpkg, "bandalmael", "-" );
1760 r = MsiEvaluateConditionA(hpkg, "bandalmael=0");
1761 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1763 MsiSetPropertyA(hpkg, "bandalmael", "+0" );
1764 r = MsiEvaluateConditionA(hpkg, "bandalmael=0");
1765 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1767 MsiSetPropertyA(hpkg, "bandalmael", "0.0" );
1768 r = MsiEvaluateConditionA(hpkg, "bandalmael=0");
1769 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1770 r = MsiEvaluateConditionA(hpkg, "bandalmael<>0");
1771 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1773 MsiSetPropertyA(hpkg, "one", "hi");
1774 MsiSetPropertyA(hpkg, "two", "hithere");
1775 r = MsiEvaluateConditionA(hpkg, "one >< two");
1776 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1778 MsiSetPropertyA(hpkg, "one", "hithere");
1779 MsiSetPropertyA(hpkg, "two", "hi");
1780 r = MsiEvaluateConditionA(hpkg, "one >< two");
1781 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1783 MsiSetPropertyA(hpkg, "one", "hello");
1784 MsiSetPropertyA(hpkg, "two", "hi");
1785 r = MsiEvaluateConditionA(hpkg, "one >< two");
1786 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1788 MsiSetPropertyA(hpkg, "one", "hellohithere");
1789 MsiSetPropertyA(hpkg, "two", "hi");
1790 r = MsiEvaluateConditionA(hpkg, "one >< two");
1791 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1793 MsiSetPropertyA(hpkg, "one", "");
1794 MsiSetPropertyA(hpkg, "two", "hi");
1795 r = MsiEvaluateConditionA(hpkg, "one >< two");
1796 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1798 MsiSetPropertyA(hpkg, "one", "hi");
1799 MsiSetPropertyA(hpkg, "two", "");
1800 r = MsiEvaluateConditionA(hpkg, "one >< two");
1801 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1803 MsiSetPropertyA(hpkg, "one", "");
1804 MsiSetPropertyA(hpkg, "two", "");
1805 r = MsiEvaluateConditionA(hpkg, "one >< two");
1806 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1808 MsiSetPropertyA(hpkg, "one", "1234");
1809 MsiSetPropertyA(hpkg, "two", "1");
1810 r = MsiEvaluateConditionA(hpkg, "one >< two");
1811 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1813 MsiSetPropertyA(hpkg, "one", "one 1234");
1814 MsiSetPropertyA(hpkg, "two", "1");
1815 r = MsiEvaluateConditionA(hpkg, "one >< two");
1816 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1818 MsiSetPropertyA(hpkg, "one", "hithere");
1819 MsiSetPropertyA(hpkg, "two", "hi");
1820 r = MsiEvaluateConditionA(hpkg, "one << two");
1821 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1823 MsiSetPropertyA(hpkg, "one", "hi");
1824 MsiSetPropertyA(hpkg, "two", "hithere");
1825 r = MsiEvaluateConditionA(hpkg, "one << two");
1826 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1828 MsiSetPropertyA(hpkg, "one", "hi");
1829 MsiSetPropertyA(hpkg, "two", "hi");
1830 r = MsiEvaluateConditionA(hpkg, "one << two");
1831 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1833 MsiSetPropertyA(hpkg, "one", "abcdhithere");
1834 MsiSetPropertyA(hpkg, "two", "hi");
1835 r = MsiEvaluateConditionA(hpkg, "one << two");
1836 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1838 MsiSetPropertyA(hpkg, "one", "");
1839 MsiSetPropertyA(hpkg, "two", "hi");
1840 r = MsiEvaluateConditionA(hpkg, "one << two");
1841 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1843 MsiSetPropertyA(hpkg, "one", "hithere");
1844 MsiSetPropertyA(hpkg, "two", "");
1845 r = MsiEvaluateConditionA(hpkg, "one << two");
1846 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1848 MsiSetPropertyA(hpkg, "one", "");
1849 MsiSetPropertyA(hpkg, "two", "");
1850 r = MsiEvaluateConditionA(hpkg, "one << two");
1851 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1853 MsiSetPropertyA(hpkg, "one", "1234");
1854 MsiSetPropertyA(hpkg, "two", "1");
1855 r = MsiEvaluateConditionA(hpkg, "one << two");
1856 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1858 MsiSetPropertyA(hpkg, "one", "1234 one");
1859 MsiSetPropertyA(hpkg, "two", "1");
1860 r = MsiEvaluateConditionA(hpkg, "one << two");
1861 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1863 MsiSetPropertyA(hpkg, "one", "hithere");
1864 MsiSetPropertyA(hpkg, "two", "there");
1865 r = MsiEvaluateConditionA(hpkg, "one >> two");
1866 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1868 MsiSetPropertyA(hpkg, "one", "hithere");
1869 MsiSetPropertyA(hpkg, "two", "hi");
1870 r = MsiEvaluateConditionA(hpkg, "one >> two");
1871 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1873 MsiSetPropertyA(hpkg, "one", "there");
1874 MsiSetPropertyA(hpkg, "two", "hithere");
1875 r = MsiEvaluateConditionA(hpkg, "one >> two");
1876 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1878 MsiSetPropertyA(hpkg, "one", "there");
1879 MsiSetPropertyA(hpkg, "two", "there");
1880 r = MsiEvaluateConditionA(hpkg, "one >> two");
1881 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1883 MsiSetPropertyA(hpkg, "one", "abcdhithere");
1884 MsiSetPropertyA(hpkg, "two", "hi");
1885 r = MsiEvaluateConditionA(hpkg, "one >> two");
1886 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1888 MsiSetPropertyA(hpkg, "one", "");
1889 MsiSetPropertyA(hpkg, "two", "there");
1890 r = MsiEvaluateConditionA(hpkg, "one >> two");
1891 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1893 MsiSetPropertyA(hpkg, "one", "there");
1894 MsiSetPropertyA(hpkg, "two", "");
1895 r = MsiEvaluateConditionA(hpkg, "one >> two");
1896 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1898 MsiSetPropertyA(hpkg, "one", "");
1899 MsiSetPropertyA(hpkg, "two", "");
1900 r = MsiEvaluateConditionA(hpkg, "one >> two");
1901 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1903 MsiSetPropertyA(hpkg, "one", "1234");
1904 MsiSetPropertyA(hpkg, "two", "4");
1905 r = MsiEvaluateConditionA(hpkg, "one >> two");
1906 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1908 MsiSetPropertyA(hpkg, "one", "one 1234");
1909 MsiSetPropertyA(hpkg, "two", "4");
1910 r = MsiEvaluateConditionA(hpkg, "one >> two");
1911 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1913 MsiSetPropertyA(hpkg, "MsiNetAssemblySupport", NULL); /* make sure it's empty */
1915 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"1.1.4322\"");
1916 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1918 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport > \"1.1.4322\"");
1919 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1921 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport >= \"1.1.4322\"");
1922 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1924 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport <= \"1.1.4322\"");
1925 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1927 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport <> \"1.1.4322\"");
1928 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1930 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport ~< \"1.1.4322\"");
1931 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1933 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"abcd\"");
1934 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1936 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"a1.1.4322\"");
1937 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1939 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"1.1.4322a\"");
1940 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1942 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"0000001.1.4322\"");
1943 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1945 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"1.1.4322.1\"");
1946 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1948 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"1.1.4322.1.1\"");
1949 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1951 r = MsiEvaluateConditionA(hpkg, "\"2\" < \"1.1");
1952 ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1954 r = MsiEvaluateConditionA(hpkg, "\"2\" < \"1.1\"");
1955 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1957 r = MsiEvaluateConditionA(hpkg, "\"2\" < \"12.1\"");
1958 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1960 r = MsiEvaluateConditionA(hpkg, "\"02.1\" < \"2.11\"");
1961 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1963 r = MsiEvaluateConditionA(hpkg, "\"02.1.1\" < \"2.1\"");
1964 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1966 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"1.1\"");
1967 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1969 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"1\"");
1970 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1972 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"0\"");
1973 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1975 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"-1\"");
1976 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1978 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"a\"");
1979 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1981 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"!\"");
1982 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1984 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"!\"");
1985 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1987 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"/\"");
1988 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1990 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \" \"");
1991 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1993 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"azAZ_\"");
1994 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1996 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"a[a]\"");
1997 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1999 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"a[a]a\"");
2000 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
2002 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"[a]\"");
2003 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
2005 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"[a]a\"");
2006 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
2008 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"{a}\"");
2009 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
2011 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"{a\"");
2012 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
2014 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"[a\"");
2015 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
2017 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"a{\"");
2018 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
2020 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"a]\"");
2021 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
2023 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"A\"");
2024 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
2026 MsiSetPropertyA(hpkg, "MsiNetAssemblySupport", "1.1.4322");
2027 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"1.1.4322\"");
2028 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
2030 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"1.1.14322\"");
2031 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
2033 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"1.1.5\"");
2034 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
2036 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"1.1\"");
2037 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
2039 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"1\"");
2040 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
2042 MsiSetPropertyA(hpkg, "one", "1");
2043 r = MsiEvaluateConditionA(hpkg, "one < \"1\"");
2044 ok( r == MSICONDITION_FALSE, "wrong return val\n");
2046 MsiSetPropertyA(hpkg, "X", "5.0");
2048 r = MsiEvaluateConditionA(hpkg, "X != \"\"");
2049 ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
2051 r = MsiEvaluateConditionA(hpkg, "X =\"5.0\"");
2052 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
2054 r = MsiEvaluateConditionA(hpkg, "X =\"5.1\"");
2055 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
2057 r = MsiEvaluateConditionA(hpkg, "X =\"6.0\"");
2058 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
2060 r = MsiEvaluateConditionA(hpkg, "X =\"5.0\" or X =\"5.1\" or X =\"6.0\"");
2061 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
2063 r = MsiEvaluateConditionA(hpkg, "(X =\"5.0\" or X =\"5.1\" or X =\"6.0\")");
2064 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
2066 r = MsiEvaluateConditionA(hpkg, "X !=\"\" and (X =\"5.0\" or X =\"5.1\" or X =\"6.0\")");
2067 ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
2069 /* feature doesn't exist */
2070 r = MsiEvaluateConditionA(hpkg, "&nofeature");
2071 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
2072 r = MsiEvaluateConditionA(hpkg, "&nofeature=\"\"");
2073 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
2074 r = MsiEvaluateConditionA(hpkg, "!nofeature=\"\"");
2075 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
2076 MsiEvaluateConditionA(hpkg, "$nocomponent=\"\"");
2077 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
2078 MsiEvaluateConditionA(hpkg, "?nocomponent=\"\"");
2079 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
2081 MsiSetPropertyA(hpkg, "A", "2");
2082 MsiSetPropertyA(hpkg, "X", "50");
2084 r = MsiEvaluateConditionA(hpkg, "2 <= X");
2085 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
2087 r = MsiEvaluateConditionA(hpkg, "A <= X");
2088 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
2090 r = MsiEvaluateConditionA(hpkg, "A <= 50");
2091 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
2093 MsiSetPropertyA(hpkg, "X", "50val");
2095 r = MsiEvaluateConditionA(hpkg, "2 <= X");
2096 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
2098 r = MsiEvaluateConditionA(hpkg, "A <= X");
2099 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
2101 MsiSetPropertyA(hpkg, "A", "7");
2102 MsiSetPropertyA(hpkg, "X", "50");
2104 r = MsiEvaluateConditionA(hpkg, "7 <= X");
2105 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
2107 r = MsiEvaluateConditionA(hpkg, "A <= X");
2108 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
2110 r = MsiEvaluateConditionA(hpkg, "A <= 50");
2111 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
2113 MsiSetPropertyA(hpkg, "X", "50val");
2115 r = MsiEvaluateConditionA(hpkg, "2 <= X");
2116 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
2118 r = MsiEvaluateConditionA(hpkg, "A <= X");
2119 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
2121 r = MsiEvaluateConditionW(hpkg, cond1);
2122 ok( r == MSICONDITION_TRUE || broken(r == MSICONDITION_FALSE),
2123 "wrong return val (%d)\n", r);
2125 r = MsiEvaluateConditionW(hpkg, cond2);
2126 ok( r == MSICONDITION_FALSE || broken(r == MSICONDITION_TRUE),
2127 "wrong return val (%d)\n", r);
2129 r = MsiEvaluateConditionW(hpkg, cond3);
2130 ok( r == MSICONDITION_TRUE || broken(r == MSICONDITION_FALSE),
2131 "wrong return val (%d)\n", r);
2133 r = MsiEvaluateConditionW(hpkg, cond4);
2134 ok( r == MSICONDITION_FALSE || broken(r == MSICONDITION_TRUE),
2135 "wrong return val (%d)\n", r);
2137 MsiCloseHandle( hpkg );
2138 DeleteFileA(msifile);
2141 static void check_prop(MSIHANDLE hpkg, const char *prop, const char *expect)
2143 char buffer[20] = "x";
2144 DWORD sz = sizeof(buffer);
2145 UINT r = MsiGetPropertyA(hpkg, prop, buffer, &sz);
2146 ok(!r, "'%s': got %u\n", prop, r);
2147 ok(sz == lstrlenA(buffer), "'%s': expected %u, got %u\n", prop, lstrlenA(buffer), sz);
2148 ok(!strcmp(buffer, expect), "expected '%s', got '%s'\n", expect, buffer);
2151 static void test_props(void)
2153 static const WCHAR booW[] = {'b','o','o',0};
2154 static const WCHAR xyzW[] = {'x','y','z',0};
2155 static const WCHAR xyW[] = {'x','y',0};
2156 MSIHANDLE hpkg, hdb;
2157 UINT r;
2158 DWORD sz;
2159 char buffer[0x100];
2160 WCHAR bufferW[10];
2162 hdb = create_package_db();
2164 create_property_table(hdb);
2165 add_property_entry(hdb, "'MetadataCompName', 'Photoshop.dll'");
2167 r = package_from_db( hdb, &hpkg );
2168 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
2170 skip("Not enough rights to perform tests\n");
2171 DeleteFileA(msifile);
2172 return;
2174 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
2176 /* test invalid values */
2177 r = MsiGetPropertyA( 0, NULL, NULL, NULL );
2178 ok(r == ERROR_INVALID_PARAMETER, "got %u\n", r);
2180 r = MsiGetPropertyA( hpkg, NULL, NULL, NULL );
2181 ok(r == ERROR_INVALID_PARAMETER, "got %u\n", r);
2183 r = MsiGetPropertyA( hpkg, "boo", NULL, NULL );
2184 ok(!r, "got %u\n", r);
2186 r = MsiGetPropertyA( hpkg, "boo", buffer, NULL );
2187 ok(r == ERROR_INVALID_PARAMETER, "got %u\n", r);
2189 /* test retrieving an empty/nonexistent property */
2190 sz = sizeof buffer;
2191 r = MsiGetPropertyA( hpkg, "boo", NULL, &sz );
2192 ok(!r, "got %u\n", r);
2193 ok(sz == 0, "got size %d\n", sz);
2195 sz = 0;
2196 strcpy(buffer,"x");
2197 r = MsiGetPropertyA( hpkg, "boo", buffer, &sz );
2198 ok(r == ERROR_MORE_DATA, "got %u\n", r);
2199 ok(!strcmp(buffer,"x"), "got \"%s\"\n", buffer);
2200 ok(sz == 0, "got size %u\n", sz);
2202 sz = 1;
2203 strcpy(buffer,"x");
2204 r = MsiGetPropertyA( hpkg, "boo", buffer, &sz );
2205 ok(!r, "got %u\n", r);
2206 ok(!buffer[0], "got \"%s\"\n", buffer);
2207 ok(sz == 0, "got size %u\n", sz);
2209 /* set the property to something */
2210 r = MsiSetPropertyA( 0, NULL, NULL );
2211 ok(r == ERROR_INVALID_HANDLE, "got %u\n", r);
2213 r = MsiSetPropertyA( hpkg, NULL, NULL );
2214 ok(r == ERROR_INVALID_PARAMETER, "got %u\n", r);
2216 r = MsiSetPropertyA( hpkg, "", NULL );
2217 ok(!r, "got %u\n", r);
2219 r = MsiSetPropertyA( hpkg, "", "asdf" );
2220 ok(r == ERROR_FUNCTION_FAILED, "got %u\n", r);
2222 r = MsiSetPropertyA( hpkg, "=", "asdf" );
2223 ok(!r, "got %u\n", r);
2224 check_prop(hpkg, "=", "asdf");
2226 r = MsiSetPropertyA( hpkg, " ", "asdf" );
2227 ok(!r, "got %u\n", r);
2228 check_prop(hpkg, " ", "asdf");
2230 r = MsiSetPropertyA( hpkg, "'", "asdf" );
2231 ok(!r, "got %u\n", r);
2232 check_prop(hpkg, "'", "asdf");
2234 /* set empty values */
2235 r = MsiSetPropertyA( hpkg, "boo", NULL );
2236 ok(!r, "got %u\n", r);
2237 check_prop(hpkg, "boo", "");
2239 r = MsiSetPropertyA( hpkg, "boo", "" );
2240 ok(!r, "got %u\n", r);
2241 check_prop(hpkg, "boo", "");
2243 /* set a non-empty value */
2244 r = MsiSetPropertyA( hpkg, "boo", "xyz" );
2245 ok(!r, "got %u\n", r);
2246 check_prop(hpkg, "boo", "xyz");
2248 r = MsiGetPropertyA(hpkg, "boo", NULL, NULL);
2249 ok(!r, "got %u\n", r);
2251 r = MsiGetPropertyA(hpkg, "boo", buffer, NULL);
2252 ok(r == ERROR_INVALID_PARAMETER, "got %u\n", r);
2254 sz = 0;
2255 r = MsiGetPropertyA(hpkg, "boo", NULL, &sz);
2256 ok(!r, "got %u\n", r);
2257 ok(sz == 3, "got size %u\n", sz);
2259 sz = 0;
2260 strcpy(buffer, "q");
2261 r = MsiGetPropertyA(hpkg, "boo", buffer, &sz);
2262 ok(r == ERROR_MORE_DATA, "got %u\n", r);
2263 ok(!strcmp(buffer, "q"), "got \"%s\"", buffer);
2264 ok(sz == 3, "got size %u\n", sz);
2266 sz = 1;
2267 strcpy(buffer,"x");
2268 r = MsiGetPropertyA( hpkg, "boo", buffer, &sz );
2269 ok(r == ERROR_MORE_DATA, "got %u\n", r);
2270 ok(!buffer[0], "got \"%s\"\n", buffer);
2271 ok(sz == 3, "got size %u\n", sz);
2273 sz = 3;
2274 strcpy(buffer,"x");
2275 r = MsiGetPropertyA( hpkg, "boo", buffer, &sz );
2276 ok(r == ERROR_MORE_DATA, "got %u\n", r);
2277 ok(!strcmp(buffer,"xy"), "got \"%s\"\n", buffer);
2278 ok(sz == 3, "got size %u\n", sz);
2280 sz = 4;
2281 strcpy(buffer,"x");
2282 r = MsiGetPropertyA( hpkg, "boo", buffer, &sz );
2283 ok(!r, "got %u\n", r);
2284 ok(!strcmp(buffer,"xyz"), "got \"%s\"\n", buffer);
2285 ok(sz == 3, "got size %u\n", sz);
2287 sz = 0;
2288 r = MsiGetPropertyW(hpkg, booW, NULL, &sz);
2289 ok(!r, "got %u\n", r);
2290 ok(sz == 3, "got size %u\n", sz);
2292 sz = 0;
2293 lstrcpyW(bufferW, booW);
2294 r = MsiGetPropertyW(hpkg, booW, bufferW, &sz);
2295 ok(r == ERROR_MORE_DATA, "got %u\n", r);
2296 ok(!lstrcmpW(bufferW, booW), "got %s\n", wine_dbgstr_w(bufferW));
2297 ok(sz == 3, "got size %u\n", sz);
2299 sz = 1;
2300 lstrcpyW(bufferW, booW);
2301 r = MsiGetPropertyW(hpkg, booW, bufferW, &sz );
2302 ok(r == ERROR_MORE_DATA, "got %u\n", r);
2303 ok(!bufferW[0], "got %s\n", wine_dbgstr_w(bufferW));
2304 ok(sz == 3, "got size %u\n", sz);
2306 sz = 3;
2307 lstrcpyW(bufferW, booW);
2308 r = MsiGetPropertyW(hpkg, booW, bufferW, &sz );
2309 ok(r == ERROR_MORE_DATA, "got %u\n", r);
2310 ok(!lstrcmpW(bufferW, xyW), "got %s\n", wine_dbgstr_w(bufferW));
2311 ok(sz == 3, "got size %u\n", sz);
2313 sz = 4;
2314 lstrcpyW(bufferW, booW);
2315 r = MsiGetPropertyW(hpkg, booW, bufferW, &sz );
2316 ok(!r, "got %u\n", r);
2317 ok(!lstrcmpW(bufferW, xyzW), "got %s\n", wine_dbgstr_w(bufferW));
2318 ok(sz == 3, "got size %u\n", sz);
2320 /* properties are case-sensitive */
2321 check_prop(hpkg, "BOO", "");
2323 /* properties set in Property table should work */
2324 check_prop(hpkg, "MetadataCompName", "Photoshop.dll");
2326 MsiCloseHandle( hpkg );
2327 DeleteFileA(msifile);
2330 static BOOL find_prop_in_property(MSIHANDLE hdb, LPCSTR prop, LPCSTR val, int len)
2332 MSIHANDLE hview, hrec;
2333 BOOL found = FALSE;
2334 CHAR buffer[MAX_PATH];
2335 DWORD sz;
2336 UINT r;
2338 r = MsiDatabaseOpenViewA(hdb, "SELECT * FROM `_Property`", &hview);
2339 ok(r == ERROR_SUCCESS, "MsiDatabaseOpenView failed\n");
2340 r = MsiViewExecute(hview, 0);
2341 ok(r == ERROR_SUCCESS, "MsiViewExecute failed\n");
2343 if (len < 0) len = lstrlenA(val);
2345 while (r == ERROR_SUCCESS && !found)
2347 r = MsiViewFetch(hview, &hrec);
2348 if (r != ERROR_SUCCESS) break;
2350 sz = MAX_PATH;
2351 r = MsiRecordGetStringA(hrec, 1, buffer, &sz);
2352 if (r == ERROR_SUCCESS && !lstrcmpA(buffer, prop))
2354 sz = MAX_PATH;
2355 r = MsiRecordGetStringA(hrec, 2, buffer, &sz);
2356 if (r == ERROR_SUCCESS && !memcmp(buffer, val, len) && !buffer[len])
2358 ok(sz == len, "wrong size %u\n", sz);
2359 found = TRUE;
2363 MsiCloseHandle(hrec);
2365 MsiViewClose(hview);
2366 MsiCloseHandle(hview);
2367 return found;
2370 static void test_property_table(void)
2372 const char *query;
2373 UINT r;
2374 MSIHANDLE hpkg, hdb, hrec;
2375 char buffer[MAX_PATH], package[10];
2376 DWORD sz;
2377 BOOL found;
2379 hdb = create_package_db();
2380 ok( hdb, "failed to create package\n");
2382 r = package_from_db(hdb, &hpkg);
2383 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
2385 skip("Not enough rights to perform tests\n");
2386 DeleteFileA(msifile);
2387 return;
2389 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
2391 MsiCloseHandle(hdb);
2393 hdb = MsiGetActiveDatabase(hpkg);
2395 query = "CREATE TABLE `_Property` ( "
2396 "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
2397 r = run_query(hdb, query);
2398 ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
2400 MsiCloseHandle(hdb);
2401 MsiCloseHandle(hpkg);
2402 DeleteFileA(msifile);
2404 hdb = create_package_db();
2405 ok( hdb, "failed to create package\n");
2407 query = "CREATE TABLE `_Property` ( "
2408 "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
2409 r = run_query(hdb, query);
2410 ok(r == ERROR_SUCCESS, "failed to create table\n");
2412 query = "ALTER `_Property` ADD `foo` INTEGER";
2413 r = run_query(hdb, query);
2414 ok(r == ERROR_BAD_QUERY_SYNTAX, "failed to add column\n");
2416 query = "ALTER TABLE `_Property` ADD `foo` INTEGER";
2417 r = run_query(hdb, query);
2418 ok(r == ERROR_BAD_QUERY_SYNTAX, "failed to add column\n");
2420 query = "ALTER TABLE `_Property` ADD `extra` INTEGER";
2421 r = run_query(hdb, query);
2422 ok(r == ERROR_SUCCESS, "failed to add column\n");
2424 sprintf(package, "#%i", hdb);
2425 r = MsiOpenPackageA(package, &hpkg);
2426 ok(r != ERROR_SUCCESS, "MsiOpenPackage succeeded\n");
2427 if (r == ERROR_SUCCESS)
2428 MsiCloseHandle(hpkg);
2430 r = MsiCloseHandle(hdb);
2431 ok(r == ERROR_SUCCESS, "MsiCloseHandle failed %u\n", r);
2433 hdb = create_package_db();
2434 ok (hdb, "failed to create package database\n");
2436 create_property_table(hdb);
2437 add_property_entry(hdb, "'prop', 'val'");
2439 create_custom_action_table(hdb);
2440 add_custom_action_entry( hdb, "'EmbedNull', 51, 'prop2', '[~]np'" );
2442 r = package_from_db(hdb, &hpkg);
2443 ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
2445 MsiCloseHandle(hdb);
2447 sz = MAX_PATH;
2448 r = MsiGetPropertyA(hpkg, "prop", buffer, &sz);
2449 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2450 ok(!lstrcmpA(buffer, "val"), "Expected val, got %s\n", buffer);
2452 hdb = MsiGetActiveDatabase(hpkg);
2454 found = find_prop_in_property(hdb, "prop", "val", -1);
2455 ok(found, "prop should be in the _Property table\n");
2457 add_property_entry(hdb, "'dantes', 'mercedes'");
2459 query = "SELECT * FROM `_Property` WHERE `Property` = 'dantes'";
2460 r = do_query(hdb, query, &hrec);
2461 ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
2463 found = find_prop_in_property(hdb, "dantes", "mercedes", -1);
2464 ok(found == FALSE, "dantes should not be in the _Property table\n");
2466 sz = MAX_PATH;
2467 lstrcpyA(buffer, "aaa");
2468 r = MsiGetPropertyA(hpkg, "dantes", buffer, &sz);
2469 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2470 ok(!buffer[0], "Expected empty string, got %s\n", buffer);
2472 r = MsiSetPropertyA(hpkg, "dantes", "mercedes");
2473 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2475 found = find_prop_in_property(hdb, "dantes", "mercedes", -1);
2476 ok(found == TRUE, "dantes should be in the _Property table\n");
2478 r = MsiDoActionA( hpkg, "EmbedNull" );
2479 ok( r == ERROR_SUCCESS, "EmbedNull failed: %d\n", r);
2481 sz = MAX_PATH;
2482 memset( buffer, 'a', sizeof(buffer) );
2483 r = MsiGetPropertyA( hpkg, "prop2", buffer, &sz );
2484 ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
2485 ok( !memcmp( buffer, "\0np", sizeof("\0np") ), "wrong value\n");
2486 ok( sz == sizeof("\0np") - 1, "got %u\n", sz );
2488 found = find_prop_in_property(hdb, "prop2", "\0np", 3);
2489 ok(found == TRUE, "prop2 should be in the _Property table\n");
2491 MsiCloseHandle(hdb);
2492 MsiCloseHandle(hpkg);
2493 DeleteFileA(msifile);
2496 static UINT try_query_param( MSIHANDLE hdb, LPCSTR szQuery, MSIHANDLE hrec )
2498 MSIHANDLE htab = 0;
2499 UINT res;
2501 res = MsiDatabaseOpenViewA( hdb, szQuery, &htab );
2502 if( res == ERROR_SUCCESS )
2504 UINT r;
2506 r = MsiViewExecute( htab, hrec );
2507 if( r != ERROR_SUCCESS )
2509 res = r;
2510 fprintf(stderr,"MsiViewExecute failed %08x\n", res);
2513 r = MsiViewClose( htab );
2514 if( r != ERROR_SUCCESS )
2515 res = r;
2517 r = MsiCloseHandle( htab );
2518 if( r != ERROR_SUCCESS )
2519 res = r;
2521 return res;
2524 static UINT try_query( MSIHANDLE hdb, LPCSTR szQuery )
2526 return try_query_param( hdb, szQuery, 0 );
2529 static void set_summary_str(MSIHANDLE hdb, DWORD pid, LPCSTR value)
2531 MSIHANDLE summary;
2532 UINT r;
2534 r = MsiGetSummaryInformationA(hdb, NULL, 1, &summary);
2535 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2537 r = MsiSummaryInfoSetPropertyA(summary, pid, VT_LPSTR, 0, NULL, value);
2538 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2540 r = MsiSummaryInfoPersist(summary);
2541 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2543 MsiCloseHandle(summary);
2546 static void set_summary_dword(MSIHANDLE hdb, DWORD pid, DWORD value)
2548 MSIHANDLE summary;
2549 UINT r;
2551 r = MsiGetSummaryInformationA(hdb, NULL, 1, &summary);
2552 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2554 r = MsiSummaryInfoSetPropertyA(summary, pid, VT_I4, value, NULL, NULL);
2555 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2557 r = MsiSummaryInfoPersist(summary);
2558 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2560 MsiCloseHandle(summary);
2563 static void test_msipackage(void)
2565 MSIHANDLE hdb = 0, hpack = 100;
2566 UINT r;
2567 const char *query;
2568 char name[10];
2570 /* NULL szPackagePath */
2571 r = MsiOpenPackageA(NULL, &hpack);
2572 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2574 /* empty szPackagePath */
2575 r = MsiOpenPackageA("", &hpack);
2576 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
2578 skip("Not enough rights to perform tests\n");
2579 return;
2581 todo_wine
2583 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2586 if (r == ERROR_SUCCESS)
2587 MsiCloseHandle(hpack);
2589 /* nonexistent szPackagePath */
2590 r = MsiOpenPackageA("nonexistent", &hpack);
2591 ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
2593 /* NULL hProduct */
2594 r = MsiOpenPackageA(msifile, NULL);
2595 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2597 name[0]='#';
2598 name[1]=0;
2599 r = MsiOpenPackageA(name, &hpack);
2600 ok(r == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got %d\n", r);
2602 r = MsiOpenDatabaseW(msifileW, MSIDBOPEN_CREATE, &hdb);
2603 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2605 /* database exists, but is empty */
2606 sprintf(name, "#%d", hdb);
2607 r = MsiOpenPackageA(name, &hpack);
2608 ok(r == ERROR_INSTALL_PACKAGE_INVALID,
2609 "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
2611 query = "CREATE TABLE `Property` ( "
2612 "`Property` CHAR(72), `Value` CHAR(0) "
2613 "PRIMARY KEY `Property`)";
2614 r = try_query(hdb, query);
2615 ok(r == ERROR_SUCCESS, "failed to create Properties table\n");
2617 query = "CREATE TABLE `InstallExecuteSequence` ("
2618 "`Action` CHAR(72), `Condition` CHAR(0), `Sequence` INTEGER "
2619 "PRIMARY KEY `Action`)";
2620 r = try_query(hdb, query);
2621 ok(r == ERROR_SUCCESS, "failed to create InstallExecuteSequence table\n");
2623 /* a few key tables exist */
2624 sprintf(name, "#%d", hdb);
2625 r = MsiOpenPackageA(name, &hpack);
2626 ok(r == ERROR_INSTALL_PACKAGE_INVALID,
2627 "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
2629 MsiCloseHandle(hdb);
2630 DeleteFileA(msifile);
2632 /* start with a clean database to show what constitutes a valid package */
2633 r = MsiOpenDatabaseW(msifileW, MSIDBOPEN_CREATE, &hdb);
2634 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2636 sprintf(name, "#%d", hdb);
2638 /* The following summary information props must exist:
2639 * - PID_REVNUMBER
2640 * - PID_PAGECOUNT
2643 set_summary_dword(hdb, PID_PAGECOUNT, 100);
2644 r = MsiOpenPackageA(name, &hpack);
2645 ok(r == ERROR_INSTALL_PACKAGE_INVALID,
2646 "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
2648 set_summary_str(hdb, PID_REVNUMBER, "{004757CD-5092-49C2-AD20-28E1CE0DF5F2}");
2649 r = MsiOpenPackageA(name, &hpack);
2650 ok(r == ERROR_SUCCESS,
2651 "Expected ERROR_SUCCESS, got %d\n", r);
2653 MsiCloseHandle(hpack);
2654 MsiCloseHandle(hdb);
2655 DeleteFileA(msifile);
2658 static void test_formatrecord2(void)
2660 MSIHANDLE hpkg, hrec ;
2661 char buffer[0x100];
2662 DWORD sz;
2663 UINT r;
2665 r = package_from_db(create_package_db(), &hpkg);
2666 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
2668 skip("Not enough rights to perform tests\n");
2669 DeleteFileA(msifile);
2670 return;
2672 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
2674 r = MsiSetPropertyA(hpkg, "Manufacturer", " " );
2675 ok( r == ERROR_SUCCESS, "set property failed\n");
2677 hrec = MsiCreateRecord(2);
2678 ok(hrec, "create record failed\n");
2680 r = MsiRecordSetStringA( hrec, 0, "[ProgramFilesFolder][Manufacturer]\\asdf");
2681 ok( r == ERROR_SUCCESS, "format record failed\n");
2683 buffer[0] = 0;
2684 sz = sizeof buffer;
2685 r = MsiFormatRecordA( hpkg, hrec, buffer, &sz );
2686 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2688 r = MsiRecordSetStringA(hrec, 0, "[foo][1]");
2689 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2690 r = MsiRecordSetStringA(hrec, 1, "hoo");
2691 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2692 sz = sizeof buffer;
2693 r = MsiFormatRecordA(hpkg, hrec, buffer, &sz);
2694 ok( sz == 3, "size wrong\n");
2695 ok( 0 == strcmp(buffer,"hoo"), "wrong output %s\n",buffer);
2696 ok( r == ERROR_SUCCESS, "format failed\n");
2698 r = MsiRecordSetStringA(hrec, 0, "x[~]x");
2699 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2700 sz = sizeof buffer;
2701 r = MsiFormatRecordA(hpkg, hrec, buffer, &sz);
2702 ok( sz == 3, "size wrong\n");
2703 ok( 0 == strcmp(buffer,"x"), "wrong output %s\n",buffer);
2704 ok( r == ERROR_SUCCESS, "format failed\n");
2706 r = MsiRecordSetStringA(hrec, 0, "[foo.$%}][1]");
2707 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2708 r = MsiRecordSetStringA(hrec, 1, "hoo");
2709 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2710 sz = sizeof buffer;
2711 r = MsiFormatRecordA(hpkg, hrec, buffer, &sz);
2712 ok( sz == 3, "size wrong\n");
2713 ok( 0 == strcmp(buffer,"hoo"), "wrong output %s\n",buffer);
2714 ok( r == ERROR_SUCCESS, "format failed\n");
2716 r = MsiRecordSetStringA(hrec, 0, "[\\[]");
2717 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2718 sz = sizeof buffer;
2719 r = MsiFormatRecordA(hpkg, hrec, buffer, &sz);
2720 ok( sz == 1, "size wrong\n");
2721 ok( 0 == strcmp(buffer,"["), "wrong output %s\n",buffer);
2722 ok( r == ERROR_SUCCESS, "format failed\n");
2724 SetEnvironmentVariableA("FOO", "BAR");
2725 r = MsiRecordSetStringA(hrec, 0, "[%FOO]");
2726 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2727 sz = sizeof buffer;
2728 r = MsiFormatRecordA(hpkg, hrec, buffer, &sz);
2729 ok( sz == 3, "size wrong\n");
2730 ok( 0 == strcmp(buffer,"BAR"), "wrong output %s\n",buffer);
2731 ok( r == ERROR_SUCCESS, "format failed\n");
2733 r = MsiRecordSetStringA(hrec, 0, "[[1]]");
2734 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2735 r = MsiRecordSetStringA(hrec, 1, "%FOO");
2736 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2737 sz = sizeof buffer;
2738 r = MsiFormatRecordA(hpkg, hrec, buffer, &sz);
2739 ok( sz == 3, "size wrong\n");
2740 ok( 0 == strcmp(buffer,"BAR"), "wrong output %s\n",buffer);
2741 ok( r == ERROR_SUCCESS, "format failed\n");
2743 MsiCloseHandle( hrec );
2744 MsiCloseHandle( hpkg );
2745 DeleteFileA(msifile);
2748 static void test_formatrecord_tables(void)
2750 MSIHANDLE hdb, hrec, hpkg = 0;
2751 CHAR buf[MAX_PATH];
2752 CHAR curr_dir[MAX_PATH];
2753 CHAR expected[MAX_PATH];
2754 CHAR root[MAX_PATH];
2755 DWORD size;
2756 UINT r;
2758 GetCurrentDirectoryA( MAX_PATH, curr_dir );
2760 hdb = create_package_db();
2761 ok ( hdb, "failed to create package database\n");
2763 add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'" );
2764 add_directory_entry( hdb, "'ReallyLongDir', 'TARGETDIR', "
2765 "'I am a really long directory'" );
2767 create_feature_table( hdb );
2768 add_feature_entry( hdb, "'occipitofrontalis', '', '', '', 2, 1, '', 0" );
2770 create_component_table( hdb );
2771 add_component_entry( hdb, "'frontal', '', 'TARGETDIR', 0, '', 'frontal_file'" );
2772 add_component_entry( hdb, "'parietal', '', 'TARGETDIR', 1, '', 'parietal_file'" );
2773 add_component_entry( hdb, "'temporal', '', 'ReallyLongDir', 0, '', 'temporal_file'" );
2775 create_feature_components_table( hdb );
2776 add_feature_components_entry( hdb, "'occipitofrontalis', 'frontal'" );
2777 add_feature_components_entry( hdb, "'occipitofrontalis', 'parietal'" );
2778 add_feature_components_entry( hdb, "'occipitofrontalis', 'temporal'" );
2780 create_file_table( hdb );
2781 add_file_entry( hdb, "'frontal_file', 'frontal', 'frontal.txt', 0, '', '1033', 8192, 1" );
2782 add_file_entry( hdb, "'parietal_file', 'parietal', 'parietal.txt', 0, '', '1033', 8192, 1" );
2783 add_file_entry( hdb, "'temporal_file', 'temporal', 'temporal.txt', 0, '', '1033', 8192, 1" );
2785 create_custom_action_table( hdb );
2786 add_custom_action_entry( hdb, "'MyCustom', 51, 'prop', '[!temporal_file]'" );
2787 add_custom_action_entry( hdb, "'EscapeIt1', 51, 'prop', '[\\[]Bracket Text[\\]]'" );
2788 add_custom_action_entry( hdb, "'EscapeIt2', 51, 'prop', '[\\xabcd]'" );
2789 add_custom_action_entry( hdb, "'EscapeIt3', 51, 'prop', '[abcd\\xefgh]'" );
2790 add_custom_action_entry( hdb, "'EmbedNull', 51, 'prop', '[~]np'" );
2792 r = package_from_db( hdb, &hpkg );
2793 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
2795 skip("Not enough rights to perform tests\n");
2796 MsiCloseHandle( hdb );
2797 DeleteFileA( msifile );
2798 return;
2800 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
2802 MsiCloseHandle( hdb );
2804 r = MsiSetPropertyA( hpkg, "imaprop", "ringer" );
2805 ok( r == ERROR_SUCCESS, "cannot set property: %d\n", r);
2807 hrec = MsiCreateRecord( 1 );
2809 /* property doesn't exist */
2810 size = MAX_PATH;
2811 /*MsiRecordSetStringA( hrec, 0, "[1]" ); */
2812 MsiRecordSetStringA( hrec, 1, "[idontexist]" );
2813 r = MsiFormatRecordA( hpkg, hrec, buf, &size );
2814 ok( r == ERROR_SUCCESS, "format record failed: %d\n", r);
2815 ok( !lstrcmpA( buf, "1: " ), "Expected '1: ', got %s\n", buf );
2817 /* property exists */
2818 size = MAX_PATH;
2819 MsiRecordSetStringA( hrec, 1, "[imaprop]" );
2820 r = MsiFormatRecordA( hpkg, hrec, buf, &size );
2821 ok( r == ERROR_SUCCESS, "format record failed: %d\n", r);
2822 ok( !lstrcmpA( buf, "1: ringer " ), "Expected '1: ringer ', got %s\n", buf );
2824 size = MAX_PATH;
2825 MsiRecordSetStringA( hrec, 0, "1: [1] " );
2826 r = MsiFormatRecordA( hpkg, hrec, buf, &size );
2827 ok( r == ERROR_SUCCESS, "format record failed: %d\n", r);
2828 ok( !lstrcmpA( buf, "1: ringer " ), "Expected '1: ringer ', got %s\n", buf );
2830 /* environment variable doesn't exist */
2831 size = MAX_PATH;
2832 MsiRecordSetStringA( hrec, 1, "[%idontexist]" );
2833 r = MsiFormatRecordA( hpkg, hrec, buf, &size );
2834 ok( r == ERROR_SUCCESS, "format record failed: %d\n", r);
2835 ok( !lstrcmpA( buf, "1: " ), "Expected '1: ', got %s\n", buf );
2837 /* environment variable exists */
2838 size = MAX_PATH;
2839 SetEnvironmentVariableA( "crazyvar", "crazyval" );
2840 MsiRecordSetStringA( hrec, 1, "[%crazyvar]" );
2841 r = MsiFormatRecordA( hpkg, hrec, buf, &size );
2842 ok( r == ERROR_SUCCESS, "format record failed: %d\n", r);
2843 ok( !lstrcmpA( buf, "1: crazyval " ), "Expected '1: crazyval ', got %s\n", buf );
2845 /* file key before CostInitialize */
2846 size = MAX_PATH;
2847 MsiRecordSetStringA( hrec, 1, "[#frontal_file]" );
2848 r = MsiFormatRecordA( hpkg, hrec, buf, &size );
2849 ok( r == ERROR_SUCCESS, "format record failed: %d\n", r);
2850 ok( !lstrcmpA( buf, "1: " ), "Expected '1: ', got %s\n", buf );
2852 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
2854 r = MsiDoActionA(hpkg, "CostInitialize");
2855 ok( r == ERROR_SUCCESS, "CostInitialize failed: %d\n", r);
2857 r = MsiDoActionA(hpkg, "FileCost");
2858 ok( r == ERROR_SUCCESS, "FileCost failed: %d\n", r);
2860 r = MsiDoActionA(hpkg, "CostFinalize");
2861 ok( r == ERROR_SUCCESS, "CostFinalize failed: %d\n", r);
2863 size = MAX_PATH;
2864 MsiGetPropertyA( hpkg, "ROOTDRIVE", root, &size );
2866 sprintf( expected, "1: %sfrontal.txt ", root);
2868 /* frontal full file key */
2869 size = MAX_PATH;
2870 MsiRecordSetStringA( hrec, 1, "[#frontal_file]" );
2871 r = MsiFormatRecordA( hpkg, hrec, buf, &size );
2872 ok( r == ERROR_SUCCESS, "format record failed: %d\n", r);
2873 ok( !lstrcmpA( buf, expected ), "Expected \"%s\", got \"%s\"\n", expected, buf);
2875 /* frontal short file key */
2876 size = MAX_PATH;
2877 MsiRecordSetStringA( hrec, 1, "[!frontal_file]" );
2878 r = MsiFormatRecordA( hpkg, hrec, buf, &size );
2879 ok( r == ERROR_SUCCESS, "format record failed: %d\n", r);
2880 ok( !lstrcmpA( buf, expected ), "Expected \"%s\", got \"%s\"\n", expected, buf);
2882 sprintf( expected, "1: %sI am a really long directory\\temporal.txt ", root);
2884 /* temporal full file key */
2885 size = MAX_PATH;
2886 MsiRecordSetStringA( hrec, 1, "[#temporal_file]" );
2887 r = MsiFormatRecordA( hpkg, hrec, buf, &size );
2888 ok( r == ERROR_SUCCESS, "format record failed: %d\n", r);
2889 ok( !lstrcmpA( buf, expected ), "Expected \"%s\", got \"%s\"\n", expected, buf);
2891 /* temporal short file key */
2892 size = MAX_PATH;
2893 MsiRecordSetStringA( hrec, 1, "[!temporal_file]" );
2894 r = MsiFormatRecordA( hpkg, hrec, buf, &size );
2895 ok( r == ERROR_SUCCESS, "format record failed: %d\n", r);
2896 ok( !lstrcmpA( buf, expected ), "Expected \"%s\", got \"%s\"\n", expected, buf);
2898 /* custom action 51, files don't exist */
2899 r = MsiDoActionA( hpkg, "MyCustom" );
2900 ok( r == ERROR_SUCCESS, "MyCustom failed: %d\n", r);
2902 sprintf( expected, "%sI am a really long directory\\temporal.txt", root);
2904 size = MAX_PATH;
2905 r = MsiGetPropertyA( hpkg, "prop", buf, &size );
2906 ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
2907 ok( !lstrcmpA( buf, expected ), "Expected \"%s\", got \"%s\"\n", expected, buf);
2909 sprintf( buf, "%sI am a really long directory", root );
2910 CreateDirectoryA( buf, NULL );
2912 lstrcatA( buf, "\\temporal.txt" );
2913 create_test_file( buf );
2915 /* custom action 51, files exist */
2916 r = MsiDoActionA( hpkg, "MyCustom" );
2917 ok( r == ERROR_SUCCESS, "MyCustom failed: %d\n", r);
2919 size = MAX_PATH;
2920 r = MsiGetPropertyA( hpkg, "prop", buf, &size );
2921 ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
2922 todo_wine
2924 ok( !lstrcmpA( buf, expected ), "Expected \"%s\", got \"%s\"\n", expected, buf);
2927 /* custom action 51, escaped text 1 */
2928 r = MsiDoActionA( hpkg, "EscapeIt1" );
2929 ok( r == ERROR_SUCCESS, "EscapeIt1 failed: %d\n", r);
2931 size = MAX_PATH;
2932 r = MsiGetPropertyA( hpkg, "prop", buf, &size );
2933 ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
2934 ok( !lstrcmpA( buf, "[Bracket Text]" ), "Expected '[Bracket Text]', got %s\n", buf);
2936 /* custom action 51, escaped text 2 */
2937 r = MsiDoActionA( hpkg, "EscapeIt2" );
2938 ok( r == ERROR_SUCCESS, "EscapeIt2 failed: %d\n", r);
2940 size = MAX_PATH;
2941 r = MsiGetPropertyA( hpkg, "prop", buf, &size );
2942 ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
2943 ok( !lstrcmpA( buf, "x" ), "Expected 'x', got %s\n", buf);
2945 /* custom action 51, escaped text 3 */
2946 r = MsiDoActionA( hpkg, "EscapeIt3" );
2947 ok( r == ERROR_SUCCESS, "EscapeIt3 failed: %d\n", r);
2949 size = MAX_PATH;
2950 r = MsiGetPropertyA( hpkg, "prop", buf, &size );
2951 ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
2952 ok( !lstrcmpA( buf, "" ), "Expected '', got %s\n", buf);
2954 /* custom action 51, embedded null */
2955 r = MsiDoActionA( hpkg, "EmbedNull" );
2956 ok( r == ERROR_SUCCESS, "EmbedNull failed: %d\n", r);
2958 size = MAX_PATH;
2959 memset( buf, 'a', sizeof(buf) );
2960 r = MsiGetPropertyA( hpkg, "prop", buf, &size );
2961 ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
2962 ok( !memcmp( buf, "\0np", sizeof("\0np") ), "wrong value\n");
2963 ok( size == sizeof("\0np") - 1, "got %u\n", size );
2965 r = MsiSetPropertyA( hpkg, "prop", "[~]np" );
2966 ok( r == ERROR_SUCCESS, "cannot set property: %d\n", r);
2968 size = MAX_PATH;
2969 memset( buf, 'a', sizeof(buf) );
2970 r = MsiGetPropertyA( hpkg, "prop", buf, &size );
2971 ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
2972 ok( !lstrcmpA( buf, "[~]np" ), "Expected '[~]np', got %s\n", buf);
2974 sprintf( expected, "1: %sI am a really long directory\\ ", root);
2976 /* component with INSTALLSTATE_LOCAL */
2977 size = MAX_PATH;
2978 MsiRecordSetStringA( hrec, 1, "[$temporal]" );
2979 r = MsiFormatRecordA( hpkg, hrec, buf, &size );
2980 ok( r == ERROR_SUCCESS, "format record failed: %d\n", r);
2981 ok( !lstrcmpA( buf, expected ), "Expected \"%s\", got \"%s\"\n", expected, buf);
2983 r = MsiSetComponentStateA( hpkg, "temporal", INSTALLSTATE_SOURCE );
2984 ok( r == ERROR_SUCCESS, "failed to set install state: %d\n", r);
2986 /* component with INSTALLSTATE_SOURCE */
2987 lstrcpyA( expected, "1: " );
2988 lstrcatA( expected, curr_dir );
2989 if (strlen(curr_dir) > 3) lstrcatA( expected, "\\" );
2990 lstrcatA( expected, " " );
2991 size = MAX_PATH;
2992 MsiRecordSetStringA( hrec, 1, "[$parietal]" );
2993 r = MsiFormatRecordA( hpkg, hrec, buf, &size );
2994 ok( r == ERROR_SUCCESS, "format record failed: %d\n", r);
2995 ok( !lstrcmpA( buf, expected ), "Expected '%s', got '%s'\n", expected, buf);
2997 sprintf( buf, "%sI am a really long directory\\temporal.txt", root );
2998 DeleteFileA( buf );
3000 sprintf( buf, "%sI am a really long directory", root );
3001 RemoveDirectoryA( buf );
3003 MsiCloseHandle( hrec );
3004 MsiCloseHandle( hpkg );
3005 DeleteFileA( msifile );
3008 static void test_feature_states( UINT line, MSIHANDLE package, const char *feature, UINT error,
3009 INSTALLSTATE expected_state, INSTALLSTATE expected_action, BOOL todo )
3011 UINT r;
3012 INSTALLSTATE state = 0xdeadbee;
3013 INSTALLSTATE action = 0xdeadbee;
3015 r = MsiGetFeatureStateA( package, feature, &state, &action );
3016 ok( r == error, "%u: expected %d got %d\n", line, error, r );
3017 if (r == ERROR_SUCCESS)
3019 ok( state == expected_state, "%u: expected state %d got %d\n",
3020 line, expected_state, state );
3021 todo_wine_if (todo)
3022 ok( action == expected_action, "%u: expected action %d got %d\n",
3023 line, expected_action, action );
3025 else
3027 ok( state == 0xdeadbee, "%u: expected state 0xdeadbee got %d\n", line, state );
3028 todo_wine_if (todo)
3029 ok( action == 0xdeadbee, "%u: expected action 0xdeadbee got %d\n", line, action );
3034 static void test_component_states( UINT line, MSIHANDLE package, const char *component, UINT error,
3035 INSTALLSTATE expected_state, INSTALLSTATE expected_action, BOOL todo )
3037 UINT r;
3038 INSTALLSTATE state = 0xdeadbee;
3039 INSTALLSTATE action = 0xdeadbee;
3041 r = MsiGetComponentStateA( package, component, &state, &action );
3042 ok( r == error, "%u: expected %d got %d\n", line, error, r );
3043 if (r == ERROR_SUCCESS)
3045 ok( state == expected_state, "%u: expected state %d got %d\n",
3046 line, expected_state, state );
3047 todo_wine_if (todo)
3048 ok( action == expected_action, "%u: expected action %d got %d\n",
3049 line, expected_action, action );
3051 else
3053 ok( state == 0xdeadbee, "%u: expected state 0xdeadbee got %d\n",
3054 line, state );
3055 todo_wine_if (todo)
3056 ok( action == 0xdeadbee, "%u: expected action 0xdeadbee got %d\n",
3057 line, action );
3061 static void test_states(void)
3063 static const char msifile2[] = "winetest2-package.msi";
3064 static const char msifile3[] = "winetest3-package.msi";
3065 static const char msifile4[] = "winetest4-package.msi";
3066 static const WCHAR msifile2W[] =
3067 {'w','i','n','e','t','e','s','t','2','-','p','a','c','k','a','g','e','.','m','s','i',0};
3068 static const WCHAR msifile3W[] =
3069 {'w','i','n','e','t','e','s','t','3','-','p','a','c','k','a','g','e','.','m','s','i',0};
3070 static const WCHAR msifile4W[] =
3071 {'w','i','n','e','t','e','s','t','4','-','p','a','c','k','a','g','e','.','m','s','i',0};
3072 char msi_cache_file[MAX_PATH];
3073 DWORD cache_file_name_len;
3074 INSTALLSTATE state;
3075 MSIHANDLE hpkg;
3076 UINT r;
3077 MSIHANDLE hdb;
3078 BOOL is_broken;
3080 if (is_process_limited())
3082 skip("process is limited\n");
3083 return;
3086 hdb = create_package_db();
3087 ok ( hdb, "failed to create package database\n" );
3089 add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
3091 create_property_table( hdb );
3092 add_property_entry( hdb, "'ProductCode', '{7262AC98-EEBD-4364-8CE3-D654F6A425B9}'" );
3093 add_property_entry( hdb, "'ProductLanguage', '1033'" );
3094 add_property_entry( hdb, "'ProductName', 'MSITEST'" );
3095 add_property_entry( hdb, "'ProductVersion', '1.1.1'" );
3096 add_property_entry( hdb, "'MSIFASTINSTALL', '1'" );
3098 create_install_execute_sequence_table( hdb );
3099 add_install_execute_sequence_entry( hdb, "'CostInitialize', '', '800'" );
3100 add_install_execute_sequence_entry( hdb, "'FileCost', '', '900'" );
3101 add_install_execute_sequence_entry( hdb, "'CostFinalize', '', '1000'" );
3102 add_install_execute_sequence_entry( hdb, "'InstallValidate', '', '1400'" );
3103 add_install_execute_sequence_entry( hdb, "'InstallInitialize', '', '1500'" );
3104 add_install_execute_sequence_entry( hdb, "'ProcessComponents', '', '1600'" );
3105 add_install_execute_sequence_entry( hdb, "'UnpublishFeatures', '', '1800'" );
3106 add_install_execute_sequence_entry( hdb, "'RegisterProduct', '', '6100'" );
3107 add_install_execute_sequence_entry( hdb, "'PublishFeatures', '', '6300'" );
3108 add_install_execute_sequence_entry( hdb, "'PublishProduct', '', '6400'" );
3109 add_install_execute_sequence_entry( hdb, "'InstallFinalize', '', '6600'" );
3111 create_media_table( hdb );
3112 add_media_entry( hdb, "'1', '3', '', '', 'DISK1', ''");
3114 create_feature_table( hdb );
3116 create_component_table( hdb );
3118 /* msidbFeatureAttributesFavorLocal */
3119 add_feature_entry( hdb, "'one', '', '', '', 2, 1, '', 0" );
3121 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
3122 add_component_entry( hdb, "'alpha', '{467EC132-739D-4784-A37B-677AA43DBC94}', 'TARGETDIR', 0, '', 'alpha_file'" );
3124 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
3125 add_component_entry( hdb, "'beta', '{2C1F189C-24A6-4C34-B26B-994A6C026506}', 'TARGETDIR', 1, '', 'beta_file'" );
3127 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
3128 add_component_entry( hdb, "'gamma', '{C271E2A4-DE2E-4F70-86D1-6984AF7DE2CA}', 'TARGETDIR', 2, '', 'gamma_file'" );
3130 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSharedDllRefCount */
3131 add_component_entry( hdb, "'theta', '{4EB3129D-81A8-48D5-9801-75600FED3DD9}', 'TARGETDIR', 8, '', 'theta_file'" );
3133 /* msidbFeatureAttributesFavorSource */
3134 add_feature_entry( hdb, "'two', '', '', '', 2, 1, '', 1" );
3136 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
3137 add_component_entry( hdb, "'delta', '{938FD4F2-C648-4259-A03C-7AA3B45643F3}', 'TARGETDIR', 0, '', 'delta_file'" );
3139 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
3140 add_component_entry( hdb, "'epsilon', '{D59713B6-C11D-47F2-A395-1E5321781190}', 'TARGETDIR', 1, '', 'epsilon_file'" );
3142 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
3143 add_component_entry( hdb, "'zeta', '{377D33AB-2FAA-42B9-A629-0C0DAE9B9C7A}', 'TARGETDIR', 2, '', 'zeta_file'" );
3145 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSharedDllRefCount */
3146 add_component_entry( hdb, "'iota', '{5D36F871-B5ED-4801-9E0F-C46B9E5C9669}', 'TARGETDIR', 8, '', 'iota_file'" );
3148 /* msidbFeatureAttributesFavorSource */
3149 add_feature_entry( hdb, "'three', '', '', '', 2, 1, '', 1" );
3151 /* msidbFeatureAttributesFavorLocal */
3152 add_feature_entry( hdb, "'four', '', '', '', 2, 1, '', 0" );
3154 /* disabled */
3155 add_feature_entry( hdb, "'five', '', '', '', 2, 0, '', 1" );
3157 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
3158 add_component_entry( hdb, "'eta', '{DD89003F-0DD4-41B8-81C0-3411A7DA2695}', 'TARGETDIR', 1, '', 'eta_file'" );
3160 /* no feature parent:msidbComponentAttributesLocalOnly */
3161 add_component_entry( hdb, "'kappa', '{D6B93DC3-8DA5-4769-9888-42BFE156BB8B}', 'TARGETDIR', 1, '', 'kappa_file'" );
3163 /* msidbFeatureAttributesFavorLocal:removed */
3164 add_feature_entry( hdb, "'six', '', '', '', 2, 1, '', 0" );
3166 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesLocalOnly */
3167 add_component_entry( hdb, "'lambda', '{6528C5E4-02A4-4636-A214-7A66A6C35B64}', 'TARGETDIR', 0, '', 'lambda_file'" );
3169 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesSourceOnly */
3170 add_component_entry( hdb, "'mu', '{97014BAB-6C56-4013-9A63-2BF913B42519}', 'TARGETDIR', 1, '', 'mu_file'" );
3172 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesOptional */
3173 add_component_entry( hdb, "'nu', '{943DD0D8-5808-4954-8526-3B8493FEDDCD}', 'TARGETDIR', 2, '', 'nu_file'" );
3175 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesSharedDllRefCount */
3176 add_component_entry( hdb, "'xi', '{D6CF9EF7-6FCF-4930-B34B-F938AEFF9BDB}', 'TARGETDIR', 8, '', 'xi_file'" );
3178 /* msidbFeatureAttributesFavorSource:removed */
3179 add_feature_entry( hdb, "'seven', '', '', '', 2, 1, '', 1" );
3181 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesLocalOnly */
3182 add_component_entry( hdb, "'omicron', '{7B57521D-15DB-4141-9AA6-01D934A4433F}', 'TARGETDIR', 0, '', 'omicron_file'" );
3184 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesSourceOnly */
3185 add_component_entry( hdb, "'pi', '{FB85346B-378E-4492-8769-792305471C81}', 'TARGETDIR', 1, '', 'pi_file'" );
3187 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesOptional */
3188 add_component_entry( hdb, "'rho', '{798F2047-7B0C-4783-8BB0-D703E554114B}', 'TARGETDIR', 2, '', 'rho_file'" );
3190 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesSharedDllRefCount */
3191 add_component_entry( hdb, "'sigma', '{5CE9DDA8-B67B-4736-9D93-99D61C5B93E7}', 'TARGETDIR', 8, '', 'sigma_file'" );
3193 /* msidbFeatureAttributesFavorLocal */
3194 add_feature_entry( hdb, "'eight', '', '', '', 2, 1, '', 0" );
3196 add_component_entry( hdb, "'tau', '{07DEB510-677C-4A6F-A0A6-7CD8EFEA77ED}', 'TARGETDIR', 1, '', 'tau_file'" );
3198 /* msidbFeatureAttributesFavorSource */
3199 add_feature_entry( hdb, "'nine', '', '', '', 2, 1, '', 1" );
3201 add_component_entry( hdb, "'phi', '{9F0594C5-35AD-43EA-94DD-8DF73FAA664D}', 'TARGETDIR', 1, '', 'phi_file'" );
3203 /* msidbFeatureAttributesFavorAdvertise */
3204 add_feature_entry( hdb, "'ten', '', '', '', 2, 1, '', 4" );
3206 add_component_entry( hdb, "'chi', '{E6B539AB-5DA9-4236-A2D2-E341A50B4C38}', 'TARGETDIR', 1, '', 'chi_file'" );
3208 /* msidbFeatureAttributesUIDisallowAbsent */
3209 add_feature_entry( hdb, "'eleven', '', '', '', 2, 1, '', 16" );
3211 add_component_entry( hdb, "'psi', '{A06B23B5-746B-427A-8A6E-FD6AC8F46A95}', 'TARGETDIR', 1, '', 'psi_file'" );
3213 /* high install level */
3214 add_feature_entry( hdb, "'twelve', '', '', '', 2, 2, '', 0" );
3216 add_component_entry( hdb, "'upsilon', '{557e0c04-ceba-4c58-86a9-4a73352e8cf6}', 'TARGETDIR', 1, '', 'upsilon_file'" );
3218 /* msidbFeatureAttributesFollowParent */
3219 add_feature_entry( hdb, "'thirteen', '', '', '', 2, 2, '', 2" );
3221 create_feature_components_table( hdb );
3222 add_feature_components_entry( hdb, "'one', 'alpha'" );
3223 add_feature_components_entry( hdb, "'one', 'beta'" );
3224 add_feature_components_entry( hdb, "'one', 'gamma'" );
3225 add_feature_components_entry( hdb, "'one', 'theta'" );
3226 add_feature_components_entry( hdb, "'two', 'delta'" );
3227 add_feature_components_entry( hdb, "'two', 'epsilon'" );
3228 add_feature_components_entry( hdb, "'two', 'zeta'" );
3229 add_feature_components_entry( hdb, "'two', 'iota'" );
3230 add_feature_components_entry( hdb, "'three', 'eta'" );
3231 add_feature_components_entry( hdb, "'four', 'eta'" );
3232 add_feature_components_entry( hdb, "'five', 'eta'" );
3233 add_feature_components_entry( hdb, "'six', 'lambda'" );
3234 add_feature_components_entry( hdb, "'six', 'mu'" );
3235 add_feature_components_entry( hdb, "'six', 'nu'" );
3236 add_feature_components_entry( hdb, "'six', 'xi'" );
3237 add_feature_components_entry( hdb, "'seven', 'omicron'" );
3238 add_feature_components_entry( hdb, "'seven', 'pi'" );
3239 add_feature_components_entry( hdb, "'seven', 'rho'" );
3240 add_feature_components_entry( hdb, "'seven', 'sigma'" );
3241 add_feature_components_entry( hdb, "'eight', 'tau'" );
3242 add_feature_components_entry( hdb, "'nine', 'phi'" );
3243 add_feature_components_entry( hdb, "'ten', 'chi'" );
3244 add_feature_components_entry( hdb, "'eleven', 'psi'" );
3245 add_feature_components_entry( hdb, "'twelve', 'upsilon'" );
3246 add_feature_components_entry( hdb, "'thirteen', 'upsilon'" );
3248 create_file_table( hdb );
3249 add_file_entry( hdb, "'alpha_file', 'alpha', 'alpha.txt', 100, '', '1033', 8192, 1" );
3250 add_file_entry( hdb, "'beta_file', 'beta', 'beta.txt', 0, '', '1033', 8192, 1" );
3251 add_file_entry( hdb, "'gamma_file', 'gamma', 'gamma.txt', 0, '', '1033', 8192, 1" );
3252 add_file_entry( hdb, "'theta_file', 'theta', 'theta.txt', 0, '', '1033', 8192, 1" );
3253 add_file_entry( hdb, "'delta_file', 'delta', 'delta.txt', 0, '', '1033', 8192, 1" );
3254 add_file_entry( hdb, "'epsilon_file', 'epsilon', 'epsilon.txt', 0, '', '1033', 8192, 1" );
3255 add_file_entry( hdb, "'zeta_file', 'zeta', 'zeta.txt', 0, '', '1033', 8192, 1" );
3256 add_file_entry( hdb, "'iota_file', 'iota', 'iota.txt', 0, '', '1033', 8192, 1" );
3258 /* compressed file */
3259 add_file_entry( hdb, "'eta_file', 'eta', 'eta.txt', 0, '', '1033', 16384, 1" );
3261 add_file_entry( hdb, "'kappa_file', 'kappa', 'kappa.txt', 0, '', '1033', 8192, 1" );
3262 add_file_entry( hdb, "'lambda_file', 'lambda', 'lambda.txt', 100, '', '1033', 8192, 1" );
3263 add_file_entry( hdb, "'mu_file', 'mu', 'mu.txt', 100, '', '1033', 8192, 1" );
3264 add_file_entry( hdb, "'nu_file', 'nu', 'nu.txt', 100, '', '1033', 8192, 1" );
3265 add_file_entry( hdb, "'xi_file', 'xi', 'xi.txt', 100, '', '1033', 8192, 1" );
3266 add_file_entry( hdb, "'omicron_file', 'omicron', 'omicron.txt', 100, '', '1033', 8192, 1" );
3267 add_file_entry( hdb, "'pi_file', 'pi', 'pi.txt', 100, '', '1033', 8192, 1" );
3268 add_file_entry( hdb, "'rho_file', 'rho', 'rho.txt', 100, '', '1033', 8192, 1" );
3269 add_file_entry( hdb, "'sigma_file', 'sigma', 'sigma.txt', 100, '', '1033', 8192, 1" );
3270 add_file_entry( hdb, "'tau_file', 'tau', 'tau.txt', 100, '', '1033', 8192, 1" );
3271 add_file_entry( hdb, "'phi_file', 'phi', 'phi.txt', 100, '', '1033', 8192, 1" );
3272 add_file_entry( hdb, "'chi_file', 'chi', 'chi.txt', 100, '', '1033', 8192, 1" );
3273 add_file_entry( hdb, "'psi_file', 'psi', 'psi.txt', 100, '', '1033', 8192, 1" );
3274 add_file_entry( hdb, "'upsilon_file', 'upsilon', 'upsilon.txt', 0, '', '1033', 16384, 1" );
3276 r = MsiDatabaseCommit(hdb);
3277 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3279 /* these properties must not be in the saved msi file */
3280 add_property_entry( hdb, "'ADDLOCAL', 'one,four'");
3281 add_property_entry( hdb, "'ADDSOURCE', 'two,three'");
3282 add_property_entry( hdb, "'REMOVE', 'six,seven'");
3283 add_property_entry( hdb, "'REINSTALL', 'eight,nine,ten'");
3284 add_property_entry( hdb, "'REINSTALLMODE', 'omus'");
3286 r = package_from_db( hdb, &hpkg );
3287 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
3289 skip("Not enough rights to perform tests\n");
3290 DeleteFileA(msifile);
3291 return;
3293 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
3295 MsiCloseHandle(hdb);
3297 CopyFileA(msifile, msifile2, FALSE);
3298 CopyFileA(msifile, msifile3, FALSE);
3299 CopyFileA(msifile, msifile4, FALSE);
3301 test_feature_states( __LINE__, hpkg, "one", ERROR_UNKNOWN_FEATURE, 0, 0, FALSE );
3302 test_component_states( __LINE__, hpkg, "alpha", ERROR_UNKNOWN_COMPONENT, 0, 0, FALSE );
3304 r = MsiDoActionA( hpkg, "CostInitialize");
3305 ok( r == ERROR_SUCCESS, "cost init failed\n");
3307 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3308 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3310 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3312 r = MsiDoActionA( hpkg, "FileCost");
3313 ok( r == ERROR_SUCCESS, "file cost failed\n");
3315 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3316 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3318 r = MsiDoActionA( hpkg, "CostFinalize");
3319 ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
3321 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, FALSE );
3322 test_feature_states( __LINE__, hpkg, "two", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_SOURCE, FALSE );
3323 test_feature_states( __LINE__, hpkg, "three", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, FALSE );
3324 test_feature_states( __LINE__, hpkg, "four", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, FALSE );
3325 test_feature_states( __LINE__, hpkg, "five", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3326 test_feature_states( __LINE__, hpkg, "six", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3327 test_feature_states( __LINE__, hpkg, "seven", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3328 test_feature_states( __LINE__, hpkg, "eight", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3329 test_feature_states( __LINE__, hpkg, "nine", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3330 test_feature_states( __LINE__, hpkg, "ten", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3331 test_feature_states( __LINE__, hpkg, "eleven", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3332 test_feature_states( __LINE__, hpkg, "twelve", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3333 test_feature_states( __LINE__, hpkg, "thirteen", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3335 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, FALSE );
3336 test_component_states( __LINE__, hpkg, "beta", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_SOURCE, FALSE );
3337 test_component_states( __LINE__, hpkg, "gamma", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, FALSE );
3338 test_component_states( __LINE__, hpkg, "theta", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, FALSE );
3339 test_component_states( __LINE__, hpkg, "delta", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, FALSE );
3340 test_component_states( __LINE__, hpkg, "epsilon", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_SOURCE, FALSE );
3341 test_component_states( __LINE__, hpkg, "zeta", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_SOURCE, FALSE );
3342 test_component_states( __LINE__, hpkg, "iota", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, FALSE );
3343 test_component_states( __LINE__, hpkg, "eta", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, FALSE );
3344 test_component_states( __LINE__, hpkg, "kappa", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3345 test_component_states( __LINE__, hpkg, "lambda", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3346 test_component_states( __LINE__, hpkg, "mu", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3347 test_component_states( __LINE__, hpkg, "nu", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3348 test_component_states( __LINE__, hpkg, "xi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3349 test_component_states( __LINE__, hpkg, "omicron", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3350 test_component_states( __LINE__, hpkg, "pi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3351 test_component_states( __LINE__, hpkg, "rho", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3352 test_component_states( __LINE__, hpkg, "sigma", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3353 test_component_states( __LINE__, hpkg, "tau", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3354 test_component_states( __LINE__, hpkg, "phi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3355 test_component_states( __LINE__, hpkg, "chi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3356 test_component_states( __LINE__, hpkg, "psi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3357 test_component_states( __LINE__, hpkg, "upsilon", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3359 MsiCloseHandle( hpkg );
3361 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3363 /* publish the features and components */
3364 r = MsiInstallProductA(msifile, "ADDLOCAL=one,four ADDSOURCE=two,three REMOVE=six,seven REINSTALL=eight,nine,ten");
3365 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3367 r = MsiOpenDatabaseW(msifileW, MSIDBOPEN_DIRECT, &hdb);
3368 ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
3370 /* these properties must not be in the saved msi file */
3371 add_property_entry( hdb, "'ADDLOCAL', 'one,four'");
3372 add_property_entry( hdb, "'ADDSOURCE', 'two,three'");
3373 add_property_entry( hdb, "'REMOVE', 'six,seven'");
3374 add_property_entry( hdb, "'REINSTALL', 'eight,nine,ten'");
3376 r = package_from_db( hdb, &hpkg );
3377 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
3379 MsiCloseHandle(hdb);
3381 test_feature_states( __LINE__, hpkg, "one", ERROR_UNKNOWN_FEATURE, 0, 0, FALSE );
3382 test_component_states( __LINE__, hpkg, "alpha", ERROR_UNKNOWN_COMPONENT, 0, 0, FALSE );
3384 r = MsiDoActionA( hpkg, "CostInitialize");
3385 ok( r == ERROR_SUCCESS, "cost init failed\n");
3387 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3388 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3390 r = MsiDoActionA( hpkg, "FileCost");
3391 ok( r == ERROR_SUCCESS, "file cost failed\n");
3393 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3394 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3396 r = MsiDoActionA( hpkg, "CostFinalize");
3397 ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
3399 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_LOCAL, FALSE );
3400 test_feature_states( __LINE__, hpkg, "two", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3401 test_feature_states( __LINE__, hpkg, "three", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3402 test_feature_states( __LINE__, hpkg, "four", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3403 test_feature_states( __LINE__, hpkg, "five", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3404 test_feature_states( __LINE__, hpkg, "six", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3405 test_feature_states( __LINE__, hpkg, "seven", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3406 test_feature_states( __LINE__, hpkg, "eight", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3407 test_feature_states( __LINE__, hpkg, "nine", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3408 test_feature_states( __LINE__, hpkg, "ten", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3409 test_feature_states( __LINE__, hpkg, "eleven", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3410 test_feature_states( __LINE__, hpkg, "twelve", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3411 test_feature_states( __LINE__, hpkg, "thirteen", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3413 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3414 test_component_states( __LINE__, hpkg, "beta", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3415 test_component_states( __LINE__, hpkg, "gamma", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3416 test_component_states( __LINE__, hpkg, "theta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3417 test_component_states( __LINE__, hpkg, "delta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3418 test_component_states( __LINE__, hpkg, "epsilon", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3419 test_component_states( __LINE__, hpkg, "zeta", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3420 test_component_states( __LINE__, hpkg, "iota", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3421 test_component_states( __LINE__, hpkg, "eta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3422 test_component_states( __LINE__, hpkg, "kappa", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3423 test_component_states( __LINE__, hpkg, "lambda", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3424 test_component_states( __LINE__, hpkg, "mu", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3425 test_component_states( __LINE__, hpkg, "nu", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3426 test_component_states( __LINE__, hpkg, "xi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3427 test_component_states( __LINE__, hpkg, "omicron", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3428 test_component_states( __LINE__, hpkg, "pi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3429 test_component_states( __LINE__, hpkg, "rho", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3430 test_component_states( __LINE__, hpkg, "sigma", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3431 test_component_states( __LINE__, hpkg, "tau", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3432 test_component_states( __LINE__, hpkg, "phi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3433 test_component_states( __LINE__, hpkg, "chi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3434 test_component_states( __LINE__, hpkg, "psi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3435 test_component_states( __LINE__, hpkg, "upsilon", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3437 MsiCloseHandle(hpkg);
3439 /* uninstall the product */
3440 r = MsiInstallProductA(msifile, "REMOVE=ALL");
3441 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3443 state = MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "five");
3444 ok(state == INSTALLSTATE_UNKNOWN, "state = %d\n", state);
3445 state = MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "twelve");
3446 ok(state == INSTALLSTATE_UNKNOWN, "state = %d\n", state);
3448 /* all features installed locally */
3449 r = MsiInstallProductA(msifile2, "ADDLOCAL=ALL");
3450 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3452 state = MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "five");
3453 ok(state == INSTALLSTATE_UNKNOWN, "state = %d\n", state);
3454 state = MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "twelve");
3455 ok(state == INSTALLSTATE_LOCAL, "state = %d\n", state);
3457 r = MsiOpenDatabaseW(msifile2W, MSIDBOPEN_DIRECT, &hdb);
3458 ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
3460 /* these properties must not be in the saved msi file */
3461 add_property_entry( hdb, "'ADDLOCAL', 'one,two,three,four,five,six,seven,eight,nine,ten,twelve'");
3463 r = package_from_db( hdb, &hpkg );
3464 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
3466 test_feature_states( __LINE__, hpkg, "one", ERROR_UNKNOWN_FEATURE, 0, 0, FALSE );
3467 test_component_states( __LINE__, hpkg, "alpha", ERROR_UNKNOWN_COMPONENT, 0, 0, FALSE );
3469 r = MsiDoActionA( hpkg, "CostInitialize");
3470 ok( r == ERROR_SUCCESS, "cost init failed\n");
3472 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3473 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3475 r = MsiDoActionA( hpkg, "CostFinalize");
3476 ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
3478 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_LOCAL, FALSE );
3479 test_feature_states( __LINE__, hpkg, "two", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_LOCAL, FALSE );
3480 test_feature_states( __LINE__, hpkg, "three", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3481 test_feature_states( __LINE__, hpkg, "four", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3482 test_feature_states( __LINE__, hpkg, "five", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3483 test_feature_states( __LINE__, hpkg, "six", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_LOCAL, FALSE );
3484 test_feature_states( __LINE__, hpkg, "seven", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_LOCAL, FALSE );
3485 test_feature_states( __LINE__, hpkg, "eight", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, TRUE );
3486 test_feature_states( __LINE__, hpkg, "nine", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, TRUE );
3487 test_feature_states( __LINE__, hpkg, "ten", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, TRUE );
3488 test_feature_states( __LINE__, hpkg, "eleven", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, TRUE );
3489 test_feature_states( __LINE__, hpkg, "twelve", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3490 test_feature_states( __LINE__, hpkg, "thirteen", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_UNKNOWN, FALSE );
3492 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3493 test_component_states( __LINE__, hpkg, "beta", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3494 test_component_states( __LINE__, hpkg, "gamma", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3495 test_component_states( __LINE__, hpkg, "theta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3496 test_component_states( __LINE__, hpkg, "delta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3497 test_component_states( __LINE__, hpkg, "epsilon", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3498 test_component_states( __LINE__, hpkg, "zeta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3499 test_component_states( __LINE__, hpkg, "iota", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3500 test_component_states( __LINE__, hpkg, "eta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3501 test_component_states( __LINE__, hpkg, "kappa", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3502 test_component_states( __LINE__, hpkg, "lambda", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3503 test_component_states( __LINE__, hpkg, "mu", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3504 test_component_states( __LINE__, hpkg, "nu", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3505 test_component_states( __LINE__, hpkg, "xi", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3506 test_component_states( __LINE__, hpkg, "omicron", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3507 test_component_states( __LINE__, hpkg, "pi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3508 test_component_states( __LINE__, hpkg, "rho", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3509 test_component_states( __LINE__, hpkg, "sigma", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3510 test_component_states( __LINE__, hpkg, "tau", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, TRUE );
3511 test_component_states( __LINE__, hpkg, "phi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, TRUE );
3512 test_component_states( __LINE__, hpkg, "chi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, TRUE );
3513 test_component_states( __LINE__, hpkg, "psi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3514 test_component_states( __LINE__, hpkg, "upsilon", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3516 MsiCloseHandle(hpkg);
3518 /* uninstall the product */
3519 r = MsiInstallProductA(msifile2, "REMOVE=ALL");
3520 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3522 /* all features installed from source */
3523 r = MsiInstallProductA(msifile3, "ADDSOURCE=ALL");
3524 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3526 state = MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "five");
3527 ok(state == INSTALLSTATE_UNKNOWN, "state = %d\n", state);
3528 state = MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "twelve");
3529 ok(state == INSTALLSTATE_LOCAL, "state = %d\n", state);
3531 r = MsiOpenDatabaseW(msifile3W, MSIDBOPEN_DIRECT, &hdb);
3532 ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
3534 /* this property must not be in the saved msi file */
3535 add_property_entry( hdb, "'ADDSOURCE', 'one,two,three,four,five,six,seven,eight,nine,ten'");
3537 r = package_from_db( hdb, &hpkg );
3538 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
3540 test_feature_states( __LINE__, hpkg, "one", ERROR_UNKNOWN_FEATURE, 0, 0, FALSE );
3541 test_component_states( __LINE__, hpkg, "alpha", ERROR_UNKNOWN_COMPONENT, 0, 0, FALSE );
3543 r = MsiDoActionA( hpkg, "CostInitialize");
3544 ok( r == ERROR_SUCCESS, "cost init failed\n");
3546 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3547 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3549 r = MsiDoActionA( hpkg, "FileCost");
3550 ok( r == ERROR_SUCCESS, "file cost failed\n");
3552 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3553 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3555 r = MsiDoActionA( hpkg, "CostFinalize");
3556 ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
3558 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3559 test_feature_states( __LINE__, hpkg, "two", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3560 test_feature_states( __LINE__, hpkg, "three", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3561 test_feature_states( __LINE__, hpkg, "four", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3562 test_feature_states( __LINE__, hpkg, "five", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3563 test_feature_states( __LINE__, hpkg, "six", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3564 test_feature_states( __LINE__, hpkg, "seven", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3565 test_feature_states( __LINE__, hpkg, "eight", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3566 test_feature_states( __LINE__, hpkg, "nine", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3567 test_feature_states( __LINE__, hpkg, "ten", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3568 test_feature_states( __LINE__, hpkg, "eleven", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, TRUE );
3569 test_feature_states( __LINE__, hpkg, "twelve", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_UNKNOWN, FALSE );
3570 test_feature_states( __LINE__, hpkg, "thirteen", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_UNKNOWN, FALSE );
3572 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3573 test_component_states( __LINE__, hpkg, "beta", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3574 test_component_states( __LINE__, hpkg, "gamma", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3575 test_component_states( __LINE__, hpkg, "theta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3576 test_component_states( __LINE__, hpkg, "delta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3577 test_component_states( __LINE__, hpkg, "epsilon", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3578 test_component_states( __LINE__, hpkg, "zeta", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3579 test_component_states( __LINE__, hpkg, "iota", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3580 test_component_states( __LINE__, hpkg, "eta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3581 test_component_states( __LINE__, hpkg, "kappa", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3582 test_component_states( __LINE__, hpkg, "lambda", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3583 test_component_states( __LINE__, hpkg, "mu", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3584 test_component_states( __LINE__, hpkg, "nu", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3585 test_component_states( __LINE__, hpkg, "xi", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3586 test_component_states( __LINE__, hpkg, "omicron", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3587 test_component_states( __LINE__, hpkg, "pi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3588 test_component_states( __LINE__, hpkg, "rho", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3589 test_component_states( __LINE__, hpkg, "sigma", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3590 test_component_states( __LINE__, hpkg, "tau", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3591 test_component_states( __LINE__, hpkg, "phi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3592 test_component_states( __LINE__, hpkg, "chi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3593 test_component_states( __LINE__, hpkg, "psi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3594 test_component_states( __LINE__, hpkg, "upsilon", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3596 MsiCloseHandle(hpkg);
3598 /* reinstall the product */
3599 r = MsiInstallProductA(msifile3, "REINSTALL=ALL");
3600 is_broken = (r == ERROR_INSTALL_FAILURE);
3601 ok(r == ERROR_SUCCESS || broken(is_broken) /* win2k3 */, "Expected ERROR_SUCCESS, got %d\n", r);
3603 state = MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "five");
3604 ok(state == INSTALLSTATE_UNKNOWN, "state = %d\n", state);
3605 state = MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "twelve");
3606 ok(state == INSTALLSTATE_LOCAL, "state = %d\n", state);
3608 r = MsiOpenDatabaseW(msifile4W, MSIDBOPEN_DIRECT, &hdb);
3609 ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
3611 /* this property must not be in the saved msi file */
3612 add_property_entry( hdb, "'ADDSOURCE', 'one,two,three,four,five,six,seven,eight,nine,ten'");
3614 r = package_from_db( hdb, &hpkg );
3615 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
3617 test_feature_states( __LINE__, hpkg, "one", ERROR_UNKNOWN_FEATURE, 0, 0, FALSE );
3618 test_component_states( __LINE__, hpkg, "alpha", ERROR_UNKNOWN_COMPONENT, 0, 0, FALSE );
3620 r = MsiDoActionA( hpkg, "CostInitialize");
3621 ok( r == ERROR_SUCCESS, "cost init failed\n");
3623 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3624 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3626 r = MsiDoActionA( hpkg, "FileCost");
3627 ok( r == ERROR_SUCCESS, "file cost failed\n");
3629 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3630 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3632 r = MsiDoActionA( hpkg, "CostFinalize");
3633 ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
3635 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3636 test_feature_states( __LINE__, hpkg, "two", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3637 test_feature_states( __LINE__, hpkg, "three", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3638 test_feature_states( __LINE__, hpkg, "four", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3639 test_feature_states( __LINE__, hpkg, "five", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3640 test_feature_states( __LINE__, hpkg, "six", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3641 test_feature_states( __LINE__, hpkg, "seven", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3642 test_feature_states( __LINE__, hpkg, "eight", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3643 test_feature_states( __LINE__, hpkg, "nine", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3644 test_feature_states( __LINE__, hpkg, "ten", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3645 test_feature_states( __LINE__, hpkg, "eleven", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, TRUE );
3646 test_feature_states( __LINE__, hpkg, "twelve", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_UNKNOWN, FALSE );
3647 test_feature_states( __LINE__, hpkg, "thirteen", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_UNKNOWN, FALSE );
3649 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3650 test_component_states( __LINE__, hpkg, "beta", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3651 test_component_states( __LINE__, hpkg, "gamma", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3652 test_component_states( __LINE__, hpkg, "theta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3653 test_component_states( __LINE__, hpkg, "delta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3654 test_component_states( __LINE__, hpkg, "epsilon", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3655 test_component_states( __LINE__, hpkg, "zeta", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3656 test_component_states( __LINE__, hpkg, "iota", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3657 test_component_states( __LINE__, hpkg, "eta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3658 test_component_states( __LINE__, hpkg, "kappa", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3659 test_component_states( __LINE__, hpkg, "lambda", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3660 test_component_states( __LINE__, hpkg, "mu", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3661 test_component_states( __LINE__, hpkg, "nu", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3662 test_component_states( __LINE__, hpkg, "xi", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3663 test_component_states( __LINE__, hpkg, "omicron", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3664 test_component_states( __LINE__, hpkg, "pi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3665 test_component_states( __LINE__, hpkg, "rho", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3666 test_component_states( __LINE__, hpkg, "sigma", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3667 test_component_states( __LINE__, hpkg, "tau", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3668 test_component_states( __LINE__, hpkg, "phi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3669 test_component_states( __LINE__, hpkg, "chi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3670 test_component_states( __LINE__, hpkg, "psi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3671 test_component_states( __LINE__, hpkg, "upsilon", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3673 MsiCloseHandle(hpkg);
3675 /* test source only install */
3676 r = MsiInstallProductA(msifile, "REMOVE=ALL");
3677 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3678 state = MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "one");
3679 ok(state == INSTALLSTATE_UNKNOWN, "state = %d\n", state);
3680 state = MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "two");
3681 ok(state == INSTALLSTATE_UNKNOWN, "state = %d\n", state);
3683 r = MsiInstallProductA(msifile, "ADDSOURCE=one");
3684 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3685 state = MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "one");
3686 ok(state == INSTALLSTATE_SOURCE, "state = %d\n", state);
3687 state = MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "two");
3688 ok(state == INSTALLSTATE_ABSENT, "state = %d\n", state);
3690 /* no arguments test */
3691 cache_file_name_len = sizeof(msi_cache_file);
3692 r = MsiGetProductInfoA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}",
3693 INSTALLPROPERTY_LOCALPACKAGEA, msi_cache_file, &cache_file_name_len);
3694 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3695 r = MsiOpenDatabaseA(msi_cache_file, (const char*)MSIDBOPEN_DIRECT, &hdb);
3696 ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
3698 create_custom_action_table( hdb );
3699 add_custom_action_entry( hdb, "'ConditionCheck1', 19, '', 'Condition check failed (1)'" );
3700 add_custom_action_entry( hdb, "'ConditionCheck2', 19, '', 'Condition check failed (2)'" );
3701 add_custom_action_entry( hdb, "'ConditionCheck3', 19, '', 'Condition check failed (3)'" );
3702 add_custom_action_entry( hdb, "'ConditionCheck4', 19, '', 'Condition check failed (4)'" );
3703 add_custom_action_entry( hdb, "'ConditionCheck5', 19, '', 'Condition check failed (5)'" );
3704 add_custom_action_entry( hdb, "'ConditionCheck6', 19, '', 'Condition check failed (6)'" );
3705 add_custom_action_entry( hdb, "'ConditionCheck7', 19, '', 'Condition check failed (7)'" );
3706 add_custom_action_entry( hdb, "'ConditionCheck8', 19, '', 'Condition check failed (8)'" );
3707 add_custom_action_entry( hdb,
3708 "'VBFeatureRequest', 38, '', 'Session.FeatureRequestState(\"three\") = 3'" );
3710 add_install_execute_sequence_entry( hdb, "'ConditionCheck1', 'REINSTALL', '798'" );
3711 add_install_execute_sequence_entry( hdb, "'ConditionCheck2', 'NOT REMOVE AND Preselected', '799'" );
3712 add_install_execute_sequence_entry( hdb, "'VBFeatureRequest', 'NOT REMOVE', '1001'" );
3713 add_install_execute_sequence_entry( hdb, "'ConditionCheck3', 'REINSTALL', '6598'" );
3714 add_install_execute_sequence_entry( hdb, "'ConditionCheck4', 'NOT REMOVE AND Preselected', '6599'" );
3715 add_install_execute_sequence_entry( hdb, "'ConditionCheck5', 'REINSTALL', '6601'" );
3716 add_install_execute_sequence_entry( hdb, "'ConditionCheck6', 'NOT REMOVE AND Preselected', '6601'" );
3717 /* Add "one" feature action tests */
3718 add_install_execute_sequence_entry( hdb, "'ConditionCheck7', 'NOT REMOVE AND NOT(&one=-1)', '1501'" );
3719 add_install_execute_sequence_entry( hdb, "'ConditionCheck8', 'NOT REMOVE AND NOT(&one=-1)', '6602'" );
3720 r = MsiDatabaseCommit(hdb);
3721 ok(r == ERROR_SUCCESS, "MsiDatabaseCommit failed: %d\n", r);
3722 r = package_from_db( hdb, &hpkg );
3723 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
3724 MsiCloseHandle(hdb);
3726 test_feature_states( __LINE__, hpkg, "one", ERROR_UNKNOWN_FEATURE, 0, 0, FALSE );
3727 test_feature_states( __LINE__, hpkg, "two", ERROR_UNKNOWN_FEATURE, 0, 0, FALSE );
3728 r = MsiDoActionA( hpkg, "CostInitialize");
3729 ok( r == ERROR_SUCCESS, "CostInitialize failed\n");
3730 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3731 test_feature_states( __LINE__, hpkg, "two", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3733 r = MsiDoActionA( hpkg, "FileCost");
3734 ok( r == ERROR_SUCCESS, "FileCost failed\n");
3735 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3736 test_feature_states( __LINE__, hpkg, "two", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3738 r = MsiDoActionA( hpkg, "CostFinalize");
3739 ok( r == ERROR_SUCCESS, "CostFinalize failed\n");
3740 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3741 test_feature_states( __LINE__, hpkg, "two", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3742 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3743 test_component_states( __LINE__, hpkg, "beta", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3744 test_component_states( __LINE__, hpkg, "gamma", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3745 test_component_states( __LINE__, hpkg, "theta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3746 test_component_states( __LINE__, hpkg, "delta", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3747 test_component_states( __LINE__, hpkg, "epsilon", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3748 test_component_states( __LINE__, hpkg, "zeta", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3749 test_component_states( __LINE__, hpkg, "iota", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3750 test_component_states( __LINE__, hpkg, "eta", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3751 test_component_states( __LINE__, hpkg, "kappa", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3752 test_component_states( __LINE__, hpkg, "lambda", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3753 test_component_states( __LINE__, hpkg, "mu", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3754 test_component_states( __LINE__, hpkg, "nu", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3755 test_component_states( __LINE__, hpkg, "xi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3756 test_component_states( __LINE__, hpkg, "omicron", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3757 test_component_states( __LINE__, hpkg, "pi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3758 test_component_states( __LINE__, hpkg, "rho", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3759 test_component_states( __LINE__, hpkg, "sigma", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3760 test_component_states( __LINE__, hpkg, "tau", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3761 test_component_states( __LINE__, hpkg, "phi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3762 test_component_states( __LINE__, hpkg, "chi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3763 test_component_states( __LINE__, hpkg, "psi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3764 test_component_states( __LINE__, hpkg, "upsilon", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3766 r = MsiDoActionA( hpkg, "InstallValidate");
3767 ok( r == ERROR_SUCCESS, "InstallValidate failed %d\n", r);
3768 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3769 test_feature_states( __LINE__, hpkg, "two", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3770 MsiCloseHandle( hpkg );
3772 r = MsiInstallProductA(msifile, "");
3773 ok(r == ERROR_SUCCESS || (is_broken && r == ERROR_INSTALL_FAILURE) /* win2k3 */,
3774 "Expected ERROR_SUCCESS, got %d\n", r);
3775 state = MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "one");
3776 ok(state == INSTALLSTATE_SOURCE, "state = %d\n", state);
3777 state = MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "two");
3778 ok(state == INSTALLSTATE_ABSENT, "state = %d\n", state);
3779 state = MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "three");
3780 ok(state == INSTALLSTATE_LOCAL, "state = %d\n", state);
3782 /* uninstall the product */
3783 r = MsiInstallProductA(msifile4, "REMOVE=ALL");
3784 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3786 DeleteFileA(msifile);
3787 DeleteFileA(msifile2);
3788 DeleteFileA(msifile3);
3789 DeleteFileA(msifile4);
3792 static void test_removefiles(void)
3794 MSIHANDLE hpkg;
3795 UINT r;
3796 MSIHANDLE hdb;
3797 INSTALLSTATE installed, action;
3799 hdb = create_package_db();
3800 ok ( hdb, "failed to create package database\n" );
3802 add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
3804 create_feature_table( hdb );
3805 add_feature_entry( hdb, "'one', '', '', '', 2, 1, '', 0" );
3807 create_component_table( hdb );
3808 add_component_entry( hdb, "'hydrogen', '', 'TARGETDIR', 0, '', 'hydrogen_file'" );
3809 add_component_entry( hdb, "'helium', '', 'TARGETDIR', 0, '', 'helium_file'" );
3810 add_component_entry( hdb, "'lithium', '', 'TARGETDIR', 0, '', 'lithium_file'" );
3811 add_component_entry( hdb, "'beryllium', '', 'TARGETDIR', 0, '', 'beryllium_file'" );
3812 add_component_entry( hdb, "'boron', '', 'TARGETDIR', 0, '', 'boron_file'" );
3813 add_component_entry( hdb, "'carbon', '', 'TARGETDIR', 0, '', 'carbon_file'" );
3814 add_component_entry( hdb, "'oxygen', '', 'TARGETDIR', 0, '0', 'oxygen_file'" );
3816 create_feature_components_table( hdb );
3817 add_feature_components_entry( hdb, "'one', 'hydrogen'" );
3818 add_feature_components_entry( hdb, "'one', 'helium'" );
3819 add_feature_components_entry( hdb, "'one', 'lithium'" );
3820 add_feature_components_entry( hdb, "'one', 'beryllium'" );
3821 add_feature_components_entry( hdb, "'one', 'boron'" );
3822 add_feature_components_entry( hdb, "'one', 'carbon'" );
3823 add_feature_components_entry( hdb, "'one', 'oxygen'" );
3825 create_file_table( hdb );
3826 add_file_entry( hdb, "'hydrogen_file', 'hydrogen', 'hydrogen.txt', 0, '', '1033', 8192, 1" );
3827 add_file_entry( hdb, "'helium_file', 'helium', 'helium.txt', 0, '', '1033', 8192, 1" );
3828 add_file_entry( hdb, "'lithium_file', 'lithium', 'lithium.txt', 0, '', '1033', 8192, 1" );
3829 add_file_entry( hdb, "'beryllium_file', 'beryllium', 'beryllium.txt', 0, '', '1033', 16384, 1" );
3830 add_file_entry( hdb, "'boron_file', 'boron', 'boron.txt', 0, '', '1033', 16384, 1" );
3831 add_file_entry( hdb, "'carbon_file', 'carbon', 'carbon.txt', 0, '', '1033', 16384, 1" );
3832 add_file_entry( hdb, "'oxygen_file', 'oxygen', 'oxygen.txt', 0, '', '1033', 16384, 1" );
3834 create_remove_file_table( hdb );
3836 r = package_from_db( hdb, &hpkg );
3837 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
3839 skip("Not enough rights to perform tests\n");
3840 DeleteFileA(msifile);
3841 return;
3843 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
3845 MsiCloseHandle( hdb );
3847 create_test_file( "hydrogen.txt" );
3848 create_test_file( "helium.txt" );
3849 create_test_file( "lithium.txt" );
3850 create_test_file( "beryllium.txt" );
3851 create_test_file( "boron.txt" );
3852 create_test_file( "carbon.txt" );
3853 create_test_file( "oxygen.txt" );
3855 r = MsiSetPropertyA( hpkg, "TARGETDIR", CURR_DIR );
3856 ok( r == ERROR_SUCCESS, "set property failed\n");
3858 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3860 r = MsiGetComponentStateA( hpkg, "oxygen", &installed, &action );
3861 ok( r == ERROR_UNKNOWN_COMPONENT, "expected ERROR_UNKNOWN_COMPONENT, got %u\n", r );
3863 r = MsiDoActionA( hpkg, "CostInitialize");
3864 ok( r == ERROR_SUCCESS, "cost init failed\n");
3866 r = MsiDoActionA( hpkg, "FileCost");
3867 ok( r == ERROR_SUCCESS, "file cost failed\n");
3869 installed = action = 0xdeadbeef;
3870 r = MsiGetComponentStateA( hpkg, "oxygen", &installed, &action );
3871 ok( r == ERROR_SUCCESS, "failed to get component state %u\n", r );
3872 ok( installed == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed );
3873 ok( action == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", action );
3875 r = MsiDoActionA( hpkg, "CostFinalize");
3876 ok( r == ERROR_SUCCESS, "cost finalize failed\n");
3878 r = MsiDoActionA( hpkg, "InstallValidate");
3879 ok( r == ERROR_SUCCESS, "install validate failed\n");
3881 r = MsiSetComponentStateA( hpkg, "hydrogen", INSTALLSTATE_ABSENT );
3882 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
3884 installed = action = 0xdeadbeef;
3885 r = MsiGetComponentStateA( hpkg, "hydrogen", &installed, &action );
3886 ok( r == ERROR_SUCCESS, "failed to get component state %u\n", r );
3887 ok( installed == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed );
3888 todo_wine ok( action == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", action );
3890 r = MsiSetComponentStateA( hpkg, "helium", INSTALLSTATE_LOCAL );
3891 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
3893 r = MsiSetComponentStateA( hpkg, "lithium", INSTALLSTATE_SOURCE );
3894 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
3896 r = MsiSetComponentStateA( hpkg, "beryllium", INSTALLSTATE_ABSENT );
3897 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
3899 r = MsiSetComponentStateA( hpkg, "boron", INSTALLSTATE_LOCAL );
3900 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
3902 r = MsiSetComponentStateA( hpkg, "carbon", INSTALLSTATE_SOURCE );
3903 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
3905 installed = action = 0xdeadbeef;
3906 r = MsiGetComponentStateA( hpkg, "oxygen", &installed, &action );
3907 ok( r == ERROR_SUCCESS, "failed to get component state %u\n", r );
3908 ok( installed == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed );
3909 ok( action == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", action );
3911 r = MsiSetComponentStateA( hpkg, "oxygen", INSTALLSTATE_ABSENT );
3912 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
3914 installed = action = 0xdeadbeef;
3915 r = MsiGetComponentStateA( hpkg, "oxygen", &installed, &action );
3916 ok( r == ERROR_SUCCESS, "failed to get component state %u\n", r );
3917 ok( installed == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed );
3918 ok( action == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", action );
3920 r = MsiDoActionA( hpkg, "RemoveFiles");
3921 ok( r == ERROR_SUCCESS, "remove files failed\n");
3923 installed = action = 0xdeadbeef;
3924 r = MsiGetComponentStateA( hpkg, "oxygen", &installed, &action );
3925 ok( r == ERROR_SUCCESS, "failed to get component state %u\n", r );
3926 ok( installed == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed );
3927 ok( action == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", action );
3929 ok(DeleteFileA("hydrogen.txt"), "Expected hydrogen.txt to exist\n");
3930 ok(DeleteFileA("lithium.txt"), "Expected lithium.txt to exist\n");
3931 ok(DeleteFileA("beryllium.txt"), "Expected beryllium.txt to exist\n");
3932 ok(DeleteFileA("carbon.txt"), "Expected carbon.txt to exist\n");
3933 ok(DeleteFileA("helium.txt"), "Expected helium.txt to exist\n");
3934 ok(DeleteFileA("boron.txt"), "Expected boron.txt to exist\n");
3935 ok(DeleteFileA("oxygen.txt"), "Expected oxygen.txt to exist\n");
3937 MsiCloseHandle( hpkg );
3938 DeleteFileA(msifile);
3941 static void test_appsearch(void)
3943 MSIHANDLE hpkg;
3944 UINT r;
3945 MSIHANDLE hdb;
3946 CHAR prop[MAX_PATH];
3947 DWORD size;
3948 HKEY hkey;
3949 const char reg_expand_value[] = "%systemroot%\\system32\\notepad.exe";
3951 hdb = create_package_db();
3952 ok ( hdb, "failed to create package database\n" );
3954 create_appsearch_table( hdb );
3955 add_appsearch_entry( hdb, "'WEBBROWSERPROG', 'NewSignature1'" );
3956 add_appsearch_entry( hdb, "'NOTEPAD', 'NewSignature2'" );
3957 add_appsearch_entry( hdb, "'REGEXPANDVAL', 'NewSignature3'" );
3959 create_reglocator_table( hdb );
3960 add_reglocator_entry( hdb, "NewSignature1", 0, "htmlfile\\shell\\open\\command", "", 1 );
3962 r = RegCreateKeyExA(HKEY_CURRENT_USER, "Software\\Winetest_msi", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hkey, NULL);
3963 ok( r == ERROR_SUCCESS, "Could not create key: %d.\n", r );
3964 r = RegSetValueExA(hkey, NULL, 0, REG_EXPAND_SZ, (const BYTE*)reg_expand_value, strlen(reg_expand_value) + 1);
3965 ok( r == ERROR_SUCCESS, "Could not set key value: %d.\n", r);
3966 RegCloseKey(hkey);
3967 add_reglocator_entry( hdb, "NewSignature3", 1, "Software\\Winetest_msi", "", 1 );
3969 create_drlocator_table( hdb );
3970 add_drlocator_entry( hdb, "'NewSignature2', 0, 'c:\\windows\\system32', 0" );
3972 create_signature_table( hdb );
3973 add_signature_entry( hdb, "'NewSignature1', 'FileName', '', '', '', '', '', '', ''" );
3974 add_signature_entry( hdb, "'NewSignature2', 'NOTEPAD.EXE|notepad.exe', '', '', '', '', '', '', ''" );
3975 add_signature_entry( hdb, "'NewSignature3', 'NOTEPAD.EXE|notepad.exe', '', '', '', '', '', '', ''" );
3977 r = package_from_db( hdb, &hpkg );
3978 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
3980 skip("Not enough rights to perform tests\n");
3981 DeleteFileA(msifile);
3982 return;
3984 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
3985 MsiCloseHandle( hdb );
3986 if (r != ERROR_SUCCESS)
3987 goto done;
3989 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3991 r = MsiDoActionA( hpkg, "AppSearch" );
3992 ok( r == ERROR_SUCCESS, "AppSearch failed: %d\n", r);
3994 size = sizeof(prop);
3995 r = MsiGetPropertyA( hpkg, "WEBBROWSERPROG", prop, &size );
3996 ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
3997 ok( lstrlenA(prop) != 0, "Expected non-zero length\n");
3999 size = sizeof(prop);
4000 r = MsiGetPropertyA( hpkg, "NOTEPAD", prop, &size );
4001 ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
4003 size = sizeof(prop);
4004 r = MsiGetPropertyA( hpkg, "REGEXPANDVAL", prop, &size );
4005 ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
4006 ok( lstrlenA(prop) != 0, "Expected non-zero length\n");
4008 done:
4009 MsiCloseHandle( hpkg );
4010 DeleteFileA(msifile);
4011 RegDeleteKeyA(HKEY_CURRENT_USER, "Software\\Winetest_msi");
4014 static void test_appsearch_complocator(void)
4016 MSIHANDLE hpkg, hdb;
4017 char path[MAX_PATH], expected[MAX_PATH], prop[MAX_PATH];
4018 LPSTR usersid;
4019 DWORD size;
4020 UINT r;
4022 if (!(usersid = get_user_sid()))
4023 return;
4025 if (is_process_limited())
4027 skip("process is limited\n");
4028 return;
4031 create_test_file("FileName1");
4032 create_test_file("FileName4");
4033 set_component_path("FileName1", MSIINSTALLCONTEXT_MACHINE,
4034 "{A8AE6692-96BA-4198-8399-145D7D1D0D0E}", NULL, FALSE);
4036 create_test_file("FileName2");
4037 set_component_path("FileName2", MSIINSTALLCONTEXT_USERUNMANAGED,
4038 "{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}", usersid, FALSE);
4040 create_test_file("FileName3");
4041 set_component_path("FileName3", MSIINSTALLCONTEXT_USERMANAGED,
4042 "{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}", usersid, FALSE);
4044 create_test_file("FileName5");
4045 set_component_path("FileName5", MSIINSTALLCONTEXT_MACHINE,
4046 "{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}", NULL, TRUE);
4048 create_test_file("FileName6");
4049 set_component_path("FileName6", MSIINSTALLCONTEXT_MACHINE,
4050 "{C0ECD96F-7898-4410-9667-194BD8C1B648}", NULL, TRUE);
4052 create_test_file("FileName7");
4053 set_component_path("FileName7", MSIINSTALLCONTEXT_MACHINE,
4054 "{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}", NULL, FALSE);
4056 /* dir is FALSE, but we're pretending it's a directory */
4057 set_component_path("IDontExist\\", MSIINSTALLCONTEXT_MACHINE,
4058 "{91B7359B-07F2-4221-AA8D-DE102BB87A5F}", NULL, FALSE);
4060 create_file_with_version("FileName8.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4061 set_component_path("FileName8.dll", MSIINSTALLCONTEXT_MACHINE,
4062 "{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}", NULL, FALSE);
4064 create_file_with_version("FileName9.dll", MAKELONG(1, 2), MAKELONG(3, 4));
4065 set_component_path("FileName9.dll", MSIINSTALLCONTEXT_MACHINE,
4066 "{A204DF48-7346-4635-BA2E-66247DBAC9DF}", NULL, FALSE);
4068 create_file_with_version("FileName10.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4069 set_component_path("FileName10.dll", MSIINSTALLCONTEXT_MACHINE,
4070 "{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}", NULL, FALSE);
4072 hdb = create_package_db();
4073 ok(hdb, "Expected a valid database handle\n");
4075 create_appsearch_table(hdb);
4076 add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
4077 add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
4078 add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
4079 add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
4080 add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
4081 add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
4082 add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
4083 add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
4084 add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
4085 add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
4086 add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
4087 add_appsearch_entry(hdb, "'SIGPROP12', 'NewSignature12'");
4089 create_complocator_table(hdb);
4091 /* published component, machine, file, signature, misdbLocatorTypeFile */
4092 add_complocator_entry(hdb, "'NewSignature1', '{A8AE6692-96BA-4198-8399-145D7D1D0D0E}', 1");
4094 /* published component, user-unmanaged, file, signature, misdbLocatorTypeFile */
4095 add_complocator_entry(hdb, "'NewSignature2', '{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}', 1");
4097 /* published component, user-managed, file, signature, misdbLocatorTypeFile */
4098 add_complocator_entry(hdb, "'NewSignature3', '{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}', 1");
4100 /* published component, machine, file, signature, misdbLocatorTypeDirectory */
4101 add_complocator_entry(hdb, "'NewSignature4', '{A8AE6692-96BA-4198-8399-145D7D1D0D0E}', 0");
4103 /* published component, machine, dir, signature, misdbLocatorTypeDirectory */
4104 add_complocator_entry(hdb, "'NewSignature5', '{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}', 0");
4106 /* published component, machine, dir, no signature, misdbLocatorTypeDirectory */
4107 add_complocator_entry(hdb, "'NewSignature6', '{C0ECD96F-7898-4410-9667-194BD8C1B648}', 0");
4109 /* published component, machine, file, no signature, misdbLocatorTypeFile */
4110 add_complocator_entry(hdb, "'NewSignature7', '{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}', 1");
4112 /* unpublished component, no signature, misdbLocatorTypeDir */
4113 add_complocator_entry(hdb, "'NewSignature8', '{FB671D5B-5083-4048-90E0-481C48D8F3A5}', 0");
4115 /* published component, no signature, dir does not exist misdbLocatorTypeDir */
4116 add_complocator_entry(hdb, "'NewSignature9', '{91B7359B-07F2-4221-AA8D-DE102BB87A5F}', 0");
4118 /* published component, signature w/ ver, misdbLocatorTypeFile */
4119 add_complocator_entry(hdb, "'NewSignature10', '{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}', 1");
4121 /* published component, signature w/ ver, ver > max, misdbLocatorTypeFile */
4122 add_complocator_entry(hdb, "'NewSignature11', '{A204DF48-7346-4635-BA2E-66247DBAC9DF}', 1");
4124 /* published component, signature w/ ver, sig->name ignored, misdbLocatorTypeFile */
4125 add_complocator_entry(hdb, "'NewSignature12', '{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}', 1");
4127 create_signature_table(hdb);
4128 add_signature_entry(hdb, "'NewSignature1', 'FileName1', '', '', '', '', '', '', ''");
4129 add_signature_entry(hdb, "'NewSignature2', 'FileName2', '', '', '', '', '', '', ''");
4130 add_signature_entry(hdb, "'NewSignature3', 'FileName3', '', '', '', '', '', '', ''");
4131 add_signature_entry(hdb, "'NewSignature4', 'FileName4', '', '', '', '', '', '', ''");
4132 add_signature_entry(hdb, "'NewSignature5', 'FileName5', '', '', '', '', '', '', ''");
4133 add_signature_entry(hdb, "'NewSignature10', 'FileName8.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
4134 add_signature_entry(hdb, "'NewSignature11', 'FileName9.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
4135 add_signature_entry(hdb, "'NewSignature12', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
4137 r = package_from_db(hdb, &hpkg);
4138 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
4140 skip("Not enough rights to perform tests\n");
4141 goto error;
4143 ok(r == ERROR_SUCCESS, "Expected a valid package handle %u\n", r);
4145 r = MsiSetPropertyA(hpkg, "SIGPROP8", "october");
4146 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4148 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
4150 r = MsiDoActionA(hpkg, "AppSearch");
4151 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4153 strcpy(expected, CURR_DIR);
4154 if (is_root(CURR_DIR)) expected[2] = 0;
4156 size = MAX_PATH;
4157 sprintf(path, "%s\\FileName1", expected);
4158 r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
4159 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4160 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4162 size = MAX_PATH;
4163 sprintf(path, "%s\\FileName2", expected);
4164 r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
4165 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4166 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4168 size = MAX_PATH;
4169 sprintf(path, "%s\\FileName3", expected);
4170 r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
4171 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4172 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4174 size = MAX_PATH;
4175 sprintf(path, "%s\\FileName4", expected);
4176 r = MsiGetPropertyA(hpkg, "SIGPROP4", prop, &size);
4177 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4178 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4180 size = MAX_PATH;
4181 sprintf(path, "%s\\FileName5", expected);
4182 r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
4183 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4184 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4186 size = MAX_PATH;
4187 sprintf(path, "%s\\", expected);
4188 r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
4189 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4190 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4192 size = MAX_PATH;
4193 sprintf(path, "%s\\", expected);
4194 r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
4195 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4196 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4198 size = MAX_PATH;
4199 r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
4200 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4201 ok(!lstrcmpA(prop, "october"), "Expected \"october\", got \"%s\"\n", prop);
4203 size = MAX_PATH;
4204 r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
4205 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4206 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4208 size = MAX_PATH;
4209 sprintf(path, "%s\\FileName8.dll", expected);
4210 r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
4211 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4212 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4214 size = MAX_PATH;
4215 r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
4216 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4217 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4219 size = MAX_PATH;
4220 sprintf(path, "%s\\FileName10.dll", expected);
4221 r = MsiGetPropertyA(hpkg, "SIGPROP12", prop, &size);
4222 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4223 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4225 delete_component_path("{A8AE6692-96BA-4198-8399-145D7D1D0D0E}",
4226 MSIINSTALLCONTEXT_MACHINE, NULL);
4227 delete_component_path("{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}",
4228 MSIINSTALLCONTEXT_USERUNMANAGED, usersid);
4229 delete_component_path("{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}",
4230 MSIINSTALLCONTEXT_USERMANAGED, usersid);
4231 delete_component_path("{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}",
4232 MSIINSTALLCONTEXT_MACHINE, NULL);
4233 delete_component_path("{C0ECD96F-7898-4410-9667-194BD8C1B648}",
4234 MSIINSTALLCONTEXT_MACHINE, NULL);
4235 delete_component_path("{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}",
4236 MSIINSTALLCONTEXT_MACHINE, NULL);
4237 delete_component_path("{91B7359B-07F2-4221-AA8D-DE102BB87A5F}",
4238 MSIINSTALLCONTEXT_MACHINE, NULL);
4239 delete_component_path("{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}",
4240 MSIINSTALLCONTEXT_MACHINE, NULL);
4241 delete_component_path("{A204DF48-7346-4635-BA2E-66247DBAC9DF}",
4242 MSIINSTALLCONTEXT_MACHINE, NULL);
4243 delete_component_path("{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}",
4244 MSIINSTALLCONTEXT_MACHINE, NULL);
4246 MsiCloseHandle(hpkg);
4248 error:
4249 DeleteFileA("FileName1");
4250 DeleteFileA("FileName2");
4251 DeleteFileA("FileName3");
4252 DeleteFileA("FileName4");
4253 DeleteFileA("FileName5");
4254 DeleteFileA("FileName6");
4255 DeleteFileA("FileName7");
4256 DeleteFileA("FileName8.dll");
4257 DeleteFileA("FileName9.dll");
4258 DeleteFileA("FileName10.dll");
4259 DeleteFileA(msifile);
4260 LocalFree(usersid);
4263 static void test_appsearch_reglocator(void)
4265 MSIHANDLE hpkg, hdb;
4266 char path[MAX_PATH], expected[MAX_PATH], prop[MAX_PATH];
4267 DWORD binary[2], size, val;
4268 BOOL space, version, is_64bit = sizeof(void *) > sizeof(int);
4269 HKEY hklm, classes, hkcu, users;
4270 LPSTR pathdata, pathvar, ptr;
4271 LONG res;
4272 UINT r, type = 0;
4273 SYSTEM_INFO si;
4275 version = TRUE;
4276 if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
4277 version = FALSE;
4279 DeleteFileA("test.dll");
4281 res = RegCreateKeyA(HKEY_CLASSES_ROOT, "Software\\Wine", &classes);
4282 if (res == ERROR_ACCESS_DENIED)
4284 skip("Not enough rights to perform tests\n");
4285 return;
4287 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4289 res = RegSetValueExA(classes, "Value1", 0, REG_SZ,
4290 (const BYTE *)"regszdata", 10);
4291 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4293 res = RegCreateKeyA(HKEY_CURRENT_USER, "Software\\Wine", &hkcu);
4294 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4296 res = RegSetValueExA(hkcu, "Value1", 0, REG_SZ,
4297 (const BYTE *)"regszdata", 10);
4298 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4300 users = 0;
4301 res = RegCreateKeyA(HKEY_USERS, "S-1-5-18\\Software\\Wine", &users);
4302 ok(res == ERROR_SUCCESS ||
4303 broken(res == ERROR_INVALID_PARAMETER),
4304 "Expected ERROR_SUCCESS, got %d\n", res);
4306 if (res == ERROR_SUCCESS)
4308 res = RegSetValueExA(users, "Value1", 0, REG_SZ,
4309 (const BYTE *)"regszdata", 10);
4310 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4313 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine", &hklm);
4314 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4316 res = RegSetValueA(hklm, NULL, REG_SZ, "defvalue", 8);
4317 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4319 res = RegSetValueExA(hklm, "Value1", 0, REG_SZ,
4320 (const BYTE *)"regszdata", 10);
4321 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4323 val = 42;
4324 res = RegSetValueExA(hklm, "Value2", 0, REG_DWORD,
4325 (const BYTE *)&val, sizeof(DWORD));
4326 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4328 val = -42;
4329 res = RegSetValueExA(hklm, "Value3", 0, REG_DWORD,
4330 (const BYTE *)&val, sizeof(DWORD));
4331 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4333 res = RegSetValueExA(hklm, "Value4", 0, REG_EXPAND_SZ,
4334 (const BYTE *)"%PATH%", 7);
4335 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4337 res = RegSetValueExA(hklm, "Value5", 0, REG_EXPAND_SZ,
4338 (const BYTE *)"my%NOVAR%", 10);
4339 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4341 res = RegSetValueExA(hklm, "Value6", 0, REG_MULTI_SZ,
4342 (const BYTE *)"one\0two\0", 9);
4343 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4345 binary[0] = 0x1234abcd;
4346 binary[1] = 0x567890ef;
4347 res = RegSetValueExA(hklm, "Value7", 0, REG_BINARY,
4348 (const BYTE *)binary, sizeof(binary));
4349 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4351 res = RegSetValueExA(hklm, "Value8", 0, REG_SZ,
4352 (const BYTE *)"#regszdata", 11);
4353 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4355 strcpy(expected, CURR_DIR);
4356 if (is_root(CURR_DIR)) expected[2] = 0;
4358 create_test_file("FileName1");
4359 sprintf(path, "%s\\FileName1", expected);
4360 res = RegSetValueExA(hklm, "Value9", 0, REG_SZ,
4361 (const BYTE *)path, lstrlenA(path) + 1);
4362 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4364 sprintf(path, "%s\\FileName2", expected);
4365 res = RegSetValueExA(hklm, "Value10", 0, REG_SZ,
4366 (const BYTE *)path, lstrlenA(path) + 1);
4367 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4369 lstrcpyA(path, expected);
4370 res = RegSetValueExA(hklm, "Value11", 0, REG_SZ,
4371 (const BYTE *)path, lstrlenA(path) + 1);
4372 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4374 res = RegSetValueExA(hklm, "Value12", 0, REG_SZ,
4375 (const BYTE *)"", 1);
4376 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4378 create_file_with_version("FileName3.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4379 sprintf(path, "%s\\FileName3.dll", expected);
4380 res = RegSetValueExA(hklm, "Value13", 0, REG_SZ,
4381 (const BYTE *)path, lstrlenA(path) + 1);
4382 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4384 create_file_with_version("FileName4.dll", MAKELONG(1, 2), MAKELONG(3, 4));
4385 sprintf(path, "%s\\FileName4.dll", expected);
4386 res = RegSetValueExA(hklm, "Value14", 0, REG_SZ,
4387 (const BYTE *)path, lstrlenA(path) + 1);
4388 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4390 create_file_with_version("FileName5.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4391 sprintf(path, "%s\\FileName5.dll", expected);
4392 res = RegSetValueExA(hklm, "Value15", 0, REG_SZ,
4393 (const BYTE *)path, lstrlenA(path) + 1);
4394 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4396 sprintf(path, "\"%s\\FileName1\" -option", expected);
4397 res = RegSetValueExA(hklm, "value16", 0, REG_SZ,
4398 (const BYTE *)path, lstrlenA(path) + 1);
4399 ok( res == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", res);
4401 space = strchr(expected, ' ') != NULL;
4402 sprintf(path, "%s\\FileName1 -option", expected);
4403 res = RegSetValueExA(hklm, "value17", 0, REG_SZ,
4404 (const BYTE *)path, lstrlenA(path) + 1);
4405 ok( res == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", res);
4407 hdb = create_package_db();
4408 ok(hdb, "Expected a valid database handle\n");
4410 create_appsearch_table(hdb);
4411 add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
4412 add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
4413 add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
4414 add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
4415 add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
4416 add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
4417 add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
4418 add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
4419 add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
4420 add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
4421 add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
4422 add_appsearch_entry(hdb, "'SIGPROP12', 'NewSignature12'");
4423 add_appsearch_entry(hdb, "'SIGPROP13', 'NewSignature13'");
4424 add_appsearch_entry(hdb, "'SIGPROP14', 'NewSignature14'");
4425 add_appsearch_entry(hdb, "'SIGPROP15', 'NewSignature15'");
4426 add_appsearch_entry(hdb, "'SIGPROP16', 'NewSignature16'");
4427 add_appsearch_entry(hdb, "'SIGPROP17', 'NewSignature17'");
4428 add_appsearch_entry(hdb, "'SIGPROP18', 'NewSignature18'");
4429 add_appsearch_entry(hdb, "'SIGPROP19', 'NewSignature19'");
4430 add_appsearch_entry(hdb, "'SIGPROP20', 'NewSignature20'");
4431 add_appsearch_entry(hdb, "'SIGPROP21', 'NewSignature21'");
4432 add_appsearch_entry(hdb, "'SIGPROP22', 'NewSignature22'");
4433 add_appsearch_entry(hdb, "'SIGPROP23', 'NewSignature23'");
4434 add_appsearch_entry(hdb, "'SIGPROP24', 'NewSignature24'");
4435 add_appsearch_entry(hdb, "'SIGPROP25', 'NewSignature25'");
4436 add_appsearch_entry(hdb, "'SIGPROP26', 'NewSignature26'");
4437 add_appsearch_entry(hdb, "'SIGPROP27', 'NewSignature27'");
4438 add_appsearch_entry(hdb, "'SIGPROP28', 'NewSignature28'");
4439 add_appsearch_entry(hdb, "'SIGPROP29', 'NewSignature29'");
4440 add_appsearch_entry(hdb, "'SIGPROP30', 'NewSignature30'");
4442 create_reglocator_table(hdb);
4444 type = msidbLocatorTypeRawValue;
4445 if (is_64bit)
4446 type |= msidbLocatorType64bit;
4448 /* HKLM, msidbLocatorTypeRawValue, REG_SZ */
4449 add_reglocator_entry(hdb, "NewSignature1", 2, "Software\\Wine", "Value1", type);
4451 /* HKLM, msidbLocatorTypeRawValue, positive DWORD */
4452 add_reglocator_entry(hdb, "NewSignature2", 2, "Software\\Wine", "Value2", type);
4454 /* HKLM, msidbLocatorTypeRawValue, negative DWORD */
4455 add_reglocator_entry(hdb, "NewSignature3", 2, "Software\\Wine", "Value3", type);
4457 /* HKLM, msidbLocatorTypeRawValue, REG_EXPAND_SZ */
4458 add_reglocator_entry(hdb, "NewSignature4", 2, "Software\\Wine", "Value4", type);
4460 /* HKLM, msidbLocatorTypeRawValue, REG_EXPAND_SZ */
4461 add_reglocator_entry(hdb, "NewSignature5", 2, "Software\\Wine", "Value5", type);
4463 /* HKLM, msidbLocatorTypeRawValue, REG_MULTI_SZ */
4464 add_reglocator_entry(hdb, "NewSignature6", 2, "Software\\Wine", "Value6", type);
4466 /* HKLM, msidbLocatorTypeRawValue, REG_BINARY */
4467 add_reglocator_entry(hdb, "NewSignature7", 2, "Software\\Wine", "Value7", type);
4469 /* HKLM, msidbLocatorTypeRawValue, REG_SZ first char is # */
4470 add_reglocator_entry(hdb, "NewSignature8", 2, "Software\\Wine", "Value8", type);
4472 type = msidbLocatorTypeFileName;
4473 if (is_64bit)
4474 type |= msidbLocatorType64bit;
4476 /* HKLM, msidbLocatorTypeFileName, signature, file exists */
4477 add_reglocator_entry(hdb, "NewSignature9", 2, "Software\\Wine", "Value9", type);
4479 /* HKLM, msidbLocatorTypeFileName, signature, file does not exist */
4480 add_reglocator_entry(hdb, "NewSignature10", 2, "Software\\Wine", "Value10", type);
4482 /* HKLM, msidbLocatorTypeFileName, no signature */
4483 add_reglocator_entry(hdb, "NewSignature11", 2, "Software\\Wine", "Value9", type);
4485 type = msidbLocatorTypeDirectory;
4486 if (is_64bit)
4487 type |= msidbLocatorType64bit;
4489 /* HKLM, msidbLocatorTypeDirectory, no signature, file exists */
4490 add_reglocator_entry(hdb, "NewSignature12", 2, "Software\\Wine", "Value9", type);
4492 /* HKLM, msidbLocatorTypeDirectory, no signature, directory exists */
4493 add_reglocator_entry(hdb, "NewSignature13", 2, "Software\\Wine", "Value11", type);
4495 /* HKLM, msidbLocatorTypeDirectory, signature, file exists */
4496 add_reglocator_entry(hdb, "NewSignature14", 2, "Software\\Wine", "Value9", type);
4498 type = msidbLocatorTypeRawValue;
4499 if (is_64bit)
4500 type |= msidbLocatorType64bit;
4502 /* HKCR, msidbLocatorTypeRawValue, REG_SZ */
4503 add_reglocator_entry(hdb, "NewSignature15", 0, "Software\\Wine", "Value1", type);
4505 /* HKCU, msidbLocatorTypeRawValue, REG_SZ */
4506 add_reglocator_entry(hdb, "NewSignature16", 1, "Software\\Wine", "Value1", type);
4508 /* HKU, msidbLocatorTypeRawValue, REG_SZ */
4509 add_reglocator_entry(hdb, "NewSignature17", 3, "S-1-5-18\\Software\\Wine", "Value1", type);
4511 /* HKLM, msidbLocatorTypeRawValue, REG_SZ, NULL Name */
4512 add_reglocator_entry(hdb, "NewSignature18", 2, "Software\\Wine", "", type);
4514 /* HKLM, msidbLocatorTypeRawValue, REG_SZ, key does not exist */
4515 add_reglocator_entry(hdb, "NewSignature19", 2, "Software\\IDontExist", "", type);
4517 /* HKLM, msidbLocatorTypeRawValue, REG_SZ, value is empty */
4518 add_reglocator_entry(hdb, "NewSignature20", 2, "Software\\Wine", "Value12", type);
4520 type = msidbLocatorTypeFileName;
4521 if (is_64bit)
4522 type |= msidbLocatorType64bit;
4524 /* HKLM, msidbLocatorTypeFileName, signature, file exists w/ version */
4525 add_reglocator_entry(hdb, "NewSignature21", 2, "Software\\Wine", "Value13", type);
4527 /* HKLM, msidbLocatorTypeFileName, file exists w/ version, version > max */
4528 add_reglocator_entry(hdb, "NewSignature22", 2, "Software\\Wine", "Value14", type);
4530 /* HKLM, msidbLocatorTypeFileName, file exists w/ version, sig->name ignored */
4531 add_reglocator_entry(hdb, "NewSignature23", 2, "Software\\Wine", "Value15", type);
4533 /* HKLM, msidbLocatorTypeFileName, no signature, directory exists */
4534 add_reglocator_entry(hdb, "NewSignature24", 2, "Software\\Wine", "Value11", type);
4536 /* HKLM, msidbLocatorTypeFileName, no signature, file does not exist */
4537 add_reglocator_entry(hdb, "NewSignature25", 2, "Software\\Wine", "Value10", type);
4539 type = msidbLocatorTypeDirectory;
4540 if (is_64bit)
4541 type |= msidbLocatorType64bit;
4543 /* HKLM, msidbLocatorTypeDirectory, signature, directory exists */
4544 add_reglocator_entry(hdb, "NewSignature26", 2, "Software\\Wine", "Value11", type);
4546 /* HKLM, msidbLocatorTypeDirectory, signature, file does not exist */
4547 add_reglocator_entry(hdb, "NewSignature27", 2, "Software\\Wine", "Value10", type);
4549 /* HKLM, msidbLocatorTypeDirectory, no signature, file does not exist */
4550 add_reglocator_entry(hdb, "NewSignature28", 2, "Software\\Wine", "Value10", type);
4552 type = msidbLocatorTypeFileName;
4553 if (is_64bit)
4554 type |= msidbLocatorType64bit;
4556 /* HKLM, msidbLocatorTypeFile, file exists, in quotes */
4557 add_reglocator_entry(hdb, "NewSignature29", 2, "Software\\Wine", "Value16", type);
4559 /* HKLM, msidbLocatorTypeFile, file exists, no quotes */
4560 add_reglocator_entry(hdb, "NewSignature30", 2, "Software\\Wine", "Value17", type);
4562 create_signature_table(hdb);
4563 add_signature_entry(hdb, "'NewSignature9', 'FileName1', '', '', '', '', '', '', ''");
4564 add_signature_entry(hdb, "'NewSignature10', 'FileName2', '', '', '', '', '', '', ''");
4565 add_signature_entry(hdb, "'NewSignature14', 'FileName1', '', '', '', '', '', '', ''");
4566 add_signature_entry(hdb, "'NewSignature21', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
4567 add_signature_entry(hdb, "'NewSignature22', 'FileName4.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
4568 add_signature_entry(hdb, "'NewSignature23', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
4570 if (!is_root(CURR_DIR))
4572 ptr = strrchr(expected, '\\') + 1;
4573 sprintf(path, "'NewSignature26', '%s', '', '', '', '', '', '', ''", ptr);
4574 add_signature_entry(hdb, path);
4576 add_signature_entry(hdb, "'NewSignature27', 'FileName2', '', '', '', '', '', '', ''");
4577 add_signature_entry(hdb, "'NewSignature29', 'FileName1', '', '', '', '', '', '', ''");
4578 add_signature_entry(hdb, "'NewSignature30', 'FileName1', '', '', '', '', '', '', ''");
4580 r = package_from_db(hdb, &hpkg);
4581 ok(r == ERROR_SUCCESS, "Expected a valid package handle %u\n", r);
4583 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
4585 r = MsiDoActionA(hpkg, "AppSearch");
4586 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4588 size = MAX_PATH;
4589 r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
4590 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4591 ok(!lstrcmpA(prop, "regszdata"),
4592 "Expected \"regszdata\", got \"%s\"\n", prop);
4594 size = MAX_PATH;
4595 r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
4596 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4597 ok(!lstrcmpA(prop, "#42"), "Expected \"#42\", got \"%s\"\n", prop);
4599 size = MAX_PATH;
4600 r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
4601 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4602 ok(!lstrcmpA(prop, "#-42"), "Expected \"#-42\", got \"%s\"\n", prop);
4604 memset(&si, 0, sizeof(si));
4605 if (pGetNativeSystemInfo) pGetNativeSystemInfo(&si);
4607 if (S(U(si)).wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL)
4609 size = ExpandEnvironmentStringsA("%PATH%", NULL, 0);
4610 pathvar = HeapAlloc(GetProcessHeap(), 0, size);
4611 ExpandEnvironmentStringsA("%PATH%", pathvar, size);
4613 size = 0;
4614 r = MsiGetPropertyA(hpkg, "SIGPROP4", NULL, &size);
4615 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4617 pathdata = HeapAlloc(GetProcessHeap(), 0, ++size);
4618 r = MsiGetPropertyA(hpkg, "SIGPROP4", pathdata, &size);
4619 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4620 ok(!lstrcmpA(pathdata, pathvar),
4621 "Expected \"%s\", got \"%s\"\n", pathvar, pathdata);
4623 HeapFree(GetProcessHeap(), 0, pathvar);
4624 HeapFree(GetProcessHeap(), 0, pathdata);
4627 size = MAX_PATH;
4628 r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
4629 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4630 ok(!lstrcmpA(prop,
4631 "my%NOVAR%"), "Expected \"my%%NOVAR%%\", got \"%s\"\n", prop);
4633 size = MAX_PATH;
4634 r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
4635 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4636 todo_wine
4638 ok(!memcmp(prop, "\0one\0two\0\0", 10),
4639 "Expected \"\\0one\\0two\\0\\0\"\n");
4642 size = MAX_PATH;
4643 lstrcpyA(path, "#xCDAB3412EF907856");
4644 r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
4645 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4646 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4648 size = MAX_PATH;
4649 r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
4650 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4651 ok(!lstrcmpA(prop, "##regszdata"),
4652 "Expected \"##regszdata\", got \"%s\"\n", prop);
4654 size = MAX_PATH;
4655 sprintf(path, "%s\\FileName1", expected);
4656 r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
4657 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4658 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4660 size = MAX_PATH;
4661 r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
4662 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4663 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4665 size = MAX_PATH;
4666 sprintf(path, "%s\\", expected);
4667 r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
4668 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4669 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4671 size = MAX_PATH;
4672 r = MsiGetPropertyA(hpkg, "SIGPROP12", prop, &size);
4673 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4674 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4676 size = MAX_PATH;
4677 sprintf(path, "%s\\", expected);
4678 r = MsiGetPropertyA(hpkg, "SIGPROP13", prop, &size);
4679 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4680 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4682 size = MAX_PATH;
4683 r = MsiGetPropertyA(hpkg, "SIGPROP14", prop, &size);
4684 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4685 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4687 size = MAX_PATH;
4688 r = MsiGetPropertyA(hpkg, "SIGPROP15", prop, &size);
4689 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4690 ok(!lstrcmpA(prop, "regszdata"),
4691 "Expected \"regszdata\", got \"%s\"\n", prop);
4693 size = MAX_PATH;
4694 r = MsiGetPropertyA(hpkg, "SIGPROP16", prop, &size);
4695 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4696 ok(!lstrcmpA(prop, "regszdata"),
4697 "Expected \"regszdata\", got \"%s\"\n", prop);
4699 if (users)
4701 size = MAX_PATH;
4702 r = MsiGetPropertyA(hpkg, "SIGPROP17", prop, &size);
4703 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4704 ok(!lstrcmpA(prop, "regszdata"),
4705 "Expected \"regszdata\", got \"%s\"\n", prop);
4708 size = MAX_PATH;
4709 r = MsiGetPropertyA(hpkg, "SIGPROP18", prop, &size);
4710 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4711 ok(!lstrcmpA(prop, "defvalue"),
4712 "Expected \"defvalue\", got \"%s\"\n", prop);
4714 size = MAX_PATH;
4715 r = MsiGetPropertyA(hpkg, "SIGPROP19", prop, &size);
4716 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4717 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4719 size = MAX_PATH;
4720 r = MsiGetPropertyA(hpkg, "SIGPROP20", prop, &size);
4721 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4722 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4724 if (version)
4726 size = MAX_PATH;
4727 sprintf(path, "%s\\FileName3.dll", expected);
4728 r = MsiGetPropertyA(hpkg, "SIGPROP21", prop, &size);
4729 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4730 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4732 size = MAX_PATH;
4733 r = MsiGetPropertyA(hpkg, "SIGPROP22", prop, &size);
4734 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4735 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4737 size = MAX_PATH;
4738 sprintf(path, "%s\\FileName5.dll", expected);
4739 r = MsiGetPropertyA(hpkg, "SIGPROP23", prop, &size);
4740 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4741 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4744 if (!is_root(CURR_DIR))
4746 size = MAX_PATH;
4747 lstrcpyA(path, expected);
4748 ptr = strrchr(path, '\\') + 1;
4749 *ptr = '\0';
4750 r = MsiGetPropertyA(hpkg, "SIGPROP24", prop, &size);
4751 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4752 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4754 size = MAX_PATH;
4755 sprintf(path, "%s\\", expected);
4756 r = MsiGetPropertyA(hpkg, "SIGPROP25", prop, &size);
4757 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4758 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4760 size = MAX_PATH;
4761 r = MsiGetPropertyA(hpkg, "SIGPROP26", prop, &size);
4762 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4763 if (is_root(CURR_DIR))
4764 ok(!lstrcmpA(prop, CURR_DIR), "Expected \"%s\", got \"%s\"\n", CURR_DIR, prop);
4765 else
4766 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4768 size = MAX_PATH;
4769 r = MsiGetPropertyA(hpkg, "SIGPROP27", prop, &size);
4770 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4771 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4773 size = MAX_PATH;
4774 r = MsiGetPropertyA(hpkg, "SIGPROP28", prop, &size);
4775 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4776 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4778 size = MAX_PATH;
4779 sprintf(path, "%s\\FileName1", expected);
4780 r = MsiGetPropertyA(hpkg, "SIGPROP29", prop, &size);
4781 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4782 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4784 size = MAX_PATH;
4785 sprintf(path, "%s\\FileName1", expected);
4786 r = MsiGetPropertyA(hpkg, "SIGPROP30", prop, &size);
4787 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4788 if (space)
4789 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4790 else
4791 todo_wine ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4793 RegSetValueA(hklm, NULL, REG_SZ, "", 0);
4794 RegDeleteValueA(hklm, "Value1");
4795 RegDeleteValueA(hklm, "Value2");
4796 RegDeleteValueA(hklm, "Value3");
4797 RegDeleteValueA(hklm, "Value4");
4798 RegDeleteValueA(hklm, "Value5");
4799 RegDeleteValueA(hklm, "Value6");
4800 RegDeleteValueA(hklm, "Value7");
4801 RegDeleteValueA(hklm, "Value8");
4802 RegDeleteValueA(hklm, "Value9");
4803 RegDeleteValueA(hklm, "Value10");
4804 RegDeleteValueA(hklm, "Value11");
4805 RegDeleteValueA(hklm, "Value12");
4806 RegDeleteValueA(hklm, "Value13");
4807 RegDeleteValueA(hklm, "Value14");
4808 RegDeleteValueA(hklm, "Value15");
4809 RegDeleteValueA(hklm, "Value16");
4810 RegDeleteValueA(hklm, "Value17");
4811 RegDeleteKeyA(hklm, "");
4812 RegCloseKey(hklm);
4814 RegDeleteValueA(classes, "Value1");
4815 RegDeleteKeyA(classes, "");
4816 RegCloseKey(classes);
4818 RegDeleteValueA(hkcu, "Value1");
4819 RegDeleteKeyA(hkcu, "");
4820 RegCloseKey(hkcu);
4822 RegDeleteValueA(users, "Value1");
4823 RegDeleteKeyA(users, "");
4824 RegCloseKey(users);
4826 DeleteFileA("FileName1");
4827 DeleteFileA("FileName3.dll");
4828 DeleteFileA("FileName4.dll");
4829 DeleteFileA("FileName5.dll");
4830 MsiCloseHandle(hpkg);
4831 DeleteFileA(msifile);
4834 static void delete_win_ini(LPCSTR file)
4836 CHAR path[MAX_PATH];
4838 GetWindowsDirectoryA(path, MAX_PATH);
4839 lstrcatA(path, "\\");
4840 lstrcatA(path, file);
4842 DeleteFileA(path);
4845 static void test_appsearch_inilocator(void)
4847 MSIHANDLE hpkg, hdb;
4848 char path[MAX_PATH], expected[MAX_PATH], prop[MAX_PATH];
4849 BOOL version;
4850 LPSTR ptr;
4851 DWORD size;
4852 UINT r;
4854 version = TRUE;
4855 if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
4856 version = FALSE;
4858 DeleteFileA("test.dll");
4860 WritePrivateProfileStringA("Section", "Key", "keydata,field2", "IniFile.ini");
4862 strcpy(expected, CURR_DIR);
4863 if (is_root(CURR_DIR)) expected[2] = 0;
4865 create_test_file("FileName1");
4866 sprintf(path, "%s\\FileName1", expected);
4867 WritePrivateProfileStringA("Section", "Key2", path, "IniFile.ini");
4869 WritePrivateProfileStringA("Section", "Key3", expected, "IniFile.ini");
4871 sprintf(path, "%s\\IDontExist", expected);
4872 WritePrivateProfileStringA("Section", "Key4", path, "IniFile.ini");
4874 create_file_with_version("FileName2.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4875 sprintf(path, "%s\\FileName2.dll", expected);
4876 WritePrivateProfileStringA("Section", "Key5", path, "IniFile.ini");
4878 create_file_with_version("FileName3.dll", MAKELONG(1, 2), MAKELONG(3, 4));
4879 sprintf(path, "%s\\FileName3.dll", expected);
4880 WritePrivateProfileStringA("Section", "Key6", path, "IniFile.ini");
4882 create_file_with_version("FileName4.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4883 sprintf(path, "%s\\FileName4.dll", expected);
4884 WritePrivateProfileStringA("Section", "Key7", path, "IniFile.ini");
4886 hdb = create_package_db();
4887 ok(hdb, "Expected a valid database handle\n");
4889 create_appsearch_table(hdb);
4890 add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
4891 add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
4892 add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
4893 add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
4894 add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
4895 add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
4896 add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
4897 add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
4898 add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
4899 add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
4900 add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
4901 add_appsearch_entry(hdb, "'SIGPROP12', 'NewSignature12'");
4903 create_inilocator_table(hdb);
4905 /* msidbLocatorTypeRawValue, field 1 */
4906 add_inilocator_entry(hdb, "'NewSignature1', 'IniFile.ini', 'Section', 'Key', 1, 2");
4908 /* msidbLocatorTypeRawValue, field 2 */
4909 add_inilocator_entry(hdb, "'NewSignature2', 'IniFile.ini', 'Section', 'Key', 2, 2");
4911 /* msidbLocatorTypeRawValue, entire field */
4912 add_inilocator_entry(hdb, "'NewSignature3', 'IniFile.ini', 'Section', 'Key', 0, 2");
4914 /* msidbLocatorTypeFile */
4915 add_inilocator_entry(hdb, "'NewSignature4', 'IniFile.ini', 'Section', 'Key2', 1, 1");
4917 /* msidbLocatorTypeDirectory, file */
4918 add_inilocator_entry(hdb, "'NewSignature5', 'IniFile.ini', 'Section', 'Key2', 1, 0");
4920 /* msidbLocatorTypeDirectory, directory */
4921 add_inilocator_entry(hdb, "'NewSignature6', 'IniFile.ini', 'Section', 'Key3', 1, 0");
4923 /* msidbLocatorTypeFile, file, no signature */
4924 add_inilocator_entry(hdb, "'NewSignature7', 'IniFile.ini', 'Section', 'Key2', 1, 1");
4926 /* msidbLocatorTypeFile, dir, no signature */
4927 add_inilocator_entry(hdb, "'NewSignature8', 'IniFile.ini', 'Section', 'Key3', 1, 1");
4929 /* msidbLocatorTypeFile, file does not exist */
4930 add_inilocator_entry(hdb, "'NewSignature9', 'IniFile.ini', 'Section', 'Key4', 1, 1");
4932 /* msidbLocatorTypeFile, signature with version */
4933 add_inilocator_entry(hdb, "'NewSignature10', 'IniFile.ini', 'Section', 'Key5', 1, 1");
4935 /* msidbLocatorTypeFile, signature with version, ver > max */
4936 add_inilocator_entry(hdb, "'NewSignature11', 'IniFile.ini', 'Section', 'Key6', 1, 1");
4938 /* msidbLocatorTypeFile, signature with version, sig->name ignored */
4939 add_inilocator_entry(hdb, "'NewSignature12', 'IniFile.ini', 'Section', 'Key7', 1, 1");
4941 create_signature_table(hdb);
4942 add_signature_entry(hdb, "'NewSignature4', 'FileName1', '', '', '', '', '', '', ''");
4943 add_signature_entry(hdb, "'NewSignature9', 'IDontExist', '', '', '', '', '', '', ''");
4944 add_signature_entry(hdb, "'NewSignature10', 'FileName2.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
4945 add_signature_entry(hdb, "'NewSignature11', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
4946 add_signature_entry(hdb, "'NewSignature12', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
4948 r = package_from_db(hdb, &hpkg);
4949 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
4951 skip("Not enough rights to perform tests\n");
4952 goto error;
4954 ok(r == ERROR_SUCCESS, "Expected a valid package handle %u\n", r);
4956 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
4958 r = MsiDoActionA(hpkg, "AppSearch");
4959 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4961 size = MAX_PATH;
4962 r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
4963 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4964 ok(!lstrcmpA(prop, "keydata"), "Expected \"keydata\", got \"%s\"\n", prop);
4966 size = MAX_PATH;
4967 r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
4968 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4969 ok(!lstrcmpA(prop, "field2"), "Expected \"field2\", got \"%s\"\n", prop);
4971 size = MAX_PATH;
4972 r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
4973 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4974 ok(!lstrcmpA(prop, "keydata,field2"),
4975 "Expected \"keydata,field2\", got \"%s\"\n", prop);
4977 size = MAX_PATH;
4978 sprintf(path, "%s\\FileName1", expected);
4979 r = MsiGetPropertyA(hpkg, "SIGPROP4", prop, &size);
4980 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4981 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4983 size = MAX_PATH;
4984 r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
4985 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4986 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4988 size = MAX_PATH;
4989 sprintf(path, "%s\\", expected);
4990 r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
4991 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4992 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4994 size = MAX_PATH;
4995 sprintf(path, "%s\\", expected);
4996 r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
4997 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4998 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5000 if (!is_root(CURR_DIR))
5002 size = MAX_PATH;
5003 lstrcpyA(path, expected);
5004 ptr = strrchr(path, '\\');
5005 *(ptr + 1) = 0;
5006 r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
5007 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5008 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5010 size = MAX_PATH;
5011 r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
5012 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5013 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
5015 if (version)
5017 size = MAX_PATH;
5018 sprintf(path, "%s\\FileName2.dll", expected);
5019 r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
5020 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5021 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5023 size = MAX_PATH;
5024 r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
5025 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5026 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
5028 size = MAX_PATH;
5029 sprintf(path, "%s\\FileName4.dll", expected);
5030 r = MsiGetPropertyA(hpkg, "SIGPROP12", prop, &size);
5031 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5032 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5035 MsiCloseHandle(hpkg);
5037 error:
5038 delete_win_ini("IniFile.ini");
5039 DeleteFileA("FileName1");
5040 DeleteFileA("FileName2.dll");
5041 DeleteFileA("FileName3.dll");
5042 DeleteFileA("FileName4.dll");
5043 DeleteFileA(msifile);
5047 * MSI AppSearch action on DrLocator table always returns absolute paths.
5048 * If a relative path was set, it returns the first absolute path that
5049 * matches or an empty string if it didn't find anything.
5050 * This helper function replicates this behaviour.
5052 static void search_absolute_directory(LPSTR absolute, LPCSTR relative)
5054 int i, size;
5055 DWORD attr, drives;
5057 size = lstrlenA(relative);
5058 drives = GetLogicalDrives();
5059 lstrcpyA(absolute, "A:\\");
5060 for (i = 0; i < 26; absolute[0] = '\0', i++)
5062 if (!(drives & (1 << i)))
5063 continue;
5065 absolute[0] = 'A' + i;
5066 if (GetDriveTypeA(absolute) != DRIVE_FIXED)
5067 continue;
5069 lstrcpynA(absolute + 3, relative, size + 1);
5070 attr = GetFileAttributesA(absolute);
5071 if (attr != INVALID_FILE_ATTRIBUTES &&
5072 (attr & FILE_ATTRIBUTE_DIRECTORY))
5074 if (absolute[3 + size - 1] != '\\')
5075 lstrcatA(absolute, "\\");
5076 break;
5078 absolute[3] = '\0';
5082 static void test_appsearch_drlocator(void)
5084 MSIHANDLE hpkg, hdb;
5085 char path[MAX_PATH], expected[MAX_PATH], prop[MAX_PATH];
5086 BOOL version;
5087 DWORD size;
5088 UINT r;
5090 version = TRUE;
5091 if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
5092 version = FALSE;
5094 DeleteFileA("test.dll");
5096 create_test_file("FileName1");
5097 CreateDirectoryA("one", NULL);
5098 CreateDirectoryA("one\\two", NULL);
5099 CreateDirectoryA("one\\two\\three", NULL);
5100 create_test_file("one\\two\\three\\FileName2");
5101 CreateDirectoryA("another", NULL);
5102 create_file_with_version("FileName3.dll", MAKELONG(2, 1), MAKELONG(4, 3));
5103 create_file_with_version("FileName4.dll", MAKELONG(1, 2), MAKELONG(3, 4));
5104 create_file_with_version("FileName5.dll", MAKELONG(2, 1), MAKELONG(4, 3));
5106 hdb = create_package_db();
5107 ok(hdb, "Expected a valid database handle\n");
5109 create_appsearch_table(hdb);
5110 add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
5111 add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
5112 add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
5113 add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
5114 add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
5115 add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
5116 add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
5117 add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
5118 add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
5119 add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
5120 add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
5121 add_appsearch_entry(hdb, "'SIGPROP13', 'NewSignature13'");
5123 create_drlocator_table(hdb);
5125 strcpy(expected, CURR_DIR);
5126 if (is_root(CURR_DIR)) expected[2] = 0;
5128 /* no parent, full path, depth 0, signature */
5129 sprintf(path, "'NewSignature1', '', '%s', 0", expected);
5130 add_drlocator_entry(hdb, path);
5132 /* no parent, full path, depth 0, no signature */
5133 sprintf(path, "'NewSignature2', '', '%s', 0", expected);
5134 add_drlocator_entry(hdb, path);
5136 /* no parent, relative path, depth 0, no signature */
5137 sprintf(path, "'NewSignature3', '', '%s', 0", expected + 3);
5138 add_drlocator_entry(hdb, path);
5140 /* no parent, full path, depth 2, signature */
5141 sprintf(path, "'NewSignature4', '', '%s', 2", expected);
5142 add_drlocator_entry(hdb, path);
5144 /* no parent, full path, depth 3, signature */
5145 sprintf(path, "'NewSignature5', '', '%s', 3", expected);
5146 add_drlocator_entry(hdb, path);
5148 /* no parent, full path, depth 1, signature is dir */
5149 sprintf(path, "'NewSignature6', '', '%s', 1", expected);
5150 add_drlocator_entry(hdb, path);
5152 /* parent is in DrLocator, relative path, depth 0, signature */
5153 sprintf(path, "'NewSignature7', 'NewSignature1', 'one\\two\\three', 1");
5154 add_drlocator_entry(hdb, path);
5156 /* no parent, full path, depth 0, signature w/ version */
5157 sprintf(path, "'NewSignature8', '', '%s', 0", expected);
5158 add_drlocator_entry(hdb, path);
5160 /* no parent, full path, depth 0, signature w/ version, ver > max */
5161 sprintf(path, "'NewSignature9', '', '%s', 0", expected);
5162 add_drlocator_entry(hdb, path);
5164 /* no parent, full path, depth 0, signature w/ version, sig->name not ignored */
5165 sprintf(path, "'NewSignature10', '', '%s', 0", expected);
5166 add_drlocator_entry(hdb, path);
5168 /* no parent, relative empty path, depth 0, no signature */
5169 sprintf(path, "'NewSignature11', '', '', 0");
5170 add_drlocator_entry(hdb, path);
5172 create_reglocator_table(hdb);
5174 /* parent */
5175 add_reglocator_entry(hdb, "NewSignature12", 2, "htmlfile\\shell\\open\\nonexistent", "", 1);
5177 /* parent is in RegLocator, no path, depth 0, no signature */
5178 sprintf(path, "'NewSignature13', 'NewSignature12', '', 0");
5179 add_drlocator_entry(hdb, path);
5181 create_signature_table(hdb);
5182 add_signature_entry(hdb, "'NewSignature1', 'FileName1', '', '', '', '', '', '', ''");
5183 add_signature_entry(hdb, "'NewSignature4', 'FileName2', '', '', '', '', '', '', ''");
5184 add_signature_entry(hdb, "'NewSignature5', 'FileName2', '', '', '', '', '', '', ''");
5185 add_signature_entry(hdb, "'NewSignature6', 'another', '', '', '', '', '', '', ''");
5186 add_signature_entry(hdb, "'NewSignature7', 'FileName2', '', '', '', '', '', '', ''");
5187 add_signature_entry(hdb, "'NewSignature8', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
5188 add_signature_entry(hdb, "'NewSignature9', 'FileName4.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
5189 add_signature_entry(hdb, "'NewSignature10', 'necessary', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
5191 r = package_from_db(hdb, &hpkg);
5192 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
5194 skip("Not enough rights to perform tests\n");
5195 goto error;
5197 ok(r == ERROR_SUCCESS, "Expected a valid package handle %u\n", r);
5199 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
5201 r = MsiDoActionA(hpkg, "AppSearch");
5202 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5204 size = MAX_PATH;
5205 sprintf(path, "%s\\FileName1", expected);
5206 r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
5207 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5208 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5210 size = MAX_PATH;
5211 sprintf(path, "%s\\", expected);
5212 r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
5213 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5214 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5216 size = MAX_PATH;
5217 search_absolute_directory(path, expected + 3);
5218 r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
5219 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5220 ok(!lstrcmpiA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5222 size = MAX_PATH;
5223 r = MsiGetPropertyA(hpkg, "SIGPROP4", prop, &size);
5224 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5225 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
5227 size = MAX_PATH;
5228 sprintf(path, "%s\\one\\two\\three\\FileName2", expected);
5229 r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
5230 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5231 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5233 size = MAX_PATH;
5234 r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
5235 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5236 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
5238 size = MAX_PATH;
5239 sprintf(path, "%s\\one\\two\\three\\FileName2", expected);
5240 r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
5241 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5242 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5244 if (version)
5246 size = MAX_PATH;
5247 sprintf(path, "%s\\FileName3.dll", expected);
5248 r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
5249 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5250 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5252 size = MAX_PATH;
5253 r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
5254 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5255 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
5257 size = MAX_PATH;
5258 r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
5259 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5260 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
5263 size = MAX_PATH;
5264 search_absolute_directory(path, "");
5265 r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
5266 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5267 ok(!lstrcmpiA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5269 size = MAX_PATH;
5270 strcpy(path, "c:\\");
5271 r = MsiGetPropertyA(hpkg, "SIGPROP13", prop, &size);
5272 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5273 ok(!prop[0], "Expected \"\", got \"%s\"\n", prop);
5275 MsiCloseHandle(hpkg);
5277 error:
5278 DeleteFileA("FileName1");
5279 DeleteFileA("FileName3.dll");
5280 DeleteFileA("FileName4.dll");
5281 DeleteFileA("FileName5.dll");
5282 DeleteFileA("one\\two\\three\\FileName2");
5283 RemoveDirectoryA("one\\two\\three");
5284 RemoveDirectoryA("one\\two");
5285 RemoveDirectoryA("one");
5286 RemoveDirectoryA("another");
5287 DeleteFileA(msifile);
5290 static void test_featureparents(void)
5292 MSIHANDLE hpkg;
5293 UINT r;
5294 MSIHANDLE hdb;
5296 hdb = create_package_db();
5297 ok ( hdb, "failed to create package database\n" );
5299 add_directory_entry(hdb, "'TARGETDIR', '', 'SourceDir'");
5301 create_feature_table( hdb );
5302 create_component_table( hdb );
5303 create_feature_components_table( hdb );
5304 create_file_table( hdb );
5306 /* msidbFeatureAttributesFavorLocal */
5307 add_feature_entry( hdb, "'zodiac', '', '', '', 2, 1, '', 0" );
5309 /* msidbFeatureAttributesFavorSource */
5310 add_feature_entry( hdb, "'perseus', '', '', '', 2, 1, '', 1" );
5312 /* msidbFeatureAttributesFavorLocal */
5313 add_feature_entry( hdb, "'orion', '', '', '', 2, 1, '', 0" );
5315 /* msidbFeatureAttributesUIDisallowAbsent */
5316 add_feature_entry( hdb, "'lyra', '', '', '', 2, 1, '', 16" );
5318 /* disabled because of install level */
5319 add_feature_entry( hdb, "'waters', '', '', '', 15, 101, '', 9" );
5321 /* child feature of disabled feature */
5322 add_feature_entry( hdb, "'bayer', 'waters', '', '', 14, 1, '', 9" );
5324 /* component of disabled feature (install level) */
5325 add_component_entry( hdb, "'delphinus', '', 'TARGETDIR', 0, '', 'delphinus_file'" );
5327 /* component of disabled child feature (install level) */
5328 add_component_entry( hdb, "'hydrus', '', 'TARGETDIR', 0, '', 'hydrus_file'" );
5330 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
5331 add_component_entry( hdb, "'leo', '', 'TARGETDIR', 0, '', 'leo_file'" );
5333 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
5334 add_component_entry( hdb, "'virgo', '', 'TARGETDIR', 1, '', 'virgo_file'" );
5336 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
5337 add_component_entry( hdb, "'libra', '', 'TARGETDIR', 2, '', 'libra_file'" );
5339 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
5340 add_component_entry( hdb, "'cassiopeia', '', 'TARGETDIR', 0, '', 'cassiopeia_file'" );
5342 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
5343 add_component_entry( hdb, "'cepheus', '', 'TARGETDIR', 1, '', 'cepheus_file'" );
5345 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
5346 add_component_entry( hdb, "'andromeda', '', 'TARGETDIR', 2, '', 'andromeda_file'" );
5348 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
5349 add_component_entry( hdb, "'canis', '', 'TARGETDIR', 0, '', 'canis_file'" );
5351 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
5352 add_component_entry( hdb, "'monoceros', '', 'TARGETDIR', 1, '', 'monoceros_file'" );
5354 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
5355 add_component_entry( hdb, "'lepus', '', 'TARGETDIR', 2, '', 'lepus_file'" );
5357 add_feature_components_entry( hdb, "'zodiac', 'leo'" );
5358 add_feature_components_entry( hdb, "'zodiac', 'virgo'" );
5359 add_feature_components_entry( hdb, "'zodiac', 'libra'" );
5360 add_feature_components_entry( hdb, "'perseus', 'cassiopeia'" );
5361 add_feature_components_entry( hdb, "'perseus', 'cepheus'" );
5362 add_feature_components_entry( hdb, "'perseus', 'andromeda'" );
5363 add_feature_components_entry( hdb, "'orion', 'leo'" );
5364 add_feature_components_entry( hdb, "'orion', 'virgo'" );
5365 add_feature_components_entry( hdb, "'orion', 'libra'" );
5366 add_feature_components_entry( hdb, "'orion', 'cassiopeia'" );
5367 add_feature_components_entry( hdb, "'orion', 'cepheus'" );
5368 add_feature_components_entry( hdb, "'orion', 'andromeda'" );
5369 add_feature_components_entry( hdb, "'orion', 'canis'" );
5370 add_feature_components_entry( hdb, "'orion', 'monoceros'" );
5371 add_feature_components_entry( hdb, "'orion', 'lepus'" );
5372 add_feature_components_entry( hdb, "'waters', 'delphinus'" );
5373 add_feature_components_entry( hdb, "'bayer', 'hydrus'" );
5375 add_file_entry( hdb, "'leo_file', 'leo', 'leo.txt', 100, '', '1033', 8192, 1" );
5376 add_file_entry( hdb, "'virgo_file', 'virgo', 'virgo.txt', 0, '', '1033', 8192, 1" );
5377 add_file_entry( hdb, "'libra_file', 'libra', 'libra.txt', 0, '', '1033', 8192, 1" );
5378 add_file_entry( hdb, "'cassiopeia_file', 'cassiopeia', 'cassiopeia.txt', 0, '', '1033', 8192, 1" );
5379 add_file_entry( hdb, "'cepheus_file', 'cepheus', 'cepheus.txt', 0, '', '1033', 8192, 1" );
5380 add_file_entry( hdb, "'andromeda_file', 'andromeda', 'andromeda.txt', 0, '', '1033', 8192, 1" );
5381 add_file_entry( hdb, "'canis_file', 'canis', 'canis.txt', 0, '', '1033', 8192, 1" );
5382 add_file_entry( hdb, "'monoceros_file', 'monoceros', 'monoceros.txt', 0, '', '1033', 8192, 1" );
5383 add_file_entry( hdb, "'lepus_file', 'lepus', 'lepus.txt', 0, '', '1033', 8192, 1" );
5384 add_file_entry( hdb, "'delphinus_file', 'delphinus', 'delphinus.txt', 0, '', '1033', 8192, 1" );
5385 add_file_entry( hdb, "'hydrus_file', 'hydrus', 'hydrus.txt', 0, '', '1033', 8192, 1" );
5387 r = package_from_db( hdb, &hpkg );
5388 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
5390 skip("Not enough rights to perform tests\n");
5391 DeleteFileA(msifile);
5392 return;
5394 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
5396 MsiCloseHandle( hdb );
5398 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
5400 r = MsiDoActionA( hpkg, "CostInitialize");
5401 ok( r == ERROR_SUCCESS, "cost init failed\n");
5403 r = MsiDoActionA( hpkg, "FileCost");
5404 ok( r == ERROR_SUCCESS, "file cost failed\n");
5406 r = MsiDoActionA( hpkg, "CostFinalize");
5407 ok( r == ERROR_SUCCESS, "cost finalize failed\n");
5409 test_feature_states( __LINE__, hpkg, "zodiac", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, FALSE );
5410 test_feature_states( __LINE__, hpkg, "perseus", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_SOURCE, FALSE );
5411 test_feature_states( __LINE__, hpkg, "orion", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, FALSE );
5412 test_feature_states( __LINE__, hpkg, "lyra", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, FALSE );
5413 test_feature_states( __LINE__, hpkg, "waters", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
5414 test_feature_states( __LINE__, hpkg, "bayer", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
5416 test_component_states( __LINE__, hpkg, "leo", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, FALSE );
5417 test_component_states( __LINE__, hpkg, "virgo", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_SOURCE, FALSE );
5418 test_component_states( __LINE__, hpkg, "libra", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, FALSE );
5419 test_component_states( __LINE__, hpkg, "cassiopeia", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, FALSE );
5420 test_component_states( __LINE__, hpkg, "cepheus", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_SOURCE, FALSE );
5421 test_component_states( __LINE__, hpkg, "andromeda", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, FALSE );
5422 test_component_states( __LINE__, hpkg, "canis", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, FALSE );
5423 test_component_states( __LINE__, hpkg, "monoceros", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_SOURCE, FALSE );
5424 test_component_states( __LINE__, hpkg, "lepus", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, FALSE );
5425 test_component_states( __LINE__, hpkg, "delphinus", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
5426 test_component_states( __LINE__, hpkg, "hydrus", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
5428 r = MsiSetFeatureStateA(hpkg, "orion", INSTALLSTATE_ABSENT);
5429 ok( r == ERROR_SUCCESS, "failed to set feature state: %d\n", r);
5431 r = MsiSetFeatureStateA(hpkg, "lyra", INSTALLSTATE_ABSENT);
5432 ok( r == ERROR_SUCCESS, "failed to set feature state: %d\n", r);
5434 r = MsiSetFeatureStateA(hpkg, "nosuchfeature", INSTALLSTATE_ABSENT);
5435 ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %u\n", r);
5437 test_feature_states( __LINE__, hpkg, "zodiac", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, FALSE );
5438 test_feature_states( __LINE__, hpkg, "perseus", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_SOURCE, FALSE );
5439 test_feature_states( __LINE__, hpkg, "orion", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_ABSENT, FALSE );
5440 test_feature_states( __LINE__, hpkg, "lyra", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_ABSENT, FALSE );
5441 test_feature_states( __LINE__, hpkg, "waters", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
5442 test_feature_states( __LINE__, hpkg, "bayer", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
5444 test_component_states( __LINE__, hpkg, "leo", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, FALSE );
5445 test_component_states( __LINE__, hpkg, "virgo", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_SOURCE, FALSE );
5446 test_component_states( __LINE__, hpkg, "libra", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, FALSE );
5447 test_component_states( __LINE__, hpkg, "cassiopeia", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, FALSE );
5448 test_component_states( __LINE__, hpkg, "cepheus", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_SOURCE, FALSE );
5449 test_component_states( __LINE__, hpkg, "andromeda", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_SOURCE, FALSE );
5450 test_component_states( __LINE__, hpkg, "canis", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
5451 test_component_states( __LINE__, hpkg, "monoceros", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
5452 test_component_states( __LINE__, hpkg, "lepus", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
5453 test_component_states( __LINE__, hpkg, "delphinus", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
5454 test_component_states( __LINE__, hpkg, "hydrus", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
5456 MsiCloseHandle(hpkg);
5457 DeleteFileA(msifile);
5460 static void test_installprops(void)
5462 MSIHANDLE hpkg, hdb;
5463 CHAR path[MAX_PATH], buf[MAX_PATH];
5464 DWORD size, type;
5465 LANGID langid;
5466 HKEY hkey1, hkey2;
5467 int res;
5468 UINT r;
5469 REGSAM access = KEY_ALL_ACCESS;
5470 SYSTEM_INFO si;
5471 INSTALLUILEVEL uilevel;
5473 if (is_wow64)
5474 access |= KEY_WOW64_64KEY;
5476 lstrcpyA(path, CURR_DIR);
5477 if (!is_root(CURR_DIR)) lstrcatA(path, "\\");
5478 lstrcatA(path, msifile);
5480 uilevel = MsiSetInternalUI(INSTALLUILEVEL_BASIC|INSTALLUILEVEL_SOURCERESONLY, NULL);
5482 hdb = create_package_db();
5483 ok( hdb, "failed to create database\n");
5485 r = package_from_db(hdb, &hpkg);
5486 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
5488 skip("Not enough rights to perform tests\n");
5489 MsiSetInternalUI(uilevel, NULL);
5490 DeleteFileA(msifile);
5491 return;
5493 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
5495 MsiCloseHandle(hdb);
5497 buf[0] = 0;
5498 size = MAX_PATH;
5499 r = MsiGetPropertyA(hpkg, "UILevel", buf, &size);
5500 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5501 ok( !lstrcmpA(buf, "3"), "Expected \"3\", got \"%s\"\n", buf);
5503 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
5505 buf[0] = 0;
5506 size = MAX_PATH;
5507 r = MsiGetPropertyA(hpkg, "UILevel", buf, &size);
5508 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5509 ok( !lstrcmpA(buf, "3"), "Expected \"3\", got \"%s\"\n", buf);
5511 buf[0] = 0;
5512 size = MAX_PATH;
5513 r = MsiGetPropertyA(hpkg, "DATABASE", buf, &size);
5514 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5515 ok( !lstrcmpA(buf, path), "Expected %s, got %s\n", path, buf);
5517 RegOpenKeyA(HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\MS Setup (ACME)\\User Info", &hkey1);
5518 RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, access, &hkey2);
5520 size = MAX_PATH;
5521 type = REG_SZ;
5522 *path = '\0';
5523 if (RegQueryValueExA(hkey1, "DefName", NULL, &type, (LPBYTE)path, &size) != ERROR_SUCCESS)
5525 size = MAX_PATH;
5526 type = REG_SZ;
5527 RegQueryValueExA(hkey2, "RegisteredOwner", NULL, &type, (LPBYTE)path, &size);
5530 buf[0] = 0;
5531 size = MAX_PATH;
5532 r = MsiGetPropertyA(hpkg, "USERNAME", buf, &size);
5533 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5534 ok( !lstrcmpA(buf, path), "Expected %s, got %s\n", path, buf);
5536 size = MAX_PATH;
5537 type = REG_SZ;
5538 *path = '\0';
5539 if (RegQueryValueExA(hkey1, "DefCompany", NULL, &type, (LPBYTE)path, &size) != ERROR_SUCCESS)
5541 size = MAX_PATH;
5542 type = REG_SZ;
5543 RegQueryValueExA(hkey2, "RegisteredOrganization", NULL, &type, (LPBYTE)path, &size);
5546 if (*path)
5548 buf[0] = 0;
5549 size = MAX_PATH;
5550 r = MsiGetPropertyA(hpkg, "COMPANYNAME", buf, &size);
5551 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5552 ok( !lstrcmpA(buf, path), "Expected %s, got %s\n", path, buf);
5555 buf[0] = 0;
5556 size = MAX_PATH;
5557 r = MsiGetPropertyA(hpkg, "VersionDatabase", buf, &size);
5558 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5559 trace("VersionDatabase = %s\n", buf);
5561 buf[0] = 0;
5562 size = MAX_PATH;
5563 r = MsiGetPropertyA(hpkg, "VersionMsi", buf, &size);
5564 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5565 trace("VersionMsi = %s\n", buf);
5567 buf[0] = 0;
5568 size = MAX_PATH;
5569 r = MsiGetPropertyA(hpkg, "Date", buf, &size);
5570 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5571 trace("Date = %s\n", buf);
5573 buf[0] = 0;
5574 size = MAX_PATH;
5575 r = MsiGetPropertyA(hpkg, "Time", buf, &size);
5576 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5577 trace("Time = %s\n", buf);
5579 buf[0] = 0;
5580 size = MAX_PATH;
5581 r = MsiGetPropertyA(hpkg, "PackageCode", buf, &size);
5582 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5583 trace("PackageCode = %s\n", buf);
5585 buf[0] = 0;
5586 size = MAX_PATH;
5587 r = MsiGetPropertyA(hpkg, "ComputerName", buf, &size);
5588 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
5589 trace("ComputerName = %s\n", buf);
5591 langid = GetUserDefaultLangID();
5592 sprintf(path, "%d", langid);
5594 buf[0] = 0;
5595 size = MAX_PATH;
5596 r = MsiGetPropertyA(hpkg, "UserLanguageID", buf, &size);
5597 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
5598 ok( !lstrcmpA(buf, path), "Expected \"%s\", got \"%s\"\n", path, buf);
5600 res = GetSystemMetrics(SM_CXSCREEN);
5601 buf[0] = 0;
5602 size = MAX_PATH;
5603 r = MsiGetPropertyA(hpkg, "ScreenX", buf, &size);
5604 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
5605 ok(atol(buf) == res, "Expected %d, got %ld\n", res, atol(buf));
5607 res = GetSystemMetrics(SM_CYSCREEN);
5608 buf[0] = 0;
5609 size = MAX_PATH;
5610 r = MsiGetPropertyA(hpkg, "ScreenY", buf, &size);
5611 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
5612 ok(atol(buf) == res, "Expected %d, got %ld\n", res, atol(buf));
5614 buf[0] = 0;
5615 size = MAX_PATH;
5616 r = MsiGetPropertyA(hpkg, "MsiNetAssemblySupport", buf, &size);
5617 if (r == ERROR_SUCCESS) trace( "MsiNetAssemblySupport \"%s\"\n", buf );
5619 if (pGetSystemInfo && pSHGetFolderPathA)
5621 pGetSystemInfo(&si);
5622 if (S(U(si)).wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
5624 buf[0] = 0;
5625 size = MAX_PATH;
5626 r = MsiGetPropertyA(hpkg, "Intel", buf, &size);
5627 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5628 ok(buf[0], "property not set\n");
5630 buf[0] = 0;
5631 size = MAX_PATH;
5632 r = MsiGetPropertyA(hpkg, "MsiAMD64", buf, &size);
5633 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5634 ok(buf[0], "property not set\n");
5636 buf[0] = 0;
5637 size = MAX_PATH;
5638 r = MsiGetPropertyA(hpkg, "Msix64", buf, &size);
5639 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5640 ok(buf[0], "property not set\n");
5642 buf[0] = 0;
5643 size = MAX_PATH;
5644 r = MsiGetPropertyA(hpkg, "System64Folder", buf, &size);
5645 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5646 GetSystemDirectoryA(path, MAX_PATH);
5647 if (size) buf[size - 1] = 0;
5648 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5650 buf[0] = 0;
5651 size = MAX_PATH;
5652 r = MsiGetPropertyA(hpkg, "SystemFolder", buf, &size);
5653 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5654 pGetSystemWow64DirectoryA(path, MAX_PATH);
5655 if (size) buf[size - 1] = 0;
5656 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5658 buf[0] = 0;
5659 size = MAX_PATH;
5660 r = MsiGetPropertyA(hpkg, "ProgramFiles64Folder", buf, &size);
5661 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5662 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES, NULL, 0, path);
5663 if (size) buf[size - 1] = 0;
5664 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5666 buf[0] = 0;
5667 size = MAX_PATH;
5668 r = MsiGetPropertyA(hpkg, "ProgramFilesFolder", buf, &size);
5669 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5670 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILESX86, NULL, 0, path);
5671 if (size) buf[size - 1] = 0;
5672 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5674 buf[0] = 0;
5675 size = MAX_PATH;
5676 r = MsiGetPropertyA(hpkg, "CommonFiles64Folder", buf, &size);
5677 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5678 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES_COMMON, NULL, 0, path);
5679 if (size) buf[size - 1] = 0;
5680 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5682 buf[0] = 0;
5683 size = MAX_PATH;
5684 r = MsiGetPropertyA(hpkg, "CommonFilesFolder", buf, &size);
5685 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5686 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES_COMMONX86, NULL, 0, path);
5687 if (size) buf[size - 1] = 0;
5688 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5690 buf[0] = 0;
5691 size = MAX_PATH;
5692 r = MsiGetPropertyA(hpkg, "VersionNT64", buf, &size);
5693 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5694 ok(buf[0], "property not set\n");
5696 else if (S(U(si)).wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL)
5698 if (!is_wow64)
5700 buf[0] = 0;
5701 size = MAX_PATH;
5702 r = MsiGetPropertyA(hpkg, "Intel", buf, &size);
5703 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5704 ok(buf[0], "property not set\n");
5706 buf[0] = 0;
5707 size = MAX_PATH;
5708 r = MsiGetPropertyA(hpkg, "MsiAMD64", buf, &size);
5709 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5710 ok(!buf[0], "property set\n");
5712 buf[0] = 0;
5713 size = MAX_PATH;
5714 r = MsiGetPropertyA(hpkg, "Msix64", buf, &size);
5715 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5716 ok(!buf[0], "property set\n");
5718 buf[0] = 0;
5719 size = MAX_PATH;
5720 r = MsiGetPropertyA(hpkg, "System64Folder", buf, &size);
5721 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5722 ok(!buf[0], "property set\n");
5724 buf[0] = 0;
5725 size = MAX_PATH;
5726 r = MsiGetPropertyA(hpkg, "SystemFolder", buf, &size);
5727 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5728 GetSystemDirectoryA(path, MAX_PATH);
5729 if (size) buf[size - 1] = 0;
5730 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5732 buf[0] = 0;
5733 size = MAX_PATH;
5734 r = MsiGetPropertyA(hpkg, "ProgramFiles64Folder", buf, &size);
5735 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5736 ok(!buf[0], "property set\n");
5738 buf[0] = 0;
5739 size = MAX_PATH;
5740 r = MsiGetPropertyA(hpkg, "ProgramFilesFolder", buf, &size);
5741 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5742 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES, NULL, 0, path);
5743 if (size) buf[size - 1] = 0;
5744 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5746 buf[0] = 0;
5747 size = MAX_PATH;
5748 r = MsiGetPropertyA(hpkg, "CommonFiles64Folder", buf, &size);
5749 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5750 ok(!buf[0], "property set\n");
5752 buf[0] = 0;
5753 size = MAX_PATH;
5754 r = MsiGetPropertyA(hpkg, "CommonFilesFolder", buf, &size);
5755 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5756 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES_COMMON, NULL, 0, path);
5757 if (size) buf[size - 1] = 0;
5758 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5760 buf[0] = 0;
5761 size = MAX_PATH;
5762 r = MsiGetPropertyA(hpkg, "VersionNT64", buf, &size);
5763 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5764 ok(!buf[0], "property set\n");
5766 else
5768 buf[0] = 0;
5769 size = MAX_PATH;
5770 r = MsiGetPropertyA(hpkg, "Intel", buf, &size);
5771 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5772 ok(buf[0], "property not set\n");
5774 buf[0] = 0;
5775 size = MAX_PATH;
5776 r = MsiGetPropertyA(hpkg, "MsiAMD64", buf, &size);
5777 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5778 ok(buf[0], "property not set\n");
5780 buf[0] = 0;
5781 size = MAX_PATH;
5782 r = MsiGetPropertyA(hpkg, "Msix64", buf, &size);
5783 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5784 ok(buf[0], "property not set\n");
5786 buf[0] = 0;
5787 size = MAX_PATH;
5788 r = MsiGetPropertyA(hpkg, "System64Folder", buf, &size);
5789 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5790 GetSystemDirectoryA(path, MAX_PATH);
5791 if (size) buf[size - 1] = 0;
5792 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5794 buf[0] = 0;
5795 size = MAX_PATH;
5796 r = MsiGetPropertyA(hpkg, "SystemFolder", buf, &size);
5797 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5798 pGetSystemWow64DirectoryA(path, MAX_PATH);
5799 if (size) buf[size - 1] = 0;
5800 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5802 buf[0] = 0;
5803 size = MAX_PATH;
5804 r = MsiGetPropertyA(hpkg, "ProgramFilesFolder64", buf, &size);
5805 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5806 ok(!buf[0], "property set\n");
5808 buf[0] = 0;
5809 size = MAX_PATH;
5810 r = MsiGetPropertyA(hpkg, "ProgramFilesFolder", buf, &size);
5811 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5812 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILESX86, NULL, 0, path);
5813 if (size) buf[size - 1] = 0;
5814 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5816 buf[0] = 0;
5817 size = MAX_PATH;
5818 r = MsiGetPropertyA(hpkg, "CommonFilesFolder64", buf, &size);
5819 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5820 ok(!buf[0], "property set\n");
5822 buf[0] = 0;
5823 size = MAX_PATH;
5824 r = MsiGetPropertyA(hpkg, "CommonFilesFolder", buf, &size);
5825 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5826 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES_COMMONX86, NULL, 0, path);
5827 if (size) buf[size - 1] = 0;
5828 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5830 buf[0] = 0;
5831 size = MAX_PATH;
5832 r = MsiGetPropertyA(hpkg, "VersionNT64", buf, &size);
5833 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5834 ok(buf[0], "property not set\n");
5839 CloseHandle(hkey1);
5840 CloseHandle(hkey2);
5841 MsiCloseHandle(hpkg);
5842 DeleteFileA(msifile);
5843 MsiSetInternalUI(uilevel, NULL);
5846 static void test_launchconditions(void)
5848 MSIHANDLE hpkg;
5849 MSIHANDLE hdb;
5850 UINT r;
5852 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
5854 hdb = create_package_db();
5855 ok( hdb, "failed to create package database\n" );
5857 create_launchcondition_table( hdb );
5859 add_launchcondition_entry( hdb, "'X = \"1\"', 'one'" );
5861 /* invalid condition */
5862 add_launchcondition_entry( hdb, "'X != \"1\"', 'one'" );
5864 r = package_from_db( hdb, &hpkg );
5865 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
5867 skip("Not enough rights to perform tests\n");
5868 DeleteFileA(msifile);
5869 return;
5871 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
5873 MsiCloseHandle( hdb );
5875 r = MsiSetPropertyA( hpkg, "X", "1" );
5876 ok( r == ERROR_SUCCESS, "failed to set property\n" );
5878 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
5880 /* invalid conditions are ignored */
5881 r = MsiDoActionA( hpkg, "LaunchConditions" );
5882 ok( r == ERROR_SUCCESS, "cost init failed\n" );
5884 /* verify LaunchConditions still does some verification */
5885 r = MsiSetPropertyA( hpkg, "X", "2" );
5886 ok( r == ERROR_SUCCESS, "failed to set property\n" );
5888 r = MsiDoActionA( hpkg, "LaunchConditions" );
5889 ok( r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %d\n", r );
5891 MsiCloseHandle( hpkg );
5892 DeleteFileA( msifile );
5895 static void test_ccpsearch(void)
5897 MSIHANDLE hdb, hpkg;
5898 CHAR prop[MAX_PATH];
5899 DWORD size = MAX_PATH;
5900 UINT r;
5902 hdb = create_package_db();
5903 ok(hdb, "failed to create package database\n");
5905 create_ccpsearch_table(hdb);
5906 add_ccpsearch_entry(hdb, "'CCP_random'");
5907 add_ccpsearch_entry(hdb, "'RMCCP_random'");
5909 create_reglocator_table(hdb);
5910 add_reglocator_entry(hdb, "CCP_random", 0, "htmlfile\\shell\\open\\nonexistent", "", 1);
5912 create_drlocator_table(hdb);
5913 add_drlocator_entry(hdb, "'RMCCP_random', '', 'C:\\', '0'");
5915 create_signature_table(hdb);
5917 r = package_from_db(hdb, &hpkg);
5918 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
5920 skip("Not enough rights to perform tests\n");
5921 DeleteFileA(msifile);
5922 return;
5924 ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
5926 MsiCloseHandle(hdb);
5928 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
5930 r = MsiDoActionA(hpkg, "CCPSearch");
5931 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5933 r = MsiGetPropertyA(hpkg, "CCP_Success", prop, &size);
5934 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5935 ok(!lstrcmpA(prop, "1"), "Expected 1, got %s\n", prop);
5937 MsiCloseHandle(hpkg);
5938 DeleteFileA(msifile);
5941 static void test_complocator(void)
5943 MSIHANDLE hdb, hpkg;
5944 UINT r;
5945 CHAR prop[MAX_PATH];
5946 CHAR expected[MAX_PATH];
5947 DWORD size = MAX_PATH;
5949 hdb = create_package_db();
5950 ok(hdb, "failed to create package database\n");
5952 create_appsearch_table(hdb);
5953 add_appsearch_entry(hdb, "'ABELISAURUS', 'abelisaurus'");
5954 add_appsearch_entry(hdb, "'BACTROSAURUS', 'bactrosaurus'");
5955 add_appsearch_entry(hdb, "'CAMELOTIA', 'camelotia'");
5956 add_appsearch_entry(hdb, "'DICLONIUS', 'diclonius'");
5957 add_appsearch_entry(hdb, "'ECHINODON', 'echinodon'");
5958 add_appsearch_entry(hdb, "'FALCARIUS', 'falcarius'");
5959 add_appsearch_entry(hdb, "'GALLIMIMUS', 'gallimimus'");
5960 add_appsearch_entry(hdb, "'HAGRYPHUS', 'hagryphus'");
5961 add_appsearch_entry(hdb, "'IGUANODON', 'iguanodon'");
5962 add_appsearch_entry(hdb, "'JOBARIA', 'jobaria'");
5963 add_appsearch_entry(hdb, "'KAKURU', 'kakuru'");
5964 add_appsearch_entry(hdb, "'LABOCANIA', 'labocania'");
5965 add_appsearch_entry(hdb, "'MEGARAPTOR', 'megaraptor'");
5966 add_appsearch_entry(hdb, "'NEOSODON', 'neosodon'");
5967 add_appsearch_entry(hdb, "'OLOROTITAN', 'olorotitan'");
5968 add_appsearch_entry(hdb, "'PANTYDRACO', 'pantydraco'");
5970 create_complocator_table(hdb);
5971 add_complocator_entry(hdb, "'abelisaurus', '{E3619EED-305A-418C-B9C7-F7D7377F0934}', 1");
5972 add_complocator_entry(hdb, "'bactrosaurus', '{D56B688D-542F-42Ef-90FD-B6DA76EE8119}', 0");
5973 add_complocator_entry(hdb, "'camelotia', '{8211BE36-2466-47E3-AFB7-6AC72E51AED2}', 1");
5974 add_complocator_entry(hdb, "'diclonius', '{5C767B20-A33C-45A4-B80B-555E512F01AE}', 0");
5975 add_complocator_entry(hdb, "'echinodon', '{A19E16C5-C75D-4699-8111-C4338C40C3CB}', 1");
5976 add_complocator_entry(hdb, "'falcarius', '{17762FA1-A7AE-4CC6-8827-62873C35361D}', 0");
5977 add_complocator_entry(hdb, "'gallimimus', '{75EBF568-C959-41E0-A99E-9050638CF5FB}', 1");
5978 add_complocator_entry(hdb, "'hagrphus', '{D4969B72-17D9-4AB6-BE49-78F2FEE857AC}', 0");
5979 add_complocator_entry(hdb, "'iguanodon', '{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}', 1");
5980 add_complocator_entry(hdb, "'jobaria', '{243C22B1-8C51-4151-B9D1-1AE5265E079E}', 0");
5981 add_complocator_entry(hdb, "'kakuru', '{5D0F03BA-50BC-44F2-ABB1-72C972F4E514}', 1");
5982 add_complocator_entry(hdb, "'labocania', '{C7DDB60C-7828-4046-A6F8-699D5E92F1ED}', 0");
5983 add_complocator_entry(hdb, "'megaraptor', '{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}', 1");
5984 add_complocator_entry(hdb, "'neosodon', '{0B499649-197A-48EF-93D2-AF1C17ED6E90}', 0");
5985 add_complocator_entry(hdb, "'olorotitan', '{54E9E91F-AED2-46D5-A25A-7E50AFA24513}', 1");
5986 add_complocator_entry(hdb, "'pantydraco', '{2A989951-5565-4FA7-93A7-E800A3E67D71}', 0");
5988 create_signature_table(hdb);
5989 add_signature_entry(hdb, "'abelisaurus', 'abelisaurus', '', '', '', '', '', '', ''");
5990 add_signature_entry(hdb, "'bactrosaurus', 'bactrosaurus', '', '', '', '', '', '', ''");
5991 add_signature_entry(hdb, "'camelotia', 'camelotia', '', '', '', '', '', '', ''");
5992 add_signature_entry(hdb, "'diclonius', 'diclonius', '', '', '', '', '', '', ''");
5993 add_signature_entry(hdb, "'iguanodon', 'iguanodon', '', '', '', '', '', '', ''");
5994 add_signature_entry(hdb, "'jobaria', 'jobaria', '', '', '', '', '', '', ''");
5995 add_signature_entry(hdb, "'kakuru', 'kakuru', '', '', '', '', '', '', ''");
5996 add_signature_entry(hdb, "'labocania', 'labocania', '', '', '', '', '', '', ''");
5998 r = package_from_db(hdb, &hpkg);
5999 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
6001 skip("Not enough rights to perform tests\n");
6002 DeleteFileA(msifile);
6003 return;
6005 ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
6007 MsiCloseHandle(hdb);
6009 create_test_file("abelisaurus");
6010 create_test_file("bactrosaurus");
6011 create_test_file("camelotia");
6012 create_test_file("diclonius");
6013 create_test_file("echinodon");
6014 create_test_file("falcarius");
6015 create_test_file("gallimimus");
6016 create_test_file("hagryphus");
6017 CreateDirectoryA("iguanodon", NULL);
6018 CreateDirectoryA("jobaria", NULL);
6019 CreateDirectoryA("kakuru", NULL);
6020 CreateDirectoryA("labocania", NULL);
6021 CreateDirectoryA("megaraptor", NULL);
6022 CreateDirectoryA("neosodon", NULL);
6023 CreateDirectoryA("olorotitan", NULL);
6024 CreateDirectoryA("pantydraco", NULL);
6026 set_component_path("abelisaurus", MSIINSTALLCONTEXT_MACHINE,
6027 "{E3619EED-305A-418C-B9C7-F7D7377F0934}", NULL, FALSE);
6028 set_component_path("bactrosaurus", MSIINSTALLCONTEXT_MACHINE,
6029 "{D56B688D-542F-42Ef-90FD-B6DA76EE8119}", NULL, FALSE);
6030 set_component_path("echinodon", MSIINSTALLCONTEXT_MACHINE,
6031 "{A19E16C5-C75D-4699-8111-C4338C40C3CB}", NULL, FALSE);
6032 set_component_path("falcarius", MSIINSTALLCONTEXT_MACHINE,
6033 "{17762FA1-A7AE-4CC6-8827-62873C35361D}", NULL, FALSE);
6034 set_component_path("iguanodon", MSIINSTALLCONTEXT_MACHINE,
6035 "{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}", NULL, FALSE);
6036 set_component_path("jobaria", MSIINSTALLCONTEXT_MACHINE,
6037 "{243C22B1-8C51-4151-B9D1-1AE5265E079E}", NULL, FALSE);
6038 set_component_path("megaraptor", MSIINSTALLCONTEXT_MACHINE,
6039 "{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}", NULL, FALSE);
6040 set_component_path("neosodon", MSIINSTALLCONTEXT_MACHINE,
6041 "{0B499649-197A-48EF-93D2-AF1C17ED6E90}", NULL, FALSE);
6043 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
6045 r = MsiDoActionA(hpkg, "AppSearch");
6046 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6048 size = MAX_PATH;
6049 r = MsiGetPropertyA(hpkg, "ABELISAURUS", prop, &size);
6050 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6052 lstrcpyA(expected, CURR_DIR);
6053 if (!is_root(CURR_DIR)) lstrcatA(expected, "\\");
6054 lstrcatA(expected, "abelisaurus");
6055 ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
6056 "Expected %s or empty string, got %s\n", expected, prop);
6058 size = MAX_PATH;
6059 r = MsiGetPropertyA(hpkg, "BACTROSAURUS", prop, &size);
6060 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6061 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6063 size = MAX_PATH;
6064 r = MsiGetPropertyA(hpkg, "CAMELOTIA", prop, &size);
6065 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6066 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6068 size = MAX_PATH;
6069 r = MsiGetPropertyA(hpkg, "DICLONIUS", prop, &size);
6070 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6071 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6073 size = MAX_PATH;
6074 r = MsiGetPropertyA(hpkg, "ECHINODON", prop, &size);
6075 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6077 lstrcpyA(expected, CURR_DIR);
6078 if (!is_root(CURR_DIR)) lstrcatA(expected, "\\");
6079 ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
6080 "Expected %s or empty string, got %s\n", expected, prop);
6082 size = MAX_PATH;
6083 r = MsiGetPropertyA(hpkg, "FALCARIUS", prop, &size);
6084 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6085 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6087 size = MAX_PATH;
6088 r = MsiGetPropertyA(hpkg, "GALLIMIMUS", prop, &size);
6089 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6090 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6092 size = MAX_PATH;
6093 r = MsiGetPropertyA(hpkg, "HAGRYPHUS", prop, &size);
6094 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6095 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6097 size = MAX_PATH;
6098 r = MsiGetPropertyA(hpkg, "IGUANODON", prop, &size);
6099 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6100 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6102 size = MAX_PATH;
6103 r = MsiGetPropertyA(hpkg, "JOBARIA", prop, &size);
6104 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6105 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6107 size = MAX_PATH;
6108 r = MsiGetPropertyA(hpkg, "KAKURU", prop, &size);
6109 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6110 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6112 size = MAX_PATH;
6113 r = MsiGetPropertyA(hpkg, "LABOCANIA", prop, &size);
6114 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6115 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6117 size = MAX_PATH;
6118 r = MsiGetPropertyA(hpkg, "MEGARAPTOR", prop, &size);
6119 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6121 lstrcpyA(expected, CURR_DIR);
6122 if (!is_root(CURR_DIR)) lstrcatA(expected, "\\");
6123 ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
6124 "Expected %s or empty string, got %s\n", expected, prop);
6126 size = MAX_PATH;
6127 r = MsiGetPropertyA(hpkg, "NEOSODON", prop, &size);
6128 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6130 lstrcpyA(expected, CURR_DIR);
6131 if (!is_root(CURR_DIR)) lstrcatA(expected, "\\");
6132 lstrcatA(expected, "neosodon\\");
6133 ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
6134 "Expected %s or empty string, got %s\n", expected, prop);
6136 size = MAX_PATH;
6137 r = MsiGetPropertyA(hpkg, "OLOROTITAN", prop, &size);
6138 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6139 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6141 size = MAX_PATH;
6142 r = MsiGetPropertyA(hpkg, "PANTYDRACO", prop, &size);
6143 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6144 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6146 MsiCloseHandle(hpkg);
6147 DeleteFileA("abelisaurus");
6148 DeleteFileA("bactrosaurus");
6149 DeleteFileA("camelotia");
6150 DeleteFileA("diclonius");
6151 DeleteFileA("echinodon");
6152 DeleteFileA("falcarius");
6153 DeleteFileA("gallimimus");
6154 DeleteFileA("hagryphus");
6155 RemoveDirectoryA("iguanodon");
6156 RemoveDirectoryA("jobaria");
6157 RemoveDirectoryA("kakuru");
6158 RemoveDirectoryA("labocania");
6159 RemoveDirectoryA("megaraptor");
6160 RemoveDirectoryA("neosodon");
6161 RemoveDirectoryA("olorotitan");
6162 RemoveDirectoryA("pantydraco");
6163 delete_component_path("{E3619EED-305A-418C-B9C7-F7D7377F0934}",
6164 MSIINSTALLCONTEXT_MACHINE, NULL);
6165 delete_component_path("{D56B688D-542F-42Ef-90FD-B6DA76EE8119}",
6166 MSIINSTALLCONTEXT_MACHINE, NULL);
6167 delete_component_path("{A19E16C5-C75D-4699-8111-C4338C40C3CB}",
6168 MSIINSTALLCONTEXT_MACHINE, NULL);
6169 delete_component_path("{17762FA1-A7AE-4CC6-8827-62873C35361D}",
6170 MSIINSTALLCONTEXT_MACHINE, NULL);
6171 delete_component_path("{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}",
6172 MSIINSTALLCONTEXT_MACHINE, NULL);
6173 delete_component_path("{243C22B1-8C51-4151-B9D1-1AE5265E079E}",
6174 MSIINSTALLCONTEXT_MACHINE, NULL);
6175 delete_component_path("{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}",
6176 MSIINSTALLCONTEXT_MACHINE, NULL);
6177 delete_component_path("{0B499649-197A-48EF-93D2-AF1C17ED6E90}",
6178 MSIINSTALLCONTEXT_MACHINE, NULL);
6179 DeleteFileA(msifile);
6182 static void set_suminfo_prop(MSIHANDLE db, DWORD prop, DWORD val)
6184 MSIHANDLE summary;
6185 UINT r;
6187 r = MsiGetSummaryInformationA(db, NULL, 1, &summary);
6188 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6190 r = MsiSummaryInfoSetPropertyA(summary, prop, VT_I4, val, NULL, NULL);
6191 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6193 r = MsiSummaryInfoPersist(summary);
6194 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
6196 MsiCloseHandle(summary);
6199 static void test_MsiGetSourcePath(void)
6201 MSIHANDLE hdb, hpkg;
6202 CHAR path[MAX_PATH];
6203 CHAR cwd[MAX_PATH];
6204 CHAR subsrc[MAX_PATH];
6205 CHAR sub2[MAX_PATH];
6206 DWORD size;
6207 UINT r;
6209 lstrcpyA(cwd, CURR_DIR);
6210 if (!is_root(CURR_DIR)) lstrcatA(cwd, "\\");
6212 lstrcpyA(subsrc, cwd);
6213 lstrcatA(subsrc, "subsource");
6214 lstrcatA(subsrc, "\\");
6216 lstrcpyA(sub2, subsrc);
6217 lstrcatA(sub2, "sub2");
6218 lstrcatA(sub2, "\\");
6220 /* uncompressed source */
6222 hdb = create_package_db();
6223 ok( hdb, "failed to create database\n");
6225 set_suminfo_prop(hdb, PID_WORDCOUNT, 0);
6227 add_directory_entry(hdb, "'TARGETDIR', '', 'SourceDir'");
6228 add_directory_entry(hdb, "'SubDir', 'TARGETDIR', 'subtarget:subsource'");
6229 add_directory_entry(hdb, "'SubDir2', 'SubDir', 'sub2'");
6231 r = MsiDatabaseCommit(hdb);
6232 ok(r == ERROR_SUCCESS , "Failed to commit database\n");
6234 r = package_from_db(hdb, &hpkg);
6235 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
6237 skip("Not enough rights to perform tests\n");
6238 DeleteFileA(msifile);
6239 return;
6241 ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
6243 MsiCloseHandle(hdb);
6245 /* invalid database handle */
6246 size = MAX_PATH;
6247 lstrcpyA(path, "kiwi");
6248 r = MsiGetSourcePathA(-1, "TARGETDIR", path, &size);
6249 ok(r == ERROR_INVALID_HANDLE,
6250 "Expected ERROR_INVALID_HANDLE, got %d\n", r);
6251 ok(!lstrcmpA(path, "kiwi"),
6252 "Expected path to be unchanged, got \"%s\"\n", path);
6253 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6255 /* NULL szFolder */
6256 size = MAX_PATH;
6257 lstrcpyA(path, "kiwi");
6258 r = MsiGetSourcePathA(hpkg, NULL, path, &size);
6259 ok(r == ERROR_INVALID_PARAMETER,
6260 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
6261 ok(!lstrcmpA(path, "kiwi"),
6262 "Expected path to be unchanged, got \"%s\"\n", path);
6263 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6265 /* empty szFolder */
6266 size = MAX_PATH;
6267 lstrcpyA(path, "kiwi");
6268 r = MsiGetSourcePathA(hpkg, "", path, &size);
6269 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6270 ok(!lstrcmpA(path, "kiwi"),
6271 "Expected path to be unchanged, got \"%s\"\n", path);
6272 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6274 /* try TARGETDIR */
6275 size = MAX_PATH;
6276 lstrcpyA(path, "kiwi");
6277 r = MsiGetSourcePathA(hpkg, "TARGETDIR", path, &size);
6278 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6279 ok(!lstrcmpA(path, "kiwi"),
6280 "Expected path to be unchanged, got \"%s\"\n", path);
6281 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6283 size = MAX_PATH;
6284 lstrcpyA(path, "kiwi");
6285 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
6286 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6287 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
6288 ok(size == 0, "Expected 0, got %d\n", size);
6290 size = MAX_PATH;
6291 lstrcpyA(path, "kiwi");
6292 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
6293 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6294 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
6295 ok(size == 0, "Expected 0, got %d\n", size);
6297 /* try SourceDir */
6298 size = MAX_PATH;
6299 lstrcpyA(path, "kiwi");
6300 r = MsiGetSourcePathA(hpkg, "SourceDir", path, &size);
6301 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6302 ok(!lstrcmpA(path, "kiwi"),
6303 "Expected path to be unchanged, got \"%s\"\n", path);
6304 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6306 /* try SOURCEDIR */
6307 size = MAX_PATH;
6308 lstrcpyA(path, "kiwi");
6309 r = MsiGetSourcePathA(hpkg, "SOURCEDIR", path, &size);
6310 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6311 ok(!lstrcmpA(path, "kiwi"),
6312 "Expected path to be unchanged, got \"%s\"\n", path);
6313 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6315 /* source path does not exist, but the property exists */
6316 size = MAX_PATH;
6317 lstrcpyA(path, "kiwi");
6318 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
6319 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6320 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
6321 ok(size == 0, "Expected 0, got %d\n", size);
6323 size = MAX_PATH;
6324 lstrcpyA(path, "kiwi");
6325 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
6326 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6327 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
6328 ok(size == 0, "Expected 0, got %d\n", size);
6330 /* try SubDir */
6331 size = MAX_PATH;
6332 lstrcpyA(path, "kiwi");
6333 r = MsiGetSourcePathA(hpkg, "SubDir", path, &size);
6334 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6335 ok(!lstrcmpA(path, "kiwi"),
6336 "Expected path to be unchanged, got \"%s\"\n", path);
6337 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6339 /* try SubDir2 */
6340 size = MAX_PATH;
6341 lstrcpyA(path, "kiwi");
6342 r = MsiGetSourcePathA(hpkg, "SubDir2", path, &size);
6343 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6344 ok(!lstrcmpA(path, "kiwi"),
6345 "Expected path to be unchanged, got \"%s\"\n", path);
6346 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6348 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
6350 r = MsiDoActionA(hpkg, "CostInitialize");
6351 ok(r == ERROR_SUCCESS, "cost init failed\n");
6353 /* try TARGETDIR after CostInitialize */
6354 size = MAX_PATH;
6355 lstrcpyA(path, "kiwi");
6356 r = MsiGetSourcePathA(hpkg, "TARGETDIR", path, &size);
6357 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6358 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6359 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6361 /* try SourceDir after CostInitialize */
6362 size = MAX_PATH;
6363 lstrcpyA(path, "kiwi");
6364 r = MsiGetSourcePathA(hpkg, "SourceDir", path, &size);
6365 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6366 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6367 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6369 /* try SOURCEDIR after CostInitialize */
6370 size = MAX_PATH;
6371 lstrcpyA(path, "kiwi");
6372 r = MsiGetSourcePathA(hpkg, "SOURCEDIR", path, &size);
6373 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6374 ok(!lstrcmpA(path, "kiwi"),
6375 "Expected path to be unchanged, got \"%s\"\n", path);
6376 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6378 /* source path does not exist, but the property exists */
6379 size = MAX_PATH;
6380 lstrcpyA(path, "kiwi");
6381 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
6382 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6383 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6384 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6386 size = MAX_PATH;
6387 lstrcpyA(path, "kiwi");
6388 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
6389 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6390 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6391 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6393 /* try SubDir after CostInitialize */
6394 size = MAX_PATH;
6395 lstrcpyA(path, "kiwi");
6396 r = MsiGetSourcePathA(hpkg, "SubDir", path, &size);
6397 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6398 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
6399 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
6401 /* try SubDir2 after CostInitialize */
6402 size = MAX_PATH;
6403 lstrcpyA(path, "kiwi");
6404 r = MsiGetSourcePathA(hpkg, "SubDir2", path, &size);
6405 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6406 ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
6407 ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
6409 r = MsiDoActionA(hpkg, "ResolveSource");
6410 ok(r == ERROR_SUCCESS, "file cost failed\n");
6412 /* try TARGETDIR after ResolveSource */
6413 size = MAX_PATH;
6414 lstrcpyA(path, "kiwi");
6415 r = MsiGetSourcePathA(hpkg, "TARGETDIR", path, &size);
6416 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6417 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6418 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6420 /* try SourceDir after ResolveSource */
6421 size = MAX_PATH;
6422 lstrcpyA(path, "kiwi");
6423 r = MsiGetSourcePathA(hpkg, "SourceDir", path, &size);
6424 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6425 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6426 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6428 /* try SOURCEDIR after ResolveSource */
6429 size = MAX_PATH;
6430 lstrcpyA(path, "kiwi");
6431 r = MsiGetSourcePathA(hpkg, "SOURCEDIR", path, &size);
6432 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6433 ok(!lstrcmpA(path, "kiwi"),
6434 "Expected path to be unchanged, got \"%s\"\n", path);
6435 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6437 /* source path does not exist, but the property exists */
6438 size = MAX_PATH;
6439 lstrcpyA(path, "kiwi");
6440 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
6441 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6442 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6443 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6445 size = MAX_PATH;
6446 lstrcpyA(path, "kiwi");
6447 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
6448 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6449 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6450 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6452 /* try SubDir after ResolveSource */
6453 size = MAX_PATH;
6454 lstrcpyA(path, "kiwi");
6455 r = MsiGetSourcePathA(hpkg, "SubDir", path, &size);
6456 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6457 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
6458 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
6460 /* try SubDir2 after ResolveSource */
6461 size = MAX_PATH;
6462 lstrcpyA(path, "kiwi");
6463 r = MsiGetSourcePathA(hpkg, "SubDir2", path, &size);
6464 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6465 ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
6466 ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
6468 r = MsiDoActionA(hpkg, "FileCost");
6469 ok(r == ERROR_SUCCESS, "file cost failed\n");
6471 /* try TARGETDIR after FileCost */
6472 size = MAX_PATH;
6473 lstrcpyA(path, "kiwi");
6474 r = MsiGetSourcePathA(hpkg, "TARGETDIR", path, &size);
6475 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6476 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6477 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6479 /* try SourceDir after FileCost */
6480 size = MAX_PATH;
6481 lstrcpyA(path, "kiwi");
6482 r = MsiGetSourcePathA(hpkg, "SourceDir", path, &size);
6483 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6484 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6485 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6487 /* try SOURCEDIR after FileCost */
6488 size = MAX_PATH;
6489 lstrcpyA(path, "kiwi");
6490 r = MsiGetSourcePathA(hpkg, "SOURCEDIR", path, &size);
6491 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6492 ok(!lstrcmpA(path, "kiwi"),
6493 "Expected path to be unchanged, got \"%s\"\n", path);
6494 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6496 /* source path does not exist, but the property exists */
6497 size = MAX_PATH;
6498 lstrcpyA(path, "kiwi");
6499 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
6500 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6501 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6502 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6504 size = MAX_PATH;
6505 lstrcpyA(path, "kiwi");
6506 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
6507 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6508 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6509 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6511 /* try SubDir after FileCost */
6512 size = MAX_PATH;
6513 lstrcpyA(path, "kiwi");
6514 r = MsiGetSourcePathA(hpkg, "SubDir", path, &size);
6515 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6516 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
6517 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
6519 /* try SubDir2 after FileCost */
6520 size = MAX_PATH;
6521 lstrcpyA(path, "kiwi");
6522 r = MsiGetSourcePathA(hpkg, "SubDir2", path, &size);
6523 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6524 ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
6525 ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
6527 r = MsiDoActionA(hpkg, "CostFinalize");
6528 ok(r == ERROR_SUCCESS, "file cost failed\n");
6530 /* try TARGETDIR after CostFinalize */
6531 size = MAX_PATH;
6532 lstrcpyA(path, "kiwi");
6533 r = MsiGetSourcePathA(hpkg, "TARGETDIR", path, &size);
6534 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6535 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6536 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6538 /* try SourceDir after CostFinalize */
6539 size = MAX_PATH;
6540 lstrcpyA(path, "kiwi");
6541 r = MsiGetSourcePathA(hpkg, "SourceDir", path, &size);
6542 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6543 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6544 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6546 /* try SOURCEDIR after CostFinalize */
6547 size = MAX_PATH;
6548 lstrcpyA(path, "kiwi");
6549 r = MsiGetSourcePathA(hpkg, "SOURCEDIR", path, &size);
6550 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6551 ok(!lstrcmpA(path, "kiwi"),
6552 "Expected path to be unchanged, got \"%s\"\n", path);
6553 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6555 /* source path does not exist, but the property exists */
6556 size = MAX_PATH;
6557 lstrcpyA(path, "kiwi");
6558 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
6559 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6560 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6561 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6563 size = MAX_PATH;
6564 lstrcpyA(path, "kiwi");
6565 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
6566 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6567 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6568 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6570 /* try SubDir after CostFinalize */
6571 size = MAX_PATH;
6572 lstrcpyA(path, "kiwi");
6573 r = MsiGetSourcePathA(hpkg, "SubDir", path, &size);
6574 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6575 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
6576 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
6578 /* try SubDir2 after CostFinalize */
6579 size = MAX_PATH;
6580 lstrcpyA(path, "kiwi");
6581 r = MsiGetSourcePathA(hpkg, "SubDir2", path, &size);
6582 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6583 ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
6584 ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
6586 /* nonexistent directory */
6587 size = MAX_PATH;
6588 lstrcpyA(path, "kiwi");
6589 r = MsiGetSourcePathA(hpkg, "IDontExist", path, &size);
6590 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6591 ok(!lstrcmpA(path, "kiwi"),
6592 "Expected path to be unchanged, got \"%s\"\n", path);
6593 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6595 /* NULL szPathBuf */
6596 size = MAX_PATH;
6597 r = MsiGetSourcePathA(hpkg, "SourceDir", NULL, &size);
6598 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6599 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6601 /* NULL pcchPathBuf */
6602 lstrcpyA(path, "kiwi");
6603 r = MsiGetSourcePathA(hpkg, "SourceDir", path, NULL);
6604 ok(r == ERROR_INVALID_PARAMETER,
6605 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
6606 ok(!lstrcmpA(path, "kiwi"),
6607 "Expected path to be unchanged, got \"%s\"\n", path);
6609 /* pcchPathBuf is 0 */
6610 size = 0;
6611 lstrcpyA(path, "kiwi");
6612 r = MsiGetSourcePathA(hpkg, "SourceDir", path, &size);
6613 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
6614 ok(!lstrcmpA(path, "kiwi"),
6615 "Expected path to be unchanged, got \"%s\"\n", path);
6616 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6618 /* pcchPathBuf does not have room for NULL terminator */
6619 size = lstrlenA(cwd);
6620 lstrcpyA(path, "kiwi");
6621 r = MsiGetSourcePathA(hpkg, "SourceDir", path, &size);
6622 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
6623 ok(!strncmp(path, cwd, lstrlenA(cwd) - 1),
6624 "Expected path with no backslash, got \"%s\"\n", path);
6625 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6627 /* pcchPathBuf has room for NULL terminator */
6628 size = lstrlenA(cwd) + 1;
6629 lstrcpyA(path, "kiwi");
6630 r = MsiGetSourcePathA(hpkg, "SourceDir", path, &size);
6631 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6632 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6633 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6635 /* remove property */
6636 r = MsiSetPropertyA(hpkg, "SourceDir", NULL);
6637 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6639 /* try SourceDir again */
6640 size = MAX_PATH;
6641 lstrcpyA(path, "kiwi");
6642 r = MsiGetSourcePathA(hpkg, "SourceDir", path, &size);
6643 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6644 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6645 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6647 /* set property to a valid directory */
6648 r = MsiSetPropertyA(hpkg, "SOURCEDIR", cwd);
6649 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6651 /* try SOURCEDIR again */
6652 size = MAX_PATH;
6653 lstrcpyA(path, "kiwi");
6654 r = MsiGetSourcePathA(hpkg, "SOURCEDIR", path, &size);
6655 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6656 ok(!lstrcmpA(path, "kiwi"),
6657 "Expected path to be unchanged, got \"%s\"\n", path);
6658 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6660 MsiCloseHandle(hpkg);
6662 /* compressed source */
6664 r = MsiOpenDatabaseW(msifileW, MSIDBOPEN_DIRECT, &hdb);
6665 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6667 set_suminfo_prop(hdb, PID_WORDCOUNT, msidbSumInfoSourceTypeCompressed);
6669 r = package_from_db(hdb, &hpkg);
6670 ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
6672 /* try TARGETDIR */
6673 size = MAX_PATH;
6674 lstrcpyA(path, "kiwi");
6675 r = MsiGetSourcePathA(hpkg, "TARGETDIR", path, &size);
6676 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6677 ok(!lstrcmpA(path, "kiwi"),
6678 "Expected path to be unchanged, got \"%s\"\n", path);
6679 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6681 /* try SourceDir */
6682 size = MAX_PATH;
6683 lstrcpyA(path, "kiwi");
6684 r = MsiGetSourcePathA(hpkg, "SourceDir", path, &size);
6685 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6686 ok(!lstrcmpA(path, "kiwi"),
6687 "Expected path to be unchanged, got \"%s\"\n", path);
6688 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6690 /* try SOURCEDIR */
6691 size = MAX_PATH;
6692 lstrcpyA(path, "kiwi");
6693 r = MsiGetSourcePathA(hpkg, "SOURCEDIR", path, &size);
6694 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6695 ok(!lstrcmpA(path, "kiwi"),
6696 "Expected path to be unchanged, got \"%s\"\n", path);
6697 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6699 /* source path nor the property exist */
6700 size = MAX_PATH;
6701 lstrcpyA(path, "kiwi");
6702 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
6703 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6704 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
6705 ok(size == 0, "Expected 0, got %d\n", size);
6707 size = MAX_PATH;
6708 lstrcpyA(path, "kiwi");
6709 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
6710 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6711 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
6712 ok(size == 0, "Expected 0, got %d\n", size);
6714 /* try SubDir */
6715 size = MAX_PATH;
6716 lstrcpyA(path, "kiwi");
6717 r = MsiGetSourcePathA(hpkg, "SubDir", path, &size);
6718 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6719 ok(!lstrcmpA(path, "kiwi"),
6720 "Expected path to be unchanged, got \"%s\"\n", path);
6721 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6723 /* try SubDir2 */
6724 size = MAX_PATH;
6725 lstrcpyA(path, "kiwi");
6726 r = MsiGetSourcePathA(hpkg, "SubDir2", path, &size);
6727 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6728 ok(!lstrcmpA(path, "kiwi"),
6729 "Expected path to be unchanged, got \"%s\"\n", path);
6730 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6732 r = MsiDoActionA(hpkg, "CostInitialize");
6733 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6735 /* try TARGETDIR after CostInitialize */
6736 size = MAX_PATH;
6737 lstrcpyA(path, "kiwi");
6738 r = MsiGetSourcePathA(hpkg, "TARGETDIR", path, &size);
6739 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6740 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6741 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6743 /* try SourceDir after CostInitialize */
6744 size = MAX_PATH;
6745 lstrcpyA(path, "kiwi");
6746 r = MsiGetSourcePathA(hpkg, "SourceDir", path, &size);
6747 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6748 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6749 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6751 /* try SOURCEDIR after CostInitialize */
6752 size = MAX_PATH;
6753 lstrcpyA(path, "kiwi");
6754 r = MsiGetSourcePathA(hpkg, "SOURCEDIR", path, &size);
6755 todo_wine
6757 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6758 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6759 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6762 /* source path does not exist, but the property exists */
6763 size = MAX_PATH;
6764 lstrcpyA(path, "kiwi");
6765 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
6766 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6767 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6768 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6770 size = MAX_PATH;
6771 lstrcpyA(path, "kiwi");
6772 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
6773 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6774 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6775 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6777 /* try SubDir after CostInitialize */
6778 size = MAX_PATH;
6779 lstrcpyA(path, "kiwi");
6780 r = MsiGetSourcePathA(hpkg, "SubDir", path, &size);
6781 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6782 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6783 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6785 /* try SubDir2 after CostInitialize */
6786 size = MAX_PATH;
6787 lstrcpyA(path, "kiwi");
6788 r = MsiGetSourcePathA(hpkg, "SubDir2", path, &size);
6789 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6790 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6791 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6793 r = MsiDoActionA(hpkg, "ResolveSource");
6794 ok(r == ERROR_SUCCESS, "file cost failed\n");
6796 /* try TARGETDIR after ResolveSource */
6797 size = MAX_PATH;
6798 lstrcpyA(path, "kiwi");
6799 r = MsiGetSourcePathA(hpkg, "TARGETDIR", path, &size);
6800 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6801 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6802 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6804 /* try SourceDir after ResolveSource */
6805 size = MAX_PATH;
6806 lstrcpyA(path, "kiwi");
6807 r = MsiGetSourcePathA(hpkg, "SourceDir", path, &size);
6808 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6809 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6810 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6812 /* try SOURCEDIR after ResolveSource */
6813 size = MAX_PATH;
6814 lstrcpyA(path, "kiwi");
6815 r = MsiGetSourcePathA(hpkg, "SOURCEDIR", path, &size);
6816 todo_wine
6818 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6819 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6820 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6823 /* source path and the property exist */
6824 size = MAX_PATH;
6825 lstrcpyA(path, "kiwi");
6826 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
6827 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6828 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6829 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6831 size = MAX_PATH;
6832 lstrcpyA(path, "kiwi");
6833 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
6834 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6835 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6836 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6838 /* try SubDir after ResolveSource */
6839 size = MAX_PATH;
6840 lstrcpyA(path, "kiwi");
6841 r = MsiGetSourcePathA(hpkg, "SubDir", path, &size);
6842 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6843 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6844 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6846 /* try SubDir2 after ResolveSource */
6847 size = MAX_PATH;
6848 lstrcpyA(path, "kiwi");
6849 r = MsiGetSourcePathA(hpkg, "SubDir2", path, &size);
6850 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6851 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6852 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6854 r = MsiDoActionA(hpkg, "FileCost");
6855 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6857 /* try TARGETDIR after CostFinalize */
6858 size = MAX_PATH;
6859 lstrcpyA(path, "kiwi");
6860 r = MsiGetSourcePathA(hpkg, "TARGETDIR", path, &size);
6861 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6862 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6863 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6865 /* try SourceDir after CostFinalize */
6866 size = MAX_PATH;
6867 lstrcpyA(path, "kiwi");
6868 r = MsiGetSourcePathA(hpkg, "SourceDir", path, &size);
6869 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6870 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6871 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6873 /* try SOURCEDIR after CostFinalize */
6874 size = MAX_PATH;
6875 lstrcpyA(path, "kiwi");
6876 r = MsiGetSourcePathA(hpkg, "SOURCEDIR", path, &size);
6877 todo_wine
6879 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6880 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6881 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6884 /* source path and the property exist */
6885 size = MAX_PATH;
6886 lstrcpyA(path, "kiwi");
6887 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
6888 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6889 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6890 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6892 size = MAX_PATH;
6893 lstrcpyA(path, "kiwi");
6894 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
6895 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6896 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6897 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6899 /* try SubDir after CostFinalize */
6900 size = MAX_PATH;
6901 lstrcpyA(path, "kiwi");
6902 r = MsiGetSourcePathA(hpkg, "SubDir", path, &size);
6903 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6904 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6905 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6907 /* try SubDir2 after CostFinalize */
6908 size = MAX_PATH;
6909 lstrcpyA(path, "kiwi");
6910 r = MsiGetSourcePathA(hpkg, "SubDir2", path, &size);
6911 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6912 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6913 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6915 r = MsiDoActionA(hpkg, "CostFinalize");
6916 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6918 /* try TARGETDIR after CostFinalize */
6919 size = MAX_PATH;
6920 lstrcpyA(path, "kiwi");
6921 r = MsiGetSourcePathA(hpkg, "TARGETDIR", path, &size);
6922 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6923 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6924 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6926 /* try SourceDir after CostFinalize */
6927 size = MAX_PATH;
6928 lstrcpyA(path, "kiwi");
6929 r = MsiGetSourcePathA(hpkg, "SourceDir", path, &size);
6930 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6931 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6932 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6934 /* try SOURCEDIR after CostFinalize */
6935 size = MAX_PATH;
6936 lstrcpyA(path, "kiwi");
6937 r = MsiGetSourcePathA(hpkg, "SOURCEDIR", path, &size);
6938 todo_wine
6940 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6941 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6942 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6945 /* source path and the property exist */
6946 size = MAX_PATH;
6947 lstrcpyA(path, "kiwi");
6948 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
6949 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6950 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6951 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6953 size = MAX_PATH;
6954 lstrcpyA(path, "kiwi");
6955 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
6956 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6957 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6958 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6960 /* try SubDir after CostFinalize */
6961 size = MAX_PATH;
6962 lstrcpyA(path, "kiwi");
6963 r = MsiGetSourcePathA(hpkg, "SubDir", path, &size);
6964 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6965 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6966 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6968 /* try SubDir2 after CostFinalize */
6969 size = MAX_PATH;
6970 lstrcpyA(path, "kiwi");
6971 r = MsiGetSourcePathA(hpkg, "SubDir2", path, &size);
6972 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6973 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6974 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6976 MsiCloseHandle(hpkg);
6977 DeleteFileA(msifile);
6980 static void test_shortlongsource(void)
6982 MSIHANDLE hdb, hpkg;
6983 CHAR path[MAX_PATH];
6984 CHAR cwd[MAX_PATH];
6985 CHAR subsrc[MAX_PATH];
6986 DWORD size;
6987 UINT r;
6989 lstrcpyA(cwd, CURR_DIR);
6990 if (!is_root(CURR_DIR)) lstrcatA(cwd, "\\");
6992 lstrcpyA(subsrc, cwd);
6993 lstrcatA(subsrc, "long");
6994 lstrcatA(subsrc, "\\");
6996 /* long file names */
6998 hdb = create_package_db();
6999 ok( hdb, "failed to create database\n");
7001 set_suminfo_prop(hdb, PID_WORDCOUNT, 0);
7003 add_directory_entry(hdb, "'TARGETDIR', '', 'SourceDir'");
7004 add_directory_entry(hdb, "'SubDir', 'TARGETDIR', 'short|long'");
7006 /* CostInitialize:short */
7007 add_directory_entry(hdb, "'SubDir2', 'TARGETDIR', 'one|two'");
7009 /* CostInitialize:long */
7010 add_directory_entry(hdb, "'SubDir3', 'TARGETDIR', 'three|four'");
7012 /* FileCost:short */
7013 add_directory_entry(hdb, "'SubDir4', 'TARGETDIR', 'five|six'");
7015 /* FileCost:long */
7016 add_directory_entry(hdb, "'SubDir5', 'TARGETDIR', 'seven|eight'");
7018 /* CostFinalize:short */
7019 add_directory_entry(hdb, "'SubDir6', 'TARGETDIR', 'nine|ten'");
7021 /* CostFinalize:long */
7022 add_directory_entry(hdb, "'SubDir7', 'TARGETDIR', 'eleven|twelve'");
7024 r = MsiDatabaseCommit(hdb);
7025 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
7027 r = package_from_db(hdb, &hpkg);
7028 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
7030 skip("Not enough rights to perform tests\n");
7031 DeleteFileA(msifile);
7032 return;
7034 ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
7036 MsiCloseHandle(hdb);
7038 CreateDirectoryA("one", NULL);
7039 CreateDirectoryA("four", NULL);
7041 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
7043 r = MsiDoActionA(hpkg, "CostInitialize");
7044 ok(r == ERROR_SUCCESS, "file cost failed\n");
7046 CreateDirectoryA("five", NULL);
7047 CreateDirectoryA("eight", NULL);
7049 r = MsiDoActionA(hpkg, "FileCost");
7050 ok(r == ERROR_SUCCESS, "file cost failed\n");
7052 CreateDirectoryA("nine", NULL);
7053 CreateDirectoryA("twelve", NULL);
7055 r = MsiDoActionA(hpkg, "CostFinalize");
7056 ok(r == ERROR_SUCCESS, "file cost failed\n");
7058 /* neither short nor long source directories exist */
7059 size = MAX_PATH;
7060 lstrcpyA(path, "kiwi");
7061 r = MsiGetSourcePathA(hpkg, "SubDir", path, &size);
7062 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7063 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7064 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7066 CreateDirectoryA("short", NULL);
7068 /* short source directory exists */
7069 size = MAX_PATH;
7070 lstrcpyA(path, "kiwi");
7071 r = MsiGetSourcePathA(hpkg, "SubDir", path, &size);
7072 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7073 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7074 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7076 CreateDirectoryA("long", NULL);
7078 /* both short and long source directories exist */
7079 size = MAX_PATH;
7080 lstrcpyA(path, "kiwi");
7081 r = MsiGetSourcePathA(hpkg, "SubDir", path, &size);
7082 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7083 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7084 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7086 lstrcpyA(subsrc, cwd);
7087 lstrcatA(subsrc, "two");
7088 lstrcatA(subsrc, "\\");
7090 /* short dir exists before CostInitialize */
7091 size = MAX_PATH;
7092 lstrcpyA(path, "kiwi");
7093 r = MsiGetSourcePathA(hpkg, "SubDir2", path, &size);
7094 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7095 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7096 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7098 lstrcpyA(subsrc, cwd);
7099 lstrcatA(subsrc, "four");
7100 lstrcatA(subsrc, "\\");
7102 /* long dir exists before CostInitialize */
7103 size = MAX_PATH;
7104 lstrcpyA(path, "kiwi");
7105 r = MsiGetSourcePathA(hpkg, "SubDir3", path, &size);
7106 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7107 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7108 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7110 lstrcpyA(subsrc, cwd);
7111 lstrcatA(subsrc, "six");
7112 lstrcatA(subsrc, "\\");
7114 /* short dir exists before FileCost */
7115 size = MAX_PATH;
7116 lstrcpyA(path, "kiwi");
7117 r = MsiGetSourcePathA(hpkg, "SubDir4", path, &size);
7118 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7119 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7120 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7122 lstrcpyA(subsrc, cwd);
7123 lstrcatA(subsrc, "eight");
7124 lstrcatA(subsrc, "\\");
7126 /* long dir exists before FileCost */
7127 size = MAX_PATH;
7128 lstrcpyA(path, "kiwi");
7129 r = MsiGetSourcePathA(hpkg, "SubDir5", path, &size);
7130 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7131 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7132 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7134 lstrcpyA(subsrc, cwd);
7135 lstrcatA(subsrc, "ten");
7136 lstrcatA(subsrc, "\\");
7138 /* short dir exists before CostFinalize */
7139 size = MAX_PATH;
7140 lstrcpyA(path, "kiwi");
7141 r = MsiGetSourcePathA(hpkg, "SubDir6", path, &size);
7142 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7143 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7144 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7146 lstrcpyA(subsrc, cwd);
7147 lstrcatA(subsrc, "twelve");
7148 lstrcatA(subsrc, "\\");
7150 /* long dir exists before CostFinalize */
7151 size = MAX_PATH;
7152 lstrcpyA(path, "kiwi");
7153 r = MsiGetSourcePathA(hpkg, "SubDir7", path, &size);
7154 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7155 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7156 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7158 MsiCloseHandle(hpkg);
7159 RemoveDirectoryA("short");
7160 RemoveDirectoryA("long");
7161 RemoveDirectoryA("one");
7162 RemoveDirectoryA("four");
7163 RemoveDirectoryA("five");
7164 RemoveDirectoryA("eight");
7165 RemoveDirectoryA("nine");
7166 RemoveDirectoryA("twelve");
7168 /* short file names */
7170 r = MsiOpenDatabaseW(msifileW, MSIDBOPEN_DIRECT, &hdb);
7171 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7173 set_suminfo_prop(hdb, PID_WORDCOUNT, msidbSumInfoSourceTypeSFN);
7175 r = package_from_db(hdb, &hpkg);
7176 ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
7178 MsiCloseHandle(hdb);
7180 CreateDirectoryA("one", NULL);
7181 CreateDirectoryA("four", NULL);
7183 r = MsiDoActionA(hpkg, "CostInitialize");
7184 ok(r == ERROR_SUCCESS, "file cost failed\n");
7186 CreateDirectoryA("five", NULL);
7187 CreateDirectoryA("eight", NULL);
7189 r = MsiDoActionA(hpkg, "FileCost");
7190 ok(r == ERROR_SUCCESS, "file cost failed\n");
7192 CreateDirectoryA("nine", NULL);
7193 CreateDirectoryA("twelve", NULL);
7195 r = MsiDoActionA(hpkg, "CostFinalize");
7196 ok(r == ERROR_SUCCESS, "file cost failed\n");
7198 lstrcpyA(subsrc, cwd);
7199 lstrcatA(subsrc, "short");
7200 lstrcatA(subsrc, "\\");
7202 /* neither short nor long source directories exist */
7203 size = MAX_PATH;
7204 lstrcpyA(path, "kiwi");
7205 r = MsiGetSourcePathA(hpkg, "SubDir", path, &size);
7206 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7207 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7208 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7210 CreateDirectoryA("short", NULL);
7212 /* short source directory exists */
7213 size = MAX_PATH;
7214 lstrcpyA(path, "kiwi");
7215 r = MsiGetSourcePathA(hpkg, "SubDir", path, &size);
7216 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7217 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7218 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7220 CreateDirectoryA("long", NULL);
7222 /* both short and long source directories exist */
7223 size = MAX_PATH;
7224 lstrcpyA(path, "kiwi");
7225 r = MsiGetSourcePathA(hpkg, "SubDir", path, &size);
7226 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7227 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7228 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7230 lstrcpyA(subsrc, cwd);
7231 lstrcatA(subsrc, "one");
7232 lstrcatA(subsrc, "\\");
7234 /* short dir exists before CostInitialize */
7235 size = MAX_PATH;
7236 lstrcpyA(path, "kiwi");
7237 r = MsiGetSourcePathA(hpkg, "SubDir2", path, &size);
7238 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7239 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7240 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7242 lstrcpyA(subsrc, cwd);
7243 lstrcatA(subsrc, "three");
7244 lstrcatA(subsrc, "\\");
7246 /* long dir exists before CostInitialize */
7247 size = MAX_PATH;
7248 lstrcpyA(path, "kiwi");
7249 r = MsiGetSourcePathA(hpkg, "SubDir3", path, &size);
7250 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7251 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7252 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7254 lstrcpyA(subsrc, cwd);
7255 lstrcatA(subsrc, "five");
7256 lstrcatA(subsrc, "\\");
7258 /* short dir exists before FileCost */
7259 size = MAX_PATH;
7260 lstrcpyA(path, "kiwi");
7261 r = MsiGetSourcePathA(hpkg, "SubDir4", path, &size);
7262 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7263 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7264 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7266 lstrcpyA(subsrc, cwd);
7267 lstrcatA(subsrc, "seven");
7268 lstrcatA(subsrc, "\\");
7270 /* long dir exists before FileCost */
7271 size = MAX_PATH;
7272 lstrcpyA(path, "kiwi");
7273 r = MsiGetSourcePathA(hpkg, "SubDir5", path, &size);
7274 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7275 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7276 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7278 lstrcpyA(subsrc, cwd);
7279 lstrcatA(subsrc, "nine");
7280 lstrcatA(subsrc, "\\");
7282 /* short dir exists before CostFinalize */
7283 size = MAX_PATH;
7284 lstrcpyA(path, "kiwi");
7285 r = MsiGetSourcePathA(hpkg, "SubDir6", path, &size);
7286 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7287 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7288 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7290 lstrcpyA(subsrc, cwd);
7291 lstrcatA(subsrc, "eleven");
7292 lstrcatA(subsrc, "\\");
7294 /* long dir exists before CostFinalize */
7295 size = MAX_PATH;
7296 lstrcpyA(path, "kiwi");
7297 r = MsiGetSourcePathA(hpkg, "SubDir7", path, &size);
7298 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7299 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7300 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7302 MsiCloseHandle(hpkg);
7303 RemoveDirectoryA("short");
7304 RemoveDirectoryA("long");
7305 RemoveDirectoryA("one");
7306 RemoveDirectoryA("four");
7307 RemoveDirectoryA("five");
7308 RemoveDirectoryA("eight");
7309 RemoveDirectoryA("nine");
7310 RemoveDirectoryA("twelve");
7311 DeleteFileA(msifile);
7314 static void test_sourcedir(void)
7316 MSIHANDLE hdb, hpkg;
7317 CHAR package[12];
7318 CHAR path[MAX_PATH];
7319 CHAR cwd[MAX_PATH];
7320 CHAR subsrc[MAX_PATH];
7321 DWORD size;
7322 UINT r;
7324 lstrcpyA(cwd, CURR_DIR);
7325 if (!is_root(CURR_DIR)) lstrcatA(cwd, "\\");
7327 lstrcpyA(subsrc, cwd);
7328 lstrcatA(subsrc, "long");
7329 lstrcatA(subsrc, "\\");
7331 hdb = create_package_db();
7332 ok( hdb, "failed to create database\n");
7334 add_directory_entry(hdb, "'TARGETDIR', '', 'SourceDir'");
7336 sprintf(package, "#%u", hdb);
7337 r = MsiOpenPackageA(package, &hpkg);
7338 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
7340 skip("Not enough rights to perform tests\n");
7341 goto error;
7343 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7345 /* properties only */
7347 /* SourceDir prop */
7348 size = MAX_PATH;
7349 lstrcpyA(path, "kiwi");
7350 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
7351 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7352 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7353 ok(size == 0, "Expected 0, got %d\n", size);
7355 /* SOURCEDIR prop */
7356 size = MAX_PATH;
7357 lstrcpyA(path, "kiwi");
7358 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
7359 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7360 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7361 ok(size == 0, "Expected 0, got %d\n", size);
7363 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
7365 r = MsiDoActionA(hpkg, "CostInitialize");
7366 ok(r == ERROR_SUCCESS, "file cost failed\n");
7368 /* SourceDir after CostInitialize */
7369 size = MAX_PATH;
7370 lstrcpyA(path, "kiwi");
7371 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
7372 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7373 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7374 ok(size == 0, "Expected 0, got %d\n", size);
7376 /* SOURCEDIR after CostInitialize */
7377 size = MAX_PATH;
7378 lstrcpyA(path, "kiwi");
7379 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
7380 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7381 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7382 ok(size == 0, "Expected 0, got %d\n", size);
7384 r = MsiDoActionA(hpkg, "FileCost");
7385 ok(r == ERROR_SUCCESS, "file cost failed\n");
7387 /* SourceDir after FileCost */
7388 size = MAX_PATH;
7389 lstrcpyA(path, "kiwi");
7390 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
7391 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7392 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7393 ok(size == 0, "Expected 0, got %d\n", size);
7395 /* SOURCEDIR after FileCost */
7396 size = MAX_PATH;
7397 lstrcpyA(path, "kiwi");
7398 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
7399 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7400 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7401 ok(size == 0, "Expected 0, got %d\n", size);
7403 r = MsiDoActionA(hpkg, "CostFinalize");
7404 ok(r == ERROR_SUCCESS, "file cost failed\n");
7406 /* SourceDir after CostFinalize */
7407 size = MAX_PATH;
7408 lstrcpyA(path, "kiwi");
7409 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
7410 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7411 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7412 ok(size == 0, "Expected 0, got %d\n", size);
7414 /* SOURCEDIR after CostFinalize */
7415 size = MAX_PATH;
7416 lstrcpyA(path, "kiwi");
7417 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
7418 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7419 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7420 ok(size == 0, "Expected 0, got %d\n", size);
7422 size = MAX_PATH;
7423 lstrcpyA(path, "kiwi");
7424 r = MsiGetSourcePathA(hpkg, "SOURCEDIR", path, &size);
7425 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7426 ok(!lstrcmpA(path, "kiwi"), "Expected \"kiwi\", got \"%s\"\n", path);
7427 ok(size == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, size);
7429 /* SOURCEDIR after calling MsiGetSourcePath */
7430 size = MAX_PATH;
7431 lstrcpyA(path, "kiwi");
7432 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
7433 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7434 todo_wine {
7435 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7436 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7439 r = MsiDoActionA(hpkg, "ResolveSource");
7440 ok(r == ERROR_SUCCESS, "file cost failed\n");
7442 /* SourceDir after ResolveSource */
7443 size = MAX_PATH;
7444 lstrcpyA(path, "kiwi");
7445 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
7446 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7447 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7448 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7450 /* SOURCEDIR after ResolveSource */
7451 size = MAX_PATH;
7452 lstrcpyA(path, "kiwi");
7453 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
7454 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7455 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7456 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7458 /* random casing */
7459 size = MAX_PATH;
7460 lstrcpyA(path, "kiwi");
7461 r = MsiGetPropertyA(hpkg, "SoUrCeDiR", path, &size);
7462 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7463 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7464 ok(size == 0, "Expected 0, got %d\n", size);
7466 MsiCloseHandle(hpkg);
7468 /* reset the package state */
7469 sprintf(package, "#%i", hdb);
7470 r = MsiOpenPackageA(package, &hpkg);
7471 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7473 /* test how MsiGetSourcePath affects the properties */
7475 /* SourceDir prop */
7476 size = MAX_PATH;
7477 lstrcpyA(path, "kiwi");
7478 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
7479 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7480 todo_wine
7482 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7483 ok(size == 0, "Expected 0, got %d\n", size);
7486 size = MAX_PATH;
7487 lstrcpyA(path, "kiwi");
7488 r = MsiGetSourcePathA(hpkg, "SourceDir", path, &size);
7489 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7490 ok(!lstrcmpA(path, "kiwi"),
7491 "Expected path to be unchanged, got \"%s\"\n", path);
7492 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7494 /* SourceDir after MsiGetSourcePath */
7495 size = MAX_PATH;
7496 lstrcpyA(path, "kiwi");
7497 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
7498 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7499 todo_wine
7501 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7502 ok(size == 0, "Expected 0, got %d\n", size);
7505 /* SOURCEDIR prop */
7506 size = MAX_PATH;
7507 lstrcpyA(path, "kiwi");
7508 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
7509 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7510 todo_wine
7512 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7513 ok(size == 0, "Expected 0, got %d\n", size);
7516 size = MAX_PATH;
7517 lstrcpyA(path, "kiwi");
7518 r = MsiGetSourcePathA(hpkg, "SOURCEDIR", path, &size);
7519 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7520 ok(!lstrcmpA(path, "kiwi"),
7521 "Expected path to be unchanged, got \"%s\"\n", path);
7522 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7524 /* SOURCEDIR prop after MsiGetSourcePath */
7525 size = MAX_PATH;
7526 lstrcpyA(path, "kiwi");
7527 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
7528 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7529 todo_wine
7531 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7532 ok(size == 0, "Expected 0, got %d\n", size);
7535 r = MsiDoActionA(hpkg, "CostInitialize");
7536 ok(r == ERROR_SUCCESS, "file cost failed\n");
7538 /* SourceDir after CostInitialize */
7539 size = MAX_PATH;
7540 lstrcpyA(path, "kiwi");
7541 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
7542 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7543 todo_wine
7545 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7546 ok(size == 0, "Expected 0, got %d\n", size);
7549 size = MAX_PATH;
7550 lstrcpyA(path, "kiwi");
7551 r = MsiGetSourcePathA(hpkg, "SourceDir", path, &size);
7552 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7553 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7554 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7556 /* SourceDir after MsiGetSourcePath */
7557 size = MAX_PATH;
7558 lstrcpyA(path, "kiwi");
7559 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
7560 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7561 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7562 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7564 /* SOURCEDIR after CostInitialize */
7565 size = MAX_PATH;
7566 lstrcpyA(path, "kiwi");
7567 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
7568 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7569 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7570 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7572 /* SOURCEDIR source path still does not exist */
7573 size = MAX_PATH;
7574 lstrcpyA(path, "kiwi");
7575 r = MsiGetSourcePathA(hpkg, "SOURCEDIR", path, &size);
7576 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7577 ok(!lstrcmpA(path, "kiwi"),
7578 "Expected path to be unchanged, got \"%s\"\n", path);
7579 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7581 r = MsiDoActionA(hpkg, "FileCost");
7582 ok(r == ERROR_SUCCESS, "file cost failed\n");
7584 /* SourceDir after FileCost */
7585 size = MAX_PATH;
7586 lstrcpyA(path, "kiwi");
7587 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
7588 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7589 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7590 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7592 /* SOURCEDIR after FileCost */
7593 size = MAX_PATH;
7594 lstrcpyA(path, "kiwi");
7595 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
7596 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7597 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7598 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7600 /* SOURCEDIR source path still does not exist */
7601 size = MAX_PATH;
7602 lstrcpyA(path, "kiwi");
7603 r = MsiGetSourcePathA(hpkg, "SOURCEDIR", path, &size);
7604 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7605 ok(!lstrcmpA(path, "kiwi"),
7606 "Expected path to be unchanged, got \"%s\"\n", path);
7607 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7609 r = MsiDoActionA(hpkg, "CostFinalize");
7610 ok(r == ERROR_SUCCESS, "file cost failed\n");
7612 /* SourceDir after CostFinalize */
7613 size = MAX_PATH;
7614 lstrcpyA(path, "kiwi");
7615 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
7616 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7617 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7618 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7620 /* SOURCEDIR after CostFinalize */
7621 size = MAX_PATH;
7622 lstrcpyA(path, "kiwi");
7623 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
7624 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7625 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7626 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7628 /* SOURCEDIR source path still does not exist */
7629 size = MAX_PATH;
7630 lstrcpyA(path, "kiwi");
7631 r = MsiGetSourcePathA(hpkg, "SOURCEDIR", path, &size);
7632 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7633 ok(!lstrcmpA(path, "kiwi"),
7634 "Expected path to be unchanged, got \"%s\"\n", path);
7635 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7637 r = MsiDoActionA(hpkg, "ResolveSource");
7638 ok(r == ERROR_SUCCESS, "file cost failed\n");
7640 /* SourceDir after ResolveSource */
7641 size = MAX_PATH;
7642 lstrcpyA(path, "kiwi");
7643 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
7644 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7645 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7646 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7648 /* SOURCEDIR after ResolveSource */
7649 size = MAX_PATH;
7650 lstrcpyA(path, "kiwi");
7651 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
7652 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7653 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7654 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7656 /* SOURCEDIR source path still does not exist */
7657 size = MAX_PATH;
7658 lstrcpyA(path, "kiwi");
7659 r = MsiGetSourcePathA(hpkg, "SOURCEDIR", path, &size);
7660 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7661 ok(!lstrcmpA(path, "kiwi"),
7662 "Expected path to be unchanged, got \"%s\"\n", path);
7663 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7665 MsiCloseHandle(hpkg);
7667 error:
7668 MsiCloseHandle(hdb);
7669 DeleteFileA(msifile);
7672 struct access_res
7674 BOOL gothandle;
7675 DWORD lasterr;
7676 BOOL ignore;
7679 static const struct access_res create[16] =
7681 { TRUE, ERROR_SUCCESS, TRUE },
7682 { TRUE, ERROR_SUCCESS, TRUE },
7683 { TRUE, ERROR_SUCCESS, FALSE },
7684 { TRUE, ERROR_SUCCESS, FALSE },
7685 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7686 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7687 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7688 { TRUE, ERROR_SUCCESS, FALSE },
7689 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7690 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7691 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7692 { TRUE, ERROR_SUCCESS, TRUE },
7693 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7694 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7695 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7696 { TRUE, ERROR_SUCCESS, TRUE }
7699 static const struct access_res create_commit[16] =
7701 { TRUE, ERROR_SUCCESS, TRUE },
7702 { TRUE, ERROR_SUCCESS, TRUE },
7703 { TRUE, ERROR_SUCCESS, FALSE },
7704 { TRUE, ERROR_SUCCESS, FALSE },
7705 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7706 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7707 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7708 { TRUE, ERROR_SUCCESS, FALSE },
7709 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7710 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7711 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7712 { TRUE, ERROR_SUCCESS, TRUE },
7713 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7714 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7715 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7716 { TRUE, ERROR_SUCCESS, TRUE }
7719 static const struct access_res create_close[16] =
7721 { TRUE, ERROR_SUCCESS, FALSE },
7722 { TRUE, ERROR_SUCCESS, FALSE },
7723 { TRUE, ERROR_SUCCESS, FALSE },
7724 { TRUE, ERROR_SUCCESS, FALSE },
7725 { TRUE, ERROR_SUCCESS, FALSE },
7726 { TRUE, ERROR_SUCCESS, FALSE },
7727 { TRUE, ERROR_SUCCESS, FALSE },
7728 { TRUE, ERROR_SUCCESS, FALSE },
7729 { TRUE, ERROR_SUCCESS, FALSE },
7730 { TRUE, ERROR_SUCCESS, FALSE },
7731 { TRUE, ERROR_SUCCESS, FALSE },
7732 { TRUE, ERROR_SUCCESS, FALSE },
7733 { TRUE, ERROR_SUCCESS, FALSE },
7734 { TRUE, ERROR_SUCCESS, FALSE },
7735 { TRUE, ERROR_SUCCESS, FALSE },
7736 { TRUE, ERROR_SUCCESS }
7739 static void _test_file_access(LPCSTR file, const struct access_res *ares, DWORD line)
7741 DWORD access = 0, share = 0;
7742 DWORD lasterr;
7743 HANDLE hfile;
7744 int i, j, idx = 0;
7746 for (i = 0; i < 4; i++)
7748 if (i == 0) access = 0;
7749 if (i == 1) access = GENERIC_READ;
7750 if (i == 2) access = GENERIC_WRITE;
7751 if (i == 3) access = GENERIC_READ | GENERIC_WRITE;
7753 for (j = 0; j < 4; j++)
7755 if (ares[idx].ignore)
7756 continue;
7758 if (j == 0) share = 0;
7759 if (j == 1) share = FILE_SHARE_READ;
7760 if (j == 2) share = FILE_SHARE_WRITE;
7761 if (j == 3) share = FILE_SHARE_READ | FILE_SHARE_WRITE;
7763 SetLastError(0xdeadbeef);
7764 hfile = CreateFileA(file, access, share, NULL, OPEN_EXISTING,
7765 FILE_ATTRIBUTE_NORMAL, 0);
7766 lasterr = GetLastError();
7768 ok((hfile != INVALID_HANDLE_VALUE) == ares[idx].gothandle,
7769 "(%d, handle, %d): Expected %d, got %d\n",
7770 line, idx, ares[idx].gothandle,
7771 (hfile != INVALID_HANDLE_VALUE));
7773 ok(lasterr == ares[idx].lasterr, "(%d, lasterr, %d): Expected %d, got %d\n",
7774 line, idx, ares[idx].lasterr, lasterr);
7776 CloseHandle(hfile);
7777 idx++;
7782 #define test_file_access(file, ares) _test_file_access(file, ares, __LINE__)
7784 static void test_access(void)
7786 MSIHANDLE hdb;
7787 UINT r;
7789 r = MsiOpenDatabaseW(msifileW, MSIDBOPEN_CREATE, &hdb);
7790 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7792 test_file_access(msifile, create);
7794 r = MsiDatabaseCommit(hdb);
7795 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7797 test_file_access(msifile, create_commit);
7798 MsiCloseHandle(hdb);
7800 test_file_access(msifile, create_close);
7801 DeleteFileA(msifile);
7803 r = MsiOpenDatabaseW(msifileW, MSIDBOPEN_CREATEDIRECT, &hdb);
7804 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7806 test_file_access(msifile, create);
7808 r = MsiDatabaseCommit(hdb);
7809 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7811 test_file_access(msifile, create_commit);
7812 MsiCloseHandle(hdb);
7814 test_file_access(msifile, create_close);
7815 DeleteFileA(msifile);
7818 static void test_emptypackage(void)
7820 MSIHANDLE hpkg = 0, hdb = 0, hsuminfo = 0;
7821 MSIHANDLE hview = 0, hrec = 0;
7822 MSICONDITION condition;
7823 CHAR buffer[MAX_PATH];
7824 DWORD size;
7825 UINT r;
7827 r = MsiOpenPackageA("", &hpkg);
7828 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
7830 skip("Not enough rights to perform tests\n");
7831 return;
7833 todo_wine
7835 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7838 hdb = MsiGetActiveDatabase(hpkg);
7839 todo_wine
7841 ok(hdb != 0, "Expected a valid database handle\n");
7844 r = MsiDatabaseOpenViewA(hdb, "SELECT * FROM `_Tables`", &hview);
7845 todo_wine
7847 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7849 r = MsiViewExecute(hview, 0);
7850 todo_wine
7852 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7855 r = MsiViewFetch(hview, &hrec);
7856 todo_wine
7858 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7861 buffer[0] = 0;
7862 size = MAX_PATH;
7863 r = MsiRecordGetStringA(hrec, 1, buffer, &size);
7864 todo_wine
7866 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7867 ok(!lstrcmpA(buffer, "_Property"),
7868 "Expected \"_Property\", got \"%s\"\n", buffer);
7871 MsiCloseHandle(hrec);
7873 r = MsiViewFetch(hview, &hrec);
7874 todo_wine
7876 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7879 size = MAX_PATH;
7880 r = MsiRecordGetStringA(hrec, 1, buffer, &size);
7881 todo_wine
7883 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7884 ok(!lstrcmpA(buffer, "#_FolderCache"),
7885 "Expected \"_Property\", got \"%s\"\n", buffer);
7888 MsiCloseHandle(hrec);
7889 MsiViewClose(hview);
7890 MsiCloseHandle(hview);
7892 condition = MsiDatabaseIsTablePersistentA(hdb, "_Property");
7893 todo_wine
7895 ok(condition == MSICONDITION_FALSE,
7896 "Expected MSICONDITION_FALSE, got %d\n", condition);
7899 r = MsiDatabaseOpenViewA(hdb, "SELECT * FROM `_Property`", &hview);
7900 todo_wine
7902 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7904 r = MsiViewExecute(hview, 0);
7905 todo_wine
7907 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7910 /* _Property table is not empty */
7911 r = MsiViewFetch(hview, &hrec);
7912 todo_wine
7914 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7917 MsiCloseHandle(hrec);
7918 MsiViewClose(hview);
7919 MsiCloseHandle(hview);
7921 condition = MsiDatabaseIsTablePersistentA(hdb, "#_FolderCache");
7922 todo_wine
7924 ok(condition == MSICONDITION_FALSE,
7925 "Expected MSICONDITION_FALSE, got %d\n", condition);
7928 r = MsiDatabaseOpenViewA(hdb, "SELECT * FROM `#_FolderCache`", &hview);
7929 todo_wine
7931 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7933 r = MsiViewExecute(hview, 0);
7934 todo_wine
7936 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7939 /* #_FolderCache is not empty */
7940 r = MsiViewFetch(hview, &hrec);
7941 todo_wine
7943 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7946 MsiCloseHandle(hrec);
7947 MsiViewClose(hview);
7948 MsiCloseHandle(hview);
7950 r = MsiDatabaseOpenViewA(hdb, "SELECT * FROM `_Streams`", &hview);
7951 todo_wine
7953 ok(r == ERROR_BAD_QUERY_SYNTAX,
7954 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
7957 r = MsiDatabaseOpenViewA(hdb, "SELECT * FROM `_Storages`", &hview);
7958 todo_wine
7960 ok(r == ERROR_BAD_QUERY_SYNTAX,
7961 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
7964 r = MsiGetSummaryInformationA(hdb, NULL, 0, &hsuminfo);
7965 todo_wine
7967 ok(r == ERROR_INSTALL_PACKAGE_INVALID,
7968 "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
7971 MsiCloseHandle(hsuminfo);
7973 r = MsiDatabaseCommit(hdb);
7974 todo_wine
7976 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7979 MsiCloseHandle(hdb);
7980 MsiCloseHandle(hpkg);
7983 static void test_MsiGetProductProperty(void)
7985 static const WCHAR prodcode_propW[] = {'P','r','o','d','u','c','t','C','o','d','e',0};
7986 static const WCHAR nonexistentW[] = {'I','D','o','n','t','E','x','i','s','t',0};
7987 static const WCHAR newpropW[] = {'N','e','w','P','r','o','p','e','r','t','y',0};
7988 static const WCHAR appleW[] = {'a','p','p','l','e',0};
7989 static const WCHAR emptyW[] = {0};
7990 WCHAR valW[MAX_PATH];
7991 MSIHANDLE hprod, hdb;
7992 CHAR val[MAX_PATH];
7993 CHAR path[MAX_PATH];
7994 CHAR query[MAX_PATH];
7995 CHAR keypath[MAX_PATH*2];
7996 CHAR prodcode[MAX_PATH];
7997 WCHAR prodcodeW[MAX_PATH];
7998 CHAR prod_squashed[MAX_PATH];
7999 WCHAR prod_squashedW[MAX_PATH];
8000 HKEY prodkey, userkey, props;
8001 DWORD size;
8002 LONG res;
8003 UINT r;
8004 REGSAM access = KEY_ALL_ACCESS;
8006 GetCurrentDirectoryA(MAX_PATH, path);
8007 lstrcatA(path, "\\");
8009 create_test_guid(prodcode, prod_squashed);
8010 MultiByteToWideChar(CP_ACP, 0, prodcode, -1, prodcodeW, MAX_PATH);
8011 squash_guid(prodcodeW, prod_squashedW);
8013 if (is_wow64)
8014 access |= KEY_WOW64_64KEY;
8016 r = MsiOpenDatabaseW(msifileW, MSIDBOPEN_CREATE, &hdb);
8017 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8019 r = MsiDatabaseCommit(hdb);
8020 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8022 r = set_summary_info(hdb);
8023 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8025 r = run_query(hdb,
8026 "CREATE TABLE `Directory` ( "
8027 "`Directory` CHAR(255) NOT NULL, "
8028 "`Directory_Parent` CHAR(255), "
8029 "`DefaultDir` CHAR(255) NOT NULL "
8030 "PRIMARY KEY `Directory`)");
8031 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8033 create_property_table(hdb);
8035 sprintf(query, "'ProductCode', '%s'", prodcode);
8036 r = add_property_entry(hdb, query);
8038 r = MsiDatabaseCommit(hdb);
8039 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8041 MsiCloseHandle(hdb);
8043 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
8044 lstrcatA(keypath, prod_squashed);
8046 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
8047 if (res == ERROR_ACCESS_DENIED)
8049 skip("Not enough rights to perform tests\n");
8050 DeleteFileA(msifile);
8051 return;
8053 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8055 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
8056 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
8057 lstrcatA(keypath, prod_squashed);
8059 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &userkey, NULL);
8060 if (res == ERROR_ACCESS_DENIED)
8062 skip("Not enough rights to perform tests\n");
8063 RegDeleteKeyA(prodkey, "");
8064 RegCloseKey(prodkey);
8065 return;
8067 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8069 res = RegCreateKeyExA(userkey, "InstallProperties", 0, NULL, 0, access, NULL, &props, NULL);
8070 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8072 lstrcpyA(val, path);
8073 lstrcatA(val, "\\");
8074 lstrcatA(val, msifile);
8075 res = RegSetValueExA(props, "LocalPackage", 0, REG_SZ,
8076 (const BYTE *)val, lstrlenA(val) + 1);
8077 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8079 hprod = 0xdeadbeef;
8080 r = MsiOpenProductA(prodcode, &hprod);
8081 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8082 ok(hprod != 0 && hprod != 0xdeadbeef, "Expected a valid product handle\n");
8084 /* hProduct is invalid */
8085 size = MAX_PATH;
8086 lstrcpyA(val, "apple");
8087 r = MsiGetProductPropertyA(0xdeadbeef, "ProductCode", val, &size);
8088 ok(r == ERROR_INVALID_HANDLE,
8089 "Expected ERROR_INVALID_HANDLE, got %d\n", r);
8090 ok(!lstrcmpA(val, "apple"),
8091 "Expected val to be unchanged, got \"%s\"\n", val);
8092 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
8094 size = MAX_PATH;
8095 lstrcpyW(valW, appleW);
8096 r = MsiGetProductPropertyW(0xdeadbeef, prodcode_propW, valW, &size);
8097 ok(r == ERROR_INVALID_HANDLE,
8098 "Expected ERROR_INVALID_HANDLE, got %d\n", r);
8099 ok(!lstrcmpW(valW, appleW),
8100 "Expected val to be unchanged, got %s\n", wine_dbgstr_w(valW));
8101 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
8103 /* szProperty is NULL */
8104 size = MAX_PATH;
8105 lstrcpyA(val, "apple");
8106 r = MsiGetProductPropertyA(hprod, NULL, val, &size);
8107 ok(r == ERROR_INVALID_PARAMETER,
8108 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
8109 ok(!lstrcmpA(val, "apple"),
8110 "Expected val to be unchanged, got \"%s\"\n", val);
8111 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
8113 size = MAX_PATH;
8114 lstrcpyW(valW, appleW);
8115 r = MsiGetProductPropertyW(hprod, NULL, valW, &size);
8116 ok(r == ERROR_INVALID_PARAMETER,
8117 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
8118 ok(!lstrcmpW(valW, appleW),
8119 "Expected val to be unchanged, got %s\n", wine_dbgstr_w(valW));
8120 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
8122 /* szProperty is empty */
8123 size = MAX_PATH;
8124 lstrcpyA(val, "apple");
8125 r = MsiGetProductPropertyA(hprod, "", val, &size);
8126 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8127 ok(!lstrcmpA(val, ""), "Expected \"\", got \"%s\"\n", val);
8128 ok(size == 0, "Expected 0, got %d\n", size);
8130 size = MAX_PATH;
8131 lstrcpyW(valW, appleW);
8132 r = MsiGetProductPropertyW(hprod, emptyW, valW, &size);
8133 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8134 ok(*valW == 0, "Expected \"\", got %s\n", wine_dbgstr_w(valW));
8135 ok(size == 0, "Expected 0, got %d\n", size);
8137 /* get the property */
8138 size = MAX_PATH;
8139 lstrcpyA(val, "apple");
8140 r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
8141 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8142 ok(!lstrcmpA(val, prodcode),
8143 "Expected \"%s\", got \"%s\"\n", prodcode, val);
8144 ok(size == lstrlenA(prodcode),
8145 "Expected %d, got %d\n", lstrlenA(prodcode), size);
8147 size = MAX_PATH;
8148 lstrcpyW(valW, appleW);
8149 r = MsiGetProductPropertyW(hprod, prodcode_propW, valW, &size);
8150 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8151 ok(!lstrcmpW(valW, prodcodeW),
8152 "Expected %s, got %s\n", wine_dbgstr_w(prodcodeW), wine_dbgstr_w(valW));
8153 ok(size == lstrlenW(prodcodeW),
8154 "Expected %d, got %d\n", lstrlenW(prodcodeW), size);
8156 /* lpValueBuf is NULL */
8157 size = MAX_PATH;
8158 r = MsiGetProductPropertyA(hprod, "ProductCode", NULL, &size);
8159 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8160 ok(size == lstrlenA(prodcode),
8161 "Expected %d, got %d\n", lstrlenA(prodcode), size);
8163 size = MAX_PATH;
8164 r = MsiGetProductPropertyW(hprod, prodcode_propW, NULL, &size);
8165 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8166 ok(size == lstrlenW(prodcodeW),
8167 "Expected %d, got %d\n", lstrlenW(prodcodeW), size);
8169 /* pcchValueBuf is NULL */
8170 lstrcpyA(val, "apple");
8171 r = MsiGetProductPropertyA(hprod, "ProductCode", val, NULL);
8172 ok(r == ERROR_INVALID_PARAMETER,
8173 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
8174 ok(!lstrcmpA(val, "apple"),
8175 "Expected val to be unchanged, got \"%s\"\n", val);
8176 ok(size == lstrlenA(prodcode),
8177 "Expected %d, got %d\n", lstrlenA(prodcode), size);
8179 lstrcpyW(valW, appleW);
8180 r = MsiGetProductPropertyW(hprod, prodcode_propW, valW, NULL);
8181 ok(r == ERROR_INVALID_PARAMETER,
8182 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
8183 ok(!lstrcmpW(valW, appleW),
8184 "Expected val to be unchanged, got %s\n", wine_dbgstr_w(valW));
8185 ok(size == lstrlenW(prodcodeW),
8186 "Expected %d, got %d\n", lstrlenW(prodcodeW), size);
8188 /* pcchValueBuf is too small */
8189 size = 4;
8190 lstrcpyA(val, "apple");
8191 r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
8192 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
8193 ok(!strncmp(val, prodcode, 3),
8194 "Expected first 3 chars of \"%s\", got \"%s\"\n", prodcode, val);
8195 ok(size == lstrlenA(prodcode),
8196 "Expected %d, got %d\n", lstrlenA(prodcode), size);
8198 size = 4;
8199 lstrcpyW(valW, appleW);
8200 r = MsiGetProductPropertyW(hprod, prodcode_propW, valW, &size);
8201 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
8202 ok(!memcmp(valW, prodcodeW, 3 * sizeof(WCHAR)),
8203 "Expected first 3 chars of %s, got %s\n", wine_dbgstr_w(prodcodeW), wine_dbgstr_w(valW));
8204 ok(size == lstrlenW(prodcodeW),
8205 "Expected %d, got %d\n", lstrlenW(prodcodeW), size);
8207 /* pcchValueBuf does not leave room for NULL terminator */
8208 size = lstrlenA(prodcode);
8209 lstrcpyA(val, "apple");
8210 r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
8211 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
8212 ok(!strncmp(val, prodcode, lstrlenA(prodcode) - 1),
8213 "Expected first 37 chars of \"%s\", got \"%s\"\n", prodcode, val);
8214 ok(size == lstrlenA(prodcode),
8215 "Expected %d, got %d\n", lstrlenA(prodcode), size);
8217 size = lstrlenW(prodcodeW);
8218 lstrcpyW(valW, appleW);
8219 r = MsiGetProductPropertyW(hprod, prodcode_propW, valW, &size);
8220 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
8221 ok(!memcmp(valW, prodcodeW, lstrlenW(prodcodeW) - 1),
8222 "Expected first 37 chars of %s, got %s\n", wine_dbgstr_w(prodcodeW), wine_dbgstr_w(valW));
8223 ok(size == lstrlenW(prodcodeW),
8224 "Expected %d, got %d\n", lstrlenW(prodcodeW), size);
8226 /* pcchValueBuf has enough room for NULL terminator */
8227 size = lstrlenA(prodcode) + 1;
8228 lstrcpyA(val, "apple");
8229 r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
8230 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8231 ok(!lstrcmpA(val, prodcode),
8232 "Expected \"%s\", got \"%s\"\n", prodcode, val);
8233 ok(size == lstrlenA(prodcode),
8234 "Expected %d, got %d\n", lstrlenA(prodcode), size);
8236 size = lstrlenW(prodcodeW) + 1;
8237 lstrcpyW(valW, appleW);
8238 r = MsiGetProductPropertyW(hprod, prodcode_propW, valW, &size);
8239 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8240 ok(!lstrcmpW(valW, prodcodeW),
8241 "Expected %s, got %s\n", wine_dbgstr_w(prodcodeW), wine_dbgstr_w(valW));
8242 ok(size == lstrlenW(prodcodeW),
8243 "Expected %d, got %d\n", lstrlenW(prodcodeW), size);
8245 /* nonexistent property */
8246 size = MAX_PATH;
8247 lstrcpyA(val, "apple");
8248 r = MsiGetProductPropertyA(hprod, "IDontExist", val, &size);
8249 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8250 ok(!lstrcmpA(val, ""), "Expected \"\", got \"%s\"\n", val);
8251 ok(size == 0, "Expected 0, got %d\n", size);
8253 size = MAX_PATH;
8254 lstrcpyW(valW, appleW);
8255 r = MsiGetProductPropertyW(hprod, nonexistentW, valW, &size);
8256 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8257 ok(!lstrcmpW(valW, emptyW), "Expected \"\", got %s\n", wine_dbgstr_w(valW));
8258 ok(size == 0, "Expected 0, got %d\n", size);
8260 r = MsiSetPropertyA(hprod, "NewProperty", "value");
8261 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8263 /* non-product property set */
8264 size = MAX_PATH;
8265 lstrcpyA(val, "apple");
8266 r = MsiGetProductPropertyA(hprod, "NewProperty", val, &size);
8267 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8268 ok(!lstrcmpA(val, ""), "Expected \"\", got \"%s\"\n", val);
8269 ok(size == 0, "Expected 0, got %d\n", size);
8271 size = MAX_PATH;
8272 lstrcpyW(valW, appleW);
8273 r = MsiGetProductPropertyW(hprod, newpropW, valW, &size);
8274 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8275 ok(!lstrcmpW(valW, emptyW), "Expected \"\", got %s\n", wine_dbgstr_w(valW));
8276 ok(size == 0, "Expected 0, got %d\n", size);
8278 r = MsiSetPropertyA(hprod, "ProductCode", "value");
8279 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8281 /* non-product property that is also a product property set */
8282 size = MAX_PATH;
8283 lstrcpyA(val, "apple");
8284 r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
8285 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8286 ok(!lstrcmpA(val, prodcode),
8287 "Expected \"%s\", got \"%s\"\n", prodcode, val);
8288 ok(size == lstrlenA(prodcode),
8289 "Expected %d, got %d\n", lstrlenA(prodcode), size);
8291 size = MAX_PATH;
8292 lstrcpyW(valW, appleW);
8293 r = MsiGetProductPropertyW(hprod, prodcode_propW, valW, &size);
8294 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8295 ok(!lstrcmpW(valW, prodcodeW),
8296 "Expected %s, got %s\n", wine_dbgstr_w(prodcodeW), wine_dbgstr_w(valW));
8297 ok(size == lstrlenW(prodcodeW),
8298 "Expected %d, got %d\n", lstrlenW(prodcodeW), size);
8300 MsiCloseHandle(hprod);
8302 RegDeleteValueA(props, "LocalPackage");
8303 delete_key(props, "", access);
8304 RegCloseKey(props);
8305 delete_key(userkey, "", access);
8306 RegCloseKey(userkey);
8307 delete_key(prodkey, "", access);
8308 RegCloseKey(prodkey);
8309 DeleteFileA(msifile);
8312 static void test_MsiSetProperty(void)
8314 MSIHANDLE hpkg, hdb, hrec;
8315 CHAR buf[MAX_PATH];
8316 LPCSTR query;
8317 DWORD size;
8318 UINT r;
8320 r = package_from_db(create_package_db(), &hpkg);
8321 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
8323 skip("Not enough rights to perform tests\n");
8324 DeleteFileA(msifile);
8325 return;
8327 ok(r == ERROR_SUCCESS, "Expected a valid package %u\n", r);
8329 /* invalid hInstall */
8330 r = MsiSetPropertyA(0, "Prop", "Val");
8331 ok(r == ERROR_INVALID_HANDLE,
8332 "Expected ERROR_INVALID_HANDLE, got %d\n", r);
8334 /* invalid hInstall */
8335 r = MsiSetPropertyA(0xdeadbeef, "Prop", "Val");
8336 ok(r == ERROR_INVALID_HANDLE,
8337 "Expected ERROR_INVALID_HANDLE, got %d\n", r);
8339 /* szName is NULL */
8340 r = MsiSetPropertyA(hpkg, NULL, "Val");
8341 ok(r == ERROR_INVALID_PARAMETER,
8342 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
8344 /* both szName and szValue are NULL */
8345 r = MsiSetPropertyA(hpkg, NULL, NULL);
8346 ok(r == ERROR_INVALID_PARAMETER,
8347 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
8349 /* szName is empty */
8350 r = MsiSetPropertyA(hpkg, "", "Val");
8351 ok(r == ERROR_FUNCTION_FAILED,
8352 "Expected ERROR_FUNCTION_FAILED, got %d\n", r);
8354 /* szName is empty and szValue is NULL */
8355 r = MsiSetPropertyA(hpkg, "", NULL);
8356 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8358 /* set a property */
8359 r = MsiSetPropertyA(hpkg, "Prop", "Val");
8360 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8362 /* get the property */
8363 size = MAX_PATH;
8364 r = MsiGetPropertyA(hpkg, "Prop", buf, &size);
8365 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8366 ok(!lstrcmpA(buf, "Val"), "Expected \"Val\", got \"%s\"\n", buf);
8367 ok(size == 3, "Expected 3, got %d\n", size);
8369 /* update the property */
8370 r = MsiSetPropertyA(hpkg, "Prop", "Nuvo");
8371 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8373 /* get the property */
8374 size = MAX_PATH;
8375 r = MsiGetPropertyA(hpkg, "Prop", buf, &size);
8376 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8377 ok(!lstrcmpA(buf, "Nuvo"), "Expected \"Nuvo\", got \"%s\"\n", buf);
8378 ok(size == 4, "Expected 4, got %d\n", size);
8380 hdb = MsiGetActiveDatabase(hpkg);
8381 ok(hdb != 0, "Expected a valid database handle\n");
8383 /* set prop is not in the _Property table */
8384 query = "SELECT * FROM `_Property` WHERE `Property` = 'Prop'";
8385 r = do_query(hdb, query, &hrec);
8386 ok(r == ERROR_BAD_QUERY_SYNTAX,
8387 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
8389 /* set prop is not in the Property table */
8390 query = "SELECT * FROM `Property` WHERE `Property` = 'Prop'";
8391 r = do_query(hdb, query, &hrec);
8392 ok(r == ERROR_BAD_QUERY_SYNTAX,
8393 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
8395 MsiCloseHandle(hdb);
8397 /* szValue is an empty string */
8398 r = MsiSetPropertyA(hpkg, "Prop", "");
8399 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8401 /* try to get the property */
8402 size = MAX_PATH;
8403 r = MsiGetPropertyA(hpkg, "Prop", buf, &size);
8404 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8405 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
8406 ok(size == 0, "Expected 0, got %d\n", size);
8408 /* reset the property */
8409 r = MsiSetPropertyA(hpkg, "Prop", "BlueTap");
8410 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8412 /* delete the property */
8413 r = MsiSetPropertyA(hpkg, "Prop", NULL);
8414 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8416 /* try to get the property */
8417 size = MAX_PATH;
8418 r = MsiGetPropertyA(hpkg, "Prop", buf, &size);
8419 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8420 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
8421 ok(size == 0, "Expected 0, got %d\n", size);
8423 MsiCloseHandle(hpkg);
8424 DeleteFileA(msifile);
8427 static void test_MsiApplyMultiplePatches(void)
8429 UINT r, type = GetDriveTypeW(NULL);
8431 r = MsiApplyMultiplePatchesA(NULL, NULL, NULL);
8432 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
8434 r = MsiApplyMultiplePatchesA("", NULL, NULL);
8435 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
8437 r = MsiApplyMultiplePatchesA(";", NULL, NULL);
8438 if (type == DRIVE_FIXED)
8439 todo_wine ok(r == ERROR_PATH_NOT_FOUND, "Expected ERROR_PATH_NOT_FOUND, got %u\n", r);
8440 else
8441 ok(r == ERROR_INVALID_NAME, "Expected ERROR_INVALID_NAME, got %u\n", r);
8443 r = MsiApplyMultiplePatchesA(" ;", NULL, NULL);
8444 if (type == DRIVE_FIXED)
8445 todo_wine ok(r == ERROR_PATCH_PACKAGE_OPEN_FAILED, "Expected ERROR_PATCH_PACKAGE_OPEN_FAILED, got %u\n", r);
8446 else
8447 ok(r == ERROR_INVALID_NAME, "Expected ERROR_INVALID_NAME, got %u\n", r);
8449 r = MsiApplyMultiplePatchesA(";;", NULL, NULL);
8450 if (type == DRIVE_FIXED)
8451 todo_wine ok(r == ERROR_PATH_NOT_FOUND, "Expected ERROR_PATH_NOT_FOUND, got %u\n", r);
8452 else
8453 ok(r == ERROR_INVALID_NAME, "Expected ERROR_INVALID_NAME, got %u\n", r);
8455 r = MsiApplyMultiplePatchesA("nosuchpatchpackage;", NULL, NULL);
8456 todo_wine ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r);
8458 r = MsiApplyMultiplePatchesA(";nosuchpatchpackage", NULL, NULL);
8459 if (type == DRIVE_FIXED)
8460 todo_wine ok(r == ERROR_PATH_NOT_FOUND, "Expected ERROR_PATH_NOT_FOUND, got %u\n", r);
8461 else
8462 ok(r == ERROR_INVALID_NAME, "Expected ERROR_INVALID_NAME, got %u\n", r);
8464 r = MsiApplyMultiplePatchesA("nosuchpatchpackage;nosuchpatchpackage", NULL, NULL);
8465 todo_wine ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r);
8467 r = MsiApplyMultiplePatchesA(" nosuchpatchpackage ; nosuchpatchpackage ", NULL, NULL);
8468 todo_wine ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r);
8471 static void test_MsiApplyPatch(void)
8473 UINT r;
8475 r = MsiApplyPatchA(NULL, NULL, INSTALLTYPE_DEFAULT, NULL);
8476 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
8478 r = MsiApplyPatchA("", NULL, INSTALLTYPE_DEFAULT, NULL);
8479 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
8482 static void test_MsiEnumComponentCosts(void)
8484 MSIHANDLE hdb, hpkg;
8485 char package[12], drive[3];
8486 DWORD len;
8487 UINT r;
8488 int cost, temp;
8490 hdb = create_package_db();
8491 ok( hdb, "failed to create database\n" );
8493 create_property_table( hdb );
8494 add_property_entry( hdb, "'ProductCode', '{379B1C47-40C1-42FA-A9BB-BEBB6F1B0172}'" );
8495 add_property_entry( hdb, "'MSIFASTINSTALL', '1'" );
8496 add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'" );
8498 create_media_table( hdb );
8499 add_media_entry( hdb, "'1', '2', 'cabinet', '', '', ''");
8501 create_file_table( hdb );
8502 add_file_entry( hdb, "'one.txt', 'one', 'one.txt', 4096, '', '', 8192, 1" );
8504 create_component_table( hdb );
8505 add_component_entry( hdb, "'one', '{B2F86B9D-8447-4BC5-8883-750C45AA31CA}', 'TARGETDIR', 0, '', 'one.txt'" );
8506 add_component_entry( hdb, "'two', '{62A09F6E-0B74-4829-BDB7-CAB66F42CCE8}', 'TARGETDIR', 0, '', ''" );
8508 create_feature_table( hdb );
8509 add_feature_entry( hdb, "'one', '', '', '', 0, 1, '', 0" );
8510 add_feature_entry( hdb, "'two', '', '', '', 0, 1, '', 0" );
8512 create_feature_components_table( hdb );
8513 add_feature_components_entry( hdb, "'one', 'one'" );
8514 add_feature_components_entry( hdb, "'two', 'two'" );
8516 create_install_execute_sequence_table( hdb );
8517 add_install_execute_sequence_entry( hdb, "'CostInitialize', '', '800'" );
8518 add_install_execute_sequence_entry( hdb, "'FileCost', '', '900'" );
8519 add_install_execute_sequence_entry( hdb, "'CostFinalize', '', '1000'" );
8520 add_install_execute_sequence_entry( hdb, "'InstallValidate', '', '1100'" );
8522 r = MsiDatabaseCommit( hdb );
8523 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
8525 sprintf( package, "#%u", hdb );
8526 r = MsiOpenPackageA( package, &hpkg );
8527 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
8529 skip("Not enough rights to perform tests\n");
8530 goto error;
8532 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
8534 r = MsiEnumComponentCostsA( 0, NULL, 0, INSTALLSTATE_UNKNOWN, NULL, NULL, NULL, NULL );
8535 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8537 r = MsiEnumComponentCostsA( hpkg, NULL, 0, INSTALLSTATE_UNKNOWN, NULL, NULL, NULL, NULL );
8538 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8540 r = MsiEnumComponentCostsA( hpkg, NULL, 0, INSTALLSTATE_UNKNOWN, NULL, NULL, NULL, NULL );
8541 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8543 r = MsiEnumComponentCostsA( hpkg, "", 0, INSTALLSTATE_UNKNOWN, NULL, NULL, NULL, NULL );
8544 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8546 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_UNKNOWN, NULL, NULL, NULL, NULL );
8547 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8549 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, NULL, NULL, NULL, NULL );
8550 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8552 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, NULL, NULL, NULL );
8553 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8555 len = sizeof(drive);
8556 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, NULL, NULL );
8557 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8559 len = sizeof(drive);
8560 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, NULL );
8561 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8563 len = sizeof(drive);
8564 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
8565 todo_wine ok( r == ERROR_INVALID_HANDLE_STATE, "Expected ERROR_INVALID_HANDLE_STATE, got %u\n", r );
8567 len = sizeof(drive);
8568 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, NULL, &len, &cost, &temp );
8569 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8571 MsiSetInternalUI( INSTALLUILEVEL_NONE, NULL );
8573 r = MsiDoActionA( hpkg, "CostInitialize" );
8574 ok( r == ERROR_SUCCESS, "CostInitialize failed %u\n", r );
8576 r = MsiDoActionA( hpkg, "FileCost" );
8577 ok( r == ERROR_SUCCESS, "FileCost failed %u\n", r );
8579 len = sizeof(drive);
8580 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
8581 ok( r == ERROR_FUNCTION_NOT_CALLED, "Expected ERROR_FUNCTION_NOT_CALLED, got %u\n", r );
8583 r = MsiDoActionA( hpkg, "CostFinalize" );
8584 ok( r == ERROR_SUCCESS, "CostFinalize failed %u\n", r );
8586 /* contrary to what msdn says InstallValidate must be called too */
8587 len = sizeof(drive);
8588 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
8589 todo_wine ok( r == ERROR_FUNCTION_NOT_CALLED, "Expected ERROR_FUNCTION_NOT_CALLED, got %u\n", r );
8591 r = MsiDoActionA( hpkg, "InstallValidate" );
8592 ok( r == ERROR_SUCCESS, "InstallValidate failed %u\n", r );
8594 len = 0;
8595 r = MsiEnumComponentCostsA( hpkg, "three", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
8596 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %u\n", r );
8598 len = 0;
8599 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
8600 ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %u\n", r );
8601 ok( len == 2, "expected len == 2, got %u\n", len );
8603 len = 2;
8604 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
8605 ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %u\n", r );
8606 ok( len == 2, "expected len == 2, got %u\n", len );
8608 len = 2;
8609 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_UNKNOWN, drive, &len, &cost, &temp );
8610 ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %u\n", r );
8611 ok( len == 2, "expected len == 2, got %u\n", len );
8613 /* install state doesn't seem to matter */
8614 len = sizeof(drive);
8615 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_UNKNOWN, drive, &len, &cost, &temp );
8616 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
8618 len = sizeof(drive);
8619 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_ABSENT, drive, &len, &cost, &temp );
8620 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
8622 len = sizeof(drive);
8623 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_SOURCE, drive, &len, &cost, &temp );
8624 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
8626 len = sizeof(drive);
8627 drive[0] = 0;
8628 cost = temp = 0xdead;
8629 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
8630 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
8631 ok( len == 2, "expected len == 2, got %u\n", len );
8632 ok( drive[0], "expected a drive\n" );
8633 ok( cost && cost != 0xdead, "expected cost > 0, got %d\n", cost );
8634 ok( !temp, "expected temp == 0, got %d\n", temp );
8636 len = sizeof(drive);
8637 drive[0] = 0;
8638 cost = temp = 0xdead;
8639 r = MsiEnumComponentCostsA( hpkg, "two", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
8640 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
8641 ok( len == 2, "expected len == 2, got %u\n", len );
8642 ok( drive[0], "expected a drive\n" );
8643 ok( !cost, "expected cost == 0, got %d\n", cost );
8644 ok( !temp, "expected temp == 0, got %d\n", temp );
8646 len = sizeof(drive);
8647 drive[0] = 0;
8648 cost = temp = 0xdead;
8649 r = MsiEnumComponentCostsA( hpkg, "", 0, INSTALLSTATE_UNKNOWN, drive, &len, &cost, &temp );
8650 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
8651 ok( len == 2, "expected len == 2, got %u\n", len );
8652 ok( drive[0], "expected a drive\n" );
8653 ok( !cost, "expected cost == 0, got %d\n", cost );
8654 ok( temp && temp != 0xdead, "expected temp > 0, got %d\n", temp );
8656 /* increased index */
8657 len = sizeof(drive);
8658 r = MsiEnumComponentCostsA( hpkg, "one", 1, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
8659 ok( r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %u\n", r );
8661 len = sizeof(drive);
8662 r = MsiEnumComponentCostsA( hpkg, "", 1, INSTALLSTATE_UNKNOWN, drive, &len, &cost, &temp );
8663 ok( r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %u\n", r );
8665 MsiCloseHandle( hpkg );
8666 error:
8667 MsiCloseHandle( hdb );
8668 DeleteFileA( msifile );
8671 static void test_MsiDatabaseCommit(void)
8673 UINT r;
8674 MSIHANDLE hdb, hpkg = 0;
8675 char buf[32], package[12];
8676 DWORD sz;
8678 hdb = create_package_db();
8679 ok( hdb, "failed to create database\n" );
8681 create_property_table( hdb );
8683 sprintf( package, "#%u", hdb );
8684 r = MsiOpenPackageA( package, &hpkg );
8685 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
8687 skip("Not enough rights to perform tests\n");
8688 goto error;
8690 ok( r == ERROR_SUCCESS, "got %u\n", r );
8692 r = MsiSetPropertyA( hpkg, "PROP", "value" );
8693 ok( r == ERROR_SUCCESS, "got %u\n", r );
8695 buf[0] = 0;
8696 sz = sizeof(buf);
8697 r = MsiGetPropertyA( hpkg, "PROP", buf, &sz );
8698 ok( r == ERROR_SUCCESS, "MsiGetPropertyA returned %u\n", r );
8699 ok( !lstrcmpA( buf, "value" ), "got \"%s\"\n", buf );
8701 r = MsiDatabaseCommit( hdb );
8702 ok( r == ERROR_SUCCESS, "MsiDatabaseCommit returned %u\n", r );
8704 buf[0] = 0;
8705 sz = sizeof(buf);
8706 r = MsiGetPropertyA( hpkg, "PROP", buf, &sz );
8707 ok( r == ERROR_SUCCESS, "MsiGetPropertyA returned %u\n", r );
8708 ok( !lstrcmpA( buf, "value" ), "got \"%s\"\n", buf );
8710 MsiCloseHandle( hpkg );
8711 error:
8712 MsiCloseHandle( hdb );
8713 DeleteFileA( msifile );
8716 static int externalui_ran;
8718 static INT CALLBACK externalui_callback(void *context, UINT message_type, LPCSTR message)
8720 externalui_ran = 1;
8721 ok(message_type == INSTALLMESSAGE_USER, "expected INSTALLMESSAGE_USER, got %08x\n", message_type);
8722 return 0;
8725 static int externalui_record_ran;
8727 static INT CALLBACK externalui_record_callback(void *context, UINT message_type, MSIHANDLE hrecord)
8729 INT retval = context ? *((INT *)context) : 0;
8730 UINT r;
8731 externalui_record_ran = 1;
8732 ok(message_type == INSTALLMESSAGE_USER, "expected INSTALLMESSAGE_USER, got %08x\n", message_type);
8733 r = MsiRecordGetFieldCount(hrecord);
8734 ok(r == 1, "expected 1, got %u\n", r);
8735 r = MsiRecordGetInteger(hrecord, 1);
8736 ok(r == 12345, "expected 12345, got %u\n", r);
8737 return retval;
8740 static void test_externalui(void)
8742 /* test that external UI handlers work correctly */
8744 INSTALLUI_HANDLERA prev;
8745 INSTALLUI_HANDLER_RECORD prev_record;
8746 MSIHANDLE hpkg, hrecord;
8747 UINT r;
8748 INT retval = 0;
8750 prev = MsiSetExternalUIA(externalui_callback, INSTALLLOGMODE_USER, NULL);
8752 r = package_from_db(create_package_db(), &hpkg);
8753 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
8755 skip("Not enough rights to perform tests\n");
8756 DeleteFileA(msifile);
8757 return;
8759 ok(r == ERROR_SUCCESS, "Expected a valid package %u\n", r);
8761 hrecord = MsiCreateRecord(1);
8762 ok(hrecord, "Expected a valid record\n");
8763 r = MsiRecordSetStringA(hrecord, 0, "test message [1]");
8764 ok(r == ERROR_SUCCESS, "MsiSetString failed %u\n", r);
8765 r = MsiRecordSetInteger(hrecord, 1, 12345);
8766 ok(r == ERROR_SUCCESS, "MsiSetInteger failed %u\n", r);
8768 externalui_ran = 0;
8769 r = MsiProcessMessage(hpkg, INSTALLMESSAGE_USER, hrecord);
8770 ok(r == 0, "expected 0, got %u\n", r);
8771 ok(externalui_ran == 1, "external UI callback did not run\n");
8773 prev = MsiSetExternalUIA(prev, 0, NULL);
8774 ok(prev == externalui_callback, "wrong callback function %p\n", prev);
8775 r = MsiSetExternalUIRecord(externalui_record_callback, INSTALLLOGMODE_USER, &retval, &prev_record);
8776 ok(r == ERROR_SUCCESS, "MsiSetExternalUIRecord failed %u\n", r);
8778 externalui_ran = externalui_record_ran = 0;
8779 r = MsiProcessMessage(hpkg, INSTALLMESSAGE_USER, hrecord);
8780 ok(r == 0, "expected 0, got %u\n", r);
8781 ok(externalui_ran == 0, "external UI callback should not have run\n");
8782 ok(externalui_record_ran == 1, "external UI record callback did not run\n");
8784 MsiSetExternalUIA(externalui_callback, INSTALLLOGMODE_USER, NULL);
8786 externalui_ran = externalui_record_ran = 0;
8787 r = MsiProcessMessage(hpkg, INSTALLMESSAGE_USER, hrecord);
8788 ok(r == 0, "expected 0, got %u\n", r);
8789 ok(externalui_ran == 1, "external UI callback did not run\n");
8790 ok(externalui_record_ran == 1, "external UI record callback did not run\n");
8792 retval = 1;
8793 externalui_ran = externalui_record_ran = 0;
8794 r = MsiProcessMessage(hpkg, INSTALLMESSAGE_USER, hrecord);
8795 ok(r == 1, "expected 1, got %u\n", r);
8796 ok(externalui_ran == 0, "external UI callback should not have run\n");
8797 ok(externalui_record_ran == 1, "external UI record callback did not run\n");
8799 /* filter and context should be kept separately */
8800 r = MsiSetExternalUIRecord(externalui_record_callback, INSTALLLOGMODE_ERROR, &retval, &prev_record);
8801 ok(r == ERROR_SUCCESS, "MsiSetExternalUIRecord failed %u\n", r);
8803 externalui_ran = externalui_record_ran = 0;
8804 r = MsiProcessMessage(hpkg, INSTALLMESSAGE_USER, hrecord);
8805 ok(r == 0, "expected 0, got %u\n", r);
8806 ok(externalui_ran == 1, "external UI callback did not run\n");
8807 ok(externalui_record_ran == 0, "external UI record callback should not have run\n");
8809 MsiCloseHandle(hpkg);
8810 DeleteFileA(msifile);
8813 struct externalui_message {
8814 UINT message;
8815 int field_count;
8816 char field[4][100];
8817 int match[4]; /* should we test for a match */
8818 int optional;
8821 static struct externalui_message *sequence;
8822 static int sequence_count, sequence_size;
8824 static void add_message(const struct externalui_message *msg)
8826 if (!sequence)
8828 sequence_size = 10;
8829 sequence = HeapAlloc(GetProcessHeap(), 0, sequence_size * sizeof(*sequence));
8831 if (sequence_count == sequence_size)
8833 sequence_size *= 2;
8834 sequence = HeapReAlloc(GetProcessHeap(), 0, sequence, sequence_size * sizeof(*sequence));
8837 assert(sequence);
8839 sequence[sequence_count++] = *msg;
8842 static void flush_sequence(void)
8844 HeapFree(GetProcessHeap(), 0, sequence);
8845 sequence = NULL;
8846 sequence_count = sequence_size = 0;
8849 static void ok_sequence_(const struct externalui_message *expected, const char *context, BOOL todo,
8850 const char *file, int line)
8852 static const struct externalui_message end_of_sequence = {0};
8853 const struct externalui_message *actual;
8854 int failcount = 0;
8855 int i;
8857 add_message(&end_of_sequence);
8859 actual = sequence;
8861 while (expected->message && actual->message)
8863 if (expected->message == actual->message)
8865 if (expected->field_count < actual->field_count)
8867 todo_wine_if (todo)
8868 ok_(file, line) (FALSE, "%s: in msg 0x%08x expecting field count %d got %d\n",
8869 context, expected->message, expected->field_count, actual->field_count);
8870 failcount++;
8873 for (i = 0; i <= actual->field_count; i++)
8875 if (expected->match[i] && strcmp(expected->field[i], actual->field[i]))
8877 todo_wine_if (todo)
8878 ok_(file, line) (FALSE, "%s: in msg 0x%08x field %d: expected \"%s\", got \"%s\"\n",
8879 context, expected->message, i, expected->field[i], actual->field[i]);
8880 failcount++;
8884 expected++;
8885 actual++;
8887 else if (expected->optional)
8889 expected++;
8891 else
8893 todo_wine_if (todo)
8894 ok_(file, line) (FALSE, "%s: the msg 0x%08x was expected, but got msg 0x%08x instead\n",
8895 context, expected->message, actual->message);
8896 failcount++;
8897 if (todo)
8898 goto done;
8899 expected++;
8900 actual++;
8904 if (expected->message || actual->message)
8906 todo_wine_if (todo)
8907 ok_(file, line) (FALSE, "%s: the msg sequence is not complete: expected %08x - actual %08x\n",
8908 context, expected->message, actual->message);
8909 failcount++;
8912 if(todo && !failcount) /* succeeded yet marked todo */
8914 todo_wine
8915 ok_(file, line)(TRUE, "%s: marked \"todo_wine\" but succeeds\n", context);
8918 done:
8919 flush_sequence();
8922 #define ok_sequence(exp, contx, todo) \
8923 ok_sequence_((exp), (contx), (todo), __FILE__, __LINE__)
8925 /* don't use PROGRESS, which is timing-dependent,
8926 * or SHOWDIALOG, which due to a bug causes a hang on XP */
8927 static const INSTALLLOGMODE MSITEST_INSTALLLOGMODE =
8928 INSTALLLOGMODE_FATALEXIT |
8929 INSTALLLOGMODE_ERROR |
8930 INSTALLLOGMODE_WARNING |
8931 INSTALLLOGMODE_USER |
8932 INSTALLLOGMODE_INFO |
8933 INSTALLLOGMODE_FILESINUSE |
8934 INSTALLLOGMODE_RESOLVESOURCE |
8935 INSTALLLOGMODE_OUTOFDISKSPACE |
8936 INSTALLLOGMODE_ACTIONSTART |
8937 INSTALLLOGMODE_ACTIONDATA |
8938 INSTALLLOGMODE_COMMONDATA |
8939 INSTALLLOGMODE_INITIALIZE |
8940 INSTALLLOGMODE_TERMINATE |
8941 INSTALLLOGMODE_RMFILESINUSE |
8942 INSTALLLOGMODE_INSTALLSTART |
8943 INSTALLLOGMODE_INSTALLEND;
8945 static const struct externalui_message empty_sequence[] = {
8949 static const struct externalui_message openpackage_nonexistent_sequence[] = {
8950 {INSTALLMESSAGE_INITIALIZE, -1},
8951 {INSTALLMESSAGE_TERMINATE, -1},
8955 static const struct externalui_message openpackage_sequence[] = {
8956 {INSTALLMESSAGE_INITIALIZE, -1},
8957 {INSTALLMESSAGE_COMMONDATA, 3, {"", "0", "1033", "1252"}, {1, 1, 1, 1}},
8958 {INSTALLMESSAGE_INFO|MB_ICONHAND, 0, {""}, {0}},
8959 {INSTALLMESSAGE_COMMONDATA, 3, {"", "0", "1033", "1252"}, {0, 1, 1, 1}},
8960 {INSTALLMESSAGE_COMMONDATA, 3, {"", "1", "", ""}, {0, 1, 0, 0}},
8964 static const struct externalui_message processmessage_info_sequence[] = {
8965 {INSTALLMESSAGE_INFO, 3, {"zero", "one", "two", "three"}, {1, 1, 1, 1}},
8969 static const struct externalui_message processmessage_actionstart_sequence[] = {
8970 {INSTALLMESSAGE_ACTIONSTART, 3, {"", "name", "description", "template"}, {0, 1, 1, 1}},
8974 static const struct externalui_message processmessage_actiondata_sequence[] = {
8975 {INSTALLMESSAGE_ACTIONDATA, 3, {"{{name: }}template", "cherry", "banana", "guava"}, {1, 1, 1, 1}},
8979 static const struct externalui_message processmessage_error_sequence[] = {
8980 {INSTALLMESSAGE_USER, 3, {"", "1311", "banana", "guava"}, {0, 1, 1, 1}},
8984 static const struct externalui_message processmessage_internal_error_sequence[] = {
8985 {INSTALLMESSAGE_INFO, 3, {"DEBUG: Error [1]: Action not found: [2]", "2726", "banana", "guava"}, {1, 1, 1, 1}},
8986 {INSTALLMESSAGE_USER, 3, {"internal error", "2726", "banana", "guava"}, {1, 1, 1, 1}},
8990 static const struct externalui_message processmessage_error_format_sequence[] = {
8991 {INSTALLMESSAGE_USER, 3, {"", "2726", "banana", "guava"}, {0, 1, 1, 1}},
8995 static const struct externalui_message doaction_costinitialize_sequence[] = {
8996 {INSTALLMESSAGE_ACTIONSTART, 3, {"", "CostInitialize", "cost description", "cost template"}, {0, 1, 1, 1}},
8997 {INSTALLMESSAGE_INFO, 2, {"", "CostInitialize", ""}, {0, 1, 1}},
8998 {INSTALLMESSAGE_INFO, 2, {"", "CostInitialize", "1"}, {0, 1, 1}},
9002 static const struct externalui_message doaction_custom_sequence[] = {
9003 {INSTALLMESSAGE_ACTIONSTART, 3, {"", "custom", "description", "template"}, {0, 1, 1, 1}},
9004 {INSTALLMESSAGE_INFO, 2, {"", "custom", "1"}, {0, 1, 1}},
9005 {INSTALLMESSAGE_INFO, 2, {"", "custom", "0"}, {0, 1, 1}},
9009 static const struct externalui_message doaction_custom_fullui_sequence[] = {
9010 {INSTALLMESSAGE_ACTIONSTART, 3, {"", "custom", "", ""}, {0, 1, 1, 1}},
9011 {INSTALLMESSAGE_INFO, 2, {"", "custom", ""}, {0, 1, 1}},
9012 {INSTALLMESSAGE_SHOWDIALOG, 0, {"custom"}, {1}},
9013 {INSTALLMESSAGE_INFO, 2, {"", "custom", "1"}, {0, 1, 1}},
9017 static const struct externalui_message doaction_custom_cancel_sequence[] = {
9018 {INSTALLMESSAGE_ACTIONSTART, 3, {"", "custom", "", ""}, {0, 1, 1, 1}},
9022 static const struct externalui_message doaction_dialog_nonexistent_sequence[] = {
9023 {INSTALLMESSAGE_ACTIONSTART, 3, {"", "custom", "", ""}, {0, 1, 1, 1}},
9024 {INSTALLMESSAGE_INFO, 2, {"", "custom", "1"}, {0, 1, 1}},
9025 {INSTALLMESSAGE_SHOWDIALOG, 0, {"custom"}, {1}},
9026 {INSTALLMESSAGE_INFO, 2, {"DEBUG: Error [1]: Action not found: [2]", "2726", "custom"}, {1, 1, 1}},
9027 {INSTALLMESSAGE_INFO, 2, {"", "2726", "custom"}, {0, 1, 1}},
9028 {INSTALLMESSAGE_INFO, 2, {"", "custom", "0"}, {0, 1, 1}},
9032 static const struct externalui_message doaction_dialog_sequence[] = {
9033 {INSTALLMESSAGE_ACTIONSTART, 3, {"", "dialog", "", ""}, {0, 1, 1, 1}},
9034 {INSTALLMESSAGE_INFO, 2, {"", "dialog", "0"}, {0, 1, 1}},
9035 {INSTALLMESSAGE_SHOWDIALOG, 0, {"dialog"}, {1}},
9036 {INSTALLMESSAGE_ACTIONSTART, 2, {"", "dialog", "Dialog created"}, {0, 1, 1}},
9037 {INSTALLMESSAGE_INFO, 2, {"", "dialog", "1"}, {0, 1, 1}},
9041 static const struct externalui_message doaction_dialog_error_sequence[] = {
9042 {INSTALLMESSAGE_ACTIONSTART, 3, {"", "error", "", ""}, {0, 1, 1, 1}},
9043 {INSTALLMESSAGE_INFO, 2, {"", "error", "1"}, {0, 1, 1}},
9044 {INSTALLMESSAGE_SHOWDIALOG, 0, {"error"}, {1}},
9048 static const struct externalui_message doaction_dialog_3_sequence[] = {
9049 {INSTALLMESSAGE_ACTIONSTART, 3, {"", "dialog", "", ""}, {0, 1, 1, 1}},
9050 {INSTALLMESSAGE_INFO, 2, {"", "dialog", "0"}, {0, 1, 1}},
9051 {INSTALLMESSAGE_SHOWDIALOG, 0, {"dialog"}, {1}},
9052 {INSTALLMESSAGE_INFO, 2, {"", "dialog", "3"}, {0, 1, 1}},
9056 static const struct externalui_message doaction_dialog_12345_sequence[] = {
9057 {INSTALLMESSAGE_ACTIONSTART, 3, {"", "dialog", "", ""}, {0, 1, 1, 1}},
9058 {INSTALLMESSAGE_INFO, 2, {"", "dialog", "3"}, {0, 1, 1}},
9059 {INSTALLMESSAGE_SHOWDIALOG, 0, {"dialog"}, {1}},
9060 {INSTALLMESSAGE_INFO, 2, {"", "dialog", "12345"}, {0, 1, 1}},
9064 static const struct externalui_message closehandle_sequence[] = {
9065 {INSTALLMESSAGE_TERMINATE, -1},
9069 static INT CALLBACK externalui_message_string_callback(void *context, UINT message, LPCSTR string)
9071 INT retval = context ? *((INT *)context) : 0;
9072 struct externalui_message msg;
9074 msg.message = message;
9075 msg.field_count = 0;
9076 strcpy(msg.field[0], string);
9077 add_message(&msg);
9079 return retval;
9082 static INT CALLBACK externalui_message_callback(void *context, UINT message, MSIHANDLE hrecord)
9084 INT retval = context ? *((INT *)context) : 0;
9085 struct externalui_message msg;
9086 char buffer[256];
9087 DWORD length;
9088 UINT r;
9089 int i;
9091 msg.message = message;
9092 if (message == INSTALLMESSAGE_TERMINATE)
9094 /* trying to access the record seems to hang on some versions of Windows */
9095 msg.field_count = -1;
9096 add_message(&msg);
9097 return 1;
9099 msg.field_count = MsiRecordGetFieldCount(hrecord);
9100 for (i = 0; i <= msg.field_count; i++)
9102 length = sizeof(buffer);
9103 r = MsiRecordGetStringA(hrecord, i, buffer, &length);
9104 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
9105 memcpy(msg.field[i], buffer, min(100, length+1));
9108 /* top-level actions dump a list of all set properties; skip them since they're inconsistent */
9109 if (message == (INSTALLMESSAGE_INFO|MB_ICONHAND) && msg.field_count > 0 && !strncmp(msg.field[0], "Property", 8))
9110 return retval;
9112 add_message(&msg);
9114 return retval;
9117 static void test_externalui_message(void)
9119 /* test that events trigger the correct sequence of messages */
9121 INSTALLUI_HANDLER_RECORD prev;
9122 MSIHANDLE hdb, hpkg, hrecord;
9123 INT retval = 1;
9124 UINT r;
9126 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
9128 MsiSetExternalUIA(externalui_message_string_callback, INSTALLLOGMODE_SHOWDIALOG, &retval);
9129 r = MsiSetExternalUIRecord(externalui_message_callback, MSITEST_INSTALLLOGMODE, &retval, &prev);
9131 flush_sequence();
9133 CoInitialize(NULL);
9135 hdb = create_package_db();
9136 ok(hdb, "failed to create database\n");
9138 create_file_data("forcecodepage.idt", "\r\n\r\n1252\t_ForceCodepage\r\n");
9139 r = MsiDatabaseImportA(hdb, CURR_DIR, "forcecodepage.idt");
9140 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9142 r = run_query(hdb, "CREATE TABLE `Error` (`Error` SHORT NOT NULL, `Message` CHAR(0) PRIMARY KEY `Error`)");
9143 ok(r == ERROR_SUCCESS, "Failed to create Error table: %u\n", r);
9144 r = run_query(hdb, "INSERT INTO `Error` (`Error`, `Message`) VALUES (5, 'internal error')");
9145 ok(r == ERROR_SUCCESS, "Failed to insert into Error table: %u\n", r);
9147 create_actiontext_table(hdb);
9148 add_actiontext_entry(hdb, "'custom', 'description', 'template'");
9149 add_actiontext_entry(hdb, "'CostInitialize', 'cost description', 'cost template'");
9151 r = MsiOpenPackageA(NULL, &hpkg);
9152 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
9153 ok_sequence(empty_sequence, "MsiOpenPackage with NULL db", FALSE);
9155 r = MsiOpenPackageA("nonexistent", &hpkg);
9156 ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
9157 ok_sequence(openpackage_nonexistent_sequence, "MsiOpenPackage with nonexistent db", FALSE);
9159 r = package_from_db(hdb, &hpkg);
9160 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
9162 skip("Not enough rights to perform tests\n");
9163 DeleteFileA(msifile);
9164 return;
9166 ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
9167 ok_sequence(openpackage_sequence, "MsiOpenPackage with valid db", FALSE);
9169 /* Test MsiProcessMessage */
9170 hrecord = MsiCreateRecord(3);
9171 ok(hrecord, "failed to create record\n");
9173 MsiRecordSetStringA(hrecord, 0, "zero");
9174 MsiRecordSetStringA(hrecord, 1, "one");
9175 MsiRecordSetStringA(hrecord, 2, "two");
9176 MsiRecordSetStringA(hrecord, 3, "three");
9177 r = MsiProcessMessage(hpkg, INSTALLMESSAGE_INFO, hrecord);
9178 ok(r == 1, "Expected 1, got %d\n", r);
9179 ok_sequence(processmessage_info_sequence, "MsiProcessMessage(INSTALLMESSAGE_INFO)", FALSE);
9181 MsiRecordSetStringA(hrecord, 1, "name");
9182 MsiRecordSetStringA(hrecord, 2, "description");
9183 MsiRecordSetStringA(hrecord, 3, "template");
9184 r = MsiProcessMessage(hpkg, INSTALLMESSAGE_ACTIONSTART, hrecord);
9185 ok(r == 1, "Expected 1, got %d\n", r);
9186 ok_sequence(processmessage_actionstart_sequence, "MsiProcessMessage(INSTALLMESSAGE_ACTIONSTART)", FALSE);
9188 MsiRecordSetStringA(hrecord, 0, "apple");
9189 MsiRecordSetStringA(hrecord, 1, "cherry");
9190 MsiRecordSetStringA(hrecord, 2, "banana");
9191 MsiRecordSetStringA(hrecord, 3, "guava");
9192 r = MsiProcessMessage(hpkg, INSTALLMESSAGE_ACTIONDATA, hrecord);
9193 ok(r == 1, "Expected 1, got %d\n", r);
9194 ok_sequence(processmessage_actiondata_sequence, "MsiProcessMessage(INSTALLMESSAGE_ACTIONDATA)", FALSE);
9196 /* non-internal error */
9197 MsiRecordSetStringA(hrecord, 0, NULL);
9198 MsiRecordSetInteger(hrecord, 1, 1311);
9199 r = MsiProcessMessage(hpkg, INSTALLMESSAGE_USER, hrecord);
9200 ok(r == 1, "Expected 1, got %d\n", r);
9201 ok_sequence(processmessage_error_sequence, "MsiProcessMessage non-internal error", FALSE);
9203 /* internal error */
9204 MsiRecordSetStringA(hrecord, 0, NULL);
9205 MsiRecordSetInteger(hrecord, 1, 2726);
9206 r = MsiProcessMessage(hpkg, INSTALLMESSAGE_USER, hrecord);
9207 ok(r == 0, "Expected 0, got %d\n", r);
9208 ok_sequence(processmessage_internal_error_sequence, "MsiProcessMessage internal error", FALSE);
9210 /* with format field */
9211 MsiRecordSetStringA(hrecord, 0, "starfruit");
9212 r = MsiProcessMessage(hpkg, INSTALLMESSAGE_USER, hrecord);
9213 ok(r == 1, "Expected 1, got %d\n", r);
9214 ok_sequence(processmessage_error_format_sequence, "MsiProcessMessage error", FALSE);
9216 /* Test a standard action */
9217 r = MsiDoActionA(hpkg, "CostInitialize");
9218 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9219 ok_sequence(doaction_costinitialize_sequence, "MsiDoAction(\"CostInitialize\")", FALSE);
9221 /* Test a custom action */
9222 r = MsiDoActionA(hpkg, "custom");
9223 ok(r == ERROR_FUNCTION_NOT_CALLED, "Expected ERROR_FUNCTION_NOT_CALLED, got %d\n", r);
9224 ok_sequence(doaction_custom_sequence, "MsiDoAction(\"custom\")", FALSE);
9226 /* close the package */
9227 MsiCloseHandle(hpkg);
9228 ok_sequence(closehandle_sequence, "MsiCloseHandle()", FALSE);
9230 /* Test dialogs */
9231 hdb = create_package_db();
9232 ok(hdb, "failed to create database\n");
9234 r = MsiDatabaseImportA(hdb, CURR_DIR, "forcecodepage.idt");
9235 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9237 create_dialog_table(hdb);
9238 add_dialog_entry(hdb, "'dialog', 50, 50, 100, 100, 0, 'dummy'");
9240 create_control_table(hdb);
9241 add_control_entry(hdb, "'dialog', 'dummy', 'Text', 5, 5, 5, 5, 3, 'dummy'");
9243 r = package_from_db(hdb, &hpkg);
9244 ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
9245 ok_sequence(openpackage_sequence, "MsiOpenPackage with valid db", FALSE);
9247 /* Test a custom action */
9248 r = MsiDoActionA(hpkg, "custom");
9249 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9250 ok_sequence(doaction_custom_fullui_sequence, "MsiDoAction(\"custom\")", FALSE);
9252 retval = 2;
9253 r = MsiDoActionA(hpkg, "custom");
9254 ok(r == ERROR_INSTALL_USEREXIT, "Expected ERROR_INSTALL_USEREXIT, got %d\n", r);
9255 ok_sequence(doaction_custom_cancel_sequence, "MsiDoAction(\"custom\")", FALSE);
9257 retval = 0;
9258 r = MsiDoActionA(hpkg, "custom");
9259 ok(r == ERROR_FUNCTION_NOT_CALLED, "Expected ERROR_FUNCTION_NOT_CALLED, got %d\n", r);
9260 ok_sequence(doaction_dialog_nonexistent_sequence, "MsiDoAction(\"custom\")", FALSE);
9262 r = MsiDoActionA(hpkg, "dialog");
9263 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9264 ok_sequence(doaction_dialog_sequence, "MsiDoAction(\"dialog\")", FALSE);
9266 retval = -1;
9267 r = MsiDoActionA(hpkg, "error");
9268 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9269 ok_sequence(doaction_dialog_error_sequence, "MsiDoAction(\"error\")", FALSE);
9271 r = MsiDoActionA(hpkg, "error");
9272 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9273 ok_sequence(doaction_dialog_error_sequence, "MsiDoAction(\"error\")", FALSE);
9275 retval = -2;
9276 r = MsiDoActionA(hpkg, "custom");
9277 ok(r == ERROR_FUNCTION_NOT_CALLED, "Expected ERROR_FUNCTION_NOT_CALLED, got %d\n", r);
9278 ok_sequence(doaction_dialog_nonexistent_sequence, "MsiDoAction(\"custom\")", FALSE);
9280 retval = 3;
9281 r = MsiDoActionA(hpkg, "dialog");
9282 ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %d\n", r);
9283 ok_sequence(doaction_dialog_3_sequence, "MsiDoAction(\"dialog\")", FALSE);
9285 retval = 12345;
9286 r = MsiDoActionA(hpkg, "dialog");
9287 ok(r == ERROR_FUNCTION_FAILED, "Expected ERROR_INSTALL_FAILURE, got %d\n", r);
9288 ok_sequence(doaction_dialog_12345_sequence, "MsiDoAction(\"dialog\")", FALSE);
9290 MsiCloseHandle(hpkg);
9291 ok_sequence(closehandle_sequence, "MsiCloseHandle()", FALSE);
9293 MsiCloseHandle(hrecord);
9294 CoUninitialize();
9295 DeleteFileA(msifile);
9296 DeleteFileA("forcecodepage.idt");
9299 static const struct externalui_message controlevent_spawn_sequence[] = {
9300 {INSTALLMESSAGE_ACTIONSTART, 3, {"", "spawn", "", ""}, {0, 1, 1, 1}},
9301 {INSTALLMESSAGE_INFO, 2, {"", "spawn", ""}, {0, 1, 1}},
9302 {INSTALLMESSAGE_SHOWDIALOG, 0, {"spawn"}, {1}},
9303 {INSTALLMESSAGE_ACTIONSTART, 2, {"", "spawn", "Dialog created"}, {0, 1, 1}},
9305 {INSTALLMESSAGE_ACTIONSTART, 3, {"", "custom", "", ""}, {0, 1, 1, 1}},
9306 {INSTALLMESSAGE_INFO, 2, {"", "custom", ""}, {0, 1, 1}},
9307 {INSTALLMESSAGE_INFO, 2, {"", "custom", "1"}, {0, 1, 1}},
9309 {INSTALLMESSAGE_ACTIONSTART, 2, {"", "child1", "Dialog created"}, {0, 1, 1}},
9311 {INSTALLMESSAGE_INFO, 2, {"", "spawn", "2"}, {0, 1, 1}},
9315 static const struct externalui_message controlevent_spawn2_sequence[] = {
9316 {INSTALLMESSAGE_ACTIONSTART, 3, {"", "spawn2", "", ""}, {0, 1, 1, 1}},
9317 {INSTALLMESSAGE_INFO, 2, {"", "spawn2", "2"}, {0, 1, 1}},
9318 {INSTALLMESSAGE_SHOWDIALOG, 0, {"spawn2"}, {1}},
9319 {INSTALLMESSAGE_ACTIONSTART, 2, {"", "spawn2", "Dialog created"}, {0, 1, 1}},
9321 {INSTALLMESSAGE_ACTIONSTART, 3, {"", "custom", "", ""}, {0, 1, 1, 1}},
9322 {INSTALLMESSAGE_INFO, 2, {"", "custom", "2"}, {0, 1, 1}},
9323 {INSTALLMESSAGE_INFO, 2, {"", "custom", "1"}, {0, 1, 1}},
9325 {INSTALLMESSAGE_ACTIONSTART, 2, {"", "child2", "Dialog created"}, {0, 1, 1}},
9327 {INSTALLMESSAGE_INFO, 2, {"", "spawn2", "2"}, {0, 1, 1}},
9331 static void test_controlevent(void)
9333 INSTALLUI_HANDLER_RECORD prev;
9334 MSIHANDLE hdb, hpkg;
9335 UINT r;
9337 if (!winetest_interactive)
9339 skip("interactive ControlEvent tests\n");
9340 return;
9343 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
9345 MsiSetExternalUIA(externalui_message_string_callback, INSTALLLOGMODE_SHOWDIALOG, NULL);
9346 r = MsiSetExternalUIRecord(externalui_message_callback, MSITEST_INSTALLLOGMODE, NULL, &prev);
9348 flush_sequence();
9350 CoInitialize(NULL);
9352 hdb = create_package_db();
9353 ok(hdb, "failed to create database\n");
9355 create_file_data("forcecodepage.idt", "\r\n\r\n1252\t_ForceCodepage\r\n");
9356 r = MsiDatabaseImportA(hdb, CURR_DIR, "forcecodepage.idt");
9357 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9359 create_dialog_table(hdb);
9360 add_dialog_entry(hdb, "'spawn', 50, 50, 100, 100, 3, 'button'");
9361 add_dialog_entry(hdb, "'spawn2', 50, 50, 100, 100, 3, 'button'");
9362 add_dialog_entry(hdb, "'child1', 50, 50, 80, 40, 3, 'exit'");
9363 add_dialog_entry(hdb, "'child2', 50, 50, 80, 40, 3, 'exit'");
9365 create_control_table(hdb);
9366 add_control_entry(hdb, "'spawn', 'button', 'PushButton', 10, 10, 66, 17, 3, 'Click me'");
9367 add_control_entry(hdb, "'spawn2', 'button', 'PushButton', 10, 10, 66, 17, 3, 'Click me'");
9368 add_control_entry(hdb, "'child1', 'exit', 'PushButton', 10, 10, 66, 17, 3, 'Click me'");
9369 add_control_entry(hdb, "'child2', 'exit', 'PushButton', 10, 10, 66, 17, 3, 'Click me'");
9371 create_controlevent_table(hdb);
9372 add_controlevent_entry(hdb, "'child1', 'exit', 'EndDialog', 'Exit', 1, 1");
9373 add_controlevent_entry(hdb, "'child2', 'exit', 'EndDialog', 'Exit', 1, 1");
9375 create_custom_action_table(hdb);
9376 add_custom_action_entry(hdb, "'custom', 51, 'dummy', 'dummy value'");
9378 /* SpawnDialog and EndDialog should trigger after all other events */
9379 add_controlevent_entry(hdb, "'spawn', 'button', 'SpawnDialog', 'child1', 1, 1");
9380 add_controlevent_entry(hdb, "'spawn', 'button', 'DoAction', 'custom', 1, 2");
9382 /* Multiple dialog events cause only the last one to be triggered */
9383 add_controlevent_entry(hdb, "'spawn2', 'button', 'SpawnDialog', 'child1', 1, 1");
9384 add_controlevent_entry(hdb, "'spawn2', 'button', 'SpawnDialog', 'child2', 1, 2");
9385 add_controlevent_entry(hdb, "'spawn2', 'button', 'DoAction', 'custom', 1, 3");
9387 r = package_from_db(hdb, &hpkg);
9388 ok(r == ERROR_SUCCESS, "failed to create package: %u\n", r);
9389 ok_sequence(openpackage_sequence, "MsiOpenPackage()", FALSE);
9391 r = MsiDoActionA(hpkg, "spawn");
9392 ok(r == ERROR_INSTALL_USEREXIT, "expected ERROR_INSTALL_USEREXIT, got %u\n", r);
9393 ok_sequence(controlevent_spawn_sequence, "control event: spawn", FALSE);
9395 r = MsiDoActionA(hpkg, "spawn2");
9396 ok(r == ERROR_INSTALL_USEREXIT, "expected ERROR_INSTALL_USEREXIT, got %u\n", r);
9397 ok_sequence(controlevent_spawn2_sequence, "control event: spawn2", FALSE);
9399 MsiCloseHandle(hpkg);
9400 ok_sequence(closehandle_sequence, "MsiCloseHandle()", FALSE);
9402 CoUninitialize();
9403 DeleteFileA(msifile);
9404 DeleteFileA("forcecodepage.idt");
9407 static const struct externalui_message toplevel_install_sequence[] = {
9408 {INSTALLMESSAGE_ACTIONSTART, 3, {"", "INSTALL", "", ""}, {0, 1, 1, 1}},
9409 {INSTALLMESSAGE_INFO, 2, {"", "INSTALL", ""}, {0, 1, 1}},
9411 {INSTALLMESSAGE_COMMONDATA, 3, {"", "0", "1033", "1252"}, {1, 1, 1, 1}},
9412 {INSTALLMESSAGE_COMMONDATA, 3, {"", "0", "1033", "1252"}, {1, 1, 1, 1}},
9413 {INSTALLMESSAGE_INFO|MB_ICONHAND, 0, {""}, {0}},
9414 {INSTALLMESSAGE_COMMONDATA, 3, {"", "0", "1033", "1252"}, {0, 1, 1, 1}},
9415 {INSTALLMESSAGE_COMMONDATA, 3, {"", "1", "", ""}, {0, 1, 0, 0}},
9417 {INSTALLMESSAGE_ACTIONSTART, 3, {"", "INSTALL", "", ""}, {0, 1, 1, 1}},
9418 {INSTALLMESSAGE_INFO, 2, {"", "INSTALL", ""}, {0, 1, 1}},
9419 {INSTALLMESSAGE_INSTALLSTART, 2, {"", "", "{7262AC98-EEBD-4364-8CE3-D654F6A425B9}"}, {1, 1, 1}, 1},
9421 {INSTALLMESSAGE_ACTIONSTART, 3, {"", "CostInitialize", "", ""}, {0, 1, 0, 1}},
9422 {INSTALLMESSAGE_INFO, 2, {"", "CostInitialize", ""}, {0, 1, 1}},
9423 {INSTALLMESSAGE_INFO, 2, {"", "CostInitialize", "1"}, {0, 1, 1}},
9425 {INSTALLMESSAGE_ACTIONSTART, 3, {"", "FileCost", "", ""}, {0, 1, 0, 1}},
9426 {INSTALLMESSAGE_INFO, 2, {"", "FileCost", "1"}, {0, 1, 1}},
9427 {INSTALLMESSAGE_INFO, 2, {"", "FileCost", "1"}, {0, 1, 1}},
9429 {INSTALLMESSAGE_ACTIONSTART, 3, {"", "CostFinalize", "", ""}, {0, 1, 0, 1}},
9430 {INSTALLMESSAGE_INFO, 2, {"", "CostFinalize", "1"}, {0, 1, 1}},
9431 {INSTALLMESSAGE_INFO, 2, {"", "CostFinalize", "1"}, {0, 1, 1}},
9433 {INSTALLMESSAGE_INFO, 2, {"", "INSTALL", "1"}, {0, 1, 1}},
9434 {INSTALLMESSAGE_INSTALLEND, 3, {"", "", "{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "1"}, {1, 1, 1, 1}, 1},
9436 /* property dump */
9438 {INSTALLMESSAGE_COMMONDATA, 2, {"", "2", "0"}, {0, 1, 1}, 1},
9439 {INSTALLMESSAGE_COMMONDATA, 2, {"", "2", "1"}, {0, 1, 1}, 1},
9440 {INSTALLMESSAGE_INFO, 2, {"", "INSTALL", "1"}, {0, 1, 1}},
9444 static const struct externalui_message toplevel_install_ui_sequence[] = {
9445 {INSTALLMESSAGE_ACTIONSTART, 3, {"", "INSTALL", "", ""}, {0, 1, 1, 1}},
9446 {INSTALLMESSAGE_INFO, 2, {"", "INSTALL", ""}, {0, 1, 1}},
9448 {INSTALLMESSAGE_ACTIONSTART, 3, {"", "AppSearch", "", ""}, {0, 1, 0, 0}},
9449 {INSTALLMESSAGE_INFO, 2, {"", "AppSearch", ""}, {0, 1, 1}},
9450 {INSTALLMESSAGE_INFO, 2, {"", "AppSearch", "0"}, {0, 1, 1}},
9452 {INSTALLMESSAGE_INFO, 2, {"", "INSTALL", "1"}, {0, 1, 1}},
9456 static const struct externalui_message toplevel_executeaction_install_sequence[] = {
9457 {INSTALLMESSAGE_ACTIONSTART, 3, {"", "ExecuteAction", "", ""}, {0, 1, 1, 1}},
9458 {INSTALLMESSAGE_INFO, 2, {"", "ExecuteAction", "1"}, {0, 1, 1}},
9460 {INSTALLMESSAGE_COMMONDATA, 3, {"", "0", "1033", "1252"}, {1, 1, 1, 1}},
9461 {INSTALLMESSAGE_COMMONDATA, 3, {"", "0", "1033", "1252"}, {1, 1, 1, 1}},
9462 {INSTALLMESSAGE_COMMONDATA, 3, {"", "0", "1033", "1252"}, {0, 1, 1, 1}},
9463 {INSTALLMESSAGE_COMMONDATA, 3, {"", "1", "", ""}, {0, 1, 0, 0}},
9465 {INSTALLMESSAGE_ACTIONSTART, 3, {"", "INSTALL", "", ""}, {0, 1, 1, 1}},
9466 {INSTALLMESSAGE_INFO, 2, {"", "INSTALL", ""}, {0, 1, 1}},
9467 {INSTALLMESSAGE_INSTALLSTART, 2, {"", "", "{7262AC98-EEBD-4364-8CE3-D654F6A425B9}"}, {1, 1, 1}, 1},
9469 {INSTALLMESSAGE_ACTIONSTART, 3, {"", "CostInitialize", "", ""}, {0, 1, 0, 1}},
9470 {INSTALLMESSAGE_INFO, 2, {"", "CostInitialize"}, {0, 1}},
9471 {INSTALLMESSAGE_INFO, 2, {"", "CostInitialize", "1"}, {0, 1, 1}},
9473 {INSTALLMESSAGE_ACTIONSTART, 3, {"", "FileCost", "", ""}, {0, 1, 0, 1}},
9474 {INSTALLMESSAGE_INFO, 2, {"", "FileCost", "1"}, {0, 1, 1}},
9475 {INSTALLMESSAGE_INFO, 2, {"", "FileCost", "1"}, {0, 1, 1}},
9477 {INSTALLMESSAGE_ACTIONSTART, 3, {"", "CostFinalize", "", ""}, {0, 1, 0, 1}},
9478 {INSTALLMESSAGE_INFO, 2, {"", "CostFinalize", "1"}, {0, 1, 1}},
9479 {INSTALLMESSAGE_INFO, 2, {"", "CostFinalize", "1"}, {0, 1, 1}},
9481 {INSTALLMESSAGE_INFO, 2, {"", "INSTALL", "1"}, {0, 1, 1}},
9482 {INSTALLMESSAGE_INSTALLEND, 3, {"", "", "{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "1"}, {1, 1, 1, 1}, 1},
9484 /* property dump */
9486 {INSTALLMESSAGE_COMMONDATA, 2, {"", "2", "0"}, {0, 1, 1}, 1},
9487 {INSTALLMESSAGE_COMMONDATA, 2, {"", "2", "1"}, {0, 1, 1}, 1},
9488 {INSTALLMESSAGE_INFO, 2, {"", "ExecuteAction", "1"}, {0, 1, 1}},
9492 static const struct externalui_message toplevel_executeaction_costinitialize_sequence[] = {
9493 {INSTALLMESSAGE_ACTIONSTART, 3, {"", "ExecuteAction", "", ""}, {0, 1, 1, 1}},
9494 {INSTALLMESSAGE_INFO, 2, {"", "ExecuteAction", "1"}, {0, 1, 1}},
9496 {INSTALLMESSAGE_COMMONDATA, 3, {"", "0", "1033", "1252"}, {1, 1, 1, 1}},
9497 {INSTALLMESSAGE_COMMONDATA, 3, {"", "0", "1033", "1252"}, {1, 1, 1, 1}},
9498 {INSTALLMESSAGE_COMMONDATA, 3, {"", "0", "1033", "1252"}, {0, 1, 1, 1}},
9499 {INSTALLMESSAGE_COMMONDATA, 3, {"", "1", "", ""}, {0, 1, 0, 0}},
9501 {INSTALLMESSAGE_ACTIONSTART, 3, {"", "CostInitialize", "", ""}, {0, 1, 0, 1}},
9502 {INSTALLMESSAGE_INFO, 2, {"", "CostInitialize", ""}, {0, 1}},
9503 {INSTALLMESSAGE_INFO, 2, {"", "CostInitialize", "1"}, {0, 1, 1}},
9505 /* property dump */
9507 {INSTALLMESSAGE_COMMONDATA, 2, {"", "2", "0"}, {0, 1, 1}, 1},
9508 {INSTALLMESSAGE_COMMONDATA, 2, {"", "2", "1"}, {0, 1, 1}, 1},
9509 {INSTALLMESSAGE_INFO, 2, {"", "ExecuteAction", "1"}, {0, 1, 1}},
9513 static const struct externalui_message toplevel_msiinstallproduct_sequence[] = {
9514 {INSTALLMESSAGE_INITIALIZE, -1},
9516 {INSTALLMESSAGE_COMMONDATA, 3, {"", "0", "1033", "1252"}, {1, 1, 1, 1}},
9517 {INSTALLMESSAGE_COMMONDATA, 3, {"", "0", "1033", "1252"}, {1, 1, 1, 1}},
9518 {INSTALLMESSAGE_INFO|MB_ICONHAND, 0, {""}, {0}},
9519 {INSTALLMESSAGE_COMMONDATA, 3, {"", "0", "1033", "1252"}, {0, 1, 1, 1}},
9520 {INSTALLMESSAGE_COMMONDATA, 3, {"", "1", "", ""}, {0, 1, 0, 0}},
9522 {INSTALLMESSAGE_ACTIONSTART, 3, {"", "INSTALL", "", ""}, {0, 1, 1, 1}},
9523 {INSTALLMESSAGE_INFO, 2, {"", "INSTALL", ""}, {0, 1, 1}},
9525 {INSTALLMESSAGE_ACTIONSTART, 3, {"", "AppSearch", "", ""}, {0, 1, 0, 0}},
9526 {INSTALLMESSAGE_INFO, 2, {"", "AppSearch", ""}, {0, 1, 1}},
9527 {INSTALLMESSAGE_INFO, 2, {"", "AppSearch", "0"}, {0, 1, 1}},
9529 {INSTALLMESSAGE_INFO, 2, {"", "INSTALL", "1"}, {0, 1, 1}},
9531 /* property dump */
9533 {INSTALLMESSAGE_INFO|MB_ICONHAND, 0, {""}, {0}},
9534 {INSTALLMESSAGE_TERMINATE, -1},
9538 static const struct externalui_message toplevel_msiinstallproduct_custom_sequence[] = {
9539 {INSTALLMESSAGE_INITIALIZE, -1},
9541 {INSTALLMESSAGE_COMMONDATA, 3, {"", "0", "1033", "1252"}, {1, 1, 1, 1}},
9542 {INSTALLMESSAGE_COMMONDATA, 3, {"", "0", "1033", "1252"}, {1, 1, 1, 1}},
9543 {INSTALLMESSAGE_INFO|MB_ICONHAND, 0, {""}, {0}},
9544 {INSTALLMESSAGE_COMMONDATA, 3, {"", "0", "1033", "1252"}, {0, 1, 1, 1}},
9545 {INSTALLMESSAGE_COMMONDATA, 3, {"", "1", "", ""}, {0, 1, 0, 0}},
9547 {INSTALLMESSAGE_ACTIONSTART, 3, {"", "CUSTOM", "", ""}, {0, 1, 1, 1}},
9548 {INSTALLMESSAGE_INFO, 2, {"", "CUSTOM", ""}, {0, 1, 1}},
9549 {INSTALLMESSAGE_INFO, 2, {"", "CUSTOM", "0"}, {0, 1, 1}},
9551 /* property dump */
9553 {INSTALLMESSAGE_INFO|MB_ICONHAND, 0, {""}, {0}},
9554 {INSTALLMESSAGE_TERMINATE, -1},
9558 /* tests involving top-level actions: INSTALL, ExecuteAction */
9559 static void test_top_level_action(void)
9561 INSTALLUI_HANDLER_RECORD prev;
9562 MSIHANDLE hdb, hpkg;
9563 UINT r;
9564 char msifile_absolute[MAX_PATH];
9566 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
9568 MsiSetExternalUIA(externalui_message_string_callback, INSTALLLOGMODE_SHOWDIALOG, NULL);
9569 r = MsiSetExternalUIRecord(externalui_message_callback, MSITEST_INSTALLLOGMODE, NULL, &prev);
9571 flush_sequence();
9573 CoInitialize(NULL);
9575 hdb = create_package_db();
9576 ok(hdb, "failed to create database\n");
9578 create_file_data("forcecodepage.idt", "\r\n\r\n1252\t_ForceCodepage\r\n");
9579 r = MsiDatabaseImportA(hdb, CURR_DIR, "forcecodepage.idt");
9580 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9582 create_property_table(hdb);
9583 add_property_entry(hdb, "'ProductCode', '{7262AC98-EEBD-4364-8CE3-D654F6A425B9}'");
9585 create_install_execute_sequence_table(hdb);
9586 add_install_execute_sequence_entry(hdb, "'CostInitialize', '', 1");
9587 add_install_execute_sequence_entry(hdb, "'FileCost', '', 2");
9588 add_install_execute_sequence_entry(hdb, "'CostFinalize', '', 3");
9590 create_install_ui_sequence_table(hdb);
9591 add_install_ui_sequence_entry(hdb, "'AppSearch', '', 1");
9593 MsiDatabaseCommit(hdb);
9595 /* for some reason we have to open the package from file using an absolute path */
9596 MsiCloseHandle(hdb);
9597 GetFullPathNameA(msifile, MAX_PATH, msifile_absolute, NULL);
9598 r = MsiOpenPackageA(msifile_absolute, &hpkg);
9599 ok(r == ERROR_SUCCESS, "failed to create package: %u\n", r);
9600 ok_sequence(openpackage_sequence, "MsiOpenPackage()", FALSE);
9602 /* test INSTALL */
9603 r = MsiDoActionA(hpkg, "INSTALL");
9604 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r);
9605 ok_sequence(toplevel_install_sequence, "INSTALL (no UI)", FALSE);
9607 /* test INSTALL with reduced+ UI */
9608 /* for some reason we need to re-open the package to change the internal UI */
9609 MsiCloseHandle(hpkg);
9610 ok_sequence(closehandle_sequence, "MsiCloseHandle()", FALSE);
9611 MsiSetInternalUI(INSTALLUILEVEL_REDUCED, NULL);
9612 r = MsiOpenPackageA(msifile_absolute, &hpkg);
9613 ok(r == ERROR_SUCCESS, "failed to create package: %u\n", r);
9614 ok_sequence(openpackage_sequence, "MsiOpenPackage()", FALSE);
9616 r = MsiDoActionA(hpkg, "INSTALL");
9617 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r);
9618 ok_sequence(toplevel_install_ui_sequence, "INSTALL (reduced+ UI)", TRUE);
9620 /* test ExecuteAction with EXECUTEACTION property unset */
9621 MsiSetPropertyA(hpkg, "EXECUTEACTION", NULL);
9622 r = MsiDoActionA(hpkg, "ExecuteAction");
9623 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r);
9624 ok_sequence(toplevel_executeaction_install_sequence, "ExecuteAction: INSTALL", FALSE);
9626 /* test ExecuteAction with EXECUTEACTION property set */
9627 MsiSetPropertyA(hpkg, "EXECUTEACTION", "CostInitialize");
9628 r = MsiDoActionA(hpkg, "ExecuteAction");
9629 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r);
9630 ok_sequence(toplevel_executeaction_costinitialize_sequence, "ExecuteAction: CostInitialize", FALSE);
9632 MsiCloseHandle(hpkg);
9633 ok_sequence(closehandle_sequence, "MsiCloseHandle()", FALSE);
9635 /* test MsiInstallProduct() */
9636 r = MsiInstallProductA(msifile_absolute, NULL);
9637 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r);
9638 ok_sequence(toplevel_msiinstallproduct_sequence, "MsiInstallProduct()", TRUE);
9640 r = MsiInstallProductA(msifile_absolute, "ACTION=custom");
9641 todo_wine
9642 ok(r == ERROR_INSTALL_FAILURE, "expected ERROR_INSTALL_FAILURE, got %u\n", r);
9643 ok_sequence(toplevel_msiinstallproduct_custom_sequence, "MsiInstallProduct(ACTION=custom)", TRUE);
9645 CoUninitialize();
9646 DeleteFileA(msifile);
9647 DeleteFileA("forcecodepage.idt");
9650 START_TEST(package)
9652 STATEMGRSTATUS status;
9653 BOOL ret = FALSE;
9655 init_functionpointers();
9657 if (pIsWow64Process)
9658 pIsWow64Process(GetCurrentProcess(), &is_wow64);
9660 GetCurrentDirectoryA(MAX_PATH, CURR_DIR);
9662 /* Create a restore point ourselves so we circumvent the multitude of restore points
9663 * that would have been created by all the installation and removal tests.
9665 * This is not needed on version 5.0 where setting MSIFASTINSTALL prevents the
9666 * creation of restore points.
9668 if (pSRSetRestorePointA && !pMsiGetComponentPathExA)
9670 memset(&status, 0, sizeof(status));
9671 ret = notify_system_change(BEGIN_NESTED_SYSTEM_CHANGE, &status);
9674 test_createpackage();
9675 test_doaction();
9676 test_gettargetpath_bad();
9677 test_settargetpath();
9678 test_props();
9679 test_property_table();
9680 test_condition();
9681 test_msipackage();
9682 test_formatrecord2();
9683 test_formatrecord_tables();
9684 test_states();
9685 test_removefiles();
9686 test_appsearch();
9687 test_appsearch_complocator();
9688 test_appsearch_reglocator();
9689 test_appsearch_inilocator();
9690 test_appsearch_drlocator();
9691 test_featureparents();
9692 test_installprops();
9693 test_launchconditions();
9694 test_ccpsearch();
9695 test_complocator();
9696 test_MsiGetSourcePath();
9697 test_shortlongsource();
9698 test_sourcedir();
9699 test_access();
9700 test_emptypackage();
9701 test_MsiGetProductProperty();
9702 test_MsiSetProperty();
9703 test_MsiApplyMultiplePatches();
9704 test_MsiApplyPatch();
9705 test_MsiEnumComponentCosts();
9706 test_MsiDatabaseCommit();
9707 test_externalui();
9708 test_externalui_message();
9709 test_controlevent();
9710 test_top_level_action();
9712 if (pSRSetRestorePointA && !pMsiGetComponentPathExA && ret)
9714 ret = notify_system_change(END_NESTED_SYSTEM_CHANGE, &status);
9715 if (ret)
9716 remove_restore_point(status.llSequenceNumber);