[CrOS Hotspot] Add hotspot feature tile
This CL adds the hotspot feature tile in quick settings. The feature tile should only be shown after user has been successfully started hotspot from OS Settings before. Screenshots: https://screenshot.googleplex.com/5HiE8YpvP4URUoC.png https://screenshot.googleplex.com/7NJRJiiRMHiRSdX.png https://screenshot.googleplex.com/B9P95oisJrMaTmP.png Bug: b/269353926 Change-Id: I96dbefc76c1ca286e561d72d103c192ca3446794 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4504776 Reviewed-by: James Cook <jamescook@chromium.org> Commit-Queue: Jason Zhang <jiajunz@google.com> Cr-Commit-Position: refs/heads/main@{#1141757}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
f6b77bd651
commit
d48957f281
ash
BUILD.gnash_strings.grd
ash_strings_grd
IDS_ASH_STATUS_TRAY_HOTSPOT.png.sha1IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_DRILL_IN_TOOLTIP_STATUS_OFF.png.sha1IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_DRILL_IN_TOOLTIP_STATUS_ON.png.sha1IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_TOOLTIP_MOBILE_DATA_NOT_SUPPORTED.png.sha1IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_TOOLTIP_NO_MOBILE_DATA.png.sha1IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_TOOLTIP_PROHIBITED_BY_POLICY.png.sha1IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_TOOLTIP_STATUS_DISABLING.png.sha1IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_TOOLTIP_STATUS_ENABLING.png.sha1IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_TOOLTIP_STATUS_OFF.png.sha1IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_TOOLTIP_STATUS_ON_MULTIPLE_DEVICES_CONNECTED.png.sha1IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_TOOLTIP_STATUS_ON_NO_DEVICE_CONNECTED.png.sha1IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_TOOLTIP_STATUS_ON_ONE_DEVICE_CONNECTED.png.sha1IDS_ASH_STATUS_TRAY_HOTSPOT_STATUS_DISABLING.png.sha1IDS_ASH_STATUS_TRAY_HOTSPOT_STATUS_ENABLING.png.sha1IDS_ASH_STATUS_TRAY_HOTSPOT_STATUS_OFF.png.sha1IDS_ASH_STATUS_TRAY_HOTSPOT_STATUS_ON.png.sha1
constants
resources
vector_icons
system
@ -1399,6 +1399,8 @@ component("ash") {
|
||||
"system/holding_space/screen_captures_section.h",
|
||||
"system/holding_space/suggestions_section.cc",
|
||||
"system/holding_space/suggestions_section.h",
|
||||
"system/hotspot/hotspot_feature_pod_controller.cc",
|
||||
"system/hotspot/hotspot_feature_pod_controller.h",
|
||||
"system/hotspot/hotspot_info_cache.cc",
|
||||
"system/hotspot/hotspot_info_cache.h",
|
||||
"system/hotspot/hotspot_tray_view.cc",
|
||||
@ -3245,6 +3247,7 @@ test("ash_unittests") {
|
||||
"system/holding_space/test_holding_space_item_views_section.h",
|
||||
"system/holding_space/test_holding_space_tray_child_bubble.cc",
|
||||
"system/holding_space/test_holding_space_tray_child_bubble.h",
|
||||
"system/hotspot/hotspot_feature_pod_controller_unittest.cc",
|
||||
"system/hotspot/hotspot_info_cache_unittest.cc",
|
||||
"system/hotspot/hotspot_tray_view_unittest.cc",
|
||||
"system/human_presence/human_presence_orientation_controller_unittest.cc",
|
||||
|
@ -2620,6 +2620,54 @@ Connect your device to power.
|
||||
<message name="IDS_ASH_STATUS_TRAY_ADD_CELLULAR_LABEL" desc="The label for button in network quick settings that allows user to add new cellular networks.">
|
||||
Add new cellular network
|
||||
</message>
|
||||
<message name="IDS_ASH_STATUS_TRAY_HOTSPOT" desc="The title for hotspot feature pod in quick settings.">
|
||||
Hotspot
|
||||
</message>
|
||||
<message name="IDS_ASH_STATUS_TRAY_HOTSPOT_STATUS_ON" desc="The sublabel for hotspot feature pod in quick settings to show hotspot is on.">
|
||||
On
|
||||
</message>
|
||||
<message name="IDS_ASH_STATUS_TRAY_HOTSPOT_STATUS_OFF" desc="The sublabel for hotspot feature pod in quick settings to show hotspot is off.">
|
||||
Off
|
||||
</message>
|
||||
<message name="IDS_ASH_STATUS_TRAY_HOTSPOT_STATUS_ENABLING" desc="The sublabel for hotspot feature pod in quick settings to show hotspot is enabling.">
|
||||
Enabling...
|
||||
</message>
|
||||
<message name="IDS_ASH_STATUS_TRAY_HOTSPOT_STATUS_DISABLING" desc="The sublabel for hotspot feature pod in quick settings to show hotspot is disabling.">
|
||||
Disabling...
|
||||
</message>
|
||||
<message name="IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_DRILL_IN_TOOLTIP_STATUS_ON" desc="The tooltip for the drill in button in hotspot feature tile of quick settings when hotspot is on.">
|
||||
Show hotspot details. Hotspot is on.
|
||||
</message>
|
||||
<message name="IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_TOOLTIP_STATUS_ENABLING" desc="The tooltip for the hotspot feature tile of quick settings when hotspot is enabling.">
|
||||
Show hotspot details. Hotspot is enabling.
|
||||
</message>
|
||||
<message name="IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_TOOLTIP_STATUS_DISABLING" desc="The tooltip for the hotspot feature tile of quick settings when hotspot is disabling.">
|
||||
Show hotspot details. Hotspot is disabling.
|
||||
</message>
|
||||
<message name="IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_DRILL_IN_TOOLTIP_STATUS_OFF" desc="The tooltip for the drill in button in hotspot feature tile of quick settings when hotspot is off and is not allowed to turn on.">
|
||||
Show hotspot details. Hotspot is off.
|
||||
</message>
|
||||
<message name="IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_TOOLTIP_STATUS_OFF" desc="The tooltip for the hotspot feature tile of quick settings when hotspot is off and is allowed to turn on.">
|
||||
Toggle Hotspot. Hotspot is off.
|
||||
</message>
|
||||
<message name="IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_TOOLTIP_STATUS_ON_NO_DEVICE_CONNECTED" desc="The tooltip for the hotspot feature tile of quick settings when hotspot is on and no device connected.">
|
||||
Toggle Hotspot. Hotspot is on, no device connected.
|
||||
</message>
|
||||
<message name="IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_TOOLTIP_STATUS_ON_ONE_DEVICE_CONNECTED" desc="The tooltip for the hotspot feature tile of quick settings when hotspot is on and one device connected.">
|
||||
Toggle Hotspot. Hotspot is on, 1 device connected.
|
||||
</message>
|
||||
<message name="IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_TOOLTIP_STATUS_ON_MULTIPLE_DEVICES_CONNECTED" desc="The tooltip for the hotspot feature tile of quick settings when hotspot is on and multiple devices connected.">
|
||||
Toggle Hotspot. Hotspot is on, <ph name="DEVICECOUNT">$1</ph> devices connected.
|
||||
</message>
|
||||
<message name="IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_TOOLTIP_NO_MOBILE_DATA" desc="The tooltip for the hotspot feature tile of quick settings when hotspot is off and not allowed to turn on due to no mobile data connection.">
|
||||
Show hotspot details. Connect to mobile network to use hotspot.
|
||||
</message>
|
||||
<message name="IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_TOOLTIP_MOBILE_DATA_NOT_SUPPORTED" desc="The tooltip for the hotspot feature tile of quick settings when hotspot is off and not allowed to turn on due to the connected mobile data doesn't support hotspot.">
|
||||
Show hotspot details. Your mobile network doesn't support hotspot.
|
||||
</message>
|
||||
<message name="IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_TOOLTIP_PROHIBITED_BY_POLICY" desc="The tooltip for the hotspot feature tile of quick settings when hotspot is off and is not allowed to turn on due to prohibited by policy.">
|
||||
Show hotspot details. Hotspot is blocked by your administrator.
|
||||
</message>
|
||||
<message name="IDS_ASH_STATUS_TRAY_BLUETOOTH_DISCOVERABLE" desc="Toast shown when a Bluetooth adapter is discoverable.">
|
||||
"<ph name="NAME">$1<ex>Chromebook</ex></ph>" visible to Bluetooth devices.
|
||||
</message>
|
||||
|
1
ash/ash_strings_grd/IDS_ASH_STATUS_TRAY_HOTSPOT.png.sha1
Normal file
1
ash/ash_strings_grd/IDS_ASH_STATUS_TRAY_HOTSPOT.png.sha1
Normal file
@ -0,0 +1 @@
|
||||
805f6f0303d2e5474bd4853e4a27be5dbf271a9a
|
1
ash/ash_strings_grd/IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_DRILL_IN_TOOLTIP_STATUS_OFF.png.sha1
Normal file
1
ash/ash_strings_grd/IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_DRILL_IN_TOOLTIP_STATUS_OFF.png.sha1
Normal file
@ -0,0 +1 @@
|
||||
3f8da8d5a5838b85691e803446da311087a1691c
|
1
ash/ash_strings_grd/IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_DRILL_IN_TOOLTIP_STATUS_ON.png.sha1
Normal file
1
ash/ash_strings_grd/IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_DRILL_IN_TOOLTIP_STATUS_ON.png.sha1
Normal file
@ -0,0 +1 @@
|
||||
0ced069eb87a2474be2f0bb6c679748f8147136f
|
1
ash/ash_strings_grd/IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_TOOLTIP_MOBILE_DATA_NOT_SUPPORTED.png.sha1
Normal file
1
ash/ash_strings_grd/IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_TOOLTIP_MOBILE_DATA_NOT_SUPPORTED.png.sha1
Normal file
@ -0,0 +1 @@
|
||||
68d748b013acef54cc2ba294633dd9ef4fd17481
|
1
ash/ash_strings_grd/IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_TOOLTIP_NO_MOBILE_DATA.png.sha1
Normal file
1
ash/ash_strings_grd/IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_TOOLTIP_NO_MOBILE_DATA.png.sha1
Normal file
@ -0,0 +1 @@
|
||||
bab9eb97c88e6f3d19c96469f030664990c2c420
|
1
ash/ash_strings_grd/IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_TOOLTIP_PROHIBITED_BY_POLICY.png.sha1
Normal file
1
ash/ash_strings_grd/IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_TOOLTIP_PROHIBITED_BY_POLICY.png.sha1
Normal file
@ -0,0 +1 @@
|
||||
b79e5844c0d512d5ef0112f54869fb060b5eb892
|
1
ash/ash_strings_grd/IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_TOOLTIP_STATUS_DISABLING.png.sha1
Normal file
1
ash/ash_strings_grd/IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_TOOLTIP_STATUS_DISABLING.png.sha1
Normal file
@ -0,0 +1 @@
|
||||
dbe1d97dc41ad169a9e099ad49b4e7f5247fa292
|
1
ash/ash_strings_grd/IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_TOOLTIP_STATUS_ENABLING.png.sha1
Normal file
1
ash/ash_strings_grd/IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_TOOLTIP_STATUS_ENABLING.png.sha1
Normal file
@ -0,0 +1 @@
|
||||
2e5dfc85a9f4002669b2041b65140eea7271c3e5
|
1
ash/ash_strings_grd/IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_TOOLTIP_STATUS_OFF.png.sha1
Normal file
1
ash/ash_strings_grd/IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_TOOLTIP_STATUS_OFF.png.sha1
Normal file
@ -0,0 +1 @@
|
||||
64b741721332364c5d2a5d951898933993fcdda7
|
1
ash/ash_strings_grd/IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_TOOLTIP_STATUS_ON_MULTIPLE_DEVICES_CONNECTED.png.sha1
Normal file
1
ash/ash_strings_grd/IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_TOOLTIP_STATUS_ON_MULTIPLE_DEVICES_CONNECTED.png.sha1
Normal file
@ -0,0 +1 @@
|
||||
6c134e3c9cb6714996a0d2794300c1bb095e0a39
|
1
ash/ash_strings_grd/IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_TOOLTIP_STATUS_ON_NO_DEVICE_CONNECTED.png.sha1
Normal file
1
ash/ash_strings_grd/IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_TOOLTIP_STATUS_ON_NO_DEVICE_CONNECTED.png.sha1
Normal file
@ -0,0 +1 @@
|
||||
bf72ac7d49653af5475f0ce49f7d3c83574e57e0
|
1
ash/ash_strings_grd/IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_TOOLTIP_STATUS_ON_ONE_DEVICE_CONNECTED.png.sha1
Normal file
1
ash/ash_strings_grd/IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_TOOLTIP_STATUS_ON_ONE_DEVICE_CONNECTED.png.sha1
Normal file
@ -0,0 +1 @@
|
||||
c4b92a5cb8784878a33c00417d1405629269b920
|
@ -0,0 +1 @@
|
||||
2a7c4d18feedf1a0c2c5744da0ebcc4a4ae72647
|
@ -0,0 +1 @@
|
||||
4a653bbafadb77d633f8274f05b828bd2af9e503
|
@ -0,0 +1 @@
|
||||
22332dda6e896afa04ab597dff58f771a4a6ce96
|
@ -0,0 +1 @@
|
||||
027c83cd556ad929f1415493944b1b97c64d67c5
|
@ -58,7 +58,8 @@ enum class QsFeatureCatalogName {
|
||||
kDarkMode = 14,
|
||||
kShelfParty = 15,
|
||||
kAutozoom = 16,
|
||||
kMaxValue = kAutozoom
|
||||
kHotspot = 17,
|
||||
kMaxValue = kHotspot
|
||||
};
|
||||
|
||||
// A catalog that registers all the sliders on the Quick Settings page (also
|
||||
|
@ -115,6 +115,7 @@ aggregate_vector_icons("ash_vector_icons") {
|
||||
"holding_space_download.icon",
|
||||
"holding_space_refresh.icon",
|
||||
"hollow_check_circle.icon",
|
||||
"hotspot_off.icon",
|
||||
"hotspot_on.icon",
|
||||
"ime_menu_emoticon.icon",
|
||||
"ime_menu_microphone.icon",
|
||||
|
50
ash/resources/vector_icons/hotspot_off.icon
Normal file
50
ash/resources/vector_icons/hotspot_off.icon
Normal file
@ -0,0 +1,50 @@
|
||||
// Copyright 2023 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
CANVAS_DIMENSIONS, 20,
|
||||
MOVE_TO, 3.18f, 2,
|
||||
LINE_TO, 2, 3.18f,
|
||||
LINE_TO, 4.24f, 5.42f,
|
||||
CUBIC_TO, 3.16f, 6.83f, 2.51f, 8.58f, 2.51f, 10.49f,
|
||||
CUBIC_TO, 2.51f, 12.79f, 3.44f, 14.88f, 4.95f, 16.38f,
|
||||
LINE_TO, 6.13f, 15.2f,
|
||||
CUBIC_TO, 4.93f, 14, 4.18f, 12.33f, 4.18f, 10.49f,
|
||||
CUBIC_TO, 4.18f, 9.03f, 4.65f, 7.7f, 5.43f, 6.61f,
|
||||
LINE_TO, 6.63f, 7.8f,
|
||||
CUBIC_TO, 6.13f, 8.57f, 5.84f, 9.5f, 5.84f, 10.49f,
|
||||
CUBIC_TO, 5.84f, 11.88f, 6.41f, 13.12f, 7.31f, 14.03f,
|
||||
LINE_TO, 8.49f, 12.84f,
|
||||
CUBIC_TO, 7.88f, 12.24f, 7.51f, 11.42f, 7.51f, 10.49f,
|
||||
CUBIC_TO, 7.51f, 9.97f, 7.63f, 9.47f, 7.85f, 9.03f,
|
||||
LINE_TO, 9.19f, 10.37f,
|
||||
CUBIC_TO, 9.19f, 10.39f, 9.19f, 10.41f, 9.18f, 10.43f,
|
||||
CUBIC_TO, 9.18f, 10.45f, 9.18f, 10.47f, 9.18f, 10.49f,
|
||||
CUBIC_TO, 9.18f, 10.95f, 9.37f, 11.37f, 9.67f, 11.67f,
|
||||
CUBIC_TO, 9.97f, 11.97f, 10.38f, 12.16f, 10.84f, 12.16f,
|
||||
CUBIC_TO, 10.88f, 12.16f, 10.91f, 12.15f, 10.95f, 12.15f,
|
||||
LINE_TO, 10.98f, 12.14f,
|
||||
LINE_TO, 17.33f, 18.49f,
|
||||
LINE_TO, 18.5f, 17.32f,
|
||||
LINE_TO, 3.18f, 2,
|
||||
CLOSE,
|
||||
MOVE_TO, 15.59f, 12.05f,
|
||||
CUBIC_TO, 15.75f, 11.56f, 15.84f, 11.03f, 15.84f, 10.49f,
|
||||
CUBIC_TO, 15.84f, 7.73f, 13.6f, 5.49f, 10.84f, 5.49f,
|
||||
CUBIC_TO, 10.3f, 5.49f, 9.78f, 5.58f, 9.28f, 5.74f,
|
||||
LINE_TO, 10.71f, 7.17f,
|
||||
CUBIC_TO, 10.75f, 7.16f, 10.8f, 7.16f, 10.84f, 7.16f,
|
||||
CUBIC_TO, 12.68f, 7.16f, 14.18f, 8.65f, 14.18f, 10.49f,
|
||||
CUBIC_TO, 14.18f, 10.53f, 14.18f, 10.58f, 14.17f, 10.63f,
|
||||
LINE_TO, 15.59f, 12.05f,
|
||||
CLOSE,
|
||||
MOVE_TO, 17.51f, 10.49f,
|
||||
CUBIC_TO, 17.51f, 6.81f, 14.53f, 3.83f, 10.84f, 3.83f,
|
||||
CUBIC_TO, 9.82f, 3.83f, 8.87f, 4.05f, 8, 4.46f,
|
||||
LINE_TO, 6.77f, 3.23f,
|
||||
CUBIC_TO, 7.98f, 2.54f, 9.36f, 2.16f, 10.84f, 2.16f,
|
||||
CUBIC_TO, 15.44f, 2.16f, 19.18f, 5.89f, 19.18f, 10.49f,
|
||||
CUBIC_TO, 19.18f, 11.98f, 18.78f, 13.37f, 18.11f, 14.57f,
|
||||
LINE_TO, 16.87f, 13.33f,
|
||||
CUBIC_TO, 17.28f, 12.47f, 17.51f, 11.51f, 17.51f, 10.49f,
|
||||
CLOSE
|
238
ash/system/hotspot/hotspot_feature_pod_controller.cc
Normal file
238
ash/system/hotspot/hotspot_feature_pod_controller.cc
Normal file
@ -0,0 +1,238 @@
|
||||
// Copyright 2023 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "ash/system/hotspot/hotspot_feature_pod_controller.h"
|
||||
|
||||
#include "ash/constants/ash_features.h"
|
||||
#include "ash/public/cpp/hotspot_config_service.h"
|
||||
#include "ash/resources/vector_icons/vector_icons.h"
|
||||
#include "ash/shell.h"
|
||||
#include "ash/strings/grit/ash_strings.h"
|
||||
#include "ash/system/hotspot/hotspot_info_cache.h"
|
||||
#include "ash/system/unified/feature_tile.h"
|
||||
#include "ash/system/unified/unified_system_tray_controller.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
|
||||
namespace ash {
|
||||
|
||||
using hotspot_config::mojom::HotspotAllowStatus;
|
||||
using hotspot_config::mojom::HotspotControlResult;
|
||||
using hotspot_config::mojom::HotspotInfo;
|
||||
using hotspot_config::mojom::HotspotInfoPtr;
|
||||
using hotspot_config::mojom::HotspotState;
|
||||
|
||||
HotspotFeaturePodController::HotspotFeaturePodController(
|
||||
UnifiedSystemTrayController* tray_controller)
|
||||
: hotspot_info_(Shell::Get()->hotspot_info_cache()->GetHotspotInfo()),
|
||||
tray_controller_(tray_controller) {
|
||||
DCHECK(features::IsQsRevampEnabled());
|
||||
DCHECK(features::IsHotspotEnabled());
|
||||
GetHotspotConfigService(
|
||||
remote_cros_hotspot_config_.BindNewPipeAndPassReceiver());
|
||||
remote_cros_hotspot_config_->AddObserver(
|
||||
hotspot_config_observer_receiver_.BindNewPipeAndPassRemote());
|
||||
}
|
||||
|
||||
HotspotFeaturePodController::~HotspotFeaturePodController() = default;
|
||||
|
||||
FeaturePodButton* HotspotFeaturePodController::CreateButton() {
|
||||
NOTREACHED();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::unique_ptr<FeatureTile> HotspotFeaturePodController::CreateTile(
|
||||
bool compact) {
|
||||
auto tile = std::make_unique<FeatureTile>(
|
||||
base::BindRepeating(&HotspotFeaturePodController::OnIconPressed,
|
||||
weak_ptr_factory_.GetWeakPtr()));
|
||||
tile_ = tile.get();
|
||||
tile_->CreateDrillInButton(
|
||||
base::BindRepeating(&HotspotFeaturePodController::OnLabelPressed,
|
||||
weak_ptr_factory_.GetWeakPtr()),
|
||||
l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_HOTSPOT));
|
||||
tile_->SetLabel(l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_HOTSPOT));
|
||||
|
||||
// Default the visibility to false and update it in `UpdateTileState()` since
|
||||
// it should only be shown if user has used the Hotspot from Settings before.
|
||||
tile_->SetVisible(false);
|
||||
UpdateTileState();
|
||||
return tile;
|
||||
}
|
||||
|
||||
QsFeatureCatalogName HotspotFeaturePodController::GetCatalogName() {
|
||||
return QsFeatureCatalogName::kHotspot;
|
||||
}
|
||||
|
||||
void HotspotFeaturePodController::OnIconPressed() {
|
||||
if (!tile_->GetEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (hotspot_info_->state == HotspotState::kEnabled) {
|
||||
remote_cros_hotspot_config_->DisableHotspot(base::BindOnce(
|
||||
&HotspotFeaturePodController::TrackToggleHotspotUMA,
|
||||
weak_ptr_factory_.GetWeakPtr(), /*target_toggle_state=*/false));
|
||||
return;
|
||||
}
|
||||
|
||||
EnableHotspotIfAllowedAndDiveIn();
|
||||
}
|
||||
|
||||
void HotspotFeaturePodController::OnLabelPressed() {
|
||||
if (!tile_->GetEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
EnableHotspotIfAllowedAndDiveIn();
|
||||
}
|
||||
|
||||
void HotspotFeaturePodController::OnHotspotInfoChanged() {
|
||||
remote_cros_hotspot_config_->GetHotspotInfo(
|
||||
base::BindOnce(&HotspotFeaturePodController::OnGetHotspotInfo,
|
||||
weak_ptr_factory_.GetWeakPtr()));
|
||||
}
|
||||
|
||||
void HotspotFeaturePodController::OnGetHotspotInfo(
|
||||
HotspotInfoPtr hotspot_info) {
|
||||
hotspot_info_ = std::move(hotspot_info);
|
||||
|
||||
UpdateTileState();
|
||||
}
|
||||
|
||||
void HotspotFeaturePodController::UpdateTileState() {
|
||||
if (!tile_) {
|
||||
return;
|
||||
}
|
||||
if (!Shell::Get()->hotspot_info_cache()->HasHotspotUsedBefore()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If the tile's visibility changes from invisible to visible, log its
|
||||
// visibility.
|
||||
if (!tile_->GetVisible()) {
|
||||
TrackVisibilityUMA();
|
||||
}
|
||||
|
||||
tile_->SetVisible(true);
|
||||
tile_->SetEnabled(true);
|
||||
tile_->SetToggled(hotspot_info_->state != HotspotState::kDisabled);
|
||||
tile_->SetVectorIcon(ComputeIcon());
|
||||
tile_->SetSubLabel(ComputeSublabel());
|
||||
tile_->SetTooltipText(ComputeTooltip());
|
||||
tile_->SetDrillInButtonTooltipText(ComputeDrillInTooltip());
|
||||
}
|
||||
|
||||
void HotspotFeaturePodController::EnableHotspotIfAllowedAndDiveIn() {
|
||||
if (hotspot_info_->state == HotspotState::kDisabled &&
|
||||
hotspot_info_->allow_status == HotspotAllowStatus::kAllowed) {
|
||||
remote_cros_hotspot_config_->EnableHotspot(base::BindOnce(
|
||||
&HotspotFeaturePodController::TrackToggleHotspotUMA,
|
||||
weak_ptr_factory_.GetWeakPtr(), /*target_toggle_state=*/true));
|
||||
}
|
||||
|
||||
TrackDiveInUMA();
|
||||
// TODO(b/274154971): Show hotspot detailed view when
|
||||
// HotspotDetailedViewController is added.
|
||||
}
|
||||
|
||||
void HotspotFeaturePodController::TrackToggleHotspotUMA(
|
||||
bool target_toggle_state,
|
||||
HotspotControlResult operation_result) {
|
||||
TrackToggleUMA(/*target_toggle_state=*/target_toggle_state);
|
||||
}
|
||||
|
||||
const gfx::VectorIcon& HotspotFeaturePodController::ComputeIcon() const {
|
||||
return tile_->IsToggled() ? kHotspotOnIcon : kHotspotOffIcon;
|
||||
}
|
||||
|
||||
std::u16string HotspotFeaturePodController::ComputeSublabel() const {
|
||||
using l10n_util::GetStringUTF16;
|
||||
|
||||
switch (hotspot_info_->state) {
|
||||
case HotspotState::kEnabled:
|
||||
return GetStringUTF16(IDS_ASH_STATUS_TRAY_HOTSPOT_STATUS_ON);
|
||||
case HotspotState::kEnabling:
|
||||
return GetStringUTF16(IDS_ASH_STATUS_TRAY_HOTSPOT_STATUS_ENABLING);
|
||||
case HotspotState::kDisabling:
|
||||
return GetStringUTF16(IDS_ASH_STATUS_TRAY_HOTSPOT_STATUS_DISABLING);
|
||||
case HotspotState::kDisabled:
|
||||
return GetStringUTF16(IDS_ASH_STATUS_TRAY_HOTSPOT_STATUS_OFF);
|
||||
}
|
||||
}
|
||||
|
||||
std::u16string HotspotFeaturePodController::ComputeTooltip() const {
|
||||
switch (hotspot_info_->state) {
|
||||
case HotspotState::kEnabled: {
|
||||
// Toggle hotspot. Hotspot is on, # devices connected.
|
||||
uint32_t client_count = hotspot_info_->client_count;
|
||||
if (client_count == 0) {
|
||||
return l10n_util::GetStringUTF16(
|
||||
IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_TOOLTIP_STATUS_ON_NO_DEVICE_CONNECTED);
|
||||
}
|
||||
if (client_count == 1) {
|
||||
return l10n_util::GetStringUTF16(
|
||||
IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_TOOLTIP_STATUS_ON_ONE_DEVICE_CONNECTED);
|
||||
}
|
||||
return l10n_util::GetStringFUTF16(
|
||||
IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_TOOLTIP_STATUS_ON_MULTIPLE_DEVICES_CONNECTED,
|
||||
base::NumberToString16(client_count));
|
||||
}
|
||||
case HotspotState::kEnabling:
|
||||
// Show hotspot details. Hotspot is enabling.
|
||||
return l10n_util::GetStringUTF16(
|
||||
IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_TOOLTIP_STATUS_ENABLING);
|
||||
case HotspotState::kDisabling:
|
||||
// Show hotspot details. Hotspot is disabling.
|
||||
return l10n_util::GetStringUTF16(
|
||||
IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_TOOLTIP_STATUS_DISABLING);
|
||||
case HotspotState::kDisabled:
|
||||
// Show hotspot details. Connect to mobile data to use hotspot.
|
||||
if (hotspot_info_->allow_status ==
|
||||
HotspotAllowStatus::kDisallowedNoMobileData) {
|
||||
return l10n_util::GetStringUTF16(
|
||||
IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_TOOLTIP_NO_MOBILE_DATA);
|
||||
}
|
||||
// Show hotspot details. Your mobile data doesn't support hotspot.
|
||||
if (hotspot_info_->allow_status ==
|
||||
HotspotAllowStatus::kDisallowedReadinessCheckFail) {
|
||||
return l10n_util::GetStringUTF16(
|
||||
IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_TOOLTIP_MOBILE_DATA_NOT_SUPPORTED);
|
||||
}
|
||||
// Show hotspot details. Hotspot is blocked by your administrator.
|
||||
if (hotspot_info_->allow_status ==
|
||||
HotspotAllowStatus::kDisallowedByPolicy) {
|
||||
return l10n_util::GetStringUTF16(
|
||||
IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_TOOLTIP_PROHIBITED_BY_POLICY);
|
||||
}
|
||||
// Toggle hotspot. Hotspot is off.
|
||||
return l10n_util::GetStringUTF16(
|
||||
IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_TOOLTIP_STATUS_OFF);
|
||||
}
|
||||
}
|
||||
|
||||
std::u16string HotspotFeaturePodController::ComputeDrillInTooltip() const {
|
||||
switch (hotspot_info_->state) {
|
||||
case HotspotState::kEnabled:
|
||||
// Show hotspot details. Hotspot is on.
|
||||
return l10n_util::GetStringUTF16(
|
||||
IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_DRILL_IN_TOOLTIP_STATUS_ON);
|
||||
case HotspotState::kEnabling:
|
||||
return l10n_util::GetStringUTF16(
|
||||
IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_TOOLTIP_STATUS_ENABLING);
|
||||
case HotspotState::kDisabling:
|
||||
return l10n_util::GetStringUTF16(
|
||||
IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_TOOLTIP_STATUS_DISABLING);
|
||||
case HotspotState::kDisabled:
|
||||
if (hotspot_info_->allow_status == HotspotAllowStatus::kAllowed) {
|
||||
// Toggle hotspot. Hotspot is off.
|
||||
return l10n_util::GetStringUTF16(
|
||||
IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_TOOLTIP_STATUS_OFF);
|
||||
}
|
||||
// Show hotspot details. Hotspot is off.
|
||||
return l10n_util::GetStringUTF16(
|
||||
IDS_ASH_STATUS_TRAY_HOTSPOT_FEATURE_TILE_DRILL_IN_TOOLTIP_STATUS_OFF);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ash
|
81
ash/system/hotspot/hotspot_feature_pod_controller.h
Normal file
81
ash/system/hotspot/hotspot_feature_pod_controller.h
Normal file
@ -0,0 +1,81 @@
|
||||
// Copyright 2023 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ASH_SYSTEM_HOTSPOT_HOTSPOT_FEATURE_POD_CONTROLLER_H_
|
||||
#define ASH_SYSTEM_HOTSPOT_HOTSPOT_FEATURE_POD_CONTROLLER_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "ash/ash_export.h"
|
||||
#include "ash/constants/quick_settings_catalogs.h"
|
||||
#include "ash/system/unified/feature_pod_controller_base.h"
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "chromeos/ash/services/hotspot_config/public/mojom/cros_hotspot_config.mojom.h"
|
||||
#include "mojo/public/cpp/bindings/receiver.h"
|
||||
#include "mojo/public/cpp/bindings/remote.h"
|
||||
|
||||
namespace gfx {
|
||||
struct VectorIcon;
|
||||
} // namespace gfx
|
||||
|
||||
namespace ash {
|
||||
|
||||
class UnifiedSystemTrayController;
|
||||
|
||||
// Controller of the feature tile button that allows users to toggle whether
|
||||
// Hotspot is enabled or disabled, and also allows users to navigate to a more
|
||||
// detailed page with a Hotspot info.
|
||||
class ASH_EXPORT HotspotFeaturePodController
|
||||
: public FeaturePodControllerBase,
|
||||
public hotspot_config::mojom::CrosHotspotConfigObserver {
|
||||
public:
|
||||
explicit HotspotFeaturePodController(
|
||||
UnifiedSystemTrayController* tray_controller);
|
||||
HotspotFeaturePodController(const HotspotFeaturePodController&) = delete;
|
||||
HotspotFeaturePodController& operator=(const HotspotFeaturePodController&) =
|
||||
delete;
|
||||
~HotspotFeaturePodController() override;
|
||||
|
||||
// FeaturePodControllerBase:
|
||||
FeaturePodButton* CreateButton() override;
|
||||
std::unique_ptr<FeatureTile> CreateTile(bool compact = false) override;
|
||||
QsFeatureCatalogName GetCatalogName() override;
|
||||
void OnIconPressed() override;
|
||||
void OnLabelPressed() override;
|
||||
|
||||
private:
|
||||
// mojom::CrosHotspotConfigObserver:
|
||||
void OnHotspotInfoChanged() override;
|
||||
|
||||
void OnGetHotspotInfo(hotspot_config::mojom::HotspotInfoPtr hotspot_info);
|
||||
void UpdateTileState();
|
||||
// Enable the hotspot if it is allowed and then show hotspot detailed page.
|
||||
void EnableHotspotIfAllowedAndDiveIn();
|
||||
void TrackToggleHotspotUMA(
|
||||
bool target_toggle_state,
|
||||
hotspot_config::mojom::HotspotControlResult operation_result);
|
||||
const gfx::VectorIcon& ComputeIcon() const;
|
||||
std::u16string ComputeSublabel() const;
|
||||
std::u16string ComputeTooltip() const;
|
||||
std::u16string ComputeDrillInTooltip() const;
|
||||
|
||||
mojo::Remote<hotspot_config::mojom::CrosHotspotConfig>
|
||||
remote_cros_hotspot_config_;
|
||||
mojo::Receiver<hotspot_config::mojom::CrosHotspotConfigObserver>
|
||||
hotspot_config_observer_receiver_{this};
|
||||
|
||||
hotspot_config::mojom::HotspotInfoPtr hotspot_info_;
|
||||
|
||||
// Owned by views hierarchy.
|
||||
raw_ptr<FeatureTile, ExperimentalAsh> tile_ = nullptr;
|
||||
|
||||
raw_ptr<UnifiedSystemTrayController, ExperimentalAsh> tray_controller_;
|
||||
|
||||
base::WeakPtrFactory<HotspotFeaturePodController> weak_ptr_factory_{this};
|
||||
};
|
||||
|
||||
} // namespace ash
|
||||
|
||||
#endif // ASH_SYSTEM_HOTSPOT_HOTSPOT_FEATURE_POD_CONTROLLER_H_
|
323
ash/system/hotspot/hotspot_feature_pod_controller_unittest.cc
Normal file
323
ash/system/hotspot/hotspot_feature_pod_controller_unittest.cc
Normal file
@ -0,0 +1,323 @@
|
||||
// Copyright 2023 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "ash/system/hotspot/hotspot_feature_pod_controller.h"
|
||||
|
||||
#include "ash/constants/ash_features.h"
|
||||
#include "ash/constants/quick_settings_catalogs.h"
|
||||
#include "ash/strings/grit/ash_strings.h"
|
||||
#include "ash/system/unified/feature_tile.h"
|
||||
#include "ash/system/unified/unified_system_tray.h"
|
||||
#include "ash/system/unified/unified_system_tray_bubble.h"
|
||||
#include "ash/system/unified/unified_system_tray_controller.h"
|
||||
#include "ash/test/ash_test_base.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/test/metrics/histogram_tester.h"
|
||||
#include "base/test/scoped_feature_list.h"
|
||||
#include "chromeos/ash/services/hotspot_config/public/cpp/cros_hotspot_config_test_helper.h"
|
||||
#include "chromeos/ash/services/hotspot_config/public/mojom/cros_hotspot_config.mojom.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
|
||||
namespace ash {
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr char kToggledOnHistogram[] = "Ash.QuickSettings.FeaturePod.ToggledOn";
|
||||
constexpr char kToggledOffHistogram[] =
|
||||
"Ash.QuickSettings.FeaturePod.ToggledOff";
|
||||
constexpr char kDiveInHistogram[] = "Ash.QuickSettings.FeaturePod.DiveIn";
|
||||
|
||||
} // namespace
|
||||
|
||||
using hotspot_config::mojom::HotspotAllowStatus;
|
||||
using hotspot_config::mojom::HotspotInfo;
|
||||
using hotspot_config::mojom::HotspotState;
|
||||
|
||||
class HotspotFeaturePodControllerTest : public AshTestBase {
|
||||
public:
|
||||
HotspotFeaturePodControllerTest() = default;
|
||||
~HotspotFeaturePodControllerTest() override = default;
|
||||
|
||||
void SetUp() override {
|
||||
scoped_feature_list_.InitWithFeatures(
|
||||
{features::kHotspot, features::kQsRevamp}, {});
|
||||
cros_hotspot_config_test_helper_ =
|
||||
std::make_unique<hotspot_config::CrosHotspotConfigTestHelper>(
|
||||
/*use_fake_implementation=*/true);
|
||||
AshTestBase::SetUp();
|
||||
|
||||
// Spin the runloop to have HotspotInfoCache finish querying the hotspot
|
||||
// info.
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
GetPrimaryUnifiedSystemTray()->ShowBubble();
|
||||
|
||||
hotspot_feature_pod_controller_ =
|
||||
std::make_unique<HotspotFeaturePodController>(
|
||||
GetPrimaryUnifiedSystemTray()
|
||||
->bubble()
|
||||
->unified_system_tray_controller());
|
||||
hotspot_feature_tile_ = hotspot_feature_pod_controller_->CreateTile();
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
hotspot_feature_tile_.reset();
|
||||
hotspot_feature_pod_controller_.reset();
|
||||
AshTestBase::TearDown();
|
||||
|
||||
cros_hotspot_config_test_helper_.reset();
|
||||
}
|
||||
|
||||
void UpdateHotspotInfo(HotspotState state,
|
||||
HotspotAllowStatus allow_status,
|
||||
uint32_t client_count = 0) {
|
||||
auto hotspot_info = HotspotInfo::New();
|
||||
hotspot_info->state = state;
|
||||
hotspot_info->allow_status = allow_status;
|
||||
hotspot_info->client_count = client_count;
|
||||
cros_hotspot_config_test_helper_->SetFakeHotspotInfo(
|
||||
std::move(hotspot_info));
|
||||
// Spin the runloop to observe the hotspot info change.
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
|
||||
void EnableAndDisableHotspotOnce() {
|
||||
UpdateHotspotInfo(HotspotState::kEnabled, HotspotAllowStatus::kAllowed);
|
||||
UpdateHotspotInfo(HotspotState::kDisabled, HotspotAllowStatus::kAllowed);
|
||||
|
||||
EXPECT_TRUE(hotspot_feature_tile_->GetVisible());
|
||||
}
|
||||
|
||||
void PressIcon() {
|
||||
hotspot_feature_pod_controller_->OnIconPressed();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
|
||||
void PressLabel() {
|
||||
hotspot_feature_pod_controller_->OnLabelPressed();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
|
||||
void LockScreen() {
|
||||
GetSessionControllerClient()->LockScreen();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
|
||||
protected:
|
||||
base::test::ScopedFeatureList scoped_feature_list_;
|
||||
std::unique_ptr<hotspot_config::CrosHotspotConfigTestHelper>
|
||||
cros_hotspot_config_test_helper_;
|
||||
std::unique_ptr<HotspotFeaturePodController> hotspot_feature_pod_controller_;
|
||||
std::unique_ptr<FeatureTile> hotspot_feature_tile_;
|
||||
};
|
||||
|
||||
TEST_F(HotspotFeaturePodControllerTest, HotspotNotUsedBefore) {
|
||||
EXPECT_FALSE(hotspot_feature_tile_->GetVisible());
|
||||
}
|
||||
|
||||
TEST_F(HotspotFeaturePodControllerTest, HotspotEnabled) {
|
||||
EnableAndDisableHotspotOnce();
|
||||
UpdateHotspotInfo(HotspotState::kEnabled, HotspotAllowStatus::kAllowed);
|
||||
|
||||
EXPECT_TRUE(hotspot_feature_tile_->GetVisible());
|
||||
EXPECT_TRUE(hotspot_feature_tile_->GetEnabled());
|
||||
EXPECT_TRUE(hotspot_feature_tile_->IsToggled());
|
||||
EXPECT_EQ(u"Hotspot", hotspot_feature_tile_->label()->GetText());
|
||||
EXPECT_EQ(u"On", hotspot_feature_tile_->sub_label()->GetText());
|
||||
EXPECT_EQ(u"Toggle Hotspot. Hotspot is on, no device connected.",
|
||||
hotspot_feature_tile_->GetTooltipText());
|
||||
EXPECT_EQ(u"Show hotspot details. Hotspot is on.",
|
||||
hotspot_feature_tile_->drill_in_button()->GetTooltipText());
|
||||
UpdateHotspotInfo(HotspotState::kEnabled, HotspotAllowStatus::kAllowed, 2);
|
||||
EXPECT_EQ(u"Toggle Hotspot. Hotspot is on, 2 devices connected.",
|
||||
hotspot_feature_tile_->GetTooltipText());
|
||||
|
||||
PressIcon();
|
||||
EXPECT_FALSE(hotspot_feature_tile_->IsToggled());
|
||||
EXPECT_TRUE(hotspot_feature_tile_->GetVisible());
|
||||
EXPECT_TRUE(hotspot_feature_tile_->GetEnabled());
|
||||
EXPECT_EQ(u"Off", hotspot_feature_tile_->sub_label()->GetText());
|
||||
}
|
||||
|
||||
TEST_F(HotspotFeaturePodControllerTest, HotspotEnabling) {
|
||||
EnableAndDisableHotspotOnce();
|
||||
UpdateHotspotInfo(HotspotState::kEnabling, HotspotAllowStatus::kAllowed);
|
||||
|
||||
EXPECT_TRUE(hotspot_feature_tile_->GetVisible());
|
||||
EXPECT_TRUE(hotspot_feature_tile_->GetEnabled());
|
||||
EXPECT_TRUE(hotspot_feature_tile_->IsToggled());
|
||||
EXPECT_EQ(u"Hotspot", hotspot_feature_tile_->label()->GetText());
|
||||
EXPECT_EQ(u"Enabling…", hotspot_feature_tile_->sub_label()->GetText());
|
||||
EXPECT_EQ(u"Show hotspot details. Hotspot is enabling.",
|
||||
hotspot_feature_tile_->GetTooltipText());
|
||||
EXPECT_EQ(u"Show hotspot details. Hotspot is enabling.",
|
||||
hotspot_feature_tile_->drill_in_button()->GetTooltipText());
|
||||
PressIcon();
|
||||
EXPECT_TRUE(hotspot_feature_tile_->IsToggled());
|
||||
EXPECT_TRUE(hotspot_feature_tile_->GetVisible());
|
||||
EXPECT_TRUE(hotspot_feature_tile_->GetEnabled());
|
||||
}
|
||||
|
||||
TEST_F(HotspotFeaturePodControllerTest, HotspotDisabling) {
|
||||
EnableAndDisableHotspotOnce();
|
||||
UpdateHotspotInfo(HotspotState::kDisabling, HotspotAllowStatus::kAllowed);
|
||||
|
||||
EXPECT_TRUE(hotspot_feature_tile_->GetVisible());
|
||||
EXPECT_TRUE(hotspot_feature_tile_->GetEnabled());
|
||||
EXPECT_TRUE(hotspot_feature_tile_->IsToggled());
|
||||
EXPECT_EQ(u"Hotspot", hotspot_feature_tile_->label()->GetText());
|
||||
EXPECT_EQ(u"Disabling…", hotspot_feature_tile_->sub_label()->GetText());
|
||||
EXPECT_EQ(u"Show hotspot details. Hotspot is disabling.",
|
||||
hotspot_feature_tile_->GetTooltipText());
|
||||
EXPECT_EQ(u"Show hotspot details. Hotspot is disabling.",
|
||||
hotspot_feature_tile_->drill_in_button()->GetTooltipText());
|
||||
PressIcon();
|
||||
EXPECT_TRUE(hotspot_feature_tile_->IsToggled());
|
||||
EXPECT_TRUE(hotspot_feature_tile_->GetVisible());
|
||||
EXPECT_TRUE(hotspot_feature_tile_->GetEnabled());
|
||||
}
|
||||
|
||||
TEST_F(HotspotFeaturePodControllerTest, HotspotDisabledAllowEnable) {
|
||||
EnableAndDisableHotspotOnce();
|
||||
UpdateHotspotInfo(HotspotState::kDisabled, HotspotAllowStatus::kAllowed);
|
||||
|
||||
EXPECT_TRUE(hotspot_feature_tile_->GetVisible());
|
||||
EXPECT_TRUE(hotspot_feature_tile_->GetEnabled());
|
||||
EXPECT_FALSE(hotspot_feature_tile_->IsToggled());
|
||||
EXPECT_EQ(u"Hotspot", hotspot_feature_tile_->label()->GetText());
|
||||
EXPECT_EQ(u"Off", hotspot_feature_tile_->sub_label()->GetText());
|
||||
EXPECT_EQ(u"Toggle Hotspot. Hotspot is off.",
|
||||
hotspot_feature_tile_->GetTooltipText());
|
||||
EXPECT_EQ(u"Toggle Hotspot. Hotspot is off.",
|
||||
hotspot_feature_tile_->drill_in_button()->GetTooltipText());
|
||||
PressIcon();
|
||||
EXPECT_TRUE(hotspot_feature_tile_->IsToggled());
|
||||
EXPECT_TRUE(hotspot_feature_tile_->GetVisible());
|
||||
EXPECT_TRUE(hotspot_feature_tile_->GetEnabled());
|
||||
}
|
||||
|
||||
TEST_F(HotspotFeaturePodControllerTest, HotspotDisabledNoMobileNetwork) {
|
||||
EnableAndDisableHotspotOnce();
|
||||
UpdateHotspotInfo(HotspotState::kDisabled,
|
||||
HotspotAllowStatus::kDisallowedNoMobileData);
|
||||
|
||||
EXPECT_TRUE(hotspot_feature_tile_->GetVisible());
|
||||
EXPECT_TRUE(hotspot_feature_tile_->GetEnabled());
|
||||
EXPECT_FALSE(hotspot_feature_tile_->IsToggled());
|
||||
EXPECT_EQ(u"Hotspot", hotspot_feature_tile_->label()->GetText());
|
||||
EXPECT_EQ(u"Off", hotspot_feature_tile_->sub_label()->GetText());
|
||||
EXPECT_EQ(u"Show hotspot details. Connect to mobile network to use hotspot.",
|
||||
hotspot_feature_tile_->GetTooltipText());
|
||||
EXPECT_EQ(u"Show hotspot details. Hotspot is off.",
|
||||
hotspot_feature_tile_->drill_in_button()->GetTooltipText());
|
||||
PressIcon();
|
||||
EXPECT_FALSE(hotspot_feature_tile_->IsToggled());
|
||||
EXPECT_TRUE(hotspot_feature_tile_->GetVisible());
|
||||
EXPECT_TRUE(hotspot_feature_tile_->GetEnabled());
|
||||
}
|
||||
|
||||
TEST_F(HotspotFeaturePodControllerTest,
|
||||
HotspotDisabledMobileNetworkNotSupported) {
|
||||
EnableAndDisableHotspotOnce();
|
||||
UpdateHotspotInfo(HotspotState::kDisabled,
|
||||
HotspotAllowStatus::kDisallowedReadinessCheckFail);
|
||||
|
||||
EXPECT_TRUE(hotspot_feature_tile_->GetVisible());
|
||||
EXPECT_TRUE(hotspot_feature_tile_->GetEnabled());
|
||||
EXPECT_FALSE(hotspot_feature_tile_->IsToggled());
|
||||
EXPECT_EQ(u"Hotspot", hotspot_feature_tile_->label()->GetText());
|
||||
EXPECT_EQ(u"Off", hotspot_feature_tile_->sub_label()->GetText());
|
||||
EXPECT_EQ(
|
||||
u"Show hotspot details. Your mobile network doesn't support hotspot.",
|
||||
hotspot_feature_tile_->GetTooltipText());
|
||||
EXPECT_EQ(u"Show hotspot details. Hotspot is off.",
|
||||
hotspot_feature_tile_->drill_in_button()->GetTooltipText());
|
||||
PressIcon();
|
||||
EXPECT_FALSE(hotspot_feature_tile_->IsToggled());
|
||||
}
|
||||
|
||||
TEST_F(HotspotFeaturePodControllerTest, HotspotDisabledBlockedByPolicy) {
|
||||
EnableAndDisableHotspotOnce();
|
||||
UpdateHotspotInfo(HotspotState::kDisabled,
|
||||
HotspotAllowStatus::kDisallowedByPolicy);
|
||||
|
||||
EXPECT_TRUE(hotspot_feature_tile_->GetVisible());
|
||||
EXPECT_TRUE(hotspot_feature_tile_->GetEnabled());
|
||||
EXPECT_FALSE(hotspot_feature_tile_->IsToggled());
|
||||
EXPECT_EQ(u"Hotspot", hotspot_feature_tile_->label()->GetText());
|
||||
EXPECT_EQ(u"Off", hotspot_feature_tile_->sub_label()->GetText());
|
||||
EXPECT_EQ(u"Show hotspot details. Hotspot is blocked by your administrator.",
|
||||
hotspot_feature_tile_->GetTooltipText());
|
||||
EXPECT_EQ(u"Show hotspot details. Hotspot is off.",
|
||||
hotspot_feature_tile_->drill_in_button()->GetTooltipText());
|
||||
PressIcon();
|
||||
EXPECT_FALSE(hotspot_feature_tile_->IsToggled());
|
||||
EXPECT_TRUE(hotspot_feature_tile_->GetVisible());
|
||||
EXPECT_TRUE(hotspot_feature_tile_->GetEnabled());
|
||||
}
|
||||
|
||||
TEST_F(HotspotFeaturePodControllerTest, LockScreen) {
|
||||
EnableAndDisableHotspotOnce();
|
||||
LockScreen();
|
||||
UpdateHotspotInfo(HotspotState::kDisabled, HotspotAllowStatus::kAllowed);
|
||||
|
||||
EXPECT_TRUE(hotspot_feature_tile_->GetVisible());
|
||||
EXPECT_TRUE(hotspot_feature_tile_->GetEnabled());
|
||||
EXPECT_FALSE(hotspot_feature_tile_->IsToggled());
|
||||
EXPECT_EQ(u"Hotspot", hotspot_feature_tile_->label()->GetText());
|
||||
EXPECT_EQ(u"Off", hotspot_feature_tile_->sub_label()->GetText());
|
||||
EXPECT_EQ(u"Toggle Hotspot. Hotspot is off.",
|
||||
hotspot_feature_tile_->GetTooltipText());
|
||||
EXPECT_EQ(u"Toggle Hotspot. Hotspot is off.",
|
||||
hotspot_feature_tile_->drill_in_button()->GetTooltipText());
|
||||
PressIcon();
|
||||
EXPECT_TRUE(hotspot_feature_tile_->IsToggled());
|
||||
EXPECT_TRUE(hotspot_feature_tile_->GetVisible());
|
||||
EXPECT_TRUE(hotspot_feature_tile_->GetEnabled());
|
||||
}
|
||||
|
||||
TEST_F(HotspotFeaturePodControllerTest, LabelUMATracking) {
|
||||
UpdateHotspotInfo(HotspotState::kDisabled, HotspotAllowStatus::kAllowed);
|
||||
|
||||
auto histogram_tester = std::make_unique<base::HistogramTester>();
|
||||
histogram_tester->ExpectTotalCount(kToggledOnHistogram,
|
||||
/*expected_count=*/0);
|
||||
histogram_tester->ExpectTotalCount(kToggledOffHistogram,
|
||||
/*expected_count=*/0);
|
||||
histogram_tester->ExpectTotalCount(kDiveInHistogram,
|
||||
/*expected_count=*/0);
|
||||
|
||||
// Toggle hotspot and show hotspot detailed view when pressing on the label.
|
||||
PressLabel();
|
||||
histogram_tester->ExpectTotalCount(kToggledOnHistogram,
|
||||
/*expected_count=*/1);
|
||||
histogram_tester->ExpectBucketCount(kToggledOnHistogram,
|
||||
QsFeatureCatalogName::kHotspot,
|
||||
/*expected_count=*/1);
|
||||
histogram_tester->ExpectTotalCount(kToggledOffHistogram,
|
||||
/*expected_count=*/0);
|
||||
histogram_tester->ExpectTotalCount(kDiveInHistogram,
|
||||
/*expected_count=*/1);
|
||||
histogram_tester->ExpectBucketCount(kDiveInHistogram,
|
||||
QsFeatureCatalogName::kHotspot,
|
||||
/*expected_count=*/1);
|
||||
PressIcon();
|
||||
histogram_tester->ExpectTotalCount(kToggledOnHistogram,
|
||||
/*expected_count=*/1);
|
||||
histogram_tester->ExpectBucketCount(kToggledOnHistogram,
|
||||
QsFeatureCatalogName::kHotspot,
|
||||
/*expected_count=*/1);
|
||||
histogram_tester->ExpectTotalCount(kToggledOffHistogram,
|
||||
/*expected_count=*/1);
|
||||
histogram_tester->ExpectBucketCount(kToggledOffHistogram,
|
||||
QsFeatureCatalogName::kHotspot,
|
||||
/*expected_count=*/1);
|
||||
histogram_tester->ExpectTotalCount(kDiveInHistogram,
|
||||
/*expected_count=*/1);
|
||||
histogram_tester->ExpectBucketCount(kDiveInHistogram,
|
||||
QsFeatureCatalogName::kHotspot,
|
||||
/*expected_count=*/1);
|
||||
}
|
||||
|
||||
} // namespace ash
|
@ -30,6 +30,7 @@
|
||||
#include "ash/system/cast/cast_feature_pod_controller.h"
|
||||
#include "ash/system/cast/unified_cast_detailed_view_controller.h"
|
||||
#include "ash/system/dark_mode/dark_mode_feature_pod_controller.h"
|
||||
#include "ash/system/hotspot/hotspot_feature_pod_controller.h"
|
||||
#include "ash/system/ime/ime_feature_pod_controller.h"
|
||||
#include "ash/system/ime/unified_ime_detailed_view_controller.h"
|
||||
#include "ash/system/locale/locale_feature_pod_controller.h"
|
||||
@ -728,6 +729,10 @@ void UnifiedSystemTrayController::InitFeatureTiles() {
|
||||
|
||||
create_tile(std::make_unique<NetworkFeaturePodController>(this),
|
||||
feature_pod_controllers_, tiles);
|
||||
if (features::IsHotspotEnabled()) {
|
||||
create_tile(std::make_unique<HotspotFeaturePodController>(this),
|
||||
feature_pod_controllers_, tiles);
|
||||
}
|
||||
|
||||
// CaptureMode and QuietMode tiles will be compact if both are visible.
|
||||
bool capture_and_quiet_tiles_are_compact =
|
||||
|
Reference in New Issue
Block a user