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

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

Issue 63273002: Rename WebKit namespace to blink (part 4) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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) 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "chrome/common/chrome_switches.h" 6 #include "chrome/common/chrome_switches.h"
7 #include "chrome/common/print_messages.h" 7 #include "chrome/common/print_messages.h"
8 #include "chrome/renderer/mock_printer.h" 8 #include "chrome/renderer/mock_printer.h"
9 #include "chrome/renderer/printing/print_web_view_helper.h" 9 #include "chrome/renderer/printing/print_web_view_helper.h"
10 #include "chrome/test/base/chrome_render_view_test.h" 10 #include "chrome/test/base/chrome_render_view_test.h"
11 #include "content/public/renderer/render_view.h" 11 #include "content/public/renderer/render_view.h"
12 #include "printing/print_job_constants.h" 12 #include "printing/print_job_constants.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 #include "third_party/WebKit/public/platform/WebString.h" 14 #include "third_party/WebKit/public/platform/WebString.h"
15 #include "third_party/WebKit/public/web/WebFrame.h" 15 #include "third_party/WebKit/public/web/WebFrame.h"
16 #include "third_party/WebKit/public/web/WebRange.h" 16 #include "third_party/WebKit/public/web/WebRange.h"
17 #include "third_party/WebKit/public/web/WebView.h" 17 #include "third_party/WebKit/public/web/WebView.h"
18 18
19 #if defined(OS_WIN) || defined(OS_MACOSX) 19 #if defined(OS_WIN) || defined(OS_MACOSX)
20 #include "base/file_util.h" 20 #include "base/file_util.h"
21 #include "printing/image.h" 21 #include "printing/image.h"
22 22
23 using WebKit::WebFrame; 23 using blink::WebFrame;
24 using WebKit::WebString; 24 using blink::WebString;
25 #endif 25 #endif
26 26
27 namespace printing { 27 namespace printing {
28 28
29 namespace { 29 namespace {
30 30
31 // A simple web page. 31 // A simple web page.
32 const char kHelloWorldHTML[] = "<body><p>Hello World!</p></body>"; 32 const char kHelloWorldHTML[] = "<body><p>Hello World!</p></body>";
33 33
34 // A simple webpage with a button to print itself with. 34 // A simple webpage with a button to print itself with.
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 VerifyPagesPrinted(false); 258 VerifyPagesPrinted(false);
259 259
260 // Try again as if user initiated, without resetting the print count. 260 // Try again as if user initiated, without resetting the print count.
261 chrome_render_thread_->printer()->ResetPrinter(); 261 chrome_render_thread_->printer()->ResetPrinter();
262 LoadHTML(kPrintOnUserAction); 262 LoadHTML(kPrintOnUserAction);
263 gfx::Size new_size(200, 100); 263 gfx::Size new_size(200, 100);
264 Resize(new_size, gfx::Rect(), false); 264 Resize(new_size, gfx::Rect(), false);
265 265
266 gfx::Rect bounds = GetElementBounds("print"); 266 gfx::Rect bounds = GetElementBounds("print");
267 EXPECT_FALSE(bounds.IsEmpty()); 267 EXPECT_FALSE(bounds.IsEmpty());
268 WebKit::WebMouseEvent mouse_event; 268 blink::WebMouseEvent mouse_event;
269 mouse_event.type = WebKit::WebInputEvent::MouseDown; 269 mouse_event.type = blink::WebInputEvent::MouseDown;
270 mouse_event.button = WebKit::WebMouseEvent::ButtonLeft; 270 mouse_event.button = blink::WebMouseEvent::ButtonLeft;
271 mouse_event.x = bounds.CenterPoint().x(); 271 mouse_event.x = bounds.CenterPoint().x();
272 mouse_event.y = bounds.CenterPoint().y(); 272 mouse_event.y = bounds.CenterPoint().y();
273 mouse_event.clickCount = 1; 273 mouse_event.clickCount = 1;
274 SendWebMouseEvent(mouse_event); 274 SendWebMouseEvent(mouse_event);
275 mouse_event.type = WebKit::WebInputEvent::MouseUp; 275 mouse_event.type = blink::WebInputEvent::MouseUp;
276 SendWebMouseEvent(mouse_event); 276 SendWebMouseEvent(mouse_event);
277 ProcessPendingMessages(); 277 ProcessPendingMessages();
278 278
279 VerifyPageCount(1); 279 VerifyPageCount(1);
280 VerifyPagesPrinted(true); 280 VerifyPagesPrinted(true);
281 } 281 }
282 282
283 TEST_F(PrintWebViewHelperTest, BlockScriptInitiatedPrintingFromPopup) { 283 TEST_F(PrintWebViewHelperTest, BlockScriptInitiatedPrintingFromPopup) {
284 PrintWebViewHelper* print_web_view_helper = PrintWebViewHelper::Get(view_); 284 PrintWebViewHelper* print_web_view_helper = PrintWebViewHelper::Get(view_);
285 print_web_view_helper->SetScriptedPrintBlocked(true); 285 print_web_view_helper->SetScriptedPrintBlocked(true);
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 VerifyPrintPreviewCancelled(false); 773 VerifyPrintPreviewCancelled(false);
774 VerifyPrintPreviewFailed(false); 774 VerifyPrintPreviewFailed(false);
775 VerifyPrintPreviewGenerated(true); 775 VerifyPrintPreviewGenerated(true);
776 VerifyPagesPrinted(false); 776 VerifyPagesPrinted(false);
777 } 777 }
778 778
779 // Test to verify that preview generated only for one page. 779 // Test to verify that preview generated only for one page.
780 TEST_F(PrintWebViewHelperPreviewTest, OnPrintPreviewForSelectedText) { 780 TEST_F(PrintWebViewHelperPreviewTest, OnPrintPreviewForSelectedText) {
781 LoadHTML(kMultipageHTML); 781 LoadHTML(kMultipageHTML);
782 GetMainFrame()->selectRange( 782 GetMainFrame()->selectRange(
783 WebKit::WebRange::fromDocumentRange(GetMainFrame(), 1, 3)); 783 blink::WebRange::fromDocumentRange(GetMainFrame(), 1, 3));
784 784
785 // Fill in some dummy values. 785 // Fill in some dummy values.
786 base::DictionaryValue dict; 786 base::DictionaryValue dict;
787 CreatePrintSettingsDictionary(&dict); 787 CreatePrintSettingsDictionary(&dict);
788 dict.SetBoolean(kSettingShouldPrintSelectionOnly, true); 788 dict.SetBoolean(kSettingShouldPrintSelectionOnly, true);
789 789
790 OnPrintPreview(dict); 790 OnPrintPreview(dict);
791 791
792 VerifyPreviewPageCount(1); 792 VerifyPreviewPageCount(1);
793 VerifyPrintPreviewCancelled(false); 793 VerifyPrintPreviewCancelled(false);
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 chrome_render_thread_->printer()->ResetPrinter(); 971 chrome_render_thread_->printer()->ResetPrinter();
972 VerifyPagesPrinted(false); 972 VerifyPagesPrinted(false);
973 973
974 // Pretend user will print, should not be throttled. 974 // Pretend user will print, should not be throttled.
975 chrome_render_thread_->set_print_dialog_user_response(true); 975 chrome_render_thread_->set_print_dialog_user_response(true);
976 PrintWithJavaScript(); 976 PrintWithJavaScript();
977 VerifyPagesPrinted(true); 977 VerifyPagesPrinted(true);
978 } 978 }
979 979
980 } // namespace printing 980 } // namespace printing
OLDNEW
« no previous file with comments | « chrome/renderer/printing/print_web_view_helper.cc ('k') | chrome/renderer/printing/print_web_view_helper_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698