ReactOS 0.4.17-dev-1321-g5c122a9
urlcache.c File Reference
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#include "wininet.h"
#include "winineti.h"
#include "shlobj.h"
#include "wine/test.h"
Include dependency graph for urlcache.c:

Go to the source code of this file.

Macros

#define check_file_exists(f)   _check_file_exists(__LINE__, f)
 
#define check_file_not_exists(f)   _check_file_not_exists(__LINE__, f)
 

Functions

static BOOL (WINAPI *pDeleteUrlCacheEntryA)(LPCSTR)
 
static void check_cache_entry_infoA (const char *returnedfrom, INTERNET_CACHE_ENTRY_INFOA *lpCacheEntryInfo)
 
static void test_find_url_cache_entriesA (void)
 
static void test_GetUrlCacheEntryInfoExA (void)
 
static void test_RetrieveUrlCacheEntryA (void)
 
static void test_IsUrlCacheEntryExpiredA (void)
 
static void _check_file_exists (LONG l, LPCSTR filename)
 
static void _check_file_not_exists (LONG l, LPCSTR filename)
 
static void create_and_write_file (LPCSTR filename, void *data, DWORD len)
 
static void test_urlcacheA (void)
 
static void test_urlcacheW (void)
 
static void test_FindCloseUrlCache (void)
 
static void test_GetDiskInfoA (void)
 
static BOOL cache_entry_exists (const char *url)
 
static void test_trailing_slash (void)
 
static void get_cache_path (DWORD flags, char path[MAX_PATH], char path_win8[MAX_PATH])
 
static void test_GetUrlCacheConfigInfo (void)
 
 START_TEST (urlcache)
 

Variables

static const char test_url [] = "http://urlcachetest.winehq.org/index.html"
 
static const WCHAR test_urlW []
 
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 DWORD
 
static char filenameA [MAX_PATH+1]
 
static char filenameA1 [MAX_PATH+1]
 
static BOOL old_ie = FALSE
 
static BOOL ie10_cache = FALSE
 

Macro Definition Documentation

◆ check_file_exists

#define check_file_exists (   f)    _check_file_exists(__LINE__, f)

Definition at line 332 of file urlcache.c.

◆ check_file_not_exists

#define check_file_not_exists (   f)    _check_file_not_exists(__LINE__, f)

Definition at line 346 of file urlcache.c.

Function Documentation

◆ _check_file_exists()

static void _check_file_exists ( LONG  l,
LPCSTR  filename 
)
static

Definition at line 320 of file urlcache.c.

321{
322 HANDLE file;
323
326 ok_(__FILE__,l)(file != INVALID_HANDLE_VALUE,
327 "expected file to exist, CreateFile failed with error %ld\n",
328 GetLastError());
330}
#define ok_(x1, x2)
Definition: atltest.h:61
r l[0]
Definition: byte_order.h:168
#define NULL
Definition: types.h:112
#define CloseHandle
Definition: compat.h:739
#define OPEN_EXISTING
Definition: compat.h:775
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:740
#define GENERIC_READ
Definition: compat.h:135
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define FILE_SHARE_READ
Definition: compat.h:136
const char * filename
Definition: ioapi.h:137
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
Definition: fci.c:123
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

◆ _check_file_not_exists()

static void _check_file_not_exists ( LONG  l,
LPCSTR  filename 
)
static

Definition at line 334 of file urlcache.c.

335{
336 HANDLE file;
337
340 ok_(__FILE__,l)(file == INVALID_HANDLE_VALUE,
341 "expected file not to exist\n");
344}

◆ BOOL()

static BOOL ( WINAPI *  pDeleteUrlCacheEntryA)
static

◆ cache_entry_exists()

static BOOL cache_entry_exists ( const char *  url)
static

Definition at line 1047 of file urlcache.c.

1048{
1049 static char buf[10000];
1050 DWORD size = sizeof(buf);
1051 BOOL ret;
1052
1053 ret = GetUrlCacheEntryInfoA(url, (void*)buf, &size);
1054 ok(ret || GetLastError() == ERROR_FILE_NOT_FOUND, "GetUrlCacheEntryInfoA returned %x (%lu)\n", ret, GetLastError());
1055
1056 return ret;
1057}
#define ok(value,...)
Definition: atltest.h:57
BOOL WINAPI GetUrlCacheEntryInfoA(LPCSTR lpszUrlName, LPINTERNET_CACHE_ENTRY_INFOA lpCacheEntryInfo, LPDWORD lpdwCacheEntryInfoBufferSize)
Definition: urlcache.c:1881
return ret
Definition: mutex.c:147
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizeiptr size
Definition: glext.h:5919
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
static const WCHAR url[]
Definition: encode.c:1384

Referenced by test_trailing_slash().

◆ check_cache_entry_infoA()

static void check_cache_entry_infoA ( const char *  returnedfrom,
INTERNET_CACHE_ENTRY_INFOA *  lpCacheEntryInfo 
)
static

Definition at line 49 of file urlcache.c.

50{
51 ok(lpCacheEntryInfo->dwStructSize == sizeof(*lpCacheEntryInfo), "%s: dwStructSize was %ld\n", returnedfrom, lpCacheEntryInfo->dwStructSize);
52 ok(!strcmp(lpCacheEntryInfo->lpszSourceUrlName, test_url), "%s: lpszSourceUrlName should be %s instead of %s\n", returnedfrom, test_url, lpCacheEntryInfo->lpszSourceUrlName);
53 ok(!strcmp(lpCacheEntryInfo->lpszLocalFileName, filenameA), "%s: lpszLocalFileName should be %s instead of %s\n", returnedfrom, filenameA, lpCacheEntryInfo->lpszLocalFileName);
54 ok(!strcmp(lpCacheEntryInfo->lpszFileExtension, "html"), "%s: lpszFileExtension should be html instead of %s\n", returnedfrom, lpCacheEntryInfo->lpszFileExtension);
55}
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3324
static char filenameA[MAX_PATH+1]
Definition: urlcache.c:44
static const char test_url[]
Definition: urlcache.c:34
LPSTR lpszFileExtension
Definition: wininet.h:2120
LPSTR lpszLocalFileName
Definition: wininet.h:2107
DWORD dwStructSize
Definition: wininet.h:2105
LPSTR lpszSourceUrlName
Definition: wininet.h:2106

Referenced by test_GetUrlCacheEntryInfoExA(), and test_urlcacheA().

◆ create_and_write_file()

static void create_and_write_file ( LPCSTR  filename,
void *  data,
DWORD  len 
)
static

Definition at line 348 of file urlcache.c.

349{
350 HANDLE file;
351 DWORD written;
352 BOOL ret;
353
357 ok(file != INVALID_HANDLE_VALUE, "CreateFileA failed with error %ld\n", GetLastError());
358
359 ret = WriteFile(file, data, len, &written, NULL);
360 ok(ret, "WriteFile failed with error %ld\n", GetLastError());
361
363}
BOOL WINAPI WriteFile(_In_ HANDLE hFile, _In_reads_bytes_opt_(nNumberOfBytesToWrite) LPCVOID lpBuffer, _In_ DWORD nNumberOfBytesToWrite, _Out_opt_ LPDWORD lpNumberOfBytesWritten, _Inout_opt_ LPOVERLAPPED lpOverlapped)
Definition: rw.c:25
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLenum GLsizei len
Definition: glext.h:6722
#define CREATE_ALWAYS
Definition: disk.h:72
#define GENERIC_WRITE
Definition: nt_native.h:90

Referenced by test_trailing_slash(), and test_urlcacheA().

◆ get_cache_path()

static void get_cache_path ( DWORD  flags,
char  path[MAX_PATH],
char  path_win8[MAX_PATH] 
)
static

Definition at line 1086 of file urlcache.c.

1087{
1088 BOOL ret;
1089 int folder = -1;
1090 const char *suffix = "";
1091 const char *suffix_win8 = "";
1092
1093 switch (flags)
1094 {
1095 case 0:
1098 suffix = "\\Content.IE5\\";
1099 suffix_win8 = "\\IE\\";
1100 break;
1101
1104 suffix = "\\";
1105 suffix_win8 = "\\";
1106 break;
1107
1110 suffix = "\\History.IE5\\";
1111 suffix_win8 = "\\History.IE5\\";
1112 break;
1113
1114 default:
1115 ok(0, "unexpected flags %#lx\n", flags);
1116 break;
1117 }
1118
1120 ok(ret, "SHGetSpecialFolderPath error %lu\n", GetLastError());
1121
1122 strcpy(path_win8, path);
1123 strcat(path_win8, suffix_win8);
1124
1125 strcat(path, suffix);
1126}
#define FALSE
Definition: types.h:117
BOOL WINAPI SHGetSpecialFolderPathA(HWND hwndOwner, LPSTR szPath, int nFolder, BOOL bCreate)
Definition: shellpath.c:4381
GLbitfield flags
Definition: glext.h:7161
strcat
Definition: string.h:92
strcpy
Definition: string.h:131
#define CSIDL_INTERNET_CACHE
Definition: shlobj.h:2251
#define CSIDL_COOKIES
Definition: shlobj.h:2252
#define CSIDL_HISTORY
Definition: shlobj.h:2253
Definition: fci.c:112
#define CACHE_CONFIG_CONTENT_PATHS_FC
Definition: winineti.h:101
#define CACHE_CONFIG_HISTORY_PATHS_FC
Definition: winineti.h:103
#define CACHE_CONFIG_COOKIES_PATHS_FC
Definition: winineti.h:102

Referenced by test_GetUrlCacheConfigInfo().

◆ START_TEST()

START_TEST ( urlcache  )

Definition at line 1182 of file urlcache.c.

