Signed-off-by: Dmitry Timoshkov dmitry@baikal.ru --- dlls/wininet/tests/Makefile.in | 2 +- dlls/wininet/tests/urlcache.c | 103 +++++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+), 1 deletion(-)
diff --git a/dlls/wininet/tests/Makefile.in b/dlls/wininet/tests/Makefile.in index cf1a86acd8..ae18bb72fa 100644 --- a/dlls/wininet/tests/Makefile.in +++ b/dlls/wininet/tests/Makefile.in @@ -1,5 +1,5 @@ TESTDLL = wininet.dll -IMPORTS = wininet crypt32 ws2_32 user32 advapi32 +IMPORTS = wininet crypt32 ws2_32 user32 advapi32 shell32
C_SRCS = \ ftp.c \ diff --git a/dlls/wininet/tests/urlcache.c b/dlls/wininet/tests/urlcache.c index 3799500489..acd4ff247c 100644 --- a/dlls/wininet/tests/urlcache.c +++ b/dlls/wininet/tests/urlcache.c @@ -18,6 +18,9 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
+#define NONAMELESSUNION +#define NONAMELESSSTRUCT + #include <stdarg.h> #include <stdio.h> #include <stdlib.h> @@ -27,6 +30,7 @@ #include "winnls.h" #include "wininet.h" #include "winineti.h" +#include "shlobj.h"
#include "wine/test.h"
@@ -1100,6 +1104,104 @@ static void test_trailing_slash(void) DeleteFileA(filename); }
+static void get_cache_path(DWORD flags, char path[MAX_PATH], char path_win8[MAX_PATH]) +{ + BOOL ret; + int folder = -1; + const char *suffix = ""; + const char *suffix_win8 = ""; + + switch (flags) + { + case 0: + case CACHE_CONFIG_CONTENT_PATHS_FC: + folder = CSIDL_INTERNET_CACHE; + suffix = "\Content.IE5\"; + suffix_win8 = "\IE\"; + break; + + case CACHE_CONFIG_COOKIES_PATHS_FC: + folder = CSIDL_COOKIES; + suffix = "\"; + suffix_win8 = "\"; + break; + + case CACHE_CONFIG_HISTORY_PATHS_FC: + folder = CSIDL_HISTORY; + suffix = "\History.IE5\"; + suffix_win8 = "\History.IE5\"; + break; + + default: + ok(0, "unexpected flags %#x\n", flags); + break; + } + + ret = SHGetSpecialFolderPathA(0, path, folder, FALSE); + ok(ret, "SHGetSpecialFolderPath error %u\n", GetLastError()); + + strcpy(path_win8, path); + strcat(path_win8, suffix_win8); + + strcat(path, suffix); +} + +static void test_GetUrlCacheConfigInfo(void) +{ + INTERNET_CACHE_CONFIG_INFOA info; + struct + { + INTERNET_CACHE_CONFIG_INFOA *info; + DWORD dwStructSize; + DWORD flags; + BOOL ret; + DWORD error; + } td[] = + { +#if 0 /* crashes under Vista */ + { NULL, 0, 0, FALSE, ERROR_INVALID_PARAMETER }, +#endif + { &info, 0, 0, TRUE }, + { &info, sizeof(info) - 1, 0, TRUE }, + { &info, sizeof(info) + 1, 0, TRUE }, + { &info, 0, CACHE_CONFIG_CONTENT_PATHS_FC, TRUE }, + { &info, sizeof(info), CACHE_CONFIG_CONTENT_PATHS_FC, TRUE }, + { &info, 0, CACHE_CONFIG_COOKIES_PATHS_FC, TRUE }, + { &info, sizeof(info), CACHE_CONFIG_COOKIES_PATHS_FC, TRUE }, + { &info, 0, CACHE_CONFIG_HISTORY_PATHS_FC, TRUE }, + { &info, sizeof(info), CACHE_CONFIG_HISTORY_PATHS_FC, TRUE }, + }; + int i; + BOOL ret; + + for (i = 0; i < ARRAY_SIZE(td); i++) + { + if (td[i].info) + { + memset(&info, 0, sizeof(*td[i].info)); + info.dwStructSize = td[i].dwStructSize; + } + + SetLastError(0xdeadbeef); + ret = GetUrlCacheConfigInfoA(td[i].info, NULL, td[i].flags); +todo_wine + ok(ret == td[i].ret, "%d: expected %d, got %d\n", i, td[i].ret, ret); + if (!ret) +todo_wine + ok(GetLastError() == td[i].error, "%d: expected %u, got %u\n", i, td[i].error, GetLastError()); + else + { + char path[MAX_PATH], path_win8[MAX_PATH]; + + get_cache_path(td[i].flags, path, path_win8); + + ok(info.dwStructSize == td[i].dwStructSize, "got %u\n", info.dwStructSize); + ok(!lstrcmpA(info.u.s.CachePath, path) || !lstrcmpA(info.u.s.CachePath, path_win8), + "%d: expected %s or %s, got %s\n", i, path, path_win8, info.u.s.CachePath); + } + } +} + START_TEST(urlcache) { HMODULE hdll; @@ -1124,4 +1226,5 @@ START_TEST(urlcache) test_FindCloseUrlCache(); test_GetDiskInfoA(); test_trailing_slash(); + test_GetUrlCacheConfigInfo(); }