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

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

Issue 11192071: sync: Merge apply updates and resolve conflicts (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Retry (base files were missing) Created 8 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
« no previous file with comments | « sync/sessions/status_controller.cc ('k') | sync/sync.gyp » ('j') | 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 24 matching lines...) Expand all
35 status.model_neutral_state().last_download_updates_result); 35 status.model_neutral_state().last_download_updates_result);
36 36
37 status.set_commit_result(SYNC_AUTH_ERROR); 37 status.set_commit_result(SYNC_AUTH_ERROR);
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) {
46 StatusController status(routes_);
47 EXPECT_FALSE(status.HasConflictingUpdates());
48
49 {
50 ScopedModelSafeGroupRestriction r(&status, GROUP_UI);
51 status.increment_num_updates_applied();
52 status.mutable_simple_conflict_ids()->insert(syncable::Id());
53 }
54
55 EXPECT_TRUE(status.HasConflictingUpdates());
56 }
57
58 TEST_F(StatusControllerTest, HasConflictingUpdates_NonBlockingUpdates) {
59 StatusController status(routes_);
60 EXPECT_FALSE(status.HasConflictingUpdates());
61
62 status.increment_num_updates_applied();
63 status.increment_num_encryption_conflicts();
64 EXPECT_TRUE(status.HasConflictingUpdates());
65 }
66
67 TEST_F(StatusControllerTest, CountUpdates) { 45 TEST_F(StatusControllerTest, CountUpdates) {
68 StatusController status(routes_); 46 StatusController status(routes_);
69 EXPECT_EQ(0, status.CountUpdates()); 47 EXPECT_EQ(0, status.CountUpdates());
70 sync_pb::ClientToServerResponse* response(status.mutable_updates_response()); 48 sync_pb::ClientToServerResponse* response(status.mutable_updates_response());
71 sync_pb::SyncEntity* entity1 = response->mutable_get_updates()->add_entries(); 49 sync_pb::SyncEntity* entity1 = response->mutable_get_updates()->add_entries();
72 sync_pb::SyncEntity* entity2 = response->mutable_get_updates()->add_entries(); 50 sync_pb::SyncEntity* entity2 = response->mutable_get_updates()->add_entries();
73 ASSERT_TRUE(entity1 != NULL && entity2 != NULL); 51 ASSERT_TRUE(entity1 != NULL && entity2 != NULL);
74 EXPECT_EQ(2, status.CountUpdates()); 52 EXPECT_EQ(2, status.CountUpdates());
75 } 53 }
76 54
77 // Test TotalNumConflictingItems 55 // Test TotalNumConflictingItems
78 TEST_F(StatusControllerTest, TotalNumConflictingItems) { 56 TEST_F(StatusControllerTest, TotalNumConflictingItems) {
79 StatusController status(routes_); 57 StatusController status(routes_);
80 TestIdFactory f; 58 EXPECT_EQ(0, status.TotalNumConflictingItems());
81 {
82 ScopedModelSafeGroupRestriction r(&status, GROUP_UI);
83 status.mutable_simple_conflict_ids()->insert(f.NewLocalId());
84 status.mutable_simple_conflict_ids()->insert(f.NewLocalId());
85 EXPECT_EQ(static_cast<size_t>(2), status.simple_conflict_ids()->size());
86 }
87 EXPECT_EQ(2, status.TotalNumConflictingItems());
88 {
89 ScopedModelSafeGroupRestriction r(&status, GROUP_DB);
90 status.mutable_simple_conflict_ids()->insert(f.NewLocalId());
91 status.mutable_simple_conflict_ids()->insert(f.NewLocalId());
92 EXPECT_EQ(static_cast<size_t>(2), status.simple_conflict_ids()->size());
93 }
94 EXPECT_EQ(4, status.TotalNumConflictingItems());
95 59
96 status.increment_num_server_conflicts(); 60 status.increment_num_server_conflicts();
97 status.set_num_hierarchy_conflicts(3); 61 status.increment_num_hierarchy_conflicts_by(3);
98 EXPECT_EQ(8, status.TotalNumConflictingItems()); 62 status.increment_num_encryption_conflicts_by(2);
63 EXPECT_EQ(6, status.TotalNumConflictingItems());
99 } 64 }
100 65
101 // Basic test that non group-restricted state accessors don't cause violations. 66 // Basic test that non group-restricted state accessors don't cause violations.
102 TEST_F(StatusControllerTest, Unrestricted) { 67 TEST_F(StatusControllerTest, Unrestricted) {
103 StatusController status(routes_); 68 StatusController status(routes_);
104 status.model_neutral_state(); 69 status.model_neutral_state();
105 status.download_updates_succeeded(); 70 status.download_updates_succeeded();
106 status.ServerSaysNothingMoreToDownload(); 71 status.ServerSaysNothingMoreToDownload();
107 status.group_restriction(); 72 status.group_restriction();
108 } 73 }
109 74
110 } // namespace sessions 75 } // namespace sessions
111 } // namespace syncer 76 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/sessions/status_controller.cc ('k') | sync/sync.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698