Skip to content

Commit e5287f5

Browse files
Remove all remaining iOS 9 support from tests.
1 parent 02548a6 commit e5287f5

File tree

4 files changed

+7
-90
lines changed

4 files changed

+7
-90
lines changed

tests/common/CommonMocks.swift

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ class MockDateProvider: DateProviderProtocol {
1616
}
1717
}
1818

19-
@available(iOS 10.0, *)
2019
struct MockNotificationResponse: NotificationResponseProtocol {
2120
let userInfo: [AnyHashable: Any]
2221
let actionIdentifier: String
@@ -81,8 +80,7 @@ public class MockCustomActionDelegate: NSObject, IterableCustomActionDelegate {
8180

8281
@objcMembers
8382
public class MockUrlOpener: NSObject, UrlOpenerProtocol {
84-
var ios10OpenedUrl: URL?
85-
var preIos10openedUrl: URL?
83+
var openedUrl: URL?
8684
var callback: ((URL) -> Void)?
8785

8886
public init(callback: ((URL) -> Void)? = nil) {
@@ -91,11 +89,7 @@ public class MockUrlOpener: NSObject, UrlOpenerProtocol {
9189

9290
public func open(url: URL) {
9391
callback?(url)
94-
if #available(iOS 10.0, *) {
95-
ios10OpenedUrl = url
96-
} else {
97-
preIos10openedUrl = url
98-
}
92+
openedUrl = url
9993
}
10094
}
10195

tests/hosting-apps/ui-tests-app/ViewController.swift

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,12 @@ class ViewController: UIViewController {
1919

2020
@IBAction func setupNotifications(_: UIButton) {
2121
ITBInfo()
22-
if #available(iOS 10, *) {
23-
setupNotifications()
24-
}
22+
setupNotifications()
2523
}
2624

2725
@IBAction func sendNotification(_: UIButton) {
2826
ITBInfo()
29-
if #available(iOS 10, *) {
30-
setupAndSendNotification()
31-
}
27+
setupAndSendNotification()
3228
}
3329

3430
@IBAction func showInAppTap(_: UIButton) {
@@ -211,7 +207,6 @@ class ViewController: UIViewController {
211207
}
212208
}
213209

214-
@available(iOS 10.0, *)
215210
private func setupNotifications(onCompletion: (() -> Void)? = nil) {
216211
UNUserNotificationCenter.current().delegate = self
217212
UNUserNotificationCenter.current().getNotificationSettings { settings in
@@ -234,23 +229,20 @@ class ViewController: UIViewController {
234229
}
235230
}
236231

237-
@available(iOS 10.0, *)
238232
private func setupAndSendNotification() {
239233
setupNotifications {
240234
self.registerCategories()
241235
self.sendNotification()
242236
}
243237
}
244238

245-
@available(iOS 10.0, *)
246239
private func removeAllNotifications() {
247240
ITBInfo()
248241
let center = UNUserNotificationCenter.current()
249242
center.removeAllPendingNotificationRequests()
250243
center.removeAllDeliveredNotifications()
251244
}
252245

253-
@available(iOS 10.0, *)
254246
private func sendNotification() {
255247
ITBInfo()
256248

@@ -308,7 +300,6 @@ class ViewController: UIViewController {
308300
UNUserNotificationCenter.current().add(request)
309301
}
310302

311-
@available(iOS 10.0, *)
312303
private func registerCategories() {
313304
ITBInfo()
314305
let tapButton1Action = UNNotificationAction(identifier: "Open Safari", title: "Open Safari", options: .foreground)
@@ -341,7 +332,6 @@ class ViewController: UIViewController {
341332
}
342333
}
343334

344-
@available(iOS 10.0, *)
345335
extension ViewController: UNUserNotificationCenterDelegate {
346336
public func userNotificationCenter(_: UNUserNotificationCenter, willPresent _: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
347337
completionHandler([.alert, .badge, .sound])

tests/unit-tests/IterableActionRunnerTests.swift

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,7 @@ class IterableActionRunnerTests: XCTestCase {
3636
wait(for: [expectation], timeout: testExpectationTimeout)
3737
XCTAssertTrue(handled)
3838

39-
if #available(iOS 10.0, *) {
40-
XCTAssertNil(urlOpener.ios10OpenedUrl)
41-
XCTAssertNil(urlOpener.preIos10openedUrl)
42-
} else {
43-
XCTAssertNil(urlOpener.ios10OpenedUrl)
44-
XCTAssertNil(urlOpener.preIos10openedUrl)
45-
}
39+
XCTAssertNil(urlOpener.openedUrl)
4640
}
4741

4842
func testCustomAction() {
@@ -169,12 +163,6 @@ class IterableActionRunnerTests: XCTestCase {
169163
wait(for: [expectation], timeout: testExpectationTimeout)
170164
XCTAssertTrue(handled)
171165

172-
if #available(iOS 10.0, *) {
173-
XCTAssertEqual(urlOpener.ios10OpenedUrl?.absoluteString, urlString)
174-
XCTAssertNil(urlOpener.preIos10openedUrl)
175-
} else {
176-
XCTAssertEqual(urlOpener.preIos10openedUrl?.absoluteString, urlString)
177-
XCTAssertNil(urlOpener.ios10OpenedUrl)
178-
}
166+
XCTAssertEqual(urlOpener.openedUrl?.absoluteString, urlString)
179167
}
180168
}

tests/unit-tests/IterableNotificationResponseTests.swift

Lines changed: 1 addition & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ class IterableNotificationResponseTests: XCTestCase {
1313
}
1414

1515
func testTrackOpenPushWithCustomAction() {
16-
guard #available(iOS 10.0, *) else {
17-
return
18-
}
19-
2016
// we test with both 'true' and 'false' values below
2117
// to make sure that it doesn't influence the result
2218
// the return value is reserved for future use.
@@ -25,10 +21,6 @@ class IterableNotificationResponseTests: XCTestCase {
2521
}
2622

2723
private func testTrackOpenPushWithCustomAction(returnValue: Bool) {
28-
guard #available(iOS 10.0, *) else {
29-
return
30-
}
31-
3224
let messageId = UUID().uuidString
3325
let userInfo: [AnyHashable: Any] = [
3426
"itbl": [
@@ -68,10 +60,6 @@ class IterableNotificationResponseTests: XCTestCase {
6860
}
6961

7062
func testActionButtonDismiss() {
71-
guard #available(iOS 10.0, *) else {
72-
return
73-
}
74-
7563
let messageId = UUID().uuidString
7664
let userInfo = [
7765
"itbl": [
@@ -114,45 +102,6 @@ class IterableNotificationResponseTests: XCTestCase {
114102
XCTAssertEqual(pushTracker.dataFields?[JsonKey.actionIdentifier] as? String, "buttonIdentifier")
115103
}
116104

117-
func testForegroundPushActionBeforeiOS10() {
118-
if #available(iOS 10, *) {
119-
} else {
120-
let messageId = UUID().uuidString
121-
let userInfo = [
122-
"itbl": [
123-
"campaignId": 1234,
124-
"templateId": 4321,
125-
"isGhostPush": false,
126-
"messageId": messageId,
127-
"defaultAction": [
128-
"type": "customAction",
129-
],
130-
],
131-
]
132-
133-
let pushTracker = MockPushTracker()
134-
let expection = XCTestExpectation(description: "customActionDelegate is called")
135-
let customActionDelegate = MockCustomActionDelegate(returnValue: true)
136-
customActionDelegate.callback = { customActionName, _ in
137-
XCTAssertEqual(customActionName, "customAction")
138-
expection.fulfill()
139-
}
140-
141-
let appIntegration = IterableAppIntegrationInternal(tracker: pushTracker,
142-
customActionDelegate: customActionDelegate,
143-
urlOpener: MockUrlOpener(),
144-
inAppNotifiable: EmptyInAppManager())
145-
appIntegration.application(MockApplicationStateProvider(applicationState: .inactive), didReceiveRemoteNotification: userInfo, fetchCompletionHandler: nil)
146-
147-
wait(for: [expection], timeout: testExpectationTimeout)
148-
149-
XCTAssertEqual(pushTracker.campaignId, 1234)
150-
XCTAssertEqual(pushTracker.templateId, 4321)
151-
XCTAssertEqual(pushTracker.messageId, messageId)
152-
XCTAssertFalse(pushTracker.appAlreadyRunnnig)
153-
}
154-
}
155-
156105
func testSavePushPayload() {
157106
let messageId = UUID().uuidString
158107
let userInfo: [AnyHashable: Any] = [
@@ -227,10 +176,6 @@ class IterableNotificationResponseTests: XCTestCase {
227176
}
228177

229178
func testLegacyDeepLinkPayload() {
230-
guard #available(iOS 10.0, *) else {
231-
return
232-
}
233-
234179
let messageId = UUID().uuidString
235180
let userInfo: [AnyHashable: Any] = [
236181
"itbl": [
@@ -254,6 +199,6 @@ class IterableNotificationResponseTests: XCTestCase {
254199
XCTAssertEqual(pushTracker.templateId, 4321)
255200
XCTAssertEqual(pushTracker.messageId, messageId)
256201

257-
XCTAssertEqual(urlOpener.ios10OpenedUrl?.absoluteString, "https://example.com")
202+
XCTAssertEqual(urlOpener.openedUrl?.absoluteString, "https://example.com")
258203
}
259204
}

0 commit comments

Comments
 (0)