| 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 18 matching lines...) Expand all Loading... |
| 29 // outputting the correct values for the debug string. | 29 // outputting the correct values for the debug string. |
| 30 static const char kStateStringStarted[] = "Started"; | 30 static const char kStateStringStarted[] = "Started"; |
| 31 static const char kStateStringDeferred[] = "Deferred"; | 31 static const char kStateStringDeferred[] = "Deferred"; |
| 32 static const char kStateStringNotStarted[] = "Not started"; | 32 static const char kStateStringNotStarted[] = "Not started"; |
| 33 | 33 |
| 34 class FakeSupervisedUserSigninManagerWrapper | 34 class FakeSupervisedUserSigninManagerWrapper |
| 35 : public SupervisedUserSigninManagerWrapper { | 35 : public SupervisedUserSigninManagerWrapper { |
| 36 public: | 36 public: |
| 37 FakeSupervisedUserSigninManagerWrapper() | 37 FakeSupervisedUserSigninManagerWrapper() |
| 38 : SupervisedUserSigninManagerWrapper(NULL, NULL) {} | 38 : SupervisedUserSigninManagerWrapper(NULL, NULL) {} |
| 39 virtual std::string GetEffectiveUsername() const OVERRIDE { | 39 virtual std::string GetEffectiveUsername() const override { |
| 40 return account_; | 40 return account_; |
| 41 } | 41 } |
| 42 | 42 |
| 43 virtual std::string GetAccountIdToUse() const OVERRIDE { | 43 virtual std::string GetAccountIdToUse() const override { |
| 44 return account_; | 44 return account_; |
| 45 } | 45 } |
| 46 | 46 |
| 47 void set_account(const std::string& account) { account_ = account; } | 47 void set_account(const std::string& account) { account_ = account; } |
| 48 | 48 |
| 49 private: | 49 private: |
| 50 std::string account_; | 50 std::string account_; |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 class StartupControllerTest : public testing::Test { | 53 class StartupControllerTest : public testing::Test { |
| 54 public: | 54 public: |
| 55 StartupControllerTest() : started_(false) {} | 55 StartupControllerTest() : started_(false) {} |
| 56 | 56 |
| 57 virtual void SetUp() OVERRIDE { | 57 virtual void SetUp() override { |
| 58 profile_.reset(new TestingProfile()); | 58 profile_.reset(new TestingProfile()); |
| 59 sync_prefs_.reset(new sync_driver::SyncPrefs(profile_->GetPrefs())); | 59 sync_prefs_.reset(new sync_driver::SyncPrefs(profile_->GetPrefs())); |
| 60 token_service_.reset(static_cast<FakeProfileOAuth2TokenService*>( | 60 token_service_.reset(static_cast<FakeProfileOAuth2TokenService*>( |
| 61 BuildFakeProfileOAuth2TokenService(profile_.get()))); | 61 BuildFakeProfileOAuth2TokenService(profile_.get()))); |
| 62 signin_.reset(new FakeSupervisedUserSigninManagerWrapper()); | 62 signin_.reset(new FakeSupervisedUserSigninManagerWrapper()); |
| 63 | 63 |
| 64 ProfileSyncServiceStartBehavior behavior = | 64 ProfileSyncServiceStartBehavior behavior = |
| 65 browser_defaults::kSyncAutoStarts ? AUTO_START : MANUAL_START; | 65 browser_defaults::kSyncAutoStarts ? AUTO_START : MANUAL_START; |
| 66 base::Closure fake_start_backend = base::Bind( | 66 base::Closure fake_start_backend = base::Bind( |
| 67 &StartupControllerTest::FakeStartBackend, base::Unretained(this)); | 67 &StartupControllerTest::FakeStartBackend, base::Unretained(this)); |
| 68 controller_.reset(new StartupController(behavior, token_service(), | 68 controller_.reset(new StartupController(behavior, token_service(), |
| 69 sync_prefs_.get(), signin_.get(), | 69 sync_prefs_.get(), signin_.get(), |
| 70 fake_start_backend)); | 70 fake_start_backend)); |
| 71 controller_->Reset(syncer::UserTypes()); | 71 controller_->Reset(syncer::UserTypes()); |
| 72 controller_->OverrideFallbackTimeoutForTest( | 72 controller_->OverrideFallbackTimeoutForTest( |
| 73 base::TimeDelta::FromSeconds(0)); | 73 base::TimeDelta::FromSeconds(0)); |
| 74 } | 74 } |
| 75 | 75 |
| 76 virtual void TearDown() OVERRIDE { | 76 virtual void TearDown() override { |
| 77 controller_.reset(); | 77 controller_.reset(); |
| 78 signin_.reset(); | 78 signin_.reset(); |
| 79 token_service_->Shutdown(); | 79 token_service_->Shutdown(); |
| 80 token_service_.reset(); | 80 token_service_.reset(); |
| 81 sync_prefs_.reset(); | 81 sync_prefs_.reset(); |
| 82 started_ = false; | 82 started_ = false; |
| 83 } | 83 } |
| 84 | 84 |
| 85 void FakeStartBackend() { | 85 void FakeStartBackend() { |
| 86 started_ = true; | 86 started_ = true; |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 controller()->set_setup_in_progress(true); | 254 controller()->set_setup_in_progress(true); |
| 255 | 255 |
| 256 // This could happen if the UI triggers a stop-syncing permanently call. | 256 // This could happen if the UI triggers a stop-syncing permanently call. |
| 257 controller()->Reset(syncer::UserTypes()); | 257 controller()->Reset(syncer::UserTypes()); |
| 258 | 258 |
| 259 // From the UI's point of view, setup is still in progress. | 259 // From the UI's point of view, setup is still in progress. |
| 260 EXPECT_TRUE(controller()->setup_in_progress()); | 260 EXPECT_TRUE(controller()->setup_in_progress()); |
| 261 } | 261 } |
| 262 | 262 |
| 263 } // namespace browser_sync | 263 } // namespace browser_sync |
| OLD | NEW |