-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #89 from blyscuit/bug/fix-screen-animations
[Bug] Fix animations causing tests failures
- Loading branch information
Showing
14 changed files
with
177 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
iosApp/Survey/Sources/Constants/Double+AnimationDuration.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// Double+AnimationDuration.swift | ||
// Survey | ||
// | ||
// Created by Bliss on 7/12/22. | ||
// Copyright © 2022 Nimble. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
extension Double { | ||
|
||
/// 0.7 | ||
static var appearing: Self { 0.7.speedModified } | ||
/// 0.2 | ||
static var fast: Self { 0.2.speedModified } | ||
/// 0.3 | ||
static var `default`: Self { 0.3.speedModified } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
iosApp/Survey/Sources/Supports/Helpers/UITests/LaunchArgument.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// | ||
// LaunchArgument.swift | ||
// Survey | ||
// | ||
// Created by Bliss on 7/12/22. | ||
// Copyright © 2022 Nimble. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
enum LaunchArgumentKey: String { | ||
|
||
case fastAnimation | ||
} | ||
|
||
enum LaunchEnvironment { | ||
|
||
static func stringFor(_ key: LaunchArgumentKey) -> String? { | ||
return ProcessInfo.processInfo.environment[key.rawValue] | ||
} | ||
} | ||
|
||
enum LaunchArgument { | ||
|
||
static func contains(_ key: LaunchArgumentKey) -> Bool { | ||
return ProcessInfo.processInfo.arguments.contains(key.rawValue) | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
iosApp/Survey/Sources/Supports/Helpers/UITests/UITestHelper.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// | ||
// UITestHelper.swift | ||
// Survey | ||
// | ||
// Created by Bliss on 7/12/22. | ||
// Copyright © 2022 Nimble. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
final class UITestHelper { | ||
|
||
static let shared = UITestHelper() | ||
|
||
var speed: Float = 1.0 | ||
|
||
var isRunningUITests: Bool { | ||
LaunchArgument.contains(.fastAnimation) | ||
} | ||
|
||
func speedUpUITestAnimation() { | ||
#if DEBUG | ||
if isRunningUITests { | ||
// swiftformat:disable:next numberFormatting | ||
speed = 1_000.0 | ||
UIApplication | ||
.shared | ||
.connectedScenes | ||
.compactMap { $0 as? UIWindowScene } | ||
.flatMap { $0.windows } | ||
.first { $0.isKeyWindow }? | ||
.layer | ||
.speed = speed | ||
UIView.setAnimationsEnabled(false) | ||
} | ||
#endif | ||
} | ||
} | ||
|
||
extension Double { | ||
|
||
var speedModified: Double { | ||
#if DEBUG | ||
self / Double(UITestHelper.shared.speed) | ||
#else | ||
self | ||
#endif | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
iosApp/SurveyUITests/Sources/Utilities/Extensions/XCTest/ArgumentedXCUIApplication.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// | ||
// FastXCUIApplication.swift | ||
// Survey | ||
// | ||
// Created by Bliss on 7/12/22. | ||
// Copyright © 2022 Nimble. All rights reserved. | ||
// | ||
|
||
import XCTest | ||
|
||
final class ArgumentedXCUIApplication: XCUIApplication { | ||
|
||
override init() { | ||
super.init() | ||
isFastAnimation = true | ||
} | ||
} | ||
|
||
extension ArgumentedXCUIApplication { | ||
|
||
var isFastAnimation: Bool { | ||
get { | ||
LaunchArgument.contains(.fastAnimation) | ||
} | ||
|
||
set { | ||
if newValue { | ||
add(launchArguments: .fastAnimation) | ||
} else { | ||
remove(launchArguments: .fastAnimation) | ||
} | ||
} | ||
} | ||
|
||
func add(launchArguments argument: LaunchArgumentKey) { | ||
launchArguments.append(argument.rawValue) | ||
} | ||
|
||
func remove(launchArguments argument: LaunchArgumentKey) { | ||
launchArguments.removeAll(where: { $0 == argument.rawValue }) | ||
} | ||
} |