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.
108 lines
3.6 KiB
Dart
108 lines
3.6 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:cutdex/errors/app_failure.dart';
|
|
import 'package:cutdex/integrations/app_failure_adapter.dart';
|
|
import 'package:cutdex/l10n/l10n.dart';
|
|
import 'package:cutdex/workspace/project_state.dart';
|
|
import 'package:cutdex_sdk/editor.dart';
|
|
import 'package:cutdex_sdk/project.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
void main() {
|
|
test('SDK rejection codes translate regardless of diagnostic wording', () {
|
|
final en = lookupAppLocalizations(const Locale('en'));
|
|
final zh = lookupAppLocalizations(const Locale('zh'));
|
|
for (final diagnostic in [
|
|
'Old wording',
|
|
'Different punctuation!',
|
|
'任意描述',
|
|
]) {
|
|
final failure = appFailureFromError(
|
|
CommandRejected('missingMedia', diagnostic),
|
|
);
|
|
expect(failure.code, AppErrorCode.mediaNoLongerExists);
|
|
expect(failure.diagnostic, diagnostic);
|
|
expect(en.failureMessage(failure), en.mediaNoLongerExists);
|
|
expect(zh.failureMessage(failure), zh.mediaNoLongerExists);
|
|
}
|
|
expect(
|
|
appFailureFromError(const CommandRejected('staleVersion', 'Changed'))
|
|
.code,
|
|
AppErrorCode.timelineChanged,
|
|
);
|
|
expect(
|
|
appFailureFromError(
|
|
const ProjectFileException(ProjectFileError.notFound, 'Any wording'),
|
|
).code,
|
|
AppErrorCode.projectMissingDirectory,
|
|
);
|
|
});
|
|
|
|
test(
|
|
'unknown diagnostics are preserved without guessing from their wording',
|
|
() {
|
|
final en = lookupAppLocalizations(const Locale('en'));
|
|
const error = CommandRejected('futureCode', '素材已不存在');
|
|
expect(appFailureFromError(error).code, AppErrorCode.diagnostic);
|
|
expect(en.errorMessage(error), error.message);
|
|
final io = const FileSystemException('Native detail', '/missing');
|
|
final failure = projectFailureFromError(io);
|
|
expect(failure.code, AppErrorCode.projectAccessFailed);
|
|
expect(failure.diagnostic, io.toString());
|
|
expect(en.failureMessage(failure), en.projectAccessFailed);
|
|
},
|
|
);
|
|
|
|
test(
|
|
'project location actions depend on the code, not the displayed text',
|
|
() {
|
|
const failure = AppFailure(
|
|
AppErrorCode.projectLocationUnavailable,
|
|
diagnostic: 'No Chinese keywords',
|
|
);
|
|
expect(failure.requiresProjectLocation, isTrue);
|
|
expect(
|
|
const AppFailure(
|
|
AppErrorCode.diagnostic,
|
|
diagnostic: '项目位置 保存位置',
|
|
).requiresProjectLocation,
|
|
isFalse,
|
|
);
|
|
},
|
|
);
|
|
|
|
testWidgets(
|
|
'an existing error follows locale changes without changing state',
|
|
(tester) async {
|
|
const state = ProjectState(
|
|
error: AppFailure(
|
|
AppErrorCode.mediaReadFailed,
|
|
diagnostic: 'Low-level read failure',
|
|
),
|
|
);
|
|
Widget view(Locale locale) => MaterialApp(
|
|
locale: locale,
|
|
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
|
supportedLocales: AppLocalizations.supportedLocales,
|
|
home: Builder(
|
|
builder: (context) => Text(context.l10n.failureMessage(state.error!)),
|
|
),
|
|
);
|
|
await tester.pumpWidget(view(const Locale('en')));
|
|
await tester.pumpAndSettle();
|
|
expect(
|
|
find.text(lookupAppLocalizations(const Locale('en')).mediaReadFailed),
|
|
findsOneWidget,
|
|
);
|
|
await tester.pumpWidget(view(const Locale('zh')));
|
|
await tester.pumpAndSettle();
|
|
expect(
|
|
find.text(lookupAppLocalizations(const Locale('zh')).mediaReadFailed),
|
|
findsOneWidget,
|
|
);
|
|
expect(state.error!.diagnostic, 'Low-level read failure');
|
|
},
|
|
);
|
|
}
|