OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/supervised_user/legacy/supervised_user_registration_uti
lity.h" | 5 #include "chrome/browser/supervised_user/legacy/supervised_user_registration_uti
lity.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
22 #include "chrome/test/base/testing_profile.h" | 22 #include "chrome/test/base/testing_profile.h" |
23 #include "components/prefs/scoped_user_pref_update.h" | 23 #include "components/prefs/scoped_user_pref_update.h" |
24 #include "components/sync/api/attachments/attachment_id.h" | 24 #include "components/sync/api/attachments/attachment_id.h" |
25 #include "components/sync/api/sync_change.h" | 25 #include "components/sync/api/sync_change.h" |
26 #include "components/sync/api/sync_error_factory_mock.h" | 26 #include "components/sync/api/sync_error_factory_mock.h" |
27 #include "components/sync/core/attachments/attachment_service_proxy_for_test.h" | 27 #include "components/sync/core/attachments/attachment_service_proxy_for_test.h" |
28 #include "components/sync/protocol/sync.pb.h" | 28 #include "components/sync/protocol/sync.pb.h" |
29 #include "components/syncable_prefs/testing_pref_service_syncable.h" | 29 #include "components/syncable_prefs/testing_pref_service_syncable.h" |
30 #include "content/public/browser/browser_thread.h" | 30 #include "content/public/browser/browser_thread.h" |
| 31 #include "content/public/test/test_browser_thread_bundle.h" |
31 #include "content/public/test/test_utils.h" | 32 #include "content/public/test/test_utils.h" |
32 #include "google_apis/gaia/google_service_auth_error.h" | 33 #include "google_apis/gaia/google_service_auth_error.h" |
33 #include "testing/gtest/include/gtest/gtest.h" | 34 #include "testing/gtest/include/gtest/gtest.h" |
34 | 35 |
35 using sync_pb::ManagedUserSpecifics; | 36 using sync_pb::ManagedUserSpecifics; |
36 using syncer::SUPERVISED_USERS; | 37 using syncer::SUPERVISED_USERS; |
37 using syncer::SyncChange; | 38 using syncer::SyncChange; |
38 using syncer::SyncChangeList; | 39 using syncer::SyncChangeList; |
39 using syncer::SyncChangeProcessor; | 40 using syncer::SyncChangeProcessor; |
40 using syncer::SyncData; | 41 using syncer::SyncData; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 MockChangeProcessor* change_processor() { return change_processor_; } | 120 MockChangeProcessor* change_processor() { return change_processor_; } |
120 | 121 |
121 bool received_callback() const { return received_callback_; } | 122 bool received_callback() const { return received_callback_; } |
122 const GoogleServiceAuthError& error() const { return error_; } | 123 const GoogleServiceAuthError& error() const { return error_; } |
123 const std::string& token() const { return token_; } | 124 const std::string& token() const { return token_; } |
124 | 125 |
125 private: | 126 private: |
126 void OnSupervisedUserRegistered(const GoogleServiceAuthError& error, | 127 void OnSupervisedUserRegistered(const GoogleServiceAuthError& error, |
127 const std::string& token); | 128 const std::string& token); |
128 | 129 |
129 base::MessageLoop message_loop_; | 130 content::TestBrowserThreadBundle thread_bundle_; |
130 base::RunLoop run_loop_; | 131 base::RunLoop run_loop_; |
131 TestingProfile profile_; | 132 TestingProfile profile_; |
132 SupervisedUserSyncService* service_; | 133 SupervisedUserSyncService* service_; |
133 SupervisedUserSharedSettingsService* shared_settings_service_; | 134 SupervisedUserSharedSettingsService* shared_settings_service_; |
134 std::unique_ptr<SupervisedUserRegistrationUtility> registration_utility_; | 135 std::unique_ptr<SupervisedUserRegistrationUtility> registration_utility_; |
135 | 136 |
136 // Owned by the SupervisedUserSyncService. | 137 // Owned by the SupervisedUserSyncService. |
137 MockChangeProcessor* change_processor_; | 138 MockChangeProcessor* change_processor_; |
138 | 139 |
139 // A unique ID for creating "remote" Sync data. | 140 // A unique ID for creating "remote" Sync data. |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 SupervisedUserRegistrationUtility::GenerateNewSupervisedUserId(), | 294 SupervisedUserRegistrationUtility::GenerateNewSupervisedUserId(), |
294 SupervisedUserRegistrationInfo(base::ASCIIToUTF16("Mike"), 17), | 295 SupervisedUserRegistrationInfo(base::ASCIIToUTF16("Mike"), 17), |
295 GetRegistrationCallback()); | 296 GetRegistrationCallback()); |
296 EXPECT_EQ(1u, prefs()->GetDictionary(prefs::kSupervisedUsers)->size()); | 297 EXPECT_EQ(1u, prefs()->GetDictionary(prefs::kSupervisedUsers)->size()); |
297 service()->StopSyncing(SUPERVISED_USERS); | 298 service()->StopSyncing(SUPERVISED_USERS); |
298 EXPECT_EQ(0u, prefs()->GetDictionary(prefs::kSupervisedUsers)->size()); | 299 EXPECT_EQ(0u, prefs()->GetDictionary(prefs::kSupervisedUsers)->size()); |
299 EXPECT_TRUE(received_callback()); | 300 EXPECT_TRUE(received_callback()); |
300 EXPECT_EQ(GoogleServiceAuthError::REQUEST_CANCELED, error().state()); | 301 EXPECT_EQ(GoogleServiceAuthError::REQUEST_CANCELED, error().state()); |
301 EXPECT_EQ(std::string(), token()); | 302 EXPECT_EQ(std::string(), token()); |
302 } | 303 } |
OLD | NEW |