ReactOS 0.4.17-dev-966-gf06eace
file.c File Reference
#include <stdio.h>
#include <shlwapi.h>
#include "wine/test.h"
#include "bits.h"
Include dependency graph for file.c:

Go to the source code of this file.

Macros

#define COBJMACROS
 

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_GetRemoteName (void)
 
static void test_GetLocalName (void)
 
static void test_GetProgress_PreTransfer (void)
 
 START_TEST (file)
 

Variables

static WCHAR test_localFile [MAX_PATH]
 
static WCHAR test_remoteUrl [MAX_PATH]
 
static IBackgroundCopyJob * test_job
 
static IBackgroundCopyManager * test_manager
 
static IEnumBackgroundCopyFiles * test_enumFiles
 
static IBackgroundCopyFile * test_file
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 25 of file file.c.

Typedef Documentation

◆ test_t

typedef void(* test_t) (void)

Definition at line 182 of file file.c.

Function Documentation

◆ addFileHelper()

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

Definition at line 41 of file file.c.

43{
44 DWORD urlSize;
45
47 PathAppendW(test_localFile, localName);
49 PathAppendW(test_remoteUrl, remoteName);
50 urlSize = MAX_PATH;
53
54 return IBackgroundCopyJob_AddFile(job, test_remoteUrl, test_localFile);
55}
#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
static WCHAR test_remoteUrl[MAX_PATH]
Definition: file.c:32
static WCHAR test_localFile[MAX_PATH]
Definition: file.c:31
#define PathAppendW
Definition: pathcch.h:310
#define URL_UNESCAPE_INPLACE
Definition: shlwapi.h:525

Referenced by setup(), and test_create_manager().

◆ setup()

static BOOL setup ( void  )
static

Definition at line 91 of file file.c.

92{
95
97 test_job = NULL;
98 memset(&test_jobId, 0, sizeof test_jobId);
99
100 hres = CoCreateInstance(&CLSID_BackgroundCopyManager, NULL,
101 CLSCTX_LOCAL_SERVER, &IID_IBackgroundCopyManager,
102 (void **) &test_manager);
103 if(hres != S_OK)
104 return FALSE;
105
106 hres = IBackgroundCopyManager_CreateJob(test_manager, L"Test",
107 BG_JOB_TYPE_DOWNLOAD, &test_jobId, &test_job);
108 if(hres != S_OK)
109 {
110 IBackgroundCopyManager_Release(test_manager);
111 return FALSE;
112 }
113
114 if (addFileHelper(test_job, L"local", L"remote") != S_OK
115 || IBackgroundCopyJob_EnumFiles(test_job, &test_enumFiles) != S_OK)
116 {
117 IBackgroundCopyJob_Release(test_job);
118 IBackgroundCopyManager_Release(test_manager);
119 return FALSE;
120 }
121
122 hres = IEnumBackgroundCopyFiles_Next(test_enumFiles, 1, &test_file, NULL);
123 if(hres != S_OK)
124 {
125 IEnumBackgroundCopyFiles_Release(test_enumFiles);
126 IBackgroundCopyJob_Release(test_job);
127 IBackgroundCopyManager_Release(test_manager);
128 return FALSE;
129 }
130
131 return TRUE;
132}
#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: file.c:35
static HRESULT addFileHelper(IBackgroundCopyJob *job, const WCHAR *localName, const WCHAR *remoteName)
Definition: file.c:41
static IBackgroundCopyJob * test_job
Definition: file.c:33
static IBackgroundCopyFile * test_file
Definition: file.c:36
static GUID test_jobId
Definition: job.c:39
#define memset(x, y, z)
Definition: compat.h:39

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( file  )

Definition at line 184 of file file.c.

185{
186 static const test_t tests[] = {
190 0
191 };
192 const test_t *test;
193 int i;
194
196
198 {
200 win_skip("Failed to create Manager instance, skipping tests\n");
201 return;
202 }
203
204 for (test = tests, i = 0; *test; ++test, ++i)
205 {
206 /* Keep state separate between tests. */
207 if (!setup())
208 {
209 ok(0, "tests:%d: Unable to setup test\n", i);
210 break;
211 }
212 (*test)();
213 teardown();
214 }
216}
#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 teardown(void)
Definition: file.c:135
static void test_GetProgress_PreTransfer(void)
Definition: file.c:168
static BOOL setup(void)
Definition: file.c:91
static void test_GetLocalName(void)
Definition: file.c:156
static void test_GetRemoteName(void)
Definition: file.c:144
static HRESULT test_create_manager(void)
Definition: file.c:57
void(* test_t)(void)
Definition: file.c:182
#define test
Definition: rosglue.h:37

