Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 16 additions & 18 deletions Sources/Testing/Extensions/TestingElement+Disableable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,14 @@ extension TestingElement where Accessibility: DisableableAccessibility {
file: StaticString = #filePath,
line: UInt = #line
) -> Self {
if !element.wait(for: \.isContentEnabled, toEqual: false, timeout: timeout), failing {
XCTFail(
"Element \(element) was not disabled within \(timeout) seconds",
file: file,
line: line
)
}

return self
wait(
for: isEnabled == false,
timeout: timeout,
failing: failing,
message: "Element \(element) was not disabled within \(timeout) seconds",
file: file,
line: line
)
}

/// Ждет указанное время, пока компонент не станет включенным.
Expand All @@ -87,15 +86,14 @@ extension TestingElement where Accessibility: DisableableAccessibility {
file: StaticString = #filePath,
line: UInt = #line
) -> Self {
if !element.wait(for: \.isContentEnabled, toEqual: true, timeout: timeout), failing {
XCTFail(
"Element \(element) was not enabled within \(timeout) seconds",
file: file,
line: line
)
}

return self
wait(
for: isEnabled == true,
timeout: timeout,
failing: failing,
message: "Element \(element) was not enabled within \(timeout) seconds",
file: file,
line: line
)
}
}

Expand Down
68 changes: 32 additions & 36 deletions Sources/Testing/Extensions/TestingElement+Editable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,14 @@ extension TestingElement where Accessibility: EditableAccessibility {
file: StaticString = #filePath,
line: UInt = #line
) -> Self {
if !element.wait(for: \.contentText, toEqual: text, timeout: timeout), failing {
XCTFail(
"Text of element \(element) was not equal to \(text) within \(timeout) seconds",
file: file,
line: line
)
}

return self
wait(
for: self.text == text,
timeout: timeout,
failing: failing,
message: "Text of element \(element) was not equal to \(text) within \(timeout) seconds",
file: file,
line: line
)
}

/// Ждет указанное время, пока текст-заполнитель компонента не станет равен указанному.
Expand All @@ -155,15 +154,14 @@ extension TestingElement where Accessibility: EditableAccessibility {
file: StaticString = #filePath,
line: UInt = #line
) -> Self {
if !element.wait(for: \.contentPlaceholder, toEqual: placeholder, timeout: timeout), failing {
XCTFail(
"Placeholder of element \(element) was not equal to \(placeholder) within \(timeout) seconds",
file: file,
line: line
)
}

return self
wait(
for: self.placeholder == placeholder,
timeout: timeout,
failing: failing,
message: "Placeholder of element \(element) was not equal to \(placeholder) within \(timeout) seconds",
file: file,
line: line
)
}

/// Ждет указанное время, пока компонент не получит фокус.
Expand All @@ -185,15 +183,14 @@ extension TestingElement where Accessibility: EditableAccessibility {
file: StaticString = #filePath,
line: UInt = #line
) -> Self {
if !element.wait(for: \.isContentFocused, toEqual: true, timeout: timeout), failing {
XCTFail(
"Element \(element) was not focused within \(timeout) seconds",
file: file,
line: line
)
}

return self
wait(
for: isFocused == true,
timeout: timeout,
failing: failing,
message: "Element \(element) was not focused within \(timeout) seconds",
file: file,
line: line
)
}

/// Ждет указанное время, пока компонент не потеряет фокус.
Expand All @@ -215,15 +212,14 @@ extension TestingElement where Accessibility: EditableAccessibility {
file: StaticString = #filePath,
line: UInt = #line
) -> Self {
if !element.wait(for: \.isContentFocused, toEqual: false, timeout: timeout), failing {
XCTFail(
"Element \(element) was not unfocused within \(timeout) seconds",
file: file,
line: line
)
}

return self
wait(
for: isFocused == false,
timeout: timeout,
failing: failing,
message: "Element \(element) was not unfocused within \(timeout) seconds",
file: file,
line: line
)
}

/// Вводит указанный текст с клавиатуры.
Expand Down
34 changes: 16 additions & 18 deletions Sources/Testing/Extensions/TestingElement+Hittable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,14 @@ extension TestingElement where Accessibility: ViewAccessibility {
file: StaticString = #filePath,
line: UInt = #line
) -> Self {
if !element.wait(for: \.isHittable, toEqual: true, timeout: timeout), failing {
XCTFail(
"Element \(element) was not hittable within \(timeout) seconds",
file: file,
line: line
)
}

return self
wait(
for: isHittable == true,
timeout: timeout,
failing: failing,
message: "Element \(element) was not hittable within \(timeout) seconds",
file: file,
line: line
)
}

