2008/4/1 Vitaly Perov <vitperov(a)etersoft.ru>:
> This test checks if function FDICopy() of cabinet.dll correctly works with an
> empty cabinet file (It's correct cab-file, but it has no files and folders
> inside).
> In this case Windows return TRUE, but WINE return FALSE. So the installation
> of certain software finishes with an error in WINE
>
> Changelog:
> - Test added for cabinet.dll FDICopy function. This test checks if it
> works correctly with an empty cab-files
>
@@ -593,9 +594,67 @@ static void test_FDIIsCabinet(void)
delete_test_files();
}
+
+static void CreateEmptyCab(void)
+{
+ static const unsigned char file_array [] = { 0x4d, 0x53, 0x43, 0x46,
+ 0x00, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x01,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+ HANDLE hFile;
+ DWORD written;
+ BOOL result;
+
+ hFile = CreateFile("test1.cab", GENERIC_WRITE, 0, NULL,
CREATE_ALWAYS, FILE_ATTRIBUTE_TEMPORARY, NULL);
+ assert(hFile != INVALID_HANDLE_VALUE);
+ result=WriteFile(hFile, file_array, sizeof(file_array), &written, NULL);
+ CloseHandle( hFile );
+ assert(result); /*can't write to file*/
+}
+
You need to use the FCI api to create this cabinet.
+static void delEmptyCab(void)
+{
+ assert(DeleteFile("test1.cab"));
+}
+
This is a very pointless function, just call DeleteFile("test...") in
its place. Also, this isn't something that needs an assert.
+INT_PTR __cdecl CopyProgress (FDINOTIFICATIONTYPE fdint,
PFDINOTIFICATION pfdin)
+{
+ return FALSE;
+}
+
Inconsistent style (space before opening parenthesis).
+static void test_FDICopy(void)
+{
+ HFDI hfdi;
+ ERF erf;
+ BOOL ret;
+ char name[] = "test1.cab";
+ char path[] = ""; /*native crashes if path=NULL*/
+
The pszCabPath parameter of FDICopy should be the current directory.
If you want to test using a relative cabinet path, do it in another
test.
+ /* native crashes if hfdi is NULL or invalid*/
These comments don't really apply to the test you've added. You're
only testing one thing (thus, unit test): how FDICopy responds to an
empty cabinet.
+ hfdi = FDICreate(fdi_alloc, fdi_free, fdi_open, fdi_read,
+ fdi_write, fdi_close, fdi_seek,
+ cpuUNKNOWN, &erf);
+ ok(hfdi, "Expected non-NULL context\n");
+
+ /* TESTING FDICopy() */
Pointless comment, please remove it.
+ CreateEmptyCab();
+ ret=FDICopy(hfdi,name,path,0,CopyProgress,NULL,0);
+ delEmptyCab();
Please move this (actually, a call to DeleteFile, see above) to the
end of the function where cleanup happens. It gets in the way of the
results of the test.
+ todo_wine
+ {
+ ok(ret, "Expected TRUE, got %d\n", ret);
+ }
+
If you're expecting TRUE, check for TRUE like the rest of the tests in
this file.
+ /* successfully destroy hfdi*/
+ ret = FDIDestroy(hfdi);
+ ok(ret, "Expected TRUE, got %d\n", ret);
+}
--
James Hawkins