| 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 // Unit tests for the SyncApi. Note that a lot of the underlying | 5 // Unit tests for the SyncApi. Note that a lot of the underlying |
| 6 // functionality is provided by the Syncable layer, which has its own | 6 // functionality is provided by the Syncable layer, which has its own |
| 7 // unit tests. We'll test SyncApi specific things in this harness. | 7 // unit tests. We'll test SyncApi specific things in this harness. |
| 8 | 8 |
| 9 #include <cstddef> | 9 #include <cstddef> |
| 10 #include <map> | 10 #include <map> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 15 #include "base/format_macros.h" | 15 #include "base/format_macros.h" |
| 16 #include "base/location.h" | 16 #include "base/location.h" |
| 17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
| 18 #include "base/message_loop.h" | 18 #include "base/message_loop.h" |
| 19 #include "base/message_loop_proxy.h" | 19 #include "base/message_loop_proxy.h" |
| 20 #include "base/scoped_temp_dir.h" | 20 #include "base/scoped_temp_dir.h" |
| 21 #include "base/string_number_conversions.h" | 21 #include "base/string_number_conversions.h" |
| 22 #include "base/stringprintf.h" | 22 #include "base/stringprintf.h" |
| 23 #include "base/test/values_test_util.h" | 23 #include "base/test/values_test_util.h" |
| 24 #include "base/utf_string_conversions.h" | 24 #include "base/utf_string_conversions.h" |
| 25 #include "base/values.h" | 25 #include "base/values.h" |
| 26 #include "sync/engine/sync_scheduler.h" |
| 26 #include "sync/internal_api/public/base/model_type_test_util.h" | 27 #include "sync/internal_api/public/base/model_type_test_util.h" |
| 27 #include "sync/engine/sync_scheduler.h" | |
| 28 #include "sync/internal_api/public/change_record.h" | 28 #include "sync/internal_api/public/change_record.h" |
| 29 #include "sync/internal_api/public/engine/model_safe_worker.h" | 29 #include "sync/internal_api/public/engine/model_safe_worker.h" |
| 30 #include "sync/internal_api/public/engine/polling_constants.h" | 30 #include "sync/internal_api/public/engine/polling_constants.h" |
| 31 #include "sync/internal_api/public/http_post_provider_factory.h" | 31 #include "sync/internal_api/public/http_post_provider_factory.h" |
| 32 #include "sync/internal_api/public/http_post_provider_interface.h" | 32 #include "sync/internal_api/public/http_post_provider_interface.h" |
| 33 #include "sync/internal_api/public/read_node.h" | 33 #include "sync/internal_api/public/read_node.h" |
| 34 #include "sync/internal_api/public/read_transaction.h" | 34 #include "sync/internal_api/public/read_transaction.h" |
| 35 #include "sync/internal_api/public/test/test_internal_components_factory.h" | 35 #include "sync/internal_api/public/test/test_internal_components_factory.h" |
| 36 #include "sync/internal_api/public/test/test_user_share.h" | 36 #include "sync/internal_api/public/test/test_user_share.h" |
| 37 #include "sync/internal_api/public/write_node.h" | 37 #include "sync/internal_api/public/write_node.h" |
| 38 #include "sync/internal_api/public/write_transaction.h" | 38 #include "sync/internal_api/public/write_transaction.h" |
| 39 #include "sync/internal_api/sync_manager_impl.h" |
| 39 #include "sync/internal_api/syncapi_internal.h" | 40 #include "sync/internal_api/syncapi_internal.h" |
| 40 #include "sync/internal_api/sync_manager_impl.h" | |
| 41 #include "sync/js/js_arg_list.h" | 41 #include "sync/js/js_arg_list.h" |
| 42 #include "sync/js/js_backend.h" | 42 #include "sync/js/js_backend.h" |
| 43 #include "sync/js/js_event_handler.h" | 43 #include "sync/js/js_event_handler.h" |
| 44 #include "sync/js/js_reply_handler.h" | 44 #include "sync/js/js_reply_handler.h" |
| 45 #include "sync/js/js_test_util.h" | 45 #include "sync/js/js_test_util.h" |
| 46 #include "sync/notifier/sync_notifier.h" | 46 #include "sync/notifier/sync_notifier.h" |
| 47 #include "sync/notifier/sync_notifier_observer.h" | 47 #include "sync/notifier/sync_notifier_observer.h" |
| 48 #include "sync/protocol/bookmark_specifics.pb.h" | 48 #include "sync/protocol/bookmark_specifics.pb.h" |
| 49 #include "sync/protocol/encryption.pb.h" | 49 #include "sync/protocol/encryption.pb.h" |
| 50 #include "sync/protocol/extension_specifics.pb.h" | 50 #include "sync/protocol/extension_specifics.pb.h" |
| 51 #include "sync/protocol/password_specifics.pb.h" | 51 #include "sync/protocol/password_specifics.pb.h" |
| 52 #include "sync/protocol/preference_specifics.pb.h" | 52 #include "sync/protocol/preference_specifics.pb.h" |
| 53 #include "sync/protocol/proto_value_conversions.h" | 53 #include "sync/protocol/proto_value_conversions.h" |
| 54 #include "sync/protocol/sync.pb.h" | 54 #include "sync/protocol/sync.pb.h" |
| 55 #include "sync/sessions/sync_session.h" | 55 #include "sync/sessions/sync_session.h" |
| 56 #include "sync/syncable/directory.h" | 56 #include "sync/syncable/directory.h" |
| 57 #include "sync/syncable/entry.h" | 57 #include "sync/syncable/entry.h" |
| 58 #include "sync/syncable/mutable_entry.h" | 58 #include "sync/syncable/mutable_entry.h" |
| 59 #include "sync/syncable/nigori_util.h" | 59 #include "sync/syncable/nigori_util.h" |
| 60 #include "sync/syncable/syncable_id.h" | 60 #include "sync/syncable/syncable_id.h" |
| 61 #include "sync/syncable/write_transaction.h" | 61 #include "sync/syncable/write_transaction.h" |
| 62 #include "sync/test/callback_counter.h" | 62 #include "sync/test/callback_counter.h" |
| 63 #include "sync/test/engine/fake_sync_scheduler.h" |
| 63 #include "sync/test/fake_encryptor.h" | 64 #include "sync/test/fake_encryptor.h" |
| 64 #include "sync/test/fake_extensions_activity_monitor.h" | 65 #include "sync/test/fake_extensions_activity_monitor.h" |
| 65 #include "sync/test/engine/fake_sync_scheduler.h" | |
| 66 #include "sync/util/cryptographer.h" | 66 #include "sync/util/cryptographer.h" |
| 67 #include "sync/util/extensions_activity_monitor.h" | 67 #include "sync/util/extensions_activity_monitor.h" |
| 68 #include "sync/util/test_unrecoverable_error_handler.h" | 68 #include "sync/util/test_unrecoverable_error_handler.h" |
| 69 #include "sync/util/time.h" | 69 #include "sync/util/time.h" |
| 70 #include "testing/gmock/include/gmock/gmock.h" | 70 #include "testing/gmock/include/gmock/gmock.h" |
| 71 #include "testing/gtest/include/gtest/gtest.h" | 71 #include "testing/gtest/include/gtest/gtest.h" |
| 72 | 72 |
| 73 using base::ExpectDictStringValue; | 73 using base::ExpectDictStringValue; |
| 74 using testing::_; | 74 using testing::_; |
| 75 using testing::AnyNumber; | 75 using testing::AnyNumber; |
| (...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 956 TEST_F(SyncManagerTest, UpdateEnabledTypes) { | 956 TEST_F(SyncManagerTest, UpdateEnabledTypes) { |
| 957 ModelSafeRoutingInfo routes; | 957 ModelSafeRoutingInfo routes; |
| 958 GetModelSafeRoutingInfo(&routes); | 958 GetModelSafeRoutingInfo(&routes); |
| 959 const ModelTypeSet enabled_types = GetRoutingInfoTypes(routes); | 959 const ModelTypeSet enabled_types = GetRoutingInfoTypes(routes); |
| 960 | 960 |
| 961 EXPECT_CALL(*sync_notifier_mock_, | 961 EXPECT_CALL(*sync_notifier_mock_, |
| 962 UpdateRegisteredIds(_, ModelTypeSetToObjectIdSet(enabled_types))); | 962 UpdateRegisteredIds(_, ModelTypeSetToObjectIdSet(enabled_types))); |
| 963 sync_manager_.UpdateEnabledTypes(enabled_types); | 963 sync_manager_.UpdateEnabledTypes(enabled_types); |
| 964 } | 964 } |
| 965 | 965 |
| 966 TEST_F(SyncManagerTest, UpdateRegisteredIds) { |
| 967 EXPECT_CALL(*sync_notifier_mock_, UpdateRegisteredIds(NULL, ObjectIdSet())); |
| 968 sync_manager_.UpdateRegisteredIds(NULL, ObjectIdSet()); |
| 969 } |
| 970 |
| 966 TEST_F(SyncManagerTest, ProcessJsMessage) { | 971 TEST_F(SyncManagerTest, ProcessJsMessage) { |
| 967 const JsArgList kNoArgs; | 972 const JsArgList kNoArgs; |
| 968 | 973 |
| 969 StrictMock<MockJsReplyHandler> reply_handler; | 974 StrictMock<MockJsReplyHandler> reply_handler; |
| 970 | 975 |
| 971 ListValue false_args; | 976 ListValue false_args; |
| 972 false_args.Append(Value::CreateBooleanValue(false)); | 977 false_args.Append(Value::CreateBooleanValue(false)); |
| 973 | 978 |
| 974 EXPECT_CALL(reply_handler, | 979 EXPECT_CALL(reply_handler, |
| 975 HandleJsReply("getNotificationState", | 980 HandleJsReply("getNotificationState", |
| (...skipping 1801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2777 | 2782 |
| 2778 // Verify only the non-disabled types remain after cleanup. | 2783 // Verify only the non-disabled types remain after cleanup. |
| 2779 sync_manager_.PurgeDisabledTypes(enabled_types, new_enabled_types); | 2784 sync_manager_.PurgeDisabledTypes(enabled_types, new_enabled_types); |
| 2780 EXPECT_TRUE(new_enabled_types.Equals( | 2785 EXPECT_TRUE(new_enabled_types.Equals( |
| 2781 Union(sync_manager_.InitialSyncEndedTypes(), partial_enabled_types))); | 2786 Union(sync_manager_.InitialSyncEndedTypes(), partial_enabled_types))); |
| 2782 EXPECT_TRUE(disabled_types.Equals( | 2787 EXPECT_TRUE(disabled_types.Equals( |
| 2783 sync_manager_.GetTypesWithEmptyProgressMarkerToken(ModelTypeSet::All()))); | 2788 sync_manager_.GetTypesWithEmptyProgressMarkerToken(ModelTypeSet::All()))); |
| 2784 } | 2789 } |
| 2785 | 2790 |
| 2786 } // namespace | 2791 } // namespace |
| OLD | NEW |