[SHELL32_WINETEST]
authorChristoph von Wittich <christoph_vw@reactos.org>
Thu, 4 Mar 2010 20:55:58 +0000 (20:55 +0000)
committerChristoph von Wittich <christoph_vw@reactos.org>
Thu, 4 Mar 2010 20:55:58 +0000 (20:55 +0000)
sync shell32_winetest to wine 1.1.39

svn path=/trunk/; revision=45842

rostests/winetests/shell32/autocomplete.c
rostests/winetests/shell32/progman_dde.c
rostests/winetests/shell32/shelllink.c
rostests/winetests/shell32/shellpath.c
rostests/winetests/shell32/shlfileop.c

index 20315c7..042e238 100644 (file)
@@ -33,7 +33,8 @@ static HWND hMainWnd, hEdit;
 static HINSTANCE hinst;
 static int killfocus_count;
 
-static BOOL test_init(void) {
+static IAutoComplete *test_init(void)
+{
     HRESULT r;
     IAutoComplete* ac;
     IUnknown *acSource;
@@ -44,7 +45,7 @@ static BOOL test_init(void) {
     if (r == REGDB_E_CLASSNOTREG)
     {
         win_skip("CLSID_AutoComplete is not registered\n");
-        return FALSE;
+        return NULL;
     }
     ok(SUCCEEDED(r), "no IID_IAutoComplete (0x%08x)\n", r);
 
@@ -54,7 +55,7 @@ static BOOL test_init(void) {
     if (r == REGDB_E_CLASSNOTREG)
     {
         win_skip("CLSID_ACLMulti is not registered\n");
-        return FALSE;
+        return NULL;
     }
     ok(SUCCEEDED(r), "no IID_IACList (0x%08x)\n", r);
 
@@ -62,9 +63,13 @@ static BOOL test_init(void) {
     r = IAutoComplete_Init(ac, hEdit, acSource, NULL, NULL);
     ok(SUCCEEDED(r), "Init failed (0x%08x)\n", r);
 
-    return TRUE;
+    IUnknown_Release(acSource);
+
+    return ac;
 }
-static void test_killfocus(void) {
+
+static void test_killfocus(void)
+{
     /* Test if WM_KILLFOCUS messages are handled properly by checking if
      * the parent receives an EN_KILLFOCUS message. */
     SetFocus(hEdit);
@@ -72,7 +77,9 @@ static void test_killfocus(void) {
     SetFocus(0);
     ok(killfocus_count == 1, "Expected one EN_KILLFOCUS message, got: %d\n", killfocus_count);
 }
-static LRESULT CALLBACK MyWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
+
+static LRESULT CALLBACK MyWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
     switch(msg) {
     case WM_CREATE:
         /* create edit control */
@@ -87,7 +94,9 @@ static LRESULT CALLBACK MyWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa
     }
     return DefWindowProcA(hWnd, msg, wParam, lParam);
 }
-static void createMainWnd(void) {
+
+static void createMainWnd(void)
+{
     WNDCLASSA wc;
     wc.style = CS_HREDRAW | CS_VREDRAW;
     wc.cbClsExtra = 0;
@@ -104,9 +113,12 @@ static void createMainWnd(void) {
     hMainWnd = CreateWindowExA(0, "MyTestWnd", "Blah", WS_OVERLAPPEDWINDOW,
       CW_USEDEFAULT, CW_USEDEFAULT, 130, 105, NULL, NULL, GetModuleHandleA(NULL), 0);
 }
-START_TEST(autocomplete) {
+
+START_TEST(autocomplete)
+{
     HRESULT r;
     MSG msg;
+    IAutoComplete* ac;
 
     r = CoInitialize(NULL);
     ok(SUCCEEDED(r), "CoInitialize failed (0x%08x). Tests aborted.\n", r);
@@ -118,7 +130,8 @@ START_TEST(autocomplete) {
     if(!ok(hMainWnd != NULL, "Failed to create parent window. Tests aborted.\n"))
         return;
 
-    if (!test_init())
+    ac = test_init();
+    if (!ac)
         goto cleanup;
     test_killfocus();
 
@@ -128,6 +141,8 @@ START_TEST(autocomplete) {
         DispatchMessageA(&msg);
     }
 
+    IAutoComplete_Release(ac);
+
 cleanup:
     DestroyWindow(hEdit);
     DestroyWindow(hMainWnd);
index 0a7fdaa..333e1f1 100644 (file)
@@ -102,6 +102,30 @@ static BOOL use_common(void)
     return TRUE;
 }
 
+static BOOL full_title(void)
+{
+    CABINETSTATE cs;
+
+    memset(&cs, 0, sizeof(cs));
+    if (pReadCabinetState)
+    {
+        pReadCabinetState(&cs, sizeof(cs));
+    }
+    else
+    {
+        HKEY key;
+        DWORD size;
+
+        win_skip("ReadCabinetState is not available, reading registry directly\n");
+        RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CabinetState", &key);
+        size = sizeof(cs);
+        RegQueryValueExA(key, "Settings", NULL, NULL, (LPBYTE)&cs, &size);
+        RegCloseKey(key);
+    }
+
+    return (cs.fFullPathTitle == -1);
+}
+
 static char ProgramsDir[MAX_PATH];
 
 static char Group1Title[MAX_PATH]  = "Group1";
@@ -115,8 +139,6 @@ static void init_strings(void)
     char commonprograms[MAX_PATH];
     char programs[MAX_PATH];
 
-    CABINETSTATE cs;
-
     if (pSHGetSpecialFolderPathA)
     {
         pSHGetSpecialFolderPathA(NULL, programs, CSIDL_PROGRAMS, FALSE);
@@ -153,9 +175,7 @@ static void init_strings(void)
     else
         lstrcpyA(ProgramsDir, programs);
 
-    memset(&cs, 0, sizeof(cs));
-    pReadCabinetState(&cs, sizeof(cs));
-    if (cs.fFullPathTitle == -1)
+    if (full_title())
     {
         lstrcpyA(Group1Title, ProgramsDir);
         lstrcatA(Group1Title, "\\Group1");
index 2535471..bb2d5b3 100755 (executable)
@@ -207,6 +207,7 @@ static void test_get_set(void)
         }
         if (ret)
             ok(lstrcmpi(buffer,str)==0, "GetIDList returned '%s'\n", buffer);
+        pILFree(tmp_pidl);
     }
 
     pidl=path_to_pidl(mypath);
@@ -214,6 +215,8 @@ static void test_get_set(void)
 
     if (pidl)
     {
+        LPITEMIDLIST second_pidl;
+
         r = IShellLinkA_SetIDList(sl, pidl);
         ok(SUCCEEDED(r), "SetIDList failed (0x%08x)\n", r);
 
@@ -223,7 +226,14 @@ static void test_get_set(void)
         ok(tmp_pidl && pILIsEqual(pidl, tmp_pidl),
            "GetIDList returned an incorrect pidl\n");
 
-        /* tmp_pidl is owned by IShellLink so we don't free it */
+        r = IShellLinkA_GetIDList(sl, &second_pidl);
+        ok(SUCCEEDED(r), "GetIDList failed (0x%08x)\n", r);
+        ok(second_pidl && pILIsEqual(pidl, second_pidl),
+           "GetIDList returned an incorrect pidl\n");
+        ok(second_pidl != tmp_pidl, "pidls are the same\n");
+
+        pILFree(second_pidl);
+        pILFree(tmp_pidl);
         pILFree(pidl);
 
         strcpy(buffer,"garbage");
index f9f59e1..c035aaf 100644 (file)
@@ -675,7 +675,7 @@ static void testWinDir(void)
  */
 static void testSystemDir(void)
 {
-    char systemShellPath[MAX_PATH], systemDir[MAX_PATH] = { 0 };
+    char systemShellPath[MAX_PATH], systemDir[MAX_PATH], systemDirx86[MAX_PATH];
 
     if (!pSHGetSpecialFolderPathA) return;
 
@@ -689,13 +689,13 @@ static void testSystemDir(void)
          systemDir, systemShellPath);
     }
 
-    if (!pGetSystemWow64DirectoryA || !pGetSystemWow64DirectoryA(systemDir, sizeof(systemDir)))
-        GetSystemDirectoryA(systemDir, sizeof(systemDir));
-    myPathRemoveBackslashA(systemDir);
+    if (!pGetSystemWow64DirectoryA || !pGetSystemWow64DirectoryA(systemDirx86, sizeof(systemDirx86)))
+        GetSystemDirectoryA(systemDirx86, sizeof(systemDirx86));
+    myPathRemoveBackslashA(systemDirx86);
     if (pSHGetSpecialFolderPathA(NULL, systemShellPath, CSIDL_SYSTEMX86, FALSE))
     {
         myPathRemoveBackslashA(systemShellPath);
-        ok(!lstrcmpiA(systemDir, systemShellPath),
+        ok(!lstrcmpiA(systemDirx86, systemShellPath) || broken(!lstrcmpiA(systemDir, systemShellPath)),
          "GetSystemDirectory returns %s SHGetSpecialFolderPath returns %s\n",
          systemDir, systemShellPath);
     }
index 0a5cdca..777801e 100644 (file)
@@ -47,6 +47,8 @@
        broken(retval == ret_prewin32),\
        "Expected %d, got %d\n", ret, retval)
 
+static BOOL old_shell32 = FALSE;
+
 static CHAR CURR_DIR[MAX_PATH];
 static const WCHAR UNICODE_PATH[] = {'c',':','\\',0x00ae,'\0','\0'};
     /* "c:\®" can be used in all codepages */
@@ -764,6 +766,8 @@ static void test_rename(void)
     /* pTo already exist */
     shfo.pFrom = "test1.txt\0";
     shfo.pTo = "test2.txt\0";
+    if (old_shell32)
+        shfo.fFlags |= FOF_NOCONFIRMMKDIR;
     retval = SHFileOperationA(&shfo);
     if (retval == ERROR_SUCCESS)
     {
@@ -817,6 +821,12 @@ static void test_copy(void)
     LPSTR ptr;
     BOOL on_nt4 = FALSE;
 
+    if (old_shell32)
+    {
+        win_skip("Too many differences for old shell32\n");
+        return;
+    }
+
     shfo.hwnd = NULL;
     shfo.wFunc = FO_COPY;
     shfo.pFrom = from;
@@ -1710,6 +1720,21 @@ static void test_copy(void)
     ok(DeleteFileA("ab.txt"), "Expected file to exist\n");
     ok(RemoveDirectoryA("one"), "Expected dir to exist\n");
     ok(RemoveDirectoryA("two"), "Expected dir to exist\n");
+
+    /* pTo is an empty string  */
+    CreateDirectoryA("dir", NULL);
+    createTestFile("dir\\abcdefgh.abc");
+    shfo.pFrom = "dir\\abcdefgh.abc\0";
+    shfo.pTo = "\0";
+    shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI;
+    retval = SHFileOperation(&shfo);
+    ok(retval == ERROR_SUCCESS ||
+       broken(retval == DE_OPCANCELLED), /* NT4 */
+       "Expected ERROR_SUCCESS, got %d\n", retval);
+    if (retval == ERROR_SUCCESS)
+        ok(DeleteFileA("abcdefgh.abc"), "Expected file to exist\n");
+    ok(DeleteFileA("dir\\abcdefgh.abc"), "Expected file to exist\n");
+    ok(RemoveDirectoryA("dir"), "Expected dir to exist\n");
 }
 
 /* tests the FO_MOVE action */
@@ -1751,6 +1776,8 @@ static void test_move(void)
 
     set_curr_dir_path(from, "test1.txt\0test2.txt\0test4.txt\0");
     set_curr_dir_path(to, "test6.txt\0test7.txt\0test8.txt\0");
+    if (old_shell32)
+        shfo2.fFlags |= FOF_NOCONFIRMMKDIR;
     ok(!SHFileOperationA(&shfo2), "Move many files\n");
     ok(DeleteFileA("test6.txt"), "The file is not moved - many files are "
        "specified as a target\n");
@@ -1765,12 +1792,23 @@ static void test_move(void)
     retval = SHFileOperationA(&shfo2);
     if (dir_exists("test6.txt"))
     {
-        /* Vista and W2K8 (broken or new behavior ?) */
-        ok(retval == DE_DESTSAMETREE, "Expected DE_DESTSAMETREE, got %d\n", retval);
-        ok(DeleteFileA("test6.txt\\test1.txt"), "The file is not moved\n");
-        RemoveDirectoryA("test6.txt");
-        ok(DeleteFileA("test7.txt\\test2.txt"), "The file is not moved\n");
-        RemoveDirectoryA("test7.txt");
+        if (retval == ERROR_SUCCESS)
+        {
+            /* Old shell32 */
+            DeleteFileA("test6.txt\\test1.txt");
+            DeleteFileA("test6.txt\\test2.txt");
+            RemoveDirectoryA("test6.txt\\test4.txt");
+            RemoveDirectoryA("test6.txt");
+        }
+        else
+        {
+            /* Vista and W2K8 (broken or new behavior ?) */
+            ok(retval == DE_DESTSAMETREE, "Expected DE_DESTSAMETREE, got %d\n", retval);
+            ok(DeleteFileA("test6.txt\\test1.txt"), "The file is not moved\n");
+            RemoveDirectoryA("test6.txt");
+            ok(DeleteFileA("test7.txt\\test2.txt"), "The file is not moved\n");
+            RemoveDirectoryA("test7.txt");
+        }
     }
     else
     {
@@ -1788,9 +1826,12 @@ static void test_move(void)
 
     set_curr_dir_path(from, "test1.txt\0test2.txt\0test4.txt\0");
     set_curr_dir_path(to, "test6.txt\0test7.txt\0test8.txt\0");
+    if (old_shell32)
+        shfo.fFlags |= FOF_NOCONFIRMMKDIR;
     retval = SHFileOperationA(&shfo);
     if (dir_exists("test6.txt"))
     {
+        /* Old shell32 */
         /* Vista and W2K8 (broken or new behavior ?) */
         ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
         ok(DeleteFileA("test6.txt\\test1.txt"), "The file is not moved. Many files are specified\n");
@@ -1839,8 +1880,14 @@ static void test_move(void)
     else
     {
         ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
+        if (old_shell32)
+        {
+            DeleteFile("a.txt\\a.txt");
+            RemoveDirectoryA("a.txt");
+        }
+        else
+            ok(DeleteFile("a.txt"), "Expected a.txt to exist\n");
         ok(!file_exists("test1.txt"), "Expected test1.txt to not exist\n");
-        ok(DeleteFile("a.txt"), "Expected a.txt to exist\n");
     }
     ok(!file_exists("b.txt"), "Expected b.txt to not exist\n");
 
@@ -1850,6 +1897,7 @@ static void test_move(void)
     retval = SHFileOperationA(&shfo);
     if (dir_exists("test1.txt"))
     {
+        /* Old shell32 */
         /* Vista and W2K8 (broken or new behavior ?) */
         ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
         ok(DeleteFileA("test1.txt\\test2.txt"), "Expected test1.txt\\test2.txt to exist\n");
@@ -1882,6 +1930,7 @@ static void test_move(void)
     retval = SHFileOperationA(&shfo);
     if (dir_exists("d.txt"))
     {
+        /* Old shell32 */
         /* Vista and W2K8 (broken or new behavior ?) */
         ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
         ok(DeleteFileA("d.txt\\test2.txt"), "Expected d.txt\\test2.txt to exist\n");
@@ -1903,13 +1952,23 @@ static void test_move(void)
     retval = SHFileOperationA(&shfo);
     if (dir_exists("d.txt"))
     {
-        /* Vista and W2K8 (broken or new behavior ?) */
-        ok(retval == DE_SAMEFILE,
-           "Expected DE_SAMEFILE, got %d\n", retval);
-        ok(DeleteFileA("d.txt\\test2.txt"), "Expected d.txt\\test2.txt to exist\n");
-        ok(!file_exists("d.txt\\test3.txt"), "Expected d.txt\\test3.txt to not exist\n");
-        RemoveDirectoryA("d.txt");
-        createTestFile("test2.txt");
+        if (old_shell32)
+        {
+            DeleteFileA("d.txt\\test2.txt");
+            DeleteFileA("d.txt\\test3.txt");
+            RemoveDirectoryA("d.txt");
+            createTestFile("test2.txt");
+        }
+        else
+        {
+            /* Vista and W2K8 (broken or new behavior ?) */
+            ok(retval == DE_SAMEFILE,
+               "Expected DE_SAMEFILE, got %d\n", retval);
+            ok(DeleteFileA("d.txt\\test2.txt"), "Expected d.txt\\test2.txt to exist\n");
+            ok(!file_exists("d.txt\\test3.txt"), "Expected d.txt\\test3.txt to not exist\n");
+            RemoveDirectoryA("d.txt");
+            createTestFile("test2.txt");
+        }
     }
     else
     {
@@ -1947,7 +2006,13 @@ static void test_move(void)
     {
         ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
         ok(!file_exists("test2.txt"), "Expected test2.txt to not exist\n");
-        ok(file_exists("test3.txt"), "Expected test3.txt to exist\n");
+        if (old_shell32)
+        {
+            DeleteFileA("test3.txt\\test3.txt");
+            RemoveDirectoryA("test3.txt");
+        }
+        else
+            ok(file_exists("test3.txt"), "Expected test3.txt to exist\n");
     }
 }
 
@@ -2224,12 +2289,67 @@ static void test_unicode(void)
     ok(!file_existsW(UNICODE_PATH), "The directory should have been removed\n");
 }
 
+extern HRESULT WINAPI Shell_MergeMenus (HMENU hmDst, HMENU hmSrc, UINT uInsert, UINT uIDAdjust, UINT uIDAdjustMax, ULONG uFlags);
+
+static void
+test_shlmenu(void) {
+       HRESULT hres;
+       hres = Shell_MergeMenus (0, 0, 0x42, 0x4242, 0x424242, 0);
+       ok (hres == 0x4242, "expected 0x4242 but got %x\n", hres);
+       hres = Shell_MergeMenus ((HMENU)42, 0, 0x42, 0x4242, 0x424242, 0);
+       ok (hres == 0x4242, "expected 0x4242 but got %x\n", hres);
+}
+
+/* Check for old shell32 (4.0.x) */
+static BOOL is_old_shell32(void)
+{
+    SHFILEOPSTRUCTA shfo;
+    CHAR from[5*MAX_PATH];
+    CHAR to[5*MAX_PATH];
+    DWORD retval;
+
+    shfo.hwnd = NULL;
+    shfo.wFunc = FO_COPY;
+    shfo.pFrom = from;
+    shfo.pTo = to;
+    /* FOF_NOCONFIRMMKDIR is needed for old shell32 */
+    shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI | FOF_MULTIDESTFILES | FOF_NOCONFIRMMKDIR;
+    shfo.hNameMappings = NULL;
+    shfo.lpszProgressTitle = NULL;
+
+    set_curr_dir_path(from, "test1.txt\0test2.txt\0test3.txt\0");
+    set_curr_dir_path(to, "test6.txt\0test7.txt\0");
+    retval = SHFileOperationA(&shfo);
+
+    /* Delete extra files on old shell32 and Vista+*/
+    DeleteFileA("test6.txt\\test1.txt");
+    /* Delete extra files on old shell32 */
+    DeleteFileA("test6.txt\\test2.txt");
+    DeleteFileA("test6.txt\\test3.txt");
+    /* Delete extra directory on old shell32 and Vista+ */
+    RemoveDirectoryA("test6.txt");
+    /* Delete extra files/directories on Vista+*/
+    DeleteFileA("test7.txt\\test2.txt");
+    RemoveDirectoryA("test7.txt");
+
+    if (retval == ERROR_SUCCESS)
+        return TRUE;
+
+    return FALSE;
+}
+
 START_TEST(shlfileop)
 {
     InitFunctionPointers();
 
     clean_after_shfo_tests();
 
+    init_shfo_tests();
+    old_shell32 = is_old_shell32();
+    if (old_shell32)
+        win_skip("Need to cater for old shell32 (4.0.x) on Win95\n");
+    clean_after_shfo_tests();
+
     init_shfo_tests();
     test_get_file_info();
     test_get_file_info_iconlist();
@@ -2263,4 +2383,6 @@ START_TEST(shlfileop)
     clean_after_shfo_tests();
 
     test_unicode();
+
+    test_shlmenu();
 }