OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // This file defines a unit test for the profile's token service. | 5 // This file defines a unit test for the profile's token service. |
6 | 6 |
7 #include "chrome/browser/signin/token_service_unittest.h" | 7 #include "chrome/browser/signin/token_service_unittest.h" |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 #if defined(OS_MACOSX) | 57 #if defined(OS_MACOSX) |
58 Encryptor::UseMockKeychain(true); | 58 Encryptor::UseMockKeychain(true); |
59 #endif | 59 #endif |
60 credentials_.sid = "sid"; | 60 credentials_.sid = "sid"; |
61 credentials_.lsid = "lsid"; | 61 credentials_.lsid = "lsid"; |
62 credentials_.token = "token"; | 62 credentials_.token = "token"; |
63 credentials_.data = "data"; | 63 credentials_.data = "data"; |
64 oauth_token_ = "oauth"; | 64 oauth_token_ = "oauth"; |
65 oauth_secret_ = "secret"; | 65 oauth_secret_ = "secret"; |
66 | 66 |
67 profile_.reset(new TestingProfile()); | 67 profile_ = CreateProfile().Pass(); |
| 68 |
68 profile_->CreateWebDataService(); | 69 profile_->CreateWebDataService(); |
69 | 70 |
70 // Force the loading of the WebDataService. | 71 // Force the loading of the WebDataService. |
71 TokenWebData::FromBrowserContext(profile_.get()); | 72 TokenWebData::FromBrowserContext(profile_.get()); |
72 base::RunLoop().RunUntilIdle(); | 73 base::RunLoop().RunUntilIdle(); |
73 | 74 |
74 service_ = TokenServiceFactory::GetForProfile(profile_.get()); | 75 service_ = TokenServiceFactory::GetForProfile(profile_.get()); |
75 | 76 |
76 success_tracker_.ListenFor(chrome::NOTIFICATION_TOKEN_AVAILABLE, | 77 success_tracker_.ListenFor(chrome::NOTIFICATION_TOKEN_AVAILABLE, |
77 content::Source<TokenService>(service_)); | 78 content::Source<TokenService>(service_)); |
78 failure_tracker_.ListenFor(chrome::NOTIFICATION_TOKEN_REQUEST_FAILED, | 79 failure_tracker_.ListenFor(chrome::NOTIFICATION_TOKEN_REQUEST_FAILED, |
79 content::Source<TokenService>(service_)); | 80 content::Source<TokenService>(service_)); |
80 | 81 |
81 service()->Initialize("test", profile_.get()); | 82 service()->Initialize("test", profile_.get()); |
82 } | 83 } |
83 | 84 |
| 85 scoped_ptr<TestingProfile> TokenServiceTestHarness::CreateProfile() { |
| 86 return make_scoped_ptr(new TestingProfile()); |
| 87 } |
| 88 |
84 void TokenServiceTestHarness::TearDown() { | 89 void TokenServiceTestHarness::TearDown() { |
85 // You have to destroy the profile before the threads are shut down. | 90 // You have to destroy the profile before the threads are shut down. |
86 profile_.reset(); | 91 profile_.reset(); |
87 } | 92 } |
88 | 93 |
89 void TokenServiceTestHarness::UpdateCredentialsOnService() { | 94 void TokenServiceTestHarness::UpdateCredentialsOnService() { |
90 service()->UpdateCredentials(credentials_); | 95 service()->UpdateCredentials(credentials_); |
91 } | 96 } |
92 | 97 |
93 class TokenServiceTest : public TokenServiceTestHarness { | 98 class TokenServiceTest : public TokenServiceTestHarness { |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 | 400 |
396 *CommandLine::ForCurrentProcess() = original_cl; | 401 *CommandLine::ForCurrentProcess() = original_cl; |
397 } | 402 } |
398 }; | 403 }; |
399 | 404 |
400 TEST_F(TokenServiceCommandLineTest, TestValueOverride) { | 405 TEST_F(TokenServiceCommandLineTest, TestValueOverride) { |
401 EXPECT_TRUE(service()->HasTokenForService("my_service")); | 406 EXPECT_TRUE(service()->HasTokenForService("my_service")); |
402 EXPECT_EQ("my_value", service()->GetTokenForService("my_service")); | 407 EXPECT_EQ("my_value", service()->GetTokenForService("my_service")); |
403 } | 408 } |
404 #endif // ifndef NDEBUG | 409 #endif // ifndef NDEBUG |
OLD | NEW |