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,228 @@
|
||||
import 'package:cutdex/app/editor_theme.dart';
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:cutdex/features/settings/update_settings.dart';
|
||||
import 'package:cutdex/integrations/app_updates.dart';
|
||||
import 'package:cutdex/l10n/app_localizations.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
tearDown(() {
|
||||
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
|
||||
.setMockMethodCallHandler(appUpdatesChannel, null);
|
||||
});
|
||||
|
||||
Widget app() => MaterialApp(
|
||||
theme: EditorTheme.penLight,
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
home: const Scaffold(body: UpdateSettings()),
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'configured updates check natively and persist automatic checks',
|
||||
(tester) async {
|
||||
var automatic = false;
|
||||
var checks = 0;
|
||||
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
|
||||
.setMockMethodCallHandler(appUpdatesChannel, (call) async {
|
||||
switch (call.method) {
|
||||
case 'status':
|
||||
return {
|
||||
'configured': true,
|
||||
'canCheck': true,
|
||||
'automaticChecks': automatic,
|
||||
'version': '1.0.0',
|
||||
'build': '42',
|
||||
};
|
||||
case 'check':
|
||||
checks++;
|
||||
case 'automaticChecks':
|
||||
automatic = call.arguments as bool;
|
||||
}
|
||||
return null;
|
||||
});
|
||||
await tester.pumpWidget(ProviderScope(child: app()));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('1.0.0 (42)'), findsOneWidget);
|
||||
await tester.tap(find.byKey(const Key('check-for-updates')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(checks, 1);
|
||||
await tester.tap(find.byType(Switch));
|
||||
await tester.pumpAndSettle();
|
||||
expect(automatic, isTrue);
|
||||
},
|
||||
variant: const TargetPlatformVariant({
|
||||
TargetPlatform.macOS,
|
||||
TargetPlatform.windows,
|
||||
}),
|
||||
);
|
||||
|
||||
testWidgets('missing native configuration disables checks', (tester) async {
|
||||
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
|
||||
.setMockMethodCallHandler(
|
||||
appUpdatesChannel,
|
||||
(_) async => {'configured': false},
|
||||
);
|
||||
await tester.pumpWidget(ProviderScope(child: app()));
|
||||
await tester.pumpAndSettle();
|
||||
final button = tester.widget<OutlinedButton>(
|
||||
find.byKey(const Key('check-for-updates')),
|
||||
);
|
||||
expect(button.onPressed, isNull);
|
||||
expect(find.text('Updates are unavailable in this build.'), findsOneWidget);
|
||||
}, variant: TargetPlatformVariant.only(TargetPlatform.macOS));
|
||||
|
||||
testWidgets('native failure is visible and permits retry', (tester) async {
|
||||
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
|
||||
.setMockMethodCallHandler(appUpdatesChannel, (call) async {
|
||||
if (call.method == 'status') {
|
||||
return {'configured': true, 'canCheck': true};
|
||||
}
|
||||
throw PlatformException(code: 'failed');
|
||||
});
|
||||
await tester.pumpWidget(ProviderScope(child: app()));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(const Key('check-for-updates')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
find.text('Could not check for updates. Please try again.'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
tester
|
||||
.widget<OutlinedButton>(find.byKey(const Key('check-for-updates')))
|
||||
.onPressed,
|
||||
isNotNull,
|
||||
);
|
||||
}, variant: TargetPlatformVariant.only(TargetPlatform.macOS));
|
||||
|
||||
testWidgets('Windows download progress leads to an explicit restart action', (
|
||||
tester,
|
||||
) async {
|
||||
var downloads = 0;
|
||||
var status = <String, Object?>{
|
||||
'configured': true,
|
||||
'canCheck': true,
|
||||
'phase': 'available',
|
||||
'availableVersion': '1.0.0-build.2',
|
||||
};
|
||||
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
|
||||
.setMockMethodCallHandler(appUpdatesChannel, (call) async {
|
||||
if (call.method == 'status') return status;
|
||||
if (call.method == 'download') {
|
||||
downloads++;
|
||||
status = {
|
||||
...status,
|
||||
'canCheck': false,
|
||||
'phase': 'downloading',
|
||||
'progress': 35,
|
||||
};
|
||||
}
|
||||
return null;
|
||||
});
|
||||
await tester.pumpWidget(ProviderScope(child: app()));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('install-update')), findsNothing);
|
||||
await tester.tap(find.byKey(const Key('download-update')));
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
expect(downloads, 1);
|
||||
expect(find.text('Downloading update: 35%'), findsOneWidget);
|
||||
expect(
|
||||
tester
|
||||
.widget<OutlinedButton>(find.byKey(const Key('check-for-updates')))
|
||||
.onPressed,
|
||||
isNull,
|
||||
);
|
||||
final message = const StandardMethodCodec().encodeMethodCall(
|
||||
MethodCall('statusChanged', {
|
||||
...status,
|
||||
'phase': 'ready',
|
||||
'progress': 100,
|
||||
'canCheck': true,
|
||||
}),
|
||||
);
|
||||
await TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
|
||||
.handlePlatformMessage(appUpdatesChannel.name, message, (_) {});
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('download-update')), findsNothing);
|
||||
expect(find.text('Restart to update'), findsOneWidget);
|
||||
expect(find.byType(LinearProgressIndicator), findsNothing);
|
||||
}, variant: TargetPlatformVariant.only(TargetPlatform.windows));
|
||||
|
||||
testWidgets('Windows corrupt download exposes retry instead of install', (
|
||||
tester,
|
||||
) async {
|
||||
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
|
||||
.setMockMethodCallHandler(
|
||||
appUpdatesChannel,
|
||||
(call) async => call.method == 'status'
|
||||
? {
|
||||
'configured': true,
|
||||
'canCheck': true,
|
||||
'phase': 'available',
|
||||
'availableVersion': '1.0.0-build.2',
|
||||
'error': 'Checksum failed',
|
||||
}
|
||||
: null,
|
||||
);
|
||||
await tester.pumpWidget(ProviderScope(child: app()));
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
find.text('Could not update. Finish active tasks and try again.'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.byKey(const Key('install-update')), findsNothing);
|
||||
expect(
|
||||
tester
|
||||
.widget<OutlinedButton>(find.byKey(const Key('download-update')))
|
||||
.onPressed,
|
||||
isNotNull,
|
||||
);
|
||||
}, variant: TargetPlatformVariant.only(TargetPlatform.windows));
|
||||
|
||||
testWidgets('late status response preserves the newer Windows update event', (
|
||||
tester,
|
||||
) async {
|
||||
final response = Completer<Map<String, Object?>>();
|
||||
var loads = 0;
|
||||
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
|
||||
.setMockMethodCallHandler(appUpdatesChannel, (call) async {
|
||||
if (call.method == 'status') {
|
||||
if (++loads > 1) return response.future;
|
||||
return {'configured': true, 'canCheck': true};
|
||||
}
|
||||
return null;
|
||||
});
|
||||
await tester.pumpWidget(ProviderScope(child: app()));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(const Key('check-for-updates')));
|
||||
await tester.pump();
|
||||
expect(loads, 2);
|
||||
final message = const StandardMethodCodec().encodeMethodCall(
|
||||
const MethodCall('statusChanged', {
|
||||
'configured': true,
|
||||
'canCheck': true,
|
||||
'phase': 'ready',
|
||||
'availableVersion': '1.0.0-build.2',
|
||||
}),
|
||||
);
|
||||
await TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
|
||||
.handlePlatformMessage(appUpdatesChannel.name, message, (_) {});
|
||||
await tester.pump();
|
||||
response.complete({
|
||||
'configured': true,
|
||||
'canCheck': false,
|
||||
'phase': 'checking',
|
||||
});
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Restart to update'), findsOneWidget);
|
||||
expect(find.text('Checking for updates…'), findsNothing);
|
||||
}, variant: TargetPlatformVariant.only(TargetPlatform.windows));
|
||||
}
|
||||
Reference in new issue
Block a user