IOSAD-55 adds PEPSessionProviderTest

IOS-898
buff 5 years ago
parent 1561df8b63
commit 171ae93690

@ -10,7 +10,7 @@
1508AEAF1F8792AC001D5230 /* PEPCopyableThread.m in Sources */ = {isa = PBXBuildFile; fileRef = 1508AEAE1F8792AC001D5230 /* PEPCopyableThread.m */; };
15206CAA1F8BA183003FF880 /* PEPSessionProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = 15206CA91F8BA183003FF880 /* PEPSessionProvider.m */; };
15206CC71F8E078B003FF880 /* PEPSession.m in Sources */ = {isa = PBXBuildFile; fileRef = 15206CC61F8E078B003FF880 /* PEPSession.m */; };
15DE372A200F5F7C007FBD94 /* PEPPEPSessionProviderTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 15DE3729200F5F7C007FBD94 /* PEPPEPSessionProviderTest.m */; };
15D3D761200F61BB00A0DA20 /* PEPSessionProviderTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 15D3D760200F61BB00A0DA20 /* PEPSessionProviderTest.m */; };
43209B3D1ECC2DA7007E7E2E /* NSArray+Extension.m in Sources */ = {isa = PBXBuildFile; fileRef = 43209B271ECC2ACD007E7E2E /* NSArray+Extension.m */; };
43209B3E1ECC2DAB007E7E2E /* PEPCSVScanner.m in Sources */ = {isa = PBXBuildFile; fileRef = 43209B291ECC2ACD007E7E2E /* PEPCSVScanner.m */; };
43209B3F1ECC2DB0007E7E2E /* PEPLanguage.m in Sources */ = {isa = PBXBuildFile; fileRef = 43209B2B1ECC2ACD007E7E2E /* PEPLanguage.m */; };
@ -115,7 +115,7 @@
15206CA91F8BA183003FF880 /* PEPSessionProvider.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PEPSessionProvider.m; sourceTree = "<group>"; };
15206CC51F8E078B003FF880 /* PEPSession.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PEPSession.h; sourceTree = "<group>"; };
15206CC61F8E078B003FF880 /* PEPSession.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PEPSession.m; sourceTree = "<group>"; };
15DE3729200F5F7C007FBD94 /* PEPPEPSessionProviderTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PEPPEPSessionProviderTest.m; sourceTree = "<group>"; };
15D3D760200F61BB00A0DA20 /* PEPSessionProviderTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PEPSessionProviderTest.m; sourceTree = "<group>"; };
352988AA1AEF964100FA7E2E /* libpEpObjCAdapter.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libpEpObjCAdapter.a; sourceTree = BUILT_PRODUCTS_DIR; };
35FB0ABB1B57F97E00377032 /* CFNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CFNetwork.framework; path = System/Library/Frameworks/CFNetwork.framework; sourceTree = SDKROOT; };
35FB0ABD1B57F99D00377032 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
@ -194,6 +194,13 @@
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
15D3D762200F6C6A00A0DA20 /* TestUtils */ = {
isa = PBXGroup;
children = (
);
path = TestUtils;
sourceTree = "<group>";
};
15DE372B200F5F93007FBD94 /* Recources */ = {
isa = PBXGroup;
children = (
@ -292,11 +299,12 @@
64415E181BE94FCB00F6CBB2 /* pEpObjCTests */ = {
isa = PBXGroup;
children = (
15D3D762200F6C6A00A0DA20 /* TestUtils */,
15DE372B200F5F93007FBD94 /* Recources */,
64415E191BE94FCB00F6CBB2 /* iOSTests.m */,
434226801D4F60000083ED79 /* PepTests.m */,
64415E1B1BE94FCB00F6CBB2 /* Info.plist */,
15DE3729200F5F7C007FBD94 /* PEPPEPSessionProviderTest.m */,
15D3D760200F61BB00A0DA20 /* PEPSessionProviderTest.m */,
);
path = pEpObjCTests;
sourceTree = "<group>";
@ -459,7 +467,7 @@
files = (
64415E1A1BE94FCB00F6CBB2 /* iOSTests.m in Sources */,
434226811D4F60000083ED79 /* PepTests.m in Sources */,
15DE372A200F5F7C007FBD94 /* PEPPEPSessionProviderTest.m in Sources */,
15D3D761200F61BB00A0DA20 /* PEPSessionProviderTest.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

@ -45,7 +45,7 @@ static PEPInternalSession *s_sessionForMainThread = nil;
}
[self nullifySessionsOfFinishedThreads];
// NSLog(@"#################\nnum sessions is now %lu",
// NSLog(@"#################\nnum sessions is now %lu", //BUFF: clean up
// (unsigned long)[self sessionForThreadDict].count + (s_sessionForMainThread ? 1 : 0));
// NSLog(@"Threads:");
// for (PEPCopyableThread *thread in dict.allKeys) {

@ -1,39 +0,0 @@
//
// PEPPEPSessionProviderTest.m
// pEpObjCAdapterTests
//
// Created by Andreas Buff on 17.01.18.
// Copyright © 2018 pp. All rights reserved.
//
#import <XCTest/XCTest.h>
@interface PEPPEPSessionProviderTest : XCTestCase
@end
@implementation PEPPEPSessionProviderTest
- (void)setUp {
[super setUp];
// Put setup code here. This method is called before the invocation of each test method in the class.
}
- (void)tearDown {
// Put teardown code here. This method is called after the invocation of each test method in the class.
[super tearDown];
}
- (void)testExample {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}
- (void)testPerformanceExample {
// This is an example of a performance test case.
[self measureBlock:^{
// Put the code you want to measure the time of here.
}];
}
@end

@ -0,0 +1,101 @@
//
// PEPSessionProviderTest.m
// pEpObjCAdapterTests
//
// Created by Andreas Buff on 17.01.18.
// Copyright © 2018 pp. All rights reserved.
//
#import <XCTest/XCTest.h>
#import "PEPSession.h"
#import "PEPInternalSession.h"
#import "PEPSessionProvider.h"
@interface PEPSessionProviderTest : XCTestCase
@end
@implementation PEPSessionProviderTest
- (void)testSeperatedSessionPerThread {
// Get main session
PEPInternalSession *sessionMain = [PEPSessionProvider session];
__block PEPInternalSession *sessionBackground = nil;
XCTestExpectation *exp = [self expectationWithDescription:@"background session created"];
// Get background session
dispatch_queue_t backgroundQueue = dispatch_queue_create("PEPSessionProviderTest.peptest1", 0);
dispatch_async(backgroundQueue, ^{
sessionBackground = [PEPSessionProvider session];
[exp fulfill];
});
[self waitForExpectationsWithTimeout:1.0 handler:^(NSError * _Nullable error) {
if (error) { XCTFail(@"timeout: %@", error); }
}];
XCTAssertNotNil(sessionMain);
XCTAssertNotNil(sessionBackground);
// Make sure we have seperated sessions
XCTAssertNotEqual(sessionBackground, sessionMain,
@"We should have seperated sessions, one per thread");
}
- (void)testMainSessionDoesNotChange {
// Get main session
PEPInternalSession *sessionMain = [PEPSessionProvider session];
__block PEPInternalSession *sessionBackground = nil;
XCTestExpectation *exp = [self expectationWithDescription:@"background session created"];
// Get background session
dispatch_queue_t backgroundQueue = dispatch_queue_create("PEPSessionProviderTest.peptest1", 0);
dispatch_async(backgroundQueue, ^{
sessionBackground = [PEPSessionProvider session];
[exp fulfill];
});
[self waitForExpectationsWithTimeout:1.0 handler:^(NSError * _Nullable error) {
if (error) { XCTFail(@"timeout: %@", error); }
}];
// Get main session again
PEPInternalSession *sessionMain2 = [PEPSessionProvider session];
XCTAssertNotNil(sessionMain);
XCTAssertNotNil(sessionMain2);
XCTAssertNotNil(sessionBackground);
XCTAssertEqual(sessionMain, sessionMain2, @"The main session stayed the same (was kept \
alive, was not recreated)");
}
- (void)testNewMainSessionAfterCleanup {
// Get main session
PEPInternalSession *sessionMain = [PEPSessionProvider session];
__block PEPInternalSession *sessionBackground = nil;
XCTestExpectation *exp = [self expectationWithDescription:@"background session created"];
// Get background session
dispatch_queue_t backgroundQueue = dispatch_queue_create("PEPSessionProviderTest.peptest1", 0);
dispatch_async(backgroundQueue, ^{
sessionBackground = [PEPSessionProvider session];
[exp fulfill];
});
[self waitForExpectationsWithTimeout:1.0 handler:^(NSError * _Nullable error) {
if (error) { XCTFail(@"timeout: %@", error); }
}];
// Get main session again
PEPInternalSession *sessionMain2 = [PEPSessionProvider session];
XCTAssertNotNil(sessionMain);
XCTAssertNotNil(sessionMain2);
XCTAssertNotNil(sessionBackground);
XCTAssertEqual(sessionMain, sessionMain2, @"The main session stayed the same (was kept \
alive, was not recreated)");
[PEPSession cleanup];
PEPInternalSession *sessionMainAfterCleanup = [PEPSessionProvider session];
XCTAssertNotNil(sessionMainAfterCleanup);
XCTAssertNotEqual(sessionMainAfterCleanup, sessionMain,
@"We got a new main session after cleanup");
}
@end
Loading…
Cancel
Save