123730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved.
223730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
323730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)// found in the LICENSE file.
423730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)
523730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)#include "ash/system/chromeos/brightness/tray_brightness.h"
623730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)
723730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)#include "ash/shell.h"
823730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)#include "ash/system/tray/system_tray_delegate.h"
923730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)#include "ash/system/tray/system_tray_item.h"
1023730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)#include "ash/test/ash_test_base.h"
11a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch#include "ash/test/status_area_widget_test_helper.h"
12f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)#include "ash/wm/maximize_mode/maximize_mode_controller.h"
1323730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)#include "ui/views/view.h"
1423730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)
1523730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)namespace ash {
1623730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)
1723730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)class TrayBrightnessTest : public test::AshTestBase {
1823730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) public:
1923730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  TrayBrightnessTest() {}
2023730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  virtual ~TrayBrightnessTest() {}
2123730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)
2223730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) protected:
2323730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  views::View* CreateDefaultView() {
2423730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)    TrayBrightness tray(NULL);
25a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch    return tray.CreateDefaultView(
26a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch        StatusAreaWidgetTestHelper::GetUserLoginStatus());
2723730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  }
2823730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)
2923730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  views::View* CreateDetailedView() {
3023730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)    TrayBrightness tray(NULL);
31a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch    return tray.CreateDetailedView(
32a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch        StatusAreaWidgetTestHelper::GetUserLoginStatus());
3323730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  }
3423730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)
3523730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) private:
3623730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(TrayBrightnessTest);
3723730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)};
3823730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)
3923730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)// Tests that when the default view is initially created, that its
4023730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)// BrightnessView is created not visible.
4123730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)TEST_F(TrayBrightnessTest, CreateDefaultView) {
4223730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  scoped_ptr<views::View> tray(CreateDefaultView());
4323730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  EXPECT_FALSE(tray->visible());
4423730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)}
4523730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)
4623730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)// Tests the construction of the default view while MaximizeMode is active.
4723730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)// The BrightnessView should be visible.
4823730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)TEST_F(TrayBrightnessTest, CreateDefaultViewDuringMaximizeMode) {
49f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)  Shell::GetInstance()->maximize_mode_controller()->
50f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)      EnableMaximizeModeWindowManager(true);
5123730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  scoped_ptr<views::View> tray(CreateDefaultView());
5223730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  EXPECT_TRUE(tray->visible());
53f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)  Shell::GetInstance()->maximize_mode_controller()->
54f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)      EnableMaximizeModeWindowManager(false);
5523730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)}
5623730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)
5723730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)// Tests that the enabling of MaximizeMode affects a previously created
5823730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)// BrightnessView, changing the visibility.
5923730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)TEST_F(TrayBrightnessTest, DefaultViewVisibilityChangesDuringMaximizeMode) {
6023730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  scoped_ptr<views::View> tray(CreateDefaultView());
61f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)  Shell::GetInstance()->maximize_mode_controller()->
62f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)      EnableMaximizeModeWindowManager(true);
6323730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  EXPECT_TRUE(tray->visible());
64f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)  Shell::GetInstance()->maximize_mode_controller()->
65f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)      EnableMaximizeModeWindowManager(false);
6623730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  EXPECT_FALSE(tray->visible());
6723730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)}
6823730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)
6923730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)// Tests that when the detailed view is initially created that its
7023730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)// BrightnessView is created as visible.
7123730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)TEST_F(TrayBrightnessTest, CreateDetailedView) {
7223730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  scoped_ptr<views::View> tray(CreateDetailedView());
7323730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  EXPECT_TRUE(tray->visible());
7423730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)}
7523730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)
7623730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)
7723730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)// Tests that when the detailed view is created during MaximizeMode that its
7823730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)// BrightnessView is visible.
7923730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)TEST_F(TrayBrightnessTest, CreateDetailedViewDuringMaximizeMode) {
80f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)  Shell::GetInstance()->maximize_mode_controller()->
81f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)      EnableMaximizeModeWindowManager(true);
8223730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  scoped_ptr<views::View> tray(CreateDetailedView());
8323730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  EXPECT_TRUE(tray->visible());
84f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)  Shell::GetInstance()->maximize_mode_controller()->
85f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)      EnableMaximizeModeWindowManager(false);
8623730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)}
8723730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)
8823730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)// Tests that the enabling of MaximizeMode has no affect on the visibility of a
8923730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)// previously created BrightnessView that belongs to a detailed view.
9023730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)TEST_F(TrayBrightnessTest, DetailedViewVisibilityChangesDuringMaximizeMode) {
9123730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  scoped_ptr<views::View> tray(CreateDetailedView());
92f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)  Shell::GetInstance()->maximize_mode_controller()->
93f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)      EnableMaximizeModeWindowManager(true);
9423730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  EXPECT_TRUE(tray->visible());
95f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)  Shell::GetInstance()->maximize_mode_controller()->
96f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)      EnableMaximizeModeWindowManager(false);
9723730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  EXPECT_TRUE(tray->visible());
9823730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)}
9923730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)
10023730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)}  // namespace ash
10123730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)
102