| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 "ash/shelf/shelf_locking_manager.h" | 5 #include "ash/shelf/shelf_locking_manager.h" |
| 6 | 6 |
| 7 #include "ash/session/session_state_delegate.h" | 7 #include "ash/session/session_state_delegate.h" |
| 8 #include "ash/shelf/wm_shelf.h" | 8 #include "ash/shelf/shelf.h" |
| 9 #include "ash/test/ash_test_base.h" | 9 #include "ash/test/ash_test_base.h" |
| 10 | 10 |
| 11 namespace ash { | 11 namespace ash { |
| 12 namespace { | 12 namespace { |
| 13 | 13 |
| 14 // Tests the shelf behavior when the screen or session is locked. | 14 // Tests the shelf behavior when the screen or session is locked. |
| 15 class ShelfLockingManagerTest : public test::AshTestBase { | 15 class ShelfLockingManagerTest : public test::AshTestBase { |
| 16 public: | 16 public: |
| 17 ShelfLockingManagerTest() {} | 17 ShelfLockingManagerTest() {} |
| 18 | 18 |
| 19 ShelfLockingManager* GetShelfLockingManager() { | 19 ShelfLockingManager* GetShelfLockingManager() { |
| 20 return GetPrimaryShelf()->GetShelfLockingManagerForTesting(); | 20 return GetPrimaryShelf()->GetShelfLockingManagerForTesting(); |
| 21 } | 21 } |
| 22 | 22 |
| 23 void SetScreenLocked(bool locked) { | 23 void SetScreenLocked(bool locked) { |
| 24 GetShelfLockingManager()->OnLockStateChanged(locked); | 24 GetShelfLockingManager()->OnLockStateChanged(locked); |
| 25 } | 25 } |
| 26 | 26 |
| 27 void SetSessionState(session_manager::SessionState state) { | 27 void SetSessionState(session_manager::SessionState state) { |
| 28 GetShelfLockingManager()->OnSessionStateChanged(state); | 28 GetShelfLockingManager()->OnSessionStateChanged(state); |
| 29 } | 29 } |
| 30 | 30 |
| 31 private: | 31 private: |
| 32 DISALLOW_COPY_AND_ASSIGN(ShelfLockingManagerTest); | 32 DISALLOW_COPY_AND_ASSIGN(ShelfLockingManagerTest); |
| 33 }; | 33 }; |
| 34 | 34 |
| 35 // Makes sure shelf alignment is correct for lock screen. | 35 // Makes sure shelf alignment is correct for lock screen. |
| 36 TEST_F(ShelfLockingManagerTest, AlignmentLockedWhileScreenLocked) { | 36 TEST_F(ShelfLockingManagerTest, AlignmentLockedWhileScreenLocked) { |
| 37 WmShelf* shelf = GetPrimaryShelf(); | 37 Shelf* shelf = GetPrimaryShelf(); |
| 38 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, shelf->GetAlignment()); | 38 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, shelf->alignment()); |
| 39 | 39 |
| 40 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); | 40 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); |
| 41 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, shelf->GetAlignment()); | 41 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, shelf->alignment()); |
| 42 | 42 |
| 43 SetScreenLocked(true); | 43 SetScreenLocked(true); |
| 44 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM_LOCKED, shelf->GetAlignment()); | 44 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM_LOCKED, shelf->alignment()); |
| 45 SetScreenLocked(false); | 45 SetScreenLocked(false); |
| 46 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, shelf->GetAlignment()); | 46 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, shelf->alignment()); |
| 47 } | 47 } |
| 48 | 48 |
| 49 // Makes sure shelf alignment is correct for login and add user screens. | 49 // Makes sure shelf alignment is correct for login and add user screens. |
| 50 TEST_F(ShelfLockingManagerTest, AlignmentLockedWhileSessionLocked) { | 50 TEST_F(ShelfLockingManagerTest, AlignmentLockedWhileSessionLocked) { |
| 51 WmShelf* shelf = GetPrimaryShelf(); | 51 Shelf* shelf = GetPrimaryShelf(); |
| 52 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, shelf->GetAlignment()); | 52 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, shelf->alignment()); |
| 53 | 53 |
| 54 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT); | 54 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT); |
| 55 EXPECT_EQ(SHELF_ALIGNMENT_RIGHT, shelf->GetAlignment()); | 55 EXPECT_EQ(SHELF_ALIGNMENT_RIGHT, shelf->alignment()); |
| 56 | 56 |
| 57 SetSessionState(session_manager::SessionState::LOGIN_PRIMARY); | 57 SetSessionState(session_manager::SessionState::LOGIN_PRIMARY); |
| 58 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM_LOCKED, shelf->GetAlignment()); | 58 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM_LOCKED, shelf->alignment()); |
| 59 SetSessionState(session_manager::SessionState::ACTIVE); | 59 SetSessionState(session_manager::SessionState::ACTIVE); |
| 60 EXPECT_EQ(SHELF_ALIGNMENT_RIGHT, shelf->GetAlignment()); | 60 EXPECT_EQ(SHELF_ALIGNMENT_RIGHT, shelf->alignment()); |
| 61 | 61 |
| 62 SetSessionState(session_manager::SessionState::LOGIN_SECONDARY); | 62 SetSessionState(session_manager::SessionState::LOGIN_SECONDARY); |
| 63 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM_LOCKED, shelf->GetAlignment()); | 63 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM_LOCKED, shelf->alignment()); |
| 64 SetSessionState(session_manager::SessionState::ACTIVE); | 64 SetSessionState(session_manager::SessionState::ACTIVE); |
| 65 EXPECT_EQ(SHELF_ALIGNMENT_RIGHT, shelf->GetAlignment()); | 65 EXPECT_EQ(SHELF_ALIGNMENT_RIGHT, shelf->alignment()); |
| 66 } | 66 } |
| 67 | 67 |
| 68 // Makes sure shelf alignment changes are stored, not set, while locked. | 68 // Makes sure shelf alignment changes are stored, not set, while locked. |
| 69 TEST_F(ShelfLockingManagerTest, AlignmentChangesDeferredWhileLocked) { | 69 TEST_F(ShelfLockingManagerTest, AlignmentChangesDeferredWhileLocked) { |
| 70 WmShelf* shelf = GetPrimaryShelf(); | 70 Shelf* shelf = GetPrimaryShelf(); |
| 71 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, shelf->GetAlignment()); | 71 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, shelf->alignment()); |
| 72 | 72 |
| 73 SetScreenLocked(true); | 73 SetScreenLocked(true); |
| 74 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM_LOCKED, shelf->GetAlignment()); | 74 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM_LOCKED, shelf->alignment()); |
| 75 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT); | 75 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT); |
| 76 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM_LOCKED, shelf->GetAlignment()); | 76 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM_LOCKED, shelf->alignment()); |
| 77 SetScreenLocked(false); | 77 SetScreenLocked(false); |
| 78 EXPECT_EQ(SHELF_ALIGNMENT_RIGHT, shelf->GetAlignment()); | 78 EXPECT_EQ(SHELF_ALIGNMENT_RIGHT, shelf->alignment()); |
| 79 } | 79 } |
| 80 | 80 |
| 81 } // namespace | 81 } // namespace |
| 82 } // namespace ash | 82 } // namespace ash |
| OLD | NEW |