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 "content/public/test/render_view_test.h" | 5 #include "content/public/test/render_view_test.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <cctype> | 9 #include <cctype> |
10 | 10 |
11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/memory/ptr_util.h" |
12 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
13 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
14 #include "build/build_config.h" | 15 #include "build/build_config.h" |
15 #include "components/scheduler/renderer/renderer_scheduler.h" | 16 #include "components/scheduler/renderer/renderer_scheduler.h" |
16 #include "content/app/mojo/mojo_init.h" | 17 #include "content/app/mojo/mojo_init.h" |
17 #include "content/common/dom_storage/dom_storage_types.h" | 18 #include "content/common/dom_storage/dom_storage_types.h" |
18 #include "content/common/frame_messages.h" | 19 #include "content/common/frame_messages.h" |
19 #include "content/common/input_messages.h" | 20 #include "content/common/input_messages.h" |
20 #include "content/common/resize_params.h" | 21 #include "content/common/resize_params.h" |
21 #include "content/common/site_isolation_policy.h" | 22 #include "content/common/site_isolation_policy.h" |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 RenderViewImpl::Create(compositor_deps_.get(), view_params, false); | 381 RenderViewImpl::Create(compositor_deps_.get(), view_params, false); |
381 view_ = view; | 382 view_ = view; |
382 } | 383 } |
383 | 384 |
384 void RenderViewTest::TearDown() { | 385 void RenderViewTest::TearDown() { |
385 // Run the loop so the release task from the renderwidget executes. | 386 // Run the loop so the release task from the renderwidget executes. |
386 ProcessPendingMessages(); | 387 ProcessPendingMessages(); |
387 | 388 |
388 render_thread_->SendCloseMessage(); | 389 render_thread_->SendCloseMessage(); |
389 | 390 |
390 scoped_ptr<blink::WebLeakDetector> leak_detector = | 391 std::unique_ptr<blink::WebLeakDetector> leak_detector = |
391 make_scoped_ptr(blink::WebLeakDetector::create(this)); | 392 base::WrapUnique(blink::WebLeakDetector::create(this)); |
392 | 393 |
393 leak_detector->prepareForLeakDetection(view_->GetWebView()->mainFrame()); | 394 leak_detector->prepareForLeakDetection(view_->GetWebView()->mainFrame()); |
394 | 395 |
395 view_ = NULL; | 396 view_ = NULL; |
396 mock_process_.reset(); | 397 mock_process_.reset(); |
397 | 398 |
398 // After telling the view to close and resetting mock_process_ we may get | 399 // After telling the view to close and resetting mock_process_ we may get |
399 // some new tasks which need to be processed before shutting down WebKit | 400 // some new tasks which need to be processed before shutting down WebKit |
400 // (http://crbug.com/21508). | 401 // (http://crbug.com/21508). |
401 base::RunLoop().RunUntilIdle(); | 402 base::RunLoop().RunUntilIdle(); |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 bool is_fullscreen_granted) { | 598 bool is_fullscreen_granted) { |
598 ResizeParams params; | 599 ResizeParams params; |
599 params.screen_info = blink::WebScreenInfo(); | 600 params.screen_info = blink::WebScreenInfo(); |
600 params.new_size = new_size; | 601 params.new_size = new_size; |
601 params.physical_backing_size = new_size; | 602 params.physical_backing_size = new_size; |
602 params.top_controls_height = 0.f; | 603 params.top_controls_height = 0.f; |
603 params.top_controls_shrink_blink_size = false; | 604 params.top_controls_shrink_blink_size = false; |
604 params.resizer_rect = resizer_rect; | 605 params.resizer_rect = resizer_rect; |
605 params.is_fullscreen_granted = is_fullscreen_granted; | 606 params.is_fullscreen_granted = is_fullscreen_granted; |
606 params.display_mode = blink::WebDisplayModeBrowser; | 607 params.display_mode = blink::WebDisplayModeBrowser; |
607 scoped_ptr<IPC::Message> resize_message(new ViewMsg_Resize(0, params)); | 608 std::unique_ptr<IPC::Message> resize_message(new ViewMsg_Resize(0, params)); |
608 OnMessageReceived(*resize_message); | 609 OnMessageReceived(*resize_message); |
609 } | 610 } |
610 | 611 |
611 void RenderViewTest::SimulateUserTypingASCIICharacter(char ascii_character, | 612 void RenderViewTest::SimulateUserTypingASCIICharacter(char ascii_character, |
612 bool flush_message_loop) { | 613 bool flush_message_loop) { |
613 blink::WebKeyboardEvent event; | 614 blink::WebKeyboardEvent event; |
614 event.text[0] = ascii_character; | 615 event.text[0] = ascii_character; |
615 ASSERT_TRUE(GetWindowsKeyCode(ascii_character, &event.windowsKeyCode)); | 616 ASSERT_TRUE(GetWindowsKeyCode(ascii_character, &event.windowsKeyCode)); |
616 if (isupper(ascii_character) || ascii_character == '@' || | 617 if (isupper(ascii_character) || ascii_character == '@' || |
617 ascii_character == '_') { | 618 ascii_character == '_') { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 } | 686 } |
686 | 687 |
687 ContentBrowserClient* RenderViewTest::CreateContentBrowserClient() { | 688 ContentBrowserClient* RenderViewTest::CreateContentBrowserClient() { |
688 return new ContentBrowserClient; | 689 return new ContentBrowserClient; |
689 } | 690 } |
690 | 691 |
691 ContentRendererClient* RenderViewTest::CreateContentRendererClient() { | 692 ContentRendererClient* RenderViewTest::CreateContentRendererClient() { |
692 return new ContentRendererClient; | 693 return new ContentRendererClient; |
693 } | 694 } |
694 | 695 |
695 scoped_ptr<ResizeParams> RenderViewTest::InitialSizeParams() { | 696 std::unique_ptr<ResizeParams> RenderViewTest::InitialSizeParams() { |
696 return make_scoped_ptr(new ResizeParams()); | 697 return base::WrapUnique(new ResizeParams()); |
697 } | 698 } |
698 | 699 |
699 void RenderViewTest::GoToOffset(int offset, | 700 void RenderViewTest::GoToOffset(int offset, |
700 const GURL& url, | 701 const GURL& url, |
701 const PageState& state) { | 702 const PageState& state) { |
702 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); | 703 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); |
703 | 704 |
704 int history_list_length = impl->historyBackListCount() + | 705 int history_list_length = impl->historyBackListCount() + |
705 impl->historyForwardListCount() + 1; | 706 impl->historyForwardListCount() + 1; |
706 int pending_offset = offset + impl->history_list_offset_; | 707 int pending_offset = offset + impl->history_list_offset_; |
(...skipping 15 matching lines...) Expand all Loading... |
722 static_cast<TestRenderFrame*>(impl->GetMainRenderFrame()); | 723 static_cast<TestRenderFrame*>(impl->GetMainRenderFrame()); |
723 frame->Navigate(common_params, StartNavigationParams(), request_params); | 724 frame->Navigate(common_params, StartNavigationParams(), request_params); |
724 | 725 |
725 // The load actually happens asynchronously, so we pump messages to process | 726 // The load actually happens asynchronously, so we pump messages to process |
726 // the pending continuation. | 727 // the pending continuation. |
727 FrameLoadWaiter(frame).Wait(); | 728 FrameLoadWaiter(frame).Wait(); |
728 view_->GetWebView()->updateAllLifecyclePhases(); | 729 view_->GetWebView()->updateAllLifecyclePhases(); |
729 } | 730 } |
730 | 731 |
731 } // namespace content | 732 } // namespace content |
OLD | NEW |