Sync to trunk (r44789)
[reactos.git] / rostests / winetests / shell32 / shlfolder.c
index 903c089..435942b 100644 (file)
@@ -472,7 +472,8 @@ static void test_GetDisplayName(void)
     /* WinXP and up store the filenames as both ANSI and UNICODE in the pidls */
     if (pidlLast->mkid.cb >= 76) {
         ok(!lstrcmpW((WCHAR*)&pidlLast->mkid.abID[46], wszFileName) ||
-            (pidlLast->mkid.cb >= 94 && !lstrcmpW((WCHAR*)&pidlLast->mkid.abID[64], wszFileName)), /* Vista */
+            (pidlLast->mkid.cb >= 94 && !lstrcmpW((WCHAR*)&pidlLast->mkid.abID[64], wszFileName)) ||  /* Vista */
+            (pidlLast->mkid.cb >= 98 && !lstrcmpW((WCHAR*)&pidlLast->mkid.abID[68], wszFileName)), /* Win7 */
             "Filename should be stored as wchar-string at this position!\n");
     }
     
@@ -585,6 +586,7 @@ static void test_GetDisplayName(void)
         ok (!lstrcmpiW(wszTestFile, wszTestFile2), "GetDisplayNameOf returns incorrect path!\n");
     }
     
+    ILFree(pidlTestFile);
     IShellFolder_Release(psfDesktop);
     IShellFolder_Release(psfPersonal);
 }
@@ -646,8 +648,12 @@ static void test_CallForAttributes(void)
      * key. So the test will return at this point, if run on wine. 
      */
     lResult = RegOpenKeyExW(HKEY_CLASSES_ROOT, wszMyDocumentsKey, 0, KEY_WRITE|KEY_READ, &hKey);
-    ok (lResult == ERROR_SUCCESS, "RegOpenKeyEx failed! result: %08x\n", lResult);
+    ok (lResult == ERROR_SUCCESS ||
+        lResult == ERROR_ACCESS_DENIED,
+        "RegOpenKeyEx failed! result: %08x\n", lResult);
     if (lResult != ERROR_SUCCESS) {
+        if (lResult == ERROR_ACCESS_DENIED)
+            skip("Not enough rights to open the registry key\n");
         IMalloc_Free(ppM, pidlMyDocuments);
         IShellFolder_Release(psfDesktop);
         return;
@@ -1524,18 +1530,38 @@ static void test_ITEMIDLIST_format(void) {
                     pFileStructA->uFileTime == pFileStructW->uTime,
                     "Last write time should match creation time!\n");
     
-                ok (pFileStructA->uFileDate == pFileStructW->uDate2 &&
-                    pFileStructA->uFileTime == pFileStructW->uTime2,
-                    "Last write time should match last access time!\n");
+                /* On FAT filesystems the last access time is midnight
+                   local time, so the values of uDate2 and uTime2 will
+                   depend on the local timezone.  If the times are exactly
+                   equal then the dates should be identical for both FAT
+                   and NTFS as no timezone is more than 1 day away from UTC.
+                */
+                if (pFileStructA->uFileTime == pFileStructW->uTime2)
+                {
+                    ok (pFileStructA->uFileDate == pFileStructW->uDate2,
+                        "Last write date and time should match last access date and time!\n");
+                }
+                else
+                {
+                    /* Filesystem may be FAT. Check date within 1 day
+                       and seconds are zero. */
+                    trace ("Filesystem may be FAT. Performing less strict atime test.\n");
+                    ok ((pFileStructW->uTime2 & 0x1F) == 0,
+                        "Last access time on FAT filesystems should have zero seconds.\n");
+                    /* TODO: Perform check for date being within one day.*/
+                }
 
                 ok (!lstrcmpW(wszFile[i], pFileStructW->wszName) ||
-                    !lstrcmpW(wszFile[i], (WCHAR *)(pFileStructW->abFooBar2 + 22)), /* Vista */
+                    !lstrcmpW(wszFile[i], (WCHAR *)(pFileStructW->abFooBar2 + 22)) || /* Vista */
+                    !lstrcmpW(wszFile[i], (WCHAR *)(pFileStructW->abFooBar2 + 26)), /* Win7 */
                     "The filename should be stored in unicode at this position!\n");
             }
         }
 
         pILFree(pidlFile);
     }
+
+    IShellFolder_Release(psfPersonal);
 }
 
 static void testSHGetFolderPathAndSubDirA(void)