1183{
1184 HMODULE hdll;
1185 hdll = GetModuleHandleA("wininet.dll");
1186
1187 if(!GetProcAddress(hdll, "InternetGetCookieExW")) {
1188 win_skip("Too old IE (older than 6.0)\n");
1189 return;
1190 }
1191 if(!GetProcAddress(hdll, "InternetGetSecurityInfoByURL")) /* < IE7 */
1192 old_ie = TRUE;
1193
1194 if(GetProcAddress(hdll, "CreateUrlCacheEntryExW")) {
1195 trace("Running tests on IE10 or newer\n");
1196 ie10_cache = TRUE;
1197 }
1198
1199 pDeleteUrlCacheEntryA = (void*)GetProcAddress(hdll, "DeleteUrlCacheEntryA");
1200 pUnlockUrlCacheEntryFileA = (void*)GetProcAddress(hdll, "UnlockUrlCacheEntryFileA");
1207}
#define trace
Definition: atltest.h:70
#define TRUE
Definition: types.h:120
#define GetProcAddress(x, y)
Definition: compat.h:753
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
#define win_skip
Definition: minitest.h:67
static void test_trailing_slash(void)
Definition: urlcache.c:1059
static void test_GetUrlCacheConfigInfo(void)
Definition: urlcache.c:1128
static BOOL ie10_cache
Definition: urlcache.c:47
static void test_FindCloseUrlCache(void)
Definition: urlcache.c:995
static void test_urlcacheA(void)
Definition: urlcache.c:365
static void test_urlcacheW(void)
Definition: urlcache.c:839
static void test_GetDiskInfoA(void)
Definition: urlcache.c:1007
static BOOL old_ie
Definition: urlcache.c:46
static PVOID hdll
Definition: shimdbg.c:126

◆ test_find_url_cache_entriesA()

static void test_find_url_cache_entriesA ( void  )
static

Definition at line 57 of file urlcache.c.

58{
59 BOOL ret;
60 HANDLE hEnumHandle;
61 BOOL found = FALSE;
62 DWORD cbCacheEntryInfo;
63 DWORD cbCacheEntryInfoSaved;
64 INTERNET_CACHE_ENTRY_INFOA *lpCacheEntryInfo;
65
66 cbCacheEntryInfo = 0;
67 SetLastError(0xdeadbeef);
68 hEnumHandle = FindFirstUrlCacheEntryA(NULL, NULL, &cbCacheEntryInfo);
69 ok(!hEnumHandle, "FindFirstUrlCacheEntry should have failed\n");
70 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "FindFirstUrlCacheEntry should have set last error to ERROR_INSUFFICIENT_BUFFER instead of %ld\n", GetLastError());
71 lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo * sizeof(char));
72 cbCacheEntryInfoSaved = cbCacheEntryInfo;
73 hEnumHandle = FindFirstUrlCacheEntryA(NULL, lpCacheEntryInfo, &cbCacheEntryInfo);
74 ok(hEnumHandle != NULL, "FindFirstUrlCacheEntry failed with error %ld\n", GetLastError());
75 while (TRUE)
76 {
77 if (!strcmp(lpCacheEntryInfo->lpszSourceUrlName, test_url))
78 {
79 found = TRUE;
80 ret = TRUE;
81 break;
82 }
83 SetLastError(0xdeadbeef);
84 cbCacheEntryInfo = cbCacheEntryInfoSaved;
85 ret = FindNextUrlCacheEntryA(hEnumHandle, lpCacheEntryInfo, &cbCacheEntryInfo);
86 if (!ret)
87 {
89 {
90 lpCacheEntryInfo = HeapReAlloc(GetProcessHeap(), 0, lpCacheEntryInfo, cbCacheEntryInfo);
91 cbCacheEntryInfoSaved = cbCacheEntryInfo;
92 ret = FindNextUrlCacheEntryA(hEnumHandle, lpCacheEntryInfo, &cbCacheEntryInfo);
93 }
94 }
95 if (!ret)
96 break;
97 }
98 ok(ret, "FindNextUrlCacheEntry failed with error %ld\n", GetLastError());
99 ok(found, "Committed url cache entry not found during enumeration\n");
100
101 ret = FindCloseUrlCache(hEnumHandle);
102 ok(ret, "FindCloseUrlCache failed with error %ld\n", GetLastError());
103 HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo);
104}
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define GetProcessHeap()
Definition: compat.h:736
#define SetLastError(x)
Definition: compat.h:752
#define HeapAlloc
Definition: compat.h:733
#define HeapReAlloc
Definition: compat.h:734
#define HeapFree(x, y, z)
Definition: compat.h:735
INTERNETAPI HANDLE WINAPI FindFirstUrlCacheEntryA(LPCSTR lpszUrlSearchPattern, LPINTERNET_CACHE_ENTRY_INFOA lpFirstCacheEntryInfo, LPDWORD lpdwFirstCacheEntryInfoBufferSize)
Definition: urlcache.c:3462
BOOL WINAPI FindCloseUrlCache(HANDLE hEnumHandle)
Definition: urlcache.c:3652
BOOL WINAPI FindNextUrlCacheEntryA(HANDLE hEnumHandle, LPINTERNET_CACHE_ENTRY_INFOA lpNextCacheEntryInfo, LPDWORD lpdwNextCacheEntryInfoBufferSize)
Definition: urlcache.c:3622
Definition: wininet.h:2104

Referenced by test_urlcacheA().

◆ test_FindCloseUrlCache()

static void test_FindCloseUrlCache ( void  )
static

Definition at line 995 of file urlcache.c.

996{
997 BOOL r;
998 DWORD err;
999
1000 SetLastError(0xdeadbeef);
1002 err = GetLastError();
1003 ok(0 == r, "expected 0, got %d\n", r);
1004 ok(ERROR_INVALID_HANDLE == err, "expected %d, got %ld\n", ERROR_INVALID_HANDLE, err);
1005}
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define err(...)

Referenced by START_TEST().

◆ test_GetDiskInfoA()

static void test_GetDiskInfoA ( void  )
static

Definition at line 1007 of file urlcache.c.

1008{
1009 BOOL ret;
1012 char path[MAX_PATH], *p;
1013
1015 if ((p = strchr(path, '\\'))) *++p = 0;
1016
1018 ok(ret, "GetDiskInfoA failed %lu\n", GetLastError());
1019
1021 ok(ret, "GetDiskInfoA failed %lu\n", GetLastError());
1022
1024 ok(ret, "GetDiskInfoA failed %lu\n", GetLastError());
1025
1027 ok(ret, "GetDiskInfoA failed %lu\n", GetLastError());
1028
1029 SetLastError(0xdeadbeef);
1030 strcpy(p, "\\non\\existing\\path");
1032 error = GetLastError();
1033 ok(!ret ||
1034 broken(old_ie && ret), /* < IE7 */
1035 "GetDiskInfoA succeeded\n");
1037 broken(old_ie && error == 0xdeadbeef), /* < IE7 */
1038 "got %lu expected ERROR_PATH_NOT_FOUND\n", error);
1039
1040 SetLastError(0xdeadbeef);
1042 error = GetLastError();
1043 ok(!ret, "GetDiskInfoA succeeded\n");
1044 ok(error == ERROR_INVALID_PARAMETER, "got %lu expected ERROR_INVALID_PARAMETER\n", error);
1045}
#define broken(x)
Definition: atltest.h:178
#define free
Definition: debug_ros.c:5
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define MAX_PATH
Definition: compat.h:34
UINT WINAPI GetSystemDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
Definition: path.c:2301
_ACRTIMP char *__cdecl strchr(const char *, int)
Definition: string.c:3291
BOOL WINAPI GetDiskInfoA(PCSTR path, PDWORD cluster_size, PDWORDLONG free, PDWORDLONG total)
Definition: urlcache.c:4056
size_t total
GLfloat GLfloat p
Definition: glext.h:8902
unsigned long long DWORDLONG
Definition: intsafe.h:93
__u8 cluster_size
Definition: mkdosfs.c:4
#define error(str)
Definition: mkdosfs.c:1605
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:228

Referenced by START_TEST().

◆ test_GetUrlCacheConfigInfo()

static void test_GetUrlCacheConfigInfo ( void  )
static

Definition at line 1128 of file urlcache.c.

1129{
1131 struct
1132 {
1134 DWORD dwStructSize;
1135 DWORD flags;
1136 BOOL ret;
1137 DWORD error;
1138 } td[] =
1139 {
1140#if 0 /* crashes under Vista */
1142#endif
1143 { &info, 0, 0, TRUE },
1144 { &info, sizeof(info) - 1, 0, TRUE },
1145 { &info, sizeof(info) + 1, 0, TRUE },
1152 };
1153 int i;
1154 BOOL ret;
1155
1156 for (i = 0; i < ARRAY_SIZE(td); i++)
1157 {
1158 if (td[i].info)
1159 {
1160 memset(&info, 0, sizeof(*td[i].info));
1161 info.dwStructSize = td[i].dwStructSize;
1162 }
1163
1164 SetLastError(0xdeadbeef);
1166 ok(ret == td[i].ret, "%d: expected %d, got %d\n", i, td[i].ret, ret);
1167 if (!ret)
1168 ok(GetLastError() == td[i].error, "%d: expected %lu, got %lu\n", i, td[i].error, GetLastError());
1169 else
1170 {
1171 char path[MAX_PATH], path_win8[MAX_PATH];
1172
1173 get_cache_path(td[i].flags, path, path_win8);
1174
1175 ok(info.dwStructSize == td[i].dwStructSize, "got %lu\n", info.dwStructSize);
1176 ok(!lstrcmpA(info.CachePath, path) || !lstrcmpA(info.CachePath, path_win8),
1177 "%d: expected %s or %s, got %s\n", i, path, path_win8, info.CachePath);
1178 }
1179 }
1180}
#define ARRAY_SIZE(A)
Definition: main.h:20
int WINAPI lstrcmpA(LPCSTR str1, LPCSTR str2)
Definition: locale.c:4104
BOOL WINAPI GetUrlCacheConfigInfoA(LPINTERNET_CACHE_CONFIG_INFOA info, LPDWORD size, DWORD flags)
Definition: urlcache.c:3851
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static void get_cache_path(DWORD flags, char path[MAX_PATH], char path_win8[MAX_PATH])
Definition: urlcache.c:1086
#define memset(x, y, z)
Definition: compat.h:39
SYMCRYPT_MAGIC_FIELD union @5445 td

