diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e8163d6c2..b169cbc25 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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' }} diff --git a/iOS_SDK/OneSignalDevApp/OneSignalDevApp/AppDelegate.m b/iOS_SDK/OneSignalDevApp/OneSignalDevApp/AppDelegate.m index d3061a94a..de420b5aa 100644 --- a/iOS_SDK/OneSignalDevApp/OneSignalDevApp/AppDelegate.m +++ b/iOS_SDK/OneSignalDevApp/OneSignalDevApp/AppDelegate.m @@ -50,7 +50,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( // [FIRApp configure]; - NSLog(@"Bundle URL: %@", [[NSBundle mainBundle] bundleURL]); + NSLog(@" Bundle URL: %@", [[NSBundle mainBundle] bundleURL]); [OneSignal.Debug setLogLevel:ONE_S_LL_VERBOSE]; [OneSignal.Debug setAlertLevel:ONE_S_LL_NONE]; diff --git a/iOS_SDK/OneSignalSDK.xcworkspace/contents.xcworkspacedata b/iOS_SDK/OneSignalSDK.xcworkspace/contents.xcworkspacedata index 9979cb733..bb378804e 100644 --- a/iOS_SDK/OneSignalSDK.xcworkspace/contents.xcworkspacedata +++ b/iOS_SDK/OneSignalSDK.xcworkspace/contents.xcworkspacedata @@ -1,6 +1,9 @@ + + diff --git a/iOS_SDK/OneSignalSDK/OneSignal.xcodeproj/xcshareddata/xcschemes/UnitTestApp.xcscheme b/iOS_SDK/OneSignalSDK/OneSignal.xcodeproj/xcshareddata/xcschemes/UnitTestApp.xcscheme index 78545068d..bf007ec61 100644 --- a/iOS_SDK/OneSignalSDK/OneSignal.xcodeproj/xcshareddata/xcschemes/UnitTestApp.xcscheme +++ b/iOS_SDK/OneSignalSDK/OneSignal.xcodeproj/xcshareddata/xcschemes/UnitTestApp.xcscheme @@ -151,6 +151,9 @@ + + + + + + 0 + print("💛 testClearBadgesWhenAppEntersForeground setting applicationIconBadgeNumber = 1") UIApplication.shared.applicationIconBadgeNumber = 1 + print("🥑 applicationIconBadgeNumber is \(UIApplication.shared.applicationIconBadgeNumber)") + // Then background the app OneSignalCoreMocks.backgroundApp() // Foreground the app OneSignalCoreMocks.foregroundApp() // Ensure that badge count == 0 + print("🥑 applicationIconBadgeNumber now is \(UIApplication.shared.applicationIconBadgeNumber)") + 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 + print("💛 testDontclearBadgesWhenAppBecomesActive setting applicationIconBadgeNumber = 1") UIApplication.shared.applicationIconBadgeNumber = 1 + print("🥑 applicationIconBadgeNumber is \(UIApplication.shared.applicationIconBadgeNumber)") + // Then resign active OneSignalCoreMocks.resignActive() // App becomes active the app OneSignalCoreMocks.becomeActive() // Ensure that badge count == 1 + print("🥑 applicationIconBadgeNumber now is \(UIApplication.shared.applicationIconBadgeNumber)") + 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 +// 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 testUpdateNotificationTypesOnAppEntersForeground() throws { // NotificationManager Start to register lifecycle listener diff --git a/iOS_SDK/OneSignalSDK/UnitTestApp/UnitTestPlan_TestPlan_BadgeOnly.xctestplan b/iOS_SDK/OneSignalSDK/UnitTestApp/UnitTestPlan_TestPlan_BadgeOnly.xctestplan new file mode 100644 index 000000000..209ee99ae --- /dev/null +++ b/iOS_SDK/OneSignalSDK/UnitTestApp/UnitTestPlan_TestPlan_BadgeOnly.xctestplan @@ -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 +}