ReactOS 0.4.15-dev-7907-g95bf896
enum_files.c File Reference
#include <shlwapi.h>
#include <stdio.h>
#include "wine/test.h"
#include "initguid.h"
#include "bits.h"
Include dependency graph for enum_files.c:

Go to the source code of this file.

Macros

#define COBJMACROS
 
#define NUM_FILES   2 /* At least two. */
 

Typedefs

typedef void(* test_t) (void)
 

Functions

static HRESULT addFileHelper (IBackgroundCopyJob *job, const WCHAR *localName, const WCHAR *remoteName)
 
static HRESULT test_create_manager (void)
 
static BOOL setup (void)
 
static void teardown (void)
 
static void test_GetCount (void)
 
static void test_Next_walkListNull (void)
 
static void test_Next_walkList_1 (void)
 
static void test_Next_walkList_2 (void)
 
static void test_Next_errors (void)
 
static void test_Skip_walkList (void)
 
static void test_Skip_offEnd (void)
 
static void test_Reset (void)
 
 START_TEST (enum_files)
 

Variables

static const WCHAR test_remoteNameA [] = {'r','e','m','o','t','e','A', 0}
 
static const WCHAR test_localNameA [] = {'l','o','c','a','l','A', 0}
 
static const WCHAR test_remoteNameB [] = {'r','e','m','o','t','e','B', 0}
 
static const WCHAR test_localNameB [] = {'l','o','c','a','l','B', 0}
 
static const WCHAR test_displayName [] = {'T', 'e', 's', 't', 0}
 
static const ULONG test_fileCount = NUM_FILES
 
static IBackgroundCopyJobtest_job
 
static IBackgroundCopyManagertest_manager
 
static IEnumBackgroundCopyFilestest_enumFiles
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 24 of file enum_files.c.

◆ NUM_FILES

#define NUM_FILES   2 /* At least two. */

Definition at line 31 of file enum_files.c.

Typedef Documentation

◆ test_t

typedef void(* test_t) (void)

Definition at line 269 of file enum_files.c.

Function Documentation

◆ addFileHelper()

static HRESULT addFileHelper ( IBackgroundCopyJob job,
const WCHAR localName,
const WCHAR remoteName 
)
static

Definition at line 45 of file enum_files.c.

47{
48 DWORD urlSize;
49 WCHAR localFile[MAX_PATH];
50 WCHAR remoteUrl[MAX_PATH];
51 WCHAR remoteFile[MAX_PATH];
52
54 PathAppendW(localFile, localName);
55 GetCurrentDirectoryW(MAX_PATH, remoteFile);
56 PathAppendW(remoteFile, remoteName);
57 urlSize = MAX_PATH;
58 UrlCreateFromPathW(remoteFile, remoteUrl, &urlSize, 0);
59 UrlUnescapeW(remoteUrl, NULL, &urlSize, URL_UNESCAPE_INPLACE);
60 return IBackgroundCopyJob_AddFile(job, remoteUrl, localFile);
61}
#define NULL
Definition: types.h:112
#define GetCurrentDirectoryW(x, y)
Definition: compat.h:756
#define MAX_PATH
Definition: compat.h:34
HRESULT WINAPI UrlUnescapeW(LPWSTR pszUrl, LPWSTR pszUnescaped, LPDWORD pcchUnescaped, DWORD dwFlags)
Definition: url.c:1367
HRESULT WINAPI UrlCreateFromPathW(LPCWSTR pszPath, LPWSTR pszUrl, LPDWORD pcchUrl, DWORD dwReserved)
Definition: url.c:2497
unsigned long DWORD
Definition: ntddk_ex.h:95
static HANDLE job
Definition: process.c:77
#define PathAppendW
Definition: pathcch.h:309
#define URL_UNESCAPE_INPLACE
Definition: shlwapi.h:1224
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by setup(), and test_create_manager().

◆ setup()

static BOOL setup ( void  )
static

Definition at line 97 of file enum_files.c.

