| Index: ios/chrome/browser/reading_list/reading_list_entry_unittest.cc
|
| diff --git a/ios/chrome/browser/reading_list/reading_list_entry_unittest.cc b/ios/chrome/browser/reading_list/reading_list_entry_unittest.cc
|
| index 215c3fdd32df3c9a0d0ff76facae81c995ee8fd4..9b5d9384225df6621b425e9c11d28d37de894cee 100644
|
| --- a/ios/chrome/browser/reading_list/reading_list_entry_unittest.cc
|
| +++ b/ios/chrome/browser/reading_list/reading_list_entry_unittest.cc
|
| @@ -4,6 +4,7 @@
|
|
|
| #include "ios/chrome/browser/reading_list/reading_list_entry.h"
|
|
|
| +#include "base/test/simple_test_tick_clock.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| TEST(ReadingListEntry, CompareIgnoreTitle) {
|
| @@ -50,3 +51,47 @@ TEST(ReadingListEntry, DistilledState) {
|
| e.SetDistilledURL(distilled_url);
|
| EXPECT_EQ(ReadingListEntry::PROCESSED, e.DistilledState());
|
| }
|
| +
|
| +// Tests that the the time until next try increase exponentially when the state
|
| +// changes from non-error to error.
|
| +TEST(ReadingListEntry, TimeUntilNextTry) {
|
| + base::SimpleTestTickClock clock;
|
| + ReadingListEntry e(GURL("http://example.com"), "bar", &clock);
|
| +
|
| + ASSERT_EQ(0, e.TimeUntilNextTry().InSeconds());
|
| +
|
| + e.SetDistilledState(ReadingListEntry::ERROR);
|
| + EXPECT_EQ(1, e.TimeUntilNextTry().InSeconds());
|
| + e.SetDistilledState(ReadingListEntry::WILL_RETRY);
|
| + EXPECT_EQ(1, e.TimeUntilNextTry().InSeconds());
|
| +
|
| + e.SetDistilledState(ReadingListEntry::PROCESSING);
|
| + EXPECT_EQ(1, e.TimeUntilNextTry().InSeconds());
|
| +
|
| + e.SetDistilledState(ReadingListEntry::WILL_RETRY);
|
| + EXPECT_EQ(2, e.TimeUntilNextTry().InSeconds());
|
| + e.SetDistilledState(ReadingListEntry::ERROR);
|
| + EXPECT_EQ(2, e.TimeUntilNextTry().InSeconds());
|
| +
|
| + e.SetDistilledState(ReadingListEntry::PROCESSING);
|
| + EXPECT_EQ(2, e.TimeUntilNextTry().InSeconds());
|
| +
|
| + e.SetDistilledState(ReadingListEntry::WILL_RETRY);
|
| + EXPECT_EQ(4, e.TimeUntilNextTry().InSeconds());
|
| +}
|
| +
|
| +// Tests that if the time until next try is in the past, 0 is returned.
|
| +TEST(ReadingListEntry, TimeUntilNextTryInThePast) {
|
| + // Setup.
|
| + base::SimpleTestTickClock clock;
|
| + ReadingListEntry e(GURL("http://example.com"), "bar", &clock);
|
| +
|
| + e.SetDistilledState(ReadingListEntry::ERROR);
|
| + ASSERT_EQ(1, e.TimeUntilNextTry().InSeconds());
|
| +
|
| + // Action.
|
| + clock.Advance(base::TimeDelta::FromSeconds(2));
|
| +
|
| + // Test.
|
| + EXPECT_EQ(0, e.TimeUntilNextTry().InMilliseconds());
|
| +}
|
|
|