Skip to content

Commit

Permalink
adfafafafadf
Browse files Browse the repository at this point in the history
  • Loading branch information
nan-li committed Oct 30, 2024
1 parent d1d8e28 commit 7398517
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- name: Test
env:
scheme: ${{ 'UnitTestApp' }}
test_plan: ${{ 'UnitTestApp_TestPlan_Reduced' }}
test_plan: ${{ 'UnitTestPlan_TestPlan_BadgeOnly' }}
platform: ${{ 'iOS Simulator' }}
file_to_build: ${{ 'iOS_SDK/OneSignalSDK/OneSignal.xcodeproj' }}
filetype_parameter: ${{ 'project' }}
Expand Down
3 changes: 3 additions & 0 deletions iOS_SDK/OneSignalSDK.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@
<TestPlanReference
reference = "container:UnitTestApp/UnitTestApp_TestPlan_Reduced.xctestplan">
</TestPlanReference>
<TestPlanReference
reference = "container:UnitTestApp/UnitTestPlan_TestPlan_BadgeOnly.xctestplan">
</TestPlanReference>
</TestPlans>
<Testables>
<TestableReference
Expand Down Expand Up @@ -213,6 +216,16 @@
ReferencedContainer = "container:OneSignal.xcodeproj">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "DEBA2A192C20E35E00E234DB"
BuildableName = "OneSignalNotificationsTests.xctest"
BlueprintName = "OneSignalNotificationsTests"
ReferencedContainer = "container:OneSignal.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ final class OneSignalNotificationsTests: XCTestCase {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}

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

func testDontclearBadgesWhenAppBecomesActive() throws {
func testDontclearBadgesWhenAppBecomesActive() throws { // Unable to make it fail alone
// NotificationManager Start to register lifecycle listener
OSNotificationsManager.start()
// Set badge count > 0
UIApplication.shared.applicationIconBadgeNumber = 1
// Then resign active
OneSignalCoreMocks.resignActive()
// App becomes active the app
OneSignalCoreMocks.becomeActive()
// Ensure that badge count == 1
XCTAssertEqual(UIApplication.shared.applicationIconBadgeNumber, 1)
}

func testClearBadgesWhenAppEntersForeground1() throws {
// NotificationManager Start to register lifecycle listener
OSNotificationsManager.start()
// Set badge count > 0
UIApplication.shared.applicationIconBadgeNumber = 1
// Then background the app
OneSignalCoreMocks.backgroundApp()
// Foreground the app
OneSignalCoreMocks.foregroundApp()
// Ensure that badge count == 0
XCTAssertEqual(UIApplication.shared.applicationIconBadgeNumber, 0)
}

func testDontclearBadgesWhenAppBecomesActive2() throws {
// NotificationManager Start to register lifecycle listener
OSNotificationsManager.start()
// Set badge count > 0
UIApplication.shared.applicationIconBadgeNumber = 1
// Then resign active
OneSignalCoreMocks.resignActive()
// App becomes active the app
OneSignalCoreMocks.becomeActive()
// Ensure that badge count == 1
XCTAssertEqual(UIApplication.shared.applicationIconBadgeNumber, 1)
}

func testClearBadgesWhenAppEntersForeground3() throws {
// NotificationManager Start to register lifecycle listener
OSNotificationsManager.start()
// Set badge count > 0
UIApplication.shared.applicationIconBadgeNumber = 1
// Then background the app
OneSignalCoreMocks.backgroundApp()
// Foreground the app
OneSignalCoreMocks.foregroundApp()
// Ensure that badge count == 0
XCTAssertEqual(UIApplication.shared.applicationIconBadgeNumber, 0)
}

func testDontclearBadgesWhenAppBecomesActive4() throws {
// NotificationManager Start to register lifecycle listener
OSNotificationsManager.start()
// Set badge count > 0
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"configurations" : [
{
"id" : "0F56CD0B-5904-415C-B328-24EE0394B75B",
"name" : "Configuration 1",
"options" : {

}
}
],
"defaultOptions" : {
"testTimeoutsEnabled" : true
},
"testTargets" : [
{
"target" : {
"containerPath" : "container:OneSignal.xcodeproj",
"identifier" : "DEBA2A192C20E35E00E234DB",
"name" : "OneSignalNotificationsTests"
}
}
],
"version" : 1
}

0 comments on commit 7398517

Please sign in to comment.