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 "ui/views/view.h"
16 class TrayBrightnessTest : public test::AshTestBase {
18 TrayBrightnessTest() {}
19 virtual ~TrayBrightnessTest() {}
22 views::View* CreateDefaultView() {
23 TrayBrightness tray(NULL);
24 return tray.CreateDefaultView(
25 StatusAreaWidgetTestHelper::GetUserLoginStatus());
28 views::View* CreateDetailedView() {
29 TrayBrightness tray(NULL);
30 return tray.CreateDetailedView(
31 StatusAreaWidgetTestHelper::GetUserLoginStatus());
35 DISALLOW_COPY_AND_ASSIGN(TrayBrightnessTest);
38 // Tests that when the default view is initially created, that its
39 // BrightnessView is created not visible.
40 TEST_F(TrayBrightnessTest, CreateDefaultView) {
41 scoped_ptr<views::View> tray(CreateDefaultView());
42 EXPECT_FALSE(tray->visible());
45 // Tests the construction of the default view while MaximizeMode is active.
46 // The BrightnessView should be visible.
47 TEST_F(TrayBrightnessTest, CreateDefaultViewDuringMaximizeMode) {
48 Shell::GetInstance()->EnableMaximizeModeWindowManager(true);
49 scoped_ptr<views::View> tray(CreateDefaultView());
50 EXPECT_TRUE(tray->visible());
51 Shell::GetInstance()->EnableMaximizeModeWindowManager(false);
54 // Tests that the enabling of MaximizeMode affects a previously created
55 // BrightnessView, changing the visibility.
56 TEST_F(TrayBrightnessTest, DefaultViewVisibilityChangesDuringMaximizeMode) {
57 scoped_ptr<views::View> tray(CreateDefaultView());
58 Shell::GetInstance()->EnableMaximizeModeWindowManager(true);
59 EXPECT_TRUE(tray->visible());
60 Shell::GetInstance()->EnableMaximizeModeWindowManager(false);
61 EXPECT_FALSE(tray->visible());
64 // Tests that when the detailed view is initially created that its
65 // BrightnessView is created as visible.
66 TEST_F(TrayBrightnessTest, CreateDetailedView) {
67 scoped_ptr<views::View> tray(CreateDetailedView());
68 EXPECT_TRUE(tray->visible());
72 // Tests that when the detailed view is created during MaximizeMode that its
73 // BrightnessView is visible.
74 TEST_F(TrayBrightnessTest, CreateDetailedViewDuringMaximizeMode) {
75 Shell::GetInstance()->EnableMaximizeModeWindowManager(true);
76 scoped_ptr<views::View> tray(CreateDetailedView());
77 EXPECT_TRUE(tray->visible());
78 Shell::GetInstance()->EnableMaximizeModeWindowManager(false);
81 // Tests that the enabling of MaximizeMode has no affect on the visibility of a
82 // previously created BrightnessView that belongs to a detailed view.
83 TEST_F(TrayBrightnessTest, DetailedViewVisibilityChangesDuringMaximizeMode) {
84 scoped_ptr<views::View> tray(CreateDetailedView());
85 Shell::GetInstance()->EnableMaximizeModeWindowManager(true);
86 EXPECT_TRUE(tray->visible());
87 Shell::GetInstance()->EnableMaximizeModeWindowManager(false);
88 EXPECT_TRUE(tray->visible());