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

Go to the source code of this file.

Macros

#define COBJMACROS
 

Functions

static HRESULT test_create_manager (void)
 
static void test_CreateJob (void)
 
static void test_EnumJobs (void)
 
static void run_child (WCHAR *secret)
 
static void do_child (const char *secretA)
 
static void test_globalness (void)
 
 START_TEST (qmgr)
 

Variables

static WCHAR progname [MAX_PATH]
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 23 of file qmgr.c.

Function Documentation

◆ do_child()

static void do_child ( const char *  secretA)
static

Definition at line 117 of file qmgr.c.

118{
119 WCHAR secretW[MAX_PATH];
120 IBackgroundCopyManager *manager = NULL;
121 GUID id;
124 hres = CoCreateInstance(&CLSID_BackgroundCopyManager, NULL,
125 CLSCTX_LOCAL_SERVER, &IID_IBackgroundCopyManager,
126 (void **) &manager);
127 ok(hres == S_OK, "got 0x%08lx\n", hres);
128
129 MultiByteToWideChar(CP_ACP, 0, secretA, -1, secretW, MAX_PATH);
130 hres = IBackgroundCopyManager_CreateJob(manager, secretW,
131 BG_JOB_TYPE_DOWNLOAD, &id, &job);
132 ok(hres == S_OK, "CreateJob in child process\n");
133 IBackgroundCopyJob_Release(job);
134 IBackgroundCopyManager_Release(manager);
135}
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, IUnknown *outer, DWORD cls_context, REFIID riid, void **obj)
Definition: combase.c:1685
#define CP_ACP
Definition: compat.h:109
#define MAX_PATH
Definition: compat.h:34
#define MultiByteToWideChar
Definition: compat.h:110
GLuint id
Definition: glext.h:5910
#define S_OK
Definition: intsafe.h:52
HRESULT hres
Definition: protocol.c:432
static HANDLE job
Definition: process.c:79
short WCHAR
Definition: pedump.c:58

◆ run_child()

static void run_child ( WCHAR *  secret)
static

Definition at line 101 of file qmgr.c.

