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

Unified Diff: ios/chrome/browser/reading_list/offline_url_utils_unittest.cc

Issue 2606873002: Move the offline URL trimming to GetFormattedURL. (Closed)
Patch Set: fix DEPS 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/chrome/browser/reading_list/offline_url_utils.cc ('k') | ios/chrome/browser/ui/toolbar/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/reading_list/offline_url_utils_unittest.cc
diff --git a/ios/chrome/browser/reading_list/offline_url_utils_unittest.cc b/ios/chrome/browser/reading_list/offline_url_utils_unittest.cc
index d711ca55f8687cfd89185ff1dc079551e6c1f68e..3f794d3b98594875721c94956388138612a77e00 100644
--- a/ios/chrome/browser/reading_list/offline_url_utils_unittest.cc
+++ b/ios/chrome/browser/reading_list/offline_url_utils_unittest.cc
@@ -7,6 +7,8 @@
#include <string>
#include "base/files/file_path.h"
+#include "base/strings/utf_string_conversions.h"
+#include "base/test/gtest_util.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
@@ -68,6 +70,7 @@ TEST(OfflineURLUtilsTest, FileURLForDistilledURLTest) {
EXPECT_EQ("/profile_path/Offline/MD5/", resource_url.path());
}
+// Checks that the offline URLs are correctly detected by |IsOfflineURL|.
TEST(OfflineURLUtilsTest, IsOfflineURL) {
EXPECT_FALSE(reading_list::IsOfflineURL(GURL()));
EXPECT_FALSE(reading_list::IsOfflineURL(GURL("chrome://")));
@@ -80,3 +83,35 @@ TEST(OfflineURLUtilsTest, IsOfflineURL) {
EXPECT_TRUE(
reading_list::IsOfflineURL(GURL("chrome://offline/foobar?foo=bar")));
}
+
+// Checks that https:// scheme is correctly removed by
+// StripSchemeFromOnlineURLTest.
+TEST(OfflineURLUtilsTest, StripSchemeFromOnlineURLTest) {
+ size_t removed_size;
+ base::string16 empty_url;
+ EXPECT_EQ(reading_list::StripSchemeFromOnlineURL(empty_url, &removed_size),
+ empty_url);
+ EXPECT_EQ(removed_size, 0u);
+
+ base::string16 https_url = base::UTF8ToUTF16("https://www.chromium.org/");
+ base::string16 trimmed_https_url = base::UTF8ToUTF16("www.chromium.org/");
+ EXPECT_EQ(reading_list::StripSchemeFromOnlineURL(https_url, &removed_size),
+ trimmed_https_url);
+ EXPECT_EQ(removed_size, 8u);
+ base::string16 http_url = base::UTF8ToUTF16("http://www.chromium.org/");
+ EXPECT_DCHECK_DEATH(
+ reading_list::StripSchemeFromOnlineURL(http_url, &removed_size));
+
+ base::string16 other_scheme_url =
+ base::UTF8ToUTF16("scheme://www.chromium.org/");
+ EXPECT_EQ(
+ reading_list::StripSchemeFromOnlineURL(other_scheme_url, &removed_size),
+ other_scheme_url);
+ EXPECT_EQ(removed_size, 0u);
+
+ base::string16 no_scheme_url = base::UTF8ToUTF16("www.chromium.org/");
+ EXPECT_EQ(
+ reading_list::StripSchemeFromOnlineURL(no_scheme_url, &removed_size),
+ no_scheme_url);
+ EXPECT_EQ(removed_size, 0u);
+}
« no previous file with comments | « ios/chrome/browser/reading_list/offline_url_utils.cc ('k') | ios/chrome/browser/ui/toolbar/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698