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

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
« no previous file with comments | « no previous file | chromeos/accelerometer/accelerometer_reader.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 CanEnterMaximizeMode returns false until a valid accelerometer
350 // event has been received, and that it returns true afterwards.
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
359 // Tests that when an accelerometer event is received which has no keyboard that
360 // we enter maximize mode.
361 TEST_F(MaximizeModeControllerTest,
362 NoKeyboardAccelerometerTriggersMaximizeMode) {
363 ASSERT_FALSE(IsMaximizeModeStarted());
364 TriggerLidUpdate(gfx::Vector3dF(0.0f, 0.0f, kMeanGravity));
365 ASSERT_TRUE(IsMaximizeModeStarted());
366 }
367
349 class MaximizeModeControllerSwitchesTest : public MaximizeModeControllerTest { 368 class MaximizeModeControllerSwitchesTest : public MaximizeModeControllerTest {
350 public: 369 public:
351 MaximizeModeControllerSwitchesTest() {} 370 MaximizeModeControllerSwitchesTest() {}
352 ~MaximizeModeControllerSwitchesTest() override {} 371 ~MaximizeModeControllerSwitchesTest() override {}
353 372
354 void SetUp() override { 373 void SetUp() override {
355 base::CommandLine::ForCurrentProcess()->AppendSwitch( 374 base::CommandLine::ForCurrentProcess()->AppendSwitch(
356 switches::kAshEnableTouchViewTesting); 375 switches::kAshEnableTouchViewTesting);
357 MaximizeModeControllerTest::SetUp(); 376 MaximizeModeControllerTest::SetUp();
358 } 377 }
359 private: 378 private:
360 DISALLOW_COPY_AND_ASSIGN(MaximizeModeControllerSwitchesTest); 379 DISALLOW_COPY_AND_ASSIGN(MaximizeModeControllerSwitchesTest);
361 }; 380 };
362 381
363 // Tests that when the command line switch for testing maximize mode is on, that 382 // 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. 383 // accelerometer updates which would normally cause it to exit do not.
365 TEST_F(MaximizeModeControllerSwitchesTest, IgnoreHingeAngles) { 384 TEST_F(MaximizeModeControllerSwitchesTest, IgnoreHingeAngles) {
366 maximize_mode_controller()->EnableMaximizeModeWindowManager(true); 385 maximize_mode_controller()->EnableMaximizeModeWindowManager(true);
367 386
368 // Would normally trigger an exit from maximize mode. 387 // Would normally trigger an exit from maximize mode.
369 OpenLidToAngle(90.0f); 388 OpenLidToAngle(90.0f);
370 EXPECT_TRUE(IsMaximizeModeStarted()); 389 EXPECT_TRUE(IsMaximizeModeStarted());
371 } 390 }
372 391
373 } // namespace ash 392 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | chromeos/accelerometer/accelerometer_reader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698