Chromium Code Reviews| 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/common/shelf/shelf_locking_manager.h" |
| 6 | 6 |
| 7 #include "ash/common/session/session_state_delegate.h" | 7 #include "ash/common/session/session_state_delegate.h" |
| 8 #include "ash/shelf/shelf.h" | 8 #include "ash/common/shelf/wm_shelf.h" |
| 9 #include "ash/test/ash_test_base.h" | 9 #include "ash/test/ash_test_base.h" |
| 10 #include "ash/test/shelf_test_api.h" | |
| 11 | 10 |
| 12 namespace ash { | 11 namespace ash { |
| 13 namespace test { | 12 namespace test { |
| 14 | 13 |
| 15 // Tests the shelf behavior when the screen or session is locked. | 14 // Tests the shelf behavior when the screen or session is locked. |
| 16 class ShelfLockingManagerTest : public ash::test::AshTestBase { | 15 class ShelfLockingManagerTest : public ash::test::AshTestBase { |
| 17 public: | 16 public: |
| 18 ShelfLockingManagerTest() {} | 17 ShelfLockingManagerTest() {} |
| 19 | 18 |
| 20 ShelfLockingManager* GetShelfLockingManager() { | 19 ShelfLockingManager* GetShelfLockingManager() { |
| 21 return ShelfTestAPI(Shelf::ForPrimaryDisplay()).shelf_locking_manager(); | 20 return GetPrimaryShelf()->GetShelfLockingManagerForTesting(); |
| 22 } | 21 } |
| 23 | 22 |
| 24 void SetScreenLocked(bool locked) { | 23 void SetScreenLocked(bool locked) { |
| 25 GetShelfLockingManager()->OnLockStateChanged(locked); | 24 GetShelfLockingManager()->OnLockStateChanged(locked); |
| 26 } | 25 } |
| 27 | 26 |
| 28 void SetSessionState(SessionStateDelegate::SessionState state) { | 27 void SetSessionState(SessionStateDelegate::SessionState state) { |
| 29 GetShelfLockingManager()->SessionStateChanged(state); | 28 GetShelfLockingManager()->SessionStateChanged(state); |
| 30 } | 29 } |
| 31 | 30 |
| 32 private: | 31 private: |
| 33 DISALLOW_COPY_AND_ASSIGN(ShelfLockingManagerTest); | 32 DISALLOW_COPY_AND_ASSIGN(ShelfLockingManagerTest); |
| 34 }; | 33 }; |
| 35 | 34 |
| 36 // Makes sure shelf alignment is correct for lock screen. | 35 // Makes sure shelf alignment is correct for lock screen. |
| 37 TEST_F(ShelfLockingManagerTest, AlignmentLockedWhileScreenLocked) { | 36 TEST_F(ShelfLockingManagerTest, AlignmentLockedWhileScreenLocked) { |
| 38 Shelf* shelf = Shelf::ForPrimaryDisplay(); | 37 WmShelf* shelf = GetPrimaryShelf(); |
| 39 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, shelf->alignment()); | 38 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, shelf->GetAlignment()); |
| 40 | 39 |
| 41 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); | 40 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); |
| 42 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, shelf->alignment()); | 41 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, shelf->GetAlignment()); |
| 43 | 42 |
| 44 SetScreenLocked(true); | 43 SetScreenLocked(true); |
| 45 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM_LOCKED, shelf->alignment()); | 44 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM_LOCKED, shelf->GetAlignment()); |
| 46 SetScreenLocked(false); | 45 SetScreenLocked(false); |
| 47 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, shelf->alignment()); | 46 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, shelf->GetAlignment()); |
| 48 } | 47 } |
| 49 | 48 |
| 50 // 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. |
| 51 TEST_F(ShelfLockingManagerTest, AlignmentLockedWhileSessionLocked) { | 50 TEST_F(ShelfLockingManagerTest, AlignmentLockedWhileSessionLocked) { |
| 52 Shelf* shelf = Shelf::ForPrimaryDisplay(); | 51 WmShelf* shelf = GetPrimaryShelf(); |
| 53 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, shelf->alignment()); | 52 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, shelf->GetAlignment()); |
| 54 | 53 |
| 55 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT); | 54 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT); |
| 56 EXPECT_EQ(SHELF_ALIGNMENT_RIGHT, shelf->alignment()); | 55 EXPECT_EQ(SHELF_ALIGNMENT_RIGHT, shelf->GetAlignment()); |
| 57 | 56 |
| 58 SetSessionState(SessionStateDelegate::SESSION_STATE_LOGIN_PRIMARY); | 57 SetSessionState(SessionStateDelegate::SESSION_STATE_LOGIN_PRIMARY); |
| 59 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM_LOCKED, shelf->alignment()); | 58 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM_LOCKED, shelf->GetAlignment()); |
| 60 SetSessionState(SessionStateDelegate::SESSION_STATE_ACTIVE); | 59 SetSessionState(SessionStateDelegate::SESSION_STATE_ACTIVE); |
| 61 EXPECT_EQ(SHELF_ALIGNMENT_RIGHT, shelf->alignment()); | 60 EXPECT_EQ(SHELF_ALIGNMENT_RIGHT, shelf->GetAlignment()); |
| 62 | 61 |
| 63 SetSessionState(SessionStateDelegate::SESSION_STATE_LOGIN_SECONDARY); | 62 SetSessionState(SessionStateDelegate::SESSION_STATE_LOGIN_SECONDARY); |
| 64 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM_LOCKED, shelf->alignment()); | 63 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM_LOCKED, shelf->GetAlignment()); |
| 65 SetSessionState(SessionStateDelegate::SESSION_STATE_ACTIVE); | 64 SetSessionState(SessionStateDelegate::SESSION_STATE_ACTIVE); |
| 66 EXPECT_EQ(SHELF_ALIGNMENT_RIGHT, shelf->alignment()); | 65 EXPECT_EQ(SHELF_ALIGNMENT_RIGHT, shelf->GetAlignment()); |
| 67 } | 66 } |
| 68 | 67 |
| 69 // Makes sure shelf alignment changes are stored, not set, while locked. | 68 // Makes sure shelf alignment changes are stored, not set, while locked. |
| 70 TEST_F(ShelfLockingManagerTest, AlignmentChangesDeferredWhileLocked) { | 69 TEST_F(ShelfLockingManagerTest, AlignmentChangesDeferredWhileLocked) { |
| 71 Shelf* shelf = Shelf::ForPrimaryDisplay(); | 70 WmShelf* shelf = GetPrimaryShelf(); |
| 72 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, shelf->alignment()); | 71 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, shelf->GetAlignment()); |
| 73 | 72 |
| 74 SetScreenLocked(true); | 73 SetScreenLocked(true); |
| 75 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM_LOCKED, shelf->alignment()); | 74 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM_LOCKED, shelf->GetAlignment()); |
| 76 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT); | 75 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT); |
| 77 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM_LOCKED, shelf->alignment()); | 76 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM_LOCKED, shelf->GetAlignment()); |
| 78 SetScreenLocked(false); | 77 SetScreenLocked(false); |
| 79 EXPECT_EQ(SHELF_ALIGNMENT_RIGHT, shelf->alignment()); | 78 EXPECT_EQ(SHELF_ALIGNMENT_RIGHT, shelf->GetAlignment()); |
| 80 } | 79 } |
| 81 | 80 |
| 82 } // namespace test | 81 } // namespace test |
| 83 } // namespace ash | 82 } // namespace ash |
|
James Cook
2016/07/20 21:14:30
woo hoo, you were able to convert the test!
msw
2016/07/20 21:21:14
Acknowledged.
| |
| OLD | NEW |