| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "components/signin/core/browser/signin_manager.h" | 5 #include "components/signin/core/browser/signin_manager.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 return service; | 54 return service; |
| 55 } | 55 } |
| 56 | 56 |
| 57 class TestSigninManagerObserver : public SigninManagerBase::Observer { | 57 class TestSigninManagerObserver : public SigninManagerBase::Observer { |
| 58 public: | 58 public: |
| 59 TestSigninManagerObserver() : num_failed_signins_(0), | 59 TestSigninManagerObserver() : num_failed_signins_(0), |
| 60 num_successful_signins_(0), | 60 num_successful_signins_(0), |
| 61 num_signouts_(0) { | 61 num_signouts_(0) { |
| 62 } | 62 } |
| 63 | 63 |
| 64 virtual ~TestSigninManagerObserver() {} | 64 ~TestSigninManagerObserver() override {} |
| 65 | 65 |
| 66 int num_failed_signins_; | 66 int num_failed_signins_; |
| 67 int num_successful_signins_; | 67 int num_successful_signins_; |
| 68 int num_signouts_; | 68 int num_signouts_; |
| 69 | 69 |
| 70 private: | 70 private: |
| 71 // SigninManagerBase::Observer: | 71 // SigninManagerBase::Observer: |
| 72 virtual void GoogleSigninFailed( | 72 void GoogleSigninFailed(const GoogleServiceAuthError& error) override { |
| 73 const GoogleServiceAuthError& error) override { | |
| 74 num_failed_signins_++; | 73 num_failed_signins_++; |
| 75 } | 74 } |
| 76 | 75 |
| 77 virtual void GoogleSigninSucceeded( | 76 void GoogleSigninSucceeded(const std::string& account_id, |
| 78 const std::string& account_id, | 77 const std::string& username, |
| 79 const std::string& username, | 78 const std::string& password) override { |
| 80 const std::string& password) override { | |
| 81 num_successful_signins_++; | 79 num_successful_signins_++; |
| 82 } | 80 } |
| 83 | 81 |
| 84 virtual void GoogleSignedOut(const std::string& account_id, | 82 void GoogleSignedOut(const std::string& account_id, |
| 85 const std::string& username) override { | 83 const std::string& username) override { |
| 86 num_signouts_++; | 84 num_signouts_++; |
| 87 } | 85 } |
| 88 }; | 86 }; |
| 89 | 87 |
| 90 } // namespace | 88 } // namespace |
| 91 | 89 |
| 92 | 90 |
| 93 class SigninManagerTest : public testing::Test { | 91 class SigninManagerTest : public testing::Test { |
| 94 public: | 92 public: |
| 95 SigninManagerTest() : manager_(NULL) {} | 93 SigninManagerTest() : manager_(NULL) {} |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 profile()->GetPrefs()->GetString(prefs::kGoogleServicesUsername)); | 342 profile()->GetPrefs()->GetString(prefs::kGoogleServicesUsername)); |
| 345 EXPECT_EQ("external@example.com", manager_->GetAuthenticatedUsername()); | 343 EXPECT_EQ("external@example.com", manager_->GetAuthenticatedUsername()); |
| 346 } | 344 } |
| 347 | 345 |
| 348 TEST_F(SigninManagerTest, SigninNotAllowed) { | 346 TEST_F(SigninManagerTest, SigninNotAllowed) { |
| 349 std::string user("user@google.com"); | 347 std::string user("user@google.com"); |
| 350 profile()->GetPrefs()->SetString(prefs::kGoogleServicesUsername, user); | 348 profile()->GetPrefs()->SetString(prefs::kGoogleServicesUsername, user); |
| 351 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false); | 349 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false); |
| 352 SetUpSigninManagerAsService(); | 350 SetUpSigninManagerAsService(); |
| 353 } | 351 } |
| OLD | NEW |