| 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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 } | 174 } |
| 175 | 175 |
| 176 void set_prehandle_keyboard_event(bool handle) { | 176 void set_prehandle_keyboard_event(bool handle) { |
| 177 prehandle_keyboard_event_ = handle; | 177 prehandle_keyboard_event_ = handle; |
| 178 } | 178 } |
| 179 | 179 |
| 180 bool unresponsive_timer_fired() const { | 180 bool unresponsive_timer_fired() const { |
| 181 return unresponsive_timer_fired_; | 181 return unresponsive_timer_fired_; |
| 182 } | 182 } |
| 183 | 183 |
| 184 void set_hung_renderer_delay_ms(int delay_ms) { |
| 185 hung_renderer_delay_ms_ = delay_ms; |
| 186 } |
| 187 |
| 184 protected: | 188 protected: |
| 185 virtual bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, | 189 virtual bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, |
| 186 bool* is_keyboard_shortcut) { | 190 bool* is_keyboard_shortcut) { |
| 187 prehandle_keyboard_event_type_ = event.type; | 191 prehandle_keyboard_event_type_ = event.type; |
| 188 prehandle_keyboard_event_called_ = true; | 192 prehandle_keyboard_event_called_ = true; |
| 189 return prehandle_keyboard_event_; | 193 return prehandle_keyboard_event_; |
| 190 } | 194 } |
| 191 | 195 |
| 192 virtual void UnhandledKeyboardEvent(const NativeWebKeyboardEvent& event) { | 196 virtual void UnhandledKeyboardEvent(const NativeWebKeyboardEvent& event) { |
| 193 unhandled_keyboard_event_type_ = event.type; | 197 unhandled_keyboard_event_type_ = event.type; |
| (...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 735 // Start it again to ensure it still works. | 739 // Start it again to ensure it still works. |
| 736 EXPECT_FALSE(host_->unresponsive_timer_fired()); | 740 EXPECT_FALSE(host_->unresponsive_timer_fired()); |
| 737 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); | 741 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); |
| 738 | 742 |
| 739 // Wait long enough for first timeout and see if it fired. | 743 // Wait long enough for first timeout and see if it fired. |
| 740 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 744 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
| 741 MessageLoop::QuitClosure(), 40); | 745 MessageLoop::QuitClosure(), 40); |
| 742 MessageLoop::current()->Run(); | 746 MessageLoop::current()->Run(); |
| 743 EXPECT_TRUE(host_->unresponsive_timer_fired()); | 747 EXPECT_TRUE(host_->unresponsive_timer_fired()); |
| 744 } | 748 } |
| 749 |
| 750 // Test that the hang monitor catches two input events but only one ack. |
| 751 // This can happen if the second input event causes the renderer to hang. |
| 752 // This test will catch a regression of crbug.com/111185 and will only |
| 753 // pass when the compositor thread is being used. |
| 754 TEST_F(RenderWidgetHostTest, FAILS_MultipleInputEvents) { |
| 755 // Configure the host to wait 10ms before considering |
| 756 // the renderer hung. |
| 757 host_->set_hung_renderer_delay_ms(10); |
| 758 |
| 759 // Send two events but only one ack. |
| 760 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); |
| 761 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); |
| 762 SendInputEventACK(WebInputEvent::RawKeyDown, true); |
| 763 |
| 764 // Wait long enough for first timeout and see if it fired. |
| 765 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
| 766 MessageLoop::QuitClosure(), 40); |
| 767 MessageLoop::current()->Run(); |
| 768 EXPECT_TRUE(host_->unresponsive_timer_fired()); |
| 769 } |
| OLD | NEW |