OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ash/shelf/shelf_locking_manager.h" |
| 6 |
| 7 #include "ash/session/session_state_delegate.h" |
| 8 #include "ash/shelf/shelf.h" |
| 9 #include "ash/test/ash_test_base.h" |
| 10 #include "ash/test/shelf_test_api.h" |
| 11 |
| 12 namespace ash { |
| 13 namespace test { |
| 14 |
| 15 // Tests the shelf behavior when the screen or session is locked. |
| 16 class ShelfLockingManagerTest : public ash::test::AshTestBase { |
| 17 public: |
| 18 ShelfLockingManagerTest() {} |
| 19 |
| 20 ShelfLockingManager* GetShelfLockingManager() { |
| 21 return ShelfTestAPI(Shelf::ForPrimaryDisplay()).shelf_locking_manager(); |
| 22 } |
| 23 |
| 24 void SetScreenLocked(bool locked) { |
| 25 GetShelfLockingManager()->OnLockStateChanged(locked); |
| 26 } |
| 27 |
| 28 void SetSessionState(SessionStateDelegate::SessionState state) { |
| 29 GetShelfLockingManager()->SessionStateChanged(state); |
| 30 } |
| 31 |
| 32 private: |
| 33 DISALLOW_COPY_AND_ASSIGN(ShelfLockingManagerTest); |
| 34 }; |
| 35 |
| 36 // Makes sure shelf alignment is correct for lock screen. |
| 37 TEST_F(ShelfLockingManagerTest, AlignmentLockedWhileScreenLocked) { |
| 38 Shelf* shelf = Shelf::ForPrimaryDisplay(); |
| 39 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, shelf->alignment()); |
| 40 |
| 41 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); |
| 42 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, shelf->alignment()); |
| 43 |
| 44 SetScreenLocked(true); |
| 45 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM_LOCKED, shelf->alignment()); |
| 46 SetScreenLocked(false); |
| 47 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, shelf->alignment()); |
| 48 } |
| 49 |
| 50 // Makes sure shelf alignment is correct for login and add user screens. |
| 51 TEST_F(ShelfLockingManagerTest, AlignmentLockedWhileSessionLocked) { |
| 52 Shelf* shelf = Shelf::ForPrimaryDisplay(); |
| 53 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, shelf->alignment()); |
| 54 |
| 55 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT); |
| 56 EXPECT_EQ(SHELF_ALIGNMENT_RIGHT, shelf->alignment()); |
| 57 |
| 58 SetSessionState(SessionStateDelegate::SESSION_STATE_LOGIN_PRIMARY); |
| 59 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM_LOCKED, shelf->alignment()); |
| 60 SetSessionState(SessionStateDelegate::SESSION_STATE_ACTIVE); |
| 61 EXPECT_EQ(SHELF_ALIGNMENT_RIGHT, shelf->alignment()); |
| 62 |
| 63 SetSessionState(SessionStateDelegate::SESSION_STATE_LOGIN_SECONDARY); |
| 64 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM_LOCKED, shelf->alignment()); |
| 65 SetSessionState(SessionStateDelegate::SESSION_STATE_ACTIVE); |
| 66 EXPECT_EQ(SHELF_ALIGNMENT_RIGHT, shelf->alignment()); |
| 67 } |
| 68 |
| 69 // Makes sure shelf alignment changes are stored, not set, while locked. |
| 70 TEST_F(ShelfLockingManagerTest, AlignmentChangesDeferredWhileLocked) { |
| 71 Shelf* shelf = Shelf::ForPrimaryDisplay(); |
| 72 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, shelf->alignment()); |
| 73 |
| 74 SetScreenLocked(true); |
| 75 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM_LOCKED, shelf->alignment()); |
| 76 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT); |
| 77 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM_LOCKED, shelf->alignment()); |
| 78 SetScreenLocked(false); |
| 79 EXPECT_EQ(SHELF_ALIGNMENT_RIGHT, shelf->alignment()); |
| 80 } |
| 81 |
| 82 } // namespace test |
| 83 } // namespace ash |
OLD | NEW |