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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 std::string GetAppLocale() override { return std::string(); } | 33 std::string GetAppLocale() override { return std::string(); } |
34 | 34 |
35 protected: | 35 protected: |
36 PrintingContext::Result result() const { return result_; } | 36 PrintingContext::Result result() const { return result_; } |
37 | 37 |
38 private: | 38 private: |
39 PrintingContext::Result result_; | 39 PrintingContext::Result result_; |
40 }; | 40 }; |
41 | 41 |
42 namespace { | 42 namespace { |
| 43 |
43 struct FreeHandleTraits { | 44 struct FreeHandleTraits { |
44 typedef HANDLE Handle; | 45 typedef HANDLE Handle; |
45 static void CloseHandle(HANDLE handle) { GlobalFree(handle); } | 46 static void CloseHandle(HANDLE handle) { GlobalFree(handle); } |
46 static bool IsHandleValid(HANDLE handle) { return handle != NULL; } | 47 static bool IsHandleValid(HANDLE handle) { return handle != NULL; } |
47 static HANDLE NullHandle() { return NULL; } | 48 static HANDLE NullHandle() { return NULL; } |
48 }; | 49 }; |
49 typedef base::win::GenericScopedHandle<FreeHandleTraits, | 50 typedef base::win::GenericScopedHandle<FreeHandleTraits, |
50 base::win::DummyVerifierTraits> | 51 base::win::DummyVerifierTraits> |
51 ScopedGlobalAlloc; | 52 ScopedGlobalAlloc; |
52 } | |
53 | 53 |
54 class MockPrintingContextWin : public PrintingContextSytemDialogWin { | 54 } // namespace |
| 55 |
| 56 class MockPrintingContextWin : public PrintingContextSystemDialogWin { |
55 public: | 57 public: |
56 MockPrintingContextWin(Delegate* delegate) | 58 explicit MockPrintingContextWin(Delegate* delegate) |
57 : PrintingContextSytemDialogWin(delegate) {} | 59 : PrintingContextSystemDialogWin(delegate) {} |
58 | 60 |
59 protected: | 61 protected: |
60 // This is a fake PrintDlgEx implementation that sets the right fields in | 62 // This is a fake PrintDlgEx implementation that sets the right fields in |
61 // |lppd| to trigger a bug in older revisions of PrintingContext. | 63 // |lppd| to trigger a bug in older revisions of PrintingContext. |
62 HRESULT ShowPrintDialog(PRINTDLGEX* lppd) override { | 64 HRESULT ShowPrintDialog(PRINTDLGEX* lppd) override { |
63 // The interesting bits: | 65 // The interesting bits: |
64 // Pretend the user hit print | 66 // Pretend the user hit print |
65 lppd->dwResultAction = PD_RESULT_PRINT; | 67 lppd->dwResultAction = PD_RESULT_PRINT; |
66 | 68 |
67 // Pretend the page range is 1-5, but since lppd->Flags does not have | 69 // Pretend the page range is 1-5, but since lppd->Flags does not have |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 EXPECT_EQ(PrintingContext::OK, context->InitWithSettings(settings)); | 168 EXPECT_EQ(PrintingContext::OK, context->InitWithSettings(settings)); |
167 | 169 |
168 // The print may lie to use and may not support world transformation. | 170 // The print may lie to use and may not support world transformation. |
169 // Verify right now. | 171 // Verify right now. |
170 XFORM random_matrix = { 1, 0.1f, 0, 1.5f, 0, 1 }; | 172 XFORM random_matrix = { 1, 0.1f, 0, 1.5f, 0, 1 }; |
171 EXPECT_TRUE(SetWorldTransform(context->context(), &random_matrix)); | 173 EXPECT_TRUE(SetWorldTransform(context->context(), &random_matrix)); |
172 EXPECT_TRUE(ModifyWorldTransform(context->context(), NULL, MWT_IDENTITY)); | 174 EXPECT_TRUE(ModifyWorldTransform(context->context(), NULL, MWT_IDENTITY)); |
173 } | 175 } |
174 | 176 |
175 } // namespace printing | 177 } // namespace printing |
OLD | NEW |