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

Side by Side Diff: ash/common/shelf/shelf_locking_manager_unittest.cc

Issue 2734653002: chromeos: Move files in //ash/common to //ash (Closed)
Patch Set: fix a11y tests, fix docs Created 3 years, 9 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 | « ash/common/shelf/shelf_locking_manager.cc ('k') | ash/common/shelf/shelf_model.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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/common/shelf/shelf_locking_manager.h"
6
7 #include "ash/common/session/session_state_delegate.h"
8 #include "ash/common/shelf/wm_shelf.h"
9 #include "ash/test/ash_test_base.h"
10
11 namespace ash {
12 namespace test {
13
14 // Tests the shelf behavior when the screen or session is locked.
15 class ShelfLockingManagerTest : public ash::test::AshTestBase {
16 public:
17 ShelfLockingManagerTest() {}
18
19 ShelfLockingManager* GetShelfLockingManager() {
20 return GetPrimaryShelf()->GetShelfLockingManagerForTesting();
21 }
22
23 void SetScreenLocked(bool locked) {
24 GetShelfLockingManager()->OnLockStateChanged(locked);
25 }
26
27 void SetSessionState(session_manager::SessionState state) {
28 GetShelfLockingManager()->SessionStateChanged(state);
29 }
30
31 private:
32 DISALLOW_COPY_AND_ASSIGN(ShelfLockingManagerTest);
33 };
34
35 // Makes sure shelf alignment is correct for lock screen.
36 TEST_F(ShelfLockingManagerTest, AlignmentLockedWhileScreenLocked) {
37 WmShelf* shelf = GetPrimaryShelf();
38 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, shelf->GetAlignment());
39
40 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT);
41 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, shelf->GetAlignment());
42
43 SetScreenLocked(true);
44 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM_LOCKED, shelf->GetAlignment());
45 SetScreenLocked(false);
46 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, shelf->GetAlignment());
47 }
48
49 // Makes sure shelf alignment is correct for login and add user screens.
50 TEST_F(ShelfLockingManagerTest, AlignmentLockedWhileSessionLocked) {
51 WmShelf* shelf = GetPrimaryShelf();
52 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, shelf->GetAlignment());
53
54 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT);
55 EXPECT_EQ(SHELF_ALIGNMENT_RIGHT, shelf->GetAlignment());
56
57 SetSessionState(session_manager::SessionState::LOGIN_PRIMARY);
58 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM_LOCKED, shelf->GetAlignment());
59 SetSessionState(session_manager::SessionState::ACTIVE);
60 EXPECT_EQ(SHELF_ALIGNMENT_RIGHT, shelf->GetAlignment());
61
62 SetSessionState(session_manager::SessionState::LOGIN_SECONDARY);
63 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM_LOCKED, shelf->GetAlignment());
64 SetSessionState(session_manager::SessionState::ACTIVE);
65 EXPECT_EQ(SHELF_ALIGNMENT_RIGHT, shelf->GetAlignment());
66 }
67
68 // Makes sure shelf alignment changes are stored, not set, while locked.
69 TEST_F(ShelfLockingManagerTest, AlignmentChangesDeferredWhileLocked) {
70 WmShelf* shelf = GetPrimaryShelf();
71 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, shelf->GetAlignment());
72
73 SetScreenLocked(true);
74 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM_LOCKED, shelf->GetAlignment());
75 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT);
76 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM_LOCKED, shelf->GetAlignment());
77 SetScreenLocked(false);
78 EXPECT_EQ(SHELF_ALIGNMENT_RIGHT, shelf->GetAlignment());
79 }
80
81 } // namespace test
82 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/shelf/shelf_locking_manager.cc ('k') | ash/common/shelf/shelf_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698