Commit 431fdef2 authored by Aaron Leventhal's avatar Aaron Leventhal Committed by Commit Bot

Accessibility checks flag warning tray crash fix

Bug: 819350
Change-Id: I75abdd3988c0c6ff3e73e67bc8fdef30e05b6aae
Reviewed-on: https://chromium-review.googlesource.com/964246
Commit-Queue: Aaron Leventhal <aleventhal@chromium.org>
Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Cr-Commit-Position: refs/heads/master@{#544088}
parent fec6a27b
...@@ -37,21 +37,22 @@ FlagWarningTray::FlagWarningTray(Shelf* shelf) : shelf_(shelf) { ...@@ -37,21 +37,22 @@ FlagWarningTray::FlagWarningTray(Shelf* shelf) : shelf_(shelf) {
DCHECK(shelf_); DCHECK(shelf_);
SetLayoutManager(std::make_unique<views::FillLayout>()); SetLayoutManager(std::make_unique<views::FillLayout>());
const bool is_mash = Shell::GetAshConfig() == Config::MASH; // Flag warning tray is not currently used in non-MASH environments, because
if (is_mash) { // mus will roll out via experiment/Finch trial and showing the tray would
container_ = new TrayContainer(shelf); // reveal the experiment state to users.
AddChildView(container_); DCHECK_EQ(Shell::GetAshConfig(), Config::MASH);
container_ = new TrayContainer(shelf);
button_ = views::MdTextButton::Create(this, base::string16(), AddChildView(container_);
CONTEXT_LAUNCHER_BUTTON);
button_->SetProminent(true); button_ = views::MdTextButton::Create(this, base::string16(),
button_->SetBgColorOverride(gfx::kGoogleYellow300); CONTEXT_LAUNCHER_BUTTON);
button_->SetEnabledTextColors(SK_ColorBLACK); button_->SetProminent(true);
button_->SetTooltipText(base::ASCIIToUTF16(kTooltipText)); button_->SetBgColorOverride(gfx::kGoogleYellow300);
UpdateButton(); button_->SetEnabledTextColors(SK_ColorBLACK);
container_->AddChildView(button_); button_->SetTooltipText(base::ASCIIToUTF16(kTooltipText));
} UpdateButton();
SetVisible(is_mash); container_->AddChildView(button_);
SetVisible(true);
} }
FlagWarningTray::~FlagWarningTray() = default; FlagWarningTray::~FlagWarningTray() = default;
......
...@@ -16,18 +16,14 @@ namespace { ...@@ -16,18 +16,14 @@ namespace {
using FlagWarningTrayTest = AshTestBase; using FlagWarningTrayTest = AshTestBase;
TEST_F(FlagWarningTrayTest, Visibility) { TEST_F(FlagWarningTrayTest, Visibility) {
// Tray is always created. // Flag warning tray is not currently used in non-MASH environments, because
FlagWarningTray* tray = Shell::GetPrimaryRootWindowController()
->GetStatusAreaWidget()
->flag_warning_tray_for_testing();
ASSERT_TRUE(tray);
// Warning should be visible in ash_unittests when mash is enabled, but not in
// regular ash_unittests. The warning does not show for Config::MUS because
// mus will roll out via experiment/Finch trial and showing the tray would // mus will roll out via experiment/Finch trial and showing the tray would
// reveal the experiment state to users. // reveal the experiment state to users.
const bool is_mash = Shell::GetAshConfig() == Config::MASH; const bool is_mash = Shell::GetAshConfig() == Config::MASH;
EXPECT_EQ(tray->visible(), is_mash); FlagWarningTray* tray = Shell::GetPrimaryRootWindowController()
->GetStatusAreaWidget()
->flag_warning_tray_for_testing();
EXPECT_EQ(tray != nullptr, is_mash);
} }
} // namespace } // namespace
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "ash/system/status_area_widget.h" #include "ash/system/status_area_widget.h"
#include "ash/public/cpp/ash_features.h" #include "ash/public/cpp/ash_features.h"
#include "ash/public/cpp/config.h"
#include "ash/session/session_controller.h" #include "ash/session/session_controller.h"
#include "ash/shelf/shelf.h" #include "ash/shelf/shelf.h"
#include "ash/shell.h" #include "ash/shell.h"
...@@ -71,8 +72,13 @@ void StatusAreaWidget::Initialize() { ...@@ -71,8 +72,13 @@ void StatusAreaWidget::Initialize() {
logout_button_tray_ = std::make_unique<LogoutButtonTray>(shelf_); logout_button_tray_ = std::make_unique<LogoutButtonTray>(shelf_);
status_area_widget_delegate_->AddChildView(logout_button_tray_.get()); status_area_widget_delegate_->AddChildView(logout_button_tray_.get());
flag_warning_tray_ = std::make_unique<FlagWarningTray>(shelf_); if (Shell::GetAshConfig() == ash::Config::MASH) {
status_area_widget_delegate_->AddChildView(flag_warning_tray_.get()); // Flag warning tray is not currently used in non-MASH environments, because
// mus will roll out via experiment/Finch trial and showing the tray would
// reveal the experiment state to users.
flag_warning_tray_ = std::make_unique<FlagWarningTray>(shelf_);
status_area_widget_delegate_->AddChildView(flag_warning_tray_.get());
}
// The layout depends on the number of children, so build it once after // The layout depends on the number of children, so build it once after
// adding all of them. // adding all of them.
...@@ -119,7 +125,8 @@ void StatusAreaWidget::UpdateAfterShelfAlignmentChange() { ...@@ -119,7 +125,8 @@ void StatusAreaWidget::UpdateAfterShelfAlignmentChange() {
ime_menu_tray_->UpdateAfterShelfAlignmentChange(); ime_menu_tray_->UpdateAfterShelfAlignmentChange();
palette_tray_->UpdateAfterShelfAlignmentChange(); palette_tray_->UpdateAfterShelfAlignmentChange();
overview_button_tray_->UpdateAfterShelfAlignmentChange(); overview_button_tray_->UpdateAfterShelfAlignmentChange();
flag_warning_tray_->UpdateAfterShelfAlignmentChange(); if (flag_warning_tray_)
flag_warning_tray_->UpdateAfterShelfAlignmentChange();
status_area_widget_delegate_->UpdateLayout(); status_area_widget_delegate_->UpdateLayout();
} }
...@@ -176,7 +183,8 @@ void StatusAreaWidget::SchedulePaint() { ...@@ -176,7 +183,8 @@ void StatusAreaWidget::SchedulePaint() {
ime_menu_tray_->SchedulePaint(); ime_menu_tray_->SchedulePaint();
palette_tray_->SchedulePaint(); palette_tray_->SchedulePaint();
overview_button_tray_->SchedulePaint(); overview_button_tray_->SchedulePaint();
flag_warning_tray_->SchedulePaint(); if (flag_warning_tray_)
flag_warning_tray_->SchedulePaint();
} }
const ui::NativeTheme* StatusAreaWidget::GetNativeTheme() const { const ui::NativeTheme* StatusAreaWidget::GetNativeTheme() const {
......
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