|
| 1 | +import XCTest |
| 2 | + |
| 3 | +@testable import MiddleDrag |
| 4 | + |
| 5 | +final class MultitouchFrameworkTests: XCTestCase { |
| 6 | + |
| 7 | + // MARK: - Singleton Tests |
| 8 | + |
| 9 | + func testMultitouchFrameworkIsSingleton() { |
| 10 | + let instance1 = MultitouchFramework.shared |
| 11 | + let instance2 = MultitouchFramework.shared |
| 12 | + XCTAssertTrue(instance1 === instance2) |
| 13 | + } |
| 14 | + |
| 15 | + // MARK: - Device Availability Tests |
| 16 | + |
| 17 | + func testIsAvailableDoesNotCrash() { |
| 18 | + let framework = MultitouchFramework.shared |
| 19 | + let isAvailable1 = framework.isAvailable |
| 20 | + let isAvailable2 = framework.isAvailable |
| 21 | + // Verify that calling isAvailable does not crash and returns a consistent value |
| 22 | + XCTAssertEqual(isAvailable1, isAvailable2) |
| 23 | + } |
| 24 | + |
| 25 | + func testGetDefaultDeviceDoesNotCrash() { |
| 26 | + let framework = MultitouchFramework.shared |
| 27 | + let device = framework.getDefaultDevice() |
| 28 | + let deviceAgain = framework.getDefaultDevice() |
| 29 | + // Verify that calling getDefaultDevice() does not crash and returns a consistent value |
| 30 | + XCTAssertEqual(device, deviceAgain) |
| 31 | + } |
| 32 | + |
| 33 | + func testGetDefaultDeviceReturnsConsistentValue() { |
| 34 | + let framework = MultitouchFramework.shared |
| 35 | + let device1 = framework.getDefaultDevice() |
| 36 | + let device2 = framework.getDefaultDevice() |
| 37 | + // Verify that repeated calls are consistent in availability (both nil or both non-nil), |
| 38 | + // without relying on pointer identity, which may legitimately differ. |
| 39 | + XCTAssertEqual(device1 != nil, device2 != nil) |
| 40 | + } |
| 41 | +} |
0 commit comments