Skip to content

Commit f8516c1

Browse files
authored
Merge pull request #239 from line/coverage/stable-creating-controller-test
Add presentingAnimation parameter to OpenChatCreatingController
2 parents b78d4b9 + 64b5aff commit f8516c1

File tree

3 files changed

+52
-11
lines changed

3 files changed

+52
-11
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ jobs:
77
name: Test LINE SDK
88
runs-on: macos-15
99
strategy:
10+
fail-fast: false
1011
matrix:
1112
swift-version: ["6.0", "5.0", "4.2"]
1213
steps:
@@ -29,6 +30,7 @@ jobs:
2930
name: Lint CocoaPods
3031
runs-on: macos-15
3132
strategy:
33+
fail-fast: false
3234
matrix:
3335
swift-version: ["6.0", "5.0", "4.2"]
3436
steps:

LineSDK/LineSDK/LineSDKUI/OpenChatUI/Public/OpenChatCreatingController.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ public class OpenChatCreatingController {
9191
/// ```
9292
public func loadAndPresent(
9393
in viewController: UIViewController,
94+
presentingAnimation: Bool = true,
9495
navigationDismissAnimating: Bool = true,
9596
presentedHandler handler: ((Result<UIViewController, LineSDKError>) -> Void)? = nil
9697
)
@@ -102,6 +103,7 @@ public class OpenChatCreatingController {
102103
if response.agreed {
103104
self.presentCreatingViewController(
104105
in: viewController,
106+
presentingAnimation: presentingAnimation,
105107
navigationDismissAnimating: navigationDismissAnimating,
106108
handler: handler
107109
)
@@ -149,6 +151,7 @@ public class OpenChatCreatingController {
149151

150152
func presentCreatingViewController(
151153
in viewController: UIViewController,
154+
presentingAnimation: Bool = true,
152155
navigationDismissAnimating: Bool = true,
153156
handler: ((Result<UIViewController, LineSDKError>) -> Void)?
154157
)
@@ -198,13 +201,13 @@ public class OpenChatCreatingController {
198201
}
199202
}
200203

201-
navigation.pushViewController(userInfoFormViewController, animated: true)
204+
navigation.pushViewController(userInfoFormViewController, animated: presentingAnimation)
202205
}
203206

204207
navigation.modalPresentationStyle = .fullScreen
205208

206209
delegate?.openChatCreatingController(self, willPresentCreatingNavigationController: navigation)
207-
viewController.present(navigation, animated: true) { handler?(.success(navigation)) }
210+
viewController.present(navigation, animated: presentingAnimation) { handler?(.success(navigation)) }
208211
}
209212
}
210213

LineSDK/LineSDKTests/OpenChat/OpenChatControllerTests.swift

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,11 @@ class OpenChatCreatingControllerTests: XCTestCase, ViewControllerCompatibleTest
115115
let controller = OpenChatCreatingController()
116116

