Skip to content

Commit 067801e

Browse files
author
Edward Smith
committed
Merge branch 'staging' of github.com:BranchMetrics/ios-branch-deep-linking into share-source-DEVEX-332
2 parents 955c28e + 919a3ec commit 067801e

File tree

19 files changed

+508
-61
lines changed

19 files changed

+508
-61
lines changed

Branch-SDK/Branch-SDK/BNCURLBlackList.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ - (void) processServerOperation:(id<BNCNetworkOperationProtocol>)operation {
153153
BNCLogDebugSDK(@"No new BlackList refresh found.");
154154
} else {
155155
BNCLogDebugSDK(@"BlackList refresh result. Error: %@ status: %ld body:\n%@.",
156-
operation.error, operation.response.statusCode, responseString);
156+
operation.error, (long)operation.response.statusCode, responseString);
157157
}
158158
if (operation.error || operation.responseData == nil || operation.response.statusCode != 200) {
159159
self.error = operation.error;

Branch-TestBed/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
1. From the command line:
44
- Clone the repo: `git clone [email protected]:BranchMetrics/ios-branch-deep-linking.git`
5-
2. In Finder open: **Branch-TestBed.xcworkspace**
5+
2. In Finder open: **Branch-TestBed.xcodeproj**
66
3. In Xcode click on the root node of the project: Branch-TestBed
77
4. Under Targets select Branch-TestBed, then the General tab
88
5. Change the Bundle Identifier to something **unique** (for this demo we'll use `io.branch.Objective-C.TestBed`)

Branch.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Use the Branch SDK (branch.io) to create and power the links that point back to
3535
s.subspec 'without-IDFA' do |idfa|
3636
idfa.source_files = source_files
3737
idfa.private_header_files = "Branch-SDK/Fabric/*.h"
38-
idfa.frameworks = 'MobileCoreServices'
38+
idfa.frameworks = 'MobileCoreServices', 'SafariServices'
3939
end
4040

4141
s.subspec 'without-Safari' do |safari|

Examples/UITestBed/UITests/Info.plist renamed to Examples/UITestBed/UITestBed-UITests/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<plist version="1.0">
44
<dict>
55
<key>CFBundleDevelopmentRegion</key>
6-
<string>en</string>
6+
<string>$(DEVELOPMENT_LANGUAGE)</string>
77
<key>CFBundleExecutable</key>
88
<string>$(EXECUTABLE_NAME)</string>
99
<key>CFBundleIdentifier</key>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
UITest.strings
3+
UITestBed
4+
5+
Created by Edward on 5/7/18.
6+
Copyright © 2018 Branch. All rights reserved.
7+
*/
8+
9+
"UITestSafari" =
10+
"
11+
{
12+
\"~referring_link\" : \"https:\\/\\/branch-uitestbed.app.link\\/YZIfk1NgJM\",
13+
\"~creation_source\" : 3,
14+
\"$one_time_use\" : false,
15+
\"+is_first_session\" : false,
16+
\"$creation_timestamp\" : 1525710507469,
17+
\"$og_title\" : \"Content Title\",
18+
\"$desktop_url\" : \"http:\\/\\/branch.io\",
19+
\"$currency\" : \"$\",
20+
\"deeplink_text\" : \"This text was embedded as data in a Branch link with the following characteristics:\\n\\ncanonicalUrl: https:\\/\\/dev.branch.io\\/getting-started\\/deep-link-routing\\/guide\\/ios\\/\\n title: Content Title\\n contentDescription: My Content Description\\n imageUrl: http:\\/\\/a57.foxnews.com\\/images.foxnews.com\\/content\\/fox-news\\/science\\/2018\\/03\\/20\\/first-day-spring-arrives-5-things-to-know-about-vernal-equinox\\/_jcr_content\\/par\\/featured_image\\/media-0.img.jpg\\/1862\\/1048\\/1521552912093.jpg?ve=1&tl=1\\n\",
21+
\"~campaign\" : \"some campaign\",
22+
\"~channel\" : \"Distribution Channel\",
23+
\"$og_description\" : \"My Content Description\",
24+
\"$og_type\" : \"website\",
25+
\"$identity_id\" : 522069179592022788,
26+
\"$content_schema\" : \"some type\",
27+
\"$canonical_identifier\" : \"item\\/12345\",
28+
\"$og_image_url\" : \"http:\\/\\/a57.foxnews.com\\/images.foxnews.com\\/content\\/fox-news\\/science\\/2018\\/03\\/20\\/first-day-spring-arrives-5-things-to-know-about-vernal-equinox\\/_jcr_content\\/par\\/featured_image\\/media-0.img.jpg\\/1862\\/1048\\/1521552912093.jpg?ve=1&tl=1\",
29+
\"+click_timestamp\" : **********,
30+
\"~id\" : 522074586054440364,
31+
\"$ios_url\" : \"https:\\/\\/dev.branch.io\\/getting-started\\/sdk-integration-guide\\/guide\\/ios\\/\",
32+
\"+clicked_branch_link\" : true,
33+
\"$price\" : 1000,
34+
\"~feature\" : \"Sharing Feature\",
35+
\"+match_guaranteed\" : true,
36+
\"$canonical_url\" : \"https:\\/\\/dev.branch.io\\/getting-started\\/deep-link-routing\\/guide\\/ios\\/\"
37+
}
38+
";
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
//
2+
// UITestEvents.m
3+
// UITestBed-UITests
4+
//
5+
// Created by Edward on 5/7/18.
6+
// Copyright © 2018 Branch. All rights reserved.
7+
//
8+
9+
#import <XCTest/XCTest.h>
10+
11+
@interface UITestEvents : XCTestCase
12+
@property (strong) XCUIApplication*currentApp;
13+
@end
14+
15+
@implementation UITestEvents
16+
17+
- (void)setUp {
18+
[super setUp];
19+
self.continueAfterFailure = NO;
20+
self.currentApp = [[XCUIApplication alloc] init];
21+
[self.currentApp launch];
22+
}
23+
24+
- (void)tearDown {
25+
[super tearDown];
26+
}
27+
28+
- (XCUIElement*) tableCellNamed:(NSString*)name {
29+
NSString*query = [NSString stringWithFormat:@"label contains '%@'", name];
30+
XCUIElementQuery*cells =
31+
[self.currentApp.cells containingPredicate:[NSPredicate predicateWithFormat:query]];
32+
return cells.firstMatch;
33+
}
34+
35+
- (void)testExample {
36+
[self.currentApp.buttons[@"Done"] tap];
37+
[[self tableCellNamed:@"Send Commerce Event"] tap];
38+
XCUIElement*element = self.currentApp.textViews[@"Data"].firstMatch;
39+
NSString*value = element.value;
40+
XCTAssertTrue(value && [value isEqualToString:@"{\n \"branch_view_enabled\" : true\n}"]);
41+
}
42+
43+
@end

Examples/UITestBed/UITests/UITestSafari.m renamed to Examples/UITestBed/UITestBed-UITests/UITestSafari.m

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
static NSString* const kWikiPageURL =
1818
@"https://github.com/BranchMetrics/ios-branch-deep-linking/wiki/"
1919
"UITest-for-Testbed-App-for-Universal-links";
20-
static NSString* const kUniversalLinkTag = @"Universal Link TestBed Obj-c";
21-
20+
static NSString* const kUniversalLinkTag = @"UITestBed: Universal Link";
2221

2322
@interface TestBedUITests : XCTestCase
2423
@end
@@ -49,16 +48,36 @@ - (void)tearDown {
4948
[super tearDown];
5049
}
5150

51+
- (NSString*) stringFromBundleWithKey:(NSString*)key {
52+
NSString *const kItemNotFound = @"<Item-Not-Found>";
53+
NSString *resource =
54+
[[NSBundle bundleForClass:self.class] localizedStringForKey:key value:kItemNotFound table:@"UITestBed"];
55+
if ([resource isEqualToString:kItemNotFound]) resource = nil;
56+
return resource;
57+
}
58+
5259
-(void)testDeepLinking {
5360
[XCUIDevice sharedDevice].orientation = UIDeviceOrientationFaceUp;
54-
61+
62+
// Close the any open data views:
63+
XCUIApplication*currentApp = [[XCUIApplication alloc] init];
64+
XCUIElement*element = currentApp.buttons[@"Done"].firstMatch;
65+
[element tap];
66+
67+
// Click Safari:
5568
XCUIApplication *safariApp = [self openSafariWithUrl:kWikiPageURL];
5669
[safariApp.links[kUniversalLinkTag] tap];
57-
sleep(kDeepLinkSleepTimeInterval);
58-
59-
XCUIApplication *currentApp = [[XCUIApplication alloc] init];
60-
XCUIElement* element = currentApp.textViews[@"DeepLinkData"];
61-
XCTAssertTrue([element.value bnc_containsString:@"Successfully Deeplinked"]);
70+
//sleep(kDeepLinkSleepTimeInterval);
71+
XCTAssertTrue(
72+
[currentApp waitForState:XCUIApplicationStateRunningForeground timeout:kDeepLinkSleepTimeInterval]
73+
);
74+
sleep(1);
75+
76+
element = currentApp.textViews[@"Data"].firstMatch;
77+
NSString*value = element.value;
78+
NSString*string = [[self stringFromBundleWithKey:@"UITestSafari"]
79+
stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
80+
XCTAssertTrue(string && value && [value bnc_isEqualToMaskedString:string]);
6281
}
6382

6483
-(XCUIApplication *) openSafariWithUrl: (NSString*) url {

0 commit comments

Comments
 (0)