ReactOS 0.4.15-dev-8102-g108db8f
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 NONAMELESSUNION
 
#define NONAMELESSSTRUCT
 
#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 335 of file urlcache.c.

◆ check_file_not_exists

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

Definition at line 349 of file urlcache.c.

◆ NONAMELESSSTRUCT

#define NONAMELESSSTRUCT

Definition at line 22 of file urlcache.c.

◆ NONAMELESSUNION

#define NONAMELESSUNION

Definition at line 21 of file urlcache.c.

Function Documentation

◆ _check_file_exists()

static void _check_file_exists ( LONG  l,
LPCSTR  filename 
)
static

Definition at line 323 of file urlcache.c.

324{
325 HANDLE file;
326
329 ok_(__FILE__,l)(file != INVALID_HANDLE_VALUE,
330 "expected file to exist, CreateFile failed with error %d\n",
331 GetLastError());
333}
#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:127
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 337 of file urlcache.c.

338{
339 HANDLE file;
340
343 ok_(__FILE__,l)(file == INVALID_HANDLE_VALUE,
344 "expected file not to exist\n");
347}

◆ BOOL()

static BOOL ( WINAPI pDeleteUrlCacheEntryA)
static

◆ cache_entry_exists()

static BOOL cache_entry_exists ( const char url)
static

Definition at line 1050 of file urlcache.c.

1051{
1052 static char buf[10000];
1053 DWORD size = sizeof(buf);
1054 BOOL ret;
1055
1056 ret = GetUrlCacheEntryInfoA(url, (void*)buf, &size);
1057 ok(ret || GetLastError() == ERROR_FILE_NOT_FOUND, "GetUrlCacheEntryInfoA returned %x (%u)\n", ret, GetLastError());
1058
1059 return ret;
1060}
#define ok(value,...)
Definition: atltest.h:57
BOOL WINAPI GetUrlCacheEntryInfoA(LPCSTR lpszUrlName, LPINTERNET_CACHE_ENTRY_INFOA lpCacheEntryInfo, LPDWORD lpdwCacheEntryInfoBufferSize)
Definition: urlcache.c:1888
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:1432
int ret

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 52 of file urlcache.c.

53{
54 ok(lpCacheEntryInfo->dwStructSize == sizeof(*lpCacheEntryInfo), "%s: dwStructSize was %d\n", returnedfrom, lpCacheEntryInfo->dwStructSize);
55 ok(!strcmp(lpCacheEntryInfo->lpszSourceUrlName, test_url), "%s: lpszSourceUrlName should be %s instead of %s\n", returnedfrom, test_url, lpCacheEntryInfo->lpszSourceUrlName);
56 ok(!strcmp(lpCacheEntryInfo->lpszLocalFileName, filenameA), "%s: lpszLocalFileName should be %s instead of %s\n", returnedfrom, filenameA, lpCacheEntryInfo->lpszLocalFileName);
57 ok(!strcmp(lpCacheEntryInfo->lpszFileExtension, "html"), "%s: lpszFileExtension should be html instead of %s\n", returnedfrom, lpCacheEntryInfo->lpszFileExtension);
58}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
static char filenameA[MAX_PATH+1]
Definition: urlcache.c:47
static const char test_url[]
Definition: urlcache.c:37
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 351 of file urlcache.c.

352{
353 HANDLE file;
354 DWORD written;
355 BOOL ret;
356
360 ok(file != INVALID_HANDLE_VALUE, "CreateFileA failed with error %d\n", GetLastError());
361
362 ret = WriteFile(file, data, len, &written, NULL);
363 ok(ret, "WriteFile failed with error %d\n", GetLastError());
364
366}
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
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 1089 of file urlcache.c.

1090{
1091 BOOL ret;
1092 int folder = -1;
1093 const char *suffix = "";
1094 const char *suffix_win8 = "";
1095
1096 switch (flags)
1097 {
1098 case 0:
1101 suffix = "\\Content.IE5\\";
1102 suffix_win8 = "\\IE\\";
1103 break;
1104
1107 suffix = "\\";
1108 suffix_win8 = "\\";
1109 break;
1110
1113 suffix = "\\History.IE5\\";
1114 suffix_win8 = "\\History.IE5\\";
1115 break;
1116
1117 default:
1118 ok(0, "unexpected flags %#x\n", flags);
1119 break;
1120 }
1121
1123 ok(ret, "SHGetSpecialFolderPath error %u\n", GetLastError());
1124
1125 strcpy(path_win8, path);
1126 strcat(path_win8, suffix_win8);
1127
1128 strcat(path, suffix);
1129}
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define FALSE
Definition: types.h:117
BOOL WINAPI SHGetSpecialFolderPathA(HWND hwndOwner, LPSTR szPath, int nFolder, BOOL bCreate)
Definition: shellpath.c:3079
GLbitfield flags
Definition: glext.h:7161
#define CSIDL_INTERNET_CACHE
Definition: shlobj.h:2190
#define CSIDL_COOKIES
Definition: shlobj.h:2191
#define CSIDL_HISTORY
Definition: shlobj.h:2192
Definition: fci.c:116
#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 1185 of file urlcache.c.

1186{
1187 HMODULE hdll;
1188 hdll = GetModuleHandleA("wininet.dll");
1189
1190 if(!GetProcAddress(hdll, "InternetGetCookieExW")) {
1191 win_skip("Too old IE (older than 6.0)\n");
1192 return;
1193 }
1194 if(!GetProcAddress(hdll, "InternetGetSecurityInfoByURL")) /* < IE7 */
1195 old_ie = TRUE;
1196
1197 if(GetProcAddress(hdll, "CreateUrlCacheEntryExW")) {
1198 trace("Running tests on IE10 or newer\n");
1199 ie10_cache = TRUE;
1200 }
1201
1202 pDeleteUrlCacheEntryA = (void*)GetProcAddress(hdll, "DeleteUrlCacheEntryA");
1203 pUnlockUrlCacheEntryFileA = (void*)GetProcAddress(hdll, "UnlockUrlCacheEntryFileA");
1210}
#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
static void test_trailing_slash(void)
Definition: urlcache.c:1062
static void test_GetUrlCacheConfigInfo(void)
Definition: urlcache.c:1131
static BOOL ie10_cache
Definition: urlcache.c:50
static void test_FindCloseUrlCache(void)
Definition: urlcache.c:998
static void test_urlcacheA(void)
Definition: urlcache.c:368
static void test_urlcacheW(void)
Definition: urlcache.c:842
static void test_GetDiskInfoA(void)
Definition: urlcache.c:1010
static BOOL old_ie
Definition: urlcache.c:49
#define win_skip
Definition: test.h:163
static PVOID hdll
Definition: shimdbg.c:126

