| 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 "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 | 8 |
| 9 TEST(ReadingListEntry, CompareIgnoreTitle) { | 9 TEST(ReadingListEntry, CompareIgnoreTitle) { |
| 10 const ReadingListEntry e1(GURL("http://example.com"), "bar"); | 10 const ReadingListEntry e1(GURL("http://example.com"), "bar"); |
| 11 const ReadingListEntry e2(GURL("http://example.com"), "foo"); | 11 const ReadingListEntry e2(GURL("http://example.com"), "foo"); |
| 12 | 12 |
| 13 EXPECT_EQ(e1, e2); | 13 EXPECT_EQ(e1, e2); |
| 14 } | 14 } |
| 15 | 15 |
| 16 TEST(ReadingListEntry, CompareFailureIgnoreTitle) { | 16 TEST(ReadingListEntry, CompareFailureIgnoreTitle) { |
| 17 const ReadingListEntry e1(GURL("http://example.com"), "bar"); | 17 const ReadingListEntry e1(GURL("http://example.com"), "bar"); |
| 18 const ReadingListEntry e2(GURL("http://example.org"), "bar"); | 18 const ReadingListEntry e2(GURL("http://example.org"), "bar"); |
| 19 | 19 |
| 20 EXPECT_FALSE(e1 == e2); | 20 EXPECT_FALSE(e1 == e2); |
| 21 } | 21 } |
| 22 | 22 |
| 23 TEST(ReadingListEntry, CopyAreEquals) { | 23 TEST(ReadingListEntry, MovesAreEquals) { |
| 24 const ReadingListEntry e1(GURL("http://example.com"), "bar"); | 24 ReadingListEntry e1(GURL("http://example.com"), "bar"); |
| 25 const ReadingListEntry e2(e1); | 25 ReadingListEntry e2(GURL("http://example.com"), "bar"); |
| 26 ASSERT_EQ(e1, e2); |
| 27 ASSERT_EQ(e1.Title(), e2.Title()); |
| 26 | 28 |
| 27 EXPECT_EQ(e1, e2); | 29 ReadingListEntry e3(std::move(e1)); |
| 28 EXPECT_EQ(e1.Title(), e2.Title()); | 30 |
| 31 EXPECT_EQ(e3, e2); |
| 32 EXPECT_EQ(e3.Title(), e2.Title()); |
| 29 } | 33 } |
| 30 | 34 |
| 31 TEST(ReadingListEntry, DistilledURL) { | 35 TEST(ReadingListEntry, DistilledURL) { |
| 32 ReadingListEntry e(GURL("http://example.com"), "bar"); | 36 ReadingListEntry e(GURL("http://example.com"), "bar"); |
| 33 | 37 |
| 34 EXPECT_FALSE(e.DistilledURL().is_valid()); | 38 EXPECT_FALSE(e.DistilledURL().is_valid()); |
| 35 | 39 |
| 36 const GURL distilled_url("http://distilled.example.com"); | 40 const GURL distilled_url("http://distilled.example.com"); |
| 37 e.SetDistilledURL(distilled_url); | 41 e.SetDistilledURL(distilled_url); |
| 38 EXPECT_EQ(distilled_url, e.DistilledURL()); | 42 EXPECT_EQ(distilled_url, e.DistilledURL()); |
| 39 } | 43 } |
| 40 | 44 |
| 41 TEST(ReadingListEntry, DistilledState) { | 45 TEST(ReadingListEntry, DistilledState) { |
| 42 ReadingListEntry e(GURL("http://example.com"), "bar"); | 46 ReadingListEntry e(GURL("http://example.com"), "bar"); |
| 43 | 47 |
| 44 EXPECT_EQ(ReadingListEntry::WAITING, e.DistilledState()); | 48 EXPECT_EQ(ReadingListEntry::WAITING, e.DistilledState()); |
| 45 | 49 |
| 46 e.SetDistilledState(ReadingListEntry::ERROR); | 50 e.SetDistilledState(ReadingListEntry::ERROR); |
| 47 EXPECT_EQ(ReadingListEntry::ERROR, e.DistilledState()); | 51 EXPECT_EQ(ReadingListEntry::ERROR, e.DistilledState()); |
| 48 | 52 |
| 49 const GURL distilled_url("http://distilled.example.com"); | 53 const GURL distilled_url("http://distilled.example.com"); |
| 50 e.SetDistilledURL(distilled_url); | 54 e.SetDistilledURL(distilled_url); |
| 51 EXPECT_EQ(ReadingListEntry::PROCESSED, e.DistilledState()); | 55 EXPECT_EQ(ReadingListEntry::PROCESSED, e.DistilledState()); |
| 52 } | 56 } |
| OLD | NEW |