Skip to content

Commit 71ebb06

Browse files
Merge pull request #26 from Iterable/ITBL-5966-codecov
[ITBL-5966] - More codecov
2 parents 023d1a9 + d5a60b7 commit 71ebb06

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+700
-104
lines changed

.travis.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
osx_image: xcode9.4
1+
osx_image: xcode10
22
language: swift
33

44
before_install:
55
- gem install xcpretty xcpretty-travis-formatter
66

77
script:
8-
- xcodebuild test -workspace swift-sdk.xcworkspace -scheme notification-extension -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone X' -enableCodeCoverage YES CODE_SIGNING_REQUIRED=NO GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES GCC_GENERATE_TEST_COVERAGE_FILES=YES | xcpretty -f `xcpretty-travis-formatter`
8+
- xcodebuild test -workspace swift-sdk.xcworkspace -scheme notification-extension-tests -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone X' -enableCodeCoverage YES CODE_SIGNING_REQUIRED=NO GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES GCC_GENERATE_TEST_COVERAGE_FILES=YES | xcpretty -f `xcpretty-travis-formatter`
99
- bash <(curl -s https://codecov.io/bash)
10-
- xcodebuild test -workspace swift-sdk.xcworkspace -scheme swift-sdk -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone X' -enableCodeCoverage YES CODE_SIGNING_REQUIRED=NO GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES GCC_GENERATE_TEST_COVERAGE_FILES=YES | xcpretty -f `xcpretty-travis-formatter`
10+
- xcodebuild test -workspace swift-sdk.xcworkspace -scheme iterable-sdk-tests -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone X' -enableCodeCoverage YES CODE_SIGNING_REQUIRED=NO GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES GCC_GENERATE_TEST_COVERAGE_FILES=YES | xcpretty -f `xcpretty-travis-formatter`
1111
- bash <(curl -s https://codecov.io/bash)
12-
- xcodebuild test -workspace swift-sdk.xcworkspace -scheme swift-sdk -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6s,OS=9.0' -enableCodeCoverage YES CODE_SIGNING_REQUIRED=NO GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES GCC_GENERATE_TEST_COVERAGE_FILES=YES | xcpretty -f `xcpretty-travis-formatter`
12+
- xcodebuild test -workspace swift-sdk.xcworkspace -scheme iterable-sdk-tests -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6s,OS=9.0' -enableCodeCoverage YES CODE_SIGNING_REQUIRED=NO GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES GCC_GENERATE_TEST_COVERAGE_FILES=YES | xcpretty -f `xcpretty-travis-formatter`
13+
- bash <(curl -s https://codecov.io/bash)
14+
- xcodebuild test -workspace swift-sdk.xcworkspace -scheme ui-tests -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone X' -enableCodeCoverage YES CODE_SIGNING_REQUIRED=NO GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES GCC_GENERATE_TEST_COVERAGE_FILES=YES | xcpretty -f `xcpretty-travis-formatter`
1315
- bash <(curl -s https://codecov.io/bash)
1416
- pod lib lint
1517

Tests/swift-sdk-swift-tests/IterableInAppNotificationTests.swift

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,4 +155,88 @@ class IterableInAppNotificationTests: XCTestCase {
155155
XCTAssertTrue(shownFirstTime)
156156
XCTAssertFalse(shownSecondTime)
157157
}
158+
159+
func testGetBackgroundAlpha() {
160+
XCTAssert(IterableInAppManager.getBackgroundAlpha(fromInAppSettings: nil) == 0)
161+
XCTAssert(IterableInAppManager.getBackgroundAlpha(fromInAppSettings: ["backgroundAlpha" : "x"]) == 0)
162+
XCTAssert(IterableInAppManager.getBackgroundAlpha(fromInAppSettings: ["backgroundAlpha" : 0.5]) == 0.5)
163+
XCTAssert(IterableInAppManager.getBackgroundAlpha(fromInAppSettings: ["backgroundAlpha" : 1]) == 1.0)
164+
}
165+
166+
func testTrackInAppClickWithButtonUrl() {
167+
let messageId = "message1"
168+
let buttonUrl = "http://somewhere.com"
169+
let expectation1 = expectation(description: "track in app click")
170+
171+
let networkSession = MockNetworkSession(statusCode: 200)
172+
IterableAPI.initialize(apiKey: IterableInAppNotificationTests.apiKey, networkSession: networkSession)
173+
IterableAPI.userId = IterableInAppNotificationTests.userId
174+
networkSession.callback = {(_, _, _) in
175+
TestUtils.validate(request: networkSession.request!,
176+
requestType: .post,
177+
apiEndPoint: .ITBL_ENDPOINT_API,
178+
path: .ITBL_PATH_TRACK_INAPP_CLICK,
179+
queryParams: [(name: AnyHashable.ITBL_KEY_API_KEY, value: IterableInAppNotificationTests.apiKey),
180+
])
181+
let body = networkSession.getRequestBody() as! [String : Any]
182+
TestUtils.validateMatch(keyPath: KeyPath("messageId"), value: messageId, inDictionary: body)
183+
TestUtils.validateMatch(keyPath: KeyPath("urlClick"), value: buttonUrl, inDictionary: body)
184+
TestUtils.validateMatch(keyPath: KeyPath("userId"), value: IterableInAppNotificationTests.userId, inDictionary: body)
185+
expectation1.fulfill()
186+
}
187+
IterableAPI.track(inAppClick: messageId, buttonURL: buttonUrl)
188+
wait(for: [expectation1], timeout: testExpectationTimeout)
189+
}
190+
191+
func testTrackInAppClickWithButtonIndex() {
192+
let messageId = "message1"
193+
let buttonIndex = "1"
194+
let expectation1 = expectation(description: "track in app click")
195+
196+
let networkSession = MockNetworkSession(statusCode: 200)
197+
IterableAPI.initialize(apiKey: IterableInAppNotificationTests.apiKey, networkSession: networkSession)
198+
IterableAPI.email = IterableInAppNotificationTests.email
199+
networkSession.callback = {(_, _, _) in
200+
TestUtils.validate(request: networkSession.request!,
201+
requestType: .post,
202+
apiEndPoint: .ITBL_ENDPOINT_API,
203+
path: .ITBL_PATH_TRACK_INAPP_CLICK,
204+
queryParams: [(name: AnyHashable.ITBL_KEY_API_KEY, value: IterableInAppNotificationTests.apiKey),
205+
])
206+
let body = networkSession.getRequestBody() as! [String : Any]
207+
TestUtils.validateMatch(keyPath: KeyPath("messageId"), value: messageId, inDictionary: body)
208+
TestUtils.validateMatch(keyPath: KeyPath("buttonIndex"), value: buttonIndex, inDictionary: body)
209+
TestUtils.validateMatch(keyPath: KeyPath("email"), value: IterableInAppNotificationTests.email, inDictionary: body)
210+
expectation1.fulfill()
211+
}
212+
IterableAPI.track(inAppClick: messageId, buttonIndex: buttonIndex)
213+
wait(for: [expectation1], timeout: testExpectationTimeout)
214+
}
215+
216+
func testTrackInAppOpen() {
217+
let messageId = "message1"
218+
let expectation1 = expectation(description: "track in app open")
219+
220+
let networkSession = MockNetworkSession(statusCode: 200)
221+
IterableAPI.initialize(apiKey: IterableInAppNotificationTests.apiKey, networkSession: networkSession)
222+
IterableAPI.email = IterableInAppNotificationTests.email
223+
networkSession.callback = {(_, _, _) in
224+
TestUtils.validate(request: networkSession.request!,
225+
requestType: .post,
226+
apiEndPoint: .ITBL_ENDPOINT_API,
227+
path: .ITBL_PATH_TRACK_INAPP_OPEN,
228+
queryParams: [(name: AnyHashable.ITBL_KEY_API_KEY, value: IterableInAppNotificationTests.apiKey),
229+
])
230+
let body = networkSession.getRequestBody() as! [String : Any]
231+
TestUtils.validateMatch(keyPath: KeyPath(AnyHashable.ITBL_KEY_MESSAGE_ID), value: messageId, inDictionary: body)
232+
TestUtils.validateMatch(keyPath: KeyPath(AnyHashable.ITBL_KEY_EMAIL), value: IterableInAppNotificationTests.email, inDictionary: body)
233+
expectation1.fulfill()
234+
}
235+
IterableAPI.track(inAppOpen: messageId)
236+
wait(for: [expectation1], timeout: testExpectationTimeout)
237+
}
238+
239+
private static let apiKey = "zeeApiKey"
240+
private static let email = "[email protected]"
241+
private static let userId = "userId1"
158242
}

Tests/ui-tests/Info.plist

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>$(DEVELOPMENT_LANGUAGE)</string>
7+
<key>CFBundleExecutable</key>
8+
<string>$(EXECUTABLE_NAME)</string>
9+
<key>CFBundleIdentifier</key>
10+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
11+
<key>CFBundleInfoDictionaryVersion</key>
12+
<string>6.0</string>
13+
<key>CFBundleName</key>
14+
<string>$(PRODUCT_NAME)</string>
15+
<key>CFBundlePackageType</key>
16+
<string>BNDL</string>
17+
<key>CFBundleShortVersionString</key>
18+
<string>1.0</string>
19+
<key>CFBundleVersion</key>
20+
<string>1</string>
21+
</dict>
22+
</plist>

Tests/ui-tests/UITests.swift

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
//
2+
//
3+
// Created by Tapash Majumder on 9/26/18.
4+
// Copyright © 2018 Iterable. All rights reserved.
5+
//
6+
7+
import XCTest
8+
9+
class UITests: XCTestCase {
10+
private var app: XCUIApplication!
11+
12+
override func setUp() {
13+
// Put setup code here. This method is called before the invocation of each test method in the class.
14+
15+
// In UI tests it is usually best to stop immediately when a failure occurs.
16+
continueAfterFailure = false
17+
18+
// UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
19+
app = XCUIApplication()
20+
app.launch()
21+
22+
// In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
23+
}
24+
25+
override func tearDown() {
26+
// Put teardown code here. This method is called after the invocation of each test method in the class.
27+
}
28+
29+
func testShowSystemNotification() {
30+
// Tap the Left Button
31+
app.buttons["Show System Notification"].tap()
32+
33+
let alert = app.alerts.element
34+
XCTAssertTrue(alert.exists)
35+
36+
XCTAssertTrue(alert.staticTexts["Zee Title"].exists)
37+
XCTAssertTrue(alert.staticTexts["Zee Body"].exists)
38+
39+
let leftButton = app.buttons["Left Button"]
40+
leftButton.tap()
41+
42+
XCTAssertTrue(app.staticTexts["Left Button"].exists)
43+
44+
// Tap the Right Button
45+
app.buttons["Show System Notification"].tap()
46+
47+
48+
let rightButton = app.buttons["Right Button"]
49+
rightButton.tap()
50+
51+
XCTAssertTrue(app.staticTexts["Right Button"].exists)
52+
}
53+
54+
}

host-app/AppDelegate.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
import UIKit
1010

11+
import IterableSDK
12+
13+
1114
@UIApplicationMain
1215
class AppDelegate: UIResponder, UIApplicationDelegate {
1316

@@ -16,6 +19,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1619

1720
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
1821
// Override point for customization after application launch.
22+
23+
IterableAPI.initialize(apiKey: "")
24+
1925
return true
2026
}
2127

host-app/Assets.xcassets/AppIcon.appiconset/Contents.json

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,111 @@
11
{
22
"images" : [
33
{
4-
"idiom" : "iphone",
54
"size" : "20x20",
5+
"idiom" : "iphone",
6+
"filename" : "[email protected]",
67
"scale" : "2x"
78
},
89
{
9-
"idiom" : "iphone",
1010
"size" : "20x20",
11+
"idiom" : "iphone",
12+
"filename" : "[email protected]",
1113
"scale" : "3x"
1214
},
1315
{
14-
"idiom" : "iphone",
1516
"size" : "29x29",
17+
"idiom" : "iphone",
18+
"filename" : "[email protected]",
1619
"scale" : "2x"
1720
},
1821
{
19-
"idiom" : "iphone",
2022
"size" : "29x29",
23+
"idiom" : "iphone",
24+
"filename" : "[email protected]",
2125
"scale" : "3x"
2226
},
2327
{
24-
"idiom" : "iphone",
2528
"size" : "40x40",
29+
"idiom" : "iphone",
30+
"filename" : "[email protected]",
2631
"scale" : "2x"
2732
},
2833
{
29-
"idiom" : "iphone",
3034
"size" : "40x40",
35+
"idiom" : "iphone",
36+
"filename" : "[email protected]",
3137
"scale" : "3x"
3238
},
3339
{
34-
"idiom" : "iphone",
3540
"size" : "60x60",
41+
"idiom" : "iphone",
42+
"filename" : "[email protected]",
3643
"scale" : "2x"
3744
},
3845
{
39-
"idiom" : "iphone",
4046
"size" : "60x60",
47+
"idiom" : "iphone",
48+
"filename" : "[email protected]",
4149
"scale" : "3x"
4250
},
4351
{
44-
"idiom" : "ipad",
4552
"size" : "20x20",
53+
"idiom" : "ipad",
54+
"filename" : "Icon-App20x20.png",
4655
"scale" : "1x"
4756
},
4857
{
49-
"idiom" : "ipad",
5058
"size" : "20x20",
59+
"idiom" : "ipad",
60+
"filename" : "[email protected]",
5161
"scale" : "2x"
5262
},
5363
{
54-
"idiom" : "ipad",
5564
"size" : "29x29",
65+
"idiom" : "ipad",
66+
"filename" : "Icon-App29x29.png",
5667
"scale" : "1x"
5768
},
5869
{
59-
"idiom" : "ipad",
6070
"size" : "29x29",
71+
"idiom" : "ipad",
72+
"filename" : "[email protected]",
6173
"scale" : "2x"
6274
},
6375
{
64-
"idiom" : "ipad",
6576
"size" : "40x40",
77+
"idiom" : "ipad",
78+
"filename" : "Icon-App40x40.png",
6679
"scale" : "1x"
6780
},
6881
{
69-
"idiom" : "ipad",
7082
"size" : "40x40",
83+
"idiom" : "ipad",
84+
"filename" : "[email protected]",
7185
"scale" : "2x"
7286
},
7387
{
74-
"idiom" : "ipad",
7588
"size" : "76x76",
89+
"idiom" : "ipad",
90+
"filename" : "Icon-App76x76.png",
7691
"scale" : "1x"
7792
},
7893
{
79-
"idiom" : "ipad",
8094
"size" : "76x76",
95+
"idiom" : "ipad",
96+
"filename" : "[email protected]",
8197
"scale" : "2x"
8298
},
8399
{
84-
"idiom" : "ipad",
85100
"size" : "83.5x83.5",
101+
"idiom" : "ipad",
102+
"filename" : "[email protected]",
86103
"scale" : "2x"
87104
},
88105
{
89-
"idiom" : "ios-marketing",
90106
"size" : "1024x1024",
107+
"idiom" : "ios-marketing",
108+
"filename" : "[email protected]",
91109
"scale" : "1x"
92110
}
93111
],
6.26 KB
Loading
5.08 KB
Loading
7.89 KB
Loading
3.26 KB
Loading

0 commit comments

Comments
 (0)