OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 // Syncer unit tests. Unfortunately a lot of these tests | 5 // Syncer unit tests. Unfortunately a lot of these tests |
6 // are outdated and need to be reworked and updated. | 6 // are outdated and need to be reworked and updated. |
7 | 7 |
| 8 #include "sync/engine/syncer.h" |
| 9 |
8 #include <stddef.h> | 10 #include <stddef.h> |
9 #include <stdint.h> | 11 #include <stdint.h> |
10 | 12 |
11 #include <algorithm> | 13 #include <algorithm> |
12 #include <limits> | 14 #include <limits> |
13 #include <list> | 15 #include <list> |
14 #include <map> | 16 #include <map> |
| 17 #include <memory> |
15 #include <set> | 18 #include <set> |
16 #include <string> | 19 #include <string> |
17 | 20 |
18 #include "base/bind.h" | 21 #include "base/bind.h" |
19 #include "base/bind_helpers.h" | 22 #include "base/bind_helpers.h" |
20 #include "base/callback.h" | 23 #include "base/callback.h" |
21 #include "base/compiler_specific.h" | 24 #include "base/compiler_specific.h" |
22 #include "base/location.h" | 25 #include "base/location.h" |
23 #include "base/macros.h" | 26 #include "base/macros.h" |
24 #include "base/memory/scoped_ptr.h" | |
25 #include "base/message_loop/message_loop.h" | 27 #include "base/message_loop/message_loop.h" |
26 #include "base/strings/string_number_conversions.h" | 28 #include "base/strings/string_number_conversions.h" |
27 #include "base/test/histogram_tester.h" | 29 #include "base/test/histogram_tester.h" |
28 #include "base/time/time.h" | 30 #include "base/time/time.h" |
29 #include "build/build_config.h" | 31 #include "build/build_config.h" |
30 #include "sync/engine/backoff_delay_provider.h" | 32 #include "sync/engine/backoff_delay_provider.h" |
31 #include "sync/engine/get_commit_ids.h" | 33 #include "sync/engine/get_commit_ids.h" |
32 #include "sync/engine/net/server_connection_manager.h" | 34 #include "sync/engine/net/server_connection_manager.h" |
33 #include "sync/engine/sync_scheduler_impl.h" | 35 #include "sync/engine/sync_scheduler_impl.h" |
34 #include "sync/engine/syncer.h" | |
35 #include "sync/engine/syncer_proto_util.h" | 36 #include "sync/engine/syncer_proto_util.h" |
36 #include "sync/internal_api/public/base/cancelation_signal.h" | 37 #include "sync/internal_api/public/base/cancelation_signal.h" |
37 #include "sync/internal_api/public/base/model_type.h" | 38 #include "sync/internal_api/public/base/model_type.h" |
38 #include "sync/internal_api/public/engine/model_safe_worker.h" | 39 #include "sync/internal_api/public/engine/model_safe_worker.h" |
39 #include "sync/internal_api/public/sessions/commit_counters.h" | 40 #include "sync/internal_api/public/sessions/commit_counters.h" |
40 #include "sync/internal_api/public/sessions/status_counters.h" | 41 #include "sync/internal_api/public/sessions/status_counters.h" |
41 #include "sync/internal_api/public/sessions/update_counters.h" | 42 #include "sync/internal_api/public/sessions/update_counters.h" |
42 #include "sync/protocol/bookmark_specifics.pb.h" | 43 #include "sync/protocol/bookmark_specifics.pb.h" |
43 #include "sync/protocol/nigori_specifics.pb.h" | 44 #include "sync/protocol/nigori_specifics.pb.h" |
44 #include "sync/protocol/preference_specifics.pb.h" | 45 #include "sync/protocol/preference_specifics.pb.h" |
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 // more confusing. | 578 // more confusing. |
578 syncable::Id root_id_; | 579 syncable::Id root_id_; |
579 syncable::Id parent_id_; | 580 syncable::Id parent_id_; |
580 syncable::Id child_id_; | 581 syncable::Id child_id_; |
581 | 582 |
582 TestIdFactory ids_; | 583 TestIdFactory ids_; |
583 | 584 |
584 TestDirectorySetterUpper dir_maker_; | 585 TestDirectorySetterUpper dir_maker_; |
585 FakeEncryptor encryptor_; | 586 FakeEncryptor encryptor_; |
586 scoped_refptr<ExtensionsActivity> extensions_activity_; | 587 scoped_refptr<ExtensionsActivity> extensions_activity_; |
587 scoped_ptr<MockConnectionManager> mock_server_; | 588 std::unique_ptr<MockConnectionManager> mock_server_; |
588 CancelationSignal cancelation_signal_; | 589 CancelationSignal cancelation_signal_; |
589 | 590 |
590 Syncer* syncer_; | 591 Syncer* syncer_; |
591 | 592 |
592 scoped_ptr<SyncSession> session_; | 593 std::unique_ptr<SyncSession> session_; |
593 TypeDebugInfoCache debug_info_cache_; | 594 TypeDebugInfoCache debug_info_cache_; |
594 MockNudgeHandler mock_nudge_handler_; | 595 MockNudgeHandler mock_nudge_handler_; |
595 scoped_ptr<ModelTypeRegistry> model_type_registry_; | 596 std::unique_ptr<ModelTypeRegistry> model_type_registry_; |
596 scoped_ptr<SyncSchedulerImpl> scheduler_; | 597 std::unique_ptr<SyncSchedulerImpl> scheduler_; |
597 scoped_ptr<SyncSessionContext> context_; | 598 std::unique_ptr<SyncSessionContext> context_; |
598 base::TimeDelta last_short_poll_interval_received_; | 599 base::TimeDelta last_short_poll_interval_received_; |
599 base::TimeDelta last_long_poll_interval_received_; | 600 base::TimeDelta last_long_poll_interval_received_; |
600 base::TimeDelta last_sessions_commit_delay_; | 601 base::TimeDelta last_sessions_commit_delay_; |
601 base::TimeDelta last_bookmarks_commit_delay_; | 602 base::TimeDelta last_bookmarks_commit_delay_; |
602 int last_client_invalidation_hint_buffer_size_; | 603 int last_client_invalidation_hint_buffer_size_; |
603 std::vector<scoped_refptr<ModelSafeWorker> > workers_; | 604 std::vector<scoped_refptr<ModelSafeWorker> > workers_; |
604 | 605 |
605 ModelTypeSet enabled_datatypes_; | 606 ModelTypeSet enabled_datatypes_; |
606 sessions::NudgeTracker nudge_tracker_; | 607 sessions::NudgeTracker nudge_tracker_; |
607 scoped_ptr<MockDebugInfoGetter> debug_info_getter_; | 608 std::unique_ptr<MockDebugInfoGetter> debug_info_getter_; |
608 | 609 |
609 private: | 610 private: |
610 DISALLOW_COPY_AND_ASSIGN(SyncerTest); | 611 DISALLOW_COPY_AND_ASSIGN(SyncerTest); |
611 }; | 612 }; |
612 | 613 |
613 TEST_F(SyncerTest, TestCallGatherUnsyncedEntries) { | 614 TEST_F(SyncerTest, TestCallGatherUnsyncedEntries) { |
614 { | 615 { |
615 Syncer::UnsyncedMetaHandles handles; | 616 Syncer::UnsyncedMetaHandles handles; |
616 { | 617 { |
617 syncable::ReadTransaction trans(FROM_HERE, directory()); | 618 syncable::ReadTransaction trans(FROM_HERE, directory()); |
(...skipping 5279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5897 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id); | 5898 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id); |
5898 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count); | 5899 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count); |
5899 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count); | 5900 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count); |
5900 } else { | 5901 } else { |
5901 EXPECT_TRUE(final_monitor_records.empty()) | 5902 EXPECT_TRUE(final_monitor_records.empty()) |
5902 << "Should not restore records after successful bookmark commit."; | 5903 << "Should not restore records after successful bookmark commit."; |
5903 } | 5904 } |
5904 } | 5905 } |
5905 | 5906 |
5906 } // namespace syncer | 5907 } // namespace syncer |
OLD | NEW |