ReactOS  0.4.15-dev-1384-g878186b
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 125 of file qmgr.c.

126 {
127  WCHAR secretW[MAX_PATH];
128  IBackgroundCopyManager *manager = NULL;
129  GUID id;
131  HRESULT hres;
132  hres = CoCreateInstance(&CLSID_BackgroundCopyManager, NULL,
133  CLSCTX_LOCAL_SERVER, &IID_IBackgroundCopyManager,
134  (void **) &manager);
135  ok(hres == S_OK, "got 0x%08x\n", hres);
136 
137  MultiByteToWideChar(CP_ACP, 0, secretA, -1, secretW, MAX_PATH);
138  hres = IBackgroundCopyManager_CreateJob(manager, secretW,
139  BG_JOB_TYPE_DOWNLOAD, &id, &job);
140  ok(hres == S_OK, "CreateJob in child process\n");
141  IBackgroundCopyJob_Release(job);
142  IBackgroundCopyManager_Release(manager);
143 }
static HANDLE job
Definition: process.c:77
#define CP_ACP
Definition: compat.h:109
HRESULT hres
Definition: protocol.c:465
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
#define MAX_PATH
Definition: compat.h:34
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:51
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define MultiByteToWideChar
Definition: compat.h:110
GLenum GLuint id
Definition: glext.h:5579

Referenced by START_TEST().

◆ run_child()

static void run_child ( WCHAR secret)
static

Definition at line 108 of file qmgr.c.

