| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/base/chrome_render_view_test.h" | 8 #include "chrome/test/base/chrome_render_view_test.h" |
| 9 #include "content/public/renderer/render_view.h" | 9 #include "content/public/renderer/render_view.h" |
| 10 #include "printing/print_job_constants.h" | 10 #include "printing/print_job_constants.h" |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 VerifyPagesPrinted(false); | 189 VerifyPagesPrinted(false); |
| 190 | 190 |
| 191 // Unblock script initiated printing and verify printing works. | 191 // Unblock script initiated printing and verify printing works. |
| 192 PrintWebViewHelper::Get(view_)->ResetScriptedPrintCount(); | 192 PrintWebViewHelper::Get(view_)->ResetScriptedPrintCount(); |
| 193 chrome_render_thread_->printer()->ResetPrinter(); | 193 chrome_render_thread_->printer()->ResetPrinter(); |
| 194 LoadHTML(kPrintWithJSHTML); | 194 LoadHTML(kPrintWithJSHTML); |
| 195 VerifyPageCount(1); | 195 VerifyPageCount(1); |
| 196 VerifyPagesPrinted(true); | 196 VerifyPagesPrinted(true); |
| 197 } | 197 } |
| 198 | 198 |
| 199 TEST_F(PrintWebViewHelperTest, BlockScriptInitiatedPrintingFromPopup) { |
| 200 // Simulate a blocked popup. |
| 201 chrome_render_thread_->printer()->ResetPrinter(); |
| 202 chrome_render_thread_->printer()->SetScriptedPrintAllowed(false); |
| 203 LoadHTML(kPrintWithJSHTML); |
| 204 VerifyPagesPrinted(false); |
| 205 |
| 206 // Unblock and verify printing works. |
| 207 chrome_render_thread_->printer()->SetScriptedPrintAllowed(true); |
| 208 chrome_render_thread_->printer()->ResetPrinter(); |
| 209 LoadHTML(kPrintWithJSHTML); |
| 210 VerifyPageCount(1); |
| 211 VerifyPagesPrinted(true); |
| 212 } |
| 213 |
| 199 #if defined(OS_WIN) || defined(OS_MACOSX) | 214 #if defined(OS_WIN) || defined(OS_MACOSX) |
| 200 // TODO(estade): I don't think this test is worth porting to Linux. We will have | 215 // TODO(estade): I don't think this test is worth porting to Linux. We will have |
| 201 // to rip out and replace most of the IPC code if we ever plan to improve | 216 // to rip out and replace most of the IPC code if we ever plan to improve |
| 202 // printing, and the comment below by sverrir suggests that it doesn't do much | 217 // printing, and the comment below by sverrir suggests that it doesn't do much |
| 203 // for us anyway. | 218 // for us anyway. |
| 204 TEST_F(PrintWebViewHelperTest, PrintWithIframe) { | 219 TEST_F(PrintWebViewHelperTest, PrintWithIframe) { |
| 205 // Document that populates an iframe. | 220 // Document that populates an iframe. |
| 206 const char html[] = | 221 const char html[] = |
| 207 "<html><body>Lorem Ipsum:" | 222 "<html><body>Lorem Ipsum:" |
| 208 "<iframe name=\"sub1\" id=\"sub1\"></iframe><script>" | 223 "<iframe name=\"sub1\" id=\"sub1\"></iframe><script>" |
| (...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 809 // Fill in some dummy values. | 824 // Fill in some dummy values. |
| 810 DictionaryValue dict; | 825 DictionaryValue dict; |
| 811 CreatePrintSettingsDictionary(&dict); | 826 CreatePrintSettingsDictionary(&dict); |
| 812 OnPrintForPrintPreview(dict); | 827 OnPrintForPrintPreview(dict); |
| 813 | 828 |
| 814 VerifyPrintFailed(true); | 829 VerifyPrintFailed(true); |
| 815 VerifyPagesPrinted(false); | 830 VerifyPagesPrinted(false); |
| 816 } | 831 } |
| 817 | 832 |
| 818 #endif // !defined(OS_CHROMEOS) | 833 #endif // !defined(OS_CHROMEOS) |
| OLD | NEW |