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

Unified Diff: ios/chrome/browser/chrome_url_util_unittest.mm

Issue 2364373002: Removed some URL Utility functions & improved unit tests (Closed)
Patch Set: Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/chrome/browser/chrome_url_util.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/chrome_url_util_unittest.mm
diff --git a/ios/chrome/browser/chrome_url_util_unittest.mm b/ios/chrome/browser/chrome_url_util_unittest.mm
index 187657a8bc61d5fb1a55a5b111ed989bd38cd4af..0e17c508fbdb0f25fe81d93e50c09312e1c17a8c 100644
--- a/ios/chrome/browser/chrome_url_util_unittest.mm
+++ b/ios/chrome/browser/chrome_url_util_unittest.mm
@@ -5,6 +5,7 @@
#import "ios/chrome/browser/chrome_url_util.h"
#include "base/macros.h"
+#include "base/strings/sys_string_conversions.h"
#include "ios/chrome/browser/chrome_url_constants.h"
#import "net/base/mac/url_conversions.h"
#import "testing/gtest_mac.h"
@@ -21,29 +22,6 @@ TEST(ChromeURLUtilTest, TestIsExternalFileReference) {
EXPECT_FALSE(UrlIsExternalFileReference(still_not_external_url));
}
-TEST(ChromeURLUtilTest, TestRewriteURLChromium) {
- [[ChromeAppConstants sharedInstance] setCallbackSchemeForTesting:@"chromium"];
- NSURL* expected = [NSURL URLWithString:@"chromium://"];
- NSURL* rewritten = UrlToLaunchChrome();
- EXPECT_NSEQ([expected absoluteString], [rewritten absoluteString]);
-}
-
-TEST(ChromeURLUtilTest, TestRewriteURLGoogleChrome) {
- [[ChromeAppConstants sharedInstance]
- setCallbackSchemeForTesting:@"googlechrome"];
- NSURL* expected = [NSURL URLWithString:@"googlechrome://"];
- NSURL* rewritten = UrlToLaunchChrome();
- EXPECT_NSEQ([expected absoluteString], [rewritten absoluteString]);
-}
-
-TEST(ChromeURLUtilTest, TestAppIconURL) {
- [[ChromeAppConstants sharedInstance] setAppIconURLProviderForTesting:nil];
- NSURL* url = UrlOfChromeAppIcon(29, 29);
- EXPECT_TRUE(url);
- GURL gurl(net::GURLWithNSURL(url));
- EXPECT_TRUE(gurl.is_valid());
-}
-
const char* kSchemeTestData[] = {
"http://foo.com",
"https://foo.com",
@@ -52,14 +30,39 @@ const char* kSchemeTestData[] = {
"chrome://settings",
};
+// Tests UrlHasChromeScheme with NSURL* parameter.
TEST(ChromeURLUtilTest, NSURLHasChromeScheme) {
for (unsigned int i = 0; i < arraysize(kSchemeTestData); ++i) {
const char* url = kSchemeTestData[i];
- bool nsurl_result = UrlHasChromeScheme(
- [NSURL URLWithString:[NSString stringWithUTF8String:url]]);
- bool gurl_result = GURL(url).SchemeIs(kChromeUIScheme);
- EXPECT_EQ(gurl_result, nsurl_result) << "Scheme check failed for " << url;
+ NSURL* nsurl = [NSURL URLWithString:base::SysUTF8ToNSString(url)];
+ bool nsurl_result = UrlHasChromeScheme(nsurl);
+ EXPECT_EQ(GURL(url).SchemeIs(kChromeUIScheme), nsurl_result)
+ << "Scheme check failed for " << url;
+ }
+}
+
+// Tests UrlHasChromeScheme with const GURL& paramter.
+TEST(ChromeURLUtilTest, GURLHasChromeScheme) {
+ for (unsigned int i = 0; i < arraysize(kSchemeTestData); ++i) {
+ GURL gurl(kSchemeTestData[i]);
+ bool result = UrlHasChromeScheme(gurl);
+ EXPECT_EQ(gurl.SchemeIs(kChromeUIScheme), result)
+ << "Scheme check failed for " << gurl.spec();
}
}
+TEST(ChromeURLUtilTest, GetBundleURLScheme) {
+ // Verifies that there is some default values.
+ ChromeAppConstants* constants = [ChromeAppConstants sharedInstance];
+ NSString* originalScheme = [constants getBundleURLScheme];
+ EXPECT_GT([originalScheme length], 0U);
+
+ // Verifies that Chrome scheme can be reset for testing.
+ [constants setCallbackSchemeForTesting:@"blah"];
+ EXPECT_NSEQ(@"blah", [constants getBundleURLScheme]);
+
+ // Resets state in case of further tests.
+ [constants setCallbackSchemeForTesting:originalScheme];
+}
+
} // namespace
« no previous file with comments | « ios/chrome/browser/chrome_url_util.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698