Referenced by START_TEST().

◆ test_GetUrlCacheEntryInfoExA()

static void test_GetUrlCacheEntryInfoExA ( void  )
static

Definition at line 106 of file urlcache.c.

107{
108 BOOL ret;
109 DWORD cbCacheEntryInfo, cbRedirectUrl;
110 INTERNET_CACHE_ENTRY_INFOA *lpCacheEntryInfo;
111
112 SetLastError(0xdeadbeef);
114 ok(!ret, "GetUrlCacheEntryInfoEx with NULL URL and NULL args should have failed\n");
116 "GetUrlCacheEntryInfoEx with NULL URL and NULL args should have set last error to ERROR_INVALID_PARAMETER instead of %ld\n", GetLastError());
117
118 cbCacheEntryInfo = sizeof(INTERNET_CACHE_ENTRY_INFOA);
119 SetLastError(0xdeadbeef);
120 ret = GetUrlCacheEntryInfoExA("", NULL, &cbCacheEntryInfo, NULL, NULL, NULL, 0);
121 ok(!ret, "GetUrlCacheEntryInfoEx with zero-length buffer should fail\n");
123 "GetUrlCacheEntryInfoEx should have set last error to ERROR_FILE_NOT_FOUND instead of %ld\n", GetLastError());
124
126 ok(ret, "GetUrlCacheEntryInfoEx with NULL args failed with error %ld\n", GetLastError());
127
128 cbCacheEntryInfo = 0;
129 SetLastError(0xdeadbeef);
130 ret = GetUrlCacheEntryInfoExA(test_url, NULL, &cbCacheEntryInfo, NULL, NULL, NULL, 0);
131 ok(!ret, "GetUrlCacheEntryInfoEx with zero-length buffer should fail\n");
133 "GetUrlCacheEntryInfoEx should have set last error to ERROR_INSUFFICIENT_BUFFER instead of %ld\n", GetLastError());
134
135 lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo);
136
137 SetLastError(0xdeadbeef);
138 ret = GetUrlCacheEntryInfoExA(test_url, NULL, NULL, NULL, NULL, NULL, 0x200 /*GET_INSTALLED_ENTRY*/);
139 ok(ret == ie10_cache, "GetUrlCacheEntryInfoEx returned %x\n", ret);
141 "GetUrlCacheEntryInfoEx should have set last error to ERROR_FILE_NOT_FOUND instead of %ld\n", GetLastError());
142
143 /* Unicode version of function seems to ignore 0x200 flag */
144 ret = GetUrlCacheEntryInfoExW(test_urlW, NULL, NULL, NULL, NULL, NULL, 0x200 /*GET_INSTALLED_ENTRY*/);
145 ok(ret || broken(old_ie && !ret), "GetUrlCacheEntryInfoExW failed with error %ld\n", GetLastError());
146
147 ret = GetUrlCacheEntryInfoExA(test_url, lpCacheEntryInfo, &cbCacheEntryInfo, NULL, NULL, NULL, 0);
148 ok(ret, "GetUrlCacheEntryInfoEx failed with error %ld\n", GetLastError());
149
150 if (ret) check_cache_entry_infoA("GetUrlCacheEntryInfoEx", lpCacheEntryInfo);
151
152 lpCacheEntryInfo->CacheEntryType |= 0x10000000; /* INSTALLED_CACHE_ENTRY */
154 ok(ret, "SetUrlCacheEntryInfoA failed with error %ld\n", GetLastError());
155
156 SetLastError(0xdeadbeef);
157 ret = GetUrlCacheEntryInfoExA(test_url, NULL, NULL, NULL, NULL, NULL, 0x200 /*GET_INSTALLED_ENTRY*/);
158 ok(ret, "GetUrlCacheEntryInfoEx failed with error %ld\n", GetLastError());
159
160 cbCacheEntryInfo = 100000;
161 SetLastError(0xdeadbeef);
162 ret = GetUrlCacheEntryInfoExA(test_url, NULL, &cbCacheEntryInfo, NULL, NULL, NULL, 0);
163 ok(!ret, "GetUrlCacheEntryInfoEx with zero-length buffer should fail\n");
164 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetUrlCacheEntryInfoEx should have set last error to ERROR_INSUFFICIENT_BUFFER instead of %ld\n", GetLastError());
165
166 HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo);
167
168 /* Querying the redirect URL fails with ERROR_INVALID_PARAMETER */
169 SetLastError(0xdeadbeef);
170 ret = GetUrlCacheEntryInfoExA(test_url, NULL, NULL, NULL, &cbRedirectUrl, NULL, 0);
171 ok(!ret, "GetUrlCacheEntryInfoEx should have failed\n");
173 "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
174 SetLastError(0xdeadbeef);
175 ret = GetUrlCacheEntryInfoExA(test_url, NULL, &cbCacheEntryInfo, NULL, &cbRedirectUrl, NULL, 0);
176 ok(!ret, "GetUrlCacheEntryInfoEx should have failed\n");
178 "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
179}
BOOL WINAPI GetUrlCacheEntryInfoExA(LPCSTR lpszUrl, LPINTERNET_CACHE_ENTRY_INFOA lpCacheEntryInfo, LPDWORD lpdwCacheEntryInfoBufSize, LPSTR lpszReserved, LPDWORD lpdwReserved, LPVOID lpReserved, DWORD dwFlags)
Definition: urlcache.c:1862
BOOL WINAPI GetUrlCacheEntryInfoExW(LPCWSTR lpszUrl, LPINTERNET_CACHE_ENTRY_INFOW lpCacheEntryInfo, LPDWORD lpdwCacheEntryInfoBufSize, LPWSTR lpszReserved, LPDWORD lpdwReserved, LPVOID lpReserved, DWORD dwFlags)
Definition: urlcache.c:1975
BOOL WINAPI SetUrlCacheEntryInfoA(LPCSTR lpszUrlName, LPINTERNET_CACHE_ENTRY_INFOA lpCacheEntryInfo, DWORD dwFieldControl)
Definition: urlcache.c:2016
static void check_cache_entry_infoA(const char *returnedfrom, INTERNET_CACHE_ENTRY_INFOA *lpCacheEntryInfo)
Definition: urlcache.c:49
static const WCHAR test_urlW[]
Definition: urlcache.c:35
DWORD CacheEntryType
Definition: wininet.h:2108
struct _INTERNET_CACHE_ENTRY_INFOA INTERNET_CACHE_ENTRY_INFOA
#define CACHE_ENTRY_ATTRIBUTE_FC
Definition: wininet.h:2293

Referenced by test_urlcacheA().

◆ test_IsUrlCacheEntryExpiredA()

static void test_IsUrlCacheEntryExpiredA ( void  )
static

Definition at line 208 of file urlcache.c.

