| 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_model_impl.h" | 5 #include "ios/chrome/browser/reading_list/reading_list_model_impl.h" |
| 6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
| 7 | 7 |
| 8 namespace { | 8 namespace { |
| 9 | 9 |
| 10 class ReadingListModelTest : public ReadingListModelObserver, | 10 class ReadingListModelTest : public ReadingListModelObserver, |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 AssertObserverCount(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); | 121 AssertObserverCount(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); |
| 122 EXPECT_EQ(0ul, model_->unread_size()); | 122 EXPECT_EQ(0ul, model_->unread_size()); |
| 123 EXPECT_EQ(0ul, model_->read_size()); | 123 EXPECT_EQ(0ul, model_->read_size()); |
| 124 model_->Shutdown(); | 124 model_->Shutdown(); |
| 125 EXPECT_FALSE(model_->loaded()); | 125 EXPECT_FALSE(model_->loaded()); |
| 126 AssertObserverCount(1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0); | 126 AssertObserverCount(1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0); |
| 127 } | 127 } |
| 128 | 128 |
| 129 TEST_F(ReadingListModelTest, AddEntry) { | 129 TEST_F(ReadingListModelTest, AddEntry) { |
| 130 ClearCounts(); | 130 ClearCounts(); |
| 131 const ReadingListEntry entry = | 131 const ReadingListEntry& entry = |
| 132 model_->AddEntry(GURL("http://example.com"), "sample"); | 132 model_->AddEntry(GURL("http://example.com"), "sample"); |
| 133 EXPECT_EQ(GURL("http://example.com"), entry.URL()); | 133 EXPECT_EQ(GURL("http://example.com"), entry.URL()); |
| 134 EXPECT_EQ("sample", entry.Title()); | 134 EXPECT_EQ("sample", entry.Title()); |
| 135 | 135 |
| 136 AssertObserverCount(0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1); | 136 AssertObserverCount(0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1); |
| 137 EXPECT_EQ(1ul, model_->unread_size()); | 137 EXPECT_EQ(1ul, model_->unread_size()); |
| 138 EXPECT_EQ(0ul, model_->read_size()); | 138 EXPECT_EQ(0ul, model_->read_size()); |
| 139 EXPECT_TRUE(model_->HasUnseenEntries()); | 139 EXPECT_TRUE(model_->HasUnseenEntries()); |
| 140 | 140 |
| 141 const ReadingListEntry other_entry = model_->GetUnreadEntryAtIndex(0); | 141 const ReadingListEntry& other_entry = model_->GetUnreadEntryAtIndex(0); |
| 142 EXPECT_EQ(GURL("http://example.com"), other_entry.URL()); | 142 EXPECT_EQ(GURL("http://example.com"), other_entry.URL()); |
| 143 EXPECT_EQ("sample", other_entry.Title()); | 143 EXPECT_EQ("sample", other_entry.Title()); |
| 144 } | 144 } |
| 145 | 145 |
| 146 TEST_F(ReadingListModelTest, ReadEntry) { | 146 TEST_F(ReadingListModelTest, ReadEntry) { |
| 147 const ReadingListEntry entry = | 147 model_->AddEntry(GURL("http://example.com"), "sample"); |
| 148 model_->AddEntry(GURL("http://example.com"), "sample"); | |
| 149 | 148 |
| 150 ClearCounts(); | 149 ClearCounts(); |
| 151 model_->MarkReadByURL(GURL("http://example.com")); | 150 model_->MarkReadByURL(GURL("http://example.com")); |
| 152 AssertObserverCount(0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); | 151 AssertObserverCount(0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); |
| 153 EXPECT_EQ(0ul, model_->unread_size()); | 152 EXPECT_EQ(0ul, model_->unread_size()); |
| 154 EXPECT_EQ(1ul, model_->read_size()); | 153 EXPECT_EQ(1ul, model_->read_size()); |
| 155 EXPECT_FALSE(model_->HasUnseenEntries()); | 154 EXPECT_FALSE(model_->HasUnseenEntries()); |
| 156 | 155 |
| 157 const ReadingListEntry other_entry = model_->GetReadEntryAtIndex(0); | 156 const ReadingListEntry& other_entry = model_->GetReadEntryAtIndex(0); |
| 158 EXPECT_EQ(GURL("http://example.com"), other_entry.URL()); | 157 EXPECT_EQ(GURL("http://example.com"), other_entry.URL()); |
| 159 EXPECT_EQ("sample", other_entry.Title()); | 158 EXPECT_EQ("sample", other_entry.Title()); |
| 160 } | 159 } |
| 161 | 160 |
| 162 TEST_F(ReadingListModelTest, BatchUpdates) { | 161 TEST_F(ReadingListModelTest, BatchUpdates) { |
| 163 auto token = model_->BeginBatchUpdates(); | 162 auto token = model_->BeginBatchUpdates(); |
| 164 AssertObserverCount(1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); | 163 AssertObserverCount(1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); |
| 165 EXPECT_TRUE(model_->IsPerformingBatchUpdates()); | 164 EXPECT_TRUE(model_->IsPerformingBatchUpdates()); |
| 166 | 165 |
| 167 delete token.release(); | 166 delete token.release(); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 const ReadingListEntry& entry = model_->GetReadEntryAtIndex(0); | 261 const ReadingListEntry& entry = model_->GetReadEntryAtIndex(0); |
| 263 ClearCounts(); | 262 ClearCounts(); |
| 264 | 263 |
| 265 model_->SetEntryDistilledURL(gurl, gurl); | 264 model_->SetEntryDistilledURL(gurl, gurl); |
| 266 AssertObserverCount(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1); | 265 AssertObserverCount(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1); |
| 267 EXPECT_EQ(ReadingListEntry::PROCESSED, entry.DistilledState()); | 266 EXPECT_EQ(ReadingListEntry::PROCESSED, entry.DistilledState()); |
| 268 EXPECT_EQ(gurl, entry.DistilledURL()); | 267 EXPECT_EQ(gurl, entry.DistilledURL()); |
| 269 } | 268 } |
| 270 | 269 |
| 271 } // namespace | 270 } // namespace |
| OLD | NEW |