qmgr: Implement IBackgroundCopyJob_AddFile.
This commit is contained in:
parent
128654ba08
commit
be8bac15fd
|
@ -80,8 +80,25 @@ static HRESULT WINAPI BITS_IBackgroundCopyJob_AddFile(
|
||||||
LPCWSTR RemoteUrl,
|
LPCWSTR RemoteUrl,
|
||||||
LPCWSTR LocalName)
|
LPCWSTR LocalName)
|
||||||
{
|
{
|
||||||
FIXME("Not implemented\n");
|
BackgroundCopyJobImpl *This = (BackgroundCopyJobImpl *) iface;
|
||||||
return E_NOTIMPL;
|
IBackgroundCopyFile *pFile;
|
||||||
|
BackgroundCopyFileImpl *file;
|
||||||
|
HRESULT res;
|
||||||
|
|
||||||
|
/* We should return E_INVALIDARG in these cases. */
|
||||||
|
FIXME("Check for valid filenames and supported protocols\n");
|
||||||
|
|
||||||
|
res = BackgroundCopyFileConstructor(RemoteUrl, LocalName, (LPVOID *) &pFile);
|
||||||
|
if (res != S_OK)
|
||||||
|
return res;
|
||||||
|
|
||||||
|
/* Add a reference to the file to file list */
|
||||||
|
IBackgroundCopyFile_AddRef(pFile);
|
||||||
|
file = (BackgroundCopyFileImpl *) pFile;
|
||||||
|
list_add_head(&This->files, &file->entryFromJob);
|
||||||
|
++This->jobProgress.FilesTotal;
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI BITS_IBackgroundCopyJob_EnumFiles(
|
static HRESULT WINAPI BITS_IBackgroundCopyJob_EnumFiles(
|
||||||
|
@ -414,6 +431,12 @@ HRESULT BackgroundCopyJobConstructor(LPCWSTR displayName, BG_JOB_TYPE type,
|
||||||
}
|
}
|
||||||
memcpy(pJobId, &This->jobId, sizeof(GUID));
|
memcpy(pJobId, &This->jobId, sizeof(GUID));
|
||||||
|
|
||||||
|
list_init(&This->files);
|
||||||
|
This->jobProgress.BytesTotal = BG_SIZE_UNKNOWN;
|
||||||
|
This->jobProgress.BytesTransferred = 0;
|
||||||
|
This->jobProgress.FilesTotal = 0;
|
||||||
|
This->jobProgress.FilesTransferred = 0;
|
||||||
|
|
||||||
*ppObj = &This->lpVtbl;
|
*ppObj = &This->lpVtbl;
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include "bits.h"
|
#include "bits.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include "wine/list.h"
|
||||||
|
|
||||||
/* Background copy job vtbl and related data */
|
/* Background copy job vtbl and related data */
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -37,6 +38,8 @@ typedef struct
|
||||||
LPWSTR displayName;
|
LPWSTR displayName;
|
||||||
BG_JOB_TYPE type;
|
BG_JOB_TYPE type;
|
||||||
GUID jobId;
|
GUID jobId;
|
||||||
|
struct list files;
|
||||||
|
BG_JOB_PROGRESS jobProgress;
|
||||||
} BackgroundCopyJobImpl;
|
} BackgroundCopyJobImpl;
|
||||||
|
|
||||||
/* Enum background copy jobs vtbl and related data */
|
/* Enum background copy jobs vtbl and related data */
|
||||||
|
@ -52,6 +55,7 @@ typedef struct
|
||||||
const IBackgroundCopyFileVtbl *lpVtbl;
|
const IBackgroundCopyFileVtbl *lpVtbl;
|
||||||
LONG ref;
|
LONG ref;
|
||||||
BG_FILE_INFO info;
|
BG_FILE_INFO info;
|
||||||
|
struct list entryFromJob;
|
||||||
} BackgroundCopyFileImpl;
|
} BackgroundCopyFileImpl;
|
||||||
|
|
||||||
/* Background copy manager vtbl and related data */
|
/* Background copy manager vtbl and related data */
|
||||||
|
@ -73,6 +77,8 @@ HRESULT BackgroundCopyJobConstructor(LPCWSTR displayName, BG_JOB_TYPE type,
|
||||||
GUID *pJobId, LPVOID *ppObj);
|
GUID *pJobId, LPVOID *ppObj);
|
||||||
HRESULT EnumBackgroundCopyJobsConstructor(LPVOID *ppObj,
|
HRESULT EnumBackgroundCopyJobsConstructor(LPVOID *ppObj,
|
||||||
IBackgroundCopyManager* copyManager);
|
IBackgroundCopyManager* copyManager);
|
||||||
|
HRESULT BackgroundCopyFileConstructor(LPCWSTR remoteName,
|
||||||
|
LPCWSTR localName, LPVOID *ppObj);
|
||||||
|
|
||||||
/* Little helper functions */
|
/* Little helper functions */
|
||||||
static inline char *
|
static inline char *
|
||||||
|
|
|
@ -3,7 +3,7 @@ TOPOBJDIR = ../../..
|
||||||
SRCDIR = @srcdir@
|
SRCDIR = @srcdir@
|
||||||
VPATH = @srcdir@
|
VPATH = @srcdir@
|
||||||
TESTDLL = qmgr.dll
|
TESTDLL = qmgr.dll
|
||||||
IMPORTS = ole32 kernel32
|
IMPORTS = ole32 user32 kernel32
|
||||||
|
|
||||||
CTESTS = \
|
CTESTS = \
|
||||||
job.c \
|
job.c \
|
||||||
|
|
|
@ -27,11 +27,67 @@
|
||||||
|
|
||||||
/* Globals used by many tests */
|
/* Globals used by many tests */
|
||||||
static const WCHAR test_displayName[] = {'T', 'e', 's', 't', 0};
|
static const WCHAR test_displayName[] = {'T', 'e', 's', 't', 0};
|
||||||
|
static const WCHAR test_remoteNameA[] = {'r','e','m','o','t','e','A', 0};
|
||||||
|
static const WCHAR test_remoteNameB[] = {'r','e','m','o','t','e','B', 0};
|
||||||
|
static const WCHAR test_localNameA[] = {'l','o','c','a','l','A', 0};
|
||||||
|
static const WCHAR test_localNameB[] = {'l','o','c','a','l','B', 0};
|
||||||
|
static WCHAR *test_currentDir;
|
||||||
|
static WCHAR *test_remotePathA;
|
||||||
|
static WCHAR *test_remotePathB;
|
||||||
|
static WCHAR *test_localPathA;
|
||||||
|
static WCHAR *test_localPathB;
|
||||||
static IBackgroundCopyManager *test_manager;
|
static IBackgroundCopyManager *test_manager;
|
||||||
static IBackgroundCopyJob *test_job;
|
static IBackgroundCopyJob *test_job;
|
||||||
static GUID test_jobId;
|
static GUID test_jobId;
|
||||||
static BG_JOB_TYPE test_type;
|
static BG_JOB_TYPE test_type;
|
||||||
|
|
||||||
|
static BOOL init_paths(void)
|
||||||
|
{
|
||||||
|
static const WCHAR format[] = {'%','s','\\','%','s', 0};
|
||||||
|
DWORD n;
|
||||||
|
|
||||||
|
n = GetCurrentDirectoryW(0, NULL);
|
||||||
|
if (n == 0)
|
||||||
|
{
|
||||||
|
skip("Couldn't get current directory size\n");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
test_currentDir = HeapAlloc(GetProcessHeap(), 0, n * sizeof(WCHAR));
|
||||||
|
test_localPathA
|
||||||
|
= HeapAlloc(GetProcessHeap(), 0,
|
||||||
|
(n + 1 + lstrlenW(test_localNameA)) * sizeof(WCHAR));
|
||||||
|
test_localPathB
|
||||||
|
= HeapAlloc(GetProcessHeap(), 0,
|
||||||
|
(n + 1 + lstrlenW(test_localNameB)) * sizeof(WCHAR));
|
||||||
|
test_remotePathA
|
||||||
|
= HeapAlloc(GetProcessHeap(), 0,
|
||||||
|
(n + 1 + lstrlenW(test_remoteNameA)) * sizeof(WCHAR));
|
||||||
|
test_remotePathB
|
||||||
|
= HeapAlloc(GetProcessHeap(), 0,
|
||||||
|
(n + 1 + lstrlenW(test_remoteNameB)) * sizeof(WCHAR));
|
||||||
|
|
||||||
|
if (!test_currentDir || !test_localPathA || !test_localPathB
|
||||||
|
|| !test_remotePathA || !test_remotePathB)
|
||||||
|
{
|
||||||
|
skip("Couldn't allocate memory for full paths\n");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GetCurrentDirectoryW(n, test_currentDir) != n - 1)
|
||||||
|
{
|
||||||
|
skip("Couldn't get current directory\n");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
wsprintfW(test_localPathA, format, test_currentDir, test_localNameA);
|
||||||
|
wsprintfW(test_localPathB, format, test_currentDir, test_localNameB);
|
||||||
|
wsprintfW(test_remotePathA, format, test_currentDir, test_remoteNameA);
|
||||||
|
wsprintfW(test_remotePathB, format, test_currentDir, test_remoteNameB);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/* Generic test setup */
|
/* Generic test setup */
|
||||||
static BOOL setup(void)
|
static BOOL setup(void)
|
||||||
{
|
{
|
||||||
|
@ -116,6 +172,25 @@ static void test_GetName(void)
|
||||||
CoTaskMemFree(displayName);
|
CoTaskMemFree(displayName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Test adding a file */
|
||||||
|
static void test_AddFile(void)
|
||||||
|
{
|
||||||
|
HRESULT hres;
|
||||||
|
|
||||||
|
hres = IBackgroundCopyJob_AddFile(test_job, test_remotePathA,
|
||||||
|
test_localPathA);
|
||||||
|
ok(hres == S_OK, "First call to AddFile failed: 0x%08x\n", hres);
|
||||||
|
if (hres != S_OK)
|
||||||
|
{
|
||||||
|
skip("Unable to add first file to job\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
hres = IBackgroundCopyJob_AddFile(test_job, test_remotePathB,
|
||||||
|
test_localPathB);
|
||||||
|
ok(hres == S_OK, "Second call to AddFile failed: 0x%08x\n", hres);
|
||||||
|
}
|
||||||
|
|
||||||
typedef void (*test_t)(void);
|
typedef void (*test_t)(void);
|
||||||
|
|
||||||
START_TEST(job)
|
START_TEST(job)
|
||||||
|
@ -124,10 +199,14 @@ START_TEST(job)
|
||||||
test_GetId,
|
test_GetId,
|
||||||
test_GetType,
|
test_GetType,
|
||||||
test_GetName,
|
test_GetName,
|
||||||
|
test_AddFile,
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
const test_t *test;
|
const test_t *test;
|
||||||
|
|
||||||
|
if (!init_paths())
|
||||||
|
return;
|
||||||
|
|
||||||
CoInitialize(NULL);
|
CoInitialize(NULL);
|
||||||
for (test = tests; *test; ++test)
|
for (test = tests; *test; ++test)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue