Commit cccb6c78 authored by Jan Krcal's avatar Jan Krcal Committed by Commit Bot

[Autofill Profile] USS cleanup: remove ProfileSyncServiceAutofillTest

This CL removes ProfileSyncServiceAutofillTest and all its dependencies
not used elsewhere.

The same functionality for the fully launched USS implementation is now
tested in AutofillProfileSyncBridgeTest.

Bug: 836718
Change-Id: I5b6f9372c1ee7aa17ffe385f5275efbee85a4543
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1642548Reviewed-by: default avatarFabio Tirelo <ftirelo@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Commit-Queue: Jan Krcal <jkrcal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#666345}
parent 1b01b443
...@@ -3318,7 +3318,6 @@ test("unit_tests") { ...@@ -3318,7 +3318,6 @@ test("unit_tests") {
"//components/sync_user_events:test_support", "//components/sync_user_events:test_support",
"//components/ukm/content", "//components/ukm/content",
"//components/version_info:generate_version_info", "//components/version_info:generate_version_info",
"//components/webdata_services:test_support",
"//content/app/resources", "//content/app/resources",
"//content/public/app:both", "//content/public/app:both",
"//content/test:test_support", "//content/test:test_support",
......
...@@ -617,7 +617,6 @@ source_set("unit_tests") { ...@@ -617,7 +617,6 @@ source_set("unit_tests") {
"//components/variations/net", "//components/variations/net",
"//components/version_info:version_info", "//components/version_info:version_info",
"//components/webdata/common", "//components/webdata/common",
"//components/webdata_services:test_support",
"//google_apis", "//google_apis",
"//google_apis:test_support", "//google_apis:test_support",
"//net:test_support", "//net:test_support",
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include "components/autofill/core/common/form_data.h" #include "components/autofill/core/common/form_data.h"
#include "components/prefs/testing_pref_service.h" #include "components/prefs/testing_pref_service.h"
#include "components/version_info/version_info.h" #include "components/version_info/version_info.h"
#include "components/webdata_services/web_data_service_test_util.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/rect.h"
......
...@@ -653,7 +653,8 @@ TEST_F(AutofillProfileSyncBridgeTest, MergeSyncData_SimilarProfiles) { ...@@ -653,7 +653,8 @@ TEST_F(AutofillProfileSyncBridgeTest, MergeSyncData_SimilarProfiles) {
AddAutofillProfilesToTable({local1, local2}); AddAutofillProfilesToTable({local1, local2});
// The synced profiles are identical to the local ones, except that the guids // The synced profiles are identical to the local ones, except that the guids
// and use_count values are different. // and use_count values are different. Remote ones have additional company
// name which makes them not be identical.
AutofillProfileSpecifics remote1 = AutofillProfileSpecifics remote1 =
CreateAutofillProfileSpecifics(kGuidC, kHttpsOrigin); CreateAutofillProfileSpecifics(kGuidC, kHttpsOrigin);
remote1.add_name_first("John"); remote1.add_name_first("John");
...@@ -672,10 +673,7 @@ TEST_F(AutofillProfileSyncBridgeTest, MergeSyncData_SimilarProfiles) { ...@@ -672,10 +673,7 @@ TEST_F(AutofillProfileSyncBridgeTest, MergeSyncData_SimilarProfiles) {
// should never overwrite a verified one. // should never overwrite a verified one.
AutofillProfileSpecifics merged1(remote1); AutofillProfileSpecifics merged1(remote1);
merged1.set_origin(kHttpOrigin); merged1.set_origin(kHttpOrigin);
// TODO(jkrcal): This is taken over from the previous test suite without any // When merging, full name gets populated.
// reasoning why this happens. This indeed happens, deep in
// AutofillProfileComparator when merging profiles both without NAME_FULL, we
// obtain a profile with NAME_FULL. Not sure if intended.
merged1.add_name_full("John"); merged1.add_name_full("John");
// Merging two profile takes their max use count. // Merging two profile takes their max use count.
merged1.set_use_count(27); merged1.set_use_count(27);
...@@ -696,11 +694,6 @@ TEST_F(AutofillProfileSyncBridgeTest, MergeSyncData_SimilarProfiles) { ...@@ -696,11 +694,6 @@ TEST_F(AutofillProfileSyncBridgeTest, MergeSyncData_SimilarProfiles) {
WithUsageStats(CreateAutofillProfile(remote2)))); WithUsageStats(CreateAutofillProfile(remote2))));
} }
// TODO(jkrcal): All the MergeSimilarProfiles_* tests need some diff in Info to
// trigger the merge similar code path (we create the diff using phone number).
// Otherwise, we trigger the merge same code path and none of the tests pass. Is
// it desired?
// Tests that MergeSimilarProfiles keeps the most recent use date of the two // Tests that MergeSimilarProfiles keeps the most recent use date of the two
// profiles being merged. // profiles being merged.
TEST_F(AutofillProfileSyncBridgeTest, TEST_F(AutofillProfileSyncBridgeTest,
......
...@@ -41,7 +41,6 @@ source_set("unit_tests") { ...@@ -41,7 +41,6 @@ source_set("unit_tests") {
testonly = true testonly = true
sources = [ sources = [
"profile_sync_service_autofill_unittest.cc",
"profile_sync_service_bookmark_unittest.cc", "profile_sync_service_bookmark_unittest.cc",
] ]
...@@ -68,7 +67,6 @@ source_set("unit_tests") { ...@@ -68,7 +67,6 @@ source_set("unit_tests") {
"//components/version_info", "//components/version_info",
"//components/version_info:generate_version_info", "//components/version_info:generate_version_info",
"//components/webdata/common", "//components/webdata/common",
"//components/webdata_services:test_support",
"//services/identity/public/cpp:test_support", "//services/identity/public/cpp:test_support",
"//services/network:test_support", "//services/network:test_support",
"//testing/gmock", "//testing/gmock",
...@@ -79,8 +77,6 @@ source_set("unit_tests") { ...@@ -79,8 +77,6 @@ source_set("unit_tests") {
static_library("test_support") { static_library("test_support") {
testonly = true testonly = true
sources = [ sources = [
"abstract_profile_sync_service_test.cc",
"abstract_profile_sync_service_test.h",
"test_http_bridge_factory.cc", "test_http_bridge_factory.cc",
"test_http_bridge_factory.h", "test_http_bridge_factory.h",
] ]
......
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/browser_sync/abstract_profile_sync_service_test.h"
#include <utility>
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/files/file_path.h"
#include "base/location.h"
#include "base/run_loop.h"
#include "base/threading/sequenced_task_runner_handle.h"
#include "components/browser_sync/test_http_bridge_factory.h"
#include "components/sync/driver/glue/sync_engine_backend.h"
#include "components/sync/driver/sync_api_component_factory_mock.h"
#include "components/sync/driver/test_profile_sync_service.h"
#include "components/sync/engine/sync_manager_factory_for_profile_sync_test.h"
#include "components/sync/engine/test_engine_components_factory.h"
#include "components/sync/protocol/sync.pb.h"
#include "components/sync/syncable/test_user_share.h"
#include "services/network/test/test_network_connection_tracker.h"
using syncer::ModelType;
using syncer::SyncEngineImpl;
using testing::_;
using testing::ByMove;
using testing::Return;
namespace browser_sync {
namespace {
std::unique_ptr<syncer::HttpPostProviderFactory> GetHttpPostProviderFactory(
syncer::CancelationSignal* signal) {
return std::make_unique<TestHttpBridgeFactory>();
}
class SyncEngineForProfileSyncTest : public SyncEngineImpl {
public:
SyncEngineForProfileSyncTest(
const base::FilePath& temp_dir,
invalidation::InvalidationService* invalidator,
const base::WeakPtr<syncer::SyncPrefs>& sync_prefs,
base::OnceClosure callback);
~SyncEngineForProfileSyncTest() override;
void Initialize(InitParams params) override;
void ConfigureDataTypes(ConfigureParams params) override;
private:
// Invoked at the start of HandleSyncManagerInitializationOnFrontendLoop.
// Allows extra initialization work to be performed before the engine comes
// up.
base::OnceClosure callback_;
DISALLOW_COPY_AND_ASSIGN(SyncEngineForProfileSyncTest);
};
SyncEngineForProfileSyncTest::SyncEngineForProfileSyncTest(
const base::FilePath& temp_dir,
invalidation::InvalidationService* invalidator,
const base::WeakPtr<syncer::SyncPrefs>& sync_prefs,
base::OnceClosure callback)
: SyncEngineImpl(
"dummy_debug_name",
invalidator,
sync_prefs,
temp_dir.Append(base::FilePath(FILE_PATH_LITERAL("test")))),
callback_(std::move(callback)) {}
SyncEngineForProfileSyncTest::~SyncEngineForProfileSyncTest() {}
void SyncEngineForProfileSyncTest::Initialize(InitParams params) {
params.http_factory_getter = base::Bind(&GetHttpPostProviderFactory);
params.sync_manager_factory =
std::make_unique<syncer::SyncManagerFactoryForProfileSyncTest>(
std::move(callback_),
network::TestNetworkConnectionTracker::GetInstance());
params.restored_key_for_bootstrapping.clear();
// It'd be nice if we avoided creating the EngineComponentsFactory in the
// first place, but SyncEngine will have created one by now so we must free
// it. Grab the switches to pass on first.
syncer::EngineComponentsFactory::Switches factory_switches =
params.engine_components_factory->GetSwitches();
params.engine_components_factory =
std::make_unique<syncer::TestEngineComponentsFactory>(
factory_switches, syncer::EngineComponentsFactory::STORAGE_IN_MEMORY,
nullptr);
SyncEngineImpl::Initialize(std::move(params));
}
void SyncEngineForProfileSyncTest::ConfigureDataTypes(ConfigureParams params) {
// The first parameter there should be the set of enabled types. That's not
// something we have access to from this strange test harness. We'll just
// send back the list of newly configured types instead and hope it doesn't
// break anything.
// Posted to avoid re-entrancy issues.
base::SequencedTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
base::BindOnce(
&SyncEngineForProfileSyncTest::FinishConfigureDataTypesOnFrontendLoop,
base::Unretained(this), params.to_download, params.to_download,
syncer::ModelTypeSet(), params.ready_task));
}
} // namespace
AbstractProfileSyncServiceTest::AbstractProfileSyncServiceTest()
: data_type_thread_("Extra thread") {
EXPECT_TRUE(temp_dir_.CreateUniqueTempDir());
}
AbstractProfileSyncServiceTest::~AbstractProfileSyncServiceTest() {
sync_service_->Shutdown();
}
bool AbstractProfileSyncServiceTest::CreateRoot(ModelType model_type) {
return syncer::TestUserShare::CreateRoot(model_type,
sync_service_->GetUserShare());
}
void AbstractProfileSyncServiceTest::CreateSyncService(
std::unique_ptr<syncer::SyncClient> sync_client,
base::OnceClosure initialization_success_callback) {
ASSERT_TRUE(sync_client);
syncer::ProfileSyncService::InitParams init_params =
profile_sync_service_bundle_.CreateBasicInitParams(
syncer::ProfileSyncService::AUTO_START, std::move(sync_client));
sync_service_ =
std::make_unique<syncer::TestProfileSyncService>(std::move(init_params));
syncer::SyncApiComponentFactoryMock* components =
profile_sync_service_bundle_.component_factory();
auto engine = std::make_unique<SyncEngineForProfileSyncTest>(
temp_dir_.GetPath(),
profile_sync_service_bundle_.fake_invalidation_service(),
sync_service_->sync_prefs()->AsWeakPtr(),
std::move(initialization_success_callback));
EXPECT_CALL(*components, CreateSyncEngine(_, _, _))
.WillOnce(Return(ByMove(std::move(engine))));
sync_service_->sync_prefs()->SetSyncRequested(true);
sync_service_->sync_prefs()->SetFirstSetupComplete();
}
CreateRootHelper::CreateRootHelper(AbstractProfileSyncServiceTest* test,
ModelType model_type)
: callback_(base::Bind(&CreateRootHelper::CreateRootCallback,
base::Unretained(this))),
test_(test),
model_type_(model_type),
success_(false) {}
CreateRootHelper::~CreateRootHelper() {}
const base::Closure& CreateRootHelper::callback() const {
return callback_;
}
bool CreateRootHelper::success() {
return success_;
}
void CreateRootHelper::CreateRootCallback() {
success_ = test_->CreateRoot(model_type_);
}
} // namespace browser_sync
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_BROWSER_SYNC_ABSTRACT_PROFILE_SYNC_SERVICE_TEST_H_
#define COMPONENTS_BROWSER_SYNC_ABSTRACT_PROFILE_SYNC_SERVICE_TEST_H_
#include <memory>
#include "base/callback.h"
#include "base/files/scoped_temp_dir.h"
#include "base/macros.h"
#include "base/test/scoped_task_environment.h"
#include "components/sync/base/model_type.h"
#include "components/sync/driver/profile_sync_service_bundle.h"
#include "components/sync/syncable/change_record.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace syncer {
class TestProfileSyncService;
} // namespace syncer
namespace browser_sync {
class AbstractProfileSyncServiceTest : public testing::Test {
public:
AbstractProfileSyncServiceTest();
~AbstractProfileSyncServiceTest() override;
bool CreateRoot(syncer::ModelType model_type);
protected:
// Creates a TestProfileSyncService instance based on
// |profile_sync_service_bundle_|, with start behavior AUTO_START. Passes
// |callback| down to SyncManagerForProfileSyncTest to be used by
// NotifyInitializationSuccess. |sync_client| is passed to the service. The
// created service is stored in |sync_service_|.
void CreateSyncService(std::unique_ptr<syncer::SyncClient> sync_client,
base::OnceClosure initialization_success_callback);
base::Thread* data_type_thread() { return &data_type_thread_; }
syncer::TestProfileSyncService* sync_service() { return sync_service_.get(); }
syncer::ProfileSyncServiceBundle* profile_sync_service_bundle() {
return &profile_sync_service_bundle_;
}
private:
// Use |data_type_thread_| for code disallowed on the UI thread.
base::Thread data_type_thread_;
base::test::ScopedTaskEnvironment scoped_task_environment_;
syncer::ProfileSyncServiceBundle profile_sync_service_bundle_;
std::unique_ptr<syncer::TestProfileSyncService> sync_service_;
base::ScopedTempDir temp_dir_; // To pass to the backend host.
DISALLOW_COPY_AND_ASSIGN(AbstractProfileSyncServiceTest);
};
class CreateRootHelper {
public:
CreateRootHelper(AbstractProfileSyncServiceTest* test,
syncer::ModelType model_type);
virtual ~CreateRootHelper();
const base::Closure& callback() const;
bool success();
private:
void CreateRootCallback();
base::Closure callback_;
AbstractProfileSyncServiceTest* test_;
syncer::ModelType model_type_;
bool success_;
DISALLOW_COPY_AND_ASSIGN(CreateRootHelper);
};
} // namespace browser_sync
#endif // COMPONENTS_BROWSER_SYNC_ABSTRACT_PROFILE_SYNC_SERVICE_TEST_H_
...@@ -449,16 +449,12 @@ static_library("test_support_engine") { ...@@ -449,16 +449,12 @@ static_library("test_support_engine") {
"engine/mock_sync_engine.h", "engine/mock_sync_engine.h",
"engine/sync_engine_host_stub.cc", "engine/sync_engine_host_stub.cc",
"engine/sync_engine_host_stub.h", "engine/sync_engine_host_stub.h",
"engine/sync_manager_factory_for_profile_sync_test.cc",
"engine/sync_manager_factory_for_profile_sync_test.h",
"engine/test_engine_components_factory.cc", "engine/test_engine_components_factory.cc",
"engine/test_engine_components_factory.h", "engine/test_engine_components_factory.h",
"engine_impl/cycle/mock_debug_info_getter.cc", "engine_impl/cycle/mock_debug_info_getter.cc",
"engine_impl/cycle/mock_debug_info_getter.h", "engine_impl/cycle/mock_debug_info_getter.h",
"engine_impl/cycle/test_util.cc", "engine_impl/cycle/test_util.cc",
"engine_impl/cycle/test_util.h", "engine_impl/cycle/test_util.h",
"engine_impl/sync_manager_for_profile_sync_test.cc",
"engine_impl/sync_manager_for_profile_sync_test.h",
"engine_impl/test_entry_factory.cc", "engine_impl/test_entry_factory.cc",
"engine_impl/test_entry_factory.h", "engine_impl/test_entry_factory.h",
"syncable/test_user_share.cc", "syncable/test_user_share.cc",
......
...@@ -164,8 +164,6 @@ static_library("test_support") { ...@@ -164,8 +164,6 @@ static_library("test_support") {
"sync_client_mock.h", "sync_client_mock.h",
"sync_user_settings_mock.cc", "sync_user_settings_mock.cc",
"sync_user_settings_mock.h", "sync_user_settings_mock.h",
"test_profile_sync_service.cc",
"test_profile_sync_service.h",
"test_sync_service.cc", "test_sync_service.cc",
"test_sync_service.h", "test_sync_service.h",
"test_sync_user_settings.cc", "test_sync_user_settings.cc",
......
...@@ -258,8 +258,6 @@ class ProfileSyncService : public SyncService, ...@@ -258,8 +258,6 @@ class ProfileSyncService : public SyncService,
SyncClient* GetSyncClientForTest(); SyncClient* GetSyncClientForTest();
private: private:
friend class TestProfileSyncService;
// Passed as an argument to StopImpl to control whether or not the sync // Passed as an argument to StopImpl to control whether or not the sync
// engine should clear its data directory when it shuts down. See StopImpl // engine should clear its data directory when it shuts down. See StopImpl
// for more information. // for more information.
......
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/sync/driver/test_profile_sync_service.h"
#include <utility>
#include "base/run_loop.h"
namespace syncer {
syncer::WeakHandle<syncer::JsEventHandler>
TestProfileSyncService::GetJsEventHandler() {
return syncer::WeakHandle<syncer::JsEventHandler>();
}
TestProfileSyncService::TestProfileSyncService(
ProfileSyncService::InitParams init_params)
: ProfileSyncService(std::move(init_params)) {}
TestProfileSyncService::~TestProfileSyncService() {}
void TestProfileSyncService::OnConfigureDone(
const syncer::DataTypeManager::ConfigureResult& result) {
ProfileSyncService::OnConfigureDone(result);
base::RunLoop::QuitCurrentWhenIdleDeprecated();
}
bool TestProfileSyncService::IsAuthenticatedAccountPrimary() const {
return true;
}
syncer::UserShare* TestProfileSyncService::GetUserShare() const {
return engine_->GetUserShare();
}
} // namespace syncer
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_SYNC_DRIVER_TEST_PROFILE_SYNC_SERVICE_H_
#define COMPONENTS_SYNC_DRIVER_TEST_PROFILE_SYNC_SERVICE_H_
#include "base/macros.h"
#include "components/sync/base/weak_handle.h"
#include "components/sync/driver/data_type_manager.h"
#include "components/sync/driver/profile_sync_service.h"
#include "components/sync/js/js_event_handler.h"
namespace syncer {
class SyncPrefs;
class TestProfileSyncService : public syncer::ProfileSyncService {
public:
explicit TestProfileSyncService(InitParams init_params);
~TestProfileSyncService() override;
void OnConfigureDone(
const syncer::DataTypeManager::ConfigureResult& result) override;
// TODO(crbug.com/871221): This is overridden here to return true by default,
// as a workaround for tests not setting up an authenticated account, and
// IsSyncFeatureEnabled() therefore returning false.
bool IsAuthenticatedAccountPrimary() const override;
// We implement our own version to avoid some DCHECKs.
syncer::UserShare* GetUserShare() const override;
// Raise visibility to ease testing.
using ProfileSyncService::NotifyObservers;
syncer::SyncPrefs* sync_prefs() { return &sync_prefs_; }
protected:
// Return null handle to use in backend initialization to avoid receiving
// js messages on UI loop when it's being destroyed, which are not deleted
// and cause memory leak in test.
syncer::WeakHandle<syncer::JsEventHandler> GetJsEventHandler() override;
private:
DISALLOW_COPY_AND_ASSIGN(TestProfileSyncService);
};
} // namespace syncer
#endif // COMPONENTS_SYNC_DRIVER_TEST_PROFILE_SYNC_SERVICE_H_
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/sync/engine/sync_manager_factory_for_profile_sync_test.h"
#include "components/sync/engine_impl/sync_manager_for_profile_sync_test.h"
namespace syncer {
SyncManagerFactoryForProfileSyncTest::SyncManagerFactoryForProfileSyncTest(
base::OnceClosure init_callback,
network::NetworkConnectionTracker* network_connection_tracker)
: SyncManagerFactory(network_connection_tracker),
init_callback_(std::move(init_callback)) {}
SyncManagerFactoryForProfileSyncTest::~SyncManagerFactoryForProfileSyncTest() {}
std::unique_ptr<SyncManager>
SyncManagerFactoryForProfileSyncTest::CreateSyncManager(
const std::string& name) {
return std::unique_ptr<SyncManager>(
new SyncManagerForProfileSyncTest(name, std::move(init_callback_)));
}
} // namespace syncer
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_SYNC_ENGINE_SYNC_MANAGER_FACTORY_FOR_PROFILE_SYNC_TEST_H_
#define COMPONENTS_SYNC_ENGINE_SYNC_MANAGER_FACTORY_FOR_PROFILE_SYNC_TEST_H_
#include <memory>
#include <string>
#include "base/callback.h"
#include "components/sync/engine/sync_manager_factory.h"
namespace syncer {
class SyncManagerFactoryForProfileSyncTest : public SyncManagerFactory {
public:
SyncManagerFactoryForProfileSyncTest(
base::OnceClosure init_callback,
network::NetworkConnectionTracker* network_connection_tracker);
~SyncManagerFactoryForProfileSyncTest() override;
std::unique_ptr<SyncManager> CreateSyncManager(
const std::string& name) override;
private:
base::OnceClosure init_callback_;
};
} // namespace syncer
#endif // COMPONENTS_SYNC_ENGINE_SYNC_MANAGER_FACTORY_FOR_PROFILE_SYNC_TEST_H_
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/sync/engine_impl/sync_manager_for_profile_sync_test.h"
#include "components/sync/syncable/directory.h"
#include "components/sync/syncable/test_user_share.h"
#include "components/sync/syncable/user_share.h"
#include "services/network/test/test_network_connection_tracker.h"
namespace syncer {
SyncManagerForProfileSyncTest::SyncManagerForProfileSyncTest(
std::string name,
base::OnceClosure init_callback)
: SyncManagerImpl(name,
network::TestNetworkConnectionTracker::GetInstance()),
init_callback_(std::move(init_callback)) {}
SyncManagerForProfileSyncTest::~SyncManagerForProfileSyncTest() {}
void SyncManagerForProfileSyncTest::NotifyInitializationSuccess() {
UserShare* user_share = GetUserShare();
syncable::Directory* directory = user_share->directory.get();
if (!init_callback_.is_null())
std::move(init_callback_).Run();
ModelTypeSet early_download_types;
early_download_types.PutAll(ControlTypes());
early_download_types.PutAll(PriorityUserTypes());
for (ModelType type : early_download_types) {
if (!directory->InitialSyncEndedForType(type)) {
TestUserShare::CreateRoot(type, user_share);
}
}
SyncManagerImpl::NotifyInitializationSuccess();
}
} // namespace syncer
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_SYNC_ENGINE_IMPL_SYNC_MANAGER_FOR_PROFILE_SYNC_TEST_H_
#define COMPONENTS_SYNC_ENGINE_IMPL_SYNC_MANAGER_FOR_PROFILE_SYNC_TEST_H_
#include <string>
#include "base/callback.h"
#include "base/compiler_specific.h"
#include "components/sync/engine_impl/sync_manager_impl.h"
namespace syncer {
// This class is used to help implement the TestProfileSyncService.
// Those tests try to test sync without instantiating a real backend.
class SyncManagerForProfileSyncTest : public SyncManagerImpl {
public:
SyncManagerForProfileSyncTest(std::string name,
base::OnceClosure init_callback);
~SyncManagerForProfileSyncTest() override;
void NotifyInitializationSuccess() override;
private:
base::OnceClosure init_callback_;
};
} // namespace syncer
#endif // COMPONENTS_SYNC_ENGINE_IMPL_SYNC_MANAGER_FOR_PROFILE_SYNC_TEST_H_
...@@ -27,18 +27,3 @@ static_library("webdata_services") { ...@@ -27,18 +27,3 @@ static_library("webdata_services") {
deps += [ "//components/payments/content:utils" ] deps += [ "//components/payments/content:utils" ]
} }
} }
static_library("test_support") {
testonly = true
sources = [
"web_data_service_test_util.cc",
"web_data_service_test_util.h",
]
deps = [
":webdata_services",
"//base",
"//components/autofill/core/browser",
"//components/signin/core/browser",
]
}
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/webdata_services/web_data_service_test_util.h"
#include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
using autofill::AutofillWebDataService;
MockWebDataServiceWrapperBase::MockWebDataServiceWrapperBase() {
}
MockWebDataServiceWrapperBase::~MockWebDataServiceWrapperBase() {
}
void MockWebDataServiceWrapperBase::Shutdown() {
}
// TODO(caitkp): This won't scale well. As we get more WebData subclasses, we
// will probably need a better way to create these mocks rather than passing
// all the webdatas in.
MockWebDataServiceWrapper::MockWebDataServiceWrapper(
scoped_refptr<AutofillWebDataService> fake_autofill,
scoped_refptr<TokenWebData> fake_token)
: fake_autofill_web_data_(fake_autofill), fake_token_web_data_(fake_token) {
}
MockWebDataServiceWrapper::~MockWebDataServiceWrapper() {
}
scoped_refptr<AutofillWebDataService>
MockWebDataServiceWrapper::GetProfileAutofillWebData() {
return fake_autofill_web_data_;
}
scoped_refptr<AutofillWebDataService>
MockWebDataServiceWrapper::GetAccountAutofillWebData() {
// TODO(feuunk): Implement when there are tests covering account data.
return nullptr;
}
scoped_refptr<TokenWebData> MockWebDataServiceWrapper::GetTokenWebData() {
return fake_token_web_data_;
}
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_WEBDATA_SERVICES_WEB_DATA_SERVICE_TEST_UTIL_H__
#define COMPONENTS_WEBDATA_SERVICES_WEB_DATA_SERVICE_TEST_UTIL_H__
#include "base/macros.h"
#include "components/signin/core/browser/webdata/token_web_data.h"
#include "components/webdata_services/web_data_service_wrapper.h"
// Base class for mocks of WebDataService, that does nothing in
// Shutdown().
class MockWebDataServiceWrapperBase : public WebDataServiceWrapper {
public:
MockWebDataServiceWrapperBase();
~MockWebDataServiceWrapperBase() override;
void Shutdown() override;
private:
DISALLOW_COPY_AND_ASSIGN(MockWebDataServiceWrapperBase);
};
// Pass your fake WebDataService in the constructor and this will
// serve it up via GetWebData().
class MockWebDataServiceWrapper : public MockWebDataServiceWrapperBase {
public:
MockWebDataServiceWrapper(
scoped_refptr<autofill::AutofillWebDataService> fake_autofill,
scoped_refptr<TokenWebData> fake_token);
~MockWebDataServiceWrapper() override;
scoped_refptr<autofill::AutofillWebDataService> GetProfileAutofillWebData()
override;
scoped_refptr<autofill::AutofillWebDataService> GetAccountAutofillWebData()
override;
scoped_refptr<TokenWebData> GetTokenWebData() override;
protected:
scoped_refptr<autofill::AutofillWebDataService> fake_autofill_web_data_;
scoped_refptr<TokenWebData> fake_token_web_data_;
private:
DISALLOW_COPY_AND_ASSIGN(MockWebDataServiceWrapper);
};
#endif // COMPONENTS_WEBDATA_SERVICES_WEB_DATA_SERVICE_TEST_UTIL_H__
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment