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/render_widget_host_delegate.h" | 11 #include "content/browser/renderer_host/render_widget_host_delegate.h" |
12 #include "content/browser/renderer_host/test_render_view_host.h" | 12 #include "content/browser/renderer_host/test_render_view_host.h" |
13 #include "content/common/view_messages.h" | 13 #include "content/common/view_messages.h" |
14 #include "content/port/browser/render_widget_host_view_port.h" | 14 #include "content/port/browser/render_widget_host_view_port.h" |
15 #include "content/public/browser/notification_details.h" | 15 #include "content/public/browser/notification_details.h" |
16 #include "content/public/browser/notification_observer.h" | 16 #include "content/public/browser/notification_observer.h" |
17 #include "content/public/browser/notification_registrar.h" | 17 #include "content/public/browser/notification_registrar.h" |
18 #include "content/public/browser/notification_source.h" | 18 #include "content/public/browser/notification_source.h" |
19 #include "content/public/browser/notification_types.h" | 19 #include "content/public/browser/notification_types.h" |
20 #include "content/public/test/mock_render_process_host.h" | 20 #include "content/public/test/mock_render_process_host.h" |
21 #include "content/test/test_browser_context.h" | 21 #include "content/public/test/test_browser_context.h" |
22 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
23 #include "ui/base/keycodes/keyboard_codes.h" | 23 #include "ui/base/keycodes/keyboard_codes.h" |
24 #include "ui/gfx/canvas.h" | 24 #include "ui/gfx/canvas.h" |
25 | 25 |
26 #if defined(USE_AURA) | 26 #if defined(USE_AURA) |
27 #include "content/browser/renderer_host/render_widget_host_view_aura.h" | 27 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
28 #include "ui/aura/env.h" | 28 #include "ui/aura/env.h" |
29 #endif | 29 #endif |
30 | 30 |
31 using base::TimeDelta; | 31 using base::TimeDelta; |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 class RenderWidgetHostTest : public testing::Test { | 288 class RenderWidgetHostTest : public testing::Test { |
289 public: | 289 public: |
290 RenderWidgetHostTest() : process_(NULL) { | 290 RenderWidgetHostTest() : process_(NULL) { |
291 } | 291 } |
292 ~RenderWidgetHostTest() { | 292 ~RenderWidgetHostTest() { |
293 } | 293 } |
294 | 294 |
295 protected: | 295 protected: |
296 // testing::Test | 296 // testing::Test |
297 void SetUp() { | 297 void SetUp() { |
298 browser_context_.reset(new TestBrowserContext()); | 298 browser_context_.reset(new content::TestBrowserContext()); |
299 delegate_.reset(new MockRenderWidgetHostDelegate()); | 299 delegate_.reset(new MockRenderWidgetHostDelegate()); |
300 process_ = new RenderWidgetHostProcess(browser_context_.get()); | 300 process_ = new RenderWidgetHostProcess(browser_context_.get()); |
301 host_.reset( | 301 host_.reset( |
302 new MockRenderWidgetHost(delegate_.get(), process_, MSG_ROUTING_NONE)); | 302 new MockRenderWidgetHost(delegate_.get(), process_, MSG_ROUTING_NONE)); |
303 view_.reset(new TestView(host_.get())); | 303 view_.reset(new TestView(host_.get())); |
304 host_->SetView(view_.get()); | 304 host_->SetView(view_.get()); |
305 host_->Init(); | 305 host_->Init(); |
306 } | 306 } |
307 void TearDown() { | 307 void TearDown() { |
308 view_.reset(); | 308 view_.reset(); |
(...skipping 27 matching lines...) Expand all Loading... |
336 WebMouseWheelEvent wheel_event; | 336 WebMouseWheelEvent wheel_event; |
337 wheel_event.type = WebInputEvent::MouseWheel; | 337 wheel_event.type = WebInputEvent::MouseWheel; |
338 wheel_event.deltaX = dX; | 338 wheel_event.deltaX = dX; |
339 wheel_event.deltaY = dY; | 339 wheel_event.deltaY = dY; |
340 wheel_event.modifiers = modifiers; | 340 wheel_event.modifiers = modifiers; |
341 host_->ForwardWheelEvent(wheel_event); | 341 host_->ForwardWheelEvent(wheel_event); |
342 } | 342 } |
343 | 343 |
344 MessageLoopForUI message_loop_; | 344 MessageLoopForUI message_loop_; |
345 | 345 |
346 scoped_ptr<TestBrowserContext> browser_context_; | 346 scoped_ptr<content::TestBrowserContext> browser_context_; |
347 RenderWidgetHostProcess* process_; // Deleted automatically by the widget. | 347 RenderWidgetHostProcess* process_; // Deleted automatically by the widget. |
348 scoped_ptr<MockRenderWidgetHostDelegate> delegate_; | 348 scoped_ptr<MockRenderWidgetHostDelegate> delegate_; |
349 scoped_ptr<MockRenderWidgetHost> host_; | 349 scoped_ptr<MockRenderWidgetHost> host_; |
350 scoped_ptr<TestView> view_; | 350 scoped_ptr<TestView> view_; |
351 | 351 |
352 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostTest); | 352 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostTest); |
353 }; | 353 }; |
354 | 354 |
355 // ----------------------------------------------------------------------------- | 355 // ----------------------------------------------------------------------------- |
356 | 356 |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); | 821 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); |
822 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); | 822 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); |
823 SendInputEventACK(WebInputEvent::RawKeyDown, true); | 823 SendInputEventACK(WebInputEvent::RawKeyDown, true); |
824 | 824 |
825 // Wait long enough for first timeout and see if it fired. | 825 // Wait long enough for first timeout and see if it fired. |
826 MessageLoop::current()->PostDelayedTask( | 826 MessageLoop::current()->PostDelayedTask( |
827 FROM_HERE, MessageLoop::QuitClosure(), TimeDelta::FromMilliseconds(40)); | 827 FROM_HERE, MessageLoop::QuitClosure(), TimeDelta::FromMilliseconds(40)); |
828 MessageLoop::current()->Run(); | 828 MessageLoop::current()->Run(); |
829 EXPECT_TRUE(host_->unresponsive_timer_fired()); | 829 EXPECT_TRUE(host_->unresponsive_timer_fired()); |
830 } | 830 } |
OLD | NEW |