◆ teardown()

static void teardown ( void  )
static

Definition at line 135 of file file.c.

136{
137 IBackgroundCopyFile_Release(test_file);
138 IEnumBackgroundCopyFiles_Release(test_enumFiles);
139 IBackgroundCopyJob_Release(test_job);
140 IBackgroundCopyManager_Release(test_manager);
141}

Referenced by START_TEST().

◆ test_create_manager()

static HRESULT test_create_manager ( void  )
static

Definition at line 57 of file file.c.

58{
61
62 /* Creating BITS instance */
63 hres = CoCreateInstance(&CLSID_BackgroundCopyManager, NULL, CLSCTX_LOCAL_SERVER,
64 &IID_IBackgroundCopyManager, (void **) &manager);
65
67 win_skip("Needed Service is disabled\n");
68 return hres;
69 }
70
71 if (hres == S_OK)
72 {
74 GUID jobId;
75
76 hres = IBackgroundCopyManager_CreateJob(manager, L"Test", BG_JOB_TYPE_DOWNLOAD, &jobId, &job);
77 if (hres == S_OK)
78 {
79 hres = addFileHelper(job, L"local", L"remote");
80 if (hres != S_OK)
81 win_skip("AddFile() with file:// protocol failed. Tests will be skipped.\n");
82 IBackgroundCopyJob_Release(job);
83 }
84 IBackgroundCopyManager_Release(manager);
85 }
86
87 return hres;
88}
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_GetLocalName()

static void test_GetLocalName ( void  )
static

Definition at line 156 of file file.c.

157{
159 LPWSTR name;
160
161 hres = IBackgroundCopyFile_GetLocalName(test_file, &name);
162 ok(hres == S_OK, "GetLocalName failed: %08lx\n", hres);
163 ok(lstrcmpW(name, test_localFile) == 0, "Got incorrect local name\n");
165}
void WINAPI CoTaskMemFree(void *ptr)
Definition: malloc.c:389
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4152
Definition: name.c:39
uint16_t * LPWSTR
Definition: typedefs.h:56

Referenced by START_TEST().

◆ test_GetProgress_PreTransfer()

static void test_GetProgress_PreTransfer ( void  )
static

Definition at line 168 of file file.c.

169{
171 BG_FILE_PROGRESS progress;
172
173 hres = IBackgroundCopyFile_GetProgress(test_file, &progress);
174 ok(hres == S_OK, "GetProgress failed: %08lx\n", hres);
175 ok(progress.BytesTotal == BG_SIZE_UNKNOWN, "Got incorrect total size: %s\n",
176 wine_dbgstr_longlong(progress.BytesTotal));
177 ok(progress.BytesTransferred == 0, "Got incorrect number of transferred bytes: %s\n",
178 wine_dbgstr_longlong(progress.BytesTransferred));
179 ok(progress.Completed == FALSE, "Got incorrect completion status\n");
180}
cd_progress_ptr progress
Definition: cdjpeg.h:152
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49

Referenced by START_TEST().

◆ test_GetRemoteName()

static void test_GetRemoteName ( void  )
static

Definition at line 144 of file file.c.

145{
147 LPWSTR name;
148
149 hres = IBackgroundCopyFile_GetRemoteName(test_file, &name);
150 ok(hres == S_OK, "GetRemoteName failed: %08lx\n", hres);
151 ok(lstrcmpW(name, test_remoteUrl) == 0, "Got incorrect remote name\n");
153}

Referenced by START_TEST().

Variable Documentation

◆ test_enumFiles

IEnumBackgroundCopyFiles* test_enumFiles
static

Definition at line 35 of file file.c.

Referenced by setup(), and teardown().

◆ test_file

◆ test_job

IBackgroundCopyJob* test_job
static

Definition at line 33 of file file.c.

Referenced by setup(), and teardown().

◆ test_localFile

WCHAR test_localFile[MAX_PATH]
static

Definition at line 31 of file file.c.

Referenced by addFileHelper(), and test_GetLocalName().

◆ test_manager

Definition at line 34 of file file.c.

◆ test_remoteUrl

WCHAR test_remoteUrl[MAX_PATH]
static

Definition at line 32 of file file.c.

Referenced by addFileHelper(), and test_GetRemoteName().