◆ test_find_url_cache_entriesA()

static void test_find_url_cache_entriesA ( void  )
static

Definition at line 60 of file urlcache.c.

61{
62 BOOL ret;
63 HANDLE hEnumHandle;
64 BOOL found = FALSE;
65 DWORD cbCacheEntryInfo;
66 DWORD cbCacheEntryInfoSaved;
67 INTERNET_CACHE_ENTRY_INFOA *lpCacheEntryInfo;
68
69 cbCacheEntryInfo = 0;
70 SetLastError(0xdeadbeef);
71 hEnumHandle = FindFirstUrlCacheEntryA(NULL, NULL, &cbCacheEntryInfo);
72 ok(!hEnumHandle, "FindFirstUrlCacheEntry should have failed\n");
73 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "FindFirstUrlCacheEntry should have set last error to ERROR_INSUFFICIENT_BUFFER instead of %d\n", GetLastError());
74 lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo * sizeof(char));
75 cbCacheEntryInfoSaved = cbCacheEntryInfo;
76 hEnumHandle = FindFirstUrlCacheEntryA(NULL, lpCacheEntryInfo, &cbCacheEntryInfo);
77 ok(hEnumHandle != NULL, "FindFirstUrlCacheEntry failed with error %d\n", GetLastError());
78 while (TRUE)
79 {
80 if (!strcmp(lpCacheEntryInfo->lpszSourceUrlName, test_url))
81 {
82 found = TRUE;
83 ret = TRUE;
84 break;
85 }
86 SetLastError(0xdeadbeef);
87 cbCacheEntryInfo = cbCacheEntryInfoSaved;
88 ret = FindNextUrlCacheEntryA(hEnumHandle, lpCacheEntryInfo, &cbCacheEntryInfo);
89 if (!ret)
90 {
92 {
93 lpCacheEntryInfo = HeapReAlloc(GetProcessHeap(), 0, lpCacheEntryInfo, cbCacheEntryInfo);
94 cbCacheEntryInfoSaved = cbCacheEntryInfo;
95 ret = FindNextUrlCacheEntryA(hEnumHandle, lpCacheEntryInfo, &cbCacheEntryInfo);
96 }
97 }
98 if (!ret)
99 break;
100 }
101 ok(ret, "FindNextUrlCacheEntry failed with error %d\n", GetLastError());
102 ok(found, "Committed url cache entry not found during enumeration\n");
103
104 ret = FindCloseUrlCache(hEnumHandle);
105 ok(ret, "FindCloseUrlCache failed with error %d\n", GetLastError());
106 HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo);
107}
#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:3469
BOOL WINAPI FindCloseUrlCache(HANDLE hEnumHandle)
Definition: urlcache.c:3659
BOOL WINAPI FindNextUrlCacheEntryA(HANDLE hEnumHandle, LPINTERNET_CACHE_ENTRY_INFOA lpNextCacheEntryInfo, LPDWORD lpdwNextCacheEntryInfoBufferSize)
Definition: urlcache.c:3629
Definition: wininet.h:2104

Referenced by test_urlcacheA().

◆ test_FindCloseUrlCache()

static void test_FindCloseUrlCache ( void  )
static

Definition at line 998 of file urlcache.c.

999{
1000 BOOL r;
1001 DWORD err;
1002
1003 SetLastError(0xdeadbeef);
1005 err = GetLastError();
1006 ok(0 == r, "expected 0, got %d\n", r);
1007 ok(ERROR_INVALID_HANDLE == err, "expected %d, got %d\n", ERROR_INVALID_HANDLE, err);
1008}
#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 1010 of file urlcache.c.

1011{
1012 BOOL ret;
1015 char path[MAX_PATH], *p;
1016
1018 if ((p = strchr(path, '\\'))) *++p = 0;
1019
1021 ok(ret, "GetDiskInfoA failed %u\n", GetLastError());
1022
1024 ok(ret, "GetDiskInfoA failed %u\n", GetLastError());
1025
1027 ok(ret, "GetDiskInfoA failed %u\n", GetLastError());
1028
1030 ok(ret, "GetDiskInfoA failed %u\n", GetLastError());
1031
1032 SetLastError(0xdeadbeef);
1033 strcpy(p, "\\non\\existing\\path");
1035 error = GetLastError();
1036 ok(!ret ||
1037 broken(old_ie && ret), /* < IE7 */
1038 "GetDiskInfoA succeeded\n");
1040 broken(old_ie && error == 0xdeadbeef), /* < IE7 */
1041 "got %u expected ERROR_PATH_NOT_FOUND\n", error);
1042
1043 SetLastError(0xdeadbeef);
1045 error = GetLastError();
1046 ok(!ret, "GetDiskInfoA succeeded\n");
1047 ok(error == ERROR_INVALID_PARAMETER, "got %u expected ERROR_INVALID_PARAMETER\n", error);
1048}
#define broken(x)
Definition: _sntprintf.h:21
char * strchr(const char *String, int ch)
Definition: utclib.c:501
#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:2283
BOOL WINAPI GetDiskInfoA(PCSTR path, PDWORD cluster_size, PDWORDLONG free, PDWORDLONG total)
Definition: urlcache.c:4062
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:106

Referenced by START_TEST().

◆ test_GetUrlCacheConfigInfo()

static void test_GetUrlCacheConfigInfo ( void  )
static

Definition at line 1131 of file urlcache.c.

