ReactOS 0.4.15-dev-8119-g4fb2fdb
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 const WCHAR test_remoteName [] = {'r','e','m','o','t','e', 0}
 
static const WCHAR test_localName [] = {'l','o','c','a','l', 0}
 
static WCHAR test_localFile [MAX_PATH]
 
static WCHAR test_remoteUrl [MAX_PATH]
 
static const WCHAR test_displayName [] = {'T','e','s','t', 0}
 
static IBackgroundCopyJobtest_job
 
static IBackgroundCopyManagertest_manager
 
static IEnumBackgroundCopyFilestest_enumFiles
 
static IBackgroundCopyFiletest_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 185 of file file.c.

Function Documentation

◆ addFileHelper()

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

Definition at line 44 of file file.c.

46{
47 DWORD urlSize;
48
50 PathAppendW(test_localFile, localName);
52 PathAppendW(test_remoteUrl, remoteName);
53 urlSize = MAX_PATH;
56
57 return IBackgroundCopyJob_AddFile(job, test_remoteUrl, test_localFile);
58}
#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
static WCHAR test_remoteUrl[MAX_PATH]
Definition: file.c:34
static WCHAR test_localFile[MAX_PATH]
Definition: file.c:33
#define PathAppendW
Definition: pathcch.h:309
#define URL_UNESCAPE_INPLACE
Definition: shlwapi.h:1224

Referenced by setup(), and test_create_manager().

◆ setup()

static BOOL setup ( void  )
static

Definition at line 94 of file file.c.

95{
98
100 test_job = NULL;
101 memset(&test_jobId, 0, sizeof test_jobId);
102
103 hres = CoCreateInstance(&CLSID_BackgroundCopyManager, NULL,
104 CLSCTX_LOCAL_SERVER, &IID_IBackgroundCopyManager,
105 (void **) &test_manager);
106 if(hres != S_OK)
107 return FALSE;
108
109 hres = IBackgroundCopyManager_CreateJob(test_manager, test_displayName,
110 BG_JOB_TYPE_DOWNLOAD, &test_jobId, &test_job);
111 if(hres != S_OK)
112 {
113 IBackgroundCopyManager_Release(test_manager);
114 return FALSE;
115 }
116
118 || IBackgroundCopyJob_EnumFiles(test_job, &test_enumFiles) != S_OK)
119 {
120 IBackgroundCopyJob_Release(test_job);
121 IBackgroundCopyManager_Release(test_manager);
122 return FALSE;
123 }
124
125 hres = IEnumBackgroundCopyFiles_Next(test_enumFiles, 1, &test_file, NULL);
126 if(hres != S_OK)
127 {
128 IEnumBackgroundCopyFiles_Release(test_enumFiles);
129 IBackgroundCopyJob_Release(test_job);
130 IBackgroundCopyManager_Release(test_manager);
131 return FALSE;
132 }
133
134 return TRUE;
135}
#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: file.c:38
static const WCHAR test_localName[]
Definition: file.c:32
static const WCHAR test_remoteName[]
Definition: file.c:31
static HRESULT addFileHelper(IBackgroundCopyJob *job, const WCHAR *localName, const WCHAR *remoteName)
Definition: file.c:44
static IBackgroundCopyJob * test_job
Definition: file.c:36
static IBackgroundCopyFile * test_file
Definition: file.c:39
static const WCHAR test_displayName[]
Definition: file.c:35
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 187 of file file.c.

188{
189 static const test_t tests[] = {
193 0
194 };
195 const test_t *test;
196 int i;
197
199
201 {
203 win_skip("Failed to create Manager instance, skipping tests\n");
204 return;
205 }
206
207 for (test = tests, i = 0; *test; ++test, ++i)
208 {
209 /* Keep state separate between tests. */
210 if (!setup())
211 {
212 ok(0, "tests:%d: Unable to setup test\n", i);
213 break;
214 }
215 (*test)();
216 teardown();
217 }
219}
#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 teardown(void)
Definition: file.c:138
static void test_GetProgress_PreTransfer(void)
Definition: file.c:171
static BOOL setup(void)
Definition: file.c:94
static void test_GetLocalName(void)
Definition: file.c:159
static void test_GetRemoteName(void)
Definition: file.c:147
static HRESULT test_create_manager(void)
Definition: file.c:60
void(* test_t)(void)
Definition: file.c:185
#define test
Definition: rosglue.h:37
#define win_skip
Definition: test.h:163

◆ teardown()

static void teardown ( void  )
static

Definition at line 138 of file file.c.

139{
140 IBackgroundCopyFile_Release(test_file);
141 IEnumBackgroundCopyFiles_Release(test_enumFiles);
142 IBackgroundCopyJob_Release(test_job);
143 IBackgroundCopyManager_Release(test_manager);
144}

Referenced by START_TEST().

◆ test_create_manager()

static HRESULT test_create_manager ( void  )
static

Definition at line 60 of file file.c.

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

Referenced by START_TEST().

◆ test_GetLocalName()

static void test_GetLocalName ( void  )
static

Definition at line 159 of file file.c.

160{
162 LPWSTR name;
163
164 hres = IBackgroundCopyFile_GetLocalName(test_file, &name);
165 ok(hres == S_OK, "GetLocalName failed: %08x\n", hres);
166 ok(lstrcmpW(name, test_localFile) == 0, "Got incorrect local name\n");
168}
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4242
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
Definition: name.c:39
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by START_TEST().

◆ test_GetProgress_PreTransfer()

static void test_GetProgress_PreTransfer ( void  )
static

Definition at line 171 of file file.c.

172{
174 BG_FILE_PROGRESS progress;
175
176 hres = IBackgroundCopyFile_GetProgress(test_file, &progress);
177 ok(hres == S_OK, "GetProgress failed: %08x\n", hres);
178 ok(progress.BytesTotal == BG_SIZE_UNKNOWN, "Got incorrect total size: %s\n",
179 wine_dbgstr_longlong(progress.BytesTotal));
180 ok(progress.BytesTransferred == 0, "Got incorrect number of transferred bytes: %s\n",
181 wine_dbgstr_longlong(progress.BytesTransferred));
182 ok(progress.Completed == FALSE, "Got incorrect completion status\n");
183}
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 147 of file file.c.

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

Referenced by START_TEST().

Variable Documentation

◆ test_displayName

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

Definition at line 35 of file file.c.

Referenced by setup(), and test_create_manager().

◆ test_enumFiles

IEnumBackgroundCopyFiles* test_enumFiles
static

Definition at line 38 of file file.c.

Referenced by setup(), and teardown().

◆ test_file

◆ test_job

IBackgroundCopyJob* test_job
static

Definition at line 36 of file file.c.

Referenced by setup(), and teardown().

◆ test_localFile

WCHAR test_localFile[MAX_PATH]
static

Definition at line 33 of file file.c.

Referenced by addFileHelper(), and test_GetLocalName().

◆ test_localName

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

Definition at line 32 of file file.c.

Referenced by setup(), and test_create_manager().

◆ test_manager

Definition at line 37 of file file.c.

◆ test_remoteName

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

Definition at line 31 of file file.c.

Referenced by setup(), and test_create_manager().

◆ test_remoteUrl

WCHAR test_remoteUrl[MAX_PATH]
static

Definition at line 34 of file file.c.

Referenced by addFileHelper(), and test_GetRemoteName().