fix(album): prevent black screen when switching preview variants
This commit is contained in:
@@ -110,6 +110,60 @@ final class TravelAlbumDetailViewControllerTests: XCTestCase {
|
||||
window.isHidden = true
|
||||
}
|
||||
|
||||
func testPreviewImageViewKeepsViewportConstraintsWhenSwitchingVariant() throws {
|
||||
UIView.setAnimationsEnabled(false)
|
||||
defer { UIView.setAnimationsEnabled(true) }
|
||||
let project = TravelAlbumPreviewProject(
|
||||
originalMaterialId: 1,
|
||||
assets: [
|
||||
TravelAlbumPreviewAsset(
|
||||
id: "original-1",
|
||||
kind: .original,
|
||||
fileURL: "",
|
||||
coverURL: "",
|
||||
fileName: "原图.jpg",
|
||||
fileSize: 0
|
||||
),
|
||||
TravelAlbumPreviewAsset(
|
||||
id: "retouched-1",
|
||||
kind: .retouched,
|
||||
fileURL: "",
|
||||
coverURL: "",
|
||||
fileName: "精修后.jpg",
|
||||
fileSize: 0
|
||||
),
|
||||
]
|
||||
)
|
||||
let controller = TravelAlbumPhotoPreviewViewController(
|
||||
projects: [project],
|
||||
totalCount: 1,
|
||||
startProjectIndex: 0
|
||||
)
|
||||
controller.loadViewIfNeeded()
|
||||
controller.view.frame = CGRect(x: 0, y: 0, width: 390, height: 844)
|
||||
controller.view.layoutIfNeeded()
|
||||
|
||||
let retouchedButton = try XCTUnwrap(
|
||||
controller.view.findSubview {
|
||||
($0 as? UIButton)?.accessibilityLabel == "精修后"
|
||||
} as? UIButton
|
||||
)
|
||||
retouchedButton.sendActions(for: .touchUpInside)
|
||||
controller.view.layoutIfNeeded()
|
||||
|
||||
let imageView = try XCTUnwrap(
|
||||
controller.view.findSubview {
|
||||
$0.accessibilityIdentifier == "travelAlbum.previewImageView"
|
||||
} as? UIImageView
|
||||
)
|
||||
let scrollView = try XCTUnwrap(imageView.superview as? UIScrollView)
|
||||
scrollView.layoutIfNeeded()
|
||||
|
||||
XCTAssertEqual(imageView.bounds.size, scrollView.bounds.size)
|
||||
XCTAssertFalse(imageView.constraintsAffectingLayout(for: .horizontal).isEmpty)
|
||||
XCTAssertFalse(imageView.constraintsAffectingLayout(for: .vertical).isEmpty)
|
||||
}
|
||||
|
||||
func testSelectionModeShowsAIRetouchOnLeftAndDeleteOnRight() async throws {
|
||||
let controller = TravelAlbumDetailViewController(albumId: 0)
|
||||
controller.loadViewIfNeeded()
|
||||
|
||||
Reference in New Issue
Block a user