| 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" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 | 83 |
| 84 db_thread_.Stop(); | 84 db_thread_.Stop(); |
| 85 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask); | 85 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask); |
| 86 MessageLoop::current()->Run(); | 86 MessageLoop::current()->Run(); |
| 87 } | 87 } |
| 88 | 88 |
| 89 void TokenServiceTestHarness::WaitForDBLoadCompletion() { | 89 void TokenServiceTestHarness::WaitForDBLoadCompletion() { |
| 90 // The WebDB does all work on the DB thread. This will add an event | 90 // The WebDB does all work on the DB thread. This will add an event |
| 91 // to the end of the DB thread, so when we reach this task, all DB | 91 // to the end of the DB thread, so when we reach this task, all DB |
| 92 // operations should be complete. | 92 // operations should be complete. |
| 93 base::WaitableEvent done(false, false); | 93 CHECK(BrowserThread::WaitForPendingTasksOn(BrowserThread::DB)); |
| 94 BrowserThread::PostTask( | |
| 95 BrowserThread::DB, FROM_HERE, new SignalingTask(&done)); | |
| 96 done.Wait(); | |
| 97 | 94 |
| 98 // Notifications should be returned from the DB thread onto the UI thread. | 95 // Notifications should be returned from the DB thread onto the UI thread. |
| 99 message_loop_.RunAllPending(); | 96 message_loop_.RunAllPending(); |
| 100 } | 97 } |
| 101 | 98 |
| 102 class TokenServiceTest : public TokenServiceTestHarness { | 99 class TokenServiceTest : public TokenServiceTestHarness { |
| 103 public: | 100 public: |
| 104 virtual void SetUp() { | 101 virtual void SetUp() { |
| 105 TokenServiceTestHarness::SetUp(); | 102 TokenServiceTestHarness::SetUp(); |
| 106 service_.UpdateCredentials(credentials_); | 103 service_.UpdateCredentials(credentials_); |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 | 444 |
| 448 *CommandLine::ForCurrentProcess() = original_cl; | 445 *CommandLine::ForCurrentProcess() = original_cl; |
| 449 } | 446 } |
| 450 }; | 447 }; |
| 451 | 448 |
| 452 TEST_F(TokenServiceCommandLineTest, TestValueOverride) { | 449 TEST_F(TokenServiceCommandLineTest, TestValueOverride) { |
| 453 EXPECT_TRUE(service_.HasTokenForService("my_service")); | 450 EXPECT_TRUE(service_.HasTokenForService("my_service")); |
| 454 EXPECT_EQ("my_value", service_.GetTokenForService("my_service")); | 451 EXPECT_EQ("my_value", service_.GetTokenForService("my_service")); |
| 455 } | 452 } |
| 456 #endif // ifndef NDEBUG | 453 #endif // ifndef NDEBUG |
| OLD | NEW |