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