| 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/system/tiles/tray_tiles.h" | 5 #include "ash/system/tiles/tray_tiles.h" |
| 6 | 6 |
| 7 #include "ash/system/tiles/tiles_default_view.h" | 7 #include "ash/system/tiles/tiles_default_view.h" |
| 8 #include "ash/test/ash_test_base.h" | 8 #include "ash/test/ash_test_base.h" |
| 9 #include "ash/test/test_session_controller_client.h" | 9 #include "ash/test/test_session_controller_client.h" |
| 10 #include "components/user_manager/user_type.h" |
| 10 #include "ui/views/controls/button/custom_button.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 using views::Button; | 14 using views::Button; |
| 14 | 15 |
| 15 namespace ash { | 16 namespace ash { |
| 16 | 17 |
| 17 // Tests manually control their session state. | 18 // Tests manually control their session state. |
| 18 class TrayTilesTest : public test::NoSessionAshTestBase { | 19 class TrayTilesTest : public test::NoSessionAshTestBase { |
| 19 public: | 20 public: |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 std::unique_ptr<views::View> default_view( | 93 std::unique_ptr<views::View> default_view( |
| 93 tray_tiles()->CreateDefaultViewForTesting()); | 94 tray_tiles()->CreateDefaultViewForTesting()); |
| 94 EXPECT_EQ(Button::STATE_DISABLED, GetSettingsButton()->state()); | 95 EXPECT_EQ(Button::STATE_DISABLED, GetSettingsButton()->state()); |
| 95 EXPECT_EQ(Button::STATE_DISABLED, GetHelpButton()->state()); | 96 EXPECT_EQ(Button::STATE_DISABLED, GetHelpButton()->state()); |
| 96 EXPECT_EQ(Button::STATE_DISABLED, GetLockButton()->state()); | 97 EXPECT_EQ(Button::STATE_DISABLED, GetLockButton()->state()); |
| 97 EXPECT_EQ(Button::STATE_NORMAL, GetPowerButton()->state()); | 98 EXPECT_EQ(Button::STATE_NORMAL, GetPowerButton()->state()); |
| 98 } | 99 } |
| 99 | 100 |
| 100 // Settings buttons are disabled when adding a supervised user. | 101 // Settings buttons are disabled when adding a supervised user. |
| 101 TEST_F(TrayTilesTest, ButtonStatesSupervisedUserFlow) { | 102 TEST_F(TrayTilesTest, ButtonStatesSupervisedUserFlow) { |
| 102 // Simulate a supervised user session with disabled settings. | 103 // Simulate the add supervised user flow, which is a regular user session but |
| 104 // with web UI settings disabled. |
| 103 const bool enable_settings = false; | 105 const bool enable_settings = false; |
| 104 GetSessionControllerClient()->AddUserSession("foo@example.com", | 106 GetSessionControllerClient()->AddUserSession( |
| 105 enable_settings); | 107 "foo@example.com", user_manager::USER_TYPE_REGULAR, enable_settings); |
| 106 std::unique_ptr<views::View> default_view( | 108 std::unique_ptr<views::View> default_view( |
| 107 tray_tiles()->CreateDefaultViewForTesting()); | 109 tray_tiles()->CreateDefaultViewForTesting()); |
| 108 EXPECT_EQ(Button::STATE_DISABLED, GetSettingsButton()->state()); | 110 EXPECT_EQ(Button::STATE_DISABLED, GetSettingsButton()->state()); |
| 109 EXPECT_EQ(Button::STATE_DISABLED, GetHelpButton()->state()); | 111 EXPECT_EQ(Button::STATE_DISABLED, GetHelpButton()->state()); |
| 110 EXPECT_EQ(Button::STATE_DISABLED, GetLockButton()->state()); | 112 EXPECT_EQ(Button::STATE_DISABLED, GetLockButton()->state()); |
| 111 EXPECT_EQ(Button::STATE_NORMAL, GetPowerButton()->state()); | 113 EXPECT_EQ(Button::STATE_NORMAL, GetPowerButton()->state()); |
| 112 } | 114 } |
| 113 | 115 |
| 114 } // namespace ash | 116 } // namespace ash |
| OLD | NEW |