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

Side by Side Diff: ash/common/system/tiles/tray_tiles_unittest.cc

Issue 2732813002: chromeos: Move files in //ash/common to //ash, part 1 (Closed)
Patch Set: rebase 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/system/tiles/tray_tiles.cc ('k') | ash/common/system/toast/OWNERS » ('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/system/tiles/tray_tiles.h"
6
7 #include "ash/common/session/session_state_delegate.h"
8 #include "ash/common/system/tiles/tiles_default_view.h"
9 #include "ash/common/wm_shell.h"
10 #include "ash/test/ash_test_base.h"
11 #include "ui/views/controls/button/custom_button.h"
12 #include "ui/views/view.h"
13
14 namespace ash {
15
16 class TrayTilesTest : public test::AshTestBase {
17 public:
18 TrayTilesTest() {}
19 ~TrayTilesTest() override {}
20
21 void SetUp() override {
22 test::AshTestBase::SetUp();
23 tray_tiles_.reset(new TrayTiles(GetPrimarySystemTray()));
24 }
25
26 void TearDown() override {
27 tray_tiles_.reset();
28 test::AshTestBase::TearDown();
29 }
30
31 views::CustomButton* GetSettingsButton() {
32 return tray_tiles()->default_view_->settings_button_;
33 }
34
35 views::CustomButton* GetHelpButton() {
36 return tray_tiles()->default_view_->help_button_;
37 }
38
39 views::CustomButton* GetLockButton() {
40 return tray_tiles()->default_view_->lock_button_;
41 }
42
43 views::CustomButton* GetPowerButton() {
44 return tray_tiles()->default_view_->power_button_;
45 }
46
47 TrayTiles* tray_tiles() { return tray_tiles_.get(); }
48
49 private:
50 std::unique_ptr<TrayTiles> tray_tiles_;
51
52 DISALLOW_COPY_AND_ASSIGN(TrayTilesTest);
53 };
54
55 TEST_F(TrayTilesTest, ButtonStatesWithAddingUser) {
56 SetUserAddingScreenRunning(true);
57 std::unique_ptr<views::View> default_view(
58 tray_tiles()->CreateDefaultViewForTesting(LoginStatus::USER));
59 EXPECT_EQ(GetSettingsButton()->state(), views::Button::STATE_DISABLED);
60 EXPECT_EQ(GetHelpButton()->state(), views::Button::STATE_DISABLED);
61 EXPECT_EQ(GetLockButton()->state(), views::Button::STATE_DISABLED);
62 EXPECT_EQ(GetPowerButton()->state(), views::Button::STATE_NORMAL);
63 }
64
65 TEST_F(TrayTilesTest, ButtonStatesWithLoginStatusNotLoggedIn) {
66 std::unique_ptr<views::View> default_view(
67 tray_tiles()->CreateDefaultViewForTesting(LoginStatus::NOT_LOGGED_IN));
68 EXPECT_EQ(GetSettingsButton()->state(), views::Button::STATE_DISABLED);
69 EXPECT_EQ(GetHelpButton()->state(), views::Button::STATE_DISABLED);
70 EXPECT_EQ(GetLockButton()->state(), views::Button::STATE_DISABLED);
71 EXPECT_EQ(GetPowerButton()->state(), views::Button::STATE_NORMAL);
72 }
73
74 TEST_F(TrayTilesTest, ButtonStatesWithLoginStatusLocked) {
75 std::unique_ptr<views::View> default_view(
76 tray_tiles()->CreateDefaultViewForTesting(LoginStatus::LOCKED));
77 EXPECT_EQ(GetSettingsButton()->state(), views::Button::STATE_DISABLED);
78 EXPECT_EQ(GetHelpButton()->state(), views::Button::STATE_DISABLED);
79 EXPECT_EQ(GetLockButton()->state(), views::Button::STATE_DISABLED);
80 EXPECT_EQ(GetPowerButton()->state(), views::Button::STATE_NORMAL);
81 }
82
83 TEST_F(TrayTilesTest, ButtonStatesWithLoginStatusUser) {
84 std::unique_ptr<views::View> default_view(
85 tray_tiles()->CreateDefaultViewForTesting(LoginStatus::USER));
86 EXPECT_EQ(GetSettingsButton()->state(), views::Button::STATE_NORMAL);
87 EXPECT_EQ(GetHelpButton()->state(), views::Button::STATE_NORMAL);
88 EXPECT_EQ(GetLockButton()->state(), views::Button::STATE_NORMAL);
89 EXPECT_EQ(GetPowerButton()->state(), views::Button::STATE_NORMAL);
90 }
91
92 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/tiles/tray_tiles.cc ('k') | ash/common/system/toast/OWNERS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698