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

Side by Side Diff: chrome/browser/sync/sessions/status_controller_unittest.cc

Issue 9305001: sync: Remove the remaining conflict sets code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review updates and renames Created 8 years, 10 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 | Annotate | Revision Log
OLDNEW
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 #include "chrome/browser/sync/sessions/sync_session.h" 5 #include "chrome/browser/sync/sessions/sync_session.h"
6 #include "chrome/browser/sync/test/engine/test_id_factory.h" 6 #include "chrome/browser/sync/test/engine/test_id_factory.h"
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 namespace browser_sync { 9 namespace browser_sync {
10 namespace sessions { 10 namespace sessions {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 status.set_invalid_store(false); 55 status.set_invalid_store(false);
56 EXPECT_TRUE(status.TestAndClearIsDirty()); 56 EXPECT_TRUE(status.TestAndClearIsDirty());
57 57
58 status.increment_num_successful_commits(); 58 status.increment_num_successful_commits();
59 EXPECT_TRUE(status.TestAndClearIsDirty()); 59 EXPECT_TRUE(status.TestAndClearIsDirty());
60 status.increment_num_successful_commits(); 60 status.increment_num_successful_commits();
61 EXPECT_TRUE(status.TestAndClearIsDirty()); 61 EXPECT_TRUE(status.TestAndClearIsDirty());
62 62
63 { 63 {
64 ScopedModelSafeGroupRestriction r(&status, GROUP_UI); 64 ScopedModelSafeGroupRestriction r(&status, GROUP_UI);
65 status.mutable_conflict_progress()->AddConflictingItemById(syncable::Id()); 65 status.mutable_conflict_progress()->
66 AddSimpleConflictingItemById(syncable::Id());
66 } 67 }
67 EXPECT_TRUE(status.TestAndClearIsDirty()); 68 EXPECT_TRUE(status.TestAndClearIsDirty());
68 69
69 std::vector<int64> v; 70 std::vector<int64> v;
70 v.push_back(1); 71 v.push_back(1);
71 status.set_unsynced_handles(v); 72 status.set_unsynced_handles(v);
72 EXPECT_TRUE(status.TestAndClearIsDirty()); 73 EXPECT_TRUE(status.TestAndClearIsDirty());
73 std::vector<int64> v2; 74 std::vector<int64> v2;
74 v2.push_back(1); 75 v2.push_back(1);
75 status.set_unsynced_handles(v2); 76 status.set_unsynced_handles(v2);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 } 145 }
145 146
146 TEST_F(StatusControllerTest, HasConflictingUpdates) { 147 TEST_F(StatusControllerTest, HasConflictingUpdates) {
147 StatusController status(routes_); 148 StatusController status(routes_);
148 EXPECT_FALSE(status.HasConflictingUpdates()); 149 EXPECT_FALSE(status.HasConflictingUpdates());
149 { 150 {
150 ScopedModelSafeGroupRestriction r(&status, GROUP_UI); 151 ScopedModelSafeGroupRestriction r(&status, GROUP_UI);
151 EXPECT_FALSE(status.update_progress()); 152 EXPECT_FALSE(status.update_progress());
152 status.mutable_update_progress()->AddAppliedUpdate(SUCCESS, 153 status.mutable_update_progress()->AddAppliedUpdate(SUCCESS,
153 syncable::Id()); 154 syncable::Id());
154 status.mutable_update_progress()->AddAppliedUpdate(CONFLICT, 155 status.mutable_update_progress()->AddAppliedUpdate(CONFLICT_ENCRYPTION,
Nicolas Zea 2012/02/02 21:53:41 Any reason you changed this? Should be valid as it
rlarocque 2012/02/03 22:31:15 When changing the HasConflictingUpdates() function
155 syncable::Id()); 156 syncable::Id());
156 EXPECT_TRUE(status.update_progress()->HasConflictingUpdates()); 157 EXPECT_TRUE(status.update_progress()->HasConflictingUpdates());
157 } 158 }
158 159
159 EXPECT_TRUE(status.HasConflictingUpdates()); 160 EXPECT_TRUE(status.HasConflictingUpdates());
160 161
161 { 162 {
162 ScopedModelSafeGroupRestriction r(&status, GROUP_PASSIVE); 163 ScopedModelSafeGroupRestriction r(&status, GROUP_PASSIVE);
163 EXPECT_FALSE(status.update_progress()); 164 EXPECT_FALSE(status.update_progress());
164 } 165 }
165 } 166 }
166 167
167 TEST_F(StatusControllerTest, CountUpdates) { 168 TEST_F(StatusControllerTest, CountUpdates) {
168 StatusController status(routes_); 169 StatusController status(routes_);
169 EXPECT_EQ(0, status.CountUpdates()); 170 EXPECT_EQ(0, status.CountUpdates());
170 ClientToServerResponse* response(status.mutable_updates_response()); 171 ClientToServerResponse* response(status.mutable_updates_response());
171 sync_pb::SyncEntity* entity1 = response->mutable_get_updates()->add_entries(); 172 sync_pb::SyncEntity* entity1 = response->mutable_get_updates()->add_entries();
172 sync_pb::SyncEntity* entity2 = response->mutable_get_updates()->add_entries(); 173 sync_pb::SyncEntity* entity2 = response->mutable_get_updates()->add_entries();
173 ASSERT_TRUE(entity1 != NULL && entity2 != NULL); 174 ASSERT_TRUE(entity1 != NULL && entity2 != NULL);
174 EXPECT_EQ(2, status.CountUpdates()); 175 EXPECT_EQ(2, status.CountUpdates());
175 } 176 }
176 177
177 // Test TotalNumConflictingItems 178 // Test TotalNumConflictingItems
178 TEST_F(StatusControllerTest, TotalNumConflictingItems) { 179 TEST_F(StatusControllerTest, TotalNumConflictingItems) {
179 StatusController status(routes_); 180 StatusController status(routes_);
180 TestIdFactory f; 181 TestIdFactory f;
181 { 182 {
182 ScopedModelSafeGroupRestriction r(&status, GROUP_UI); 183 ScopedModelSafeGroupRestriction r(&status, GROUP_UI);
183 EXPECT_FALSE(status.conflict_progress()); 184 EXPECT_FALSE(status.conflict_progress());
184 status.mutable_conflict_progress()->AddConflictingItemById(f.NewLocalId()); 185 status.mutable_conflict_progress()->
185 status.mutable_conflict_progress()->AddConflictingItemById(f.NewLocalId()); 186 AddSimpleConflictingItemById(f.NewLocalId());
186 EXPECT_EQ(2, status.conflict_progress()->ConflictingItemsSize()); 187 status.mutable_conflict_progress()->
188 AddSimpleConflictingItemById(f.NewLocalId());
189 EXPECT_EQ(2, status.conflict_progress()->SimpleConflictingItemsSize());
187 } 190 }
188 EXPECT_EQ(2, status.TotalNumConflictingItems()); 191 EXPECT_EQ(2, status.TotalNumConflictingItems());
189 { 192 {
190 ScopedModelSafeGroupRestriction r(&status, GROUP_DB); 193 ScopedModelSafeGroupRestriction r(&status, GROUP_DB);
191 EXPECT_FALSE(status.conflict_progress()); 194 EXPECT_FALSE(status.conflict_progress());
192 status.mutable_conflict_progress()->AddConflictingItemById(f.NewLocalId()); 195 status.mutable_conflict_progress()->
193 status.mutable_conflict_progress()->AddConflictingItemById(f.NewLocalId()); 196 AddSimpleConflictingItemById(f.NewLocalId());
194 EXPECT_EQ(2, status.conflict_progress()->ConflictingItemsSize()); 197 status.mutable_conflict_progress()->
198 AddSimpleConflictingItemById(f.NewLocalId());
199 EXPECT_EQ(2, status.conflict_progress()->SimpleConflictingItemsSize());
195 } 200 }
196 EXPECT_EQ(4, status.TotalNumConflictingItems()); 201 EXPECT_EQ(4, status.TotalNumConflictingItems());
197 } 202 }
198 203
199 // Basic test that non group-restricted state accessors don't cause violations. 204 // Basic test that non group-restricted state accessors don't cause violations.
200 TEST_F(StatusControllerTest, Unrestricted) { 205 TEST_F(StatusControllerTest, Unrestricted) {
201 StatusController status(routes_); 206 StatusController status(routes_);
202 const UpdateProgress* progress = 207 const UpdateProgress* progress =
203 status.GetUnrestrictedUpdateProgress(GROUP_UI); 208 status.GetUnrestrictedUpdateProgress(GROUP_UI);
204 EXPECT_FALSE(progress); 209 EXPECT_FALSE(progress);
205 status.mutable_commit_message(); 210 status.mutable_commit_message();
206 status.commit_response(); 211 status.commit_response();
207 status.mutable_commit_response(); 212 status.mutable_commit_response();
208 status.updates_response(); 213 status.updates_response();
209 status.mutable_updates_response(); 214 status.mutable_updates_response();
210 status.error(); 215 status.error();
211 status.syncer_status(); 216 status.syncer_status();
212 status.num_server_changes_remaining(); 217 status.num_server_changes_remaining();
213 status.commit_ids(); 218 status.commit_ids();
214 status.HasBookmarkCommitActivity(); 219 status.HasBookmarkCommitActivity();
215 status.download_updates_succeeded(); 220 status.download_updates_succeeded();
216 status.ServerSaysNothingMoreToDownload(); 221 status.ServerSaysNothingMoreToDownload();
217 status.group_restriction(); 222 status.group_restriction();
218 } 223 }
219 224
220 } // namespace sessions 225 } // namespace sessions
221 } // namespace browser_sync 226 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698