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 "ash/shell.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" 14 15namespace ash { 16 17class TrayBrightnessTest : public test::AshTestBase { 18 public: 19 TrayBrightnessTest() {} 20 virtual ~TrayBrightnessTest() {} 21 22 protected: 23 views::View* CreateDefaultView() { 24 TrayBrightness tray(NULL); 25 return tray.CreateDefaultView( 26 StatusAreaWidgetTestHelper::GetUserLoginStatus()); 27 } 28 29 views::View* CreateDetailedView() { 30 TrayBrightness tray(NULL); 31 return tray.CreateDetailedView( 32 StatusAreaWidgetTestHelper::GetUserLoginStatus()); 33 } 34 35 private: 36 DISALLOW_COPY_AND_ASSIGN(TrayBrightnessTest); 37}; 38 39// Tests that when the default view is initially created, that its 40// BrightnessView is created not visible. 41TEST_F(TrayBrightnessTest, CreateDefaultView) { 42 scoped_ptr<views::View> tray(CreateDefaultView()); 43 EXPECT_FALSE(tray->visible()); 44} 45 46// Tests the construction of the default view while MaximizeMode is active. 47// The BrightnessView should be visible. 48TEST_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); 55} 56 57// Tests that the enabling of MaximizeMode affects a previously created 58// BrightnessView, changing the visibility. 59TEST_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()); 67} 68 69// Tests that when the detailed view is initially created that its 70// BrightnessView is created as visible. 71TEST_F(TrayBrightnessTest, CreateDetailedView) { 72 scoped_ptr<views::View> tray(CreateDetailedView()); 73 EXPECT_TRUE(tray->visible()); 74} 75 76 77// Tests that when the detailed view is created during MaximizeMode that its 78// BrightnessView is visible. 79TEST_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); 86} 87 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. 90TEST_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()); 98} 99 100} // namespace ash 101 102