Skip to content

Commit 56b2f2b

Browse files
attempting to fix conflict
2 parents 4ce6bbb + 16154d5 commit 56b2f2b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1418
-733
lines changed

Branch-SDK-Tests/BNCDeviceInfo.Test.m

Lines changed: 0 additions & 169 deletions
This file was deleted.
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
//
2+
// BNCDeviceInfoTests.m
3+
// Branch-SDK-Tests
4+
//
5+
// Created by Ernest Cho on 11/21/19.
6+
// Copyright © 2019 Branch, Inc. All rights reserved.
7+
//
8+
9+
#import <XCTest/XCTest.h>
10+
#import "BNCDeviceInfo.h"
11+
12+
@interface BNCDeviceInfoTests : XCTestCase
13+
@property (nonatomic, strong, readwrite) BNCDeviceInfo *deviceInfo;
14+
@end
15+
16+
@implementation BNCDeviceInfoTests
17+
18+
- (void)setUp {
19+
self.deviceInfo = [BNCDeviceInfo new];
20+
}
21+
22+
- (void)tearDown {
23+
24+
}
25+
26+
- (void)testAppVersion {
27+
// checks test app version
28+
XCTAssert([@"1.1" isEqualToString:self.deviceInfo.applicationVersion]);
29+
}
30+
31+
- (void)testBrandName {
32+
XCTAssert([@"Apple" isEqualToString:self.deviceInfo.brandName]);
33+
}
34+
35+
- (void)testModelName_Simulator {
36+
XCTAssert([@"x86_64" isEqualToString:self.deviceInfo.modelName]);
37+
}
38+
39+
//- (void)testModelName_iPhone7 {
40+
// XCTAssert([@"iPhone9,3" isEqualToString:self.deviceInfo.modelName]);
41+
//}
42+
43+
- (void)testOSName {
44+
XCTAssertNotNil(self.deviceInfo.osName);
45+
XCTAssert([self.deviceInfo.osName isEqualToString:[UIDevice currentDevice].systemName]);
46+
}
47+
48+
- (void)testOSVersion {
49+
XCTAssertNotNil(self.deviceInfo.osVersion);
50+
XCTAssert([self.deviceInfo.osVersion isEqualToString:[UIDevice currentDevice].systemVersion]);
51+
}
52+
53+
- (void)testOSBuildVersion {
54+
XCTAssertNotNil(self.deviceInfo.osBuildVersion);
55+
}
56+
57+
- (void)testExtensionType {
58+
XCTAssert([@"FULL_APP" isEqualToString:self.deviceInfo.extensionType]);
59+
}
60+
61+
- (void)testCpuType_Simulator {
62+
NSNumber *expected = @(7);
63+
XCTAssert([expected isEqualToNumber:self.deviceInfo.cpuType]);
64+
}
65+
66+
//- (void)testCpuType_iPhone7 {
67+
// NSNumber *expected = @(16777228);
68+
// XCTAssert([expected isEqualToNumber:self.deviceInfo.cpuType]);
69+
//}
70+
71+
- (void)testScreenWidth {
72+
XCTAssert(self.deviceInfo.screenWidth.intValue > 320);
73+
}
74+
75+
- (void)testScreenHeight {
76+
XCTAssert(self.deviceInfo.screenHeight.intValue > 320);
77+
}
78+
79+
- (void)testScreenScale {
80+
XCTAssert(self.deviceInfo.screenScale.intValue > 0);
81+
}
82+
83+
- (void)testCarrierName_Simulator {
84+
XCTAssertNil(self.deviceInfo.carrierName);
85+
}
86+
87+
//- (void)testCarrierName_Att {
88+
// XCTAssert([@"AT&T" isEqualToString:self.deviceInfo.carrierName]);
89+
//}
90+
91+
- (void)testLocale {
92+
NSString *locale = [NSLocale currentLocale].localeIdentifier;
93+
XCTAssertNotNil(locale);
94+
XCTAssert([locale isEqualToString:self.deviceInfo.locale]);
95+
}
96+
97+
- (void)testCountry {
98+
NSString *locale = [NSLocale currentLocale].localeIdentifier;
99+
XCTAssertNotNil(locale);
100+
XCTAssert([locale containsString:self.deviceInfo.country]);
101+
}
102+
103+
- (void)testLanguage {
104+
NSString *locale = [NSLocale currentLocale].localeIdentifier;
105+
XCTAssertNotNil(locale);
106+
XCTAssert([locale containsString:self.deviceInfo.language]);
107+
}
108+
109+
- (void)testUserAgentString {
110+
// Currently this method is a trivial pass through to the BNCUserAgentCollector singleton
111+
// Eventually remove the singleton to enable easier testing
112+
}
113+
114+
- (void)testPlugin {
115+
XCTAssertNil(self.deviceInfo.pluginName);
116+
XCTAssertNil(self.deviceInfo.pluginVersion);
117+
118+
NSString *expectedName = @"react native";
119+
NSString *expectedVersion = @"1.0.0";
120+
121+
[self.deviceInfo registerPluginName:expectedName version:expectedVersion];
122+
123+
XCTAssert([expectedName isEqualToString:self.deviceInfo.pluginName]);
124+
XCTAssert([expectedVersion isEqualToString:self.deviceInfo.pluginVersion]);
125+
}
126+
127+
- (void)testLocalIPAddress {
128+
NSString *address = [self.deviceInfo localIPAddress];
129+
XCTAssertNotNil(address);
130+
131+
// shortest ipv4 is 7
132+
XCTAssert(address.length >= 7);
133+
}
134+
135+
// just a sanity check on the V2 dictionary
136+
- (void)testV2Dictionary {
137+
NSDictionary *dict = [self.deviceInfo v2dictionary];
138+
XCTAssertNotNil(dict);
139+
XCTAssertNotNil([dict objectForKey:@"brand"]);
140+
XCTAssertNotNil([dict objectForKey:@"os"]);
141+
XCTAssertNotNil([dict objectForKey:@"sdk"]);
142+
XCTAssertNotNil([dict objectForKey:@"sdk_version"]);
143+
}
144+
145+
@end
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//
2+
// BNCDeviceSystemTests.m
3+
// Branch-SDK-Tests
4+
//
5+
// Created by Ernest Cho on 11/14/19.
6+
// Copyright © 2019 Branch, Inc. All rights reserved.
7+
//
8+
9+
#import <XCTest/XCTest.h>
10+
#import "BNCDeviceSystem.h"
11+
12+
@interface BNCDeviceSystemTests : XCTestCase
13+
14+
@property (nonatomic, strong, readwrite) BNCDeviceSystem *deviceSystem;
15+
16+
@end
17+
18+
@implementation BNCDeviceSystemTests
19+
20+
- (void)setUp {
21+
self.deviceSystem = [BNCDeviceSystem new];
22+
}
23+
24+
- (void)tearDown {
25+
26+
}
27+
28+
- (void)testSystemBuildVersion {
29+
XCTAssertNotNil(self.deviceSystem.systemBuildVersion);
30+
XCTAssert(self.deviceSystem.systemBuildVersion.length > 0);
31+
}
32+
33+
- (void)testMachine_Simulator {
34+
XCTAssert([@"x86_64" isEqualToString:self.deviceSystem.machine]);
35+
}
36+
37+
- (void)testCPUType_Simulator {
38+
XCTAssert([@(7) isEqualToNumber:self.deviceSystem.cpuType]);
39+
XCTAssert([@(8) isEqualToNumber:self.deviceSystem.cpuSubType]);
40+
}
41+
42+
@end

