ReactOS 0.4.15-dev-7931-gfd331f1
fpSetJob.c
Go to the documentation of this file.
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
23
24/* From printing/include/spoolss.h */
25#define MAX_PRINTER_NAME 220
26
27START_TEST(fpSetJob)
28{
29 HANDLE hPrinter = NULL;
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
59 if (pwszDefaultPrinter)
60 HeapFree(GetProcessHeap(), 0, pwszDefaultPrinter);
61
62 if (hPrinter)
63 pp.fpClosePrinter(hPrinter);
64}
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define START_TEST(x)
Definition: atltest.h:75
#define NULL
Definition: types.h:112
#define GetProcessHeap()
Definition: compat.h:736
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define HeapFree(x, y, z)
Definition: compat.h:735
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
static const WCHAR Cleanup[]
Definition: register.c:80
unsigned int BOOL
Definition: ntddk_ex.h:94
PWSTR GetDefaultPrinterFromRegistry(VOID)
Definition: main.c:45
BOOL GetLocalsplFuncs(LPPRINTPROVIDOR pp)
Definition: main.c:110
uint16_t * PWSTR
Definition: typedefs.h:56
DWORD WINAPI GetLastError(void)
Definition: except.c:1042