OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/maximize_mode/maximize_mode_controller.h" | 5 #include "ash/wm/maximize_mode/maximize_mode_controller.h" |
6 | 6 |
7 #include "ash/accelerometer/accelerometer_controller.h" | 7 #include "ash/accelerometer/accelerometer_controller.h" |
8 #include "ash/display/display_manager.h" | 8 #include "ash/display/display_manager.h" |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/system/tray/system_tray_delegate.h" | 10 #include "ash/system/tray/system_tray_delegate.h" |
11 #include "ash/test/ash_test_base.h" | 11 #include "ash/test/ash_test_base.h" |
12 #include "ash/test/display_manager_test_api.h" | 12 #include "ash/test/display_manager_test_api.h" |
13 #include "ash/test/test_lock_state_controller_delegate.h" | 13 #include "ash/test/test_lock_state_controller_delegate.h" |
14 #include "ash/test/test_screenshot_delegate.h" | 14 #include "ash/test/test_screenshot_delegate.h" |
15 #include "ash/test/test_system_tray_delegate.h" | 15 #include "ash/test/test_system_tray_delegate.h" |
16 #include "ash/test/test_volume_control_delegate.h" | 16 #include "ash/test/test_volume_control_delegate.h" |
17 #include "base/test/simple_test_tick_clock.h" | |
17 #include "ui/events/event_handler.h" | 18 #include "ui/events/event_handler.h" |
18 #include "ui/events/test/event_generator.h" | 19 #include "ui/events/test/event_generator.h" |
19 #include "ui/gfx/vector3d_f.h" | 20 #include "ui/gfx/vector3d_f.h" |
20 #include "ui/message_center/message_center.h" | 21 #include "ui/message_center/message_center.h" |
21 | 22 |
22 #if defined(USE_X11) | 23 #if defined(USE_X11) |
23 #include "ui/events/test/events_test_utils_x11.h" | 24 #include "ui/events/test/events_test_utils_x11.h" |
24 #endif | 25 #endif |
25 | 26 |
26 namespace ash { | 27 namespace ash { |
(...skipping 11 matching lines...) Expand all Loading... | |
38 extern const float kAccelerometerLaptopModeTestData[]; | 39 extern const float kAccelerometerLaptopModeTestData[]; |
39 extern const size_t kAccelerometerLaptopModeTestDataLength; | 40 extern const size_t kAccelerometerLaptopModeTestDataLength; |
40 | 41 |
41 // Test accelerometer data taken with the lid open 360 degrees while | 42 // Test accelerometer data taken with the lid open 360 degrees while |
42 // shaking the device around. The data is to be interpreted in groups of 6 where | 43 // shaking the device around. The data is to be interpreted in groups of 6 where |
43 // each 6 values corresponds to the X, Y, and Z readings from the base and lid | 44 // each 6 values corresponds to the X, Y, and Z readings from the base and lid |
44 // accelerometers in this order. | 45 // accelerometers in this order. |
45 extern const float kAccelerometerFullyOpenTestData[]; | 46 extern const float kAccelerometerFullyOpenTestData[]; |
46 extern const size_t kAccelerometerFullyOpenTestDataLength; | 47 extern const size_t kAccelerometerFullyOpenTestDataLength; |
47 | 48 |
49 // Test vectors that can be used to make the hinge appear to be near a given | |
50 // angle. Use TriggerAccelerometerUpdate(kHingeBaseVector, k<#>DegreeVector) | |
51 // where <#> in k<#>DegreeVector is the desired angle. Note the <#> values are | |
52 // approximations and are within +/-1 degree. | |
53 const gfx::Vector3dF kHingeBaseVector(1.0f, 0.0f, 0.0f); | |
flackr
2014/07/31 20:21:41
Global object types are forbidden: http://google-s
bruthig
2014/08/05 18:06:43
Done.
| |
54 const gfx::Vector3dF kHingeLidVector_5(1.0f, 0.0f, 0.1f); | |
55 const gfx::Vector3dF kHingeLidVector_45(0.75f, 0.0f, 0.75f); | |
56 const gfx::Vector3dF kHingeLidVector_90(0.0f, 0.0f, 1.0f); | |
57 const gfx::Vector3dF kHingeLidVector_180(-1.0f, 0.0f, 0.0f); | |
58 const gfx::Vector3dF kHingeLidVector_270(0.0f, 0.0f, -1.0f); | |
59 const gfx::Vector3dF kHingeLidVector_315(0.75f, 0.0f, -0.75f); | |
60 const gfx::Vector3dF kHingeLidVector_355(1.0f, 0.0f, -0.1f); | |
61 | |
48 class MaximizeModeControllerTest : public test::AshTestBase { | 62 class MaximizeModeControllerTest : public test::AshTestBase { |
49 public: | 63 public: |
50 MaximizeModeControllerTest() {} | 64 MaximizeModeControllerTest() {} |
51 virtual ~MaximizeModeControllerTest() {} | 65 virtual ~MaximizeModeControllerTest() {} |
52 | 66 |
53 virtual void SetUp() OVERRIDE { | 67 virtual void SetUp() OVERRIDE { |
54 test::AshTestBase::SetUp(); | 68 test::AshTestBase::SetUp(); |
55 Shell::GetInstance()->accelerometer_controller()->RemoveObserver( | 69 Shell::GetInstance()->accelerometer_controller()->RemoveObserver( |
56 maximize_mode_controller()); | 70 maximize_mode_controller()); |
57 | 71 |
(...skipping 25 matching lines...) Expand all Loading... | |
83 gfx::Display::Rotation GetInternalDisplayRotation() const { | 97 gfx::Display::Rotation GetInternalDisplayRotation() const { |
84 return Shell::GetInstance()->display_manager()->GetDisplayInfo( | 98 return Shell::GetInstance()->display_manager()->GetDisplayInfo( |
85 gfx::Display::InternalDisplayId()).rotation(); | 99 gfx::Display::InternalDisplayId()).rotation(); |
86 } | 100 } |
87 | 101 |
88 void SetInternalDisplayRotation(gfx::Display::Rotation rotation) const { | 102 void SetInternalDisplayRotation(gfx::Display::Rotation rotation) const { |
89 Shell::GetInstance()->display_manager()-> | 103 Shell::GetInstance()->display_manager()-> |
90 SetDisplayRotation(gfx::Display::InternalDisplayId(), rotation); | 104 SetDisplayRotation(gfx::Display::InternalDisplayId(), rotation); |
91 } | 105 } |
92 | 106 |
107 // Attaches a SimpleTestTickClock to the MaximizeModeController with a non | |
108 // null value initial value. | |
109 void AttachTickClockForTest() { | |
110 scoped_ptr<base::TickClock> tick_clock( | |
111 test_tick_clock_ = new base::SimpleTestTickClock()); | |
112 test_tick_clock_->Advance(base::TimeDelta::FromSeconds(1)); | |
113 maximize_mode_controller()->SetTickClockForTest(tick_clock.Pass()); | |
114 } | |
115 | |
116 void AdvanceTickClock(const base::TimeDelta& delta) { | |
117 DCHECK(test_tick_clock_); | |
118 test_tick_clock_->Advance(delta); | |
119 } | |
120 | |
121 #if defined(OS_CHROMEOS) | |
122 void OpenLid() { | |
123 maximize_mode_controller()->LidEventReceived(true /* open */, | |
124 maximize_mode_controller()->tick_clock_->NowTicks()); | |
flackr
2014/07/31 20:21:41
nit: indent 4.
bruthig
2014/08/05 18:06:43
Done.
| |
125 } | |
126 | |
127 void CloseLid() { | |
128 maximize_mode_controller()->LidEventReceived(false /* open */, | |
129 maximize_mode_controller()->tick_clock_->NowTicks()); | |
flackr
2014/07/31 20:21:41
nit: indent 4.
bruthig
2014/08/05 18:06:43
Done.
| |
130 } | |
131 #endif // OS_CHROMEOS | |
132 | |
133 bool WasLidOpenedRecently() { | |
134 return maximize_mode_controller()->WasLidOpenedRecently(); | |
135 } | |
136 | |
93 private: | 137 private: |
138 base::SimpleTestTickClock* test_tick_clock_; | |
139 | |
94 DISALLOW_COPY_AND_ASSIGN(MaximizeModeControllerTest); | 140 DISALLOW_COPY_AND_ASSIGN(MaximizeModeControllerTest); |
95 }; | 141 }; |
96 | 142 |
97 // Tests that opening the lid beyond 180 will enter touchview, and that it will | 143 #if defined(OS_CHROMEOS) |
98 // exit when the lid comes back from 180. Also tests the thresholds, i.e. it | |
99 // will stick to the current mode. | |
100 TEST_F(MaximizeModeControllerTest, EnterExitThresholds) { | |
101 // For the simple test the base remains steady. | |
102 gfx::Vector3dF base(0.0f, 0.0f, 1.0f); | |
103 | 144 |
104 // Lid open 90 degrees. | 145 // Verify that closing the lid will exit maximize mode. |
105 TriggerAccelerometerUpdate(base, gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); | 146 TEST_F(MaximizeModeControllerTest, CloseLidWhileInMaximizeMode) { |
106 EXPECT_FALSE(IsMaximizeModeStarted()); | 147 TriggerAccelerometerUpdate(kHingeBaseVector, kHingeLidVector_315); |
148 ASSERT_TRUE(IsMaximizeModeStarted()); | |
107 | 149 |
108 // Open just past 180. | 150 CloseLid(); |
109 TriggerAccelerometerUpdate(base, gfx::Vector3dF(0.05f, 0.0f, -1.0f)); | |
110 EXPECT_FALSE(IsMaximizeModeStarted()); | |
111 | |
112 // Open up 270 degrees. | |
113 TriggerAccelerometerUpdate(base, gfx::Vector3dF(1.0f, 0.0f, 0.0f)); | |
114 EXPECT_TRUE(IsMaximizeModeStarted()); | |
115 | |
116 // Open up 360 degrees and appearing to be slightly past it (i.e. as if almost | |
117 // closed). | |
118 TriggerAccelerometerUpdate(base, gfx::Vector3dF(-0.05f, 0.0f, 1.0f)); | |
119 EXPECT_TRUE(IsMaximizeModeStarted()); | |
120 | |
121 // Open just before 180. | |
122 TriggerAccelerometerUpdate(base, gfx::Vector3dF(-0.05f, 0.0f, -1.0f)); | |
123 EXPECT_TRUE(IsMaximizeModeStarted()); | |
124 | |
125 // Open 90 degrees. | |
126 TriggerAccelerometerUpdate(base, gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); | |
127 EXPECT_FALSE(IsMaximizeModeStarted()); | 151 EXPECT_FALSE(IsMaximizeModeStarted()); |
128 } | 152 } |
129 | 153 |
154 // Verify that maximize mode will not be entered when the lid is closed. | |
155 TEST_F(MaximizeModeControllerTest, | |
156 HingeAnglesWithLidClosed) { | |
157 AttachTickClockForTest(); | |
158 | |
159 CloseLid(); | |
160 | |
161 TriggerAccelerometerUpdate(kHingeBaseVector, kHingeLidVector_270); | |
162 EXPECT_FALSE(IsMaximizeModeStarted()); | |
163 | |
164 TriggerAccelerometerUpdate(kHingeBaseVector, kHingeLidVector_315); | |
165 EXPECT_FALSE(IsMaximizeModeStarted()); | |
166 | |
167 TriggerAccelerometerUpdate(kHingeBaseVector, kHingeLidVector_355); | |
168 EXPECT_FALSE(IsMaximizeModeStarted()); | |
169 } | |
170 | |
171 // Verify the maximize mode state for unstable hinge angles when the lid was | |
172 // recently open. | |
173 TEST_F(MaximizeModeControllerTest, | |
174 UnstableHingeAnglesWhenLidRecentlyOpened) { | |
175 AttachTickClockForTest(); | |
176 | |
177 OpenLid(); | |
178 ASSERT_TRUE(WasLidOpenedRecently()); | |
179 | |
180 TriggerAccelerometerUpdate(kHingeBaseVector, kHingeLidVector_5); | |
181 EXPECT_FALSE(IsMaximizeModeStarted()); | |
182 | |
183 TriggerAccelerometerUpdate(kHingeBaseVector, kHingeLidVector_355); | |
184 EXPECT_FALSE(IsMaximizeModeStarted()); | |
185 | |
186 // This is a stable reading and should clear the last lid opened time. | |
187 TriggerAccelerometerUpdate(kHingeBaseVector, kHingeLidVector_45); | |
188 EXPECT_FALSE(IsMaximizeModeStarted()); | |
189 EXPECT_FALSE(WasLidOpenedRecently()); | |
190 | |
191 TriggerAccelerometerUpdate(kHingeBaseVector, kHingeLidVector_355); | |
192 EXPECT_TRUE(IsMaximizeModeStarted()); | |
193 } | |
194 | |
195 #endif // OS_CHROMEOS | |
196 | |
197 // Verify the WasLidOpenedRecently signal with respect to time. | |
198 TEST_F(MaximizeModeControllerTest, WasLidOpenedRecentlyOverTime) { | |
199 #if defined(OS_CHROMEOS) | |
200 | |
201 AttachTickClockForTest(); | |
202 | |
203 // No lid open time initially. | |
204 ASSERT_FALSE(WasLidOpenedRecently()); | |
205 | |
206 CloseLid(); | |
207 EXPECT_FALSE(WasLidOpenedRecently()); | |
208 | |
209 OpenLid(); | |
210 EXPECT_TRUE(WasLidOpenedRecently()); | |
211 | |
212 // 1 second after lid open. | |
213 AdvanceTickClock(base::TimeDelta::FromSeconds(1)); | |
214 EXPECT_TRUE(WasLidOpenedRecently()); | |
215 | |
216 // 2 seconds after lid open. | |
217 AdvanceTickClock(base::TimeDelta::FromSeconds(1)); | |
218 EXPECT_TRUE(WasLidOpenedRecently()); | |
219 | |
220 // 3 seconds after lid open. | |
221 AdvanceTickClock(base::TimeDelta::FromSeconds(1)); | |
222 EXPECT_FALSE(WasLidOpenedRecently()); | |
223 | |
224 #else | |
225 | |
226 EXPECT_FALSE(WasLidOpenedRecently()); | |
227 | |
228 #endif // OS_CHROMEOS | |
229 } | |
230 | |
231 // Verify the maximize mode enter/exit thresholds for stable angles. | |
232 TEST_F(MaximizeModeControllerTest, StableHingeAnglesWithLidOpened) { | |
233 ASSERT_FALSE(IsMaximizeModeStarted()); | |
234 ASSERT_FALSE(WasLidOpenedRecently()); | |
235 | |
236 TriggerAccelerometerUpdate(kHingeBaseVector, kHingeLidVector_180); | |
237 EXPECT_FALSE(IsMaximizeModeStarted()); | |
238 | |
239 TriggerAccelerometerUpdate(kHingeBaseVector, kHingeLidVector_315); | |
240 EXPECT_TRUE(IsMaximizeModeStarted()); | |
241 | |
242 TriggerAccelerometerUpdate(kHingeBaseVector, kHingeLidVector_180); | |
243 EXPECT_TRUE(IsMaximizeModeStarted()); | |
244 | |
245 TriggerAccelerometerUpdate(kHingeBaseVector, kHingeLidVector_45); | |
246 EXPECT_FALSE(IsMaximizeModeStarted()); | |
247 | |
248 TriggerAccelerometerUpdate(kHingeBaseVector, kHingeLidVector_270); | |
249 EXPECT_TRUE(IsMaximizeModeStarted()); | |
250 | |
251 TriggerAccelerometerUpdate(kHingeBaseVector, kHingeLidVector_90); | |
252 EXPECT_FALSE(IsMaximizeModeStarted()); | |
253 } | |
254 | |
255 // Verify the maximize mode state for unstable hinge angles when the lid is open | |
256 // but not recently. | |
257 TEST_F(MaximizeModeControllerTest, UnstableHingeAnglesWithLidOpened) { | |
258 AttachTickClockForTest(); | |
259 | |
260 ASSERT_FALSE(WasLidOpenedRecently()); | |
261 ASSERT_FALSE(IsMaximizeModeStarted()); | |
262 | |
263 TriggerAccelerometerUpdate(kHingeBaseVector, kHingeLidVector_5); | |
264 EXPECT_FALSE(IsMaximizeModeStarted()); | |
265 | |
266 TriggerAccelerometerUpdate(kHingeBaseVector, kHingeLidVector_355); | |
267 EXPECT_TRUE(IsMaximizeModeStarted()); | |
268 | |
269 TriggerAccelerometerUpdate(kHingeBaseVector, kHingeLidVector_5); | |
270 EXPECT_TRUE(IsMaximizeModeStarted()); | |
271 } | |
272 | |
130 // Tests that when the hinge is nearly vertically aligned, the current state | 273 // Tests that when the hinge is nearly vertically aligned, the current state |
131 // persists as the computed angle is highly inaccurate in this orientation. | 274 // persists as the computed angle is highly inaccurate in this orientation. |
132 TEST_F(MaximizeModeControllerTest, HingeAligned) { | 275 TEST_F(MaximizeModeControllerTest, HingeAligned) { |
133 // Laptop in normal orientation lid open 90 degrees. | 276 // Laptop in normal orientation lid open 90 degrees. |
134 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, 1.0f), | 277 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, 1.0f), |
135 gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); | 278 gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); |
136 EXPECT_FALSE(IsMaximizeModeStarted()); | 279 EXPECT_FALSE(IsMaximizeModeStarted()); |
137 | 280 |
138 // Completely vertical. | 281 // Completely vertical. |
139 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, -1.0f, 0.0f), | 282 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, -1.0f, 0.0f), |
(...skipping 10 matching lines...) Expand all Loading... | |
150 gfx::Vector3dF(1.0f, 0.0f, 0.0f)); | 293 gfx::Vector3dF(1.0f, 0.0f, 0.0f)); |
151 EXPECT_TRUE(IsMaximizeModeStarted()); | 294 EXPECT_TRUE(IsMaximizeModeStarted()); |
152 | 295 |
153 // Normal 90 degree orientation but near vertical should stay in maximize | 296 // Normal 90 degree orientation but near vertical should stay in maximize |
154 // mode. | 297 // mode. |
155 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, -1.0f, 0.01f), | 298 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, -1.0f, 0.01f), |
156 gfx::Vector3dF(-0.01f, -1.0f, 0.0f)); | 299 gfx::Vector3dF(-0.01f, -1.0f, 0.0f)); |
157 EXPECT_TRUE(IsMaximizeModeStarted()); | 300 EXPECT_TRUE(IsMaximizeModeStarted()); |
158 } | 301 } |
159 | 302 |
160 // Tests that accelerometer readings in each of the screen angles will trigger | 303 // Tests that accelerometer readings in each of the screen angles will trigger a |
161 // a rotation of the internal display. | 304 // rotation of the internal display. |
162 TEST_F(MaximizeModeControllerTest, DisplayRotation) { | 305 TEST_F(MaximizeModeControllerTest, DisplayRotation) { |
163 // Trigger maximize mode by opening to 270. | 306 // Trigger maximize mode by opening to 270. |
164 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, -1.0f), | 307 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, -1.0f), |
165 gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); | 308 gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); |
166 ASSERT_TRUE(IsMaximizeModeStarted()); | 309 ASSERT_TRUE(IsMaximizeModeStarted()); |
167 | 310 |
168 // Now test rotating in all directions. | 311 // Now test rotating in all directions. |
169 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 1.0f, 0.0f), | 312 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 1.0f, 0.0f), |
170 gfx::Vector3dF(0.0f, 1.0f, 0.0f)); | 313 gfx::Vector3dF(0.0f, 1.0f, 0.0f)); |
171 EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); | 314 EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
268 // and pressing power. | 411 // and pressing power. |
269 TEST_F(MaximizeModeControllerTest, Screenshot) { | 412 TEST_F(MaximizeModeControllerTest, Screenshot) { |
270 Shell::GetInstance()->lock_state_controller()->SetDelegate( | 413 Shell::GetInstance()->lock_state_controller()->SetDelegate( |
271 new test::TestLockStateControllerDelegate); | 414 new test::TestLockStateControllerDelegate); |
272 aura::Window* root = Shell::GetPrimaryRootWindow(); | 415 aura::Window* root = Shell::GetPrimaryRootWindow(); |
273 ui::test::EventGenerator event_generator(root, root); | 416 ui::test::EventGenerator event_generator(root, root); |
274 test::TestScreenshotDelegate* delegate = GetScreenshotDelegate(); | 417 test::TestScreenshotDelegate* delegate = GetScreenshotDelegate(); |
275 delegate->set_can_take_screenshot(true); | 418 delegate->set_can_take_screenshot(true); |
276 | 419 |
277 // Open up 270 degrees. | 420 // Open up 270 degrees. |
278 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, 1.0f), | 421 TriggerAccelerometerUpdate(kHingeBaseVector, kHingeLidVector_270); |
279 gfx::Vector3dF(1.0f, 0.0f, 0.0f)); | |
280 ASSERT_TRUE(IsMaximizeModeStarted()); | 422 ASSERT_TRUE(IsMaximizeModeStarted()); |
281 | 423 |
282 // Pressing power alone does not take a screenshot. | 424 // Pressing power alone does not take a screenshot. |
283 event_generator.PressKey(ui::VKEY_POWER, 0); | 425 event_generator.PressKey(ui::VKEY_POWER, 0); |
284 event_generator.ReleaseKey(ui::VKEY_POWER, 0); | 426 event_generator.ReleaseKey(ui::VKEY_POWER, 0); |
285 EXPECT_EQ(0, delegate->handle_take_screenshot_count()); | 427 EXPECT_EQ(0, delegate->handle_take_screenshot_count()); |
286 | 428 |
287 // Holding volume down and pressing power takes a screenshot. | 429 // Holding volume down and pressing power takes a screenshot. |
288 event_generator.PressKey(ui::VKEY_VOLUME_DOWN, 0); | 430 event_generator.PressKey(ui::VKEY_VOLUME_DOWN, 0); |
289 event_generator.PressKey(ui::VKEY_POWER, 0); | 431 event_generator.PressKey(ui::VKEY_POWER, 0); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
356 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); | 498 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); |
357 | 499 |
358 maximize_mode_controller()->SetRotationLocked(false); | 500 maximize_mode_controller()->SetRotationLocked(false); |
359 TriggerAccelerometerUpdate(gravity, gravity); | 501 TriggerAccelerometerUpdate(gravity, gravity); |
360 EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); | 502 EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); |
361 } | 503 } |
362 | 504 |
363 // Tests that when MaximizeModeController turns off MaximizeMode that on the | 505 // Tests that when MaximizeModeController turns off MaximizeMode that on the |
364 // next accelerometer update the rotation lock is cleared. | 506 // next accelerometer update the rotation lock is cleared. |
365 TEST_F(MaximizeModeControllerTest, ExitingMaximizeModeClearRotationLock) { | 507 TEST_F(MaximizeModeControllerTest, ExitingMaximizeModeClearRotationLock) { |
366 // The base remains steady. | |
367 gfx::Vector3dF base(0.0f, 0.0f, 1.0f); | |
368 | |
369 // Trigger maximize mode by opening to 270. | 508 // Trigger maximize mode by opening to 270. |
370 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, -1.0f), | 509 TriggerAccelerometerUpdate(kHingeBaseVector, kHingeLidVector_270); |
371 gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); | |
372 ASSERT_TRUE(IsMaximizeModeStarted()); | 510 ASSERT_TRUE(IsMaximizeModeStarted()); |
373 | 511 |
374 maximize_mode_controller()->SetRotationLocked(true); | 512 maximize_mode_controller()->SetRotationLocked(true); |
375 | 513 |
376 // Open 90 degrees. | 514 TriggerAccelerometerUpdate(kHingeBaseVector, kHingeLidVector_90); |
377 TriggerAccelerometerUpdate(base, gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); | |
378 EXPECT_FALSE(IsMaximizeModeStarted()); | 515 EXPECT_FALSE(IsMaximizeModeStarted()); |
379 | 516 |
380 // Send an update that would not relaunch MaximizeMode. 90 degrees. | 517 // Send an update that would not relaunch MaximizeMode. |
381 TriggerAccelerometerUpdate(base, gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); | 518 TriggerAccelerometerUpdate(kHingeBaseVector, kHingeLidVector_90); |
382 EXPECT_FALSE(maximize_mode_controller()->rotation_locked()); | 519 EXPECT_FALSE(maximize_mode_controller()->rotation_locked()); |
383 } | 520 } |
384 | 521 |
385 // The TrayDisplay class that is responsible for adding/updating MessageCenter | 522 // The TrayDisplay class that is responsible for adding/updating MessageCenter |
386 // notifications is only added to the SystemTray on ChromeOS. | 523 // notifications is only added to the SystemTray on ChromeOS. |
387 #if defined(OS_CHROMEOS) | 524 #if defined(OS_CHROMEOS) |
388 // Tests that the screen rotation notifications are suppressed when | 525 // Tests that the screen rotation notifications are suppressed when |
389 // triggered by the accelerometer. | 526 // triggered by the accelerometer. |
390 TEST_F(MaximizeModeControllerTest, BlockRotationNotifications) { | 527 TEST_F(MaximizeModeControllerTest, BlockRotationNotifications) { |
391 test::TestSystemTrayDelegate* tray_delegate = | 528 test::TestSystemTrayDelegate* tray_delegate = |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
490 // User sets rotation to the same rotation that the display was at when | 627 // User sets rotation to the same rotation that the display was at when |
491 // maximize mode was activated. | 628 // maximize mode was activated. |
492 SetInternalDisplayRotation(gfx::Display::ROTATE_0); | 629 SetInternalDisplayRotation(gfx::Display::ROTATE_0); |
493 // Exit maximize mode | 630 // Exit maximize mode |
494 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, 1.0f), | 631 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, 1.0f), |
495 gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); | 632 gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); |
496 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); | 633 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); |
497 } | 634 } |
498 | 635 |
499 } // namespace ash | 636 } // namespace ash |
OLD | NEW |