feat: initial Cutdex application
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.
This commit is contained in:
commit
27e77fff39
718 files changed
+183958
No files matched your search
@@ -0,0 +1,142 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:cutdex/app/editor_theme.dart';
|
||||
import 'package:cutdex/diagnostics/app_diagnostics.dart';
|
||||
import 'package:cutdex/diagnostics/diagnostic_store.dart';
|
||||
import 'package:cutdex/features/settings/diagnostic_settings.dart';
|
||||
import 'package:cutdex/integrations/platform/file_picker.dart';
|
||||
import 'package:cutdex/l10n/app_localizations.dart';
|
||||
import 'package:cutdex/settings/settings_operation.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';
|
||||
|
||||
class _Picker extends AppFilePicker {
|
||||
_Picker(this.destination);
|
||||
final String? destination;
|
||||
@override
|
||||
Future<String?> pickDirectory({
|
||||
String? initialDirectory,
|
||||
String? confirmButtonText,
|
||||
}) async => destination;
|
||||
}
|
||||
|
||||
void main() {
|
||||
late Directory root;
|
||||
setUp(() {
|
||||
root = Directory.systemTemp.createTempSync('cutdex-export-ui-');
|
||||
AppDiagnostics.instance = AppDiagnostics(
|
||||
DiagnosticStore(Directory('${root.path}/logs')),
|
||||
);
|
||||
});
|
||||
tearDown(() async {
|
||||
await AppDiagnostics.instance?.store.flush();
|
||||
AppDiagnostics.instance = null;
|
||||
await root.delete(recursive: true);
|
||||
});
|
||||
Future<ProviderContainer> show(
|
||||
WidgetTester tester,
|
||||
String? destination,
|
||||
) async {
|
||||
final container = ProviderContainer(
|
||||
overrides: [filePickerProvider.overrideWithValue(_Picker(destination))],
|
||||
);
|
||||
addTearDown(container.dispose);
|
||||
await tester.pumpWidget(
|
||||
UncontrolledProviderScope(
|
||||
container: container,
|
||||
child: MaterialApp(
|
||||
theme: EditorTheme.penLight,
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
home: const Scaffold(body: DiagnosticSettings()),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
return container;
|
||||
}
|
||||
|
||||
Future<void> click(WidgetTester tester, ProviderContainer container) async {
|
||||
await tester.runAsync(() async {
|
||||
await tester.tap(find.byKey(const Key('export-diagnostics')));
|
||||
for (
|
||||
var i = 0;
|
||||
i < 2000 &&
|
||||
container
|
||||
.read(settingsOperationProvider('diagnosticsExport'))
|
||||
.isLoading;
|
||||
i++
|
||||
) {
|
||||
await Future<void>.delayed(const Duration(milliseconds: 1));
|
||||
}
|
||||
expect(
|
||||
container
|
||||
.read(settingsOperationProvider('diagnosticsExport'))
|
||||
.isLoading,
|
||||
isFalse,
|
||||
);
|
||||
});
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
testWidgets('exports a diagnostic package into the selected directory', (
|
||||
tester,
|
||||
) async {
|
||||
final container = await show(tester, '${root.path}/export');
|
||||
await tester.runAsync(() async {
|
||||
AppDiagnostics.report(
|
||||
const DiagnosticEvent(
|
||||
component: 'preview',
|
||||
operation: 'test',
|
||||
error: 'Bearer PRIVATE',
|
||||
),
|
||||
);
|
||||
await AppDiagnostics.instance!.store.flush();
|
||||
});
|
||||
await click(tester, container);
|
||||
expect(find.text('Diagnostic package saved.'), findsOneWidget);
|
||||
final directory = Directory('${root.path}/export');
|
||||
final files = directory.listSync().cast<File>().toList();
|
||||
expect(files, hasLength(1));
|
||||
final contents = files.single.readAsStringSync();
|
||||
expect(jsonDecode(contents)['events'], hasLength(1));
|
||||
expect(contents, isNot(contains('PRIVATE')));
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'canceling directory selection leaves no success message or export',
|
||||
(tester) async {
|
||||
final container = await show(tester, null);
|
||||
await click(tester, container);
|
||||
expect(find.text('Diagnostic package saved.'), findsNothing);
|
||||
expect(
|
||||
container.read(settingsOperationProvider('diagnosticsExport')).hasError,
|
||||
isFalse,
|
||||
);
|
||||
expect(root.listSync(), isEmpty);
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('export failures show feedback and leave the button usable', (
|
||||
tester,
|
||||
) async {
|
||||
final blocked = File('${root.path}/blocked')..writeAsStringSync('file');
|
||||
final container = await show(tester, blocked.path);
|
||||
await click(tester, container);
|
||||
expect(
|
||||
find.text('Could not export diagnostics. Please try again.'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
tester
|
||||
.widget<OutlinedButton>(find.byKey(const Key('export-diagnostics')))
|
||||
.onPressed,
|
||||
isNotNull,
|
||||
);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user