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 "ios/chrome/browser/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 "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 ASSERT_EQ(2, e.TimeUntilNextTry().InSeconds()); | 123 ASSERT_EQ(2, e.TimeUntilNextTry().InSeconds()); |
124 | 124 |
125 // Action. | 125 // Action. |
126 e.SetDistilledURL(GURL("http://example.com")); | 126 e.SetDistilledURL(GURL("http://example.com")); |
127 | 127 |
128 // Test. | 128 // Test. |
129 EXPECT_EQ(0, e.TimeUntilNextTry().InSeconds()); | 129 EXPECT_EQ(0, e.TimeUntilNextTry().InSeconds()); |
130 e.SetDistilledState(ReadingListEntry::ERROR); | 130 e.SetDistilledState(ReadingListEntry::ERROR); |
131 EXPECT_EQ(1, e.TimeUntilNextTry().InSeconds()); | 131 EXPECT_EQ(1, e.TimeUntilNextTry().InSeconds()); |
132 } | 132 } |
| 133 |
| 134 // Tests that the failed download counter is incremented when the state change |
| 135 // from non-error to error. |
| 136 TEST(ReadingListEntry, FailedDownloadCounter) { |
| 137 ReadingListEntry e(GURL("http://example.com"), "bar"); |
| 138 |
| 139 ASSERT_EQ(0, e.FailedDownloadCounter()); |
| 140 |
| 141 e.SetDistilledState(ReadingListEntry::ERROR); |
| 142 EXPECT_EQ(1, e.FailedDownloadCounter()); |
| 143 e.SetDistilledState(ReadingListEntry::WILL_RETRY); |
| 144 EXPECT_EQ(1, e.FailedDownloadCounter()); |
| 145 |
| 146 e.SetDistilledState(ReadingListEntry::PROCESSING); |
| 147 EXPECT_EQ(1, e.FailedDownloadCounter()); |
| 148 |
| 149 e.SetDistilledState(ReadingListEntry::WILL_RETRY); |
| 150 EXPECT_EQ(2, e.FailedDownloadCounter()); |
| 151 e.SetDistilledState(ReadingListEntry::ERROR); |
| 152 EXPECT_EQ(2, e.FailedDownloadCounter()); |
| 153 } |
OLD | NEW |