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

Side by Side Diff: ios/chrome/browser/ui/dialogs/nsurl_protection_space_util_unittest.mm

Issue 2686913003: [ObjC ARC] Converts ios/chrome/browser/ui/dialogs:unit_tests_internal to ARC. (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « ios/chrome/browser/ui/dialogs/dialog_presenter_unittest.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "ios/chrome/browser/ui/dialogs/nsurl_protection_space_util.h" 5 #import "ios/chrome/browser/ui/dialogs/nsurl_protection_space_util.h"
6 6
7 #include "base/ios/ios_util.h" 7 #include "base/ios/ios_util.h"
8 #import "base/mac/scoped_nsobject.h"
9 #include "base/strings/sys_string_conversions.h" 8 #include "base/strings/sys_string_conversions.h"
10 #include "components/strings/grit/components_strings.h" 9 #include "components/strings/grit/components_strings.h"
11 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
12 #include "testing/gtest_mac.h" 11 #include "testing/gtest_mac.h"
13 #include "testing/platform_test.h" 12 #include "testing/platform_test.h"
14 #include "ui/base/l10n/l10n_util.h" 13 #include "ui/base/l10n/l10n_util.h"
15 #include "ui/base/l10n/l10n_util_mac.h" 14 #include "ui/base/l10n/l10n_util_mac.h"
16 15
16 #if !defined(__has_feature) || !__has_feature(objc_arc)
17 #error "This file requires ARC support."
18 #endif
19
17 using namespace ios_internal::nsurlprotectionspace_util; 20 using namespace ios_internal::nsurlprotectionspace_util;
18 21
19 namespace { 22 namespace {
20 23
21 // Test hostnames and URL origins. 24 // Test hostnames and URL origins.
22 NSString* const kTestHost = @"chromium.org"; 25 NSString* const kTestHost = @"chromium.org";
23 NSString* const kTestHttpOrigin = @"http://chromium.org"; 26 NSString* const kTestHttpOrigin = @"http://chromium.org";
24 NSString* const kTestHttpsOrigin = @"https://chromium.org:80"; 27 NSString* const kTestHttpsOrigin = @"https://chromium.org:80";
25 28
26 // Returns protection space for the given |host|, |protocol| and |port|. 29 // Returns protection space for the given |host|, |protocol| and |port|.
27 NSURLProtectionSpace* GetProtectionSpaceForHost(NSString* host, 30 NSURLProtectionSpace* GetProtectionSpaceForHost(NSString* host,
28 NSString* protocol, 31 NSString* protocol,
29 NSInteger port) { 32 NSInteger port) {
30 return [[[NSURLProtectionSpace alloc] initWithHost:host 33 return [[NSURLProtectionSpace alloc] initWithHost:host
31 port:port 34 port:port
32 protocol:protocol 35 protocol:protocol
33 realm:nil 36 realm:nil
34 authenticationMethod:nil] autorelease]; 37 authenticationMethod:nil];
35 } 38 }
36 39
37 // Returns protection space for the given |host| and |protocol| and port 80. 40 // Returns protection space for the given |host| and |protocol| and port 80.
38 NSURLProtectionSpace* GetProtectionSpaceForHost(NSString* host, 41 NSURLProtectionSpace* GetProtectionSpaceForHost(NSString* host,
39 NSString* protocol) { 42 NSString* protocol) {
40 return GetProtectionSpaceForHost(host, protocol, 80); 43 return GetProtectionSpaceForHost(host, protocol, 80);
41 } 44 }
42 45
43 // Returns protection space for the given proxy |host| and |protocol|. 46 // Returns protection space for the given proxy |host| and |protocol|.
44 NSURLProtectionSpace* GetProtectionSpaceForProxyHost(NSString* host, 47 NSURLProtectionSpace* GetProtectionSpaceForProxyHost(NSString* host,
45 NSString* type) { 48 NSString* type) {
46 return [[[NSURLProtectionSpace alloc] initWithProxyHost:host 49 return [[NSURLProtectionSpace alloc] initWithProxyHost:host
47 port:80 50 port:80
48 type:type 51 type:type
49 realm:nil 52 realm:nil
50 authenticationMethod:nil] autorelease]; 53 authenticationMethod:nil];
51 } 54 }
52 55
53 } // namespace 56 } // namespace
54 57
55 // Tests that dialog can not be shown without valid host. 58 // Tests that dialog can not be shown without valid host.
56 TEST(NSURLProtectionSpaceUtilTest, CantShowWithoutValidHost) { 59 TEST(NSURLProtectionSpaceUtilTest, CantShowWithoutValidHost) {
57 NSURLProtectionSpace* protectionSpace = 60 NSURLProtectionSpace* protectionSpace =
58 GetProtectionSpaceForHost(@"", NSURLProtectionSpaceHTTPS); 61 GetProtectionSpaceForHost(@"", NSURLProtectionSpaceHTTPS);
59 62
60 EXPECT_FALSE(CanShow(protectionSpace)); 63 EXPECT_FALSE(CanShow(protectionSpace));
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 GetProtectionSpaceForHost(kTestHost, NSURLProtectionSpaceHTTPS); 165 GetProtectionSpaceForHost(kTestHost, NSURLProtectionSpaceHTTPS);
163 166
164 ASSERT_TRUE(CanShow(protectionSpace)); 167 ASSERT_TRUE(CanShow(protectionSpace));
165 168
166 // Expecting the following text: 169 // Expecting the following text:
167 // https://chromium.org:80 requires a username and password. 170 // https://chromium.org:80 requires a username and password.
168 NSString* expectedText = l10n_util::GetNSStringF( 171 NSString* expectedText = l10n_util::GetNSStringF(
169 IDS_LOGIN_DIALOG_AUTHORITY, base::SysNSStringToUTF16(kTestHttpsOrigin)); 172 IDS_LOGIN_DIALOG_AUTHORITY, base::SysNSStringToUTF16(kTestHttpsOrigin));
170 EXPECT_NSEQ(expectedText, MessageForHTTPAuth(protectionSpace)); 173 EXPECT_NSEQ(expectedText, MessageForHTTPAuth(protectionSpace));
171 } 174 }
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/dialogs/dialog_presenter_unittest.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698