Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wip] ci #1505

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion iOS_SDK/OneSignalDevApp/OneSignalDevApp/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];

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 @@ -260,8 +260,10 @@ + (void)start {
+ (void)registerLifecycleObserver {
// Replacing swizzled lifecycle selectors with notification center observers for scene based Apps
if ([OSBundleUtils isAppUsingUIScene]) {
NSLog(@"💛 registerLifecycleObserverAs UIScene ");
[self registerLifecycleObserverAsUIScene];
} else {
NSLog(@"💛 registerLifecycleObserverAs UIApplication ");
[self registerLifecycleObserverAsUIApplication];
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ final class OneSignalNotificationsTests: XCTestCase {
var token: String = ""

override func setUpWithError() throws {
// Temp. logging to help debug during testing
OneSignalLog.setLogLevel(.LL_VERBOSE)
// Put setup code here. This method is called before the invocation of each test method in the class.
self.notifTypes = 0
self.token = ""
Expand All @@ -40,10 +42,11 @@ 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
print("💛 testClearBadgesWhenAppEntersForeground setting applicationIconBadgeNumber")
UIApplication.shared.applicationIconBadgeNumber = 1
// Then background the app
OneSignalCoreMocks.backgroundApp()
Expand All @@ -53,10 +56,11 @@ 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
print("💛 testDontclearBadgesWhenAppBecomesActive setting applicationIconBadgeNumber")
UIApplication.shared.applicationIconBadgeNumber = 1
// Then resign active
OneSignalCoreMocks.resignActive()
Expand All @@ -65,6 +69,58 @@ final class OneSignalNotificationsTests: XCTestCase {
// 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
// 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
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
}
Loading