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

Side by Side Diff: ios/web/public/origin_util_unittest.mm

Issue 2610923005: Replace ObjCPropertyReleaser with ReleaseProperties() project-wide. (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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/web/public/origin_util.h" 5 #import "ios/web/public/origin_util.h"
6 6
7 #import <WebKit/WebKit.h> 7 #import <WebKit/WebKit.h>
8 8
9 #import "base/mac/objc_property_releaser.h" 9 #include "base/mac/objc_release_properties.h"
10 #import "base/mac/scoped_nsobject.h" 10 #import "base/mac/scoped_nsobject.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "url/gurl.h" 12 #include "url/gurl.h"
13 13
14 // WKSecurityOrigin can not be manually created, hence stub is needed. 14 // WKSecurityOrigin can not be manually created, hence stub is needed.
15 @interface WKSecurityOriginStub : NSObject 15 @interface WKSecurityOriginStub : NSObject
16 // Methods from WKSecurityOrigin class. 16 // Methods from WKSecurityOrigin class.
17 @property(nonatomic, copy) NSString* protocol; 17 @property(nonatomic, copy) NSString* protocol;
18 @property(nonatomic, copy) NSString* host; 18 @property(nonatomic, copy) NSString* host;
19 @property(nonatomic) NSInteger port; 19 @property(nonatomic) NSInteger port;
20 @end 20 @end
21 21
22 @implementation WKSecurityOriginStub { 22 @implementation WKSecurityOriginStub
23 base::mac::ObjCPropertyReleaser _propertyReleaser;
24 }
25 @synthesize protocol = _protocol; 23 @synthesize protocol = _protocol;
26 @synthesize host = _host; 24 @synthesize host = _host;
27 @synthesize port = _port; 25 @synthesize port = _port;
28 - (instancetype)init { 26 - (void)dealloc {
29 if (self = [super init]) { 27 base::mac::ReleaseProperties(self);
30 _propertyReleaser.Init(self, [WKSecurityOriginStub class]); 28 [super dealloc];
31 }
32 return self;
33 } 29 }
34 @end 30 @end
35 31
36 namespace web { 32 namespace web {
37 33
38 // Tests calling GURLOriginWithWKSecurityOrigin with nil. 34 // Tests calling GURLOriginWithWKSecurityOrigin with nil.
39 TEST(OriginUtilTest, GURLOriginWithNilWKSecurityOrigin) { 35 TEST(OriginUtilTest, GURLOriginWithNilWKSecurityOrigin) {
40 GURL url(GURLOriginWithWKSecurityOrigin(nil)); 36 GURL url(GURLOriginWithWKSecurityOrigin(nil));
41 37
42 EXPECT_FALSE(url.is_valid()); 38 EXPECT_FALSE(url.is_valid());
43 EXPECT_TRUE(url.spec().empty()); 39 EXPECT_TRUE(url.spec().empty());
44 } 40 }
45 41
46 // Tests calling GURLOriginWithWKSecurityOrigin with valid origin. 42 // Tests calling GURLOriginWithWKSecurityOrigin with valid origin.
47 TEST(OriginUtilTest, GURLOriginWithValidWKSecurityOrigin) { 43 TEST(OriginUtilTest, GURLOriginWithValidWKSecurityOrigin) {
48 base::scoped_nsobject<WKSecurityOriginStub> origin( 44 base::scoped_nsobject<WKSecurityOriginStub> origin(
49 [[WKSecurityOriginStub alloc] init]); 45 [[WKSecurityOriginStub alloc] init]);
50 [origin setProtocol:@"http"]; 46 [origin setProtocol:@"http"];
51 [origin setHost:@"chromium.org"]; 47 [origin setHost:@"chromium.org"];
52 [origin setPort:80]; 48 [origin setPort:80];
53 49
54 GURL url(GURLOriginWithWKSecurityOrigin( 50 GURL url(GURLOriginWithWKSecurityOrigin(
55 static_cast<WKSecurityOrigin*>(origin.get()))); 51 static_cast<WKSecurityOrigin*>(origin.get())));
56 EXPECT_EQ("http://chromium.org/", url.spec()); 52 EXPECT_EQ("http://chromium.org/", url.spec());
57 EXPECT_TRUE(url.port().empty()); 53 EXPECT_TRUE(url.port().empty());
58 } 54 }
59 55
60 } // namespace web 56 } // namespace web
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/tools_menu/tools_menu_view_tools_cell.mm ('k') | ios/web/web_state/ui/crw_web_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698