Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8020)

Unified Diff: chrome/renderer/print_web_view_helper_browsertest.cc

Issue 7365003: Print Preview: Make preview generation event driven to eliminate synchronous messages. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: clang fix Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/renderer/print_web_view_helper.cc ('k') | chrome/renderer/print_web_view_helper_linux.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/print_web_view_helper_browsertest.cc
===================================================================
--- chrome/renderer/print_web_view_helper_browsertest.cc (revision 92822)
+++ chrome/renderer/print_web_view_helper_browsertest.cc (working copy)
@@ -311,13 +311,6 @@
}
protected:
- void VerifyPrintPreviewCancelled(bool did_cancel) {
- bool print_preview_cancelled =
- (render_thread_.sink().GetUniqueMessageMatching(
- PrintHostMsg_PrintPreviewCancelled::ID) != NULL);
- EXPECT_EQ(did_cancel, print_preview_cancelled);
- }
-
void VerifyPrintPreviewFailed(bool did_fail) {
bool print_preview_failed = (render_thread_.sink().GetUniqueMessageMatching(
PrintHostMsg_PrintPreviewFailed::ID) != NULL);
@@ -353,45 +346,34 @@
TEST_F(PrintWebViewHelperPreviewTest, OnPrintPreview) {
LoadHTML(kHelloWorldHTML);
+ PrintWebViewHelper::Get(view_)->OnInitiatePrintPreview();
// Fill in some dummy values.
DictionaryValue dict;
CreatePrintSettingsDictionary(&dict);
PrintWebViewHelper::Get(view_)->OnPrintPreview(dict);
- VerifyPrintPreviewCancelled(false);
+ // Need to finish simulating print preview.
+ // Generate the page and finalize it.
+ PrintWebViewHelper::Get(view_)->OnContinuePreview();
+ PrintWebViewHelper::Get(view_)->OnContinuePreview();
+
+ EXPECT_EQ(0, render_thread_.print_preview_pages_remaining());
VerifyPrintPreviewFailed(false);
VerifyPrintPreviewGenerated(true);
VerifyPagesPrinted(false);
}
-// Tests that cancelling a print preview works correctly.
-TEST_F(PrintWebViewHelperPreviewTest, OnPrintPreviewCancel) {
- LoadHTML(kPrintPreviewHTML);
-
- // Cancel the print preview.
- render_thread_.set_cancel_print_preview(true);
-
- // Fill in some dummy values.
- DictionaryValue dict;
- CreatePrintSettingsDictionary(&dict);
- PrintWebViewHelper::Get(view_)->OnPrintPreview(dict);
-
- VerifyPrintPreviewCancelled(true);
- VerifyPrintPreviewFailed(false);
- VerifyPrintPreviewGenerated(false);
- VerifyPagesPrinted(false);
-}
-
// Tests that print preview fails and receiving error messages through
// that channel all works.
TEST_F(PrintWebViewHelperPreviewTest, OnPrintPreviewFail) {
LoadHTML(kHelloWorldHTML);
+ PrintWebViewHelper::Get(view_)->OnInitiatePrintPreview();
// An empty dictionary should fail.
DictionaryValue empty_dict;
PrintWebViewHelper::Get(view_)->OnPrintPreview(empty_dict);
- VerifyPrintPreviewCancelled(false);
+ EXPECT_EQ(0, render_thread_.print_preview_pages_remaining());
VerifyPrintPreviewFailed(true);
VerifyPrintPreviewGenerated(false);
VerifyPagesPrinted(false);
« no previous file with comments | « chrome/renderer/print_web_view_helper.cc ('k') | chrome/renderer/print_web_view_helper_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698