Chromium Code Reviews| 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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 181 LoadHTML(kPrintWithJSHTML); | 181 LoadHTML(kPrintWithJSHTML); |
| 182 LoadHTML(kPrintWithJSHTML); | 182 LoadHTML(kPrintWithJSHTML); |
| 183 LoadHTML(kPrintWithJSHTML); | 183 LoadHTML(kPrintWithJSHTML); |
| 184 VerifyPagesPrinted(false); | 184 VerifyPagesPrinted(false); |
| 185 | 185 |
| 186 // Pretend user will print. (but printing is blocked.) | 186 // Pretend user will print. (but printing is blocked.) |
| 187 chrome_render_thread_->set_print_dialog_user_response(true); | 187 chrome_render_thread_->set_print_dialog_user_response(true); |
| 188 LoadHTML(kPrintWithJSHTML); | 188 LoadHTML(kPrintWithJSHTML); |
| 189 VerifyPagesPrinted(false); | 189 VerifyPagesPrinted(false); |
| 190 | 190 |
| 191 // Unblock script initiated printing and verify printing works. | 191 // Unblock based on count. |
| 192 PrintWebViewHelper::Get(view_)->ResetScriptedPrintCount(); | 192 PrintWebViewHelper::Get(view_)->ResetScriptedPrintCount(); |
|
Lei Zhang
2012/03/19 20:19:32
You are missing a test here to make sure resetting
Albert Bodenhamer
2012/03/19 23:16:17
Good catch. I've split this into 2 different test
| |
| 193 | |
| 194 // Simulate a blocked popup. | |
| 195 chrome_render_thread_->printer()->ResetPrinter(); | |
| 196 chrome_render_thread_->printer()->SetScriptedPrintAllowed(false); | |
| 197 LoadHTML(kPrintWithJSHTML); | |
| 198 VerifyPagesPrinted(false); | |
| 199 | |
| 200 // Unblock and verify printing works. | |
| 201 chrome_render_thread_->printer()->SetScriptedPrintAllowed(true); | |
| 193 chrome_render_thread_->printer()->ResetPrinter(); | 202 chrome_render_thread_->printer()->ResetPrinter(); |
| 194 LoadHTML(kPrintWithJSHTML); | 203 LoadHTML(kPrintWithJSHTML); |
| 195 VerifyPageCount(1); | 204 VerifyPageCount(1); |
| 196 VerifyPagesPrinted(true); | 205 VerifyPagesPrinted(true); |
| 197 } | 206 } |
| 198 | 207 |
| 199 #if defined(OS_WIN) || defined(OS_MACOSX) | 208 #if defined(OS_WIN) || defined(OS_MACOSX) |
| 200 // TODO(estade): I don't think this test is worth porting to Linux. We will have | 209 // 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 | 210 // 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 | 211 // printing, and the comment below by sverrir suggests that it doesn't do much |
| (...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 809 // Fill in some dummy values. | 818 // Fill in some dummy values. |
| 810 DictionaryValue dict; | 819 DictionaryValue dict; |
| 811 CreatePrintSettingsDictionary(&dict); | 820 CreatePrintSettingsDictionary(&dict); |
| 812 OnPrintForPrintPreview(dict); | 821 OnPrintForPrintPreview(dict); |
| 813 | 822 |
| 814 VerifyPrintFailed(true); | 823 VerifyPrintFailed(true); |
| 815 VerifyPagesPrinted(false); | 824 VerifyPagesPrinted(false); |
| 816 } | 825 } |
| 817 | 826 |
| 818 #endif // !defined(OS_CHROMEOS) | 827 #endif // !defined(OS_CHROMEOS) |
| OLD | NEW |