Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
eonist committed Oct 15, 2023
1 parent 5dc490e commit cc8116d
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 17 deletions.
1 change: 0 additions & 1 deletion Sources/UITestSugar/query/QueryAsserter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,3 @@ public class QueryAsserter {
// let result = XCTWaiter().wait(for: [expectation], timeout: 5)
// return result == .completed
// }

2 changes: 1 addition & 1 deletion Sources/UITestSugar/query/XCUIElementQuery+Ext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ extension XCUIElementQuery {
QueryHelper.hittableElements(query: self)
}
}
#endif
#endif
2 changes: 1 addition & 1 deletion Sources/UITestSugar/ui/XCUIApplication+Ext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ extension XCUIApplication {
* - Fixme: ⚠️️ This function should be added to UITestSugar.
* - Note: ref: https://stackoverflow.com/questions/43904798/how-to-dismiss-a-popover-in-a-ui-test (The selected link provides a solution for dismissing a popover in UI testing by using the XCUIApplication class and tapping on the "Dismiss" button.)
*/

public func dismissPopup() {
// Dismiss the popup by tapping the "Cancel" button
otherElements["Cancel"].tap()
Expand Down
2 changes: 1 addition & 1 deletion Sources/UITestSugar/ui/element/ElementAsserter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class ElementAsserter {
public static func isVisibleInWindow(element: XCUIElement) -> Bool {
// Check if the element exists and has a non-empty frame
guard element.exists && !element.frame.isEmpty else { return false }

// Check if the element's frame is contained within the frame of the main window
return XCUIApplication().windows.element(boundBy: 0).frame.contains(element.frame)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ extension XCUIElement {
(value as? String) == "1" // Check if the value is a string and equal to "1"
}
}
#endif
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ extension XCUIElement {
return self // Return the adjusted slider element
}
}
#endif
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ extension XCUIElement {
return self // Return the modified element
}
}
#endif
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ extension XCUIElement {
* - waitAfter: The time to wait after tapping the element.
* - Returns: The same XCUIElement object.
*/
@discardableResult public func forceTap(waitForExistence: Double = 5, waitAfter: Double = 0.2) -> XCUIElement {
@discardableResult public func forceTap(waitForExistence: Double = 5, waitAfter: Double = 0.2) -> XCUIElement {
guard self.waitForExistence(timeout: waitForExistence) else { return self } // Wait for the element to exist
let vector: CGVector = .init(dx: 0.5, dy: 0.5) // Set the vector
self.coordinate(withNormalizedOffset: vector).tap() // Tap the element
Expand All @@ -56,9 +56,9 @@ extension XCUIElement {
* - Parameter sec: - Fixme: ⚠️️ doc
*/
@discardableResult public func tap(waitForExistence sec: Double) -> XCUIElement? {
guard self.waitForExistence(timeout: sec) else {
guard self.waitForExistence(timeout: sec) else {
// If the element does not exist within the specified timeout, return nil
return nil
return nil
}
self.tap()
return self
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ extension ElementModifier {
*/
public static func scrollTo(element: XCUIElement, dir: Direction, searchCondition: ElementParser.MatchCondition) {
// Keep scrolling until the search condition is met
while !searchCondition(element) {
while !searchCondition(element) {
switch dir { // Perform a swipe in the specified direction
case .up: element.swipeUp() // Swipe up
case .down: element.swipeDown() // Swipe down
Expand Down Expand Up @@ -57,7 +57,7 @@ extension ElementModifier {
* - timeOut: The maximum amount of time to wait for the element to be found. Default is 10 seconds.
*/
public static func scrollDownUntilFound(element: XCUIElement, id: String, type: XCUIElement.ElementType, timeOut: Double = 10) {
var exists: Bool = false // Initialize a boolean variable to keep track of whether the element exists or not
var exists = false // Initialize a boolean variable to keep track of whether the element exists or not
repeat { // Repeat the following block until the condition is met
let element: XCUIElement = element.descendants(matching: type).element(matching: type, identifier: id).firstMatch // Find the first descendant that matches the specified search types and identifier
exists = ElementAsserter.exists(element: element, timeout: timeOut) // Check if the element exists within the specified timeout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ extension ElementParser {
if metCondition {
collector = [(i, child)] // Found the item, we don't include the actual item we are looking for
break
}
}
// If the child doesn't satisfy the condition, recursively call the ancestry function on the child
// and add the child and its descendants to the collector array
else if let descendants = ancestry(root: (0, child), condition: condition) {
Expand Down
6 changes: 3 additions & 3 deletions Sources/UITestSugar/util/ScreenShotMaker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public final class ScreenShotMaker {
* XCTAssertNotNil(screenshot)
* ```
*/
@discardableResult public static func screenShotScreen(name: String, testCase: XCTestCase?) -> XCUIScreenshot? {
@discardableResult public static func screenShotScreen(name: String, testCase: XCTestCase?) -> XCUIScreenshot? {
// Make sure that the testCase parameter is not nil
guard let testCase = testCase else {
Swift.print("⚠️️ Err, ScreenShotMaker.makeScreenShot() - testcase is nil")
Expand Down Expand Up @@ -78,7 +78,7 @@ public final class ScreenShotMaker {
* XCTAssertNotNil(screenshot)
* ```
*/
@discardableResult public static func screenShotApp(name: String, testCase: XCTestCase?, app: XCUIApplication) -> XCUIScreenshot? {
@discardableResult public static func screenShotApp(name: String, testCase: XCTestCase?, app: XCUIApplication) -> XCUIScreenshot? {
// Check if the provided XCTestCase is not nil
guard let testCase = testCase else {
Swift.print("⚠️️ Err, ScreenShotMaker.makeScreenShot() - testcase is nil")
Expand All @@ -99,7 +99,7 @@ public final class ScreenShotMaker {
* - window: The XCUIElement instance of the window to be screenshot.
* - Returns: The XCUIScreenshot instance of the screenshot taken.
*/
@discardableResult static public func screenShotWindow(name: String, testCase: XCTestCase?, window: XCUIElement) -> XCUIScreenshot? {
@discardableResult public static func screenShotWindow(name: String, testCase: XCTestCase?, window: XCUIElement) -> XCUIScreenshot? {
// Check if the provided XCTestCase is not nil
guard let testCase = testCase else {
// Print an error message indicating that the testcase is nil
Expand Down
2 changes: 1 addition & 1 deletion Sources/UITestSugar/util/Sleep.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ import Foundation
public func sleep(sec: Double) {
// Wait for the specified duration in seconds
usleep(useconds_t(sec * 1_000_000))
}
}

0 comments on commit cc8116d

Please sign in to comment.