1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586
|
// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/ash/network/tether_notification_presenter.h"
#include <memory>
#include "ash/constants/ash_features.h"
#include "base/check.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/observer_list.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/values.h"
#include "chrome/browser/notifications/notification_display_service_tester.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/base/browser_with_test_window_test.h"
#include "chrome/test/base/testing_profile.h"
#include "chromeos/ash/components/network/network_connect.h"
#include "chromeos/ash/components/tether/pref_names.h"
#include "components/sync_preferences/testing_pref_service_syncable.h"
namespace ash::tether {
namespace {
const int kTestNetworkSignalStrength = 50;
const char kTetherSettingsSubpage[] = "networks?type=Tether";
const char kDeviceId[] = "device_id";
const char kDeviceName[] = "device_name";
} // namespace
class TetherNotificationPresenterTest : public BrowserWithTestWindowTest {
public:
class TestNetworkConnect : public NetworkConnect {
public:
TestNetworkConnect() = default;
~TestNetworkConnect() override = default;
std::string network_id_to_connect() { return network_id_to_connect_; }
// NetworkConnect:
void DisconnectFromNetworkId(const std::string& network_id) override {}
void ShowMobileSetup(const std::string& network_id) override {}
void ShowCarrierAccountDetail(const std::string& network_id) override {}
void ShowCarrierUnlockNotification() override {}
void ShowPortalSignin(const std::string& network_id,
NetworkConnect::Source source) override {}
void ConfigureNetworkIdAndConnect(const std::string& network_id,
const base::Value::Dict& shill_properties,
bool shared) override {}
void CreateConfigurationAndConnect(base::Value::Dict shill_properties,
bool shared) override {}
void CreateConfiguration(base::Value::Dict shill_properties,
bool shared) override {}
void ConnectToNetworkId(const std::string& network_id) override {
network_id_to_connect_ = network_id;
}
private:
std::string network_id_to_connect_;
};
class TestSettingsUiDelegate
: public TetherNotificationPresenter::SettingsUiDelegate {
public:
TestSettingsUiDelegate() = default;
~TestSettingsUiDelegate() override = default;
Profile* last_profile() { return last_profile_; }
std::string last_settings_subpage() { return last_settings_subpage_; }
// TetherNotificationPresenter::SettingsUiDelegate:
void ShowSettingsSubPageForProfile(Profile* profile,
const std::string& sub_page) override {
last_profile_ = profile;
last_settings_subpage_ = sub_page;
}
private:
raw_ptr<Profile, DanglingUntriaged> last_profile_ = nullptr;
std::string last_settings_subpage_;
};
TetherNotificationPresenterTest(const TetherNotificationPresenterTest&) =
delete;
TetherNotificationPresenterTest& operator=(
const TetherNotificationPresenterTest&) = delete;
protected:
TetherNotificationPresenterTest() = default;
void SetUp() override {
BrowserWithTestWindowTest::SetUp();
display_service_ =
std::make_unique<NotificationDisplayServiceTester>(profile());
test_network_connect_ = base::WrapUnique(new TestNetworkConnect());
notification_presenter_ = std::make_unique<TetherNotificationPresenter>(
profile(), test_network_connect_.get());
test_settings_ui_delegate_ = new TestSettingsUiDelegate();
notification_presenter_->SetSettingsUiDelegateForTesting(
base::WrapUnique(test_settings_ui_delegate_.get()));
has_verified_metrics_ = false;
}
void TearDown() override {
if (!has_verified_metrics_) {
VerifyNotificationInteractionMetrics(
0u /* num_expected_body_tapped_single_host_nearby */,
0u /* num_expected_body_tapped_multiple_hosts_nearby */,
0u /* num_expected_body_tapped_setup_required */,
0u /* num_expected_body_tapped_connection_failed */,
0u /* num_expected_button_tapped_single_host_nearby */);
}
BrowserWithTestWindowTest::TearDown();
}
std::string GetActiveHostNotificationId() {
return std::string(TetherNotificationPresenter::kActiveHostNotificationId);
}
std::string GetPotentialHotspotNotificationId() {
return std::string(
TetherNotificationPresenter::kPotentialHotspotNotificationId);
}
std::string GetSetupRequiredNotificationId() {
return std::string(
TetherNotificationPresenter::kSetupRequiredNotificationId);
}
void VerifySettingsOpened(const std::string& expected_subpage) {
EXPECT_EQ(profile(), test_settings_ui_delegate_->last_profile());
EXPECT_EQ(expected_subpage,
test_settings_ui_delegate_->last_settings_subpage());
}
void VerifySettingsNotOpened() {
EXPECT_FALSE(test_settings_ui_delegate_->last_profile());
EXPECT_TRUE(test_settings_ui_delegate_->last_settings_subpage().empty());
}
void VerifyNotificationInteractionMetrics(
size_t num_expected_body_tapped_single_host_nearby,
size_t num_expected_body_tapped_multiple_hosts_nearby,
size_t num_expected_body_tapped_setup_required,
size_t num_expected_body_tapped_connection_failed,
size_t num_expected_button_tapped_single_host_nearby) {
if (num_expected_body_tapped_single_host_nearby +
num_expected_body_tapped_multiple_hosts_nearby +
num_expected_body_tapped_setup_required +
num_expected_body_tapped_connection_failed +
num_expected_button_tapped_single_host_nearby ==
0u) {
histogram_tester_.ExpectTotalCount(
"InstantTethering.NotificationInteractionType", 0u);
return;
}
histogram_tester_.ExpectBucketCount(
"InstantTethering.NotificationInteractionType",
TetherNotificationPresenter::
NOTIFICATION_BODY_TAPPED_SINGLE_HOST_NEARBY,
num_expected_body_tapped_single_host_nearby);
histogram_tester_.ExpectBucketCount(
"InstantTethering.NotificationInteractionType",
TetherNotificationPresenter::
NOTIFICATION_BODY_TAPPED_MULTIPLE_HOSTS_NEARBY,
num_expected_body_tapped_multiple_hosts_nearby);
histogram_tester_.ExpectBucketCount(
"InstantTethering.NotificationInteractionType",
TetherNotificationPresenter::NOTIFICATION_BODY_TAPPED_SETUP_REQUIRED,
num_expected_body_tapped_setup_required);
histogram_tester_.ExpectBucketCount(
"InstantTethering.NotificationInteractionType",
TetherNotificationPresenter::NOTIFICATION_BODY_TAPPED_CONNECTION_FAILED,
num_expected_body_tapped_connection_failed);
histogram_tester_.ExpectBucketCount(
"InstantTethering.NotificationInteractionType",
TetherNotificationPresenter::NOTIFICATION_BUTTON_TAPPED_HOST_NEARBY,
num_expected_button_tapped_single_host_nearby);
has_verified_metrics_ = true;
}
base::HistogramTester histogram_tester_;
bool has_verified_metrics_;
std::unique_ptr<TestNetworkConnect> test_network_connect_;
raw_ptr<TestSettingsUiDelegate, DanglingUntriaged> test_settings_ui_delegate_;
std::unique_ptr<TetherNotificationPresenter> notification_presenter_;
std::unique_ptr<NotificationDisplayServiceTester> display_service_;
};
TEST_F(TetherNotificationPresenterTest,
TestHostConnectionFailedNotification_RemoveProgrammatically) {
EXPECT_FALSE(
display_service_->GetNotification(GetActiveHostNotificationId()));
notification_presenter_->NotifyConnectionToHostFailed();
std::optional<message_center::Notification> notification =
display_service_->GetNotification(GetActiveHostNotificationId());
ASSERT_TRUE(notification);
EXPECT_EQ(GetActiveHostNotificationId(), notification->id());
notification_presenter_->RemoveConnectionToHostFailedNotification();
EXPECT_FALSE(
display_service_->GetNotification(GetActiveHostNotificationId()));
VerifySettingsNotOpened();
}
TEST_F(TetherNotificationPresenterTest,
TestHostConnectionFailedNotification_TapNotification) {
EXPECT_FALSE(
display_service_->GetNotification(GetActiveHostNotificationId()));
notification_presenter_->NotifyConnectionToHostFailed();
std::optional<message_center::Notification> notification =
display_service_->GetNotification(GetActiveHostNotificationId());
ASSERT_TRUE(notification);
EXPECT_EQ(GetActiveHostNotificationId(), notification->id());
// Tap the notification.
ASSERT_TRUE(notification->delegate());
notification->delegate()->Click(std::nullopt, std::nullopt);
VerifySettingsOpened(kTetherSettingsSubpage);
EXPECT_FALSE(
display_service_->GetNotification(GetActiveHostNotificationId()));
VerifyNotificationInteractionMetrics(
0u /* num_expected_body_tapped_single_host_nearby */,
0u /* num_expected_body_tapped_multiple_hosts_nearby */,
0u /* num_expected_body_tapped_setup_required */,
1u /* num_expected_body_tapped_connection_failed */,
0u /* num_expected_button_tapped_single_host_nearby */);
}
TEST_F(TetherNotificationPresenterTest,
TestHostConnectionFailedNotification_NotShownWhenNotificationsDisabled) {
EXPECT_FALSE(
display_service_->GetNotification(GetActiveHostNotificationId()));
profile()->GetPrefs()->SetBoolean(prefs::kNotificationsEnabled,
/*value=*/false);
notification_presenter_->NotifyConnectionToHostFailed();
std::optional<message_center::Notification> notification =
display_service_->GetNotification(GetActiveHostNotificationId());
ASSERT_FALSE(notification);
}
TEST_F(TetherNotificationPresenterTest,
TestSetupRequiredNotification_RemoveProgrammatically) {
EXPECT_FALSE(
display_service_->GetNotification(GetSetupRequiredNotificationId()));
notification_presenter_->NotifySetupRequired(kDeviceName,
kTestNetworkSignalStrength);
std::optional<message_center::Notification> notification =
display_service_->GetNotification(GetSetupRequiredNotificationId());
ASSERT_TRUE(notification);
EXPECT_EQ(GetSetupRequiredNotificationId(), notification->id());
notification_presenter_->RemoveSetupRequiredNotification();
EXPECT_FALSE(
display_service_->GetNotification(GetSetupRequiredNotificationId()));
VerifySettingsNotOpened();
}
TEST_F(TetherNotificationPresenterTest,
TestSetupRequiredNotification_TapNotification) {
EXPECT_FALSE(
display_service_->GetNotification(GetSetupRequiredNotificationId()));
notification_presenter_->NotifySetupRequired(kDeviceName,
kTestNetworkSignalStrength);
std::optional<message_center::Notification> notification =
display_service_->GetNotification(GetSetupRequiredNotificationId());
ASSERT_TRUE(notification);
EXPECT_EQ(GetSetupRequiredNotificationId(), notification->id());
// Tap the notification.
ASSERT_TRUE(notification->delegate());
notification->delegate()->Click(std::nullopt, std::nullopt);
VerifySettingsOpened(kTetherSettingsSubpage);
EXPECT_FALSE(
display_service_->GetNotification(GetSetupRequiredNotificationId()));
VerifyNotificationInteractionMetrics(
0u /* num_expected_body_tapped_single_host_nearby */,
0u /* num_expected_body_tapped_multiple_hosts_nearby */,
1u /* num_expected_body_tapped_setup_required */,
0u /* num_expected_body_tapped_connection_failed */,
0u /* num_expected_button_tapped_single_host_nearby */);
}
TEST_F(TetherNotificationPresenterTest,
TestInstantHotspotNotification_NeverDismiss) {
base::test::ScopedFeatureList scoped_list;
scoped_list.InitAndEnableFeature(ash::features::kInstantHotspotRebrand);
EXPECT_FALSE(
display_service_->GetNotification(GetPotentialHotspotNotificationId()));
notification_presenter_->NotifyPotentialHotspotNearby(
kDeviceId, kDeviceName, kTestNetworkSignalStrength);
std::optional<message_center::Notification> notification =
display_service_->GetNotification(GetPotentialHotspotNotificationId());
EXPECT_TRUE(notification->never_timeout());
}
TEST_F(TetherNotificationPresenterTest,
TestInstantHotspotNotification_NeverDismissNoFF) {
EXPECT_FALSE(
display_service_->GetNotification(GetPotentialHotspotNotificationId()));
notification_presenter_->NotifyPotentialHotspotNearby(
kDeviceId, kDeviceName, kTestNetworkSignalStrength);
std::optional<message_center::Notification> notification =
display_service_->GetNotification(GetPotentialHotspotNotificationId());
EXPECT_FALSE(notification->never_timeout());
}
TEST_F(TetherNotificationPresenterTest,
TestPotentialHotspotNotification_RemoveProgrammatically) {
EXPECT_FALSE(
display_service_->GetNotification(GetPotentialHotspotNotificationId()));
notification_presenter_->NotifyPotentialHotspotNearby(
kDeviceId, kDeviceName, kTestNetworkSignalStrength);
std::optional<message_center::Notification> notification =
display_service_->GetNotification(GetPotentialHotspotNotificationId());
ASSERT_TRUE(notification);
EXPECT_EQ(GetPotentialHotspotNotificationId(), notification->id());
notification_presenter_->RemovePotentialHotspotNotification();
EXPECT_FALSE(
display_service_->GetNotification(GetPotentialHotspotNotificationId()));
VerifySettingsNotOpened();
}
TEST_F(TetherNotificationPresenterTest,
TestPotentialHotspotNotification_NotificationsDisabled) {
EXPECT_FALSE(
display_service_->GetNotification(GetPotentialHotspotNotificationId()));
profile()->GetPrefs()->SetBoolean(prefs::kNotificationsEnabled,
/*value=*/false);
notification_presenter_->NotifyPotentialHotspotNearby(
kDeviceId, kDeviceName, kTestNetworkSignalStrength);
std::optional<message_center::Notification> notification =
display_service_->GetNotification(GetPotentialHotspotNotificationId());
ASSERT_FALSE(notification);
}
TEST_F(TetherNotificationPresenterTest,
TestPotentialHotspotNotification_TapNotification) {
EXPECT_FALSE(
display_service_->GetNotification(GetPotentialHotspotNotificationId()));
notification_presenter_->NotifyPotentialHotspotNearby(
kDeviceId, kDeviceName, kTestNetworkSignalStrength);
std::optional<message_center::Notification> notification =
display_service_->GetNotification(GetPotentialHotspotNotificationId());
ASSERT_TRUE(notification);
EXPECT_EQ(GetPotentialHotspotNotificationId(), notification->id());
// Tap the notification.
ASSERT_TRUE(notification->delegate());
notification->delegate()->Click(std::nullopt, std::nullopt);
VerifySettingsOpened(kTetherSettingsSubpage);
EXPECT_FALSE(
display_service_->GetNotification(GetPotentialHotspotNotificationId()));
VerifyNotificationInteractionMetrics(
1u /* num_expected_body_tapped_single_host_nearby */,
0u /* num_expected_body_tapped_multiple_hosts_nearby */,
0u /* num_expected_body_tapped_setup_required */,
0u /* num_expected_body_tapped_connection_failed */,
0u /* num_expected_button_tapped_single_host_nearby */);
}
TEST_F(TetherNotificationPresenterTest,
TestSinglePotentialHotspotNotification_TapNotificationButton) {
EXPECT_FALSE(
display_service_->GetNotification(GetPotentialHotspotNotificationId()));
notification_presenter_->NotifyPotentialHotspotNearby(
kDeviceId, kDeviceName, kTestNetworkSignalStrength);
std::optional<message_center::Notification> notification =
display_service_->GetNotification(GetPotentialHotspotNotificationId());
ASSERT_TRUE(notification);
EXPECT_EQ(GetPotentialHotspotNotificationId(), notification->id());
// Tap the notification's button.
ASSERT_TRUE(notification->delegate());
notification->delegate()->Click(0, std::nullopt);
EXPECT_FALSE(
display_service_->GetNotification(GetPotentialHotspotNotificationId()));
EXPECT_EQ(kDeviceId, test_network_connect_->network_id_to_connect());
VerifyNotificationInteractionMetrics(
0u /* num_expected_body_tapped_single_host_nearby */,
0u /* num_expected_body_tapped_multiple_hosts_nearby */,
0u /* num_expected_body_tapped_setup_required */,
0u /* num_expected_body_tapped_connection_failed */,
1u /* num_expected_button_tapped_single_host_nearby */);
}
TEST_F(TetherNotificationPresenterTest,
TestMultiplePotentialHotspotNotification_RemoveProgrammatically) {
EXPECT_FALSE(
display_service_->GetNotification(GetPotentialHotspotNotificationId()));
notification_presenter_->NotifyMultiplePotentialHotspotsNearby();
std::optional<message_center::Notification> notification =
display_service_->GetNotification(GetPotentialHotspotNotificationId());
ASSERT_TRUE(notification);
EXPECT_EQ(GetPotentialHotspotNotificationId(), notification->id());
notification_presenter_->RemovePotentialHotspotNotification();
EXPECT_FALSE(
display_service_->GetNotification(GetPotentialHotspotNotificationId()));
VerifySettingsNotOpened();
}
TEST_F(TetherNotificationPresenterTest,
TestMultiplePotentialHotspotNotification_TapNotification) {
EXPECT_FALSE(
display_service_->GetNotification(GetPotentialHotspotNotificationId()));
notification_presenter_->NotifyMultiplePotentialHotspotsNearby();
std::optional<message_center::Notification> notification =
display_service_->GetNotification(GetPotentialHotspotNotificationId());
ASSERT_TRUE(notification);
EXPECT_EQ(GetPotentialHotspotNotificationId(), notification->id());
// Tap the notification.
ASSERT_TRUE(notification->delegate());
notification->delegate()->Click(std::nullopt, std::nullopt);
VerifySettingsOpened(kTetherSettingsSubpage);
EXPECT_FALSE(
display_service_->GetNotification(GetPotentialHotspotNotificationId()));
VerifyNotificationInteractionMetrics(
0u /* num_expected_body_tapped_single_host_nearby */,
1u /* num_expected_body_tapped_multiple_hosts_nearby */,
0u /* num_expected_body_tapped_setup_required */,
0u /* num_expected_body_tapped_connection_failed */,
0u /* num_expected_button_tapped_single_host_nearby */);
}
TEST_F(TetherNotificationPresenterTest,
TestPotentialHotspotNotifications_UpdatesOneNotification) {
EXPECT_FALSE(
display_service_->GetNotification(GetPotentialHotspotNotificationId()));
notification_presenter_->NotifyPotentialHotspotNearby(
kDeviceId, kDeviceName, kTestNetworkSignalStrength);
std::optional<message_center::Notification> notification =
display_service_->GetNotification(GetPotentialHotspotNotificationId());
ASSERT_TRUE(notification);
EXPECT_EQ(GetPotentialHotspotNotificationId(), notification->id());
// Simulate more device results coming in. Display the potential hotspots
// notification for multiple devices.
notification_presenter_->NotifyMultiplePotentialHotspotsNearby();
// The existing notification should have been updated instead of creating a
// new one.
notification =
display_service_->GetNotification(GetPotentialHotspotNotificationId());
ASSERT_TRUE(notification);
EXPECT_EQ(GetPotentialHotspotNotificationId(), notification->id());
notification_presenter_->RemovePotentialHotspotNotification();
EXPECT_FALSE(
display_service_->GetNotification(GetPotentialHotspotNotificationId()));
VerifySettingsNotOpened();
}
TEST_F(TetherNotificationPresenterTest,
TestGetPotentialHotspotNotificationState) {
EXPECT_EQ(notification_presenter_->GetPotentialHotspotNotificationState(),
NotificationPresenter::PotentialHotspotNotificationState::
NO_HOTSPOT_NOTIFICATION_SHOWN);
// Notify single host available and remove.
notification_presenter_->NotifyPotentialHotspotNearby(
kDeviceId, kDeviceName, kTestNetworkSignalStrength);
EXPECT_EQ(notification_presenter_->GetPotentialHotspotNotificationState(),
NotificationPresenter::PotentialHotspotNotificationState::
SINGLE_HOTSPOT_NEARBY_SHOWN);
notification_presenter_->RemovePotentialHotspotNotification();
EXPECT_EQ(notification_presenter_->GetPotentialHotspotNotificationState(),
NotificationPresenter::PotentialHotspotNotificationState::
NO_HOTSPOT_NOTIFICATION_SHOWN);
// Notify single host available and remove by tapping notification.
notification_presenter_->NotifyPotentialHotspotNearby(
kDeviceId, kDeviceName, kTestNetworkSignalStrength);
EXPECT_EQ(notification_presenter_->GetPotentialHotspotNotificationState(),
NotificationPresenter::PotentialHotspotNotificationState::
SINGLE_HOTSPOT_NEARBY_SHOWN);
display_service_->GetNotification(GetPotentialHotspotNotificationId())
->delegate()
->Click(std::nullopt, std::nullopt);
EXPECT_EQ(notification_presenter_->GetPotentialHotspotNotificationState(),
NotificationPresenter::PotentialHotspotNotificationState::
NO_HOTSPOT_NOTIFICATION_SHOWN);
// Notify single host available and remove by tapping notification button.
notification_presenter_->NotifyPotentialHotspotNearby(
kDeviceId, kDeviceName, kTestNetworkSignalStrength);
EXPECT_EQ(notification_presenter_->GetPotentialHotspotNotificationState(),
NotificationPresenter::PotentialHotspotNotificationState::
SINGLE_HOTSPOT_NEARBY_SHOWN);
display_service_->GetNotification(GetPotentialHotspotNotificationId())
->delegate()
->Click(0, std::nullopt);
EXPECT_EQ(notification_presenter_->GetPotentialHotspotNotificationState(),
NotificationPresenter::PotentialHotspotNotificationState::
NO_HOTSPOT_NOTIFICATION_SHOWN);
// Notify single, then multiple hosts available and remove.
notification_presenter_->NotifyPotentialHotspotNearby(
kDeviceId, kDeviceName, kTestNetworkSignalStrength);
EXPECT_EQ(notification_presenter_->GetPotentialHotspotNotificationState(),
NotificationPresenter::PotentialHotspotNotificationState::
SINGLE_HOTSPOT_NEARBY_SHOWN);
notification_presenter_->NotifyMultiplePotentialHotspotsNearby();
EXPECT_EQ(notification_presenter_->GetPotentialHotspotNotificationState(),
NotificationPresenter::PotentialHotspotNotificationState::
MULTIPLE_HOTSPOTS_NEARBY_SHOWN);
notification_presenter_->RemovePotentialHotspotNotification();
EXPECT_EQ(notification_presenter_->GetPotentialHotspotNotificationState(),
NotificationPresenter::PotentialHotspotNotificationState::
NO_HOTSPOT_NOTIFICATION_SHOWN);
// Notify single, then multiple hosts available and remove by tapping
// notification.
notification_presenter_->NotifyPotentialHotspotNearby(
kDeviceId, kDeviceName, kTestNetworkSignalStrength);
EXPECT_EQ(notification_presenter_->GetPotentialHotspotNotificationState(),
NotificationPresenter::PotentialHotspotNotificationState::
SINGLE_HOTSPOT_NEARBY_SHOWN);
notification_presenter_->NotifyMultiplePotentialHotspotsNearby();
EXPECT_EQ(notification_presenter_->GetPotentialHotspotNotificationState(),
NotificationPresenter::PotentialHotspotNotificationState::
MULTIPLE_HOTSPOTS_NEARBY_SHOWN);
display_service_->GetNotification(GetPotentialHotspotNotificationId())
->delegate()
->Click(std::nullopt, std::nullopt);
EXPECT_EQ(notification_presenter_->GetPotentialHotspotNotificationState(),
NotificationPresenter::PotentialHotspotNotificationState::
NO_HOTSPOT_NOTIFICATION_SHOWN);
VerifyNotificationInteractionMetrics(
1u /* num_expected_body_tapped_single_host_nearby */,
1u /* num_expected_body_tapped_multiple_hosts_nearby */,
0u /* num_expected_body_tapped_setup_required */,
0u /* num_expected_body_tapped_connection_failed */,
1u /* num_expected_button_tapped_single_host_nearby */);
}
} // namespace ash::tether
|