OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "printing/printing_context_win.h" | 5 #include "printing/printing_context_win.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "printing/backend/printing_info_win.h" | 9 #include "printing/backend/printing_info_win.h" |
10 #include "printing/backend/win_helper.h" | 10 #include "printing/backend/win_helper.h" |
11 #include "printing/print_settings.h" | 11 #include "printing/print_settings.h" |
12 #include "printing/printing_context_system_dialog_win.h" | 12 #include "printing/printing_context_system_dialog_win.h" |
13 #include "printing/printing_test.h" | 13 #include "printing/printing_test.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 | 15 |
16 namespace printing { | 16 namespace printing { |
17 | 17 |
18 // This test is automatically disabled if no printer is available. | 18 // This test is automatically disabled if no printer is available. |
19 class PrintingContextTest : public PrintingTest<testing::Test>, | 19 class PrintingContextTest : public PrintingTest<testing::Test>, |
20 public PrintingContext::Delegate { | 20 public PrintingContext::Delegate { |
21 public: | 21 public: |
22 void PrintSettingsCallback(PrintingContext::Result result) { | 22 void PrintSettingsCallback(PrintingContext::Result result) { |
23 result_ = result; | 23 result_ = result; |
24 } | 24 } |
25 | 25 |
26 // PrintingContext::Delegate methods. | 26 // PrintingContext::Delegate methods. |
27 virtual gfx::NativeView GetParentView() OVERRIDE { return NULL; } | 27 virtual gfx::NativeView GetParentView() override { return NULL; } |
28 virtual std::string GetAppLocale() OVERRIDE { return std::string(); } | 28 virtual std::string GetAppLocale() override { return std::string(); } |
29 | 29 |
30 protected: | 30 protected: |
31 PrintingContext::Result result() const { return result_; } | 31 PrintingContext::Result result() const { return result_; } |
32 | 32 |
33 private: | 33 private: |
34 PrintingContext::Result result_; | 34 PrintingContext::Result result_; |
35 }; | 35 }; |
36 | 36 |
37 class MockPrintingContextWin : public PrintingContextSytemDialogWin { | 37 class MockPrintingContextWin : public PrintingContextSytemDialogWin { |
38 public: | 38 public: |
39 MockPrintingContextWin(Delegate* delegate) | 39 MockPrintingContextWin(Delegate* delegate) |
40 : PrintingContextSytemDialogWin(delegate) {} | 40 : PrintingContextSytemDialogWin(delegate) {} |
41 | 41 |
42 protected: | 42 protected: |
43 // This is a fake PrintDlgEx implementation that sets the right fields in | 43 // This is a fake PrintDlgEx implementation that sets the right fields in |
44 // |lppd| to trigger a bug in older revisions of PrintingContext. | 44 // |lppd| to trigger a bug in older revisions of PrintingContext. |
45 HRESULT ShowPrintDialog(PRINTDLGEX* lppd) OVERRIDE { | 45 HRESULT ShowPrintDialog(PRINTDLGEX* lppd) override { |
46 // The interesting bits: | 46 // The interesting bits: |
47 // Pretend the user hit print | 47 // Pretend the user hit print |
48 lppd->dwResultAction = PD_RESULT_PRINT; | 48 lppd->dwResultAction = PD_RESULT_PRINT; |
49 | 49 |
50 // Pretend the page range is 1-5, but since lppd->Flags does not have | 50 // Pretend the page range is 1-5, but since lppd->Flags does not have |
51 // PD_SELECTION set, this really shouldn't matter. | 51 // PD_SELECTION set, this really shouldn't matter. |
52 lppd->nPageRanges = 1; | 52 lppd->nPageRanges = 1; |
53 lppd->lpPageRanges[0].nFromPage = 1; | 53 lppd->lpPageRanges[0].nFromPage = 1; |
54 lppd->lpPageRanges[0].nToPage = 5; | 54 lppd->lpPageRanges[0].nToPage = 5; |
55 | 55 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 EXPECT_EQ(PrintingContext::OK, context->InitWithSettings(settings)); | 179 EXPECT_EQ(PrintingContext::OK, context->InitWithSettings(settings)); |
180 | 180 |
181 // The print may lie to use and may not support world transformation. | 181 // The print may lie to use and may not support world transformation. |
182 // Verify right now. | 182 // Verify right now. |
183 XFORM random_matrix = { 1, 0.1f, 0, 1.5f, 0, 1 }; | 183 XFORM random_matrix = { 1, 0.1f, 0, 1.5f, 0, 1 }; |
184 EXPECT_TRUE(SetWorldTransform(context->context(), &random_matrix)); | 184 EXPECT_TRUE(SetWorldTransform(context->context(), &random_matrix)); |
185 EXPECT_TRUE(ModifyWorldTransform(context->context(), NULL, MWT_IDENTITY)); | 185 EXPECT_TRUE(ModifyWorldTransform(context->context(), NULL, MWT_IDENTITY)); |
186 } | 186 } |
187 | 187 |
188 } // namespace printing | 188 } // namespace printing |
OLD | NEW |