Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: ios/chrome/browser/reading_list/reading_list_model_unittest.cc

Issue 2436743002: Add GetEntryFromURL method to the ReadingListModel. (Closed)
Patch Set: Fixed test. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ios/chrome/browser/reading_list/reading_list_model_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/bind.h" 5 #include "base/bind.h"
6 #include "ios/chrome/browser/reading_list/reading_list_model_impl.h" 6 #include "ios/chrome/browser/reading_list/reading_list_model_impl.h"
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 namespace { 9 namespace {
10 10
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 AssertObserverCount(0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 164 AssertObserverCount(0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
165 EXPECT_EQ(0ul, model_->unread_size()); 165 EXPECT_EQ(0ul, model_->unread_size());
166 EXPECT_EQ(1ul, model_->read_size()); 166 EXPECT_EQ(1ul, model_->read_size());
167 EXPECT_FALSE(model_->HasUnseenEntries()); 167 EXPECT_FALSE(model_->HasUnseenEntries());
168 168
169 const ReadingListEntry& other_entry = model_->GetReadEntryAtIndex(0); 169 const ReadingListEntry& other_entry = model_->GetReadEntryAtIndex(0);
170 EXPECT_EQ(GURL("http://example.com"), other_entry.URL()); 170 EXPECT_EQ(GURL("http://example.com"), other_entry.URL());
171 EXPECT_EQ("sample", other_entry.Title()); 171 EXPECT_EQ("sample", other_entry.Title());
172 } 172 }
173 173
174 TEST_F(ReadingListModelTest, EntryFromURL) {
175 GURL url1("http://example.com");
176 GURL url2("http://example2.com");
177 std::string entry1_title = "foo bar qux";
178 model_->AddEntry(url1, entry1_title);
179
180 const ReadingListEntry* entry1 = model_->GetEntryFromURL(url1);
181 EXPECT_NE(nullptr, entry1);
182 EXPECT_EQ(entry1_title, entry1->Title());
183 model_->MarkReadByURL(url1);
184 entry1 = model_->GetEntryFromURL(url1);
185 EXPECT_NE(nullptr, entry1);
186 EXPECT_EQ(entry1_title, entry1->Title());
187
188 const ReadingListEntry* entry2 = model_->GetEntryFromURL(url2);
189 EXPECT_EQ(nullptr, entry2);
190 }
191
174 TEST_F(ReadingListModelTest, UnreadEntry) { 192 TEST_F(ReadingListModelTest, UnreadEntry) {
175 // Setup. 193 // Setup.
176 model_->AddEntry(GURL("http://example.com"), "sample"); 194 model_->AddEntry(GURL("http://example.com"), "sample");
177 model_->MarkReadByURL(GURL("http://example.com")); 195 model_->MarkReadByURL(GURL("http://example.com"));
178 ClearCounts(); 196 ClearCounts();
179 ASSERT_EQ(0ul, model_->unread_size()); 197 ASSERT_EQ(0ul, model_->unread_size());
180 ASSERT_EQ(1ul, model_->read_size()); 198 ASSERT_EQ(1ul, model_->read_size());
181 199
182 // Action. 200 // Action.
183 model_->MarkUnreadByURL(GURL("http://example.com")); 201 model_->MarkUnreadByURL(GURL("http://example.com"));
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 } 375 }
358 376
359 // Tests that ReadingListModel calls CallbackModelBeingDeleted when destroyed. 377 // Tests that ReadingListModel calls CallbackModelBeingDeleted when destroyed.
360 TEST_F(ReadingListModelTest, CallbackModelBeingDeleted) { 378 TEST_F(ReadingListModelTest, CallbackModelBeingDeleted) {
361 AssertObserverCount(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); 379 AssertObserverCount(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
362 model_.reset(); 380 model_.reset();
363 AssertObserverCount(1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0); 381 AssertObserverCount(1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0);
364 } 382 }
365 383
366 } // namespace 384 } // namespace
OLDNEW
« no previous file with comments | « ios/chrome/browser/reading_list/reading_list_model_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698