Skip to content

Commit 7398517

Browse files
committed
adfafafafadf
1 parent d1d8e28 commit 7398517

File tree

5 files changed

+95
-3
lines changed

5 files changed

+95
-3
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
- name: Test
4141
env:
4242
scheme: ${{ 'UnitTestApp' }}
43-
test_plan: ${{ 'UnitTestApp_TestPlan_Reduced' }}
43+
test_plan: ${{ 'UnitTestPlan_TestPlan_BadgeOnly' }}
4444
platform: ${{ 'iOS Simulator' }}
4545
file_to_build: ${{ 'iOS_SDK/OneSignalSDK/OneSignal.xcodeproj' }}
4646
filetype_parameter: ${{ 'project' }}

iOS_SDK/OneSignalSDK.xcworkspace/contents.xcworkspacedata

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

+13
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@
151151
<TestPlanReference
152152
reference = "container:UnitTestApp/UnitTestApp_TestPlan_Reduced.xctestplan">
153153
</TestPlanReference>
154+
<TestPlanReference
155+
reference = "container:UnitTestApp/UnitTestPlan_TestPlan_BadgeOnly.xctestplan">
156+
</TestPlanReference>
154157
</TestPlans>
155158
<Testables>
156159
<TestableReference
@@ -213,6 +216,16 @@
213216
ReferencedContainer = "container:OneSignal.xcodeproj">
214217
</BuildableReference>
215218
</TestableReference>
219+
<TestableReference
220+
skipped = "NO">
221+
<BuildableReference
222+
BuildableIdentifier = "primary"
223+
BlueprintIdentifier = "DEBA2A192C20E35E00E234DB"
224+
BuildableName = "OneSignalNotificationsTests.xctest"
225+
BlueprintName = "OneSignalNotificationsTests"
226+
ReferencedContainer = "container:OneSignal.xcodeproj">
227+
</BuildableReference>
228+
</TestableReference>
216229
</Testables>
217230
</TestAction>
218231
<LaunchAction

iOS_SDK/OneSignalSDK/OneSignalNotificationsTests/OneSignalNotificationsTests.swift

+54-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ final class OneSignalNotificationsTests: XCTestCase {
4040
// Put teardown code here. This method is called after the invocation of each test method in the class.
4141
}
4242

43-
func testClearBadgesWhenAppEntersForeground() throws {
43+
func testClearBadgesWhenAppEntersForeground() throws { // Fails when running alone
4444
// NotificationManager Start to register lifecycle listener
4545
OSNotificationsManager.start()
4646
// Set badge count > 0
@@ -53,7 +53,59 @@ final class OneSignalNotificationsTests: XCTestCase {
5353
XCTAssertEqual(UIApplication.shared.applicationIconBadgeNumber, 0)
5454
}
5555

56-
func testDontclearBadgesWhenAppBecomesActive() throws {
56+
func testDontclearBadgesWhenAppBecomesActive() throws { // Unable to make it fail alone
57+
// NotificationManager Start to register lifecycle listener
58+
OSNotificationsManager.start()
59+
// Set badge count > 0
60+
UIApplication.shared.applicationIconBadgeNumber = 1
61+
// Then resign active
62+
OneSignalCoreMocks.resignActive()
63+
// App becomes active the app
64+
OneSignalCoreMocks.becomeActive()
65+
// Ensure that badge count == 1
66+
XCTAssertEqual(UIApplication.shared.applicationIconBadgeNumber, 1)
67+
}
68+
69+
func testClearBadgesWhenAppEntersForeground1() throws {
70+
// NotificationManager Start to register lifecycle listener
71+
OSNotificationsManager.start()
72+
// Set badge count > 0
73+
UIApplication.shared.applicationIconBadgeNumber = 1
74+
// Then background the app
75+
OneSignalCoreMocks.backgroundApp()
76+
// Foreground the app
77+
OneSignalCoreMocks.foregroundApp()
78+
// Ensure that badge count == 0
79+
XCTAssertEqual(UIApplication.shared.applicationIconBadgeNumber, 0)
80+
}
81+
82+
func testDontclearBadgesWhenAppBecomesActive2() throws {
83+
// NotificationManager Start to register lifecycle listener
84+
OSNotificationsManager.start()
85+
// Set badge count > 0
86+
UIApplication.shared.applicationIconBadgeNumber = 1
87+
// Then resign active
88+
OneSignalCoreMocks.resignActive()
89+
// App becomes active the app
90+
OneSignalCoreMocks.becomeActive()
91+
// Ensure that badge count == 1
92+
XCTAssertEqual(UIApplication.shared.applicationIconBadgeNumber, 1)
93+
}
94+
95+
func testClearBadgesWhenAppEntersForeground3() throws {
96+
// NotificationManager Start to register lifecycle listener
97+
OSNotificationsManager.start()
98+
// Set badge count > 0
99+
UIApplication.shared.applicationIconBadgeNumber = 1
100+
// Then background the app
101+
OneSignalCoreMocks.backgroundApp()
102+
// Foreground the app
103+
OneSignalCoreMocks.foregroundApp()
104+
// Ensure that badge count == 0
105+
XCTAssertEqual(UIApplication.shared.applicationIconBadgeNumber, 0)
106+
}
107+
108+
func testDontclearBadgesWhenAppBecomesActive4() throws {
57109
// NotificationManager Start to register lifecycle listener
58110
OSNotificationsManager.start()
59111
// Set badge count > 0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"configurations" : [
3+
{
4+
"id" : "0F56CD0B-5904-415C-B328-24EE0394B75B",
5+
"name" : "Configuration 1",
6+
"options" : {
7+
8+
}
9+
}
10+
],
11+
"defaultOptions" : {
12+
"testTimeoutsEnabled" : true
13+
},
14+
"testTargets" : [
15+
{
16+
"target" : {
17+
"containerPath" : "container:OneSignal.xcodeproj",
18+
"identifier" : "DEBA2A192C20E35E00E234DB",
19+
"name" : "OneSignalNotificationsTests"
20+
}
21+
}
22+
],
23+
"version" : 1
24+
}

0 commit comments

Comments
 (0)