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

Unified Diff: components/reading_list/ios/reading_list_entry_unittest.cc

Issue 2553143002: Create a strict order in ReadingListSpecifics (Closed)
Patch Set: rebase Created 4 years 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: components/reading_list/ios/reading_list_entry_unittest.cc
diff --git a/components/reading_list/ios/reading_list_entry_unittest.cc b/components/reading_list/ios/reading_list_entry_unittest.cc
index 61f486ca83af0d6dfdbc8c29eb58ec0160935675..0157f4c694bad889a8b7ce7f945a6bfc22179801 100644
--- a/components/reading_list/ios/reading_list_entry_unittest.cc
+++ b/components/reading_list/ios/reading_list_entry_unittest.cc
@@ -316,25 +316,47 @@ TEST(ReadingListEntry, FromReadingListLocal) {
EXPECT_NEAR(delta.InMillisecondsRoundedUp(), 0, 10);
}
-// Tests that the merging of two ReadingListEntry.
-TEST(ReadingListEntry, MergeLocalStateFrom) {
+// Tests the merging of two ReadingListEntry.
+TEST(ReadingListEntry, MergeWithEntry) {
ReadingListEntry local_entry(GURL("http://example.com/"), "title");
+ local_entry.SetDistilledState(ReadingListEntry::ERROR);
base::Time next_call = base::Time::Now() + local_entry.TimeUntilNextTry();
int64_t local_update_time_us = local_entry.UpdateTime();
- local_entry.SetDistilledPath(base::FilePath("distilled/page.html"));
- ReadingListEntry sync_entry(GURL("http://example2.com/"), "title2");
+ ReadingListEntry sync_entry(GURL("http://example.com/"), "title2");
sync_entry.SetDistilledState(ReadingListEntry::ERROR);
int64_t sync_update_time_us = sync_entry.UpdateTime();
EXPECT_NE(local_update_time_us, sync_update_time_us);
- sync_entry.MergeLocalStateFrom(local_entry);
- EXPECT_EQ(sync_entry.URL().spec(), "http://example2.com/");
- EXPECT_EQ(sync_entry.Title(), "title2");
- EXPECT_EQ(sync_entry.UpdateTime(), sync_update_time_us);
- EXPECT_EQ(sync_entry.FailedDownloadCounter(), 0);
- EXPECT_EQ(sync_entry.DistilledState(), ReadingListEntry::PROCESSED);
- EXPECT_EQ(sync_entry.DistilledPath().value(), "distilled/page.html");
- base::Time sync_next_call = base::Time::Now() + sync_entry.TimeUntilNextTry();
- base::TimeDelta delta = next_call - sync_next_call;
+ local_entry.MergeWithEntry(sync_entry);
+ EXPECT_EQ(local_entry.URL().spec(), "http://example.com/");
+ EXPECT_EQ(local_entry.Title(), "title2");
+ EXPECT_FALSE(local_entry.HasBeenSeen());
+ EXPECT_EQ(local_entry.UpdateTime(), sync_update_time_us);
+ EXPECT_EQ(local_entry.FailedDownloadCounter(), 1);
+ EXPECT_EQ(local_entry.DistilledState(), ReadingListEntry::ERROR);
+ base::Time merge_next_call =
+ base::Time::Now() + local_entry.TimeUntilNextTry();
+ base::TimeDelta delta = merge_next_call - next_call;
EXPECT_NEAR(delta.InMillisecondsRoundedUp(), 0, 10);
}
+
+// Tests the merging of two ReadingListEntry, the oldest one SEEN and the newer
+// UNSEEN.
+TEST(ReadingListEntry, MergeWithEntrySeen) {
+ ReadingListEntry local_entry(GURL("http://example.com/"), "title");
+ local_entry.SetRead(true);
+ int64_t local_update_time_us = local_entry.UpdateTime();
+ local_entry.SetDistilledPath(base::FilePath("distilled/page.html"));
+
+ ReadingListEntry sync_entry(GURL("http://example.com/"), "title2");
+ int64_t sync_update_time_us = sync_entry.UpdateTime();
+ EXPECT_NE(local_update_time_us, sync_update_time_us);
+ local_entry.MergeWithEntry(sync_entry);
+ EXPECT_EQ(local_entry.URL().spec(), "http://example.com/");
+ EXPECT_EQ(local_entry.Title(), "title2");
+ EXPECT_TRUE(local_entry.HasBeenSeen());
+ EXPECT_EQ(local_entry.UpdateTime(), sync_update_time_us);
+ EXPECT_EQ(local_entry.FailedDownloadCounter(), 0);
+ EXPECT_EQ(local_entry.DistilledState(), ReadingListEntry::PROCESSED);
+ EXPECT_EQ(local_entry.DistilledPath().value(), "distilled/page.html");
+}
« no previous file with comments | « components/reading_list/ios/reading_list_entry.cc ('k') | components/reading_list/ios/reading_list_model_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698