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

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

Issue 2429923002: Implement all system menu title row buttons for Ash MD (Closed)
Patch Set: OS_WIN define in tests Created 4 years, 2 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/tray/special_popup_row.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/common/system/tiles/tray_tiles.h" 5 #include "ash/common/system/tiles/tray_tiles.h"
6 6
7 #include "ash/common/session/session_state_delegate.h" 7 #include "ash/common/session/session_state_delegate.h"
8 #include "ash/common/system/tiles/tiles_default_view.h" 8 #include "ash/common/system/tiles/tiles_default_view.h"
9 #include "ash/common/wm_shell.h" 9 #include "ash/common/wm_shell.h"
10 #include "ash/test/ash_test_base.h" 10 #include "ash/test/ash_test_base.h"
11 #include "ui/views/controls/button/custom_button.h"
11 #include "ui/views/view.h" 12 #include "ui/views/view.h"
12 13
13 namespace ash { 14 namespace ash {
14 15
15 class TrayTilesTest : public test::AshTestBase { 16 class TrayTilesTest : public test::AshTestBase {
16 public: 17 public:
17 TrayTilesTest() {} 18 TrayTilesTest() {}
18 ~TrayTilesTest() override {} 19 ~TrayTilesTest() override {}
19 20
20 void SetUp() override { 21 void SetUp() override {
21 test::AshTestBase::SetUp(); 22 test::AshTestBase::SetUp();
22 tray_tiles_.reset(new TrayTiles(GetPrimarySystemTray())); 23 tray_tiles_.reset(new TrayTiles(GetPrimarySystemTray()));
23 } 24 }
24 25
25 void TearDown() override { 26 void TearDown() override {
26 tray_tiles_.reset(); 27 tray_tiles_.reset();
27 test::AshTestBase::TearDown(); 28 test::AshTestBase::TearDown();
28 } 29 }
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
30 TrayTiles* tray_tiles() { return tray_tiles_.get(); } 47 TrayTiles* tray_tiles() { return tray_tiles_.get(); }
31 48
32 private: 49 private:
33 std::unique_ptr<TrayTiles> tray_tiles_; 50 std::unique_ptr<TrayTiles> tray_tiles_;
34 51
35 DISALLOW_COPY_AND_ASSIGN(TrayTilesTest); 52 DISALLOW_COPY_AND_ASSIGN(TrayTilesTest);
36 }; 53 };
37 54
38 // TODO(tdanderson|bruthig): Many of the other rows follow the same rules for 55 TEST_F(TrayTilesTest, ButtonStatesWithAddingUser) {
39 // not being shown if the login status is NOT_LOGGED_IN, LOCKED, or if the
40 // add-user screen is active. Consider applying the test coverage below to
41 // such rows.
42
43 TEST_F(TrayTilesTest, TilesRowNotCreatedWithAddingUser) {
44 SetUserAddingScreenRunning(true); 56 SetUserAddingScreenRunning(true);
45 std::unique_ptr<views::View> default_view( 57 std::unique_ptr<views::View> default_view(
46 tray_tiles()->CreateDefaultView(LoginStatus::USER)); 58 tray_tiles()->CreateDefaultView(LoginStatus::USER));
47 EXPECT_FALSE(default_view); 59 EXPECT_EQ(GetSettingsButton()->state(), views::Button::STATE_DISABLED);
60 EXPECT_EQ(GetHelpButton()->state(), views::Button::STATE_DISABLED);
61 #if !defined(OS_WIN)
62 EXPECT_EQ(GetLockButton()->state(), views::Button::STATE_DISABLED);
63 EXPECT_EQ(GetPowerButton()->state(), views::Button::STATE_NORMAL);
64 #endif // !defined(OS_WIN)
48 } 65 }
49 66
50 TEST_F(TrayTilesTest, TilesRowNotCreatedWithLoginStatusNotLoggedIn) { 67 TEST_F(TrayTilesTest, ButtonStatesWithLoginStatusNotLoggedIn) {
51 std::unique_ptr<views::View> default_view( 68 std::unique_ptr<views::View> default_view(
52 tray_tiles()->CreateDefaultView(LoginStatus::NOT_LOGGED_IN)); 69 tray_tiles()->CreateDefaultView(LoginStatus::NOT_LOGGED_IN));
53 EXPECT_FALSE(default_view); 70 EXPECT_EQ(GetSettingsButton()->state(), views::Button::STATE_DISABLED);
71 EXPECT_EQ(GetHelpButton()->state(), views::Button::STATE_DISABLED);
72 #if !defined(OS_WIN)
73 EXPECT_EQ(GetLockButton()->state(), views::Button::STATE_DISABLED);
74 EXPECT_EQ(GetPowerButton()->state(), views::Button::STATE_NORMAL);
75 #endif // !defined(OS_WIN)
54 } 76 }
55 77
56 TEST_F(TrayTilesTest, TilesRowNotCreatedWithLoginStatusLocked) { 78 TEST_F(TrayTilesTest, ButtonStatesWithLoginStatusLocked) {
57 std::unique_ptr<views::View> default_view( 79 std::unique_ptr<views::View> default_view(
58 tray_tiles()->CreateDefaultView(LoginStatus::LOCKED)); 80 tray_tiles()->CreateDefaultView(LoginStatus::LOCKED));
59 EXPECT_FALSE(default_view); 81 EXPECT_EQ(GetSettingsButton()->state(), views::Button::STATE_DISABLED);
82 EXPECT_EQ(GetHelpButton()->state(), views::Button::STATE_DISABLED);
83 #if !defined(OS_WIN)
84 EXPECT_EQ(GetLockButton()->state(), views::Button::STATE_DISABLED);
85 EXPECT_EQ(GetPowerButton()->state(), views::Button::STATE_NORMAL);
86 #endif // !defined(OS_WIN)
60 } 87 }
61 88
62 TEST_F(TrayTilesTest, TilesRowCreatedWithLoginStatusUser) { 89 TEST_F(TrayTilesTest, ButtonStatesWithLoginStatusUser) {
63 std::unique_ptr<views::View> default_view( 90 std::unique_ptr<views::View> default_view(
64 tray_tiles()->CreateDefaultView(LoginStatus::USER)); 91 tray_tiles()->CreateDefaultView(LoginStatus::USER));
65 EXPECT_TRUE(default_view); 92 EXPECT_EQ(GetSettingsButton()->state(), views::Button::STATE_NORMAL);
93 EXPECT_EQ(GetHelpButton()->state(), views::Button::STATE_NORMAL);
94 #if !defined(OS_WIN)
95 EXPECT_EQ(GetLockButton()->state(), views::Button::STATE_NORMAL);
96 EXPECT_EQ(GetPowerButton()->state(), views::Button::STATE_NORMAL);
97 #endif // !defined(OS_WIN)
66 } 98 }
67 99
68 } // namespace ash 100 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/tiles/tray_tiles.cc ('k') | ash/common/system/tray/special_popup_row.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698