Commit a0c9298d authored by Kyle Horimoto's avatar Kyle Horimoto Committed by Commit Bot

[CrOS MultiDevice] Rename MultiDeviceSetupObserver.

This CL changes its name to AccountStatusChangeDelegate. There are two
reasons for the change:
(1) In a follow-up CL, we will be adding a different type of observer,
    so specificity is needed to differentiate the two.
(2) The word "observer" generally implies that there can be more than
    one observer, whereas "delegate" generally implies that there is
    only one. This change was suggested by dcheng@ in
    https://chromium-review.googlesource.com/c/chromium/src/+/954010.

Bug: 824568
Change-Id: Ib17e415614ec1d0575a00288c59de789df7c68d7
Reviewed-on: https://chromium-review.googlesource.com/1107264Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Commit-Queue: Kyle Horimoto <khorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#568898}
parent 8cad95a2
......@@ -157,7 +157,7 @@ void MultiDeviceNotificationPresenter::OnSessionStateChanged(
}
void MultiDeviceNotificationPresenter::ObserveMultiDeviceSetupIfPossible() {
// If already observing, there is nothing else to do.
// If already the delegate, there is nothing else to do.
if (multidevice_setup_ptr_)
return;
......@@ -185,11 +185,12 @@ void MultiDeviceNotificationPresenter::ObserveMultiDeviceSetupIfPossible() {
chromeos::multidevice_setup::mojom::kServiceName, service_user_id),
&multidevice_setup_ptr_);
// Start observing the MultiDeviceSetup Service.
chromeos::multidevice_setup::mojom::MultiDeviceSetupObserverPtr observer_ptr;
binding_.Bind(mojo::MakeRequest(&observer_ptr));
multidevice_setup_ptr_->SetObserver(std::move(observer_ptr),
base::DoNothing());
// Add this object as the delegate of the MultiDeviceSetup Service.
chromeos::multidevice_setup::mojom::AccountStatusChangeDelegatePtr
delegate_ptr;
binding_.Bind(mojo::MakeRequest(&delegate_ptr));
multidevice_setup_ptr_->SetAccountStatusChangeDelegate(
std::move(delegate_ptr), base::DoNothing());
}
void MultiDeviceNotificationPresenter::OnNotificationClicked() {
......
......@@ -43,7 +43,7 @@ namespace ash {
// Note that if one notification is showing and another one is triggered, the
// old text is replaced (if it's different) and the notification pops up again.
class ASH_EXPORT MultiDeviceNotificationPresenter
: public chromeos::multidevice_setup::mojom::MultiDeviceSetupObserver,
: public chromeos::multidevice_setup::mojom::AccountStatusChangeDelegate,
public SessionObserver {
public:
MultiDeviceNotificationPresenter(
......@@ -57,7 +57,7 @@ class ASH_EXPORT MultiDeviceNotificationPresenter
void RemoveMultiDeviceSetupNotification();
protected:
// multidevice_setup::mojom::MultiDeviceSetupObserver:
// multidevice_setup::mojom::AccountStatusChangeDelegate:
void OnPotentialHostExistsForNewUser() override;
void OnConnectedHostSwitchedForExistingUser() override;
void OnNewChromebookAddedForExistingUser() override;
......@@ -128,7 +128,7 @@ class ASH_EXPORT MultiDeviceNotificationPresenter
chromeos::multidevice_setup::mojom::MultiDeviceSetupPtr
multidevice_setup_ptr_;
mojo::Binding<chromeos::multidevice_setup::mojom::MultiDeviceSetupObserver>
mojo::Binding<chromeos::multidevice_setup::mojom::AccountStatusChangeDelegate>
binding_;
std::unique_ptr<OpenUiDelegate> open_ui_delegate_;
......
......@@ -80,16 +80,17 @@ class TestMessageCenter : public message_center::FakeMessageCenter {
};
// Fake for the MultiDeviceSetup service. This class only implements the
// SetObserver() interface function since it's the only one that is used by
// MultiDeviceNotificationPresenter.
// SetAccountStatusChangeDelegate() interface function since it's the only one
// that is used by MultiDeviceNotificationPresenter.
class FakeMultiDeviceSetup
: public chromeos::multidevice_setup::mojom::MultiDeviceSetup {
public:
FakeMultiDeviceSetup() : binding_(this) {}
~FakeMultiDeviceSetup() override = default;
chromeos::multidevice_setup::mojom::MultiDeviceSetupObserverPtr& observer() {
return observer_;
chromeos::multidevice_setup::mojom::AccountStatusChangeDelegatePtr&
delegate() {
return delegate_;
}
void Bind(mojo::ScopedMessagePipeHandle handle) {
......@@ -98,10 +99,11 @@ class FakeMultiDeviceSetup
}
// mojom::MultiDeviceSetup:
void SetObserver(
chromeos::multidevice_setup::mojom::MultiDeviceSetupObserverPtr observer,
SetObserverCallback callback) override {
observer_ = std::move(observer);
void SetAccountStatusChangeDelegate(
chromeos::multidevice_setup::mojom::AccountStatusChangeDelegatePtr
delegate,
SetAccountStatusChangeDelegateCallback callback) override {
delegate_ = std::move(delegate);
std::move(callback).Run();
}
......@@ -112,7 +114,7 @@ class FakeMultiDeviceSetup
}
private:
chromeos::multidevice_setup::mojom::MultiDeviceSetupObserverPtr observer_;
chromeos::multidevice_setup::mojom::AccountStatusChangeDelegatePtr delegate_;
mojo::Binding<chromeos::multidevice_setup::mojom::MultiDeviceSetup> binding_;
};
......@@ -206,25 +208,25 @@ class MultiDeviceNotificationPresenterTest : public NoSessionAshTestBase {
AccountId::FromUserEmail(kTestUserEmail));
InvokePendingMojoCalls();
EXPECT_TRUE(fake_multidevice_setup_->observer().is_bound());
EXPECT_TRUE(fake_multidevice_setup_->delegate().is_bound());
}
void ShowNewUserNotification() {
EXPECT_TRUE(fake_multidevice_setup_->observer().is_bound());
fake_multidevice_setup_->observer()->OnPotentialHostExistsForNewUser();
EXPECT_TRUE(fake_multidevice_setup_->delegate().is_bound());
fake_multidevice_setup_->delegate()->OnPotentialHostExistsForNewUser();
InvokePendingMojoCalls();
}
void ShowExistingUserHostSwitchedNotification() {
EXPECT_TRUE(fake_multidevice_setup_->observer().is_bound());
fake_multidevice_setup_->observer()
EXPECT_TRUE(fake_multidevice_setup_->delegate().is_bound());
fake_multidevice_setup_->delegate()
->OnConnectedHostSwitchedForExistingUser();
InvokePendingMojoCalls();
}
void ShowExistingUserNewChromebookNotification() {
EXPECT_TRUE(fake_multidevice_setup_->observer().is_bound());
fake_multidevice_setup_->observer()->OnNewChromebookAddedForExistingUser();
EXPECT_TRUE(fake_multidevice_setup_->delegate().is_bound());
fake_multidevice_setup_->delegate()->OnNewChromebookAddedForExistingUser();
InvokePendingMojoCalls();
}
......@@ -348,15 +350,15 @@ TEST_F(MultiDeviceNotificationPresenterTest, NotSignedIntoAccount) {
session_manager::SessionState::LOGIN_SECONDARY};
// For each of the states which is not ACTIVE, set the session state. None of
// these should trigger a SetObserver() call.
// these should trigger a SetAccountStatusChangeDelegate() call.
for (const auto state : kNonActiveStates) {
GetSessionControllerClient()->SetSessionState(state);
InvokePendingMojoCalls();
EXPECT_FALSE(fake_multidevice_setup_->observer().is_bound());
EXPECT_FALSE(fake_multidevice_setup_->delegate().is_bound());
}
SignIntoAccount();
EXPECT_TRUE(fake_multidevice_setup_->observer().is_bound());
EXPECT_TRUE(fake_multidevice_setup_->delegate().is_bound());
}
TEST_F(MultiDeviceNotificationPresenterTest,
......
......@@ -10,12 +10,12 @@ assert(is_chromeos, "Non-ChromeOS builds cannot depend on //chromeos")
static_library("multidevice_setup") {
sources = [
"account_status_change_delegate_notifier.cc",
"account_status_change_delegate_notifier.h",
"multidevice_setup_impl.cc",
"multidevice_setup_impl.h",
"multidevice_setup_service.cc",
"multidevice_setup_service.h",
"observer_notifier.cc",
"observer_notifier.h",
"setup_flow_completion_recorder.h",
"setup_flow_completion_recorder_impl.cc",
"setup_flow_completion_recorder_impl.h",
......@@ -43,8 +43,8 @@ static_library("test_support") {
testonly = true
sources = [
"fake_multidevice_setup_observer.cc",
"fake_multidevice_setup_observer.h",
"fake_account_status_change_delegate.cc",
"fake_account_status_change_delegate.h",
"fake_setup_flow_completion_recorder.cc",
"fake_setup_flow_completion_recorder.h",
]
......@@ -66,8 +66,8 @@ source_set("unit_tests") {
testonly = true
sources = [
"account_status_change_delegate_notifier_unittest.cc",
"multidevice_setup_service_unittest.cc",
"observer_notifier_unittest.cc",
"setup_flow_completion_recorder_impl_unittest.cc",
]
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROMEOS_SERVICES_MULTIDEVICE_SETUP_OBSERVER_NOTIFIER_H_
#define CHROMEOS_SERVICES_MULTIDEVICE_SETUP_OBSERVER_NOTIFIER_H_
#ifndef CHROMEOS_SERVICES_MULTIDEVICE_SETUP_ACCOUNT_STATUS_CHANGE_DELEGATE_NOTIFIER_H_
#define CHROMEOS_SERVICES_MULTIDEVICE_SETUP_ACCOUNT_STATUS_CHANGE_DELEGATE_NOTIFIER_H_
#include <memory>
#include <string>
......@@ -17,7 +17,7 @@ class PrefService;
namespace base {
class Clock;
}
} // namespace base
namespace chromeos {
......@@ -25,19 +25,20 @@ namespace multidevice_setup {
class SetupFlowCompletionRecorder;
// Notifies the observer of MultiDeviceSetup for each of the following changes:
// Notifies the delegate of MultiDeviceSetup for each of the following changes:
// (1) a potential host is found for someone who has not gone through the setup
// flow before,
// (2) the host has switched for someone who has, or
// (3) a new Chromebook has been added to an account for someone who has.
class ObserverNotifier : public device_sync::DeviceSyncClient::Observer {
class AccountStatusChangeDelegateNotifier
: public device_sync::DeviceSyncClient::Observer {
public:
class Factory {
public:
static Factory* Get();
static void SetFactoryForTesting(Factory* test_factory);
virtual ~Factory();
virtual std::unique_ptr<ObserverNotifier> BuildInstance(
virtual std::unique_ptr<AccountStatusChangeDelegateNotifier> BuildInstance(
device_sync::DeviceSyncClient* device_sync_client,
PrefService* pref_service,
SetupFlowCompletionRecorder* setup_flow_completion_recorder,
......@@ -49,13 +50,13 @@ class ObserverNotifier : public device_sync::DeviceSyncClient::Observer {
static void RegisterPrefs(PrefRegistrySimple* registry);
~ObserverNotifier() override;
~AccountStatusChangeDelegateNotifier() override;
void SetMultiDeviceSetupObserverPtr(
mojom::MultiDeviceSetupObserverPtr observer_ptr);
void SetAccountStatusChangeDelegatePtr(
mojom::AccountStatusChangeDelegatePtr delegate_ptr);
private:
friend class ObserverNotifierTest;
friend class MultiDeviceSetupAccountStatusChangeDelegateNotifierTest;
static const char kNewUserPotentialHostExistsPrefName[];
static const char kExistingUserHostSwitchedPrefName[];
......@@ -63,10 +64,11 @@ class ObserverNotifier : public device_sync::DeviceSyncClient::Observer {
static const char kHostPublicKeyFromMostRecentSyncPrefName[];
ObserverNotifier(device_sync::DeviceSyncClient* device_sync_client,
PrefService* pref_service,
SetupFlowCompletionRecorder* setup_flow_completion_recorder,
base::Clock* clock);
AccountStatusChangeDelegateNotifier(
device_sync::DeviceSyncClient* device_sync_client,
PrefService* pref_service,
SetupFlowCompletionRecorder* setup_flow_completion_recorder,
base::Clock* clock);
// device_sync::DeviceSyncClient::Observer:
void OnNewDevicesSynced() override;
......@@ -80,26 +82,26 @@ class ObserverNotifier : public device_sync::DeviceSyncClient::Observer {
void CheckForExistingUserChromebookAddedEvent(
bool local_device_was_enabled_client_before_sync);
void FlushForTesting();
// Loads data from previous session using PrefService.
base::Optional<std::string> LoadHostPublicKeyFromEndOfPreviousSession();
void FlushForTesting();
// Set to base::nullopt if there was no enabled host in the most recent sync.
base::Optional<std::string> host_public_key_from_most_recent_sync_;
bool local_device_is_enabled_client_;
mojom::MultiDeviceSetupObserverPtr observer_ptr_;
mojom::AccountStatusChangeDelegatePtr delegate_ptr_;
device_sync::DeviceSyncClient* device_sync_client_;
PrefService* pref_service_;
SetupFlowCompletionRecorder* setup_flow_completion_recorder_;
base::Clock* clock_;
DISALLOW_COPY_AND_ASSIGN(ObserverNotifier);
DISALLOW_COPY_AND_ASSIGN(AccountStatusChangeDelegateNotifier);
};
} // namespace multidevice_setup
} // namespace chromeos
#endif // CHROMEOS_SERVICES_MULTIDEVICE_SETUP_OBSERVER_NOTIFIER_H_
#endif // CHROMEOS_SERVICES_MULTIDEVICE_SETUP_ACCOUNT_STATUS_CHANGE_DELEGATE_NOTIFIER_H_
......@@ -2,32 +2,32 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chromeos/services/multidevice_setup/fake_multidevice_setup_observer.h"
#include "chromeos/services/multidevice_setup/fake_account_status_change_delegate.h"
namespace chromeos {
namespace multidevice_setup {
FakeMultiDeviceSetupObserver::FakeMultiDeviceSetupObserver() = default;
FakeAccountStatusChangeDelegate::FakeAccountStatusChangeDelegate() = default;
FakeMultiDeviceSetupObserver::~FakeMultiDeviceSetupObserver() = default;
FakeAccountStatusChangeDelegate::~FakeAccountStatusChangeDelegate() = default;
mojom::MultiDeviceSetupObserverPtr
FakeMultiDeviceSetupObserver::GenerateInterfacePtr() {
mojom::MultiDeviceSetupObserverPtr interface_ptr;
mojom::AccountStatusChangeDelegatePtr
FakeAccountStatusChangeDelegate::GenerateInterfacePtr() {
mojom::AccountStatusChangeDelegatePtr interface_ptr;
bindings_.AddBinding(this, mojo::MakeRequest(&interface_ptr));
return interface_ptr;
}
void FakeMultiDeviceSetupObserver::OnPotentialHostExistsForNewUser() {
void FakeAccountStatusChangeDelegate::OnPotentialHostExistsForNewUser() {
++num_new_user_events_handled_;
}
void FakeMultiDeviceSetupObserver::OnConnectedHostSwitchedForExistingUser() {
void FakeAccountStatusChangeDelegate::OnConnectedHostSwitchedForExistingUser() {
++num_existing_user_host_switched_events_handled_;
}
void FakeMultiDeviceSetupObserver::OnNewChromebookAddedForExistingUser() {
void FakeAccountStatusChangeDelegate::OnNewChromebookAddedForExistingUser() {
++num_existing_user_chromebook_added_events_handled_;
}
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROMEOS_SERVICES_MULTIDEVICE_SETUP_FAKE_MULTIDEVICE_SETUP_OBSERVER_H_
#define CHROMEOS_SERVICES_MULTIDEVICE_SETUP_FAKE_MULTIDEVICE_SETUP_OBSERVER_H_
#ifndef CHROMEOS_SERVICES_MULTIDEVICE_SETUP_FAKE_ACCOUNT_STATUS_CHANGE_DELEGATE_H_
#define CHROMEOS_SERVICES_MULTIDEVICE_SETUP_FAKE_ACCOUNT_STATUS_CHANGE_DELEGATE_H_
#include "base/macros.h"
#include "chromeos/services/multidevice_setup/public/mojom/multidevice_setup.mojom.h"
......@@ -13,13 +13,14 @@ namespace chromeos {
namespace multidevice_setup {
// Fake MultiDeviceSetupObserver implementation for tests.
class FakeMultiDeviceSetupObserver : public mojom::MultiDeviceSetupObserver {
// Fake mojom::AccountStatusChangeDelegate implementation for tests.
class FakeAccountStatusChangeDelegate
: public mojom::AccountStatusChangeDelegate {
public:
FakeMultiDeviceSetupObserver();
~FakeMultiDeviceSetupObserver() override;
FakeAccountStatusChangeDelegate();
~FakeAccountStatusChangeDelegate() override;
mojom::MultiDeviceSetupObserverPtr GenerateInterfacePtr();
mojom::AccountStatusChangeDelegatePtr GenerateInterfacePtr();
size_t num_new_user_events_handled() { return num_new_user_events_handled_; }
......@@ -31,7 +32,7 @@ class FakeMultiDeviceSetupObserver : public mojom::MultiDeviceSetupObserver {
return num_existing_user_chromebook_added_events_handled_;
}
// mojom::MultiDeviceSetupObserver:
// mojom::AccountStatusChangeDelegate:
void OnPotentialHostExistsForNewUser() override;
void OnConnectedHostSwitchedForExistingUser() override;
void OnNewChromebookAddedForExistingUser() override;
......@@ -41,13 +42,13 @@ class FakeMultiDeviceSetupObserver : public mojom::MultiDeviceSetupObserver {
size_t num_existing_user_host_switched_events_handled_ = 0u;
size_t num_existing_user_chromebook_added_events_handled_ = 0u;
mojo::BindingSet<mojom::MultiDeviceSetupObserver> bindings_;
mojo::BindingSet<mojom::AccountStatusChangeDelegate> bindings_;
DISALLOW_COPY_AND_ASSIGN(FakeMultiDeviceSetupObserver);
DISALLOW_COPY_AND_ASSIGN(FakeAccountStatusChangeDelegate);
};
} // namespace multidevice_setup
} // namespace chromeos
#endif // CHROMEOS_SERVICES_MULTIDEVICE_SETUP_FAKE_MULTIDEVICE_SETUP_OBSERVER_H_
#endif // CHROMEOS_SERVICES_MULTIDEVICE_SETUP_FAKE_ACCOUNT_STATUS_CHANGE_DELEGATE_H_
......@@ -10,24 +10,6 @@ namespace chromeos {
namespace multidevice_setup {
namespace {
std::string EventTypeEnumToString(mojom::EventTypeForDebugging type) {
switch (type) {
case mojom::EventTypeForDebugging::kNewUserPotentialHostExists:
return "kNewUserPotentialHostExists";
case mojom::EventTypeForDebugging::kExistingUserConnectedHostSwitched:
return "kExistingUserConnectedHostSwitched";
case mojom::EventTypeForDebugging::kExistingUserNewChromebookAdded:
return "kExistingUserNewChromebookAdded";
default:
NOTREACHED();
return "[invalid input]";
}
}
} // namespace
MultiDeviceSetupImpl::MultiDeviceSetupImpl() = default;
MultiDeviceSetupImpl::~MultiDeviceSetupImpl() = default;
......@@ -36,42 +18,35 @@ void MultiDeviceSetupImpl::BindRequest(mojom::MultiDeviceSetupRequest request) {
bindings_.AddBinding(this, std::move(request));
}
void MultiDeviceSetupImpl::SetObserver(
mojom::MultiDeviceSetupObserverPtr observer,
SetObserverCallback callback) {
if (observer_.is_bound()) {
PA_LOG(ERROR) << "SetObserver() called when a MultiDeviceSetupObserver was "
<< "already set. Replacing the previously-set "
<< "MultiDeviceSetupObserver.";
}
PA_LOG(INFO) << "MultiDeviceSetupImpl::SetObserver()";
observer_ = std::move(observer);
void MultiDeviceSetupImpl::SetAccountStatusChangeDelegate(
mojom::AccountStatusChangeDelegatePtr delegate,
SetAccountStatusChangeDelegateCallback callback) {
delegate_ = std::move(delegate);
std::move(callback).Run();
}
void MultiDeviceSetupImpl::TriggerEventForDebugging(
mojom::EventTypeForDebugging type,
TriggerEventForDebuggingCallback callback) {
PA_LOG(INFO) << "TriggerEventForDebugging(" << EventTypeEnumToString(type)
PA_LOG(INFO) << "MultiDeviceSetupImpl::TriggerEventForDebugging(" << type
<< ") called.";
if (!observer_.is_bound()) {
PA_LOG(ERROR) << "No MultiDeviceSetupObserver has been set. Cannot "
<< "proceed.";
if (!delegate_.is_bound()) {
PA_LOG(ERROR) << "MultiDeviceSetupImpl::TriggerEventForDebugging(): No "
<< "delgate has been set; cannot proceed.";
std::move(callback).Run(false /* success */);
return;
}
switch (type) {
case mojom::EventTypeForDebugging::kNewUserPotentialHostExists:
observer_->OnPotentialHostExistsForNewUser();
delegate_->OnPotentialHostExistsForNewUser();
break;
case mojom::EventTypeForDebugging::kExistingUserConnectedHostSwitched:
observer_->OnConnectedHostSwitchedForExistingUser();
delegate_->OnConnectedHostSwitchedForExistingUser();
break;
case mojom::EventTypeForDebugging::kExistingUserNewChromebookAdded:
observer_->OnNewChromebookAddedForExistingUser();
delegate_->OnNewChromebookAddedForExistingUser();
break;
default:
NOTREACHED();
......
......@@ -27,14 +27,15 @@ class MultiDeviceSetupImpl : public mojom::MultiDeviceSetup {
void BindRequest(mojom::MultiDeviceSetupRequest request);
// mojom::MultiDeviceSetup:
void SetObserver(mojom::MultiDeviceSetupObserverPtr presenter,
SetObserverCallback callback) override;
void SetAccountStatusChangeDelegate(
mojom::AccountStatusChangeDelegatePtr delegate,
SetAccountStatusChangeDelegateCallback callback) override;
void TriggerEventForDebugging(
mojom::EventTypeForDebugging type,
TriggerEventForDebuggingCallback callback) override;
private:
mojom::MultiDeviceSetupObserverPtr observer_;
mojom::AccountStatusChangeDelegatePtr delegate_;
mojo::BindingSet<mojom::MultiDeviceSetup> bindings_;
DISALLOW_COPY_AND_ASSIGN(MultiDeviceSetupImpl);
......
......@@ -7,7 +7,7 @@
#include "base/memory/ptr_util.h"
#include "base/run_loop.h"
#include "base/test/scoped_task_environment.h"
#include "chromeos/services/multidevice_setup/fake_multidevice_setup_observer.h"
#include "chromeos/services/multidevice_setup/fake_account_status_change_delegate.h"
#include "chromeos/services/multidevice_setup/multidevice_setup_service.h"
#include "chromeos/services/multidevice_setup/public/mojom/constants.mojom.h"
#include "chromeos/services/multidevice_setup/public/mojom/multidevice_setup.mojom.h"
......@@ -24,8 +24,8 @@ class MultiDeviceSetupServiceTest : public testing::Test {
~MultiDeviceSetupServiceTest() override = default;
void SetUp() override {
fake_multidevice_setup_observer_ =
std::make_unique<FakeMultiDeviceSetupObserver>();
fake_account_status_change_delegate_ =
std::make_unique<FakeAccountStatusChangeDelegate>();
connector_factory_ =
service_manager::TestConnectorFactory::CreateForUniqueService(
std::make_unique<MultiDeviceSetupService>());
......@@ -39,21 +39,21 @@ class MultiDeviceSetupServiceTest : public testing::Test {
connector_ = connector_factory_->CreateConnector();
connector_->BindInterface(mojom::kServiceName, &multidevice_setup_);
// Set |fake_multidevice_setup_observer_|.
CallSetObserver();
// Set |fake_account_status_change_delegate_|.
CallSetAccountStatusChangeDelegate();
}
return multidevice_setup_.get();
}
FakeMultiDeviceSetupObserver* fake_multidevice_setup_observer() {
return fake_multidevice_setup_observer_.get();
FakeAccountStatusChangeDelegate* fake_account_status_change_delegate() {
return fake_account_status_change_delegate_.get();
}
void CallSetObserver() {
void CallSetAccountStatusChangeDelegate() {
base::RunLoop run_loop;
multidevice_setup_->SetObserver(
fake_multidevice_setup_observer_->GenerateInterfacePtr(),
multidevice_setup_->SetAccountStatusChangeDelegate(
fake_account_status_change_delegate_->GenerateInterfacePtr(),
base::BindOnce(
&MultiDeviceSetupServiceTest::OnNotificationPresenterRegistered,
base::Unretained(this), run_loop.QuitClosure()));
......@@ -87,8 +87,8 @@ class MultiDeviceSetupServiceTest : public testing::Test {
std::unique_ptr<service_manager::TestConnectorFactory> connector_factory_;
std::unique_ptr<service_manager::Connector> connector_;
std::unique_ptr<FakeMultiDeviceSetupObserver>
fake_multidevice_setup_observer_;
std::unique_ptr<FakeAccountStatusChangeDelegate>
fake_account_status_change_delegate_;
mojom::MultiDeviceSetupPtr multidevice_setup_;
DISALLOW_COPY_AND_ASSIGN(MultiDeviceSetupServiceTest);
......@@ -99,8 +99,8 @@ TEST_F(MultiDeviceSetupServiceTest,
CallTriggerEventForDebugging(
mojom::EventTypeForDebugging::kNewUserPotentialHostExists);
EXPECT_EQ(1u,
fake_multidevice_setup_observer()->num_new_user_events_handled());
EXPECT_EQ(
1u, fake_account_status_change_delegate()->num_new_user_events_handled());
}
TEST_F(MultiDeviceSetupServiceTest,
......@@ -108,7 +108,7 @@ TEST_F(MultiDeviceSetupServiceTest,
CallTriggerEventForDebugging(
mojom::EventTypeForDebugging::kExistingUserConnectedHostSwitched);
EXPECT_EQ(1u, fake_multidevice_setup_observer()
EXPECT_EQ(1u, fake_account_status_change_delegate()
->num_existing_user_host_switched_events_handled());
}
......@@ -117,7 +117,7 @@ TEST_F(MultiDeviceSetupServiceTest,
CallTriggerEventForDebugging(
mojom::EventTypeForDebugging::kExistingUserNewChromebookAdded);
EXPECT_EQ(1u, fake_multidevice_setup_observer()
EXPECT_EQ(1u, fake_account_status_change_delegate()
->num_existing_user_chromebook_added_events_handled());
}
......
......@@ -4,8 +4,7 @@
module chromeos.multidevice_setup.mojom;
// Handles events dispatched by MultiDeviceSetup.
interface MultiDeviceSetupObserver {
interface AccountStatusChangeDelegate {
// Callback which indicates that one or more MultiDevice host phones are
// available for setup with the MultiDevice setup flow. This function is only
// called if the current user has not yet set up MultiDevice features.
......@@ -37,12 +36,10 @@ enum EventTypeForDebugging {
// chrome://proximity-auth (debugging only).
// TODO(khorimoto): Finish fleshing out this interface.
interface MultiDeviceSetup {
// Registers the observer to be used by the service. Once this function has
// been called, the service will begin monitoring changes to synced devices
// and will notify |observer| when appropriate. Only one observer can be
// active at a time; calling this function a second time will remove the
// first observer added.
SetObserver(MultiDeviceSetupObserver observer) => ();
// Registers the "account status change" delegate to be used by the service.
// Only one delegate can be set; this function should not be called more than
// once.
SetAccountStatusChangeDelegate(AccountStatusChangeDelegate delegate) => ();
// Triggers an event to be dispatched by the service. This API function is
// intended to be used only for debugging in the chrome://proximity-auth page.
......
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