Skip to content

Commit 782ae72

Browse files
authored
Merge pull request #1371 from OneSignal/5.x.x/unit_tests_infra
[unit tests] Add some infrastructure for `OneSignalCore` and `OneSignalUser`
2 parents 8f47b6f + 194832e commit 782ae72

36 files changed

+2006
-720
lines changed

iOS_SDK/OneSignalSDK/OneSignal.xcodeproj/project.pbxproj

Lines changed: 1269 additions & 57 deletions
Large diffs are not rendered by default.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1520"
4+
version = "1.7">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
</BuildAction>
9+
<TestAction
10+
buildConfiguration = "Debug"
11+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
12+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
13+
shouldUseLaunchSchemeArgsEnv = "YES"
14+
shouldAutocreateTestPlan = "YES">
15+
<Testables>
16+
<TestableReference
17+
skipped = "NO"
18+
parallelizable = "YES">
19+
<BuildableReference
20+
BuildableIdentifier = "primary"
21+
BlueprintIdentifier = "3CC063A02B6D7A8D002BB07F"
22+
BuildableName = "OneSignalCoreTests.xctest"
23+
BlueprintName = "OneSignalCoreTests"
24+
ReferencedContainer = "container:OneSignal.xcodeproj">
25+
</BuildableReference>
26+
</TestableReference>
27+
</Testables>
28+
</TestAction>
29+
<LaunchAction
30+
buildConfiguration = "Debug"
31+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
32+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
33+
launchStyle = "0"
34+
useCustomWorkingDirectory = "NO"
35+
ignoresPersistentStateOnLaunch = "NO"
36+
debugDocumentVersioning = "YES"
37+
debugServiceExtension = "internal"
38+
allowLocationSimulation = "YES">
39+
</LaunchAction>
40+
<ProfileAction
41+
buildConfiguration = "Release"
42+
shouldUseLaunchSchemeArgsEnv = "YES"
43+
savedToolIdentifier = ""
44+
useCustomWorkingDirectory = "NO"
45+
debugDocumentVersioning = "YES">
46+
</ProfileAction>
47+
<AnalyzeAction
48+
buildConfiguration = "Debug">
49+
</AnalyzeAction>
50+
<ArchiveAction
51+
buildConfiguration = "Release"
52+
revealArchiveInOrganizer = "YES">
53+
</ArchiveAction>
54+
</Scheme>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1520"
4+
version = "1.7">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
</BuildAction>
9+
<TestAction
10+
buildConfiguration = "Debug"
11+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
12+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
13+
shouldUseLaunchSchemeArgsEnv = "YES"
14+
shouldAutocreateTestPlan = "YES">
15+
<Testables>
16+
<TestableReference
17+
skipped = "NO"
18+
parallelizable = "YES">
19+
<BuildableReference
20+
BuildableIdentifier = "primary"
21+
BlueprintIdentifier = "3CC063EA2B6D7FE8002BB07F"
22+
BuildableName = "OneSignalUserTests.xctest"
23+
BlueprintName = "OneSignalUserTests"
24+
ReferencedContainer = "container:OneSignal.xcodeproj">
25+
</BuildableReference>
26+
</TestableReference>
27+
</Testables>
28+
</TestAction>
29+
<LaunchAction
30+
buildConfiguration = "Debug"
31+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
32+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
33+
launchStyle = "0"
34+
useCustomWorkingDirectory = "NO"
35+
ignoresPersistentStateOnLaunch = "NO"
36+
debugDocumentVersioning = "YES"
37+
debugServiceExtension = "internal"
38+
allowLocationSimulation = "YES">
39+
</LaunchAction>
40+
<ProfileAction
41+
buildConfiguration = "Release"
42+
shouldUseLaunchSchemeArgsEnv = "YES"
43+
savedToolIdentifier = ""
44+
useCustomWorkingDirectory = "NO"
45+
debugDocumentVersioning = "YES">
46+
</ProfileAction>
47+
<AnalyzeAction
48+
buildConfiguration = "Debug">
49+
</AnalyzeAction>
50+
<ArchiveAction
51+
buildConfiguration = "Release"
52+
revealArchiveInOrganizer = "YES">
53+
</ArchiveAction>
54+
</Scheme>

