fix(preview): keep source navigation and canvas interactions responsive
This commit is contained in:
1 parent
107e93b959
commit
77dbb1897f
4 files changed
+685
-22
No files matched your search
@@ -17,6 +17,9 @@ import 'package:cutdex/features/timeline/timeline_asset_drop_target.dart';
|
||||
import 'package:cutdex/features/media/media_asset_drag.dart';
|
||||
|
||||
import 'dart:io';
|
||||
import 'dart:ui' as ui;
|
||||
|
||||
import 'package:flutter/rendering.dart';
|
||||
|
||||
import 'package:cutdex/workspace/timeline_provider.dart';
|
||||
|
||||
@@ -131,6 +134,94 @@ void main() {
|
||||
await root.delete(recursive: true);
|
||||
});
|
||||
|
||||
for (final direction in [-1.0, 1.0]) {
|
||||
testWidgets('single primary clip stays painted off axis $direction', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(
|
||||
ProviderScope(
|
||||
overrides: [
|
||||
projectsProvider.overrideWith(
|
||||
() => _ViewProjects(session, projectId),
|
||||
),
|
||||
editorTimelineProvider(
|
||||
projectId,
|
||||
'project',
|
||||
).overrideWith((ref) => session),
|
||||
],
|
||||
child: MaterialApp(
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
locale: const Locale('zh'),
|
||||
theme: EditorTheme.penDark,
|
||||
home: Scaffold(
|
||||
body: EditorTimelinePanel(
|
||||
projectId: projectId,
|
||||
timelineId: 'project',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
final surface = find.byKey(const Key('editor-timeline-surface'));
|
||||
final origin = tester.getTopLeft(surface);
|
||||
final size = tester.getSize(surface);
|
||||
final viewport = TimelineViewportRect(
|
||||
width: size.width,
|
||||
height: size.height,
|
||||
);
|
||||
final controller = session.view(session.activeSequenceId!);
|
||||
final base = controller.version;
|
||||
final frame = controller.project(viewport);
|
||||
final clipBounds = controller.presentationBoundsAt(frame, 0);
|
||||
final start = Offset(clipBounds.left + 30, clipBounds.center.dy);
|
||||
final gesture = await tester.startGesture(
|
||||
origin + start,
|
||||
kind: PointerDeviceKind.mouse,
|
||||
);
|
||||
await gesture.moveTo(origin + start + Offset(0, 100 * direction));
|
||||
await tester.pump();
|
||||
expect(tester.takeException(), isNull);
|
||||
expect(controller.isDragging, isTrue);
|
||||
expect(controller.dragRejection, isNull);
|
||||
expect(controller.dragGhost, isNotNull);
|
||||
expect(controller.version, same(base));
|
||||
final ghostBounds = controller.dragGhostBounds(
|
||||
controller.dragGhost!,
|
||||
viewport,
|
||||
);
|
||||
final boundary = tester.renderObject<RenderRepaintBoundary>(
|
||||
find.descendant(of: surface, matching: find.byType(RepaintBoundary)),
|
||||
);
|
||||
await tester.runAsync(() async {
|
||||
final image = await boundary.toImage(pixelRatio: 1);
|
||||
try {
|
||||
final bytes = (await image.toByteData(
|
||||
format: ui.ImageByteFormat.rawRgba,
|
||||
))!;
|
||||
final point = Offset(ghostBounds.left + 30, ghostBounds.bottom - 10);
|
||||
final color = TimelineThemeData.of(tester.element(surface))
|
||||
.visualClipColor
|
||||
.toARGB32();
|
||||
expect(
|
||||
bytes.getUint32(
|
||||
(point.dy.toInt() * image.width + point.dx.toInt()) * 4,
|
||||
),
|
||||
((color & 0xffffff) << 8) | (color >> 24),
|
||||
);
|
||||
} finally {
|
||||
image.dispose();
|
||||
}
|
||||
});
|
||||
await gesture.cancel();
|
||||
expect(controller.version, same(base));
|
||||
expect(controller.canUndo, isFalse);
|
||||
await tester.pumpWidget(const SizedBox());
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
}
|
||||
|
||||
for (final connected in [false, true]) {
|
||||
test('detach audio is independent and atomic (connected=$connected)', () async {
|
||||
final id = SequenceId('two');
|
||||
|
||||
Reference in new issue
Block a user