| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 22 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
| 23 #include "content/common/input/synthetic_web_input_event_builders.h" | 23 #include "content/common/input/synthetic_web_input_event_builders.h" |
| 24 #include "content/common/input_messages.h" | 24 #include "content/common/input_messages.h" |
| 25 #include "content/common/resize_params.h" | 25 #include "content/common/resize_params.h" |
| 26 #include "content/common/view_messages.h" | 26 #include "content/common/view_messages.h" |
| 27 #include "content/public/common/content_switches.h" | 27 #include "content/public/common/content_switches.h" |
| 28 #include "content/public/test/mock_render_process_host.h" | 28 #include "content/public/test/mock_render_process_host.h" |
| 29 #include "content/public/test/test_browser_context.h" | 29 #include "content/public/test/test_browser_context.h" |
| 30 #include "content/test/test_render_view_host.h" | 30 #include "content/test/test_render_view_host.h" |
| 31 #include "testing/gtest/include/gtest/gtest.h" | 31 #include "testing/gtest/include/gtest/gtest.h" |
| 32 #include "ui/display/screen.h" |
| 32 #include "ui/events/keycodes/keyboard_codes.h" | 33 #include "ui/events/keycodes/keyboard_codes.h" |
| 33 #include "ui/gfx/canvas.h" | 34 #include "ui/gfx/canvas.h" |
| 34 #include "ui/gfx/screen.h" | |
| 35 | 35 |
| 36 #if defined(OS_ANDROID) | 36 #if defined(OS_ANDROID) |
| 37 #include "content/browser/renderer_host/render_widget_host_view_android.h" | 37 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
| 38 #endif | 38 #endif |
| 39 | 39 |
| 40 #if defined(USE_AURA) || defined(OS_MACOSX) | 40 #if defined(USE_AURA) || defined(OS_MACOSX) |
| 41 #include "content/browser/compositor/test/no_transport_image_transport_factory.h
" | 41 #include "content/browser/compositor/test/no_transport_image_transport_factory.h
" |
| 42 #endif | 42 #endif |
| 43 | 43 |
| 44 #if defined(USE_AURA) | 44 #if defined(USE_AURA) |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 browser_context_.reset(new TestBrowserContext()); | 457 browser_context_.reset(new TestBrowserContext()); |
| 458 delegate_.reset(new MockRenderWidgetHostDelegate()); | 458 delegate_.reset(new MockRenderWidgetHostDelegate()); |
| 459 process_ = new RenderWidgetHostProcess(browser_context_.get()); | 459 process_ = new RenderWidgetHostProcess(browser_context_.get()); |
| 460 #if defined(USE_AURA) || defined(OS_MACOSX) | 460 #if defined(USE_AURA) || defined(OS_MACOSX) |
| 461 ImageTransportFactory::InitializeForUnitTests( | 461 ImageTransportFactory::InitializeForUnitTests( |
| 462 std::unique_ptr<ImageTransportFactory>( | 462 std::unique_ptr<ImageTransportFactory>( |
| 463 new NoTransportImageTransportFactory)); | 463 new NoTransportImageTransportFactory)); |
| 464 #endif | 464 #endif |
| 465 #if defined(USE_AURA) | 465 #if defined(USE_AURA) |
| 466 screen_.reset(aura::TestScreen::Create(gfx::Size())); | 466 screen_.reset(aura::TestScreen::Create(gfx::Size())); |
| 467 gfx::Screen::SetScreenInstance(screen_.get()); | 467 display::Screen::SetScreenInstance(screen_.get()); |
| 468 #endif | 468 #endif |
| 469 host_.reset(new MockRenderWidgetHost(delegate_.get(), process_, | 469 host_.reset(new MockRenderWidgetHost(delegate_.get(), process_, |
| 470 process_->GetNextRoutingID())); | 470 process_->GetNextRoutingID())); |
| 471 view_.reset(new TestView(host_.get())); | 471 view_.reset(new TestView(host_.get())); |
| 472 ConfigureView(view_.get()); | 472 ConfigureView(view_.get()); |
| 473 host_->SetView(view_.get()); | 473 host_->SetView(view_.get()); |
| 474 SetInitialRenderSizeParams(); | 474 SetInitialRenderSizeParams(); |
| 475 host_->Init(); | 475 host_->Init(); |
| 476 host_->DisableGestureDebounce(); | 476 host_->DisableGestureDebounce(); |
| 477 } | 477 } |
| 478 | 478 |
| 479 void TearDown() override { | 479 void TearDown() override { |
| 480 view_.reset(); | 480 view_.reset(); |
| 481 host_.reset(); | 481 host_.reset(); |
| 482 delegate_.reset(); | 482 delegate_.reset(); |
| 483 process_ = NULL; | 483 process_ = NULL; |
| 484 browser_context_.reset(); | 484 browser_context_.reset(); |
| 485 | 485 |
| 486 #if defined(USE_AURA) | 486 #if defined(USE_AURA) |
| 487 gfx::Screen::SetScreenInstance(nullptr); | 487 display::Screen::SetScreenInstance(nullptr); |
| 488 screen_.reset(); | 488 screen_.reset(); |
| 489 #endif | 489 #endif |
| 490 #if defined(USE_AURA) || defined(OS_MACOSX) | 490 #if defined(USE_AURA) || defined(OS_MACOSX) |
| 491 ImageTransportFactory::Terminate(); | 491 ImageTransportFactory::Terminate(); |
| 492 #endif | 492 #endif |
| 493 | 493 |
| 494 // Process all pending tasks to avoid leaks. | 494 // Process all pending tasks to avoid leaks. |
| 495 base::MessageLoop::current()->RunUntilIdle(); | 495 base::MessageLoop::current()->RunUntilIdle(); |
| 496 } | 496 } |
| 497 | 497 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 return reinterpret_cast<const WebInputEvent*>(data); | 622 return reinterpret_cast<const WebInputEvent*>(data); |
| 623 } | 623 } |
| 624 | 624 |
| 625 base::MessageLoopForUI message_loop_; | 625 base::MessageLoopForUI message_loop_; |
| 626 | 626 |
| 627 std::unique_ptr<TestBrowserContext> browser_context_; | 627 std::unique_ptr<TestBrowserContext> browser_context_; |
| 628 RenderWidgetHostProcess* process_; // Deleted automatically by the widget. | 628 RenderWidgetHostProcess* process_; // Deleted automatically by the widget. |
| 629 std::unique_ptr<MockRenderWidgetHostDelegate> delegate_; | 629 std::unique_ptr<MockRenderWidgetHostDelegate> delegate_; |
| 630 std::unique_ptr<MockRenderWidgetHost> host_; | 630 std::unique_ptr<MockRenderWidgetHost> host_; |
| 631 std::unique_ptr<TestView> view_; | 631 std::unique_ptr<TestView> view_; |
| 632 std::unique_ptr<gfx::Screen> screen_; | 632 std::unique_ptr<display::Screen> screen_; |
| 633 bool handle_key_press_event_; | 633 bool handle_key_press_event_; |
| 634 bool handle_mouse_event_; | 634 bool handle_mouse_event_; |
| 635 double last_simulated_event_time_seconds_; | 635 double last_simulated_event_time_seconds_; |
| 636 double simulated_event_time_delta_seconds_; | 636 double simulated_event_time_delta_seconds_; |
| 637 | 637 |
| 638 private: | 638 private: |
| 639 SyntheticWebTouchEvent touch_event_; | 639 SyntheticWebTouchEvent touch_event_; |
| 640 | 640 |
| 641 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostTest); | 641 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostTest); |
| 642 }; | 642 }; |
| (...skipping 1029 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1672 ui::LatencyInfo()); | 1672 ui::LatencyInfo()); |
| 1673 | 1673 |
| 1674 | 1674 |
| 1675 // Tests RWHI::ForwardWheelEventWithLatencyInfo(). | 1675 // Tests RWHI::ForwardWheelEventWithLatencyInfo(). |
| 1676 SimulateWheelEventWithLatencyInfo(-5, 0, 0, true, ui::LatencyInfo()); | 1676 SimulateWheelEventWithLatencyInfo(-5, 0, 0, true, ui::LatencyInfo()); |
| 1677 | 1677 |
| 1678 ASSERT_FALSE(host_->input_router()->HasPendingEvents()); | 1678 ASSERT_FALSE(host_->input_router()->HasPendingEvents()); |
| 1679 } | 1679 } |
| 1680 | 1680 |
| 1681 } // namespace content | 1681 } // namespace content |
| OLD | NEW |