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/aura/test/event_generator.h" | 18 #include "ui/aura/test/event_generator.h" |
18 #include "ui/events/event_handler.h" | 19 #include "ui/events/event_handler.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); | |
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 tick_clock_ = new base::SimpleTestTickClock(); | |
111 tick_clock_->Advance(base::TimeDelta::FromSeconds(1)); | |
112 maximize_mode_controller()->SetTickClockForTest(tick_clock_); | |
113 } | |
114 | |
115 void AdvanceTickClock(const base::TimeDelta& delta) { | |
116 DCHECK(tick_clock_); | |
117 tick_clock_->Advance(delta); | |
118 } | |
119 | |
120 #if defined(OS_CHROMEOS) | |
121 void OpenLid() { | |
122 maximize_mode_controller()->LidEventReceived(true /* open */, | |
123 maximize_mode_controller()->tick_clock_->NowTicks()); | |
124 } | |
125 | |
126 void CloseLid() { | |
127 maximize_mode_controller()->LidEventReceived(false /* open */, | |
128 maximize_mode_controller()->tick_clock_->NowTicks()); | |
129 } | |
130 #endif // OS_CHROMEOS | |
131 | |
132 bool WasLidOpenedRecently() { | |
133 return maximize_mode_controller()->WasLidOpenedRecently(); | |
134 } | |
135 | |
93 private: | 136 private: |
137 base::SimpleTestTickClock* tick_clock_; | |
138 | |
94 DISALLOW_COPY_AND_ASSIGN(MaximizeModeControllerTest); | 139 DISALLOW_COPY_AND_ASSIGN(MaximizeModeControllerTest); |
95 }; | 140 }; |
96 | 141 |
97 // Tests that opening the lid beyond 180 will enter touchview, and that it will | 142 #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 | 143 |
104 // Lid open 90 degrees. | 144 // Verify that closing the lid will exit maximize mode. |
105 TriggerAccelerometerUpdate(base, gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); | 145 TEST_F(MaximizeModeControllerTest, CloseLidWhileInMaximizeMode) { |
146 TriggerAccelerometerUpdate(kHingeBaseVector, kHingeLidVector_315); | |
147 ASSERT_TRUE(IsMaximizeModeStarted()); | |
148 | |
149 CloseLid(); | |
150 EXPECT_FALSE(IsMaximizeModeStarted()); | |
151 } | |
152 | |
153 // Verify that maximize mode will not be entered when the lid is closed. | |
154 TEST_F(MaximizeModeControllerTest, | |
155 HingeAnglesWithLidClosed) { | |
156 AttachTickClockForTest(); | |
157 | |
158 CloseLid(); | |
159 | |
160 TriggerAccelerometerUpdate(kHingeBaseVector, kHingeLidVector_5); | |
106 EXPECT_FALSE(IsMaximizeModeStarted()); | 161 EXPECT_FALSE(IsMaximizeModeStarted()); |
107 | 162 |
108 // Open just past 180. | 163 TriggerAccelerometerUpdate(kHingeBaseVector, kHingeLidVector_45); |
109 TriggerAccelerometerUpdate(base, gfx::Vector3dF(0.05f, 0.0f, -1.0f)); | |
110 EXPECT_FALSE(IsMaximizeModeStarted()); | 164 EXPECT_FALSE(IsMaximizeModeStarted()); |
111 | 165 |
112 // Open up 270 degrees. | 166 TriggerAccelerometerUpdate(kHingeBaseVector, kHingeLidVector_90); |
113 TriggerAccelerometerUpdate(base, gfx::Vector3dF(1.0f, 0.0f, 0.0f)); | 167 EXPECT_FALSE(IsMaximizeModeStarted()); |
168 | |
169 TriggerAccelerometerUpdate(kHingeBaseVector, kHingeLidVector_180); | |
flackr
2014/07/29 16:41:45
All of these values < 270 would not normally engag
bruthig
2014/07/31 16:10:49
Done.
| |
170 EXPECT_FALSE(IsMaximizeModeStarted()); | |
171 | |
172 TriggerAccelerometerUpdate(kHingeBaseVector, kHingeLidVector_270); | |
173 EXPECT_FALSE(IsMaximizeModeStarted()); | |
174 | |
175 TriggerAccelerometerUpdate(kHingeBaseVector, kHingeLidVector_315); | |
176 EXPECT_FALSE(IsMaximizeModeStarted()); | |
177 | |
178 TriggerAccelerometerUpdate(kHingeBaseVector, kHingeLidVector_355); | |
179 EXPECT_FALSE(IsMaximizeModeStarted()); | |
180 } | |
181 | |
182 // Verify the maximize mode state for unstable hinge angles when the lid was | |
183 // recently open. | |
184 TEST_F(MaximizeModeControllerTest, | |
185 UnstableHingeAnglesWhenLidRecentlyOpened) { | |
186 AttachTickClockForTest(); | |
187 | |
188 OpenLid(); | |
189 ASSERT_TRUE(WasLidOpenedRecently()); | |
190 | |
191 TriggerAccelerometerUpdate(kHingeBaseVector, kHingeLidVector_5); | |
192 EXPECT_FALSE(IsMaximizeModeStarted()); | |
193 | |
194 TriggerAccelerometerUpdate(kHingeBaseVector, kHingeLidVector_355); | |
195 EXPECT_FALSE(IsMaximizeModeStarted()); | |
196 | |
197 TriggerAccelerometerUpdate(kHingeBaseVector, kHingeLidVector_5); | |
198 EXPECT_FALSE(IsMaximizeModeStarted()); | |
flackr
2014/07/29 16:41:45
Why test 5 again?
bruthig
2014/07/31 16:10:49
Removed.
| |
199 | |
200 // This is a stable reading and should clear the last lid opened time. | |
201 TriggerAccelerometerUpdate(kHingeBaseVector, kHingeLidVector_45); | |
202 EXPECT_FALSE(IsMaximizeModeStarted()); | |
203 EXPECT_FALSE(WasLidOpenedRecently()); | |
204 | |
205 TriggerAccelerometerUpdate(kHingeBaseVector, kHingeLidVector_355); | |
114 EXPECT_TRUE(IsMaximizeModeStarted()); | 206 EXPECT_TRUE(IsMaximizeModeStarted()); |
115 | 207 |
116 // Open up 360 degrees and appearing to be slightly past it (i.e. as if almost | 208 TriggerAccelerometerUpdate(kHingeBaseVector, kHingeLidVector_5); |
117 // closed). | 209 EXPECT_TRUE(IsMaximizeModeStarted()); |
flackr
2014/07/29 16:41:45
This is tested by another test isn't it?
bruthig
2014/07/31 16:10:49
Yes, removed.
| |
118 TriggerAccelerometerUpdate(base, gfx::Vector3dF(-0.05f, 0.0f, 1.0f)); | 210 } |
211 | |
212 #endif // OS_CHROMEOS | |
213 | |
214 // Verify the WasLidOpenedRecently signal with respect to time. | |
215 TEST_F(MaximizeModeControllerTest, WasLidOpenedRecentlyOverTime) { | |
216 #if defined(OS_CHROMEOS) | |
217 | |
218 AttachTickClockForTest(); | |
219 | |
220 // No lid open time initially. | |
221 ASSERT_FALSE(WasLidOpenedRecently()); | |
222 | |
223 CloseLid(); | |
224 EXPECT_FALSE(WasLidOpenedRecently()); | |
225 | |
226 OpenLid(); | |
227 EXPECT_TRUE(WasLidOpenedRecently()); | |
228 | |
229 // 1 second after lid open. | |
230 AdvanceTickClock(base::TimeDelta::FromSeconds(1)); | |
231 EXPECT_TRUE(WasLidOpenedRecently()); | |
232 | |
233 // 2 seconds after lid open. | |
flackr
2014/07/29 16:41:45
1 time before the threshold and 1 after is fine.
bruthig
2014/07/31 16:10:49
I disagree, "2 seconds after lid open" is testing
flackr
2014/07/31 20:21:41
The exact boundary is really more of an implementa
bruthig
2014/08/05 18:06:43
Done.
| |
234 AdvanceTickClock(base::TimeDelta::FromSeconds(1)); | |
235 EXPECT_TRUE(WasLidOpenedRecently()); | |
236 | |
237 // 3 seconds after lid open. | |
238 AdvanceTickClock(base::TimeDelta::FromSeconds(1)); | |
239 EXPECT_FALSE(WasLidOpenedRecently()); | |
240 | |
241 #else | |
242 | |
243 EXPECT_FALSE(WasLidOpenedRecently()); | |
244 | |
245 #endif // OS_CHROMEOS | |
246 } | |
247 | |
248 // Verify the maximize mode enter/exit thresholds for stable angles. | |
249 TEST_F(MaximizeModeControllerTest, StableHingeAnglesWithLidOpened) { | |
250 ASSERT_FALSE(IsMaximizeModeStarted()); | |
251 ASSERT_FALSE(WasLidOpenedRecently()); | |
252 | |
253 TriggerAccelerometerUpdate(kHingeBaseVector, kHingeLidVector_180); | |
254 EXPECT_FALSE(IsMaximizeModeStarted()); | |
255 | |
256 TriggerAccelerometerUpdate(kHingeBaseVector, kHingeLidVector_315); | |
119 EXPECT_TRUE(IsMaximizeModeStarted()); | 257 EXPECT_TRUE(IsMaximizeModeStarted()); |
120 | 258 |
121 // Open just before 180. | 259 TriggerAccelerometerUpdate(kHingeBaseVector, kHingeLidVector_180); |
122 TriggerAccelerometerUpdate(base, gfx::Vector3dF(-0.05f, 0.0f, -1.0f)); | |
123 EXPECT_TRUE(IsMaximizeModeStarted()); | 260 EXPECT_TRUE(IsMaximizeModeStarted()); |
124 | 261 |
125 // Open 90 degrees. | 262 TriggerAccelerometerUpdate(kHingeBaseVector, kHingeLidVector_45); |
126 TriggerAccelerometerUpdate(base, gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); | |
127 EXPECT_FALSE(IsMaximizeModeStarted()); | 263 EXPECT_FALSE(IsMaximizeModeStarted()); |
264 | |
265 TriggerAccelerometerUpdate(kHingeBaseVector, kHingeLidVector_270); | |
266 EXPECT_TRUE(IsMaximizeModeStarted()); | |
267 | |
268 TriggerAccelerometerUpdate(kHingeBaseVector, kHingeLidVector_90); | |
269 EXPECT_FALSE(IsMaximizeModeStarted()); | |
270 } | |
271 | |
272 // Verify the maximize mode state for unstable hinge angles when the lid is open | |
273 // but not recently. | |
274 TEST_F(MaximizeModeControllerTest, UnstableHingeAnglesWithLidOpened) { | |
275 AttachTickClockForTest(); | |
276 | |
277 ASSERT_FALSE(WasLidOpenedRecently()); | |
278 ASSERT_FALSE(IsMaximizeModeStarted()); | |
279 | |
280 TriggerAccelerometerUpdate(kHingeBaseVector, kHingeLidVector_5); | |
281 EXPECT_FALSE(IsMaximizeModeStarted()); | |
282 | |
283 TriggerAccelerometerUpdate(kHingeBaseVector, kHingeLidVector_355); | |
284 EXPECT_TRUE(IsMaximizeModeStarted()); | |
285 | |
286 TriggerAccelerometerUpdate(kHingeBaseVector, kHingeLidVector_5); | |
287 EXPECT_TRUE(IsMaximizeModeStarted()); | |
128 } | 288 } |
129 | 289 |
130 // Tests that when the hinge is nearly vertically aligned, the current state | 290 // Tests that when the hinge is nearly vertically aligned, the current state |
131 // persists as the computed angle is highly inaccurate in this orientation. | 291 // persists as the computed angle is highly inaccurate in this orientation. |
132 TEST_F(MaximizeModeControllerTest, HingeAligned) { | 292 TEST_F(MaximizeModeControllerTest, HingeAligned) { |
133 // Laptop in normal orientation lid open 90 degrees. | 293 // Laptop in normal orientation lid open 90 degrees. |
134 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, 1.0f), | 294 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, 1.0f), |
135 gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); | 295 gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); |
136 EXPECT_FALSE(IsMaximizeModeStarted()); | 296 EXPECT_FALSE(IsMaximizeModeStarted()); |
137 | 297 |
(...skipping 12 matching lines...) Expand all Loading... | |
150 gfx::Vector3dF(1.0f, 0.0f, 0.0f)); | 310 gfx::Vector3dF(1.0f, 0.0f, 0.0f)); |
151 EXPECT_TRUE(IsMaximizeModeStarted()); | 311 EXPECT_TRUE(IsMaximizeModeStarted()); |
152 | 312 |
153 // Normal 90 degree orientation but near vertical should stay in maximize | 313 // Normal 90 degree orientation but near vertical should stay in maximize |
154 // mode. | 314 // mode. |
155 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, -1.0f, 0.01f), | 315 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, -1.0f, 0.01f), |
156 gfx::Vector3dF(-0.01f, -1.0f, 0.0f)); | 316 gfx::Vector3dF(-0.01f, -1.0f, 0.0f)); |
157 EXPECT_TRUE(IsMaximizeModeStarted()); | 317 EXPECT_TRUE(IsMaximizeModeStarted()); |
158 } | 318 } |
159 | 319 |
160 // Tests that accelerometer readings in each of the screen angles will trigger | 320 // Tests that accelerometer readings in each of the screen angles will trigger a |
161 // a rotation of the internal display. | 321 // rotation of the internal display. |
162 TEST_F(MaximizeModeControllerTest, DisplayRotation) { | 322 TEST_F(MaximizeModeControllerTest, DisplayRotation) { |
163 // Trigger maximize mode by opening to 270. | 323 // Trigger maximize mode by opening to 270. |
164 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, -1.0f), | 324 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, -1.0f), |
165 gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); | 325 gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); |
166 ASSERT_TRUE(IsMaximizeModeStarted()); | 326 ASSERT_TRUE(IsMaximizeModeStarted()); |
167 | 327 |
168 // Now test rotating in all directions. | 328 // Now test rotating in all directions. |
169 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 1.0f, 0.0f), | 329 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 1.0f, 0.0f), |
170 gfx::Vector3dF(0.0f, 1.0f, 0.0f)); | 330 gfx::Vector3dF(0.0f, 1.0f, 0.0f)); |
171 EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); | 331 EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
268 // and pressing power. | 428 // and pressing power. |
269 TEST_F(MaximizeModeControllerTest, Screenshot) { | 429 TEST_F(MaximizeModeControllerTest, Screenshot) { |
270 Shell::GetInstance()->lock_state_controller()->SetDelegate( | 430 Shell::GetInstance()->lock_state_controller()->SetDelegate( |
271 new test::TestLockStateControllerDelegate); | 431 new test::TestLockStateControllerDelegate); |
272 aura::Window* root = Shell::GetPrimaryRootWindow(); | 432 aura::Window* root = Shell::GetPrimaryRootWindow(); |
273 aura::test::EventGenerator event_generator(root, root); | 433 aura::test::EventGenerator event_generator(root, root); |
274 test::TestScreenshotDelegate* delegate = GetScreenshotDelegate(); | 434 test::TestScreenshotDelegate* delegate = GetScreenshotDelegate(); |
275 delegate->set_can_take_screenshot(true); | 435 delegate->set_can_take_screenshot(true); |
276 | 436 |
277 // Open up 270 degrees. | 437 // Open up 270 degrees. |
278 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, 1.0f), | 438 TriggerAccelerometerUpdate(kHingeBaseVector, kHingeLidVector_270); |
279 gfx::Vector3dF(1.0f, 0.0f, 0.0f)); | |
280 ASSERT_TRUE(IsMaximizeModeStarted()); | 439 ASSERT_TRUE(IsMaximizeModeStarted()); |
281 | 440 |
282 // Pressing power alone does not take a screenshot. | 441 // Pressing power alone does not take a screenshot. |
283 event_generator.PressKey(ui::VKEY_POWER, 0); | 442 event_generator.PressKey(ui::VKEY_POWER, 0); |
284 event_generator.ReleaseKey(ui::VKEY_POWER, 0); | 443 event_generator.ReleaseKey(ui::VKEY_POWER, 0); |
285 EXPECT_EQ(0, delegate->handle_take_screenshot_count()); | 444 EXPECT_EQ(0, delegate->handle_take_screenshot_count()); |
286 | 445 |
287 // Holding volume down and pressing power takes a screenshot. | 446 // Holding volume down and pressing power takes a screenshot. |
288 event_generator.PressKey(ui::VKEY_VOLUME_DOWN, 0); | 447 event_generator.PressKey(ui::VKEY_VOLUME_DOWN, 0); |
289 event_generator.PressKey(ui::VKEY_POWER, 0); | 448 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()); | 515 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); |
357 | 516 |
358 maximize_mode_controller()->SetRotationLocked(false); | 517 maximize_mode_controller()->SetRotationLocked(false); |
359 TriggerAccelerometerUpdate(gravity, gravity); | 518 TriggerAccelerometerUpdate(gravity, gravity); |
360 EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); | 519 EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); |
361 } | 520 } |
362 | 521 |
363 // Tests that when MaximizeModeController turns off MaximizeMode that on the | 522 // Tests that when MaximizeModeController turns off MaximizeMode that on the |
364 // next accelerometer update the rotation lock is cleared. | 523 // next accelerometer update the rotation lock is cleared. |
365 TEST_F(MaximizeModeControllerTest, ExitingMaximizeModeClearRotationLock) { | 524 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. | 525 // Trigger maximize mode by opening to 270. |
370 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, -1.0f), | 526 TriggerAccelerometerUpdate(kHingeBaseVector, kHingeLidVector_270); |
371 gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); | |
372 ASSERT_TRUE(IsMaximizeModeStarted()); | 527 ASSERT_TRUE(IsMaximizeModeStarted()); |
373 | 528 |
374 maximize_mode_controller()->SetRotationLocked(true); | 529 maximize_mode_controller()->SetRotationLocked(true); |
375 | 530 |
376 // Open 90 degrees. | 531 TriggerAccelerometerUpdate(kHingeBaseVector, kHingeLidVector_90); |
377 TriggerAccelerometerUpdate(base, gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); | |
378 EXPECT_FALSE(IsMaximizeModeStarted()); | 532 EXPECT_FALSE(IsMaximizeModeStarted()); |
379 | 533 |
380 // Send an update that would not relaunch MaximizeMode. 90 degrees. | 534 // Send an update that would not relaunch MaximizeMode. |
381 TriggerAccelerometerUpdate(base, gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); | 535 TriggerAccelerometerUpdate(kHingeBaseVector, kHingeLidVector_90); |
382 EXPECT_FALSE(maximize_mode_controller()->rotation_locked()); | 536 EXPECT_FALSE(maximize_mode_controller()->rotation_locked()); |
383 } | 537 } |
384 | 538 |
385 // The TrayDisplay class that is responsible for adding/updating MessageCenter | 539 // The TrayDisplay class that is responsible for adding/updating MessageCenter |
386 // notifications is only added to the SystemTray on ChromeOS. | 540 // notifications is only added to the SystemTray on ChromeOS. |
387 #if defined(OS_CHROMEOS) | 541 #if defined(OS_CHROMEOS) |
388 // Tests that the screen rotation notifications are suppressed when | 542 // Tests that the screen rotation notifications are suppressed when |
389 // triggered by the accelerometer. | 543 // triggered by the accelerometer. |
390 TEST_F(MaximizeModeControllerTest, BlockRotationNotifications) { | 544 TEST_F(MaximizeModeControllerTest, BlockRotationNotifications) { |
391 test::TestSystemTrayDelegate* tray_delegate = | 545 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 | 644 // User sets rotation to the same rotation that the display was at when |
491 // maximize mode was activated. | 645 // maximize mode was activated. |
492 SetInternalDisplayRotation(gfx::Display::ROTATE_0); | 646 SetInternalDisplayRotation(gfx::Display::ROTATE_0); |
493 // Exit maximize mode | 647 // Exit maximize mode |
494 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, 1.0f), | 648 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, 1.0f), |
495 gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); | 649 gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); |
496 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); | 650 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); |
497 } | 651 } |
498 | 652 |
499 } // namespace ash | 653 } // namespace ash |
OLD | NEW |