| Index: components/sync/sessions_impl/nudge_tracker_unittest.cc
|
| diff --git a/sync/sessions/nudge_tracker_unittest.cc b/components/sync/sessions_impl/nudge_tracker_unittest.cc
|
| similarity index 95%
|
| rename from sync/sessions/nudge_tracker_unittest.cc
|
| rename to components/sync/sessions_impl/nudge_tracker_unittest.cc
|
| index 3f8f38b1cbd1477774baa6606c30034775d2ee28..469f036e4f2a5ec27cf40dfc4d7b8b60e709fb6e 100644
|
| --- a/sync/sessions/nudge_tracker_unittest.cc
|
| +++ b/components/sync/sessions_impl/nudge_tracker_unittest.cc
|
| @@ -2,20 +2,21 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "sync/sessions/nudge_tracker.h"
|
| +#include "components/sync/sessions_impl/nudge_tracker.h"
|
|
|
| #include <stddef.h>
|
| #include <stdint.h>
|
| +
|
| #include <string>
|
| #include <utility>
|
| #include <vector>
|
|
|
| #include "base/message_loop/message_loop.h"
|
| #include "base/run_loop.h"
|
| -#include "sync/internal_api/public/base/model_type_test_util.h"
|
| -#include "sync/test/mock_invalidation.h"
|
| -#include "sync/test/mock_invalidation_tracker.h"
|
| -#include "sync/test/trackable_mock_invalidation.h"
|
| +#include "components/sync/base/model_type_test_util.h"
|
| +#include "components/sync/test/mock_invalidation.h"
|
| +#include "components/sync/test/mock_invalidation_tracker.h"
|
| +#include "components/sync/test/trackable_mock_invalidation.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| namespace syncer {
|
| @@ -27,8 +28,8 @@ testing::AssertionResult ModelTypeSetEquals(ModelTypeSet a, ModelTypeSet b) {
|
| return testing::AssertionSuccess();
|
| } else {
|
| return testing::AssertionFailure()
|
| - << "Left side " << ModelTypeSetToString(a)
|
| - << ", does not match rigth side: " << ModelTypeSetToString(b);
|
| + << "Left side " << ModelTypeSetToString(a)
|
| + << ", does not match rigth side: " << ModelTypeSetToString(b);
|
| }
|
| }
|
|
|
| @@ -38,9 +39,7 @@ namespace sessions {
|
|
|
| class NudgeTrackerTest : public ::testing::Test {
|
| public:
|
| - NudgeTrackerTest() {
|
| - SetInvalidationsInSync();
|
| - }
|
| + NudgeTrackerTest() { SetInvalidationsInSync(); }
|
|
|
| static size_t GetHintBufferSize() {
|
| // Assumes that no test has adjusted this size.
|
| @@ -242,7 +241,8 @@ TEST_F(NudgeTrackerTest, DropHintsLocally_OneAtATime) {
|
| static_cast<size_t>(gu_trigger.notification_hint_size()));
|
|
|
| // Verify the newest hint was not dropped and is the last in the list.
|
| - EXPECT_EQ("new_hint", gu_trigger.notification_hint(GetHintBufferSize()-1));
|
| + EXPECT_EQ("new_hint",
|
| + gu_trigger.notification_hint(GetHintBufferSize() - 1));
|
|
|
| // Verify the oldest hint, too.
|
| EXPECT_EQ("hint", gu_trigger.notification_hint(0));
|
| @@ -446,9 +446,8 @@ TEST_F(NudgeTrackerTest, IsSyncRequired_Throttling) {
|
| EXPECT_TRUE(nudge_tracker_.IsSyncRequired());
|
|
|
| // But the throttling of sessions unsets it.
|
| - nudge_tracker_.SetTypesThrottledUntil(ModelTypeSet(SESSIONS),
|
| - throttle_length,
|
| - t0);
|
| + nudge_tracker_.SetTypesThrottledUntil(ModelTypeSet(SESSIONS), throttle_length,
|
| + t0);
|
| EXPECT_FALSE(nudge_tracker_.IsSyncRequired());
|
|
|
| // A refresh request for bookmarks means we have reason to sync again.
|
| @@ -480,9 +479,8 @@ TEST_F(NudgeTrackerTest, IsGetUpdatesRequired_Throttling) {
|
| EXPECT_TRUE(nudge_tracker_.IsGetUpdatesRequired());
|
|
|
| // But the throttling of sessions unsets it.
|
| - nudge_tracker_.SetTypesThrottledUntil(ModelTypeSet(SESSIONS),
|
| - throttle_length,
|
| - t0);
|
| + nudge_tracker_.SetTypesThrottledUntil(ModelTypeSet(SESSIONS), throttle_length,
|
| + t0);
|
| EXPECT_FALSE(nudge_tracker_.IsGetUpdatesRequired());
|
|
|
| // A refresh request for bookmarks means we have reason to sync again.
|
| @@ -515,8 +513,7 @@ TEST_F(NudgeTrackerTest, ThrottleAndUnthrottle) {
|
| const base::TimeTicks t1 = t0 + throttle_length;
|
|
|
| nudge_tracker_.SetTypesThrottledUntil(ModelTypeSet(SESSIONS, PREFERENCES),
|
| - throttle_length,
|
| - t0);
|
| + throttle_length, t0);
|
|
|
| EXPECT_TRUE(nudge_tracker_.IsAnyTypeThrottled());
|
| EXPECT_TRUE(nudge_tracker_.IsTypeThrottled(SESSIONS));
|
| @@ -540,32 +537,25 @@ TEST_F(NudgeTrackerTest, OverlappingThrottleIntervals) {
|
|
|
| // Setup the longer of two intervals.
|
| nudge_tracker_.SetTypesThrottledUntil(ModelTypeSet(SESSIONS, PREFERENCES),
|
| - throttle2_length,
|
| - t0);
|
| - EXPECT_TRUE(ModelTypeSetEquals(
|
| - ModelTypeSet(SESSIONS, PREFERENCES),
|
| - nudge_tracker_.GetThrottledTypes()));
|
| - EXPECT_EQ(throttle2_length,
|
| - nudge_tracker_.GetTimeUntilNextUnthrottle(t0));
|
| + throttle2_length, t0);
|
| + EXPECT_TRUE(ModelTypeSetEquals(ModelTypeSet(SESSIONS, PREFERENCES),
|
| + nudge_tracker_.GetThrottledTypes()));
|
| + EXPECT_EQ(throttle2_length, nudge_tracker_.GetTimeUntilNextUnthrottle(t0));
|
|
|
| // Setup the shorter interval.
|
| nudge_tracker_.SetTypesThrottledUntil(ModelTypeSet(SESSIONS, BOOKMARKS),
|
| - throttle1_length,
|
| - t0);
|
| - EXPECT_TRUE(ModelTypeSetEquals(
|
| - ModelTypeSet(SESSIONS, PREFERENCES, BOOKMARKS),
|
| - nudge_tracker_.GetThrottledTypes()));
|
| - EXPECT_EQ(throttle1_length,
|
| - nudge_tracker_.GetTimeUntilNextUnthrottle(t0));
|
| + throttle1_length, t0);
|
| + EXPECT_TRUE(ModelTypeSetEquals(ModelTypeSet(SESSIONS, PREFERENCES, BOOKMARKS),
|
| + nudge_tracker_.GetThrottledTypes()));
|
| + EXPECT_EQ(throttle1_length, nudge_tracker_.GetTimeUntilNextUnthrottle(t0));
|
|
|
| // Expire the first interval.
|
| nudge_tracker_.UpdateTypeThrottlingState(t1);
|
|
|
| // SESSIONS appeared in both intervals. We expect it will be throttled for
|
| // the longer of the two, so it's still throttled at time t1.
|
| - EXPECT_TRUE(ModelTypeSetEquals(
|
| - ModelTypeSet(SESSIONS, PREFERENCES),
|
| - nudge_tracker_.GetThrottledTypes()));
|
| + EXPECT_TRUE(ModelTypeSetEquals(ModelTypeSet(SESSIONS, PREFERENCES),
|
| + nudge_tracker_.GetThrottledTypes()));
|
| EXPECT_EQ(throttle2_length - throttle1_length,
|
| nudge_tracker_.GetTimeUntilNextUnthrottle(t1));
|
|
|
| @@ -913,8 +903,7 @@ TEST_F(NudgeTrackerAckTrackingTest, OverflowAndRecover) {
|
| }
|
|
|
| for (std::vector<int>::iterator it = invalidation_ids.begin();
|
| - it != invalidation_ids.end();
|
| - ++it) {
|
| + it != invalidation_ids.end(); ++it) {
|
| EXPECT_TRUE(IsInvalidationUnacknowledged(*it));
|
| }
|
|
|
| @@ -932,8 +921,7 @@ TEST_F(NudgeTrackerAckTrackingTest, OverflowAndRecover) {
|
| RecordSuccessfulSyncCycle();
|
|
|
| for (std::vector<int>::iterator it = invalidation_ids.begin();
|
| - it != invalidation_ids.end();
|
| - ++it) {
|
| + it != invalidation_ids.end(); ++it) {
|
| EXPECT_TRUE(IsInvalidationAcknowledged(*it));
|
| }
|
| EXPECT_TRUE(IsInvalidationAcknowledged(inv100_id));
|
|
|