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

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

Issue 2782553004: Move TestingPrefService to use unique_ptr<Value> (Closed)
Patch Set: comments Created 3 years, 8 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/memory/ptr_util.h"
9 #include "base/run_loop.h" 10 #include "base/run_loop.h"
10 #include "base/threading/sequenced_worker_pool.h" 11 #include "base/threading/sequenced_worker_pool.h"
11 #include "base/threading/thread_task_runner_handle.h" 12 #include "base/threading/thread_task_runner_handle.h"
12 #include "chrome/browser/chromeos/policy/device_policy_builder.h" 13 #include "chrome/browser/chromeos/policy/device_policy_builder.h"
13 #include "chrome/browser/chromeos/settings/cros_settings.h" 14 #include "chrome/browser/chromeos/settings/cros_settings.h"
14 #include "chrome/browser/chromeos/settings/device_oauth2_token_service_delegate. h" 15 #include "chrome/browser/chromeos/settings/device_oauth2_token_service_delegate. h"
15 #include "chrome/browser/chromeos/settings/device_settings_service.h" 16 #include "chrome/browser/chromeos/settings/device_settings_service.h"
16 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h" 17 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h"
17 #include "chrome/browser/chromeos/settings/token_encryptor.h" 18 #include "chrome/browser/chromeos/settings/token_encryptor.h"
18 #include "chrome/common/pref_names.h" 19 #include "chrome/common/pref_names.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 request_context_getter_.get(), scoped_testing_local_state_.Get()); 135 request_context_getter_.get(), scoped_testing_local_state_.Get());
135 delegate->max_refresh_token_validation_retries_ = 0; 136 delegate->max_refresh_token_validation_retries_ = 0;
136 oauth2_service_.reset(new DeviceOAuth2TokenService(std::move(delegate))); 137 oauth2_service_.reset(new DeviceOAuth2TokenService(std::move(delegate)));
137 oauth2_service_->set_max_authorization_token_fetch_retries_for_testing(0); 138 oauth2_service_->set_max_authorization_token_fetch_retries_for_testing(0);
138 } 139 }
139 140
140 // 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
141 // (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).
142 void SetDeviceRefreshTokenInLocalState(const std::string& refresh_token) { 143 void SetDeviceRefreshTokenInLocalState(const std::string& refresh_token) {
143 scoped_testing_local_state_.Get()->SetUserPref( 144 scoped_testing_local_state_.Get()->SetUserPref(
144 prefs::kDeviceRobotAnyApiRefreshToken, new base::Value(refresh_token)); 145 prefs::kDeviceRobotAnyApiRefreshToken,
146 base::MakeUnique<base::Value>(refresh_token));
145 } 147 }
146 148
147 std::string GetValidTokenInfoResponse(const std::string& email) { 149 std::string GetValidTokenInfoResponse(const std::string& email) {
148 return "{ \"email\": \"" + email + "\"," 150 return "{ \"email\": \"" + email + "\","
149 " \"user_id\": \"1234567890\" }"; 151 " \"user_id\": \"1234567890\" }";
150 } 152 }
151 153
152 bool RefreshTokenIsAvailable() { 154 bool RefreshTokenIsAvailable() {
153 return oauth2_service_->RefreshTokenIsAvailable( 155 return oauth2_service_->RefreshTokenIsAvailable(
154 oauth2_service_->GetRobotAccountId()); 156 oauth2_service_->GetRobotAccountId());
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 // 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
471 // announced now. 473 // announced now.
472 EXPECT_CALL(observer, OnRefreshTokenAvailable("robot@example.com")); 474 EXPECT_CALL(observer, OnRefreshTokenAvailable("robot@example.com"));
473 SetRobotAccountId("robot@example.com"); 475 SetRobotAccountId("robot@example.com");
474 testing::Mock::VerifyAndClearExpectations(&observer); 476 testing::Mock::VerifyAndClearExpectations(&observer);
475 477
476 oauth2_service_->RemoveObserver(&observer); 478 oauth2_service_->RemoveObserver(&observer);
477 } 479 }
478 480
479 } // namespace chromeos 481 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698