OLD | NEW |
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/core/reading_list_model.h" | 5 #include "components/reading_list/core/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 #include "base/test/simple_test_clock.h" | 9 #include "base/test/simple_test_clock.h" |
10 #include "components/reading_list/core/reading_list_model_impl.h" | 10 #include "components/reading_list/core/reading_list_model_impl.h" |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 }; | 307 }; |
308 | 308 |
309 // Tests creating an empty model. | 309 // Tests creating an empty model. |
310 TEST_F(ReadingListModelTest, EmptyLoaded) { | 310 TEST_F(ReadingListModelTest, EmptyLoaded) { |
311 EXPECT_TRUE(model_->loaded()); | 311 EXPECT_TRUE(model_->loaded()); |
312 AssertObserverCount(1, 0, 0, 0, 0, 0, 0, 0, 0); | 312 AssertObserverCount(1, 0, 0, 0, 0, 0, 0, 0, 0); |
313 EXPECT_EQ(0ul, UnreadSize()); | 313 EXPECT_EQ(0ul, UnreadSize()); |
314 EXPECT_EQ(0ul, ReadSize()); | 314 EXPECT_EQ(0ul, ReadSize()); |
315 model_->Shutdown(); | 315 model_->Shutdown(); |
316 EXPECT_FALSE(model_->loaded()); | 316 EXPECT_FALSE(model_->loaded()); |
| 317 // Shutdown() does not delete the model observer. Verify that deleting the |
| 318 // model will delete the model observer. |
| 319 model_.reset(); |
317 AssertObserverCount(1, 0, 0, 1, 0, 0, 0, 0, 0); | 320 AssertObserverCount(1, 0, 0, 1, 0, 0, 0, 0, 0); |
318 } | 321 } |
319 | 322 |
320 // Tests load model. | 323 // Tests load model. |
321 TEST_F(ReadingListModelTest, ModelLoaded) { | 324 TEST_F(ReadingListModelTest, ModelLoaded) { |
322 ClearCounts(); | 325 ClearCounts(); |
323 auto clock = base::MakeUnique<base::SimpleTestClock>(); | 326 auto clock = base::MakeUnique<base::SimpleTestClock>(); |
324 auto storage = base::MakeUnique<TestReadingListStorage>(this, clock.get()); | 327 auto storage = base::MakeUnique<TestReadingListStorage>(this, clock.get()); |
325 storage->AddSampleEntries(); | 328 storage->AddSampleEntries(); |
326 SetStorage(std::move(storage), std::move(clock)); | 329 SetStorage(std::move(storage), std::move(clock)); |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
738 model_->SetReadStatus(gurl, true); | 741 model_->SetReadStatus(gurl, true); |
739 const ReadingListEntry* entry = model_->GetEntryByURL(gurl); | 742 const ReadingListEntry* entry = model_->GetEntryByURL(gurl); |
740 EXPECT_EQ(entry->Title(), "This title contains new line characters"); | 743 EXPECT_EQ(entry->Title(), "This title contains new line characters"); |
741 model_->SetEntryTitle(gurl, "test"); | 744 model_->SetEntryTitle(gurl, "test"); |
742 EXPECT_EQ(entry->Title(), "test"); | 745 EXPECT_EQ(entry->Title(), "test"); |
743 model_->SetEntryTitle(gurl, title); | 746 model_->SetEntryTitle(gurl, title); |
744 EXPECT_EQ(entry->Title(), "This title contains new line characters"); | 747 EXPECT_EQ(entry->Title(), "This title contains new line characters"); |
745 } | 748 } |
746 | 749 |
747 } // namespace | 750 } // namespace |
OLD | NEW |