Chromium Code Reviews| 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" |
| 11 #include "content/browser/renderer_host/test_render_view_host.h" | 11 #include "content/browser/renderer_host/test_render_view_host.h" |
| 12 #include "content/common/view_messages.h" | 12 #include "content/common/view_messages.h" |
| 13 #include "content/public/browser/notification_details.h" | 13 #include "content/public/browser/notification_details.h" |
| 14 #include "content/public/browser/notification_observer.h" | 14 #include "content/public/browser/notification_observer.h" |
| 15 #include "content/public/browser/notification_registrar.h" | 15 #include "content/public/browser/notification_registrar.h" |
| 16 #include "content/public/browser/notification_source.h" | 16 #include "content/public/browser/notification_source.h" |
| 17 #include "content/public/browser/notification_types.h" | 17 #include "content/public/browser/notification_types.h" |
| 18 #include "content/port/browser/render_widget_host_view_port.h" | 18 #include "content/port/browser/render_widget_host_view_port.h" |
| 19 #include "content/test/test_browser_context.h" | 19 #include "content/test/test_browser_context.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 21 #include "ui/base/keycodes/keyboard_codes.h" | 21 #include "ui/base/keycodes/keyboard_codes.h" |
| 22 #include "ui/gfx/canvas_skia.h" | 22 #include "ui/gfx/canvas_skia.h" |
| 23 | 23 |
| 24 #if defined(USE_AURA) | 24 #if defined(USE_AURA) |
| 25 #include "content/browser/renderer_host/render_widget_host_view_aura.h" | 25 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
| 26 #endif | 26 #endif |
| 27 | 27 |
| 28 using base::TimeDelta; | 28 using base::TimeDelta; |
| 29 using content::BrowserThread; | 29 using content::BrowserThread; |
| 30 | |
| 31 using content::BrowserThreadImpl; | 30 using content::BrowserThreadImpl; |
| 32 | 31 using content::RenderWidgetHost; |
| 32 using content::RenderWidgetHostImpl; | |
| 33 using WebKit::WebInputEvent; | 33 using WebKit::WebInputEvent; |
| 34 using WebKit::WebMouseWheelEvent; | 34 using WebKit::WebMouseWheelEvent; |
| 35 | 35 |
| 36 namespace gfx { | 36 namespace gfx { |
| 37 class Size; | 37 class Size; |
| 38 } | 38 } |
| 39 | 39 |
| 40 // RenderWidgetHostProcess ----------------------------------------------------- | 40 // RenderWidgetHostProcess ----------------------------------------------------- |
| 41 | 41 |
| 42 class RenderWidgetHostProcess : public MockRenderProcessHost { | 42 class RenderWidgetHostProcess : public MockRenderProcessHost { |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 151 MockRenderWidgetHost(content::RenderProcessHost* process, int routing_id) | 151 MockRenderWidgetHost(content::RenderProcessHost* process, int routing_id) |
| 152 : RenderWidgetHostImpl(process, routing_id), | 152 : RenderWidgetHostImpl(process, routing_id), |
| 153 prehandle_keyboard_event_(false), | 153 prehandle_keyboard_event_(false), |
| 154 prehandle_keyboard_event_called_(false), | 154 prehandle_keyboard_event_called_(false), |
| 155 prehandle_keyboard_event_type_(WebInputEvent::Undefined), | 155 prehandle_keyboard_event_type_(WebInputEvent::Undefined), |
| 156 unhandled_keyboard_event_called_(false), | 156 unhandled_keyboard_event_called_(false), |
| 157 unhandled_keyboard_event_type_(WebInputEvent::Undefined), | 157 unhandled_keyboard_event_type_(WebInputEvent::Undefined), |
| 158 unresponsive_timer_fired_(false) { | 158 unresponsive_timer_fired_(false) { |
| 159 } | 159 } |
| 160 | 160 |
| 161 // Allow poking at a few private members. | |
| 162 using RenderWidgetHostImpl::OnMsgPaintAtSizeAck; | |
|
jam
2012/03/05 23:59:28
neat trick, I didn't know this :)
| |
| 163 using RenderWidgetHostImpl::OnMsgUpdateRect; | |
| 164 using RenderWidgetHostImpl::RendererExited; | |
| 165 using RenderWidgetHostImpl::in_flight_size_; | |
| 166 using RenderWidgetHostImpl::is_hidden_; | |
| 167 using RenderWidgetHostImpl::resize_ack_pending_; | |
| 168 | |
| 161 // Tests that make sure we ignore keyboard event acknowledgments to events we | 169 // Tests that make sure we ignore keyboard event acknowledgments to events we |
| 162 // didn't send work by making sure we didn't call UnhandledKeyboardEvent(). | 170 // didn't send work by making sure we didn't call UnhandledKeyboardEvent(). |
| 163 bool unhandled_keyboard_event_called() const { | 171 bool unhandled_keyboard_event_called() const { |
| 164 return unhandled_keyboard_event_called_; | 172 return unhandled_keyboard_event_called_; |
| 165 } | 173 } |
| 166 | 174 |
| 167 WebInputEvent::Type unhandled_keyboard_event_type() const { | 175 WebInputEvent::Type unhandled_keyboard_event_type() const { |
| 168 return unhandled_keyboard_event_type_; | 176 return unhandled_keyboard_event_type_; |
| 169 } | 177 } |
| 170 | 178 |
| (...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 765 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); | 773 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); |
| 766 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); | 774 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); |
| 767 SendInputEventACK(WebInputEvent::RawKeyDown, true); | 775 SendInputEventACK(WebInputEvent::RawKeyDown, true); |
| 768 | 776 |
| 769 // Wait long enough for first timeout and see if it fired. | 777 // Wait long enough for first timeout and see if it fired. |
| 770 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 778 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
| 771 MessageLoop::QuitClosure(), 40); | 779 MessageLoop::QuitClosure(), 40); |
| 772 MessageLoop::current()->Run(); | 780 MessageLoop::current()->Run(); |
| 773 EXPECT_TRUE(host_->unresponsive_timer_fired()); | 781 EXPECT_TRUE(host_->unresponsive_timer_fired()); |
| 774 } | 782 } |
| OLD | NEW |