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

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

Issue 2707043002: [Reading List iOS] Store distillation date and size. (Closed)
Patch Set: done Created 3 years, 10 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
« no previous file with comments | « components/reading_list/ios/reading_list_entry.cc ('k') | components/reading_list/ios/reading_list_model.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 7afd3aebe0396b04ef101f9927e186765c1ad108..875fc7da385043cd2de4cc404ad6062ad2ad50e7 100644
--- a/components/reading_list/ios/reading_list_entry_unittest.cc
+++ b/components/reading_list/ios/reading_list_entry_unittest.cc
@@ -17,6 +17,11 @@ const int kSecondBackoff = 10;
const int kThirdBackoff = 60;
const int kFourthBackoff = 120;
const int kFifthBackoff = 120;
+
+// Returns the number of microseconds since Jan 1st 1970.
+int64_t Now() {
+ return (base::Time::Now() - base::Time::UnixEpoch()).InMicroseconds();
+}
} // namespace
TEST(ReadingListEntry, CompareIgnoreTitle) {
@@ -69,16 +74,20 @@ TEST(ReadingListEntry, UpdateTitle) {
EXPECT_EQ("foo", e.Title());
}
-TEST(ReadingListEntry, DistilledPathAndURL) {
+TEST(ReadingListEntry, DistilledInfo) {
ReadingListEntry e(GURL("http://example.com"), "bar");
EXPECT_TRUE(e.DistilledPath().empty());
const base::FilePath distilled_path("distilled/page.html");
const GURL distilled_url("http://example.com/distilled");
- e.SetDistilledInfo(distilled_path, distilled_url);
+ int64_t size = 50;
+ int64_t time = 100;
+ e.SetDistilledInfo(distilled_path, distilled_url, size, time);
EXPECT_EQ(distilled_path, e.DistilledPath());
EXPECT_EQ(distilled_url, e.DistilledURL());
+ EXPECT_EQ(size, e.DistillationSize());
+ EXPECT_EQ(e.DistillationTime(), time);
}
TEST(ReadingListEntry, DistilledState) {
@@ -91,7 +100,7 @@ TEST(ReadingListEntry, DistilledState) {
const base::FilePath distilled_path("distilled/page.html");
const GURL distilled_url("http://example.com/distilled");
- e.SetDistilledInfo(distilled_path, distilled_url);
+ e.SetDistilledInfo(distilled_path, distilled_url, 50, 100);
EXPECT_EQ(ReadingListEntry::PROCESSED, e.DistilledState());
}
@@ -185,7 +194,7 @@ TEST(ReadingListEntry, ResetTimeUntilNextTry) {
// Action.
const base::FilePath distilled_path("distilled/page.html");
const GURL distilled_url("http://example.com/distilled");
- e.SetDistilledInfo(distilled_path, distilled_url);
+ e.SetDistilledInfo(distilled_path, distilled_url, 50, 100);
// Test.
EXPECT_EQ(0, e.TimeUntilNextTry().InSeconds());
@@ -288,7 +297,9 @@ TEST(ReadingListEntry, AsReadingListLocal) {
const base::FilePath distilled_path("distilled/page.html");
const GURL distilled_url("http://example.com/distilled");
- entry.SetDistilledInfo(distilled_path, distilled_url);
+ int64_t size = 50;
+ entry.SetDistilledInfo(distilled_path, distilled_url, size, 100);
+
entry.SetRead(true);
entry.MarkEntryUpdated();
EXPECT_NE(entry.UpdateTime(), creation_time_us);
@@ -302,6 +313,9 @@ TEST(ReadingListEntry, AsReadingListLocal) {
reading_list::ReadingListLocal::PROCESSED);
EXPECT_EQ(distilled_pb_entry->distilled_path(), "distilled/page.html");
EXPECT_EQ(distilled_pb_entry->failed_download_counter(), 0);
+ EXPECT_EQ(distilled_pb_entry->distillation_time_us(),
+ entry.DistillationTime());
+ EXPECT_EQ(distilled_pb_entry->distillation_size(), entry.DistillationSize());
}
// Tests that the reading list entry is correctly parsed from
@@ -312,6 +326,7 @@ TEST(ReadingListEntry, FromReadingListLocal) {
std::unique_ptr<reading_list::ReadingListLocal> pb_entry(
entry.AsReadingListLocal());
+ int64_t now = Now();
pb_entry->set_entry_id("http://example.com/");
pb_entry->set_url("http://example.com/");
@@ -321,6 +336,8 @@ TEST(ReadingListEntry, FromReadingListLocal) {
pb_entry->set_status(reading_list::ReadingListLocal::UNREAD);
pb_entry->set_distillation_state(reading_list::ReadingListLocal::WAITING);
pb_entry->set_failed_download_counter(2);
+ pb_entry->set_distillation_time_us(now);
+ pb_entry->set_distillation_size(50);
std::unique_ptr<ReadingListEntry> waiting_entry(
ReadingListEntry::FromReadingListLocal(*pb_entry));
@@ -330,6 +347,8 @@ TEST(ReadingListEntry, FromReadingListLocal) {
EXPECT_EQ(waiting_entry->FailedDownloadCounter(), 2);
EXPECT_EQ(waiting_entry->DistilledState(), ReadingListEntry::WAITING);
EXPECT_EQ(waiting_entry->DistilledPath(), base::FilePath());
+ EXPECT_EQ(waiting_entry->DistillationSize(), 50);
+ EXPECT_EQ(waiting_entry->DistillationTime(), now);
base::Time waiting_next_call =
base::Time::Now() + waiting_entry->TimeUntilNextTry();
base::TimeDelta delta = next_call - waiting_next_call;
« no previous file with comments | « components/reading_list/ios/reading_list_entry.cc ('k') | components/reading_list/ios/reading_list_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698