Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(691)

Side by Side Diff: ash/wm/maximize_mode/maximize_mode_controller_unittest.cc

Issue 2095193002: clang-format all of //ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <math.h> 7 #include <math.h>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 DCHECK(test_tick_clock_); 129 DCHECK(test_tick_clock_);
130 test_tick_clock_->Advance(delta); 130 test_tick_clock_->Advance(delta);
131 } 131 }
132 132
133 void OpenLidToAngle(float degrees) { 133 void OpenLidToAngle(float degrees) {
134 DCHECK(degrees >= 0.0f); 134 DCHECK(degrees >= 0.0f);
135 DCHECK(degrees <= 360.0f); 135 DCHECK(degrees <= 360.0f);
136 136
137 float radians = degrees * kDegreesToRadians; 137 float radians = degrees * kDegreesToRadians;
138 gfx::Vector3dF base_vector(0.0f, -kMeanGravity, 0.0f); 138 gfx::Vector3dF base_vector(0.0f, -kMeanGravity, 0.0f);
139 gfx::Vector3dF lid_vector(0.0f, 139 gfx::Vector3dF lid_vector(0.0f, kMeanGravity * cos(radians),
140 kMeanGravity * cos(radians),
141 kMeanGravity * sin(radians)); 140 kMeanGravity * sin(radians));
142 TriggerBaseAndLidUpdate(base_vector, lid_vector); 141 TriggerBaseAndLidUpdate(base_vector, lid_vector);
143 } 142 }
144 143
145 void HoldDeviceVertical() { 144 void HoldDeviceVertical() {
146 gfx::Vector3dF base_vector(9.8f, 0.0f, 0.0f); 145 gfx::Vector3dF base_vector(9.8f, 0.0f, 0.0f);
147 gfx::Vector3dF lid_vector(9.8f, 0.0f, 0.0f); 146 gfx::Vector3dF lid_vector(9.8f, 0.0f, 0.0f);
148 TriggerBaseAndLidUpdate(base_vector, lid_vector); 147 TriggerBaseAndLidUpdate(base_vector, lid_vector);
149 } 148 }
150 149
151 void OpenLid() { 150 void OpenLid() {
152 maximize_mode_controller()->LidEventReceived(true /* open */, 151 maximize_mode_controller()->LidEventReceived(
153 maximize_mode_controller()->tick_clock_->NowTicks()); 152 true /* open */, maximize_mode_controller()->tick_clock_->NowTicks());
154 } 153 }
155 154
156 void CloseLid() { 155 void CloseLid() {
157 maximize_mode_controller()->LidEventReceived(false /* open */, 156 maximize_mode_controller()->LidEventReceived(
158 maximize_mode_controller()->tick_clock_->NowTicks()); 157 false /* open */, maximize_mode_controller()->tick_clock_->NowTicks());
159 } 158 }
160 159
161 bool WasLidOpenedRecently() { 160 bool WasLidOpenedRecently() {
162 return maximize_mode_controller()->WasLidOpenedRecently(); 161 return maximize_mode_controller()->WasLidOpenedRecently();
163 } 162 }
164 163
165 void SetTabletMode(bool on) { 164 void SetTabletMode(bool on) {
166 maximize_mode_controller()->TabletModeEventReceived( 165 maximize_mode_controller()->TabletModeEventReceived(
167 on, maximize_mode_controller()->tick_clock_->NowTicks()); 166 on, maximize_mode_controller()->tick_clock_->NowTicks());
168 } 167 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 // Verify that closing the lid will exit maximize mode. 208 // Verify that closing the lid will exit maximize mode.
210 TEST_F(MaximizeModeControllerTest, CloseLidWhileInMaximizeMode) { 209 TEST_F(MaximizeModeControllerTest, CloseLidWhileInMaximizeMode) {
211 OpenLidToAngle(315.0f); 210 OpenLidToAngle(315.0f);
212 ASSERT_TRUE(IsMaximizeModeStarted()); 211 ASSERT_TRUE(IsMaximizeModeStarted());
213 212
214 CloseLid(); 213 CloseLid();
215 EXPECT_FALSE(IsMaximizeModeStarted()); 214 EXPECT_FALSE(IsMaximizeModeStarted());
216 } 215 }
217 216
218 // Verify that maximize mode will not be entered when the lid is closed. 217 // Verify that maximize mode will not be entered when the lid is closed.
219 TEST_F(MaximizeModeControllerTest, 218 TEST_F(MaximizeModeControllerTest, HingeAnglesWithLidClosed) {
220 HingeAnglesWithLidClosed) {
221 AttachTickClockForTest(); 219 AttachTickClockForTest();
222 220
223 CloseLid(); 221 CloseLid();
224 222
225 OpenLidToAngle(270.0f); 223 OpenLidToAngle(270.0f);
226 EXPECT_FALSE(IsMaximizeModeStarted()); 224 EXPECT_FALSE(IsMaximizeModeStarted());
227 225
228 OpenLidToAngle(315.0f); 226 OpenLidToAngle(315.0f);
229 EXPECT_FALSE(IsMaximizeModeStarted()); 227 EXPECT_FALSE(IsMaximizeModeStarted());
230 228
231 OpenLidToAngle(355.0f); 229 OpenLidToAngle(355.0f);
232 EXPECT_FALSE(IsMaximizeModeStarted()); 230 EXPECT_FALSE(IsMaximizeModeStarted());
233 } 231 }
234 232
235 // Verify the maximize mode state for unstable hinge angles when the lid was 233 // Verify the maximize mode state for unstable hinge angles when the lid was
236 // recently open. 234 // recently open.
237 TEST_F(MaximizeModeControllerTest, 235 TEST_F(MaximizeModeControllerTest, UnstableHingeAnglesWhenLidRecentlyOpened) {
238 UnstableHingeAnglesWhenLidRecentlyOpened) {
239 AttachTickClockForTest(); 236 AttachTickClockForTest();
240 237
241 OpenLid(); 238 OpenLid();
242 ASSERT_TRUE(WasLidOpenedRecently()); 239 ASSERT_TRUE(WasLidOpenedRecently());
243 240
244 OpenLidToAngle(5.0f); 241 OpenLidToAngle(5.0f);
245 EXPECT_FALSE(IsMaximizeModeStarted()); 242 EXPECT_FALSE(IsMaximizeModeStarted());
246 243
247 OpenLidToAngle(355.0f); 244 OpenLidToAngle(355.0f);
248 EXPECT_FALSE(IsMaximizeModeStarted()); 245 EXPECT_FALSE(IsMaximizeModeStarted());
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 class MaximizeModeControllerSwitchesTest : public MaximizeModeControllerTest { 511 class MaximizeModeControllerSwitchesTest : public MaximizeModeControllerTest {
515 public: 512 public:
516 MaximizeModeControllerSwitchesTest() {} 513 MaximizeModeControllerSwitchesTest() {}
517 ~MaximizeModeControllerSwitchesTest() override {} 514 ~MaximizeModeControllerSwitchesTest() override {}
518 515
519 void SetUp() override { 516 void SetUp() override {
520 base::CommandLine::ForCurrentProcess()->AppendSwitch( 517 base::CommandLine::ForCurrentProcess()->AppendSwitch(
521 switches::kAshEnableTouchViewTesting); 518 switches::kAshEnableTouchViewTesting);
522 MaximizeModeControllerTest::SetUp(); 519 MaximizeModeControllerTest::SetUp();
523 } 520 }
521
524 private: 522 private:
525 DISALLOW_COPY_AND_ASSIGN(MaximizeModeControllerSwitchesTest); 523 DISALLOW_COPY_AND_ASSIGN(MaximizeModeControllerSwitchesTest);
526 }; 524 };
527 525
528 // Tests that when the command line switch for testing maximize mode is on, that 526 // Tests that when the command line switch for testing maximize mode is on, that
529 // accelerometer updates which would normally cause it to exit do not. 527 // accelerometer updates which would normally cause it to exit do not.
530 TEST_F(MaximizeModeControllerSwitchesTest, IgnoreHingeAngles) { 528 TEST_F(MaximizeModeControllerSwitchesTest, IgnoreHingeAngles) {
531 maximize_mode_controller()->EnableMaximizeModeWindowManager(true); 529 maximize_mode_controller()->EnableMaximizeModeWindowManager(true);
532 530
533 // Would normally trigger an exit from maximize mode. 531 // Would normally trigger an exit from maximize mode.
534 OpenLidToAngle(90.0f); 532 OpenLidToAngle(90.0f);
535 EXPECT_TRUE(IsMaximizeModeStarted()); 533 EXPECT_TRUE(IsMaximizeModeStarted());
536 } 534 }
537 535
538 } // namespace ash 536 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/maximize_mode/maximize_mode_controller.cc ('k') | ash/wm/maximize_mode/maximize_mode_window_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698