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

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

Issue 2881183002: Revert of Replace ObjCPropertyReleaser with ReleaseProperties() project-wide. (Closed)
Patch Set: 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 #include "base/mac/objc_release_properties.h" 9 #import "base/mac/objc_property_releaser.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 }
23 @synthesize protocol = _protocol; 25 @synthesize protocol = _protocol;
24 @synthesize host = _host; 26 @synthesize host = _host;
25 @synthesize port = _port; 27 @synthesize port = _port;
26 - (void)dealloc { 28 - (instancetype)init {
27 base::mac::ReleaseProperties(self); 29 if (self = [super init]) {
28 [super dealloc]; 30 _propertyReleaser.Init(self, [WKSecurityOriginStub class]);
31 }
32 return self;
29 } 33 }
30 @end 34 @end
31 35
32 namespace web { 36 namespace web {
33 37
34 // Tests calling GURLOriginWithWKSecurityOrigin with nil. 38 // Tests calling GURLOriginWithWKSecurityOrigin with nil.
35 TEST(OriginUtilTest, GURLOriginWithNilWKSecurityOrigin) { 39 TEST(OriginUtilTest, GURLOriginWithNilWKSecurityOrigin) {
36 GURL url(GURLOriginWithWKSecurityOrigin(nil)); 40 GURL url(GURLOriginWithWKSecurityOrigin(nil));
37 41
38 EXPECT_FALSE(url.is_valid()); 42 EXPECT_FALSE(url.is_valid());
39 EXPECT_TRUE(url.spec().empty()); 43 EXPECT_TRUE(url.spec().empty());
40 } 44 }
41 45
42 // Tests calling GURLOriginWithWKSecurityOrigin with valid origin. 46 // Tests calling GURLOriginWithWKSecurityOrigin with valid origin.
43 TEST(OriginUtilTest, GURLOriginWithValidWKSecurityOrigin) { 47 TEST(OriginUtilTest, GURLOriginWithValidWKSecurityOrigin) {
44 base::scoped_nsobject<WKSecurityOriginStub> origin( 48 base::scoped_nsobject<WKSecurityOriginStub> origin(
45 [[WKSecurityOriginStub alloc] init]); 49 [[WKSecurityOriginStub alloc] init]);
46 [origin setProtocol:@"http"]; 50 [origin setProtocol:@"http"];
47 [origin setHost:@"chromium.org"]; 51 [origin setHost:@"chromium.org"];
48 [origin setPort:80]; 52 [origin setPort:80];
49 53
50 GURL url(GURLOriginWithWKSecurityOrigin( 54 GURL url(GURLOriginWithWKSecurityOrigin(
51 static_cast<WKSecurityOrigin*>(origin.get()))); 55 static_cast<WKSecurityOrigin*>(origin.get())));
52 EXPECT_EQ("http://chromium.org/", url.spec()); 56 EXPECT_EQ("http://chromium.org/", url.spec());
53 EXPECT_TRUE(url.port().empty()); 57 EXPECT_TRUE(url.port().empty());
54 } 58 }
55 59
56 } // namespace web 60 } // 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