Skip to content

Commit 82b9d6c

Browse files
committed
Fixed a logging test and updated some file names.
1 parent 5073beb commit 82b9d6c

File tree

6 files changed

+41
-27
lines changed

6 files changed

+41
-27
lines changed

Branch-SDK/Branch-SDK/BNCLog.m

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ BOOL BNCLogRecordWrapOpenURL_Internal(NSURL *url, long maxRecords, long recordSi
217217

218218
off_t oldestOffset = 0;
219219
NSDate * oldestDate = [NSDate distantFuture];
220+
NSDate * lastDate = [NSDate distantFuture];
220221

221222
off_t offset = 0;
222223
char buffer[bnc_LogRecordSize];
@@ -225,11 +226,13 @@ BOOL BNCLogRecordWrapOpenURL_Internal(NSURL *url, long maxRecords, long recordSi
225226
NSString *dateString =
226227
[[NSString alloc] initWithBytes:buffer length:27 encoding:NSUTF8StringEncoding];
227228
NSDate *date = [bnc_LogDateFormatter dateFromString:dateString];
228-
if (date && [date compare:oldestDate] < 0) {
229+
if ([date compare:oldestDate] < 0 ||
230+
[date compare:lastDate] < 0) {
229231
oldestOffset = offset;
230232
oldestDate = date;
231233
}
232234
offset++;
235+
if (date) lastDate = date;
233236
bytesRead = read(bnc_LogDescriptor, &buffer, sizeof(buffer));
234237
}
235238
if (offset < bnc_LogOffsetMax)
@@ -638,7 +641,7 @@ void BNCLogFlushMessages() {
638641
__attribute__((constructor)) void BNCLogInitialize(void) {
639642
static dispatch_once_t onceToken = 0;
640643
dispatch_once(&onceToken, ^ {
641-
bnc_LogQueue = dispatch_queue_create("io.branch.log", DISPATCH_QUEUE_SERIAL);
644+
bnc_LogQueue = dispatch_queue_create("io.branch.sdk.log", DISPATCH_QUEUE_SERIAL);
642645

643646
bnc_LogDateFormatter = [[NSDateFormatter alloc] init];
644647
bnc_LogDateFormatter.locale = [NSLocale localeWithLocaleIdentifier:@"en_US_POSIX"];

Branch-SDK/Branch-SDK/Networking/BNCNetworkService.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ - (NSURLSession*) session {
144144
configuration.URLCache = nil;
145145

146146
self.sessionQueue = [NSOperationQueue new];
147-
self.sessionQueue.name = @"io.branch.network.queue";
147+
self.sessionQueue.name = @"io.branch.sdk.network.queue";
148148
self.sessionQueue.maxConcurrentOperationCount = self.maximumConcurrentOperations;
149149
if ([self.sessionQueue respondsToSelector:@selector(setQualityOfService:)]) {
150150
// qualityOfService is iOS 8 and above.
@@ -155,7 +155,7 @@ - (NSURLSession*) session {
155155
[NSURLSession sessionWithConfiguration:configuration
156156
delegate:self
157157
delegateQueue:self.sessionQueue];
158-
_session.sessionDescription = @"io.branch.network.session";
158+
_session.sessionDescription = @"io.branch.sdk.network.session";
159159

160160
return _session;
161161
}

Branch-TestBed/Branch-SDK-Tests/BNCLog.Test.m

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,10 +436,14 @@ - (void) testLogFunctionOutputToURLRecordWrap {
436436
"****-**-**T**:**:**.******Z 6 [branch.io] BNCLog.Test.m(***) Log: Log 20. \n"
437437
"****-**-**T**:**:**.******Z 6 [branch.io] BNCLog.Test.m(***) Log: Log 21. \n"
438438
"****-**-**T**:**:**.******Z 6 [branch.io] BNCLog.Test.m(***) Log: Log 22. \n";
439-
NSLog(@"testLogFunctionOutputToURLRecordWrap truth/string:\n%@\n%@.", truth, string); // TODO: Remove log.
440439
XCTAssert([string bnc_isEqualToMaskedString:truth]);
441440
}
442441

442+
- (void) testStressRecordWrap {
443+
for (int i = 0; i < 1000; i++)
444+
[self testLogFunctionOutputToURLRecordWrap];
445+
}
446+
443447
- (void) testLogRecordWrapPerformanceTesting {
444448

445449
NSError *error = nil;
@@ -706,6 +710,11 @@ - (void) testLogFunctionOutputToURLByteWrap {
706710
XCTAssert([string bnc_isEqualToMaskedString:truth]);
707711
}
708712

713+
- (void) testStressByteWrap {
714+
for (int i = 0; i < 1000; i++)
715+
[self testLogFunctionOutputToURLByteWrap];
716+
}
717+
709718
- (void) testLogByteWrapPerformanceTesting {
710719

711720
NSError *error = nil;
@@ -801,7 +810,6 @@ - (void) testLogByteWrapPerformanceTesting {
801810
NSLog(@"%@: Synchronized time: %1.5f.",
802811
BNCSStringForCurrentMethod(), - startTime.timeIntervalSinceNow);
803812

804-
805813
/* // Non-sychronized --
806814
// EBS: Non-sychronized is no longer a thing. It was slower and less safe.
807815
File renamed without changes.

Branch-TestBed/Branch-TestBedUITests/Branch_TestBedUITests.m renamed to Branch-TestBed/Branch-TestBed-UITests/TestBedUITests.m

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,39 @@
55
// Created by Parth Kalavadia on 8/2/17.
66
// Copyright © 2017 Branch Metrics. All rights reserved.
77
//
8+
89
#import <XCTest/XCTest.h>
910

1011
static NSTimeInterval const kDeepLinkSleepTimeInterval = 10.0;
1112
static NSTimeInterval const kLoadWikiPageTimeInterval = 3.0;
12-
static NSString* const kWikiPageURL = @"https://github.com/BranchMetrics/ios-branch-deep-linking/wiki/UITest-for-Testbed-App-for-Universal-links";
13+
static NSString* const kWikiPageURL =
14+
@"https://github.com/BranchMetrics/ios-branch-deep-linking/wiki/"
15+
"UITest-for-Testbed-App-for-Universal-links";
1316
static NSString* const kUniversalLinkTag = @"Universal Link TestBed Obj-c";
14-
@interface Branch_TestBedUITests : XCTestCase
1517

1618

19+
@interface TestBedUITests : XCTestCase
1720
@end
1821

1922
@interface XCUIApplication (Private)
2023
- (id)initPrivateWithPath:(NSString *)path bundleID:(NSString *)bundleID;
2124
- (void)resolve;
2225
@end
2326

24-
@implementation Branch_TestBedUITests
27+
@implementation TestBedUITests
2528

2629
- (void)setUp {
2730
[super setUp];
28-
29-
// Put setup code here. This method is called before the invocation of each test method in the class.
30-
31+
3132
// In UI tests it is usually best to stop immediately when a failure occurs.
3233
self.continueAfterFailure = NO;
33-
// UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
34+
35+
// UI tests must launch the application that they test.
36+
// Doing this in setup will make sure it happens for each test method.
3437
[[[XCUIApplication alloc] init] launch];
3538

36-
// In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
39+
// In UI tests it’s important to set the initial state - such as interface orientation -
40+
// required for your tests before they run. The setUp method is a good place to do this.
3741
}
3842

3943
- (void)tearDown {
@@ -54,16 +58,15 @@ -(void)testDeepLinking {
5458
}
5559

5660
-(XCUIApplication *) openSafariWithUrl: (NSString*) url {
57-
XCUIApplication *app = [[XCUIApplication alloc] initPrivateWithPath:nil bundleID:@"com.apple.mobilesafari"];
61+
XCUIApplication *app =
62+
[[XCUIApplication alloc] initPrivateWithPath:nil bundleID:@"com.apple.mobilesafari"];
5863
[app launch];
59-
6064
[app.otherElements[@"URL"] tap];
6165
[app.textFields[@"Search or enter website name"] tap];
6266
[app typeText:url];
6367
[app.buttons[@"Go"] tap];
6468
sleep(kLoadWikiPageTimeInterval);
6569
return app;
66-
6770
}
6871

6972
@end

Branch-TestBed/Branch-TestBed.xcodeproj/project.pbxproj

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
E2B9474A1D15D75000F2270D /* BNCCallbacks.h in Headers */ = {isa = PBXBuildFile; fileRef = E2B947491D15D73900F2270D /* BNCCallbacks.h */; settings = {ATTRIBUTES = (Public, ); }; };
116116
F1D359201ED4DCC500A93FD5 /* BNCDeepLinkViewControllerInstance.h in Headers */ = {isa = PBXBuildFile; fileRef = F1D3591E1ED4DCC500A93FD5 /* BNCDeepLinkViewControllerInstance.h */; };
117117
F1D359211ED4DCC500A93FD5 /* BNCDeepLinkViewControllerInstance.m in Sources */ = {isa = PBXBuildFile; fileRef = F1D3591F1ED4DCC500A93FD5 /* BNCDeepLinkViewControllerInstance.m */; };
118-
F1D4F9AF1F323F01002D13FF /* Branch_TestBedUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = F1D4F9AE1F323F01002D13FF /* Branch_TestBedUITests.m */; };
118+
F1D4F9AF1F323F01002D13FF /* TestBedUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = F1D4F9AE1F323F01002D13FF /* TestBedUITests.m */; };
119119
/* End PBXBuildFile section */
120120

121121
/* Begin PBXContainerItemProxy section */
@@ -318,7 +318,7 @@
318318
F1D3591E1ED4DCC500A93FD5 /* BNCDeepLinkViewControllerInstance.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BNCDeepLinkViewControllerInstance.h; sourceTree = "<group>"; };
319319
F1D3591F1ED4DCC500A93FD5 /* BNCDeepLinkViewControllerInstance.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BNCDeepLinkViewControllerInstance.m; sourceTree = "<group>"; };
320320
F1D4F9AC1F323F01002D13FF /* Branch-TestBed-UITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Branch-TestBed-UITests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
321-
F1D4F9AE1F323F01002D13FF /* Branch_TestBedUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Branch_TestBedUITests.m; sourceTree = "<group>"; };
321+
F1D4F9AE1F323F01002D13FF /* TestBedUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TestBedUITests.m; sourceTree = "<group>"; };
322322
F1D4F9B01F323F01002D13FF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
323323
/* End PBXFileReference section */
324324

@@ -445,7 +445,7 @@
445445
670016BB1946309100A9E103 /* Branch-SDK */,
446446
7E6B3B521AA42D0E005F45BF /* Branch-SDK-Tests */,
447447
670016691940F51400A9E103 /* Branch-TestBed */,
448-
F1D4F9AD1F323F01002D13FF /* Branch-TestBedUITests */,
448+
F1D4F9AD1F323F01002D13FF /* Branch-TestBed-UITests */,
449449
E220F4281C7D39D500F5B126 /* Fabric */,
450450
670016621940F51400A9E103 /* Frameworks */,
451451
670016611940F51400A9E103 /* Products */,
@@ -655,13 +655,13 @@
655655
name = Fabric;
656656
sourceTree = "<group>";
657657
};
658-
F1D4F9AD1F323F01002D13FF /* Branch-TestBedUITests */ = {
658+
F1D4F9AD1F323F01002D13FF /* Branch-TestBed-UITests */ = {
659659
isa = PBXGroup;
660660
children = (
661-
F1D4F9AE1F323F01002D13FF /* Branch_TestBedUITests.m */,
661+
F1D4F9AE1F323F01002D13FF /* TestBedUITests.m */,
662662
F1D4F9B01F323F01002D13FF /* Info.plist */,
663663
);
664-
path = "Branch-TestBedUITests";
664+
path = "Branch-TestBed-UITests";
665665
sourceTree = "<group>";
666666
};
667667
/* End PBXGroup section */
@@ -804,8 +804,8 @@
804804
projectRoot = "";
805805
targets = (
806806
466B58371B17773000A69EDE /* Branch */,
807-
6700165F1940F51400A9E103 /* Branch-TestBed */,
808807
7E6B3B501AA42D0E005F45BF /* Branch-SDK-Tests */,
808+
6700165F1940F51400A9E103 /* Branch-TestBed */,
809809
F1D4F9AB1F323F01002D13FF /* Branch-TestBed-UITests */,
810810
);
811811
};
@@ -1002,7 +1002,7 @@
10021002
isa = PBXSourcesBuildPhase;
10031003
buildActionMask = 2147483647;
10041004
files = (
1005-
F1D4F9AF1F323F01002D13FF /* Branch_TestBedUITests.m in Sources */,
1005+
F1D4F9AF1F323F01002D13FF /* TestBedUITests.m in Sources */,
10061006
);
10071007
runOnlyForDeploymentPostprocessing = 0;
10081008
};
@@ -1265,7 +1265,7 @@
12651265
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
12661266
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
12671267
DEVELOPMENT_TEAM = R63EM248DP;
1268-
INFOPLIST_FILE = "Branch-TestBedUITests/Info.plist";
1268+
INFOPLIST_FILE = "Branch-TestBed-UITests/Info.plist";
12691269
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
12701270
MTL_ENABLE_DEBUG_INFO = YES;
12711271
PRODUCT_BUNDLE_IDENTIFIER = "io.branch.sdk.$(PRODUCT_NAME:rfc1034identifier)";
@@ -1284,7 +1284,7 @@
12841284
COPY_PHASE_STRIP = NO;
12851285
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
12861286
DEVELOPMENT_TEAM = R63EM248DP;
1287-
INFOPLIST_FILE = "Branch-TestBedUITests/Info.plist";
1287+
INFOPLIST_FILE = "Branch-TestBed-UITests/Info.plist";
12881288
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
12891289
MTL_ENABLE_DEBUG_INFO = NO;
12901290
PRODUCT_BUNDLE_IDENTIFIER = "io.branch.sdk.$(PRODUCT_NAME:rfc1034identifier)";

0 commit comments

Comments
 (0)