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 "ios/chrome/browser/reading_list/reading_list_entry.h" | 5 #include "components/reading_list/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/proto/reading_list.pb.h" |
9 #include "components/sync/protocol/reading_list_specifics.pb.h" | 10 #include "components/sync/protocol/reading_list_specifics.pb.h" |
10 #include "ios/chrome/browser/reading_list/proto/reading_list.pb.h" | |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 | 12 |
13 namespace { | 13 namespace { |
14 const int kFirstBackoff = 10; | 14 const int kFirstBackoff = 10; |
15 const int kSecondBackoff = 10; | 15 const int kSecondBackoff = 10; |
16 const int kThirdBackoff = 60; | 16 const int kThirdBackoff = 60; |
17 const int kFourthBackoff = 120; | 17 const int kFourthBackoff = 120; |
18 const int kFifthBackoff = 120; | 18 const int kFifthBackoff = 120; |
19 } // namespace | 19 } // namespace |
20 | 20 |
(...skipping 24 matching lines...) Expand all Loading... |
45 } | 45 } |
46 | 46 |
47 TEST(ReadingListEntry, DistilledPathAndURL) { | 47 TEST(ReadingListEntry, DistilledPathAndURL) { |
48 ReadingListEntry e(GURL("http://example.com"), "bar"); | 48 ReadingListEntry e(GURL("http://example.com"), "bar"); |
49 | 49 |
50 EXPECT_TRUE(e.DistilledPath().empty()); | 50 EXPECT_TRUE(e.DistilledPath().empty()); |
51 | 51 |
52 const base::FilePath distilled_path("distilled/page.html"); | 52 const base::FilePath distilled_path("distilled/page.html"); |
53 e.SetDistilledPath(distilled_path); | 53 e.SetDistilledPath(distilled_path); |
54 EXPECT_EQ(distilled_path, e.DistilledPath()); | 54 EXPECT_EQ(distilled_path, e.DistilledPath()); |
55 EXPECT_EQ(GURL("chrome://offline/distilled/page.html"), e.DistilledURL()); | |
56 } | 55 } |
57 | 56 |
58 TEST(ReadingListEntry, DistilledState) { | 57 TEST(ReadingListEntry, DistilledState) { |
59 ReadingListEntry e(GURL("http://example.com"), "bar"); | 58 ReadingListEntry e(GURL("http://example.com"), "bar"); |
60 | 59 |
61 EXPECT_EQ(ReadingListEntry::WAITING, e.DistilledState()); | 60 EXPECT_EQ(ReadingListEntry::WAITING, e.DistilledState()); |
62 | 61 |
63 e.SetDistilledState(ReadingListEntry::ERROR); | 62 e.SetDistilledState(ReadingListEntry::ERROR); |
64 EXPECT_EQ(ReadingListEntry::ERROR, e.DistilledState()); | 63 EXPECT_EQ(ReadingListEntry::ERROR, e.DistilledState()); |
65 | 64 |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 EXPECT_EQ(sync_entry.URL().spec(), "http://example2.com/"); | 318 EXPECT_EQ(sync_entry.URL().spec(), "http://example2.com/"); |
320 EXPECT_EQ(sync_entry.Title(), "title2"); | 319 EXPECT_EQ(sync_entry.Title(), "title2"); |
321 EXPECT_EQ(sync_entry.UpdateTime(), sync_update_time_us); | 320 EXPECT_EQ(sync_entry.UpdateTime(), sync_update_time_us); |
322 EXPECT_EQ(sync_entry.FailedDownloadCounter(), 0); | 321 EXPECT_EQ(sync_entry.FailedDownloadCounter(), 0); |
323 EXPECT_EQ(sync_entry.DistilledState(), ReadingListEntry::PROCESSED); | 322 EXPECT_EQ(sync_entry.DistilledState(), ReadingListEntry::PROCESSED); |
324 EXPECT_EQ(sync_entry.DistilledPath().value(), "distilled/page.html"); | 323 EXPECT_EQ(sync_entry.DistilledPath().value(), "distilled/page.html"); |
325 base::Time sync_next_call = base::Time::Now() + sync_entry.TimeUntilNextTry(); | 324 base::Time sync_next_call = base::Time::Now() + sync_entry.TimeUntilNextTry(); |
326 base::TimeDelta delta = next_call - sync_next_call; | 325 base::TimeDelta delta = next_call - sync_next_call; |
327 EXPECT_NEAR(delta.InMillisecondsRoundedUp(), 0, 10); | 326 EXPECT_NEAR(delta.InMillisecondsRoundedUp(), 0, 10); |
328 } | 327 } |
OLD | NEW |