| 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> |
| (...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 874 syncable::MutableEntry entry(&trans, syncable::GET_BY_CLIENT_TAG, | 874 syncable::MutableEntry entry(&trans, syncable::GET_BY_CLIENT_TAG, |
| 875 hash); | 875 hash); |
| 876 EXPECT_TRUE(entry.good()); | 876 EXPECT_TRUE(entry.good()); |
| 877 if (!entry.Get(IS_UNSYNCED)) | 877 if (!entry.Get(IS_UNSYNCED)) |
| 878 return false; | 878 return false; |
| 879 entry.Put(IS_UNSYNCED, false); | 879 entry.Put(IS_UNSYNCED, false); |
| 880 return true; | 880 return true; |
| 881 } | 881 } |
| 882 | 882 |
| 883 virtual InternalComponentsFactory* GetFactory() { | 883 virtual InternalComponentsFactory* GetFactory() { |
| 884 return new TestInternalComponentsFactory( | 884 return new TestInternalComponentsFactory(STORAGE_IN_MEMORY); |
| 885 TestInternalComponentsFactory::IN_MEMORY); | |
| 886 } | 885 } |
| 887 | 886 |
| 888 // Returns true if we are currently encrypting all sync data. May | 887 // Returns true if we are currently encrypting all sync data. May |
| 889 // be called on any thread. | 888 // be called on any thread. |
| 890 bool EncryptEverythingEnabledForTest() { | 889 bool EncryptEverythingEnabledForTest() { |
| 891 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); | 890 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); |
| 892 return trans.GetCryptographer()->encrypt_everything(); | 891 return trans.GetCryptographer()->encrypt_everything(); |
| 893 } | 892 } |
| 894 | 893 |
| 895 // Gets the set of encrypted types from the cryptographer | 894 // Gets the set of encrypted types from the cryptographer |
| (...skipping 1618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2514 | 2513 |
| 2515 MOCK_METHOD1(Start, void(SyncScheduler::Mode)); | 2514 MOCK_METHOD1(Start, void(SyncScheduler::Mode)); |
| 2516 MOCK_METHOD1(ScheduleConfiguration, bool(const ConfigurationParams&)); | 2515 MOCK_METHOD1(ScheduleConfiguration, bool(const ConfigurationParams&)); |
| 2517 }; | 2516 }; |
| 2518 | 2517 |
| 2519 class ComponentsFactory : public TestInternalComponentsFactory { | 2518 class ComponentsFactory : public TestInternalComponentsFactory { |
| 2520 public: | 2519 public: |
| 2521 ComponentsFactory(SyncScheduler* scheduler_to_use, | 2520 ComponentsFactory(SyncScheduler* scheduler_to_use, |
| 2522 sessions::SyncSessionContext** session_context) | 2521 sessions::SyncSessionContext** session_context) |
| 2523 : TestInternalComponentsFactory( | 2522 : TestInternalComponentsFactory( |
| 2524 TestInternalComponentsFactory::IN_MEMORY), | 2523 syncer::STORAGE_IN_MEMORY), |
| 2525 scheduler_to_use_(scheduler_to_use), | 2524 scheduler_to_use_(scheduler_to_use), |
| 2526 session_context_(session_context) {} | 2525 session_context_(session_context) {} |
| 2527 virtual ~ComponentsFactory() {} | 2526 virtual ~ComponentsFactory() {} |
| 2528 | 2527 |
| 2529 virtual scoped_ptr<SyncScheduler> BuildScheduler( | 2528 virtual scoped_ptr<SyncScheduler> BuildScheduler( |
| 2530 const std::string& name, | 2529 const std::string& name, |
| 2531 sessions::SyncSessionContext* context) OVERRIDE { | 2530 sessions::SyncSessionContext* context) OVERRIDE { |
| 2532 *session_context_ = context; | 2531 *session_context_ = context; |
| 2533 return scheduler_to_use_.Pass(); | 2532 return scheduler_to_use_.Pass(); |
| 2534 } | 2533 } |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2777 | 2776 |
| 2778 // Verify only the non-disabled types remain after cleanup. | 2777 // Verify only the non-disabled types remain after cleanup. |
| 2779 sync_manager_.PurgeDisabledTypes(enabled_types, new_enabled_types); | 2778 sync_manager_.PurgeDisabledTypes(enabled_types, new_enabled_types); |
| 2780 EXPECT_TRUE(new_enabled_types.Equals( | 2779 EXPECT_TRUE(new_enabled_types.Equals( |
| 2781 Union(sync_manager_.InitialSyncEndedTypes(), partial_enabled_types))); | 2780 Union(sync_manager_.InitialSyncEndedTypes(), partial_enabled_types))); |
| 2782 EXPECT_TRUE(disabled_types.Equals( | 2781 EXPECT_TRUE(disabled_types.Equals( |
| 2783 sync_manager_.GetTypesWithEmptyProgressMarkerToken(ModelTypeSet::All()))); | 2782 sync_manager_.GetTypesWithEmptyProgressMarkerToken(ModelTypeSet::All()))); |
| 2784 } | 2783 } |
| 2785 | 2784 |
| 2786 } // namespace | 2785 } // namespace |
| OLD | NEW |