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

Side by Side Diff: chrome/browser/chromeos/settings/device_oauth2_token_service_unittest.cc

Issue 2685123002: Make OAuth2TokenService and subclasses take delegate by unique_ptr (Closed)
Patch Set: Created 3 years, 10 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/chromeos/settings/device_oauth2_token_service.h" 5 #include "chrome/browser/chromeos/settings/device_oauth2_token_service.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 TestingBrowserProcess::GetGlobal()->ShutdownBrowserPolicyConnector(); 124 TestingBrowserProcess::GetGlobal()->ShutdownBrowserPolicyConnector();
125 content::BrowserThread::GetBlockingPool()->FlushForTesting(); 125 content::BrowserThread::GetBlockingPool()->FlushForTesting();
126 DeviceSettingsService::Get()->UnsetSessionManager(); 126 DeviceSettingsService::Get()->UnsetSessionManager();
127 DeviceSettingsService::Shutdown(); 127 DeviceSettingsService::Shutdown();
128 SystemSaltGetter::Shutdown(); 128 SystemSaltGetter::Shutdown();
129 DBusThreadManager::Shutdown(); 129 DBusThreadManager::Shutdown();
130 base::RunLoop().RunUntilIdle(); 130 base::RunLoop().RunUntilIdle();
131 } 131 }
132 132
133 void CreateService() { 133 void CreateService() {
134 DeviceOAuth2TokenServiceDelegate* delegate = 134 auto delegate = base::MakeUnique<DeviceOAuth2TokenServiceDelegate>(
135 new DeviceOAuth2TokenServiceDelegate(request_context_getter_.get(), 135 request_context_getter_.get(), scoped_testing_local_state_.Get());
136 scoped_testing_local_state_.Get());
137 delegate->max_refresh_token_validation_retries_ = 0; 136 delegate->max_refresh_token_validation_retries_ = 0;
138 oauth2_service_.reset(new DeviceOAuth2TokenService(delegate)); 137 oauth2_service_.reset(new DeviceOAuth2TokenService(std::move(delegate)));
msarda 2017/02/10 09:21:22 Optional: Consider using MakeUnique.
bsazonov 2017/02/10 10:41:50 The DeviceOAuth2TokenService ctor is private, so M
139 oauth2_service_->set_max_authorization_token_fetch_retries_for_testing(0); 138 oauth2_service_->set_max_authorization_token_fetch_retries_for_testing(0);
140 } 139 }
141 140
142 // Utility method to set a value in Local State for the device refresh token 141 // Utility method to set a value in Local State for the device refresh token
143 // (it must have a non-empty value or it won't be used). 142 // (it must have a non-empty value or it won't be used).
144 void SetDeviceRefreshTokenInLocalState(const std::string& refresh_token) { 143 void SetDeviceRefreshTokenInLocalState(const std::string& refresh_token) {
145 scoped_testing_local_state_.Get()->SetUserPref( 144 scoped_testing_local_state_.Get()->SetUserPref(
146 prefs::kDeviceRobotAnyApiRefreshToken, 145 prefs::kDeviceRobotAnyApiRefreshToken,
147 new base::StringValue(refresh_token)); 146 new base::StringValue(refresh_token));
148 } 147 }
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 // Also make the robot account ID available. Verify that the token is 472 // Also make the robot account ID available. Verify that the token is
474 // announced now. 473 // announced now.
475 EXPECT_CALL(observer, OnRefreshTokenAvailable("robot@example.com")); 474 EXPECT_CALL(observer, OnRefreshTokenAvailable("robot@example.com"));
476 SetRobotAccountId("robot@example.com"); 475 SetRobotAccountId("robot@example.com");
477 testing::Mock::VerifyAndClearExpectations(&observer); 476 testing::Mock::VerifyAndClearExpectations(&observer);
478 477
479 oauth2_service_->RemoveObserver(&observer); 478 oauth2_service_->RemoveObserver(&observer);
480 } 479 }
481 480
482 } // namespace chromeos 481 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698