| 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/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "base/shared_memory.h" | 7 #include "base/shared_memory.h" |
| 8 #include "base/timer.h" | 8 #include "base/timer.h" |
| 9 #include "content/browser/browser_thread_impl.h" | 9 #include "content/browser/browser_thread_impl.h" |
| 10 #include "content/browser/renderer_host/backing_store.h" | 10 #include "content/browser/renderer_host/backing_store.h" |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 } | 217 } |
| 218 | 218 |
| 219 // Allow poking at a few private members. | 219 // Allow poking at a few private members. |
| 220 using RenderWidgetHostImpl::OnMsgPaintAtSizeAck; | 220 using RenderWidgetHostImpl::OnMsgPaintAtSizeAck; |
| 221 using RenderWidgetHostImpl::OnMsgUpdateRect; | 221 using RenderWidgetHostImpl::OnMsgUpdateRect; |
| 222 using RenderWidgetHostImpl::RendererExited; | 222 using RenderWidgetHostImpl::RendererExited; |
| 223 using RenderWidgetHostImpl::in_flight_size_; | 223 using RenderWidgetHostImpl::in_flight_size_; |
| 224 using RenderWidgetHostImpl::is_hidden_; | 224 using RenderWidgetHostImpl::is_hidden_; |
| 225 using RenderWidgetHostImpl::resize_ack_pending_; | 225 using RenderWidgetHostImpl::resize_ack_pending_; |
| 226 using RenderWidgetHostImpl::coalesced_gesture_events_; | 226 using RenderWidgetHostImpl::coalesced_gesture_events_; |
| 227 using RenderWidgetHostImpl::fling_in_progress_; |
| 227 | 228 |
| 228 bool unresponsive_timer_fired() const { | 229 bool unresponsive_timer_fired() const { |
| 229 return unresponsive_timer_fired_; | 230 return unresponsive_timer_fired_; |
| 230 } | 231 } |
| 231 | 232 |
| 232 void set_hung_renderer_delay_ms(int delay_ms) { | 233 void set_hung_renderer_delay_ms(int delay_ms) { |
| 233 hung_renderer_delay_ms_ = delay_ms; | 234 hung_renderer_delay_ms_ = delay_ms; |
| 234 } | 235 } |
| 235 | 236 |
| 236 protected: | 237 protected: |
| (...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 847 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( | 848 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( |
| 848 ViewMsg_HandleInputEvent::ID)); | 849 ViewMsg_HandleInputEvent::ID)); |
| 849 process_->sink().ClearMessages(); | 850 process_->sink().ClearMessages(); |
| 850 | 851 |
| 851 // After the final ack, the queue should be empty. | 852 // After the final ack, the queue should be empty. |
| 852 SendInputEventACK(WebInputEvent::GestureScrollEnd, true); | 853 SendInputEventACK(WebInputEvent::GestureScrollEnd, true); |
| 853 MessageLoop::current()->RunAllPending(); | 854 MessageLoop::current()->RunAllPending(); |
| 854 EXPECT_EQ(0U, process_->sink().message_count()); | 855 EXPECT_EQ(0U, process_->sink().message_count()); |
| 855 } | 856 } |
| 856 | 857 |
| 858 // HERE |
| 859 TEST_F(RenderWidgetHostTest, GestureFlingCancelsFiltered) { |
| 860 process_->sink().ClearMessages(); |
| 861 // GFC without previous GFS is dropped. |
| 862 SimulateGestureEvent(0, -10, 0, WebInputEvent::GestureFlingCancel); |
| 863 EXPECT_EQ(0U, process_->sink().message_count()); |
| 864 EXPECT_EQ(0U, host_->coalesced_gesture_events_.size()); |
| 865 |
| 866 // GFC after previous GFS is dispatched and acked. |
| 867 process_->sink().ClearMessages(); |
| 868 SimulateGestureEvent(0, -10, 0, WebInputEvent::GestureFlingStart); |
| 869 EXPECT_TRUE(host_->fling_in_progress_); |
| 870 SendInputEventACK(WebInputEvent::GestureFlingStart, true); |
| 871 MessageLoop::current()->RunAllPending(); |
| 872 SimulateGestureEvent(0, -10, 0, WebInputEvent::GestureFlingCancel); |
| 873 EXPECT_FALSE(host_->fling_in_progress_); |
| 874 EXPECT_EQ(2U, process_->sink().message_count()); |
| 875 SendInputEventACK(WebInputEvent::GestureFlingCancel, true); |
| 876 MessageLoop::current()->RunAllPending(); |
| 877 EXPECT_EQ(0U, host_->coalesced_gesture_events_.size()); |
| 878 |
| 879 // GFC before previous GFS is acked. |
| 880 process_->sink().ClearMessages(); |
| 881 SimulateGestureEvent(0, -10, 0, WebInputEvent::GestureFlingStart); |
| 882 EXPECT_TRUE(host_->fling_in_progress_); |
| 883 SimulateGestureEvent(0, -10, 0, WebInputEvent::GestureFlingCancel); |
| 884 EXPECT_FALSE(host_->fling_in_progress_); |
| 885 EXPECT_EQ(1U, process_->sink().message_count()); |
| 886 EXPECT_FALSE(host_->coalesced_gesture_events_.empty()); |
| 887 |
| 888 // Advance state realistically. |
| 889 SendInputEventACK(WebInputEvent::GestureFlingStart, true); |
| 890 MessageLoop::current()->RunAllPending(); |
| 891 SendInputEventACK(WebInputEvent::GestureFlingCancel, true); |
| 892 MessageLoop::current()->RunAllPending(); |
| 893 EXPECT_EQ(0U, host_->coalesced_gesture_events_.size()); |
| 894 |
| 895 // GFS is added to the queue if another event is pending |
| 896 process_->sink().ClearMessages(); |
| 897 SimulateGestureEvent(8, -7, 0, WebInputEvent::GestureScrollUpdate); |
| 898 SimulateGestureEvent(0, -10, 0, WebInputEvent::GestureFlingStart); |
| 899 EXPECT_EQ(1U, process_->sink().message_count()); |
| 900 WebGestureEvent merged_event = host_->coalesced_gesture_events_.back(); |
| 901 EXPECT_EQ(WebInputEvent::GestureFlingStart, merged_event.type); |
| 902 EXPECT_FALSE(host_->fling_in_progress_); |
| 903 EXPECT_EQ(1U, host_->coalesced_gesture_events_.size()); |
| 904 |
| 905 // GFS in queue means that a GFC is added to the queue |
| 906 SimulateGestureEvent(0, -10, 0, WebInputEvent::GestureFlingCancel); |
| 907 merged_event = host_->coalesced_gesture_events_.back(); |
| 908 EXPECT_EQ(WebInputEvent::GestureFlingCancel, merged_event.type); |
| 909 EXPECT_FALSE(host_->fling_in_progress_); |
| 910 EXPECT_EQ(2U, host_->coalesced_gesture_events_.size()); |
| 911 |
| 912 |
| 913 // Adding a second GFC is dropped. |
| 914 SimulateGestureEvent(0, -10, 0, WebInputEvent::GestureFlingCancel); |
| 915 EXPECT_FALSE(host_->fling_in_progress_); |
| 916 EXPECT_EQ(2U, host_->coalesced_gesture_events_.size()); |
| 917 |
| 918 // Adding another GFS will add it to the queue. |
| 919 SimulateGestureEvent(0, -10, 0, WebInputEvent::GestureFlingStart); |
| 920 merged_event = host_->coalesced_gesture_events_.back(); |
| 921 EXPECT_EQ(WebInputEvent::GestureFlingStart, merged_event.type); |
| 922 EXPECT_FALSE(host_->fling_in_progress_); |
| 923 EXPECT_EQ(3U, host_->coalesced_gesture_events_.size()); |
| 924 |
| 925 // GFS in queue means that a GFC is added to the queue |
| 926 SimulateGestureEvent(0, -10, 0, WebInputEvent::GestureFlingCancel); |
| 927 merged_event = host_->coalesced_gesture_events_.back(); |
| 928 EXPECT_EQ(WebInputEvent::GestureFlingCancel, merged_event.type); |
| 929 EXPECT_FALSE(host_->fling_in_progress_); |
| 930 EXPECT_EQ(4U, host_->coalesced_gesture_events_.size()); |
| 931 |
| 932 // Adding another GFC with a GFC already there is dropped. |
| 933 SimulateGestureEvent(0, -10, 0, WebInputEvent::GestureFlingCancel); |
| 934 merged_event = host_->coalesced_gesture_events_.back(); |
| 935 EXPECT_EQ(WebInputEvent::GestureFlingCancel, merged_event.type); |
| 936 EXPECT_FALSE(host_->fling_in_progress_); |
| 937 EXPECT_EQ(4U, host_->coalesced_gesture_events_.size()); |
| 938 |
| 939 } |
| 940 |
| 857 // Test that the hang monitor timer expires properly if a new timer is started | 941 // Test that the hang monitor timer expires properly if a new timer is started |
| 858 // while one is in progress (see crbug.com/11007). | 942 // while one is in progress (see crbug.com/11007). |
| 859 TEST_F(RenderWidgetHostTest, DontPostponeHangMonitorTimeout) { | 943 TEST_F(RenderWidgetHostTest, DontPostponeHangMonitorTimeout) { |
| 860 // Start with a short timeout. | 944 // Start with a short timeout. |
| 861 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); | 945 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); |
| 862 | 946 |
| 863 // Immediately try to add a long 30 second timeout. | 947 // Immediately try to add a long 30 second timeout. |
| 864 EXPECT_FALSE(host_->unresponsive_timer_fired()); | 948 EXPECT_FALSE(host_->unresponsive_timer_fired()); |
| 865 host_->StartHangMonitorTimeout(TimeDelta::FromSeconds(30)); | 949 host_->StartHangMonitorTimeout(TimeDelta::FromSeconds(30)); |
| 866 | 950 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 918 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); | 1002 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); |
| 919 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); | 1003 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); |
| 920 SendInputEventACK(WebInputEvent::RawKeyDown, true); | 1004 SendInputEventACK(WebInputEvent::RawKeyDown, true); |
| 921 | 1005 |
| 922 // Wait long enough for first timeout and see if it fired. | 1006 // Wait long enough for first timeout and see if it fired. |
| 923 MessageLoop::current()->PostDelayedTask( | 1007 MessageLoop::current()->PostDelayedTask( |
| 924 FROM_HERE, MessageLoop::QuitClosure(), TimeDelta::FromMilliseconds(40)); | 1008 FROM_HERE, MessageLoop::QuitClosure(), TimeDelta::FromMilliseconds(40)); |
| 925 MessageLoop::current()->Run(); | 1009 MessageLoop::current()->Run(); |
| 926 EXPECT_TRUE(host_->unresponsive_timer_fired()); | 1010 EXPECT_TRUE(host_->unresponsive_timer_fired()); |
| 927 } | 1011 } |
| OLD | NEW |