| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/reading_list/ios/reading_list_entry.h" | 5 #include "components/reading_list/ios/reading_list_entry.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/test/simple_test_tick_clock.h" | 8 #include "base/test/simple_test_tick_clock.h" |
| 9 #include "components/reading_list/ios/proto/reading_list.pb.h" | 9 #include "components/reading_list/ios/proto/reading_list.pb.h" |
| 10 #include "components/sync/protocol/reading_list_specifics.pb.h" | 10 #include "components/sync/protocol/reading_list_specifics.pb.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 ReadingListEntry e2(GURL("http://example.com"), "bar"); | 37 ReadingListEntry e2(GURL("http://example.com"), "bar"); |
| 38 ASSERT_EQ(e1, e2); | 38 ASSERT_EQ(e1, e2); |
| 39 ASSERT_EQ(e1.Title(), e2.Title()); | 39 ASSERT_EQ(e1.Title(), e2.Title()); |
| 40 | 40 |
| 41 ReadingListEntry e3(std::move(e1)); | 41 ReadingListEntry e3(std::move(e1)); |
| 42 | 42 |
| 43 EXPECT_EQ(e3, e2); | 43 EXPECT_EQ(e3, e2); |
| 44 EXPECT_EQ(e3.Title(), e2.Title()); | 44 EXPECT_EQ(e3.Title(), e2.Title()); |
| 45 } | 45 } |
| 46 | 46 |
| 47 TEST(ReadingListEntry, ReadState) { |
| 48 ReadingListEntry e(GURL("http://example.com"), "bar"); |
| 49 EXPECT_FALSE(e.HasBeenSeen()); |
| 50 EXPECT_FALSE(e.IsRead()); |
| 51 e.SetRead(false); |
| 52 EXPECT_TRUE(e.HasBeenSeen()); |
| 53 EXPECT_FALSE(e.IsRead()); |
| 54 e.SetRead(true); |
| 55 EXPECT_TRUE(e.HasBeenSeen()); |
| 56 EXPECT_TRUE(e.IsRead()); |
| 57 } |
| 58 |
| 47 TEST(ReadingListEntry, DistilledPathAndURL) { | 59 TEST(ReadingListEntry, DistilledPathAndURL) { |
| 48 ReadingListEntry e(GURL("http://example.com"), "bar"); | 60 ReadingListEntry e(GURL("http://example.com"), "bar"); |
| 49 | 61 |
| 50 EXPECT_TRUE(e.DistilledPath().empty()); | 62 EXPECT_TRUE(e.DistilledPath().empty()); |
| 51 | 63 |
| 52 const base::FilePath distilled_path("distilled/page.html"); | 64 const base::FilePath distilled_path("distilled/page.html"); |
| 53 e.SetDistilledPath(distilled_path); | 65 e.SetDistilledPath(distilled_path); |
| 54 EXPECT_EQ(distilled_path, e.DistilledPath()); | 66 EXPECT_EQ(distilled_path, e.DistilledPath()); |
| 55 } | 67 } |
| 56 | 68 |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 ReadingListEntry entry(GURL("http://example.com/"), "bar"); | 203 ReadingListEntry entry(GURL("http://example.com/"), "bar"); |
| 192 int64_t creation_time_us = entry.UpdateTime(); | 204 int64_t creation_time_us = entry.UpdateTime(); |
| 193 | 205 |
| 194 std::unique_ptr<sync_pb::ReadingListSpecifics> pb_entry( | 206 std::unique_ptr<sync_pb::ReadingListSpecifics> pb_entry( |
| 195 entry.AsReadingListSpecifics()); | 207 entry.AsReadingListSpecifics()); |
| 196 EXPECT_EQ(pb_entry->entry_id(), "http://example.com/"); | 208 EXPECT_EQ(pb_entry->entry_id(), "http://example.com/"); |
| 197 EXPECT_EQ(pb_entry->url(), "http://example.com/"); | 209 EXPECT_EQ(pb_entry->url(), "http://example.com/"); |
| 198 EXPECT_EQ(pb_entry->title(), "bar"); | 210 EXPECT_EQ(pb_entry->title(), "bar"); |
| 199 EXPECT_EQ(pb_entry->creation_time_us(), creation_time_us); | 211 EXPECT_EQ(pb_entry->creation_time_us(), creation_time_us); |
| 200 EXPECT_EQ(pb_entry->update_time_us(), entry.UpdateTime()); | 212 EXPECT_EQ(pb_entry->update_time_us(), entry.UpdateTime()); |
| 201 EXPECT_EQ(pb_entry->status(), sync_pb::ReadingListSpecifics::UNREAD); | 213 EXPECT_EQ(pb_entry->status(), sync_pb::ReadingListSpecifics::UNSEEN); |
| 202 | 214 |
| 203 entry.SetRead(true); | 215 entry.SetRead(true); |
| 204 EXPECT_NE(entry.UpdateTime(), creation_time_us); | 216 EXPECT_NE(entry.UpdateTime(), creation_time_us); |
| 205 std::unique_ptr<sync_pb::ReadingListSpecifics> updated_pb_entry( | 217 std::unique_ptr<sync_pb::ReadingListSpecifics> updated_pb_entry( |
| 206 entry.AsReadingListSpecifics()); | 218 entry.AsReadingListSpecifics()); |
| 207 EXPECT_EQ(updated_pb_entry->creation_time_us(), creation_time_us); | 219 EXPECT_EQ(updated_pb_entry->creation_time_us(), creation_time_us); |
| 208 EXPECT_EQ(updated_pb_entry->update_time_us(), entry.UpdateTime()); | 220 EXPECT_EQ(updated_pb_entry->update_time_us(), entry.UpdateTime()); |
| 209 EXPECT_EQ(updated_pb_entry->status(), sync_pb::ReadingListSpecifics::READ); | 221 EXPECT_EQ(updated_pb_entry->status(), sync_pb::ReadingListSpecifics::READ); |
| 210 } | 222 } |
| 211 | 223 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 235 ReadingListEntry entry(GURL("http://example.com/"), "bar"); | 247 ReadingListEntry entry(GURL("http://example.com/"), "bar"); |
| 236 int64_t creation_time_us = entry.UpdateTime(); | 248 int64_t creation_time_us = entry.UpdateTime(); |
| 237 | 249 |
| 238 std::unique_ptr<reading_list::ReadingListLocal> pb_entry( | 250 std::unique_ptr<reading_list::ReadingListLocal> pb_entry( |
| 239 entry.AsReadingListLocal()); | 251 entry.AsReadingListLocal()); |
| 240 EXPECT_EQ(pb_entry->entry_id(), "http://example.com/"); | 252 EXPECT_EQ(pb_entry->entry_id(), "http://example.com/"); |
| 241 EXPECT_EQ(pb_entry->url(), "http://example.com/"); | 253 EXPECT_EQ(pb_entry->url(), "http://example.com/"); |
| 242 EXPECT_EQ(pb_entry->title(), "bar"); | 254 EXPECT_EQ(pb_entry->title(), "bar"); |
| 243 EXPECT_EQ(pb_entry->creation_time_us(), creation_time_us); | 255 EXPECT_EQ(pb_entry->creation_time_us(), creation_time_us); |
| 244 EXPECT_EQ(pb_entry->update_time_us(), entry.UpdateTime()); | 256 EXPECT_EQ(pb_entry->update_time_us(), entry.UpdateTime()); |
| 245 EXPECT_EQ(pb_entry->status(), reading_list::ReadingListLocal::UNREAD); | 257 EXPECT_EQ(pb_entry->status(), reading_list::ReadingListLocal::UNSEEN); |
| 246 EXPECT_EQ(pb_entry->distillation_state(), | 258 EXPECT_EQ(pb_entry->distillation_state(), |
| 247 reading_list::ReadingListLocal::WAITING); | 259 reading_list::ReadingListLocal::WAITING); |
| 248 EXPECT_EQ(pb_entry->distilled_path(), ""); | 260 EXPECT_EQ(pb_entry->distilled_path(), ""); |
| 249 EXPECT_EQ(pb_entry->failed_download_counter(), 0); | 261 EXPECT_EQ(pb_entry->failed_download_counter(), 0); |
| 250 EXPECT_NE(pb_entry->backoff(), ""); | 262 EXPECT_NE(pb_entry->backoff(), ""); |
| 251 | 263 |
| 252 entry.SetDistilledState(ReadingListEntry::WILL_RETRY); | 264 entry.SetDistilledState(ReadingListEntry::WILL_RETRY); |
| 253 std::unique_ptr<reading_list::ReadingListLocal> will_retry_pb_entry( | 265 std::unique_ptr<reading_list::ReadingListLocal> will_retry_pb_entry( |
| 254 entry.AsReadingListLocal()); | 266 entry.AsReadingListLocal()); |
| 255 EXPECT_EQ(will_retry_pb_entry->distillation_state(), | 267 EXPECT_EQ(will_retry_pb_entry->distillation_state(), |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 EXPECT_EQ(sync_entry.URL().spec(), "http://example2.com/"); | 331 EXPECT_EQ(sync_entry.URL().spec(), "http://example2.com/"); |
| 320 EXPECT_EQ(sync_entry.Title(), "title2"); | 332 EXPECT_EQ(sync_entry.Title(), "title2"); |
| 321 EXPECT_EQ(sync_entry.UpdateTime(), sync_update_time_us); | 333 EXPECT_EQ(sync_entry.UpdateTime(), sync_update_time_us); |
| 322 EXPECT_EQ(sync_entry.FailedDownloadCounter(), 0); | 334 EXPECT_EQ(sync_entry.FailedDownloadCounter(), 0); |
| 323 EXPECT_EQ(sync_entry.DistilledState(), ReadingListEntry::PROCESSED); | 335 EXPECT_EQ(sync_entry.DistilledState(), ReadingListEntry::PROCESSED); |
| 324 EXPECT_EQ(sync_entry.DistilledPath().value(), "distilled/page.html"); | 336 EXPECT_EQ(sync_entry.DistilledPath().value(), "distilled/page.html"); |
| 325 base::Time sync_next_call = base::Time::Now() + sync_entry.TimeUntilNextTry(); | 337 base::Time sync_next_call = base::Time::Now() + sync_entry.TimeUntilNextTry(); |
| 326 base::TimeDelta delta = next_call - sync_next_call; | 338 base::TimeDelta delta = next_call - sync_next_call; |
| 327 EXPECT_NEAR(delta.InMillisecondsRoundedUp(), 0, 10); | 339 EXPECT_NEAR(delta.InMillisecondsRoundedUp(), 0, 10); |
| 328 } | 340 } |
| OLD | NEW |