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

Side by Side Diff: components/reading_list/offline_url_utils_unittest.cc

Issue 2514333003: Componentize Reading List (Closed)
Patch Set: rebase Created 4 years, 1 month 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/reading_list/offline_url_utils.cc ('k') | components/reading_list/proto/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 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 "ios/chrome/browser/reading_list/offline_url_utils.h" 5 #include "components/reading_list/offline_url_utils.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "url/gurl.h" 11 #include "url/gurl.h"
12 12
13 // Checks the root directory of offline pages. 13 // Checks the root directory of offline pages.
14 TEST(OfflineURLUtilsTest, OfflineRootDirectoryPathTest) { 14 TEST(OfflineURLUtilsTest, OfflineRootDirectoryPathTest) {
15 base::FilePath profile_path("/profile_path"); 15 base::FilePath profile_path("/profile_path");
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 EXPECT_EQ("/profile_path/Offline/0090071ef710946a1263c276284bb3b8/page.html", 48 EXPECT_EQ("/profile_path/Offline/0090071ef710946a1263c276284bb3b8/page.html",
49 offline_page.value()); 49 offline_page.value());
50 } 50 }
51 51
52 // Checks the offline page path is OfflineURLDirectoryID/page.html; 52 // Checks the offline page path is OfflineURLDirectoryID/page.html;
53 TEST(OfflineURLUtilsTest, OfflinePagePathTest) { 53 TEST(OfflineURLUtilsTest, OfflinePagePathTest) {
54 GURL url("http://www.google.com/test"); 54 GURL url("http://www.google.com/test");
55 base::FilePath offline_page = reading_list::OfflinePagePath(url); 55 base::FilePath offline_page = reading_list::OfflinePagePath(url);
56 EXPECT_EQ("0090071ef710946a1263c276284bb3b8/page.html", offline_page.value()); 56 EXPECT_EQ("0090071ef710946a1263c276284bb3b8/page.html", offline_page.value());
57 } 57 }
58
59 // Checks the distilled URL for the page is chrome://offline/MD5/page.html;
60 TEST(OfflineURLUtilsTest, DistilledURLForPathTest) {
61 base::FilePath page_path("MD5/page.html");
62 GURL distilled_url = reading_list::DistilledURLForPath(page_path);
63 EXPECT_EQ("chrome://offline/MD5/page.html", distilled_url.spec());
64 }
65
66 // Checks the file path for chrome://offline/MD5/page.html is
67 // file://profile_path/Offline/MD5/page.html.
68 // Checks the resource root for chrome://offline/MD5/page.html is
69 // file://profile_path/Offline/MD5
70 TEST(OfflineURLUtilsTest, FileURLForDistilledURLTest) {
71 base::FilePath profile_path("/profile_path");
72 GURL file_url =
73 reading_list::FileURLForDistilledURL(GURL(), profile_path, nullptr);
74 EXPECT_FALSE(file_url.is_valid());
75
76 GURL distilled_url("chrome://offline/MD5/page.html");
77 file_url = reading_list::FileURLForDistilledURL(distilled_url, profile_path,
78 nullptr);
79 EXPECT_TRUE(file_url.is_valid());
80 EXPECT_TRUE(file_url.SchemeIsFile());
81 EXPECT_EQ("/profile_path/Offline/MD5/page.html", file_url.path());
82
83 GURL resource_url;
84 file_url = reading_list::FileURLForDistilledURL(distilled_url, profile_path,
85 &resource_url);
86 EXPECT_TRUE(resource_url.is_valid());
87 EXPECT_TRUE(resource_url.SchemeIsFile());
88 EXPECT_EQ("/profile_path/Offline/MD5/", resource_url.path());
89 }
OLDNEW
« no previous file with comments | « components/reading_list/offline_url_utils.cc ('k') | components/reading_list/proto/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698