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

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

Issue 2023293002: OfflinePageModel cleanups - improved CanSavePage() and moved static kInvalidOfflineId to impl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 "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"
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 std::unique_ptr<OfflinePageTestArchiver> OfflinePageUtilsTest::BuildArchiver( 169 std::unique_ptr<OfflinePageTestArchiver> OfflinePageUtilsTest::BuildArchiver(
170 const GURL& url, 170 const GURL& url,
171 const base::FilePath& file_name) { 171 const base::FilePath& file_name) {
172 std::unique_ptr<OfflinePageTestArchiver> archiver(new OfflinePageTestArchiver( 172 std::unique_ptr<OfflinePageTestArchiver> archiver(new OfflinePageTestArchiver(
173 this, url, OfflinePageArchiver::ArchiverResult::SUCCESSFULLY_CREATED, 173 this, url, OfflinePageArchiver::ArchiverResult::SUCCESSFULLY_CREATED,
174 kTestFileSize, base::ThreadTaskRunnerHandle::Get())); 174 kTestFileSize, base::ThreadTaskRunnerHandle::Get()));
175 archiver->set_filename(file_name); 175 archiver->set_filename(file_name);
176 return archiver; 176 return archiver;
177 } 177 }
178 178
179 TEST_F(OfflinePageUtilsTest, CanSaveURL) {
180 EXPECT_TRUE(OfflinePageUtils::CanSaveURL(GURL("http://foo")));
181 EXPECT_TRUE(OfflinePageUtils::CanSaveURL(GURL("https://foo")));
182 EXPECT_FALSE(OfflinePageUtils::CanSaveURL(GURL("file:///foo")));
183 EXPECT_FALSE(OfflinePageUtils::CanSaveURL(GURL("data:image/png;base64,ab")));
184 EXPECT_FALSE(OfflinePageUtils::CanSaveURL(GURL("chrome://version")));
185 EXPECT_FALSE(OfflinePageUtils::CanSaveURL(GURL("chrome-native://newtab/")));
186 EXPECT_FALSE(OfflinePageUtils::CanSaveURL(GURL("/invalid/url.mhtml")));
187 }
188
179 TEST_F(OfflinePageUtilsTest, MightBeOfflineURL) { 189 TEST_F(OfflinePageUtilsTest, MightBeOfflineURL) {
180 // URL is invalid. 190 // URL is invalid.
181 EXPECT_FALSE(OfflinePageUtils::MightBeOfflineURL(GURL("/test.mhtml"))); 191 EXPECT_FALSE(OfflinePageUtils::MightBeOfflineURL(GURL("/test.mhtml")));
182 // Scheme is not file. 192 // Scheme is not file.
183 EXPECT_FALSE(OfflinePageUtils::MightBeOfflineURL(GURL("http://test.com/"))); 193 EXPECT_FALSE(OfflinePageUtils::MightBeOfflineURL(GURL("http://test.com/")));
184 // Does not end with .mhtml. 194 // Does not end with .mhtml.
185 EXPECT_FALSE(OfflinePageUtils::MightBeOfflineURL(GURL("file:///test.txt"))); 195 EXPECT_FALSE(OfflinePageUtils::MightBeOfflineURL(GURL("file:///test.txt")));
186 // Might still be an offline page. 196 // Might still be an offline page.
187 EXPECT_TRUE(OfflinePageUtils::MightBeOfflineURL(GURL("file:///test.mhtml"))); 197 EXPECT_TRUE(OfflinePageUtils::MightBeOfflineURL(GURL("file:///test.mhtml")));
188 } 198 }
(...skipping 28 matching lines...) Expand all
217 TEST_F(OfflinePageUtilsTest, HasOfflinePageForOnlineURL) { 227 TEST_F(OfflinePageUtilsTest, HasOfflinePageForOnlineURL) {
218 EXPECT_TRUE( 228 EXPECT_TRUE(
219 OfflinePageUtils::HasOfflinePageForOnlineURL(profile(), kTestPage1Url)); 229 OfflinePageUtils::HasOfflinePageForOnlineURL(profile(), kTestPage1Url));
220 EXPECT_TRUE( 230 EXPECT_TRUE(
221 OfflinePageUtils::HasOfflinePageForOnlineURL(profile(), kTestPage2Url)); 231 OfflinePageUtils::HasOfflinePageForOnlineURL(profile(), kTestPage2Url));
222 EXPECT_FALSE( 232 EXPECT_FALSE(
223 OfflinePageUtils::HasOfflinePageForOnlineURL(profile(), kTestPage3Url)); 233 OfflinePageUtils::HasOfflinePageForOnlineURL(profile(), kTestPage3Url));
224 } 234 }
225 235
226 } // namespace offline_pages 236 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698