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

Go to the source code of this file.

Macros

#define COBJMACROS
 

Typedefs

typedef void(* test_t) (void)
 

Functions

static BOOL setup (void)
 
static void teardown (void)
 
static void test_GetCount (void)
 
static void test_Next_walkListNull (void)
 
static void test_Next_walkList_1 (void)
 
static void test_Next_walkList_2 (void)
 
static void test_Next_errors (void)
 
static void test_Skip_walkList (void)
 
static void test_Skip_offEnd (void)
 
static void test_Reset (void)
 
 START_TEST (enum_jobs)
 

Variables

static IBackgroundCopyManager * test_manager
 
static IBackgroundCopyJob * test_jobA
 
static IBackgroundCopyJob * test_jobB
 
static ULONG test_jobCountB
 
static IEnumBackgroundCopyJobs * test_enumJobsA
 
static IEnumBackgroundCopyJobs * test_enumJobsB
 
static GUID test_jobIdA
 
static GUID test_jobIdB
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 23 of file enum_jobs.c.

Typedef Documentation

◆ test_t

typedef void(* test_t) (void)

Definition at line 242 of file enum_jobs.c.

Function Documentation

◆ setup()

static BOOL setup ( void  )
static

Definition at line 39 of file enum_jobs.c.

40{
42
46 memset(&test_jobIdA, 0, sizeof test_jobIdA);
47 memset(&test_jobIdB, 0, sizeof test_jobIdB);
48
49 hres = CoCreateInstance(&CLSID_BackgroundCopyManager, NULL,
50 CLSCTX_LOCAL_SERVER, &IID_IBackgroundCopyManager,
51 (void **) &test_manager);
52 if(hres != S_OK)
53 return FALSE;
54
55 hres = IBackgroundCopyManager_CreateJob(test_manager, L"TestA", BG_JOB_TYPE_DOWNLOAD,
57 if(hres != S_OK)
58 return FALSE;
59
60 hres = IBackgroundCopyManager_EnumJobs(test_manager, 0, &test_enumJobsA);
61 if(hres != S_OK)
62 return FALSE;
63
64 hres = IBackgroundCopyManager_CreateJob(test_manager, L"TestB", BG_JOB_TYPE_DOWNLOAD,
66 if(hres != S_OK)
67 return FALSE;
68
69 hres = IBackgroundCopyManager_EnumJobs(test_manager, 0, &test_enumJobsB);
70 if(hres != S_OK)
71 return FALSE;
72
73 hres = IEnumBackgroundCopyJobs_GetCount(test_enumJobsB, &test_jobCountB);
74 if (hres != S_OK)
75 return FALSE;
76
77 return TRUE;
78}
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, IUnknown *outer, DWORD cls_context, REFIID riid, void **obj)
Definition: combase.c:1685
#define L(x)
Definition: resources.c:13
#define S_OK
Definition: intsafe.h:52
HRESULT hres
Definition: protocol.c:432
static IBackgroundCopyJob * test_jobA
Definition: enum_jobs.c:30
static IEnumBackgroundCopyJobs * test_enumJobsB
Definition: enum_jobs.c:34
static ULONG test_jobCountB
Definition: enum_jobs.c:32
static GUID test_jobIdB
Definition: enum_jobs.c:36
static IEnumBackgroundCopyJobs * test_enumJobsA
Definition: enum_jobs.c:33
static IBackgroundCopyJob * test_jobB
Definition: enum_jobs.c:31
static GUID test_jobIdA
Definition: enum_jobs.c:35
#define memset(x, y, z)
Definition: compat.h:39

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( enum_jobs  )

Definition at line 244 of file enum_jobs.c.

245{
246 static const test_t tests[] = {
255 0
256 };
257 const test_t *test;
258 int i;
259
261 for (test = tests, i = 0; *test; ++test, ++i)
262 {
263 /* Keep state separate between tests */
264 if (!setup())
265 {
266 teardown();
267 ok(0, "tests:%d: Unable to setup test\n", i);
268 break;
269 }
270 (*test)();
271 teardown();
272 }
274}
#define ok(value,...)
Definition: atltest.h:57
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: combase.c:2842
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:531
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 struct test_info tests[]
static void test_Reset(void)
Definition: enum_jobs.c:228
static void test_Next_errors(void)
Definition: enum_jobs.c:192
static void test_Next_walkList_2(void)
Definition: enum_jobs.c:165
static void teardown(void)
Definition: enum_jobs.c:81
static void test_Next_walkListNull(void)
Definition: enum_jobs.c:120
static void test_Next_walkList_1(void)
Definition: enum_jobs.c:140
static void test_GetCount(void)
Definition: enum_jobs.c:105
static void test_Skip_offEnd(void)
Definition: enum_jobs.c:219
static BOOL setup(void)
Definition: enum_jobs.c:39
static void test_Skip_walkList(void)
Definition: enum_jobs.c:203
void(* test_t)(void)
Definition: enum_jobs.c:242
#define test
Definition: rosglue.h:37

◆ teardown()

static void teardown ( void  )
static

Definition at line 81 of file enum_jobs.c.

82{
84 IEnumBackgroundCopyJobs_Release(test_enumJobsB);
86 if (test_jobB)
87 IBackgroundCopyJob_Release(test_jobB);
90 IEnumBackgroundCopyJobs_Release(test_enumJobsA);
92 if (test_jobA)
93 IBackgroundCopyJob_Release(test_jobA);
95 if (test_manager)
96 IBackgroundCopyManager_Release(test_manager);
98}

Referenced by START_TEST().

◆ test_GetCount()

static void test_GetCount ( void  )
static

Definition at line 105 of file enum_jobs.c.

106{
108 ULONG jobCountA, jobCountB;
109
110 hres = IEnumBackgroundCopyJobs_GetCount(test_enumJobsA, &jobCountA);
111 ok(hres == S_OK, "GetCount failed: %08lx\n", hres);
112
113 hres = IEnumBackgroundCopyJobs_GetCount(test_enumJobsB, &jobCountB);
114 ok(hres == S_OK, "GetCount failed: %08lx\n", hres);
115
116 ok(jobCountB == jobCountA + 1, "Got incorrect count\n");
117}
uint32_t ULONG
Definition: typedefs.h:59

Referenced by START_TEST().

◆ test_Next_errors()

static void test_Next_errors ( void  )
static

Definition at line 192 of file enum_jobs.c.

193{
195 IBackgroundCopyJob *jobs[2];
196
197 /* E_INVALIDARG: pceltFetched can ONLY be NULL if celt is 1 */
198 hres = IEnumBackgroundCopyJobs_Next(test_enumJobsB, 2, jobs, NULL);
199 ok(hres != S_OK, "Invalid call to Next succeeded: %08lx\n", hres);
200}

Referenced by START_TEST().

◆ test_Next_walkList_1()

static void test_Next_walkList_1 ( void  )
static

Definition at line 140 of file enum_jobs.c.

141{
144 ULONG fetched;
145 ULONG i;
146
147 /* Fetch the available jobs */
148 for (i = 0; i < test_jobCountB; i++)
149 {
150 fetched = 0;
151 hres = IEnumBackgroundCopyJobs_Next(test_enumJobsB, 1, &job, &fetched);
152 ok(hres == S_OK, "Next failed: %08lx\n", hres);
153 ok(fetched == 1, "Next returned the incorrect number of jobs: %08lx\n", hres);
154 IBackgroundCopyJob_Release(job);
155 }
156
157 /* Attempt to fetch one more than the number of available jobs */
158 fetched = 0;
159 hres = IEnumBackgroundCopyJobs_Next(test_enumJobsB, 1, &job, &fetched);
160 ok(hres == S_FALSE, "Next off end of available jobs failed: %08lx\n", hres);
161 ok(fetched == 0, "Next returned the incorrect number of jobs: %08lx\n", hres);
162}
static HANDLE job
Definition: process.c:79
#define S_FALSE
Definition: winerror.h:3451

Referenced by START_TEST().

◆ test_Next_walkList_2()

static void test_Next_walkList_2 ( void  )
static

Definition at line 165 of file enum_jobs.c.

166{
168 IBackgroundCopyJob **jobs;
169 ULONG fetched;
170 ULONG i;
171
172 jobs = HeapAlloc(GetProcessHeap(), 0, test_jobCountB * sizeof *jobs);
173 for (i = 0; i < test_jobCountB; i++)
174 jobs[i] = NULL;
175
176 fetched = 0;
177 hres = IEnumBackgroundCopyJobs_Next(test_enumJobsB, test_jobCountB, jobs, &fetched);
178 ok(hres == S_OK, "Next failed: %08lx\n", hres);
179 ok(fetched == test_jobCountB, "Next returned the incorrect number of jobs: %08lx\n", hres);
180
181 for (i = 0; i < test_jobCountB; i++)
182 {
183 ok(jobs[i] != NULL, "Next returned NULL\n");
184 if (jobs[i])
185 IBackgroundCopyJob_Release(jobs[i]);
186 }
187
188 HeapFree(GetProcessHeap(), 0, jobs);
189}
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735

Referenced by START_TEST().

◆ test_Next_walkListNull()

static void test_Next_walkListNull ( void  )
static

Definition at line 120 of file enum_jobs.c.

121{
124 ULONG i;
125
126 /* Fetch the available jobs */
127 for (i = 0; i < test_jobCountB; i++)
128 {
129 hres = IEnumBackgroundCopyJobs_Next(test_enumJobsB, 1, &job, NULL);
130 ok(hres == S_OK, "Next failed: %08lx\n", hres);
131 IBackgroundCopyJob_Release(job);
132 }
133
134 /* Attempt to fetch one more than the number of available jobs */
135 hres = IEnumBackgroundCopyJobs_Next(test_enumJobsB, 1, &job, NULL);
136 ok(hres == S_FALSE, "Next off end of available jobs failed: %08lx\n", hres);
137}

Referenced by START_TEST().

◆ test_Reset()

static void test_Reset ( void  )
static

Definition at line 228 of file enum_jobs.c.

229{
231
232 hres = IEnumBackgroundCopyJobs_Skip(test_enumJobsB, test_jobCountB);
233 ok(hres == S_OK, "Skip failed: %08lx\n", hres);
234
235 hres = IEnumBackgroundCopyJobs_Reset(test_enumJobsB);
236 ok(hres == S_OK, "Reset failed: %08lx\n", hres);
237
238 hres = IEnumBackgroundCopyJobs_Skip(test_enumJobsB, test_jobCountB);
239 ok(hres == S_OK, "Reset failed: %08lx\n", hres);
240}

Referenced by START_TEST().

◆ test_Skip_offEnd()

static void test_Skip_offEnd ( void  )
static

Definition at line 219 of file enum_jobs.c.

220{
222
223 hres = IEnumBackgroundCopyJobs_Skip(test_enumJobsB, test_jobCountB + 1);
224 ok(hres == S_FALSE, "Skip expected end of list: %08lx\n", hres);
225}

Referenced by START_TEST().

◆ test_Skip_walkList()

static void test_Skip_walkList ( void  )
static

Definition at line 203 of file enum_jobs.c.

204{
206 ULONG i;
207
208 for (i = 0; i < test_jobCountB; i++)
209 {
210 hres = IEnumBackgroundCopyJobs_Skip(test_enumJobsB, 1);
211 ok(hres == S_OK, "Skip failed: %08lx\n", hres);
212 }
213
214 hres = IEnumBackgroundCopyJobs_Skip(test_enumJobsB, 1);
215 ok(hres == S_FALSE, "Skip expected end of list: %08lx\n", hres);
216}

Referenced by START_TEST().

Variable Documentation

◆ test_enumJobsA

IEnumBackgroundCopyJobs* test_enumJobsA
static

Definition at line 33 of file enum_jobs.c.

Referenced by setup(), teardown(), and test_GetCount().

◆ test_enumJobsB

◆ test_jobA

IBackgroundCopyJob* test_jobA
static

Definition at line 30 of file enum_jobs.c.

Referenced by setup(), and teardown().

◆ test_jobB

IBackgroundCopyJob* test_jobB
static

Definition at line 31 of file enum_jobs.c.

Referenced by setup(), and teardown().

◆ test_jobCountB

◆ test_jobIdA

GUID test_jobIdA
static

Definition at line 35 of file enum_jobs.c.

Referenced by setup().

◆ test_jobIdB

GUID test_jobIdB
static

Definition at line 36 of file enum_jobs.c.

Referenced by setup().

◆ test_manager

Definition at line 29 of file enum_jobs.c.