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

Side by Side Diff: ios/chrome/browser/web/mailto_handler_unittest.mm

Issue 2852003002: Adds mailto: URL support to app launching. (Closed)
Patch Set: rebase 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 }
30
31 TEST(MailtoHandlerTest, TestRewriteBad) {
32 MailtoHandler* handler = [[MailtoHandler alloc] init];
33 NSString* result = [handler rewriteMailtoURL:GURL("http://www.google.com")];
34 EXPECT_FALSE(result);
35 result = [handler
36 rewriteMailtoURL:
37 GURL("mailto:user@domain.com?foo=bar&cc=someone@somewhere.com")];
38 EXPECT_NSEQ(@"mailtohandler:/co?to=user@domain.com&cc=someone@somewhere.com",
39 result);
40 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698