Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" | |
| 11 #include "base/test/gtest_util.h" | |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "url/gurl.h" | 13 #include "url/gurl.h" |
| 12 | 14 |
| 13 // 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; |
| 14 TEST(OfflineURLUtilsTest, DistilledURLForPathTest) { | 16 TEST(OfflineURLUtilsTest, DistilledURLForPathTest) { |
| 15 base::FilePath page_path("MD5/page.html"); | 17 base::FilePath page_path("MD5/page.html"); |
| 16 GURL distilled_url = reading_list::DistilledURLForPath(page_path, GURL()); | 18 GURL distilled_url = reading_list::DistilledURLForPath(page_path, GURL()); |
| 17 EXPECT_EQ("chrome://offline/MD5/page.html", distilled_url.spec()); | 19 EXPECT_EQ("chrome://offline/MD5/page.html", distilled_url.spec()); |
| 18 } | 20 } |
| 19 | 21 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 EXPECT_FALSE(reading_list::IsOfflineURL(GURL("chrome://"))); | 75 EXPECT_FALSE(reading_list::IsOfflineURL(GURL("chrome://"))); |
| 74 EXPECT_FALSE(reading_list::IsOfflineURL(GURL("chrome://offline-foobar"))); | 76 EXPECT_FALSE(reading_list::IsOfflineURL(GURL("chrome://offline-foobar"))); |
| 75 EXPECT_FALSE(reading_list::IsOfflineURL(GURL("http://offline/"))); | 77 EXPECT_FALSE(reading_list::IsOfflineURL(GURL("http://offline/"))); |
| 76 EXPECT_FALSE(reading_list::IsOfflineURL(GURL("http://chrome://offline/"))); | 78 EXPECT_FALSE(reading_list::IsOfflineURL(GURL("http://chrome://offline/"))); |
| 77 EXPECT_TRUE(reading_list::IsOfflineURL(GURL("chrome://offline"))); | 79 EXPECT_TRUE(reading_list::IsOfflineURL(GURL("chrome://offline"))); |
| 78 EXPECT_TRUE(reading_list::IsOfflineURL(GURL("chrome://offline/"))); | 80 EXPECT_TRUE(reading_list::IsOfflineURL(GURL("chrome://offline/"))); |
| 79 EXPECT_TRUE(reading_list::IsOfflineURL(GURL("chrome://offline/foobar"))); | 81 EXPECT_TRUE(reading_list::IsOfflineURL(GURL("chrome://offline/foobar"))); |
| 80 EXPECT_TRUE( | 82 EXPECT_TRUE( |
| 81 reading_list::IsOfflineURL(GURL("chrome://offline/foobar?foo=bar"))); | 83 reading_list::IsOfflineURL(GURL("chrome://offline/foobar?foo=bar"))); |
| 82 } | 84 } |
| 85 | |
| 86 TEST(OfflineURLUtilsTest, StripSchemeFromOnlineUrlTest) { | |
|
Eugene But (OOO till 7-30)
2016/12/28 17:02:59
Could you please add comments for test method.
Olivier
2016/12/29 12:37:20
Done.
| |
| 87 base::string16 empty_url = base::UTF8ToUTF16(""); | |
|
Eugene But (OOO till 7-30)
2016/12/28 17:02:59
Should this be just |base::string16 empty_url;|?
Olivier
2016/12/29 12:37:20
Done.
| |
| 88 EXPECT_EQ(reading_list::StripSchemeFromOnlineUrl(empty_url), empty_url); | |
| 89 base::string16 https_url = base::UTF8ToUTF16("https://www.chromium.org/"); | |
| 90 base::string16 trimmed_https_url = base::UTF8ToUTF16("www.chromium.org/"); | |
| 91 EXPECT_EQ(reading_list::StripSchemeFromOnlineUrl(https_url), | |
| 92 trimmed_https_url); | |
| 93 base::string16 http_url = base::UTF8ToUTF16("http://www.chromium.org/"); | |
| 94 EXPECT_DCHECK_DEATH(reading_list::StripSchemeFromOnlineUrl(http_url)); | |
| 95 base::string16 other_scheme_url = | |
| 96 base::UTF8ToUTF16("scheme://www.chromium.org/"); | |
| 97 EXPECT_EQ(reading_list::StripSchemeFromOnlineUrl(other_scheme_url), | |
| 98 other_scheme_url); | |
| 99 base::string16 no_scheme_url = base::UTF8ToUTF16("www.chromium.org/"); | |
| 100 EXPECT_EQ(reading_list::StripSchemeFromOnlineUrl(no_scheme_url), | |
| 101 no_scheme_url); | |
| 102 } | |
| OLD | NEW |