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

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: 2 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
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)
Olivier 2016/10/25 13:11:26 ;
jif-google 2016/10/25 13:51:28 Done.
182 EXPECT_EQ(entry1_title, entry1->Title());
Olivier 2016/10/25 13:11:26 mark read, then retest?
jif-google 2016/10/25 13:51:28 Done.
183
184 const ReadingListEntry* entry2 = model_->GetEntryFromURL(url2);
185 EXPECT_EQ(nullptr, entry2);
186 }
187
174 TEST_F(ReadingListModelTest, UnreadEntry) { 188 TEST_F(ReadingListModelTest, UnreadEntry) {
175 // Setup. 189 // Setup.
176 model_->AddEntry(GURL("http://example.com"), "sample"); 190 model_->AddEntry(GURL("http://example.com"), "sample");
177 model_->MarkReadByURL(GURL("http://example.com")); 191 model_->MarkReadByURL(GURL("http://example.com"));
178 ClearCounts(); 192 ClearCounts();
179 ASSERT_EQ(0ul, model_->unread_size()); 193 ASSERT_EQ(0ul, model_->unread_size());
180 ASSERT_EQ(1ul, model_->read_size()); 194 ASSERT_EQ(1ul, model_->read_size());
181 195
182 // Action. 196 // Action.
183 model_->MarkUnreadByURL(GURL("http://example.com")); 197 model_->MarkUnreadByURL(GURL("http://example.com"));
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 } 371 }
358 372
359 // Tests that ReadingListModel calls CallbackModelBeingDeleted when destroyed. 373 // Tests that ReadingListModel calls CallbackModelBeingDeleted when destroyed.
360 TEST_F(ReadingListModelTest, CallbackModelBeingDeleted) { 374 TEST_F(ReadingListModelTest, CallbackModelBeingDeleted) {
361 AssertObserverCount(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); 375 AssertObserverCount(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
362 model_.reset(); 376 model_.reset();
363 AssertObserverCount(1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0); 377 AssertObserverCount(1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0);
364 } 378 }
365 379
366 } // namespace 380 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698