1 // Copyright 2006-2008 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef PRINTING_PRINTING_TEST_H_
6 #define PRINTING_PRINTING_TEST_H_
13 // Disable the whole test case when executing on a computer that has no printer
15 // Note: Parent should be testing::Test or InProcessBrowserTest.
16 template <typename Parent>
17 class PrintingTest : public Parent {
19 static bool IsTestCaseDisabled() { return GetDefaultPrinter().empty(); }
20 static std::wstring GetDefaultPrinter() {
21 wchar_t printer_name[MAX_PATH];
22 DWORD size = std::size(printer_name);
23 BOOL result = ::GetDefaultPrinter(printer_name, &size);
25 if (GetLastError() == ERROR_FILE_NOT_FOUND) {
26 printf("There is no printer installed, printing can't be tested!\n");
27 return std::wstring();
29 printf("INTERNAL PRINTER ERROR!\n");
30 return std::wstring();
36 #endif // PRINTING_PRINTING_TEST_H_