将 otg_swift OTG 引擎迁入 Core/CameraOTG,并接入旅拍有线传图与历史导入。
恢复 USB 相机连接、边拍边传、三品牌驱动与 SwiftUI 历史导入页,通过适配层对接现有本地上传与 OSS 管道。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
95
suixinkanTests/CameraOTG/PlatformDetectorTests.swift
Normal file
95
suixinkanTests/CameraOTG/PlatformDetectorTests.swift
Normal file
@ -0,0 +1,95 @@
|
||||
//
|
||||
// PlatformDetectorTests.swift
|
||||
// suixinkanTests
|
||||
//
|
||||
|
||||
import XCTest
|
||||
@testable import suixinkan
|
||||
|
||||
/// PlatformDetector USB VID 与型号关键字识别测试。
|
||||
final class PlatformDetectorTests: XCTestCase {
|
||||
/// 测试 Sony USB Vendor ID 识别。
|
||||
func testDetectSonyByVendorID() {
|
||||
let info = CameraDeviceInfo(
|
||||
name: "USB Device",
|
||||
manufacturer: nil,
|
||||
model: nil,
|
||||
serialNumber: nil,
|
||||
usbVendorID: 0x054C,
|
||||
usbProductID: 0x1234
|
||||
)
|
||||
XCTAssertEqual(PlatformDetector.detect(from: info), .sony)
|
||||
}
|
||||
|
||||
/// 测试 Canon USB Vendor ID 识别。
|
||||
func testDetectCanonByVendorID() {
|
||||
let info = CameraDeviceInfo(
|
||||
name: "USB Device",
|
||||
manufacturer: nil,
|
||||
model: nil,
|
||||
serialNumber: nil,
|
||||
usbVendorID: 0x04A9,
|
||||
usbProductID: nil
|
||||
)
|
||||
XCTAssertEqual(PlatformDetector.detect(from: info), .canon)
|
||||
}
|
||||
|
||||
/// 测试 Nikon USB Vendor ID 识别。
|
||||
func testDetectNikonByVendorID() {
|
||||
let info = CameraDeviceInfo(
|
||||
name: "USB Device",
|
||||
manufacturer: nil,
|
||||
model: nil,
|
||||
serialNumber: nil,
|
||||
usbVendorID: 0x04B0,
|
||||
usbProductID: nil
|
||||
)
|
||||
XCTAssertEqual(PlatformDetector.detect(from: info), .nikon)
|
||||
}
|
||||
|
||||
/// 测试 VID 不可用时按设备名关键字兜底识别。
|
||||
func testDetectByDeviceNameKeyword() {
|
||||
let sony = CameraDeviceInfo(
|
||||
name: "ILCE-7M4",
|
||||
manufacturer: nil,
|
||||
model: nil,
|
||||
serialNumber: nil,
|
||||
usbVendorID: nil,
|
||||
usbProductID: nil
|
||||
)
|
||||
XCTAssertEqual(PlatformDetector.detect(from: sony), .sony)
|
||||
|
||||
let canon = CameraDeviceInfo(
|
||||
name: "Canon EOS R5",
|
||||
manufacturer: nil,
|
||||
model: nil,
|
||||
serialNumber: nil,
|
||||
usbVendorID: nil,
|
||||
usbProductID: nil
|
||||
)
|
||||
XCTAssertEqual(PlatformDetector.detect(from: canon), .canon)
|
||||
|
||||
let nikon = CameraDeviceInfo(
|
||||
name: "Nikon Z 8",
|
||||
manufacturer: nil,
|
||||
model: nil,
|
||||
serialNumber: nil,
|
||||
usbVendorID: nil,
|
||||
usbProductID: nil
|
||||
)
|
||||
XCTAssertEqual(PlatformDetector.detect(from: nikon), .nikon)
|
||||
}
|
||||
|
||||
/// 测试无法识别时返回 unknown。
|
||||
func testDetectUnknownWhenNoMatch() {
|
||||
let info = CameraDeviceInfo(
|
||||
name: "Generic Webcam",
|
||||
manufacturer: nil,
|
||||
model: nil,
|
||||
serialNumber: nil,
|
||||
usbVendorID: nil,
|
||||
usbProductID: nil
|
||||
)
|
||||
XCTAssertEqual(PlatformDetector.detect(from: info), .unknown)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user