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

Side by Side Diff: ios/chrome/browser/reading_list/offline_url_utils_unittest.cc

Issue 2644293002: [Reading List iOS] Display distilled URL instead of entry URL in omnibox (Closed)
Patch Set: Created 3 years, 11 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 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 "ios/chrome/browser/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 "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "base/test/gtest_util.h" 11 #include "base/test/gtest_util.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "url/gurl.h" 13 #include "url/gurl.h"
14 14
15 // Checks the distilled URL for the page is chrome://offline/MD5/page.html; 15 // Checks the distilled URL for the page is chrome://offline/MD5/page.html;
16 TEST(OfflineURLUtilsTest, DistilledURLForPathTest) { 16 TEST(OfflineURLUtilsTest, DistilledURLForPathTest) {
17 base::FilePath page_path("MD5/page.html"); 17 base::FilePath page_path("MD5/page.html");
18 GURL distilled_url = reading_list::DistilledURLForPath(page_path, GURL()); 18 GURL distilled_url =
19 reading_list::OfflineURLForPath(page_path, GURL(), GURL());
19 EXPECT_EQ("chrome://offline/MD5/page.html", distilled_url.spec()); 20 EXPECT_EQ("chrome://offline/MD5/page.html", distilled_url.spec());
20 } 21 }
21 22
22 // Checks the distilled URL for the page with an onlineURL is 23 // Checks the distilled URL for the page with an onlineURL is
23 // chrome://offline/MD5/page.html?virtualURL=encorded%20URL; 24 // chrome://offline/MD5/page.html?virtualURL=encorded%20URL;
gambard 2017/01/20 14:49:34 Update comment
Olivier 2017/01/20 16:09:14 Done.
24 TEST(OfflineURLUtilsTest, DistilledURLForPathWithVirtualURLTest) { 25 TEST(OfflineURLUtilsTest, OfflineURLForPathWithEntryURLTest) {
gambard 2017/01/20 14:49:34 s/OfflineURLForPathWithEntryURLTest/OfflineURLForP
Olivier 2017/01/20 16:09:14 Done.
25 base::FilePath page_path("MD5/page.html"); 26 base::FilePath page_path("MD5/page.html");
26 GURL online_url = GURL("http://foo.bar"); 27 GURL entry_url = GURL("http://foo.bar");
27 GURL distilled_url = reading_list::DistilledURLForPath(page_path, online_url); 28 GURL virtual_url = GURL("http://foo.bar/virtual");
28 EXPECT_EQ("chrome://offline/MD5/page.html?virtualURL=http%3A%2F%2Ffoo.bar%2F", 29 GURL distilled_url =
29 distilled_url.spec()); 30 reading_list::OfflineURLForPath(page_path, entry_url, virtual_url);
31 EXPECT_EQ(
32 "chrome://offline/MD5/page.html?"
33 "entryURL=http%3A%2F%2Ffoo.bar%2F&"
34 "virtualURL=http%3A%2F%2Ffoo.bar%2Fvirtual",
35 distilled_url.spec());
30 } 36 }
31 37
32 // Checks the distilled URL for the page is chrome://offline/MD5/page.html; 38 // Checks the distilled URL for the page is chrome://offline/MD5/page.html;
gambard 2017/01/20 14:49:34 Update this comment. You are checking that the ent
Olivier 2017/01/20 16:09:14 Done.
33 TEST(OfflineURLUtilsTest, VirtualURLForDistilledURLTest) { 39 TEST(OfflineURLUtilsTest, ParseOfflineURLTest) {
34 GURL distilled_url("chrome://offline/MD5/page.html"); 40 GURL distilled_url("chrome://offline/MD5/page.html");
35 GURL virtual_url = reading_list::VirtualURLForDistilledURL(distilled_url); 41 GURL entry_url = reading_list::EntryURLForOfflineURL(distilled_url);
36 EXPECT_EQ("chrome://offline/MD5/page.html", virtual_url.spec()); 42 EXPECT_EQ("chrome://offline/MD5/page.html", entry_url.spec());
37 } 43 }
38 44
39 // Checks the distilled URL for the page with an onlineURL is 45 // Checks the distilled URL for the page with an onlineURL is
40 // chrome://offline/MD5/page.html?virtualURL=encorded%20URL; 46 // chrome://offline/MD5/page.html?entryURL=encorded%20URL
gambard 2017/01/20 14:49:34 WDYT of: // Checks that the entry URL and the virt
Olivier 2017/01/20 16:09:14 Normalized all comments.
41 TEST(OfflineURLUtilsTest, VirtualURLForDistilledURLWithVirtualURLTest) { 47 TEST(OfflineURLUtilsTest, ParseOfflineURLWithEntryURLTest) {
42 GURL distilled_url( 48 GURL offline_url(
49 "chrome://offline/MD5/page.html?entryURL=http%3A%2F%2Ffoo.bar%2F");
50 GURL entry_url = reading_list::EntryURLForOfflineURL(offline_url);
51 EXPECT_EQ("http://foo.bar/", entry_url.spec());
52 GURL virtual_url = reading_list::VirtualURLForOfflineURL(offline_url);
53 EXPECT_EQ("http://foo.bar/", virtual_url.spec());
54 }
55
56 // Checks the distilled URL for the page with an onlineURL is
57 // chrome://offline/MD5/page.html?virtualURL=encorded%20URL
gambard 2017/01/20 14:49:34 WDYT: // Checks that if the only parameter present
Olivier 2017/01/20 16:09:14 Normalized all comments.
58 TEST(OfflineURLUtilsTest, ParseOfflineURLWithVirtualURLTest) {
59 GURL offline_url(
43 "chrome://offline/MD5/page.html?virtualURL=http%3A%2F%2Ffoo.bar%2F"); 60 "chrome://offline/MD5/page.html?virtualURL=http%3A%2F%2Ffoo.bar%2F");
44 GURL virtual_url = reading_list::VirtualURLForDistilledURL(distilled_url); 61 GURL entry_url = reading_list::EntryURLForOfflineURL(offline_url);
62 EXPECT_EQ(offline_url, entry_url);
63 GURL virtual_url = reading_list::VirtualURLForOfflineURL(offline_url);
45 EXPECT_EQ("http://foo.bar/", virtual_url.spec()); 64 EXPECT_EQ("http://foo.bar/", virtual_url.spec());
46 } 65 }
47 66
67 // Checks the distilled URL for the page with an onlineURL is
68 // chrome://offline/MD5/page.html?entryURL=...&virtualURL=...
gambard 2017/01/20 14:49:34 WDYT: // Checks that the entry URL and the virtual
Olivier 2017/01/20 16:09:14 Normalized all comments.
69 TEST(OfflineURLUtilsTest, ParseOfflineURLWithVirtualAndEntryURLTest) {
70 GURL offline_url(
71 "chrome://offline/MD5/"
72 "page.html?virtualURL=http%3A%2F%2Ffoo.bar%2Fvirtual&entryURL=http%3A%2F%"
73 "2Ffoo.bar%2Fentry");
74 GURL entry_url = reading_list::EntryURLForOfflineURL(offline_url);
75 EXPECT_EQ("http://foo.bar/entry", entry_url.spec());
76 GURL virtual_url = reading_list::VirtualURLForOfflineURL(offline_url);
77 EXPECT_EQ("http://foo.bar/virtual", virtual_url.spec());
78 }
79
48 // Checks the file path for chrome://offline/MD5/page.html is 80 // Checks the file path for chrome://offline/MD5/page.html is
49 // file://profile_path/Offline/MD5/page.html. 81 // file://profile_path/Offline/MD5/page.html.
50 // Checks the resource root for chrome://offline/MD5/page.html is 82 // Checks the resource root for chrome://offline/MD5/page.html is
51 // file://profile_path/Offline/MD5 83 // file://profile_path/Offline/MD5
52 TEST(OfflineURLUtilsTest, FileURLForDistilledURLTest) { 84 TEST(OfflineURLUtilsTest, FileURLForDistilledURLTest) {
53 base::FilePath offline_path("/profile_path/Offline"); 85 base::FilePath offline_path("/profile_path/Offline");
54 GURL file_url = 86 GURL file_url =
55 reading_list::FileURLForDistilledURL(GURL(), offline_path, nullptr); 87 reading_list::FileURLForDistilledURL(GURL(), offline_path, nullptr);
56 EXPECT_FALSE(file_url.is_valid()); 88 EXPECT_FALSE(file_url.is_valid());
57 89
(...skipping 19 matching lines...) Expand all
77 EXPECT_FALSE(reading_list::IsOfflineURL(GURL("chrome://offline-foobar"))); 109 EXPECT_FALSE(reading_list::IsOfflineURL(GURL("chrome://offline-foobar")));
78 EXPECT_FALSE(reading_list::IsOfflineURL(GURL("http://offline/"))); 110 EXPECT_FALSE(reading_list::IsOfflineURL(GURL("http://offline/")));
79 EXPECT_FALSE(reading_list::IsOfflineURL(GURL("http://chrome://offline/"))); 111 EXPECT_FALSE(reading_list::IsOfflineURL(GURL("http://chrome://offline/")));
80 EXPECT_TRUE(reading_list::IsOfflineURL(GURL("chrome://offline"))); 112 EXPECT_TRUE(reading_list::IsOfflineURL(GURL("chrome://offline")));
81 EXPECT_TRUE(reading_list::IsOfflineURL(GURL("chrome://offline/"))); 113 EXPECT_TRUE(reading_list::IsOfflineURL(GURL("chrome://offline/")));
82 EXPECT_TRUE(reading_list::IsOfflineURL(GURL("chrome://offline/foobar"))); 114 EXPECT_TRUE(reading_list::IsOfflineURL(GURL("chrome://offline/foobar")));
83 EXPECT_TRUE( 115 EXPECT_TRUE(
84 reading_list::IsOfflineURL(GURL("chrome://offline/foobar?foo=bar"))); 116 reading_list::IsOfflineURL(GURL("chrome://offline/foobar?foo=bar")));
85 } 117 }
86 118
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698