forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathshelf_locking_manager_unittest.cc
81 lines (63 loc) · 2.71 KB
/
shelf_locking_manager_unittest.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// 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/shelf/shelf.h"
#include "ash/test/ash_test_base.h"
namespace ash {
namespace {
// Tests the shelf behavior when the screen or session is locked.
class ShelfLockingManagerTest : public AshTestBase {
public:
ShelfLockingManagerTest() = default;
ShelfLockingManager* GetShelfLockingManager() {
return GetPrimaryShelf()->GetShelfLockingManagerForTesting();
}
void SetScreenLocked(bool locked) {
GetShelfLockingManager()->OnLockStateChanged(locked);
}
void SetSessionState(session_manager::SessionState state) {
GetShelfLockingManager()->OnSessionStateChanged(state);
}
private:
DISALLOW_COPY_AND_ASSIGN(ShelfLockingManagerTest);
};
// Makes sure shelf alignment is correct for lock screen.
TEST_F(ShelfLockingManagerTest, AlignmentLockedWhileScreenLocked) {
Shelf* shelf = GetPrimaryShelf();
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 = GetPrimaryShelf();
EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, shelf->alignment());
shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT);
EXPECT_EQ(SHELF_ALIGNMENT_RIGHT, shelf->alignment());
SetSessionState(session_manager::SessionState::LOGIN_PRIMARY);
EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM_LOCKED, shelf->alignment());
SetSessionState(session_manager::SessionState::ACTIVE);
EXPECT_EQ(SHELF_ALIGNMENT_RIGHT, shelf->alignment());
SetSessionState(session_manager::SessionState::LOGIN_SECONDARY);
EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM_LOCKED, shelf->alignment());
SetSessionState(session_manager::SessionState::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 = GetPrimaryShelf();
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
} // namespace ash