Commit abe996a2 authored by yiyix's avatar yiyix Committed by Commit bot

Enable the brightness row to be visible at all times

Update the visibility of the the brightness row to be visible at all
time for Chrome OS MD; the visibility stays as it is for non-MD.

TEST=Tray_brightness_unittests in ash_unittests

BUG=631809

Review-Url: https://codereview.chromium.org/2329333002
Cr-Commit-Position: refs/heads/master@{#417975}
parent d7532546
...@@ -47,6 +47,9 @@ const double kMinBrightnessPercent = 5.0; ...@@ -47,6 +47,9 @@ const double kMinBrightnessPercent = 5.0;
} // namespace } // namespace
// TODO(yiyix|tdanderson): Once Chrome OS material design is enabled by default,
// BrightnessView does not need to be a ShellObserver to observe touch view mode
// changes. See crbug.com/614453.
class BrightnessView : public ShellObserver, class BrightnessView : public ShellObserver,
public views::View, public views::View,
public views::SliderListener { public views::SliderListener {
...@@ -123,11 +126,15 @@ BrightnessView::BrightnessView(bool default_view, double initial_percent) ...@@ -123,11 +126,15 @@ BrightnessView::BrightnessView(bool default_view, double initial_percent)
rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_BRIGHTNESS)); rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_BRIGHTNESS));
AddChildView(slider_); AddChildView(slider_);
if (is_default_view_) { if (MaterialDesignController::IsSystemTrayMenuMaterial()) {
WmShell::Get()->AddShellObserver(this); SetVisible(true);
SetVisible(WmShell::Get() } else {
->maximize_mode_controller() if (is_default_view_) {
->IsMaximizeModeWindowManagerEnabled()); WmShell::Get()->AddShellObserver(this);
SetVisible(WmShell::Get()
->maximize_mode_controller()
->IsMaximizeModeWindowManagerEnabled());
}
} }
} }
...@@ -143,11 +150,13 @@ void BrightnessView::SetBrightnessPercent(double percent) { ...@@ -143,11 +150,13 @@ void BrightnessView::SetBrightnessPercent(double percent) {
} }
void BrightnessView::OnMaximizeModeStarted() { void BrightnessView::OnMaximizeModeStarted() {
SetVisible(true); if (!MaterialDesignController::IsSystemTrayMenuMaterial())
SetVisible(true);
} }
void BrightnessView::OnMaximizeModeEnded() { void BrightnessView::OnMaximizeModeEnded() {
SetVisible(false); if (!MaterialDesignController::IsSystemTrayMenuMaterial())
SetVisible(false);
} }
void BrightnessView::OnBoundsChanged(const gfx::Rect& old_bounds) { void BrightnessView::OnBoundsChanged(const gfx::Rect& old_bounds) {
......
...@@ -39,14 +39,17 @@ class TrayBrightnessTest : public test::AshTestBase { ...@@ -39,14 +39,17 @@ class TrayBrightnessTest : public test::AshTestBase {
}; };
// Tests that when the default view is initially created, that its // Tests that when the default view is initially created, that its
// BrightnessView is created not visible. // BrightnessView is created not visible for non MD and visible for MD.
TEST_F(TrayBrightnessTest, CreateDefaultView) { TEST_F(TrayBrightnessTest, CreateDefaultView) {
std::unique_ptr<views::View> tray(CreateDefaultView()); std::unique_ptr<views::View> tray(CreateDefaultView());
EXPECT_FALSE(tray->visible()); if (ash::MaterialDesignController::IsSystemTrayMenuMaterial())
EXPECT_TRUE(tray->visible());
else
EXPECT_FALSE(tray->visible());
} }
// Tests the construction of the default view while MaximizeMode is active. // Tests the construction of the default view while MaximizeMode is active.
// The BrightnessView should be visible. // The BrightnessView should be visible for both modes non MD and MD.
TEST_F(TrayBrightnessTest, CreateDefaultViewDuringMaximizeMode) { TEST_F(TrayBrightnessTest, CreateDefaultViewDuringMaximizeMode) {
WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
true); true);
...@@ -56,8 +59,9 @@ TEST_F(TrayBrightnessTest, CreateDefaultViewDuringMaximizeMode) { ...@@ -56,8 +59,9 @@ TEST_F(TrayBrightnessTest, CreateDefaultViewDuringMaximizeMode) {
false); false);
} }
// Tests that the enabling of MaximizeMode affects a previously created // Tests that, when MD is not enabled, then the enabling of MaximizeMode
// BrightnessView, changing the visibility. // affects a previously created BrightnessView, changing the visibility; when MD
// is enabled, then the BrightnessView is visible regardless of the mode change.
TEST_F(TrayBrightnessTest, DefaultViewVisibilityChangesDuringMaximizeMode) { TEST_F(TrayBrightnessTest, DefaultViewVisibilityChangesDuringMaximizeMode) {
std::unique_ptr<views::View> tray(CreateDefaultView()); std::unique_ptr<views::View> tray(CreateDefaultView());
WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
...@@ -65,18 +69,21 @@ TEST_F(TrayBrightnessTest, DefaultViewVisibilityChangesDuringMaximizeMode) { ...@@ -65,18 +69,21 @@ TEST_F(TrayBrightnessTest, DefaultViewVisibilityChangesDuringMaximizeMode) {
EXPECT_TRUE(tray->visible()); EXPECT_TRUE(tray->visible());
WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
false); false);
EXPECT_FALSE(tray->visible()); if (ash::MaterialDesignController::IsSystemTrayMenuMaterial())
EXPECT_TRUE(tray->visible());
else
EXPECT_FALSE(tray->visible());
} }
// Tests that when the detailed view is initially created that its // Tests that when the detailed view is initially created that its
// BrightnessView is created as visible. // BrightnessView is created as visible for both MD and non MD modes.
TEST_F(TrayBrightnessTest, CreateDetailedView) { TEST_F(TrayBrightnessTest, CreateDetailedView) {
std::unique_ptr<views::View> tray(CreateDetailedView()); std::unique_ptr<views::View> tray(CreateDetailedView());
EXPECT_TRUE(tray->visible()); EXPECT_TRUE(tray->visible());
} }
// Tests that when the detailed view is created during MaximizeMode that its // Tests that when the detailed view is created during MaximizeMode that its
// BrightnessView is visible. // BrightnessView is visible for both MD and non MD modes.
TEST_F(TrayBrightnessTest, CreateDetailedViewDuringMaximizeMode) { TEST_F(TrayBrightnessTest, CreateDetailedViewDuringMaximizeMode) {
WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
true); true);
...@@ -87,7 +94,8 @@ TEST_F(TrayBrightnessTest, CreateDetailedViewDuringMaximizeMode) { ...@@ -87,7 +94,8 @@ TEST_F(TrayBrightnessTest, CreateDetailedViewDuringMaximizeMode) {
} }
// Tests that the enabling of MaximizeMode has no affect on the visibility of a // Tests that the enabling of MaximizeMode has no affect on the visibility of a
// previously created BrightnessView that belongs to a detailed view. // previously created BrightnessView that belongs to a detailed view for both MD
// and non MD modes.
TEST_F(TrayBrightnessTest, DetailedViewVisibilityChangesDuringMaximizeMode) { TEST_F(TrayBrightnessTest, DetailedViewVisibilityChangesDuringMaximizeMode) {
std::unique_ptr<views::View> tray(CreateDetailedView()); std::unique_ptr<views::View> tray(CreateDetailedView());
WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment