Skip to content

Commit f1fad8c

Browse files
committed
Add waitForNonExistence Backport
1 parent a1e051b commit f1fad8c

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

CodeEdit.xcodeproj/project.pbxproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@
403403
6C48D8F72972E5F300D6D205 /* WindowObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C48D8F62972E5F300D6D205 /* WindowObserver.swift */; };
404404
6C4E37F62C73DA5200AEE7B5 /* UtilityAreaTerminalSidebar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C4E37F52C73DA5200AEE7B5 /* UtilityAreaTerminalSidebar.swift */; };
405405
6C4E37FC2C73E00700AEE7B5 /* SwiftTerm in Frameworks */ = {isa = PBXBuildFile; productRef = 6C4E37FB2C73E00700AEE7B5 /* SwiftTerm */; };
406+
6C510CB82D2E4639006EBE85 /* XCUITest+waitForNonExistence.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C510CB72D2E4639006EBE85 /* XCUITest+waitForNonExistence.swift */; };
406407
6C5228B529A868BD00AC48F6 /* Environment+ContentInsets.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C5228B429A868BD00AC48F6 /* Environment+ContentInsets.swift */; };
407408
6C53AAD829A6C4FD00EE9ED6 /* SplitView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C53AAD729A6C4FD00EE9ED6 /* SplitView.swift */; };
408409
6C578D8129CD294800DC73B2 /* ExtensionActivatorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C578D8029CD294800DC73B2 /* ExtensionActivatorView.swift */; };
@@ -1095,6 +1096,7 @@
10951096
6C48D8F32972DB1A00D6D205 /* Env+Window.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Env+Window.swift"; sourceTree = "<group>"; };
10961097
6C48D8F62972E5F300D6D205 /* WindowObserver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WindowObserver.swift; sourceTree = "<group>"; };
10971098
6C4E37F52C73DA5200AEE7B5 /* UtilityAreaTerminalSidebar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UtilityAreaTerminalSidebar.swift; sourceTree = "<group>"; };
1099+
6C510CB72D2E4639006EBE85 /* XCUITest+waitForNonExistence.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "XCUITest+waitForNonExistence.swift"; sourceTree = "<group>"; };
10981100
6C5228B429A868BD00AC48F6 /* Environment+ContentInsets.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Environment+ContentInsets.swift"; sourceTree = "<group>"; };
10991101
6C53AAD729A6C4FD00EE9ED6 /* SplitView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SplitView.swift; sourceTree = "<group>"; };
11001102
6C578D8029CD294800DC73B2 /* ExtensionActivatorView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExtensionActivatorView.swift; sourceTree = "<group>"; };
@@ -2966,6 +2968,14 @@
29662968
path = Environment;
29672969
sourceTree = "<group>";
29682970
};
2971+
6C510CB62D2E462D006EBE85 /* Extensions */ = {
2972+
isa = PBXGroup;
2973+
children = (
2974+
6C510CB72D2E4639006EBE85 /* XCUITest+waitForNonExistence.swift */,
2975+
);
2976+
path = Extensions;
2977+
sourceTree = "<group>";
2978+
};
29692979
6C6BD6ED29CD123000235D17 /* Extensions */ = {
29702980
isa = PBXGroup;
29712981
children = (
@@ -3031,6 +3041,7 @@
30313041
6C96191F2C3F27E3009733CE /* CodeEditUITests */ = {
30323042
isa = PBXGroup;
30333043
children = (
3044+
6C510CB62D2E462D006EBE85 /* Extensions */,
30343045
6CFBA54A2C4E168A00E3A914 /* App.swift */,
30353046
6C9619232C3F2809009733CE /* ProjectPath.swift */,
30363047
6C9619212C3F27F1009733CE /* Query.swift */,
@@ -4596,6 +4607,7 @@
45964607
isa = PBXSourcesBuildPhase;
45974608
buildActionMask = 2147483647;
45984609
files = (
4610+
6C510CB82D2E4639006EBE85 /* XCUITest+waitForNonExistence.swift in Sources */,
45994611
6C9619242C3F2809009733CE /* ProjectPath.swift in Sources */,
46004612
6CFBA54B2C4E168A00E3A914 /* App.swift in Sources */,
46014613
6CFBA54D2C4E16C900E3A914 /* WindowCloseCommandTests.swift in Sources */,
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//
2+
// XCUITest+waitForNonExistence.swift
3+
// CodeEditUITests
4+
//
5+
// Created by Khan Winter on 1/7/25.
6+
//
7+
8+
import XCTest
9+
10+
// Backport to Xcode 15, this exists in Xcode 16.
11+
12+
extension XCUIElement {
13+
/// Waits the specified amount of time for the element’s `exists` property to become `false`.
14+
/// - Parameter timeout: The amount of time to wait.
15+
/// - Returns: `false` if the timeout expires without the element coming out of existence.
16+
///
17+
func waitForNonExistence(timeout: TimeInterval) -> Bool {
18+
let timeStart = Date().timeIntervalSince1970
19+
20+
while Date().timeIntervalSince1970 <= (timeStart + timeout) {
21+
if !exists { return true }
22+
}
23+
24+
return false
25+
}
26+
}

0 commit comments

Comments
 (0)