[FUSION_WINETEST]
[reactos.git] / rostests / winetests / fusion / asmcache.c
index 06867e6..141e442 100644 (file)
@@ -888,7 +888,6 @@ static void test_InstallAssembly(void)
     ULONG disp;
     DWORD attr;
     char dllpath[MAX_PATH];
-    UINT size;
 
     static const WCHAR empty[] = {0};
     static const WCHAR noext[] = {'f','i','l','e',0};
@@ -942,7 +941,7 @@ static void test_InstallAssembly(void)
     hr = IAssemblyCache_InstallAssembly(cache, 0, winedll, NULL);
     ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
 
-    size = GetWindowsDirectoryA(dllpath, MAX_PATH);
+    GetWindowsDirectoryA(dllpath, MAX_PATH);
     strcat(dllpath, "\\assembly\\GAC_MSIL\\wine\\\\1.0.0.0__2d03617b1c31e2f5\\wine.dll");
 
     attr = GetFileAttributes(dllpath);
@@ -951,19 +950,18 @@ static void test_InstallAssembly(void)
     /* uninstall the assembly from the GAC */
     disp = 0xf00dbad;
     hr = IAssemblyCache_UninstallAssembly(cache, 0, wine, NULL, &disp);
-    todo_wine
-    {
-        ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
-        ok(disp == IASSEMBLYCACHE_UNINSTALL_DISPOSITION_UNINSTALLED,
-           "Expected IASSEMBLYCACHE_UNINSTALL_DISPOSITION_UNINSTALLED, got %d\n", disp);
-    }
+    ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+    ok(disp == IASSEMBLYCACHE_UNINSTALL_DISPOSITION_UNINSTALLED,
+       "Expected IASSEMBLYCACHE_UNINSTALL_DISPOSITION_UNINSTALLED, got %d\n", disp);
 
-    /* FIXME: remove once UninstallAssembly is implemented */
-    DeleteFileA(dllpath);
-    dllpath[size + sizeof("\\assembly\\GAC_MSIL\\wine\\1.0.0.0__2d03617b1c31e2f5")] = '\0';
-    RemoveDirectoryA(dllpath);
-    dllpath[size + sizeof("\\assembly\\GAC_MSIL\\wine")] = '\0';
-    RemoveDirectoryA(dllpath);
+    attr = GetFileAttributes(dllpath);
+    ok(attr == INVALID_FILE_ATTRIBUTES, "Expected assembly not to exist\n");
+
+    disp = 0xf00dbad;
+    hr = IAssemblyCache_UninstallAssembly(cache, 0, wine, NULL, &disp);
+    ok(hr == S_FALSE, "Expected S_FALSE, got %08x\n", hr);
+    ok(disp == IASSEMBLYCACHE_UNINSTALL_DISPOSITION_ALREADY_UNINSTALLED,
+       "Expected IASSEMBLYCACHE_UNINSTALL_DISPOSITION_ALREADY_UNINSTALLED, got %d\n", disp);
 
     DeleteFileA("test.dll");
     DeleteFileA("wine.dll");
@@ -987,8 +985,6 @@ static void test_QueryAssemblyInfo(void)
     HRESULT hr;
     DWORD size;
     ULONG disp;
-    char dllpath[MAX_PATH];
-    UINT len;
 
     static const WCHAR empty[] = {0};
     static const WCHAR commasep[] = {',',' ',0};
@@ -1091,13 +1087,10 @@ static void test_QueryAssemblyInfo(void)
        "Expected 0, got %d\n", info.uliAssemblySizeInKB.u.HighPart);
     ok(info.uliAssemblySizeInKB.u.LowPart == 0,
        "Expected 0, got %d\n", info.uliAssemblySizeInKB.u.LowPart);
