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/bind.h" |
| 10 #include "base/bind_helpers.h" |
9 #include "base/command_line.h" | 11 #include "base/command_line.h" |
10 #include "base/synchronization/waitable_event.h" | 12 #include "base/synchronization/waitable_event.h" |
11 #include "base/test/signaling_task.h" | |
12 #include "chrome/browser/password_manager/encryptor.h" | 13 #include "chrome/browser/password_manager/encryptor.h" |
13 #include "chrome/common/chrome_notification_types.h" | 14 #include "chrome/common/chrome_notification_types.h" |
14 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
15 #include "chrome/common/net/gaia/gaia_auth_fetcher_unittest.h" | 16 #include "chrome/common/net/gaia/gaia_auth_fetcher_unittest.h" |
16 #include "chrome/common/net/gaia/gaia_constants.h" | 17 #include "chrome/common/net/gaia/gaia_constants.h" |
17 #include "content/test/test_url_fetcher_factory.h" | 18 #include "content/test/test_url_fetcher_factory.h" |
18 | 19 |
19 using content::BrowserThread; | 20 using content::BrowserThread; |
20 | 21 |
21 TokenAvailableTracker::TokenAvailableTracker() {} | 22 TokenAvailableTracker::TokenAvailableTracker() {} |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask); | 91 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask); |
91 MessageLoop::current()->Run(); | 92 MessageLoop::current()->Run(); |
92 } | 93 } |
93 | 94 |
94 void TokenServiceTestHarness::WaitForDBLoadCompletion() { | 95 void TokenServiceTestHarness::WaitForDBLoadCompletion() { |
95 // The WebDB does all work on the DB thread. This will add an event | 96 // The WebDB does all work on the DB thread. This will add an event |
96 // to the end of the DB thread, so when we reach this task, all DB | 97 // to the end of the DB thread, so when we reach this task, all DB |
97 // operations should be complete. | 98 // operations should be complete. |
98 base::WaitableEvent done(false, false); | 99 base::WaitableEvent done(false, false); |
99 BrowserThread::PostTask( | 100 BrowserThread::PostTask( |
100 BrowserThread::DB, FROM_HERE, new base::SignalingTask(&done)); | 101 BrowserThread::DB, |
| 102 FROM_HERE, |
| 103 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&done))); |
101 done.Wait(); | 104 done.Wait(); |
102 | 105 |
103 // Notifications should be returned from the DB thread onto the UI thread. | 106 // Notifications should be returned from the DB thread onto the UI thread. |
104 message_loop_.RunAllPending(); | 107 message_loop_.RunAllPending(); |
105 } | 108 } |
106 | 109 |
107 class TokenServiceTest : public TokenServiceTestHarness { | 110 class TokenServiceTest : public TokenServiceTestHarness { |
108 public: | 111 public: |
109 virtual void SetUp() { | 112 virtual void SetUp() { |
110 TokenServiceTestHarness::SetUp(); | 113 TokenServiceTestHarness::SetUp(); |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 | 509 |
507 *CommandLine::ForCurrentProcess() = original_cl; | 510 *CommandLine::ForCurrentProcess() = original_cl; |
508 } | 511 } |
509 }; | 512 }; |
510 | 513 |
511 TEST_F(TokenServiceCommandLineTest, TestValueOverride) { | 514 TEST_F(TokenServiceCommandLineTest, TestValueOverride) { |
512 EXPECT_TRUE(service_.HasTokenForService("my_service")); | 515 EXPECT_TRUE(service_.HasTokenForService("my_service")); |
513 EXPECT_EQ("my_value", service_.GetTokenForService("my_service")); | 516 EXPECT_EQ("my_value", service_.GetTokenForService("my_service")); |
514 } | 517 } |
515 #endif // ifndef NDEBUG | 518 #endif // ifndef NDEBUG |
OLD | NEW |