iOS_SDK/OneSignalSDK/OneSignal.xcodeproj/xcshareddata/xcschemes/UnitTestApp.xcscheme

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,34 @@
2020
ReferencedContainer = "container:OneSignal.xcodeproj">
2121
</BuildableReference>
2222
</BuildActionEntry>
23+
<BuildActionEntry
24+
buildForTesting = "YES"
25+
buildForRunning = "NO"
26+
buildForProfiling = "NO"
27+
buildForArchiving = "NO"
28+
buildForAnalyzing = "NO">
29+
<BuildableReference
30+
BuildableIdentifier = "primary"
31+
BlueprintIdentifier = "3CC063EA2B6D7FE8002BB07F"
32+
BuildableName = "OneSignalUserTests.xctest"
33+
BlueprintName = "OneSignalUserTests"
34+
ReferencedContainer = "container:OneSignal.xcodeproj">
35+
</BuildableReference>
36+
</BuildActionEntry>
37+
<BuildActionEntry
38+
buildForTesting = "YES"
39+
buildForRunning = "NO"
40+
buildForProfiling = "NO"
41+
buildForArchiving = "NO"
42+
buildForAnalyzing = "NO">
43+
<BuildableReference
44+
BuildableIdentifier = "primary"
45+
BlueprintIdentifier = "3CC063A02B6D7A8D002BB07F"
46+
BuildableName = "OneSignalCoreTests.xctest"
47+
BlueprintName = "OneSignalCoreTests"
48+
ReferencedContainer = "container:OneSignal.xcodeproj">
49+
</BuildableReference>
50+
</BuildActionEntry>
2351
</BuildActionEntries>
2452
</BuildAction>
2553
<TestAction
@@ -79,6 +107,20 @@
79107
BlueprintName = "OneSignalUser"
80108
ReferencedContainer = "container:OneSignal.xcodeproj">
81109
</BuildableReference>
110+
<BuildableReference
111+
BuildableIdentifier = "primary"
112+
BlueprintIdentifier = "3CC063EA2B6D7FE8002BB07F"
113+
BuildableName = "OneSignalUserTests.xctest"
114+
BlueprintName = "OneSignalUserTests"
115+
ReferencedContainer = "container:OneSignal.xcodeproj">
116+
</BuildableReference>
117+
<BuildableReference
118+
BuildableIdentifier = "primary"
119+
BlueprintIdentifier = "3CC063A02B6D7A8D002BB07F"
120+
BuildableName = "OneSignalCoreTests.xctest"
121+
BlueprintName = "OneSignalCoreTests"
122+
ReferencedContainer = "container:OneSignal.xcodeproj">
123+
</BuildableReference>
82124
</CodeCoverageTargets>
83125
<Testables>
84126
<TestableReference
@@ -91,6 +133,26 @@
91133
ReferencedContainer = "container:OneSignal.xcodeproj">
92134
</BuildableReference>
93135
</TestableReference>
136+
<TestableReference
137+
skipped = "NO">
138+
<BuildableReference
139+
BuildableIdentifier = "primary"
140+
BlueprintIdentifier = "3CC063A02B6D7A8D002BB07F"
141+
BuildableName = "OneSignalCoreTests.xctest"
142+
BlueprintName = "OneSignalCoreTests"
143+
ReferencedContainer = "container:OneSignal.xcodeproj">
144+
</BuildableReference>
145+
</TestableReference>
146+
<TestableReference
147+
skipped = "NO">
148+
<BuildableReference
149+
BuildableIdentifier = "primary"
150+
BlueprintIdentifier = "3CC063EA2B6D7FE8002BB07F"
151+
BuildableName = "OneSignalUserTests.xctest"
152+
BlueprintName = "OneSignalUserTests"
153+
ReferencedContainer = "container:OneSignal.xcodeproj">
154+
</BuildableReference>
155+
</TestableReference>
94156
</Testables>
95157
</TestAction>
96158
<LaunchAction

iOS_SDK/OneSignalSDK/OneSignalCore/Source/API/OneSignalClient.h

Lines changed: 4 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -31,52 +31,12 @@
3131
#ifndef OneSignalClient_h
3232
#define OneSignalClient_h
3333

34-
typedef void (^OSDataRequestSuccessBlock)(NSData *data);
35-
36-
typedef void (^OSMultipleCompletionBlock)(NSDictionary *responses);
37-
typedef void (^OSMultipleFailureBlock)(NSDictionary<NSString *, NSError *> *errors);
38-
typedef void (^OSMultipleSuccessBlock)(NSDictionary<NSString *, NSDictionary *> *results);
39-
40-
@interface OneSignalClient : NSObject
41-
+ (OneSignalClient *)sharedClient;
34+
@protocol IOneSignalClient <NSObject>
4235
- (void)executeRequest:(OneSignalRequest *)request onSuccess:(OSResultSuccessBlock)successBlock onFailure:(OSFailureBlock)failureBlock;
43-
- (void)executeSynchronousRequest:(OneSignalRequest *)request onSuccess:(OSResultSuccessBlock)successBlock onFailure:(OSFailureBlock)failureBlock;
44-
45-
// ie. for loading HTML or other non-JSON based requests
46-
- (void)executeDataRequest:(OneSignalRequest *)request onSuccess:(OSDataRequestSuccessBlock)successBlock onFailure:(OSFailureBlock)failureBlock;
47-
48-
// Executes multiple OneSignalRequest's simultaneously, needs a unique identifier for each request
49-
- (void)executeSimultaneousRequests:(NSDictionary<NSString *, OneSignalRequest *> *)requests withSuccess:(OSMultipleSuccessBlock)successBlock onFailure:(OSMultipleFailureBlock)failureBlock;
50-
51-
/*
52-
TODO: We want to eventually migrate over to using this method for executing simultaneous requests:
53-
This allows us to combine multiple async concurrent requests to return from a single callback with the proper formatted responses from each reuqest (successful or not, account for params returning from GETs).
54-
A generalized format should be followed and we should make sure not to break form that as it could break peoples apps in the future if we add params and remove params from this callback.
55-
Currently for the only implementation this is used for "setExternalUserId:withCOmpletion:" the format is as follows:
56-
57-
NSDictionary response = @{
58-
(required) @"push" : {
59-
@"success" : @(true) or @(false)
60-
},
61-
62-
(optional) @"email" : {
63-
@"success" : @(true) or @(false)
64-
}
65-
}
36+
@end
6637

67-
68-
Building off of this format now will require:
69-
70-
1. Including other attributes and whether they are required or not
71-
ex. @"push" is always going to be within the callback resposne (required), meanwhile,
72-
@"email" will not always exist in the callback resposne (optoinal)
73-
74-
2. Can't remove params that are required as an app may be expecting them and removing/modifying a key could break there app with an SDK upgrade
75-
76-
3. Add more requirements...
77-
78-
*/
79-
- (void)executeSimultaneousRequests:(NSDictionary<NSString *, OneSignalRequest *> *)requests withCompletion:(OSMultipleCompletionBlock)completionBlock;
38+
@interface OneSignalClient : NSObject <IOneSignalClient>
39+
+ (OneSignalClient *)sharedClient;
8040
@end
8141

8242
#endif

0 commit comments

Comments
 (0)