-    todo_wine
-    {
-        ok(!lstrcmpW(info.pszCurrentAssemblyPathBuf, asmpath),
-           "Wrong assembly path returned\n");
-        ok(info.cchBuf == lstrlenW(asmpath) + 1,
-           "Expected %d, got %d\n", lstrlenW(asmpath) + 1, info.cchBuf);
-    }
+    ok(!lstrcmpW(info.pszCurrentAssemblyPathBuf, asmpath),
+       "Wrong assembly path returned\n");
+    ok(info.cchBuf == lstrlenW(asmpath) + 1,
+       "Expected %d, got %d\n", lstrlenW(asmpath) + 1, info.cchBuf);
 
     /* pwzCachePath is full filename */
     INIT_ASM_INFO();
@@ -1139,13 +1132,10 @@ static void test_QueryAssemblyInfo(void)
        "Expected 0, got %d\n", info.uliAssemblySizeInKB.u.HighPart);
     ok(info.uliAssemblySizeInKB.u.LowPart == 0,
        "Expected 0, got %d\n", info.uliAssemblySizeInKB.u.LowPart);
-    todo_wine
-    {
-        ok(!lstrcmpW(info.pszCurrentAssemblyPathBuf, asmpath),
-           "Wrong assembly path returned\n");
-        ok(info.cchBuf == lstrlenW(asmpath) + 1,
-           "Expected %d, got %d\n", lstrlenW(asmpath) + 1, info.cchBuf);
-    }
+    ok(!lstrcmpW(info.pszCurrentAssemblyPathBuf, asmpath),
+       "Wrong assembly path returned\n");
+    ok(info.cchBuf == lstrlenW(asmpath) + 1,
+       "Expected %d, got %d\n", lstrlenW(asmpath) + 1, info.cchBuf);
 
     /* info.cbAssemblyInfo is 1 */
     INIT_ASM_INFO();
@@ -1193,15 +1183,13 @@ static void test_QueryAssemblyInfo(void)
        "Expected 0, got %d\n", info.uliAssemblySizeInKB.u.HighPart);
     todo_wine
     {
-        /* win9x: 32 */
-        ok((info.uliAssemblySizeInKB.u.LowPart == 4) ||
-           broken(info.uliAssemblySizeInKB.u.LowPart == 32),
+        ok((info.uliAssemblySizeInKB.u.LowPart == 4),
            "Expected 4, got %d\n", info.uliAssemblySizeInKB.u.LowPart);
-        ok(!lstrcmpW(info.pszCurrentAssemblyPathBuf, asmpath),
-           "Wrong assembly path returned\n");
-        ok(info.cchBuf == lstrlenW(asmpath) + 1,
-           "Expected %d, got %d\n", lstrlenW(asmpath) + 1, info.cchBuf);
     }
+    ok(!lstrcmpW(info.pszCurrentAssemblyPathBuf, asmpath),
+       "Wrong assembly path returned\n");
+    ok(info.cchBuf == lstrlenW(asmpath) + 1,
+       "Expected %d, got %d\n", lstrlenW(asmpath) + 1, info.cchBuf);
 
     /* QUERYASMINFO_FLAG_GETSIZE and QUERYASMINFO_FLAG_VALIDATE */
     INIT_ASM_INFO();
@@ -1216,15 +1204,13 @@ static void test_QueryAssemblyInfo(void)
        "Expected 0, got %d\n", info.uliAssemblySizeInKB.u.HighPart);
     todo_wine
     {
-        /* win9x: 32 */
-        ok((info.uliAssemblySizeInKB.u.LowPart == 4) ||
-           broken(info.uliAssemblySizeInKB.u.LowPart == 32),
+        ok((info.uliAssemblySizeInKB.u.LowPart == 4),
            "Expected 4, got %d\n", info.uliAssemblySizeInKB.u.LowPart);
-        ok(!lstrcmpW(info.pszCurrentAssemblyPathBuf, asmpath),
-           "Wrong assembly path returned\n");
-        ok(info.cchBuf == lstrlenW(asmpath) + 1,
-           "Expected %d, got %d\n", lstrlenW(asmpath) + 1, info.cchBuf);
     }
+    ok(!lstrcmpW(info.pszCurrentAssemblyPathBuf, asmpath),
+       "Wrong assembly path returned\n");
+    ok(info.cchBuf == lstrlenW(asmpath) + 1,
+       "Expected %d, got %d\n", lstrlenW(asmpath) + 1, info.cchBuf);
 
     /* info.pszCurrentAssemblyPathBuf is NULL */
     INIT_ASM_INFO();
@@ -1237,17 +1223,15 @@ static void test_QueryAssemblyInfo(void)
        "Expected ASSEMBLYINFO_FLAG_INSTALLED, got %08x\n", info.dwAssemblyFlags);
     ok(info.uliAssemblySizeInKB.u.HighPart == 0,
        "Expected 0, got %d\n", info.uliAssemblySizeInKB.u.HighPart);
