OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "components/offline_pages/offline_page_model.h" |
| 6 |
| 7 #include "components/offline_pages/offline_page_metadata_store.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "url/gurl.h" |
| 10 |
| 11 namespace offline_pages { |
| 12 |
| 13 namespace { |
| 14 |
| 15 class OfflinePageTestStore : public OfflinePageMetadataStore { |
| 16 public: |
| 17 ~OfflinePageTestStore() override; |
| 18 |
| 19 // OfflinePageMetadataStore overrides: |
| 20 void Load(const LoadCallback& callback) override; |
| 21 void AddOfflinePage(const OfflinePageItem& offline_page, |
| 22 const UpdateCallback& callback) override; |
| 23 void RemoveOfflinePage(const GURL& page_url, |
| 24 const UpdateCallback& callback) override; |
| 25 }; |
| 26 |
| 27 OfflinePageTestStore::~OfflinePageTestStore() { |
| 28 } |
| 29 |
| 30 void OfflinePageTestStore::Load(const LoadCallback& callback) { |
| 31 } |
| 32 |
| 33 void OfflinePageTestStore::AddOfflinePage(const OfflinePageItem& offline_page, |
| 34 const UpdateCallback& callback) { |
| 35 } |
| 36 |
| 37 void OfflinePageTestStore::RemoveOfflinePage(const GURL& page_url, |
| 38 const UpdateCallback& callback) { |
| 39 } |
| 40 |
| 41 class OfflinePageModelTest : public testing::Test { |
| 42 public: |
| 43 OfflinePageModelTest(); |
| 44 ~OfflinePageModelTest() override; |
| 45 |
| 46 scoped_ptr<OfflinePageMetadataStore> BuildStore(); |
| 47 }; |
| 48 |
| 49 OfflinePageModelTest::OfflinePageModelTest() { |
| 50 } |
| 51 |
| 52 OfflinePageModelTest::~OfflinePageModelTest() { |
| 53 } |
| 54 |
| 55 scoped_ptr<OfflinePageMetadataStore> OfflinePageModelTest::BuildStore() { |
| 56 return scoped_ptr<OfflinePageMetadataStore>(new OfflinePageTestStore()); |
| 57 } |
| 58 |
| 59 TEST_F(OfflinePageModelTest, Initialize) { |
| 60 OfflinePageModel model; |
| 61 EXPECT_EQ(nullptr, model.GetStoreForTesting()); |
| 62 scoped_ptr<OfflinePageMetadataStore> store = BuildStore(); |
| 63 OfflinePageMetadataStore* store_ptr = store.get(); |
| 64 model.Initialize(store.Pass()); |
| 65 EXPECT_EQ(store_ptr, model.GetStoreForTesting()); |
| 66 } |
| 67 |
| 68 } // namespace |
| 69 |
| 70 } // namespace offline_pages |
OLD | NEW |