0

testing: Add SIM lock policy tests

This change adds a test that covers how the SIM lock policy interacts
with SIM locking.

Bug: b/339294577, b/339294583
Change-Id: Ief137a91161173ba4eea100027fecd57ac99511d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5770655
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Dana Fried <dfried@chromium.org>
Commit-Queue: Chad Duffin <chadduffin@chromium.org>
Reviewed-by: Peter Beverloo <peter@chromium.org>
Reviewed-by: Jason Zhang <jiajunz@google.com>
Reviewed-by: Nikhil Nayunigari <nikhilcn@google.com>
Cr-Commit-Position: refs/heads/main@{#1343580}
This commit is contained in:
Chad Duffin
2024-08-19 17:16:27 +00:00
committed by Chromium LUCI CQ
parent 86736fe488
commit f1bd3a89cc
15 changed files with 232 additions and 59 deletions

@ -18,6 +18,8 @@ DEFINE_EXPORTED_ELEMENT_IDENTIFIER_VALUE(kBluetoothFeatureTileToggleElementId);
DEFINE_EXPORTED_ELEMENT_IDENTIFIER_VALUE(
kBluetoothFeatureTileDrillInArrowElementId);
DEFINE_EXPORTED_ELEMENT_IDENTIFIER_VALUE(kCalendarViewElementId);
DEFINE_EXPORTED_ELEMENT_IDENTIFIER_VALUE(
kCellularManagedSimLockNotificationElementId);
DEFINE_EXPORTED_ELEMENT_IDENTIFIER_VALUE(kEnterpriseManagedView);
DEFINE_EXPORTED_ELEMENT_IDENTIFIER_VALUE(kExploreAppElementId);
DEFINE_EXPORTED_ELEMENT_IDENTIFIER_VALUE(kFilesAppElementId);

@ -34,6 +34,10 @@ DECLARE_EXPORTED_ELEMENT_IDENTIFIER_VALUE(
DECLARE_EXPORTED_ELEMENT_IDENTIFIER_VALUE(ASH_EXPORT, kCalendarViewElementId);
DECLARE_EXPORTED_ELEMENT_IDENTIFIER_VALUE(
ASH_EXPORT,
kCellularManagedSimLockNotificationElementId);
DECLARE_EXPORTED_ELEMENT_IDENTIFIER_VALUE(ASH_EXPORT, kEnterpriseManagedView);
// Uniquely identifies an element corresponding to the Explore app. Note that

@ -4,6 +4,7 @@
#include "ash/system/network/managed_sim_lock_notifier.h"
#include "ash/ash_element_identifiers.h"
#include "ash/public/cpp/network_config_service.h"
#include "ash/public/cpp/notification_utils.h"
#include "ash/public/cpp/system_tray_client.h"
@ -195,6 +196,8 @@ void ManagedSimLockNotifier::ShowNotification() {
weak_ptr_factory_.GetWeakPtr()),
/*small_image=*/gfx::VectorIcon(),
message_center::SystemNotificationWarningLevel::WARNING);
notification->set_host_view_element_id(
kCellularManagedSimLockNotificationElementId);
message_center::MessageCenter* message_center =
message_center::MessageCenter::Get();

@ -23,6 +23,8 @@ class ASH_EXPORT ManagedSimLockNotifier
public chromeos::network_config::CrosNetworkConfigObserver,
public message_center::NotificationObserver {
public:
static const char kManagedSimLockNotificationId[];
ManagedSimLockNotifier();
ManagedSimLockNotifier(const ManagedSimLockNotifier&) = delete;
ManagedSimLockNotifier& operator=(const ManagedSimLockNotifier&) = delete;
@ -57,8 +59,6 @@ class ASH_EXPORT ManagedSimLockNotifier
void MaybeShowNotification();
void ShowNotification();
static const char kManagedSimLockNotificationId[];
std::string primary_iccid_ = std::string();
mojo::Remote<chromeos::network_config::mojom::CrosNetworkConfig>
remote_cros_network_config_;

@ -102,7 +102,6 @@
#include "ui/views/metadata/view_factory_internal.h"
#include "ui/views/style/typography.h"
#include "ui/views/view.h"
#include "ui/views/view_class_properties.h"
namespace {
@ -293,8 +292,6 @@ using Orientation = views::BoxLayout::Orientation;
BEGIN_METADATA(AshNotificationView, NotificationTitleRow)
END_METADATA
DEFINE_CLASS_ELEMENT_IDENTIFIER_VALUE(AshNotificationView, kBubbleIdForTesting);
void AshNotificationView::AddedToWidget() {
MessageView::AddedToWidget();
@ -461,8 +458,6 @@ AshNotificationView::AshNotificationView(
Shell::Get()->message_center_controller()->drag_controller());
}
SetProperty(views::kElementIdentifierKey, kBubbleIdForTesting);
message_center_observer_.Observe(message_center::MessageCenter::Get());
// TODO(crbug.com/40780100): fix views and layout to match spec.
// Instantiate view instances and define layout and view hierarchy.

@ -11,7 +11,6 @@
#include "base/memory/raw_ptr.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "ui/base/interaction/element_identifier.h"
#include "ui/base/metadata/metadata_header_macros.h"
#include "ui/message_center/message_center.h"
#include "ui/message_center/message_center_observer.h"
@ -49,8 +48,6 @@ class ASH_EXPORT AshNotificationView
METADATA_HEADER(AshNotificationView, message_center::NotificationViewBase)
public:
DECLARE_CLASS_ELEMENT_IDENTIFIER_VALUE(kBubbleIdForTesting);
// TODO(crbug/1241983): Add metadata and builder support to this view.
explicit AshNotificationView(const message_center::Notification& notification,
bool shown_in_popup);

@ -6,7 +6,6 @@
#include "ash/constants/ash_features.h"
#include "ash/constants/ash_switches.h"
#include "ash/system/notification_center/views/ash_notification_view.h"
#include "ash/system/toast/system_nudge_view.h"
#include "ash/webui/system_apps/public/system_web_app_type.h"
#include "ash/wm/tablet_mode/tablet_mode_controller_test_api.h"
@ -17,6 +16,7 @@
#include "base/strings/stringprintf.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/ash/growth/show_notification_action_performer.h"
#include "chrome/browser/feature_engagement/tracker_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/ash/system_web_apps/system_web_app_ui_utils.h"
@ -481,7 +481,7 @@ IN_PROC_BROWSER_TEST_P(CampaignsManagerInteractiveUiNotificationTest,
ShowNotification) {
RunTestSequence(
SetTabletMode(ShouldUseTabletMode()),
WaitForShow(ash::AshNotificationView::kBubbleIdForTesting),
WaitForShow(ShowNotificationActionPerformer::kBubbleIdForTesting),
WithoutDelay(Steps(
CheckHistogramCounts("Ash.Growth.Ui.Impression.Campaigns500", 101, 1),
CheckHistogramCounts(
@ -499,9 +499,9 @@ IN_PROC_BROWSER_TEST_P(CampaignsManagerInteractiveUiNotificationTest,
RunTestSequence(
SetTabletMode(ShouldUseTabletMode()),
WaitForShow(ash::AshNotificationView::kBubbleIdForTesting),
WaitForShow(ShowNotificationActionPerformer::kBubbleIdForTesting),
Click(/*button_index=*/0),
WaitForHide(ash::AshNotificationView::kBubbleIdForTesting),
WaitForHide(ShowNotificationActionPerformer::kBubbleIdForTesting),
WaitForWindowWithTitle(env, u"www.google.com"),
WithoutDelay(Steps(
CheckHistogramCounts("Ash.Growth.Ui.Impression.Campaigns500", 101, 1),
@ -520,9 +520,9 @@ IN_PROC_BROWSER_TEST_P(CampaignsManagerInteractiveUiNotificationTest,
RunTestSequence(
SetTabletMode(ShouldUseTabletMode()),
WaitForShow(ash::AshNotificationView::kBubbleIdForTesting),
WaitForShow(ShowNotificationActionPerformer::kBubbleIdForTesting),
Click(/*button_index=*/1),
WaitForHide(ash::AshNotificationView::kBubbleIdForTesting),
WaitForHide(ShowNotificationActionPerformer::kBubbleIdForTesting),
WithoutDelay(Steps(
CheckHistogramCounts("Ash.Growth.Ui.Impression.Campaigns500", 101, 1),
CheckHistogramCounts(

@ -156,6 +156,9 @@ void HandleNotificationClickAndCloseDelegate::Close(bool by_user) {
close_callback_.Run(by_user);
}
DEFINE_CLASS_ELEMENT_IDENTIFIER_VALUE(ShowNotificationActionPerformer,
kBubbleIdForTesting);
ShowNotificationActionPerformer::ShowNotificationActionPerformer() = default;
ShowNotificationActionPerformer::~ShowNotificationActionPerformer() = default;
@ -206,6 +209,8 @@ void ShowNotificationActionPerformer::Run(
show_notification_params->should_log_cros_events)),
*show_notification_params->icon,
message_center::SystemNotificationWarningLevel::NORMAL);
notification->set_host_view_element_id(kBubbleIdForTesting);
auto* message_center = message_center::MessageCenter::Get();
CHECK(message_center);

@ -11,6 +11,7 @@
#include "base/values.h"
#include "chrome/browser/ash/growth/ui_action_performer.h"
#include "chromeos/ash/components/growth/campaigns_model.h"
#include "ui/base/interaction/element_identifier.h"
#include "ui/message_center/public/cpp/notification_delegate.h"
// A simple notification delegate which invokes the passed closure when the body
@ -49,6 +50,8 @@ class HandleNotificationClickAndCloseDelegate
// Implements show system notification action for the growth framework.
class ShowNotificationActionPerformer : public UiActionPerformer {
public:
DECLARE_CLASS_ELEMENT_IDENTIFIER_VALUE(kBubbleIdForTesting);
ShowNotificationActionPerformer();
~ShowNotificationActionPerformer() override;

@ -41,6 +41,7 @@ source_set("interactive_ui_tests") {
"//ui/base:base",
"//ui/base:test_support",
"//ui/chromeos/strings:strings_grit",
"//ui/message_center",
"//ui/views:test_support",
]
}

@ -5,6 +5,7 @@
#include <string>
#include "ash/ash_element_identifiers.h"
#include "ash/system/network/managed_sim_lock_notifier.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/test/scoped_run_loop_timeout.h"
@ -17,6 +18,7 @@
#include "chrome/test/base/ash/interactive/settings/interactive_uitest_elements.h"
#include "chromeos/ash/components/dbus/shill/fake_shill_device_client.h"
#include "chromeos/ash/components/dbus/shill/shill_device_client.h"
#include "chromeos/ash/components/network/managed_network_configuration_handler.h"
#include "chromeos/strings/grit/chromeos_strings.h"
#include "third_party/cros_system_api/dbus/shill/dbus-constants.h"
#include "ui/base/interaction/element_identifier.h"
@ -26,6 +28,7 @@
#include "ui/events/event.h"
#include "ui/events/types/event_type.h"
#include "ui/gfx/geometry/point_f.h"
#include "ui/message_center/message_center.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/interaction/polling_view_observer.h"
#include "ui/views/test/button_test_api.h"
@ -59,14 +62,23 @@ class SimLockInteractiveUiTest : public EsimInteractiveUiTestBase {
ASSERT_TRUE(device_test);
device_path_ = device_test->GetDevicePathForType(shill::kTypeCellular);
SetSimLockState(/*type=*/"", FakeShillDeviceClient::kSimPinRetryCount,
/*lock_enabled=*/false);
}
void SetSimLockState(const std::string& type,
const int retries_left,
const bool lock_enabled) {
auto* device_test = ShillDeviceClient::Get()->GetTestInterface();
ASSERT_TRUE(device_test);
device_test->SetDeviceProperty(
device_path_, shill::kSIMLockStatusProperty,
base::Value(
base::Value::Dict()
.Set(shill::kSIMLockTypeProperty, base::Value(""))
.Set(shill::kSIMLockRetriesLeftProperty,
base::Value(FakeShillDeviceClient::kSimPinRetryCount))
.Set(shill::kSIMLockEnabledProperty, base::Value(false))),
base::Value(base::Value::Dict()
.Set(shill::kSIMLockTypeProperty, base::Value(type))
.Set(shill::kSIMLockRetriesLeftProperty,
base::Value(retries_left))
.Set(shill::kSIMLockEnabledProperty,
base::Value(lock_enabled))),
/*notify_changed=*/true);
}
@ -93,6 +105,15 @@ class SimLockInteractiveUiTest : public EsimInteractiveUiTestBase {
EXPECT_EQ(*lock_enabled_value, lock_enabled);
}
void RestrictSimLockFromPolicy(bool allow_sim_lock) {
base::Value::Dict global_config;
global_config.Set(::onc::global_network_config::kAllowCellularSimLock,
allow_sim_lock);
NetworkHandler::Get()->managed_network_configuration_handler()->SetPolicy(
::onc::ONC_SOURCE_DEVICE_POLICY, /*userhash=*/std::string(),
base::Value::List(), global_config);
}
// Navigates to the SIM lock settings on the detailed page of the cellular
// network used for all SIM lock tests. This function does not do any checks
// that we are in the correct state.
@ -133,11 +154,11 @@ class SimLockInteractiveUiTest : public EsimInteractiveUiTestBase {
}
// Enables SIM lock with the provided `pin`, checking that SIM lock is
// initially disabled and checking that the subsequent state is correct.
// initially off and checking that the subsequent state is correct.
ui::test::internal::InteractiveTestPrivate::MultiStep EnableSimLockWithPin(
const std::string& pin) {
return Steps(
Log("Checking that the SIM lock toggle exists and is disabled"),
Log("Checking that the SIM lock toggle exists and is off"),
WaitForToggleState(kOSSettingsId,
settings::cellular::CellularSimLockToggle(),
@ -168,7 +189,7 @@ class SimLockInteractiveUiTest : public EsimInteractiveUiTestBase {
kOSSettingsId,
settings::cellular::CellularSimLockEnterPinDialogPin()),
Log("Checking that the SIM lock toggle is now enabled"),
Log("Checking that the SIM lock toggle is now on"),
WaitForToggleState(kOSSettingsId,
settings::cellular::CellularSimLockToggle(),
@ -181,6 +202,44 @@ class SimLockInteractiveUiTest : public EsimInteractiveUiTestBase {
}));
}
// Disables SIM lock with the provided `pin`, checking that SIM lock is
// initially on and checking that the subsequent state is correct.
ui::test::internal::InteractiveTestPrivate::MultiStep DisableSimLockWithPin(
const std::string& pin) {
return Steps(
Log("Checking that the SIM lock toggle exists and is on"),
WaitForToggleState(kOSSettingsId,
settings::cellular::CellularSimLockToggle(),
/*is_checked=*/true),
Log(base::StringPrintf("Disabling SIM lock with PIN %s", pin.c_str())),
ClickElement(kOSSettingsId,
settings::cellular::CellularSimLockToggle()),
ClearInputAndEnterText(
kOSSettingsId,
settings::cellular::CellularSimLockEnterPinDialogPin(),
pin.c_str()),
ClickElement(kOSSettingsId,
settings::cellular::CellularSimLockEnterPinDialogButton()),
WaitForElementDoesNotExist(
kOSSettingsId,
settings::cellular::CellularSimLockEnterPinDialogPin()),
Log("Checking that the SIM lock toggle is now off"),
WaitForToggleState(kOSSettingsId,
settings::cellular::CellularSimLockToggle(),
/*is_checked=*/false),
Do([this]() {
CheckSimLockState(
/*type=*/"",
/*retries_left=*/FakeShillDeviceClient::kSimPinRetryCount,
/*lock_enabled=*/false);
}));
}
const SimInfo& esim_info() const { return *esim_info_; }
private:
@ -200,29 +259,7 @@ IN_PROC_BROWSER_TEST_F(SimLockInteractiveUiTest, LockUnlockPin) {
EnableSimLockWithPin(kCorrectPin1),
Log(base::StringPrintf("Disabling SIM lock with PIN %s", kCorrectPin1)),
ClickElement(kOSSettingsId, settings::cellular::CellularSimLockToggle()),
ClearInputAndEnterText(
kOSSettingsId, settings::cellular::CellularSimLockEnterPinDialogPin(),
kCorrectPin1),
ClickElement(kOSSettingsId,
settings::cellular::CellularSimLockEnterPinDialogButton()),
WaitForElementDoesNotExist(
kOSSettingsId,
settings::cellular::CellularSimLockEnterPinDialogPin()),
Log("Checking that the SIM lock toggle is now disabled"),
WaitForToggleState(kOSSettingsId,
settings::cellular::CellularSimLockToggle(),
/*is_checked=*/false),
Do([this]() {
CheckSimLockState(
/*type=*/"",
/*retries_left=*/FakeShillDeviceClient::kSimPinRetryCount,
/*lock_enabled=*/false);
}),
DisableSimLockWithPin(kCorrectPin1),
Log("Closing the Settings app"),
@ -381,7 +418,7 @@ IN_PROC_BROWSER_TEST_F(SimLockInteractiveUiTest, LockUnlockPuk) {
kOSSettingsId,
settings::cellular::CellularSimLockEnterPinDialogPin()),
Log("Checking that the SIM lock toggle is enabled again"),
Log("Checking that the SIM lock toggle is on again"),
WaitForToggleState(kOSSettingsId,
settings::cellular::CellularSimLockToggle(),
@ -400,5 +437,89 @@ IN_PROC_BROWSER_TEST_F(SimLockInteractiveUiTest, LockUnlockPuk) {
Log("Test complete"));
}
IN_PROC_BROWSER_TEST_F(SimLockInteractiveUiTest, ProhibitWithPolicy) {
ui::ElementContext context =
LaunchSystemWebApp(SystemWebAppType::SETTINGS, kOSSettingsId);
// Run the following steps with the OS Settings context set as the default.
RunTestSequenceInContext(
context,
NavigateToSimLockSettings(),
EnableSimLockWithPin(kCorrectPin1),
Log("Checking that SIM PIN lock toggle does not have an enterprise icon"),
WaitForElementDoesNotExist(
kOSSettingsId, settings::cellular::CellularSimLockTogglePolicyIcon()),
Log("Prohibiting SIM PIN lock with policy"),
Do([this]() { RestrictSimLockFromPolicy(/*allow_sim_lock=*/false); }),
Log("Checking that SIM PIN lock toggle has an enterprise icon"),
WaitForElementExists(
kOSSettingsId, settings::cellular::CellularSimLockTogglePolicyIcon()),
Log("Waiting for the unlock SIM notification to be shown"),
WaitForShow(kCellularManagedSimLockNotificationElementId),
// We remove the notification since clicking it will cause OS Settings to
// refresh and re-navigate to the SIM lock settings which takes a
// significant amount of time (would need to extend the step timeout to
// account for this), and leaving the notification open could cause issues
// with clicking the SIM lock toggle.
Log("Removing the unlock SIM notification and waiting for it to be "
"hidden before continuing"),
Do([]() {
message_center::MessageCenter::Get()->RemoveNotification(
/*id=*/ManagedSimLockNotifier::kManagedSimLockNotificationId,
/*by_user=*/false);
}),
WaitForHide(kCellularManagedSimLockNotificationElementId),
Log(base::StringPrintf("Unlocking SIM lock with PIN %s", kCorrectPin1)),
ClickElement(kOSSettingsId, settings::cellular::CellularSimLockToggle()),
WaitForElementTextContains(
kOSSettingsId,
settings::cellular::CellularSimLockEnterPinDialogPolicySubtitle(),
/*expected=*/
l10n_util::GetStringUTF8(
IDS_SETTINGS_INTERNET_NETWORK_SIM_LOCK_POLICY_ADMIN_SUBTITLE)),
ClearInputAndEnterText(
kOSSettingsId, settings::cellular::CellularSimLockEnterPinDialogPin(),
kCorrectPin1),
ClickElement(kOSSettingsId,
settings::cellular::CellularSimLockEnterPinDialogButton()),
WaitForElementDoesNotExist(
kOSSettingsId,
settings::cellular::CellularSimLockEnterPinDialogPin()),
Log("Checking that the SIM lock toggle is now off and disabled"),
WaitForToggleState(kOSSettingsId,
settings::cellular::CellularSimLockToggle(),
/*is_checked=*/false),
WaitForElementDisabled(kOSSettingsId,
settings::cellular::CellularSimLockToggle()),
Do([this]() {
CheckSimLockState(
/*type=*/"",
/*retries_left=*/FakeShillDeviceClient::kSimPinRetryCount,
/*lock_enabled=*/false);
}),
Log("Closing the Settings app"),
Do([&]() { CloseSystemWebApp(SystemWebAppType::SETTINGS); }),
Log("Test complete"));
}
} // namespace
} // namespace ash

@ -299,6 +299,11 @@ WebContentsInteractionTestUtil::DeepQuery CellularSimLockToggle() {
"cr-toggle#simLockButton";
}
WebContentsInteractionTestUtil::DeepQuery CellularSimLockTogglePolicyIcon() {
return InternetDetailsSubpage() + "network-siminfo#cellularSimInfoAdvanced" +
"cr-policy-indicator#simLockPolicyIcon";
}
WebContentsInteractionTestUtil::DeepQuery CellularSimLockChangePinButton() {
return InternetDetailsSubpage() + "network-siminfo#cellularSimInfoAdvanced" +
"cr-button#changePinButton";
@ -309,6 +314,11 @@ WebContentsInteractionTestUtil::DeepQuery CellularSimLockDialogs() {
"sim-lock-dialogs";
}
WebContentsInteractionTestUtil::DeepQuery
CellularSimLockEnterPinDialogPolicySubtitle() {
return CellularSimLockDialogs() + "div#adminSubtitle";
}
WebContentsInteractionTestUtil::DeepQuery
CellularSimLockEnterPinDialogButton() {
return CellularSimLockDialogs() + "cr-button#enterPinButton";
@ -320,7 +330,8 @@ CellularSimLockEnterPinDialogSubtext() {
}
WebContentsInteractionTestUtil::DeepQuery CellularSimLockEnterPinDialogPin() {
return CellularSimLockDialogs() + "network-password-input#enterPin";
return CellularSimLockDialogs() + "network-password-input#enterPin" +
"cr-input#input" + "input#input";
}
WebContentsInteractionTestUtil::DeepQuery
@ -329,24 +340,29 @@ CellularSimLockChangePinDialogButton() {
}
WebContentsInteractionTestUtil::DeepQuery CellularSimLockChangePinDialogNew() {
return CellularSimLockDialogs() + "network-password-input#changePinNew1";
return CellularSimLockDialogs() + "network-password-input#changePinNew1" +
"cr-input#input" + "input#input";
}
WebContentsInteractionTestUtil::DeepQuery
CellularSimLockChangePinDialogNewConfirm() {
return CellularSimLockDialogs() + "network-password-input#changePinNew2";
return CellularSimLockDialogs() + "network-password-input#changePinNew2" +
"cr-input#input" + "input#input";
}
WebContentsInteractionTestUtil::DeepQuery CellularSimLockChangePinDialogOld() {
return CellularSimLockDialogs() + "network-password-input#changePinOld";
return CellularSimLockDialogs() + "network-password-input#changePinOld" +
"cr-input#input" + "input#input";
}
WebContentsInteractionTestUtil::DeepQuery CellularSimLockUnlockPinDialogDone() {
WebContentsInteractionTestUtil::DeepQuery
CellularSimLockUnlockPinDialogButton() {
return CellularSimLockDialogs() + "cr-button#unlockPinButton";
}
WebContentsInteractionTestUtil::DeepQuery CellularSimLockUnlockPinDialogPin() {
return CellularSimLockDialogs() + "network-password-input#unlockPin";
return CellularSimLockDialogs() + "network-password-input#unlockPin" +
"cr-input#input" + "input#input";
}
WebContentsInteractionTestUtil::DeepQuery
@ -355,16 +371,19 @@ CellularSimLockUnlockPukDialogButton() {
}
WebContentsInteractionTestUtil::DeepQuery CellularSimLockUnlockPukDialogPin() {
return CellularSimLockDialogs() + "network-password-input#unlockPin1";
return CellularSimLockDialogs() + "network-password-input#unlockPin1" +
"cr-input#input" + "input#input";
}
WebContentsInteractionTestUtil::DeepQuery CellularSimLockUnlockPukDialogPuk() {
return CellularSimLockDialogs() + "network-password-input#unlockPuk";
return CellularSimLockDialogs() + "network-password-input#unlockPuk" +
"cr-input#input" + "input#input";
}
WebContentsInteractionTestUtil::DeepQuery
CellularSimLockUnlockPukDialogPinConfirm() {
return CellularSimLockDialogs() + "network-password-input#unlockPin2";
return CellularSimLockDialogs() + "network-password-input#unlockPin2" +
"cr-input#input" + "input#input";
}
WebContentsInteractionTestUtil::DeepQuery CellularSubpageMenuRenameButton() {

@ -224,8 +224,11 @@ WebContentsInteractionTestUtil::DeepQuery CellularDetailsProxySection();
// the details page of a cellular network, or the dialog shown to unlock a
// locked SIM either using a PIN or a PUK.
WebContentsInteractionTestUtil::DeepQuery CellularSimLockToggle();
WebContentsInteractionTestUtil::DeepQuery CellularSimLockTogglePolicyIcon();
WebContentsInteractionTestUtil::DeepQuery CellularSimLockChangePinButton();
WebContentsInteractionTestUtil::DeepQuery CellularSimLockDialogs();
WebContentsInteractionTestUtil::DeepQuery
CellularSimLockEnterPinDialogPolicySubtitle();
WebContentsInteractionTestUtil::DeepQuery CellularSimLockEnterPinDialogButton();
WebContentsInteractionTestUtil::DeepQuery
CellularSimLockEnterPinDialogSubtext();
@ -236,7 +239,8 @@ WebContentsInteractionTestUtil::DeepQuery CellularSimLockChangePinDialogNew();
WebContentsInteractionTestUtil::DeepQuery
CellularSimLockChangePinDialogNewConfirm();
WebContentsInteractionTestUtil::DeepQuery CellularSimLockChangePinDialogOld();
WebContentsInteractionTestUtil::DeepQuery CellularSimLockUnlockPinDialogDone();
WebContentsInteractionTestUtil::DeepQuery
CellularSimLockUnlockPinDialogButton();
WebContentsInteractionTestUtil::DeepQuery CellularSimLockUnlockPinDialogPin();
WebContentsInteractionTestUtil::DeepQuery
CellularSimLockUnlockPukDialogButton();

@ -16,6 +16,7 @@
#include "base/time/time.h"
#include "build/chromeos_buildflags.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/base/interaction/element_identifier.h"
#include "ui/base/models/image_model.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/geometry/skia_conversions.h"
@ -612,6 +613,16 @@ class MESSAGE_CENTER_PUBLIC_EXPORT Notification {
custom_view_type_ = custom_view_type;
}
// Gets the element ID that should be used for the view that hosts this
// notification.
ui::ElementIdentifier host_view_element_id() const {
return host_view_element_id_;
}
void set_host_view_element_id(
const ui::ElementIdentifier host_view_element_id) {
host_view_element_id_ = host_view_element_id;
}
protected:
// The type of notification we'd like displayed.
NotificationType type_;
@ -661,6 +672,10 @@ class MESSAGE_CENTER_PUBLIC_EXPORT Notification {
// used to register the factory in MessageViewFactory.
std::string custom_view_type_;
// The value that should be used for the element ID of the view that hosts
// this notification.
ui::ElementIdentifier host_view_element_id_;
#if BUILDFLAG(IS_CHROMEOS_ASH)
// The warning level of a system notification.
SystemNotificationWarningLevel system_notification_warning_level_ =

@ -5,6 +5,7 @@
#include "ui/message_center/views/notification_view_base.h"
#include <stddef.h>
#include <algorithm>
#include <memory>
#include <utility>
@ -61,6 +62,7 @@
#include "ui/views/layout/box_layout.h"
#include "ui/views/layout/box_layout_view.h"
#include "ui/views/style/typography.h"
#include "ui/views/view_class_properties.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_delegate.h"
@ -212,6 +214,8 @@ void NotificationViewBase::CreateOrUpdateViews(
NotificationViewBase::NotificationViewBase(const Notification& notification)
: MessageView(notification), for_ash_notification_(IsForAshNotification()) {
UpdateCornerRadius(kNotificationCornerRadius, kNotificationCornerRadius);
SetProperty(views::kElementIdentifierKey,
notification.host_view_element_id());
}
NotificationViewBase::~NotificationViewBase() = default;