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

Side by Side Diff: components/sync/engine_impl/syncer_unittest.cc

Issue 2916133002: [Sync] Support commit only types. (Closed)
Patch Set: Rebase again. Created 3 years, 6 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 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 #include "components/sync/engine_impl/syncer.h" 5 #include "components/sync/engine_impl/syncer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <limits> 10 #include <limits>
(...skipping 5070 matching lines...) Expand 10 before | Expand all | Expand 10 after
5081 5081
5082 { 5082 {
5083 syncable::ReadTransaction trans(FROM_HERE, directory()); 5083 syncable::ReadTransaction trans(FROM_HERE, directory());
5084 Entry root(&trans, GET_TYPE_ROOT, PREFERENCES); 5084 Entry root(&trans, GET_TYPE_ROOT, PREFERENCES);
5085 EXPECT_TRUE(root.good()); 5085 EXPECT_TRUE(root.good());
5086 } 5086 }
5087 5087
5088 EXPECT_TRUE(directory()->InitialSyncEndedForType(PREFERENCES)); 5088 EXPECT_TRUE(directory()->InitialSyncEndedForType(PREFERENCES));
5089 } 5089 }
5090 5090
5091 // Verify that commit only types are never requested in GetUpdates, but still
5092 // make it into the commit messages. Additionally, make sure failing GU types
5093 // are correctly removed before commit.
5094 TEST_F(SyncerTest, CommitOnlyTypes) {
5095 mock_server_->set_partial_failure(true);
5096 mock_server_->SetPartialFailureTypes(ModelTypeSet(PREFERENCES));
5097
5098 EnableDatatype(USER_EVENTS);
5099 {
5100 syncable::WriteTransaction trans(FROM_HERE, UNITTEST, directory());
5101
5102 MutableEntry pref(&trans, CREATE, PREFERENCES, ids_.root(), "name");
5103 ASSERT_TRUE(pref.good());
5104 pref.PutUniqueClientTag("tag1");
5105 pref.PutIsUnsynced(true);
5106
5107 MutableEntry ext(&trans, CREATE, EXTENSIONS, ids_.root(), "name");
5108 ASSERT_TRUE(ext.good());
5109 ext.PutUniqueClientTag("tag2");
5110 ext.PutIsUnsynced(true);
5111
5112 MutableEntry event(&trans, CREATE, USER_EVENTS, ids_.root(), "name");
5113 ASSERT_TRUE(event.good());
5114 event.PutUniqueClientTag("tag3");
5115 event.PutIsUnsynced(true);
5116 }
5117
5118 EXPECT_TRUE(SyncShareNudge());
5119
5120 ASSERT_EQ(2U, mock_server_->requests().size());
5121 ASSERT_TRUE(mock_server_->requests()[0].has_get_updates());
5122 // MockConnectionManager will ensure USER_EVENTS was not included in the GU.
5123 EXPECT_EQ(
5124 4, mock_server_->requests()[0].get_updates().from_progress_marker_size());
5125
5126 ASSERT_TRUE(mock_server_->requests()[1].has_commit());
5127 const sync_pb::CommitMessage commit = mock_server_->requests()[1].commit();
5128 EXPECT_EQ(2, commit.entries_size());
5129 EXPECT_TRUE(commit.entries(0).specifics().has_extension());
5130 EXPECT_TRUE(commit.entries(1).specifics().has_user_event());
5131 }
5132
5091 // Tests specifically related to bookmark (and therefore no client tags) sync 5133 // Tests specifically related to bookmark (and therefore no client tags) sync
5092 // logic. Entities without client tags have custom logic in parts of the code, 5134 // logic. Entities without client tags have custom logic in parts of the code,
5093 // and hence are not covered by e.g. the Undeletion tests below. 5135 // and hence are not covered by e.g. the Undeletion tests below.
5094 class SyncerBookmarksTest : public SyncerTest { 5136 class SyncerBookmarksTest : public SyncerTest {
5095 public: 5137 public:
5096 SyncerBookmarksTest() : metahandle_(syncable::kInvalidMetaHandle) {} 5138 SyncerBookmarksTest() : metahandle_(syncable::kInvalidMetaHandle) {}
5097 5139
5098 void Create() { 5140 void Create() {
5099 syncable::WriteTransaction trans(FROM_HERE, UNITTEST, directory()); 5141 syncable::WriteTransaction trans(FROM_HERE, UNITTEST, directory());
5100 MutableEntry bookmark(&trans, CREATE, BOOKMARKS, ids_.root(), "clientname"); 5142 MutableEntry bookmark(&trans, CREATE, BOOKMARKS, ids_.root(), "clientname");
(...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after
5910 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id); 5952 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id);
5911 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count); 5953 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count);
5912 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count); 5954 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count);
5913 } else { 5955 } else {
5914 EXPECT_TRUE(final_monitor_records.empty()) 5956 EXPECT_TRUE(final_monitor_records.empty())
5915 << "Should not restore records after successful bookmark commit."; 5957 << "Should not restore records after successful bookmark commit.";
5916 } 5958 }
5917 } 5959 }
5918 5960
5919 } // namespace syncer 5961 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/engine_impl/syncer.cc ('k') | components/sync/model/model_type_change_processor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698