From 9642c17f2ca686a59017455c2323b3f4b04d1d3b Mon Sep 17 00:00:00 2001 From: tisfeng Date: Mon, 11 Nov 2024 20:49:02 +0800 Subject: [PATCH] test: improve alert volume test --- EasydictSwiftTests/Test.swift | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/EasydictSwiftTests/Test.swift b/EasydictSwiftTests/Test.swift index 68abff90b..e1fe6964b 100644 --- a/EasydictSwiftTests/Test.swift +++ b/EasydictSwiftTests/Test.swift @@ -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 { @@ -83,4 +89,5 @@ import Translation } } } + #expect(true, "Concurrent test getSelectedText completed without crash") }