| 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 DeviceSettingsService::Get()->Load(); | 67 DeviceSettingsService::Get()->Load(); |
| 68 device_settings_test_helper_.Flush(); | 68 device_settings_test_helper_.Flush(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 scoped_ptr<OAuth2TokenService::Request> StartTokenRequest() { | 71 scoped_ptr<OAuth2TokenService::Request> StartTokenRequest() { |
| 72 return oauth2_service_->StartRequest(oauth2_service_->GetRobotAccountId(), | 72 return oauth2_service_->StartRequest(oauth2_service_->GetRobotAccountId(), |
| 73 std::set<std::string>(), | 73 std::set<std::string>(), |
| 74 &consumer_); | 74 &consumer_); |
| 75 } | 75 } |
| 76 | 76 |
| 77 virtual void SetUp() OVERRIDE { | 77 virtual void SetUp() override { |
| 78 fake_cryptohome_client_ = new FakeCryptohomeClient; | 78 fake_cryptohome_client_ = new FakeCryptohomeClient; |
| 79 fake_cryptohome_client_->SetServiceIsAvailable(true); | 79 fake_cryptohome_client_->SetServiceIsAvailable(true); |
| 80 fake_cryptohome_client_->set_system_salt( | 80 fake_cryptohome_client_->set_system_salt( |
| 81 FakeCryptohomeClient::GetStubSystemSalt()); | 81 FakeCryptohomeClient::GetStubSystemSalt()); |
| 82 chromeos::DBusThreadManager::GetSetterForTesting()->SetCryptohomeClient( | 82 chromeos::DBusThreadManager::GetSetterForTesting()->SetCryptohomeClient( |
| 83 scoped_ptr<CryptohomeClient>(fake_cryptohome_client_)); | 83 scoped_ptr<CryptohomeClient>(fake_cryptohome_client_)); |
| 84 | 84 |
| 85 SystemSaltGetter::Initialize(); | 85 SystemSaltGetter::Initialize(); |
| 86 | 86 |
| 87 DeviceSettingsService::Initialize(); | 87 DeviceSettingsService::Initialize(); |
| 88 scoped_refptr<ownership::MockOwnerKeyUtil> owner_key_util_( | 88 scoped_refptr<ownership::MockOwnerKeyUtil> owner_key_util_( |
| 89 new ownership::MockOwnerKeyUtil()); | 89 new ownership::MockOwnerKeyUtil()); |
| 90 owner_key_util_->SetPublicKeyFromPrivateKey( | 90 owner_key_util_->SetPublicKeyFromPrivateKey( |
| 91 *device_policy_.GetSigningKey()); | 91 *device_policy_.GetSigningKey()); |
| 92 DeviceSettingsService::Get()->SetSessionManager( | 92 DeviceSettingsService::Get()->SetSessionManager( |
| 93 &device_settings_test_helper_, owner_key_util_); | 93 &device_settings_test_helper_, owner_key_util_); |
| 94 | 94 |
| 95 CrosSettings::Initialize(); | 95 CrosSettings::Initialize(); |
| 96 } | 96 } |
| 97 | 97 |
| 98 virtual void TearDown() OVERRIDE { | 98 virtual void TearDown() override { |
| 99 CrosSettings::Shutdown(); | 99 CrosSettings::Shutdown(); |
| 100 TestingBrowserProcess::GetGlobal()->SetBrowserPolicyConnector(NULL); | 100 TestingBrowserProcess::GetGlobal()->SetBrowserPolicyConnector(NULL); |
| 101 content::BrowserThread::GetBlockingPool()->FlushForTesting(); | 101 content::BrowserThread::GetBlockingPool()->FlushForTesting(); |
| 102 DeviceSettingsService::Get()->UnsetSessionManager(); | 102 DeviceSettingsService::Get()->UnsetSessionManager(); |
| 103 DeviceSettingsService::Shutdown(); | 103 DeviceSettingsService::Shutdown(); |
| 104 SystemSaltGetter::Shutdown(); | 104 SystemSaltGetter::Shutdown(); |
| 105 DBusThreadManager::Shutdown(); | 105 DBusThreadManager::Shutdown(); |
| 106 base::RunLoop().RunUntilIdle(); | 106 base::RunLoop().RunUntilIdle(); |
| 107 } | 107 } |
| 108 | 108 |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 | 424 |
| 425 AssertConsumerTokensAndErrors(0, 1); | 425 AssertConsumerTokensAndErrors(0, 1); |
| 426 | 426 |
| 427 // Retry should succeed. | 427 // Retry should succeed. |
| 428 request = StartTokenRequest(); | 428 request = StartTokenRequest(); |
| 429 PerformURLFetches(); | 429 PerformURLFetches(); |
| 430 AssertConsumerTokensAndErrors(1, 1); | 430 AssertConsumerTokensAndErrors(1, 1); |
| 431 } | 431 } |
| 432 | 432 |
| 433 } // namespace chromeos | 433 } // namespace chromeos |
| OLD | NEW |