Add more unit tests. Add app icon and info.plist information in preparation for TestFlight beta
This commit is contained in:
@@ -15,6 +15,12 @@ class DummyEngine: Engine {
|
||||
var delegate: Starscream.EngineDelegate?
|
||||
|
||||
@Published var startCalled = false
|
||||
@Published var stopCalled = false
|
||||
|
||||
func resetForNextTest() {
|
||||
self.startCalled = false
|
||||
self.stopCalled = false
|
||||
}
|
||||
|
||||
func register(delegate: Starscream.EngineDelegate) {
|
||||
self.delegate = delegate
|
||||
@@ -25,10 +31,12 @@ class DummyEngine: Engine {
|
||||
}
|
||||
|
||||
func stop(closeCode: UInt16) {
|
||||
stopCalled = true
|
||||
return
|
||||
}
|
||||
|
||||
func forceStop() {
|
||||
stopCalled = true
|
||||
return
|
||||
}
|
||||
|
||||
@@ -66,22 +74,57 @@ class MoonrakerSocketManagerTests: XCTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func testConnectToBonjourEndpoint() {
|
||||
let endpoint = NWEndpoint.hostPort(host: "localhost", port: .http)
|
||||
print("Trying to connect to bonjour endpoint \(endpoint)")
|
||||
|
||||
let expectation = XCTestExpectation(description: "MoonrakerSocketManager.connectToBonjourEndpoint opens Starscream socket")
|
||||
// Test connecting to endpoint
|
||||
let connectExpectation = XCTestExpectation(description: "MoonrakerSocketManager.connectToBonjourEndpoint opens Starscream socket")
|
||||
|
||||
cancellable = engine.$startCalled
|
||||
.sink(receiveValue: { newValue in
|
||||
if newValue == true {
|
||||
expectation.fulfill()
|
||||
connectExpectation.fulfill()
|
||||
}
|
||||
})
|
||||
|
||||
socketManager?.connectToBonjourEndpoint(endpoint)
|
||||
wait(for: [expectation], timeout: 2)
|
||||
wait(for: [connectExpectation], timeout: 2)
|
||||
XCTAssertTrue(engine.startCalled)
|
||||
|
||||
// Test screen sleeping
|
||||
engine.resetForNextTest()
|
||||
let screenSleepExpectation = XCTestExpectation(description: "MoonrakerSocketManager.screenChangedSleepState screen sleep triggers Starscream socket disconnection")
|
||||
|
||||
let sleepNotification = Notification(name: NSWorkspace.screensDidSleepNotification)
|
||||
|
||||
cancellable = engine.$stopCalled
|
||||
.sink(receiveValue: { newValue in
|
||||
if newValue == true {
|
||||
screenSleepExpectation.fulfill()
|
||||
}
|
||||
})
|
||||
|
||||
socketManager?.screenChangedSleepState(sleepNotification)
|
||||
wait(for: [screenSleepExpectation], timeout: 2)
|
||||
XCTAssertTrue(engine.stopCalled)
|
||||
|
||||
// Test screen waking
|
||||
engine.resetForNextTest()
|
||||
let screenWakeExpectation = XCTestExpectation(description: "MoonrakerSocketManager.screenChangedSleepState screen wake triggers Starscream socket reconnection")
|
||||
|
||||
let wakeNotification = Notification(name: NSWorkspace.screensDidWakeNotification)
|
||||
|
||||
cancellable = engine.$startCalled
|
||||
.sink(receiveValue: { newValue in
|
||||
if newValue == true {
|
||||
screenWakeExpectation.fulfill()
|
||||
}
|
||||
})
|
||||
|
||||
socketManager?.screenChangedSleepState(wakeNotification)
|
||||
wait(for: [screenWakeExpectation], timeout: 2)
|
||||
XCTAssertTrue(engine.startCalled)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
//
|
||||
// KlipperMonScratchTests.swift
|
||||
// KlipperMonTests
|
||||
//
|
||||
// Created by maddiefuzz on 2/20/23.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
|
||||
class SoyuzScratchTests: XCTestCase {
|
||||
|
||||
func testOneAndOneIsEqual() {
|
||||
let a = 1
|
||||
let b = 1
|
||||
XCTAssertEqual(a, b, "1 did not equal 1.")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user