import 'dart:ui'; import 'package:cutdex_timeline_ui/cutdex_timeline_ui.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { test( 'adding a header preserves all body regions at their viewport positions', () { for (final audioOnly in [false, true]) { final before = TimelineClipLayout( bounds: const Rect.fromLTWH(25, 64, 240, 76), nameHeight: 16, audioOnly: audioOnly, hasVideoAudio: !audioOnly, ); final after = TimelineClipLayout( bounds: const Rect.fromLTWH(25, 48, 240, 92), headerHeight: 16, nameHeight: 16, audioOnly: audioOnly, hasVideoAudio: !audioOnly, ); for (final pair in [ (before.body, after.body), (before.name, after.name), (before.preview, after.preview), (before.waveformBackground, after.waveformBackground), (before.waveform, after.waveform), ]) { expect(before.toViewport(pair.$1), after.toViewport(pair.$2)); } expect( before.bounds.topLeft + before.keyframeCenter, after.bounds.topLeft + after.keyframeCenter, ); expect(after.header.bottom, after.body.top); expect(after.name.bottom, after.preview.top); if (!audioOnly) { expect(after.preview.bottom, after.waveformBackground.top); expect(after.preview.height, 44); } } }, ); test( 'small clip regions stay inside the clip and omit an undersized waveform', () { for (final width in [0.0, 1.0, 3.0, 20.0]) { for (final height in [0.0, 16.0, 20.0, 35.0]) { for (final audioOnly in [false, true]) { final layout = TimelineClipLayout( bounds: Rect.fromLTWH(-80, 150, width, height), headerHeight: 16, nameHeight: 16, audioOnly: audioOnly, hasVideoAudio: !audioOnly, ); for (final region in [ layout.header, layout.body, layout.bodyPaintBounds, layout.name, layout.preview, layout.waveformBackground, layout.waveform, ]) { expect(region.width, greaterThanOrEqualTo(0)); expect(region.height, greaterThanOrEqualTo(0)); expect(region.left, greaterThanOrEqualTo(0)); expect(region.top, greaterThanOrEqualTo(0)); expect(region.right, lessThanOrEqualTo(width)); expect(region.bottom, lessThanOrEqualTo(height)); } expect(layout.waveform.isEmpty, isTrue); } } } }, ); }