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

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

Issue 2491383002: Use Distilled path instead of DistilledURL. (Closed)
Patch Set: feedback 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 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 TEST_F(ReadingListModelTest, UpdateEntryState) { 265 TEST_F(ReadingListModelTest, UpdateEntryState) {
266 const GURL gurl("http://example.com"); 266 const GURL gurl("http://example.com");
267 const ReadingListEntry& entry = model_->AddEntry(gurl, "sample"); 267 const ReadingListEntry& entry = model_->AddEntry(gurl, "sample");
268 ClearCounts(); 268 ClearCounts();
269 269
270 model_->SetEntryDistilledState(gurl, ReadingListEntry::PROCESSING); 270 model_->SetEntryDistilledState(gurl, ReadingListEntry::PROCESSING);
271 AssertObserverCount(0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1); 271 AssertObserverCount(0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1);
272 EXPECT_EQ(ReadingListEntry::PROCESSING, entry.DistilledState()); 272 EXPECT_EQ(ReadingListEntry::PROCESSING, entry.DistilledState());
273 } 273 }
274 274
275 TEST_F(ReadingListModelTest, UpdateDistilledURL) { 275 TEST_F(ReadingListModelTest, UpdateDistilledPath) {
276 const GURL gurl("http://example.com"); 276 const GURL gurl("http://example.com");
277 const ReadingListEntry& entry = model_->AddEntry(gurl, "sample"); 277 const ReadingListEntry& entry = model_->AddEntry(gurl, "sample");
278 ClearCounts(); 278 ClearCounts();
279 279
280 model_->SetEntryDistilledURL(gurl, gurl); 280 model_->SetEntryDistilledPath(gurl, base::FilePath("distilled/page.html"));
281 AssertObserverCount(0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1); 281 AssertObserverCount(0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1);
282 EXPECT_EQ(ReadingListEntry::PROCESSED, entry.DistilledState()); 282 EXPECT_EQ(ReadingListEntry::PROCESSED, entry.DistilledState());
283 EXPECT_EQ(gurl, entry.DistilledURL()); 283 EXPECT_EQ(GURL("chrome://offline/distilled/page.html"), entry.DistilledURL());
gambard 2016/11/10 16:54:35 DistilledURL of DistilledPath?
Olivier 2016/11/14 16:43:23 Done.
284 } 284 }
285 285
286 TEST_F(ReadingListModelTest, UpdateReadEntryTitle) { 286 TEST_F(ReadingListModelTest, UpdateReadEntryTitle) {
287 const GURL gurl("http://example.com"); 287 const GURL gurl("http://example.com");
288 model_->AddEntry(gurl, "sample"); 288 model_->AddEntry(gurl, "sample");
289 model_->MarkReadByURL(gurl); 289 model_->MarkReadByURL(gurl);
290 const ReadingListEntry& entry = model_->GetReadEntryAtIndex(0); 290 const ReadingListEntry& entry = model_->GetReadEntryAtIndex(0);
291 ClearCounts(); 291 ClearCounts();
292 292
293 model_->SetEntryTitle(gurl, "ping"); 293 model_->SetEntryTitle(gurl, "ping");
294 AssertObserverCount(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1); 294 AssertObserverCount(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1);
295 EXPECT_EQ("ping", entry.Title()); 295 EXPECT_EQ("ping", entry.Title());
296 } 296 }
297 297
298 TEST_F(ReadingListModelTest, UpdateReadEntryState) { 298 TEST_F(ReadingListModelTest, UpdateReadEntryState) {
299 const GURL gurl("http://example.com"); 299 const GURL gurl("http://example.com");
300 model_->AddEntry(gurl, "sample"); 300 model_->AddEntry(gurl, "sample");
301 model_->MarkReadByURL(gurl); 301 model_->MarkReadByURL(gurl);
302 const ReadingListEntry& entry = model_->GetReadEntryAtIndex(0); 302 const ReadingListEntry& entry = model_->GetReadEntryAtIndex(0);
303 ClearCounts(); 303 ClearCounts();
304 304
305 model_->SetEntryDistilledState(gurl, ReadingListEntry::PROCESSING); 305 model_->SetEntryDistilledState(gurl, ReadingListEntry::PROCESSING);
306 AssertObserverCount(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1); 306 AssertObserverCount(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1);
307 EXPECT_EQ(ReadingListEntry::PROCESSING, entry.DistilledState()); 307 EXPECT_EQ(ReadingListEntry::PROCESSING, entry.DistilledState());
308 } 308 }
309 309
310 TEST_F(ReadingListModelTest, UpdateReadDistilledURL) { 310 TEST_F(ReadingListModelTest, UpdateReadDistilledPath) {
311 const GURL gurl("http://example.com"); 311 const GURL gurl("http://example.com");
312 model_->AddEntry(gurl, "sample"); 312 model_->AddEntry(gurl, "sample");
313 model_->MarkReadByURL(gurl); 313 model_->MarkReadByURL(gurl);
314 const ReadingListEntry& entry = model_->GetReadEntryAtIndex(0); 314 const ReadingListEntry& entry = model_->GetReadEntryAtIndex(0);
315 ClearCounts(); 315 ClearCounts();
316 316
317 model_->SetEntryDistilledURL(gurl, gurl); 317 model_->SetEntryDistilledPath(gurl, base::FilePath("distilled/page.html"));
318 AssertObserverCount(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1); 318 AssertObserverCount(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1);
319 EXPECT_EQ(ReadingListEntry::PROCESSED, entry.DistilledState()); 319 EXPECT_EQ(ReadingListEntry::PROCESSED, entry.DistilledState());
320 EXPECT_EQ(gurl, entry.DistilledURL()); 320 EXPECT_EQ(GURL("chrome://offline/distilled/page.html"), entry.DistilledURL());
321 } 321 }
322 322
323 // Tests that the callback is called when the entry is unread. 323 // Tests that the callback is called when the entry is unread.
324 TEST_F(ReadingListModelTest, CallbackEntryURLUnread) { 324 TEST_F(ReadingListModelTest, CallbackEntryURLUnread) {
325 // Setup. 325 // Setup.
326 model_->AddEntry(callback_url, callback_title); 326 model_->AddEntry(callback_url, callback_title);
327 327
328 ASSERT_EQ(0UL, model_->read_size()); 328 ASSERT_EQ(0UL, model_->read_size());
329 ASSERT_EQ(1UL, model_->unread_size()); 329 ASSERT_EQ(1UL, model_->unread_size());
330 330
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 } 375 }
376 376
377 // Tests that ReadingListModel calls CallbackModelBeingDeleted when destroyed. 377 // Tests that ReadingListModel calls CallbackModelBeingDeleted when destroyed.
378 TEST_F(ReadingListModelTest, CallbackModelBeingDeleted) { 378 TEST_F(ReadingListModelTest, CallbackModelBeingDeleted) {
379 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);
380 model_.reset(); 380 model_.reset();
381 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);
382 } 382 }
383 383
384 } // namespace 384 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698