98{
101
102 hres = CoCreateInstance(&CLSID_BackgroundCopyManager, NULL,
103 CLSCTX_LOCAL_SERVER, &IID_IBackgroundCopyManager,
104 (void **) &test_manager);
105 if(hres != S_OK)
106 return FALSE;
107
108 hres = IBackgroundCopyManager_CreateJob(test_manager, test_displayName,
109 BG_JOB_TYPE_DOWNLOAD, &test_jobId,
110 &test_job);
111 if(hres != S_OK)
112 {
113 IBackgroundCopyManager_Release(test_manager);
114 return FALSE;
115 }
116
119 || IBackgroundCopyJob_EnumFiles(test_job, &test_enumFiles) != S_OK)
120 {
121 IBackgroundCopyJob_Release(test_job);
122 IBackgroundCopyManager_Release(test_manager);
123 return FALSE;
124 }
125
126 return TRUE;
127}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
#define S_OK
Definition: intsafe.h:52
HRESULT hres
Definition: protocol.c:465
static IEnumBackgroundCopyFiles * test_enumFiles
Definition: enum_files.c:40
static const WCHAR test_remoteNameB[]
Definition: enum_files.c:34
static const WCHAR test_localNameB[]
Definition: enum_files.c:35
static const WCHAR test_remoteNameA[]
Definition: enum_files.c:32
static HRESULT addFileHelper(IBackgroundCopyJob *job, const WCHAR *localName, const WCHAR *remoteName)
Definition: enum_files.c:45
static IBackgroundCopyJob * test_job
Definition: enum_files.c:38
static const WCHAR test_localNameA[]
Definition: enum_files.c:33
static const WCHAR test_displayName[]
Definition: enum_files.c:36
static GUID test_jobId
Definition: job.c:39

Referenced by create_suite(), DoInfInstall(), DoInfInstallW(), set_script_mode(), SetPerUserSecValuesW(), START_TEST(), test_CreateTrigger(), Test_InitializeLpkHooks(), test_SetAccountInformation_GetAccountInformation(), test_SetApplicationName_GetApplicationName(), test_SetComment_GetComment(), test_SetMaxRunTime_GetMaxRunTime(), test_SetParameters_GetParameters(), test_SetTrigger_GetTrigger(), UserInstStubWrapperW(), and via82c_timing().

◆ START_TEST()

START_TEST ( enum_files  )

Definition at line 271 of file enum_files.c.

272{
273 static const test_t tests[] = {
282 0
283 };
284 const test_t *test;
285 int i;
286
288
290 {
292 win_skip("Failed to create Manager instance, skipping tests\n");
293 return;
294 }
295
296 for (test = tests, i = 0; *test; ++test, ++i)
297 {
298 /* Keep state separate between tests. */
299 if (!setup())
300 {
301 ok(0, "tests:%d: Unable to setup test\n", i);
302 break;
303 }
304 (*test)();
305 teardown();
306 }
308}
#define ok(value,...)
Definition: atltest.h:57
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
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
#define FAILED(hr)
Definition: intsafe.h:51
static struct test_info tests[]
static void test_Reset(void)
Definition: enum_files.c:257
static void test_Next_errors(void)
Definition: enum_files.c:221
static void test_Next_walkList_2(void)
Definition: enum_files.c:197
static void teardown(void)
Definition: enum_files.c:130
static void test_Next_walkListNull(void)
Definition: enum_files.c:149
static void test_Next_walkList_1(void)
Definition: enum_files.c:169
static void test_GetCount(void)
Definition: enum_files.c:138
static void test_Skip_offEnd(void)
Definition: enum_files.c:248
static BOOL setup(void)
Definition: enum_files.c:97
static void test_Skip_walkList(void)
Definition: enum_files.c:232
static HRESULT test_create_manager(void)
Definition: enum_files.c:63
void(* test_t)(void)
Definition: enum_files.c:269
#define test
Definition: rosglue.h:37
#define win_skip
Definition: test.h:160

◆ teardown()

static void teardown ( void  )
static

Definition at line 130 of file enum_files.c.

131{
132 IEnumBackgroundCopyFiles_Release(test_enumFiles);
133 IBackgroundCopyJob_Release(test_job);
134 IBackgroundCopyManager_Release(test_manager);
135}

