Chromium Code Reviews| 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..c31d4340c7f54eb197d186fdadd0c237b4f6ed08 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,26 @@ void ExtensionSessionsTest::SetUpOnMainThread() { |
| CreateTestExtension(); |
| } |
| +KeyedService* ExtensionSessionsTest::BuildProfileSyncService( |
| + content::BrowserContext* profile) { |
| + |
|
sky
2014/07/18 15:37:18
nit: no newline here.
|
| + ProfileSyncComponentsFactoryMock* factory = |
| + new ProfileSyncComponentsFactoryMock(); |
| + |
| + factory->SetLocalDeviceInfoProvider( |
| + scoped_ptr<LocalDeviceInfoProvider>( |
| + 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 +150,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 +167,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()); |