Commit b8c14e08 authored by tengs's avatar tengs Committed by Commit Bot

[EasyUnlock] Introduce EasyUnlockNotificationController

This class is responsible for displaying and handling all EasyUnlock notifications.

Originally, EasyUnlock notifications were shown by a component app, but this app is now deprecated and we are migrating EasyUnlock natively for v2.

BUG=726791

Review-Url: https://codereview.chromium.org/2968323002
Cr-Commit-Position: refs/heads/master@{#488522}
parent bfc6ec67
...@@ -271,6 +271,8 @@ ...@@ -271,6 +271,8 @@
<structure type="chrome_scaled_image" name="IDR_NOTIFICATION_EXTENSION_INSTALLED" file="common/notification_extension_installed.png" /> <structure type="chrome_scaled_image" name="IDR_NOTIFICATION_EXTENSION_INSTALLED" file="common/notification_extension_installed.png" />
<structure type="chrome_scaled_image" name="IDR_NOTIFICATION_SCREENSHOT_ANNOTATE" file="cros/notification_screenshot_annotate.png" /> <structure type="chrome_scaled_image" name="IDR_NOTIFICATION_SCREENSHOT_ANNOTATE" file="cros/notification_screenshot_annotate.png" />
<structure type="chrome_scaled_image" name="IDR_NOTIFICATION_SCREENSHOT_COPY_TO_CLIPBOARD" file="cros/notification_screenshot_copy_to_clipboard.png" /> <structure type="chrome_scaled_image" name="IDR_NOTIFICATION_SCREENSHOT_COPY_TO_CLIPBOARD" file="cros/notification_screenshot_copy_to_clipboard.png" />
<structure type="chrome_scaled_image" name="IDR_NOTIFICATION_EASYUNLOCK_ENABLED" file="cros/notification_easyunlock_enabled.png" />
<structure type="chrome_scaled_image" name="IDR_NOTIFICATION_EASYUNLOCK_PROMO" file="cros/notification_easyunlock_promo.png" />
</if> </if>
<structure type="chrome_scaled_image" name="IDR_NOTIFICATION_WELCOME_ICON" file="common/notification_welcome_icon.png" /> <structure type="chrome_scaled_image" name="IDR_NOTIFICATION_WELCOME_ICON" file="common/notification_welcome_icon.png" />
<structure type="chrome_scaled_image" name="IDR_NOTIFICATION_WELCOME_LEARN_MORE" file="common/notification_welcome_learn_more.png" /> <structure type="chrome_scaled_image" name="IDR_NOTIFICATION_WELCOME_LEARN_MORE" file="common/notification_welcome_learn_more.png" />
......
...@@ -1847,6 +1847,10 @@ split_static_library("browser") { ...@@ -1847,6 +1847,10 @@ split_static_library("browser") {
"signin/easy_unlock_auth_attempt.h", "signin/easy_unlock_auth_attempt.h",
"signin/easy_unlock_metrics.cc", "signin/easy_unlock_metrics.cc",
"signin/easy_unlock_metrics.h", "signin/easy_unlock_metrics.h",
"signin/easy_unlock_notification_controller.cc",
"signin/easy_unlock_notification_controller.h",
"signin/easy_unlock_notification_controller_chromeos.cc",
"signin/easy_unlock_notification_controller_chromeos.h",
"signin/easy_unlock_screenlock_state_handler.cc", "signin/easy_unlock_screenlock_state_handler.cc",
"signin/easy_unlock_screenlock_state_handler.h", "signin/easy_unlock_screenlock_state_handler.h",
"signin/easy_unlock_service.cc", "signin/easy_unlock_service.cc",
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/signin/easy_unlock_notification_controller.h"
#include "base/memory/ptr_util.h"
#include "build/build_config.h"
#if defined(OS_CHROMEOS)
#include "chrome/browser/signin/easy_unlock_notification_controller_chromeos.h"
#include "ui/message_center/message_center.h"
#endif
namespace {
// Stub implementation of EasyUnlockNotificationController for non-ChromeOS
// platforms.
class EasyUnlockNotificationControllerStub
: public EasyUnlockNotificationController {
public:
EasyUnlockNotificationControllerStub() {}
~EasyUnlockNotificationControllerStub() override {}
// EasyUnlockNotificationController:
void ShowChromebookAddedNotification() override {}
void ShowPairingChangeNotification() override {}
void ShowPairingChangeAppliedNotification(
const std::string& phone_name) override {}
void ShowPromotionNotification() override {}
private:
DISALLOW_COPY_AND_ASSIGN(EasyUnlockNotificationControllerStub);
};
} // namespace
std::unique_ptr<EasyUnlockNotificationController>
EasyUnlockNotificationController::Create(Profile* profile) {
#if defined(OS_CHROMEOS)
return base::MakeUnique<EasyUnlockNotificationControllerChromeOS>(
profile, message_center::MessageCenter::Get());
#else
return base::MakeUnique<EasyUnlockNotificationControllerStub>();
#endif
}
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_SIGNIN_EASY_UNLOCK_NOTIFICATION_CONTROLLER_H_
#define CHROME_BROWSER_SIGNIN_EASY_UNLOCK_NOTIFICATION_CONTROLLER_H_
#include <memory>
#include <string>
#include "base/macros.h"
class Profile;
// Responsible for displaying all notifications for EasyUnlock.
class EasyUnlockNotificationController {
public:
// Creates an instance of the EasyUnlockNotificationController.
static std::unique_ptr<EasyUnlockNotificationController> Create(
Profile* profile);
EasyUnlockNotificationController() {}
virtual ~EasyUnlockNotificationController() {}
// Shows the notification when EasyUnlock is synced to a new Chromebook.
virtual void ShowChromebookAddedNotification() = 0;
// Shows the notification when EasyUnlock is already enabled on a Chromebook,
// but a different phone is synced as the unlock key.
virtual void ShowPairingChangeNotification() = 0;
// Shows the notification after password reauth confirming that the new phone
// should be used for EasyUnlock from now on.
virtual void ShowPairingChangeAppliedNotification(
const std::string& phone_name) = 0;
// Shows the notification to promote EasyUnlock to the user.
virtual void ShowPromotionNotification() = 0;
private:
DISALLOW_COPY_AND_ASSIGN(EasyUnlockNotificationController);
};
#endif // CHROME_BROWSER_SIGNIN_EASY_UNLOCK_NOTIFICATION_CONTROLLER_H_
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/signin/easy_unlock_notification_controller_chromeos.h"
#include "ash/system/devicetype_utils.h"
#include "base/guid.h"
#include "base/memory/ptr_util.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/ui/chrome_pages.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/grit/theme_resources.h"
#include "components/proximity_auth/screenlock_bridge.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/message_center/message_center_types.h"
#include "ui/message_center/notification_types.h"
namespace {
const char kEasyUnlockChromebookAddedNotifierId[] =
"easyunlock_notification_ids.chromebook_added";
const char kEasyUnlockPairingChangeNotifierId[] =
"easyunlock_notification_ids.pairing_change";
const char kEasyUnlockPairingChangeAppliedNotifierId[] =
"easyunlock_notification_ids.pairing_change_applied";
const char kEasyUnlockPromotionNotifierId[] =
"easyunlock_notification_ids.promotion";
const char kLockScreenSettingsSubpage[] = "lockScreen";
// Convenience function for creating a Notification.
std::unique_ptr<message_center::Notification> CreateNotification(
const std::string& id,
const base::string16& title,
const base::string16& message,
const gfx::Image& icon,
const message_center::RichNotificationData& rich_notification_data,
message_center::NotificationDelegate* delegate) {
return base::MakeUnique<message_center::Notification>(
message_center::NotificationType::NOTIFICATION_TYPE_SIMPLE, id, title,
message, icon, base::string16() /* display_source */,
GURL() /* origin_url */,
message_center::NotifierId(
message_center::NotifierId::NotifierType::SYSTEM_COMPONENT, id),
rich_notification_data, delegate);
}
} // namespace
EasyUnlockNotificationControllerChromeOS::
EasyUnlockNotificationControllerChromeOS(
Profile* profile,
message_center::MessageCenter* message_center)
: profile_(profile),
message_center_(message_center),
weak_ptr_factory_(this) {}
EasyUnlockNotificationControllerChromeOS::
~EasyUnlockNotificationControllerChromeOS() {}
void EasyUnlockNotificationControllerChromeOS::
ShowChromebookAddedNotification() {
message_center::RichNotificationData rich_notification_data;
rich_notification_data.buttons.push_back(
message_center::ButtonInfo(l10n_util::GetStringUTF16(
IDS_EASY_UNLOCK_CHROMEBOOK_ADDED_NOTIFICATION_ABOUT_BUTTON)));
ShowNotification(CreateNotification(
kEasyUnlockChromebookAddedNotifierId,
l10n_util::GetStringUTF16(
IDS_EASY_UNLOCK_CHROMEBOOK_ADDED_NOTIFICATION_TITLE),
l10n_util::GetStringFUTF16(
IDS_EASY_UNLOCK_CHROMEBOOK_ADDED_NOTIFICATION_MESSAGE,
ash::GetChromeOSDeviceName()),
ui::ResourceBundle::GetSharedInstance().GetImageNamed(
IDR_NOTIFICATION_EASYUNLOCK_ENABLED),
rich_notification_data,
new NotificationDelegate(kEasyUnlockChromebookAddedNotifierId,
weak_ptr_factory_.GetWeakPtr())));
}
void EasyUnlockNotificationControllerChromeOS::ShowPairingChangeNotification() {
message_center::RichNotificationData rich_notification_data;
rich_notification_data.buttons.push_back(
message_center::ButtonInfo(l10n_util::GetStringUTF16(
IDS_EASY_UNLOCK_PAIRING_CHANGED_NOTIFICATION_UPDATE_BUTTON)));
rich_notification_data.buttons.push_back(
message_center::ButtonInfo(l10n_util::GetStringUTF16(
IDS_EASY_UNLOCK_CHROMEBOOK_ADDED_NOTIFICATION_ABOUT_BUTTON)));
ShowNotification(CreateNotification(
kEasyUnlockPairingChangeNotifierId,
l10n_util::GetStringUTF16(
IDS_EASY_UNLOCK_PAIRING_CHANGED_NOTIFICATION_TITLE),
l10n_util::GetStringFUTF16(
IDS_EASY_UNLOCK_PAIRING_CHANGED_NOTIFICATION_MESSAGE,
ash::GetChromeOSDeviceName()),
ui::ResourceBundle::GetSharedInstance().GetImageNamed(
IDR_NOTIFICATION_EASYUNLOCK_ENABLED),
rich_notification_data,
new NotificationDelegate(kEasyUnlockPairingChangeNotifierId,
weak_ptr_factory_.GetWeakPtr())));
}
void EasyUnlockNotificationControllerChromeOS::
ShowPairingChangeAppliedNotification(const std::string& phone_name) {
// Remove the pairing change notification if it is still being shown.
message_center_->RemoveNotification(kEasyUnlockPairingChangeNotifierId,
false /* by_user */);
message_center::RichNotificationData rich_notification_data;
rich_notification_data.buttons.push_back(
message_center::ButtonInfo(l10n_util::GetStringUTF16(
IDS_EASY_UNLOCK_CHROMEBOOK_ADDED_NOTIFICATION_ABOUT_BUTTON)));
ShowNotification(CreateNotification(
kEasyUnlockPairingChangeAppliedNotifierId,
l10n_util::GetStringUTF16(
IDS_EASY_UNLOCK_PAIRING_CHANGE_APPLIED_NOTIFICATION_TITLE),
l10n_util::GetStringFUTF16(
IDS_EASY_UNLOCK_PAIRING_CHANGE_APPLIED_NOTIFICATION_MESSAGE,
base::UTF8ToUTF16(phone_name), ash::GetChromeOSDeviceName()),
ui::ResourceBundle::GetSharedInstance().GetImageNamed(
IDR_NOTIFICATION_EASYUNLOCK_ENABLED),
rich_notification_data,
new NotificationDelegate(kEasyUnlockPairingChangeAppliedNotifierId,
weak_ptr_factory_.GetWeakPtr())));
}
void EasyUnlockNotificationControllerChromeOS::ShowPromotionNotification() {
message_center::RichNotificationData rich_notification_data;
rich_notification_data.buttons.push_back(
message_center::ButtonInfo(l10n_util::GetStringUTF16(
IDS_EASY_UNLOCK_SETUP_NOTIFICATION_BUTTON_TITLE)));
ShowNotification(CreateNotification(
kEasyUnlockPromotionNotifierId,
l10n_util::GetStringUTF16(IDS_EASY_UNLOCK_SETUP_NOTIFICATION_TITLE),
l10n_util::GetStringFUTF16(IDS_EASY_UNLOCK_SETUP_NOTIFICATION_MESSAGE,
ash::GetChromeOSDeviceName()),
ui::ResourceBundle::GetSharedInstance().GetImageNamed(
IDR_NOTIFICATION_EASYUNLOCK_PROMO),
rich_notification_data,
new NotificationDelegate(kEasyUnlockPromotionNotifierId,
weak_ptr_factory_.GetWeakPtr())));
}
void EasyUnlockNotificationControllerChromeOS::ShowNotification(
std::unique_ptr<message_center::Notification> notification) {
notification->SetSystemPriority();
std::string notification_id = notification->id();
if (message_center_->FindVisibleNotificationById(notification_id)) {
message_center_->UpdateNotification(notification_id,
std::move(notification));
} else {
message_center_->AddNotification(std::move(notification));
}
}
void EasyUnlockNotificationControllerChromeOS::LaunchEasyUnlockSettings() {
chrome::ShowSettingsSubPageForProfile(profile_, kLockScreenSettingsSubpage);
}
void EasyUnlockNotificationControllerChromeOS::LockScreen() {
proximity_auth::ScreenlockBridge::Get()->Lock();
}
EasyUnlockNotificationControllerChromeOS::NotificationDelegate::
NotificationDelegate(
const std::string& notification_id,
const base::WeakPtr<EasyUnlockNotificationControllerChromeOS>&
notification_controller)
: notification_id_(notification_id),
notification_controller_(notification_controller) {}
EasyUnlockNotificationControllerChromeOS::NotificationDelegate::
~NotificationDelegate() {}
void EasyUnlockNotificationControllerChromeOS::NotificationDelegate::Click() {
if (!notification_controller_)
return;
if (notification_id_ == kEasyUnlockChromebookAddedNotifierId ||
notification_id_ == kEasyUnlockPairingChangeAppliedNotifierId ||
notification_id_ == kEasyUnlockPromotionNotifierId)
notification_controller_->LaunchEasyUnlockSettings();
}
void EasyUnlockNotificationControllerChromeOS::NotificationDelegate::
ButtonClick(int button_index) {
if (!notification_controller_)
return;
if (notification_id_ == kEasyUnlockChromebookAddedNotifierId ||
notification_id_ == kEasyUnlockPairingChangeAppliedNotifierId ||
notification_id_ == kEasyUnlockPromotionNotifierId) {
notification_controller_->LaunchEasyUnlockSettings();
} else if (notification_id_ == kEasyUnlockPairingChangeNotifierId) {
if (button_index == 0) {
notification_controller_->LockScreen();
} else if (button_index == 1) {
notification_controller_->LaunchEasyUnlockSettings();
}
}
}
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_SIGNIN_EASY_UNLOCK_NOTIFICATION_CONTROLLER_CHROMEOS_H_
#define CHROME_BROWSER_SIGNIN_EASY_UNLOCK_NOTIFICATION_CONTROLLER_CHROMEOS_H_
#include <memory>
#include <string>
#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/signin/easy_unlock_notification_controller.h"
#include "ui/message_center/message_center.h"
#include "ui/message_center/notification.h"
#include "ui/message_center/notification_delegate.h"
class Profile;
// Implementation of EasyUnlockNotificationController for ChromeOS.
class EasyUnlockNotificationControllerChromeOS
: public EasyUnlockNotificationController {
public:
EasyUnlockNotificationControllerChromeOS(
Profile* profile,
message_center::MessageCenter* message_center);
~EasyUnlockNotificationControllerChromeOS() override;
// EasyUnlockNotificationController:
void ShowChromebookAddedNotification() override;
void ShowPairingChangeNotification() override;
void ShowPairingChangeAppliedNotification(
const std::string& phone_name) override;
void ShowPromotionNotification() override;
protected:
// Exposed for testing
virtual void LaunchEasyUnlockSettings();
virtual void LockScreen();
private:
// NotificationDelegate implementation for handling click events.
class NotificationDelegate : public message_center::NotificationDelegate {
public:
NotificationDelegate(
const std::string& notification_id,
const base::WeakPtr<EasyUnlockNotificationControllerChromeOS>&
notification_controller);
// message_center::NotificationDelegate:
void Click() override;
void ButtonClick(int button_index) override;
private:
~NotificationDelegate() override;
std::string notification_id_;
base::WeakPtr<EasyUnlockNotificationControllerChromeOS>
notification_controller_;
DISALLOW_COPY_AND_ASSIGN(NotificationDelegate);
};
// Displays the notification to the user.
void ShowNotification(
std::unique_ptr<message_center::Notification> notification);
Profile* profile_;
message_center::MessageCenter* message_center_;
base::WeakPtrFactory<EasyUnlockNotificationControllerChromeOS>
weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(EasyUnlockNotificationControllerChromeOS);
};
#endif // CHROME_BROWSER_SIGNIN_EASY_UNLOCK_NOTIFICATION_CONTROLLER_CHROMEOS_H_
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/signin/easy_unlock_notification_controller_chromeos.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/test/base/testing_profile.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/message_center/fake_message_center.h"
#include "ui/message_center/notification.h"
#include "ui/message_center/notification_types.h"
namespace {
const char kPhoneName[] = "Nexus 6";
class TestMessageCenter : public message_center::FakeMessageCenter {
public:
TestMessageCenter() : message_center::FakeMessageCenter() {}
~TestMessageCenter() override {}
// message_center::FakeMessageCenter:
message_center::Notification* FindVisibleNotificationById(
const std::string& id) override {
auto iter = std::find_if(
notifications_.begin(), notifications_.end(),
[id](const std::shared_ptr<message_center::Notification> notification) {
return notification->id() == id;
});
return iter != notifications_.end() ? iter->get() : nullptr;
}
void AddNotification(
std::unique_ptr<message_center::Notification> notification) override {
notifications_.push_back(std::move(notification));
}
void UpdateNotification(
const std::string& old_id,
std::unique_ptr<message_center::Notification> new_notification) override {
RemoveNotification(old_id, false /* by_user */);
AddNotification(std::move(new_notification));
}
void RemoveNotification(const std::string& id, bool by_user) override {
if (!FindVisibleNotificationById(id))
return;
notifications_.erase(std::find_if(
notifications_.begin(), notifications_.end(),
[id](const std::shared_ptr<message_center::Notification> notification) {
return notification->id() == id;
}));
}
private:
std::vector<std::shared_ptr<message_center::Notification>> notifications_;
DISALLOW_COPY_AND_ASSIGN(TestMessageCenter);
};
class TestableNotificationController
: public EasyUnlockNotificationControllerChromeOS {
public:
TestableNotificationController(Profile* profile,
message_center::MessageCenter* message_center)
: EasyUnlockNotificationControllerChromeOS(profile, message_center) {}
~TestableNotificationController() override {}
// EasyUnlockNotificationControllerChromeOS:
MOCK_METHOD0(LaunchEasyUnlockSettings, void());
MOCK_METHOD0(LockScreen, void());
private:
DISALLOW_COPY_AND_ASSIGN(TestableNotificationController);
};
} // namespace
class EasyUnlockNotificationControllerChromeOSTest : public ::testing::Test {
protected:
EasyUnlockNotificationControllerChromeOSTest()
: notification_controller_(&profile_, &message_center_) {}
~EasyUnlockNotificationControllerChromeOSTest() override {}
const content::TestBrowserThreadBundle thread_bundle_;
TestingProfile profile_;
TestMessageCenter message_center_;
testing::StrictMock<TestableNotificationController> notification_controller_;
private:
DISALLOW_COPY_AND_ASSIGN(EasyUnlockNotificationControllerChromeOSTest);
};
TEST_F(EasyUnlockNotificationControllerChromeOSTest,
TestShowChromebookAddedNotification) {
const char kNotificationId[] = "easyunlock_notification_ids.chromebook_added";
notification_controller_.ShowChromebookAddedNotification();
message_center::Notification* notification =
message_center_.FindVisibleNotificationById(kNotificationId);
ASSERT_TRUE(notification);
ASSERT_EQ(1u, notification->buttons().size());
EXPECT_EQ(message_center::SYSTEM_PRIORITY, notification->priority());
// Clicking notification button should launch settings.
EXPECT_CALL(notification_controller_, LaunchEasyUnlockSettings());
notification->ButtonClick(0);
// Clicking the notification itself should also launch settings.
EXPECT_CALL(notification_controller_, LaunchEasyUnlockSettings());
notification->Click();
}
TEST_F(EasyUnlockNotificationControllerChromeOSTest,
TestShowPairingChangeNotification) {
const char kNotificationId[] = "easyunlock_notification_ids.pairing_change";
notification_controller_.ShowPairingChangeNotification();
message_center::Notification* notification =
message_center_.FindVisibleNotificationById(kNotificationId);
ASSERT_TRUE(notification);
ASSERT_EQ(2u, notification->buttons().size());
EXPECT_EQ(message_center::SYSTEM_PRIORITY, notification->priority());
// Clicking 1st notification button should lock screen settings.
EXPECT_CALL(notification_controller_, LockScreen());
notification->ButtonClick(0);
// Clicking 2nd notification button should launch settings.
EXPECT_CALL(notification_controller_, LaunchEasyUnlockSettings());
notification->ButtonClick(1);
// Clicking the notification itself should do nothing.
notification->Click();
}
TEST_F(EasyUnlockNotificationControllerChromeOSTest,
TestShowPairingChangeAppliedNotification) {
const char kNotificationId[] =
"easyunlock_notification_ids.pairing_change_applied";
notification_controller_.ShowPairingChangeAppliedNotification(kPhoneName);
message_center::Notification* notification =
message_center_.FindVisibleNotificationById(kNotificationId);
ASSERT_TRUE(notification);
ASSERT_EQ(1u, notification->buttons().size());
EXPECT_EQ(message_center::SYSTEM_PRIORITY, notification->priority());
// Check that the phone name is in the notification message.
EXPECT_NE(std::string::npos,
notification->message().find(base::UTF8ToUTF16(kPhoneName)));
// Clicking notification button should launch settings.
EXPECT_CALL(notification_controller_, LaunchEasyUnlockSettings());
notification->ButtonClick(0);
// Clicking the notification itself should also launch settings.
EXPECT_CALL(notification_controller_, LaunchEasyUnlockSettings());
notification->Click();
}
TEST_F(EasyUnlockNotificationControllerChromeOSTest,
PairingAppliedRemovesPairingChange) {
const char kPairingChangeId[] = "easyunlock_notification_ids.pairing_change";
const char kPairingAppliedId[] =
"easyunlock_notification_ids.pairing_change_applied";
notification_controller_.ShowPairingChangeNotification();
EXPECT_TRUE(message_center_.FindVisibleNotificationById(kPairingChangeId));
notification_controller_.ShowPairingChangeAppliedNotification(kPhoneName);
EXPECT_FALSE(message_center_.FindVisibleNotificationById(kPairingChangeId));
EXPECT_TRUE(message_center_.FindVisibleNotificationById(kPairingAppliedId));
}
TEST_F(EasyUnlockNotificationControllerChromeOSTest,
TestShowPromotionNotification) {
const char kNotificationId[] = "easyunlock_notification_ids.promotion";
notification_controller_.ShowPromotionNotification();
message_center::Notification* notification =
message_center_.FindVisibleNotificationById(kNotificationId);
ASSERT_TRUE(notification);
ASSERT_EQ(1u, notification->buttons().size());
EXPECT_EQ(message_center::SYSTEM_PRIORITY, notification->priority());
// Clicking notification button should launch settings.
EXPECT_CALL(notification_controller_, LaunchEasyUnlockSettings());
notification->ButtonClick(0);
// Clicking the notification itself should also launch settings.
EXPECT_CALL(notification_controller_, LaunchEasyUnlockSettings());
notification->Click();
}
...@@ -4085,6 +4085,7 @@ test("unit_tests") { ...@@ -4085,6 +4085,7 @@ test("unit_tests") {
"../browser/search/hotword_service_unittest.cc", "../browser/search/hotword_service_unittest.cc",
"../browser/signin/easy_unlock_app_manager_unittest.cc", "../browser/signin/easy_unlock_app_manager_unittest.cc",
"../browser/signin/easy_unlock_auth_attempt_unittest.cc", "../browser/signin/easy_unlock_auth_attempt_unittest.cc",
"../browser/signin/easy_unlock_notification_controller_chromeos_unittest.cc",
"../browser/signin/easy_unlock_screenlock_state_handler_unittest.cc", "../browser/signin/easy_unlock_screenlock_state_handler_unittest.cc",
"../browser/signin/easy_unlock_service_unittest_chromeos.cc", "../browser/signin/easy_unlock_service_unittest_chromeos.cc",
"../browser/sync/glue/extensions_activity_monitor_unittest.cc", "../browser/sync/glue/extensions_activity_monitor_unittest.cc",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment