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

Side by Side Diff: chrome/browser/android/offline_pages/background_loader_offliner_unittest.cc

Issue 2534673002: [Offline pages] Create offliner that uses background loader (Closed)
Patch Set: test update Created 4 years 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/android/offline_pages/background_loader_offliner.h"
6
7 #include "components/offline_pages/content/background_loader/background_loader_c ontents_stub.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9
10 namespace offline_pages {
11
12 namespace {
13
14 const int64_t kRequestId = 7;
15 const GURL kHttpUrl("http://tunafish.com");
16 const GURL kFileUrl("file://salmon.png");
17 const ClientId kClientId("AsyncLoading", "88");
18 const bool kUserRequested = true;
19
20 // A BackgroundLoader that we can run tests on.
21 // Overrides the ResetState so we don't actually try to create any web contents.
22 // This is a temporary solution to test core BackgroundLoaderOffliner
23 // functionality until we straighten out assumptions made by RequestCoordinator
24 // so that the ResetState method is no longer needed.
25 class TestBackgroundLoaderOffliner
26 : public BackgroundLoaderOffliner {
27 public:
28 explicit TestBackgroundLoaderOffliner(
29 content::BrowserContext* browser_context,
30 const OfflinerPolicy* policy,
31 OfflinePageModel* offline_page_model);
32 ~TestBackgroundLoaderOffliner() override;
33 content::WebContents* web_contents() {
34 return BackgroundLoaderOffliner::loader_.get()->web_contents();
35 }
36
37 private:
38 void ResetState() override;
39 };
40
41 TestBackgroundLoaderOffliner::TestBackgroundLoaderOffliner(
42 content::BrowserContext* browser_context,
43 const OfflinerPolicy* policy,
44 OfflinePageModel* offline_page_model)
45 : BackgroundLoaderOffliner(browser_context,
46 policy,
47 offline_page_model) {}
48
49 TestBackgroundLoaderOffliner::~TestBackgroundLoaderOffliner() {
50 BackgroundLoaderOffliner::~BackgroundLoaderOffliner();
51 }
52
53 void TestBackgroundLoaderOffliner::ResetState() {
54 BackgroundLoaderOffliner::loader_.reset(
55 new BackgroundLoaderContentsStub());
56 }
57 } // namespace
58
59 class BackgroundLoaderOfflinerTest : public testing::Test {
60 public:
61 BackgroundLoaderOfflinerTest();
62 ~BackgroundLoaderOfflinerTest() override;
63
64 void SetUp() override;
65
66 BackgroundLoaderOffliner* offliner() const { return offliner_.get(); }
67 Profile* profile() { return &profile_; }
68
69 private:
70 TestingProfile profile_;
71 std::unique_ptr<TestBackgroundLoaderOffliner> offliner_;
72 MockOfflinePageModel* model_;
73
74 DISALLOW_COPY_AND_ASSIGN(BackgroundLoaderOfflinerTest);
75 };
76
77 BackgroundLoaderOfflinerTest::BackgroundLoaderOfflinerTest() {}
78
79 BackgroundLoaderOfflinerTest::~BackgroundLoaderOfflinerTest() {}
80
81 void BackgroundLoaderOfflinerTest::SetUp() {
82 model_ = new MockOfflinePageModel();
83 offliner_.reset(new TestBackgroundLoaderOffliner(profile(), nullptr, model_));
84 }
85
86 TEST_F(BackgroundLoaderOfflinerTest, LoadAndSaveUrl) {
87 base::Time creation_time = base::Time::Now();
88 SavePageRequest request(
89 kRequestId, kFileUrl, kClientId, creation_time, kUserRequested);
90
91 }
92
93
94 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698