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

Side by Side Diff: chrome/renderer/print_web_view_helper_browsertest.cc

Issue 7544018: Print preview page selection should not require a rerendering of draft pages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove blank line Created 9 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/base/render_view_test.h" 8 #include "chrome/test/base/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 24 matching lines...) Expand all
35 35
36 void CreatePrintSettingsDictionary(DictionaryValue* dict) { 36 void CreatePrintSettingsDictionary(DictionaryValue* dict) {
37 dict->SetBoolean(printing::kSettingLandscape, false); 37 dict->SetBoolean(printing::kSettingLandscape, false);
38 dict->SetBoolean(printing::kSettingCollate, false); 38 dict->SetBoolean(printing::kSettingCollate, false);
39 dict->SetBoolean(printing::kSettingColor, false); 39 dict->SetBoolean(printing::kSettingColor, false);
40 dict->SetBoolean(printing::kSettingPrintToPDF, true); 40 dict->SetBoolean(printing::kSettingPrintToPDF, true);
41 dict->SetInteger(printing::kSettingDuplexMode, printing::SIMPLEX); 41 dict->SetInteger(printing::kSettingDuplexMode, printing::SIMPLEX);
42 dict->SetInteger(printing::kSettingCopies, 1); 42 dict->SetInteger(printing::kSettingCopies, 1);
43 dict->SetString(printing::kSettingDeviceName, "dummy"); 43 dict->SetString(printing::kSettingDeviceName, "dummy");
44 dict->SetInteger(printing::kPreviewRequestID, 12345); 44 dict->SetInteger(printing::kPreviewRequestID, 12345);
45 dict->SetBoolean(printing::kSettingGenerateDraftData, true);
vandebo (ex-Chrome) 2011/08/08 20:11:46 Should we create another test for generating the c
45 } 46 }
46 47
47 } // namespace 48 } // namespace
48 49
49 class PrintWebViewHelperTestBase : public RenderViewTest { 50 class PrintWebViewHelperTestBase : public RenderViewTest {
50 public: 51 public:
51 PrintWebViewHelperTestBase() {} 52 PrintWebViewHelperTestBase() {}
52 ~PrintWebViewHelperTestBase() {} 53 ~PrintWebViewHelperTestBase() {}
53 54
54 protected: 55 protected:
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 LoadHTML(kHelloWorldHTML); 348 LoadHTML(kHelloWorldHTML);
348 349
349 PrintWebViewHelper::Get(view_)->OnInitiatePrintPreview(); 350 PrintWebViewHelper::Get(view_)->OnInitiatePrintPreview();
350 // Fill in some dummy values. 351 // Fill in some dummy values.
351 DictionaryValue dict; 352 DictionaryValue dict;
352 CreatePrintSettingsDictionary(&dict); 353 CreatePrintSettingsDictionary(&dict);
353 PrintWebViewHelper::Get(view_)->OnPrintPreview(dict); 354 PrintWebViewHelper::Get(view_)->OnPrintPreview(dict);
354 355
355 // Need to finish simulating print preview. 356 // Need to finish simulating print preview.
356 // Generate the page and finalize it. 357 // Generate the page and finalize it.
357 PrintWebViewHelper::Get(view_)->OnContinuePreview( 358 PrintWebViewHelper::Get(view_)->OnContinuePreview();
358 printing::INVALID_PAGE_INDEX); 359 PrintWebViewHelper::Get(view_)->OnContinuePreview();
359 PrintWebViewHelper::Get(view_)->OnContinuePreview(
360 printing::INVALID_PAGE_INDEX);
361 360
362 EXPECT_EQ(0, render_thread_.print_preview_pages_remaining()); 361 EXPECT_EQ(0, render_thread_.print_preview_pages_remaining());
363 VerifyPrintPreviewFailed(false); 362 VerifyPrintPreviewFailed(false);
364 VerifyPrintPreviewGenerated(true); 363 VerifyPrintPreviewGenerated(true);
365 VerifyPagesPrinted(false); 364 VerifyPagesPrinted(false);
366 } 365 }
367 366
368 // Tests that print preview fails and receiving error messages through 367 // Tests that print preview fails and receiving error messages through
369 // that channel all works. 368 // that channel all works.
370 TEST_F(PrintWebViewHelperPreviewTest, OnPrintPreviewFail) { 369 TEST_F(PrintWebViewHelperPreviewTest, OnPrintPreviewFail) {
(...skipping 30 matching lines...) Expand all
401 LoadHTML(kPrintPreviewHTML); 400 LoadHTML(kPrintPreviewHTML);
402 401
403 // An empty dictionary should fail. 402 // An empty dictionary should fail.
404 DictionaryValue empty_dict; 403 DictionaryValue empty_dict;
405 PrintWebViewHelper::Get(view_)->OnPrintForPrintPreview(empty_dict); 404 PrintWebViewHelper::Get(view_)->OnPrintForPrintPreview(empty_dict);
406 405
407 VerifyPrintFailed(true); 406 VerifyPrintFailed(true);
408 VerifyPagesPrinted(false); 407 VerifyPagesPrinted(false);
409 } 408 }
410 #endif // !defined(OS_CHROMEOS) 409 #endif // !defined(OS_CHROMEOS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698