2 * Copyright 2020 Nikolay Sivov for CodeWeavers
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.
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.
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
26 #include "wine/test.h"
28 static void test_platform_init(void)
30 APTTYPEQUALIFIER qualifier
;
34 /* Startup initializes MTA. */
35 hr
= CoGetApartmentType(&apttype
, &qualifier
);
36 ok(hr
== CO_E_NOTINITIALIZED
, "Unexpected hr %#x.\n", hr
);
39 ok(hr
== S_OK
, "Failed to start up, hr %#x.\n", hr
);
41 hr
= CoGetApartmentType(&apttype
, &qualifier
);
42 ok(hr
== S_OK
|| broken(FAILED(hr
)) /* Win8 */, "Unexpected hr %#x.\n", hr
);
44 ok(apttype
== APTTYPE_MTA
&& qualifier
== APTTYPEQUALIFIER_IMPLICIT_MTA
,
45 "Unexpected apartment type %d, qualifier %d.\n", apttype
, qualifier
);
48 ok(hr
== S_OK
, "Failed to shut down, hr %#x.\n", hr
);
50 hr
= CoGetApartmentType(&apttype
, &qualifier
);
51 ok(hr
== CO_E_NOTINITIALIZED
, "Unexpected hr %#x.\n", hr
);
53 /* Try with STA initialized before startup. */
54 hr
= CoInitializeEx(NULL
, COINIT_APARTMENTTHREADED
);
55 ok(hr
== S_OK
, "Failed to initialize, hr %#x.\n", hr
);
57 hr
= CoGetApartmentType(&apttype
, &qualifier
);
58 ok(hr
== S_OK
, "Unexpected hr %#x.\n", hr
);
59 ok(apttype
== APTTYPE_MAINSTA
&& qualifier
== APTTYPEQUALIFIER_NONE
,
60 "Unexpected apartment type %d, qualifier %d.\n", apttype
, qualifier
);
63 ok(hr
== S_OK
, "Failed to start up, hr %#x.\n", hr
);
65 hr
= CoGetApartmentType(&apttype
, &qualifier
);
66 ok(hr
== S_OK
, "Unexpected hr %#x.\n", hr
);
67 ok(apttype
== APTTYPE_MAINSTA
&& qualifier
== APTTYPEQUALIFIER_NONE
,
68 "Unexpected apartment type %d, qualifier %d.\n", apttype
, qualifier
);
71 ok(hr
== S_OK
, "Failed to shut down, hr %#x.\n", hr
);
75 /* Startup -> init main STA -> uninitialize -> shutdown */
77 ok(hr
== S_OK
, "Failed to start up, hr %#x.\n", hr
);
79 hr
= CoGetApartmentType(&apttype
, &qualifier
);
80 ok(hr
== S_OK
|| broken(FAILED(hr
)) /* Win8 */, "Unexpected hr %#x.\n", hr
);
82 ok(apttype
== APTTYPE_MTA
&& qualifier
== APTTYPEQUALIFIER_IMPLICIT_MTA
,
83 "Unexpected apartment type %d, qualifier %d.\n", apttype
, qualifier
);
85 hr
= CoInitializeEx(NULL
, COINIT_APARTMENTTHREADED
);
86 ok(hr
== S_OK
, "Failed to initialize, hr %#x.\n", hr
);
88 hr
= CoGetApartmentType(&apttype
, &qualifier
);
89 ok(hr
== S_OK
, "Unexpected hr %#x.\n", hr
);
90 ok(apttype
== APTTYPE_MAINSTA
&& qualifier
== APTTYPEQUALIFIER_NONE
,
91 "Unexpected apartment type %d, qualifier %d.\n", apttype
, qualifier
);
95 hr
= CoGetApartmentType(&apttype
, &qualifier
);
96 ok(hr
== S_OK
, "Unexpected hr %#x.\n", hr
);
97 ok(apttype
== APTTYPE_MTA
&& qualifier
== APTTYPEQUALIFIER_IMPLICIT_MTA
,
98 "Unexpected apartment type %d, qualifier %d.\n", apttype
, qualifier
);
101 ok(hr
== S_OK
, "Failed to shut down, hr %#x.\n", hr
);
106 test_platform_init();