2 * Copyright (C) 2006 James Hawkins
4 * A test program for installing MSI products.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
29 #include "wine/test.h"
31 static const char *msifile = "winetest.msi";
32 CHAR CURR_DIR[MAX_PATH];
33 CHAR PROG_FILES_DIR[MAX_PATH];
35 /* msi database data */
37 static const CHAR component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
38 "s72\tS38\ts72\ti2\tS255\tS72\n"
39 "Component\tComponent\n"
40 "Five\t{8CC92E9D-14B2-4CA4-B2AA-B11D02078087}\tNEWDIR\t2\t\tfive.txt\n"
41 "Four\t{FD37B4EA-7209-45C0-8917-535F35A2F080}\tCABOUTDIR\t2\t\tfour.txt\n"
42 "One\t{783B242E-E185-4A56-AF86-C09815EC053C}\tMSITESTDIR\t2\t\tone.txt\n"
43 "Three\t{010B6ADD-B27D-4EDD-9B3D-34C4F7D61684}\tCHANGEDDIR\t2\t\tthree.txt\n"
44 "Two\t{BF03D1A6-20DA-4A65-82F3-6CAC995915CE}\tFIRSTDIR\t2\t\ttwo.txt\n"
45 "dangler\t{6091DF25-EF96-45F1-B8E9-A9B1420C7A3C}\tTARGETDIR\t4\t\tregdata\n"
46 "component\t\tMSITESTDIR\t0\t1\tfile\n"
47 "service_comp\t\tMSITESTDIR\t0\t1\tservice_file";
49 static const CHAR directory_dat[] = "Directory\tDirectory_Parent\tDefaultDir\n"
51 "Directory\tDirectory\n"
52 "CABOUTDIR\tMSITESTDIR\tcabout\n"
53 "CHANGEDDIR\tMSITESTDIR\tchanged:second\n"
54 "FIRSTDIR\tMSITESTDIR\tfirst\n"
55 "MSITESTDIR\tProgramFilesFolder\tmsitest\n"
56 "NEWDIR\tCABOUTDIR\tnew\n"
57 "ProgramFilesFolder\tTARGETDIR\t.\n"
58 "TARGETDIR\t\tSourceDir";
60 static const CHAR feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
61 "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
63 "Five\t\tFive\tThe Five Feature\t5\t3\tNEWDIR\t0\n"
64 "Four\t\tFour\tThe Four Feature\t4\t3\tCABOUTDIR\t0\n"
65 "One\t\tOne\tThe One Feature\t1\t3\tMSITESTDIR\t0\n"
66 "Three\t\tThree\tThe Three Feature\t3\t3\tCHANGEDDIR\t0\n"
67 "Two\t\tTwo\tThe Two Feature\t2\t3\tFIRSTDIR\t0\n"
68 "feature\t\t\t\t2\t1\tTARGETDIR\t0\n"
69 "service_feature\t\t\t\t2\t1\tTARGETDIR\t0";
71 static const CHAR feature_comp_dat[] = "Feature_\tComponent_\n"
73 "FeatureComponents\tFeature_\tComponent_\n"
79 "feature\tcomponent\n"
80 "service_feature\tservice_comp\n";
82 static const CHAR file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
83 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
85 "five.txt\tFive\tfive.txt\t1000\t\t\t16384\t5\n"
86 "four.txt\tFour\tfour.txt\t1000\t\t\t16384\t4\n"
87 "one.txt\tOne\tone.txt\t1000\t\t\t0\t1\n"
88 "three.txt\tThree\tthree.txt\t1000\t\t\t0\t3\n"
89 "two.txt\tTwo\ttwo.txt\t1000\t\t\t0\t2\n"
90 "file\tcomponent\tfilename\t100\t\t\t8192\t1\n"
91 "service_file\tservice_comp\tservice.exe\t100\t\t\t8192\t1";
93 static const CHAR install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
95 "InstallExecuteSequence\tAction\n"
96 "AllocateRegistrySpace\tNOT Installed\t1550\n"
97 "CostFinalize\t\t1000\n"
98 "CostInitialize\t\t800\n"
100 "InstallFiles\t\t4000\n"
101 "InstallServices\t\t5000\n"
102 "InstallFinalize\t\t6600\n"
103 "InstallInitialize\t\t1500\n"
104 "InstallValidate\t\t1400\n"
105 "LaunchConditions\t\t100\n"
106 "WriteRegistryValues\tSourceDir And SOURCEDIR\t5000";
108 static const CHAR media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
109 "i2\ti4\tL64\tS255\tS32\tS72\n"
111 "1\t3\t\t\tDISK1\t\n"
112 "2\t5\t\tmsitest.cab\tDISK2\t\n";
114 static const CHAR property_dat[] = "Property\tValue\n"
116 "Property\tProperty\n"
117 "DefaultUIFont\tDlgFont8\n"
119 "InstallMode\tTypical\n"
120 "Manufacturer\tWine\n"
121 "PIDTemplate\t12345<###-%%%%%%%>@@@@@\n"
122 "ProductCode\t{F1C3AF50-8B56-4A69-A00C-00773FE42F30}\n"
124 "ProductLanguage\t1033\n"
125 "ProductName\tMSITEST\n"
126 "ProductVersion\t1.1.1\n"
127 "PROMPTROLLBACKCOST\tP\n"
129 "UpgradeCode\t{CE067E8D-2E1A-4367-B734-4EB2BDAD6565}";
131 static const CHAR registry_dat[] = "Registry\tRoot\tKey\tName\tValue\tComponent_\n"
132 "s72\ti2\tl255\tL255\tL0\ts72\n"
133 "Registry\tRegistry\n"
134 "Apples\t2\tSOFTWARE\\Wine\\msitest\tName\timaname\tOne\n"
135 "Oranges\t2\tSOFTWARE\\Wine\\msitest\tnumber\t#314\tTwo\n"
136 "regdata\t2\tSOFTWARE\\Wine\\msitest\tblah\tbad\tdangler\n"
137 "OrderTest\t2\tSOFTWARE\\Wine\\msitest\tOrderTestName\tOrderTestValue\tcomponent";
139 static const CHAR service_install_dat[] = "ServiceInstall\tName\tDisplayName\tServiceType\tStartType\tErrorControl\t"
140 "LoadOrderGroup\tDependencies\tStartName\tPassword\tArguments\tComponent_\tDescription\n"
141 "s72\ts255\tL255\ti4\ti4\ti4\tS255\tS255\tS255\tS255\tS255\ts72\tL255\n"
142 "ServiceInstall\tServiceInstall\n"
143 "TestService\tTestService\tTestService\t2\t3\t0\t\t\tTestService\t\t\tservice_comp\t\t";
145 static const CHAR service_control_dat[] = "ServiceControl\tName\tEvent\tArguments\tWait\tComponent_\n"
146 "s72\tl255\ti2\tL255\tI2\ts72\n"
147 "ServiceControl\tServiceControl\n"
148 "ServiceControl\tTestService\t8\t\t0\tservice_comp";
150 /* tables for test_continuouscabs */
151 static const CHAR cc_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
152 "s72\tS38\ts72\ti2\tS255\tS72\n"
153 "Component\tComponent\n"
154 "maximus\t\tMSITESTDIR\t0\t1\tmaximus\n"
155 "augustus\t\tMSITESTDIR\t0\t1\taugustus";
157 static const CHAR cc_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
158 "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
160 "feature\t\t\t\t2\t1\tTARGETDIR\t0";
162 static const CHAR cc_feature_comp_dat[] = "Feature_\tComponent_\n"
164 "FeatureComponents\tFeature_\tComponent_\n"
168 static const CHAR cc_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
169 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
171 "maximus\tmaximus\tmaximus\t500\t\t\t16384\t1\n"
172 "augustus\taugustus\taugustus\t50000\t\t\t16384\t1";
174 static const CHAR cc_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
175 "i2\ti4\tL64\tS255\tS32\tS72\n"
177 "1\t10\t\ttest1.cab\tDISK1\t\n"
178 "2\t2\t\ttest2.cab\tDISK2\t\n";
180 typedef struct _msi_table
182 const CHAR *filename;
187 #define ADD_TABLE(x) {#x".idt", x##_dat, sizeof(x##_dat)}
189 static const msi_table tables[] =
191 ADD_TABLE(component),
192 ADD_TABLE(directory),
194 ADD_TABLE(feature_comp),
196 ADD_TABLE(install_exec_seq),
200 ADD_TABLE(service_install),
201 ADD_TABLE(service_control)
204 static const msi_table cc_tables[] =
206 ADD_TABLE(cc_component),
207 ADD_TABLE(directory),
208 ADD_TABLE(cc_feature),
209 ADD_TABLE(cc_feature_comp),
211 ADD_TABLE(install_exec_seq),
216 /* cabinet definitions */
218 /* make the max size large so there is only one cab file */
219 #define MEDIA_SIZE 0x7FFFFFFF
220 #define FOLDER_THRESHOLD 900000
222 /* the FCI callbacks */
224 static void *mem_alloc(ULONG cb)
226 return HeapAlloc(GetProcessHeap(), 0, cb);
229 static void mem_free(void *memory)
231 HeapFree(GetProcessHeap(), 0, memory);
234 static BOOL get_next_cabinet(PCCAB pccab, ULONG cbPrevCab, void *pv)
236 sprintf(pccab->szCab, pv, pccab->iCab);
240 static long progress(UINT typeStatus, ULONG cb1, ULONG cb2, void *pv)
245 static int file_placed(PCCAB pccab, char *pszFile, long cbFile,
246 BOOL fContinuation, void *pv)
251 static INT_PTR fci_open(char *pszFile, int oflag, int pmode, int *err, void *pv)
255 DWORD dwShareMode = 0;
256 DWORD dwCreateDisposition = OPEN_EXISTING;
258 dwAccess = GENERIC_READ | GENERIC_WRITE;
259 /* FILE_SHARE_DELETE is not supported by Windows Me/98/95 */
260 dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
262 if (GetFileAttributesA(pszFile) != INVALID_FILE_ATTRIBUTES)
263 dwCreateDisposition = OPEN_EXISTING;
265 dwCreateDisposition = CREATE_NEW;
267 handle = CreateFileA(pszFile, dwAccess, dwShareMode, NULL,
268 dwCreateDisposition, 0, NULL);
270 ok(handle != INVALID_HANDLE_VALUE, "Failed to CreateFile %s\n", pszFile);
272 return (INT_PTR)handle;
275 static UINT fci_read(INT_PTR hf, void *memory, UINT cb, int *err, void *pv)
277 HANDLE handle = (HANDLE)hf;
281 res = ReadFile(handle, memory, cb, &dwRead, NULL);
282 ok(res, "Failed to ReadFile\n");
287 static UINT fci_write(INT_PTR hf, void *memory, UINT cb, int *err, void *pv)
289 HANDLE handle = (HANDLE)hf;
293 res = WriteFile(handle, memory, cb, &dwWritten, NULL);
294 ok(res, "Failed to WriteFile\n");
299 static int fci_close(INT_PTR hf, int *err, void *pv)
301 HANDLE handle = (HANDLE)hf;
302 ok(CloseHandle(handle), "Failed to CloseHandle\n");
307 static long fci_seek(INT_PTR hf, long dist, int seektype, int *err, void *pv)
309 HANDLE handle = (HANDLE)hf;
312 ret = SetFilePointer(handle, dist, NULL, seektype);
313 ok(ret != INVALID_SET_FILE_POINTER, "Failed to SetFilePointer\n");
318 static int fci_delete(char *pszFile, int *err, void *pv)
320 BOOL ret = DeleteFileA(pszFile);
321 ok(ret, "Failed to DeleteFile %s\n", pszFile);
326 static BOOL check_record(MSIHANDLE rec, UINT field, LPCSTR val)
333 r = MsiRecordGetString(rec, field, buffer, &sz);
334 return (r == ERROR_SUCCESS ) && !strcmp(val, buffer);
337 static BOOL get_temp_file(char *pszTempName, int cbTempName, void *pv)
341 tempname = HeapAlloc(GetProcessHeap(), 0, MAX_PATH);
342 GetTempFileNameA(".", "xx", 0, tempname);
344 if (tempname && (strlen(tempname) < (unsigned)cbTempName))
346 lstrcpyA(pszTempName, tempname);
347 HeapFree(GetProcessHeap(), 0, tempname);
351 HeapFree(GetProcessHeap(), 0, tempname);
356 static INT_PTR get_open_info(char *pszName, USHORT *pdate, USHORT *ptime,
357 USHORT *pattribs, int *err, void *pv)
359 BY_HANDLE_FILE_INFORMATION finfo;
365 handle = CreateFile(pszName, GENERIC_READ, FILE_SHARE_READ, NULL,
366 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
368 ok(handle != INVALID_HANDLE_VALUE, "Failed to CreateFile %s\n", pszName);
370 res = GetFileInformationByHandle(handle, &finfo);
371 ok(res, "Expected GetFileInformationByHandle to succeed\n");
373 FileTimeToLocalFileTime(&finfo.ftLastWriteTime, &filetime);
374 FileTimeToDosDateTime(&filetime, pdate, ptime);
376 attrs = GetFileAttributes(pszName);
377 ok(attrs != INVALID_FILE_ATTRIBUTES, "Failed to GetFileAttributes\n");
379 return (INT_PTR)handle;
382 static BOOL add_file(HFCI hfci, const char *file, TCOMP compress)
385 char filename[MAX_PATH];
387 lstrcpyA(path, CURR_DIR);
388 lstrcatA(path, "\\");
389 lstrcatA(path, file);
391 lstrcpyA(filename, file);
393 return FCIAddFile(hfci, path, filename, FALSE, get_next_cabinet,
394 progress, get_open_info, compress);
397 static void set_cab_parameters(PCCAB pCabParams, const CHAR *name, DWORD max_size)
399 ZeroMemory(pCabParams, sizeof(CCAB));
401 pCabParams->cb = max_size;
402 pCabParams->cbFolderThresh = FOLDER_THRESHOLD;
403 pCabParams->setID = 0xbeef;
404 pCabParams->iCab = 1;
405 lstrcpyA(pCabParams->szCabPath, CURR_DIR);
406 lstrcatA(pCabParams->szCabPath, "\\");
407 lstrcpyA(pCabParams->szCab, name);
410 static void create_cab_file(const CHAR *name, DWORD max_size, const CHAR *files)
418 set_cab_parameters(&cabParams, name, max_size);
420 hfci = FCICreate(&erf, file_placed, mem_alloc, mem_free, fci_open,
421 fci_read, fci_write, fci_close, fci_seek, fci_delete,
422 get_temp_file, &cabParams, NULL);
424 ok(hfci != NULL, "Failed to create an FCI context\n");
429 res = add_file(hfci, ptr, tcompTYPE_MSZIP);
430 ok(res, "Failed to add file: %s\n", ptr);
431 ptr += lstrlen(ptr) + 1;
434 res = FCIFlushCabinet(hfci, FALSE, get_next_cabinet, progress);
435 ok(res, "Failed to flush the cabinet\n");
437 res = FCIDestroy(hfci);
438 ok(res, "Failed to destroy the cabinet\n");
441 static BOOL get_program_files_dir(LPSTR buf)
444 DWORD type = REG_EXPAND_SZ, size;
446 if (RegOpenKey(HKEY_LOCAL_MACHINE,
447 "Software\\Microsoft\\Windows\\CurrentVersion", &hkey))
451 if (RegQueryValueEx(hkey, "ProgramFilesDir", 0, &type, (LPBYTE)buf, &size))
458 static void create_file(const CHAR *name, DWORD size)
463 file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
464 ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name);
465 WriteFile(file, name, strlen(name), &written, NULL);
466 WriteFile(file, "\n", strlen("\n"), &written, NULL);
468 left = size - lstrlen(name) - 1;
470 SetFilePointer(file, left, NULL, FILE_CURRENT);
476 static void create_test_files(void)
478 CreateDirectoryA("msitest", NULL);
479 create_file("msitest\\one.txt", 100);
480 CreateDirectoryA("msitest\\first", NULL);
481 create_file("msitest\\first\\two.txt", 100);
482 CreateDirectoryA("msitest\\second", NULL);
483 create_file("msitest\\second\\three.txt", 100);
485 create_file("four.txt", 100);
486 create_file("five.txt", 100);
487 create_cab_file("msitest.cab", MEDIA_SIZE, "four.txt\0five.txt\0");
489 create_file("msitest\\filename", 100);
490 create_file("msitest\\service.exe", 100);
492 DeleteFileA("four.txt");
493 DeleteFileA("five.txt");
496 static BOOL delete_pf(const CHAR *rel_path, BOOL is_file)
500 lstrcpyA(path, PROG_FILES_DIR);
501 lstrcatA(path, "\\");
502 lstrcatA(path, rel_path);
505 return DeleteFileA(path);
507 return RemoveDirectoryA(path);
510 static void delete_test_files(void)
512 DeleteFileA("msitest.msi");
513 DeleteFileA("msitest.cab");
514 DeleteFileA("msitest\\second\\three.txt");
515 DeleteFileA("msitest\\first\\two.txt");
516 DeleteFileA("msitest\\one.txt");
517 DeleteFileA("msitest\\service.exe");
518 DeleteFileA("msitest\\filename");
519 RemoveDirectoryA("msitest\\second");
520 RemoveDirectoryA("msitest\\first");
521 RemoveDirectoryA("msitest");
524 static void write_file(const CHAR *filename, const char *data, int data_size)
528 HANDLE hf = CreateFile(filename, GENERIC_WRITE, 0, NULL,
529 CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
531 WriteFile(hf, data, data_size, &size, NULL);
535 static void write_msi_summary_info(MSIHANDLE db)
540 r = MsiGetSummaryInformationA(db, NULL, 4, &summary);
541 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
543 r = MsiSummaryInfoSetPropertyA(summary, PID_TEMPLATE, VT_LPSTR, 0, NULL, ";1033");
544 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
546 r = MsiSummaryInfoSetPropertyA(summary, PID_REVNUMBER, VT_LPSTR, 0, NULL,
547 "{004757CA-5092-49c2-AD20-28E1CE0DF5F2}");
548 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
550 r = MsiSummaryInfoSetPropertyA(summary, PID_PAGECOUNT, VT_I4, 100, NULL, NULL);
551 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
553 r = MsiSummaryInfoSetPropertyA(summary, PID_WORDCOUNT, VT_I4, 0, NULL, NULL);
554 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
556 /* write the summary changes back to the stream */
557 r = MsiSummaryInfoPersist(summary);
558 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
560 MsiCloseHandle(summary);
563 static void create_database(const CHAR *name, const msi_table *tables, int num_tables)
569 r = MsiOpenDatabaseA(name, MSIDBOPEN_CREATE, &db);
570 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
572 /* import the tables into the database */
573 for (j = 0; j < num_tables; j++)
575 const msi_table *table = &tables[j];
577 write_file(table->filename, table->data, (table->size - 1) * sizeof(char));
579 r = MsiDatabaseImportA(db, CURR_DIR, table->filename);
580 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
582 DeleteFileA(table->filename);
585 write_msi_summary_info(db);
587 r = MsiDatabaseCommit(db);
588 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
593 static void check_service_is_installed(void)
595 SC_HANDLE scm, service;
598 scm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
599 ok(scm != NULL, "Failed to open the SC Manager\n");
601 service = OpenService(scm, "TestService", SC_MANAGER_ALL_ACCESS);
602 ok(service != NULL, "Failed to open TestService\n");
604 res = DeleteService(service);
605 ok(res, "Failed to delete TestService\n");
608 static void test_MsiInstallProduct(void)
614 DWORD num, size, type;
617 create_database(msifile, tables, sizeof(tables) / sizeof(msi_table));
619 r = MsiInstallProductA(msifile, NULL);
620 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
622 ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
623 ok(delete_pf("msitest\\cabout\\new", FALSE), "File not installed\n");
624 ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
625 ok(delete_pf("msitest\\cabout", FALSE), "File not installed\n");
626 ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
627 ok(delete_pf("msitest\\changed", FALSE), "File not installed\n");
628 ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
629 ok(delete_pf("msitest\\first", FALSE), "File not installed\n");
630 ok(delete_pf("msitest\\one.txt", TRUE), "File not installed\n");
631 ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
632 ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
633 ok(delete_pf("msitest", FALSE), "File not installed\n");
635 res = RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine\\msitest", &hkey);
636 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
640 res = RegQueryValueExA(hkey, "Name", NULL, &type, (LPBYTE)path, &size);
641 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
642 ok(!lstrcmpA(path, "imaname"), "Expected imaname, got %s\n", path);
646 res = RegQueryValueExA(hkey, "blah", NULL, &type, (LPBYTE)path, &size);
647 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
651 res = RegQueryValueExA(hkey, "number", NULL, &type, (LPBYTE)&num, &size);
652 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
653 ok(num == 314, "Expected 314, got %d\n", num);
657 res = RegQueryValueExA(hkey, "OrderTestName", NULL, &type, (LPBYTE)path, &size);
658 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
659 ok(!lstrcmpA(path, "OrderTestValue"), "Expected imaname, got %s\n", path);
661 check_service_is_installed();
663 RegDeleteKeyA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine\\msitest");
668 static void test_MsiSetComponentState(void)
670 INSTALLSTATE installed, action;
675 create_database(msifile, tables, sizeof(tables) / sizeof(msi_table));
679 lstrcpy(path, CURR_DIR);
681 lstrcat(path, msifile);
683 r = MsiOpenPackage(path, &package);
684 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
686 r = MsiDoAction(package, "CostInitialize");
687 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
689 r = MsiDoAction(package, "FileCost");
690 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
692 r = MsiDoAction(package, "CostFinalize");
693 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
695 r = MsiGetComponentState(package, "dangler", &installed, &action);
696 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
697 ok(installed == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", installed);
698 ok(action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
700 r = MsiSetComponentState(package, "dangler", INSTALLSTATE_SOURCE);
701 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
703 MsiCloseHandle(package);
706 DeleteFileA(msifile);
709 static void test_packagecoltypes(void)
711 MSIHANDLE hdb, view, rec;
716 create_database(msifile, tables, sizeof(tables) / sizeof(msi_table));
720 lstrcpy(path, CURR_DIR);
722 lstrcat(path, msifile);
724 r = MsiOpenDatabase(path, MSIDBOPEN_READONLY, &hdb);
725 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
727 query = "SELECT * FROM `Media`";
728 r = MsiDatabaseOpenView( hdb, query, &view );
729 ok(r == ERROR_SUCCESS, "MsiDatabaseOpenView failed\n");
731 r = MsiViewGetColumnInfo( view, MSICOLINFO_NAMES, &rec );
732 count = MsiRecordGetFieldCount( rec );
733 ok(r == ERROR_SUCCESS, "MsiViewGetColumnInfo failed\n");
734 ok(count == 6, "Expected 6, got %d\n", count);
735 ok(check_record(rec, 1, "DiskId"), "wrong column label\n");
736 ok(check_record(rec, 2, "LastSequence"), "wrong column label\n");
737 ok(check_record(rec, 3, "DiskPrompt"), "wrong column label\n");
738 ok(check_record(rec, 4, "Cabinet"), "wrong column label\n");
739 ok(check_record(rec, 5, "VolumeLabel"), "wrong column label\n");
740 ok(check_record(rec, 6, "Source"), "wrong column label\n");
743 r = MsiViewGetColumnInfo( view, MSICOLINFO_TYPES, &rec );
744 count = MsiRecordGetFieldCount( rec );
745 ok(r == ERROR_SUCCESS, "MsiViewGetColumnInfo failed\n");
746 ok(count == 6, "Expected 6, got %d\n", count);
747 ok(check_record(rec, 1, "i2"), "wrong column label\n");
748 ok(check_record(rec, 2, "i4"), "wrong column label\n");
749 ok(check_record(rec, 3, "L64"), "wrong column label\n");
750 ok(check_record(rec, 4, "S255"), "wrong column label\n");
751 ok(check_record(rec, 5, "S32"), "wrong column label\n");
752 ok(check_record(rec, 6, "S72"), "wrong column label\n");
755 MsiCloseHandle(view);
760 static void create_cc_test_files(void)
767 create_file("maximus", 500);
768 create_file("augustus", 50000);
770 set_cab_parameters(&cabParams, "test1.cab", 200);
772 hfci = FCICreate(&erf, file_placed, mem_alloc, mem_free, fci_open,
773 fci_read, fci_write, fci_close, fci_seek, fci_delete,
774 get_temp_file, &cabParams, (void*)"test%d.cab");
775 ok(hfci != NULL, "Failed to create an FCI context\n");
777 /* spews out hundreds of cab files. re-enable when cabinet.dll is fixed */
779 res = add_file(hfci, "maximus", tcompTYPE_MSZIP);
780 ok(res, "Failed to add file maximus\n");
782 res = add_file(hfci, "augustus", tcompTYPE_MSZIP);
785 ok(res, "Failed to add file augustus\n");
789 res = FCIFlushCabinet(hfci, FALSE, get_next_cabinet, progress);
790 ok(res, "Failed to flush the cabinet\n");
792 res = FCIDestroy(hfci);
793 ok(res, "Failed to destroy the cabinet\n");
795 DeleteFile("maximus");
796 DeleteFile("augustus");
799 static void test_continuouscabs(void)
803 create_cc_test_files();
804 create_database(msifile, cc_tables, sizeof(cc_tables) / sizeof(msi_table));
806 r = MsiInstallProductA(msifile, NULL);
809 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
814 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
815 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
817 ok(delete_pf("msitest", FALSE), "File not installed\n");
819 DeleteFile("test1.cab");
820 DeleteFile("test2.cab");
828 get_program_files_dir(PROG_FILES_DIR);
830 GetCurrentDirectoryA(MAX_PATH, CURR_DIR);
831 len = lstrlenA(CURR_DIR);
833 if(len && (CURR_DIR[len-1] == '\\'))
834 CURR_DIR[len - 1] = 0;
836 test_MsiInstallProduct();
837 test_MsiSetComponentState();
838 test_packagecoltypes();
839 test_continuouscabs();