From f78154d3da3a61d137f65ea59b792eb45de8d20d Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Tue, 12 Nov 2024 01:02:14 -0500 Subject: [PATCH] Updated unit tests --- Tests/BluetoothTests/GATTTests.swift | 79 +++++++++++++++++++++++++++- 1 file changed, 78 insertions(+), 1 deletion(-) diff --git a/Tests/BluetoothTests/GATTTests.swift b/Tests/BluetoothTests/GATTTests.swift index 396eb4063..90eb88fb4 100644 --- a/Tests/BluetoothTests/GATTTests.swift +++ b/Tests/BluetoothTests/GATTTests.swift @@ -58,7 +58,6 @@ final class GATTTests: XCTestCase { log: { print("GATTServer:", $0) } ) - // request Task { [weak client] in while let client { try await Task.sleep(nanoseconds: 10_000) @@ -144,6 +143,19 @@ final class GATTTests: XCTestCase { ) let server = try await serverAcceptTask.value + Task { [weak client] in + while let client { + try await Task.sleep(nanoseconds: 10_000) + try await client.run() + } + } + Task { [weak server] in + while let server { + try await Task.sleep(nanoseconds: 10_000) + try await server.run() + } + } + // request let services = try await client.discoverAllPrimaryServices() XCTAssertEqual(services.map { $0.uuid }, profile.map { $0.uuid }) @@ -459,6 +471,19 @@ final class GATTTests: XCTestCase { ) let server = try await serverAcceptTask.value + Task { [weak client] in + while let client { + try await Task.sleep(nanoseconds: 10_000) + try await client.run() + } + } + Task { [weak server] in + while let server { + try await Task.sleep(nanoseconds: 10_000) + try await server.run() + } + } + // request let services = try await client.discoverAllPrimaryServices() XCTAssertEqual(services.map { $0.uuid }, ProximityProfile.services.map { $0.uuid }) @@ -593,6 +618,19 @@ final class GATTTests: XCTestCase { ) let server = try await serverAcceptTask.value + Task { [weak client] in + while let client { + try await Task.sleep(nanoseconds: 10_000) + try await client.run() + } + } + Task { [weak server] in + while let server { + try await Task.sleep(nanoseconds: 10_000) + try await server.run() + } + } + // request let services = try await client.discoverAllPrimaryServices() XCTAssertEqual(services.map { $0.uuid }, [service].map { $0.uuid }) @@ -660,6 +698,19 @@ final class GATTTests: XCTestCase { ) let server = try await serverAcceptTask.value + Task { [weak client] in + while let client { + try await Task.sleep(nanoseconds: 10_000) + try await client.run() + } + } + Task { [weak server] in + while let server { + try await Task.sleep(nanoseconds: 10_000) + try await server.run() + } + } + // discover service let foundServices = try await client.discoverPrimaryServices(by: services[0].uuid) guard foundServices.count == 1, @@ -738,6 +789,19 @@ final class GATTTests: XCTestCase { ) let server = try await serverAcceptTask.value + Task { [weak client] in + while let client { + try await Task.sleep(nanoseconds: 10_000) + try await client.run() + } + } + Task { [weak server] in + while let server { + try await Task.sleep(nanoseconds: 10_000) + try await server.run() + } + } + // discover service let foundServices = try await client.discoverPrimaryServices(by: service.uuid) guard foundServices.count == 1, @@ -826,6 +890,19 @@ final class GATTTests: XCTestCase { ) let server = try await serverAcceptTask.value + Task { [weak client] in + while let client { + try await Task.sleep(nanoseconds: 10_000) + try await client.run() + } + } + Task { [weak server] in + while let server { + try await Task.sleep(nanoseconds: 10_000) + try await server.run() + } + } + // discover service let foundServices = try await client.discoverPrimaryServices(by: service.uuid) guard foundServices.count == 1,