/// Ждет указанное время, пока компонент не перестанет быть доступным для касаний.
Expand All @@ -87,15 +86,14 @@ extension TestingElement where Accessibility: ViewAccessibility {
file: StaticString = #filePath,
line: UInt = #line
) -> Self {
if !element.wait(for: \.isHittable, toEqual: false, timeout: timeout), failing {
XCTFail(
"Element \(element) was hittable within \(timeout) seconds",
file: file,
line: line
)
}

return self
wait(
for: isHittable == false,
timeout: timeout,
failing: failing,
message: "Element \(element) was hittable within \(timeout) seconds",
file: file,
line: line
)
}

#if os(iOS)
Expand Down
17 changes: 8 additions & 9 deletions Sources/Testing/Extensions/TestingElement+Image.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,14 @@ extension TestingElement where Accessibility: ImageAccessibility {
file: StaticString = #filePath,
line: UInt = #line
) -> Self {
if !element.wait(for: \.contentLabel, toEqual: label, timeout: timeout), failing {
XCTFail(
"Label of element \(element) was not equal to \(label) within \(timeout) seconds",
file: file,
line: line
)
}

return self
wait(
for: self.label == label,
timeout: timeout,
failing: failing,
message: "Label of element \(element) was not equal to \(label) within \(timeout) seconds",
file: file,
line: line
)
}
}

Expand Down
34 changes: 16 additions & 18 deletions Sources/Testing/Extensions/TestingElement+Selectable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,14 @@ extension TestingElement where Accessibility: SelectableAccessibility {
file: StaticString = #filePath,
line: UInt = #line
) -> Self {
if !element.wait(for: \.isContentSelected, toEqual: true, timeout: timeout), failing {
XCTFail(
"Element \(element) was not selected within \(timeout) seconds",
file: file,
line: line
)
}

return self
wait(
for: isSelected == true,
timeout: timeout,
failing: failing,
message: "Element \(element) was not selected within \(timeout) seconds",
file: file,
line: line
)
}

/// Ждет указанное время, пока компонент не перестанет быть выбранным.
Expand All @@ -87,15 +86,14 @@ extension TestingElement where Accessibility: SelectableAccessibility {
file: StaticString = #filePath,
line: UInt = #line
) -> Self {
if !element.wait(for: \.isContentSelected, toEqual: false, timeout: timeout), failing {
XCTFail(
"Element \(element) was not deselected within \(timeout) seconds",
file: file,
line: line
)
}

return self
wait(
for: isSelected == false,
timeout: timeout,
failing: failing,
message: "Element \(element) was not deselected within \(timeout) seconds",
file: file,
line: line
)
}
}

Expand Down
17 changes: 8 additions & 9 deletions Sources/Testing/Extensions/TestingElement+Text.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,14 @@ extension TestingElement where Accessibility: TextAccessibility {
file: StaticString = #filePath,
line: UInt = #line
) -> Self {
if !element.wait(for: \.contentText, toEqual: text, timeout: timeout), failing {
XCTFail(
"Text of element \(element) was not equal to \(text) within \(timeout) seconds",
file: file,
line: line
)
}

return self
wait(
for: self.text == text,
timeout: timeout,
failing: failing,
message: "Text of element \(element) was not equal to \(text) within \(timeout) seconds",
file: file,
line: line
)
}
}

Expand Down
51 changes: 24 additions & 27 deletions Sources/Testing/Extensions/TestingElement+View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,14 @@ extension TestingElement where Accessibility: ViewAccessibility {
file: StaticString = #filePath,
line: UInt = #line
) -> Self {
if !element.wait(for: \.frame, toEqual: frame, timeout: timeout), failing {
XCTFail(
"Frame of element \(element) was not equal to \(frame) within \(timeout) seconds",
file: file,
line: line
)
}

return self
wait(
for: self.frame == frame,
timeout: timeout,
failing: failing,
message: "Frame of element \(element) was not equal to \(frame) within \(timeout) seconds",
file: file,
line: line
)
}

/// Ждет указанное время, пока компонент не появится.
Expand All @@ -121,15 +120,14 @@ extension TestingElement where Accessibility: ViewAccessibility {
file: StaticString = #filePath,
line: UInt = #line
) -> Self {
if !element.waitForExistence(timeout: timeout), failing {
XCTFail(
"Element \(element) was not appeared within \(timeout) seconds",
file: file,
line: line
)
}

return self
wait(
for: isExist,
timeout: timeout,
failing: failing,
message: "Element \(element) was not appeared within \(timeout) seconds",
file: file,
line: line
)
}

/// Ждет указанное время, пока компонент не исчезнет.
Expand All @@ -151,15 +149,14 @@ extension TestingElement where Accessibility: ViewAccessibility {
file: StaticString = #filePath,
line: UInt = #line
) -> Self {
if !element.waitForNonExistence(timeout: timeout), failing {
XCTFail(
"Element \(element) was not disappeared within \(timeout) seconds",
file: file,
line: line
)
}

return self
wait(
for: !isExist,
timeout: timeout,
failing: failing,
message: "Element \(element) was not disappeared within \(timeout) seconds",
file: file,
line: line
)
}

/// Выводит в консоль отладочную информацию.
Expand Down
Loading