Referenced by create_suite(), and START_TEST().

◆ test_create_manager()

static HRESULT test_create_manager ( void  )
static

Definition at line 63 of file enum_files.c.

64{
67
68 /* Creating BITS instance */
69 hres = CoCreateInstance(&CLSID_BackgroundCopyManager, NULL, CLSCTX_LOCAL_SERVER,
70 &IID_IBackgroundCopyManager, (void **) &manager);
71
73 win_skip("Needed Service is disabled\n");
74 return hres;
75 }
76
77 if (hres == S_OK)
78 {
80 GUID jobId;
81
82 hres = IBackgroundCopyManager_CreateJob(manager, test_displayName, BG_JOB_TYPE_DOWNLOAD, &jobId, &job);
83 if (hres == S_OK)
84 {
86 if (hres != S_OK)
87 win_skip("AddFile() with file:// protocol failed. Tests will be skipped.\n");
88 IBackgroundCopyJob_Release(job);
89 }
90 IBackgroundCopyManager_Release(manager);
91 }
92
93 return hres;
94}
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
#define ERROR_SERVICE_DISABLED
Definition: winerror.h:609

Referenced by START_TEST().

◆ test_GetCount()

static void test_GetCount ( void  )
static

Definition at line 138 of file enum_files.c.

139{
141 ULONG fileCount;
142
143 hres = IEnumBackgroundCopyFiles_GetCount(test_enumFiles, &fileCount);
144 ok(hres == S_OK, "GetCount failed: %08x\n", hres);
145 ok(fileCount == test_fileCount, "Got incorrect count\n");
146}
static const ULONG test_fileCount
Definition: enum_files.c:37
uint32_t ULONG
Definition: typedefs.h:59

Referenced by START_TEST().

◆ test_Next_errors()

static void test_Next_errors ( void  )
static

Definition at line 221 of file enum_files.c.

222{
225
226 /* E_INVALIDARG: pceltFetched can ONLY be NULL if celt is 1 */
227 hres = IEnumBackgroundCopyFiles_Next(test_enumFiles, 2, files, NULL);
228 ok(hres == E_INVALIDARG, "Invalid call to Next succeeded: %08x\n", hres);
229}
#define E_INVALIDARG
Definition: ddrawi.h:101
#define NUM_FILES
Definition: enum_files.c:31

Referenced by START_TEST().

◆ test_Next_walkList_1()

static void test_Next_walkList_1 ( void  )
static

Definition at line 169 of file enum_files.c.

170{
173 ULONG fetched;
174 ULONG i;
175
176 /* Fetch the available files */
177 for (i = 0; i < test_fileCount; i++)
178 {
179 file = NULL;
180 fetched = 0;
181 hres = IEnumBackgroundCopyFiles_Next(test_enumFiles, 1, &file, &fetched);
182 ok(hres == S_OK, "Next failed: %08x\n", hres);
183 ok(fetched == 1, "Next returned the incorrect number of files: %08x\n", hres);
184 ok(file != NULL, "Next returned NULL\n");
185 if (file)
186 IBackgroundCopyFile_Release(file);
187 }
188
189 /* Attempt to fetch one more than the number of available files */
190 fetched = 0;
191 hres = IEnumBackgroundCopyFiles_Next(test_enumFiles, 1, &file, &fetched);
192 ok(hres == S_FALSE, "Next off end of available files failed: %08x\n", hres);
193 ok(fetched == 0, "Next returned the incorrect number of files: %08x\n", hres);
194}
Definition: fci.c:127
#define S_FALSE
Definition: winerror.h:2357

Referenced by START_TEST().

◆ test_Next_walkList_2()

static void test_Next_walkList_2 ( void  )
static

Definition at line 197 of file enum_files.c.

198{
201 ULONG fetched;
202 ULONG i;
203
204 for (i = 0; i < test_fileCount; i++)
205 files[i] = NULL;
206
207 fetched = 0;
208 hres = IEnumBackgroundCopyFiles_Next(test_enumFiles, test_fileCount, files, &fetched);
209 ok(hres == S_OK, "Next failed: %08x\n", hres);
210 ok(fetched == test_fileCount, "Next returned the incorrect number of files: %08x\n", hres);
211
212 for (i = 0; i < test_fileCount; i++)
213 {
214 ok(files[i] != NULL, "Next returned NULL\n");
215 if (files[i])
216 IBackgroundCopyFile_Release(files[i]);
217 }
218}

