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

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

Issue 15764010: Experimental functionize patch (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync: Expose sync functionality as functions Created 7 years, 6 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/nudge_tracker.cc ('k') | sync/sessions/sync_session.h » ('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/nudge_tracker.h" 5 #include "sync/sessions/nudge_tracker.h"
6 6
7 #include "sync/internal_api/public/base/model_type_invalidation_map.h" 7 #include "sync/internal_api/public/base/model_type_invalidation_map.h"
8 #include "sync/internal_api/public/sessions/sync_source_info.h" 8 #include "sync/internal_api/public/sessions/sync_source_info.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 nudge_tracker.FillProtoMessage(type, &gu_trigger); 46 nudge_tracker.FillProtoMessage(type, &gu_trigger);
47 return gu_trigger.local_modification_nudges(); 47 return gu_trigger.local_modification_nudges();
48 } 48 }
49 49
50 int ProtoRefreshRequestedCount(const NudgeTracker& nudge_tracker, 50 int ProtoRefreshRequestedCount(const NudgeTracker& nudge_tracker,
51 ModelType type) { 51 ModelType type) {
52 sync_pb::GetUpdateTriggers gu_trigger; 52 sync_pb::GetUpdateTriggers gu_trigger;
53 nudge_tracker.FillProtoMessage(type, &gu_trigger); 53 nudge_tracker.FillProtoMessage(type, &gu_trigger);
54 return gu_trigger.datatype_refresh_nudges(); 54 return gu_trigger.datatype_refresh_nudges();
55 } 55 }
56
57 void FullySync(NudgeTracker* nudge_tracker) {
58 // We enable invalidations and perform a successful sync cycle so our
59 // invalidations list will be 100% up to date and reliable.
60 nudge_tracker->OnInvalidationsEnabled();
61 nudge_tracker->RecordSuccessfulSyncCycle();
62 }
56 }; 63 };
57 64
58 // Exercise an empty NudgeTracker. 65 // Exercise an empty NudgeTracker.
59 // Use with valgrind to detect uninitialized members. 66 // Use with valgrind to detect uninitialized members.
60 TEST_F(NudgeTrackerTest, EmptyNudgeTracker) { 67 TEST_F(NudgeTrackerTest, EmptyNudgeTracker) {
61 NudgeTracker nudge_tracker; 68 NudgeTracker nudge_tracker;
62 69
63 EXPECT_FALSE(nudge_tracker.IsSyncRequired()); 70 EXPECT_FALSE(nudge_tracker.IsSyncRequired());
64 EXPECT_EQ(sync_pb::GetUpdatesCallerInfo::UNKNOWN, 71 EXPECT_EQ(sync_pb::GetUpdatesCallerInfo::UNKNOWN,
65 nudge_tracker.updates_source()); 72 nudge_tracker.updates_source());
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 ModelTypeSet(SESSIONS, PREFERENCES), 412 ModelTypeSet(SESSIONS, PREFERENCES),
406 nudge_tracker.GetThrottledTypes())); 413 nudge_tracker.GetThrottledTypes()));
407 EXPECT_EQ(throttle2_length - throttle1_length, 414 EXPECT_EQ(throttle2_length - throttle1_length,
408 nudge_tracker.GetTimeUntilNextUnthrottle(t1)); 415 nudge_tracker.GetTimeUntilNextUnthrottle(t1));
409 416
410 // Expire the second interval. 417 // Expire the second interval.
411 nudge_tracker.UpdateTypeThrottlingState(t2); 418 nudge_tracker.UpdateTypeThrottlingState(t2);
412 EXPECT_TRUE(nudge_tracker.GetThrottledTypes().Empty()); 419 EXPECT_TRUE(nudge_tracker.GetThrottledTypes().Empty());
413 } 420 }
414 421
415
416 } // namespace sessions 422 } // namespace sessions
417 } // namespace syncer 423 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/sessions/nudge_tracker.cc ('k') | sync/sessions/sync_session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698