summaryrefslogtreecommitdiffstats
path: root/ash/system/chromeos/brightness/tray_brightness_unittest.cc
blob: 9f641db5ba54c45b3710dc22c72477aca7124b25 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ash/system/chromeos/brightness/tray_brightness.h"

#include "ash/shell.h"
#include "ash/system/tray/system_tray_delegate.h"
#include "ash/system/tray/system_tray_item.h"
#include "ash/test/ash_test_base.h"
#include "ash/test/status_area_widget_test_helper.h"
#include "ui/views/view.h"

namespace ash {

class TrayBrightnessTest : public test::AshTestBase {
 public:
  TrayBrightnessTest() {}
  virtual ~TrayBrightnessTest() {}

 protected:
  views::View* CreateDefaultView() {
    TrayBrightness tray(NULL);
    return tray.CreateDefaultView(
        StatusAreaWidgetTestHelper::GetUserLoginStatus());
  }

  views::View* CreateDetailedView() {
    TrayBrightness tray(NULL);
    return tray.CreateDetailedView(
        StatusAreaWidgetTestHelper::GetUserLoginStatus());
  }

 private:
  DISALLOW_COPY_AND_ASSIGN(TrayBrightnessTest);
};

// Tests that when the default view is initially created, that its
// BrightnessView is created not visible.
TEST_F(TrayBrightnessTest, CreateDefaultView) {
  scoped_ptr<views::View> tray(CreateDefaultView());
  EXPECT_FALSE(tray->visible());
}

// Tests the construction of the default view while MaximizeMode is active.
// The BrightnessView should be visible.
TEST_F(TrayBrightnessTest, CreateDefaultViewDuringMaximizeMode) {
  Shell::GetInstance()->EnableMaximizeModeWindowManager(true);
  scoped_ptr<views::View> tray(CreateDefaultView());
  EXPECT_TRUE(tray->visible());
  Shell::GetInstance()->EnableMaximizeModeWindowManager(false);
}

// Tests that the enabling of MaximizeMode affects a previously created
// BrightnessView, changing the visibility.
TEST_F(TrayBrightnessTest, DefaultViewVisibilityChangesDuringMaximizeMode) {
  scoped_ptr<views::View> tray(CreateDefaultView());
  Shell::GetInstance()->EnableMaximizeModeWindowManager(true);
  EXPECT_TRUE(tray->visible());
  Shell::GetInstance()->EnableMaximizeModeWindowManager(false);
  EXPECT_FALSE(tray->visible());
}

// Tests that when the detailed view is initially created that its
// BrightnessView is created as visible.
TEST_F(TrayBrightnessTest, CreateDetailedView) {
  scoped_ptr<views::View> tray(CreateDetailedView());
  EXPECT_TRUE(tray->visible());
}


// Tests that when the detailed view is created during MaximizeMode that its
// BrightnessView is visible.
TEST_F(TrayBrightnessTest, CreateDetailedViewDuringMaximizeMode) {
  Shell::GetInstance()->EnableMaximizeModeWindowManager(true);
  scoped_ptr<views::View> tray(CreateDetailedView());
  EXPECT_TRUE(tray->visible());
  Shell::GetInstance()->EnableMaximizeModeWindowManager(false);
}

// Tests that the enabling of MaximizeMode has no affect on the visibility of a
// previously created BrightnessView that belongs to a detailed view.
TEST_F(TrayBrightnessTest, DetailedViewVisibilityChangesDuringMaximizeMode) {
  scoped_ptr<views::View> tray(CreateDetailedView());
  Shell::GetInstance()->EnableMaximizeModeWindowManager(true);
  EXPECT_TRUE(tray->visible());
  Shell::GetInstance()->EnableMaximizeModeWindowManager(false);
  EXPECT_TRUE(tray->visible());
}

}  // namespace ash