Referenced by START_TEST().

◆ test_Next_walkListNull()

static void test_Next_walkListNull ( void  )
static

Definition at line 149 of file enum_files.c.

150{
153 ULONG i;
154
155 /* Fetch the available files */
156 for (i = 0; i < test_fileCount; i++)
157 {
158 hres = IEnumBackgroundCopyFiles_Next(test_enumFiles, 1, &file, NULL);
159 ok(hres == S_OK, "Next failed: %08x\n", hres);
160 IBackgroundCopyFile_Release(file);
161 }
162
163 /* Attempt to fetch one more than the number of available files */
164 hres = IEnumBackgroundCopyFiles_Next(test_enumFiles, 1, &file, NULL);
165 ok(hres == S_FALSE, "Next off end of available files failed: %08x\n", hres);
166}

Referenced by START_TEST().

◆ test_Reset()

static void test_Reset ( void  )
static

Definition at line 257 of file enum_files.c.

258{
260
261 hres = IEnumBackgroundCopyFiles_Skip(test_enumFiles, test_fileCount);
262 ok(hres == S_OK, "Skip failed: %08x\n", hres);
263 hres = IEnumBackgroundCopyFiles_Reset(test_enumFiles);
264 ok(hres == S_OK, "Reset failed: %08x\n", hres);
265 hres = IEnumBackgroundCopyFiles_Skip(test_enumFiles, test_fileCount);
266 ok(hres == S_OK, "Reset failed: %08x\n", hres);
267}

Referenced by START_TEST().

◆ test_Skip_offEnd()

static void test_Skip_offEnd ( void  )
static

Definition at line 248 of file enum_files.c.

249{
251
252 hres = IEnumBackgroundCopyFiles_Skip(test_enumFiles, test_fileCount + 1);
253 ok(hres == S_FALSE, "Skip expected end of list: %08x\n", hres);
254}

Referenced by START_TEST().

◆ test_Skip_walkList()

static void test_Skip_walkList ( void  )
static

Definition at line 232 of file enum_files.c.

233{
235 ULONG i;
236
237 for (i = 0; i < test_fileCount; i++)
238 {
239 hres = IEnumBackgroundCopyFiles_Skip(test_enumFiles, 1);
240 ok(hres == S_OK, "Skip failed: %08x\n", hres);
241 }
242
243 hres = IEnumBackgroundCopyFiles_Skip(test_enumFiles, 1);
244 ok(hres == S_FALSE, "Skip expected end of list: %08x\n", hres);
245}

Referenced by START_TEST().

Variable Documentation

◆ test_displayName

const WCHAR test_displayName[] = {'T', 'e', 's', 't', 0}
static

Definition at line 36 of file enum_files.c.

Referenced by setup(), and test_create_manager().

◆ test_enumFiles

◆ test_fileCount

◆ test_job

IBackgroundCopyJob* test_job
static

Definition at line 38 of file enum_files.c.

Referenced by setup(), and teardown().

◆ test_localNameA

const WCHAR test_localNameA[] = {'l','o','c','a','l','A', 0}
static

Definition at line 33 of file enum_files.c.

Referenced by setup(), and test_create_manager().

◆ test_localNameB

const WCHAR test_localNameB[] = {'l','o','c','a','l','B', 0}
static

Definition at line 35 of file enum_files.c.

Referenced by setup().

◆ test_manager

Definition at line 39 of file enum_files.c.

◆ test_remoteNameA

const WCHAR test_remoteNameA[] = {'r','e','m','o','t','e','A', 0}
static

Definition at line 32 of file enum_files.c.

Referenced by setup(), and test_create_manager().

◆ test_remoteNameB

const WCHAR test_remoteNameB[] = {'r','e','m','o','t','e','B', 0}
static

Definition at line 34 of file enum_files.c.

Referenced by setup().