1132{
1134 struct
1135 {
1137 DWORD dwStructSize;
1138 DWORD flags;
1139 BOOL ret;
1140 DWORD error;
1141 } td[] =
1142 {
1143#if 0 /* crashes under Vista */
1145#endif
1146 { &info, 0, 0, TRUE },
1147 { &info, sizeof(info) - 1, 0, TRUE },
1148 { &info, sizeof(info) + 1, 0, TRUE },
1155 };
1156 int i;
1157 BOOL ret;
1158
1159 for (i = 0; i < ARRAY_SIZE(td); i++)
1160 {
1161 if (td[i].info)
1162 {
1163 memset(&info, 0, sizeof(*td[i].info));
1164 info.dwStructSize = td[i].dwStructSize;
1165 }
1166
1167 SetLastError(0xdeadbeef);
1169 ok(ret == td[i].ret, "%d: expected %d, got %d\n", i, td[i].ret, ret);
1170 if (!ret)
1171 ok(GetLastError() == td[i].error, "%d: expected %u, got %u\n", i, td[i].error, GetLastError());
1172 else
1173 {
1174 char path[MAX_PATH], path_win8[MAX_PATH];
1175
1176 get_cache_path(td[i].flags, path, path_win8);
1177
1178 ok(info.dwStructSize == td[i].dwStructSize, "got %u\n", info.dwStructSize);
1179 ok(!lstrcmpA(info.CachePath, path) || !lstrcmpA(info.CachePath, path_win8),
1180 "%d: expected %s or %s, got %s\n", i, path, path_win8, info.CachePath);
1181 }
1182 }
1183}
#define ARRAY_SIZE(A)
Definition: main.h:33
int WINAPI lstrcmpA(LPCSTR str1, LPCSTR str2)
Definition: locale.c:4194
BOOL WINAPI GetUrlCacheConfigInfoA(LPINTERNET_CACHE_CONFIG_INFOA info, LPDWORD size, DWORD flags)
Definition: urlcache.c:3857
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:1089
#define memset(x, y, z)
Definition: compat.h:39

Referenced by START_TEST().

◆ test_GetUrlCacheEntryInfoExA()

static void test_GetUrlCacheEntryInfoExA ( void  )
static

Definition at line 109 of file urlcache.c.

110{
111 BOOL ret;
112 DWORD cbCacheEntryInfo, cbRedirectUrl;
113 INTERNET_CACHE_ENTRY_INFOA *lpCacheEntryInfo;
114
115 SetLastError(0xdeadbeef);
117 ok(!ret, "GetUrlCacheEntryInfoEx with NULL URL and NULL args should have failed\n");
119 "GetUrlCacheEntryInfoEx with NULL URL and NULL args should have set last error to ERROR_INVALID_PARAMETER instead of %d\n", GetLastError());
120
121 cbCacheEntryInfo = sizeof(INTERNET_CACHE_ENTRY_INFOA);
122 SetLastError(0xdeadbeef);
123 ret = GetUrlCacheEntryInfoExA("", NULL, &cbCacheEntryInfo, NULL, NULL, NULL, 0);
124 ok(!ret, "GetUrlCacheEntryInfoEx with zero-length buffer should fail\n");
126 "GetUrlCacheEntryInfoEx should have set last error to ERROR_FILE_NOT_FOUND instead of %d\n", GetLastError());
127
129 ok(ret, "GetUrlCacheEntryInfoEx with NULL args failed with error %d\n", GetLastError());
130
131 cbCacheEntryInfo = 0;
132 SetLastError(0xdeadbeef);
133 ret = GetUrlCacheEntryInfoExA(test_url, NULL, &cbCacheEntryInfo, NULL, NULL, NULL, 0);
134 ok(!ret, "GetUrlCacheEntryInfoEx with zero-length buffer should fail\n");
136 "GetUrlCacheEntryInfoEx should have set last error to ERROR_INSUFFICIENT_BUFFER instead of %d\n", GetLastError());
137
138 lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo);
139
140 SetLastError(0xdeadbeef);
141 ret = GetUrlCacheEntryInfoExA(test_url, NULL, NULL, NULL, NULL, NULL, 0x200 /*GET_INSTALLED_ENTRY*/);
142 ok(ret == ie10_cache, "GetUrlCacheEntryInfoEx returned %x\n", ret);
144 "GetUrlCacheEntryInfoEx should have set last error to ERROR_FILE_NOT_FOUND instead of %d\n", GetLastError());
145
146 /* Unicode version of function seems to ignore 0x200 flag */
147 ret = GetUrlCacheEntryInfoExW(test_urlW, NULL, NULL, NULL, NULL, NULL, 0x200 /*GET_INSTALLED_ENTRY*/);
148 ok(ret || broken(old_ie && !ret), "GetUrlCacheEntryInfoExW failed with error %d\n", GetLastError());
149
150 ret = GetUrlCacheEntryInfoExA(test_url, lpCacheEntryInfo, &cbCacheEntryInfo, NULL, NULL, NULL, 0);
151 ok(ret, "GetUrlCacheEntryInfoEx failed with error %d\n", GetLastError());
152
153 if (ret) check_cache_entry_infoA("GetUrlCacheEntryInfoEx", lpCacheEntryInfo);
154
155 lpCacheEntryInfo->CacheEntryType |= 0x10000000; /* INSTALLED_CACHE_ENTRY */
157 ok(ret, "SetUrlCacheEntryInfoA failed with error %d\n", GetLastError());
158
159 SetLastError(0xdeadbeef);
160 ret = GetUrlCacheEntryInfoExA(test_url, NULL, NULL, NULL, NULL, NULL, 0x200 /*GET_INSTALLED_ENTRY*/);
161 ok(ret, "GetUrlCacheEntryInfoEx failed with error %d\n", GetLastError());
162
163 cbCacheEntryInfo = 100000;
164 SetLastError(0xdeadbeef);
165 ret = GetUrlCacheEntryInfoExA(test_url, NULL, &cbCacheEntryInfo, NULL, NULL, NULL, 0);
166 ok(!ret, "GetUrlCacheEntryInfoEx with zero-length buffer should fail\n");
167 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetUrlCacheEntryInfoEx should have set last error to ERROR_INSUFFICIENT_BUFFER instead of %d\n", GetLastError());
168
169 HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo);
170
171 /* Querying the redirect URL fails with ERROR_INVALID_PARAMETER */
172 SetLastError(0xdeadbeef);
173 ret = GetUrlCacheEntryInfoExA(test_url, NULL, NULL, NULL, &cbRedirectUrl, NULL, 0);
174 ok(!ret, "GetUrlCacheEntryInfoEx should have failed\n");
176 "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
177 SetLastError(0xdeadbeef);
178 ret = GetUrlCacheEntryInfoExA(test_url, NULL, &cbCacheEntryInfo, NULL, &cbRedirectUrl, NULL, 0);
179 ok(!ret, "GetUrlCacheEntryInfoEx should have failed\n");
181 "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
182}
BOOL WINAPI GetUrlCacheEntryInfoExA(LPCSTR lpszUrl, LPINTERNET_CACHE_ENTRY_INFOA lpCacheEntryInfo, LPDWORD lpdwCacheEntryInfoBufSize, LPSTR lpszReserved, LPDWORD lpdwReserved, LPVOID lpReserved, DWORD dwFlags)
Definition: urlcache.c:1869
BOOL WINAPI GetUrlCacheEntryInfoExW(LPCWSTR lpszUrl, LPINTERNET_CACHE_ENTRY_INFOW lpCacheEntryInfo, LPDWORD lpdwCacheEntryInfoBufSize, LPWSTR lpszReserved, LPDWORD lpdwReserved, LPVOID lpReserved, DWORD dwFlags)
Definition: urlcache.c:1982
BOOL WINAPI SetUrlCacheEntryInfoA(LPCSTR lpszUrlName, LPINTERNET_CACHE_ENTRY_INFOA lpCacheEntryInfo, DWORD dwFieldControl)
Definition: urlcache.c:2023
static void check_cache_entry_infoA(const char *returnedfrom, INTERNET_CACHE_ENTRY_INFOA *lpCacheEntryInfo)
Definition: urlcache.c:52
static const WCHAR test_urlW[]
Definition: urlcache.c:38
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 211 of file urlcache.c.

