| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_observer.h" | 5 #include "chrome/browser/ui/sync/one_click_signin_sync_observer.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 9 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 10 #include "chrome/browser/signin/signin_manager_factory.h" | 10 #include "chrome/browser/signin/signin_manager_factory.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 | 108 |
| 109 } // namespace | 109 } // namespace |
| 110 | 110 |
| 111 class OneClickSigninSyncObserverTest : public ChromeRenderViewHostTestHarness { | 111 class OneClickSigninSyncObserverTest : public ChromeRenderViewHostTestHarness { |
| 112 public: | 112 public: |
| 113 OneClickSigninSyncObserverTest() | 113 OneClickSigninSyncObserverTest() |
| 114 : sync_service_(NULL), | 114 : sync_service_(NULL), |
| 115 sync_observer_(NULL), | 115 sync_observer_(NULL), |
| 116 sync_observer_destroyed_(true) {} | 116 sync_observer_destroyed_(true) {} |
| 117 | 117 |
| 118 virtual void SetUp() override { | 118 void SetUp() override { |
| 119 ChromeRenderViewHostTestHarness::SetUp(); | 119 ChromeRenderViewHostTestHarness::SetUp(); |
| 120 web_contents_observer_.reset(new MockWebContentsObserver(web_contents())); | 120 web_contents_observer_.reset(new MockWebContentsObserver(web_contents())); |
| 121 sync_service_ = | 121 sync_service_ = |
| 122 static_cast<OneClickTestProfileSyncService*>( | 122 static_cast<OneClickTestProfileSyncService*>( |
| 123 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 123 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
| 124 profile(), OneClickTestProfileSyncService::Build)); | 124 profile(), OneClickTestProfileSyncService::Build)); |
| 125 } | 125 } |
| 126 | 126 |
| 127 virtual void TearDown() override { | 127 void TearDown() override { |
| 128 // Verify that the |sync_observer_| unregistered as an observer from the | 128 // Verify that the |sync_observer_| unregistered as an observer from the |
| 129 // sync service and freed its memory. | 129 // sync service and freed its memory. |
| 130 EXPECT_TRUE(sync_observer_destroyed_); | 130 EXPECT_TRUE(sync_observer_destroyed_); |
| 131 if (sync_service_) | 131 if (sync_service_) |
| 132 EXPECT_FALSE(sync_service_->HasObserver(sync_observer_)); | 132 EXPECT_FALSE(sync_service_->HasObserver(sync_observer_)); |
| 133 ChromeRenderViewHostTestHarness::TearDown(); | 133 ChromeRenderViewHostTestHarness::TearDown(); |
| 134 } | 134 } |
| 135 | 135 |
| 136 protected: | 136 protected: |
| 137 void CreateSyncObserver(const std::string& url) { | 137 void CreateSyncObserver(const std::string& url) { |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 OnSyncStateChanged_SyncConfiguredSuccessfully_SourceIsSettings) { | 234 OnSyncStateChanged_SyncConfiguredSuccessfully_SourceIsSettings) { |
| 235 GURL continue_url = signin::GetPromoURL(signin::SOURCE_SETTINGS, false); | 235 GURL continue_url = signin::GetPromoURL(signin::SOURCE_SETTINGS, false); |
| 236 CreateSyncObserver(continue_url.spec()); | 236 CreateSyncObserver(continue_url.spec()); |
| 237 sync_service_->set_first_setup_in_progress(false); | 237 sync_service_->set_first_setup_in_progress(false); |
| 238 sync_service_->set_sync_active(true); | 238 sync_service_->set_sync_active(true); |
| 239 | 239 |
| 240 EXPECT_CALL(*web_contents_observer_, AboutToNavigateRenderView(_)).Times(0); | 240 EXPECT_CALL(*web_contents_observer_, AboutToNavigateRenderView(_)).Times(0); |
| 241 sync_service_->NotifyObservers(); | 241 sync_service_->NotifyObservers(); |
| 242 EXPECT_NE(GURL(kContinueUrl), web_contents()->GetVisibleURL()); | 242 EXPECT_NE(GURL(kContinueUrl), web_contents()->GetVisibleURL()); |
| 243 } | 243 } |
| OLD | NEW |