wininet: Added more GetUrlCacheEntryInfo tests with GET_INSTALLED_ENTRY flag.

This commit is contained in:
Piotr Caban 2012-09-25 17:31:55 +02:00 committed by Alexandre Julliard
parent f9e80f588a
commit 306f53cbf2
1 changed files with 101 additions and 87 deletions

View File

@ -29,10 +29,12 @@
#include "wine/test.h" #include "wine/test.h"
#define TEST_URL "http://urlcachetest.winehq.org/index.html" static const char test_url[] = "http://urlcachetest.winehq.org/index.html";
#define TEST_URL1 "Visited: user@http://urlcachetest.winehq.org/index.html" static const WCHAR test_urlW[] = {'h','t','t','p',':','/','/','u','r','l','c','a','c','h','e','t','e','s','t','.',
#define TEST_HASH_COLLISIONS1 "Visited: http://winehq.org/doc0.html" 'w','i','n','e','h','q','.','o','r','g','/','i','n','d','e','x','.','h','t','m','l',0};
#define TEST_HASH_COLLISIONS2 "Visited: http://winehq.org/doc75651909.html" static const char test_url1[] = "Visited: user@http://urlcachetest.winehq.org/index.html";
static const char test_hash_collisions1[] = "Visited: http://winehq.org/doc0.html";
static const char test_hash_collisions2[] = "Visited: http://winehq.org/doc75651909.html";
static BOOL (WINAPI *pDeleteUrlCacheEntryA)(LPCSTR); static BOOL (WINAPI *pDeleteUrlCacheEntryA)(LPCSTR);
static BOOL (WINAPI *pUnlockUrlCacheEntryFileA)(LPCSTR,DWORD); static BOOL (WINAPI *pUnlockUrlCacheEntryFileA)(LPCSTR,DWORD);
@ -43,7 +45,7 @@ static char filenameA1[MAX_PATH + 1];
static void check_cache_entry_infoA(const char *returnedfrom, LPINTERNET_CACHE_ENTRY_INFO lpCacheEntryInfo) static void check_cache_entry_infoA(const char *returnedfrom, LPINTERNET_CACHE_ENTRY_INFO lpCacheEntryInfo)
{ {
ok(lpCacheEntryInfo->dwStructSize == sizeof(*lpCacheEntryInfo), "%s: dwStructSize was %d\n", returnedfrom, lpCacheEntryInfo->dwStructSize); ok(lpCacheEntryInfo->dwStructSize == sizeof(*lpCacheEntryInfo), "%s: dwStructSize was %d\n", returnedfrom, lpCacheEntryInfo->dwStructSize);
ok(!strcmp(lpCacheEntryInfo->lpszSourceUrlName, TEST_URL), "%s: lpszSourceUrlName should be %s instead of %s\n", returnedfrom, TEST_URL, lpCacheEntryInfo->lpszSourceUrlName); ok(!strcmp(lpCacheEntryInfo->lpszSourceUrlName, test_url), "%s: lpszSourceUrlName should be %s instead of %s\n", returnedfrom, test_url, lpCacheEntryInfo->lpszSourceUrlName);
ok(!strcmp(lpCacheEntryInfo->lpszLocalFileName, filenameA), "%s: lpszLocalFileName should be %s instead of %s\n", returnedfrom, filenameA, lpCacheEntryInfo->lpszLocalFileName); ok(!strcmp(lpCacheEntryInfo->lpszLocalFileName, filenameA), "%s: lpszLocalFileName should be %s instead of %s\n", returnedfrom, filenameA, lpCacheEntryInfo->lpszLocalFileName);
ok(!strcmp(lpCacheEntryInfo->lpszFileExtension, "html"), "%s: lpszFileExtension should be html instead of %s\n", returnedfrom, lpCacheEntryInfo->lpszFileExtension); ok(!strcmp(lpCacheEntryInfo->lpszFileExtension, "html"), "%s: lpszFileExtension should be html instead of %s\n", returnedfrom, lpCacheEntryInfo->lpszFileExtension);
} }
@ -68,7 +70,7 @@ static void test_find_url_cache_entriesA(void)
ok(hEnumHandle != NULL, "FindFirstUrlCacheEntry failed with error %d\n", GetLastError()); ok(hEnumHandle != NULL, "FindFirstUrlCacheEntry failed with error %d\n", GetLastError());
while (TRUE) while (TRUE)
{ {
if (!strcmp(lpCacheEntryInfo->lpszSourceUrlName, TEST_URL)) if (!strcmp(lpCacheEntryInfo->lpszSourceUrlName, test_url))
{ {
found = TRUE; found = TRUE;
ret = TRUE; ret = TRUE;
@ -115,12 +117,12 @@ static void test_GetUrlCacheEntryInfoExA(void)
ok(GetLastError() == ERROR_FILE_NOT_FOUND, ok(GetLastError() == ERROR_FILE_NOT_FOUND,
"GetUrlCacheEntryInfoEx should have set last error to ERROR_FILE_NOT_FOUND instead of %d\n", GetLastError()); "GetUrlCacheEntryInfoEx should have set last error to ERROR_FILE_NOT_FOUND instead of %d\n", GetLastError());
ret = GetUrlCacheEntryInfoEx(TEST_URL, NULL, NULL, NULL, NULL, NULL, 0); ret = GetUrlCacheEntryInfoEx(test_url, NULL, NULL, NULL, NULL, NULL, 0);
ok(ret, "GetUrlCacheEntryInfoEx with NULL args failed with error %d\n", GetLastError()); ok(ret, "GetUrlCacheEntryInfoEx with NULL args failed with error %d\n", GetLastError());
cbCacheEntryInfo = 0; cbCacheEntryInfo = 0;
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = GetUrlCacheEntryInfoEx(TEST_URL, NULL, &cbCacheEntryInfo, NULL, NULL, NULL, 0); ret = GetUrlCacheEntryInfoEx(test_url, NULL, &cbCacheEntryInfo, NULL, NULL, NULL, 0);
ok(!ret, "GetUrlCacheEntryInfoEx with zero-length buffer should fail\n"); ok(!ret, "GetUrlCacheEntryInfoEx with zero-length buffer should fail\n");
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
"GetUrlCacheEntryInfoEx should have set last error to ERROR_INSUFFICIENT_BUFFER instead of %d\n", GetLastError()); "GetUrlCacheEntryInfoEx should have set last error to ERROR_INSUFFICIENT_BUFFER instead of %d\n", GetLastError());
@ -128,19 +130,31 @@ static void test_GetUrlCacheEntryInfoExA(void)
lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo); lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo);
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = GetUrlCacheEntryInfoEx(TEST_URL, lpCacheEntryInfo, &cbCacheEntryInfo, NULL, NULL, NULL, 0x200); ret = GetUrlCacheEntryInfoEx(test_url, NULL, NULL, NULL, NULL, NULL, 0x200 /*GET_INSTALLED_ENTRY*/);
ok(!ret, "GetUrlCacheEntryInfoEx succeeded\n"); ok(!ret, "GetUrlCacheEntryInfoEx succeeded\n");
ok(GetLastError() == ERROR_FILE_NOT_FOUND, ok(GetLastError() == ERROR_FILE_NOT_FOUND,
"GetUrlCacheEntryInfoEx should have set last error to ERROR_FILE_NOT_FOUND instead of %d\n", GetLastError()); "GetUrlCacheEntryInfoEx should have set last error to ERROR_FILE_NOT_FOUND instead of %d\n", GetLastError());
ret = GetUrlCacheEntryInfoEx(TEST_URL, lpCacheEntryInfo, &cbCacheEntryInfo, NULL, NULL, NULL, 0); /* Unicode version of function seems to ignore 0x200 flag */
ret = GetUrlCacheEntryInfoExW(test_urlW, NULL, NULL, NULL, NULL, NULL, 0x200 /*GET_INSTALLED_ENTRY*/);
ok(ret, "GetUrlCacheEntryInfoExW failed with error %d\n", GetLastError());
ret = GetUrlCacheEntryInfoEx(test_url, lpCacheEntryInfo, &cbCacheEntryInfo, NULL, NULL, NULL, 0);
ok(ret, "GetUrlCacheEntryInfoEx failed with error %d\n", GetLastError()); ok(ret, "GetUrlCacheEntryInfoEx failed with error %d\n", GetLastError());
if (ret) check_cache_entry_infoA("GetUrlCacheEntryInfoEx", lpCacheEntryInfo); if (ret) check_cache_entry_infoA("GetUrlCacheEntryInfoEx", lpCacheEntryInfo);
lpCacheEntryInfo->CacheEntryType |= 0x10000000; /* INSTALLED_CACHE_ENTRY */
ret = SetUrlCacheEntryInfoA(test_url, lpCacheEntryInfo, CACHE_ENTRY_ATTRIBUTE_FC);
ok(ret, "SetUrlCacheEntryInfoA failed with error %d\n", GetLastError());
SetLastError(0xdeadbeef);
ret = GetUrlCacheEntryInfoEx(test_url, NULL, NULL, NULL, NULL, NULL, 0x200 /*GET_INSTALLED_ENTRY*/);
ok(ret, "GetUrlCacheEntryInfoEx failed with error %d\n", GetLastError());
cbCacheEntryInfo = 100000; cbCacheEntryInfo = 100000;
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = GetUrlCacheEntryInfoEx(TEST_URL, NULL, &cbCacheEntryInfo, NULL, NULL, NULL, 0); ret = GetUrlCacheEntryInfoEx(test_url, NULL, &cbCacheEntryInfo, NULL, NULL, NULL, 0);
ok(!ret, "GetUrlCacheEntryInfoEx with zero-length buffer should fail\n"); ok(!ret, "GetUrlCacheEntryInfoEx with zero-length buffer should fail\n");
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetUrlCacheEntryInfoEx should have set last error to ERROR_INSUFFICIENT_BUFFER instead of %d\n", GetLastError()); ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetUrlCacheEntryInfoEx should have set last error to ERROR_INSUFFICIENT_BUFFER instead of %d\n", GetLastError());
@ -148,12 +162,12 @@ static void test_GetUrlCacheEntryInfoExA(void)
/* Querying the redirect URL fails with ERROR_INVALID_PARAMETER */ /* Querying the redirect URL fails with ERROR_INVALID_PARAMETER */
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = GetUrlCacheEntryInfoEx(TEST_URL, NULL, NULL, NULL, &cbRedirectUrl, NULL, 0); ret = GetUrlCacheEntryInfoEx(test_url, NULL, NULL, NULL, &cbRedirectUrl, NULL, 0);
ok(!ret, "GetUrlCacheEntryInfoEx should have failed\n"); ok(!ret, "GetUrlCacheEntryInfoEx should have failed\n");
ok(GetLastError() == ERROR_INVALID_PARAMETER, ok(GetLastError() == ERROR_INVALID_PARAMETER,
"expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = GetUrlCacheEntryInfoEx(TEST_URL, NULL, &cbCacheEntryInfo, NULL, &cbRedirectUrl, NULL, 0); ret = GetUrlCacheEntryInfoEx(test_url, NULL, &cbCacheEntryInfo, NULL, &cbRedirectUrl, NULL, 0);
ok(!ret, "GetUrlCacheEntryInfoEx should have failed\n"); ok(!ret, "GetUrlCacheEntryInfoEx should have failed\n");
ok(GetLastError() == ERROR_INVALID_PARAMETER, ok(GetLastError() == ERROR_INVALID_PARAMETER,
"expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
@ -174,7 +188,7 @@ static void test_RetrieveUrlCacheEntryA(void)
{ {
/* Crashes on Win9x, NT4 and W2K */ /* Crashes on Win9x, NT4 and W2K */
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = RetrieveUrlCacheEntryFile(TEST_URL, NULL, NULL, 0); ret = RetrieveUrlCacheEntryFile(test_url, NULL, NULL, 0);
ok(!ret, "RetrieveUrlCacheEntryFile should have failed\n"); ok(!ret, "RetrieveUrlCacheEntryFile should have failed\n");
ok(GetLastError() == ERROR_INVALID_PARAMETER, "RetrieveUrlCacheEntryFile should have set last error to ERROR_INVALID_PARAMETER instead of %d\n", GetLastError()); ok(GetLastError() == ERROR_INVALID_PARAMETER, "RetrieveUrlCacheEntryFile should have set last error to ERROR_INVALID_PARAMETER instead of %d\n", GetLastError());
} }
@ -208,7 +222,7 @@ static void test_IsUrlCacheEntryExpiredA(void)
ok(ft.dwLowDateTime == 0xdeadbeef && ft.dwHighDateTime == 0xbaadf00d, ok(ft.dwLowDateTime == 0xdeadbeef && ft.dwHighDateTime == 0xbaadf00d,
"expected time to be unchanged, got (%u,%u)\n", "expected time to be unchanged, got (%u,%u)\n",
ft.dwLowDateTime, ft.dwHighDateTime); ft.dwLowDateTime, ft.dwHighDateTime);
ret = IsUrlCacheEntryExpiredA(TEST_URL, 0, NULL); ret = IsUrlCacheEntryExpiredA(test_url, 0, NULL);
ok(ret, "expected TRUE\n"); ok(ret, "expected TRUE\n");
/* The return value should indicate whether the URL is expired, /* The return value should indicate whether the URL is expired,
@ -217,7 +231,7 @@ static void test_IsUrlCacheEntryExpiredA(void)
*/ */
ft.dwLowDateTime = 0xdeadbeef; ft.dwLowDateTime = 0xdeadbeef;
ft.dwHighDateTime = 0xbaadf00d; ft.dwHighDateTime = 0xbaadf00d;
ret = IsUrlCacheEntryExpiredA(TEST_URL, 0, &ft); ret = IsUrlCacheEntryExpiredA(test_url, 0, &ft);
ok(!ret, "expected FALSE\n"); ok(!ret, "expected FALSE\n");
ok(!ft.dwLowDateTime && !ft.dwHighDateTime, ok(!ft.dwLowDateTime && !ft.dwHighDateTime,
"expected time (0,0), got (%u,%u)\n", "expected time (0,0), got (%u,%u)\n",
@ -226,19 +240,19 @@ static void test_IsUrlCacheEntryExpiredA(void)
/* Same behavior with bogus flags. */ /* Same behavior with bogus flags. */
ft.dwLowDateTime = 0xdeadbeef; ft.dwLowDateTime = 0xdeadbeef;
ft.dwHighDateTime = 0xbaadf00d; ft.dwHighDateTime = 0xbaadf00d;
ret = IsUrlCacheEntryExpiredA(TEST_URL, 0xffffffff, &ft); ret = IsUrlCacheEntryExpiredA(test_url, 0xffffffff, &ft);
ok(!ret, "expected FALSE\n"); ok(!ret, "expected FALSE\n");
ok(!ft.dwLowDateTime && !ft.dwHighDateTime, ok(!ft.dwLowDateTime && !ft.dwHighDateTime,
"expected time (0,0), got (%u,%u)\n", "expected time (0,0), got (%u,%u)\n",
ft.dwLowDateTime, ft.dwHighDateTime); ft.dwLowDateTime, ft.dwHighDateTime);
/* Set the expire time to a point in the past.. */ /* Set the expire time to a point in the past.. */
ret = GetUrlCacheEntryInfo(TEST_URL, NULL, &size); ret = GetUrlCacheEntryInfo(test_url, NULL, &size);
ok(!ret, "GetUrlCacheEntryInfo should have failed\n"); ok(!ret, "GetUrlCacheEntryInfo should have failed\n");
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
"expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError()); "expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
info = HeapAlloc(GetProcessHeap(), 0, size); info = HeapAlloc(GetProcessHeap(), 0, size);
ret = GetUrlCacheEntryInfo(TEST_URL, info, &size); ret = GetUrlCacheEntryInfo(test_url, info, &size);
ok(ret, "GetUrlCacheEntryInfo failed: %d\n", GetLastError()); ok(ret, "GetUrlCacheEntryInfo failed: %d\n", GetLastError());
GetSystemTimeAsFileTime(&info->ExpireTime); GetSystemTimeAsFileTime(&info->ExpireTime);
exp_time.u.LowPart = info->ExpireTime.dwLowDateTime; exp_time.u.LowPart = info->ExpireTime.dwLowDateTime;
@ -246,12 +260,12 @@ static void test_IsUrlCacheEntryExpiredA(void)
exp_time.QuadPart -= 10 * 60 * (ULONGLONG)10000000; exp_time.QuadPart -= 10 * 60 * (ULONGLONG)10000000;
info->ExpireTime.dwLowDateTime = exp_time.u.LowPart; info->ExpireTime.dwLowDateTime = exp_time.u.LowPart;
info->ExpireTime.dwHighDateTime = exp_time.u.HighPart; info->ExpireTime.dwHighDateTime = exp_time.u.HighPart;
ret = SetUrlCacheEntryInfo(TEST_URL, info, CACHE_ENTRY_EXPTIME_FC); ret = SetUrlCacheEntryInfo(test_url, info, CACHE_ENTRY_EXPTIME_FC);
ok(ret, "SetUrlCacheEntryInfo failed: %d\n", GetLastError()); ok(ret, "SetUrlCacheEntryInfo failed: %d\n", GetLastError());
ft.dwLowDateTime = 0xdeadbeef; ft.dwLowDateTime = 0xdeadbeef;
ft.dwHighDateTime = 0xbaadf00d; ft.dwHighDateTime = 0xbaadf00d;
/* and the entry should be expired. */ /* and the entry should be expired. */
ret = IsUrlCacheEntryExpiredA(TEST_URL, 0, &ft); ret = IsUrlCacheEntryExpiredA(test_url, 0, &ft);
ok(ret, "expected TRUE\n"); ok(ret, "expected TRUE\n");
/* The modified time returned is 0. */ /* The modified time returned is 0. */
ok(!ft.dwLowDateTime && !ft.dwHighDateTime, ok(!ft.dwLowDateTime && !ft.dwHighDateTime,
@ -261,12 +275,12 @@ static void test_IsUrlCacheEntryExpiredA(void)
exp_time.QuadPart += 20 * 60 * (ULONGLONG)10000000; exp_time.QuadPart += 20 * 60 * (ULONGLONG)10000000;
info->ExpireTime.dwLowDateTime = exp_time.u.LowPart; info->ExpireTime.dwLowDateTime = exp_time.u.LowPart;
info->ExpireTime.dwHighDateTime = exp_time.u.HighPart; info->ExpireTime.dwHighDateTime = exp_time.u.HighPart;
ret = SetUrlCacheEntryInfo(TEST_URL, info, CACHE_ENTRY_EXPTIME_FC); ret = SetUrlCacheEntryInfo(test_url, info, CACHE_ENTRY_EXPTIME_FC);
ok(ret, "SetUrlCacheEntryInfo failed: %d\n", GetLastError()); ok(ret, "SetUrlCacheEntryInfo failed: %d\n", GetLastError());
ft.dwLowDateTime = 0xdeadbeef; ft.dwLowDateTime = 0xdeadbeef;
ft.dwHighDateTime = 0xbaadf00d; ft.dwHighDateTime = 0xbaadf00d;
/* and the entry should no longer be expired. */ /* and the entry should no longer be expired. */
ret = IsUrlCacheEntryExpiredA(TEST_URL, 0, &ft); ret = IsUrlCacheEntryExpiredA(test_url, 0, &ft);
ok(!ret, "expected FALSE\n"); ok(!ret, "expected FALSE\n");
/* The modified time returned is still 0. */ /* The modified time returned is still 0. */
ok(!ft.dwLowDateTime && !ft.dwHighDateTime, ok(!ft.dwLowDateTime && !ft.dwHighDateTime,
@ -274,10 +288,10 @@ static void test_IsUrlCacheEntryExpiredA(void)
ft.dwLowDateTime, ft.dwHighDateTime); ft.dwLowDateTime, ft.dwHighDateTime);
/* Set the modified time... */ /* Set the modified time... */
GetSystemTimeAsFileTime(&info->LastModifiedTime); GetSystemTimeAsFileTime(&info->LastModifiedTime);
ret = SetUrlCacheEntryInfo(TEST_URL, info, CACHE_ENTRY_MODTIME_FC); ret = SetUrlCacheEntryInfo(test_url, info, CACHE_ENTRY_MODTIME_FC);
ok(ret, "SetUrlCacheEntryInfo failed: %d\n", GetLastError()); ok(ret, "SetUrlCacheEntryInfo failed: %d\n", GetLastError());
/* and the entry should still be unexpired.. */ /* and the entry should still be unexpired.. */
ret = IsUrlCacheEntryExpiredA(TEST_URL, 0, &ft); ret = IsUrlCacheEntryExpiredA(test_url, 0, &ft);
ok(!ret, "expected FALSE\n"); ok(!ret, "expected FALSE\n");
/* but the modified time returned is the last modified time just set. */ /* but the modified time returned is the last modified time just set. */
ok(ft.dwLowDateTime == info->LastModifiedTime.dwLowDateTime && ok(ft.dwLowDateTime == info->LastModifiedTime.dwLowDateTime &&
@ -355,10 +369,10 @@ static void test_urlcacheA(void)
static const FILETIME filetime_zero; static const FILETIME filetime_zero;
FILETIME now; FILETIME now;
ret = CreateUrlCacheEntry(TEST_URL, 0, "html", filenameA, 0); ret = CreateUrlCacheEntry(test_url, 0, "html", filenameA, 0);
ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError()); ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError());
ret = CreateUrlCacheEntry(TEST_URL, 0, "html", filenameA1, 0); ret = CreateUrlCacheEntry(test_url, 0, "html", filenameA1, 0);
ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError()); ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError());
check_file_exists(filenameA1); check_file_exists(filenameA1);
DeleteFileA(filenameA1); DeleteFileA(filenameA1);
@ -367,15 +381,15 @@ static void test_urlcacheA(void)
create_and_write_file(filenameA, &zero_byte, sizeof(zero_byte)); create_and_write_file(filenameA, &zero_byte, sizeof(zero_byte));
ret = CommitUrlCacheEntry(TEST_URL1, NULL, filetime_zero, filetime_zero, NORMAL_CACHE_ENTRY, NULL, 0, "html", NULL); ret = CommitUrlCacheEntry(test_url1, NULL, filetime_zero, filetime_zero, NORMAL_CACHE_ENTRY, NULL, 0, "html", NULL);
ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError()); ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError());
cbCacheEntryInfo = 0; cbCacheEntryInfo = 0;
ret = GetUrlCacheEntryInfo(TEST_URL1, NULL, &cbCacheEntryInfo); ret = GetUrlCacheEntryInfo(test_url1, NULL, &cbCacheEntryInfo);
ok(!ret, "GetUrlCacheEntryInfo should have failed\n"); ok(!ret, "GetUrlCacheEntryInfo should have failed\n");
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
"GetUrlCacheEntryInfo should have set last error to ERROR_INSUFFICIENT_BUFFER instead of %d\n", GetLastError()); "GetUrlCacheEntryInfo should have set last error to ERROR_INSUFFICIENT_BUFFER instead of %d\n", GetLastError());
lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo); lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo);
ret = GetUrlCacheEntryInfo(TEST_URL1, lpCacheEntryInfo, &cbCacheEntryInfo); ret = GetUrlCacheEntryInfo(test_url1, lpCacheEntryInfo, &cbCacheEntryInfo);
ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError()); ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError());
ok(!memcmp(&lpCacheEntryInfo->ExpireTime, &filetime_zero, sizeof(FILETIME)), ok(!memcmp(&lpCacheEntryInfo->ExpireTime, &filetime_zero, sizeof(FILETIME)),
"expected zero ExpireTime\n"); "expected zero ExpireTime\n");
@ -393,16 +407,16 @@ static void test_urlcacheA(void)
/* A subsequent commit with a different time/type doesn't change most of the entry */ /* A subsequent commit with a different time/type doesn't change most of the entry */
GetSystemTimeAsFileTime(&now); GetSystemTimeAsFileTime(&now);
ret = CommitUrlCacheEntry(TEST_URL1, NULL, now, now, NORMAL_CACHE_ENTRY, ret = CommitUrlCacheEntry(test_url1, NULL, now, now, NORMAL_CACHE_ENTRY,
(LPBYTE)ok_header, strlen(ok_header), NULL, NULL); (LPBYTE)ok_header, strlen(ok_header), NULL, NULL);
ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError()); ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError());
cbCacheEntryInfo = 0; cbCacheEntryInfo = 0;
ret = GetUrlCacheEntryInfo(TEST_URL1, NULL, &cbCacheEntryInfo); ret = GetUrlCacheEntryInfo(test_url1, NULL, &cbCacheEntryInfo);
ok(!ret, "GetUrlCacheEntryInfo should have failed\n"); ok(!ret, "GetUrlCacheEntryInfo should have failed\n");
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
"expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError()); "expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
lpCacheEntryInfo2 = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo); lpCacheEntryInfo2 = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo);
ret = GetUrlCacheEntryInfo(TEST_URL1, lpCacheEntryInfo2, &cbCacheEntryInfo); ret = GetUrlCacheEntryInfo(test_url1, lpCacheEntryInfo2, &cbCacheEntryInfo);
ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError()); ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError());
/* but it does change the time.. */ /* but it does change the time.. */
ok(memcmp(&lpCacheEntryInfo2->ExpireTime, &filetime_zero, sizeof(FILETIME)), ok(memcmp(&lpCacheEntryInfo2->ExpireTime, &filetime_zero, sizeof(FILETIME)),
@ -431,18 +445,18 @@ static void test_urlcacheA(void)
HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo); HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo);
HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo2); HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo2);
ret = CommitUrlCacheEntry(TEST_URL, filenameA, filetime_zero, filetime_zero, NORMAL_CACHE_ENTRY, NULL, 0, "html", NULL); ret = CommitUrlCacheEntry(test_url, filenameA, filetime_zero, filetime_zero, NORMAL_CACHE_ENTRY, NULL, 0, "html", NULL);
ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError()); ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError());
cbCacheEntryInfo = 0; cbCacheEntryInfo = 0;
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = RetrieveUrlCacheEntryFile(TEST_URL, NULL, &cbCacheEntryInfo, 0); ret = RetrieveUrlCacheEntryFile(test_url, NULL, &cbCacheEntryInfo, 0);
ok(!ret, "RetrieveUrlCacheEntryFile should have failed\n"); ok(!ret, "RetrieveUrlCacheEntryFile should have failed\n");
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
"RetrieveUrlCacheEntryFile should have set last error to ERROR_INSUFFICIENT_BUFFER instead of %d\n", GetLastError()); "RetrieveUrlCacheEntryFile should have set last error to ERROR_INSUFFICIENT_BUFFER instead of %d\n", GetLastError());
lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo); lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo);
ret = RetrieveUrlCacheEntryFile(TEST_URL, lpCacheEntryInfo, &cbCacheEntryInfo, 0); ret = RetrieveUrlCacheEntryFile(test_url, lpCacheEntryInfo, &cbCacheEntryInfo, 0);
ok(ret, "RetrieveUrlCacheEntryFile failed with error %d\n", GetLastError()); ok(ret, "RetrieveUrlCacheEntryFile failed with error %d\n", GetLastError());
if (ret) check_cache_entry_infoA("RetrieveUrlCacheEntryFile", lpCacheEntryInfo); if (ret) check_cache_entry_infoA("RetrieveUrlCacheEntryFile", lpCacheEntryInfo);
@ -451,14 +465,14 @@ static void test_urlcacheA(void)
cbCacheEntryInfo = 0; cbCacheEntryInfo = 0;
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = RetrieveUrlCacheEntryFile(TEST_URL1, NULL, &cbCacheEntryInfo, 0); ret = RetrieveUrlCacheEntryFile(test_url1, NULL, &cbCacheEntryInfo, 0);
ok(!ret, "RetrieveUrlCacheEntryFile should have failed\n"); ok(!ret, "RetrieveUrlCacheEntryFile should have failed\n");
ok(GetLastError() == ERROR_INVALID_DATA, ok(GetLastError() == ERROR_INVALID_DATA,
"RetrieveUrlCacheEntryFile should have set last error to ERROR_INVALID_DATA instead of %d\n", GetLastError()); "RetrieveUrlCacheEntryFile should have set last error to ERROR_INVALID_DATA instead of %d\n", GetLastError());
if (pUnlockUrlCacheEntryFileA) if (pUnlockUrlCacheEntryFileA)
{ {
ret = pUnlockUrlCacheEntryFileA(TEST_URL, 0); ret = pUnlockUrlCacheEntryFileA(test_url, 0);
ok(ret, "UnlockUrlCacheEntryFileA failed with error %d\n", GetLastError()); ok(ret, "UnlockUrlCacheEntryFileA failed with error %d\n", GetLastError());
} }
@ -471,9 +485,9 @@ static void test_urlcacheA(void)
if (pDeleteUrlCacheEntryA) if (pDeleteUrlCacheEntryA)
{ {
ret = pDeleteUrlCacheEntryA(TEST_URL); ret = pDeleteUrlCacheEntryA(test_url);
ok(ret, "DeleteUrlCacheEntryA failed with error %d\n", GetLastError()); ok(ret, "DeleteUrlCacheEntryA failed with error %d\n", GetLastError());
ret = pDeleteUrlCacheEntryA(TEST_URL1); ret = pDeleteUrlCacheEntryA(test_url1);
ok(ret, "DeleteUrlCacheEntryA failed with error %d\n", GetLastError()); ok(ret, "DeleteUrlCacheEntryA failed with error %d\n", GetLastError());
} }
@ -482,10 +496,10 @@ static void test_urlcacheA(void)
ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, "local file should no longer exist\n"); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, "local file should no longer exist\n");
/* Creating two entries with the same URL */ /* Creating two entries with the same URL */
ret = CreateUrlCacheEntry(TEST_URL, 0, "html", filenameA, 0); ret = CreateUrlCacheEntry(test_url, 0, "html", filenameA, 0);
ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError()); ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError());
ret = CreateUrlCacheEntry(TEST_URL, 0, "html", filenameA1, 0); ret = CreateUrlCacheEntry(test_url, 0, "html", filenameA1, 0);
ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError()); ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError());
ok(lstrcmpiA(filenameA, filenameA1), "expected a different file name\n"); ok(lstrcmpiA(filenameA, filenameA1), "expected a different file name\n");
@ -495,13 +509,13 @@ static void test_urlcacheA(void)
check_file_exists(filenameA); check_file_exists(filenameA);
check_file_exists(filenameA1); check_file_exists(filenameA1);
ret = CommitUrlCacheEntry(TEST_URL, filenameA, filetime_zero, ret = CommitUrlCacheEntry(test_url, filenameA, filetime_zero,
filetime_zero, NORMAL_CACHE_ENTRY, (LPBYTE)ok_header, filetime_zero, NORMAL_CACHE_ENTRY, (LPBYTE)ok_header,
strlen(ok_header), "html", NULL); strlen(ok_header), "html", NULL);
ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError()); ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError());
check_file_exists(filenameA); check_file_exists(filenameA);
check_file_exists(filenameA1); check_file_exists(filenameA1);
ret = CommitUrlCacheEntry(TEST_URL, filenameA1, filetime_zero, ret = CommitUrlCacheEntry(test_url, filenameA1, filetime_zero,
filetime_zero, COOKIE_CACHE_ENTRY, NULL, 0, "html", NULL); filetime_zero, COOKIE_CACHE_ENTRY, NULL, 0, "html", NULL);
ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError()); ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError());
/* By committing the same URL a second time, the prior entry is /* By committing the same URL a second time, the prior entry is
@ -509,12 +523,12 @@ static void test_urlcacheA(void)
*/ */
cbCacheEntryInfo = 0; cbCacheEntryInfo = 0;
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = GetUrlCacheEntryInfo(TEST_URL, NULL, &cbCacheEntryInfo); ret = GetUrlCacheEntryInfo(test_url, NULL, &cbCacheEntryInfo);
ok(!ret, "GetUrlCacheEntryInfo should have failed\n"); ok(!ret, "GetUrlCacheEntryInfo should have failed\n");
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
"expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError()); "expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo); lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo);
ret = GetUrlCacheEntryInfo(TEST_URL, lpCacheEntryInfo, &cbCacheEntryInfo); ret = GetUrlCacheEntryInfo(test_url, lpCacheEntryInfo, &cbCacheEntryInfo);
ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError()); ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError());
/* with the previous entry type retained.. */ /* with the previous entry type retained.. */
ok(lpCacheEntryInfo->CacheEntryType & NORMAL_CACHE_ENTRY, ok(lpCacheEntryInfo->CacheEntryType & NORMAL_CACHE_ENTRY,
@ -530,7 +544,7 @@ static void test_urlcacheA(void)
if (pDeleteUrlCacheEntryA) if (pDeleteUrlCacheEntryA)
{ {
ret = pDeleteUrlCacheEntryA(TEST_URL); ret = pDeleteUrlCacheEntryA(test_url);
ok(ret, "DeleteUrlCacheEntryA failed with error %d\n", GetLastError()); ok(ret, "DeleteUrlCacheEntryA failed with error %d\n", GetLastError());
check_file_not_exists(filenameA); check_file_not_exists(filenameA);
check_file_not_exists(filenameA1); check_file_not_exists(filenameA1);
@ -542,21 +556,21 @@ static void test_urlcacheA(void)
/* Check whether a retrieved cache entry can be deleted before it's /* Check whether a retrieved cache entry can be deleted before it's
* unlocked: * unlocked:
*/ */
ret = CreateUrlCacheEntry(TEST_URL, 0, "html", filenameA, 0); ret = CreateUrlCacheEntry(test_url, 0, "html", filenameA, 0);
ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError()); ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError());
ret = CommitUrlCacheEntry(TEST_URL, filenameA, filetime_zero, filetime_zero, ret = CommitUrlCacheEntry(test_url, filenameA, filetime_zero, filetime_zero,
NORMAL_CACHE_ENTRY, NULL, 0, "html", NULL); NORMAL_CACHE_ENTRY, NULL, 0, "html", NULL);
ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError()); ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError());
cbCacheEntryInfo = 0; cbCacheEntryInfo = 0;
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = RetrieveUrlCacheEntryFile(TEST_URL, NULL, &cbCacheEntryInfo, 0); ret = RetrieveUrlCacheEntryFile(test_url, NULL, &cbCacheEntryInfo, 0);
ok(!ret, "RetrieveUrlCacheEntryFile should have failed\n"); ok(!ret, "RetrieveUrlCacheEntryFile should have failed\n");
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
"expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError()); "expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo); lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo);
ret = RetrieveUrlCacheEntryFile(TEST_URL, lpCacheEntryInfo, ret = RetrieveUrlCacheEntryFile(test_url, lpCacheEntryInfo,
&cbCacheEntryInfo, 0); &cbCacheEntryInfo, 0);
ok(ret, "RetrieveUrlCacheEntryFile failed with error %d\n", GetLastError()); ok(ret, "RetrieveUrlCacheEntryFile failed with error %d\n", GetLastError());
@ -564,7 +578,7 @@ static void test_urlcacheA(void)
if (pDeleteUrlCacheEntryA) if (pDeleteUrlCacheEntryA)
{ {
ret = pDeleteUrlCacheEntryA(TEST_URL); ret = pDeleteUrlCacheEntryA(test_url);
ok(!ret, "Expected failure\n"); ok(!ret, "Expected failure\n");
ok(GetLastError() == ERROR_SHARING_VIOLATION, ok(GetLastError() == ERROR_SHARING_VIOLATION,
"Expected ERROR_SHARING_VIOLATION, got %d\n", GetLastError()); "Expected ERROR_SHARING_VIOLATION, got %d\n", GetLastError());
@ -573,7 +587,7 @@ static void test_urlcacheA(void)
lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo); lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo);
memset(lpCacheEntryInfo, 0, cbCacheEntryInfo); memset(lpCacheEntryInfo, 0, cbCacheEntryInfo);
ret = GetUrlCacheEntryInfo(TEST_URL, lpCacheEntryInfo, &cbCacheEntryInfo); ret = GetUrlCacheEntryInfo(test_url, lpCacheEntryInfo, &cbCacheEntryInfo);
ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError()); ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError());
ok(lpCacheEntryInfo->CacheEntryType & 0x400000, ok(lpCacheEntryInfo->CacheEntryType & 0x400000,
"CacheEntryType hasn't PENDING_DELETE_CACHE_ENTRY set, (flags %08x)\n", "CacheEntryType hasn't PENDING_DELETE_CACHE_ENTRY set, (flags %08x)\n",
@ -583,7 +597,7 @@ static void test_urlcacheA(void)
if (pUnlockUrlCacheEntryFileA) if (pUnlockUrlCacheEntryFileA)
{ {
check_file_exists(filenameA); check_file_exists(filenameA);
ret = pUnlockUrlCacheEntryFileA(TEST_URL, 0); ret = pUnlockUrlCacheEntryFileA(test_url, 0);
ok(ret, "UnlockUrlCacheEntryFileA failed: %d\n", GetLastError()); ok(ret, "UnlockUrlCacheEntryFileA failed: %d\n", GetLastError());
/* By unlocking the already-deleted cache entry, the file associated /* By unlocking the already-deleted cache entry, the file associated
* with it is deleted.. * with it is deleted..
@ -595,7 +609,7 @@ static void test_urlcacheA(void)
if (pDeleteUrlCacheEntryA) if (pDeleteUrlCacheEntryA)
{ {
/* and a subsequent deletion should fail. */ /* and a subsequent deletion should fail. */
ret = pDeleteUrlCacheEntryA(TEST_URL); ret = pDeleteUrlCacheEntryA(test_url);
ok(!ret, "Expected failure\n"); ok(!ret, "Expected failure\n");
ok(GetLastError() == ERROR_FILE_NOT_FOUND, ok(GetLastError() == ERROR_FILE_NOT_FOUND,
"expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError()); "expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
@ -604,13 +618,13 @@ static void test_urlcacheA(void)
/* Test whether preventing a file from being deleted causes /* Test whether preventing a file from being deleted causes
* DeleteUrlCacheEntryA to fail. * DeleteUrlCacheEntryA to fail.
*/ */
ret = CreateUrlCacheEntry(TEST_URL, 0, "html", filenameA, 0); ret = CreateUrlCacheEntry(test_url, 0, "html", filenameA, 0);
ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError()); ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError());
create_and_write_file(filenameA, &zero_byte, sizeof(zero_byte)); create_and_write_file(filenameA, &zero_byte, sizeof(zero_byte));
check_file_exists(filenameA); check_file_exists(filenameA);
ret = CommitUrlCacheEntry(TEST_URL, filenameA, filetime_zero, ret = CommitUrlCacheEntry(test_url, filenameA, filetime_zero,
filetime_zero, NORMAL_CACHE_ENTRY, (LPBYTE)ok_header, filetime_zero, NORMAL_CACHE_ENTRY, (LPBYTE)ok_header,
strlen(ok_header), "html", NULL); strlen(ok_header), "html", NULL);
ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError()); ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError());
@ -622,14 +636,14 @@ static void test_urlcacheA(void)
if (pDeleteUrlCacheEntryA) if (pDeleteUrlCacheEntryA)
{ {
/* DeleteUrlCacheEntryA should succeed.. */ /* DeleteUrlCacheEntryA should succeed.. */
ret = pDeleteUrlCacheEntryA(TEST_URL); ret = pDeleteUrlCacheEntryA(test_url);
ok(ret, "DeleteUrlCacheEntryA failed with error %d\n", GetLastError()); ok(ret, "DeleteUrlCacheEntryA failed with error %d\n", GetLastError());
} }
CloseHandle(hFile); CloseHandle(hFile);
if (pDeleteUrlCacheEntryA) if (pDeleteUrlCacheEntryA)
{ {
/* and a subsequent deletion should fail.. */ /* and a subsequent deletion should fail.. */
ret = pDeleteUrlCacheEntryA(TEST_URL); ret = pDeleteUrlCacheEntryA(test_url);
ok(!ret, "Expected failure\n"); ok(!ret, "Expected failure\n");
ok(GetLastError() == ERROR_FILE_NOT_FOUND, ok(GetLastError() == ERROR_FILE_NOT_FOUND,
"expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError()); "expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
@ -642,35 +656,35 @@ static void test_urlcacheA(void)
* must have been set already. * must have been set already.
*/ */
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = CommitUrlCacheEntry(TEST_URL, NULL, filetime_zero, filetime_zero, ret = CommitUrlCacheEntry(test_url, NULL, filetime_zero, filetime_zero,
STICKY_CACHE_ENTRY, (LPBYTE)ok_header, strlen(ok_header), "html", STICKY_CACHE_ENTRY, (LPBYTE)ok_header, strlen(ok_header), "html",
NULL); NULL);
ok(!ret, "expected failure\n"); ok(!ret, "expected failure\n");
ok(GetLastError() == ERROR_INVALID_PARAMETER, ok(GetLastError() == ERROR_INVALID_PARAMETER,
"expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = CommitUrlCacheEntry(TEST_URL, NULL, filetime_zero, filetime_zero, ret = CommitUrlCacheEntry(test_url, NULL, filetime_zero, filetime_zero,
NORMAL_CACHE_ENTRY|STICKY_CACHE_ENTRY, NORMAL_CACHE_ENTRY|STICKY_CACHE_ENTRY,
(LPBYTE)ok_header, strlen(ok_header), "html", NULL); (LPBYTE)ok_header, strlen(ok_header), "html", NULL);
ok(!ret, "expected failure\n"); ok(!ret, "expected failure\n");
ok(GetLastError() == ERROR_INVALID_PARAMETER, ok(GetLastError() == ERROR_INVALID_PARAMETER,
"expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
ret = CreateUrlCacheEntry(TEST_URL, 0, "html", filenameA, 0); ret = CreateUrlCacheEntry(test_url, 0, "html", filenameA, 0);
ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError()); ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError());
create_and_write_file(filenameA, &zero_byte, sizeof(zero_byte)); create_and_write_file(filenameA, &zero_byte, sizeof(zero_byte));
ret = CommitUrlCacheEntry(TEST_URL, filenameA, filetime_zero, filetime_zero, ret = CommitUrlCacheEntry(test_url, filenameA, filetime_zero, filetime_zero,
NORMAL_CACHE_ENTRY|STICKY_CACHE_ENTRY, NORMAL_CACHE_ENTRY|STICKY_CACHE_ENTRY,
(LPBYTE)ok_header, strlen(ok_header), "html", NULL); (LPBYTE)ok_header, strlen(ok_header), "html", NULL);
ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError()); ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError());
cbCacheEntryInfo = 0; cbCacheEntryInfo = 0;
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = GetUrlCacheEntryInfo(TEST_URL, NULL, &cbCacheEntryInfo); ret = GetUrlCacheEntryInfo(test_url, NULL, &cbCacheEntryInfo);
ok(!ret, "GetUrlCacheEntryInfo should have failed\n"); ok(!ret, "GetUrlCacheEntryInfo should have failed\n");
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
"expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError()); "expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo); lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo);
ret = GetUrlCacheEntryInfo(TEST_URL, lpCacheEntryInfo, &cbCacheEntryInfo); ret = GetUrlCacheEntryInfo(test_url, lpCacheEntryInfo, &cbCacheEntryInfo);
ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError()); ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError());
ok(lpCacheEntryInfo->CacheEntryType & (NORMAL_CACHE_ENTRY|STICKY_CACHE_ENTRY), ok(lpCacheEntryInfo->CacheEntryType & (NORMAL_CACHE_ENTRY|STICKY_CACHE_ENTRY),
"expected cache entry type NORMAL_CACHE_ENTRY | STICKY_CACHE_ENTRY, got %d (0x%08x)\n", "expected cache entry type NORMAL_CACHE_ENTRY | STICKY_CACHE_ENTRY, got %d (0x%08x)\n",
@ -681,27 +695,27 @@ static void test_urlcacheA(void)
HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo); HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo);
if (pDeleteUrlCacheEntryA) if (pDeleteUrlCacheEntryA)
{ {
ret = pDeleteUrlCacheEntryA(TEST_URL); ret = pDeleteUrlCacheEntryA(test_url);
ok(ret, "DeleteUrlCacheEntryA failed with error %d\n", GetLastError()); ok(ret, "DeleteUrlCacheEntryA failed with error %d\n", GetLastError());
/* When explicitly deleting the cache entry, the file is also deleted */ /* When explicitly deleting the cache entry, the file is also deleted */
check_file_not_exists(filenameA); check_file_not_exists(filenameA);
} }
/* Test once again, setting the exempt delta via SetUrlCacheEntryInfo */ /* Test once again, setting the exempt delta via SetUrlCacheEntryInfo */
ret = CreateUrlCacheEntry(TEST_URL, 0, "html", filenameA, 0); ret = CreateUrlCacheEntry(test_url, 0, "html", filenameA, 0);
ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError()); ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError());
create_and_write_file(filenameA, &zero_byte, sizeof(zero_byte)); create_and_write_file(filenameA, &zero_byte, sizeof(zero_byte));
ret = CommitUrlCacheEntry(TEST_URL, filenameA, filetime_zero, filetime_zero, ret = CommitUrlCacheEntry(test_url, filenameA, filetime_zero, filetime_zero,
NORMAL_CACHE_ENTRY|STICKY_CACHE_ENTRY, NORMAL_CACHE_ENTRY|STICKY_CACHE_ENTRY,
(LPBYTE)ok_header, strlen(ok_header), "html", NULL); (LPBYTE)ok_header, strlen(ok_header), "html", NULL);
ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError()); ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError());
cbCacheEntryInfo = 0; cbCacheEntryInfo = 0;
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = GetUrlCacheEntryInfo(TEST_URL, NULL, &cbCacheEntryInfo); ret = GetUrlCacheEntryInfo(test_url, NULL, &cbCacheEntryInfo);
ok(!ret, "GetUrlCacheEntryInfo should have failed\n"); ok(!ret, "GetUrlCacheEntryInfo should have failed\n");
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
"expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError()); "expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo); lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo);
ret = GetUrlCacheEntryInfo(TEST_URL, lpCacheEntryInfo, &cbCacheEntryInfo); ret = GetUrlCacheEntryInfo(test_url, lpCacheEntryInfo, &cbCacheEntryInfo);
ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError()); ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError());
ok(lpCacheEntryInfo->CacheEntryType & (NORMAL_CACHE_ENTRY|STICKY_CACHE_ENTRY), ok(lpCacheEntryInfo->CacheEntryType & (NORMAL_CACHE_ENTRY|STICKY_CACHE_ENTRY),
"expected cache entry type NORMAL_CACHE_ENTRY | STICKY_CACHE_ENTRY, got %d (0x%08x)\n", "expected cache entry type NORMAL_CACHE_ENTRY | STICKY_CACHE_ENTRY, got %d (0x%08x)\n",
@ -710,10 +724,10 @@ static void test_urlcacheA(void)
"expected dwExemptDelta 86400, got %d\n", "expected dwExemptDelta 86400, got %d\n",
U(*lpCacheEntryInfo).dwExemptDelta); U(*lpCacheEntryInfo).dwExemptDelta);
U(*lpCacheEntryInfo).dwExemptDelta = 0; U(*lpCacheEntryInfo).dwExemptDelta = 0;
ret = SetUrlCacheEntryInfoA(TEST_URL, lpCacheEntryInfo, ret = SetUrlCacheEntryInfoA(test_url, lpCacheEntryInfo,
CACHE_ENTRY_EXEMPT_DELTA_FC); CACHE_ENTRY_EXEMPT_DELTA_FC);
ok(ret, "SetUrlCacheEntryInfo failed: %d\n", GetLastError()); ok(ret, "SetUrlCacheEntryInfo failed: %d\n", GetLastError());
ret = GetUrlCacheEntryInfo(TEST_URL, lpCacheEntryInfo, &cbCacheEntryInfo); ret = GetUrlCacheEntryInfo(test_url, lpCacheEntryInfo, &cbCacheEntryInfo);
ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError()); ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError());
ok(!U(*lpCacheEntryInfo).dwExemptDelta, "expected dwExemptDelta 0, got %d\n", ok(!U(*lpCacheEntryInfo).dwExemptDelta, "expected dwExemptDelta 0, got %d\n",
U(*lpCacheEntryInfo).dwExemptDelta); U(*lpCacheEntryInfo).dwExemptDelta);
@ -726,20 +740,20 @@ static void test_urlcacheA(void)
/* Recommit of Url entry keeps dwExemptDelta */ /* Recommit of Url entry keeps dwExemptDelta */
U(*lpCacheEntryInfo).dwExemptDelta = 8600; U(*lpCacheEntryInfo).dwExemptDelta = 8600;
ret = SetUrlCacheEntryInfoA(TEST_URL, lpCacheEntryInfo, ret = SetUrlCacheEntryInfoA(test_url, lpCacheEntryInfo,
CACHE_ENTRY_EXEMPT_DELTA_FC); CACHE_ENTRY_EXEMPT_DELTA_FC);
ok(ret, "SetUrlCacheEntryInfo failed: %d\n", GetLastError()); ok(ret, "SetUrlCacheEntryInfo failed: %d\n", GetLastError());
ret = CreateUrlCacheEntry(TEST_URL, 0, "html", filenameA1, 0); ret = CreateUrlCacheEntry(test_url, 0, "html", filenameA1, 0);
ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError()); ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError());
create_and_write_file(filenameA1, &zero_byte, sizeof(zero_byte)); create_and_write_file(filenameA1, &zero_byte, sizeof(zero_byte));
ret = CommitUrlCacheEntry(TEST_URL, filenameA1, filetime_zero, filetime_zero, ret = CommitUrlCacheEntry(test_url, filenameA1, filetime_zero, filetime_zero,
NORMAL_CACHE_ENTRY|STICKY_CACHE_ENTRY, NORMAL_CACHE_ENTRY|STICKY_CACHE_ENTRY,
(LPBYTE)ok_header, strlen(ok_header), "html", NULL); (LPBYTE)ok_header, strlen(ok_header), "html", NULL);
ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError()); ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError());
ret = GetUrlCacheEntryInfo(TEST_URL, lpCacheEntryInfo, &cbCacheEntryInfo); ret = GetUrlCacheEntryInfo(test_url, lpCacheEntryInfo, &cbCacheEntryInfo);
ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError()); ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError());
ok(U(*lpCacheEntryInfo).dwExemptDelta == 8600, ok(U(*lpCacheEntryInfo).dwExemptDelta == 8600,
"expected dwExemptDelta 8600, got %d\n", "expected dwExemptDelta 8600, got %d\n",
@ -749,45 +763,45 @@ static void test_urlcacheA(void)
if (pDeleteUrlCacheEntryA) if (pDeleteUrlCacheEntryA)
{ {
ret = pDeleteUrlCacheEntryA(TEST_URL); ret = pDeleteUrlCacheEntryA(test_url);
ok(ret, "DeleteUrlCacheEntryA failed with error %d\n", GetLastError()); ok(ret, "DeleteUrlCacheEntryA failed with error %d\n", GetLastError());
check_file_not_exists(filenameA); check_file_not_exists(filenameA);
} }
/* Test if files with identical hash keys are handled correctly */ /* Test if files with identical hash keys are handled correctly */
ret = CommitUrlCacheEntryA(TEST_HASH_COLLISIONS1, NULL, filetime_zero, filetime_zero, NORMAL_CACHE_ENTRY, NULL, 0, "html", NULL); ret = CommitUrlCacheEntryA(test_hash_collisions1, NULL, filetime_zero, filetime_zero, NORMAL_CACHE_ENTRY, NULL, 0, "html", NULL);
ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError()); ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError());
ret = CommitUrlCacheEntryA(TEST_HASH_COLLISIONS2, NULL, filetime_zero, filetime_zero, NORMAL_CACHE_ENTRY, NULL, 0, "html", NULL); ret = CommitUrlCacheEntryA(test_hash_collisions2, NULL, filetime_zero, filetime_zero, NORMAL_CACHE_ENTRY, NULL, 0, "html", NULL);
ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError()); ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError());
cbCacheEntryInfo = 0; cbCacheEntryInfo = 0;
ret = GetUrlCacheEntryInfo(TEST_HASH_COLLISIONS1, NULL, &cbCacheEntryInfo); ret = GetUrlCacheEntryInfo(test_hash_collisions1, NULL, &cbCacheEntryInfo);
ok(!ret, "GetUrlCacheEntryInfo should have failed\n"); ok(!ret, "GetUrlCacheEntryInfo should have failed\n");
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
"expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError()); "expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo); lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo);
ret = GetUrlCacheEntryInfo(TEST_HASH_COLLISIONS1, lpCacheEntryInfo, &cbCacheEntryInfo); ret = GetUrlCacheEntryInfo(test_hash_collisions1, lpCacheEntryInfo, &cbCacheEntryInfo);
ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError()); ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError());
ok(!strcmp(lpCacheEntryInfo->lpszSourceUrlName, TEST_HASH_COLLISIONS1), ok(!strcmp(lpCacheEntryInfo->lpszSourceUrlName, test_hash_collisions1),
"got incorrect entry: %s\n", lpCacheEntryInfo->lpszSourceUrlName); "got incorrect entry: %s\n", lpCacheEntryInfo->lpszSourceUrlName);
HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo); HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo);
cbCacheEntryInfo = 0; cbCacheEntryInfo = 0;
ret = GetUrlCacheEntryInfo(TEST_HASH_COLLISIONS2, NULL, &cbCacheEntryInfo); ret = GetUrlCacheEntryInfo(test_hash_collisions2, NULL, &cbCacheEntryInfo);
ok(!ret, "GetUrlCacheEntryInfo should have failed\n"); ok(!ret, "GetUrlCacheEntryInfo should have failed\n");
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
"expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError()); "expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo); lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo);
ret = GetUrlCacheEntryInfo(TEST_HASH_COLLISIONS2, lpCacheEntryInfo, &cbCacheEntryInfo); ret = GetUrlCacheEntryInfo(test_hash_collisions2, lpCacheEntryInfo, &cbCacheEntryInfo);
ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError()); ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError());
ok(!strcmp(lpCacheEntryInfo->lpszSourceUrlName, TEST_HASH_COLLISIONS2), ok(!strcmp(lpCacheEntryInfo->lpszSourceUrlName, test_hash_collisions2),
"got incorrect entry: %s\n", lpCacheEntryInfo->lpszSourceUrlName); "got incorrect entry: %s\n", lpCacheEntryInfo->lpszSourceUrlName);
HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo); HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo);
if (pDeleteUrlCacheEntryA) { if (pDeleteUrlCacheEntryA) {
ret = pDeleteUrlCacheEntryA(TEST_HASH_COLLISIONS1); ret = pDeleteUrlCacheEntryA(test_hash_collisions1);
ok(ret, "DeleteUrlCacheEntry failed: %d\n", GetLastError()); ok(ret, "DeleteUrlCacheEntry failed: %d\n", GetLastError());
ret = pDeleteUrlCacheEntryA(TEST_HASH_COLLISIONS2); ret = pDeleteUrlCacheEntryA(test_hash_collisions2);
ok(ret, "DeleteUrlCacheEntry failed: %d\n", GetLastError()); ok(ret, "DeleteUrlCacheEntry failed: %d\n", GetLastError());
} }
} }