tray_brightness_unittest.cc revision 23730a6e56a168d1879203e4b3819bb36e3d8f1f
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 "ui/views/view.h" 12 13namespace ash { 14 15namespace { 16 17user::LoginStatus GetUserLoginStatus() { 18 return Shell::GetInstance()->system_tray_delegate()->GetUserLoginStatus(); 19} 20 21} // namespace 22 23namespace internal { 24 25class TrayBrightnessTest : public test::AshTestBase { 26 public: 27 TrayBrightnessTest() {} 28 virtual ~TrayBrightnessTest() {} 29 30 protected: 31 views::View* CreateDefaultView() { 32 TrayBrightness tray(NULL); 33 return tray.CreateDefaultView(GetUserLoginStatus()); 34 } 35 36 views::View* CreateDetailedView() { 37 TrayBrightness tray(NULL); 38 return tray.CreateDetailedView(GetUserLoginStatus()); 39 } 40 41 private: 42 DISALLOW_COPY_AND_ASSIGN(TrayBrightnessTest); 43}; 44 45// Tests that when the default view is initially created, that its 46// BrightnessView is created not visible. 47TEST_F(TrayBrightnessTest, CreateDefaultView) { 48 scoped_ptr<views::View> tray(CreateDefaultView()); 49 EXPECT_FALSE(tray->visible()); 50} 51 52// Tests the construction of the default view while MaximizeMode is active. 53// The BrightnessView should be visible. 54TEST_F(TrayBrightnessTest, CreateDefaultViewDuringMaximizeMode) { 55 Shell::GetInstance()->EnableMaximizeModeWindowManager(true); 56 scoped_ptr<views::View> tray(CreateDefaultView()); 57 EXPECT_TRUE(tray->visible()); 58 Shell::GetInstance()->EnableMaximizeModeWindowManager(false); 59} 60 61// Tests that the enabling of MaximizeMode affects a previously created 62// BrightnessView, changing the visibility. 63TEST_F(TrayBrightnessTest, DefaultViewVisibilityChangesDuringMaximizeMode) { 64 scoped_ptr<views::View> tray(CreateDefaultView()); 65 Shell::GetInstance()->EnableMaximizeModeWindowManager(true); 66 EXPECT_TRUE(tray->visible()); 67 Shell::GetInstance()->EnableMaximizeModeWindowManager(false); 68 EXPECT_FALSE(tray->visible()); 69} 70 71// Tests that when the detailed view is initially created that its 72// BrightnessView is created as visible. 73TEST_F(TrayBrightnessTest, CreateDetailedView) { 74 scoped_ptr<views::View> tray(CreateDetailedView()); 75 EXPECT_TRUE(tray->visible()); 76} 77 78 79// Tests that when the detailed view is created during MaximizeMode that its 80// BrightnessView is visible. 81TEST_F(TrayBrightnessTest, CreateDetailedViewDuringMaximizeMode) { 82 Shell::GetInstance()->EnableMaximizeModeWindowManager(true); 83 scoped_ptr<views::View> tray(CreateDetailedView()); 84 EXPECT_TRUE(tray->visible()); 85 Shell::GetInstance()->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()->EnableMaximizeModeWindowManager(true); 93 EXPECT_TRUE(tray->visible()); 94 Shell::GetInstance()->EnableMaximizeModeWindowManager(false); 95 EXPECT_TRUE(tray->visible()); 96} 97 98} // namespace internal 99 100} // namespace ash 101 102