209{
210 static const char uncached_url[] =
211 "What's the airspeed velocity of an unladen swallow?";
212 BOOL ret;
213 FILETIME ft;
214 DWORD size;
216 ULARGE_INTEGER exp_time;
217
218 /* The function returns TRUE when the output time is NULL or the tested URL
219 * is NULL.
220 */
222 ok(ret != ie10_cache, "IsUrlCacheEntryExpiredA returned %x\n", ret);
223 ft.dwLowDateTime = 0xdeadbeef;
224 ft.dwHighDateTime = 0xbaadf00d;
226 ok(ret != ie10_cache, "IsUrlCacheEntryExpiredA returned %x\n", ret);
227 ok(ft.dwLowDateTime == 0xdeadbeef && ft.dwHighDateTime == 0xbaadf00d,
228 "expected time to be unchanged, got (%lu,%lu)\n",
231 ok(ret != ie10_cache, "IsUrlCacheEntryExpiredA returned %x\n", ret);
232
233 /* The return value should indicate whether the URL is expired,
234 * and the filetime indicates the last modified time, but a cache entry
235 * with a zero expire time is "not expired".
236 */
237 ft.dwLowDateTime = 0xdeadbeef;
238 ft.dwHighDateTime = 0xbaadf00d;
240 ok(!ret, "expected FALSE\n");
242 "expected time (0,0), got (%lu,%lu)\n",
244
245 /* Same behavior with bogus flags. */
246 ft.dwLowDateTime = 0xdeadbeef;
247 ft.dwHighDateTime = 0xbaadf00d;
248 ret = IsUrlCacheEntryExpiredA(test_url, 0xffffffff, &ft);
249 ok(!ret, "expected FALSE\n");
251 "expected time (0,0), got (%lu,%lu)\n",
253
254 /* Set the expire time to a point in the past.. */
256 ok(!ret, "GetUrlCacheEntryInfo should have failed\n");
258 "expected ERROR_INSUFFICIENT_BUFFER, got %ld\n", GetLastError());
261 ok(ret, "GetUrlCacheEntryInfo failed: %ld\n", GetLastError());
262 GetSystemTimeAsFileTime(&info->ExpireTime);
263 exp_time.u.LowPart = info->ExpireTime.dwLowDateTime;
264 exp_time.u.HighPart = info->ExpireTime.dwHighDateTime;
265 exp_time.QuadPart -= 10 * 60 * (ULONGLONG)10000000;
266 info->ExpireTime.dwLowDateTime = exp_time.u.LowPart;
267 info->ExpireTime.dwHighDateTime = exp_time.u.HighPart;
269 ok(ret, "SetUrlCacheEntryInfo failed: %ld\n", GetLastError());
270 ft.dwLowDateTime = 0xdeadbeef;
271 ft.dwHighDateTime = 0xbaadf00d;
272 /* and the entry should be expired. */
274 ok(ret, "expected TRUE\n");
275 /* The modified time returned is 0. */
277 "expected time (0,0), got (%lu,%lu)\n",
279 /* Set the expire time to a point in the future.. */
280 exp_time.QuadPart += 20 * 60 * (ULONGLONG)10000000;
281 info->ExpireTime.dwLowDateTime = exp_time.u.LowPart;
282 info->ExpireTime.dwHighDateTime = exp_time.u.HighPart;
284 ok(ret, "SetUrlCacheEntryInfo failed: %ld\n", GetLastError());
285 ft.dwLowDateTime = 0xdeadbeef;
286 ft.dwHighDateTime = 0xbaadf00d;
287 /* and the entry should no longer be expired. */
289 ok(!ret, "expected FALSE\n");
290 /* The modified time returned is still 0. */
292 "expected time (0,0), got (%lu,%lu)\n",
294 /* Set the modified time... */
295 GetSystemTimeAsFileTime(&info->LastModifiedTime);
297 ok(ret, "SetUrlCacheEntryInfo failed: %ld\n", GetLastError());
298 /* and the entry should still be unexpired.. */
300 ok(!ret, "expected FALSE\n");
301 /* but the modified time returned is the last modified time just set. */
302 ok(ft.dwLowDateTime == info->LastModifiedTime.dwLowDateTime &&
303 ft.dwHighDateTime == info->LastModifiedTime.dwHighDateTime,
304 "expected time (%lu,%lu), got (%lu,%lu)\n",
305 info->LastModifiedTime.dwLowDateTime,
306 info->LastModifiedTime.dwHighDateTime,
309
310 /* An uncached URL is implicitly expired, but with unknown time. */
311 ft.dwLowDateTime = 0xdeadbeef;
312 ft.dwHighDateTime = 0xbaadf00d;
313 ret = IsUrlCacheEntryExpiredA(uncached_url, 0, &ft);
314 ok(ret != ie10_cache, "IsUrlCacheEntryExpiredA returned %x\n", ret);
316 "expected time (0,0), got (%lu,%lu)\n",
318}
VOID WINAPI GetSystemTimeAsFileTime(OUT PFILETIME lpFileTime)
Definition: time.c:128
BOOL WINAPI IsUrlCacheEntryExpiredA(LPCSTR url, DWORD dwFlags, FILETIME *pftLastModified)
Definition: urlcache.c:3972
DWORD dwHighDateTime
Definition: mapidefs.h:66
DWORD dwLowDateTime
Definition: mapidefs.h:65
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
struct _ULARGE_INTEGER::@5292 u
uint64_t ULONGLONG
Definition: typedefs.h:67
#define CACHE_ENTRY_EXPTIME_FC
Definition: wininet.h:2296
#define CACHE_ENTRY_MODTIME_FC
Definition: wininet.h:2295

Referenced by test_urlcacheA().

◆ test_RetrieveUrlCacheEntryA()

static void test_RetrieveUrlCacheEntryA ( void  )
static

Definition at line 181 of file urlcache.c.

182{
183 BOOL ret;
184 DWORD cbCacheEntryInfo;
185
186 cbCacheEntryInfo = 0;
187 SetLastError(0xdeadbeef);
188 ret = RetrieveUrlCacheEntryFileA(NULL, NULL, &cbCacheEntryInfo, 0);
189 ok(!ret, "RetrieveUrlCacheEntryFile should have failed\n");
190 ok(GetLastError() == ERROR_INVALID_PARAMETER, "RetrieveUrlCacheEntryFile should have set last error to ERROR_INVALID_PARAMETER instead of %ld\n", GetLastError());
191
192 if (0)
193 {
194 /* Crashes on Win9x, NT4 and W2K */
195 SetLastError(0xdeadbeef);
197 ok(!ret, "RetrieveUrlCacheEntryFile should have failed\n");
198 ok(GetLastError() == ERROR_INVALID_PARAMETER, "RetrieveUrlCacheEntryFile should have set last error to ERROR_INVALID_PARAMETER instead of %ld\n", GetLastError());
199 }
200
201 SetLastError(0xdeadbeef);
202 cbCacheEntryInfo = 100000;
203 ret = RetrieveUrlCacheEntryFileA(NULL, NULL, &cbCacheEntryInfo, 0);
204 ok(!ret, "RetrieveUrlCacheEntryFile should have failed\n");
205 ok(GetLastError() == ERROR_INVALID_PARAMETER, "RetrieveUrlCacheEntryFile should have set last error to ERROR_INVALID_PARAMETER instead of %ld\n", GetLastError());
206}
BOOL WINAPI RetrieveUrlCacheEntryFileA(LPCSTR lpszUrlName, LPINTERNET_CACHE_ENTRY_INFOA lpCacheEntryInfo, LPDWORD lpdwCacheEntryInfoBufferSize, DWORD dwReserved)
Definition: urlcache.c:2166

Referenced by test_urlcacheA().

◆ test_trailing_slash()

static void test_trailing_slash ( void  )
static

Definition at line 1059 of file urlcache.c.

1060{
1061 char filename[MAX_PATH];
1062 BYTE zero_byte = 0;
1063 BOOL ret;
1064
1065 static const FILETIME filetime_zero;
1066 static char url_with_slash[] = "http://testing.cache.com/";
1067
1068
1069 ret = CreateUrlCacheEntryA(url_with_slash, 0, "html", filename, 0);
1070 ok(ret, "CreateUrlCacheEntry failed with error %ld\n", GetLastError());
1071
1073
1074 ret = CommitUrlCacheEntryA("Visited: http://testing.cache.com/", NULL, filetime_zero, filetime_zero,
1075 NORMAL_CACHE_ENTRY, NULL, 0, "html", NULL);
1076 ok(ret, "CommitUrlCacheEntry failed with error %ld\n", GetLastError());
1077
1078 ok(cache_entry_exists("Visited: http://testing.cache.com/"), "cache entry does not exist\n");
1079 ok(!cache_entry_exists("Visited: http://testing.cache.com"), "cache entry exists\n");
1080
1081 ret = DeleteUrlCacheEntryA("Visited: http://testing.cache.com/");
1082 ok(ret, "DeleteCacheEntryA failed\n");
1084}
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
BOOL WINAPI DeleteUrlCacheEntryA(LPCSTR lpszUrlName)
Definition: urlcache.c:3291
BOOL WINAPI CreateUrlCacheEntryA(LPCSTR lpszUrlName, DWORD dwExpectedFileSize, LPCSTR lpszFileExtension, LPSTR lpszFileName, DWORD dwReserved)
Definition: urlcache.c:2789
BOOL WINAPI CommitUrlCacheEntryA(LPCSTR lpszUrlName, LPCSTR lpszLocalFileName, FILETIME ExpireTime, FILETIME LastModifiedTime, DWORD CacheEntryType, LPBYTE lpHeaderInfo, DWORD dwHeaderSize, LPCSTR lpszFileExtension, LPCSTR lpszOriginalUrl)
Definition: urlcache.c:3056
static int zero_byte(mpg123_handle *fr)
Definition: libmpg123.c:763
static BOOL cache_entry_exists(const char *url)
Definition: urlcache.c:1047
static void create_and_write_file(LPCSTR filename, void *data, DWORD len)
Definition: urlcache.c:348
#define NORMAL_CACHE_ENTRY
Definition: wininet.h:2087
unsigned char BYTE
Definition: xxhash.c:193

Referenced by START_TEST().

◆ test_urlcacheA()

static void test_urlcacheA ( void  )
static

Definition at line 365 of file urlcache.c.

366{
367 static char long_url[300] = "http://www.winehq.org/";
368 static char ok_header[] = "HTTP/1.0 200 OK\r\n\r\n";
369 BOOL ret;
371 BYTE zero_byte = 0;
372 INTERNET_CACHE_ENTRY_INFOA *lpCacheEntryInfo;
373 INTERNET_CACHE_ENTRY_INFOA *lpCacheEntryInfo2;
374 DWORD cbCacheEntryInfo;
375 static const FILETIME filetime_zero;
377 int len;
378
379 ret = CreateUrlCacheEntryA(test_url, 0, "html", filenameA, 0);
380 ok(ret, "CreateUrlCacheEntry failed with error %ld\n", GetLastError());
381
383 ok(ret, "CreateUrlCacheEntry failed with error %ld\n", GetLastError());
386
387 ok(lstrcmpiA(filenameA, filenameA1), "expected a different file name\n");
388
390
391 ret = CommitUrlCacheEntryA(test_url1, NULL, filetime_zero, filetime_zero, NORMAL_CACHE_ENTRY, NULL, 0, "html", NULL);
392 ok(ret, "CommitUrlCacheEntry failed with error %ld\n", GetLastError());
393 cbCacheEntryInfo = 0;
394 ret = GetUrlCacheEntryInfoA(test_url1, NULL, &cbCacheEntryInfo);
395 ok(!ret, "GetUrlCacheEntryInfo should have failed\n");
397 "GetUrlCacheEntryInfo should have set last error to ERROR_INSUFFICIENT_BUFFER instead of %ld\n", GetLastError());
398 lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo);
399 ret = GetUrlCacheEntryInfoA(test_url1, lpCacheEntryInfo, &cbCacheEntryInfo);
400 ok(ret, "GetUrlCacheEntryInfo failed with error %ld\n", GetLastError());
401 ok(!memcmp(&lpCacheEntryInfo->ExpireTime, &filetime_zero, sizeof(FILETIME)),
402 "expected zero ExpireTime\n");
403 ok(!memcmp(&lpCacheEntryInfo->LastModifiedTime, &filetime_zero, sizeof(FILETIME)),
404 "expected zero LastModifiedTime\n");
406 broken(lpCacheEntryInfo->CacheEntryType == NORMAL_CACHE_ENTRY /* NT4/W2k */),
407 "expected type NORMAL_CACHE_ENTRY|URLHISTORY_CACHE_ENTRY, got %08lx\n",
408 lpCacheEntryInfo->CacheEntryType);
409 ok(!lpCacheEntryInfo->dwExemptDelta, "expected dwExemptDelta 0, got %ld\n",
410 lpCacheEntryInfo->dwExemptDelta);
411
412 /* Make sure there is a notable change in timestamps */
413 Sleep(1000);
414
415 /* A subsequent commit with a different time/type doesn't change most of the entry */
418 (LPBYTE)ok_header, strlen(ok_header), NULL, NULL);
419 ok(ret, "CommitUrlCacheEntry failed with error %ld\n", GetLastError());
420 cbCacheEntryInfo = 0;
421 ret = GetUrlCacheEntryInfoA(test_url1, NULL, &cbCacheEntryInfo);
422 ok(!ret, "GetUrlCacheEntryInfo should have failed\n");
424 "expected ERROR_INSUFFICIENT_BUFFER, got %ld\n", GetLastError());
425 lpCacheEntryInfo2 = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo);
426 ret = GetUrlCacheEntryInfoA(test_url1, lpCacheEntryInfo2, &cbCacheEntryInfo);
427 ok(ret, "GetUrlCacheEntryInfo failed with error %ld\n", GetLastError());
428 /* but it does change the time.. */
429 ok(memcmp(&lpCacheEntryInfo2->ExpireTime, &filetime_zero, sizeof(FILETIME)),
430 "expected positive ExpireTime\n");
431 ok(memcmp(&lpCacheEntryInfo2->LastModifiedTime, &filetime_zero, sizeof(FILETIME)),
432 "expected positive LastModifiedTime\n");
434 broken(lpCacheEntryInfo2->CacheEntryType == NORMAL_CACHE_ENTRY /* NT4/W2k */),
435 "expected type NORMAL_CACHE_ENTRY|URLHISTORY_CACHE_ENTRY, got %08lx\n",
436 lpCacheEntryInfo2->CacheEntryType);
437 /* and set the headers. */
438 ok(lpCacheEntryInfo2->dwHeaderInfoSize == 19,
439 "expected headers size 19, got %ld\n",
440 lpCacheEntryInfo2->dwHeaderInfoSize);
441 /* Hit rate gets incremented by 1 */
442 ok((lpCacheEntryInfo->dwHitRate + 1) == lpCacheEntryInfo2->dwHitRate,
443 "HitRate not incremented by one on commit\n");
444 /* Last access time should be updated */
445 ok(!(lpCacheEntryInfo->LastAccessTime.dwHighDateTime == lpCacheEntryInfo2->LastAccessTime.dwHighDateTime &&
446 lpCacheEntryInfo->LastAccessTime.dwLowDateTime == lpCacheEntryInfo2->LastAccessTime.dwLowDateTime),
447 "Last accessed time was not updated by commit\n");
448 /* File extension should be unset */
449 ok(lpCacheEntryInfo2->lpszFileExtension == NULL,
450 "Fileextension isn't unset: %s\n",
451 lpCacheEntryInfo2->lpszFileExtension);
452 HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo);
453 HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo2);
454
455 ret = CommitUrlCacheEntryA(test_url, filenameA, filetime_zero, filetime_zero, NORMAL_CACHE_ENTRY, NULL, 0, "html", NULL);
456 ok(ret, "CommitUrlCacheEntry failed with error %ld\n", GetLastError());
457
458 cbCacheEntryInfo = 0;
459 SetLastError(0xdeadbeef);
460 ret = RetrieveUrlCacheEntryFileA(test_url, NULL, &cbCacheEntryInfo, 0);
461 ok(!ret, "RetrieveUrlCacheEntryFile should have failed\n");
463 "RetrieveUrlCacheEntryFile should have set last error to ERROR_INSUFFICIENT_BUFFER instead of %ld\n", GetLastError());
464
465 lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo);
466 ret = RetrieveUrlCacheEntryFileA(test_url, lpCacheEntryInfo, &cbCacheEntryInfo, 0);
467 ok(ret, "RetrieveUrlCacheEntryFile failed with error %ld\n", GetLastError());
468
469 if (ret) check_cache_entry_infoA("RetrieveUrlCacheEntryFile", lpCacheEntryInfo);
470
471 HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo);
472
473 cbCacheEntryInfo = 0;
474 SetLastError(0xdeadbeef);
475 ret = RetrieveUrlCacheEntryFileA(test_url1, NULL, &cbCacheEntryInfo, 0);
476 ok(!ret, "RetrieveUrlCacheEntryFile should have failed\n");
478 "RetrieveUrlCacheEntryFile should have set last error to ERROR_INVALID_DATA instead of %ld\n", GetLastError());
479
480 if (pUnlockUrlCacheEntryFileA)
481 {
482 ret = pUnlockUrlCacheEntryFileA(test_url, 0);
483 ok(ret, "UnlockUrlCacheEntryFileA failed with error %ld\n", GetLastError());
484 }
485
486 /* test Find*UrlCacheEntry functions */
488
492
493 if (pDeleteUrlCacheEntryA)
494 {
495 ret = pDeleteUrlCacheEntryA(test_url);
496 ok(ret, "DeleteUrlCacheEntryA failed with error %ld\n", GetLastError());
497 ret = pDeleteUrlCacheEntryA(test_url1);
498 ok(ret, "DeleteUrlCacheEntryA failed with error %ld\n", GetLastError());
499 }
500
501 SetLastError(0xdeadbeef);
503 ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, "local file should no longer exist\n");
504
505 /* Creating two entries with the same URL */
506 ret = CreateUrlCacheEntryA(test_url, 0, "html", filenameA, 0);
507 ok(ret, "CreateUrlCacheEntry failed with error %ld\n", GetLastError());
508
510 ok(ret, "CreateUrlCacheEntry failed with error %ld\n", GetLastError());
511
512 ok(lstrcmpiA(filenameA, filenameA1), "expected a different file name\n");
513
518
519 ret = CommitUrlCacheEntryA(test_url, filenameA, filetime_zero,
520 filetime_zero, NORMAL_CACHE_ENTRY, (LPBYTE)ok_header,
521 strlen(ok_header), "html", NULL);
522 ok(ret, "CommitUrlCacheEntry failed with error %ld\n", GetLastError());
526 filetime_zero, COOKIE_CACHE_ENTRY, NULL, 0, "html", NULL);
527 ok(ret, "CommitUrlCacheEntry failed with error %ld\n", GetLastError());
528 /* By committing the same URL a second time, the prior entry is
529 * overwritten...
530 */
531 cbCacheEntryInfo = 0;
532 SetLastError(0xdeadbeef);
533 ret = GetUrlCacheEntryInfoA(test_url, NULL, &cbCacheEntryInfo);
534 ok(!ret, "GetUrlCacheEntryInfo should have failed\n");
536 "expected ERROR_INSUFFICIENT_BUFFER, got %ld\n", GetLastError());
537 lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo);
538 ret = GetUrlCacheEntryInfoA(test_url, lpCacheEntryInfo, &cbCacheEntryInfo);
539 ok(ret, "GetUrlCacheEntryInfo failed with error %ld\n", GetLastError());
540 /* with the previous entry type retained.. */
541 ok(lpCacheEntryInfo->CacheEntryType & NORMAL_CACHE_ENTRY,
542 "expected cache entry type NORMAL_CACHE_ENTRY, got %ld (0x%08lx)\n",
543 lpCacheEntryInfo->CacheEntryType, lpCacheEntryInfo->CacheEntryType);
544 /* and the headers overwritten.. */
545 ok(!lpCacheEntryInfo->dwHeaderInfoSize, "expected headers size 0, got %ld\n",
546 lpCacheEntryInfo->dwHeaderInfoSize);
547 HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo);
548 /* and the previous filename shouldn't exist. */
551
552 if (pDeleteUrlCacheEntryA)
553 {
554 ret = pDeleteUrlCacheEntryA(test_url);
555 ok(ret, "DeleteUrlCacheEntryA failed with error %ld\n", GetLastError());
558 /* Just in case, clean up files */
561 }
562
563 /* Check whether a retrieved cache entry can be deleted before it's
564 * unlocked:
565 */
566 ret = CreateUrlCacheEntryA(test_url, 0, "html", filenameA, 0);
567 ok(ret, "CreateUrlCacheEntry failed with error %ld\n", GetLastError());
568 ret = CommitUrlCacheEntryA(test_url, filenameA, filetime_zero, filetime_zero,
569 NORMAL_CACHE_ENTRY, NULL, 0, "html", NULL);
570 ok(ret, "CommitUrlCacheEntry failed with error %ld\n", GetLastError());
571
572 cbCacheEntryInfo = 0;
573 SetLastError(0xdeadbeef);
574 ret = RetrieveUrlCacheEntryFileA(test_url, NULL, &cbCacheEntryInfo, 0);
575 ok(!ret, "RetrieveUrlCacheEntryFile should have failed\n");
577 "expected ERROR_INSUFFICIENT_BUFFER, got %ld\n", GetLastError());
578
579 lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo);
580 ret = RetrieveUrlCacheEntryFileA(test_url, lpCacheEntryInfo,
581 &cbCacheEntryInfo, 0);
582 ok(ret, "RetrieveUrlCacheEntryFile failed with error %ld\n", GetLastError());
583
584 HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo);
585
586 if (pDeleteUrlCacheEntryA)
587 {
588 ret = pDeleteUrlCacheEntryA(test_url);
589 ok(!ret, "Expected failure\n");
591 "Expected ERROR_SHARING_VIOLATION, got %ld\n", GetLastError());
593 }
594
595 lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo);
596 memset(lpCacheEntryInfo, 0, cbCacheEntryInfo);
597 ret = GetUrlCacheEntryInfoA(test_url, lpCacheEntryInfo, &cbCacheEntryInfo);
598 ok(ret, "GetUrlCacheEntryInfo failed with error %ld\n", GetLastError());
599 ok(lpCacheEntryInfo->CacheEntryType & 0x400000,
600 "CacheEntryType hasn't PENDING_DELETE_CACHE_ENTRY set, (flags %08lx)\n",
601 lpCacheEntryInfo->CacheEntryType);
602 HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo);
603
604 if (pUnlockUrlCacheEntryFileA)
605 {
607 ret = pUnlockUrlCacheEntryFileA(test_url, 0);
608 ok(ret, "UnlockUrlCacheEntryFileA failed: %ld\n", GetLastError());
609 /* By unlocking the already-deleted cache entry, the file associated
610 * with it is deleted..
611 */
613 /* (just in case, delete file) */
615 }
616 if (pDeleteUrlCacheEntryA)
617 {
618 /* and a subsequent deletion should fail. */
619 ret = pDeleteUrlCacheEntryA(test_url);
620 ok(!ret, "Expected failure\n");
622 "expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError());
623 }
624
625 /* Test whether preventing a file from being deleted causes
626 * DeleteUrlCacheEntryA to fail.
627 */
628 ret = CreateUrlCacheEntryA(test_url, 0, "html", filenameA, 0);
629 ok(ret, "CreateUrlCacheEntry failed with error %ld\n", GetLastError());
630
633
634 ret = CommitUrlCacheEntryA(test_url, filenameA, filetime_zero,
635 filetime_zero, NORMAL_CACHE_ENTRY, (LPBYTE)ok_header,
636 strlen(ok_header), "html", NULL);
637 ok(ret, "CommitUrlCacheEntry failed with error %ld\n", GetLastError());
641 ok(hFile != INVALID_HANDLE_VALUE, "CreateFileA failed: %ld\n",
642 GetLastError());
643 if (pDeleteUrlCacheEntryA)
644 {
645 /* DeleteUrlCacheEntryA should succeed.. */
646 ret = pDeleteUrlCacheEntryA(test_url);
647 ok(ret, "DeleteUrlCacheEntryA failed with error %ld\n", GetLastError());
648 }
650 if (pDeleteUrlCacheEntryA)
651 {
652 /* and a subsequent deletion should fail.. */
653 ret = pDeleteUrlCacheEntryA(test_url);
654 ok(!ret, "Expected failure\n");
656 "expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError());
657 }
658 /* and the file should be untouched. */
661
662 /* Try creating a sticky entry. Unlike non-sticky entries, the filename
663 * must have been set already.
664 */
665 SetLastError(0xdeadbeef);
666 ret = CommitUrlCacheEntryA(test_url, NULL, filetime_zero, filetime_zero,
667 STICKY_CACHE_ENTRY, (LPBYTE)ok_header, strlen(ok_header), "html",
668 NULL);
669 ok(ret == ie10_cache, "CommitUrlCacheEntryA returned %x\n", ret);
671 "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
672 SetLastError(0xdeadbeef);
673 ret = CommitUrlCacheEntryA(test_url, NULL, filetime_zero, filetime_zero,
675 (LPBYTE)ok_header, strlen(ok_header), "html", NULL);
676 ok(ret == ie10_cache, "CommitUrlCacheEntryA returned %x\n", ret);
678 "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
679
680 ret = CreateUrlCacheEntryA(test_url, 0, "html", filenameA, 0);
681 ok(ret, "CreateUrlCacheEntry failed with error %ld\n", GetLastError());
683 ret = CommitUrlCacheEntryA(test_url, filenameA, filetime_zero, filetime_zero,
685 (LPBYTE)ok_header, strlen(ok_header), "html", NULL);
686 ok(ret, "CommitUrlCacheEntry failed with error %ld\n", GetLastError());
687 cbCacheEntryInfo = 0;
688 SetLastError(0xdeadbeef);
689 ret = GetUrlCacheEntryInfoA(test_url, NULL, &cbCacheEntryInfo);
690 ok(!ret, "GetUrlCacheEntryInfo should have failed\n");
692 "expected ERROR_INSUFFICIENT_BUFFER, got %ld\n", GetLastError());
693 lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo);
694 ret = GetUrlCacheEntryInfoA(test_url, lpCacheEntryInfo, &cbCacheEntryInfo);
695 ok(ret, "GetUrlCacheEntryInfo failed with error %ld\n", GetLastError());
697 "expected cache entry type NORMAL_CACHE_ENTRY | STICKY_CACHE_ENTRY, got %ld (0x%08lx)\n",
698 lpCacheEntryInfo->CacheEntryType, lpCacheEntryInfo->CacheEntryType);
699 ok(lpCacheEntryInfo->dwExemptDelta == 86400,
700 "expected dwExemptDelta 86400, got %ld\n",
701 lpCacheEntryInfo->dwExemptDelta);
702 HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo);
703 if (pDeleteUrlCacheEntryA)
704 {
705 ret = pDeleteUrlCacheEntryA(test_url);
706 ok(ret, "DeleteUrlCacheEntryA failed with error %ld\n", GetLastError());
707 /* When explicitly deleting the cache entry, the file is also deleted */
709 }
710 /* Test once again, setting the exempt delta via SetUrlCacheEntryInfo */
711 ret = CreateUrlCacheEntryA(test_url, 0, "html", filenameA, 0);
712 ok(ret, "CreateUrlCacheEntry failed with error %ld\n", GetLastError());
714 ret = CommitUrlCacheEntryA(test_url, filenameA, filetime_zero, filetime_zero,
716 (LPBYTE)ok_header, strlen(ok_header), "html", NULL);
717 ok(ret, "CommitUrlCacheEntry failed with error %ld\n", GetLastError());
718 cbCacheEntryInfo = 0;
719 SetLastError(0xdeadbeef);
720 ret = GetUrlCacheEntryInfoA(test_url, NULL, &cbCacheEntryInfo);
721 ok(!ret, "GetUrlCacheEntryInfo should have failed\n");
723 "expected ERROR_INSUFFICIENT_BUFFER, got %ld\n", GetLastError());
724 lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo);
725 ret = GetUrlCacheEntryInfoA(test_url, lpCacheEntryInfo, &cbCacheEntryInfo);
726 ok(ret, "GetUrlCacheEntryInfo failed with error %ld\n", GetLastError());
728 "expected cache entry type NORMAL_CACHE_ENTRY | STICKY_CACHE_ENTRY, got %ld (0x%08lx)\n",
729 lpCacheEntryInfo->CacheEntryType, lpCacheEntryInfo->CacheEntryType);
730 ok(lpCacheEntryInfo->dwExemptDelta == 86400,
731 "expected dwExemptDelta 86400, got %ld\n",
732 lpCacheEntryInfo->dwExemptDelta);
733 lpCacheEntryInfo->dwExemptDelta = 0;
734 ret = SetUrlCacheEntryInfoA(test_url, lpCacheEntryInfo,
736 ok(ret, "SetUrlCacheEntryInfo failed: %ld\n", GetLastError());
737 ret = GetUrlCacheEntryInfoA(test_url, lpCacheEntryInfo, &cbCacheEntryInfo);
738 ok(ret, "GetUrlCacheEntryInfo failed with error %ld\n", GetLastError());
739 ok(!lpCacheEntryInfo->dwExemptDelta, "expected dwExemptDelta 0, got %ld\n",
740 lpCacheEntryInfo->dwExemptDelta);
741 /* See whether a sticky cache entry has the flag cleared once the exempt
742 * delta is meaningless.
743 */
745 "expected cache entry type NORMAL_CACHE_ENTRY | STICKY_CACHE_ENTRY, got %ld (0x%08lx)\n",
746 lpCacheEntryInfo->CacheEntryType, lpCacheEntryInfo->CacheEntryType);
747
748 /* Recommit of Url entry keeps dwExemptDelta */
749 lpCacheEntryInfo->dwExemptDelta = 8600;
750 ret = SetUrlCacheEntryInfoA(test_url, lpCacheEntryInfo,
752 ok(ret, "SetUrlCacheEntryInfo failed: %ld\n", GetLastError());
753
755 ok(ret, "CreateUrlCacheEntry failed with error %ld\n", GetLastError());
757
758 ret = CommitUrlCacheEntryA(test_url, filenameA1, filetime_zero, filetime_zero,
760 (LPBYTE)ok_header, strlen(ok_header), "html", NULL);
761 ok(ret, "CommitUrlCacheEntry failed with error %ld\n", GetLastError());
762
763 ret = GetUrlCacheEntryInfoA(test_url, lpCacheEntryInfo, &cbCacheEntryInfo);
764 ok(ret, "GetUrlCacheEntryInfo failed with error %ld\n", GetLastError());
765 ok(lpCacheEntryInfo->dwExemptDelta == 8600 || (ie10_cache && lpCacheEntryInfo->dwExemptDelta == 86400),
766 "expected dwExemptDelta 8600, got %ld\n", lpCacheEntryInfo->dwExemptDelta);
767
768 HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo);
769
770 if (pDeleteUrlCacheEntryA)
771 {
772 ret = pDeleteUrlCacheEntryA(test_url);
773 ok(ret, "DeleteUrlCacheEntryA failed with error %ld\n", GetLastError());
775 }
776
777 /* Test if files with identical hash keys are handled correctly */
778 ret = CommitUrlCacheEntryA(test_hash_collisions1, NULL, filetime_zero, filetime_zero, NORMAL_CACHE_ENTRY, NULL, 0, "html", NULL);
779 ok(ret, "CommitUrlCacheEntry failed with error %ld\n", GetLastError());
780 ret = CommitUrlCacheEntryA(test_hash_collisions2, NULL, filetime_zero, filetime_zero, NORMAL_CACHE_ENTRY, NULL, 0, "html", NULL);
781 ok(ret, "CommitUrlCacheEntry failed with error %ld\n", GetLastError());
782
783 cbCacheEntryInfo = 0;
785 ok(!ret, "GetUrlCacheEntryInfo should have failed\n");
787 "expected ERROR_INSUFFICIENT_BUFFER, got %ld\n", GetLastError());
788 lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo);
789 ret = GetUrlCacheEntryInfoA(test_hash_collisions1, lpCacheEntryInfo, &cbCacheEntryInfo);
790 ok(ret, "GetUrlCacheEntryInfo failed with error %ld\n", GetLastError());
792 "got incorrect entry: %s\n", lpCacheEntryInfo->lpszSourceUrlName);
793 HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo);
794
795 cbCacheEntryInfo = 0;
797 ok(!ret, "GetUrlCacheEntryInfo should have failed\n");
799 "expected ERROR_INSUFFICIENT_BUFFER, got %ld\n", GetLastError());
800 lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo);
801 ret = GetUrlCacheEntryInfoA(test_hash_collisions2, lpCacheEntryInfo, &cbCacheEntryInfo);
802 ok(ret, "GetUrlCacheEntryInfo failed with error %ld\n", GetLastError());
804 "got incorrect entry: %s\n", lpCacheEntryInfo->lpszSourceUrlName);
805 HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo);
806
807 if (pDeleteUrlCacheEntryA) {
808 ret = pDeleteUrlCacheEntryA(test_hash_collisions1);
809 ok(ret, "DeleteUrlCacheEntry failed: %ld\n", GetLastError());
810 ret = pDeleteUrlCacheEntryA(test_hash_collisions2);
811 ok(ret, "DeleteUrlCacheEntry failed: %ld\n", GetLastError());
812 }
813
814 len = strlen(long_url);
815 memset(long_url+len, 'a', sizeof(long_url)-len);
816 long_url[sizeof(long_url)-1] = 0;
817 ret = CreateUrlCacheEntryA(long_url, 0, NULL, filenameA, 0);
818 ok(ret, "CreateUrlCacheEntry failed with error %ld\n", GetLastError());
821
822 ret = CreateUrlCacheEntryA(long_url, 0, "extension", filenameA, 0);
823 ok(ret, "CreateUrlCacheEntry failed with error %ld\n", GetLastError());
826
827 long_url[250] = 0;
828 ret = CreateUrlCacheEntryA(long_url, 0, NULL, filenameA, 0);
829 ok(ret, "CreateUrlCacheEntry failed with error %ld\n", GetLastError());
832
833 ret = CreateUrlCacheEntryA(long_url, 0, "extension", filenameA, 0);
834 ok(ret, "CreateUrlCacheEntry failed with error %ld\n", GetLastError());
837}
int WINAPI lstrcmpiA(LPCSTR str1, LPCSTR str2)
Definition: locale.c:4133
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2807
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1597
time_t now
Definition: finger.c:65
#define check_file_not_exists(f)
Definition: urlcache.c:346
static void test_GetUrlCacheEntryInfoExA(void)
Definition: urlcache.c:106
static const char test_hash_collisions2[]
Definition: urlcache.c:39
static void test_IsUrlCacheEntryExpiredA(void)
Definition: urlcache.c:208
static const char test_url1[]
Definition: urlcache.c:37
static char filenameA1[MAX_PATH+1]
Definition: urlcache.c:45
static void test_RetrieveUrlCacheEntryA(void)
Definition: urlcache.c:181
static void test_find_url_cache_entriesA(void)
Definition: urlcache.c:57
#define check_file_exists(f)
Definition: urlcache.c:332
static const char test_hash_collisions1[]
Definition: urlcache.c:38
_In_ HANDLE hFile
Definition: mswsock.h:90
FILETIME LastAccessTime
Definition: wininet.h:2115
DWORD dwHitRate
Definition: wininet.h:2110
DWORD dwExemptDelta
Definition: wininet.h:2123
DWORD dwHeaderInfoSize
Definition: wininet.h:2119
FILETIME LastModifiedTime
Definition: wininet.h:2113
FILETIME ExpireTime
Definition: wininet.h:2114
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:726
unsigned char * LPBYTE
Definition: typedefs.h:53
#define ERROR_SHARING_VIOLATION
Definition: winerror.h:257
#define ERROR_INVALID_DATA
Definition: winerror.h:238
#define COOKIE_CACHE_ENTRY
Definition: wininet.h:2090
#define URLHISTORY_CACHE_ENTRY
Definition: wininet.h:2091
#define CACHE_ENTRY_EXEMPT_DELTA_FC
Definition: wininet.h:2300
#define STICKY_CACHE_ENTRY
Definition: wininet.h:2088

