| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/ui/sync/one_click_signin_sync_starter.h" | 5 #include "chrome/browser/ui/sync/one_click_signin_sync_starter.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "chrome/browser/signin/fake_signin_manager.h" | 11 #include "chrome/browser/signin/fake_signin_manager.h" |
| 12 #include "chrome/browser/signin/signin_manager_factory.h" | 12 #include "chrome/browser/signin/signin_manager_factory.h" |
| 13 #include "chrome/browser/signin/signin_promo.h" | 13 #include "chrome/browser/signin/signin_promo.h" |
| 14 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
| 15 #include "chrome/test/base/testing_profile.h" | 15 #include "chrome/test/base/testing_profile.h" |
| 16 #include "content/public/test/test_browser_thread_bundle.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 18 |
| 18 namespace { | 19 namespace { |
| 19 const char* kTestingUsername = "fake_username"; | 20 const char* kTestingUsername = "fake_username"; |
| 20 } // namespace | 21 } // namespace |
| 21 | 22 |
| 22 class OneClickSigninSyncStarterTest : public testing::Test { | 23 class OneClickSigninSyncStarterTest : public testing::Test { |
| 23 public: | 24 public: |
| 24 OneClickSigninSyncStarterTest() | 25 OneClickSigninSyncStarterTest() |
| 25 : sync_starter_(NULL), | 26 : sync_starter_(NULL), |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 kTestingUsername, | 61 kTestingUsername, |
| 61 std::string(), | 62 std::string(), |
| 62 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS, | 63 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS, |
| 63 NULL, | 64 NULL, |
| 64 OneClickSigninSyncStarter::NO_CONFIRMATION, | 65 OneClickSigninSyncStarter::NO_CONFIRMATION, |
| 65 signin::SOURCE_UNKNOWN, | 66 signin::SOURCE_UNKNOWN, |
| 66 callback | 67 callback |
| 67 ); | 68 ); |
| 68 } | 69 } |
| 69 | 70 |
| 71 content::TestBrowserThreadBundle thread_bundle_; |
| 72 |
| 70 scoped_ptr<TestingProfile> profile_; | 73 scoped_ptr<TestingProfile> profile_; |
| 71 | 74 |
| 72 // Deletes itself when SigninFailed() or SigninSuccess() is called. | 75 // Deletes itself when SigninFailed() or SigninSuccess() is called. |
| 73 OneClickSigninSyncStarter* sync_starter_; | 76 OneClickSigninSyncStarter* sync_starter_; |
| 74 | 77 |
| 75 // Number of times that the callback is called with SYNC_SETUP_FAILURE. | 78 // Number of times that the callback is called with SYNC_SETUP_FAILURE. |
| 76 int failed_count_; | 79 int failed_count_; |
| 77 | 80 |
| 78 // Number of times that the callback is called with SYNC_SETUP_SUCCESS. | 81 // Number of times that the callback is called with SYNC_SETUP_SUCCESS. |
| 79 int succeeded_count_; | 82 int succeeded_count_; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 98 } | 101 } |
| 99 | 102 |
| 100 // Verifies that there is no crash when the callback is NULL. | 103 // Verifies that there is no crash when the callback is NULL. |
| 101 TEST_F(OneClickSigninSyncStarterTest, CallbackNull) { | 104 TEST_F(OneClickSigninSyncStarterTest, CallbackNull) { |
| 102 CreateSyncStarter(OneClickSigninSyncStarter::Callback()); | 105 CreateSyncStarter(OneClickSigninSyncStarter::Callback()); |
| 103 sync_starter_->SigninFailed(GoogleServiceAuthError( | 106 sync_starter_->SigninFailed(GoogleServiceAuthError( |
| 104 GoogleServiceAuthError::REQUEST_CANCELED)); | 107 GoogleServiceAuthError::REQUEST_CANCELED)); |
| 105 EXPECT_EQ(0, failed_count_); | 108 EXPECT_EQ(0, failed_count_); |
| 106 EXPECT_EQ(0, succeeded_count_); | 109 EXPECT_EQ(0, succeeded_count_); |
| 107 } | 110 } |
| OLD | NEW |