212{
213 static const char uncached_url[] =
214 "What's the airspeed velocity of an unladen swallow?";
215 BOOL ret;
216 FILETIME ft;
217 DWORD size;
219 ULARGE_INTEGER exp_time;
220
221 /* The function returns TRUE when the output time is NULL or the tested URL
222 * is NULL.
223 */
225 ok(ret != ie10_cache, "IsUrlCacheEntryExpiredA returned %x\n", ret);
226 ft.dwLowDateTime = 0xdeadbeef;
227 ft.dwHighDateTime = 0xbaadf00d;
229 ok(ret != ie10_cache, "IsUrlCacheEntryExpiredA returned %x\n", ret);
230 ok(ft.dwLowDateTime == 0xdeadbeef && ft.dwHighDateTime == 0xbaadf00d,
231 "expected time to be unchanged, got (%u,%u)\n",
234 ok(ret != ie10_cache, "IsUrlCacheEntryExpiredA returned %x\n", ret);
235
236 /* The return value should indicate whether the URL is expired,
237 * and the filetime indicates the last modified time, but a cache entry
238 * with a zero expire time is "not expired".
239 */
240 ft.dwLowDateTime = 0xdeadbeef;
241 ft.dwHighDateTime = 0xbaadf00d;
243 ok(!ret, "expected FALSE\n");
245 "expected time (0,0), got (%u,%u)\n",
247
248 /* Same behavior with bogus flags. */
249 ft.dwLowDateTime = 0xdeadbeef;
250 ft.dwHighDateTime = 0xbaadf00d;
251 ret = IsUrlCacheEntryExpiredA(test_url, 0xffffffff, &ft);
252 ok(!ret, "expected FALSE\n");
254 "expected time (0,0), got (%u,%u)\n",
256
257 /* Set the expire time to a point in the past.. */
259 ok(!ret, "GetUrlCacheEntryInfo should have failed\n");
261 "expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
264 ok(ret, "GetUrlCacheEntryInfo failed: %d\n", GetLastError());
265 GetSystemTimeAsFileTime(&info->ExpireTime);
266 exp_time.u.LowPart = info->ExpireTime.dwLowDateTime;
267 exp_time.u.HighPart = info->ExpireTime.dwHighDateTime;
268 exp_time.QuadPart -= 10 * 60 * (ULONGLONG)10000000;
269 info->ExpireTime.dwLowDateTime = exp_time.u.LowPart;
270 info->ExpireTime.dwHighDateTime = exp_time.u.HighPart;
272 ok(ret, "SetUrlCacheEntryInfo failed: %d\n", GetLastError());
273 ft.dwLowDateTime = 0xdeadbeef;
274 ft.dwHighDateTime = 0xbaadf00d;
275 /* and the entry should be expired. */
277 ok(ret, "expected TRUE\n");
278 /* The modified time returned is 0. */
280 "expected time (0,0), got (%u,%u)\n",
282 /* Set the expire time to a point in the future.. */
283 exp_time.QuadPart += 20 * 60 * (ULONGLONG)10000000;
284 info->ExpireTime.dwLowDateTime = exp_time.u.LowPart;
285 info->ExpireTime.dwHighDateTime = exp_time.u.HighPart;
287 ok(ret, "SetUrlCacheEntryInfo failed: %d\n", GetLastError());
288 ft.dwLowDateTime = 0xdeadbeef;
289 ft.dwHighDateTime = 0xbaadf00d;
290 /* and the entry should no longer be expired. */
292 ok(!ret, "expected FALSE\n");
293 /* The modified time returned is still 0. */
295 "expected time (0,0), got (%u,%u)\n",
297 /* Set the modified time... */
298 GetSystemTimeAsFileTime(&info->LastModifiedTime);
300 ok(ret, "SetUrlCacheEntryInfo failed: %d\n", GetLastError());
301 /* and the entry should still be unexpired.. */
303 ok(!ret, "expected FALSE\n");
304 /* but the modified time returned is the last modified time just set. */
305 ok(ft.dwLowDateTime == info->LastModifiedTime.dwLowDateTime &&
306 ft.dwHighDateTime == info->LastModifiedTime.dwHighDateTime,
307 "expected time (%u,%u), got (%u,%u)\n",
308 info->LastModifiedTime.dwLowDateTime,
309 info->LastModifiedTime.dwHighDateTime,
312
313 /* An uncached URL is implicitly expired, but with unknown time. */
314 ft.dwLowDateTime = 0xdeadbeef;
315 ft.dwHighDateTime = 0xbaadf00d;
316 ret = IsUrlCacheEntryExpiredA(uncached_url, 0, &ft);
317 ok(ret != ie10_cache, "IsUrlCacheEntryExpiredA returned %x\n", ret);
319 "expected time (0,0), got (%u,%u)\n",
321}
VOID WINAPI GetSystemTimeAsFileTime(OUT PFILETIME lpFileTime)
Definition: time.c:128
BOOL WINAPI IsUrlCacheEntryExpiredA(LPCSTR url, DWORD dwFlags, FILETIME *pftLastModified)
Definition: urlcache.c:3978
DWORD dwHighDateTime
Definition: mapidefs.h:66
DWORD dwLowDateTime
Definition: mapidefs.h:65
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
struct _ULARGE_INTEGER::@4144 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 184 of file urlcache.c.

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

Referenced by test_urlcacheA().

◆ test_trailing_slash()

static void test_trailing_slash ( void  )
static

Definition at line 1062 of file urlcache.c.

1063{
1064 char filename[MAX_PATH];
1065 BYTE zero_byte = 0;
1066 BOOL ret;
1067
1068 static const FILETIME filetime_zero;
1069 static char url_with_slash[] = "http://testing.cache.com/";
1070
1071
1072 ret = CreateUrlCacheEntryA(url_with_slash, 0, "html", filename, 0);
1073 ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError());
1074
1076
1077 ret = CommitUrlCacheEntryA("Visited: http://testing.cache.com/", NULL, filetime_zero, filetime_zero,
1078 NORMAL_CACHE_ENTRY, NULL, 0, "html", NULL);
1079 ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError());
1080
1081 ok(cache_entry_exists("Visited: http://testing.cache.com/"), "cache entry does not exist\n");
1082 ok(!cache_entry_exists("Visited: http://testing.cache.com"), "cache entry exists\n");
1083
1084 ret = DeleteUrlCacheEntryA("Visited: http://testing.cache.com/");
1085 ok(ret, "DeleteCacheEntryA failed\n");
1087}
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
BOOL WINAPI DeleteUrlCacheEntryA(LPCSTR lpszUrlName)
Definition: urlcache.c:3298
BOOL WINAPI CreateUrlCacheEntryA(LPCSTR lpszUrlName, DWORD dwExpectedFileSize, LPCSTR lpszFileExtension, LPSTR lpszFileName, DWORD dwReserved)
Definition: urlcache.c:2796
BOOL WINAPI CommitUrlCacheEntryA(LPCSTR lpszUrlName, LPCSTR lpszLocalFileName, FILETIME ExpireTime, FILETIME LastModifiedTime, DWORD CacheEntryType, LPBYTE lpHeaderInfo, DWORD dwHeaderSize, LPCSTR lpszFileExtension, LPCSTR lpszOriginalUrl)
Definition: urlcache.c:3063
static int zero_byte(mpg123_handle *fr)
Definition: libmpg123.c:763
static BOOL cache_entry_exists(const char *url)
Definition: urlcache.c:1050
static void create_and_write_file(LPCSTR filename, void *data, DWORD len)
Definition: urlcache.c:351
#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 368 of file urlcache.c.