102{
106
107 memset(&startup, 0, sizeof startup);
108 startup.cb = sizeof startup;
109
110 wsprintfW(cmdline, L"%s qmgr %s", progname, secret);
111 ok(CreateProcessW(NULL, cmdline, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess\n");
112 wait_child_process(info.hProcess);
113 ok(CloseHandle(info.hProcess), "CloseHandle\n");
114 ok(CloseHandle(info.hThread), "CloseHandle\n");
115}
static void startup(void)
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessW(LPCWSTR lpApplicationName, LPWSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCWSTR lpCurrentDirectory, LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
Definition: proc.c:4491
#define L(x)
Definition: resources.c:13
static WCHAR progname[MAX_PATH]
Definition: qmgr.c:28
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
#define wait_child_process
Definition: test.h:161
#define memset(x, y, z)
Definition: compat.h:39
TCHAR * cmdline
Definition: stretchblt.cpp:32

Referenced by test_globalness().

◆ START_TEST()

START_TEST ( qmgr  )

Definition at line 181 of file qmgr.c.

182{
183 char **argv;
186
188
190 {
191 win_skip("Failed to create Manager instance, skipping tests\n");
193 return;
194 }
195
196 if (argc == 3)
197 do_child(argv[2]);
198 else
199 {
203 }
205}
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: combase.c:2842
MonoAssembly int argc
Definition: metahost.c:107
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:531
#define FAILED(hr)
Definition: intsafe.h:51
#define win_skip
Definition: minitest.h:67
static void test_CreateJob(void)
Definition: qmgr.c:50
static void test_globalness(void)
Definition: qmgr.c:137
static void test_EnumJobs(void)
Definition: qmgr.c:74
static HRESULT test_create_manager(void)
Definition: qmgr.c:30
static void do_child(void)
Definition: cursoricon.c:358
#define argv
Definition: mplay32.c:18
int winetest_get_mainargs(char ***pargv)

◆ test_create_manager()

static HRESULT test_create_manager ( void  )
static

Definition at line 30 of file qmgr.c.

31{
34
35 /* Creating BITS instance */
36 hres = CoCreateInstance(&CLSID_BackgroundCopyManager, NULL, CLSCTX_LOCAL_SERVER,
37 &IID_IBackgroundCopyManager, (void **) &manager);
38
40 win_skip("Needed Service is disabled\n");
41 return hres;
42 }
43
44 if (hres == S_OK)
45 IBackgroundCopyManager_Release(manager);
46
47 return hres;
48}
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_CreateJob()

static void test_CreateJob ( void  )
static

Definition at line 50 of file qmgr.c.

51{
52 /* Job information */
54 GUID tmpId;
56 ULONG res;
58
59 /* Setup */
60 hres = CoCreateInstance(&CLSID_BackgroundCopyManager, NULL,
61 CLSCTX_LOCAL_SERVER, &IID_IBackgroundCopyManager,
62 (void **) &manager);
63 ok(hres == S_OK, "got 0x%08lx\n", hres);
64
65 /* Create bits job */
66 hres = IBackgroundCopyManager_CreateJob(manager, L"Test", BG_JOB_TYPE_DOWNLOAD, &tmpId, &job);
67 ok(hres == S_OK, "CreateJob failed: %08lx\n", hres);
68
69 res = IBackgroundCopyJob_Release(job);
70 ok(res == 0, "Bad ref count on release: %lu\n", res);
71 IBackgroundCopyManager_Release(manager);
72}
GLuint res
Definition: glext.h:9613
uint32_t ULONG
Definition: typedefs.h:59

Referenced by START_TEST().

◆ test_EnumJobs()

static void test_EnumJobs ( void  )
static

Definition at line 74 of file qmgr.c.

75{
76 /* Job Enumerator */
81 GUID tmpId;
82
83 /* Setup */
84 hres = CoCreateInstance(&CLSID_BackgroundCopyManager, NULL,
85 CLSCTX_LOCAL_SERVER, &IID_IBackgroundCopyManager,
86 (void **) &manager);
87 ok(hres == S_OK, "got 0x%08lx\n", hres);
88
89 hres = IBackgroundCopyManager_CreateJob(manager, L"Test", BG_JOB_TYPE_DOWNLOAD, &tmpId, &job);
90 ok(hres == S_OK, "got 0x%08lx\n", hres);
91
92 hres = IBackgroundCopyManager_EnumJobs(manager, 0, &enumJobs);
93 ok(hres == S_OK, "EnumJobs failed: %08lx\n", hres);
94 IEnumBackgroundCopyJobs_Release(enumJobs);
95
96 /* Tear down */
97 IBackgroundCopyJob_Release(job);
98 IBackgroundCopyManager_Release(manager);
99}

Referenced by START_TEST().

◆ test_globalness()

static void test_globalness ( void  )
static

Definition at line 137 of file qmgr.c.

138{
139 WCHAR secretName[MAX_PATH];
140 IEnumBackgroundCopyJobs* enumJobs;
141 IBackgroundCopyManager *manager = NULL;
143 hres = CoCreateInstance(&CLSID_BackgroundCopyManager, NULL,
144 CLSCTX_LOCAL_SERVER, &IID_IBackgroundCopyManager,
145 (void **) &manager);
146 ok(hres == S_OK, "got 0x%08lx\n", hres);
147
148 wsprintfW(secretName, L"test_%u", GetTickCount());
149 run_child(secretName);
150
151 hres = IBackgroundCopyManager_EnumJobs(manager, 0, &enumJobs);
152 ok(hres == S_OK, "EnumJobs failed: %08lx\n", hres);
153 if(hres != S_OK)
154 skip("Unable to create job enumerator.\n");
155 else
156 {
157 ULONG i, n;
159 BOOL found = FALSE;
160
161 hres = IEnumBackgroundCopyJobs_GetCount(enumJobs, &n);
162 ok(hres == S_OK, "GetCount failed: %08lx\n", hres);
163 for (i = 0; i < n && !found; ++i)
164 {
165 LPWSTR name;
166 IEnumBackgroundCopyJobs_Next(enumJobs, 1, &job, NULL);
167 IBackgroundCopyJob_GetDisplayName(job, &name);
168 if (lstrcmpW(name, secretName) == 0)
169 found = TRUE;
171 IBackgroundCopyJob_Release(job);
172 }
173
174 IEnumBackgroundCopyJobs_Release(enumJobs);
175 ok(found, "Adding a job in another process failed\n");
176 }
177
178 IBackgroundCopyManager_Release(manager);
179}
#define skip(...)
Definition: atltest.h:64
#define TRUE
Definition: types.h:120
void WINAPI CoTaskMemFree(void *ptr)
Definition: malloc.c:389
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4152
ULONG WINAPI DECLSPEC_HOTPATCH GetTickCount(void)
Definition: sync.c:182
unsigned int BOOL
Definition: ntddk_ex.h:94
GLdouble n
Definition: glext.h:7729
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 void run_child(WCHAR *secret)
Definition: qmgr.c:101
Definition: name.c:39
uint16_t * LPWSTR
Definition: typedefs.h:56

Referenced by START_TEST().

Variable Documentation

◆ progname

WCHAR progname[MAX_PATH]
static

Definition at line 28 of file qmgr.c.

Referenced by run_child(), and START_TEST().