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

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

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

Powered by Google App Engine
This is Rietveld 408576698