summaryrefslogtreecommitdiffstats
path: root/chrome/browser/managed_mode
diff options
context:
space:
mode:
authorantrim@chromium.org <antrim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-29 12:23:25 +0000
committerantrim@chromium.org <antrim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-29 12:23:25 +0000
commit841202c8efe7d791a72b4ebcd4ebb784fe49d672 (patch)
tree658b74b81dc81627bec3d89ea9824887ffbe785a /chrome/browser/managed_mode
parent9eda541c4a5c125fb076b01179d3ea02f2dd3b36 (diff)
downloadchromium_src-841202c8efe7d791a72b4ebcd4ebb784fe49d672.zip
chromium_src-841202c8efe7d791a72b4ebcd4ebb784fe49d672.tar.gz
chromium_src-841202c8efe7d791a72b4ebcd4ebb784fe49d672.tar.bz2
Write automated tests for front-end Playpen
Add test for Supervised user creation and login BUG=265589 Review URL: https://chromiumcodereview.appspot.com/23383014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@220280 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/managed_mode')
-rw-r--r--chrome/browser/managed_mode/managed_user_registration_utility.cc170
-rw-r--r--chrome/browser/managed_mode/managed_user_registration_utility.h83
-rw-r--r--chrome/browser/managed_mode/managed_user_registration_utility_stub.cc47
-rw-r--r--chrome/browser/managed_mode/managed_user_registration_utility_stub.h47
-rw-r--r--chrome/browser/managed_mode/managed_user_registration_utility_unittest.cc45
5 files changed, 285 insertions, 107 deletions
diff --git a/chrome/browser/managed_mode/managed_user_registration_utility.cc b/chrome/browser/managed_mode/managed_user_registration_utility.cc
index e1f86919..72404c6 100644
--- a/chrome/browser/managed_mode/managed_user_registration_utility.cc
+++ b/chrome/browser/managed_mode/managed_user_registration_utility.cc
@@ -27,43 +27,119 @@
using base::DictionaryValue;
+namespace {
+
const char kAcknowledged[] = "acknowledged";
const char kName[] = "name";
const char kMasterKey[] = "masterKey";
+ManagedUserRegistrationUtility* g_instance_for_tests = NULL;
+
+// Actual implementation of ManagedUserRegistrationUtility.
+class ManagedUserRegistrationUtilityImpl
+ : public ManagedUserRegistrationUtility,
+ public ManagedUserSyncServiceObserver {
+ public:
+ ManagedUserRegistrationUtilityImpl(
+ PrefService* prefs,
+ scoped_ptr<ManagedUserRefreshTokenFetcher> token_fetcher,
+ ManagedUserSyncService* service);
+
+ virtual ~ManagedUserRegistrationUtilityImpl();
+
+ // Registers a new managed user with the server. |managed_user_id| is a new
+ // unique ID for the new managed user. If its value is the same as that of
+ // of one of the existing managed users, then the same user will be created
+ // on this machine. |info| contains necessary information like the display
+ // name of the the user. |callback| is called with the result of the
+ // registration. We use the info here and not the profile, because on
+ // Chrome OS the profile of the managed user does not yet exist.
+ virtual void Register(const std::string& managed_user_id,
+ const ManagedUserRegistrationInfo& info,
+ const RegistrationCallback& callback) OVERRIDE;
+
+ // ManagedUserSyncServiceObserver:
+ virtual void OnManagedUserAcknowledged(const std::string& managed_user_id)
+ OVERRIDE;
+ virtual void OnManagedUsersSyncingStopped() OVERRIDE;
+
+ private:
+ // Fetches the managed user token when we have the device name.
+ void FetchToken(const std::string& client_name);
+
+ // Called when we have received a token for the managed user.
+ void OnReceivedToken(const GoogleServiceAuthError& error,
+ const std::string& token);
+
+ // Dispatches the callback and cleans up if all the conditions have been met.
+ void CompleteRegistrationIfReady();
+
+ // Aborts any registration currently in progress. If |run_callback| is true,
+ // calls the callback specified in Register() with the given |error|.
+ void AbortPendingRegistration(bool run_callback,
+ const GoogleServiceAuthError& error);
+
+ // If |run_callback| is true, dispatches the callback with the saved token
+ // (which may be empty) and the given |error|. In any case, resets internal
+ // variables to be ready for the next registration.
+ void CompleteRegistration(bool run_callback,
+ const GoogleServiceAuthError& error);
+
+ // Cancels any registration currently in progress, without calling the
+ // callback or reporting an error.
+ void CancelPendingRegistration();
+
+ base::WeakPtrFactory<ManagedUserRegistrationUtilityImpl> weak_ptr_factory_;
+ PrefService* prefs_;
+ scoped_ptr<ManagedUserRefreshTokenFetcher> token_fetcher_;
+
+ // A |BrowserContextKeyedService| owned by the custodian profile.
+ ManagedUserSyncService* managed_user_sync_service_;
+
+ std::string pending_managed_user_id_;
+ std::string pending_managed_user_token_;
+ bool pending_managed_user_acknowledged_;
+ bool is_existing_managed_user_;
+ RegistrationCallback callback_;
+
+ DISALLOW_COPY_AND_ASSIGN(ManagedUserRegistrationUtilityImpl);
+};
+
+} // namespace
+
ManagedUserRegistrationInfo::ManagedUserRegistrationInfo(const string16& name)
: name(name) {
}
-ManagedUserRegistrationUtility::ManagedUserRegistrationUtility(
- PrefService* prefs,
- scoped_ptr<ManagedUserRefreshTokenFetcher> token_fetcher,
- ManagedUserSyncService* service)
- : weak_ptr_factory_(this),
- prefs_(prefs),
- token_fetcher_(token_fetcher.Pass()),
- managed_user_sync_service_(service),
- pending_managed_user_acknowledged_(false),
- is_existing_managed_user_(false) {
- managed_user_sync_service_->AddObserver(this);
+ScopedTestingManagedUserRegistrationUtility::
+ ScopedTestingManagedUserRegistrationUtility(
+ ManagedUserRegistrationUtility* instance) {
+ ManagedUserRegistrationUtility::SetUtilityForTests(instance);
}
-ManagedUserRegistrationUtility::~ManagedUserRegistrationUtility() {
- managed_user_sync_service_->RemoveObserver(this);
- CancelPendingRegistration();
+ScopedTestingManagedUserRegistrationUtility::
+ ~ScopedTestingManagedUserRegistrationUtility() {
+ ManagedUserRegistrationUtility::SetUtilityForTests(NULL);
}
// static
scoped_ptr<ManagedUserRegistrationUtility>
ManagedUserRegistrationUtility::Create(Profile* profile) {
+ if (g_instance_for_tests) {
+ ManagedUserRegistrationUtility* result = g_instance_for_tests;
+ g_instance_for_tests = NULL;
+ return make_scoped_ptr(result);
+ }
scoped_ptr<ManagedUserRefreshTokenFetcher> token_fetcher =
ManagedUserRefreshTokenFetcher::Create(
ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
profile->GetRequestContext());
ManagedUserSyncService* managed_user_sync_service =
ManagedUserSyncServiceFactory::GetForProfile(profile);
- return make_scoped_ptr(new ManagedUserRegistrationUtility(
- profile->GetPrefs(), token_fetcher.Pass(), managed_user_sync_service));
+ return make_scoped_ptr(ManagedUserRegistrationUtility::CreateImpl(
+ profile->GetPrefs(),
+ token_fetcher.Pass(),
+ managed_user_sync_service));
}
// static
@@ -75,7 +151,45 @@ std::string ManagedUserRegistrationUtility::GenerateNewManagedUserId() {
return new_managed_user_id;
}
-void ManagedUserRegistrationUtility::Register(
+// static
+void ManagedUserRegistrationUtility::SetUtilityForTests(
+ ManagedUserRegistrationUtility* utility) {
+ if (g_instance_for_tests)
+ delete g_instance_for_tests;
+ g_instance_for_tests = utility;
+}
+
+// static
+ManagedUserRegistrationUtility* ManagedUserRegistrationUtility::CreateImpl(
+ PrefService* prefs,
+ scoped_ptr<ManagedUserRefreshTokenFetcher> token_fetcher,
+ ManagedUserSyncService* service) {
+ return new ManagedUserRegistrationUtilityImpl(prefs,
+ token_fetcher.Pass(),
+ service);
+}
+
+namespace {
+
+ManagedUserRegistrationUtilityImpl::ManagedUserRegistrationUtilityImpl(
+ PrefService* prefs,
+ scoped_ptr<ManagedUserRefreshTokenFetcher> token_fetcher,
+ ManagedUserSyncService* service)
+ : weak_ptr_factory_(this),
+ prefs_(prefs),
+ token_fetcher_(token_fetcher.Pass()),
+ managed_user_sync_service_(service),
+ pending_managed_user_acknowledged_(false),
+ is_existing_managed_user_(false) {
+ managed_user_sync_service_->AddObserver(this);
+}
+
+ManagedUserRegistrationUtilityImpl::~ManagedUserRegistrationUtilityImpl() {
+ managed_user_sync_service_->RemoveObserver(this);
+ CancelPendingRegistration();
+}
+
+void ManagedUserRegistrationUtilityImpl::Register(
const std::string& managed_user_id,
const ManagedUserRegistrationInfo& info,
const RegistrationCallback& callback) {
@@ -95,17 +209,17 @@ void ManagedUserRegistrationUtility::Register(
}
browser_sync::DeviceInfo::GetClientName(
- base::Bind(&ManagedUserRegistrationUtility::FetchToken,
+ base::Bind(&ManagedUserRegistrationUtilityImpl::FetchToken,
weak_ptr_factory_.GetWeakPtr()));
}
-void ManagedUserRegistrationUtility::CancelPendingRegistration() {
+void ManagedUserRegistrationUtilityImpl::CancelPendingRegistration() {
AbortPendingRegistration(
false, // Don't run the callback. The error will be ignored.
GoogleServiceAuthError(GoogleServiceAuthError::NONE));
}
-void ManagedUserRegistrationUtility::OnManagedUserAcknowledged(
+void ManagedUserRegistrationUtilityImpl::OnManagedUserAcknowledged(
const std::string& managed_user_id) {
DCHECK_EQ(pending_managed_user_id_, managed_user_id);
DCHECK(!pending_managed_user_acknowledged_);
@@ -113,21 +227,21 @@ void ManagedUserRegistrationUtility::OnManagedUserAcknowledged(
CompleteRegistrationIfReady();
}
-void ManagedUserRegistrationUtility::OnManagedUsersSyncingStopped() {
+void ManagedUserRegistrationUtilityImpl::OnManagedUsersSyncingStopped() {
AbortPendingRegistration(
true, // Run the callback.
GoogleServiceAuthError(GoogleServiceAuthError::REQUEST_CANCELED));
}
-void ManagedUserRegistrationUtility::FetchToken(
+void ManagedUserRegistrationUtilityImpl::FetchToken(
const std::string& client_name) {
token_fetcher_->Start(
pending_managed_user_id_, client_name,
- base::Bind(&ManagedUserRegistrationUtility::OnReceivedToken,
+ base::Bind(&ManagedUserRegistrationUtilityImpl::OnReceivedToken,
weak_ptr_factory_.GetWeakPtr()));
}
-void ManagedUserRegistrationUtility::OnReceivedToken(
+void ManagedUserRegistrationUtilityImpl::OnReceivedToken(
const GoogleServiceAuthError& error,
const std::string& token) {
if (error.state() != GoogleServiceAuthError::NONE) {
@@ -140,7 +254,7 @@ void ManagedUserRegistrationUtility::OnReceivedToken(
CompleteRegistrationIfReady();
}
-void ManagedUserRegistrationUtility::CompleteRegistrationIfReady() {
+void ManagedUserRegistrationUtilityImpl::CompleteRegistrationIfReady() {
bool require_acknowledgment =
!pending_managed_user_acknowledged_ &&
!CommandLine::ForCurrentProcess()->HasSwitch(
@@ -152,14 +266,14 @@ void ManagedUserRegistrationUtility::CompleteRegistrationIfReady() {
CompleteRegistration(true, error);
}
-void ManagedUserRegistrationUtility::AbortPendingRegistration(
+void ManagedUserRegistrationUtilityImpl::AbortPendingRegistration(
bool run_callback,
const GoogleServiceAuthError& error) {
pending_managed_user_token_.clear();
CompleteRegistration(run_callback, error);
}
-void ManagedUserRegistrationUtility::CompleteRegistration(
+void ManagedUserRegistrationUtilityImpl::CompleteRegistration(
bool run_callback,
const GoogleServiceAuthError& error) {
if (callback_.is_null())
@@ -182,3 +296,5 @@ void ManagedUserRegistrationUtility::CompleteRegistration(
callback_.Run(error, pending_managed_user_token_);
callback_.Reset();
}
+
+} // namespace
diff --git a/chrome/browser/managed_mode/managed_user_registration_utility.h b/chrome/browser/managed_mode/managed_user_registration_utility.h
index 5e6fe52..716f18c 100644
--- a/chrome/browser/managed_mode/managed_user_registration_utility.h
+++ b/chrome/browser/managed_mode/managed_user_registration_utility.h
@@ -8,6 +8,7 @@
#include <map>
#include <string>
+#include "base/basictypes.h"
#include "base/callback.h"
#include "base/gtest_prod_util.h"
#include "base/memory/weak_ptr.h"
@@ -39,8 +40,7 @@ struct ManagedUserRegistrationInfo {
// management server and associating it with its custodian. Each instance
// of this class handles registering a single managed user and should not
// be used afterwards.
-class ManagedUserRegistrationUtility
- : public ManagedUserSyncServiceObserver {
+class ManagedUserRegistrationUtility {
public:
// Callback for Register() below. If registration is successful, |token| will
// contain an OAuth2 refresh token for the newly registered managed user,
@@ -50,8 +50,9 @@ class ManagedUserRegistrationUtility
const std::string& /* token */)>
RegistrationCallback;
- virtual ~ManagedUserRegistrationUtility();
+ virtual ~ManagedUserRegistrationUtility() {}
+ // Creates ManagedUserRegistrationUtility for a given |profile|.
static scoped_ptr<ManagedUserRegistrationUtility> Create(Profile* profile);
static std::string GenerateNewManagedUserId();
@@ -63,68 +64,38 @@ class ManagedUserRegistrationUtility
// name of the the user. |callback| is called with the result of the
// registration. We use the info here and not the profile, because on
// Chrome OS the profile of the managed user does not yet exist.
- void Register(const std::string& managed_user_id,
- const ManagedUserRegistrationInfo& info,
- const RegistrationCallback& callback);
+ virtual void Register(const std::string& managed_user_id,
+ const ManagedUserRegistrationInfo& info,
+ const RegistrationCallback& callback) = 0;
- // ManagedUserSyncServiceObserver:
- virtual void OnManagedUserAcknowledged(const std::string& managed_user_id)
- OVERRIDE;
- virtual void OnManagedUsersSyncingStopped() OVERRIDE;
+ protected:
+ ManagedUserRegistrationUtility() {}
private:
- FRIEND_TEST_ALL_PREFIXES(ManagedUserRegistrationUtilityTest, Register);
- FRIEND_TEST_ALL_PREFIXES(ManagedUserRegistrationUtilityTest,
- RegisterBeforeInitialSync);
- FRIEND_TEST_ALL_PREFIXES(ManagedUserRegistrationUtilityTest,
- SyncServiceShutdownBeforeRegFinish);
- FRIEND_TEST_ALL_PREFIXES(ManagedUserRegistrationUtilityTest,
- StopSyncingBeforeRegFinish);
-
- // Use the |Create(...)| method to get instances of this class.
- ManagedUserRegistrationUtility(
+ friend class ScopedTestingManagedUserRegistrationUtility;
+ friend class ManagedUserRegistrationUtilityTest;
+
+ // Creates implementation with explicit dependencies, can be used for testing.
+ static ManagedUserRegistrationUtility* CreateImpl(
PrefService* prefs,
scoped_ptr<ManagedUserRefreshTokenFetcher> token_fetcher,
ManagedUserSyncService* service);
- // Fetches the managed user token when we have the device name.
- void FetchToken(const std::string& client_name);
-
- // Called when we have received a token for the managed user.
- void OnReceivedToken(const GoogleServiceAuthError& error,
- const std::string& token);
-
- // Dispatches the callback and cleans up if all the conditions have been met.
- void CompleteRegistrationIfReady();
-
- // Aborts any registration currently in progress. If |run_callback| is true,
- // calls the callback specified in Register() with the given |error|.
- void AbortPendingRegistration(bool run_callback,
- const GoogleServiceAuthError& error);
-
- // If |run_callback| is true, dispatches the callback with the saved token
- // (which may be empty) and the given |error|. In any case, resets internal
- // variables to be ready for the next registration.
- void CompleteRegistration(bool run_callback,
- const GoogleServiceAuthError& error);
- // Cancels any registration currently in progress, without calling the
- // callback or reporting an error.
- void CancelPendingRegistration();
-
- base::WeakPtrFactory<ManagedUserRegistrationUtility> weak_ptr_factory_;
- PrefService* prefs_;
- scoped_ptr<ManagedUserRefreshTokenFetcher> token_fetcher_;
-
- // A |BrowserContextKeyedService| owned by the custodian profile.
- ManagedUserSyncService* managed_user_sync_service_;
+ // Set the instance of ManagedUserRegistrationUtility that will be returned
+ // by next Create() call. Takes ownership of the |utility|.
+ static void SetUtilityForTests(ManagedUserRegistrationUtility* utility);
+};
- std::string pending_managed_user_id_;
- std::string pending_managed_user_token_;
- bool pending_managed_user_acknowledged_;
- bool is_existing_managed_user_;
- RegistrationCallback callback_;
+// Class that sets the instance of ManagedUserRegistrationUtility that will be
+// returned by next Create() call, and correctly destroys it if Create() was
+// not called.
+class ScopedTestingManagedUserRegistrationUtility {
+ public:
+ // Delegates ownership of the |instance| to ManagedUserRegistrationUtility.
+ ScopedTestingManagedUserRegistrationUtility(
+ ManagedUserRegistrationUtility* instance);
- DISALLOW_COPY_AND_ASSIGN(ManagedUserRegistrationUtility);
+ ~ScopedTestingManagedUserRegistrationUtility();
};
#endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_REGISTRATION_UTILITY_H_
diff --git a/chrome/browser/managed_mode/managed_user_registration_utility_stub.cc b/chrome/browser/managed_mode/managed_user_registration_utility_stub.cc
new file mode 100644
index 0000000..1149649
--- /dev/null
+++ b/chrome/browser/managed_mode/managed_user_registration_utility_stub.cc
@@ -0,0 +1,47 @@
+// Copyright 2013 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/managed_mode/managed_user_registration_utility_stub.h"
+
+#include "base/bind.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/strings/utf_string_conversions.h"
+#include "google_apis/gaia/gaia_urls.h"
+#include "google_apis/gaia/google_service_auth_error.h"
+
+ManagedUserRegistrationUtilityStub::ManagedUserRegistrationUtilityStub()
+ : register_was_called_(false) {
+}
+
+ManagedUserRegistrationUtilityStub::~ManagedUserRegistrationUtilityStub() {
+}
+
+void ManagedUserRegistrationUtilityStub::Register(
+ const std::string& managed_user_id,
+ const ManagedUserRegistrationInfo& info,
+ const RegistrationCallback& callback) {
+ DCHECK(!register_was_called_);
+ register_was_called_ = true;
+ callback_ = callback;
+ managed_user_id_ = managed_user_id;
+ display_name_ = info.name;
+ master_key_ = info.master_key;
+}
+
+void ManagedUserRegistrationUtilityStub::RunSuccessCallback(
+ const std::string& token) {
+ if (callback_.is_null())
+ return;
+ callback_.Run(GoogleServiceAuthError(GoogleServiceAuthError::NONE), token);
+ callback_.Reset();
+}
+
+void ManagedUserRegistrationUtilityStub::RunFailureCallback(
+ const GoogleServiceAuthError::State state) {
+ if (callback_.is_null())
+ return;
+ GoogleServiceAuthError error(state);
+ callback_.Run(error, std::string());
+ callback_.Reset();
+}
diff --git a/chrome/browser/managed_mode/managed_user_registration_utility_stub.h b/chrome/browser/managed_mode/managed_user_registration_utility_stub.h
new file mode 100644
index 0000000..59f4734
--- /dev/null
+++ b/chrome/browser/managed_mode/managed_user_registration_utility_stub.h
@@ -0,0 +1,47 @@
+// Copyright 2013 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_MANAGED_MODE_MANAGED_USER_REGISTRATION_UTILITY_STUB_H_
+#define CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_REGISTRATION_UTILITY_STUB_H_
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "base/strings/string16.h"
+#include "chrome/browser/managed_mode/managed_user_registration_utility.h"
+#include "google_apis/gaia/google_service_auth_error.h"
+
+class ManagedUserRegistrationUtilityStub
+ : public ManagedUserRegistrationUtility {
+ public:
+ ManagedUserRegistrationUtilityStub();
+ virtual ~ManagedUserRegistrationUtilityStub();
+
+ virtual void Register(const std::string& managed_user_id,
+ const ManagedUserRegistrationInfo& info,
+ const RegistrationCallback& callback) OVERRIDE;
+
+ bool register_was_called() { return register_was_called_; }
+
+ std::string managed_user_id() { return managed_user_id_; }
+
+ string16 display_name() { return display_name_; }
+
+ std::string master_key() { return master_key_; }
+
+ void RunSuccessCallback(const std::string& token);
+ void RunFailureCallback(GoogleServiceAuthError::State error);
+
+ private:
+ RegistrationCallback callback_;
+ bool register_was_called_;
+ std::string managed_user_id_;
+ string16 display_name_;
+ std::string master_key_;
+
+ DISALLOW_COPY_AND_ASSIGN(ManagedUserRegistrationUtilityStub);
+};
+
+#endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_REGISTRATION_UTILITY_STUB_H_
diff --git a/chrome/browser/managed_mode/managed_user_registration_utility_unittest.cc b/chrome/browser/managed_mode/managed_user_registration_utility_unittest.cc
index 5bb75de..124b5e6 100644
--- a/chrome/browser/managed_mode/managed_user_registration_utility_unittest.cc
+++ b/chrome/browser/managed_mode/managed_user_registration_utility_unittest.cc
@@ -94,6 +94,8 @@ class ManagedUserRegistrationUtilityTest : public ::testing::Test {
ManagedUserRegistrationUtility::RegistrationCallback
GetRegistrationCallback();
+ ManagedUserRegistrationUtility* GetRegistrationUtility();
+
void Acknowledge();
PrefService* prefs() { return profile_.GetTestingPrefService(); }
@@ -113,6 +115,7 @@ class ManagedUserRegistrationUtilityTest : public ::testing::Test {
base::WeakPtrFactory<ManagedUserRegistrationUtilityTest> weak_ptr_factory_;
TestingProfile profile_;
ManagedUserSyncService* service_;
+ scoped_ptr<ManagedUserRegistrationUtility> registration_utility_;
// Owned by the ManagedUserSyncService.
MockChangeProcessor* change_processor_;
@@ -176,6 +179,20 @@ ManagedUserRegistrationUtilityTest::GetRegistrationCallback() {
weak_ptr_factory_.GetWeakPtr());
}
+ManagedUserRegistrationUtility*
+ManagedUserRegistrationUtilityTest::GetRegistrationUtility() {
+ if (registration_utility_.get())
+ return registration_utility_.get();
+
+ scoped_ptr<ManagedUserRefreshTokenFetcher> token_fetcher(
+ new MockManagedUserRefreshTokenFetcher);
+ registration_utility_.reset(
+ ManagedUserRegistrationUtility::CreateImpl(prefs(),
+ token_fetcher.Pass(),
+ service()));
+ return registration_utility_.get();
+}
+
void ManagedUserRegistrationUtilityTest::Acknowledge() {
SyncChangeList new_changes;
const SyncChangeList& changes = change_processor()->changes();
@@ -207,12 +224,7 @@ void ManagedUserRegistrationUtilityTest::OnManagedUserRegistered(
TEST_F(ManagedUserRegistrationUtilityTest, Register) {
StartInitialSync();
- scoped_ptr<ManagedUserRefreshTokenFetcher> token_fetcher(
- new MockManagedUserRefreshTokenFetcher);
- ManagedUserRegistrationUtility registration_utility(prefs(),
- token_fetcher.Pass(),
- service());
- registration_utility.Register(
+ GetRegistrationUtility()->Register(
ManagedUserRegistrationUtility::GenerateNewManagedUserId(),
ManagedUserRegistrationInfo(ASCIIToUTF16("Dug")),
GetRegistrationCallback());
@@ -225,12 +237,7 @@ TEST_F(ManagedUserRegistrationUtilityTest, Register) {
}
TEST_F(ManagedUserRegistrationUtilityTest, RegisterBeforeInitialSync) {
- scoped_ptr<ManagedUserRefreshTokenFetcher> token_fetcher(
- new MockManagedUserRefreshTokenFetcher);
- ManagedUserRegistrationUtility registration_utility(prefs(),
- token_fetcher.Pass(),
- service());
- registration_utility.Register(
+ GetRegistrationUtility()->Register(
ManagedUserRegistrationUtility::GenerateNewManagedUserId(),
ManagedUserRegistrationInfo(ASCIIToUTF16("Nemo")),
GetRegistrationCallback());
@@ -245,12 +252,7 @@ TEST_F(ManagedUserRegistrationUtilityTest, RegisterBeforeInitialSync) {
TEST_F(ManagedUserRegistrationUtilityTest, SyncServiceShutdownBeforeRegFinish) {
StartInitialSync();
- scoped_ptr<ManagedUserRefreshTokenFetcher> token_fetcher(
- new MockManagedUserRefreshTokenFetcher);
- ManagedUserRegistrationUtility registration_utility(prefs(),
- token_fetcher.Pass(),
- service());
- registration_utility.Register(
+ GetRegistrationUtility()->Register(
ManagedUserRegistrationUtility::GenerateNewManagedUserId(),
ManagedUserRegistrationInfo(ASCIIToUTF16("Remy")),
GetRegistrationCallback());
@@ -264,12 +266,7 @@ TEST_F(ManagedUserRegistrationUtilityTest, SyncServiceShutdownBeforeRegFinish) {
TEST_F(ManagedUserRegistrationUtilityTest, StopSyncingBeforeRegFinish) {
StartInitialSync();
- scoped_ptr<ManagedUserRefreshTokenFetcher> token_fetcher(
- new MockManagedUserRefreshTokenFetcher);
- ManagedUserRegistrationUtility registration_utility(prefs(),
- token_fetcher.Pass(),
- service());
- registration_utility.Register(
+ GetRegistrationUtility()->Register(
ManagedUserRegistrationUtility::GenerateNewManagedUserId(),
ManagedUserRegistrationInfo(ASCIIToUTF16("Mike")),
GetRegistrationCallback());