+    ok(hr == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER),
+       "Expected HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), got %08x\n", hr);
     todo_wine
     {
-        ok(hr == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER),
-           "Expected HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), got %08x\n", hr);
-        /* win9x: 32 */
-        ok((info.uliAssemblySizeInKB.u.LowPart == 4) ||
-           broken(info.uliAssemblySizeInKB.u.LowPart == 32),
+        ok((info.uliAssemblySizeInKB.u.LowPart == 4),
            "Expected 4, got %d\n", info.uliAssemblySizeInKB.u.LowPart);
-        ok(info.cchBuf == lstrlenW(asmpath) + 1,
-           "Expected %d, got %d\n", lstrlenW(asmpath) + 1, info.cchBuf);
     }
+    ok(info.cchBuf == lstrlenW(asmpath) + 1,
+       "Expected %d, got %d\n", lstrlenW(asmpath) + 1, info.cchBuf);
 
     /* info.cchBuf is exactly size of asmpath */
     INIT_ASM_INFO();
@@ -1262,17 +1246,15 @@ static void test_QueryAssemblyInfo(void)
        "Expected 0, got %d\n", info.uliAssemblySizeInKB.u.HighPart);
     ok(!lstrcmpW(info.pszCurrentAssemblyPathBuf, empty),
        "Assembly path was changed\n");
+    ok(hr == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER),
+       "Expected HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), got %08x\n", hr);
     todo_wine
     {
-        ok(hr == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER),
-           "Expected HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), got %08x\n", hr);
-        /* win9x: 32 */
-        ok((info.uliAssemblySizeInKB.u.LowPart == 4) ||
-           broken(info.uliAssemblySizeInKB.u.LowPart == 32),
+        ok((info.uliAssemblySizeInKB.u.LowPart == 4),
            "Expected 4, got %d\n", info.uliAssemblySizeInKB.u.LowPart);
-        ok(info.cchBuf == lstrlenW(asmpath) + 1,
-           "Expected %d, got %d\n", lstrlenW(asmpath) + 1, info.cchBuf);
     }
+    ok(info.cchBuf == lstrlenW(asmpath) + 1,
+       "Expected %d, got %d\n", lstrlenW(asmpath) + 1, info.cchBuf);
 
     /* info.cchBuf has room for NULL-terminator */
     INIT_ASM_INFO();
