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

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

Issue 2434993002: Add methods to Reading List Model (Closed)
Patch Set: Remove ClearModelForTest Created 4 years, 2 months 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_observer.h ('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, UnreadEntry) {
175 // Setup.
176 model_->AddEntry(GURL("http://example.com"), "sample");
177 model_->MarkReadByURL(GURL("http://example.com"));
178 ClearCounts();
179 ASSERT_EQ(0ul, model_->unread_size());
180 ASSERT_EQ(1ul, model_->read_size());
181
182 // Action.
183 model_->MarkUnreadByURL(GURL("http://example.com"));
184
185 // Tests.
186 AssertObserverCount(0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
187 EXPECT_EQ(1ul, model_->unread_size());
188 EXPECT_EQ(0ul, model_->read_size());
189 EXPECT_TRUE(model_->HasUnseenEntries());
190
191 const ReadingListEntry& other_entry = model_->GetUnreadEntryAtIndex(0);
192 EXPECT_EQ(GURL("http://example.com"), other_entry.URL());
193 EXPECT_EQ("sample", other_entry.Title());
194 }
195
174 TEST_F(ReadingListModelTest, BatchUpdates) { 196 TEST_F(ReadingListModelTest, BatchUpdates) {
175 auto token = model_->BeginBatchUpdates(); 197 auto token = model_->BeginBatchUpdates();
176 AssertObserverCount(1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); 198 AssertObserverCount(1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
177 EXPECT_TRUE(model_->IsPerformingBatchUpdates()); 199 EXPECT_TRUE(model_->IsPerformingBatchUpdates());
178 200
179 delete token.release(); 201 delete token.release();
180 AssertObserverCount(1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0); 202 AssertObserverCount(1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0);
181 EXPECT_FALSE(model_->IsPerformingBatchUpdates()); 203 EXPECT_FALSE(model_->IsPerformingBatchUpdates());
182 } 204 }
183 205
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 } 357 }
336 358
337 // Tests that ReadingListModel calls CallbackModelBeingDeleted when destroyed. 359 // Tests that ReadingListModel calls CallbackModelBeingDeleted when destroyed.
338 TEST_F(ReadingListModelTest, CallbackModelBeingDeleted) { 360 TEST_F(ReadingListModelTest, CallbackModelBeingDeleted) {
339 AssertObserverCount(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); 361 AssertObserverCount(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
340 model_.reset(); 362 model_.reset();
341 AssertObserverCount(1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0); 363 AssertObserverCount(1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0);
342 } 364 }
343 365
344 } // namespace 366 } // namespace
OLDNEW
« no previous file with comments | « ios/chrome/browser/reading_list/reading_list_model_observer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698