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

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: Addressed comments. 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 EXPECT_NE(nullptr, entry1);
Olivier 2016/10/25 15:21:09 model->GetEntryFromURL(url)
jif 2016/10/25 15:36:15 Done.
185 EXPECT_EQ(entry1_title, entry1->Title());
186
187 const ReadingListEntry* entry2 = model_->GetEntryFromURL(url2);
188 EXPECT_EQ(nullptr, entry2);
189 }
190
174 TEST_F(ReadingListModelTest, UnreadEntry) { 191 TEST_F(ReadingListModelTest, UnreadEntry) {
175 // Setup. 192 // Setup.
176 model_->AddEntry(GURL("http://example.com"), "sample"); 193 model_->AddEntry(GURL("http://example.com"), "sample");
177 model_->MarkReadByURL(GURL("http://example.com")); 194 model_->MarkReadByURL(GURL("http://example.com"));
178 ClearCounts(); 195 ClearCounts();
179 ASSERT_EQ(0ul, model_->unread_size()); 196 ASSERT_EQ(0ul, model_->unread_size());
180 ASSERT_EQ(1ul, model_->read_size()); 197 ASSERT_EQ(1ul, model_->read_size());
181 198
182 // Action. 199 // Action.
183 model_->MarkUnreadByURL(GURL("http://example.com")); 200 model_->MarkUnreadByURL(GURL("http://example.com"));
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 } 374 }
358 375
359 // Tests that ReadingListModel calls CallbackModelBeingDeleted when destroyed. 376 // Tests that ReadingListModel calls CallbackModelBeingDeleted when destroyed.
360 TEST_F(ReadingListModelTest, CallbackModelBeingDeleted) { 377 TEST_F(ReadingListModelTest, CallbackModelBeingDeleted) {
361 AssertObserverCount(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); 378 AssertObserverCount(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
362 model_.reset(); 379 model_.reset();
363 AssertObserverCount(1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0); 380 AssertObserverCount(1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0);
364 } 381 }
365 382
366 } // namespace 383 } // 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