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

Unified Diff: ios/chrome/browser/reading_list/reading_list_entry_unittest.cc

Issue 2338133010: Add a TimeUntilNextTry to reading list (Closed)
Patch Set: fixes Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
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());
+}

Powered by Google App Engine
This is Rietveld 408576698