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 "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "base/prefs/testing_pref_service.h" | 8 #include "base/prefs/testing_pref_service.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/threading/sequenced_worker_pool.h" | 10 #include "base/threading/sequenced_worker_pool.h" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 } | 138 } |
139 | 139 |
140 // Utility method to set a value in Local State for the device refresh token | 140 // 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). | 141 // (it must have a non-empty value or it won't be used). |
142 void SetDeviceRefreshTokenInLocalState(const std::string& refresh_token) { | 142 void SetDeviceRefreshTokenInLocalState(const std::string& refresh_token) { |
143 scoped_testing_local_state_.Get()->SetUserPref( | 143 scoped_testing_local_state_.Get()->SetUserPref( |
144 prefs::kDeviceRobotAnyApiRefreshToken, | 144 prefs::kDeviceRobotAnyApiRefreshToken, |
145 new base::StringValue(refresh_token)); | 145 new base::StringValue(refresh_token)); |
146 } | 146 } |
147 | 147 |
148 std::string GetValidTokenInfoResponse(const std::string email) { | 148 std::string GetValidTokenInfoResponse(const std::string& email) { |
149 return "{ \"email\": \"" + email + "\"," | 149 return "{ \"email\": \"" + email + "\"," |
150 " \"user_id\": \"1234567890\" }"; | 150 " \"user_id\": \"1234567890\" }"; |
151 } | 151 } |
152 | 152 |
153 bool RefreshTokenIsAvailable() { | 153 bool RefreshTokenIsAvailable() { |
154 return oauth2_service_->RefreshTokenIsAvailable( | 154 return oauth2_service_->RefreshTokenIsAvailable( |
155 oauth2_service_->GetRobotAccountId()); | 155 oauth2_service_->GetRobotAccountId()); |
156 } | 156 } |
157 | 157 |
158 std::string GetRefreshToken() { | 158 std::string GetRefreshToken() { |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 // Also make the robot account ID available. Verify that the token is | 470 // Also make the robot account ID available. Verify that the token is |
471 // announced now. | 471 // announced now. |
472 EXPECT_CALL(observer, OnRefreshTokenAvailable("robot@example.com")); | 472 EXPECT_CALL(observer, OnRefreshTokenAvailable("robot@example.com")); |
473 SetRobotAccountId("robot@example.com"); | 473 SetRobotAccountId("robot@example.com"); |
474 testing::Mock::VerifyAndClearExpectations(&observer); | 474 testing::Mock::VerifyAndClearExpectations(&observer); |
475 | 475 |
476 oauth2_service_->RemoveObserver(&observer); | 476 oauth2_service_->RemoveObserver(&observer); |
477 } | 477 } |
478 | 478 |
479 } // namespace chromeos | 479 } // namespace chromeos |
OLD | NEW |