OLD | NEW |
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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 request_context_getter_.get(), scoped_testing_local_state_.Get()); | 135 request_context_getter_.get(), scoped_testing_local_state_.Get()); |
136 delegate->max_refresh_token_validation_retries_ = 0; | 136 delegate->max_refresh_token_validation_retries_ = 0; |
137 oauth2_service_.reset(new DeviceOAuth2TokenService(std::move(delegate))); | 137 oauth2_service_.reset(new DeviceOAuth2TokenService(std::move(delegate))); |
138 oauth2_service_->set_max_authorization_token_fetch_retries_for_testing(0); | 138 oauth2_service_->set_max_authorization_token_fetch_retries_for_testing(0); |
139 } | 139 } |
140 | 140 |
141 // 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 |
142 // (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). |
143 void SetDeviceRefreshTokenInLocalState(const std::string& refresh_token) { | 143 void SetDeviceRefreshTokenInLocalState(const std::string& refresh_token) { |
144 scoped_testing_local_state_.Get()->SetUserPref( | 144 scoped_testing_local_state_.Get()->SetUserPref( |
145 prefs::kDeviceRobotAnyApiRefreshToken, | 145 prefs::kDeviceRobotAnyApiRefreshToken, new base::Value(refresh_token)); |
146 new base::StringValue(refresh_token)); | |
147 } | 146 } |
148 | 147 |
149 std::string GetValidTokenInfoResponse(const std::string& email) { | 148 std::string GetValidTokenInfoResponse(const std::string& email) { |
150 return "{ \"email\": \"" + email + "\"," | 149 return "{ \"email\": \"" + email + "\"," |
151 " \"user_id\": \"1234567890\" }"; | 150 " \"user_id\": \"1234567890\" }"; |
152 } | 151 } |
153 | 152 |
154 bool RefreshTokenIsAvailable() { | 153 bool RefreshTokenIsAvailable() { |
155 return oauth2_service_->RefreshTokenIsAvailable( | 154 return oauth2_service_->RefreshTokenIsAvailable( |
156 oauth2_service_->GetRobotAccountId()); | 155 oauth2_service_->GetRobotAccountId()); |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 // Also make the robot account ID available. Verify that the token is | 471 // Also make the robot account ID available. Verify that the token is |
473 // announced now. | 472 // announced now. |
474 EXPECT_CALL(observer, OnRefreshTokenAvailable("robot@example.com")); | 473 EXPECT_CALL(observer, OnRefreshTokenAvailable("robot@example.com")); |
475 SetRobotAccountId("robot@example.com"); | 474 SetRobotAccountId("robot@example.com"); |
476 testing::Mock::VerifyAndClearExpectations(&observer); | 475 testing::Mock::VerifyAndClearExpectations(&observer); |
477 | 476 |
478 oauth2_service_->RemoveObserver(&observer); | 477 oauth2_service_->RemoveObserver(&observer); |
479 } | 478 } |
480 | 479 |
481 } // namespace chromeos | 480 } // namespace chromeos |
OLD | NEW |