| 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 #include "chrome/browser/sync/signin_manager.h" | 5 #include "chrome/browser/sync/signin_manager.h" |
| 6 | 6 |
| 7 #include "chrome/browser/net/gaia/token_service.h" | 7 #include "chrome/browser/net/gaia/token_service.h" |
| 8 #include "chrome/browser/net/gaia/token_service_unittest.h" | 8 #include "chrome/browser/net/gaia/token_service_unittest.h" |
| 9 #include "chrome/browser/password_manager/encryptor.h" | 9 #include "chrome/browser/password_manager/encryptor.h" |
| 10 #include "chrome/browser/webdata/web_data_service.h" | 10 #include "chrome/browser/webdata/web_data_service.h" |
| 11 #include "chrome/common/chrome_notification_types.h" |
| 11 #include "chrome/common/net/gaia/gaia_urls.h" | 12 #include "chrome/common/net/gaia/gaia_urls.h" |
| 12 #include "chrome/test/signaling_task.h" | 13 #include "chrome/test/signaling_task.h" |
| 13 #include "chrome/test/testing_profile.h" | 14 #include "chrome/test/testing_profile.h" |
| 14 #include "content/common/test_url_fetcher_factory.h" | 15 #include "content/common/test_url_fetcher_factory.h" |
| 15 #include "net/url_request/url_request.h" | 16 #include "net/url_request/url_request.h" |
| 16 #include "net/url_request/url_request_status.h" | 17 #include "net/url_request/url_request_status.h" |
| 17 | 18 |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 19 | 20 |
| 20 class SigninManagerTest : public TokenServiceTestHarness { | 21 class SigninManagerTest : public TokenServiceTestHarness { |
| 21 public: | 22 public: |
| 22 virtual void SetUp() { | 23 virtual void SetUp() { |
| 23 TokenServiceTestHarness::SetUp(); | 24 TokenServiceTestHarness::SetUp(); |
| 24 manager_.reset(new SigninManager()); | 25 manager_.reset(new SigninManager()); |
| 25 google_login_success_.ListenFor(NotificationType::GOOGLE_SIGNIN_SUCCESSFUL, | 26 google_login_success_.ListenFor( |
| 26 Source<Profile>(profile_.get())); | 27 chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL, |
| 27 google_login_failure_.ListenFor(NotificationType::GOOGLE_SIGNIN_FAILED, | 28 Source<Profile>(profile_.get())); |
| 29 google_login_failure_.ListenFor(chrome::NOTIFICATION_GOOGLE_SIGNIN_FAILED, |
| 28 Source<Profile>(profile_.get())); | 30 Source<Profile>(profile_.get())); |
| 29 | 31 |
| 30 URLFetcher::set_factory(&factory_); | 32 URLFetcher::set_factory(&factory_); |
| 31 } | 33 } |
| 32 | 34 |
| 33 void SimulateValidResponse() { | 35 void SimulateValidResponse() { |
| 34 // Simulate the correct ClientLogin response. | 36 // Simulate the correct ClientLogin response. |
| 35 TestURLFetcher* fetcher = factory_.GetFetcherByID(0); | 37 TestURLFetcher* fetcher = factory_.GetFetcherByID(0); |
| 36 DCHECK(fetcher); | 38 DCHECK(fetcher); |
| 37 DCHECK(fetcher->delegate()); | 39 DCHECK(fetcher->delegate()); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 | 160 |
| 159 TEST_F(SigninManagerTest, SignOutMidConnect) { | 161 TEST_F(SigninManagerTest, SignOutMidConnect) { |
| 160 manager_->Initialize(profile_.get()); | 162 manager_->Initialize(profile_.get()); |
| 161 manager_->StartSignIn("username", "password", "", ""); | 163 manager_->StartSignIn("username", "password", "", ""); |
| 162 manager_->SignOut(); | 164 manager_->SignOut(); |
| 163 EXPECT_EQ(0U, google_login_success_.size()); | 165 EXPECT_EQ(0U, google_login_success_.size()); |
| 164 EXPECT_EQ(0U, google_login_failure_.size()); | 166 EXPECT_EQ(0U, google_login_failure_.size()); |
| 165 | 167 |
| 166 EXPECT_TRUE(manager_->GetUsername().empty()); | 168 EXPECT_TRUE(manager_->GetUsername().empty()); |
| 167 } | 169 } |
| OLD | NEW |