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 #include "components/autofill/core/browser/webdata/autocomplete_sync_bridge.h" | 5 #include "components/autofill/core/browser/webdata/autocomplete_sync_bridge.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/files/scoped_temp_dir.h" | 13 #include "base/files/scoped_temp_dir.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
16 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
17 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
18 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
| 19 #include "base/test/scoped_task_environment.h" |
19 #include "base/threading/thread_task_runner_handle.h" | 20 #include "base/threading/thread_task_runner_handle.h" |
20 #include "base/time/time.h" | 21 #include "base/time/time.h" |
21 #include "components/autofill/core/browser/webdata/autofill_entry.h" | 22 #include "components/autofill/core/browser/webdata/autofill_entry.h" |
22 #include "components/autofill/core/browser/webdata/autofill_table.h" | 23 #include "components/autofill/core/browser/webdata/autofill_table.h" |
23 #include "components/autofill/core/browser/webdata/autofill_webdata_backend.h" | 24 #include "components/autofill/core/browser/webdata/autofill_webdata_backend.h" |
24 #include "components/autofill/core/browser/webdata/autofill_webdata_backend_impl
.h" | 25 #include "components/autofill/core/browser/webdata/autofill_webdata_backend_impl
.h" |
25 #include "components/sync/model/data_batch.h" | 26 #include "components/sync/model/data_batch.h" |
26 #include "components/sync/model/metadata_batch.h" | 27 #include "components/sync/model/metadata_batch.h" |
27 #include "components/sync/model/model_error.h" | 28 #include "components/sync/model/model_error.h" |
28 #include "components/sync/model/recording_model_type_change_processor.h" | 29 #include "components/sync/model/recording_model_type_change_processor.h" |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 std::unique_ptr<syncer::ModelTypeChangeProcessor> | 270 std::unique_ptr<syncer::ModelTypeChangeProcessor> |
270 CreateModelTypeChangeProcessor(syncer::ModelType type, | 271 CreateModelTypeChangeProcessor(syncer::ModelType type, |
271 syncer::ModelTypeSyncBridge* bridge) { | 272 syncer::ModelTypeSyncBridge* bridge) { |
272 auto processor = | 273 auto processor = |
273 base::MakeUnique<syncer::RecordingModelTypeChangeProcessor>(); | 274 base::MakeUnique<syncer::RecordingModelTypeChangeProcessor>(); |
274 processor_ = processor.get(); | 275 processor_ = processor.get(); |
275 return std::move(processor); | 276 return std::move(processor); |
276 } | 277 } |
277 | 278 |
278 ScopedTempDir temp_dir_; | 279 ScopedTempDir temp_dir_; |
279 base::MessageLoop message_loop_; | 280 base::test::ScopedTaskEnvironment scoped_task_environment_; |
280 FakeAutofillBackend backend_; | 281 FakeAutofillBackend backend_; |
281 AutofillTable table_; | 282 AutofillTable table_; |
282 WebDatabase db_; | 283 WebDatabase db_; |
283 std::unique_ptr<AutocompleteSyncBridge> bridge_; | 284 std::unique_ptr<AutocompleteSyncBridge> bridge_; |
284 // A non-owning pointer to the processor given to the bridge. Will be null | 285 // A non-owning pointer to the processor given to the bridge. Will be null |
285 // before being given to the bridge, to make ownership easier. | 286 // before being given to the bridge, to make ownership easier. |
286 syncer::RecordingModelTypeChangeProcessor* processor_ = nullptr; | 287 syncer::RecordingModelTypeChangeProcessor* processor_ = nullptr; |
287 | 288 |
288 DISALLOW_COPY_AND_ASSIGN(AutocompleteSyncBridgeTest); | 289 DISALLOW_COPY_AND_ASSIGN(AutocompleteSyncBridgeTest); |
289 }; | 290 }; |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
680 VerifyMerge({remote2, specifics3, remote4}); | 681 VerifyMerge({remote2, specifics3, remote4}); |
681 | 682 |
682 VerifyAllData({local1, remote2, specifics3, merged4}); | 683 VerifyAllData({local1, remote2, specifics3, merged4}); |
683 EXPECT_EQ(2u, processor()->put_multimap().size()); | 684 EXPECT_EQ(2u, processor()->put_multimap().size()); |
684 VerifyProcessorRecordedPut(local1); | 685 VerifyProcessorRecordedPut(local1); |
685 VerifyProcessorRecordedPut(merged4); | 686 VerifyProcessorRecordedPut(merged4); |
686 EXPECT_EQ(0u, processor()->delete_set().size()); | 687 EXPECT_EQ(0u, processor()->delete_set().size()); |
687 } | 688 } |
688 | 689 |
689 } // namespace autofill | 690 } // namespace autofill |
OLD | NEW |