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

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

Issue 1968563003: [Offline pages] Extracting callbacks from the Offline Page Model (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding a missing fix to gypi file Created 4 years, 7 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 "chrome/browser/android/offline_pages/offline_page_utils.h" 5 #include "chrome/browser/android/offline_pages/offline_page_utils.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/feature_list.h" 12 #include "base/feature_list.h"
13 #include "base/files/file.h" 13 #include "base/files/file.h"
14 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
15 #include "base/files/file_util.h" 15 #include "base/files/file_util.h"
16 #include "base/test/test_simple_task_runner.h" 16 #include "base/test/test_simple_task_runner.h"
17 #include "base/thread_task_runner_handle.h" 17 #include "base/thread_task_runner_handle.h"
18 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" 18 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h"
19 #include "chrome/browser/android/offline_pages/test_offline_page_model_builder.h " 19 #include "chrome/browser/android/offline_pages/test_offline_page_model_builder.h "
20 #include "chrome/common/chrome_constants.h" 20 #include "chrome/common/chrome_constants.h"
21 #include "chrome/test/base/testing_profile.h" 21 #include "chrome/test/base/testing_profile.h"
22 #include "components/offline_pages/offline_page_feature.h" 22 #include "components/offline_pages/offline_page_feature.h"
23 #include "components/offline_pages/offline_page_model.h" 23 #include "components/offline_pages/offline_page_model.h"
24 #include "components/offline_pages/offline_page_test_archiver.h" 24 #include "components/offline_pages/offline_page_test_archiver.h"
25 #include "components/offline_pages/offline_page_test_store.h" 25 #include "components/offline_pages/offline_page_test_store.h"
26 #include "components/offline_pages/proto/offline_pages.pb.h" 26 #include "components/offline_pages/offline_page_types.h"
27 #include "net/base/filename_util.h" 27 #include "net/base/filename_util.h"
28 #include "testing/gtest/include/gtest/gtest.h" 28 #include "testing/gtest/include/gtest/gtest.h"
29 #include "url/gurl.h" 29 #include "url/gurl.h"
30 30
31 namespace offline_pages { 31 namespace offline_pages {
32 namespace { 32 namespace {
33 33
34 const GURL kTestPage1Url("http://test.org/page1"); 34 const GURL kTestPage1Url("http://test.org/page1");
35 const GURL kTestPage2Url("http://test.org/page2"); 35 const GURL kTestPage2Url("http://test.org/page2");
36 const GURL kTestPage3Url("http://test.org/page3"); 36 const GURL kTestPage3Url("http://test.org/page3");
(...skipping 10 matching lines...) Expand all
47 public OfflinePageTestArchiver::Observer, 47 public OfflinePageTestArchiver::Observer,
48 public base::SupportsWeakPtr<OfflinePageUtilsTest> { 48 public base::SupportsWeakPtr<OfflinePageUtilsTest> {
49 public: 49 public:
50 OfflinePageUtilsTest(); 50 OfflinePageUtilsTest();
51 ~OfflinePageUtilsTest() override; 51 ~OfflinePageUtilsTest() override;
52 52
53 void SetUp() override; 53 void SetUp() override;
54 void RunUntilIdle(); 54 void RunUntilIdle();
55 55
56 // Necessary callbacks for the offline page model. 56 // Necessary callbacks for the offline page model.
57 void OnSavePageDone(OfflinePageModel::SavePageResult result, 57 void OnSavePageDone(SavePageResult result, int64_t offlineId);
58 int64_t offlineId);
59 void OnClearAllDone(); 58 void OnClearAllDone();
60 59
61 // OfflinePageTestArchiver::Observer implementation: 60 // OfflinePageTestArchiver::Observer implementation:
62 void SetLastPathCreatedByArchiver(const base::FilePath& file_path) override; 61 void SetLastPathCreatedByArchiver(const base::FilePath& file_path) override;
63 62
64 // Offline page URL for the first page. 63 // Offline page URL for the first page.
65 const GURL& offline_url_page_1() const { return offline_url_page_1_; } 64 const GURL& offline_url_page_1() const { return offline_url_page_1_; }
66 // Offline page URL for the second page. 65 // Offline page URL for the second page.
67 const GURL& offline_url_page_2() const { return offline_url_page_2_; } 66 const GURL& offline_url_page_2() const { return offline_url_page_2_; }
68 // Offline page URL not related to any page. 67 // Offline page URL not related to any page.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 110
112 // Make sure the store contains the right offline pages before the load 111 // Make sure the store contains the right offline pages before the load
113 // happens. 112 // happens.
114 CreateOfflinePages(); 113 CreateOfflinePages();
115 } 114 }
116 115
117 void OfflinePageUtilsTest::RunUntilIdle() { 116 void OfflinePageUtilsTest::RunUntilIdle() {
118 task_runner_->RunUntilIdle(); 117 task_runner_->RunUntilIdle();
119 } 118 }
120 119
121 void OfflinePageUtilsTest::OnSavePageDone( 120 void OfflinePageUtilsTest::OnSavePageDone(SavePageResult result,
122 OfflinePageModel::SavePageResult result, 121 int64_t offline_id) {
123 int64_t offline_id) {
124 offline_id_ = offline_id; 122 offline_id_ = offline_id;
125 } 123 }
126 124
127 void OfflinePageUtilsTest::OnClearAllDone() { 125 void OfflinePageUtilsTest::OnClearAllDone() {
128 // Result ignored here. 126 // Result ignored here.
129 } 127 }
130 128
131 void OfflinePageUtilsTest::SetLastPathCreatedByArchiver( 129 void OfflinePageUtilsTest::SetLastPathCreatedByArchiver(
132 const base::FilePath& file_path) {} 130 const base::FilePath& file_path) {}
133 131
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 TEST_F(OfflinePageUtilsTest, HasOfflinePageForOnlineURL) { 228 TEST_F(OfflinePageUtilsTest, HasOfflinePageForOnlineURL) {
231 EXPECT_TRUE( 229 EXPECT_TRUE(
232 OfflinePageUtils::HasOfflinePageForOnlineURL(profile(), kTestPage1Url)); 230 OfflinePageUtils::HasOfflinePageForOnlineURL(profile(), kTestPage1Url));
233 EXPECT_TRUE( 231 EXPECT_TRUE(
234 OfflinePageUtils::HasOfflinePageForOnlineURL(profile(), kTestPage2Url)); 232 OfflinePageUtils::HasOfflinePageForOnlineURL(profile(), kTestPage2Url));
235 EXPECT_FALSE( 233 EXPECT_FALSE(
236 OfflinePageUtils::HasOfflinePageForOnlineURL(profile(), kTestPage3Url)); 234 OfflinePageUtils::HasOfflinePageForOnlineURL(profile(), kTestPage3Url));
237 } 235 }
238 236
239 } // namespace offline_pages 237 } // namespace offline_pages
OLDNEW
« no previous file with comments | « chrome/browser/android/offline_pages/offline_page_tab_helper_unittest.cc ('k') | components/offline_pages.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698