Referenced by START_TEST().

◆ test_urlcacheW()

static void test_urlcacheW ( void  )
static

Definition at line 839 of file urlcache.c.

840{
841 static struct test_data
842 {
843 DWORD err;
844 WCHAR url[128];
845 char encoded_url[128];
846 WCHAR extension[32];
847 WCHAR header_info[128];
848 }urls[] = {
849 {
850 0, {'h','t','t','p',':','/','/','T','.','p','l','/','t',0},
851 "http://T.pl/t", {0}, {0}
852 },
853 {
854 0, {'w','w','w','.','T','.','p','l','/','t',0},
855 "www.T.pl/t", {0}, {0}
856 },
857 {
858 0, {'h','t','t','p',':','/','/','w','w','w','.','t','e','s','t',0x15b,0x107,
859 '.','o','r','g','/','t','e','s','t','.','h','t','m','l',0},
860 "http://www.xn--test-ota71c.org/test.html", {'t','x','t',0}, {0}
861 },
862 {
863 0, {'w','w','w','.','T','e','s','t',0x15b,0x107,'.','o','r','g',
864 '/','t','e','s','t','.','h','t','m','l',0},
865 "www.Test\xc5\x9b\xc4\x87.org/test.html", {'a',0x106,'a',0}, {'b',0x106,'b',0}
866 },
867 {
868 0, {'H','t','t','p','s',':','/','/',0x15b,0x15b,0x107,'/','t',0x107,'/',
869 't','e','s','t','?','a','=','%','2','0',0x106,0},
870 "Https://xn--4da1oa/t\xc4\x87/test?a=%20\xc4\x86", {'a',0x15b,'a',0}, {'b',0x15b,'b',0}
871 },
872 {
873 12005, {'h','t','t','p','s',':','/','/','/','/',0x107,'.','o','r','g','/','t','e','s','t',0},
874 "", {0}, {0}
875 },
876 {
877 0, {'C','o','o','k','i','e',':',' ','u','s','e','r','@','t','e','s','t','.','o','r','g','/',0},
878 "Cookie: user@test.org/", {0}, {0}
879 }
880 };
881 static const FILETIME filetime_zero;
882
883 WCHAR bufW[MAX_PATH];
884 DWORD i;
885 BOOL ret;
886
887 if(old_ie) {
888 win_skip("urlcache unicode functions\n");
889 return;
890 }
891
892 for(i=0; i<ARRAY_SIZE(urls); i++) {
893 INTERNET_CACHE_ENTRY_INFOA *entry_infoA;
894 INTERNET_CACHE_ENTRY_INFOW *entry_infoW;
895 DWORD size;
896
897 SetLastError(0xdeadbeef);
898 ret = CreateUrlCacheEntryW(urls[i].url, 0, NULL, bufW, 0);
899 if(urls[i].err != 0) {
900 ok(!ret, "%ld) CreateUrlCacheEntryW succeeded\n", i);
901 ok(urls[i].err == GetLastError(), "%ld) GetLastError() = %ld\n", i, GetLastError());
902 continue;
903 }
904 ok(ret, "%ld) CreateUrlCacheEntryW failed: %ld\n", i, GetLastError());
905
906 /* dwHeaderSize is ignored, pass 0 to prove it */
907 ret = CommitUrlCacheEntryW(urls[i].url, bufW, filetime_zero, filetime_zero,
908 NORMAL_CACHE_ENTRY, urls[i].header_info, 0, urls[i].extension, NULL);
909 ok(ret, "%ld) CommitUrlCacheEntryW failed: %ld\n", i, GetLastError());
910
911 SetLastError(0xdeadbeef);
912 size = 0;
915 "%ld) GetLastError() = %ld\n", i, GetLastError());
916 entry_infoW = HeapAlloc(GetProcessHeap(), 0, size);
917 ret = GetUrlCacheEntryInfoW(urls[i].url, entry_infoW, &size);
918 ok(ret, "%ld) GetUrlCacheEntryInfoW failed: %ld\n", i, GetLastError());
919
920 ret = GetUrlCacheEntryInfoA(urls[i].encoded_url, NULL, &size);
922 "%ld) GetLastError() = %ld\n", i, GetLastError());
923 entry_infoA = HeapAlloc(GetProcessHeap(), 0, size);
924 ret = GetUrlCacheEntryInfoA(urls[i].encoded_url, entry_infoA, &size);
925 ok(ret, "%ld) GetUrlCacheEntryInfoA failed: %ld\n", i, GetLastError());
926
927 ok(entry_infoW->dwStructSize == entry_infoA->dwStructSize,
928 "%ld) entry_infoW->dwStructSize = %ld, expected %ld\n",
929 i, entry_infoW->dwStructSize, entry_infoA->dwStructSize);
930 ok(!lstrcmpW(urls[i].url, entry_infoW->lpszSourceUrlName),
931 "%ld) entry_infoW->lpszSourceUrlName = %s\n",
932 i, wine_dbgstr_w(entry_infoW->lpszSourceUrlName));
933 ok(!lstrcmpA(urls[i].encoded_url, entry_infoA->lpszSourceUrlName),
934 "%ld) entry_infoA->lpszSourceUrlName = %s\n",
935 i, entry_infoA->lpszSourceUrlName);
936 ok(entry_infoW->CacheEntryType == entry_infoA->CacheEntryType,
937 "%ld) entry_infoW->CacheEntryType = %lx, expected %lx\n",
938 i, entry_infoW->CacheEntryType, entry_infoA->CacheEntryType);
939 ok(entry_infoW->dwUseCount == entry_infoA->dwUseCount,
940 "%ld) entry_infoW->dwUseCount = %ld, expected %ld\n",
941 i, entry_infoW->dwUseCount, entry_infoA->dwUseCount);
942 ok(entry_infoW->dwHitRate == entry_infoA->dwHitRate,
943 "%ld) entry_infoW->dwHitRate = %ld, expected %ld\n",
944 i, entry_infoW->dwHitRate, entry_infoA->dwHitRate);
945 ok(entry_infoW->dwSizeLow == entry_infoA->dwSizeLow,
946 "%ld) entry_infoW->dwSizeLow = %ld, expected %ld\n",
947 i, entry_infoW->dwSizeLow, entry_infoA->dwSizeLow);
948 ok(entry_infoW->dwSizeHigh == entry_infoA->dwSizeHigh,
949 "%ld) entry_infoW->dwSizeHigh = %ld, expected %ld\n",
950 i, entry_infoW->dwSizeHigh, entry_infoA->dwSizeHigh);
951 ok(!memcmp(&entry_infoW->LastModifiedTime, &entry_infoA->LastModifiedTime, sizeof(FILETIME)),
952 "%ld) entry_infoW->LastModifiedTime is incorrect\n", i);
953 ok(!memcmp(&entry_infoW->ExpireTime, &entry_infoA->ExpireTime, sizeof(FILETIME)),
954 "%ld) entry_infoW->ExpireTime is incorrect\n", i);
955 ok(!memcmp(&entry_infoW->LastAccessTime, &entry_infoA->LastAccessTime, sizeof(FILETIME)),
956 "%ld) entry_infoW->LastAccessTime is incorrect\n", i);
957 ok(!memcmp(&entry_infoW->LastSyncTime, &entry_infoA->LastSyncTime, sizeof(FILETIME)),
958 "%ld) entry_infoW->LastSyncTime is incorrect\n", i);
959
960 MultiByteToWideChar(CP_ACP, 0, entry_infoA->lpszLocalFileName, -1, bufW, MAX_PATH);
961 ok(!lstrcmpW(entry_infoW->lpszLocalFileName, bufW),
962 "%ld) entry_infoW->lpszLocalFileName = %s, expected %s\n",
963 i, wine_dbgstr_w(entry_infoW->lpszLocalFileName), wine_dbgstr_w(bufW));
964
965 if(!urls[i].header_info[0]) {
966 ok(!entry_infoW->lpHeaderInfo, "entry_infoW->lpHeaderInfo != NULL\n");
967 }else {
968 ok(!lstrcmpW((WCHAR*)entry_infoW->lpHeaderInfo, urls[i].header_info),
969 "%ld) entry_infoW->lpHeaderInfo = %s\n",
970 i, wine_dbgstr_w((WCHAR*)entry_infoW->lpHeaderInfo));
971 }
972
973 if(!urls[i].extension[0]) {
974 ok(!entry_infoW->lpszFileExtension || (ie10_cache && !entry_infoW->lpszFileExtension[0]),
975 "%ld) entry_infoW->lpszFileExtension = %s\n",
976 i, wine_dbgstr_w(entry_infoW->lpszFileExtension));
977 }else {
978 MultiByteToWideChar(CP_ACP, 0, entry_infoA->lpszFileExtension, -1, bufW, MAX_PATH);
979 ok(!lstrcmpW(entry_infoW->lpszFileExtension, bufW) ||
980 (ie10_cache && !lstrcmpW(entry_infoW->lpszFileExtension, urls[i].extension)),
981 "%ld) entry_infoW->lpszFileExtension = %s, expected %s\n",
982 i, wine_dbgstr_w(entry_infoW->lpszFileExtension), wine_dbgstr_w(bufW));
983 }
984
985 HeapFree(GetProcessHeap(), 0, entry_infoW);
986 HeapFree(GetProcessHeap(), 0, entry_infoA);
987
988 if(pDeleteUrlCacheEntryA) {
989 ret = pDeleteUrlCacheEntryA(urls[i].encoded_url);
990 ok(ret, "%ld) DeleteUrlCacheEntryW failed: %ld\n", i, GetLastError());
991 }
992 }
993}
#define CP_ACP
Definition: compat.h:109
#define MultiByteToWideChar
Definition: compat.h:110
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4152
BOOL WINAPI GetUrlCacheEntryInfoW(LPCWSTR lpszUrl, LPINTERNET_CACHE_ENTRY_INFOW lpCacheEntryInfo, LPDWORD lpdwCacheEntryInfoBufferSize)
Definition: urlcache.c:2005
BOOL WINAPI CreateUrlCacheEntryW(LPCWSTR lpszUrlName, DWORD dwExpectedFileSize, LPCWSTR lpszFileExtension, LPWSTR lpszFileName, DWORD dwReserved)
Definition: urlcache.c:2808
BOOL WINAPI CommitUrlCacheEntryW(LPCWSTR lpszUrlName, LPCWSTR lpszLocalFileName, FILETIME ExpireTime, FILETIME LastModifiedTime, DWORD CacheEntryType, LPWSTR lpHeaderInfo, DWORD dwHeaderSize, LPCWSTR lpszFileExtension, LPCWSTR lpszOriginalUrl)
Definition: urlcache.c:3078
#define wine_dbgstr_w
Definition: kernel32.h:34
short WCHAR
Definition: pedump.c:58
DWORD dwUseCount
Definition: wininet.h:2109
DWORD dwSizeHigh
Definition: wininet.h:2112
FILETIME LastSyncTime
Definition: wininet.h:2116
DWORD dwSizeLow
Definition: wininet.h:2111
Definition: wininet.h:2127
DWORD CacheEntryType
Definition: wininet.h:2131
FILETIME LastSyncTime
Definition: wininet.h:2139
FILETIME LastModifiedTime
Definition: wininet.h:2136
LPWSTR lpszSourceUrlName
Definition: wininet.h:2129
FILETIME LastAccessTime
Definition: wininet.h:2138
DWORD dwHitRate
Definition: wininet.h:2133
LPBYTE lpHeaderInfo
Definition: wininet.h:2141
DWORD dwSizeHigh
Definition: wininet.h:2135
DWORD dwSizeLow
Definition: wininet.h:2134
DWORD dwStructSize
Definition: wininet.h:2128
LPWSTR lpszFileExtension
Definition: wininet.h:2143
FILETIME ExpireTime
Definition: wininet.h:2137
DWORD dwUseCount
Definition: wininet.h:2132
LPWSTR lpszLocalFileName
Definition: wininet.h:2130