Branch-SDK-Tests/BNCFacebookAppLinksTests.m

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ - (void)testFetchFacebookAppLink {
4848
[self.applinks registerFacebookDeepLinkingClass:[BNCFacebookMock new]];
4949
[self.applinks fetchFacebookAppLinkWithCompletion:^(NSURL * _Nullable appLink, NSError * _Nullable error) {
5050
XCTAssertTrue([[appLink absoluteString] isEqualToString:@"https://branch.io"]);
51+
XCTAssertTrue([NSThread isMainThread]);
5152
[expectation fulfill];
5253
}];
5354

@@ -56,4 +57,23 @@ - (void)testFetchFacebookAppLink {
5657
}];
5758
}
5859

60+
// check if FBSDKAppLinkUtility.fetchDeferredAppLink is called on the main thread
61+
// https://developers.facebook.com/docs/reference/ios/current/class/FBSDKAppLinkUtility
62+
- (void)testFetchFacebookAppLink_BackgroundThead {
63+
__block XCTestExpectation *expectation = [self expectationWithDescription:@""];
64+
65+
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
66+
[self.applinks registerFacebookDeepLinkingClass:[BNCFacebookMock new]];
67+
[self.applinks fetchFacebookAppLinkWithCompletion:^(NSURL * _Nullable appLink, NSError * _Nullable error) {
68+
XCTAssertTrue([[appLink absoluteString] isEqualToString:@"https://branch.io"]);
69+
XCTAssertTrue([NSThread isMainThread]);
70+
[expectation fulfill];
71+
}];
72+
});
73+
74+
[self waitForExpectationsWithTimeout:2 handler:^(NSError * _Nullable error) {
75+
NSLog(@"%@", error);
76+
}];
77+
}
78+
5979
@end

0 commit comments

Comments
 (0)