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

Side by Side Diff: chrome/browser/supervised_user/supervised_user_registration_utility_unittest.cc

Issue 409743003: Use content::RunBlockingPoolTask() in tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed. Created 6 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/supervised_user_registration_utility.h"
6
5 #include "base/bind.h" 7 #include "base/bind.h"
6 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
7 #include "base/prefs/scoped_user_pref_update.h" 9 #include "base/prefs/scoped_user_pref_update.h"
8 #include "base/run_loop.h" 10 #include "base/run_loop.h"
9 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
10 #include "base/threading/sequenced_worker_pool.h" 12 #include "base/threading/sequenced_worker_pool.h"
11 #include "chrome/browser/supervised_user/supervised_user_refresh_token_fetcher.h " 13 #include "chrome/browser/supervised_user/supervised_user_refresh_token_fetcher.h "
12 #include "chrome/browser/supervised_user/supervised_user_registration_utility.h"
13 #include "chrome/browser/supervised_user/supervised_user_shared_settings_service .h" 14 #include "chrome/browser/supervised_user/supervised_user_shared_settings_service .h"
14 #include "chrome/browser/supervised_user/supervised_user_shared_settings_service _factory.h" 15 #include "chrome/browser/supervised_user/supervised_user_shared_settings_service _factory.h"
15 #include "chrome/browser/supervised_user/supervised_user_sync_service.h" 16 #include "chrome/browser/supervised_user/supervised_user_sync_service.h"
16 #include "chrome/browser/supervised_user/supervised_user_sync_service_factory.h" 17 #include "chrome/browser/supervised_user/supervised_user_sync_service_factory.h"
17 #include "chrome/common/pref_names.h" 18 #include "chrome/common/pref_names.h"
18 #include "chrome/test/base/testing_pref_service_syncable.h" 19 #include "chrome/test/base/testing_pref_service_syncable.h"
19 #include "chrome/test/base/testing_profile.h" 20 #include "chrome/test/base/testing_profile.h"
20 #include "content/public/browser/browser_thread.h" 21 #include "content/public/browser/browser_thread.h"
22 #include "content/public/test/test_utils.h"
21 #include "google_apis/gaia/google_service_auth_error.h" 23 #include "google_apis/gaia/google_service_auth_error.h"
22 #include "sync/api/attachments/attachment_id.h" 24 #include "sync/api/attachments/attachment_id.h"
23 #include "sync/api/sync_change.h" 25 #include "sync/api/sync_change.h"
24 #include "sync/api/sync_error_factory_mock.h" 26 #include "sync/api/sync_error_factory_mock.h"
25 #include "sync/internal_api/public/attachments/attachment_service_proxy_for_test .h" 27 #include "sync/internal_api/public/attachments/attachment_service_proxy_for_test .h"
26 #include "sync/protocol/sync.pb.h" 28 #include "sync/protocol/sync.pb.h"
27 #include "testing/gtest/include/gtest/gtest.h" 29 #include "testing/gtest/include/gtest/gtest.h"
28 30
29 using sync_pb::ManagedUserSpecifics; 31 using sync_pb::ManagedUserSpecifics;
30 using syncer::SUPERVISED_USERS; 32 using syncer::SUPERVISED_USERS;
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 SupervisedUserSharedSettingsServiceFactory::GetForBrowserContext( 158 SupervisedUserSharedSettingsServiceFactory::GetForBrowserContext(
157 &profile_); 159 &profile_);
158 } 160 }
159 161
160 SupervisedUserRegistrationUtilityTest:: 162 SupervisedUserRegistrationUtilityTest::
161 ~SupervisedUserRegistrationUtilityTest() { 163 ~SupervisedUserRegistrationUtilityTest() {
162 EXPECT_FALSE(weak_ptr_factory_.HasWeakPtrs()); 164 EXPECT_FALSE(weak_ptr_factory_.HasWeakPtrs());
163 } 165 }
164 166
165 void SupervisedUserRegistrationUtilityTest::TearDown() { 167 void SupervisedUserRegistrationUtilityTest::TearDown() {
166 content::BrowserThread::GetBlockingPool()->FlushForTesting(); 168 content::RunAllBlockingPoolTasksUntilIdle();
167 base::RunLoop().RunUntilIdle();
168 } 169 }
169 170
170 scoped_ptr<SyncChangeProcessor> 171 scoped_ptr<SyncChangeProcessor>
171 SupervisedUserRegistrationUtilityTest::CreateChangeProcessor() { 172 SupervisedUserRegistrationUtilityTest::CreateChangeProcessor() {
172 EXPECT_FALSE(change_processor_); 173 EXPECT_FALSE(change_processor_);
173 change_processor_ = new MockChangeProcessor(); 174 change_processor_ = new MockChangeProcessor();
174 return scoped_ptr<SyncChangeProcessor>(change_processor_); 175 return scoped_ptr<SyncChangeProcessor>(change_processor_);
175 } 176 }
176 177
177 scoped_ptr<SyncErrorFactory> 178 scoped_ptr<SyncErrorFactory>
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 SupervisedUserRegistrationUtility::GenerateNewSupervisedUserId(), 295 SupervisedUserRegistrationUtility::GenerateNewSupervisedUserId(),
295 SupervisedUserRegistrationInfo(base::ASCIIToUTF16("Mike"), 17), 296 SupervisedUserRegistrationInfo(base::ASCIIToUTF16("Mike"), 17),
296 GetRegistrationCallback()); 297 GetRegistrationCallback());
297 EXPECT_EQ(1u, prefs()->GetDictionary(prefs::kSupervisedUsers)->size()); 298 EXPECT_EQ(1u, prefs()->GetDictionary(prefs::kSupervisedUsers)->size());
298 service()->StopSyncing(SUPERVISED_USERS); 299 service()->StopSyncing(SUPERVISED_USERS);
299 EXPECT_EQ(0u, prefs()->GetDictionary(prefs::kSupervisedUsers)->size()); 300 EXPECT_EQ(0u, prefs()->GetDictionary(prefs::kSupervisedUsers)->size());
300 EXPECT_TRUE(received_callback()); 301 EXPECT_TRUE(received_callback());
301 EXPECT_EQ(GoogleServiceAuthError::REQUEST_CANCELED, error().state()); 302 EXPECT_EQ(GoogleServiceAuthError::REQUEST_CANCELED, error().state());
302 EXPECT_EQ(std::string(), token()); 303 EXPECT_EQ(std::string(), token());
303 } 304 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698