Skip to content

Commit

Permalink
Fix Network Tile disabled drill-in button
Browse files Browse the repository at this point in the history
Create the drill-in button before the enabled state is set to reflect
disabled state.

Bug: b:269675008
Change-Id: I62d7c5efe4c295769a61d1cb66aca98910971a48
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4263358
Reviewed-by: Alex Newcomer <newcomer@chromium.org>
Commit-Queue: Kevin Radtke <kradtke@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1107108}
  • Loading branch information
Kevin Radtke authored and Chromium LUCI CQ committed Feb 18, 2023
1 parent f9d2617 commit 0211499
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
11 changes: 5 additions & 6 deletions ash/system/network/network_feature_pod_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,11 @@ std::unique_ptr<FeatureTile> NetworkFeaturePodController::CreateTile(
base::BindRepeating(&FeaturePodControllerBase::OnIconPressed,
weak_ptr_factory_.GetWeakPtr()));
tile_ = tile.get();
tile_->CreateDrillInButton(
base::BindRepeating(&FeaturePodControllerBase::OnLabelPressed,
weak_ptr_factory_.GetWeakPtr()),
l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_NETWORK_SETTINGS_TOOLTIP,
std::u16string()));
UpdateButtonStateIfExists();
TrackVisibilityUMA();
return tile;
Expand Down Expand Up @@ -320,12 +325,6 @@ void NetworkFeaturePodController::UpdateButtonStateIfExists() {
if (is_qs_revamp_enabled) {
tile_->SetLabel(ComputeButtonLabel(default_network));
tile_->SetSubLabel(ComputeButtonSubLabel(default_network));
if (!tile_->drill_in_button()) {
tile_->CreateDrillInButton(
base::BindRepeating(&FeaturePodControllerBase::OnLabelPressed,
weak_ptr_factory_.GetWeakPtr()),
tooltip);
}
if (!tile_->GetEnabled()) {
tile_->SetTooltipText(tooltip);
tile_->SetDrillInButtonTooltipText(tooltip);
Expand Down
13 changes: 9 additions & 4 deletions ash/system/network/network_feature_pod_controller_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,14 @@ class NetworkFeaturePodControllerTest
}

bool IsButtonEnabled() {
return IsQsRevampEnabled() ? feature_tile_->GetEnabled()
: feature_pod_button_->GetEnabled();
}

bool IsDiveInButtonEnabled() {
return IsQsRevampEnabled()
? feature_tile_->GetEnabled() &&
feature_tile_->drill_in_button()->GetEnabled()
: feature_pod_button_->GetEnabled() &&
feature_pod_button_->label_button()->GetEnabled();
? feature_tile_->drill_in_button()->GetEnabled()
: feature_pod_button_->label_button()->GetEnabled();
}

void SetButtonEnabled(bool enabled) {
Expand Down Expand Up @@ -484,8 +487,10 @@ TEST_P(NetworkFeaturePodControllerTest,

TEST_P(NetworkFeaturePodControllerTest, CannotBeModifiedWhenScreenIsLocked) {
EXPECT_TRUE(IsButtonEnabled());
EXPECT_TRUE(IsDiveInButtonEnabled());
LockScreen();
EXPECT_FALSE(IsButtonEnabled());
EXPECT_FALSE(IsDiveInButtonEnabled());
}

TEST_P(NetworkFeaturePodControllerTest,
Expand Down
2 changes: 1 addition & 1 deletion ash/system/unified/feature_tile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ FeatureTile::FeatureTile(base::RepeatingCallback<void()> callback,
enabled_changed_subscription_ = AddEnabledChangedCallback(base::BindRepeating(
[](FeatureTile* feature_tile) {
feature_tile->UpdateColors();
if (!feature_tile->drill_in_button()) {
if (!feature_tile->drill_in_button_) {
return;
}
feature_tile->drill_in_button_->SetEnabled(feature_tile->GetEnabled());
Expand Down

0 comments on commit 0211499

Please sign in to comment.