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

Side by Side Diff: components/offline_pages/offline_page_model_unittest.cc

Issue 1174803002: [Offline] Adding archiver interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@offline-pages-store
Patch Set: Addressing code review feedback Created 5 years, 6 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 2015 The Chromium Authors. All rights reserved. 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 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/offline_pages/offline_page_model.h" 5 #include "components/offline_pages/offline_page_model.h"
6 6
7 #include "components/offline_pages/offline_page_metadata_store.h" 7 #include "components/offline_pages/offline_page_metadata_store.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "url/gurl.h" 9 #include "url/gurl.h"
10 10
(...skipping 20 matching lines...) Expand all
31 } 31 }
32 32
33 void OfflinePageTestStore::AddOfflinePage(const OfflinePageItem& offline_page, 33 void OfflinePageTestStore::AddOfflinePage(const OfflinePageItem& offline_page,
34 const UpdateCallback& callback) { 34 const UpdateCallback& callback) {
35 } 35 }
36 36
37 void OfflinePageTestStore::RemoveOfflinePage(const GURL& page_url, 37 void OfflinePageTestStore::RemoveOfflinePage(const GURL& page_url,
38 const UpdateCallback& callback) { 38 const UpdateCallback& callback) {
39 } 39 }
40 40
41 class OfflinePageTestArchiverRequest : public OfflinePageArchiver::Request {
42 public:
43 explicit OfflinePageTestArchiverRequest(const GURL& url) : Request(url) {}
44 ~OfflinePageTestArchiverRequest() override {}
45
46 void Cancel() override;
47 };
48
49 void OfflinePageTestArchiverRequest::Cancel() {
50 }
51
52
53 class OfflinePageTestArchiver : public OfflinePageArchiver {
54 public:
55 ~OfflinePageTestArchiver() override;
56
57 // OfflinePageArchiver implementation:
58 scoped_ptr<Request> CreateArchive(const GURL& url,
59 Client* client) override;
60 };
61
62 OfflinePageTestArchiver::~OfflinePageTestArchiver() {
63 }
64
65 scoped_ptr<OfflinePageArchiver::Request> OfflinePageTestArchiver::CreateArchive(
66 const GURL& url,
67 Client* client) {
68 scoped_ptr<OfflinePageTestArchiverRequest> request(
69 new OfflinePageTestArchiverRequest(url));
70 return request.Pass();
71 }
72
41 class OfflinePageModelTest : public testing::Test { 73 class OfflinePageModelTest : public testing::Test {
42 public: 74 public:
43 OfflinePageModelTest(); 75 OfflinePageModelTest();
44 ~OfflinePageModelTest() override; 76 ~OfflinePageModelTest() override;
45 77
46 scoped_ptr<OfflinePageMetadataStore> BuildStore(); 78 scoped_ptr<OfflinePageMetadataStore> BuildStore();
79
80 OfflinePageTestArchiver* archiver() { return &archiver_; }
81
82 private:
83 OfflinePageTestArchiver archiver_;
47 }; 84 };
48 85
49 OfflinePageModelTest::OfflinePageModelTest() { 86 OfflinePageModelTest::OfflinePageModelTest() {
50 } 87 }
51 88
52 OfflinePageModelTest::~OfflinePageModelTest() { 89 OfflinePageModelTest::~OfflinePageModelTest() {
53 } 90 }
54 91
55 scoped_ptr<OfflinePageMetadataStore> OfflinePageModelTest::BuildStore() { 92 scoped_ptr<OfflinePageMetadataStore> OfflinePageModelTest::BuildStore() {
56 return scoped_ptr<OfflinePageMetadataStore>(new OfflinePageTestStore()); 93 return scoped_ptr<OfflinePageMetadataStore>(new OfflinePageTestStore());
57 } 94 }
58 95
59 TEST_F(OfflinePageModelTest, Initialize) { 96 TEST_F(OfflinePageModelTest, Initialize) {
60 scoped_ptr<OfflinePageMetadataStore> store = BuildStore(); 97 scoped_ptr<OfflinePageMetadataStore> store = BuildStore();
61 OfflinePageMetadataStore* store_ptr = store.get(); 98 OfflinePageMetadataStore* store_ptr = store.get();
62 OfflinePageModel model(store.Pass()); 99 OfflinePageModel model(store.Pass(), archiver());
63 EXPECT_EQ(store_ptr, model.GetStoreForTesting()); 100 EXPECT_EQ(store_ptr, model.GetStoreForTesting());
64 } 101 }
65 102
66 } // namespace 103 } // namespace
67 104
68 } // namespace offline_pages 105 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698