ReactOS 0.4.17-dev-691-gfdddc52
rtworkq.c
Go to the documentation of this file.
1/*
2 * Copyright 2020 Nikolay Sivov for CodeWeavers
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18
19#include <stdarg.h>
20#include <string.h>
21
22#include "windef.h"
23#include "winbase.h"
24#include "rtworkq.h"
25
26#include "wine/test.h"
27
28static void test_platform_init(void)
29{
31 APTTYPE apttype;
32 HRESULT hr;
33
34 /* Startup initializes MTA. */
35 hr = CoGetApartmentType(&apttype, &qualifier);
36 ok(hr == CO_E_NOTINITIALIZED, "Unexpected hr %#lx.\n", hr);
37
38 hr = RtwqStartup();
39 ok(hr == S_OK, "Failed to start up, hr %#lx.\n", hr);
40
41 hr = CoGetApartmentType(&apttype, &qualifier);
42 ok(hr == S_OK || broken(FAILED(hr)) /* Win8 */, "Unexpected hr %#lx.\n", hr);
43 if (SUCCEEDED(hr))
45 "Unexpected apartment type %d, qualifier %d.\n", apttype, qualifier);
46
47 hr = RtwqShutdown();
48 ok(hr == S_OK, "Failed to shut down, hr %#lx.\n", hr);
49
50 hr = CoGetApartmentType(&apttype, &qualifier);
51 ok(hr == CO_E_NOTINITIALIZED, "Unexpected hr %#lx.\n", hr);
52
53 /* Try with STA initialized before startup. */
55 ok(hr == S_OK, "Failed to initialize, hr %#lx.\n", hr);
56
57 hr = CoGetApartmentType(&apttype, &qualifier);
58 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
60 "Unexpected apartment type %d, qualifier %d.\n", apttype, qualifier);
61
62 hr = RtwqStartup();
63 ok(hr == S_OK, "Failed to start up, hr %#lx.\n", hr);
64
65 hr = CoGetApartmentType(&apttype, &qualifier);
66 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
68 "Unexpected apartment type %d, qualifier %d.\n", apttype, qualifier);
69
70 hr = RtwqShutdown();
71 ok(hr == S_OK, "Failed to shut down, hr %#lx.\n", hr);
72
74
75 /* Startup -> init main STA -> uninitialize -> shutdown */
76 hr = RtwqStartup();
77 ok(hr == S_OK, "Failed to start up, hr %#lx.\n", hr);
78
79 hr = CoGetApartmentType(&apttype, &qualifier);
80 ok(hr == S_OK || broken(FAILED(hr)) /* Win8 */, "Unexpected hr %#lx.\n", hr);
81 if (SUCCEEDED(hr))
83 "Unexpected apartment type %d, qualifier %d.\n", apttype, qualifier);
84
86 ok(hr == S_OK, "Failed to initialize, hr %#lx.\n", hr);
87
88 hr = CoGetApartmentType(&apttype, &qualifier);
89 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
91 "Unexpected apartment type %d, qualifier %d.\n", apttype, qualifier);
92
94
95 hr = CoGetApartmentType(&apttype, &qualifier);
96 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
98 "Unexpected apartment type %d, qualifier %d.\n", apttype, qualifier);
99
100 hr = RtwqShutdown();
101 ok(hr == S_OK, "Failed to shut down, hr %#lx.\n", hr);
102}
103
105{
107}
#define CO_E_NOTINITIALIZED
#define ok(value,...)
Definition: atltest.h:57
#define broken(x)
Definition: atltest.h:178
#define START_TEST(x)
Definition: atltest.h:75
HRESULT hr
Definition: delayimp.cpp:582
#define NULL
Definition: types.h:112
HRESULT WINAPI CoGetApartmentType(APTTYPE *type, APTTYPEQUALIFIER *qualifier)
Definition: combase.c:2928
HRESULT WINAPI DECLSPEC_HOTPATCH CoInitializeEx(void *reserved, DWORD model)
Definition: combase.c:2803
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: combase.c:2842
HRESULT WINAPI RtwqStartup(void)
Definition: queue.c:1207
HRESULT WINAPI RtwqShutdown(void)
Definition: queue.c:1235
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
static APTTYPEQUALIFIER * qualifier
Definition: compobj.c:77
@ COINIT_APARTMENTTHREADED
Definition: objbase.h:279
@ APTTYPEQUALIFIER_IMPLICIT_MTA
@ APTTYPEQUALIFIER_NONE
enum _APTTYPEQUALIFIER APTTYPEQUALIFIER
static void test_platform_init(void)
Definition: rtworkq.c:28