Chromium Code Reviews| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 #include "net/base/load_flags.h" | 82 #include "net/base/load_flags.h" |
| 83 #include "net/base/network_change_notifier.h" | 83 #include "net/base/network_change_notifier.h" |
| 84 #include "net/base/port_util.h" | 84 #include "net/base/port_util.h" |
| 85 #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" | 85 #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" |
| 86 #include "net/url_request/test_url_fetcher_factory.h" | 86 #include "net/url_request/test_url_fetcher_factory.h" |
| 87 #include "net/url_request/url_fetcher.h" | 87 #include "net/url_request/url_fetcher.h" |
| 88 #include "net/url_request/url_fetcher_delegate.h" | 88 #include "net/url_request/url_fetcher_delegate.h" |
| 89 #include "url/gurl.h" | 89 #include "url/gurl.h" |
| 90 | 90 |
| 91 #if defined(OS_CHROMEOS) | 91 #if defined(OS_CHROMEOS) |
| 92 #include "chrome/browser/sync/test/integration/sync_arc_package_helper.h" | |
| 93 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs_factory.h" | |
| 92 #include "chromeos/chromeos_switches.h" | 94 #include "chromeos/chromeos_switches.h" |
| 95 #include "components/arc/arc_util.h" | |
| 93 #endif | 96 #endif |
| 94 | 97 |
| 95 using browser_sync::ProfileSyncService; | 98 using browser_sync::ProfileSyncService; |
| 96 using content::BrowserThread; | 99 using content::BrowserThread; |
| 97 | 100 |
| 98 namespace switches { | 101 namespace switches { |
| 99 const char kPasswordFileForTest[] = "password-file-for-test"; | 102 const char kPasswordFileForTest[] = "password-file-for-test"; |
| 100 const char kSyncUserForTest[] = "sync-user-for-test"; | 103 const char kSyncUserForTest[] = "sync-user-for-test"; |
| 101 const char kSyncPasswordForTest[] = "sync-password-for-test"; | 104 const char kSyncPasswordForTest[] = "sync-password-for-test"; |
| 102 const char kSyncServerCommandLine[] = "sync-server-command-line"; | 105 const char kSyncServerCommandLine[] = "sync-server-command-line"; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 206 } | 209 } |
| 207 | 210 |
| 208 } // namespace | 211 } // namespace |
| 209 | 212 |
| 210 SyncTest::SyncTest(TestType test_type) | 213 SyncTest::SyncTest(TestType test_type) |
| 211 : test_type_(test_type), | 214 : test_type_(test_type), |
| 212 server_type_(SERVER_TYPE_UNDECIDED), | 215 server_type_(SERVER_TYPE_UNDECIDED), |
| 213 num_clients_(-1), | 216 num_clients_(-1), |
| 214 use_verifier_(true), | 217 use_verifier_(true), |
| 215 notifications_enabled_(true), | 218 notifications_enabled_(true), |
| 216 create_gaia_account_at_runtime_(false) { | 219 create_gaia_account_at_runtime_(false), |
| 220 sync_arc_helper_(nullptr) { | |
| 217 sync_datatype_helper::AssociateWithTest(this); | 221 sync_datatype_helper::AssociateWithTest(this); |
| 218 switch (test_type_) { | 222 switch (test_type_) { |
| 219 case SINGLE_CLIENT: | 223 case SINGLE_CLIENT: |
| 220 case SINGLE_CLIENT_LEGACY: { | 224 case SINGLE_CLIENT_LEGACY: { |
| 221 num_clients_ = 1; | 225 num_clients_ = 1; |
| 222 break; | 226 break; |
| 223 } | 227 } |
| 224 case TWO_CLIENT: | 228 case TWO_CLIENT: |
| 225 case TWO_CLIENT_LEGACY: { | 229 case TWO_CLIENT_LEGACY: { |
| 226 num_clients_ = 2; | 230 num_clients_ = 2; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 285 | 289 |
| 286 // Stop the local sync test server. This is a no-op if one wasn't started. | 290 // Stop the local sync test server. This is a no-op if one wasn't started. |
| 287 TearDownLocalTestServer(); | 291 TearDownLocalTestServer(); |
| 288 | 292 |
| 289 // Return OSCrypt to its real behaviour | 293 // Return OSCrypt to its real behaviour |
| 290 OSCryptMocker::TearDown(); | 294 OSCryptMocker::TearDown(); |
| 291 | 295 |
| 292 fake_server_.reset(); | 296 fake_server_.reset(); |
| 293 } | 297 } |
| 294 | 298 |
| 299 void SyncTest::SetUpOnMainThread() { | |
| 300 #if defined(OS_CHROMEOS) | |
| 301 const auto* cl = base::CommandLine::ForCurrentProcess(); | |
| 302 // Sets up for ARC_PACKAGE. | |
| 303 if (!cl->HasSwitch(switches::kSupervisedUserId)) | |
|
Gang Wu
2017/03/16 18:40:30
add this because "Supervised users are not support
skym
2017/03/16 23:27:19
Can you put that into a comment?
Gang Wu
2017/03/17 19:23:23
Done.
| |
| 304 ArcAppListPrefsFactory::SetFactoryForSyncTest(); | |
| 305 #endif | |
| 306 } | |
| 307 | |
| 295 void SyncTest::SetUpCommandLine(base::CommandLine* cl) { | 308 void SyncTest::SetUpCommandLine(base::CommandLine* cl) { |
| 296 AddTestSwitches(cl); | 309 AddTestSwitches(cl); |
| 297 AddOptionalTypesToCommandLine(cl); | 310 AddOptionalTypesToCommandLine(cl); |
| 298 | 311 |
| 299 #if defined(OS_CHROMEOS) | 312 #if defined(OS_CHROMEOS) |
| 300 cl->AppendSwitch(chromeos::switches::kIgnoreUserProfileMappingForTests); | 313 cl->AppendSwitch(chromeos::switches::kIgnoreUserProfileMappingForTests); |
| 314 arc::SetArcAvailableCommandLineForTesting(cl); | |
| 301 #endif | 315 #endif |
| 302 } | 316 } |
| 303 | 317 |
| 304 void SyncTest::AddTestSwitches(base::CommandLine* cl) { | 318 void SyncTest::AddTestSwitches(base::CommandLine* cl) { |
| 305 // Disable non-essential access of external network resources. | 319 // Disable non-essential access of external network resources. |
| 306 if (!cl->HasSwitch(switches::kDisableBackgroundNetworking)) | 320 if (!cl->HasSwitch(switches::kDisableBackgroundNetworking)) |
| 307 cl->AppendSwitch(switches::kDisableBackgroundNetworking); | 321 cl->AppendSwitch(switches::kDisableBackgroundNetworking); |
| 308 | 322 |
| 309 if (!cl->HasSwitch(switches::kSyncShortInitialRetryOverride)) | 323 if (!cl->HasSwitch(switches::kSyncShortInitialRetryOverride)) |
| 310 cl->AppendSwitch(switches::kSyncShortInitialRetryOverride); | 324 cl->AppendSwitch(switches::kSyncShortInitialRetryOverride); |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 524 // Create the verifier profile. | 538 // Create the verifier profile. |
| 525 if (use_verifier_) { | 539 if (use_verifier_) { |
| 526 base::FilePath user_data_dir; | 540 base::FilePath user_data_dir; |
| 527 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); | 541 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); |
| 528 profile_delegates_[num_clients_] = | 542 profile_delegates_[num_clients_] = |
| 529 base::MakeUnique<SyncProfileDelegate>(base::Callback<void(Profile*)>()); | 543 base::MakeUnique<SyncProfileDelegate>(base::Callback<void(Profile*)>()); |
| 530 verifier_ = MakeTestProfile( | 544 verifier_ = MakeTestProfile( |
| 531 user_data_dir.Append(FILE_PATH_LITERAL("Verifier")), num_clients_); | 545 user_data_dir.Append(FILE_PATH_LITERAL("Verifier")), num_clients_); |
| 532 WaitForDataModels(verifier()); | 546 WaitForDataModels(verifier()); |
| 533 } | 547 } |
| 548 | |
| 549 #if defined(OS_CHROMEOS) | |
| 550 // Init SyncArcPackageHelper to ensure that the arc services are initialized | |
| 551 // for each Profile. | |
| 552 const auto* cl = base::CommandLine::ForCurrentProcess(); | |
| 553 if (!cl->HasSwitch(switches::kSupervisedUserId)) { | |
|
skym
2017/03/16 23:27:19
I've seen this check before! Can you unify them? A
Gang Wu
2017/03/17 19:23:23
cannot combine two code together, ArcAppListPrefsF
| |
| 554 sync_arc_helper_ = arc::SyncArcPackageHelper::GetInstance(); | |
| 555 if (!sync_arc_helper_) | |
| 556 return false; | |
| 557 } | |
| 558 #endif | |
| 559 | |
| 534 // Error cases are all handled by LOG(FATAL) messages. So there is not really | 560 // Error cases are all handled by LOG(FATAL) messages. So there is not really |
| 535 // a case that returns false. In case we failed to create a verifier profile, | 561 // a case that returns false. In case we failed to create a verifier profile, |
| 536 // any call to the verifier() would fail. | 562 // any call to the verifier() would fail. |
| 537 return true; | 563 return true; |
| 538 } | 564 } |
| 539 | 565 |
| 540 void SyncTest::InitializeProfile(int index, Profile* profile) { | 566 void SyncTest::InitializeProfile(int index, Profile* profile) { |
| 541 DCHECK(profile); | 567 DCHECK(profile); |
| 542 profiles_[index] = profile; | 568 profiles_[index] = profile; |
| 543 | 569 |
| (...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1181 bool SyncTest::ClearServerData(ProfileSyncServiceHarness* harness) { | 1207 bool SyncTest::ClearServerData(ProfileSyncServiceHarness* harness) { |
| 1182 // At this point our birthday is good. | 1208 // At this point our birthday is good. |
| 1183 base::RunLoop run_loop; | 1209 base::RunLoop run_loop; |
| 1184 harness->service()->ClearServerDataForTest(run_loop.QuitClosure()); | 1210 harness->service()->ClearServerDataForTest(run_loop.QuitClosure()); |
| 1185 run_loop.Run(); | 1211 run_loop.Run(); |
| 1186 | 1212 |
| 1187 // Our birthday is invalidated on the server here so restart sync to get | 1213 // Our birthday is invalidated on the server here so restart sync to get |
| 1188 // the new birthday from the server. | 1214 // the new birthday from the server. |
| 1189 return harness->RestartSyncService(); | 1215 return harness->RestartSyncService(); |
| 1190 } | 1216 } |
| OLD | NEW |