[FREELDR] Merge boot-drive and partition functionalities together (#6760)
[reactos.git] / modules / rostests / apitests / localspl / dll / fpSetJob.c
1 /*
2 * PROJECT: ReactOS Local Spooler API Tests Injected DLL
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: Tests for fpSetJob
5 * COPYRIGHT: Copyright 2017 Colin Finck (colin@reactos.org)
6 */
7
8 #include <apitest.h>
9
10 #define WIN32_NO_STATUS
11 #include <windef.h>
12 #include <winbase.h>
13 #include <wingdi.h>
14 #include <winreg.h>
15 #include <winspool.h>
16 #include <winsplp.h>
17
18 #include "../localspl_apitest.h"
19 #include <spoolss.h>
20
21 extern PWSTR GetDefaultPrinterFromRegistry(VOID);
22 extern BOOL GetLocalsplFuncs(LPPRINTPROVIDOR pp);
23
24 /* From printing/include/spoolss.h */
25 #define MAX_PRINTER_NAME 220
26
27 START_TEST(fpSetJob)
28 {
29 HANDLE hPrinter = NULL;
30 PRINTPROVIDOR pp;
31 PWSTR pwszDefaultPrinter = NULL;
32
33 if (!GetLocalsplFuncs(&pp))
34 goto Cleanup;
35
36 // Verify that fpSetJob returns ERROR_INVALID_HANDLE when nothing is provided.
37 ok(!pp.fpSetJob(NULL, 0, 0, NULL, 0), "fpSetJob returns TRUE\n");
38 ok(GetLastError() == ERROR_INVALID_HANDLE, "fpSetJob returns error %lu!\n", GetLastError());
39
40 // Get the default printer.
41 pwszDefaultPrinter = GetDefaultPrinterFromRegistry();
42 if (!pwszDefaultPrinter)
43 {
44 skip("Could not determine the default printer!\n");
45 goto Cleanup;
46 }
47
48 if (!pp.fpOpenPrinter(pwszDefaultPrinter, &hPrinter, NULL))
49 {
50 skip("Could not open a handle to the default printer, last error is %lu!\n", GetLastError());
51 goto Cleanup;
52 }
53
54 // Verify that fpSetJob returns ERROR_INVALID_PARAMETER if only a printer handle is provided.
55 ok(!pp.fpSetJob(hPrinter, 0, 0, NULL, 0), "fpSetJob returns TRUE\n");
56 ok(GetLastError() == ERROR_INVALID_PARAMETER, "fpSetJob returns error %lu!\n", GetLastError());
57
58 Cleanup:
59 if (pwszDefaultPrinter)
60 HeapFree(GetProcessHeap(), 0, pwszDefaultPrinter);
61
62 if (hPrinter)
63 pp.fpClosePrinter(hPrinter);
64 }