109 {
110  static const WCHAR format[] = {'%','s',' ','q','m','g','r',' ','%','s', 0};
114 
115  memset(&startup, 0, sizeof startup);
116  startup.cb = sizeof startup;
117 
119  ok(CreateProcessW(NULL, cmdline, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess\n");
121  ok(CloseHandle(info.hProcess), "CloseHandle\n");
122  ok(CloseHandle(info.hThread), "CloseHandle\n");
123 }
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
#define CloseHandle
Definition: compat.h:598
static WCHAR progname[MAX_PATH]
Definition: qmgr.c:28
int startup(int argc, const char *argv[])
Definition: startup.c:430
TCHAR * cmdline
Definition: stretchblt.cpp:32
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define FALSE
Definition: types.h:117
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:4595
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:34
struct _test_info info[]
Definition: SetCursorPos.c:19
static UCHAR * secret
Definition: bcrypt.c:29
static const WCHAR L[]
Definition: oid.c:1250
void winetest_wait_child_process(HANDLE process)
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define memset(x, y, z)
Definition: compat.h:39

Referenced by test_globalness().

◆ START_TEST()

START_TEST ( qmgr  )

Definition at line 190 of file qmgr.c.

191 {
192  char **argv;
195 
197 
199  {
200  win_skip("Failed to create Manager instance, skipping tests\n");
201  CoUninitialize();
202  return;
203  }
204 
205  if (argc == 3)
206  do_child(argv[2]);
207  else
208  {
209  test_CreateJob();
210  test_EnumJobs();
211  test_globalness();
212  }
213  CoUninitialize();
214 }
static int argc
Definition: ServiceArgs.c:12
#define CP_ACP
Definition: compat.h:109
static WCHAR progname[MAX_PATH]
Definition: qmgr.c:28
static void do_child(const char *secretA)
Definition: qmgr.c:125
#define argv
Definition: mplay32.c:18
static void test_globalness(void)
Definition: qmgr.c:145
static void test_EnumJobs(void)
Definition: qmgr.c:77
#define MAX_PATH
Definition: compat.h:34
int winetest_get_mainargs(char ***pargv)
static void test_CreateJob(void)
Definition: qmgr.c:50
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
#define NULL
Definition: types.h:112
#define MultiByteToWideChar
Definition: compat.h:110
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
#define win_skip
Definition: test.h:149
static HRESULT test_create_manager(void)
Definition: qmgr.c:30

◆ test_create_manager()

static HRESULT test_create_manager ( void  )
static

Definition at line 30 of file qmgr.c.

31 {
32  HRESULT hres;
33  IBackgroundCopyManager *manager = NULL;
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 }
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
#define ERROR_SERVICE_DISABLED
Definition: winerror.h:609
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:79
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:51
#define NULL
Definition: types.h:112
#define win_skip
Definition: test.h:149

Referenced by START_TEST().

◆ test_CreateJob()

static void test_CreateJob ( void  )
static

Definition at line 50 of file qmgr.c.

51 {
52  /* Job information */
53  static const WCHAR copyNameW[] = {'T', 'e', 's', 't', 0};
55  GUID tmpId;
56  HRESULT hres;
57  ULONG res;
58  IBackgroundCopyManager* manager = NULL;
59 
60  /* Setup */
61  hres = CoCreateInstance(&CLSID_BackgroundCopyManager, NULL,
62  CLSCTX_LOCAL_SERVER, &IID_IBackgroundCopyManager,
63  (void **) &manager);
64  ok(hres == S_OK, "got 0x%08x\n", hres);
65 
66  /* Create bits job */
67  hres = IBackgroundCopyManager_CreateJob(manager, copyNameW,
68  BG_JOB_TYPE_DOWNLOAD, &tmpId,
69  &job);
70  ok(hres == S_OK, "CreateJob failed: %08x\n", hres);
71 
72  res = IBackgroundCopyJob_Release(job);
73  ok(res == 0, "Bad ref count on release: %u\n", res);
74  IBackgroundCopyManager_Release(manager);
75 }
static HANDLE job
Definition: process.c:77
HRESULT hres
Definition: protocol.c:465
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
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:51
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
GLuint res
Definition: glext.h:9613
unsigned int ULONG
Definition: retypes.h:1

Referenced by START_TEST().

◆ test_EnumJobs()

static void test_EnumJobs ( void  )
static

Definition at line 77 of file qmgr.c.

78 {
79  /* Job Enumerator */
80  IEnumBackgroundCopyJobs* enumJobs;
81 
82  static const WCHAR copyNameW[] = {'T', 'e', 's', 't', 0};
83  IBackgroundCopyManager *manager = NULL;
85  HRESULT hres;
86  GUID tmpId;
87 
88  /* Setup */
89  hres = CoCreateInstance(&CLSID_BackgroundCopyManager, NULL,
90  CLSCTX_LOCAL_SERVER, &IID_IBackgroundCopyManager,
91  (void **) &manager);
92  ok(hres == S_OK, "got 0x%08x\n", hres);
93 
94  hres = IBackgroundCopyManager_CreateJob(manager, copyNameW,
95  BG_JOB_TYPE_DOWNLOAD, &tmpId,
96  &job);
97  ok(hres == S_OK, "got 0x%08x\n", hres);
98 
99  hres = IBackgroundCopyManager_EnumJobs(manager, 0, &enumJobs);
100  ok(hres == S_OK, "EnumJobs failed: %08x\n", hres);
101  IEnumBackgroundCopyJobs_Release(enumJobs);
102 
103  /* Tear down */
104  IBackgroundCopyJob_Release(job);
105  IBackgroundCopyManager_Release(manager);
106 }
static HANDLE job
Definition: process.c:77
HRESULT hres
Definition: protocol.c:465
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
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:51
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112

Referenced by START_TEST().

◆ test_globalness()

static void test_globalness ( void  )
static

Definition at line 145 of file qmgr.c.

146 {
147  static const WCHAR format[] = {'t','e','s','t','_','%','u', 0};
148  WCHAR secretName[MAX_PATH];
149  IEnumBackgroundCopyJobs* enumJobs;
150  IBackgroundCopyManager *manager = NULL;
151  HRESULT hres;
152  hres = CoCreateInstance(&CLSID_BackgroundCopyManager, NULL,
153  CLSCTX_LOCAL_SERVER, &IID_IBackgroundCopyManager,
154  (void **) &manager);
155  ok(hres == S_OK, "got 0x%08x\n", hres);
156 
157  wsprintfW(secretName, format, GetTickCount());
158  run_child(secretName);
159 
160  hres = IBackgroundCopyManager_EnumJobs(manager, 0, &enumJobs);
161  ok(hres == S_OK, "EnumJobs failed: %08x\n", hres);
162  if(hres != S_OK)
163  skip("Unable to create job enumerator.\n");
164  else
165  {
166  ULONG i, n;
168  BOOL found = FALSE;
169 
170  hres = IEnumBackgroundCopyJobs_GetCount(enumJobs, &n);
171  ok(hres == S_OK, "GetCount failed: %08x\n", hres);
172  for (i = 0; i < n && !found; ++i)
173  {
174  LPWSTR name;
175  IEnumBackgroundCopyJobs_Next(enumJobs, 1, &job, NULL);
176  IBackgroundCopyJob_GetDisplayName(job, &name);
177  if (lstrcmpW(name, secretName) == 0)
178  found = TRUE;
180  IBackgroundCopyJob_Release(job);
181  }
182 
183  IEnumBackgroundCopyJobs_Release(enumJobs);
184  ok(found, "Adding a job in another process failed\n");
185  }
186 
187  IBackgroundCopyManager_Release(manager);
188 }
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
static HANDLE job
Definition: process.c:77
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
#define TRUE
Definition: types.h:120
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455
GLdouble n
Definition: glext.h:7729
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
static void run_child(WCHAR *secret)
Definition: qmgr.c:108
HRESULT hres
Definition: protocol.c:465
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
#define MAX_PATH
Definition: compat.h:34
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:51
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 ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define skip(...)
Definition: atltest.h:64
Definition: name.c:38
unsigned int ULONG
Definition: retypes.h:1
WCHAR * LPWSTR
Definition: xmlstorage.h:184
GLuint const GLchar * name
Definition: glext.h:6031

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