| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #import "ios/chrome/test/app/sync_test_util.h" | 5 #import "ios/chrome/test/app/sync_test_util.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "components/sync/test/fake_server/unique_client_entity.h" | 27 #include "components/sync/test/fake_server/unique_client_entity.h" |
| 28 #include "ios/chrome/browser/autofill/personal_data_manager_factory.h" | 28 #include "ios/chrome/browser/autofill/personal_data_manager_factory.h" |
| 29 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" | 29 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" |
| 30 #include "ios/chrome/browser/history/history_service_factory.h" | 30 #include "ios/chrome/browser/history/history_service_factory.h" |
| 31 #include "ios/chrome/browser/sync/ios_chrome_profile_sync_service_factory.h" | 31 #include "ios/chrome/browser/sync/ios_chrome_profile_sync_service_factory.h" |
| 32 #include "ios/chrome/browser/sync/sync_setup_service.h" | 32 #include "ios/chrome/browser/sync/sync_setup_service.h" |
| 33 #include "ios/chrome/browser/sync/sync_setup_service_factory.h" | 33 #include "ios/chrome/browser/sync/sync_setup_service_factory.h" |
| 34 #import "ios/chrome/test/app/chrome_test_util.h" | 34 #import "ios/chrome/test/app/chrome_test_util.h" |
| 35 #include "testing/gtest/include/gtest/gtest.h" | 35 #include "testing/gtest/include/gtest/gtest.h" |
| 36 | 36 |
| 37 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 38 #error "This file requires ARC support." |
| 39 #endif |
| 40 |
| 37 namespace { | 41 namespace { |
| 38 | 42 |
| 39 fake_server::FakeServer* gSyncFakeServer = nullptr; | 43 fake_server::FakeServer* gSyncFakeServer = nullptr; |
| 40 | 44 |
| 41 NSString* const kSyncTestErrorDomain = @"SyncTestDomain"; | 45 NSString* const kSyncTestErrorDomain = @"SyncTestDomain"; |
| 42 | 46 |
| 43 // Overrides the network resources of the current ProfileSyncService with | 47 // Overrides the network resources of the current ProfileSyncService with |
| 44 // |resources|. | 48 // |resources|. |
| 45 void OverrideSyncNetworkResources( | 49 void OverrideSyncNetworkResources( |
| 46 std::unique_ptr<syncer::NetworkResources> resources) { | 50 std::unique_ptr<syncer::NetworkResources> resources) { |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 browser_state, ServiceAccessType::EXPLICIT_ACCESS); | 283 browser_state, ServiceAccessType::EXPLICIT_ACCESS); |
| 280 | 284 |
| 281 const GURL block_safe_url(url); | 285 const GURL block_safe_url(url); |
| 282 std::set<GURL> origins; | 286 std::set<GURL> origins; |
| 283 origins.insert(block_safe_url); | 287 origins.insert(block_safe_url); |
| 284 | 288 |
| 285 __block bool history_service_callback_called = false; | 289 __block bool history_service_callback_called = false; |
| 286 __block int count = 0; | 290 __block int count = 0; |
| 287 using history::OriginCountAndLastVisitMap; | 291 using history::OriginCountAndLastVisitMap; |
| 288 history_service->GetCountsAndLastVisitForOrigins( | 292 history_service->GetCountsAndLastVisitForOrigins( |
| 289 origins, base::BindBlock(^(const OriginCountAndLastVisitMap& result) { | 293 origins, base::BindBlockArc(^(const OriginCountAndLastVisitMap& result) { |
| 290 auto iter = result.find(block_safe_url); | 294 auto iter = result.find(block_safe_url); |
| 291 if (iter != result.end()) | 295 if (iter != result.end()) |
| 292 count = iter->second.first; | 296 count = iter->second.first; |
| 293 history_service_callback_called = true; | 297 history_service_callback_called = true; |
| 294 })); | 298 })); |
| 295 | 299 |
| 296 NSDate* deadline = [NSDate dateWithTimeIntervalSinceNow:4.0]; | 300 NSDate* deadline = [NSDate dateWithTimeIntervalSinceNow:4.0]; |
| 297 while (!history_service_callback_called && | 301 while (!history_service_callback_called && |
| 298 [[NSDate date] compare:deadline] != NSOrderedDescending) { | 302 [[NSDate date] compare:deadline] != NSOrderedDescending) { |
| 299 base::test::ios::SpinRunLoopWithMaxDelay( | 303 base::test::ios::SpinRunLoopWithMaxDelay( |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 } | 346 } |
| 343 } | 347 } |
| 344 if (!entity_id.empty()) { | 348 if (!entity_id.empty()) { |
| 345 std::unique_ptr<fake_server::FakeServerEntity> entity; | 349 std::unique_ptr<fake_server::FakeServerEntity> entity; |
| 346 entity = fake_server::TombstoneEntity::Create(entity_id, std::string()); | 350 entity = fake_server::TombstoneEntity::Create(entity_id, std::string()); |
| 347 gSyncFakeServer->InjectEntity(std::move(entity)); | 351 gSyncFakeServer->InjectEntity(std::move(entity)); |
| 348 } | 352 } |
| 349 } | 353 } |
| 350 | 354 |
| 351 } // namespace chrome_test_util | 355 } // namespace chrome_test_util |
| OLD | NEW |