ReactOS 0.4.17-dev-966-gf06eace
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 ULONG test_fileCount = NUM_FILES
 
static IBackgroundCopyJob * test_job
 
static IBackgroundCopyManager * test_manager
 
static IEnumBackgroundCopyFiles * test_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 263 of file enum_files.c.

Function Documentation

◆ addFileHelper()

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

Definition at line 40 of file enum_files.c.

42{
43 DWORD urlSize;
44 WCHAR localFile[MAX_PATH];
45 WCHAR remoteUrl[MAX_PATH];
46 WCHAR remoteFile[MAX_PATH];
47
49 PathAppendW(localFile, localName);
50 GetCurrentDirectoryW(MAX_PATH, remoteFile);
51 PathAppendW(remoteFile, remoteName);
52 urlSize = MAX_PATH;
53 UrlCreateFromPathW(remoteFile, remoteUrl, &urlSize, 0);
54 UrlUnescapeW(remoteUrl, NULL, &urlSize, URL_UNESCAPE_INPLACE);
55 return IBackgroundCopyJob_AddFile(job, remoteUrl, localFile);
56}
#define NULL
Definition: types.h:112
#define GetCurrentDirectoryW(x, y)
Definition: compat.h:756
#define MAX_PATH
Definition: compat.h:34
HRESULT WINAPI UrlCreateFromPathW(const WCHAR *path, WCHAR *url, DWORD *url_len, DWORD reserved)
Definition: path.c:4892
HRESULT WINAPI UrlUnescapeW(WCHAR *url, WCHAR *unescaped, DWORD *unescaped_len, DWORD flags)
Definition: path.c:2912
unsigned long DWORD
Definition: ntddk_ex.h:95
static HANDLE job
Definition: process.c:79
#define PathAppendW
Definition: pathcch.h:310
short WCHAR
Definition: pedump.c:58
#define URL_UNESCAPE_INPLACE
Definition: shlwapi.h:525

Referenced by setup(), and test_create_manager().

◆ setup()

static BOOL setup ( void  )
static

Definition at line 92 of file enum_files.c.

93{
96
97 hres = CoCreateInstance(&CLSID_BackgroundCopyManager, NULL,
98 CLSCTX_LOCAL_SERVER, &IID_IBackgroundCopyManager,
99 (void **) &test_manager);
100 if(hres != S_OK)
101 return FALSE;
102
103 hres = IBackgroundCopyManager_CreateJob(test_manager, L"Test", BG_JOB_TYPE_DOWNLOAD,
105 if(hres != S_OK)
106 {
107 IBackgroundCopyManager_Release(test_manager);
108 return FALSE;
109 }
110
111 if (addFileHelper(test_job, L"localA", L"remoteA") != S_OK
112 || addFileHelper(test_job, L"localB", L"remoteB") != S_OK
113 || IBackgroundCopyJob_EnumFiles(test_job, &test_enumFiles) != S_OK)
114 {
115 IBackgroundCopyJob_Release(test_job);
116 IBackgroundCopyManager_Release(test_manager);
117 return FALSE;
118 }
119
120 return TRUE;
121}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, IUnknown *outer, DWORD cls_context, REFIID riid, void **obj)
Definition: combase.c:1685
#define L(x)
Definition: resources.c:13
#define S_OK
Definition: intsafe.h:52
HRESULT hres
Definition: protocol.c:432
static IEnumBackgroundCopyFiles * test_enumFiles
Definition: enum_files.c:35
static HRESULT addFileHelper(IBackgroundCopyJob *job, const WCHAR *localName, const WCHAR *remoteName)
Definition: enum_files.c:40
static IBackgroundCopyJob * test_job
Definition: enum_files.c:33
static GUID test_jobId
Definition: job.c:39

Referenced by corruntimehost_CreateDomainEx(), create_suite(), DoInfInstall(), DoInfInstallW(), RuntimeHost_AddDomain(), 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 265 of file enum_files.c.

266{
267 static const test_t tests[] = {
276 0
277 };
278 const test_t *test;
279 int i;
280
282
284 {
286 win_skip("Failed to create Manager instance, skipping tests\n");
287 return;
288 }
289
290 for (test = tests, i = 0; *test; ++test, ++i)
291 {
292 /* Keep state separate between tests. */
293 if (!setup())
294 {
295 ok(0, "tests:%d: Unable to setup test\n", i);
296 break;
297 }
298 (*test)();
299 teardown();
300 }
302}
#define ok(value,...)
Definition: atltest.h:57
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: combase.c:2842
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:531
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
#define win_skip
Definition: minitest.h:67
static struct test_info tests[]
static void test_Reset(void)
Definition: enum_files.c:251
static void test_Next_errors(void)
Definition: enum_files.c:215
static void test_Next_walkList_2(void)
Definition: enum_files.c:191
static void teardown(void)
Definition: enum_files.c:124
static void test_Next_walkListNull(void)
Definition: enum_files.c:143
static void test_Next_walkList_1(void)
Definition: enum_files.c:163
static void test_GetCount(void)
Definition: enum_files.c:132
static void test_Skip_offEnd(void)
Definition: enum_files.c:242
static BOOL setup(void)
Definition: enum_files.c:92
static void test_Skip_walkList(void)
Definition: enum_files.c:226
static HRESULT test_create_manager(void)
Definition: enum_files.c:58
void(* test_t)(void)
Definition: enum_files.c:263
#define test
Definition: rosglue.h:37

◆ teardown()

static void teardown ( void  )
static

Definition at line 124 of file enum_files.c.

