Add the Flutter video editing application with project management, media import, timeline editing, preview, AI assistance, diagnostics and settings. Include shared UI and native host packages, platform runners, application tests and release tooling. Provide usage and contribution guides, the MIT license and third-party notices. Exclude local credentials, build outputs and validation data.
63 lines
2.1 KiB
Dart
63 lines
2.1 KiB
Dart
import 'package:cutdex/app/editor_theme.dart';
|
|
|
|
import 'dart:convert';
|
|
import 'dart:io';
|
|
|
|
import 'package:cutdex/features/assistant/agent_attachment_card.dart';
|
|
import 'package:cutdex/integrations/runtime/media_thumbnails.dart';
|
|
import 'package:cutdex_sdk/project.dart';
|
|
import 'package:cutdex_sdk/runtime.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
void main() {
|
|
testWidgets('a dropped image uses its pixels in the attachment preview', (
|
|
tester,
|
|
) async {
|
|
late AssetDocument asset;
|
|
late MediaThumbnails thumbnails;
|
|
final preview = await tester.runAsync(() async {
|
|
final directory = await Directory.systemTemp.createTemp(
|
|
'cutdex-image-preview-',
|
|
);
|
|
addTearDown(() => directory.delete(recursive: true));
|
|
final file = File('${directory.path}/picture.png');
|
|
await file.writeAsBytes(
|
|
base64Decode(
|
|
'iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAIAAAD91JpzAAAAEElEQVR4nGP4z8AARAwQCgAf7gP9i18U1AAAAABJRU5ErkJggg==',
|
|
),
|
|
);
|
|
asset = AssetDocument(
|
|
id: 'image-1',
|
|
name: 'picture.png',
|
|
storage: AssetStorage.external,
|
|
location: file.uri.toString(),
|
|
metadata: const {'kind': 'image'},
|
|
);
|
|
thumbnails = MediaThumbnails(
|
|
loadMedia: <T>(asset, action) =>
|
|
action(MediaReference(id: asset.id, uri: file.uri, isImage: true)),
|
|
);
|
|
return thumbnails.load(asset);
|
|
});
|
|
expect(preview, isNotNull);
|
|
await tester.pumpWidget(
|
|
ProviderScope(
|
|
overrides: [mediaThumbnailsProvider.overrideWithValue(thumbnails)],
|
|
child: MaterialApp(
|
|
theme: EditorTheme.penDark,
|
|
home: Scaffold(body: AgentAttachmentCard(asset: asset)),
|
|
),
|
|
),
|
|
);
|
|
await tester.runAsync(
|
|
() => Future<void>.delayed(const Duration(milliseconds: 20)),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
expect(find.byType(Image), findsOneWidget);
|
|
expect(find.text('picture.png'), findsOneWidget);
|
|
expect(tester.takeException(), isNull);
|
|
});
|
|
}
|