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 "base/memory/scoped_ptr.h" |
9 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 10 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
10 #include "chrome/browser/signin/signin_manager_factory.h" | 11 #include "chrome/browser/signin/signin_manager_factory.h" |
11 #include "chrome/browser/signin/signin_promo.h" | 12 #include "chrome/browser/signin/signin_promo.h" |
12 #include "chrome/browser/sync/profile_sync_components_factory_mock.h" | 13 #include "chrome/browser/sync/profile_sync_components_factory_mock.h" |
13 #include "chrome/browser/sync/profile_sync_service_factory.h" | 14 #include "chrome/browser/sync/profile_sync_service_factory.h" |
14 #include "chrome/browser/sync/startup_controller.h" | 15 #include "chrome/browser/sync/startup_controller.h" |
15 #include "chrome/browser/sync/test_profile_sync_service.h" | 16 #include "chrome/browser/sync/test_profile_sync_service.h" |
16 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 17 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
17 #include "chrome/test/base/testing_profile.h" | 18 #include "chrome/test/base/testing_profile.h" |
18 #include "components/signin/core/browser/signin_manager.h" | 19 #include "components/signin/core/browser/signin_manager.h" |
(...skipping 22 matching lines...) Expand all Loading... |
41 MOCK_METHOD2(AboutToNavigateRenderFrame, void(content::RenderFrameHost*, | 42 MOCK_METHOD2(AboutToNavigateRenderFrame, void(content::RenderFrameHost*, |
42 content::RenderFrameHost*)); | 43 content::RenderFrameHost*)); |
43 }; | 44 }; |
44 | 45 |
45 class OneClickTestProfileSyncService : public TestProfileSyncService { | 46 class OneClickTestProfileSyncService : public TestProfileSyncService { |
46 public: | 47 public: |
47 ~OneClickTestProfileSyncService() override {} | 48 ~OneClickTestProfileSyncService() override {} |
48 | 49 |
49 // Helper routine to be used in conjunction with | 50 // Helper routine to be used in conjunction with |
50 // BrowserContextKeyedServiceFactory::SetTestingFactory(). | 51 // BrowserContextKeyedServiceFactory::SetTestingFactory(). |
51 static KeyedService* Build(content::BrowserContext* profile) { | 52 static scoped_ptr<KeyedService> Build(content::BrowserContext* profile) { |
52 return new OneClickTestProfileSyncService(static_cast<Profile*>(profile)); | 53 return make_scoped_ptr( |
| 54 new OneClickTestProfileSyncService(static_cast<Profile*>(profile))); |
53 } | 55 } |
54 | 56 |
55 bool FirstSetupInProgress() const override { | 57 bool FirstSetupInProgress() const override { |
56 return first_setup_in_progress_; | 58 return first_setup_in_progress_; |
57 } | 59 } |
58 | 60 |
59 bool IsSyncActive() const override { return sync_active_; } | 61 bool IsSyncActive() const override { return sync_active_; } |
60 | 62 |
61 void set_first_setup_in_progress(bool in_progress) { | 63 void set_first_setup_in_progress(bool in_progress) { |
62 first_setup_in_progress_ = in_progress; | 64 first_setup_in_progress_ = in_progress; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 destruction_callback_.Run(this); | 98 destruction_callback_.Run(this); |
97 } | 99 } |
98 | 100 |
99 private: | 101 private: |
100 DestructionCallback destruction_callback_; | 102 DestructionCallback destruction_callback_; |
101 | 103 |
102 DISALLOW_COPY_AND_ASSIGN(TestOneClickSigninSyncObserver); | 104 DISALLOW_COPY_AND_ASSIGN(TestOneClickSigninSyncObserver); |
103 }; | 105 }; |
104 | 106 |
105 // A trivial factory to build a null service. | 107 // A trivial factory to build a null service. |
106 KeyedService* BuildNullService(content::BrowserContext* context) { | 108 scoped_ptr<KeyedService> BuildNullService(content::BrowserContext* context) { |
107 return NULL; | 109 return nullptr; |
108 } | 110 } |
109 | 111 |
110 } // namespace | 112 } // namespace |
111 | 113 |
112 class OneClickSigninSyncObserverTest : public ChromeRenderViewHostTestHarness { | 114 class OneClickSigninSyncObserverTest : public ChromeRenderViewHostTestHarness { |
113 public: | 115 public: |
114 OneClickSigninSyncObserverTest() | 116 OneClickSigninSyncObserverTest() |
115 : sync_service_(NULL), | 117 : sync_service_(NULL), |
116 sync_observer_(NULL), | 118 sync_observer_(NULL), |
117 sync_observer_destroyed_(true) {} | 119 sync_observer_destroyed_(true) {} |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 signin_metrics::SOURCE_SETTINGS, false); | 242 signin_metrics::SOURCE_SETTINGS, false); |
241 CreateSyncObserver(continue_url.spec()); | 243 CreateSyncObserver(continue_url.spec()); |
242 sync_service_->set_first_setup_in_progress(false); | 244 sync_service_->set_first_setup_in_progress(false); |
243 sync_service_->set_sync_active(true); | 245 sync_service_->set_sync_active(true); |
244 | 246 |
245 EXPECT_CALL(*web_contents_observer_, | 247 EXPECT_CALL(*web_contents_observer_, |
246 AboutToNavigateRenderFrame(_, _)).Times(0); | 248 AboutToNavigateRenderFrame(_, _)).Times(0); |
247 sync_service_->NotifyObservers(); | 249 sync_service_->NotifyObservers(); |
248 EXPECT_NE(GURL(kContinueUrl), web_contents()->GetVisibleURL()); | 250 EXPECT_NE(GURL(kContinueUrl), web_contents()->GetVisibleURL()); |
249 } | 251 } |
OLD | NEW |