test: 完成机巢任务界面的真机回归

任务页按已确认的本地状态及门禁文案校验,待确认场景保留后端完整说明并禁止操作。到达态布局测试使用真实窗口宿主,核对30、29、0秒时按钮图文包含和居中。

验证:160项相关用例在iPhone 11分组回归通过,包含通用Loading、到达态、倒计时、图传接收与几何日志;git diff --check通过。生产代码保持不变。
This commit is contained in:
2026-11-05 08:49:35 +08:00
parent 3882a0d4c6
commit 7d69a8ae7e
2 changed files with 42 additions and 7 deletions
@@ -142,13 +142,25 @@ final class DroneDockTaskFixedLayoutTests: XCTestCase {
}
/// 到达面板采用蓝色圆勾与三级文案,保留完整秒数、整行按钮和实际可点击区域。
func testReadyPanelMatchesPrototypeAndKeepsCountdownActionTappable() throws {
func testReadyPanelMatchesPrototypeAndKeepsCountdownActionTappable() async throws {
let scene = UIApplication.shared.connectedScenes.compactMap { $0 as? UIWindowScene }.first
let previous = scene?.windows.first { $0.isKeyWindow }
let window = scene.map { UIWindow(windowScene: $0) } ?? UIWindow(frame: UIScreen.main.bounds)
let host = UIViewController()
window.rootViewController = host
window.makeKeyAndVisible()
defer { window.isHidden = true; window.rootViewController = nil; previous?.makeKeyAndVisible() }
for size in [CGSize(width: 320, height: 146), compactSize, regularSize] {
let status = makeStatus(size: size)
host.view.addSubview(status)
defer { status.removeFromSuperview() }
let ready = DroneDockTaskPresentation(phase: .ready, title: "无人机已到达",
message: "确认游客站位与取景后开始", deviceStatus: "设备摘要不应显示", action: .start,
actionTitle: "开始拍摄", isActionEnabled: true, countdownSeconds: 30)
apply(ready, to: status)
window.layoutIfNeeded()
try await Task.sleep(for: .milliseconds(50))
layoutHierarchy(status)
let title = try XCTUnwrap(find(in: status, suffix: "statusTitle") as? UILabel)
let prompt = try XCTUnwrap(find(in: status, suffix: "readyPrompt") as? UILabel)
let message = try XCTUnwrap(find(in: status, suffix: "statusMessage") as? UILabel)
@@ -174,8 +186,18 @@ final class DroneDockTaskFixedLayoutTests: XCTestCase {
let initialFrame = button.convert(button.bounds, to: status)
for (index, seconds) in [30, 29, 0].enumerated() {
status.updateCountdown(seconds: seconds)
window.layoutIfNeeded()
try await Task.sleep(for: .milliseconds(50))
layoutHierarchy(status)
try assertFullButtonTitle("开始拍摄(\(seconds)s)", button: button)
let text = try XCTUnwrap(button.titleLabel)
let image = try XCTUnwrap(button.imageView)
XCTAssertFalse(image.bounds.isEmpty)
assertContained(text, in: button)
assertContained(image, in: button)
let contentFrame = text.convert(text.bounds, to: button).union(image.convert(image.bounds, to: button))
XCTAssertEqual(contentFrame.midX, button.bounds.midX, accuracy: 1, "开拍图标与文字整体水平居中")
XCTAssertEqual(contentFrame.midY, button.bounds.midY, accuracy: 2, "开拍图标与文字整体垂直居中")
XCTAssertTrue(button.isEnabled)
XCTAssertEqual(button.convert(button.bounds, to: status), initialFrame)
let center = button.convert(CGPoint(x: button.bounds.midX, y: button.bounds.midY), to: status)