| 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 "content/browser/renderer_host/render_widget_host_view_aura.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/memory/shared_memory.h" | 9 #include "base/memory/shared_memory.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 #include "ui/aura/window_event_dispatcher.h" | 49 #include "ui/aura/window_event_dispatcher.h" |
| 50 #include "ui/aura/window_observer.h" | 50 #include "ui/aura/window_observer.h" |
| 51 #include "ui/base/ui_base_types.h" | 51 #include "ui/base/ui_base_types.h" |
| 52 #include "ui/compositor/compositor.h" | 52 #include "ui/compositor/compositor.h" |
| 53 #include "ui/compositor/test/draw_waiter_for_test.h" | 53 #include "ui/compositor/test/draw_waiter_for_test.h" |
| 54 #include "ui/events/event.h" | 54 #include "ui/events/event.h" |
| 55 #include "ui/events/event_utils.h" | 55 #include "ui/events/event_utils.h" |
| 56 #include "ui/events/gesture_detection/gesture_configuration.h" | 56 #include "ui/events/gesture_detection/gesture_configuration.h" |
| 57 #include "ui/events/test/event_generator.h" | 57 #include "ui/events/test/event_generator.h" |
| 58 #include "ui/wm/core/default_activation_client.h" | 58 #include "ui/wm/core/default_activation_client.h" |
| 59 #include "ui/wm/core/default_screen_position_client.h" |
| 59 | 60 |
| 60 using testing::_; | 61 using testing::_; |
| 61 | 62 |
| 62 using blink::WebGestureEvent; | 63 using blink::WebGestureEvent; |
| 63 using blink::WebInputEvent; | 64 using blink::WebInputEvent; |
| 64 using blink::WebMouseEvent; | 65 using blink::WebMouseEvent; |
| 65 using blink::WebMouseWheelEvent; | 66 using blink::WebMouseWheelEvent; |
| 66 using blink::WebTouchEvent; | 67 using blink::WebTouchEvent; |
| 67 using blink::WebTouchPoint; | 68 using blink::WebTouchPoint; |
| 68 | 69 |
| 69 namespace content { | 70 namespace content { |
| 70 namespace { | 71 namespace { |
| 71 | 72 |
| 72 // Simple screen position client to test coordinate system conversion. | |
| 73 class TestScreenPositionClient | |
| 74 : public aura::client::ScreenPositionClient { | |
| 75 public: | |
| 76 TestScreenPositionClient() {} | |
| 77 ~TestScreenPositionClient() override {} | |
| 78 | |
| 79 // aura::client::ScreenPositionClient overrides: | |
| 80 void ConvertPointToScreen(const aura::Window* window, | |
| 81 gfx::Point* point) override { | |
| 82 point->Offset(-1, -1); | |
| 83 } | |
| 84 | |
| 85 void ConvertPointFromScreen(const aura::Window* window, | |
| 86 gfx::Point* point) override { | |
| 87 point->Offset(1, 1); | |
| 88 } | |
| 89 | |
| 90 void ConvertHostPointToScreen(aura::Window* window, | |
| 91 gfx::Point* point) override { | |
| 92 ConvertPointToScreen(window, point); | |
| 93 } | |
| 94 | |
| 95 void SetBounds(aura::Window* window, | |
| 96 const gfx::Rect& bounds, | |
| 97 const gfx::Display& display) override {} | |
| 98 }; | |
| 99 | |
| 100 class TestOverscrollDelegate : public OverscrollControllerDelegate { | 73 class TestOverscrollDelegate : public OverscrollControllerDelegate { |
| 101 public: | 74 public: |
| 102 explicit TestOverscrollDelegate(RenderWidgetHostView* view) | 75 explicit TestOverscrollDelegate(RenderWidgetHostView* view) |
| 103 : view_(view), | 76 : view_(view), |
| 104 current_mode_(OVERSCROLL_NONE), | 77 current_mode_(OVERSCROLL_NONE), |
| 105 completed_mode_(OVERSCROLL_NONE), | 78 completed_mode_(OVERSCROLL_NONE), |
| 106 delta_x_(0.f), | 79 delta_x_(0.f), |
| 107 delta_y_(0.f) {} | 80 delta_y_(0.f) {} |
| 108 | 81 |
| 109 ~TestOverscrollDelegate() override {} | 82 ~TestOverscrollDelegate() override {} |
| (...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 EXPECT_TRUE(window->HasFocus()); | 671 EXPECT_TRUE(window->HasFocus()); |
| 699 | 672 |
| 700 // Check that we'll also say it's okay to activate the window when there's an | 673 // Check that we'll also say it's okay to activate the window when there's an |
| 701 // ActivationClient defined. | 674 // ActivationClient defined. |
| 702 EXPECT_TRUE(view_->ShouldActivate()); | 675 EXPECT_TRUE(view_->ShouldActivate()); |
| 703 } | 676 } |
| 704 | 677 |
| 705 // Checks that a popup is positioned correctly relative to its parent using | 678 // Checks that a popup is positioned correctly relative to its parent using |
| 706 // screen coordinates. | 679 // screen coordinates. |
| 707 TEST_F(RenderWidgetHostViewAuraTest, PositionChildPopup) { | 680 TEST_F(RenderWidgetHostViewAuraTest, PositionChildPopup) { |
| 708 TestScreenPositionClient screen_position_client; | 681 wm::DefaultScreenPositionClient screen_position_client; |
| 709 | 682 |
| 710 aura::Window* window = parent_view_->GetNativeView(); | 683 aura::Window* window = parent_view_->GetNativeView(); |
| 711 aura::Window* root = window->GetRootWindow(); | 684 aura::Window* root = window->GetRootWindow(); |
| 712 aura::client::SetScreenPositionClient(root, &screen_position_client); | 685 aura::client::SetScreenPositionClient(root, &screen_position_client); |
| 713 | 686 |
| 714 parent_view_->SetBounds(gfx::Rect(10, 10, 800, 600)); | 687 parent_view_->SetBounds(gfx::Rect(10, 10, 800, 600)); |
| 715 gfx::Rect bounds_in_screen = parent_view_->GetViewBounds(); | 688 gfx::Rect bounds_in_screen = parent_view_->GetViewBounds(); |
| 716 int horiz = bounds_in_screen.width() / 4; | 689 int horiz = bounds_in_screen.width() / 4; |
| 717 int vert = bounds_in_screen.height() / 4; | 690 int vert = bounds_in_screen.height() / 4; |
| 718 bounds_in_screen.Inset(horiz, vert); | 691 bounds_in_screen.Inset(horiz, vert); |
| (...skipping 2185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2904 } | 2877 } |
| 2905 | 2878 |
| 2906 // Tests that when view initiated shutdown happens (i.e. RWHView is deleted | 2879 // Tests that when view initiated shutdown happens (i.e. RWHView is deleted |
| 2907 // before RWH), we clean up properly and don't leak the RWHVGuest. | 2880 // before RWH), we clean up properly and don't leak the RWHVGuest. |
| 2908 TEST_F(RenderWidgetHostViewGuestAuraTest, GuestViewDoesNotLeak) { | 2881 TEST_F(RenderWidgetHostViewGuestAuraTest, GuestViewDoesNotLeak) { |
| 2909 TearDownEnvironment(); | 2882 TearDownEnvironment(); |
| 2910 ASSERT_FALSE(guest_view_weak_.get()); | 2883 ASSERT_FALSE(guest_view_weak_.get()); |
| 2911 } | 2884 } |
| 2912 | 2885 |
| 2913 } // namespace content | 2886 } // namespace content |
| OLD | NEW |