mfplat: Read queue subscriber within the critical section.
[wine/zf.git] / dlls / prntvpt / tests / prntvpt.c
blob55b6f3fdef15274c1e4c256cfe76daebcf76a40e
1 /*
2 * Copyright 2019 Dmitry Timoshkov
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
19 #define COBJMACROS
21 #include <stdarg.h>
23 #include <windef.h>
24 #include <winbase.h>
25 #include <wingdi.h>
26 #include <winspool.h>
27 #include <objbase.h>
28 #include <prntvpt.h>
30 #include "wine/test.h"
32 static WCHAR default_name[256];
34 struct hprov_data
36 HPTPROVIDER hprov;
37 HRESULT hr;
40 static DWORD WINAPI CloseProvider_proc(void *param)
42 struct hprov_data *data = param;
44 data->hr = PTCloseProvider(data->hprov);
46 return 0;
49 static void test_PTOpenProvider(void)
51 DWORD tid, i;
52 HPTPROVIDER hprov;
53 HRESULT hr;
54 HANDLE hthread;
55 struct hprov_data data;
57 hr = PTOpenProvider(default_name, 1, &hprov);
58 ok(hr == S_OK, "got %#x\n", hr);
60 data.hprov = hprov;
61 hthread = CreateThread(NULL, 0, CloseProvider_proc, &data, 0, &tid);
62 WaitForSingleObject(hthread, INFINITE);
63 CloseHandle(hthread);
64 ok(data.hr == E_HANDLE || data.hr == E_INVALIDARG /* XP */ || broken(data.hr == S_OK) /* Win8 */, "got %#x\n", data.hr);
66 if (data.hr != S_OK)
68 hr = PTCloseProvider(hprov);
69 ok(hr == S_OK, "got %#x\n", hr);
72 hr = PTOpenProvider(default_name, 0, &hprov);
73 ok(hr == E_INVALIDARG, "got %#x\n", hr);
75 for (i = 2; i < 20; i++)
77 hr = PTOpenProvider(default_name, i, &hprov);
78 ok(hr == 0x80040001 || hr == E_INVALIDARG /* Wine */, "%u: got %#x\n", i, hr);
82 static void test_PTOpenProviderEx(void)
84 DWORD tid, ver, i;
85 HPTPROVIDER hprov;
86 HRESULT hr;
87 HANDLE hthread;
88 struct hprov_data data;
90 hr = PTOpenProviderEx(default_name, 1, 1, &hprov, NULL);
91 ok(hr == E_INVALIDARG, "got %#x\n", hr);
93 ver = 0xdeadbeef;
94 hr = PTOpenProviderEx(default_name, 1, 1, &hprov, &ver);
95 ok(hr == S_OK, "got %#x\n", hr);
96 ok(ver == 1, "got %#x\n", ver);
98 data.hprov = hprov;
99 hthread = CreateThread(NULL, 0, CloseProvider_proc, &data, 0, &tid);
100 WaitForSingleObject(hthread, INFINITE);
101 CloseHandle(hthread);
102 ok(data.hr == E_HANDLE || data.hr == E_INVALIDARG /* XP */ || broken(data.hr == S_OK) /* Win8 */, "got %#x\n", data.hr);
104 if (data.hr != S_OK)
106 hr = PTCloseProvider(hprov);
107 ok(hr == S_OK, "got %#x\n", hr);
110 for (i = 1; i < 20; i++)
112 hr = PTOpenProviderEx(default_name, 0, i, &hprov, &ver);
113 ok(hr == E_INVALIDARG, "%u: got %#x\n", i, hr);
115 ver = 0xdeadbeef;
116 hr = PTOpenProviderEx(default_name, 1, i, &hprov, &ver);
117 ok(hr == S_OK, "%u: got %#x\n", i, hr);
118 ok(ver == 1, "%u: got %#x\n", i, ver);
119 PTCloseProvider(hprov);
121 ver = 0xdeadbeef;
122 hr = PTOpenProviderEx(default_name, i, i, &hprov, &ver);
123 ok(hr == S_OK, "%u: got %#x\n", i, hr);
124 ok(ver == 1, "%u: got %#x\n", i, ver);
125 PTCloseProvider(hprov);
129 START_TEST(prntvpt)
131 DWORD size;
133 CoInitializeEx(NULL, COINIT_MULTITHREADED);
135 size = ARRAY_SIZE(default_name);
136 if (!GetDefaultPrinterW(default_name, &size))
138 skip("no default printer set\n");
139 return;
142 trace("default printer: %s\n", wine_dbgstr_w(default_name));
144 test_PTOpenProvider();
145 test_PTOpenProviderEx();
147 CoUninitialize();