125{
126 IEnumBackgroundCopyFiles_Release(test_enumFiles);
127 IBackgroundCopyJob_Release(test_job);
128 IBackgroundCopyManager_Release(test_manager);
129}

Referenced by create_suite(), and START_TEST().

◆ test_create_manager()

static HRESULT test_create_manager ( void  )
static

Definition at line 58 of file enum_files.c.

59{
62
63 /* Creating BITS instance */
64 hres = CoCreateInstance(&CLSID_BackgroundCopyManager, NULL, CLSCTX_LOCAL_SERVER,
65 &IID_IBackgroundCopyManager, (void **) &manager);
66
68 win_skip("Needed Service is disabled\n");
69 return hres;
70 }
71
72 if (hres == S_OK)
73 {
75 GUID jobId;
76
77 hres = IBackgroundCopyManager_CreateJob(manager, L"Test", BG_JOB_TYPE_DOWNLOAD, &jobId, &job);
78 if (hres == S_OK)
79 {
80 hres = addFileHelper(job, L"localA", L"remoteA");
81 if (hres != S_OK)
82 win_skip("AddFile() with file:// protocol failed. Tests will be skipped.\n");
83 IBackgroundCopyJob_Release(job);
84 }
85 IBackgroundCopyManager_Release(manager);
86 }
87
88 return hres;
89}
static HRESULT HRESULT_FROM_WIN32(unsigned int x)
Definition: winerror.h:210
#define ERROR_SERVICE_DISABLED
Definition: winerror.h:933

Referenced by START_TEST().

◆ test_GetCount()

static void test_GetCount ( void  )
static

Definition at line 132 of file enum_files.c.

133{
135 ULONG fileCount;
136
137 hres = IEnumBackgroundCopyFiles_GetCount(test_enumFiles, &fileCount);
138 ok(hres == S_OK, "GetCount failed: %08lx\n", hres);
139 ok(fileCount == test_fileCount, "Got incorrect count\n");
140}
static const ULONG test_fileCount
Definition: enum_files.c:32
uint32_t ULONG
Definition: typedefs.h:59

Referenced by START_TEST().

◆ test_Next_errors()

static void test_Next_errors ( void  )
static

Definition at line 215 of file enum_files.c.

216{
219
220 /* E_INVALIDARG: pceltFetched can ONLY be NULL if celt is 1 */
221 hres = IEnumBackgroundCopyFiles_Next(test_enumFiles, 2, files, NULL);
222 ok(hres == E_INVALIDARG, "Invalid call to Next succeeded: %08lx\n", hres);
223}
#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 163 of file enum_files.c.

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

Referenced by START_TEST().

◆ test_Next_walkList_2()

static void test_Next_walkList_2 ( void  )
static

Definition at line 191 of file enum_files.c.

192{
195 ULONG fetched;
196 ULONG i;
197
198 for (i = 0; i < test_fileCount; i++)
199 files[i] = NULL;
200
201 fetched = 0;
202 hres = IEnumBackgroundCopyFiles_Next(test_enumFiles, test_fileCount, files, &fetched);
203 ok(hres == S_OK, "Next failed: %08lx\n", hres);
204 ok(fetched == test_fileCount, "Next returned the incorrect number of files: %08lx\n", hres);
205
206 for (i = 0; i < test_fileCount; i++)
207 {
208 ok(files[i] != NULL, "Next returned NULL\n");
209 if (files[i])
210 IBackgroundCopyFile_Release(files[i]);
211 }
212}

Referenced by START_TEST().

◆ test_Next_walkListNull()

static void test_Next_walkListNull ( void  )
static

Definition at line 143 of file enum_files.c.

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

Referenced by START_TEST().

◆ test_Reset()

static void test_Reset ( void  )
static

Definition at line 251 of file enum_files.c.

252{
254
255 hres = IEnumBackgroundCopyFiles_Skip(test_enumFiles, test_fileCount);
256 ok(hres == S_OK, "Skip failed: %08lx\n", hres);
257 hres = IEnumBackgroundCopyFiles_Reset(test_enumFiles);
258 ok(hres == S_OK, "Reset failed: %08lx\n", hres);
259 hres = IEnumBackgroundCopyFiles_Skip(test_enumFiles, test_fileCount);
260 ok(hres == S_OK, "Reset failed: %08lx\n", hres);
261}

Referenced by START_TEST().

◆ test_Skip_offEnd()

static void test_Skip_offEnd ( void  )
static

Definition at line 242 of file enum_files.c.

243{
245
246 hres = IEnumBackgroundCopyFiles_Skip(test_enumFiles, test_fileCount + 1);
247 ok(hres == S_FALSE, "Skip expected end of list: %08lx\n", hres);
248}

Referenced by START_TEST().

◆ test_Skip_walkList()

static void test_Skip_walkList ( void  )
static

Definition at line 226 of file enum_files.c.

227{
229 ULONG i;
230
231 for (i = 0; i < test_fileCount; i++)
232 {
233 hres = IEnumBackgroundCopyFiles_Skip(test_enumFiles, 1);
234 ok(hres == S_OK, "Skip failed: %08lx\n", hres);
235 }
236
237 hres = IEnumBackgroundCopyFiles_Skip(test_enumFiles, 1);
238 ok(hres == S_FALSE, "Skip expected end of list: %08lx\n", hres);
239}

Referenced by START_TEST().

Variable Documentation

◆ test_enumFiles

◆ test_fileCount

◆ test_job

IBackgroundCopyJob* test_job
static

Definition at line 33 of file enum_files.c.

Referenced by setup(), and teardown().

◆ test_manager

Definition at line 34 of file enum_files.c.