Skip to content

Commit 518e3c8

Browse files
authored
Merge pull request #411 from Iterable/MOB-2231-webviewprotocol-tests
[MOB-2231] add missing coverage tests for webviewprotocol
2 parents d15d687 + 4c1ad05 commit 518e3c8

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

swift-sdk.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
55B9F15324B6625D00E8198A /* ApiClientProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55B9F15224B6625D00E8198A /* ApiClientProtocol.swift */; };
3030
55CC257B2462064F00A77FD5 /* InAppPresenterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55CC257A2462064F00A77FD5 /* InAppPresenterTests.swift */; };
3131
55D54656239AE5750093ED1E /* LoggingInternal.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55D54655239AE5750093ED1E /* LoggingInternal.swift */; };
32+
55E02D39253F8D86009DB8BC /* WebViewProtocolTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55E02D38253F8D86009DB8BC /* WebViewProtocolTests.swift */; };
3233
55E6F460238E066400808BCE /* DeferredDeepLinkTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55E6F45D238E066400808BCE /* DeferredDeepLinkTests.swift */; };
3334
55E6F462238E066400808BCE /* DeepLinkTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55E6F45E238E066400808BCE /* DeepLinkTests.swift */; };
3435
AC02480822791E2100495FB9 /* IterableInboxNavigationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AC02480722791E2100495FB9 /* IterableInboxNavigationViewController.swift */; };
@@ -372,6 +373,7 @@
372373
55B9F15224B6625D00E8198A /* ApiClientProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApiClientProtocol.swift; sourceTree = "<group>"; };
373374
55CC257A2462064F00A77FD5 /* InAppPresenterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InAppPresenterTests.swift; sourceTree = "<group>"; };
374375
55D54655239AE5750093ED1E /* LoggingInternal.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoggingInternal.swift; sourceTree = "<group>"; };
376+
55E02D38253F8D86009DB8BC /* WebViewProtocolTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebViewProtocolTests.swift; sourceTree = "<group>"; };
375377
55E6F45D238E066400808BCE /* DeferredDeepLinkTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DeferredDeepLinkTests.swift; sourceTree = "<group>"; };
376378
55E6F45E238E066400808BCE /* DeepLinkTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DeepLinkTests.swift; sourceTree = "<group>"; };
377379
AC02480722791E2100495FB9 /* IterableInboxNavigationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IterableInboxNavigationViewController.swift; sourceTree = "<group>"; };
@@ -972,6 +974,7 @@
972974
AC02CAA5234E50B5006617E0 /* RegistrationTests.swift */,
973975
ACAA816D231163660035C743 /* RequestCreatorTests.swift */,
974976
ACB37AAF240268A60093A8EA /* SampleInboxViewDelegateImplementations.swift */,
977+
55E02D38253F8D86009DB8BC /* WebViewProtocolTests.swift */,
975978
);
976979
path = "swift-sdk-swift-tests";
977980
sourceTree = "<group>";
@@ -1766,6 +1769,7 @@
17661769
5531CDAE22A9C992000D05E2 /* ClassExtensionsTests.swift in Sources */,
17671770
AC995F9E2167E9FD0099A184 /* CommonExtensions.swift in Sources */,
17681771
AC2C668020D31B1F00D46CC9 /* IterableNotificationResponseTests.swift in Sources */,
1772+
55E02D39253F8D86009DB8BC /* WebViewProtocolTests.swift in Sources */,
17691773
AC750A4A234CD67900561902 /* InAppHelperTests.swift in Sources */,
17701774
AC87172621A4E47E00FEA369 /* TestInAppPayloadGenerator.swift in Sources */,
17711775
AC1670CD2230A91C00989F8E /* InboxTests.swift in Sources */,
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//
2+
// Copyright © 2020 Iterable. All rights reserved.
3+
//
4+
5+
import XCTest
6+
import WebKit
7+
8+
@testable import IterableSDK
9+
10+
class WebViewProtocolTests: XCTestCase {
11+
func testVerifyViewPosition() {
12+
let webView = WKWebView(frame: CGRect(x: 0, y: 1, width: 2, height: 3))
13+
14+
XCTAssertEqual(webView.position.center, webView.center)
15+
XCTAssertEqual(webView.position.width, webView.frame.size.width)
16+
XCTAssertEqual(webView.position.height, webView.frame.size.height)
17+
}
18+
19+
func testWebViewHeightCalculationReject() {
20+
let condition1 = expectation(description: "")
21+
22+
let webView = WKWebView(frame: .zero)
23+
24+
let heightCalculationFuture = webView.calculateHeight()
25+
26+
heightCalculationFuture.onSuccess { height in
27+
XCTFail("promise shouldn't have succeeded")
28+
}
29+
30+
heightCalculationFuture.onError { error in
31+
XCTAssertEqual(error.errorDescription, "unable to get height")
32+
33+
condition1.fulfill()
34+
}
35+
36+
wait(for: [condition1], timeout: testExpectationTimeout)
37+
}
38+
}

0 commit comments

Comments
 (0)