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

Side by Side Diff: components/reading_list/reading_list_model_unittest.cc

Issue 2514333003: Componentize Reading List (Closed)
Patch Set: rebase 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 "base/memory/ptr_util.h" 6 #include "base/memory/ptr_util.h"
7 #import "base/test/ios/wait_util.h" 7 #import "base/test/ios/wait_util.h"
8 #include "ios/chrome/browser/reading_list/reading_list_model_impl.h" 8 #include "components/reading_list/reading_list_model_impl.h"
9 #include "ios/chrome/browser/reading_list/reading_list_model_storage.h" 9 #include "components/reading_list/reading_list_model_storage.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 11
12 namespace { 12 namespace {
13 13
14 const GURL callback_url("http://example.com"); 14 const GURL callback_url("http://example.com");
15 const std::string callback_title("test title"); 15 const std::string callback_title("test title");
16 16
17 class TestReadingListStorageObserver { 17 class TestReadingListStorageObserver {
18 public: 18 public:
19 virtual void ReadingListDidSaveEntry() = 0; 19 virtual void ReadingListDidSaveEntry() = 0;
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 const ReadingListEntry* local_entry = 304 const ReadingListEntry* local_entry =
305 model_->GetEntryFromURL(GURL("http://example.com"), nullptr); 305 model_->GetEntryFromURL(GURL("http://example.com"), nullptr);
306 int64_t local_update_time = local_entry->UpdateTime(); 306 int64_t local_update_time = local_entry->UpdateTime();
307 307
308 base::test::ios::SpinRunLoopWithMinDelay( 308 base::test::ios::SpinRunLoopWithMinDelay(
309 base::TimeDelta::FromMilliseconds(10)); 309 base::TimeDelta::FromMilliseconds(10));
310 auto sync_entry = 310 auto sync_entry =
311 base::MakeUnique<ReadingListEntry>(GURL("http://example.com"), "sample"); 311 base::MakeUnique<ReadingListEntry>(GURL("http://example.com"), "sample");
312 ASSERT_GT(sync_entry->UpdateTime(), local_update_time); 312 ASSERT_GT(sync_entry->UpdateTime(), local_update_time);
313 int64_t sync_update_time = sync_entry->UpdateTime(); 313 int64_t sync_update_time = sync_entry->UpdateTime();
314 EXPECT_FALSE(sync_entry->DistilledURL().is_valid()); 314 EXPECT_TRUE(sync_entry->DistilledPath().empty());
315 315
316 EXPECT_EQ(model_->unread_size(), 1u); 316 EXPECT_EQ(model_->unread_size(), 1u);
317 EXPECT_EQ(model_->read_size(), 0u); 317 EXPECT_EQ(model_->read_size(), 0u);
318 318
319 ReadingListEntry* merged_entry = 319 ReadingListEntry* merged_entry =
320 model_->SyncMergeEntry(std::move(sync_entry), true); 320 model_->SyncMergeEntry(std::move(sync_entry), true);
321 EXPECT_EQ(model_->unread_size(), 0u); 321 EXPECT_EQ(model_->unread_size(), 0u);
322 EXPECT_EQ(model_->read_size(), 1u); 322 EXPECT_EQ(model_->read_size(), 1u);
323 EXPECT_EQ(merged_entry->DistilledPath(), 323 EXPECT_EQ(merged_entry->DistilledPath(),
324 base::FilePath("distilled/page.html")); 324 base::FilePath("distilled/page.html"));
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 TEST_F(ReadingListModelTest, UpdateReadDistilledPath) { 545 TEST_F(ReadingListModelTest, UpdateReadDistilledPath) {
546 const GURL gurl("http://example.com"); 546 const GURL gurl("http://example.com");
547 model_->AddEntry(gurl, "sample"); 547 model_->AddEntry(gurl, "sample");
548 model_->MarkReadByURL(gurl); 548 model_->MarkReadByURL(gurl);
549 const ReadingListEntry& entry = model_->GetReadEntryAtIndex(0); 549 const ReadingListEntry& entry = model_->GetReadEntryAtIndex(0);
550 ClearCounts(); 550 ClearCounts();
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, 0, 0, 0, 1, 1); 553 AssertObserverCount(0, 0, 0, 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(GURL("chrome://offline/distilled/page.html"), entry.DistilledURL()); 555 EXPECT_EQ(base::FilePath("distilled/page.html"), entry.DistilledPath());
556 } 556 }
557 557
558 // Tests that the callback is called when the entry is unread. 558 // Tests that the callback is called when the entry is unread.
559 TEST_F(ReadingListModelTest, CallbackEntryURLUnread) { 559 TEST_F(ReadingListModelTest, CallbackEntryURLUnread) {
560 // Setup. 560 // Setup.
561 model_->AddEntry(callback_url, callback_title); 561 model_->AddEntry(callback_url, callback_title);
562 562
563 ASSERT_EQ(0UL, model_->read_size()); 563 ASSERT_EQ(0UL, model_->read_size());
564 ASSERT_EQ(1UL, model_->unread_size()); 564 ASSERT_EQ(1UL, model_->unread_size());
565 565
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 } 610 }
611 611
612 // Tests that ReadingListModel calls CallbackModelBeingDeleted when destroyed. 612 // Tests that ReadingListModel calls CallbackModelBeingDeleted when destroyed.
613 TEST_F(ReadingListModelTest, CallbackModelBeingDeleted) { 613 TEST_F(ReadingListModelTest, CallbackModelBeingDeleted) {
614 AssertObserverCount(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); 614 AssertObserverCount(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
615 model_.reset(); 615 model_.reset();
616 AssertObserverCount(1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0); 616 AssertObserverCount(1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0);
617 } 617 }
618 618
619 } // namespace 619 } // namespace
OLDNEW
« no previous file with comments | « components/reading_list/reading_list_model_storage.h ('k') | components/reading_list/reading_list_pref_names.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698