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

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

Issue 8638001: [Sync] Made some sync session member functions const (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix latent bug in StatusController Created 9 years, 1 month 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 v.push_back(16); 147 v.push_back(16);
148 status.set_unsynced_handles(v); 148 status.set_unsynced_handles(v);
149 EXPECT_EQ(16, v[0]); 149 EXPECT_EQ(16, v[0]);
150 } 150 }
151 151
152 TEST_F(StatusControllerTest, HasConflictingUpdates) { 152 TEST_F(StatusControllerTest, HasConflictingUpdates) {
153 StatusController status(routes_); 153 StatusController status(routes_);
154 EXPECT_FALSE(status.HasConflictingUpdates()); 154 EXPECT_FALSE(status.HasConflictingUpdates());
155 { 155 {
156 ScopedModelSafeGroupRestriction r(&status, GROUP_UI); 156 ScopedModelSafeGroupRestriction r(&status, GROUP_UI);
157 EXPECT_FALSE(status.update_progress().HasConflictingUpdates()); 157 EXPECT_FALSE(status.update_progress());
158 status.mutable_update_progress()->AddAppliedUpdate(SUCCESS, 158 status.mutable_update_progress()->AddAppliedUpdate(SUCCESS,
159 syncable::Id()); 159 syncable::Id());
160 status.mutable_update_progress()->AddAppliedUpdate(CONFLICT, 160 status.mutable_update_progress()->AddAppliedUpdate(CONFLICT,
161 syncable::Id()); 161 syncable::Id());
162 EXPECT_TRUE(status.update_progress().HasConflictingUpdates()); 162 EXPECT_TRUE(status.update_progress()->HasConflictingUpdates());
163 } 163 }
164 164
165 EXPECT_TRUE(status.HasConflictingUpdates()); 165 EXPECT_TRUE(status.HasConflictingUpdates());
166 166
167 { 167 {
168 ScopedModelSafeGroupRestriction r(&status, GROUP_PASSIVE); 168 ScopedModelSafeGroupRestriction r(&status, GROUP_PASSIVE);
169 EXPECT_FALSE(status.update_progress().HasConflictingUpdates()); 169 EXPECT_FALSE(status.update_progress());
170 } 170 }
171 } 171 }
172 172
173 TEST_F(StatusControllerTest, CountUpdates) { 173 TEST_F(StatusControllerTest, CountUpdates) {
174 StatusController status(routes_); 174 StatusController status(routes_);
175 EXPECT_EQ(0, status.CountUpdates()); 175 EXPECT_EQ(0, status.CountUpdates());
176 ClientToServerResponse* response(status.mutable_updates_response()); 176 ClientToServerResponse* response(status.mutable_updates_response());
177 sync_pb::SyncEntity* entity1 = response->mutable_get_updates()->add_entries(); 177 sync_pb::SyncEntity* entity1 = response->mutable_get_updates()->add_entries();
178 sync_pb::SyncEntity* entity2 = response->mutable_get_updates()->add_entries(); 178 sync_pb::SyncEntity* entity2 = response->mutable_get_updates()->add_entries();
179 ASSERT_TRUE(entity1 != NULL && entity2 != NULL); 179 ASSERT_TRUE(entity1 != NULL && entity2 != NULL);
180 EXPECT_EQ(2, status.CountUpdates()); 180 EXPECT_EQ(2, status.CountUpdates());
181 } 181 }
182 182
183 // Test TotalNumConflictingItems 183 // Test TotalNumConflictingItems
184 TEST_F(StatusControllerTest, TotalNumConflictingItems) { 184 TEST_F(StatusControllerTest, TotalNumConflictingItems) {
185 StatusController status(routes_); 185 StatusController status(routes_);
186 TestIdFactory f; 186 TestIdFactory f;
187 { 187 {
188 ScopedModelSafeGroupRestriction r(&status, GROUP_UI); 188 ScopedModelSafeGroupRestriction r(&status, GROUP_UI);
189 EXPECT_FALSE(status.conflict_progress());
189 status.mutable_conflict_progress()->AddConflictingItemById(f.NewLocalId()); 190 status.mutable_conflict_progress()->AddConflictingItemById(f.NewLocalId());
190 status.mutable_conflict_progress()->AddConflictingItemById(f.NewLocalId()); 191 status.mutable_conflict_progress()->AddConflictingItemById(f.NewLocalId());
191 EXPECT_EQ(2, status.conflict_progress().ConflictingItemsSize()); 192 EXPECT_EQ(2, status.conflict_progress()->ConflictingItemsSize());
192 } 193 }
193 EXPECT_EQ(2, status.TotalNumConflictingItems()); 194 EXPECT_EQ(2, status.TotalNumConflictingItems());
194 { 195 {
195 ScopedModelSafeGroupRestriction r(&status, GROUP_DB); 196 ScopedModelSafeGroupRestriction r(&status, GROUP_DB);
196 EXPECT_EQ(0, status.conflict_progress().ConflictingItemsSize()); 197 EXPECT_FALSE(status.conflict_progress());
197 status.mutable_conflict_progress()->AddConflictingItemById(f.NewLocalId()); 198 status.mutable_conflict_progress()->AddConflictingItemById(f.NewLocalId());
198 status.mutable_conflict_progress()->AddConflictingItemById(f.NewLocalId()); 199 status.mutable_conflict_progress()->AddConflictingItemById(f.NewLocalId());
199 EXPECT_EQ(2, status.conflict_progress().ConflictingItemsSize()); 200 EXPECT_EQ(2, status.conflict_progress()->ConflictingItemsSize());
200 } 201 }
201 EXPECT_EQ(4, status.TotalNumConflictingItems()); 202 EXPECT_EQ(4, status.TotalNumConflictingItems());
202 } 203 }
203 204
204 // Basic test that non group-restricted state accessors don't cause violations. 205 // Basic test that non group-restricted state accessors don't cause violations.
205 TEST_F(StatusControllerTest, Unrestricted) { 206 TEST_F(StatusControllerTest, Unrestricted) {
206 StatusController status(routes_); 207 StatusController status(routes_);
207 status.GetUnrestrictedUpdateProgress( 208 const UpdateProgress* progress =
208 GROUP_UI)->SuccessfullyAppliedUpdateCount(); 209 status.GetUnrestrictedUpdateProgress(GROUP_UI);
210 EXPECT_FALSE(progress);
209 status.mutable_commit_message(); 211 status.mutable_commit_message();
210 status.commit_response(); 212 status.commit_response();
211 status.mutable_commit_response(); 213 status.mutable_commit_response();
212 status.updates_response(); 214 status.updates_response();
213 status.mutable_updates_response(); 215 status.mutable_updates_response();
214 status.error(); 216 status.error();
215 status.syncer_status(); 217 status.syncer_status();
216 status.num_server_changes_remaining(); 218 status.num_server_changes_remaining();
217 status.commit_ids(); 219 status.commit_ids();
218 status.HasBookmarkCommitActivity(); 220 status.HasBookmarkCommitActivity();
219 status.download_updates_succeeded(); 221 status.download_updates_succeeded();
220 status.ServerSaysNothingMoreToDownload(); 222 status.ServerSaysNothingMoreToDownload();
221 status.group_restriction(); 223 status.group_restriction();
222 } 224 }
223 225
224 } // namespace sessions 226 } // namespace sessions
225 } // namespace browser_sync 227 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/sessions/status_controller.cc ('k') | chrome/browser/sync/sessions/sync_session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698