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

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

Issue 2541683003: Clean ReadingListModel. (Closed)
Patch Set: Created 4 years 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 | « components/reading_list/ios/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 "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 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 551
552 model_->SetEntryDistilledPath(gurl, base::FilePath("distilled/page.html")); 552 model_->SetEntryDistilledPath(gurl, base::FilePath("distilled/page.html"));
553 AssertObserverCount(0, 0, 0, 0, 0, 0, 0, 1, 1); 553 AssertObserverCount(0, 0, 0, 0, 0, 0, 0, 1, 1);
554 EXPECT_EQ(ReadingListEntry::PROCESSED, entry.DistilledState()); 554 EXPECT_EQ(ReadingListEntry::PROCESSED, entry.DistilledState());
555 EXPECT_EQ(base::FilePath("distilled/page.html"), entry.DistilledPath()); 555 EXPECT_EQ(base::FilePath("distilled/page.html"), entry.DistilledPath());
556 } 556 }
557 557
558 TEST_F(ReadingListModelTest, UpdateReadEntryTitle) { 558 TEST_F(ReadingListModelTest, UpdateReadEntryTitle) {
559 const GURL gurl("http://example.com"); 559 const GURL gurl("http://example.com");
560 model_->AddEntry(gurl, "sample"); 560 model_->AddEntry(gurl, "sample");
561 model_->MarkReadByURL(gurl); 561 model_->SetReadStatus(gurl, true);
562 const ReadingListEntry& entry = model_->GetReadEntryAtIndex(0); 562 const ReadingListEntry* entry = model_->GetEntryByURL(gurl);
563 ClearCounts(); 563 ClearCounts();
564 564
565 model_->SetEntryTitle(gurl, "ping"); 565 model_->SetEntryTitle(gurl, "ping");
566 AssertObserverCount(0, 0, 0, 0, 0, 0, 0, 1, 1); 566 AssertObserverCount(0, 0, 0, 0, 0, 0, 0, 1, 1);
567 EXPECT_EQ("ping", entry.Title()); 567 EXPECT_EQ("ping", entry->Title());
568 } 568 }
569 569
570 TEST_F(ReadingListModelTest, UpdateReadEntryState) { 570 TEST_F(ReadingListModelTest, UpdateReadEntryState) {
571 const GURL gurl("http://example.com"); 571 const GURL gurl("http://example.com");
572 model_->AddEntry(gurl, "sample"); 572 model_->AddEntry(gurl, "sample");
573 model_->MarkReadByURL(gurl); 573 model_->SetReadStatus(gurl, true);
574 const ReadingListEntry& entry = model_->GetReadEntryAtIndex(0); 574 const ReadingListEntry* entry = model_->GetEntryByURL(gurl);
575 ClearCounts(); 575 ClearCounts();
576 576
577 model_->SetEntryDistilledState(gurl, ReadingListEntry::PROCESSING); 577 model_->SetEntryDistilledState(gurl, ReadingListEntry::PROCESSING);
578 AssertObserverCount(0, 0, 0, 0, 0, 0, 0, 1, 1); 578 AssertObserverCount(0, 0, 0, 0, 0, 0, 0, 1, 1);
579 EXPECT_EQ(ReadingListEntry::PROCESSING, entry.DistilledState()); 579 EXPECT_EQ(ReadingListEntry::PROCESSING, entry->DistilledState());
580 } 580 }
581 581
582 TEST_F(ReadingListModelTest, UpdateReadDistilledPath) { 582 TEST_F(ReadingListModelTest, UpdateReadDistilledPath) {
583 const GURL gurl("http://example.com"); 583 const GURL gurl("http://example.com");
584 model_->AddEntry(gurl, "sample"); 584 model_->AddEntry(gurl, "sample");
585 model_->MarkReadByURL(gurl); 585 model_->SetReadStatus(gurl, true);
586 const ReadingListEntry& entry = model_->GetReadEntryAtIndex(0); 586 const ReadingListEntry* entry = model_->GetEntryByURL(gurl);
587 ClearCounts(); 587 ClearCounts();
588 588
589 model_->SetEntryDistilledPath(gurl, base::FilePath("distilled/page.html")); 589 model_->SetEntryDistilledPath(gurl, base::FilePath("distilled/page.html"));
590 AssertObserverCount(0, 0, 0, 0, 0, 0, 0, 1, 1); 590 AssertObserverCount(0, 0, 0, 0, 0, 0, 0, 1, 1);
591 EXPECT_EQ(ReadingListEntry::PROCESSED, entry.DistilledState()); 591 EXPECT_EQ(ReadingListEntry::PROCESSED, entry->DistilledState());
592 EXPECT_EQ(base::FilePath("distilled/page.html"), entry.DistilledPath()); 592 EXPECT_EQ(base::FilePath("distilled/page.html"), entry->DistilledPath());
593 } 593 }
594 594
595 // Tests that ReadingListModel calls CallbackModelBeingDeleted when destroyed. 595 // Tests that ReadingListModel calls CallbackModelBeingDeleted when destroyed.
596 TEST_F(ReadingListModelTest, CallbackModelBeingDeleted) { 596 TEST_F(ReadingListModelTest, CallbackModelBeingDeleted) {
597 AssertObserverCount(1, 0, 0, 0, 0, 0, 0, 0, 0); 597 AssertObserverCount(1, 0, 0, 0, 0, 0, 0, 0, 0);
598 model_.reset(); 598 model_.reset();
599 AssertObserverCount(1, 0, 0, 1, 0, 0, 0, 0, 0); 599 AssertObserverCount(1, 0, 0, 1, 0, 0, 0, 0, 0);
600 } 600 }
601 601
602 } // namespace 602 } // namespace
OLDNEW
« no previous file with comments | « components/reading_list/ios/reading_list_model_observer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698