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/sync/startup_controller.h" | 5 #include "chrome/browser/sync/startup_controller.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
11 #include "chrome/browser/defaults.h" | 11 #include "chrome/browser/defaults.h" |
12 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" | 12 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" |
13 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" | 13 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" |
14 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 14 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
15 #include "chrome/browser/sync/supervised_user_signin_manager_wrapper.h" | 15 #include "chrome/browser/sync/supervised_user_signin_manager_wrapper.h" |
16 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
17 #include "chrome/test/base/testing_profile.h" | 17 #include "chrome/test/base/testing_profile.h" |
18 #include "components/sync_driver/sync_prefs.h" | 18 #include "components/sync_driver/sync_prefs.h" |
| 19 #include "content/public/test/test_browser_thread_bundle.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
20 | 21 |
21 namespace browser_sync { | 22 namespace browser_sync { |
22 | 23 |
23 static const char kTestUser[] = "test@gmail.com"; | 24 static const char kTestUser[] = "test@gmail.com"; |
24 static const char kTestToken[] = "testToken"; | 25 static const char kTestToken[] = "testToken"; |
25 | 26 |
26 // These are coupled to the implementation of StartupController's | 27 // These are coupled to the implementation of StartupController's |
27 // GetBackendInitializationStateString which is used by about:sync. We use it | 28 // GetBackendInitializationStateString which is used by about:sync. We use it |
28 // as a convenient way to verify internal state and that the class is | 29 // as a convenient way to verify internal state and that the class is |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 StartupController* controller() { return controller_.get(); } | 88 StartupController* controller() { return controller_.get(); } |
88 FakeSupervisedUserSigninManagerWrapper* signin() { return signin_.get(); } | 89 FakeSupervisedUserSigninManagerWrapper* signin() { return signin_.get(); } |
89 FakeProfileOAuth2TokenService* token_service() { | 90 FakeProfileOAuth2TokenService* token_service() { |
90 return token_service_.get(); | 91 return token_service_.get(); |
91 } | 92 } |
92 sync_driver::SyncPrefs* sync_prefs() { return sync_prefs_.get(); } | 93 sync_driver::SyncPrefs* sync_prefs() { return sync_prefs_.get(); } |
93 Profile* profile() { return profile_.get(); } | 94 Profile* profile() { return profile_.get(); } |
94 | 95 |
95 private: | 96 private: |
96 bool started_; | 97 bool started_; |
97 base::MessageLoop message_loop_; | 98 content::TestBrowserThreadBundle thread_bundle_; |
98 scoped_ptr<StartupController> controller_; | 99 scoped_ptr<StartupController> controller_; |
99 scoped_ptr<FakeSupervisedUserSigninManagerWrapper> signin_; | 100 scoped_ptr<FakeSupervisedUserSigninManagerWrapper> signin_; |
100 scoped_ptr<FakeProfileOAuth2TokenService> token_service_; | 101 scoped_ptr<FakeProfileOAuth2TokenService> token_service_; |
101 scoped_ptr<sync_driver::SyncPrefs> sync_prefs_; | 102 scoped_ptr<sync_driver::SyncPrefs> sync_prefs_; |
102 scoped_ptr<TestingProfile> profile_; | 103 scoped_ptr<TestingProfile> profile_; |
103 }; | 104 }; |
104 | 105 |
105 // Test that sync doesn't start until all conditions are met. | 106 // Test that sync doesn't start until all conditions are met. |
106 TEST_F(StartupControllerTest, Basic) { | 107 TEST_F(StartupControllerTest, Basic) { |
107 controller()->TryStart(); | 108 controller()->TryStart(); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 controller()->set_setup_in_progress(true); | 253 controller()->set_setup_in_progress(true); |
253 | 254 |
254 // This could happen if the UI triggers a stop-syncing permanently call. | 255 // This could happen if the UI triggers a stop-syncing permanently call. |
255 controller()->Reset(syncer::UserTypes()); | 256 controller()->Reset(syncer::UserTypes()); |
256 | 257 |
257 // From the UI's point of view, setup is still in progress. | 258 // From the UI's point of view, setup is still in progress. |
258 EXPECT_TRUE(controller()->setup_in_progress()); | 259 EXPECT_TRUE(controller()->setup_in_progress()); |
259 } | 260 } |
260 | 261 |
261 } // namespace browser_sync | 262 } // namespace browser_sync |
OLD | NEW |