Skip to content

Commit

Permalink
Merge pull request #138 from theappbusiness/release/1.7.1
Browse files Browse the repository at this point in the history
Release/1.7.1
  • Loading branch information
jsanderson44 authored Oct 2, 2020
2 parents 5ea2520 + 4bf1c67 commit 69fece3
Show file tree
Hide file tree
Showing 8 changed files with 132 additions and 106 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# CHANGELOG

## 1.7.1

### Fixed

- Fixed an issue with entering background states on different OS versions. (issue #135)

---

## 1.7.0

- Added support for double tapping, long pressing and two finger tapping, with default implementations for any Elements that conform to Tappable. (issue #88)
Expand Down
12 changes: 6 additions & 6 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
PODS:
- ShowTime (2.5.2)
- TABTestKit (1.7.0):
- TABTestKit/BDD (= 1.7.0)
- TABTestKit/Biometrics (= 1.7.0)
- TABTestKit/BDD (1.7.0)
- TABTestKit/Biometrics (1.7.0)
- TABTestKit (1.7.1):
- TABTestKit/BDD (= 1.7.1)
- TABTestKit/Biometrics (= 1.7.1)
- TABTestKit/BDD (1.7.1)
- TABTestKit/Biometrics (1.7.1)

DEPENDENCIES:
- ShowTime
Expand All @@ -20,7 +20,7 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
ShowTime: 5cb2c5314da2983cec44f27123a15473cf29306f
TABTestKit: 937e406987fa0d11b2ee27e84a1c68f7d9cf09b9
TABTestKit: ebe37a44be0522faf36e79911ab2104dd2efca92

PODFILE CHECKSUM: b6b0b334dee592f181c8d68b62229392f1cd2529

Expand Down
9 changes: 6 additions & 3 deletions Example/Pods/Local Podspecs/TABTestKit.podspec.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions Example/Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

166 changes: 83 additions & 83 deletions Example/Pods/Pods.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions TABTestKit.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TABTestKit'
s.version = '1.7.0'
s.version = '1.7.1'
s.summary = 'Strongly typed Swift wrapper around XCTest / XCUI, enabling you to write BDD-style automation tests, without writing much code at all.'
s.homepage = 'https://github.com/theappbusiness/TABTestKit'
s.license = { :type => 'MIT', :file => 'LICENSE' }
Expand All @@ -9,7 +9,8 @@ Pod::Spec.new do |s|
'theblixguy' => '[email protected]',
'neil3079' => '[email protected]',
'annpiktas' => '[email protected]',
'roger-tan' => '[email protected]' }
'roger-tan' => '[email protected]',
'jsanderson44' => '[email protected]' }
s.source = { :git => 'https://github.com/theappbusiness/TABTestKit.git', :tag => s.version.to_s }
s.ios.deployment_target = '12.4'
s.swift_version = '5.0'
Expand Down
24 changes: 19 additions & 5 deletions TABTestKit/Classes/Apps/BaseApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@ open class BaseApp: XCUIApplication {
/// "Backgrounds" the app, waiting for the state to be suspended before continuing.
open func background() {
XCUIDevice.shared.press(.home)
if #available(iOS 12.4, *) { // https://github.com/theappbusiness/TABTestKit/issues/67
XCTAssertTrue(wait(for: .runningBackground, timeout: 10), "Failed waiting for app to become .runningBackground")
} else {
XCTAssertTrue(wait(for: .runningBackgroundSuspended, timeout: 10), "Failed waiting for app to become .runningBackgroundSuspended")
}
XCTAssertTrue(waitForBackgroundState(timeout: 10), "Failed waiting for app to become either .runningBackground or .runningBackgroundSuspended")
}

/// Activates/foregrounds the app, waiting for the state to be running before continuing.
Expand All @@ -57,3 +53,21 @@ extension BaseApp: Element {
public var underlyingXCUIElement: XCUIElement { return self }

}

private extension BaseApp {

/// Waits for the application to enter one of the background states (either `.runningBackground` or `.runningBackgroundSuspended`).
/// This is a fix for both https://github.com/theappbusiness/TABTestKit/issues/67 and https://github.com/theappbusiness/TABTestKit/issues/135
///
/// - Parameter timeout: The time to wait before failing.
/// - Returns: `true` if the application enters one of the background states, `false` otherwise.
func waitForBackgroundState(timeout: TimeInterval) -> Bool {
var interval = 0.0
repeat {
let isInBackgroundState = wait(for: .runningBackground, timeout: 1) || wait(for: .runningBackgroundSuspended, timeout: 1)
guard !isInBackgroundState else { return true }
interval += 1
} while interval <= timeout
return false
}
}

0 comments on commit 69fece3

Please sign in to comment.