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.
5 #include "ash/system/chromeos/brightness/tray_brightness.h"
8 #include "ash/system/tray/system_tray_delegate.h"
9 #include "ash/system/tray/system_tray_item.h"
10 #include "ash/test/ash_test_base.h"
11 #include "ash/test/status_area_widget_test_helper.h"
12 #include "ash/wm/maximize_mode/maximize_mode_controller.h"
13 #include "ui/views/view.h"
17 class TrayBrightnessTest
: public test::AshTestBase
{
19 TrayBrightnessTest() {}
20 ~TrayBrightnessTest() override
{}
23 views::View
* CreateDefaultView() {
24 TrayBrightness
tray(NULL
);
25 return tray
.CreateDefaultView(
26 StatusAreaWidgetTestHelper::GetUserLoginStatus());
29 views::View
* CreateDetailedView() {
30 TrayBrightness
tray(NULL
);
31 return tray
.CreateDetailedView(
32 StatusAreaWidgetTestHelper::GetUserLoginStatus());
36 DISALLOW_COPY_AND_ASSIGN(TrayBrightnessTest
);
39 // Tests that when the default view is initially created, that its
40 // BrightnessView is created not visible.
41 TEST_F(TrayBrightnessTest
, CreateDefaultView
) {
42 scoped_ptr
<views::View
> tray(CreateDefaultView());
43 EXPECT_FALSE(tray
->visible());
46 // Tests the construction of the default view while MaximizeMode is active.
47 // The BrightnessView should be visible.
48 TEST_F(TrayBrightnessTest
, CreateDefaultViewDuringMaximizeMode
) {
49 Shell::GetInstance()->maximize_mode_controller()->
50 EnableMaximizeModeWindowManager(true);
51 scoped_ptr
<views::View
> tray(CreateDefaultView());
52 EXPECT_TRUE(tray
->visible());
53 Shell::GetInstance()->maximize_mode_controller()->
54 EnableMaximizeModeWindowManager(false);
57 // Tests that the enabling of MaximizeMode affects a previously created
58 // BrightnessView, changing the visibility.
59 TEST_F(TrayBrightnessTest
, DefaultViewVisibilityChangesDuringMaximizeMode
) {
60 scoped_ptr
<views::View
> tray(CreateDefaultView());
61 Shell::GetInstance()->maximize_mode_controller()->
62 EnableMaximizeModeWindowManager(true);
63 EXPECT_TRUE(tray
->visible());
64 Shell::GetInstance()->maximize_mode_controller()->
65 EnableMaximizeModeWindowManager(false);
66 EXPECT_FALSE(tray
->visible());
69 // Tests that when the detailed view is initially created that its
70 // BrightnessView is created as visible.
71 TEST_F(TrayBrightnessTest
, CreateDetailedView
) {
72 scoped_ptr
<views::View
> tray(CreateDetailedView());
73 EXPECT_TRUE(tray
->visible());
77 // Tests that when the detailed view is created during MaximizeMode that its
78 // BrightnessView is visible.
79 TEST_F(TrayBrightnessTest
, CreateDetailedViewDuringMaximizeMode
) {
80 Shell::GetInstance()->maximize_mode_controller()->
81 EnableMaximizeModeWindowManager(true);
82 scoped_ptr
<views::View
> tray(CreateDetailedView());
83 EXPECT_TRUE(tray
->visible());
84 Shell::GetInstance()->maximize_mode_controller()->
85 EnableMaximizeModeWindowManager(false);
88 // Tests that the enabling of MaximizeMode has no affect on the visibility of a
89 // previously created BrightnessView that belongs to a detailed view.
90 TEST_F(TrayBrightnessTest
, DetailedViewVisibilityChangesDuringMaximizeMode
) {
91 scoped_ptr
<views::View
> tray(CreateDetailedView());
92 Shell::GetInstance()->maximize_mode_controller()->
93 EnableMaximizeModeWindowManager(true);
94 EXPECT_TRUE(tray
->visible());
95 Shell::GetInstance()->maximize_mode_controller()->
96 EnableMaximizeModeWindowManager(false);
97 EXPECT_TRUE(tray
->visible());