OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ash/wm/immersive_fullscreen_controller.h" | 5 #include "ash/wm/immersive_fullscreen_controller.h" |
6 | 6 |
7 #include "ash/display/display_manager.h" | 7 #include "ash/display/display_manager.h" |
8 #include "ash/display/mouse_cursor_event_filter.h" | 8 #include "ash/display/mouse_cursor_event_filter.h" |
9 #include "ash/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
10 #include "ash/shelf/shelf_layout_manager.h" | 10 #include "ash/shelf/shelf_layout_manager.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 namespace { | 32 namespace { |
33 | 33 |
34 class MockImmersiveFullscreenControllerDelegate | 34 class MockImmersiveFullscreenControllerDelegate |
35 : public ImmersiveFullscreenController::Delegate { | 35 : public ImmersiveFullscreenController::Delegate { |
36 public: | 36 public: |
37 MockImmersiveFullscreenControllerDelegate(views::View* top_container_view) | 37 MockImmersiveFullscreenControllerDelegate(views::View* top_container_view) |
38 : top_container_view_(top_container_view), | 38 : top_container_view_(top_container_view), |
39 enabled_(false), | 39 enabled_(false), |
40 visible_fraction_(1) { | 40 visible_fraction_(1) { |
41 } | 41 } |
42 virtual ~MockImmersiveFullscreenControllerDelegate() {} | 42 ~MockImmersiveFullscreenControllerDelegate() override {} |
43 | 43 |
44 // ImmersiveFullscreenController::Delegate overrides: | 44 // ImmersiveFullscreenController::Delegate overrides: |
45 virtual void OnImmersiveRevealStarted() override { | 45 void OnImmersiveRevealStarted() override { |
46 enabled_ = true; | 46 enabled_ = true; |
47 visible_fraction_ = 0; | 47 visible_fraction_ = 0; |
48 } | 48 } |
49 virtual void OnImmersiveRevealEnded() override { | 49 void OnImmersiveRevealEnded() override { visible_fraction_ = 0; } |
50 visible_fraction_ = 0; | 50 void OnImmersiveFullscreenExited() override { |
51 } | |
52 virtual void OnImmersiveFullscreenExited() override { | |
53 enabled_ = false; | 51 enabled_ = false; |
54 visible_fraction_ = 1; | 52 visible_fraction_ = 1; |
55 } | 53 } |
56 virtual void SetVisibleFraction(double visible_fraction) override { | 54 void SetVisibleFraction(double visible_fraction) override { |
57 visible_fraction_ = visible_fraction; | 55 visible_fraction_ = visible_fraction; |
58 } | 56 } |
59 virtual std::vector<gfx::Rect> GetVisibleBoundsInScreen() const override { | 57 std::vector<gfx::Rect> GetVisibleBoundsInScreen() const override { |
60 std::vector<gfx::Rect> bounds_in_screen; | 58 std::vector<gfx::Rect> bounds_in_screen; |
61 bounds_in_screen.push_back(top_container_view_->GetBoundsInScreen()); | 59 bounds_in_screen.push_back(top_container_view_->GetBoundsInScreen()); |
62 return bounds_in_screen; | 60 return bounds_in_screen; |
63 } | 61 } |
64 | 62 |
65 bool is_enabled() const { | 63 bool is_enabled() const { |
66 return enabled_; | 64 return enabled_; |
67 } | 65 } |
68 | 66 |
69 double visible_fraction() const { | 67 double visible_fraction() const { |
70 return visible_fraction_; | 68 return visible_fraction_; |
71 } | 69 } |
72 | 70 |
73 private: | 71 private: |
74 views::View* top_container_view_; | 72 views::View* top_container_view_; |
75 bool enabled_; | 73 bool enabled_; |
76 double visible_fraction_; | 74 double visible_fraction_; |
77 | 75 |
78 DISALLOW_COPY_AND_ASSIGN(MockImmersiveFullscreenControllerDelegate); | 76 DISALLOW_COPY_AND_ASSIGN(MockImmersiveFullscreenControllerDelegate); |
79 }; | 77 }; |
80 | 78 |
81 class ConsumeEventHandler : public ui::test::TestEventHandler { | 79 class ConsumeEventHandler : public ui::test::TestEventHandler { |
82 public: | 80 public: |
83 ConsumeEventHandler() {} | 81 ConsumeEventHandler() {} |
84 virtual ~ConsumeEventHandler() {} | 82 ~ConsumeEventHandler() override {} |
85 | 83 |
86 private: | 84 private: |
87 virtual void OnEvent(ui::Event* event) override { | 85 void OnEvent(ui::Event* event) override { |
88 ui::test::TestEventHandler::OnEvent(event); | 86 ui::test::TestEventHandler::OnEvent(event); |
89 if (event->cancelable()) | 87 if (event->cancelable()) |
90 event->SetHandled(); | 88 event->SetHandled(); |
91 } | 89 } |
92 | 90 |
93 DISALLOW_COPY_AND_ASSIGN(ConsumeEventHandler); | 91 DISALLOW_COPY_AND_ASSIGN(ConsumeEventHandler); |
94 }; | 92 }; |
95 | 93 |
96 } // namespace | 94 } // namespace |
97 | 95 |
98 ///////////////////////////////////////////////////////////////////////////// | 96 ///////////////////////////////////////////////////////////////////////////// |
99 | 97 |
100 class ImmersiveFullscreenControllerTest : public ash::test::AshTestBase { | 98 class ImmersiveFullscreenControllerTest : public ash::test::AshTestBase { |
101 public: | 99 public: |
102 enum Modality { | 100 enum Modality { |
103 MODALITY_MOUSE, | 101 MODALITY_MOUSE, |
104 MODALITY_GESTURE_TAP, | 102 MODALITY_GESTURE_TAP, |
105 MODALITY_GESTURE_SCROLL | 103 MODALITY_GESTURE_SCROLL |
106 }; | 104 }; |
107 | 105 |
108 ImmersiveFullscreenControllerTest() | 106 ImmersiveFullscreenControllerTest() |
109 : widget_(NULL), | 107 : widget_(NULL), |
110 top_container_(NULL), | 108 top_container_(NULL), |
111 content_view_(NULL) {} | 109 content_view_(NULL) {} |
112 virtual ~ImmersiveFullscreenControllerTest() {} | 110 ~ImmersiveFullscreenControllerTest() override {} |
113 | 111 |
114 ImmersiveFullscreenController* controller() { | 112 ImmersiveFullscreenController* controller() { |
115 return controller_.get(); | 113 return controller_.get(); |
116 } | 114 } |
117 | 115 |
118 views::NativeViewHost* content_view() { | 116 views::NativeViewHost* content_view() { |
119 return content_view_; | 117 return content_view_; |
120 } | 118 } |
121 | 119 |
122 views::View* top_container() { | 120 views::View* top_container() { |
(...skipping 12 matching lines...) Expand all Loading... |
135 | 133 |
136 // Access to private data from the controller. | 134 // Access to private data from the controller. |
137 bool top_edge_hover_timer_running() const { | 135 bool top_edge_hover_timer_running() const { |
138 return controller_->top_edge_hover_timer_.IsRunning(); | 136 return controller_->top_edge_hover_timer_.IsRunning(); |
139 } | 137 } |
140 int mouse_x_when_hit_top() const { | 138 int mouse_x_when_hit_top() const { |
141 return controller_->mouse_x_when_hit_top_in_screen_; | 139 return controller_->mouse_x_when_hit_top_in_screen_; |
142 } | 140 } |
143 | 141 |
144 // ash::test::AshTestBase overrides: | 142 // ash::test::AshTestBase overrides: |
145 virtual void SetUp() override { | 143 void SetUp() override { |
146 ash::test::AshTestBase::SetUp(); | 144 ash::test::AshTestBase::SetUp(); |
147 | 145 |
148 widget_ = new views::Widget(); | 146 widget_ = new views::Widget(); |
149 views::Widget::InitParams params; | 147 views::Widget::InitParams params; |
150 params.context = CurrentContext(); | 148 params.context = CurrentContext(); |
151 widget_->Init(params); | 149 widget_->Init(params); |
152 widget_->Show(); | 150 widget_->Show(); |
153 | 151 |
154 window()->SetProperty(aura::client::kShowStateKey, | 152 window()->SetProperty(aura::client::kShowStateKey, |
155 ui::SHOW_STATE_FULLSCREEN); | 153 ui::SHOW_STATE_FULLSCREEN); |
(...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1062 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state()); | 1060 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state()); |
1063 | 1061 |
1064 // Disabling immersive fullscreen maintains the user's auto-hide selection. | 1062 // Disabling immersive fullscreen maintains the user's auto-hide selection. |
1065 SetEnabled(false); | 1063 SetEnabled(false); |
1066 window()->SetProperty(aura::client::kShowStateKey, | 1064 window()->SetProperty(aura::client::kShowStateKey, |
1067 ui::SHOW_STATE_NORMAL); | 1065 ui::SHOW_STATE_NORMAL); |
1068 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state()); | 1066 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state()); |
1069 } | 1067 } |
1070 | 1068 |
1071 } // namespase ash | 1069 } // namespase ash |
OLD | NEW |