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

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

Issue 11190013: sync: Remove UpdateProgress and related code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Formatting improvements Created 8 years, 2 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
« no previous file with comments | « sync/sessions/status_controller.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "sync/sessions/sync_session.h" 5 #include "sync/sessions/sync_session.h"
6 #include "sync/test/engine/test_id_factory.h" 6 #include "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 syncer { 9 namespace syncer {
10 namespace sessions { 10 namespace sessions {
(...skipping 27 matching lines...) Expand all
38 EXPECT_EQ(SYNC_AUTH_ERROR, status.model_neutral_state().commit_result); 38 EXPECT_EQ(SYNC_AUTH_ERROR, status.model_neutral_state().commit_result);
39 39
40 for (int i = 0; i < 14; i++) 40 for (int i = 0; i < 14; i++)
41 status.increment_num_successful_commits(); 41 status.increment_num_successful_commits();
42 EXPECT_EQ(14, status.model_neutral_state().num_successful_commits); 42 EXPECT_EQ(14, status.model_neutral_state().num_successful_commits);
43 } 43 }
44 44
45 TEST_F(StatusControllerTest, HasConflictingUpdates) { 45 TEST_F(StatusControllerTest, HasConflictingUpdates) {
46 StatusController status(routes_); 46 StatusController status(routes_);
47 EXPECT_FALSE(status.HasConflictingUpdates()); 47 EXPECT_FALSE(status.HasConflictingUpdates());
48
48 { 49 {
49 ScopedModelSafeGroupRestriction r(&status, GROUP_UI); 50 ScopedModelSafeGroupRestriction r(&status, GROUP_UI);
50 EXPECT_FALSE(status.update_progress()); 51 status.increment_num_updates_applied();
51 status.mutable_update_progress()->AddAppliedUpdate(SUCCESS, 52 status.mutable_simple_conflict_ids()->insert(syncable::Id());
52 syncable::Id());
53 status.mutable_update_progress()->AddAppliedUpdate(CONFLICT_SIMPLE,
54 syncable::Id());
55 EXPECT_TRUE(status.update_progress()->HasConflictingUpdates());
56 } 53 }
57 54
58 EXPECT_TRUE(status.HasConflictingUpdates()); 55 EXPECT_TRUE(status.HasConflictingUpdates());
59
60 {
61 ScopedModelSafeGroupRestriction r(&status, GROUP_PASSIVE);
62 EXPECT_FALSE(status.update_progress());
63 }
64 } 56 }
65 57
66 TEST_F(StatusControllerTest, HasConflictingUpdates_NonBlockingUpdates) { 58 TEST_F(StatusControllerTest, HasConflictingUpdates_NonBlockingUpdates) {
67 StatusController status(routes_); 59 StatusController status(routes_);
68 EXPECT_FALSE(status.HasConflictingUpdates()); 60 EXPECT_FALSE(status.HasConflictingUpdates());
69 {
70 ScopedModelSafeGroupRestriction r(&status, GROUP_UI);
71 EXPECT_FALSE(status.update_progress());
72 status.mutable_update_progress()->AddAppliedUpdate(SUCCESS,
73 syncable::Id());
74 status.mutable_update_progress()->AddAppliedUpdate(CONFLICT_HIERARCHY,
75 syncable::Id());
76 EXPECT_TRUE(status.update_progress()->HasConflictingUpdates());
77 }
78 61
62 status.increment_num_updates_applied();
63 status.increment_num_encryption_conflicts();
79 EXPECT_TRUE(status.HasConflictingUpdates()); 64 EXPECT_TRUE(status.HasConflictingUpdates());
80 } 65 }
81 66
82 TEST_F(StatusControllerTest, CountUpdates) { 67 TEST_F(StatusControllerTest, CountUpdates) {
83 StatusController status(routes_); 68 StatusController status(routes_);
84 EXPECT_EQ(0, status.CountUpdates()); 69 EXPECT_EQ(0, status.CountUpdates());
85 sync_pb::ClientToServerResponse* response(status.mutable_updates_response()); 70 sync_pb::ClientToServerResponse* response(status.mutable_updates_response());
86 sync_pb::SyncEntity* entity1 = response->mutable_get_updates()->add_entries(); 71 sync_pb::SyncEntity* entity1 = response->mutable_get_updates()->add_entries();
87 sync_pb::SyncEntity* entity2 = response->mutable_get_updates()->add_entries(); 72 sync_pb::SyncEntity* entity2 = response->mutable_get_updates()->add_entries();
88 ASSERT_TRUE(entity1 != NULL && entity2 != NULL); 73 ASSERT_TRUE(entity1 != NULL && entity2 != NULL);
(...skipping 20 matching lines...) Expand all
109 EXPECT_EQ(4, status.TotalNumConflictingItems()); 94 EXPECT_EQ(4, status.TotalNumConflictingItems());
110 95
111 status.increment_num_server_conflicts(); 96 status.increment_num_server_conflicts();
112 status.set_num_hierarchy_conflicts(3); 97 status.set_num_hierarchy_conflicts(3);
113 EXPECT_EQ(8, status.TotalNumConflictingItems()); 98 EXPECT_EQ(8, status.TotalNumConflictingItems());
114 } 99 }
115 100
116 // Basic test that non group-restricted state accessors don't cause violations. 101 // Basic test that non group-restricted state accessors don't cause violations.
117 TEST_F(StatusControllerTest, Unrestricted) { 102 TEST_F(StatusControllerTest, Unrestricted) {
118 StatusController status(routes_); 103 StatusController status(routes_);
119 const UpdateProgress* progress =
120 status.GetUnrestrictedUpdateProgress(GROUP_UI);
121 EXPECT_FALSE(progress);
122 status.model_neutral_state(); 104 status.model_neutral_state();
123 status.download_updates_succeeded(); 105 status.download_updates_succeeded();
124 status.ServerSaysNothingMoreToDownload(); 106 status.ServerSaysNothingMoreToDownload();
125 status.group_restriction(); 107 status.group_restriction();
126 } 108 }
127 109
128 } // namespace sessions 110 } // namespace sessions
129 } // namespace syncer 111 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/sessions/status_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698