Files
ichmagmaus111andClaude Opus 5.5 0622057a4f Ghostgram: open-source release
Ghostgram for iOS, rebuilt from scratch on Telegram iOS 13.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 17:57:09 +01:00

31 lines
1.4 KiB
Swift
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#if canImport(UIKit)
import XCTest
@testable import RichTextEditorUIKit
@testable import RichTextEditorCore
@available(iOS 13.0, *)
final class MediaBlockBoxSlideshowTests: XCTestCase {
private func makeBlock(mode: MediaDisplayMode) -> MediaBlock {
// Two portrait items (100×200) and one landscape (100×50). Tallest-fitted-to-width drives slideshow height.
MediaBlock(id: BlockID.generate(),
items: [MediaItem(mediaID: "a", kind: .image, naturalSize: Size2D(width: 100, height: 200)),
MediaItem(mediaID: "b", kind: .image, naturalSize: Size2D(width: 100, height: 50))],
displayMode: mode)
}
private func mapper() -> AttributedStringMapper { AttributedStringMapper() }
func test_slideshowHeight_isTallestItemFittedToWidth() {
let width: CGFloat = 300
let box = MediaBlockBox(media: makeBlock(mode: .slideshow), mapper: mapper(), width: width, horizontalBleed: 0)
// Tallest item 100×200 fitted to width 300 → 600, capped at min(1000, 300) = 300.
XCTAssertEqual(box.imageAreaHeight, 300, accuracy: 0.5)
}
func test_currentBlock_carriesDisplayMode() {
let box = MediaBlockBox(media: makeBlock(mode: .slideshow), mapper: mapper(), width: 300, horizontalBleed: 0)
guard case .media(let m) = box.currentBlock() else { return XCTFail("expected media") }
XCTAssertEqual(m.displayMode, .slideshow)
}
}
#endif