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

Unified Diff: ios/chrome/browser/web/mailto_handler_unittest.mm

Issue 2852003002: Adds mailto: URL support to app launching. (Closed)
Patch Set: separate migration from auto-default even more Created 3 years, 7 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
Index: ios/chrome/browser/web/mailto_handler_unittest.mm
diff --git a/ios/chrome/browser/web/mailto_handler_unittest.mm b/ios/chrome/browser/web/mailto_handler_unittest.mm
new file mode 100644
index 0000000000000000000000000000000000000000..fa9029fd4d92cdc68cfb3230b8d05d8de9fcab74
--- /dev/null
+++ b/ios/chrome/browser/web/mailto_handler_unittest.mm
@@ -0,0 +1,45 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ios/chrome/browser/web/mailto_handler.h"
+
+#include "testing/gtest/include/gtest/gtest.h"
+#include "testing/gtest_mac.h"
+#include "url/gurl.h"
+
+TEST(MailtoHandlerTest, TestConstructor) {
+ MailtoHandler* handler =
+ [[MailtoHandler alloc] initWithName:@"Some App" appStoreID:@"12345"];
+ EXPECT_NSEQ(@"Some App", [handler appName]);
+ EXPECT_NSEQ(@"12345", [handler appStoreID]);
+ EXPECT_NSEQ(@"mailtohandler:/co?", [handler beginningScheme]);
+ EXPECT_GT([[handler supportedHeaders] count], 0U);
+}
+
+TEST(MailtoHandlerTest, TestRewriteGood) {
+ MailtoHandler* handler = [[MailtoHandler alloc] init];
+ // Tests mailto URL without a subject.
+ NSString* result = [handler rewriteMailtoURL:GURL("mailto:user@domain.com")];
+ EXPECT_NSEQ(@"mailtohandler:/co?to=user@domain.com", result);
+ // Tests mailto URL with a subject.
+ result =
+ [handler rewriteMailtoURL:GURL("mailto:user@domain.com?subject=hello")];
+ EXPECT_NSEQ(@"mailtohandler:/co?to=user@domain.com&subject=hello", result);
+ // Tests mailto URL with unrecognized query parameters.
+ result = [handler
+ rewriteMailtoURL:
+ GURL("mailto:someone@there.com?garbage=in&garbageOut&subject=trash")];
+ EXPECT_NSEQ(@"mailtohandler:/co?to=someone@there.com&subject=trash", result);
+}
+
+TEST(MailtoHandlerTest, TestRewriteBad) {
+ MailtoHandler* handler = [[MailtoHandler alloc] init];
+ NSString* result = [handler rewriteMailtoURL:GURL("http://www.google.com")];
+ EXPECT_FALSE(result);
+ result = [handler
+ rewriteMailtoURL:
+ GURL("mailto:user@domain.com?foo=bar&cc=someone@somewhere.com")];
+ EXPECT_NSEQ(@"mailtohandler:/co?to=user@domain.com&cc=someone@somewhere.com",
+ result);
+}
« no previous file with comments | « ios/chrome/browser/web/mailto_handler_system_mail_unittest.mm ('k') | ios/chrome/browser/web/mailto_url_rewriter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698