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" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 void set_account(const std::string& account) { account_ = account; } | 43 void set_account(const std::string& account) { account_ = account; } |
44 | 44 |
45 private: | 45 private: |
46 std::string account_; | 46 std::string account_; |
47 }; | 47 }; |
48 | 48 |
49 class StartupControllerTest : public testing::Test { | 49 class StartupControllerTest : public testing::Test { |
50 public: | 50 public: |
51 StartupControllerTest() : started_(false) {} | 51 StartupControllerTest() : started_(false) {} |
52 | 52 |
53 virtual void SetUp() override { | 53 void SetUp() override { |
54 profile_.reset(new TestingProfile()); | 54 profile_.reset(new TestingProfile()); |
55 sync_prefs_.reset(new sync_driver::SyncPrefs(profile_->GetPrefs())); | 55 sync_prefs_.reset(new sync_driver::SyncPrefs(profile_->GetPrefs())); |
56 token_service_.reset(static_cast<FakeProfileOAuth2TokenService*>( | 56 token_service_.reset(static_cast<FakeProfileOAuth2TokenService*>( |
57 BuildFakeProfileOAuth2TokenService(profile_.get()))); | 57 BuildFakeProfileOAuth2TokenService(profile_.get()))); |
58 signin_.reset(new FakeSupervisedUserSigninManagerWrapper()); | 58 signin_.reset(new FakeSupervisedUserSigninManagerWrapper()); |
59 | 59 |
60 ProfileSyncServiceStartBehavior behavior = | 60 ProfileSyncServiceStartBehavior behavior = |
61 browser_defaults::kSyncAutoStarts ? AUTO_START : MANUAL_START; | 61 browser_defaults::kSyncAutoStarts ? AUTO_START : MANUAL_START; |
62 base::Closure fake_start_backend = base::Bind( | 62 base::Closure fake_start_backend = base::Bind( |
63 &StartupControllerTest::FakeStartBackend, base::Unretained(this)); | 63 &StartupControllerTest::FakeStartBackend, base::Unretained(this)); |
64 controller_.reset(new StartupController(behavior, token_service(), | 64 controller_.reset(new StartupController(behavior, token_service(), |
65 sync_prefs_.get(), signin_.get(), | 65 sync_prefs_.get(), signin_.get(), |
66 fake_start_backend)); | 66 fake_start_backend)); |
67 controller_->Reset(syncer::UserTypes()); | 67 controller_->Reset(syncer::UserTypes()); |
68 controller_->OverrideFallbackTimeoutForTest( | 68 controller_->OverrideFallbackTimeoutForTest( |
69 base::TimeDelta::FromSeconds(0)); | 69 base::TimeDelta::FromSeconds(0)); |
70 } | 70 } |
71 | 71 |
72 virtual void TearDown() override { | 72 void TearDown() override { |
73 controller_.reset(); | 73 controller_.reset(); |
74 signin_.reset(); | 74 signin_.reset(); |
75 token_service_->Shutdown(); | 75 token_service_->Shutdown(); |
76 token_service_.reset(); | 76 token_service_.reset(); |
77 sync_prefs_.reset(); | 77 sync_prefs_.reset(); |
78 started_ = false; | 78 started_ = false; |
79 } | 79 } |
80 | 80 |
81 void FakeStartBackend() { | 81 void FakeStartBackend() { |
82 started_ = true; | 82 started_ = true; |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 controller()->set_setup_in_progress(true); | 250 controller()->set_setup_in_progress(true); |
251 | 251 |
252 // This could happen if the UI triggers a stop-syncing permanently call. | 252 // This could happen if the UI triggers a stop-syncing permanently call. |
253 controller()->Reset(syncer::UserTypes()); | 253 controller()->Reset(syncer::UserTypes()); |
254 | 254 |
255 // From the UI's point of view, setup is still in progress. | 255 // From the UI's point of view, setup is still in progress. |
256 EXPECT_TRUE(controller()->setup_in_progress()); | 256 EXPECT_TRUE(controller()->setup_in_progress()); |
257 } | 257 } |
258 | 258 |
259 } // namespace browser_sync | 259 } // namespace browser_sync |
OLD | NEW |