Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1595)

Unified Diff: chrome/browser/managed_mode/managed_user_registration_service_unittest.cc

Issue 15977002: Add ManagedUserTokenFetcher to fetch scoped-down tokens. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/managed_mode/managed_user_registration_service_unittest.cc
diff --git a/chrome/browser/managed_mode/managed_user_registration_service_unittest.cc b/chrome/browser/managed_mode/managed_user_registration_service_unittest.cc
index f3b3f3c2891dd927e1b6286acf5dfd6c448840c6..5867a11af57d5cb1023952070ce2721bc86904f4 100644
--- a/chrome/browser/managed_mode/managed_user_registration_service_unittest.cc
+++ b/chrome/browser/managed_mode/managed_user_registration_service_unittest.cc
@@ -5,8 +5,11 @@
#include <string>
#include "base/bind.h"
+#include "base/message_loop.h"
+#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/managed_mode/managed_user_registration_service.h"
+#include "chrome/browser/managed_mode/managed_user_token_fetcher.h"
#include "chrome/browser/prefs/scoped_user_pref_update.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_pref_service_syncable.h"
@@ -29,6 +32,8 @@ using syncer::SyncMergeResult;
namespace {
+const char kManagedUserToken[] = "managedusertoken";
+
class MockChangeProcessor : public SyncChangeProcessor {
public:
MockChangeProcessor() {}
@@ -62,6 +67,21 @@ SyncChange MockChangeProcessor::GetChange(const std::string& id) const {
return SyncChange();
}
+class MockManagedUserTokenFetcher : public ManagedUserTokenFetcher {
+ public:
+ MockManagedUserTokenFetcher() {}
+ virtual ~MockManagedUserTokenFetcher() {}
+
+ // ManagedUserTokenFetcher implementation:
+ virtual void Start(const std::string& managed_user_id,
+ const string16& name,
+ const std::string& device_name,
+ const TokenCallback& callback) OVERRIDE {
+ GoogleServiceAuthError error(GoogleServiceAuthError::NONE);
+ callback.Run(error, kManagedUserToken);
+ }
+};
+
} // namespace
class ManagedUserRegistrationServiceTest : public ::testing::Test {
@@ -94,6 +114,8 @@ class ManagedUserRegistrationServiceTest : public ::testing::Test {
void OnManagedUserRegistered(const GoogleServiceAuthError& error,
const std::string& token);
+ base::MessageLoop message_loop_;
+ base::RunLoop run_loop_;
base::WeakPtrFactory<ManagedUserRegistrationServiceTest> weak_ptr_factory_;
TestingPrefServiceSyncable prefs_;
scoped_ptr<ManagedUserRegistrationService> service_;
@@ -114,12 +136,15 @@ class ManagedUserRegistrationServiceTest : public ::testing::Test {
ManagedUserRegistrationServiceTest::ManagedUserRegistrationServiceTest()
: weak_ptr_factory_(this),
- service_(new ManagedUserRegistrationService(&prefs_)),
change_processor_(NULL),
sync_data_id_(0),
received_callback_(false),
error_(GoogleServiceAuthError::NUM_STATES) {
ManagedUserRegistrationService::RegisterUserPrefs(prefs_.registry());
+ scoped_ptr<ManagedUserTokenFetcher> token_fetcher(
+ new MockManagedUserTokenFetcher);
+ service_.reset(
+ new ManagedUserRegistrationService(&prefs_, token_fetcher.Pass()));
}
ManagedUserRegistrationServiceTest::~ManagedUserRegistrationServiceTest() {
@@ -180,6 +205,8 @@ void ManagedUserRegistrationServiceTest::Acknowledge() {
SyncData::CreateRemoteData(++sync_data_id_, specifics)));
}
service()->ProcessSyncChanges(FROM_HERE, new_changes);
+
+ run_loop_.Run();
}
void ManagedUserRegistrationServiceTest::ResetService() {
@@ -194,6 +221,7 @@ void ManagedUserRegistrationServiceTest::OnManagedUserRegistered(
received_callback_ = true;
error_ = error;
token_ = token;
+ run_loop_.Quit();
}
TEST_F(ManagedUserRegistrationServiceTest, MergeEmpty) {

Powered by Google App Engine
This is Rietveld 408576698