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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ios/chrome/browser/web/mailto_handler.h"
6
7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "testing/gtest_mac.h"
9 #include "url/gurl.h"
10
11 TEST(MailtoHandlerTest, TestConstructor) {
12 MailtoHandler* handler =
13 [[MailtoHandler alloc] initWithName:@"Some App" appStoreID:@"12345"];
14 EXPECT_NSEQ(@"Some App", [handler appName]);
15 EXPECT_NSEQ(@"12345", [handler appStoreID]);
16 EXPECT_NSEQ(@"mailtohandler:/co?", [handler beginningScheme]);
17 EXPECT_GT([[handler supportedHeaders] count], 0U);
18 }
19
20 TEST(MailtoHandlerTest, TestRewriteGood) {
21 MailtoHandler* handler = [[MailtoHandler alloc] init];
22 // Tests mailto URL without a subject.
23 NSString* result = [handler rewriteMailtoURL:GURL("mailto:user@domain.com")];
24 EXPECT_NSEQ(@"mailtohandler:/co?to=user@domain.com", result);
25 // Tests mailto URL with a subject.
26 result =
27 [handler rewriteMailtoURL:GURL("mailto:user@domain.com?subject=hello")];
28 EXPECT_NSEQ(@"mailtohandler:/co?to=user@domain.com&subject=hello", result);
29 // Tests mailto URL with unrecognized query parameters.
30 result = [handler
31 rewriteMailtoURL:
32 GURL("mailto:someone@there.com?garbage=in&garbageOut&subject=trash")];
33 EXPECT_NSEQ(@"mailtohandler:/co?to=someone@there.com&subject=trash", result);
34 }
35
36 TEST(MailtoHandlerTest, TestRewriteBad) {
37 MailtoHandler* handler = [[MailtoHandler alloc] init];
38 NSString* result = [handler rewriteMailtoURL:GURL("http://www.google.com")];
39 EXPECT_FALSE(result);
40 result = [handler
41 rewriteMailtoURL:
42 GURL("mailto:user@domain.com?foo=bar&cc=someone@somewhere.com")];
43 EXPECT_NSEQ(@"mailtohandler:/co?to=user@domain.com&cc=someone@somewhere.com",
44 result);
45 }
OLDNEW
« 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