| 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/gesture_event_filter.h" | 12 #include "content/browser/renderer_host/gesture_event_filter.h" |
| 13 #include "content/browser/renderer_host/test_render_view_host.h" | 13 #include "content/browser/renderer_host/test_render_view_host.h" |
| 14 #include "content/browser/renderer_host/touch_event_queue.h" | 14 #include "content/browser/renderer_host/touch_event_queue.h" |
| 15 #include "content/common/view_messages.h" | 15 #include "content/common/view_messages.h" |
| 16 #include "content/port/browser/render_widget_host_view_port.h" | 16 #include "content/port/browser/render_widget_host_view_port.h" |
| 17 #include "content/public/browser/notification_details.h" | 17 #include "content/public/browser/notification_details.h" |
| 18 #include "content/public/browser/notification_observer.h" | 18 #include "content/public/browser/notification_observer.h" |
| 19 #include "content/public/browser/notification_registrar.h" | 19 #include "content/public/browser/notification_registrar.h" |
| 20 #include "content/public/browser/notification_source.h" | 20 #include "content/public/browser/notification_source.h" |
| 21 #include "content/public/browser/notification_types.h" | 21 #include "content/public/browser/notification_types.h" |
| 22 #include "content/public/test/mock_render_process_host.h" | 22 #include "content/public/test/mock_render_process_host.h" |
| 23 #include "content/public/test/test_browser_context.h" | 23 #include "content/public/test/test_browser_context.h" |
| 24 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
| 25 #include "ui/base/keycodes/keyboard_codes.h" | 25 #include "ui/base/keycodes/keyboard_codes.h" |
| 26 #include "ui/gfx/canvas.h" | 26 #include "ui/gfx/canvas.h" |
| 27 #include "ui/gfx/screen.h" |
| 27 | 28 |
| 28 #if defined(USE_AURA) | 29 #if defined(USE_AURA) |
| 29 #include "content/browser/renderer_host/render_widget_host_view_aura.h" | 30 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
| 30 #include "ui/aura/env.h" | 31 #include "ui/aura/env.h" |
| 32 #include "ui/aura/test/test_screen.h" |
| 31 #endif | 33 #endif |
| 32 | 34 |
| 33 #if defined(OS_WIN) || defined(USE_AURA) | 35 #if defined(OS_WIN) || defined(USE_AURA) |
| 34 #include "content/browser/renderer_host/ui_events_helper.h" | 36 #include "content/browser/renderer_host/ui_events_helper.h" |
| 35 #include "ui/base/events/event.h" | 37 #include "ui/base/events/event.h" |
| 36 #endif | 38 #endif |
| 37 | 39 |
| 38 using base::TimeDelta; | 40 using base::TimeDelta; |
| 39 using WebKit::WebGestureEvent; | 41 using WebKit::WebGestureEvent; |
| 40 using WebKit::WebInputEvent; | 42 using WebKit::WebInputEvent; |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 } | 385 } |
| 384 ~RenderWidgetHostTest() { | 386 ~RenderWidgetHostTest() { |
| 385 } | 387 } |
| 386 | 388 |
| 387 protected: | 389 protected: |
| 388 // testing::Test | 390 // testing::Test |
| 389 void SetUp() { | 391 void SetUp() { |
| 390 browser_context_.reset(new TestBrowserContext()); | 392 browser_context_.reset(new TestBrowserContext()); |
| 391 delegate_.reset(new MockRenderWidgetHostDelegate()); | 393 delegate_.reset(new MockRenderWidgetHostDelegate()); |
| 392 process_ = new RenderWidgetHostProcess(browser_context_.get()); | 394 process_ = new RenderWidgetHostProcess(browser_context_.get()); |
| 395 #if defined(USE_AURA) |
| 396 screen_.reset(new aura::TestScreen); |
| 397 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get()); |
| 398 #endif |
| 393 host_.reset( | 399 host_.reset( |
| 394 new MockRenderWidgetHost(delegate_.get(), process_, MSG_ROUTING_NONE)); | 400 new MockRenderWidgetHost(delegate_.get(), process_, MSG_ROUTING_NONE)); |
| 395 view_.reset(new TestView(host_.get())); | 401 view_.reset(new TestView(host_.get())); |
| 396 host_->SetView(view_.get()); | 402 host_->SetView(view_.get()); |
| 397 host_->Init(); | 403 host_->Init(); |
| 398 } | 404 } |
| 399 void TearDown() { | 405 void TearDown() { |
| 400 view_.reset(); | 406 view_.reset(); |
| 401 host_.reset(); | 407 host_.reset(); |
| 402 delegate_.reset(); | 408 delegate_.reset(); |
| 403 process_ = NULL; | 409 process_ = NULL; |
| 404 browser_context_.reset(); | 410 browser_context_.reset(); |
| 405 | 411 |
| 406 #if defined(USE_AURA) | 412 #if defined(USE_AURA) |
| 407 aura::Env::DeleteInstance(); | 413 aura::Env::DeleteInstance(); |
| 414 screen_.reset(); |
| 408 #endif | 415 #endif |
| 409 | 416 |
| 410 // Process all pending tasks to avoid leaks. | 417 // Process all pending tasks to avoid leaks. |
| 411 MessageLoop::current()->RunAllPending(); | 418 MessageLoop::current()->RunAllPending(); |
| 412 } | 419 } |
| 413 | 420 |
| 414 void SendInputEventACK(WebInputEvent::Type type, bool processed) { | 421 void SendInputEventACK(WebInputEvent::Type type, bool processed) { |
| 415 scoped_ptr<IPC::Message> response( | 422 scoped_ptr<IPC::Message> response( |
| 416 new ViewHostMsg_HandleInputEvent_ACK(0, type, processed)); | 423 new ViewHostMsg_HandleInputEvent_ACK(0, type, processed)); |
| 417 host_->OnMessageReceived(*response); | 424 host_->OnMessageReceived(*response); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 touch_event_.type = WebInputEvent::TouchEnd; | 521 touch_event_.type = WebInputEvent::TouchEnd; |
| 515 } | 522 } |
| 516 | 523 |
| 517 MessageLoopForUI message_loop_; | 524 MessageLoopForUI message_loop_; |
| 518 | 525 |
| 519 scoped_ptr<TestBrowserContext> browser_context_; | 526 scoped_ptr<TestBrowserContext> browser_context_; |
| 520 RenderWidgetHostProcess* process_; // Deleted automatically by the widget. | 527 RenderWidgetHostProcess* process_; // Deleted automatically by the widget. |
| 521 scoped_ptr<MockRenderWidgetHostDelegate> delegate_; | 528 scoped_ptr<MockRenderWidgetHostDelegate> delegate_; |
| 522 scoped_ptr<MockRenderWidgetHost> host_; | 529 scoped_ptr<MockRenderWidgetHost> host_; |
| 523 scoped_ptr<TestView> view_; | 530 scoped_ptr<TestView> view_; |
| 531 scoped_ptr<gfx::Screen> screen_; |
| 524 | 532 |
| 525 private: | 533 private: |
| 526 WebTouchEvent touch_event_; | 534 WebTouchEvent touch_event_; |
| 527 | 535 |
| 528 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostTest); | 536 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostTest); |
| 529 }; | 537 }; |
| 530 | 538 |
| 531 } // namespace | 539 } // namespace |
| 532 | 540 |
| 533 // ----------------------------------------------------------------------------- | 541 // ----------------------------------------------------------------------------- |
| (...skipping 1252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1786 process_->InitUpdateRectParams(¶ms); | 1794 process_->InitUpdateRectParams(¶ms); |
| 1787 params.scale_factor = params.scale_factor * 2; | 1795 params.scale_factor = params.scale_factor * 2; |
| 1788 | 1796 |
| 1789 EXPECT_EQ(0, process_->bad_msg_count()); | 1797 EXPECT_EQ(0, process_->bad_msg_count()); |
| 1790 host_->OnMsgUpdateRect(params); | 1798 host_->OnMsgUpdateRect(params); |
| 1791 EXPECT_EQ(1, process_->bad_msg_count()); | 1799 EXPECT_EQ(1, process_->bad_msg_count()); |
| 1792 } | 1800 } |
| 1793 #endif | 1801 #endif |
| 1794 | 1802 |
| 1795 } // namespace content | 1803 } // namespace content |
| OLD | NEW |