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

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

Issue 1919473003: [ios Mojo] Added util function to convert WKSecurityOrigin to GURL. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed test Created 4 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
« no previous file with comments | « ios/web/public/origin_util.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
(Empty)
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
3 // found in the LICENSE file.
4
5 #import "ios/web/public/origin_util.h"
6
7 #import <WebKit/WebKit.h>
8
9 #include "base/mac/objc_property_releaser.h"
10 #include "base/mac/scoped_nsobject.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "url/gurl.h"
13
14 // WKSecurityOrigin can not be manually created, hence stub is needed.
15 @interface WKSecurityOriginStub : NSObject
16 // Methods from WKSecurityOrigin class.
17 @property(nonatomic, copy) NSString* protocol;
18 @property(nonatomic, copy) NSString* host;
19 @property(nonatomic) NSInteger port;
20 @end
21
22 @implementation WKSecurityOriginStub {
23 base::mac::ObjCPropertyReleaser _propertyReleaser;
24 }
25 @synthesize protocol = _protocol;
26 @synthesize host = _host;
27 @synthesize port = _port;
28 - (instancetype)init {
29 if (self = [super init]) {
30 _propertyReleaser.Init(self, [WKSecurityOriginStub class]);
31 }
32 return self;
33 }
34 @end
35
36 namespace web {
37
38 // Tests calling GURLOriginWithWKSecurityOrigin with nil.
39 TEST(OriginUtilTest, GURLOriginWithNilWKSecurityOrigin) {
40 GURL url(GURLOriginWithWKSecurityOrigin(nil));
41
42 EXPECT_FALSE(url.is_valid());
43 EXPECT_TRUE(url.spec().empty());
44 }
45
46 // Tests calling GURLOriginWithWKSecurityOrigin with valid origin.
47 TEST(OriginUtilTest, GURLOriginWithValidWKSecurityOrigin) {
48 base::scoped_nsobject<WKSecurityOriginStub> origin(
49 [[WKSecurityOriginStub alloc] init]);
50 [origin setProtocol:@"http"];
51 [origin setHost:@"chromium.org"];
52 [origin setPort:80];
53
54 GURL url(GURLOriginWithWKSecurityOrigin(
55 static_cast<WKSecurityOrigin*>(origin.get())));
56 EXPECT_EQ("http://chromium.org/", url.spec());
57 EXPECT_TRUE(url.port().empty());
58 }
59
60 } // namespace web
OLDNEW
« no previous file with comments | « ios/web/public/origin_util.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698