117117
// Test loadAndPresent flow when terms not agreed
118-
controller.loadAndPresent(in: viewController, navigationDismissAnimating: false) { result in
118+
controller.loadAndPresent(
119+
in: viewController,
120+
presentingAnimation: false,
121+
navigationDismissAnimating: false
122+
) { result in
119123
switch result {
120124
case .success(let resultVC):
121125
XCTAssertNotNil(viewController.presentedViewController)
@@ -151,7 +155,11 @@ class OpenChatCreatingControllerTests: XCTestCase, ViewControllerCompatibleTest
151155
let viewController = setupViewController()
152156

153157
let controller = OpenChatCreatingController()
154-
controller.loadAndPresent(in: viewController, navigationDismissAnimating: false) { result in
158+
controller.loadAndPresent(
159+
in: viewController,
160+
presentingAnimation: false,
161+
navigationDismissAnimating: false
162+
) { result in
155163
expect.fulfill()
156164
switch result {
157165
case .success:
@@ -178,7 +186,11 @@ class OpenChatCreatingControllerTests: XCTestCase, ViewControllerCompatibleTest
178186
let mockDelegate = MockOpenChatCreatingControllerDelegate()
179187
controller.delegate = mockDelegate
180188

181-
controller.presentCreatingViewController(in: viewController, navigationDismissAnimating: false) { result in
189+
controller.presentCreatingViewController(
190+
in: viewController,
191+
presentingAnimation: false,
192+
navigationDismissAnimating: false
193+
) { result in
182194
switch result {
183195
case .success(let navigationVC):
184196
XCTAssertNotNil(viewController.presentedViewController)
@@ -228,7 +240,11 @@ class OpenChatCreatingControllerTests: XCTestCase, ViewControllerCompatibleTest
228240
let mockDelegate = MockOpenChatCreatingControllerDelegate()
229241
controller.delegate = mockDelegate
230242

231-
controller.presentCreatingViewController(in: viewController, navigationDismissAnimating: false) { result in
243+
controller.presentCreatingViewController(
244+
in: viewController,
245+
presentingAnimation: false,
246+
navigationDismissAnimating: false
247+
) { result in
232248
switch result {
233249
case .success(let navigationVC):
234250
guard let navigation = navigationVC as? UINavigationController,
@@ -280,7 +296,11 @@ class OpenChatCreatingControllerTests: XCTestCase, ViewControllerCompatibleTest
280296
let mockDelegate = MockOpenChatCreatingControllerDelegate()
281297
controller.delegate = mockDelegate
282298

283-
controller.presentCreatingViewController(in: viewController, navigationDismissAnimating: false) { result in
299+
controller.presentCreatingViewController(
300+
in: viewController,
301+
presentingAnimation: false,
302+
navigationDismissAnimating: false
303+
) { result in
284304
switch result {
285305
case .success(let navigationVC):
286306
guard let navigation = navigationVC as? UINavigationController,
@@ -333,7 +353,11 @@ class OpenChatCreatingControllerTests: XCTestCase, ViewControllerCompatibleTest
333353
let mockDelegate = MockOpenChatCreatingControllerDelegate()
334354
controller.delegate = mockDelegate
335355

336-
controller.presentCreatingViewController(in: viewController, navigationDismissAnimating: false) { result in
356+
controller.presentCreatingViewController(
357+
in: viewController,
358+
presentingAnimation: false,
359+
navigationDismissAnimating: false
360+
) { result in
337361
switch result {
338362
case .success(let navigationVC):
339363
guard let navigation = navigationVC as? UINavigationController,
@@ -395,7 +419,11 @@ class OpenChatCreatingControllerTests: XCTestCase, ViewControllerCompatibleTest
395419
controller.delegate = mockDelegate
396420

397421
// Start the load and present operation
398-
controller.loadAndPresent(in: viewController, navigationDismissAnimating: false) { result in
422+
controller.loadAndPresent(
423+
in: viewController,
424+
presentingAnimation: false,
425+
navigationDismissAnimating: false
426+
) { result in
399427
// This should not be called when delegate prevents the alert
400428
XCTFail("Handler should not be called when delegate prevents alert")
401429
}
@@ -425,7 +453,11 @@ class OpenChatCreatingControllerTests: XCTestCase, ViewControllerCompatibleTest
425453
let viewController = setupViewController()
426454
let controller = OpenChatCreatingController()
427455

428-
controller.loadAndPresent(in: viewController, navigationDismissAnimating: false) { result in
456+
controller.loadAndPresent(
457+
in: viewController,
458+
presentingAnimation: false,
459+
navigationDismissAnimating: false
460+
) { result in
429461
expect.fulfill()
430462
switch result {
431463
case .success:
@@ -447,7 +479,11 @@ class OpenChatCreatingControllerTests: XCTestCase, ViewControllerCompatibleTest
447479
let mockDelegate = MockOpenChatCreatingControllerDelegate()
448480
controller.delegate = mockDelegate
449481

450-
controller.presentCreatingViewController(in: viewController, navigationDismissAnimating: false) { result in
482+
controller.presentCreatingViewController(
483+
in: viewController,
484+
presentingAnimation: false,
485+
navigationDismissAnimating: false
486+
) { result in
451487
expect.fulfill()
452488
switch result {
453489
case .success:

0 commit comments

Comments
 (0)