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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <tuple> | 9 #include <tuple> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/location.h" | 13 #include "base/location.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
16 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
17 #include "base/threading/thread_task_runner_handle.h" | 17 #include "base/threading/thread_task_runner_handle.h" |
18 #include "base/timer/timer.h" | 18 #include "base/timer/timer.h" |
19 #include "build/build_config.h" | 19 #include "build/build_config.h" |
20 #include "content/browser/browser_thread_impl.h" | |
21 #include "content/browser/gpu/compositor_util.h" | 20 #include "content/browser/gpu/compositor_util.h" |
22 #include "content/browser/renderer_host/input/input_router_impl.h" | 21 #include "content/browser/renderer_host/input/input_router_impl.h" |
23 #include "content/browser/renderer_host/render_widget_host_delegate.h" | 22 #include "content/browser/renderer_host/render_widget_host_delegate.h" |
24 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 23 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
25 #include "content/common/input/synthetic_web_input_event_builders.h" | 24 #include "content/common/input/synthetic_web_input_event_builders.h" |
26 #include "content/common/input_messages.h" | 25 #include "content/common/input_messages.h" |
27 #include "content/common/resize_params.h" | 26 #include "content/common/resize_params.h" |
28 #include "content/common/view_messages.h" | 27 #include "content/common/view_messages.h" |
29 #include "content/public/common/content_switches.h" | 28 #include "content/public/common/content_switches.h" |
30 #include "content/public/test/mock_render_process_host.h" | 29 #include "content/public/test/mock_render_process_host.h" |
31 #include "content/public/test/test_browser_context.h" | 30 #include "content/public/test/test_browser_context.h" |
| 31 #include "content/public/test/test_browser_thread_bundle.h" |
32 #include "content/test/test_render_view_host.h" | 32 #include "content/test/test_render_view_host.h" |
33 #include "testing/gtest/include/gtest/gtest.h" | 33 #include "testing/gtest/include/gtest/gtest.h" |
34 #include "ui/display/screen.h" | 34 #include "ui/display/screen.h" |
35 #include "ui/events/blink/web_input_event_traits.h" | 35 #include "ui/events/blink/web_input_event_traits.h" |
36 #include "ui/events/keycodes/keyboard_codes.h" | 36 #include "ui/events/keycodes/keyboard_codes.h" |
37 #include "ui/gfx/canvas.h" | 37 #include "ui/gfx/canvas.h" |
38 | 38 |
39 #if defined(OS_ANDROID) | 39 #if defined(OS_ANDROID) |
40 #include "content/browser/renderer_host/context_provider_factory_impl_android.h" | 40 #include "content/browser/renderer_host/context_provider_factory_impl_android.h" |
41 #include "content/browser/renderer_host/render_widget_host_view_android.h" | 41 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 | 634 |
635 const WebInputEvent* GetInputEventFromMessage(const IPC::Message& message) { | 635 const WebInputEvent* GetInputEventFromMessage(const IPC::Message& message) { |
636 base::PickleIterator iter(message); | 636 base::PickleIterator iter(message); |
637 const char* data; | 637 const char* data; |
638 int data_length; | 638 int data_length; |
639 if (!iter.ReadData(&data, &data_length)) | 639 if (!iter.ReadData(&data, &data_length)) |
640 return NULL; | 640 return NULL; |
641 return reinterpret_cast<const WebInputEvent*>(data); | 641 return reinterpret_cast<const WebInputEvent*>(data); |
642 } | 642 } |
643 | 643 |
644 base::MessageLoopForUI message_loop_; | |
645 | |
646 std::unique_ptr<TestBrowserContext> browser_context_; | 644 std::unique_ptr<TestBrowserContext> browser_context_; |
647 RenderWidgetHostProcess* process_; // Deleted automatically by the widget. | 645 RenderWidgetHostProcess* process_; // Deleted automatically by the widget. |
648 std::unique_ptr<MockRenderWidgetHostDelegate> delegate_; | 646 std::unique_ptr<MockRenderWidgetHostDelegate> delegate_; |
649 std::unique_ptr<MockRenderWidgetHost> host_; | 647 std::unique_ptr<MockRenderWidgetHost> host_; |
650 std::unique_ptr<TestView> view_; | 648 std::unique_ptr<TestView> view_; |
651 std::unique_ptr<display::Screen> screen_; | 649 std::unique_ptr<display::Screen> screen_; |
652 bool handle_key_press_event_; | 650 bool handle_key_press_event_; |
653 bool handle_mouse_event_; | 651 bool handle_mouse_event_; |
654 double last_simulated_event_time_seconds_; | 652 double last_simulated_event_time_seconds_; |
655 double simulated_event_time_delta_seconds_; | 653 double simulated_event_time_delta_seconds_; |
656 | 654 |
657 #if defined(OS_ANDROID) | 655 #if defined(OS_ANDROID) |
658 MockGpuChannelEstablishFactory gpu_channel_factory_; | 656 MockGpuChannelEstablishFactory gpu_channel_factory_; |
659 #endif | 657 #endif |
660 | 658 |
661 private: | 659 private: |
662 SyntheticWebTouchEvent touch_event_; | 660 SyntheticWebTouchEvent touch_event_; |
663 | 661 |
| 662 TestBrowserThreadBundle thread_bundle_; |
| 663 |
664 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostTest); | 664 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostTest); |
665 }; | 665 }; |
666 | 666 |
667 #if GTEST_HAS_PARAM_TEST | 667 #if GTEST_HAS_PARAM_TEST |
668 // RenderWidgetHostWithSourceTest ---------------------------------------------- | 668 // RenderWidgetHostWithSourceTest ---------------------------------------------- |
669 | 669 |
670 // This is for tests that are to be run for all source devices. | 670 // This is for tests that are to be run for all source devices. |
671 class RenderWidgetHostWithSourceTest | 671 class RenderWidgetHostWithSourceTest |
672 : public RenderWidgetHostTest, | 672 : public RenderWidgetHostTest, |
673 public testing::WithParamInterface<WebGestureDevice> {}; | 673 public testing::WithParamInterface<WebGestureDevice> {}; |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
889 EXPECT_FALSE(std::get<0>(sent_background)); | 889 EXPECT_FALSE(std::get<0>(sent_background)); |
890 | 890 |
891 host_->SetView(NULL); | 891 host_->SetView(NULL); |
892 static_cast<RenderWidgetHostViewBase*>(view.release())->Destroy(); | 892 static_cast<RenderWidgetHostViewBase*>(view.release())->Destroy(); |
893 } | 893 } |
894 #endif | 894 #endif |
895 | 895 |
896 // Test that we don't paint when we're hidden, but we still send the ACK. Most | 896 // Test that we don't paint when we're hidden, but we still send the ACK. Most |
897 // of the rest of the painting is tested in the GetBackingStore* ones. | 897 // of the rest of the painting is tested in the GetBackingStore* ones. |
898 TEST_F(RenderWidgetHostTest, HiddenPaint) { | 898 TEST_F(RenderWidgetHostTest, HiddenPaint) { |
899 BrowserThreadImpl ui_thread(BrowserThread::UI, base::MessageLoop::current()); | |
900 // Hide the widget, it should have sent out a message to the renderer. | 899 // Hide the widget, it should have sent out a message to the renderer. |
901 EXPECT_FALSE(host_->is_hidden_); | 900 EXPECT_FALSE(host_->is_hidden_); |
902 host_->WasHidden(); | 901 host_->WasHidden(); |
903 EXPECT_TRUE(host_->is_hidden_); | 902 EXPECT_TRUE(host_->is_hidden_); |
904 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(ViewMsg_WasHidden::ID)); | 903 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(ViewMsg_WasHidden::ID)); |
905 | 904 |
906 // Send it an update as from the renderer. | 905 // Send it an update as from the renderer. |
907 process_->sink().ClearMessages(); | 906 process_->sink().ClearMessages(); |
908 ViewHostMsg_UpdateRect_Params params; | 907 ViewHostMsg_UpdateRect_Params params; |
909 params.view_size = gfx::Size(100, 100); | 908 params.view_size = gfx::Size(100, 100); |
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1707 ui::LatencyInfo()); | 1706 ui::LatencyInfo()); |
1708 | 1707 |
1709 | 1708 |
1710 // Tests RWHI::ForwardWheelEventWithLatencyInfo(). | 1709 // Tests RWHI::ForwardWheelEventWithLatencyInfo(). |
1711 SimulateWheelEventWithLatencyInfo(-5, 0, 0, true, ui::LatencyInfo()); | 1710 SimulateWheelEventWithLatencyInfo(-5, 0, 0, true, ui::LatencyInfo()); |
1712 | 1711 |
1713 ASSERT_FALSE(host_->input_router()->HasPendingEvents()); | 1712 ASSERT_FALSE(host_->input_router()->HasPendingEvents()); |
1714 } | 1713 } |
1715 | 1714 |
1716 } // namespace content | 1715 } // namespace content |
OLD | NEW |