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

Unified Diff: chrome/browser/extensions/api/sessions/sessions_apitest.cc

Issue 367153005: Sync: Refactoring of DEVICE_INFO syncable type - Part 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed scoped_ptr issue in ProfileSyncService constructor Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/sessions/sessions_apitest.cc
diff --git a/chrome/browser/extensions/api/sessions/sessions_apitest.cc b/chrome/browser/extensions/api/sessions/sessions_apitest.cc
index cc208d22acc41d70e8295bf411b965d1d16fef9d..d64d29759a63d12e554999e6ee42c746c6229fff 100644
--- a/chrome/browser/extensions/api/sessions/sessions_apitest.cc
+++ b/chrome/browser/extensions/api/sessions/sessions_apitest.cc
@@ -11,7 +11,9 @@
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/browser/extensions/extension_function_test_utils.h"
#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/browser/sync/glue/local_device_info_provider_mock.h"
#include "chrome/browser/sync/open_tabs_ui_delegate.h"
+#include "chrome/browser/sync/profile_sync_components_factory_mock.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/sync/profile_sync_service_mock.h"
@@ -85,6 +87,9 @@ class ExtensionSessionsTest : public InProcessBrowserTest {
virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE;
virtual void SetUpOnMainThread() OVERRIDE;
protected:
+ static KeyedService* BuildProfileSyncService(
+ content::BrowserContext* profile);
+
void CreateTestProfileSyncService();
void CreateTestExtension();
void CreateSessionModels();
@@ -113,6 +118,25 @@ void ExtensionSessionsTest::SetUpOnMainThread() {
CreateTestExtension();
}
+KeyedService* ExtensionSessionsTest::BuildProfileSyncService(
+ content::BrowserContext* profile) {
+
+ ProfileSyncComponentsFactoryMock* factory =
+ new ProfileSyncComponentsFactoryMock();
+
+ ON_CALL(*factory, CreateLocalDeviceInfoProviderMock()).WillByDefault(
+ testing::Return(new browser_sync::LocalDeviceInfoProviderMock(
+ kSessionTags[0],
+ "machine name",
+ "Chromium 10k",
+ "Chrome 10k",
+ sync_pb::SyncEnums_DeviceType_TYPE_LINUX)));
+
+ return new ProfileSyncServiceMock(
+ scoped_ptr<ProfileSyncComponentsFactory>(factory),
+ static_cast<Profile*>(profile));
+}
+
void ExtensionSessionsTest::CreateTestProfileSyncService() {
ProfileManager* profile_manager = g_browser_process->profile_manager();
base::FilePath path;
@@ -125,7 +149,7 @@ void ExtensionSessionsTest::CreateTestProfileSyncService() {
profile_manager->RegisterTestingProfile(profile, true, false);
ProfileSyncServiceMock* service = static_cast<ProfileSyncServiceMock*>(
ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse(
- profile, &ProfileSyncServiceMock::BuildMockProfileSyncService));
+ profile, &ExtensionSessionsTest::BuildProfileSyncService));
browser_ = new Browser(Browser::CreateParams(
profile, chrome::HOST_DESKTOP_TYPE_NATIVE));
@@ -142,15 +166,6 @@ void ExtensionSessionsTest::CreateTestProfileSyncService() {
testing::ReturnRef(no_error));
ON_CALL(*service, GetActiveDataTypes()).WillByDefault(
testing::Return(preferred_types));
- ON_CALL(*service, GetLocalDeviceInfoMock()).WillByDefault(
- testing::Return(new browser_sync::DeviceInfo(
- std::string(kSessionTags[0]),
- "machine name",
- "Chromium 10k",
- "Chrome 10k",
- sync_pb::SyncEnums_DeviceType_TYPE_LINUX)));
- ON_CALL(*service, GetLocalSyncCacheGUID()).WillByDefault(
- testing::Return(std::string(kSessionTags[0])));
EXPECT_CALL(*service, AddObserver(testing::_)).Times(testing::AnyNumber());
EXPECT_CALL(*service, RemoveObserver(testing::_)).Times(testing::AnyNumber());

Powered by Google App Engine
This is Rietveld 408576698