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

Side by Side Diff: components/reading_list/ios/reading_list_model_unittest.mm

Issue 2647763005: Store the distilled_url in Reading List entry in Reading List on iOS. (Closed)
Patch Set: Created 3 years, 11 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
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 "components/reading_list/ios/reading_list_model.h" 5 #include "components/reading_list/ios/reading_list_model.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #import "base/test/ios/wait_util.h" 9 #import "base/test/ios/wait_util.h"
10 #include "components/reading_list/ios/reading_list_model_impl.h" 10 #include "components/reading_list/ios/reading_list_model_impl.h"
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 ClearCounts(); 363 ClearCounts();
364 364
365 model_->SyncAddEntry(std::move(entry)); 365 model_->SyncAddEntry(std::move(entry));
366 AssertObserverCount(0, 0, 0, 0, 0, 0, 1, 0, 1); 366 AssertObserverCount(0, 0, 0, 0, 0, 0, 1, 0, 1);
367 AssertStorageCount(0, 0); 367 AssertStorageCount(0, 0);
368 EXPECT_EQ(0ul, UnreadSize()); 368 EXPECT_EQ(0ul, UnreadSize());
369 EXPECT_EQ(1ul, ReadSize()); 369 EXPECT_EQ(1ul, ReadSize());
370 ClearCounts(); 370 ClearCounts();
371 } 371 }
372 372
373 TEST_F(ReadingListModelTest, SyncMergeEntry) { 373 TEST_F(ReadingListModelTest, SyncMergeEntry) {
gambard 2017/01/20 14:01:25 Maybe out of scope, but can you add comments to al
Olivier 2017/01/20 14:43:51 Done.
374 auto storage = base::MakeUnique<TestReadingListStorage>(this); 374 auto storage = base::MakeUnique<TestReadingListStorage>(this);
375 SetStorage(std::move(storage)); 375 SetStorage(std::move(storage));
376 model_->AddEntry(GURL("http://example.com"), "sample", 376 model_->AddEntry(GURL("http://example.com"), "sample",
377 reading_list::ADDED_VIA_CURRENT_APP); 377 reading_list::ADDED_VIA_CURRENT_APP);
378 model_->SetEntryDistilledPath(GURL("http://example.com"), 378 const base::FilePath distilled_path("distilled/page.html");
379 base::FilePath("distilled/page.html")); 379 const GURL distilled_url("http://example.com/distilled");
380 model_->SetEntryDistilledInfo(GURL("http://example.com"), distilled_path,
381 distilled_url);
380 const ReadingListEntry* local_entry = 382 const ReadingListEntry* local_entry =
381 model_->GetEntryByURL(GURL("http://example.com")); 383 model_->GetEntryByURL(GURL("http://example.com"));
382 int64_t local_update_time = local_entry->UpdateTime(); 384 int64_t local_update_time = local_entry->UpdateTime();
383 385
384 base::test::ios::SpinRunLoopWithMinDelay( 386 base::test::ios::SpinRunLoopWithMinDelay(
385 base::TimeDelta::FromMilliseconds(10)); 387 base::TimeDelta::FromMilliseconds(10));
386 auto sync_entry = 388 auto sync_entry =
387 base::MakeUnique<ReadingListEntry>(GURL("http://example.com"), "sample"); 389 base::MakeUnique<ReadingListEntry>(GURL("http://example.com"), "sample");
388 sync_entry->SetRead(true); 390 sync_entry->SetRead(true);
389 ASSERT_GT(sync_entry->UpdateTime(), local_update_time); 391 ASSERT_GT(sync_entry->UpdateTime(), local_update_time);
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 AssertObserverCount(0, 0, 0, 0, 0, 0, 0, 1, 1); 600 AssertObserverCount(0, 0, 0, 0, 0, 0, 0, 1, 1);
599 EXPECT_EQ(ReadingListEntry::PROCESSING, entry.DistilledState()); 601 EXPECT_EQ(ReadingListEntry::PROCESSING, entry.DistilledState());
600 } 602 }
601 603
602 TEST_F(ReadingListModelTest, UpdateDistilledPath) { 604 TEST_F(ReadingListModelTest, UpdateDistilledPath) {
603 const GURL gurl("http://example.com"); 605 const GURL gurl("http://example.com");
604 const ReadingListEntry& entry = 606 const ReadingListEntry& entry =
605 model_->AddEntry(gurl, "sample", reading_list::ADDED_VIA_CURRENT_APP); 607 model_->AddEntry(gurl, "sample", reading_list::ADDED_VIA_CURRENT_APP);
606 ClearCounts(); 608 ClearCounts();
607 609
608 model_->SetEntryDistilledPath(gurl, base::FilePath("distilled/page.html")); 610 const base::FilePath distilled_path("distilled/page.html");
611 const GURL distilled_url("http://example.com/distilled");
612 model_->SetEntryDistilledInfo(GURL("http://example.com"), distilled_path,
613 distilled_url);
609 AssertObserverCount(0, 0, 0, 0, 0, 0, 0, 1, 1); 614 AssertObserverCount(0, 0, 0, 0, 0, 0, 0, 1, 1);
610 EXPECT_EQ(ReadingListEntry::PROCESSED, entry.DistilledState()); 615 EXPECT_EQ(ReadingListEntry::PROCESSED, entry.DistilledState());
611 EXPECT_EQ(base::FilePath("distilled/page.html"), entry.DistilledPath()); 616 EXPECT_EQ(base::FilePath("distilled/page.html"), entry.DistilledPath());
gambard 2017/01/20 14:01:25 Add test for the distilled url.
Olivier 2017/01/20 14:43:51 Done.
612 } 617 }
613 618
614 TEST_F(ReadingListModelTest, UpdateReadEntryTitle) { 619 TEST_F(ReadingListModelTest, UpdateReadEntryTitle) {
615 const GURL gurl("http://example.com"); 620 const GURL gurl("http://example.com");
616 model_->AddEntry(gurl, "sample", reading_list::ADDED_VIA_CURRENT_APP); 621 model_->AddEntry(gurl, "sample", reading_list::ADDED_VIA_CURRENT_APP);
617 model_->SetReadStatus(gurl, true); 622 model_->SetReadStatus(gurl, true);
618 const ReadingListEntry* entry = model_->GetEntryByURL(gurl); 623 const ReadingListEntry* entry = model_->GetEntryByURL(gurl);
619 ClearCounts(); 624 ClearCounts();
620 625
621 model_->SetEntryTitle(gurl, "ping"); 626 model_->SetEntryTitle(gurl, "ping");
(...skipping 13 matching lines...) Expand all
635 EXPECT_EQ(ReadingListEntry::PROCESSING, entry->DistilledState()); 640 EXPECT_EQ(ReadingListEntry::PROCESSING, entry->DistilledState());
636 } 641 }
637 642
638 TEST_F(ReadingListModelTest, UpdateReadDistilledPath) { 643 TEST_F(ReadingListModelTest, UpdateReadDistilledPath) {
639 const GURL gurl("http://example.com"); 644 const GURL gurl("http://example.com");
640 model_->AddEntry(gurl, "sample", reading_list::ADDED_VIA_CURRENT_APP); 645 model_->AddEntry(gurl, "sample", reading_list::ADDED_VIA_CURRENT_APP);
641 model_->SetReadStatus(gurl, true); 646 model_->SetReadStatus(gurl, true);
642 const ReadingListEntry* entry = model_->GetEntryByURL(gurl); 647 const ReadingListEntry* entry = model_->GetEntryByURL(gurl);
643 ClearCounts(); 648 ClearCounts();
644 649
645 model_->SetEntryDistilledPath(gurl, base::FilePath("distilled/page.html")); 650 const base::FilePath distilled_path("distilled/page.html");
651 const GURL distilled_url("http://example.com/distilled");
652 model_->SetEntryDistilledInfo(GURL("http://example.com"), distilled_path,
653 distilled_url);
646 AssertObserverCount(0, 0, 0, 0, 0, 0, 0, 1, 1); 654 AssertObserverCount(0, 0, 0, 0, 0, 0, 0, 1, 1);
647 EXPECT_EQ(ReadingListEntry::PROCESSED, entry->DistilledState()); 655 EXPECT_EQ(ReadingListEntry::PROCESSED, entry->DistilledState());
648 EXPECT_EQ(base::FilePath("distilled/page.html"), entry->DistilledPath()); 656 EXPECT_EQ(base::FilePath("distilled/page.html"), entry->DistilledPath());
gambard 2017/01/20 14:01:24 Add test for distilled url.
Olivier 2017/01/20 14:43:51 Done.
649 } 657 }
650 658
651 // Tests that ReadingListModel calls CallbackModelBeingDeleted when destroyed. 659 // Tests that ReadingListModel calls CallbackModelBeingDeleted when destroyed.
652 TEST_F(ReadingListModelTest, CallbackModelBeingDeleted) { 660 TEST_F(ReadingListModelTest, CallbackModelBeingDeleted) {
653 AssertObserverCount(1, 0, 0, 0, 0, 0, 0, 0, 0); 661 AssertObserverCount(1, 0, 0, 0, 0, 0, 0, 0, 0);
654 model_.reset(); 662 model_.reset();
655 AssertObserverCount(1, 0, 0, 1, 0, 0, 0, 0, 0); 663 AssertObserverCount(1, 0, 0, 1, 0, 0, 0, 0, 0);
656 } 664 }
657 665
658 } // namespace 666 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698