Referenced by START_TEST().

Variable Documentation

◆ DWORD

Definition at line 42 of file urlcache.c.

◆ filenameA

char filenameA[MAX_PATH+1]
static

Definition at line 44 of file urlcache.c.

Referenced by check_cache_entry_infoA(), and test_urlcacheA().

◆ filenameA1

char filenameA1[MAX_PATH+1]
static

Definition at line 45 of file urlcache.c.

Referenced by test_urlcacheA().

◆ ie10_cache

◆ old_ie

BOOL old_ie = FALSE
static

◆ test_hash_collisions1

const char test_hash_collisions1[] = "Visited: http://winehq.org/doc0.html"
static

Definition at line 38 of file urlcache.c.

Referenced by test_urlcacheA().

◆ test_hash_collisions2

const char test_hash_collisions2[] = "Visited: http://winehq.org/doc75651909.html"
static

Definition at line 39 of file urlcache.c.

Referenced by test_urlcacheA().

◆ test_url

◆ test_url1

const char test_url1[] = "Visited: user@http://urlcachetest.winehq.org/index.html"
static

Definition at line 37 of file urlcache.c.

Referenced by test_urlcacheA().

◆ test_urlW

const WCHAR test_urlW[]
static
Initial value:
= {'h','t','t','p',':','/','/','u','r','l','c','a','c','h','e','t','e','s','t','.',
'w','i','n','e','h','q','.','o','r','g','/','i','n','d','e','x','.','h','t','m','l',0}

Definition at line 35 of file urlcache.c.

Referenced by test_GetUrlCacheEntryInfoExA().