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

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 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 kAccelerometerFullyOpenTestData[i * 6 + 3], 339 kAccelerometerFullyOpenTestData[i * 6 + 3],
340 kAccelerometerFullyOpenTestData[i * 6 + 5]); 340 kAccelerometerFullyOpenTestData[i * 6 + 5]);
341 lid.Scale(kMeanGravity); 341 lid.Scale(kMeanGravity);
342 TriggerBaseAndLidUpdate(base, lid); 342 TriggerBaseAndLidUpdate(base, lid);
343 // There are a lot of samples, so ASSERT rather than EXPECT to only generate 343 // There are a lot of samples, so ASSERT rather than EXPECT to only generate
344 // one failure rather than potentially hundreds. 344 // one failure rather than potentially hundreds.
345 ASSERT_TRUE(IsMaximizeModeStarted()); 345 ASSERT_TRUE(IsMaximizeModeStarted());
346 } 346 }
347 } 347 }
348 348
349 // Tests that when and empty accelerometer update is received for attaching as a
350 // chromeos::AccelerometerReader::Observer, that CanEnterMaximizeMode returns
351 // false, and that valid accelerometer events allow entering maximize mode.
352 TEST_F(MaximizeModeControllerTest,
353 CanEnterMaximizeModeRequiresValidAccelerometerUpdate) {
354 // Should be false until an accelerometer event is sent.
355 ASSERT_FALSE(maximize_mode_controller()->CanEnterMaximizeMode());
356 OpenLidToAngle(90.0f);
357 EXPECT_TRUE(maximize_mode_controller()->CanEnterMaximizeMode());
358 }
359
360 // Tests that when an accelerometer event is received which has no keyboard that
361 // we enter maximize mode.
362 TEST_F(MaximizeModeControllerTest,
363 NoKeyboardAccelerometerTriggersMaximizeMode) {
364 ASSERT_FALSE(IsMaximizeModeStarted());
365 TriggerLidUpdate(gfx::Vector3dF(0.0f, 0.0f, kMeanGravity));
366 ASSERT_TRUE(IsMaximizeModeStarted());
367 }
368
349 class MaximizeModeControllerSwitchesTest : public MaximizeModeControllerTest { 369 class MaximizeModeControllerSwitchesTest : public MaximizeModeControllerTest {
350 public: 370 public:
351 MaximizeModeControllerSwitchesTest() {} 371 MaximizeModeControllerSwitchesTest() {}
352 ~MaximizeModeControllerSwitchesTest() override {} 372 ~MaximizeModeControllerSwitchesTest() override {}
353 373
354 void SetUp() override { 374 void SetUp() override {
355 base::CommandLine::ForCurrentProcess()->AppendSwitch( 375 base::CommandLine::ForCurrentProcess()->AppendSwitch(
356 switches::kAshEnableTouchViewTesting); 376 switches::kAshEnableTouchViewTesting);
357 MaximizeModeControllerTest::SetUp(); 377 MaximizeModeControllerTest::SetUp();
358 } 378 }
359 private: 379 private:
360 DISALLOW_COPY_AND_ASSIGN(MaximizeModeControllerSwitchesTest); 380 DISALLOW_COPY_AND_ASSIGN(MaximizeModeControllerSwitchesTest);
361 }; 381 };
362 382
363 // Tests that when the command line switch for testing maximize mode is on, that 383 // Tests that when the command line switch for testing maximize mode is on, that
364 // accelerometer updates which would normally cause it to exit do not. 384 // accelerometer updates which would normally cause it to exit do not.
365 TEST_F(MaximizeModeControllerSwitchesTest, IgnoreHingeAngles) { 385 TEST_F(MaximizeModeControllerSwitchesTest, IgnoreHingeAngles) {
366 maximize_mode_controller()->EnableMaximizeModeWindowManager(true); 386 maximize_mode_controller()->EnableMaximizeModeWindowManager(true);
367 387
368 // Would normally trigger an exit from maximize mode. 388 // Would normally trigger an exit from maximize mode.
369 OpenLidToAngle(90.0f); 389 OpenLidToAngle(90.0f);
370 EXPECT_TRUE(IsMaximizeModeStarted()); 390 EXPECT_TRUE(IsMaximizeModeStarted());
371 } 391 }
372 392
373 } // namespace ash 393 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | chromeos/accelerometer/accelerometer_reader.cc » ('j') | chromeos/accelerometer/accelerometer_reader.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698