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,8 +37,10 @@ FlagWarningTray::FlagWarningTray(Shelf* shelf) : shelf_(shelf) {
DCHECK(shelf_);
SetLayoutManager(std::make_unique<views::FillLayout>());
const bool is_mash = Shell::GetAshConfig() == Config::MASH;
if (is_mash) {
// 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.
DCHECK_EQ(Shell::GetAshConfig(), Config::MASH);
container_ = new TrayContainer(shelf);
AddChildView(container_);
......@@ -50,8 +52,7 @@ FlagWarningTray::FlagWarningTray(Shelf* shelf) : shelf_(shelf) {
button_->SetTooltipText(base::ASCIIToUTF16(kTooltipText));
UpdateButton();
container_->AddChildView(button_);
}
SetVisible(is_mash);
SetVisible(true);
}
FlagWarningTray::~FlagWarningTray() = default;
......
......@@ -16,18 +16,14 @@ namespace {
using FlagWarningTrayTest = AshTestBase;
TEST_F(FlagWarningTrayTest, Visibility) {
// Tray is always created.
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
// 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.
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
......
......@@ -5,6 +5,7 @@
#include "ash/system/status_area_widget.h"
#include "ash/public/cpp/ash_features.h"
#include "ash/public/cpp/config.h"
#include "ash/session/session_controller.h"
#include "ash/shelf/shelf.h"
#include "ash/shell.h"
......@@ -71,8 +72,13 @@ void StatusAreaWidget::Initialize() {
logout_button_tray_ = std::make_unique<LogoutButtonTray>(shelf_);
status_area_widget_delegate_->AddChildView(logout_button_tray_.get());
if (Shell::GetAshConfig() == ash::Config::MASH) {
// 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
// adding all of them.
......@@ -119,6 +125,7 @@ void StatusAreaWidget::UpdateAfterShelfAlignmentChange() {
ime_menu_tray_->UpdateAfterShelfAlignmentChange();
palette_tray_->UpdateAfterShelfAlignmentChange();
overview_button_tray_->UpdateAfterShelfAlignmentChange();
if (flag_warning_tray_)
flag_warning_tray_->UpdateAfterShelfAlignmentChange();
status_area_widget_delegate_->UpdateLayout();
}
......@@ -176,6 +183,7 @@ void StatusAreaWidget::SchedulePaint() {
ime_menu_tray_->SchedulePaint();
palette_tray_->SchedulePaint();
overview_button_tray_->SchedulePaint();
if (flag_warning_tray_)
flag_warning_tray_->SchedulePaint();
}
......
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