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 <ocidl.h> | 5 #include <ocidl.h> |
6 #include <commdlg.h> | 6 #include <commdlg.h> |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/run_loop.h" | |
14 #include "printing/backend/printing_info_win.h" | 13 #include "printing/backend/printing_info_win.h" |
15 #include "printing/printing_test.h" | 14 #include "printing/printing_test.h" |
16 #include "printing/printing_context.h" | 15 #include "printing/printing_context.h" |
17 #include "printing/printing_context_win.h" | 16 #include "printing/printing_context_win.h" |
18 #include "printing/print_settings.h" | 17 #include "printing/print_settings.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
20 | 19 |
21 // This test is automatically disabled if no printer is available. | 20 // This test is automatically disabled if no printer is available. |
22 class PrintingContextTest : public PrintingTest<testing::Test> { | 21 class PrintingContextTest : public PrintingTest<testing::Test> { |
23 public: | 22 public: |
24 void PrintSettingsCallback(printing::PrintingContext::Result result) { | 23 void PrintSettingsCallback(printing::PrintingContext::Result result) { |
25 result_ = result; | 24 result_ = result; |
26 base::MessageLoop::current()->QuitWhenIdle(); | |
27 } | 25 } |
28 | 26 |
29 protected: | 27 protected: |
30 printing::PrintingContext::Result result() const { return result_; } | 28 printing::PrintingContext::Result result() const { return result_; } |
31 | 29 |
32 private: | 30 private: |
33 printing::PrintingContext::Result result_; | 31 printing::PrintingContext::Result result_; |
34 }; | 32 }; |
35 | 33 |
36 // This is a fake PrintDlgEx implementation that sets the right fields in | 34 // This is a fake PrintDlgEx implementation that sets the right fields in |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 EXPECT_EQ(printing::PrintingContext::OK, context->InitWithSettings(settings)); | 152 EXPECT_EQ(printing::PrintingContext::OK, context->InitWithSettings(settings)); |
155 | 153 |
156 // The print may lie to use and may not support world transformation. | 154 // The print may lie to use and may not support world transformation. |
157 // Verify right now. | 155 // Verify right now. |
158 XFORM random_matrix = { 1, 0.1f, 0, 1.5f, 0, 1 }; | 156 XFORM random_matrix = { 1, 0.1f, 0, 1.5f, 0, 1 }; |
159 EXPECT_TRUE(SetWorldTransform(context->context(), &random_matrix)); | 157 EXPECT_TRUE(SetWorldTransform(context->context(), &random_matrix)); |
160 EXPECT_TRUE(ModifyWorldTransform(context->context(), NULL, MWT_IDENTITY)); | 158 EXPECT_TRUE(ModifyWorldTransform(context->context(), NULL, MWT_IDENTITY)); |
161 } | 159 } |
162 | 160 |
163 TEST_F(PrintingContextTest, PrintAll) { | 161 TEST_F(PrintingContextTest, PrintAll) { |
164 base::MessageLoopForUI loop; | |
165 if (IsTestCaseDisabled()) | 162 if (IsTestCaseDisabled()) |
166 return; | 163 return; |
167 | 164 |
168 std::string dummy_locale; | 165 std::string dummy_locale; |
169 printing::PrintingContextWin context(dummy_locale); | 166 printing::PrintingContextWin context(dummy_locale); |
170 context.SetPrintDialog(&PrintDlgExMock); | 167 context.SetPrintDialog(&PrintDlgExMock); |
171 context.AskUserForSettings( | 168 context.AskUserForSettings( |
172 NULL, 123, false, base::Bind(&PrintingContextTest::PrintSettingsCallback, | 169 NULL, 123, false, base::Bind(&PrintingContextTest::PrintSettingsCallback, |
173 base::Unretained(this))); | 170 base::Unretained(this))); |
174 base::RunLoop().Run(); | |
175 EXPECT_EQ(printing::PrintingContext::OK, result()); | 171 EXPECT_EQ(printing::PrintingContext::OK, result()); |
176 | |
177 printing::PrintSettings settings = context.settings(); | 172 printing::PrintSettings settings = context.settings(); |
178 EXPECT_EQ(settings.ranges().size(), 0); | 173 EXPECT_EQ(settings.ranges().size(), 0); |
179 } | 174 } |
OLD | NEW |