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

Side by Side Diff: sync/engine/sync_session_job_unittest.cc

Issue 12317104: Remove canary member from SyncSessionJob (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 9 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/engine/sync_session_job.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/engine/sync_session_job.h" 5 #include "sync/engine/sync_session_job.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/time.h" 9 #include "base/time.h"
10 #include "sync/internal_api/public/base/model_type_invalidation_map.h" 10 #include "sync/internal_api/public/base/model_type_invalidation_map.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 const ModelSafeRoutingInfo& routes() { return routes_; } 90 const ModelSafeRoutingInfo& routes() { return routes_; }
91 91
92 // Checks that the two jobs are "clones" as defined by SyncSessionJob, 92 // Checks that the two jobs are "clones" as defined by SyncSessionJob,
93 // minus location and SyncSession checking, for reuse in different 93 // minus location and SyncSession checking, for reuse in different
94 // scenarios. 94 // scenarios.
95 void ExpectClonesBase(SyncSessionJob* job, SyncSessionJob* clone) { 95 void ExpectClonesBase(SyncSessionJob* job, SyncSessionJob* clone) {
96 EXPECT_EQ(job->purpose(), clone->purpose()); 96 EXPECT_EQ(job->purpose(), clone->purpose());
97 EXPECT_EQ(job->scheduled_start(), clone->scheduled_start()); 97 EXPECT_EQ(job->scheduled_start(), clone->scheduled_start());
98 EXPECT_EQ(job->start_step(), clone->start_step()); 98 EXPECT_EQ(job->start_step(), clone->start_step());
99 EXPECT_EQ(job->end_step(), clone->end_step()); 99 EXPECT_EQ(job->end_step(), clone->end_step());
100 EXPECT_FALSE(clone->is_canary());
101 } 100 }
102 101
103 private: 102 private:
104 scoped_ptr<sessions::SyncSessionContext> context_; 103 scoped_ptr<sessions::SyncSessionContext> context_;
105 std::vector<scoped_refptr<ModelSafeWorker> > workers_; 104 std::vector<scoped_refptr<ModelSafeWorker> > workers_;
106 MockDelegate delegate_; 105 MockDelegate delegate_;
107 ModelSafeRoutingInfo routes_; 106 ModelSafeRoutingInfo routes_;
108 bool config_params_callback_invoked_; 107 bool config_params_callback_invoked_;
109 }; 108 };
110 109
111 TEST_F(SyncSessionJobTest, Clone) { 110 TEST_F(SyncSessionJobTest, Clone) {
112 SyncSessionJob job1(SyncSessionJob::NUDGE, TimeTicks::Now(), 111 SyncSessionJob job1(SyncSessionJob::NUDGE, TimeTicks::Now(),
113 NewLocalSession().Pass(), ConfigurationParams()); 112 NewLocalSession().Pass(), ConfigurationParams());
114 113
115 sessions::test_util::SimulateSuccess(job1.mutable_session(), 114 sessions::test_util::SimulateSuccess(job1.mutable_session(),
116 job1.start_step(), 115 job1.start_step(),
117 job1.end_step()); 116 job1.end_step());
118 job1.Finish(false); 117 job1.Finish(false);
119 ModelSafeRoutingInfo new_routes; 118 ModelSafeRoutingInfo new_routes;
120 new_routes[AUTOFILL] = GROUP_PASSIVE; 119 new_routes[AUTOFILL] = GROUP_PASSIVE;
121 context()->set_routing_info(new_routes); 120 context()->set_routing_info(new_routes);
122 scoped_ptr<SyncSessionJob> clone1 = job1.Clone(); 121 scoped_ptr<SyncSessionJob> clone1 = job1.Clone();
123 122
124 ExpectClonesBase(&job1, clone1.get()); 123 ExpectClonesBase(&job1, clone1.get());
125 EXPECT_NE(job1.session(), clone1->session()); 124 EXPECT_NE(job1.session(), clone1->session());
126 125
127 context()->set_routing_info(routes()); 126 context()->set_routing_info(routes());
128 clone1->GrantCanaryPrivilege();
129 sessions::test_util::SimulateSuccess(clone1->mutable_session(), 127 sessions::test_util::SimulateSuccess(clone1->mutable_session(),
130 clone1->start_step(), 128 clone1->start_step(),
131 clone1->end_step()); 129 clone1->end_step());
132 clone1->Finish(false); 130 clone1->Finish(false);
133 scoped_ptr<SyncSessionJob> clone2 = clone1->Clone(); 131 scoped_ptr<SyncSessionJob> clone2 = clone1->Clone();
134 132
135 ExpectClonesBase(clone1.get(), clone2.get()); 133 ExpectClonesBase(clone1.get(), clone2.get());
136 EXPECT_NE(clone1->session(), clone2->session()); 134 EXPECT_NE(clone1->session(), clone2->session());
137 EXPECT_NE(clone1->session(), clone2->session()); 135 EXPECT_NE(clone1->session(), clone2->session());
138 136
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 SyncSessionJob job1(SyncSessionJob::CONFIGURATION, TimeTicks::Now(), 198 SyncSessionJob job1(SyncSessionJob::CONFIGURATION, TimeTicks::Now(),
201 session.Pass(), params); 199 session.Pass(), params);
202 sessions::test_util::SimulateSuccess(job1.mutable_session(), 200 sessions::test_util::SimulateSuccess(job1.mutable_session(),
203 job1.start_step(), 201 job1.start_step(),
204 job1.end_step()); 202 job1.end_step());
205 job1.Finish(false); 203 job1.Finish(false);
206 EXPECT_TRUE(config_params_callback_invoked()); 204 EXPECT_TRUE(config_params_callback_invoked());
207 } 205 }
208 206
209 } // namespace syncer 207 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/engine/sync_session_job.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698