Hans Leidekker : setupapi: Add tests for SetupGetFileCompressionInfoEx.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Apr 9 07:36:12 CDT 2007


Module: wine
Branch: master
Commit: c1a856e64989c9981d1bc2a55b14c4606f6d51dc
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=c1a856e64989c9981d1bc2a55b14c4606f6d51dc

Author: Hans Leidekker <hans at it.vu.nl>
Date:   Sun Apr  8 13:19:01 2007 +0200

setupapi: Add tests for SetupGetFileCompressionInfoEx.

---

 dlls/setupapi/tests/misc.c |  114 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 114 insertions(+), 0 deletions(-)

diff --git a/dlls/setupapi/tests/misc.c b/dlls/setupapi/tests/misc.c
index 2efaa64..2c5c0f3 100644
--- a/dlls/setupapi/tests/misc.c
+++ b/dlls/setupapi/tests/misc.c
@@ -2,6 +2,7 @@
  * Miscellaneous tests
  *
  * Copyright 2007 James Hawkins
+ * Copyright 2007 Hans Leidekker
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -247,9 +248,122 @@ static void test_SetupCopyOEMInf(void)
     ok(!file_exists(path), "Expected source inf to not exist\n");
 }
 
+static void create_source_file(LPSTR filename, const BYTE *data, DWORD size)
+{
+    HANDLE handle;
+    DWORD written;
+
+    handle = CreateFileA(filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+    WriteFile(handle, data, size, &written, NULL);
+    CloseHandle(handle);
+}
+
+static const BYTE uncompressed[] = {
+    'u','n','c','o','m','p','r','e','s','s','e','d','\r','\n'
+};
+static const BYTE comp_lzx[] = {
+    0x53, 0x5a, 0x44, 0x44, 0x88, 0xf0, 0x27, 0x33, 0x41, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xff, 0x00,
+    0x00, 0x75, 0x6e, 0x63, 0x6f, 0x6d, 0x70, 0x3f, 0x72, 0x65, 0x73, 0x73, 0x65, 0x64
+};
+static const BYTE comp_zip[] = {
+    0x50, 0x4b, 0x03, 0x04, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbd, 0xae, 0x81, 0x36, 0x75, 0x11,
+    0x2c, 0x1b, 0x0e, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x04, 0x00, 0x15, 0x00, 0x77, 0x69,
+    0x6e, 0x65, 0x55, 0x54, 0x09, 0x00, 0x03, 0xd6, 0x0d, 0x10, 0x46, 0xfd, 0x0d, 0x10, 0x46, 0x55,
+    0x78, 0x04, 0x00, 0xe8, 0x03, 0xe8, 0x03, 0x00, 0x00, 0x75, 0x6e, 0x63, 0x6f, 0x6d, 0x70, 0x72,
+    0x65, 0x73, 0x73, 0x65, 0x64, 0x50, 0x4b, 0x01, 0x02, 0x17, 0x03, 0x0a, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0xbd, 0xae, 0x81, 0x36, 0x75, 0x11, 0x2c, 0x1b, 0x0e, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00,
+    0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa4, 0x81, 0x00,
+    0x00, 0x00, 0x00, 0x77, 0x69, 0x6e, 0x65, 0x55, 0x54, 0x05, 0x00, 0x03, 0xd6, 0x0d, 0x10, 0x46,
+    0x55, 0x78, 0x00, 0x00, 0x50, 0x4b, 0x05, 0x06, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00,
+    0x3f, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+static const BYTE comp_cab_lzx[] = {
+    0x4d, 0x53, 0x43, 0x46, 0x00, 0x00, 0x00, 0x00, 0x6b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x2c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x01, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, 0x01, 0x00, 0x03, 0x0f, 0x0e, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x84, 0x36, 0x86, 0x72, 0x20, 0x00, 0x77, 0x69, 0x6e, 0x65,
+    0x00, 0x19, 0xd0, 0x1a, 0xe3, 0x22, 0x00, 0x0e, 0x00, 0x5b, 0x80, 0x80, 0x8d, 0x00, 0x30, 0xe0,
+    0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x75, 0x6e, 0x63,
+    0x6f, 0x6d, 0x70, 0x72, 0x65, 0x73, 0x73, 0x65, 0x64, 0x0d, 0x0a
+};
+static const BYTE comp_cab_zip[] =  {
+    0x4d, 0x53, 0x43, 0x46, 0x00, 0x00, 0x00, 0x00, 0x5b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x2c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x01, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x0e, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0x36, 0x2f, 0xa5, 0x20, 0x00, 0x77, 0x69, 0x6e, 0x65,
+    0x00, 0x7c, 0x80, 0x26, 0x2b, 0x12, 0x00, 0x0e, 0x00, 0x43, 0x4b, 0x2b, 0xcd, 0x4b, 0xce, 0xcf,
+    0x2d, 0x28, 0x4a, 0x2d, 0x2e, 0x4e, 0x4d, 0xe1, 0xe5, 0x02, 0x00
+};
+
+static void test_SetupGetFileCompressionInfoEx(void)
+{
+    BOOL ret;
+    DWORD required_len, source_size, target_size;
+    char source[MAX_PATH], temp[MAX_PATH], name[MAX_PATH];
+    UINT type;
+
+    GetTempPathA(sizeof(temp), temp);
+    GetTempFileNameA(temp, "doc", 0, source);
+
+    ret = SetupGetFileCompressionInfoExA(NULL, NULL, 0, NULL, NULL, NULL, NULL);
+    ok(!ret, "SetupGetFileCompressionInfoEx succeeded unexpectedly\n");
+
+    ret = SetupGetFileCompressionInfoExA(source, NULL, 0, NULL, NULL, NULL, NULL);
+    ok(!ret, "SetupGetFileCompressionInfoEx succeeded unexpectedly\n");
+
+    ret = SetupGetFileCompressionInfoExA(source, NULL, 0, &required_len, NULL, NULL, NULL);
+    ok(!ret, "SetupGetFileCompressionInfoEx succeeded unexpectedly\n");
+    ok(required_len == lstrlenA(source) + 1, "got %d, expected %d\n", required_len, lstrlenA(source) + 1);
+
+    create_source_file(source, comp_lzx, sizeof(comp_lzx));
+
+    ret = SetupGetFileCompressionInfoExA(source, name, sizeof(name), &required_len, &source_size, &target_size, &type);
+    ok(ret, "SetupGetFileCompressionInfoEx failed unexpectedly: %d\n", ret);
+    ok(!lstrcmpA(name, source), "got %s, expected %s\n", name, source);
+    ok(required_len == lstrlenA(source) + 1, "got %d, expected %d\n", required_len, lstrlenA(source) + 1);
+    ok(source_size == sizeof(comp_lzx), "got %d, expected %d\n", source_size, sizeof(comp_lzx));
+    ok(target_size == sizeof(uncompressed), "got %d, expected %d\n", target_size, sizeof(uncompressed));
+    ok(type == FILE_COMPRESSION_WINLZA, "got %d, expected FILE_COMPRESSION_WINLZA\n", type);
+    DeleteFileA(source);
+
+    create_source_file(source, comp_zip, sizeof(comp_zip));
+
+    ret = SetupGetFileCompressionInfoExA(source, name, sizeof(name), &required_len, &source_size, &target_size, &type);
+    ok(ret, "SetupGetFileCompressionInfoEx failed unexpectedly: %d\n", ret);
+    ok(!lstrcmpA(name, source), "got %s, expected %s\n", name, source);
+    ok(required_len == lstrlenA(source) + 1, "got %d, expected %d\n", required_len, lstrlenA(source) + 1);
+    ok(source_size == sizeof(comp_zip), "got %d, expected %d\n", source_size, sizeof(comp_zip));
+    ok(target_size == sizeof(comp_zip), "got %d, expected %d\n", target_size, sizeof(comp_zip));
+    ok(type == FILE_COMPRESSION_NONE, "got %d, expected FILE_COMPRESSION_NONE\n", type);
+    DeleteFileA(source);
+
+    create_source_file(source, comp_cab_lzx, sizeof(comp_cab_lzx));
+
+    ret = SetupGetFileCompressionInfoExA(source, name, sizeof(name), &required_len, &source_size, &target_size, &type);
+    ok(ret, "SetupGetFileCompressionInfoEx failed unexpectedly: %d\n", ret);
+    ok(!lstrcmpA(name, source), "got %s, expected %s\n", name, source);
+    ok(required_len == lstrlenA(source) + 1, "got %d, expected %d\n", required_len, lstrlenA(source) + 1);
+    ok(source_size == sizeof(comp_cab_lzx), "got %d, expected %d\n", source_size, sizeof(comp_cab_lzx));
+    ok(target_size == sizeof(uncompressed), "got %d, expected %d\n", target_size, sizeof(uncompressed));
+    ok(type == FILE_COMPRESSION_MSZIP, "got %d, expected FILE_COMPRESSION_MSZIP\n", type);
+    DeleteFileA(source);
+
+    create_source_file(source, comp_cab_zip, sizeof(comp_cab_zip));
+
+    ret = SetupGetFileCompressionInfoExA(source, name, sizeof(name), &required_len, &source_size, &target_size, &type);
+    ok(ret, "SetupGetFileCompressionInfoEx failed unexpectedly: %d\n", ret);
+    ok(!lstrcmpA(name, source), "got %s, expected %s\n", name, source);
+    ok(required_len == lstrlenA(source) + 1, "got %d, expected %d\n", required_len, lstrlenA(source) + 1);
+    ok(source_size == sizeof(comp_cab_zip), "got %d, expected %d\n", source_size, sizeof(comp_cab_zip));
+    ok(target_size == sizeof(uncompressed), "got %d, expected %d\n", target_size, sizeof(uncompressed));
+    ok(type == FILE_COMPRESSION_MSZIP, "got %d, expected FILE_COMPRESSION_MSZIP\n", type);
+    DeleteFileA(source);
+}
+
 START_TEST(misc)
 {
     GetCurrentDirectoryA(MAX_PATH, CURR_DIR);
 
     test_SetupCopyOEMInf();
+    test_SetupGetFileCompressionInfoEx();
 }




More information about the wine-cvs mailing list