Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(143)

Side by Side Diff: components/sync_driver/glue/sync_backend_host_impl_unittest.cc

Issue 1549993003: Switch to standard integer types in components/, part 4 of 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/sync_driver/glue/sync_backend_host_impl.h" 5 #include "components/sync_driver/glue/sync_backend_host_impl.h"
6 6
7 #include <stdint.h>
8
7 #include <cstddef> 9 #include <cstddef>
8 #include <map> 10 #include <map>
9 11
10 #include "base/files/file_util.h" 12 #include "base/files/file_util.h"
11 #include "base/files/scoped_temp_dir.h" 13 #include "base/files/scoped_temp_dir.h"
12 #include "base/location.h" 14 #include "base/location.h"
13 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
14 #include "base/message_loop/message_loop.h" 16 #include "base/message_loop/message_loop.h"
15 #include "base/run_loop.h" 17 #include "base/run_loop.h"
16 #include "base/synchronization/waitable_event.h" 18 #include "base/synchronization/waitable_event.h"
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 backend_->ClearServerData(base::Bind(&syncer::CallbackCounter::Callback, 790 backend_->ClearServerData(base::Bind(&syncer::CallbackCounter::Callback,
789 base::Unretained(&callback_counter))); 791 base::Unretained(&callback_counter)));
790 fake_manager_->WaitForSyncThread(); 792 fake_manager_->WaitForSyncThread();
791 EXPECT_EQ(1, callback_counter.times_called()); 793 EXPECT_EQ(1, callback_counter.times_called());
792 } 794 }
793 795
794 // Ensure that redundant invalidations are ignored and that the most recent 796 // Ensure that redundant invalidations are ignored and that the most recent
795 // set of invalidation version is persisted across restarts. 797 // set of invalidation version is persisted across restarts.
796 TEST_F(SyncBackendHostTest, IgnoreOldInvalidations) { 798 TEST_F(SyncBackendHostTest, IgnoreOldInvalidations) {
797 // Set up some old persisted invalidations. 799 // Set up some old persisted invalidations.
798 std::map<syncer::ModelType, int64> invalidation_versions; 800 std::map<syncer::ModelType, int64_t> invalidation_versions;
799 invalidation_versions[syncer::BOOKMARKS] = 20; 801 invalidation_versions[syncer::BOOKMARKS] = 20;
800 sync_prefs_->UpdateInvalidationVersions(invalidation_versions); 802 sync_prefs_->UpdateInvalidationVersions(invalidation_versions);
801 InitializeBackend(true); 803 InitializeBackend(true);
802 EXPECT_EQ(0, fake_manager_->GetInvalidationCount()); 804 EXPECT_EQ(0, fake_manager_->GetInvalidationCount());
803 805
804 // Receiving an invalidation with an old version should do nothing. 806 // Receiving an invalidation with an old version should do nothing.
805 syncer::ObjectIdInvalidationMap invalidation_map; 807 syncer::ObjectIdInvalidationMap invalidation_map;
806 std::string notification_type; 808 std::string notification_type;
807 syncer::RealModelTypeToNotificationType(syncer::BOOKMARKS, 809 syncer::RealModelTypeToNotificationType(syncer::BOOKMARKS,
808 &notification_type); 810 &notification_type);
(...skipping 27 matching lines...) Expand all
836 // acted on, but should not affect the persisted versions. 838 // acted on, but should not affect the persisted versions.
837 invalidation_map.Insert(syncer::Invalidation::InitUnknownVersion( 839 invalidation_map.Insert(syncer::Invalidation::InitUnknownVersion(
838 invalidation::ObjectId(0, notification_type))); 840 invalidation::ObjectId(0, notification_type)));
839 backend_->OnIncomingInvalidation(invalidation_map); 841 backend_->OnIncomingInvalidation(invalidation_map);
840 fake_manager_->WaitForSyncThread(); 842 fake_manager_->WaitForSyncThread();
841 EXPECT_EQ(3, fake_manager_->GetInvalidationCount()); 843 EXPECT_EQ(3, fake_manager_->GetInvalidationCount());
842 844
843 // Verify that the invalidation versions were updated in the prefs. 845 // Verify that the invalidation versions were updated in the prefs.
844 invalidation_versions[syncer::BOOKMARKS] = 30; 846 invalidation_versions[syncer::BOOKMARKS] = 30;
845 invalidation_versions[syncer::SESSIONS] = 10; 847 invalidation_versions[syncer::SESSIONS] = 10;
846 std::map<syncer::ModelType, int64> persisted_invalidation_versions; 848 std::map<syncer::ModelType, int64_t> persisted_invalidation_versions;
847 sync_prefs_->GetInvalidationVersions(&persisted_invalidation_versions); 849 sync_prefs_->GetInvalidationVersions(&persisted_invalidation_versions);
848 EXPECT_EQ(invalidation_versions.size(), 850 EXPECT_EQ(invalidation_versions.size(),
849 persisted_invalidation_versions.size()); 851 persisted_invalidation_versions.size());
850 for (auto iter : persisted_invalidation_versions) { 852 for (auto iter : persisted_invalidation_versions) {
851 EXPECT_EQ(invalidation_versions[iter.first], iter.second); 853 EXPECT_EQ(invalidation_versions[iter.first], iter.second);
852 } 854 }
853 } 855 }
854 856
855 } // namespace 857 } // namespace
856 858
857 } // namespace browser_sync 859 } // namespace browser_sync
OLDNEW
« no previous file with comments | « components/sync_driver/glue/sync_backend_host_impl.cc ('k') | components/sync_driver/glue/sync_backend_registrar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698