| OLD | NEW |
| 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 "chrome/browser/sync/test/integration/sync_test.h" | 5 #include "chrome/browser/sync/test/integration/sync_test.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 #include "chrome/test/base/ui_test_utils.h" | 59 #include "chrome/test/base/ui_test_utils.h" |
| 60 #include "components/bookmarks/test/bookmark_test_helpers.h" | 60 #include "components/bookmarks/test/bookmark_test_helpers.h" |
| 61 #include "components/browser_sync/browser/profile_sync_service.h" | 61 #include "components/browser_sync/browser/profile_sync_service.h" |
| 62 #include "components/google/core/browser/google_url_tracker.h" | 62 #include "components/google/core/browser/google_url_tracker.h" |
| 63 #include "components/invalidation/impl/invalidation_switches.h" | 63 #include "components/invalidation/impl/invalidation_switches.h" |
| 64 #include "components/invalidation/impl/p2p_invalidation_service.h" | 64 #include "components/invalidation/impl/p2p_invalidation_service.h" |
| 65 #include "components/invalidation/impl/p2p_invalidator.h" | 65 #include "components/invalidation/impl/p2p_invalidator.h" |
| 66 #include "components/invalidation/impl/profile_invalidation_provider.h" | 66 #include "components/invalidation/impl/profile_invalidation_provider.h" |
| 67 #include "components/invalidation/public/invalidation_service.h" | 67 #include "components/invalidation/public/invalidation_service.h" |
| 68 #include "components/keyed_service/core/keyed_service.h" | 68 #include "components/keyed_service/core/keyed_service.h" |
| 69 #include "components/os_crypt/os_crypt.h" | 69 #include "components/os_crypt/os_crypt_mocker.h" |
| 70 #include "components/search_engines/template_url_service.h" | 70 #include "components/search_engines/template_url_service.h" |
| 71 #include "components/signin/core/browser/profile_identity_provider.h" | 71 #include "components/signin/core/browser/profile_identity_provider.h" |
| 72 #include "components/signin/core/browser/signin_manager.h" | 72 #include "components/signin/core/browser/signin_manager.h" |
| 73 #include "components/sync_driver/invalidation_helper.h" | 73 #include "components/sync_driver/invalidation_helper.h" |
| 74 #include "components/sync_driver/sync_driver_switches.h" | 74 #include "components/sync_driver/sync_driver_switches.h" |
| 75 #include "content/public/browser/navigation_entry.h" | 75 #include "content/public/browser/navigation_entry.h" |
| 76 #include "content/public/browser/notification_service.h" | 76 #include "content/public/browser/notification_service.h" |
| 77 #include "content/public/browser/web_contents.h" | 77 #include "content/public/browser/web_contents.h" |
| 78 #include "content/public/test/test_browser_thread.h" | 78 #include "content/public/test/test_browser_thread.h" |
| 79 #include "google_apis/gaia/gaia_urls.h" | 79 #include "google_apis/gaia/gaia_urls.h" |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 // Decide on password to use. | 255 // Decide on password to use. |
| 256 password_ = cl->HasSwitch(switches::kSyncPasswordForTest) | 256 password_ = cl->HasSwitch(switches::kSyncPasswordForTest) |
| 257 ? cl->GetSwitchValueASCII(switches::kSyncPasswordForTest) | 257 ? cl->GetSwitchValueASCII(switches::kSyncPasswordForTest) |
| 258 : "password"; | 258 : "password"; |
| 259 } | 259 } |
| 260 | 260 |
| 261 if (username_.empty() || password_.empty()) | 261 if (username_.empty() || password_.empty()) |
| 262 LOG(FATAL) << "Cannot run sync tests without GAIA credentials."; | 262 LOG(FATAL) << "Cannot run sync tests without GAIA credentials."; |
| 263 | 263 |
| 264 // Mock the Mac Keychain service. The real Keychain can block on user input. | 264 // Mock the Mac Keychain service. The real Keychain can block on user input. |
| 265 #if defined(OS_MACOSX) | 265 OSCryptMocker::SetUpWithSingleton(); |
| 266 OSCrypt::UseMockKeychain(true); | |
| 267 #endif | |
| 268 | 266 |
| 269 // Start up a sync test server if one is needed and setup mock gaia responses. | 267 // Start up a sync test server if one is needed and setup mock gaia responses. |
| 270 // Note: This must be done prior to the call to SetupClients() because we want | 268 // Note: This must be done prior to the call to SetupClients() because we want |
| 271 // the mock gaia responses to be available before GaiaUrls is initialized. | 269 // the mock gaia responses to be available before GaiaUrls is initialized. |
| 272 SetUpTestServerIfRequired(); | 270 SetUpTestServerIfRequired(); |
| 273 | 271 |
| 274 // Yield control back to the InProcessBrowserTest framework. | 272 // Yield control back to the InProcessBrowserTest framework. |
| 275 InProcessBrowserTest::SetUp(); | 273 InProcessBrowserTest::SetUp(); |
| 276 } | 274 } |
| 277 | 275 |
| 278 void SyncTest::TearDown() { | 276 void SyncTest::TearDown() { |
| 279 // Clear any mock gaia responses that might have been set. | 277 // Clear any mock gaia responses that might have been set. |
| 280 ClearMockGaiaResponses(); | 278 ClearMockGaiaResponses(); |
| 281 | 279 |
| 282 // Allow the InProcessBrowserTest framework to perform its tear down. | 280 // Allow the InProcessBrowserTest framework to perform its tear down. |
| 283 InProcessBrowserTest::TearDown(); | 281 InProcessBrowserTest::TearDown(); |
| 284 | 282 |
| 285 // Stop the local python test server. This is a no-op if one wasn't started. | 283 // Stop the local python test server. This is a no-op if one wasn't started. |
| 286 TearDownLocalPythonTestServer(); | 284 TearDownLocalPythonTestServer(); |
| 287 | 285 |
| 288 // Stop the local sync test server. This is a no-op if one wasn't started. | 286 // Stop the local sync test server. This is a no-op if one wasn't started. |
| 289 TearDownLocalTestServer(); | 287 TearDownLocalTestServer(); |
| 290 | 288 |
| 289 // Return OSCrypt to its real behaviour |
| 290 OSCryptMocker::TearDown(); |
| 291 |
| 291 fake_server_.reset(); | 292 fake_server_.reset(); |
| 292 } | 293 } |
| 293 | 294 |
| 294 void SyncTest::SetUpCommandLine(base::CommandLine* cl) { | 295 void SyncTest::SetUpCommandLine(base::CommandLine* cl) { |
| 295 AddTestSwitches(cl); | 296 AddTestSwitches(cl); |
| 296 AddOptionalTypesToCommandLine(cl); | 297 AddOptionalTypesToCommandLine(cl); |
| 297 | 298 |
| 298 #if defined(OS_CHROMEOS) | 299 #if defined(OS_CHROMEOS) |
| 299 cl->AppendSwitch(chromeos::switches::kIgnoreUserProfileMappingForTests); | 300 cl->AppendSwitch(chromeos::switches::kIgnoreUserProfileMappingForTests); |
| 300 #endif | 301 #endif |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 } | 474 } |
| 474 | 475 |
| 475 bool SyncTest::SetupClients() { | 476 bool SyncTest::SetupClients() { |
| 476 if (num_clients_ <= 0) | 477 if (num_clients_ <= 0) |
| 477 LOG(FATAL) << "num_clients_ incorrectly initialized."; | 478 LOG(FATAL) << "num_clients_ incorrectly initialized."; |
| 478 if (!profiles_.empty() || !browsers_.empty() || !clients_.empty()) | 479 if (!profiles_.empty() || !browsers_.empty() || !clients_.empty()) |
| 479 LOG(FATAL) << "SetupClients() has already been called."; | 480 LOG(FATAL) << "SetupClients() has already been called."; |
| 480 | 481 |
| 481 // Create the required number of sync profiles, browsers and clients. | 482 // Create the required number of sync profiles, browsers and clients. |
| 482 profiles_.resize(num_clients_); | 483 profiles_.resize(num_clients_); |
| 483 profile_delegates_.resize(num_clients_ + 1); // + 1 for the verifier. | 484 profile_delegates_.resize(num_clients_ + 1); // + 1 for the verifier. |
| 484 tmp_profile_paths_.resize(num_clients_); | 485 tmp_profile_paths_.resize(num_clients_); |
| 485 browsers_.resize(num_clients_); | 486 browsers_.resize(num_clients_); |
| 486 clients_.resize(num_clients_); | 487 clients_.resize(num_clients_); |
| 487 invalidation_forwarders_.resize(num_clients_); | 488 invalidation_forwarders_.resize(num_clients_); |
| 488 sync_refreshers_.resize(num_clients_); | 489 sync_refreshers_.resize(num_clients_); |
| 489 fake_server_invalidation_services_.resize(num_clients_); | 490 fake_server_invalidation_services_.resize(num_clients_); |
| 490 | 491 |
| 491 if (create_gaia_account_at_runtime_) { | 492 if (create_gaia_account_at_runtime_) { |
| 492 CHECK(UsingExternalServers()) << | 493 CHECK(UsingExternalServers()) << |
| 493 "Cannot create Gaia accounts without external authentication servers"; | 494 "Cannot create Gaia accounts without external authentication servers"; |
| (...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1129 | 1130 |
| 1130 void SyncTest::TriggerSyncForModelTypes(int index, | 1131 void SyncTest::TriggerSyncForModelTypes(int index, |
| 1131 syncer::ModelTypeSet model_types) { | 1132 syncer::ModelTypeSet model_types) { |
| 1132 GetSyncService(index)->TriggerRefresh(model_types); | 1133 GetSyncService(index)->TriggerRefresh(model_types); |
| 1133 } | 1134 } |
| 1134 | 1135 |
| 1135 void SyncTest::SetPreexistingPreferencesFileContents( | 1136 void SyncTest::SetPreexistingPreferencesFileContents( |
| 1136 const std::string& contents) { | 1137 const std::string& contents) { |
| 1137 preexisting_preferences_file_contents_ = contents; | 1138 preexisting_preferences_file_contents_ = contents; |
| 1138 } | 1139 } |
| OLD | NEW |