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 | 10 |
10 #include "base/bind.h" | 11 #include "base/bind.h" |
11 #include "base/command_line.h" | 12 #include "base/command_line.h" |
12 #include "base/location.h" | 13 #include "base/location.h" |
13 #include "base/macros.h" | 14 #include "base/macros.h" |
14 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
15 #include "base/threading/thread_task_runner_handle.h" | 16 #include "base/threading/thread_task_runner_handle.h" |
16 #include "base/timer/timer.h" | 17 #include "base/timer/timer.h" |
17 #include "build/build_config.h" | 18 #include "build/build_config.h" |
18 #include "content/browser/browser_thread_impl.h" | 19 #include "content/browser/browser_thread_impl.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 | 61 |
61 namespace content { | 62 namespace content { |
62 | 63 |
63 std::string GetInputMessageTypes(MockRenderProcessHost* process) { | 64 std::string GetInputMessageTypes(MockRenderProcessHost* process) { |
64 std::string result; | 65 std::string result; |
65 for (size_t i = 0; i < process->sink().message_count(); ++i) { | 66 for (size_t i = 0; i < process->sink().message_count(); ++i) { |
66 const IPC::Message* message = process->sink().GetMessageAt(i); | 67 const IPC::Message* message = process->sink().GetMessageAt(i); |
67 EXPECT_EQ(InputMsg_HandleInputEvent::ID, message->type()); | 68 EXPECT_EQ(InputMsg_HandleInputEvent::ID, message->type()); |
68 InputMsg_HandleInputEvent::Param params; | 69 InputMsg_HandleInputEvent::Param params; |
69 EXPECT_TRUE(InputMsg_HandleInputEvent::Read(message, ¶ms)); | 70 EXPECT_TRUE(InputMsg_HandleInputEvent::Read(message, ¶ms)); |
70 const WebInputEvent* event = base::get<0>(params); | 71 const WebInputEvent* event = std::get<0>(params); |
71 if (i != 0) | 72 if (i != 0) |
72 result += " "; | 73 result += " "; |
73 result += WebInputEventTraits::GetName(event->type); | 74 result += WebInputEventTraits::GetName(event->type); |
74 } | 75 } |
75 process->sink().ClearMessages(); | 76 process->sink().ClearMessages(); |
76 return result; | 77 return result; |
77 } | 78 } |
78 | 79 |
79 // MockInputRouter ------------------------------------------------------------- | 80 // MockInputRouter ------------------------------------------------------------- |
80 | 81 |
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
851 host_->SetView(view.get()); | 852 host_->SetView(view.get()); |
852 | 853 |
853 EXPECT_TRUE(view->GetBackgroundOpaque()); | 854 EXPECT_TRUE(view->GetBackgroundOpaque()); |
854 view->SetBackgroundColor(SK_ColorTRANSPARENT); | 855 view->SetBackgroundColor(SK_ColorTRANSPARENT); |
855 EXPECT_FALSE(view->GetBackgroundOpaque()); | 856 EXPECT_FALSE(view->GetBackgroundOpaque()); |
856 | 857 |
857 const IPC::Message* set_background = | 858 const IPC::Message* set_background = |
858 process_->sink().GetUniqueMessageMatching( | 859 process_->sink().GetUniqueMessageMatching( |
859 ViewMsg_SetBackgroundOpaque::ID); | 860 ViewMsg_SetBackgroundOpaque::ID); |
860 ASSERT_TRUE(set_background); | 861 ASSERT_TRUE(set_background); |
861 base::Tuple<bool> sent_background; | 862 std::tuple<bool> sent_background; |
862 ViewMsg_SetBackgroundOpaque::Read(set_background, &sent_background); | 863 ViewMsg_SetBackgroundOpaque::Read(set_background, &sent_background); |
863 EXPECT_FALSE(base::get<0>(sent_background)); | 864 EXPECT_FALSE(std::get<0>(sent_background)); |
864 | 865 |
865 #if defined(USE_AURA) | 866 #if defined(USE_AURA) |
866 // See the comment above |InitAsChild(NULL)|. | 867 // See the comment above |InitAsChild(NULL)|. |
867 host_->SetView(NULL); | 868 host_->SetView(NULL); |
868 static_cast<RenderWidgetHostViewBase*>(view.release())->Destroy(); | 869 static_cast<RenderWidgetHostViewBase*>(view.release())->Destroy(); |
869 #endif | 870 #endif |
870 } | 871 } |
871 #endif | 872 #endif |
872 | 873 |
873 // Test that we don't paint when we're hidden, but we still send the ACK. Most | 874 // Test that we don't paint when we're hidden, but we still send the ACK. Most |
(...skipping 14 matching lines...) Expand all Loading... |
888 | 889 |
889 // Now unhide. | 890 // Now unhide. |
890 process_->sink().ClearMessages(); | 891 process_->sink().ClearMessages(); |
891 host_->WasShown(ui::LatencyInfo()); | 892 host_->WasShown(ui::LatencyInfo()); |
892 EXPECT_FALSE(host_->is_hidden_); | 893 EXPECT_FALSE(host_->is_hidden_); |
893 | 894 |
894 // It should have sent out a restored message with a request to paint. | 895 // It should have sent out a restored message with a request to paint. |
895 const IPC::Message* restored = process_->sink().GetUniqueMessageMatching( | 896 const IPC::Message* restored = process_->sink().GetUniqueMessageMatching( |
896 ViewMsg_WasShown::ID); | 897 ViewMsg_WasShown::ID); |
897 ASSERT_TRUE(restored); | 898 ASSERT_TRUE(restored); |
898 base::Tuple<bool, ui::LatencyInfo> needs_repaint; | 899 std::tuple<bool, ui::LatencyInfo> needs_repaint; |
899 ViewMsg_WasShown::Read(restored, &needs_repaint); | 900 ViewMsg_WasShown::Read(restored, &needs_repaint); |
900 EXPECT_TRUE(base::get<0>(needs_repaint)); | 901 EXPECT_TRUE(std::get<0>(needs_repaint)); |
901 } | 902 } |
902 | 903 |
903 TEST_F(RenderWidgetHostTest, IgnoreKeyEventsHandledByRenderer) { | 904 TEST_F(RenderWidgetHostTest, IgnoreKeyEventsHandledByRenderer) { |
904 // Simulate a keyboard event. | 905 // Simulate a keyboard event. |
905 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); | 906 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); |
906 | 907 |
907 // Make sure we sent the input event to the renderer. | 908 // Make sure we sent the input event to the renderer. |
908 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( | 909 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( |
909 InputMsg_HandleInputEvent::ID)); | 910 InputMsg_HandleInputEvent::ID)); |
910 process_->sink().ClearMessages(); | 911 process_->sink().ClearMessages(); |
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1525 void CheckLatencyInfoComponentInMessage(RenderWidgetHostProcess* process, | 1526 void CheckLatencyInfoComponentInMessage(RenderWidgetHostProcess* process, |
1526 int64_t component_id, | 1527 int64_t component_id, |
1527 WebInputEvent::Type expected_type) { | 1528 WebInputEvent::Type expected_type) { |
1528 EXPECT_EQ(process->sink().message_count(), 1U); | 1529 EXPECT_EQ(process->sink().message_count(), 1U); |
1529 | 1530 |
1530 const IPC::Message* message = process->sink().GetMessageAt(0); | 1531 const IPC::Message* message = process->sink().GetMessageAt(0); |
1531 EXPECT_EQ(InputMsg_HandleInputEvent::ID, message->type()); | 1532 EXPECT_EQ(InputMsg_HandleInputEvent::ID, message->type()); |
1532 InputMsg_HandleInputEvent::Param params; | 1533 InputMsg_HandleInputEvent::Param params; |
1533 EXPECT_TRUE(InputMsg_HandleInputEvent::Read(message, ¶ms)); | 1534 EXPECT_TRUE(InputMsg_HandleInputEvent::Read(message, ¶ms)); |
1534 | 1535 |
1535 const WebInputEvent* event = base::get<0>(params); | 1536 const WebInputEvent* event = std::get<0>(params); |
1536 ui::LatencyInfo latency_info = base::get<1>(params); | 1537 ui::LatencyInfo latency_info = std::get<1>(params); |
1537 | 1538 |
1538 EXPECT_TRUE(event->type == expected_type); | 1539 EXPECT_TRUE(event->type == expected_type); |
1539 EXPECT_TRUE(latency_info.FindLatency( | 1540 EXPECT_TRUE(latency_info.FindLatency( |
1540 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, component_id, NULL)); | 1541 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, component_id, NULL)); |
1541 | 1542 |
1542 process->sink().ClearMessages(); | 1543 process->sink().ClearMessages(); |
1543 } | 1544 } |
1544 | 1545 |
1545 // Tests that after input event passes through RWHI through ForwardXXXEvent() | 1546 // Tests that after input event passes through RWHI through ForwardXXXEvent() |
1546 // or ForwardXXXEventWithLatencyInfo(), LatencyInfo component | 1547 // or ForwardXXXEventWithLatencyInfo(), LatencyInfo component |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1672 ui::LatencyInfo()); | 1673 ui::LatencyInfo()); |
1673 | 1674 |
1674 | 1675 |
1675 // Tests RWHI::ForwardWheelEventWithLatencyInfo(). | 1676 // Tests RWHI::ForwardWheelEventWithLatencyInfo(). |
1676 SimulateWheelEventWithLatencyInfo(-5, 0, 0, true, ui::LatencyInfo()); | 1677 SimulateWheelEventWithLatencyInfo(-5, 0, 0, true, ui::LatencyInfo()); |
1677 | 1678 |
1678 ASSERT_FALSE(host_->input_router()->HasPendingEvents()); | 1679 ASSERT_FALSE(host_->input_router()->HasPendingEvents()); |
1679 } | 1680 } |
1680 | 1681 |
1681 } // namespace content | 1682 } // namespace content |
OLD | NEW |