OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/net/gaia/token_service_unittest.h" | 7 #include "chrome/browser/net/gaia/token_service_unittest.h" |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
11 #include "chrome/browser/password_manager/encryptor.h" | 11 #include "chrome/browser/password_manager/encryptor.h" |
12 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
13 #include "chrome/common/net/gaia/gaia_auth_fetcher_unittest.h" | 13 #include "chrome/common/net/gaia/gaia_auth_fetcher_unittest.h" |
14 #include "chrome/common/net/gaia/gaia_constants.h" | 14 #include "chrome/common/net/gaia/gaia_constants.h" |
15 #include "chrome/common/net/test_url_fetcher_factory.h" | 15 #include "chrome/common/net/test_url_fetcher_factory.h" |
16 | 16 |
| 17 TokenAvailableTracker::TokenAvailableTracker() {} |
| 18 |
| 19 TokenAvailableTracker::~TokenAvailableTracker() {} |
| 20 |
| 21 void TokenAvailableTracker::Observe(NotificationType type, |
| 22 const NotificationSource& source, |
| 23 const NotificationDetails& details) { |
| 24 TestNotificationTracker::Observe(type, source, details); |
| 25 if (type == NotificationType::TOKEN_AVAILABLE) { |
| 26 Details<const TokenService::TokenAvailableDetails> full = details; |
| 27 details_ = *full.ptr(); |
| 28 } |
| 29 } |
| 30 |
| 31 TokenFailedTracker::TokenFailedTracker() {} |
| 32 |
| 33 TokenFailedTracker::~TokenFailedTracker() {} |
| 34 |
| 35 void TokenFailedTracker::Observe(NotificationType type, |
| 36 const NotificationSource& source, |
| 37 const NotificationDetails& details) { |
| 38 TestNotificationTracker::Observe(type, source, details); |
| 39 if (type == NotificationType::TOKEN_REQUEST_FAILED) { |
| 40 Details<const TokenService::TokenRequestFailedDetails> full = details; |
| 41 details_ = *full.ptr(); |
| 42 } |
| 43 } |
| 44 |
17 TokenServiceTestHarness::TokenServiceTestHarness() | 45 TokenServiceTestHarness::TokenServiceTestHarness() |
18 : ui_thread_(BrowserThread::UI, &message_loop_), | 46 : ui_thread_(BrowserThread::UI, &message_loop_), |
19 db_thread_(BrowserThread::DB) { | 47 db_thread_(BrowserThread::DB) { |
20 } | 48 } |
21 | 49 |
22 TokenServiceTestHarness::~TokenServiceTestHarness() {} | 50 TokenServiceTestHarness::~TokenServiceTestHarness() {} |
23 | 51 |
24 void TokenServiceTestHarness::SetUp() { | 52 void TokenServiceTestHarness::SetUp() { |
25 #if defined(OS_MACOSX) | 53 #if defined(OS_MACOSX) |
26 Encryptor::UseMockKeychain(true); | 54 Encryptor::UseMockKeychain(true); |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 | 357 |
330 *CommandLine::ForCurrentProcess() = original_cl; | 358 *CommandLine::ForCurrentProcess() = original_cl; |
331 } | 359 } |
332 }; | 360 }; |
333 | 361 |
334 TEST_F(TokenServiceCommandLineTest, TestValueOverride) { | 362 TEST_F(TokenServiceCommandLineTest, TestValueOverride) { |
335 EXPECT_TRUE(service_.HasTokenForService("my_service")); | 363 EXPECT_TRUE(service_.HasTokenForService("my_service")); |
336 EXPECT_EQ("my_value", service_.GetTokenForService("my_service")); | 364 EXPECT_EQ("my_value", service_.GetTokenForService("my_service")); |
337 } | 365 } |
338 #endif // ifndef NDEBUG | 366 #endif // ifndef NDEBUG |
OLD | NEW |