Skip to content

Commit

Permalink
test: improve alert volume test
Browse files Browse the repository at this point in the history
  • Loading branch information
tisfeng committed Nov 14, 2024
1 parent 3ca78ef commit 9642c17
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions EasydictSwiftTests/Test.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,28 @@ import Translation
#expect(decryptedText == text)
}

@Test func alertVolume() async throws {
let volume = try await AppleScriptTask.alertVolume()
print(volume)
}
@Test func testAlertVolume() async throws {
let originalVolume = try await AppleScriptTask.alertVolume()
print("Original volume: \(originalVolume)")

let testVolume = 50
try await AppleScriptTask.setAlertVolume(testVolume)

let newVolume = try await AppleScriptTask.alertVolume()
#expect(newVolume == testVolume)

@Test func setAlertVolume() async throws {
try await AppleScriptTask.setAlertVolume(50)
try await AppleScriptTask.setAlertVolume(originalVolume)
#expect(true, "Alert volume test completed")
}

@Test func testGetSelectedText() async {
@Test func testGetSelectedText() async throws {
// Run thousands of times to test crash.
for i in 0..<2000 {
print("test index: \(i)")
let selectedText = await (try? getSelectedText()) ?? ""
print("\(i) selectedText: \(selectedText)")
}
#expect(true, "Test getSelectedText completed without crash")
}

@Test func testConcurrentGetSelectedText() async throws {
Expand All @@ -83,4 +89,5 @@ import Translation
}
}
}
#expect(true, "Concurrent test getSelectedText completed without crash")
}

0 comments on commit 9642c17

Please sign in to comment.