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 "chrome/common/chrome_switches.h" | 5 #include "chrome/common/chrome_switches.h" |
6 #include "chrome/common/print_messages.h" | 6 #include "chrome/common/print_messages.h" |
7 #include "chrome/renderer/print_web_view_helper.h" | 7 #include "chrome/renderer/print_web_view_helper.h" |
8 #include "chrome/test/render_view_test.h" | 8 #include "chrome/test/render_view_test.h" |
9 #include "printing/print_job_constants.h" | 9 #include "printing/print_job_constants.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 | 93 |
94 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelperTestBase); | 94 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelperTestBase); |
95 }; | 95 }; |
96 | 96 |
97 class PrintWebViewHelperTest : public PrintWebViewHelperTestBase { | 97 class PrintWebViewHelperTest : public PrintWebViewHelperTestBase { |
98 public: | 98 public: |
99 PrintWebViewHelperTest() {} | 99 PrintWebViewHelperTest() {} |
100 virtual ~PrintWebViewHelperTest() {} | 100 virtual ~PrintWebViewHelperTest() {} |
101 | 101 |
102 virtual void SetUp() { | 102 virtual void SetUp() { |
103 // Append the print preview switch before creating the PrintWebViewHelper. | |
104 #if defined(GOOGLE_CHROME_BUILD) && !defined(OS_CHROMEOS) && !defined(OS_MACOSX) | |
105 CommandLine::ForCurrentProcess()->AppendSwitch( | |
106 switches::kDisablePrintPreview); | |
107 #endif | |
108 | |
109 RenderViewTest::SetUp(); | 103 RenderViewTest::SetUp(); |
110 } | 104 } |
111 | 105 |
112 protected: | 106 protected: |
113 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelperTest); | 107 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelperTest); |
114 }; | 108 }; |
115 | 109 |
116 // Tests that printing pages work and sending and receiving messages through | 110 // Tests that printing pages work and sending and receiving messages through |
117 // that channel all works. | 111 // that channel all works. |
118 TEST_F(PrintWebViewHelperTest, OnPrintPages) { | 112 TEST_F(PrintWebViewHelperTest, OnPrintPages) { |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 | 288 |
295 // These print preview tests do not work on Chrome OS yet. | 289 // These print preview tests do not work on Chrome OS yet. |
296 #if !defined(OS_CHROMEOS) | 290 #if !defined(OS_CHROMEOS) |
297 class PrintWebViewHelperPreviewTest : public PrintWebViewHelperTestBase { | 291 class PrintWebViewHelperPreviewTest : public PrintWebViewHelperTestBase { |
298 public: | 292 public: |
299 PrintWebViewHelperPreviewTest() {} | 293 PrintWebViewHelperPreviewTest() {} |
300 virtual ~PrintWebViewHelperPreviewTest() {} | 294 virtual ~PrintWebViewHelperPreviewTest() {} |
301 | 295 |
302 virtual void SetUp() { | 296 virtual void SetUp() { |
303 // Append the print preview switch before creating the PrintWebViewHelper. | 297 // Append the print preview switch before creating the PrintWebViewHelper. |
304 #if !defined(GOOGLE_CHROME_BUILD) || defined(OS_MACOSX) | |
305 CommandLine::ForCurrentProcess()->AppendSwitch( | 298 CommandLine::ForCurrentProcess()->AppendSwitch( |
306 switches::kEnablePrintPreview); | 299 switches::kEnablePrintPreview); |
307 #endif | |
308 | 300 |
309 RenderViewTest::SetUp(); | 301 RenderViewTest::SetUp(); |
310 } | 302 } |
311 | 303 |
312 protected: | 304 protected: |
313 void VerifyPrintPreviewFailed(bool did_fail) { | 305 void VerifyPrintPreviewFailed(bool did_fail) { |
314 bool print_preview_failed = (render_thread_.sink().GetUniqueMessageMatching( | 306 bool print_preview_failed = (render_thread_.sink().GetUniqueMessageMatching( |
315 PrintHostMsg_PrintPreviewFailed::ID) != NULL); | 307 PrintHostMsg_PrintPreviewFailed::ID) != NULL); |
316 EXPECT_EQ(did_fail, print_preview_failed); | 308 EXPECT_EQ(did_fail, print_preview_failed); |
317 } | 309 } |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 LoadHTML(kPrintPreviewHTML); | 381 LoadHTML(kPrintPreviewHTML); |
390 | 382 |
391 // An empty dictionary should fail. | 383 // An empty dictionary should fail. |
392 DictionaryValue empty_dict; | 384 DictionaryValue empty_dict; |
393 PrintWebViewHelper::Get(view_)->OnPrintForPrintPreview(empty_dict); | 385 PrintWebViewHelper::Get(view_)->OnPrintForPrintPreview(empty_dict); |
394 | 386 |
395 VerifyPrintFailed(true); | 387 VerifyPrintFailed(true); |
396 VerifyPagesPrinted(false); | 388 VerifyPagesPrinted(false); |
397 } | 389 } |
398 #endif // !defined(OS_CHROMEOS) | 390 #endif // !defined(OS_CHROMEOS) |
OLD | NEW |