OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/test/signaling_task.h" |
11 #include "chrome/browser/password_manager/encryptor.h" | 12 #include "chrome/browser/password_manager/encryptor.h" |
12 #include "chrome/common/chrome_notification_types.h" | 13 #include "chrome/common/chrome_notification_types.h" |
13 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
14 #include "chrome/common/net/gaia/gaia_auth_fetcher_unittest.h" | 15 #include "chrome/common/net/gaia/gaia_auth_fetcher_unittest.h" |
15 #include "chrome/common/net/gaia/gaia_constants.h" | 16 #include "chrome/common/net/gaia/gaia_constants.h" |
16 #include "content/test/test_url_fetcher_factory.h" | 17 #include "content/test/test_url_fetcher_factory.h" |
17 | 18 |
18 TokenAvailableTracker::TokenAvailableTracker() {} | 19 TokenAvailableTracker::TokenAvailableTracker() {} |
19 | 20 |
20 TokenAvailableTracker::~TokenAvailableTracker() {} | 21 TokenAvailableTracker::~TokenAvailableTracker() {} |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask); | 88 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask); |
88 MessageLoop::current()->Run(); | 89 MessageLoop::current()->Run(); |
89 } | 90 } |
90 | 91 |
91 void TokenServiceTestHarness::WaitForDBLoadCompletion() { | 92 void TokenServiceTestHarness::WaitForDBLoadCompletion() { |
92 // The WebDB does all work on the DB thread. This will add an event | 93 // The WebDB does all work on the DB thread. This will add an event |
93 // to the end of the DB thread, so when we reach this task, all DB | 94 // to the end of the DB thread, so when we reach this task, all DB |
94 // operations should be complete. | 95 // operations should be complete. |
95 base::WaitableEvent done(false, false); | 96 base::WaitableEvent done(false, false); |
96 BrowserThread::PostTask( | 97 BrowserThread::PostTask( |
97 BrowserThread::DB, FROM_HERE, new SignalingTask(&done)); | 98 BrowserThread::DB, FROM_HERE, new base::SignalingTask(&done)); |
98 done.Wait(); | 99 done.Wait(); |
99 | 100 |
100 // Notifications should be returned from the DB thread onto the UI thread. | 101 // Notifications should be returned from the DB thread onto the UI thread. |
101 message_loop_.RunAllPending(); | 102 message_loop_.RunAllPending(); |
102 } | 103 } |
103 | 104 |
104 class TokenServiceTest : public TokenServiceTestHarness { | 105 class TokenServiceTest : public TokenServiceTestHarness { |
105 public: | 106 public: |
106 virtual void SetUp() { | 107 virtual void SetUp() { |
107 TokenServiceTestHarness::SetUp(); | 108 TokenServiceTestHarness::SetUp(); |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 | 450 |
450 *CommandLine::ForCurrentProcess() = original_cl; | 451 *CommandLine::ForCurrentProcess() = original_cl; |
451 } | 452 } |
452 }; | 453 }; |
453 | 454 |
454 TEST_F(TokenServiceCommandLineTest, TestValueOverride) { | 455 TEST_F(TokenServiceCommandLineTest, TestValueOverride) { |
455 EXPECT_TRUE(service_.HasTokenForService("my_service")); | 456 EXPECT_TRUE(service_.HasTokenForService("my_service")); |
456 EXPECT_EQ("my_value", service_.GetTokenForService("my_service")); | 457 EXPECT_EQ("my_value", service_.GetTokenForService("my_service")); |
457 } | 458 } |
458 #endif // ifndef NDEBUG | 459 #endif // ifndef NDEBUG |
OLD | NEW |