[M120 Migration][MM] Fix EME AD insert issue
[platform/framework/web/chromium-efl.git] / printing / printing_test.h
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.
4
5 #ifndef PRINTING_PRINTING_TEST_H_
6 #define PRINTING_PRINTING_TEST_H_
7
8 #include <windows.h>
9 #include <winspool.h>
10
11 #include <string>
12
13 #include "printing/backend/spooler_win.h"
14
15 // Disable the whole test case when executing on a computer that has no printer
16 // installed.
17 // Note: Parent should be testing::Test or InProcessBrowserTest.
18 template <typename Parent>
19 class PrintingTest : public Parent {
20  public:
21   static bool IsTestCaseDisabled() { return GetDefaultPrinter().empty(); }
22   static std::wstring GetDefaultPrinter() {
23     wchar_t printer_name[MAX_PATH];
24     DWORD size = std::size(printer_name);
25     BOOL result = ::GetDefaultPrinter(printer_name, &size);
26     if (result == 0) {
27       if (printing::internal::IsSpoolerRunning() !=
28           printing::internal::SpoolerServiceStatus::kRunning) {
29         printf("The Windows print spooler service is not running!\n");
30         return std::wstring();
31       }
32       if (GetLastError() == ERROR_FILE_NOT_FOUND) {
33         printf("There is no printer installed, printing can't be tested!\n");
34         return std::wstring();
35       }
36       printf("INTERNAL PRINTER ERROR!\n");
37       return std::wstring();
38     }
39     return printer_name;
40   }
41 };
42
43 #endif  // PRINTING_PRINTING_TEST_H_