import XCTest import CoreGraphics @testable import 康康 /// 异常项快拍的局部裁剪几何。 /// 回归用例:屏上「宽而矮」的小框,必须裁出「宽 > 高」的照片 rect。 /// 旧实现用 `metadataOutputRectConverted`(传感器横向坐标)套到竖屏照片 → x/y 轴对调, /// 把宽框裁成竖窄条(2026-05-31 真机 bug)。本组用例钉住正确的纯几何映射。 final class RegionImageCropperTests: XCTestCase { /// 竖屏照片 + 竖屏屏幕 + 宽框 → 裁出的 rect 必须是横向(宽 > 高)。 func testWideBoxYieldsLandscapeCropRect() { let photo = CGSize(width: 3024, height: 4032) // 竖屏照片(像素) let view = CGSize(width: 393, height: 852) // 竖屏屏幕(点) let box = RegionFraming.box(in: view) // 宽 84% / 矮 160 let rect = RegionImageCropper.cropRect(photoPixelSize: photo, box: box, in: view) XCTAssertGreaterThan(rect.width, rect.height, "宽框应裁出宽 rect;若 width