@@ -1290,13 +1272,11 @@ static void test_QueryAssemblyInfo(void)
        "Expected %d, got %d\n", lstrlenW(asmpath) + 1, info.cchBuf);
     todo_wine
     {
-        /* win9x: 32 */
-        ok((info.uliAssemblySizeInKB.u.LowPart == 4) ||
-           broken(info.uliAssemblySizeInKB.u.LowPart == 32),
+        ok((info.uliAssemblySizeInKB.u.LowPart == 4),
            "Expected 4, got %d\n", info.uliAssemblySizeInKB.u.LowPart);
-        ok(!lstrcmpW(info.pszCurrentAssemblyPathBuf, asmpath),
-           "Wrong assembly path returned\n");
     }
+    ok(!lstrcmpW(info.pszCurrentAssemblyPathBuf, asmpath),
+       "Wrong assembly path returned\n");
 
     /* display name is "wine, Version=1.0.0.0" */
     INIT_ASM_INFO();
@@ -1314,21 +1294,36 @@ static void test_QueryAssemblyInfo(void)
        "Expected 0, got %d\n", info.uliAssemblySizeInKB.u.HighPart);
     todo_wine
     {
-        /* win9x: 32 */
-        ok((info.uliAssemblySizeInKB.u.LowPart == 4) ||
-           broken(info.uliAssemblySizeInKB.u.LowPart == 32),
+        ok((info.uliAssemblySizeInKB.u.LowPart == 4),
            "Expected 4, got %d\n", info.uliAssemblySizeInKB.u.LowPart);
-        ok(!lstrcmpW(info.pszCurrentAssemblyPathBuf, asmpath),
-           "Wrong assembly path returned\n");
-        ok(info.cchBuf == lstrlenW(asmpath) + 1,
-           "Expected %d, got %d\n", lstrlenW(asmpath) + 1, info.cchBuf);
     }
+    ok(!lstrcmpW(info.pszCurrentAssemblyPathBuf, asmpath),
+       "Wrong assembly path returned\n");
+    ok(info.cchBuf == lstrlenW(asmpath) + 1,
+       "Expected %d, got %d\n", lstrlenW(asmpath) + 1, info.cchBuf);
 
-    /* display name is "wine, Version=1.0.0.00000" */
-    INIT_ASM_INFO();
+    /* short buffer, QUERYASMINFO_FLAG_VALIDATE */
+    memset(&info, 0, sizeof(info));
+    lstrcpyW(name, wine);
+    lstrcatW(name, commasep);
+    lstrcatW(name, otherver);
+    hr = IAssemblyCache_QueryAssemblyInfo(cache, QUERYASMINFO_FLAG_VALIDATE,
+                                          name, &info);
+    ok(hr == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), "got %08x\n", hr);
+    ok(info.dwAssemblyFlags == ASSEMBLYINFO_FLAG_INSTALLED, "got %08x\n", info.dwAssemblyFlags);
+
+    /* short buffer, QUERYASMINFO_FLAG_GETSIZE */
+    memset(&info, 0, sizeof(info));
     lstrcpyW(name, wine);
     lstrcatW(name, commasep);
     lstrcatW(name, otherver);
+    hr = IAssemblyCache_QueryAssemblyInfo(cache, QUERYASMINFO_FLAG_GETSIZE,
+                                          name, &info);
+    ok(hr == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), "got %08x\n", hr);
+    ok(info.dwAssemblyFlags == ASSEMBLYINFO_FLAG_INSTALLED, "got %08x\n", info.dwAssemblyFlags);
+
+    /* display name is "wine, Version=1.0.0.00000" */
+    INIT_ASM_INFO();
     hr = IAssemblyCache_QueryAssemblyInfo(cache, QUERYASMINFO_FLAG_GETSIZE,
                                           name, &info);
     ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
