tray_brightness_unittest.cc revision a02191e04bc25c4935f804f2c080ae28663d096d
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 "ui/views/view.h" 13 14namespace ash { 15 16class TrayBrightnessTest : public test::AshTestBase { 17 public: 18 TrayBrightnessTest() {} 19 virtual ~TrayBrightnessTest() {} 20 21 protected: 22 views::View* CreateDefaultView() { 23 TrayBrightness tray(NULL); 24 return tray.CreateDefaultView( 25 StatusAreaWidgetTestHelper::GetUserLoginStatus()); 26 } 27 28 views::View* CreateDetailedView() { 29 TrayBrightness tray(NULL); 30 return tray.CreateDetailedView( 31 StatusAreaWidgetTestHelper::GetUserLoginStatus()); 32 } 33 34 private: 35 DISALLOW_COPY_AND_ASSIGN(TrayBrightnessTest); 36}; 37 38// Tests that when the default view is initially created, that its 39// BrightnessView is created not visible. 40TEST_F(TrayBrightnessTest, CreateDefaultView) { 41 scoped_ptr<views::View> tray(CreateDefaultView()); 42 EXPECT_FALSE(tray->visible()); 43} 44 45// Tests the construction of the default view while MaximizeMode is active. 46// The BrightnessView should be visible. 47TEST_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); 52} 53 54// Tests that the enabling of MaximizeMode affects a previously created 55// BrightnessView, changing the visibility. 56TEST_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()); 62} 63 64// Tests that when the detailed view is initially created that its 65// BrightnessView is created as visible. 66TEST_F(TrayBrightnessTest, CreateDetailedView) { 67 scoped_ptr<views::View> tray(CreateDetailedView()); 68 EXPECT_TRUE(tray->visible()); 69} 70 71 72// Tests that when the detailed view is created during MaximizeMode that its 73// BrightnessView is visible. 74TEST_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); 79} 80 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. 83TEST_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()); 89} 90 91} // namespace ash 92 93