Files
suixinkan_ios_new/suixinkanTests/CameraTransfer/SonyPTPCommandsTests.swift
汉秋 d2fe5d71e4 Add TravelAlbum, ProfileSpace, and wired camera transfer modules.
Introduce travel album entry with Sony PTP tethering pipeline, profile space settings page, home routing updates, Launch Screen storyboard, and related tests/docs.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-30 09:41:05 +08:00

64 lines
1.9 KiB
Swift

//
// SonyPTPCommandsTests.swift
// suixinkanTests
//
// Created by Codex on 2026/6/29.
//
import XCTest
@testable import suixinkan
/// Sony PTP
final class SonyPTPCommandsTests: XCTestCase {
/// OpenSession opcode
func testBuildOpenSessionCommand() {
let data = SonyPTPHelper.buildCommand(
code: SonyPTPCommand.openSession,
transactionID: 1,
parameters: [1]
)
XCTAssertEqual(data.count, 16)
XCTAssertEqual(data[6], 0x02)
XCTAssertEqual(data[7], 0x10)
}
/// SDIO Connect opcode
func testBuildSonyConnectCommand() {
let data = SonyPTPHelper.buildCommand(
code: SonyPTPCommand.sdioConnect,
transactionID: 42,
parameters: [1, 0, 0]
)
XCTAssertEqual(data.count, 24)
XCTAssertEqual(data[6], 0x01)
XCTAssertEqual(data[7], 0x92)
}
/// GetObject
func testParseObjectCompressedSize() {
var data = Data(repeating: 0, count: 52)
data[8] = 0x00
data[9] = 0x10
data[10] = 0x00
data[11] = 0x00
XCTAssertEqual(SonyPTPHelper.parseObjectCompressedSize(data), 0x1000)
}
/// SDIE ObjectAdded
func testParseObjectAddedEvent() throws {
var event = Data()
event.append(contentsOf: [0x10, 0x00, 0x00, 0x00])
event.append(contentsOf: [0x04, 0x00])
event.append(contentsOf: [0x01, 0xC2])
event.append(contentsOf: [0xFF, 0xFF, 0xFF, 0xFF])
event.append(contentsOf: [0x01, 0xC0, 0xFF, 0xFF])
let container = try SonyPTPHelper.parseContainer(event)
XCTAssertEqual(container.code, SonyPTPCommand.sdieObjectAdded)
XCTAssertEqual(container.params.first, SonyPTPCommand.shotObjectHandle)
}
}