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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/memory/shared_memory.h" | 9 #include "base/memory/shared_memory.h" |
10 #include "base/timer/timer.h" | 10 #include "base/timer/timer.h" |
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
773 host_->SetView(view.get()); | 773 host_->SetView(view.get()); |
774 | 774 |
775 EXPECT_TRUE(view->GetBackgroundOpaque()); | 775 EXPECT_TRUE(view->GetBackgroundOpaque()); |
776 view->SetBackgroundColor(SK_ColorTRANSPARENT); | 776 view->SetBackgroundColor(SK_ColorTRANSPARENT); |
777 EXPECT_FALSE(view->GetBackgroundOpaque()); | 777 EXPECT_FALSE(view->GetBackgroundOpaque()); |
778 | 778 |
779 const IPC::Message* set_background = | 779 const IPC::Message* set_background = |
780 process_->sink().GetUniqueMessageMatching( | 780 process_->sink().GetUniqueMessageMatching( |
781 ViewMsg_SetBackgroundOpaque::ID); | 781 ViewMsg_SetBackgroundOpaque::ID); |
782 ASSERT_TRUE(set_background); | 782 ASSERT_TRUE(set_background); |
783 Tuple1<bool> sent_background; | 783 Tuple<bool> sent_background; |
784 ViewMsg_SetBackgroundOpaque::Read(set_background, &sent_background); | 784 ViewMsg_SetBackgroundOpaque::Read(set_background, &sent_background); |
785 EXPECT_FALSE(sent_background.a); | 785 EXPECT_FALSE(get<0>(sent_background)); |
786 | 786 |
787 #if defined(USE_AURA) | 787 #if defined(USE_AURA) |
788 // See the comment above |InitAsChild(NULL)|. | 788 // See the comment above |InitAsChild(NULL)|. |
789 host_->SetView(NULL); | 789 host_->SetView(NULL); |
790 static_cast<RenderWidgetHostViewBase*>(view.release())->Destroy(); | 790 static_cast<RenderWidgetHostViewBase*>(view.release())->Destroy(); |
791 #endif | 791 #endif |
792 } | 792 } |
793 #endif | 793 #endif |
794 | 794 |
795 // Test that we don't paint when we're hidden, but we still send the ACK. Most | 795 // Test that we don't paint when we're hidden, but we still send the ACK. Most |
(...skipping 14 matching lines...) Expand all Loading... |
810 | 810 |
811 // Now unhide. | 811 // Now unhide. |
812 process_->sink().ClearMessages(); | 812 process_->sink().ClearMessages(); |
813 host_->WasShown(ui::LatencyInfo()); | 813 host_->WasShown(ui::LatencyInfo()); |
814 EXPECT_FALSE(host_->is_hidden_); | 814 EXPECT_FALSE(host_->is_hidden_); |
815 | 815 |
816 // It should have sent out a restored message with a request to paint. | 816 // It should have sent out a restored message with a request to paint. |
817 const IPC::Message* restored = process_->sink().GetUniqueMessageMatching( | 817 const IPC::Message* restored = process_->sink().GetUniqueMessageMatching( |
818 ViewMsg_WasShown::ID); | 818 ViewMsg_WasShown::ID); |
819 ASSERT_TRUE(restored); | 819 ASSERT_TRUE(restored); |
820 Tuple2<bool, ui::LatencyInfo> needs_repaint; | 820 Tuple<bool, ui::LatencyInfo> needs_repaint; |
821 ViewMsg_WasShown::Read(restored, &needs_repaint); | 821 ViewMsg_WasShown::Read(restored, &needs_repaint); |
822 EXPECT_TRUE(needs_repaint.a); | 822 EXPECT_TRUE(get<0>(needs_repaint)); |
823 } | 823 } |
824 | 824 |
825 TEST_F(RenderWidgetHostTest, IgnoreKeyEventsHandledByRenderer) { | 825 TEST_F(RenderWidgetHostTest, IgnoreKeyEventsHandledByRenderer) { |
826 // Simulate a keyboard event. | 826 // Simulate a keyboard event. |
827 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); | 827 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); |
828 | 828 |
829 // Make sure we sent the input event to the renderer. | 829 // Make sure we sent the input event to the renderer. |
830 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( | 830 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( |
831 InputMsg_HandleInputEvent::ID)); | 831 InputMsg_HandleInputEvent::ID)); |
832 process_->sink().ClearMessages(); | 832 process_->sink().ClearMessages(); |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1014 EXPECT_TRUE(host_->unresponsive_timer_fired()); | 1014 EXPECT_TRUE(host_->unresponsive_timer_fired()); |
1015 } | 1015 } |
1016 | 1016 |
1017 std::string GetInputMessageTypes(RenderWidgetHostProcess* process) { | 1017 std::string GetInputMessageTypes(RenderWidgetHostProcess* process) { |
1018 std::string result; | 1018 std::string result; |
1019 for (size_t i = 0; i < process->sink().message_count(); ++i) { | 1019 for (size_t i = 0; i < process->sink().message_count(); ++i) { |
1020 const IPC::Message *message = process->sink().GetMessageAt(i); | 1020 const IPC::Message *message = process->sink().GetMessageAt(i); |
1021 EXPECT_EQ(InputMsg_HandleInputEvent::ID, message->type()); | 1021 EXPECT_EQ(InputMsg_HandleInputEvent::ID, message->type()); |
1022 InputMsg_HandleInputEvent::Param params; | 1022 InputMsg_HandleInputEvent::Param params; |
1023 EXPECT_TRUE(InputMsg_HandleInputEvent::Read(message, ¶ms)); | 1023 EXPECT_TRUE(InputMsg_HandleInputEvent::Read(message, ¶ms)); |
1024 const WebInputEvent* event = params.a; | 1024 const WebInputEvent* event = get<0>(params); |
1025 if (i != 0) | 1025 if (i != 0) |
1026 result += " "; | 1026 result += " "; |
1027 result += WebInputEventTraits::GetName(event->type); | 1027 result += WebInputEventTraits::GetName(event->type); |
1028 } | 1028 } |
1029 process->sink().ClearMessages(); | 1029 process->sink().ClearMessages(); |
1030 return result; | 1030 return result; |
1031 } | 1031 } |
1032 | 1032 |
1033 TEST_F(RenderWidgetHostTest, TouchEmulator) { | 1033 TEST_F(RenderWidgetHostTest, TouchEmulator) { |
1034 simulated_event_time_delta_seconds_ = 0.1; | 1034 simulated_event_time_delta_seconds_ = 0.1; |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1336 EXPECT_TRUE(host_->mock_input_router()->message_received_); | 1336 EXPECT_TRUE(host_->mock_input_router()->message_received_); |
1337 } | 1337 } |
1338 | 1338 |
1339 ui::LatencyInfo GetLatencyInfoFromInputEvent(RenderWidgetHostProcess* process) { | 1339 ui::LatencyInfo GetLatencyInfoFromInputEvent(RenderWidgetHostProcess* process) { |
1340 const IPC::Message* message = process->sink().GetUniqueMessageMatching( | 1340 const IPC::Message* message = process->sink().GetUniqueMessageMatching( |
1341 InputMsg_HandleInputEvent::ID); | 1341 InputMsg_HandleInputEvent::ID); |
1342 EXPECT_TRUE(message); | 1342 EXPECT_TRUE(message); |
1343 InputMsg_HandleInputEvent::Param params; | 1343 InputMsg_HandleInputEvent::Param params; |
1344 EXPECT_TRUE(InputMsg_HandleInputEvent::Read(message, ¶ms)); | 1344 EXPECT_TRUE(InputMsg_HandleInputEvent::Read(message, ¶ms)); |
1345 process->sink().ClearMessages(); | 1345 process->sink().ClearMessages(); |
1346 return params.b; | 1346 return get<1>(params); |
1347 } | 1347 } |
1348 | 1348 |
1349 void CheckLatencyInfoComponentInMessage(RenderWidgetHostProcess* process, | 1349 void CheckLatencyInfoComponentInMessage(RenderWidgetHostProcess* process, |
1350 int64 component_id, | 1350 int64 component_id, |
1351 WebInputEvent::Type input_type) { | 1351 WebInputEvent::Type input_type) { |
1352 ui::LatencyInfo latency_info = GetLatencyInfoFromInputEvent(process); | 1352 ui::LatencyInfo latency_info = GetLatencyInfoFromInputEvent(process); |
1353 EXPECT_TRUE(latency_info.FindLatency( | 1353 EXPECT_TRUE(latency_info.FindLatency( |
1354 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, | 1354 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, |
1355 component_id, | 1355 component_id, |
1356 NULL)); | 1356 NULL)); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1464 // Having an initial size set means that the size information had been sent | 1464 // Having an initial size set means that the size information had been sent |
1465 // with the reqiest to new up the RenderView and so subsequent WasResized | 1465 // with the reqiest to new up the RenderView and so subsequent WasResized |
1466 // calls should not result in new IPC (unless the size has actually changed). | 1466 // calls should not result in new IPC (unless the size has actually changed). |
1467 host_->WasResized(); | 1467 host_->WasResized(); |
1468 EXPECT_FALSE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID)); | 1468 EXPECT_FALSE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID)); |
1469 EXPECT_EQ(initial_size_, host_->old_resize_params_->new_size); | 1469 EXPECT_EQ(initial_size_, host_->old_resize_params_->new_size); |
1470 EXPECT_TRUE(host_->resize_ack_pending_); | 1470 EXPECT_TRUE(host_->resize_ack_pending_); |
1471 } | 1471 } |
1472 | 1472 |
1473 } // namespace content | 1473 } // namespace content |
OLD | NEW |