| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 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/system/chromeos/brightness/tray_brightness.h" | |
| 6 | |
| 7 #include <memory> | |
| 8 | |
| 9 #include "ash/common/system/tray/system_tray_delegate.h" | |
| 10 #include "ash/common/system/tray/system_tray_item.h" | |
| 11 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" | |
| 12 #include "ash/common/wm_shell.h" | |
| 13 #include "ash/shell.h" | |
| 14 #include "ash/test/ash_test_base.h" | |
| 15 #include "ash/test/status_area_widget_test_helper.h" | |
| 16 #include "ui/views/view.h" | |
| 17 | |
| 18 namespace ash { | |
| 19 | |
| 20 class TrayBrightnessTest : public test::AshTestBase { | |
| 21 public: | |
| 22 TrayBrightnessTest() {} | |
| 23 ~TrayBrightnessTest() override {} | |
| 24 | |
| 25 protected: | |
| 26 views::View* CreateDefaultView() { | |
| 27 TrayBrightness tray(NULL); | |
| 28 return tray.CreateDefaultView( | |
| 29 StatusAreaWidgetTestHelper::GetUserLoginStatus()); | |
| 30 } | |
| 31 | |
| 32 views::View* CreateDetailedView() { | |
| 33 TrayBrightness tray(NULL); | |
| 34 return tray.CreateDetailedView( | |
| 35 StatusAreaWidgetTestHelper::GetUserLoginStatus()); | |
| 36 } | |
| 37 | |
| 38 private: | |
| 39 DISALLOW_COPY_AND_ASSIGN(TrayBrightnessTest); | |
| 40 }; | |
| 41 | |
| 42 // Tests that when the default view is initially created, that its | |
| 43 // BrightnessView is created not visible. | |
| 44 TEST_F(TrayBrightnessTest, CreateDefaultView) { | |
| 45 std::unique_ptr<views::View> tray(CreateDefaultView()); | |
| 46 EXPECT_FALSE(tray->visible()); | |
| 47 } | |
| 48 | |
| 49 // Tests the construction of the default view while MaximizeMode is active. | |
| 50 // The BrightnessView should be visible. | |
| 51 TEST_F(TrayBrightnessTest, CreateDefaultViewDuringMaximizeMode) { | |
| 52 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( | |
| 53 true); | |
| 54 std::unique_ptr<views::View> tray(CreateDefaultView()); | |
| 55 EXPECT_TRUE(tray->visible()); | |
| 56 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( | |
| 57 false); | |
| 58 } | |
| 59 | |
| 60 // Tests that the enabling of MaximizeMode affects a previously created | |
| 61 // BrightnessView, changing the visibility. | |
| 62 TEST_F(TrayBrightnessTest, DefaultViewVisibilityChangesDuringMaximizeMode) { | |
| 63 std::unique_ptr<views::View> tray(CreateDefaultView()); | |
| 64 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( | |
| 65 true); | |
| 66 EXPECT_TRUE(tray->visible()); | |
| 67 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( | |
| 68 false); | |
| 69 EXPECT_FALSE(tray->visible()); | |
| 70 } | |
| 71 | |
| 72 // Tests that when the detailed view is initially created that its | |
| 73 // BrightnessView is created as visible. | |
| 74 TEST_F(TrayBrightnessTest, CreateDetailedView) { | |
| 75 std::unique_ptr<views::View> tray(CreateDetailedView()); | |
| 76 EXPECT_TRUE(tray->visible()); | |
| 77 } | |
| 78 | |
| 79 // Tests that when the detailed view is created during MaximizeMode that its | |
| 80 // BrightnessView is visible. | |
| 81 TEST_F(TrayBrightnessTest, CreateDetailedViewDuringMaximizeMode) { | |
| 82 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( | |
| 83 true); | |
| 84 std::unique_ptr<views::View> tray(CreateDetailedView()); | |
| 85 EXPECT_TRUE(tray->visible()); | |
| 86 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( | |
| 87 false); | |
| 88 } | |
| 89 | |
| 90 // Tests that the enabling of MaximizeMode has no affect on the visibility of a | |
| 91 // previously created BrightnessView that belongs to a detailed view. | |
| 92 TEST_F(TrayBrightnessTest, DetailedViewVisibilityChangesDuringMaximizeMode) { | |
| 93 std::unique_ptr<views::View> tray(CreateDetailedView()); | |
| 94 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( | |
| 95 true); | |
| 96 EXPECT_TRUE(tray->visible()); | |
| 97 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( | |
| 98 false); | |
| 99 EXPECT_TRUE(tray->visible()); | |
| 100 } | |
| 101 | |
| 102 } // namespace ash | |
| OLD | NEW |