@@ -1340,15 +1335,13 @@ static void test_QueryAssemblyInfo(void)
        "Expected 0, got %d\n", info.uliAssemblySizeInKB.u.HighPart);
     todo_wine
     {
-        /* win9x: 32 */
-        ok((info.uliAssemblySizeInKB.u.LowPart == 4) ||
-           broken(info.uliAssemblySizeInKB.u.LowPart == 32),
+        ok((info.uliAssemblySizeInKB.u.LowPart == 4),
            "Expected 4, got %d\n", info.uliAssemblySizeInKB.u.LowPart);
-        ok(!lstrcmpW(info.pszCurrentAssemblyPathBuf, asmpath),
-           "Wrong assembly path returned\n");
-        ok(info.cchBuf == lstrlenW(asmpath) + 1,
-           "Expected %d, got %d\n", lstrlenW(asmpath) + 1, info.cchBuf);
     }
+    ok(!lstrcmpW(info.pszCurrentAssemblyPathBuf, asmpath),
+       "Wrong assembly path returned\n");
+    ok(info.cchBuf == lstrlenW(asmpath) + 1,
+       "Expected %d, got %d\n", lstrlenW(asmpath) + 1, info.cchBuf);
 
     /* display name is "wine, Version=1.0.0.1", versions don't match */
     INIT_ASM_INFO();
@@ -1386,15 +1379,13 @@ static void test_QueryAssemblyInfo(void)
        "Expected 0, got %d\n", info.uliAssemblySizeInKB.u.HighPart);
     todo_wine
     {
-        /* win9x: 32 */
-        ok((info.uliAssemblySizeInKB.u.LowPart == 4) ||
-           broken(info.uliAssemblySizeInKB.u.LowPart == 32),
+        ok((info.uliAssemblySizeInKB.u.LowPart == 4),
            "Expected 4, got %d\n", info.uliAssemblySizeInKB.u.LowPart);
-        ok(!lstrcmpW(info.pszCurrentAssemblyPathBuf, asmpath),
-           "Wrong assembly path returned\n");
-        ok(info.cchBuf == lstrlenW(asmpath) + 1,
-           "Expected %d, got %d\n", lstrlenW(asmpath) + 1, info.cchBuf);
     }
+    ok(!lstrcmpW(info.pszCurrentAssemblyPathBuf, asmpath),
+       "Wrong assembly path returned\n");
+    ok(info.cchBuf == lstrlenW(asmpath) + 1,
+       "Expected %d, got %d\n", lstrlenW(asmpath) + 1, info.cchBuf);
 
     /* display name is "wine, Culture=en", cultures don't match */
     INIT_ASM_INFO();
@@ -1415,9 +1406,12 @@ static void test_QueryAssemblyInfo(void)
        "Expected 0, got %d\n", info.uliAssemblySizeInKB.u.HighPart);
     ok(info.uliAssemblySizeInKB.u.LowPart == 0,
        "Expected 0, got %d\n", info.uliAssemblySizeInKB.u.LowPart);
-    ok(!lstrcmpW(info.pszCurrentAssemblyPathBuf, empty),
-       "Assembly path was changed\n");
-    ok(info.cchBuf == MAX_PATH, "Expected MAX_PATH, got %d\n", info.cchBuf);
+    todo_wine
+    {
+        ok(!lstrcmpW(info.pszCurrentAssemblyPathBuf, empty),
+           "Assembly path was changed\n");
+        ok(info.cchBuf == MAX_PATH, "Expected MAX_PATH, got %d\n", info.cchBuf);
+    }
 
     /* display name is "wine, PublicKeyTokens=2d03617b1c31e2f5" */
     INIT_ASM_INFO();
