| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 std::unique_ptr<SyncApiComponentFactoryMock> factory( | 185 std::unique_ptr<SyncApiComponentFactoryMock> factory( |
| 186 new SyncApiComponentFactoryMock()); | 186 new SyncApiComponentFactoryMock()); |
| 187 | 187 |
| 188 factory->SetLocalDeviceInfoProvider( | 188 factory->SetLocalDeviceInfoProvider( |
| 189 std::unique_ptr<sync_driver::LocalDeviceInfoProvider>( | 189 std::unique_ptr<sync_driver::LocalDeviceInfoProvider>( |
| 190 new sync_driver::LocalDeviceInfoProviderMock( | 190 new sync_driver::LocalDeviceInfoProviderMock( |
| 191 kSessionTags[0], "machine name", "Chromium 10k", "Chrome 10k", | 191 kSessionTags[0], "machine name", "Chromium 10k", "Chrome 10k", |
| 192 sync_pb::SyncEnums_DeviceType_TYPE_LINUX, "device_id"))); | 192 sync_pb::SyncEnums_DeviceType_TYPE_LINUX, "device_id"))); |
| 193 | 193 |
| 194 Profile* profile = static_cast<Profile*>(context); | 194 Profile* profile = static_cast<Profile*>(context); |
| 195 ProfileSyncServiceMock* sync_service = | 195 browser_sync::ProfileSyncServiceMock* sync_service = |
| 196 new ProfileSyncServiceMock(CreateProfileSyncServiceParamsForTest( | 196 new browser_sync::ProfileSyncServiceMock( |
| 197 base::MakeUnique<browser_sync::ChromeSyncClient>(profile), profile)); | 197 CreateProfileSyncServiceParamsForTest( |
| 198 base::MakeUnique<browser_sync::ChromeSyncClient>(profile), |
| 199 profile)); |
| 198 static_cast<browser_sync::ChromeSyncClient*>(sync_service->GetSyncClient()) | 200 static_cast<browser_sync::ChromeSyncClient*>(sync_service->GetSyncClient()) |
| 199 ->SetSyncApiComponentFactoryForTesting(std::move(factory)); | 201 ->SetSyncApiComponentFactoryForTesting(std::move(factory)); |
| 200 return base::WrapUnique(sync_service); | 202 return base::WrapUnique(sync_service); |
| 201 } | 203 } |
| 202 | 204 |
| 203 void ExtensionSessionsTest::CreateTestProfileSyncService() { | 205 void ExtensionSessionsTest::CreateTestProfileSyncService() { |
| 204 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 206 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 205 base::FilePath path; | 207 base::FilePath path; |
| 206 PathService::Get(chrome::DIR_USER_DATA, &path); | 208 PathService::Get(chrome::DIR_USER_DATA, &path); |
| 207 path = path.AppendASCII("test_profile"); | 209 path = path.AppendASCII("test_profile"); |
| 208 if (!base::PathExists(path)) | 210 if (!base::PathExists(path)) |
| 209 CHECK(base::CreateDirectory(path)); | 211 CHECK(base::CreateDirectory(path)); |
| 210 Profile* profile = | 212 Profile* profile = |
| 211 Profile::CreateProfile(path, NULL, Profile::CREATE_MODE_SYNCHRONOUS); | 213 Profile::CreateProfile(path, NULL, Profile::CREATE_MODE_SYNCHRONOUS); |
| 212 profile_manager->RegisterTestingProfile(profile, true, false); | 214 profile_manager->RegisterTestingProfile(profile, true, false); |
| 213 ProfileSyncServiceMock* service = static_cast<ProfileSyncServiceMock*>( | 215 browser_sync::ProfileSyncServiceMock* service = |
| 214 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 216 static_cast<browser_sync::ProfileSyncServiceMock*>( |
| 215 profile, &ExtensionSessionsTest::BuildProfileSyncService)); | 217 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
| 218 profile, &ExtensionSessionsTest::BuildProfileSyncService)); |
| 216 | 219 |
| 217 syncer::ModelTypeSet preferred_types; | 220 syncer::ModelTypeSet preferred_types; |
| 218 preferred_types.Put(syncer::SESSIONS); | 221 preferred_types.Put(syncer::SESSIONS); |
| 219 GoogleServiceAuthError no_error(GoogleServiceAuthError::NONE); | 222 GoogleServiceAuthError no_error(GoogleServiceAuthError::NONE); |
| 220 ON_CALL(*service, IsDataTypeControllerRunning(syncer::SESSIONS)) | 223 ON_CALL(*service, IsDataTypeControllerRunning(syncer::SESSIONS)) |
| 221 .WillByDefault(testing::Return(true)); | 224 .WillByDefault(testing::Return(true)); |
| 222 ON_CALL(*service, GetRegisteredDataTypes()) | 225 ON_CALL(*service, GetRegisteredDataTypes()) |
| 223 .WillByDefault(testing::Return(syncer::UserTypes())); | 226 .WillByDefault(testing::Return(syncer::UserTypes())); |
| 224 ON_CALL(*service, GetPreferredDataTypes()).WillByDefault( | 227 ON_CALL(*service, GetPreferredDataTypes()).WillByDefault( |
| 225 testing::Return(preferred_types)); | 228 testing::Return(preferred_types)); |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 EXPECT_EQ(0u, sessions->GetSize()); | 379 EXPECT_EQ(0u, sessions->GetSize()); |
| 377 } | 380 } |
| 378 | 381 |
| 379 // http://crbug.com/251199 | 382 // http://crbug.com/251199 |
| 380 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_SessionsApis) { | 383 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_SessionsApis) { |
| 381 ASSERT_TRUE(RunExtensionSubtest("sessions", | 384 ASSERT_TRUE(RunExtensionSubtest("sessions", |
| 382 "sessions.html")) << message_; | 385 "sessions.html")) << message_; |
| 383 } | 386 } |
| 384 | 387 |
| 385 } // namespace extensions | 388 } // namespace extensions |
| OLD | NEW |