OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 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/external_app_launcher.h" |
| 6 |
| 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "testing/gtest_mac.h" |
| 9 |
| 10 @interface ExternalAppLauncher (Private) |
| 11 // Returns the Phone/FaceTime call argument from |url|. |
| 12 // Made available for unit testing. |
| 13 + (NSString*)formatCallArgument:(NSURL*)url; |
| 14 @end |
| 15 |
| 16 namespace { |
| 17 |
| 18 TEST(ExternalAppLauncherTest, TestBadFormatCallArgument) { |
| 19 EXPECT_NSEQ(@"garbage:", |
| 20 [ExternalAppLauncher |
| 21 formatCallArgument:[NSURL URLWithString:@"garbage:"]]); |
| 22 EXPECT_NSEQ(@"malformed:////", |
| 23 [ExternalAppLauncher |
| 24 formatCallArgument:[NSURL URLWithString:@"malformed:////"]]); |
| 25 } |
| 26 |
| 27 TEST(ExternalAppLauncherTest, TestFormatCallArgument) { |
| 28 EXPECT_NSEQ( |
| 29 @"+1234", |
| 30 [ExternalAppLauncher |
| 31 formatCallArgument:[NSURL URLWithString:@"facetime://+1234"]]); |
| 32 EXPECT_NSEQ( |
| 33 @"+abcd", |
| 34 [ExternalAppLauncher |
| 35 formatCallArgument:[NSURL URLWithString:@"facetime-audio://+abcd"]]); |
| 36 EXPECT_NSEQ( |
| 37 @"+1-650-555-1212", |
| 38 [ExternalAppLauncher |
| 39 formatCallArgument:[NSURL URLWithString:@"tel://+1-650-555-1212"]]); |
| 40 EXPECT_NSEQ(@"75009", |
| 41 [ExternalAppLauncher |
| 42 formatCallArgument:[NSURL URLWithString:@"garbage:75009"]]); |
| 43 } |
| 44 |
| 45 TEST(ExternalAppLauncherTest, TestURLEscapedArgument) { |
| 46 EXPECT_NSEQ(@"+1 650 555 1212", |
| 47 [ExternalAppLauncher |
| 48 formatCallArgument: |
| 49 [NSURL URLWithString:@"tel://+1%20650%20555%201212"]]); |
| 50 } |
| 51 |
| 52 } // namespace |
OLD | NEW |