Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Side by Side Diff: components/browser_sync/profile_sync_service_startup_unittest.cc

Issue 2354613002: [Sync] Fix namespaces for the browser_sync component. (Closed)
Patch Set: Address comments. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <memory> 5 #include <memory>
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
(...skipping 15 matching lines...) Expand all
26 #include "components/sync/driver/sync_prefs.h" 26 #include "components/sync/driver/sync_prefs.h"
27 #include "components/sync/driver/sync_service_observer.h" 27 #include "components/sync/driver/sync_service_observer.h"
28 #include "components/syncable_prefs/pref_service_syncable.h" 28 #include "components/syncable_prefs/pref_service_syncable.h"
29 #include "google_apis/gaia/gaia_auth_consumer.h" 29 #include "google_apis/gaia/gaia_auth_consumer.h"
30 #include "google_apis/gaia/gaia_constants.h" 30 #include "google_apis/gaia/gaia_constants.h"
31 #include "google_apis/gaia/oauth2_token_service.h" 31 #include "google_apis/gaia/oauth2_token_service.h"
32 #include "net/url_request/url_request_test_util.h" 32 #include "net/url_request/url_request_test_util.h"
33 #include "testing/gmock/include/gmock/gmock.h" 33 #include "testing/gmock/include/gmock/gmock.h"
34 #include "testing/gtest/include/gtest/gtest.h" 34 #include "testing/gtest/include/gtest/gtest.h"
35 35
36 using browser_sync::SyncBackendHostMock;
37 using sync_driver::DataTypeManager; 36 using sync_driver::DataTypeManager;
38 using sync_driver::DataTypeManagerMock; 37 using sync_driver::DataTypeManagerMock;
39 using testing::_; 38 using testing::_;
40 using testing::AnyNumber; 39 using testing::AnyNumber;
41 using testing::DoAll; 40 using testing::DoAll;
42 using testing::Mock; 41 using testing::Mock;
43 using testing::Return; 42 using testing::Return;
44 43
44 namespace browser_sync {
45
45 namespace { 46 namespace {
46 47
47 const char kGaiaId[] = "12345"; 48 const char kGaiaId[] = "12345";
48 const char kEmail[] = "test_user@gmail.com"; 49 const char kEmail[] = "test_user@gmail.com";
49 const char kDummyPassword[] = ""; 50 const char kDummyPassword[] = "";
50 51
51 class SyncServiceObserverMock : public sync_driver::SyncServiceObserver { 52 class SyncServiceObserverMock : public sync_driver::SyncServiceObserver {
52 public: 53 public:
53 SyncServiceObserverMock(); 54 SyncServiceObserverMock();
54 virtual ~SyncServiceObserverMock(); 55 virtual ~SyncServiceObserverMock();
(...skipping 26 matching lines...) Expand all
81 ->set_auto_post_fetch_response_on_message_loop(true); 82 ->set_auto_post_fetch_response_on_message_loop(true);
82 } 83 }
83 84
84 ~ProfileSyncServiceStartupTest() override { 85 ~ProfileSyncServiceStartupTest() override {
85 sync_service_->RemoveObserver(&observer_); 86 sync_service_->RemoveObserver(&observer_);
86 sync_service_->Shutdown(); 87 sync_service_->Shutdown();
87 } 88 }
88 89
89 void CreateSyncService(ProfileSyncService::StartBehavior start_behavior) { 90 void CreateSyncService(ProfileSyncService::StartBehavior start_behavior) {
90 component_factory_ = profile_sync_service_bundle_.component_factory(); 91 component_factory_ = profile_sync_service_bundle_.component_factory();
91 browser_sync::ProfileSyncServiceBundle::SyncClientBuilder builder( 92 ProfileSyncServiceBundle::SyncClientBuilder builder(
92 &profile_sync_service_bundle_); 93 &profile_sync_service_bundle_);
93 ProfileSyncService::InitParams init_params = 94 ProfileSyncService::InitParams init_params =
94 profile_sync_service_bundle_.CreateBasicInitParams(start_behavior, 95 profile_sync_service_bundle_.CreateBasicInitParams(start_behavior,
95 builder.Build()); 96 builder.Build());
96 97
97 sync_service_.reset(new ProfileSyncService(std::move(init_params))); 98 sync_service_.reset(new ProfileSyncService(std::move(init_params)));
98 sync_service_->RegisterDataTypeController( 99 sync_service_->RegisterDataTypeController(
99 base::MakeUnique<sync_driver::FakeDataTypeController>( 100 base::MakeUnique<sync_driver::FakeDataTypeController>(
100 syncer::BOOKMARKS)); 101 syncer::BOOKMARKS));
101 sync_service_->AddObserver(&observer_); 102 sync_service_->AddObserver(&observer_);
(...skipping 30 matching lines...) Expand all
132 return account_id; 133 return account_id;
133 } 134 }
134 135
135 DataTypeManagerMock* SetUpDataTypeManager() { 136 DataTypeManagerMock* SetUpDataTypeManager() {
136 DataTypeManagerMock* data_type_manager = new DataTypeManagerMock(); 137 DataTypeManagerMock* data_type_manager = new DataTypeManagerMock();
137 EXPECT_CALL(*component_factory_, CreateDataTypeManager(_, _, _, _, _)) 138 EXPECT_CALL(*component_factory_, CreateDataTypeManager(_, _, _, _, _))
138 .WillOnce(Return(data_type_manager)); 139 .WillOnce(Return(data_type_manager));
139 return data_type_manager; 140 return data_type_manager;
140 } 141 }
141 142
142 browser_sync::SyncBackendHostMock* SetUpSyncBackendHost() { 143 SyncBackendHostMock* SetUpSyncBackendHost() {
143 browser_sync::SyncBackendHostMock* sync_backend_host = 144 SyncBackendHostMock* sync_backend_host = new SyncBackendHostMock();
144 new browser_sync::SyncBackendHostMock();
145 EXPECT_CALL(*component_factory_, CreateSyncBackendHost(_, _, _, _)) 145 EXPECT_CALL(*component_factory_, CreateSyncBackendHost(_, _, _, _))
146 .WillOnce(Return(sync_backend_host)); 146 .WillOnce(Return(sync_backend_host));
147 return sync_backend_host; 147 return sync_backend_host;
148 } 148 }
149 149
150 PrefService* pref_service() { 150 PrefService* pref_service() {
151 return profile_sync_service_bundle_.pref_service(); 151 return profile_sync_service_bundle_.pref_service();
152 } 152 }
153 153
154 base::MessageLoop message_loop_; 154 base::MessageLoop message_loop_;
155 browser_sync::ProfileSyncServiceBundle profile_sync_service_bundle_; 155 ProfileSyncServiceBundle profile_sync_service_bundle_;
156 std::unique_ptr<ProfileSyncService> sync_service_; 156 std::unique_ptr<ProfileSyncService> sync_service_;
157 SyncServiceObserverMock observer_; 157 SyncServiceObserverMock observer_;
158 sync_driver::DataTypeStatusTable data_type_status_table_; 158 sync_driver::DataTypeStatusTable data_type_status_table_;
159 SyncApiComponentFactoryMock* component_factory_ = nullptr; 159 SyncApiComponentFactoryMock* component_factory_ = nullptr;
160 }; 160 };
161 161
162 class ProfileSyncServiceStartupCrosTest : public ProfileSyncServiceStartupTest { 162 class ProfileSyncServiceStartupCrosTest : public ProfileSyncServiceStartupTest {
163 public: 163 public:
164 ProfileSyncServiceStartupCrosTest() { 164 ProfileSyncServiceStartupCrosTest() {
165 CreateSyncService(ProfileSyncService::AUTO_START); 165 CreateSyncService(ProfileSyncService::AUTO_START);
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 pref_service()->ClearPref(sync_driver::prefs::kSyncFirstSetupComplete); 472 pref_service()->ClearPref(sync_driver::prefs::kSyncFirstSetupComplete);
473 473
474 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); 474 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber());
475 sync_service_->Initialize(); 475 sync_service_->Initialize();
476 476
477 auto sync_blocker = sync_service_->GetSetupInProgressHandle(); 477 auto sync_blocker = sync_service_->GetSetupInProgressHandle();
478 IssueTestTokens(account_id); 478 IssueTestTokens(account_id);
479 sync_blocker.reset(); 479 sync_blocker.reset();
480 EXPECT_FALSE(sync_service_->IsSyncActive()); 480 EXPECT_FALSE(sync_service_->IsSyncActive());
481 } 481 }
482
483 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698