@@ -1435,15 +1429,13 @@ static void test_QueryAssemblyInfo(void)
        "Expected 0, got %d\n", info.uliAssemblySizeInKB.u.HighPart);
     todo_wine
     {
-        /* win9x: 32 */
-        ok((info.uliAssemblySizeInKB.u.LowPart == 4) ||
-           broken(info.uliAssemblySizeInKB.u.LowPart == 32),
+        ok((info.uliAssemblySizeInKB.u.LowPart == 4),
            "Expected 4, got %d\n", info.uliAssemblySizeInKB.u.LowPart);
-        ok(!lstrcmpW(info.pszCurrentAssemblyPathBuf, asmpath),
-           "Wrong assembly path returned\n");
-        ok(info.cchBuf == lstrlenW(asmpath) + 1,
-           "Expected %d, got %d\n", lstrlenW(asmpath) + 1, info.cchBuf);
     }
+    ok(!lstrcmpW(info.pszCurrentAssemblyPathBuf, asmpath),
+       "Wrong assembly path returned\n");
+    ok(info.cchBuf == lstrlenW(asmpath) + 1,
+       "Expected %d, got %d\n", lstrlenW(asmpath) + 1, info.cchBuf);
 
     /* display name is "wine, PublicKeyToken=aaaaaaaaaaaaaaaa", pubkeys don't match */
     INIT_ASM_INFO();
@@ -1481,34 +1473,35 @@ static void test_QueryAssemblyInfo(void)
        "Expected 0, got %d\n", info.uliAssemblySizeInKB.u.HighPart);
     todo_wine
     {
-        /* win9x: 32 */
-        ok((info.uliAssemblySizeInKB.u.LowPart == 4) ||
-           broken(info.uliAssemblySizeInKB.u.LowPart == 32),
+        ok((info.uliAssemblySizeInKB.u.LowPart == 4),
            "Expected 4, got %d\n", info.uliAssemblySizeInKB.u.LowPart);
-        ok(!lstrcmpW(info.pszCurrentAssemblyPathBuf, asmpath),
-           "Wrong assembly path returned\n");
-        ok(info.cchBuf == lstrlenW(asmpath) + 1,
-           "Expected %d, got %d\n", lstrlenW(asmpath) + 1, info.cchBuf);
     }
+    ok(!lstrcmpW(info.pszCurrentAssemblyPathBuf, asmpath),
+       "Wrong assembly path returned\n");
+    ok(info.cchBuf == lstrlenW(asmpath) + 1,
+       "Expected %d, got %d\n", lstrlenW(asmpath) + 1, info.cchBuf);
+
+    /* no flags, display name is "wine, Version=1.0.0.0" */
+    INIT_ASM_INFO();
+    info.pszCurrentAssemblyPathBuf = NULL;
+    info.cchBuf = 0;
+    lstrcpyW(name, wine);
+    lstrcatW(name, commasep);
+    lstrcatW(name, ver);
+    hr = IAssemblyCache_QueryAssemblyInfo(cache, 0, name, &info);
+    ok(hr == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER),
+       "Expected HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), got %08x\n", hr);
+    ok(info.cbAssemblyInfo == sizeof(ASSEMBLY_INFO),
+       "Expected sizeof(ASSEMBLY_INFO), got %d\n", info.cbAssemblyInfo);
+    ok(info.dwAssemblyFlags == ASSEMBLYINFO_FLAG_INSTALLED,
+       "Expected ASSEMBLYINFO_FLAG_INSTALLED, got %08x\n", info.dwAssemblyFlags);
 
     /* uninstall the assembly from the GAC */
     disp = 0xf00dbad;
     hr = IAssemblyCache_UninstallAssembly(cache, 0, wine, NULL, &disp);
-    todo_wine
-    {
-        ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
-        ok(disp == IASSEMBLYCACHE_UNINSTALL_DISPOSITION_UNINSTALLED,
-           "Expected IASSEMBLYCACHE_UNINSTALL_DISPOSITION_UNINSTALLED, got %d\n", disp);
-    }
-
-    /* FIXME: remove once UninstallAssembly is implemented */
-    len = GetWindowsDirectoryA(dllpath, MAX_PATH);
-    strcat(dllpath, "\\assembly\\GAC_MSIL\\wine\\\\1.0.0.0__2d03617b1c31e2f5\\wine.dll");
-    DeleteFileA(dllpath);
-    dllpath[len + sizeof("\\assembly\\GAC_MSIL\\wine\\1.0.0.0__2d03617b1c31e2f5")] = '\0';
-    RemoveDirectoryA(dllpath);
-    dllpath[len + sizeof("\\assembly\\GAC_MSIL\\wine")] = '\0';
-    RemoveDirectoryA(dllpath);
+    ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+    ok(disp == IASSEMBLYCACHE_UNINSTALL_DISPOSITION_UNINSTALLED,
+       "Expected IASSEMBLYCACHE_UNINSTALL_DISPOSITION_UNINSTALLED, got %d\n", disp);
 
     DeleteFileA("test.dll");
     DeleteFileA("wine.dll");