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
30 #include "wine/test.h"
32 static WCHAR default_name
[256];
40 static DWORD WINAPI
CloseProvider_proc(void *param
)
42 struct hprov_data
*data
= param
;
44 data
->hr
= PTCloseProvider(data
->hprov
);
49 static void test_PTOpenProvider(void)
55 struct hprov_data data
;
57 hr
= PTOpenProvider(default_name
, 1, &hprov
);
58 ok(hr
== S_OK
, "got %#x\n", hr
);
61 hthread
= CreateThread(NULL
, 0, CloseProvider_proc
, &data
, 0, &tid
);
62 WaitForSingleObject(hthread
, INFINITE
);
64 ok(data
.hr
== E_HANDLE
|| data
.hr
== E_INVALIDARG
/* XP */ || broken(data
.hr
== S_OK
) /* Win8 */, "got %#x\n", data
.hr
);
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)
88 struct hprov_data data
;
90 hr
= PTOpenProviderEx(default_name
, 1, 1, &hprov
, NULL
);
91 ok(hr
== E_INVALIDARG
, "got %#x\n", hr
);
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
);
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
);
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
);
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
);
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
);
133 CoInitializeEx(NULL
, COINIT_MULTITHREADED
);
135 size
= ARRAY_SIZE(default_name
);
136 if (!GetDefaultPrinterW(default_name
, &size
))
138 skip("no default printer set\n");
142 trace("default printer: %s\n", wine_dbgstr_w(default_name
));
144 test_PTOpenProvider();
145 test_PTOpenProviderEx();