369{
370 static char long_url[300] = "http://www.winehq.org/";
371 static char ok_header[] = "HTTP/1.0 200 OK\r\n\r\n";
372 BOOL ret;
374 BYTE zero_byte = 0;
375 INTERNET_CACHE_ENTRY_INFOA *lpCacheEntryInfo;
376 INTERNET_CACHE_ENTRY_INFOA *lpCacheEntryInfo2;
377 DWORD cbCacheEntryInfo;
378 static const FILETIME filetime_zero;
380 int len;
381
382 ret = CreateUrlCacheEntryA(test_url, 0, "html", filenameA, 0);
383 ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError());
384
386 ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError());
389
390 ok(lstrcmpiA(filenameA, filenameA1), "expected a different file name\n");
391
393
394 ret = CommitUrlCacheEntryA(test_url1, NULL, filetime_zero, filetime_zero, NORMAL_CACHE_ENTRY, NULL, 0, "html", NULL);
395 ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError());
396 cbCacheEntryInfo = 0;
397 ret = GetUrlCacheEntryInfoA(test_url1, NULL, &cbCacheEntryInfo);
398 ok(!ret, "GetUrlCacheEntryInfo should have failed\n");
400 "GetUrlCacheEntryInfo should have set last error to ERROR_INSUFFICIENT_BUFFER instead of %d\n", GetLastError());
401 lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo);
402 ret = GetUrlCacheEntryInfoA(test_url1, lpCacheEntryInfo, &cbCacheEntryInfo);
403 ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError());
404 ok(!memcmp(&lpCacheEntryInfo->ExpireTime, &filetime_zero, sizeof(FILETIME)),
405 "expected zero ExpireTime\n");
406 ok(!memcmp(&lpCacheEntryInfo->LastModifiedTime, &filetime_zero, sizeof(FILETIME)),
407 "expected zero LastModifiedTime\n");
409 broken(lpCacheEntryInfo->CacheEntryType == NORMAL_CACHE_ENTRY /* NT4/W2k */),
410 "expected type NORMAL_CACHE_ENTRY|URLHISTORY_CACHE_ENTRY, got %08x\n",
411 lpCacheEntryInfo->CacheEntryType);
412 ok(!U(*lpCacheEntryInfo).dwExemptDelta, "expected dwExemptDelta 0, got %d\n",
413 U(*lpCacheEntryInfo).dwExemptDelta);
414
415 /* Make sure there is a notable change in timestamps */
416 Sleep(1000);
417
418 /* A subsequent commit with a different time/type doesn't change most of the entry */
421 (LPBYTE)ok_header, strlen(ok_header), NULL, NULL);
422 ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError());
423 cbCacheEntryInfo = 0;
424 ret = GetUrlCacheEntryInfoA(test_url1, NULL, &cbCacheEntryInfo);
425 ok(!ret, "GetUrlCacheEntryInfo should have failed\n");
427 "expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
428 lpCacheEntryInfo2 = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo);
429 ret = GetUrlCacheEntryInfoA(test_url1, lpCacheEntryInfo2, &cbCacheEntryInfo);
430 ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError());
431 /* but it does change the time.. */
432 ok(memcmp(&lpCacheEntryInfo2->ExpireTime, &filetime_zero, sizeof(FILETIME)),
433 "expected positive ExpireTime\n");
434 ok(memcmp(&lpCacheEntryInfo2->LastModifiedTime, &filetime_zero, sizeof(FILETIME)),
435 "expected positive LastModifiedTime\n");
437 broken(lpCacheEntryInfo2->CacheEntryType == NORMAL_CACHE_ENTRY /* NT4/W2k */),
438 "expected type NORMAL_CACHE_ENTRY|URLHISTORY_CACHE_ENTRY, got %08x\n",
439 lpCacheEntryInfo2->CacheEntryType);
440 /* and set the headers. */
441 ok(lpCacheEntryInfo2->dwHeaderInfoSize == 19,
442 "expected headers size 19, got %d\n",
443 lpCacheEntryInfo2->dwHeaderInfoSize);
444 /* Hit rate gets incremented by 1 */
445 ok((lpCacheEntryInfo->dwHitRate + 1) == lpCacheEntryInfo2->dwHitRate,
446 "HitRate not incremented by one on commit\n");
447 /* Last access time should be updated */
448 ok(!(lpCacheEntryInfo->LastAccessTime.dwHighDateTime == lpCacheEntryInfo2->LastAccessTime.dwHighDateTime &&
449 lpCacheEntryInfo->LastAccessTime.dwLowDateTime == lpCacheEntryInfo2->LastAccessTime.dwLowDateTime),
450 "Last accessed time was not updated by commit\n");
451 /* File extension should be unset */
452 ok(lpCacheEntryInfo2->lpszFileExtension == NULL,
453 "Fileextension isn't unset: %s\n",
454 lpCacheEntryInfo2->lpszFileExtension);
455 HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo);
456 HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo2);
457
458 ret = CommitUrlCacheEntryA(test_url, filenameA, filetime_zero, filetime_zero, NORMAL_CACHE_ENTRY, NULL, 0, "html", NULL);
459 ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError());
460
461 cbCacheEntryInfo = 0;
462 SetLastError(0xdeadbeef);
463 ret = RetrieveUrlCacheEntryFileA(test_url, NULL, &cbCacheEntryInfo, 0);
464 ok(!ret, "RetrieveUrlCacheEntryFile should have failed\n");
466 "RetrieveUrlCacheEntryFile should have set last error to ERROR_INSUFFICIENT_BUFFER instead of %d\n", GetLastError());
467
468 lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo);
469 ret = RetrieveUrlCacheEntryFileA(test_url, lpCacheEntryInfo, &cbCacheEntryInfo, 0);
470 ok(ret, "RetrieveUrlCacheEntryFile failed with error %d\n", GetLastError());
471
472 if (ret) check_cache_entry_infoA("RetrieveUrlCacheEntryFile", lpCacheEntryInfo);
473
474 HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo);
475
476 cbCacheEntryInfo = 0;
477 SetLastError(0xdeadbeef);
478 ret = RetrieveUrlCacheEntryFileA(test_url1, NULL, &cbCacheEntryInfo, 0);
479 ok(!ret, "RetrieveUrlCacheEntryFile should have failed\n");
481 "RetrieveUrlCacheEntryFile should have set last error to ERROR_INVALID_DATA instead of %d\n", GetLastError());
482
483 if (pUnlockUrlCacheEntryFileA)
484 {
485 ret = pUnlockUrlCacheEntryFileA(test_url, 0);
486 ok(ret, "UnlockUrlCacheEntryFileA failed with error %d\n", GetLastError());
487 }
488
489 /* test Find*UrlCacheEntry functions */
491
495
496 if (pDeleteUrlCacheEntryA)
497 {
498 ret = pDeleteUrlCacheEntryA(test_url);
499 ok(ret, "DeleteUrlCacheEntryA failed with error %d\n", GetLastError());
500 ret = pDeleteUrlCacheEntryA(test_url1);
501 ok(ret, "DeleteUrlCacheEntryA failed with error %d\n", GetLastError());
502 }
503
504 SetLastError(0xdeadbeef);
506 ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, "local file should no longer exist\n");
507
508 /* Creating two entries with the same URL */
509 ret = CreateUrlCacheEntryA(test_url, 0, "html", filenameA, 0);
510 ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError());
511
513 ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError());
514
515 ok(lstrcmpiA(filenameA, filenameA1), "expected a different file name\n");
516
521
522 ret = CommitUrlCacheEntryA(test_url, filenameA, filetime_zero,
523 filetime_zero, NORMAL_CACHE_ENTRY, (LPBYTE)ok_header,
524 strlen(ok_header), "html", NULL);
525 ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError());
529 filetime_zero, COOKIE_CACHE_ENTRY, NULL, 0, "html", NULL);
530 ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError());
531 /* By committing the same URL a second time, the prior entry is
532 * overwritten...
533 */
534 cbCacheEntryInfo = 0;
535 SetLastError(0xdeadbeef);
536 ret = GetUrlCacheEntryInfoA(test_url, NULL, &cbCacheEntryInfo);
537 ok(!ret, "GetUrlCacheEntryInfo should have failed\n");
539 "expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
540 lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo);
541 ret = GetUrlCacheEntryInfoA(test_url, lpCacheEntryInfo, &cbCacheEntryInfo);
542 ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError());
543 /* with the previous entry type retained.. */
544 ok(lpCacheEntryInfo->CacheEntryType & NORMAL_CACHE_ENTRY,
545 "expected cache entry type NORMAL_CACHE_ENTRY, got %d (0x%08x)\n",
546 lpCacheEntryInfo->CacheEntryType, lpCacheEntryInfo->CacheEntryType);
547 /* and the headers overwritten.. */
548 ok(!lpCacheEntryInfo->dwHeaderInfoSize, "expected headers size 0, got %d\n",
549 lpCacheEntryInfo->dwHeaderInfoSize);
550 HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo);
551 /* and the previous filename shouldn't exist. */
554
555 if (pDeleteUrlCacheEntryA)
556 {
557 ret = pDeleteUrlCacheEntryA(test_url);
558 ok(ret, "DeleteUrlCacheEntryA failed with error %d\n", GetLastError());
561 /* Just in case, clean up files */
564 }
565
566 /* Check whether a retrieved cache entry can be deleted before it's
567 * unlocked:
568 */
569 ret = CreateUrlCacheEntryA(test_url, 0, "html", filenameA, 0);
570 ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError());
571 ret = CommitUrlCacheEntryA(test_url, filenameA, filetime_zero, filetime_zero,
572 NORMAL_CACHE_ENTRY, NULL, 0, "html", NULL);
573 ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError());
574
575 cbCacheEntryInfo = 0;
576 SetLastError(0xdeadbeef);
577 ret = RetrieveUrlCacheEntryFileA(test_url, NULL, &cbCacheEntryInfo, 0);
578 ok(!ret, "RetrieveUrlCacheEntryFile should have failed\n");
580 "expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
581
582 lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo);
583 ret = RetrieveUrlCacheEntryFileA(test_url, lpCacheEntryInfo,
584 &cbCacheEntryInfo, 0);
585 ok(ret, "RetrieveUrlCacheEntryFile failed with error %d\n", GetLastError());
586
587 HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo);
588
589 if (pDeleteUrlCacheEntryA)
590 {
591 ret = pDeleteUrlCacheEntryA(test_url);
592 ok(!ret, "Expected failure\n");
594 "Expected ERROR_SHARING_VIOLATION, got %d\n", GetLastError());
596 }
597
598 lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo);
599 memset(lpCacheEntryInfo, 0, cbCacheEntryInfo);
600 ret = GetUrlCacheEntryInfoA(test_url, lpCacheEntryInfo, &cbCacheEntryInfo);
601 ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError());
602 ok(lpCacheEntryInfo->CacheEntryType & 0x400000,
603 "CacheEntryType hasn't PENDING_DELETE_CACHE_ENTRY set, (flags %08x)\n",
604 lpCacheEntryInfo->CacheEntryType);
605 HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo);
606
607 if (pUnlockUrlCacheEntryFileA)
608 {
610 ret = pUnlockUrlCacheEntryFileA(test_url, 0);
611 ok(ret, "UnlockUrlCacheEntryFileA failed: %d\n", GetLastError());
612 /* By unlocking the already-deleted cache entry, the file associated
613 * with it is deleted..
614 */
616 /* (just in case, delete file) */
618 }
619 if (pDeleteUrlCacheEntryA)
620 {
621 /* and a subsequent deletion should fail. */
622 ret = pDeleteUrlCacheEntryA(test_url);
623 ok(!ret, "Expected failure\n");
625 "expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
626 }
627
628 /* Test whether preventing a file from being deleted causes
629 * DeleteUrlCacheEntryA to fail.
630 */
631 ret = CreateUrlCacheEntryA(test_url, 0, "html", filenameA, 0);
632 ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError());
633
636
637 ret = CommitUrlCacheEntryA(test_url, filenameA, filetime_zero,
638 filetime_zero, NORMAL_CACHE_ENTRY, (LPBYTE)ok_header,
639 strlen(ok_header), "html", NULL);
640 ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError());
644 ok(hFile != INVALID_HANDLE_VALUE, "CreateFileA failed: %d\n",
645 GetLastError());
646 if (pDeleteUrlCacheEntryA)
647 {
648 /* DeleteUrlCacheEntryA should succeed.. */
649 ret = pDeleteUrlCacheEntryA(test_url);
650 ok(ret, "DeleteUrlCacheEntryA failed with error %d\n", GetLastError());
651 }
653 if (pDeleteUrlCacheEntryA)
654 {
655 /* and a subsequent deletion should fail.. */
656 ret = pDeleteUrlCacheEntryA(test_url);
657 ok(!ret, "Expected failure\n");
659 "expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
660 }
661 /* and the file should be untouched. */
664
665 /* Try creating a sticky entry. Unlike non-sticky entries, the filename
666 * must have been set already.
667 */
668 SetLastError(0xdeadbeef);
669 ret = CommitUrlCacheEntryA(test_url, NULL, filetime_zero, filetime_zero,
670 STICKY_CACHE_ENTRY, (LPBYTE)ok_header, strlen(ok_header), "html",
671 NULL);
672 ok(ret == ie10_cache, "CommitUrlCacheEntryA returned %x\n", ret);
674 "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
675 SetLastError(0xdeadbeef);
676 ret = CommitUrlCacheEntryA(test_url, NULL, filetime_zero, filetime_zero,
678 (LPBYTE)ok_header, strlen(ok_header), "html", NULL);
679 ok(ret == ie10_cache, "CommitUrlCacheEntryA returned %x\n", ret);
681 "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
682
683 ret = CreateUrlCacheEntryA(test_url, 0, "html", filenameA, 0);
684 ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError());
686 ret = CommitUrlCacheEntryA(test_url, filenameA, filetime_zero, filetime_zero,
688 (LPBYTE)ok_header, strlen(ok_header), "html", NULL);
689 ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError());
690 cbCacheEntryInfo = 0;
691 SetLastError(0xdeadbeef);
692 ret = GetUrlCacheEntryInfoA(test_url, NULL, &cbCacheEntryInfo);
693 ok(!ret, "GetUrlCacheEntryInfo should have failed\n");
695 "expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
696 lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo);
697 ret = GetUrlCacheEntryInfoA(test_url, lpCacheEntryInfo, &cbCacheEntryInfo);
698 ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError());
700 "expected cache entry type NORMAL_CACHE_ENTRY | STICKY_CACHE_ENTRY, got %d (0x%08x)\n",
701 lpCacheEntryInfo->CacheEntryType, lpCacheEntryInfo->CacheEntryType);
702 ok(U(*lpCacheEntryInfo).dwExemptDelta == 86400,
703 "expected dwExemptDelta 86400, got %d\n",
704 U(*lpCacheEntryInfo).dwExemptDelta);
705 HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo);
706 if (pDeleteUrlCacheEntryA)
707 {
708 ret = pDeleteUrlCacheEntryA(test_url);
709 ok(ret, "DeleteUrlCacheEntryA failed with error %d\n", GetLastError());
710 /* When explicitly deleting the cache entry, the file is also deleted */
712 }
713 /* Test once again, setting the exempt delta via SetUrlCacheEntryInfo */
714 ret = CreateUrlCacheEntryA(test_url, 0, "html", filenameA, 0);
715 ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError());
717 ret = CommitUrlCacheEntryA(test_url, filenameA, filetime_zero, filetime_zero,
719 (LPBYTE)ok_header, strlen(ok_header), "html", NULL);
720 ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError());
721 cbCacheEntryInfo = 0;
722 SetLastError(0xdeadbeef);
723 ret = GetUrlCacheEntryInfoA(test_url, NULL, &cbCacheEntryInfo);
724 ok(!ret, "GetUrlCacheEntryInfo should have failed\n");
726 "expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
727 lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo);
728 ret = GetUrlCacheEntryInfoA(test_url, lpCacheEntryInfo, &cbCacheEntryInfo);
729 ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError());
731 "expected cache entry type NORMAL_CACHE_ENTRY | STICKY_CACHE_ENTRY, got %d (0x%08x)\n",
732 lpCacheEntryInfo->CacheEntryType, lpCacheEntryInfo->CacheEntryType);
733 ok(U(*lpCacheEntryInfo).dwExemptDelta == 86400,
734 "expected dwExemptDelta 86400, got %d\n",
735 U(*lpCacheEntryInfo).dwExemptDelta);
736 U(*lpCacheEntryInfo).dwExemptDelta = 0;
737 ret = SetUrlCacheEntryInfoA(test_url, lpCacheEntryInfo,
739 ok(ret, "SetUrlCacheEntryInfo failed: %d\n", GetLastError());
740 ret = GetUrlCacheEntryInfoA(test_url, lpCacheEntryInfo, &cbCacheEntryInfo);
741 ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError());
742 ok(!U(*lpCacheEntryInfo).dwExemptDelta, "expected dwExemptDelta 0, got %d\n",
743 U(*lpCacheEntryInfo).dwExemptDelta);
744 /* See whether a sticky cache entry has the flag cleared once the exempt
745 * delta is meaningless.
746 */
748 "expected cache entry type NORMAL_CACHE_ENTRY | STICKY_CACHE_ENTRY, got %d (0x%08x)\n",
749 lpCacheEntryInfo->CacheEntryType, lpCacheEntryInfo->CacheEntryType);
750
751 /* Recommit of Url entry keeps dwExemptDelta */
752 U(*lpCacheEntryInfo).dwExemptDelta = 8600;
753 ret = SetUrlCacheEntryInfoA(test_url, lpCacheEntryInfo,
755 ok(ret, "SetUrlCacheEntryInfo failed: %d\n", GetLastError());
756
758 ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError());
760
761 ret = CommitUrlCacheEntryA(test_url, filenameA1, filetime_zero, filetime_zero,
763 (LPBYTE)ok_header, strlen(ok_header), "html", NULL);
764 ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError());
765
766 ret = GetUrlCacheEntryInfoA(test_url, lpCacheEntryInfo, &cbCacheEntryInfo);
767 ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError());
768 ok(U(*lpCacheEntryInfo).dwExemptDelta == 8600 || (ie10_cache && U(*lpCacheEntryInfo).dwExemptDelta == 86400),
769 "expected dwExemptDelta 8600, got %d\n", U(*lpCacheEntryInfo).dwExemptDelta);
770
771 HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo);
772
773 if (pDeleteUrlCacheEntryA)
774 {
775 ret = pDeleteUrlCacheEntryA(test_url);
776 ok(ret, "DeleteUrlCacheEntryA failed with error %d\n", GetLastError());
778 }
779
780 /* Test if files with identical hash keys are handled correctly */
781 ret = CommitUrlCacheEntryA(test_hash_collisions1, NULL, filetime_zero, filetime_zero, NORMAL_CACHE_ENTRY, NULL, 0, "html", NULL);
782 ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError());
783 ret = CommitUrlCacheEntryA(test_hash_collisions2, NULL, filetime_zero, filetime_zero, NORMAL_CACHE_ENTRY, NULL, 0, "html", NULL);
784 ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError());
785
786 cbCacheEntryInfo = 0;
788 ok(!ret, "GetUrlCacheEntryInfo should have failed\n");
790 "expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
791 lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo);
792 ret = GetUrlCacheEntryInfoA(test_hash_collisions1, lpCacheEntryInfo, &cbCacheEntryInfo);
793 ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError());
795 "got incorrect entry: %s\n", lpCacheEntryInfo->lpszSourceUrlName);
796 HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo);
797
798 cbCacheEntryInfo = 0;
800 ok(!ret, "GetUrlCacheEntryInfo should have failed\n");
802 "expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
803 lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo);
804 ret = GetUrlCacheEntryInfoA(test_hash_collisions2, lpCacheEntryInfo, &cbCacheEntryInfo);
805 ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError());
807 "got incorrect entry: %s\n", lpCacheEntryInfo->lpszSourceUrlName);
808 HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo);
809
810 if (pDeleteUrlCacheEntryA) {
811 ret = pDeleteUrlCacheEntryA(test_hash_collisions1);
812 ok(ret, "DeleteUrlCacheEntry failed: %d\n", GetLastError());
813 ret = pDeleteUrlCacheEntryA(test_hash_collisions2);
814 ok(ret, "DeleteUrlCacheEntry failed: %d\n", GetLastError());
815 }
816
817 len = strlen(long_url);
818 memset(long_url+len, 'a', sizeof(long_url)-len);
819 long_url[sizeof(long_url)-1] = 0;
820 ret = CreateUrlCacheEntryA(long_url, 0, NULL, filenameA, 0);
821 ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError());
824
825 ret = CreateUrlCacheEntryA(long_url, 0, "extension", filenameA, 0);
826 ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError());
829
830 long_url[250] = 0;
831 ret = CreateUrlCacheEntryA(long_url, 0, NULL, filenameA, 0);
832 ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError());
835
836 ret = CreateUrlCacheEntryA(long_url, 0, "extension", filenameA, 0);
837 ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError());
840}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define U(x)
Definition: wordpad.c:45
int WINAPI lstrcmpiA(LPCSTR str1, LPCSTR str2)
Definition: locale.c:4223
time_t now
Definition: finger.c:65
#define check_file_not_exists(f)
Definition: urlcache.c:349
static void test_GetUrlCacheEntryInfoExA(void)
Definition: urlcache.c:109
static const char test_hash_collisions2[]
Definition: urlcache.c:42
static void test_IsUrlCacheEntryExpiredA(void)
Definition: urlcache.c:211
static const char test_url1[]
Definition: urlcache.c:40
static char filenameA1[MAX_PATH+1]
Definition: urlcache.c:48
static void test_RetrieveUrlCacheEntryA(void)
Definition: urlcache.c:184
static void test_find_url_cache_entriesA(void)
Definition: urlcache.c:60
#define check_file_exists(f)
Definition: urlcache.c:335
static const char test_hash_collisions1[]
Definition: urlcache.c:41
_In_ HANDLE hFile
Definition: mswsock.h:90
FILETIME LastAccessTime
Definition: wininet.h:2115
DWORD dwHitRate
Definition: wininet.h:2110
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:790
unsigned char * LPBYTE
Definition: typedefs.h:53
#define ERROR_SHARING_VIOLATION
Definition: winerror.h:135
#define ERROR_INVALID_DATA
Definition: winerror.h:116
#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 842 of file urlcache.c.

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

Referenced by START_TEST().

Variable Documentation

◆ DWORD

Definition at line 45 of file urlcache.c.

◆ filenameA

char filenameA[MAX_PATH+1]
static

Definition at line 47 of file urlcache.c.

Referenced by check_cache_entry_infoA(), and test_urlcacheA().

◆ filenameA1

char filenameA1[MAX_PATH+1]
static

Definition at line 48 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 41 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 42 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 40 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 38 of file urlcache.c.

Referenced by test_GetUrlCacheEntryInfoExA().