Francois Gouget : shell32/tests: Hack SHGetFileInfo() so it does not crash and add a test for it.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Jan 8 06:35:16 CST 2007


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

Author: Francois Gouget <fgouget at free.fr>
Date:   Sat Jan  6 19:24:06 2007 +0100

shell32/tests: Hack SHGetFileInfo() so it does not crash and add a test for it.

---

 dlls/shell32/shell32_main.c    |    8 ++++++++
 dlls/shell32/tests/shlfileop.c |   22 ++++++++++++++++++++++
 2 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/dlls/shell32/shell32_main.c b/dlls/shell32/shell32_main.c
index 797f98e..476a4ae 100644
--- a/dlls/shell32/shell32_main.c
+++ b/dlls/shell32/shell32_main.c
@@ -356,6 +356,14 @@ DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR
          (flags & (SHGFI_ATTRIBUTES|SHGFI_EXETYPE|SHGFI_PIDL)))
         return FALSE;
 
+    if ( (flags & SHGFI_USEFILEATTRIBUTES) &&
+         (flags & (SHGFI_ICONLOCATION | SHGFI_ICON | SHGFI_SYSICONINDEX)) )
+    {
+        FIXME("This combination of flags is not supported yet\n");
+        /* And it would cause a crash, so return false instead */
+        return FALSE;
+    }
+
     /* windows initializes these values regardless of the flags */
     if (psfi != NULL)
     {
diff --git a/dlls/shell32/tests/shlfileop.c b/dlls/shell32/tests/shlfileop.c
index c016b56..c6d8004 100644
--- a/dlls/shell32/tests/shlfileop.c
+++ b/dlls/shell32/tests/shlfileop.c
@@ -111,6 +111,26 @@ static void clean_after_shfo_tests(void)
     RemoveDirectoryA("nonexistent");
 }
 
+
+static void test_get_file_info(void)
+{
+    DWORD rc;
+    SHFILEINFO shfi;
+
+    strcpy(shfi.szDisplayName, "dummy");
+    shfi.iIcon=0xdeadbeef;
+    rc=SHGetFileInfoA("c:\\nonexistent", FILE_ATTRIBUTE_DIRECTORY,
+                      &shfi, sizeof(shfi),
+                      SHGFI_ICONLOCATION | SHGFI_USEFILEATTRIBUTES);
+    todo_wine ok(rc, "SHGetFileInfoA(c:\\nonexistent) returned %d\n", rc);
+    if (rc)
+    {
+        ok(strcpy(shfi.szDisplayName, "dummy") != 0, "SHGetFileInfoA(c:\\nonexistent) displayname is not set\n");
+        ok(shfi.iIcon != 0xdeadbeef, "SHGetFileInfoA(c:\\nonexistent) iIcon is not set\n");
+    }
+}
+
+
 /*
  puts into the specified buffer file names with current directory.
  files - string with file names, separated by null characters. Ends on a double
@@ -855,6 +875,8 @@ START_TEST(shlfileop)
 
     clean_after_shfo_tests();
 
+    test_get_file_info();
+
     init_shfo_tests();
     test_delete();
     clean_after_shfo_tests();




More information about the wine-cvs mailing list