| Index: chrome/browser/supervised_user/supervised_user_registration_utility_unittest.cc
|
| diff --git a/chrome/browser/managed_mode/managed_user_registration_utility_unittest.cc b/chrome/browser/supervised_user/supervised_user_registration_utility_unittest.cc
|
| similarity index 64%
|
| rename from chrome/browser/managed_mode/managed_user_registration_utility_unittest.cc
|
| rename to chrome/browser/supervised_user/supervised_user_registration_utility_unittest.cc
|
| index ed33dcd60e7568bccea296c9db476bd715f66baf..309b4a56264a73fce4cd1a76f054898ade50d258 100644
|
| --- a/chrome/browser/managed_mode/managed_user_registration_utility_unittest.cc
|
| +++ b/chrome/browser/supervised_user/supervised_user_registration_utility_unittest.cc
|
| @@ -8,12 +8,12 @@
|
| #include "base/run_loop.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| #include "base/threading/sequenced_worker_pool.h"
|
| -#include "chrome/browser/managed_mode/managed_user_refresh_token_fetcher.h"
|
| -#include "chrome/browser/managed_mode/managed_user_registration_utility.h"
|
| -#include "chrome/browser/managed_mode/managed_user_shared_settings_service.h"
|
| -#include "chrome/browser/managed_mode/managed_user_shared_settings_service_factory.h"
|
| -#include "chrome/browser/managed_mode/managed_user_sync_service.h"
|
| -#include "chrome/browser/managed_mode/managed_user_sync_service_factory.h"
|
| +#include "chrome/browser/supervised_user/supervised_user_refresh_token_fetcher.h"
|
| +#include "chrome/browser/supervised_user/supervised_user_registration_utility.h"
|
| +#include "chrome/browser/supervised_user/supervised_user_shared_settings_service.h"
|
| +#include "chrome/browser/supervised_user/supervised_user_shared_settings_service_factory.h"
|
| +#include "chrome/browser/supervised_user/supervised_user_sync_service.h"
|
| +#include "chrome/browser/supervised_user/supervised_user_sync_service_factory.h"
|
| #include "chrome/common/pref_names.h"
|
| #include "chrome/test/base/testing_pref_service_syncable.h"
|
| #include "chrome/test/base/testing_profile.h"
|
| @@ -69,14 +69,14 @@ SyncError MockChangeProcessor::ProcessSyncChanges(
|
| return SyncError();
|
| }
|
|
|
| -class MockManagedUserRefreshTokenFetcher
|
| - : public ManagedUserRefreshTokenFetcher {
|
| +class MockSupervisedUserRefreshTokenFetcher
|
| + : public SupervisedUserRefreshTokenFetcher {
|
| public:
|
| - MockManagedUserRefreshTokenFetcher() {}
|
| - virtual ~MockManagedUserRefreshTokenFetcher() {}
|
| + MockSupervisedUserRefreshTokenFetcher() {}
|
| + virtual ~MockSupervisedUserRefreshTokenFetcher() {}
|
|
|
| - // ManagedUserRefreshTokenFetcher implementation:
|
| - virtual void Start(const std::string& managed_user_id,
|
| + // SupervisedUserRefreshTokenFetcher implementation:
|
| + virtual void Start(const std::string& supervised_user_id,
|
| const std::string& device_name,
|
| const TokenCallback& callback) OVERRIDE {
|
| GoogleServiceAuthError error(GoogleServiceAuthError::NONE);
|
| @@ -86,10 +86,10 @@ class MockManagedUserRefreshTokenFetcher
|
|
|
| } // namespace
|
|
|
| -class ManagedUserRegistrationUtilityTest : public ::testing::Test {
|
| +class SupervisedUserRegistrationUtilityTest : public ::testing::Test {
|
| public:
|
| - ManagedUserRegistrationUtilityTest();
|
| - virtual ~ManagedUserRegistrationUtilityTest();
|
| + SupervisedUserRegistrationUtilityTest();
|
| + virtual ~SupervisedUserRegistrationUtilityTest();
|
|
|
| virtual void TearDown() OVERRIDE;
|
|
|
| @@ -100,16 +100,16 @@ class ManagedUserRegistrationUtilityTest : public ::testing::Test {
|
|
|
| SyncMergeResult StartInitialSync();
|
|
|
| - ManagedUserRegistrationUtility::RegistrationCallback
|
| + SupervisedUserRegistrationUtility::RegistrationCallback
|
| GetRegistrationCallback();
|
|
|
| - ManagedUserRegistrationUtility* GetRegistrationUtility();
|
| + SupervisedUserRegistrationUtility* GetRegistrationUtility();
|
|
|
| void Acknowledge();
|
|
|
| PrefService* prefs() { return profile_.GetTestingPrefService(); }
|
| - ManagedUserSyncService* service() { return service_; }
|
| - ManagedUserSharedSettingsService* shared_settings_service() {
|
| + SupervisedUserSyncService* service() { return service_; }
|
| + SupervisedUserSharedSettingsService* shared_settings_service() {
|
| return shared_settings_service_;
|
| }
|
| MockChangeProcessor* change_processor() { return change_processor_; }
|
| @@ -119,65 +119,67 @@ class ManagedUserRegistrationUtilityTest : public ::testing::Test {
|
| const std::string& token() const { return token_; }
|
|
|
| private:
|
| - void OnManagedUserRegistered(const GoogleServiceAuthError& error,
|
| - const std::string& token);
|
| + void OnSupervisedUserRegistered(const GoogleServiceAuthError& error,
|
| + const std::string& token);
|
|
|
| base::MessageLoop message_loop_;
|
| base::RunLoop run_loop_;
|
| TestingProfile profile_;
|
| - ManagedUserSyncService* service_;
|
| - ManagedUserSharedSettingsService* shared_settings_service_;
|
| - scoped_ptr<ManagedUserRegistrationUtility> registration_utility_;
|
| + SupervisedUserSyncService* service_;
|
| + SupervisedUserSharedSettingsService* shared_settings_service_;
|
| + scoped_ptr<SupervisedUserRegistrationUtility> registration_utility_;
|
|
|
| - // Owned by the ManagedUserSyncService.
|
| + // Owned by the SupervisedUserSyncService.
|
| MockChangeProcessor* change_processor_;
|
|
|
| // A unique ID for creating "remote" Sync data.
|
| int64 sync_data_id_;
|
|
|
| - // Whether OnManagedUserRegistered has been called.
|
| + // Whether OnSupervisedUserRegistered has been called.
|
| bool received_callback_;
|
|
|
| // Hold the registration result (either an error, or a token).
|
| GoogleServiceAuthError error_;
|
| std::string token_;
|
|
|
| - base::WeakPtrFactory<ManagedUserRegistrationUtilityTest> weak_ptr_factory_;
|
| + base::WeakPtrFactory<SupervisedUserRegistrationUtilityTest> weak_ptr_factory_;
|
| };
|
|
|
| -ManagedUserRegistrationUtilityTest::ManagedUserRegistrationUtilityTest()
|
| +SupervisedUserRegistrationUtilityTest::SupervisedUserRegistrationUtilityTest()
|
| : change_processor_(NULL),
|
| sync_data_id_(0),
|
| received_callback_(false),
|
| error_(GoogleServiceAuthError::NUM_STATES),
|
| weak_ptr_factory_(this) {
|
| - service_ = ManagedUserSyncServiceFactory::GetForProfile(&profile_);
|
| + service_ = SupervisedUserSyncServiceFactory::GetForProfile(&profile_);
|
| shared_settings_service_ =
|
| - ManagedUserSharedSettingsServiceFactory::GetForBrowserContext(&profile_);
|
| + SupervisedUserSharedSettingsServiceFactory::GetForBrowserContext(
|
| + &profile_);
|
| }
|
|
|
| -ManagedUserRegistrationUtilityTest::~ManagedUserRegistrationUtilityTest() {
|
| +SupervisedUserRegistrationUtilityTest::
|
| + ~SupervisedUserRegistrationUtilityTest() {
|
| EXPECT_FALSE(weak_ptr_factory_.HasWeakPtrs());
|
| }
|
|
|
| -void ManagedUserRegistrationUtilityTest::TearDown() {
|
| +void SupervisedUserRegistrationUtilityTest::TearDown() {
|
| content::BrowserThread::GetBlockingPool()->FlushForTesting();
|
| base::RunLoop().RunUntilIdle();
|
| }
|
|
|
| scoped_ptr<SyncChangeProcessor>
|
| -ManagedUserRegistrationUtilityTest::CreateChangeProcessor() {
|
| +SupervisedUserRegistrationUtilityTest::CreateChangeProcessor() {
|
| EXPECT_FALSE(change_processor_);
|
| change_processor_ = new MockChangeProcessor();
|
| return scoped_ptr<SyncChangeProcessor>(change_processor_);
|
| }
|
|
|
| scoped_ptr<SyncErrorFactory>
|
| -ManagedUserRegistrationUtilityTest::CreateErrorFactory() {
|
| +SupervisedUserRegistrationUtilityTest::CreateErrorFactory() {
|
| return scoped_ptr<SyncErrorFactory>(new syncer::SyncErrorFactoryMock());
|
| }
|
|
|
| -SyncMergeResult ManagedUserRegistrationUtilityTest::StartInitialSync() {
|
| +SyncMergeResult SupervisedUserRegistrationUtilityTest::StartInitialSync() {
|
| SyncDataList initial_sync_data;
|
| SyncMergeResult result =
|
| service()->MergeDataAndStartSyncing(SUPERVISED_USERS,
|
| @@ -188,29 +190,29 @@ SyncMergeResult ManagedUserRegistrationUtilityTest::StartInitialSync() {
|
| return result;
|
| }
|
|
|
| -ManagedUserRegistrationUtility::RegistrationCallback
|
| -ManagedUserRegistrationUtilityTest::GetRegistrationCallback() {
|
| +SupervisedUserRegistrationUtility::RegistrationCallback
|
| +SupervisedUserRegistrationUtilityTest::GetRegistrationCallback() {
|
| return base::Bind(
|
| - &ManagedUserRegistrationUtilityTest::OnManagedUserRegistered,
|
| + &SupervisedUserRegistrationUtilityTest::OnSupervisedUserRegistered,
|
| weak_ptr_factory_.GetWeakPtr());
|
| }
|
|
|
| -ManagedUserRegistrationUtility*
|
| -ManagedUserRegistrationUtilityTest::GetRegistrationUtility() {
|
| +SupervisedUserRegistrationUtility*
|
| +SupervisedUserRegistrationUtilityTest::GetRegistrationUtility() {
|
| if (registration_utility_.get())
|
| return registration_utility_.get();
|
|
|
| - scoped_ptr<ManagedUserRefreshTokenFetcher> token_fetcher(
|
| - new MockManagedUserRefreshTokenFetcher);
|
| + scoped_ptr<SupervisedUserRefreshTokenFetcher> token_fetcher(
|
| + new MockSupervisedUserRefreshTokenFetcher);
|
| registration_utility_.reset(
|
| - ManagedUserRegistrationUtility::CreateImpl(prefs(),
|
| - token_fetcher.Pass(),
|
| - service(),
|
| - shared_settings_service()));
|
| + SupervisedUserRegistrationUtility::CreateImpl(prefs(),
|
| + token_fetcher.Pass(),
|
| + service(),
|
| + shared_settings_service()));
|
| return registration_utility_.get();
|
| }
|
|
|
| -void ManagedUserRegistrationUtilityTest::Acknowledge() {
|
| +void SupervisedUserRegistrationUtilityTest::Acknowledge() {
|
| SyncChangeList new_changes;
|
| const SyncChangeList& changes = change_processor()->changes();
|
| for (SyncChangeList::const_iterator it = changes.begin(); it != changes.end();
|
| @@ -234,7 +236,7 @@ void ManagedUserRegistrationUtilityTest::Acknowledge() {
|
| run_loop_.Run();
|
| }
|
|
|
| -void ManagedUserRegistrationUtilityTest::OnManagedUserRegistered(
|
| +void SupervisedUserRegistrationUtilityTest::OnSupervisedUserRegistered(
|
| const GoogleServiceAuthError& error,
|
| const std::string& token) {
|
| received_callback_ = true;
|
| @@ -243,11 +245,11 @@ void ManagedUserRegistrationUtilityTest::OnManagedUserRegistered(
|
| run_loop_.Quit();
|
| }
|
|
|
| -TEST_F(ManagedUserRegistrationUtilityTest, Register) {
|
| +TEST_F(SupervisedUserRegistrationUtilityTest, Register) {
|
| StartInitialSync();
|
| GetRegistrationUtility()->Register(
|
| - ManagedUserRegistrationUtility::GenerateNewManagedUserId(),
|
| - ManagedUserRegistrationInfo(base::ASCIIToUTF16("Dug"), 0),
|
| + SupervisedUserRegistrationUtility::GenerateNewSupervisedUserId(),
|
| + SupervisedUserRegistrationInfo(base::ASCIIToUTF16("Dug"), 0),
|
| GetRegistrationCallback());
|
| EXPECT_EQ(1u, prefs()->GetDictionary(prefs::kSupervisedUsers)->size());
|
| Acknowledge();
|
| @@ -257,10 +259,10 @@ TEST_F(ManagedUserRegistrationUtilityTest, Register) {
|
| EXPECT_FALSE(token().empty());
|
| }
|
|
|
| -TEST_F(ManagedUserRegistrationUtilityTest, RegisterBeforeInitialSync) {
|
| +TEST_F(SupervisedUserRegistrationUtilityTest, RegisterBeforeInitialSync) {
|
| GetRegistrationUtility()->Register(
|
| - ManagedUserRegistrationUtility::GenerateNewManagedUserId(),
|
| - ManagedUserRegistrationInfo(base::ASCIIToUTF16("Nemo"), 5),
|
| + SupervisedUserRegistrationUtility::GenerateNewSupervisedUserId(),
|
| + SupervisedUserRegistrationInfo(base::ASCIIToUTF16("Nemo"), 5),
|
| GetRegistrationCallback());
|
| EXPECT_EQ(1u, prefs()->GetDictionary(prefs::kSupervisedUsers)->size());
|
| StartInitialSync();
|
| @@ -271,11 +273,12 @@ TEST_F(ManagedUserRegistrationUtilityTest, RegisterBeforeInitialSync) {
|
| EXPECT_FALSE(token().empty());
|
| }
|
|
|
| -TEST_F(ManagedUserRegistrationUtilityTest, SyncServiceShutdownBeforeRegFinish) {
|
| +TEST_F(SupervisedUserRegistrationUtilityTest,
|
| + SyncServiceShutdownBeforeRegFinish) {
|
| StartInitialSync();
|
| GetRegistrationUtility()->Register(
|
| - ManagedUserRegistrationUtility::GenerateNewManagedUserId(),
|
| - ManagedUserRegistrationInfo(base::ASCIIToUTF16("Remy"), 12),
|
| + SupervisedUserRegistrationUtility::GenerateNewSupervisedUserId(),
|
| + SupervisedUserRegistrationInfo(base::ASCIIToUTF16("Remy"), 12),
|
| GetRegistrationCallback());
|
| EXPECT_EQ(1u, prefs()->GetDictionary(prefs::kSupervisedUsers)->size());
|
| service()->Shutdown();
|
| @@ -285,11 +288,11 @@ TEST_F(ManagedUserRegistrationUtilityTest, SyncServiceShutdownBeforeRegFinish) {
|
| EXPECT_EQ(std::string(), token());
|
| }
|
|
|
| -TEST_F(ManagedUserRegistrationUtilityTest, StopSyncingBeforeRegFinish) {
|
| +TEST_F(SupervisedUserRegistrationUtilityTest, StopSyncingBeforeRegFinish) {
|
| StartInitialSync();
|
| GetRegistrationUtility()->Register(
|
| - ManagedUserRegistrationUtility::GenerateNewManagedUserId(),
|
| - ManagedUserRegistrationInfo(base::ASCIIToUTF16("Mike"), 17),
|
| + SupervisedUserRegistrationUtility::GenerateNewSupervisedUserId(),
|
| + SupervisedUserRegistrationInfo(base::ASCIIToUTF16("Mike"), 17),
|
| GetRegistrationCallback());
|
| EXPECT_EQ(1u, prefs()->GetDictionary(prefs::kSupervisedUsers)->size());
|
| service()->StopSyncing(SUPERVISED_USERS);
|
|
|