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

Unified Diff: ash/shelf/shelf_locking_manager_unittest.cc

Issue 1920073002: Fix Chrome OS shelf locking for chromebook lid open/close. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update and add unit tests. Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/shelf/shelf_locking_manager.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/shelf/shelf_locking_manager_unittest.cc
diff --git a/ash/shelf/shelf_locking_manager_unittest.cc b/ash/shelf/shelf_locking_manager_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d46de3fc06b68d386278f2b6e894e951bcab84c6
--- /dev/null
+++ b/ash/shelf/shelf_locking_manager_unittest.cc
@@ -0,0 +1,83 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ash/shelf/shelf_locking_manager.h"
+
+#include "ash/session/session_state_delegate.h"
+#include "ash/shelf/shelf.h"
+#include "ash/test/ash_test_base.h"
+#include "ash/test/shelf_test_api.h"
+
+namespace ash {
+namespace test {
+
+// Tests the shelf behavior when the screen or session is locked.
+class ShelfLockingManagerTest : public ash::test::AshTestBase {
+ public:
+ ShelfLockingManagerTest() {}
+
+ ShelfLockingManager* GetShelfLockingManager() {
+ return ShelfTestAPI(Shelf::ForPrimaryDisplay()).shelf_locking_manager();
+ }
+
+ void SetScreenLocked(bool locked) {
+ GetShelfLockingManager()->OnLockStateChanged(locked);
+ }
+
+ void SetSessionState(SessionStateDelegate::SessionState state) {
+ GetShelfLockingManager()->SessionStateChanged(state);
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ShelfLockingManagerTest);
+};
+
+// Makes sure shelf alignment is correct for lock screen.
+TEST_F(ShelfLockingManagerTest, AlignmentLockedWhileScreenLocked) {
+ Shelf* shelf = Shelf::ForPrimaryDisplay();
+ EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, shelf->alignment());
+
+ shelf->SetAlignment(SHELF_ALIGNMENT_LEFT);
+ EXPECT_EQ(SHELF_ALIGNMENT_LEFT, shelf->alignment());
+
+ SetScreenLocked(true);
+ EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM_LOCKED, shelf->alignment());
+ SetScreenLocked(false);
+ EXPECT_EQ(SHELF_ALIGNMENT_LEFT, shelf->alignment());
+}
+
+// Makes sure shelf alignment is correct for login and add user screens.
+TEST_F(ShelfLockingManagerTest, AlignmentLockedWhileSessionLocked) {
+ Shelf* shelf = Shelf::ForPrimaryDisplay();
+ EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, shelf->alignment());
+
+ shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT);
+ EXPECT_EQ(SHELF_ALIGNMENT_RIGHT, shelf->alignment());
+
+ SetSessionState(SessionStateDelegate::SESSION_STATE_LOGIN_PRIMARY);
+ EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM_LOCKED, shelf->alignment());
+ SetSessionState(SessionStateDelegate::SESSION_STATE_ACTIVE);
+ EXPECT_EQ(SHELF_ALIGNMENT_RIGHT, shelf->alignment());
+
+ SetSessionState(SessionStateDelegate::SESSION_STATE_LOGIN_SECONDARY);
+ EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM_LOCKED, shelf->alignment());
+ SetSessionState(SessionStateDelegate::SESSION_STATE_ACTIVE);
+ EXPECT_EQ(SHELF_ALIGNMENT_RIGHT, shelf->alignment());
+}
+
+// Makes sure shelf alignment changes are stored, not set, while locked.
+TEST_F(ShelfLockingManagerTest, AlignmentChangesDeferredWhileLocked) {
+ Shelf* shelf = Shelf::ForPrimaryDisplay();
+ EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, shelf->alignment());
+
+ SetScreenLocked(true);
+ EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM_LOCKED, shelf->alignment());
+ shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT);
+ EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM_LOCKED, shelf->alignment());
+ SetScreenLocked(false);
+ EXPECT_EQ(SHELF_ALIGNMENT_RIGHT, shelf->alignment());
+}
+
+} // namespace test
+} // namespace ash
« no previous file with comments | « ash/shelf/shelf_locking_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698