| 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 "components/printing/renderer/print_web_view_helper.h" | 5 #include "components/printing/renderer/print_web_view_helper.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <tuple> | 10 #include <tuple> |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 | 321 |
| 322 // Pretend user will print. (but printing is blocked.) | 322 // Pretend user will print. (but printing is blocked.) |
| 323 print_render_thread_->set_print_dialog_user_response(true); | 323 print_render_thread_->set_print_dialog_user_response(true); |
| 324 PrintWithJavaScript(); | 324 PrintWithJavaScript(); |
| 325 VerifyPagesPrinted(false); | 325 VerifyPagesPrinted(false); |
| 326 | 326 |
| 327 // Try again as if user initiated, without resetting the print count. | 327 // Try again as if user initiated, without resetting the print count. |
| 328 print_render_thread_->printer()->ResetPrinter(); | 328 print_render_thread_->printer()->ResetPrinter(); |
| 329 LoadHTML(kPrintOnUserAction); | 329 LoadHTML(kPrintOnUserAction); |
| 330 gfx::Size new_size(200, 100); | 330 gfx::Size new_size(200, 100); |
| 331 Resize(new_size, gfx::Rect(), false); | 331 Resize(new_size, false); |
| 332 | 332 |
| 333 gfx::Rect bounds = GetElementBounds("print"); | 333 gfx::Rect bounds = GetElementBounds("print"); |
| 334 EXPECT_FALSE(bounds.IsEmpty()); | 334 EXPECT_FALSE(bounds.IsEmpty()); |
| 335 blink::WebMouseEvent mouse_event; | 335 blink::WebMouseEvent mouse_event; |
| 336 mouse_event.type = blink::WebInputEvent::MouseDown; | 336 mouse_event.type = blink::WebInputEvent::MouseDown; |
| 337 mouse_event.button = blink::WebMouseEvent::Button::Left; | 337 mouse_event.button = blink::WebMouseEvent::Button::Left; |
| 338 mouse_event.x = bounds.CenterPoint().x(); | 338 mouse_event.x = bounds.CenterPoint().x(); |
| 339 mouse_event.y = bounds.CenterPoint().y(); | 339 mouse_event.y = bounds.CenterPoint().y(); |
| 340 mouse_event.clickCount = 1; | 340 mouse_event.clickCount = 1; |
| 341 SendWebMouseEvent(mouse_event); | 341 SendWebMouseEvent(mouse_event); |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 VerifyPreviewRequest(false); | 628 VerifyPreviewRequest(false); |
| 629 | 629 |
| 630 print_web_view_helper->SetScriptedPrintBlocked(false); | 630 print_web_view_helper->SetScriptedPrintBlocked(false); |
| 631 PrintWithJavaScript(); | 631 PrintWithJavaScript(); |
| 632 VerifyPreviewRequest(true); | 632 VerifyPreviewRequest(true); |
| 633 } | 633 } |
| 634 | 634 |
| 635 TEST_F(MAYBE_PrintWebViewHelperPreviewTest, PrintWithJavaScript) { | 635 TEST_F(MAYBE_PrintWebViewHelperPreviewTest, PrintWithJavaScript) { |
| 636 LoadHTML(kPrintOnUserAction); | 636 LoadHTML(kPrintOnUserAction); |
| 637 gfx::Size new_size(200, 100); | 637 gfx::Size new_size(200, 100); |
| 638 Resize(new_size, gfx::Rect(), false); | 638 Resize(new_size, false); |
| 639 | 639 |
| 640 gfx::Rect bounds = GetElementBounds("print"); | 640 gfx::Rect bounds = GetElementBounds("print"); |
| 641 EXPECT_FALSE(bounds.IsEmpty()); | 641 EXPECT_FALSE(bounds.IsEmpty()); |
| 642 blink::WebMouseEvent mouse_event; | 642 blink::WebMouseEvent mouse_event; |
| 643 mouse_event.type = blink::WebInputEvent::MouseDown; | 643 mouse_event.type = blink::WebInputEvent::MouseDown; |
| 644 mouse_event.button = blink::WebMouseEvent::Button::Left; | 644 mouse_event.button = blink::WebMouseEvent::Button::Left; |
| 645 mouse_event.x = bounds.CenterPoint().x(); | 645 mouse_event.x = bounds.CenterPoint().x(); |
| 646 mouse_event.y = bounds.CenterPoint().y(); | 646 mouse_event.y = bounds.CenterPoint().y(); |
| 647 mouse_event.clickCount = 1; | 647 mouse_event.clickCount = 1; |
| 648 SendWebMouseEvent(mouse_event); | 648 SendWebMouseEvent(mouse_event); |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1053 | 1053 |
| 1054 VerifyPrintFailed(true); | 1054 VerifyPrintFailed(true); |
| 1055 VerifyPagesPrinted(false); | 1055 VerifyPagesPrinted(false); |
| 1056 } | 1056 } |
| 1057 #endif // defined(ENABLE_BASIC_PRINTING) | 1057 #endif // defined(ENABLE_BASIC_PRINTING) |
| 1058 #endif // defined(ENABLE_PRINT_PREVIEW) | 1058 #endif // defined(ENABLE_PRINT_PREVIEW) |
| 1059 | 1059 |
| 1060 #endif // !defined(OS_CHROMEOS) | 1060 #endif // !defined(OS_CHROMEOS) |
| 1061 | 1061 |
| 1062 } // namespace printing | 1062 } // namespace printing |
| OLD | NEW |