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

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

Issue 895993002: Correcly Report CanEnterMaximizeMode on devices without accelerometers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 <math.h> 5 #include <math.h>
6 6
7 #include "ash/wm/maximize_mode/maximize_mode_controller.h" 7 #include "ash/wm/maximize_mode/maximize_mode_controller.h"
8 8
9 #include "ash/ash_switches.h" 9 #include "ash/ash_switches.h"
10 #include "ash/display/display_manager.h" 10 #include "ash/display/display_manager.h"
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 kAccelerometerFullyOpenTestData[i * 6 + 3], 338 kAccelerometerFullyOpenTestData[i * 6 + 3],
339 kAccelerometerFullyOpenTestData[i * 6 + 5]); 339 kAccelerometerFullyOpenTestData[i * 6 + 5]);
340 lid.Scale(kMeanGravity); 340 lid.Scale(kMeanGravity);
341 TriggerBaseAndLidUpdate(base, lid); 341 TriggerBaseAndLidUpdate(base, lid);
342 // There are a lot of samples, so ASSERT rather than EXPECT to only generate 342 // There are a lot of samples, so ASSERT rather than EXPECT to only generate
343 // one failure rather than potentially hundreds. 343 // one failure rather than potentially hundreds.
344 ASSERT_TRUE(IsMaximizeModeStarted()); 344 ASSERT_TRUE(IsMaximizeModeStarted());
345 } 345 }
346 } 346 }
347 347
348 // Tests that when and empty accelerometer update is received for attaching as a
349 // chromeos::AccelerometerReader::Observer, that CanEnterMaximizeMode returns
350 // false, and that valid accelerometer events allow entering maximize mode.
351 TEST_F(MaximizeModeControllerTest,
352 CanEnterMaximizeModeRequiresValidAccelerometerUpdate) {
353 // Should be false until an accelerometer event is sent.
354 ASSERT_FALSE(maximize_mode_controller()->CanEnterMaximizeMode());
355 OpenLidToAngle(90.0f);
356 EXPECT_TRUE(maximize_mode_controller()->CanEnterMaximizeMode());
357 }
358
348 class MaximizeModeControllerSwitchesTest : public MaximizeModeControllerTest { 359 class MaximizeModeControllerSwitchesTest : public MaximizeModeControllerTest {
349 public: 360 public:
350 MaximizeModeControllerSwitchesTest() {} 361 MaximizeModeControllerSwitchesTest() {}
351 ~MaximizeModeControllerSwitchesTest() override {} 362 ~MaximizeModeControllerSwitchesTest() override {}
352 363
353 void SetUp() override { 364 void SetUp() override {
354 base::CommandLine::ForCurrentProcess()->AppendSwitch( 365 base::CommandLine::ForCurrentProcess()->AppendSwitch(
355 switches::kAshEnableTouchViewTesting); 366 switches::kAshEnableTouchViewTesting);
356 MaximizeModeControllerTest::SetUp(); 367 MaximizeModeControllerTest::SetUp();
357 } 368 }
358 private: 369 private:
359 DISALLOW_COPY_AND_ASSIGN(MaximizeModeControllerSwitchesTest); 370 DISALLOW_COPY_AND_ASSIGN(MaximizeModeControllerSwitchesTest);
360 }; 371 };
361 372
362 // Tests that when the command line switch for testing maximize mode is on, that 373 // Tests that when the command line switch for testing maximize mode is on, that
363 // accelerometer updates which would normally cause it to exit do not. 374 // accelerometer updates which would normally cause it to exit do not.
364 TEST_F(MaximizeModeControllerSwitchesTest, IgnoreHingeAngles) { 375 TEST_F(MaximizeModeControllerSwitchesTest, IgnoreHingeAngles) {
365 maximize_mode_controller()->EnableMaximizeModeWindowManager(true); 376 maximize_mode_controller()->EnableMaximizeModeWindowManager(true);
366 377
367 // Would normally trigger an exit from maximize mode. 378 // Would normally trigger an exit from maximize mode.
368 OpenLidToAngle(90.0f); 379 OpenLidToAngle(90.0f);
369 EXPECT_TRUE(IsMaximizeModeStarted()); 380 EXPECT_TRUE(IsMaximizeModeStarted());
370 } 381 }
371 382
372 } // namespace ash 383 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698