| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/test/sync/engine/test_id_factory.h" | 6 #include "chrome/test/sync/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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 status.set_unsynced_handles(v2); | 96 status.set_unsynced_handles(v2); |
| 97 EXPECT_FALSE(status.TestAndClearIsDirty()); // Test for deep comparison. | 97 EXPECT_FALSE(status.TestAndClearIsDirty()); // Test for deep comparison. |
| 98 } | 98 } |
| 99 | 99 |
| 100 TEST_F(StatusControllerTest, StaysClean) { | 100 TEST_F(StatusControllerTest, StaysClean) { |
| 101 StatusController status(routes_); | 101 StatusController status(routes_); |
| 102 status.update_conflict_sets_built(true); | 102 status.update_conflict_sets_built(true); |
| 103 EXPECT_FALSE(status.TestAndClearIsDirty()); | 103 EXPECT_FALSE(status.TestAndClearIsDirty()); |
| 104 status.update_conflicts_resolved(true); | 104 status.update_conflicts_resolved(true); |
| 105 EXPECT_FALSE(status.TestAndClearIsDirty()); | 105 EXPECT_FALSE(status.TestAndClearIsDirty()); |
| 106 status.set_got_new_timestamp(); | |
| 107 EXPECT_FALSE(status.TestAndClearIsDirty()); | |
| 108 | 106 |
| 109 status.set_items_committed(); | 107 status.set_items_committed(); |
| 110 EXPECT_FALSE(status.TestAndClearIsDirty()); | 108 EXPECT_FALSE(status.TestAndClearIsDirty()); |
| 111 | 109 |
| 112 OrderedCommitSet commits(routes_); | 110 OrderedCommitSet commits(routes_); |
| 113 commits.AddCommitItem(0, syncable::Id(), syncable::BOOKMARKS); | 111 commits.AddCommitItem(0, syncable::Id(), syncable::BOOKMARKS); |
| 114 status.set_commit_set(commits); | 112 status.set_commit_set(commits); |
| 115 EXPECT_FALSE(status.TestAndClearIsDirty()); | 113 EXPECT_FALSE(status.TestAndClearIsDirty()); |
| 116 } | 114 } |
| 117 | 115 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 | 187 |
| 190 { | 188 { |
| 191 ScopedModelSafeGroupRestriction r(&status, GROUP_PASSIVE); | 189 ScopedModelSafeGroupRestriction r(&status, GROUP_PASSIVE); |
| 192 EXPECT_FALSE(status.update_progress().HasConflictingUpdates()); | 190 EXPECT_FALSE(status.update_progress().HasConflictingUpdates()); |
| 193 } | 191 } |
| 194 } | 192 } |
| 195 | 193 |
| 196 TEST_F(StatusControllerTest, CountUpdates) { | 194 TEST_F(StatusControllerTest, CountUpdates) { |
| 197 StatusController status(routes_); | 195 StatusController status(routes_); |
| 198 EXPECT_EQ(0, status.CountUpdates()); | 196 EXPECT_EQ(0, status.CountUpdates()); |
| 199 EXPECT_TRUE(status.got_zero_updates()); | |
| 200 ClientToServerResponse* response(status.mutable_updates_response()); | 197 ClientToServerResponse* response(status.mutable_updates_response()); |
| 201 sync_pb::SyncEntity* entity1 = response->mutable_get_updates()->add_entries(); | 198 sync_pb::SyncEntity* entity1 = response->mutable_get_updates()->add_entries(); |
| 202 sync_pb::SyncEntity* entity2 = response->mutable_get_updates()->add_entries(); | 199 sync_pb::SyncEntity* entity2 = response->mutable_get_updates()->add_entries(); |
| 203 ASSERT_TRUE(entity1 != NULL && entity2 != NULL); | 200 ASSERT_TRUE(entity1 != NULL && entity2 != NULL); |
| 204 EXPECT_EQ(2, status.CountUpdates()); | 201 EXPECT_EQ(2, status.CountUpdates()); |
| 205 EXPECT_FALSE(status.got_zero_updates()); | |
| 206 } | 202 } |
| 207 | 203 |
| 208 // Test TotalNumConflictingItems | 204 // Test TotalNumConflictingItems |
| 209 TEST_F(StatusControllerTest, TotalNumConflictingItems) { | 205 TEST_F(StatusControllerTest, TotalNumConflictingItems) { |
| 210 StatusController status(routes_); | 206 StatusController status(routes_); |
| 211 TestIdFactory f; | 207 TestIdFactory f; |
| 212 { | 208 { |
| 213 ScopedModelSafeGroupRestriction r(&status, GROUP_UI); | 209 ScopedModelSafeGroupRestriction r(&status, GROUP_UI); |
| 214 status.mutable_conflict_progress()->AddConflictingItemById(f.NewLocalId()); | 210 status.mutable_conflict_progress()->AddConflictingItemById(f.NewLocalId()); |
| 215 status.mutable_conflict_progress()->AddConflictingItemById(f.NewLocalId()); | 211 status.mutable_conflict_progress()->AddConflictingItemById(f.NewLocalId()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 235 status.commit_response(); | 231 status.commit_response(); |
| 236 status.mutable_commit_response(); | 232 status.mutable_commit_response(); |
| 237 status.updates_response(); | 233 status.updates_response(); |
| 238 status.mutable_updates_response(); | 234 status.mutable_updates_response(); |
| 239 status.error_counters(); | 235 status.error_counters(); |
| 240 status.syncer_status(); | 236 status.syncer_status(); |
| 241 status.num_server_changes_remaining(); | 237 status.num_server_changes_remaining(); |
| 242 status.ComputeMaxLocalTimestamp(); | 238 status.ComputeMaxLocalTimestamp(); |
| 243 status.commit_ids(); | 239 status.commit_ids(); |
| 244 status.HasBookmarkCommitActivity(); | 240 status.HasBookmarkCommitActivity(); |
| 245 status.got_zero_updates(); | 241 status.download_updates_succeeded(); |
| 242 status.server_says_nothing_more_to_download(); |
| 246 status.group_restriction(); | 243 status.group_restriction(); |
| 247 } | 244 } |
| 248 | 245 |
| 249 } // namespace sessions | 246 } // namespace sessions |
| 250 } // namespace browser_sync | 247 } // namespace browser_sync |
| OLD | NEW |