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

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 feedback to documentation 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
« no previous file with comments | « components/offline_pages/offline_page_model.cc ('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 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) : url_(url) {}
44 ~OfflinePageTestArchiverRequest() override {}
45
46 void Cancel() override;
47 const GURL& url() const override { return url_; }
48
49 private:
50 GURL url_;
51 };
52
53 void OfflinePageTestArchiverRequest::Cancel() {
54 }
55
56
57 class OfflinePageTestArchiver : public OfflinePageArchiver {
58 public:
59 ~OfflinePageTestArchiver() override;
60
61 // OfflinePageArchiver implementation:
62 scoped_ptr<Request> CreateArchive(const GURL& url,
63 Client* client) override;
64 };
65
66 OfflinePageTestArchiver::~OfflinePageTestArchiver() {
67 }
68
69 scoped_ptr<OfflinePageArchiver::Request> OfflinePageTestArchiver::CreateArchive(
70 const GURL& url,
71 Client* client) {
72 scoped_ptr<OfflinePageTestArchiverRequest> request(
73 new OfflinePageTestArchiverRequest(url));
74 return request.Pass();
75 }
76
41 class OfflinePageModelTest : public testing::Test { 77 class OfflinePageModelTest : public testing::Test {
42 public: 78 public:
43 OfflinePageModelTest(); 79 OfflinePageModelTest();
44 ~OfflinePageModelTest() override; 80 ~OfflinePageModelTest() override;
45 81
46 scoped_ptr<OfflinePageMetadataStore> BuildStore(); 82 scoped_ptr<OfflinePageMetadataStore> BuildStore();
83
84 OfflinePageTestArchiver* archiver() { return &archiver_; }
85
86 private:
87 OfflinePageTestArchiver archiver_;
47 }; 88 };
48 89
49 OfflinePageModelTest::OfflinePageModelTest() { 90 OfflinePageModelTest::OfflinePageModelTest() {
50 } 91 }
51 92
52 OfflinePageModelTest::~OfflinePageModelTest() { 93 OfflinePageModelTest::~OfflinePageModelTest() {
53 } 94 }
54 95
55 scoped_ptr<OfflinePageMetadataStore> OfflinePageModelTest::BuildStore() { 96 scoped_ptr<OfflinePageMetadataStore> OfflinePageModelTest::BuildStore() {
56 return scoped_ptr<OfflinePageMetadataStore>(new OfflinePageTestStore()); 97 return scoped_ptr<OfflinePageMetadataStore>(new OfflinePageTestStore());
57 } 98 }
58 99
59 TEST_F(OfflinePageModelTest, Initialize) { 100 TEST_F(OfflinePageModelTest, Initialize) {
60 scoped_ptr<OfflinePageMetadataStore> store = BuildStore(); 101 scoped_ptr<OfflinePageMetadataStore> store = BuildStore();
61 OfflinePageMetadataStore* store_ptr = store.get(); 102 OfflinePageMetadataStore* store_ptr = store.get();
62 OfflinePageModel model(store.Pass()); 103 OfflinePageModel model(store.Pass(), archiver());
63 EXPECT_EQ(store_ptr, model.GetStoreForTesting()); 104 EXPECT_EQ(store_ptr, model.GetStoreForTesting());
64 } 105 }
65 106
66 } // namespace 107 } // namespace
67 108
68 } // namespace offline_pages 109 } // namespace offline_pages
OLDNEW
« no previous file with comments | « components/offline_pages/offline_page_model.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698