ReactOS  0.4.14-dev-293-g2b39b42
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 }
static HANDLE job
Definition: process.c:77
#define URL_UNESCAPE_INPLACE
Definition: shlwapi.h:1224
#define GetCurrentDirectoryW(x, y)
Definition: compat.h:413
BOOL WINAPI PathAppendW(LPWSTR lpszPath, LPCWSTR lpszAppend)
Definition: path.c:121
HRESULT WINAPI UrlUnescapeW(LPWSTR pszUrl, LPWSTR pszUnescaped, LPDWORD pcchUnescaped, DWORD dwFlags)
Definition: url.c:1367
smooth NULL
Definition: ftsmooth.c:416
HRESULT WINAPI UrlCreateFromPathW(LPCWSTR pszPath, LPWSTR pszUrl, LPDWORD pcchUrl, DWORD dwReserved)
Definition: url.c:2497
static WCHAR test_localFile[MAX_PATH]
Definition: file.c:33
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
static WCHAR test_remoteUrl[MAX_PATH]
Definition: file.c:34

Referenced by setup(), and test_create_manager().

◆ setup()

static BOOL setup ( void  )
static

Definition at line 94 of file file.c.

95 {
96  HRESULT hres;
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 }
static const WCHAR test_remoteName[]
Definition: file.c:31
#define TRUE
Definition: types.h:120
static IBackgroundCopyFile * test_file
Definition: file.c:39
static GUID test_jobId
Definition: job.c:39
static IEnumBackgroundCopyFiles * test_enumFiles
Definition: file.c:38
smooth NULL
Definition: ftsmooth.c:416
static HRESULT addFileHelper(IBackgroundCopyJob *job, const WCHAR *localName, const WCHAR *remoteName)
Definition: file.c:44
static IBackgroundCopyManager * test_manager
Definition: file.c:37
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static const WCHAR test_displayName[]
Definition: file.c:35
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
static const WCHAR test_localName[]
Definition: file.c:32
#define S_OK
Definition: intsafe.h:59
#define memset(x, y, z)
Definition: compat.h:39
static IBackgroundCopyJob * test_job
Definition: file.c:36

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  {
202  CoUninitialize();
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  }
218  CoUninitialize();
219 }
struct param_test tests[]
static HRESULT test_create_manager(void)
Definition: file.c:60
static void test_GetLocalName(void)
Definition: file.c:159
static void test_GetProgress_PreTransfer(void)
Definition: file.c:171
#define test
Definition: rosglue.h:37
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 BOOL setup(void)
Definition: file.c:94
smooth NULL
Definition: ftsmooth.c:416
static void teardown(void)
Definition: file.c:138
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
static void test_GetRemoteName(void)
Definition: file.c:147
#define ok(value,...)
Definition: atltest.h:57
void(* test_t)(void)
Definition: file.c:185
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
#define win_skip
Definition: test.h:141

◆ 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 }
static IBackgroundCopyFile * test_file
Definition: file.c:39
static IEnumBackgroundCopyFiles * test_enumFiles
Definition: file.c:38
static IBackgroundCopyManager * test_manager
Definition: file.c:37
static IBackgroundCopyJob * test_job
Definition: file.c:36

Referenced by START_TEST().

◆ test_create_manager()

static HRESULT test_create_manager ( void  )
static

Definition at line 60 of file file.c.

61 {
62  HRESULT hres;
63  IBackgroundCopyManager *manager = NULL;
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 }
static HANDLE job
Definition: process.c:77
static const WCHAR test_remoteName[]
Definition: file.c:31
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
#define ERROR_SERVICE_DISABLED
Definition: winerror.h:609
smooth NULL
Definition: ftsmooth.c:416
static HRESULT addFileHelper(IBackgroundCopyJob *job, const WCHAR *localName, const WCHAR *remoteName)
Definition: file.c:44
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static const WCHAR test_displayName[]
Definition: file.c:35
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
static const WCHAR test_localName[]
Definition: file.c:32
#define S_OK
Definition: intsafe.h:59
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test_GetLocalName()

static void test_GetLocalName ( void  )
static

Definition at line 159 of file file.c.

160 {
161  HRESULT hres;
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 }
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:420
static IBackgroundCopyFile * test_file
Definition: file.c:39
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static WCHAR test_localFile[MAX_PATH]
Definition: file.c:33
#define S_OK
Definition: intsafe.h:59
#define ok(value,...)
Definition: atltest.h:57
Definition: name.c:36
WCHAR * LPWSTR
Definition: xmlstorage.h:184
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by START_TEST().

◆ test_GetProgress_PreTransfer()

static void test_GetProgress_PreTransfer ( void  )
static

Definition at line 171 of file file.c.

172 {
173  HRESULT hres;
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 }
static IBackgroundCopyFile * test_file
Definition: file.c:39
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
#define S_OK
Definition: intsafe.h:59
#define ok(value,...)
Definition: atltest.h:57
cd_progress_ptr progress
Definition: cdjpeg.h:150
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:41

Referenced by START_TEST().

◆ test_GetRemoteName()

static void test_GetRemoteName ( void  )
static

Definition at line 147 of file file.c.

148 {
149  HRESULT hres;
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 }
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:420
static IBackgroundCopyFile * test_file
Definition: file.c:39
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static WCHAR test_remoteUrl[MAX_PATH]
Definition: file.c:34
#define S_OK
Definition: intsafe.h:59
#define ok(value,...)
Definition: atltest.h:57
Definition: name.c:36
WCHAR * LPWSTR
Definition: xmlstorage.h:184
GLuint const GLchar * name
Definition: glext.h:6031

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

IBackgroundCopyManager* test_manager
static

Definition at line 37 of file file.c.

Referenced by setup(), and teardown().

◆ 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().