feat(workspace): 桌面工作区、主题与交互更新,发布 0.1.2
Gitea CI / Check code and tests (push) Successful in 6m37s
Gitea CI / Build Windows x64 app (push) Successful in 3m18s
Gitea CI / Build Android APK (push) Successful in 3m47s
Gitea CI / Audit and package Windows x64 (push) Successful in 1m7s
Gitea CI / Assemble and validate CI artifacts (push) Successful in 50s
Gitea CI / Gitea CI passed (push) Successful in 2s
Gitea Release / Prepare draft Release (push) Successful in 9s
Gitea Release / Upload Android to draft Release (push) Successful in 16s
Gitea Release / Upload Windows to draft Release (push) Successful in 22s
Gitea Release / Verify and publish Release (push) Successful in 14s
Gitea CI / Check code and tests (push) Successful in 6m37s
Gitea CI / Build Windows x64 app (push) Successful in 3m18s
Gitea CI / Build Android APK (push) Successful in 3m47s
Gitea CI / Audit and package Windows x64 (push) Successful in 1m7s
Gitea CI / Assemble and validate CI artifacts (push) Successful in 50s
Gitea CI / Gitea CI passed (push) Successful in 2s
Gitea Release / Prepare draft Release (push) Successful in 9s
Gitea Release / Upload Android to draft Release (push) Successful in 16s
Gitea Release / Upload Windows to draft Release (push) Successful in 22s
Gitea Release / Verify and publish Release (push) Successful in 14s
This commit was merged in pull request #13.
This commit is contained in:
1 parent
aa5255d1e4
commit
abc1868550
260 files changed
+43964
-5591
No files matched your search
+378
-349
@@ -5,6 +5,7 @@ import 'package:crypto/crypto.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:cutdex/integrations/runtime/processing_resource_repository.dart';
|
||||
import 'package:cutdex/l10n/app_localizations.dart';
|
||||
import 'package:cutdex_ui/icons.dart';
|
||||
import 'package:cutdex_ui/theme.dart';
|
||||
import 'package:cutdex_ui/widgets.dart';
|
||||
|
||||
@@ -1763,156 +1764,230 @@ void main() {
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'MCP caption edit updates visible fields and undo restores them',
|
||||
(tester) async {
|
||||
late String id;
|
||||
await tester.runAsync(() async {
|
||||
final task = await applyFixture();
|
||||
final result = await session.applyTranscription(
|
||||
sequence,
|
||||
ApplyTranscription(taskId: task, clipId: 'clip'),
|
||||
);
|
||||
id = (result['captionIds'] as List).single as String;
|
||||
});
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
locale: const Locale('zh'),
|
||||
for (final desktop in [false, true]) {
|
||||
testWidgets(
|
||||
'MCP caption edit desktop=$desktop updates visible fields and undo restores them',
|
||||
(tester) async {
|
||||
late String id;
|
||||
await tester.runAsync(() async {
|
||||
final task = await applyFixture();
|
||||
final result = await session.applyTranscription(
|
||||
sequence,
|
||||
ApplyTranscription(taskId: task, clipId: 'clip'),
|
||||
);
|
||||
id = (result['captionIds'] as List).single as String;
|
||||
});
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
locale: const Locale('zh'),
|
||||
theme: desktop
|
||||
? AppTheme.propertiesPanelTheme(
|
||||
EditorTheme.desktop(EditorTheme.penDark),
|
||||
)
|
||||
: EditorTheme.penDark,
|
||||
|
||||
home: Scaffold(
|
||||
body: Align(
|
||||
alignment: Alignment.topRight,
|
||||
child: SizedBox(
|
||||
width: 280,
|
||||
child: CaptionProperties(
|
||||
session: session,
|
||||
sequence: sequence,
|
||||
clipId: id,
|
||||
home: Scaffold(
|
||||
body: Align(
|
||||
alignment: Alignment.topRight,
|
||||
child: SizedBox(
|
||||
width: 280,
|
||||
child: CaptionProperties(
|
||||
session: session,
|
||||
sequence: sequence,
|
||||
clipId: id,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
expect(find.text('测试字幕'), findsOneWidget);
|
||||
expect(
|
||||
find.ancestor(of: find.text('测试字幕'), matching: find.byType(ShaderMask)),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
find.byKey(const ValueKey('caption-property-tab-captions')),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
find.byKey(const ValueKey('caption-property-tab-text')),
|
||||
findsOneWidget,
|
||||
);
|
||||
for (final key in const [
|
||||
'caption-fontSize',
|
||||
'caption-strokeWidth',
|
||||
'caption-positionY',
|
||||
'caption-start',
|
||||
'caption-duration',
|
||||
]) {
|
||||
expect(find.byKey(Key(key)), findsOneWidget);
|
||||
}
|
||||
expect(find.text('描边颜色'), findsOneWidget);
|
||||
await tester.runAsync(() async {
|
||||
session.setCaption(
|
||||
sequence,
|
||||
SetCaption(
|
||||
captionId: id,
|
||||
start: CommandTime(1, 1000),
|
||||
duration: CommandTime(1, 1000),
|
||||
positionY: -.298,
|
||||
);
|
||||
expect(find.text('测试字幕'), findsOneWidget);
|
||||
expect(
|
||||
find.ancestor(
|
||||
of: find.text('测试字幕'),
|
||||
matching: find.byType(ShaderMask),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
find.byKey(const ValueKey('caption-property-tab-captions')),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
find.byKey(const ValueKey('caption-property-tab-text')),
|
||||
findsOneWidget,
|
||||
);
|
||||
for (final key in const [
|
||||
'caption-fontSize',
|
||||
'caption-strokeWidth',
|
||||
'caption-positionY',
|
||||
'caption-start',
|
||||
'caption-duration',
|
||||
]) {
|
||||
expect(find.byKey(Key(key)), findsOneWidget);
|
||||
}
|
||||
expect(find.text('描边颜色'), findsOneWidget);
|
||||
await tester.runAsync(() async {
|
||||
session.setCaption(
|
||||
sequence,
|
||||
SetCaption(
|
||||
captionId: id,
|
||||
start: CommandTime(1, 1000),
|
||||
duration: CommandTime(1, 1000),
|
||||
positionY: -.298,
|
||||
),
|
||||
);
|
||||
await session.flush();
|
||||
});
|
||||
await tester.pump();
|
||||
String fieldText(String key) => tester
|
||||
.widget<TextField>(
|
||||
find.descendant(
|
||||
of: find.byKey(ValueKey(key)),
|
||||
matching: find.byType(TextField),
|
||||
),
|
||||
)
|
||||
.controller!
|
||||
.text;
|
||||
expect(fieldText('caption-start'), '0.001');
|
||||
expect(fieldText('caption-duration'), '0.001');
|
||||
expect(fieldText('caption-positionY'), '-0.298');
|
||||
await tester.runAsync(() async => session.undo(sequence));
|
||||
await tester.pump();
|
||||
|
||||
await tester.tap(
|
||||
find.byKey(const ValueKey('caption-property-tab-captions')),
|
||||
);
|
||||
await tester.pump();
|
||||
expect(find.byKey(ValueKey('caption-list-$id')), findsOneWidget);
|
||||
expect(find.byKey(const Key('caption-fontSize')), findsNothing);
|
||||
await tester.tap(find.byKey(ValueKey('caption-list-$id')));
|
||||
await tester.pump();
|
||||
expect(find.byKey(ValueKey('caption-list-$id')), findsOneWidget);
|
||||
expect(find.byKey(const Key('caption-fontSize')), findsNothing);
|
||||
await tester.tap(
|
||||
find.byKey(const ValueKey('caption-property-tab-text')),
|
||||
);
|
||||
await tester.pump();
|
||||
expect(find.byKey(const Key('caption-fontSize')), findsOneWidget);
|
||||
final versionBeforeScrub = session.version;
|
||||
await tester.drag(find.text('字号'), const Offset(50, 0));
|
||||
await tester.pump();
|
||||
expect(session.caption(sequence, id).fontSize, closeTo(58, 1e-9));
|
||||
expect(session.version, isNot(versionBeforeScrub));
|
||||
await tester.runAsync(() async => session.undo(sequence));
|
||||
await tester.pump();
|
||||
expect(session.caption(sequence, id).fontSize, 48);
|
||||
final access = EditorToolAccess(session);
|
||||
addTearDown(access.dispose);
|
||||
final connection = access.server.connect();
|
||||
addTearDown(connection.close);
|
||||
final response = await tester.runAsync(
|
||||
() => connection.handleJson(
|
||||
jsonEncode({
|
||||
'jsonrpc': '2.0',
|
||||
'id': 1,
|
||||
'method': 'tools/call',
|
||||
'params': {
|
||||
'_meta': {
|
||||
'io.modelcontextprotocol/protocolVersion': '2026-07-28',
|
||||
'io.modelcontextprotocol/clientCapabilities':
|
||||
<String, Object?>{},
|
||||
},
|
||||
'name': 'caption.set',
|
||||
'arguments': {
|
||||
'workspaceId': access.workspaces.keys.single,
|
||||
'operationId': 'mcp-text',
|
||||
'captionId': id,
|
||||
'text': '来自 MCP 的字幕',
|
||||
'strokeColor': '#FF0000',
|
||||
'strokeWidth': 2,
|
||||
},
|
||||
},
|
||||
}),
|
||||
),
|
||||
);
|
||||
await session.flush();
|
||||
});
|
||||
await tester.pump();
|
||||
String fieldText(String key) => tester
|
||||
.widget<TextField>(
|
||||
find.descendant(
|
||||
of: find.byKey(ValueKey(key)),
|
||||
matching: find.byType(TextField),
|
||||
),
|
||||
)
|
||||
.controller!
|
||||
.text;
|
||||
expect(fieldText('caption-start'), '0.001');
|
||||
expect(fieldText('caption-duration'), '0.001');
|
||||
expect(fieldText('caption-positionY'), '-0.298');
|
||||
await tester.runAsync(() async => session.undo(sequence));
|
||||
await tester.pump();
|
||||
expect(response.toString(), contains('来自 MCP 的字幕'));
|
||||
await tester.pump();
|
||||
expect(find.text('来自 MCP 的字幕'), findsOneWidget);
|
||||
expect(session.caption(sequence, id).strokeColor, '#FF0000');
|
||||
expect(session.caption(sequence, id).strokeWidth, 2);
|
||||
await tester.runAsync(() async {
|
||||
session.undo(sequence);
|
||||
});
|
||||
await tester.pump();
|
||||
expect(find.text('测试字幕'), findsOneWidget);
|
||||
final role = session.captionRole(sequence)!;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
locale: const Locale('zh'),
|
||||
|
||||
await tester.tap(
|
||||
find.byKey(const ValueKey('caption-property-tab-captions')),
|
||||
);
|
||||
await tester.pump();
|
||||
expect(find.byKey(ValueKey('caption-list-$id')), findsOneWidget);
|
||||
expect(find.byKey(const Key('caption-fontSize')), findsNothing);
|
||||
await tester.tap(find.byKey(ValueKey('caption-list-$id')));
|
||||
await tester.pump();
|
||||
expect(find.byKey(ValueKey('caption-list-$id')), findsOneWidget);
|
||||
expect(find.byKey(const Key('caption-fontSize')), findsNothing);
|
||||
await tester.tap(find.byKey(const ValueKey('caption-property-tab-text')));
|
||||
await tester.pump();
|
||||
expect(find.byKey(const Key('caption-fontSize')), findsOneWidget);
|
||||
final versionBeforeScrub = session.version;
|
||||
await tester.drag(find.text('字号'), const Offset(50, 0));
|
||||
await tester.pump();
|
||||
expect(session.caption(sequence, id).fontSize, closeTo(58, 1e-9));
|
||||
expect(session.version, isNot(versionBeforeScrub));
|
||||
await tester.runAsync(() async => session.undo(sequence));
|
||||
await tester.pump();
|
||||
expect(session.caption(sequence, id).fontSize, 48);
|
||||
final access = EditorToolAccess(session);
|
||||
addTearDown(access.dispose);
|
||||
final connection = access.server.connect();
|
||||
addTearDown(connection.close);
|
||||
final response = await tester.runAsync(
|
||||
() => connection.handleJson(
|
||||
jsonEncode({
|
||||
'jsonrpc': '2.0',
|
||||
'id': 1,
|
||||
'method': 'tools/call',
|
||||
'params': {
|
||||
'_meta': {
|
||||
'io.modelcontextprotocol/protocolVersion': '2026-07-28',
|
||||
'io.modelcontextprotocol/clientCapabilities':
|
||||
<String, Object?>{},
|
||||
},
|
||||
'name': 'caption.set',
|
||||
'arguments': {
|
||||
'workspaceId': access.workspaces.keys.single,
|
||||
'operationId': 'mcp-text',
|
||||
'captionId': id,
|
||||
'text': '来自 MCP 的字幕',
|
||||
'strokeColor': '#FF0000',
|
||||
'strokeWidth': 2,
|
||||
},
|
||||
},
|
||||
}),
|
||||
),
|
||||
);
|
||||
expect(response.toString(), contains('来自 MCP 的字幕'));
|
||||
await tester.pump();
|
||||
expect(find.text('来自 MCP 的字幕'), findsOneWidget);
|
||||
expect(session.caption(sequence, id).strokeColor, '#FF0000');
|
||||
expect(session.caption(sequence, id).strokeWidth, 2);
|
||||
await tester.runAsync(() async {
|
||||
session.undo(sequence);
|
||||
});
|
||||
await tester.pump();
|
||||
expect(find.text('测试字幕'), findsOneWidget);
|
||||
final role = session.captionRole(sequence)!;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: SizedBox(
|
||||
width: 280,
|
||||
child: CaptionProperties(
|
||||
session: session,
|
||||
sequence: sequence,
|
||||
clipId: session.persistence
|
||||
.timeline(sequence)
|
||||
.current
|
||||
.query()
|
||||
.element(role)
|
||||
.id
|
||||
.value,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
expect(
|
||||
find.byKey(const ValueKey('caption-property-tab-captions')),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
find.byKey(const ValueKey('caption-property-tab-text')),
|
||||
findsNothing,
|
||||
);
|
||||
expect(find.byKey(ValueKey('caption-list-$id')), findsOneWidget);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
for (final desktop in [false, true]) {
|
||||
testWidgets(
|
||||
'caption overview desktop=$desktop selects the chosen text cue',
|
||||
(tester) async {
|
||||
await tester.binding.setSurfaceSize(const Size(280, 240));
|
||||
addTearDown(() => tester.binding.setSurfaceSize(null));
|
||||
late String firstId;
|
||||
late String secondId;
|
||||
await tester.runAsync(() async {
|
||||
final task = await applyFixture();
|
||||
final first = await session.applyTranscription(
|
||||
sequence,
|
||||
ApplyTranscription(taskId: task, clipId: 'clip'),
|
||||
);
|
||||
final second = await session.applyTranscription(
|
||||
sequence,
|
||||
ApplyTranscription(taskId: task, clipId: 'clip'),
|
||||
);
|
||||
firstId = (first['captionIds'] as List).single as String;
|
||||
secondId = (second['captionIds'] as List).single as String;
|
||||
});
|
||||
Widget panel(String clipId) => MaterialApp(
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
locale: const Locale('zh'),
|
||||
theme: desktop
|
||||
? AppTheme.propertiesPanelTheme(
|
||||
EditorTheme.desktop(EditorTheme.penDark),
|
||||
)
|
||||
: EditorTheme.penDark,
|
||||
|
||||
home: Scaffold(
|
||||
body: SizedBox(
|
||||
@@ -1920,220 +1995,174 @@ void main() {
|
||||
child: CaptionProperties(
|
||||
session: session,
|
||||
sequence: sequence,
|
||||
clipId: session.persistence
|
||||
.timeline(sequence)
|
||||
.current
|
||||
.query()
|
||||
.element(role)
|
||||
.id
|
||||
.value,
|
||||
clipId: clipId,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
expect(
|
||||
find.byKey(const ValueKey('caption-property-tab-captions')),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
find.byKey(const ValueKey('caption-property-tab-text')),
|
||||
findsNothing,
|
||||
);
|
||||
expect(find.byKey(ValueKey('caption-list-$id')), findsOneWidget);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
},
|
||||
);
|
||||
);
|
||||
await tester.pumpWidget(panel(firstId));
|
||||
await tester.tap(
|
||||
find.byKey(const ValueKey('caption-property-tab-captions')),
|
||||
);
|
||||
await tester.pump();
|
||||
for (final id in [firstId, secondId]) {
|
||||
final row = tester.getRect(find.byKey(ValueKey('caption-list-$id')));
|
||||
final number = tester.getRect(
|
||||
find.byKey(ValueKey('caption-number-$id')),
|
||||
);
|
||||
final content = tester.getRect(
|
||||
find.byKey(ValueKey('caption-content-$id')),
|
||||
);
|
||||
final action = tester.getRect(
|
||||
find.byKey(ValueKey('caption-action-$id')),
|
||||
);
|
||||
expect(row.height, 28);
|
||||
final list = tester.getRect(
|
||||
find.ancestor(
|
||||
of: find.byKey(ValueKey('caption-list-$id')),
|
||||
matching: find.byType(ListView),
|
||||
),
|
||||
);
|
||||
expect(row.left - list.left, desktop ? 12 : 14);
|
||||
expect(number.left - row.left, 0);
|
||||
expect(content.left - number.right, 6);
|
||||
expect(number.right, lessThan(content.left));
|
||||
expect(content.right, lessThan(action.left));
|
||||
expect(number.center.dy, closeTo(content.center.dy, 0.1));
|
||||
expect(content.center.dy, closeTo(action.center.dy, 0.1));
|
||||
expect(action.right, lessThanOrEqualTo(row.right));
|
||||
}
|
||||
await tester.runAsync(() async {
|
||||
session.setCaption(
|
||||
sequence,
|
||||
SetCaption(captionId: secondId, text: 'Searchable CAPTION ' * 20),
|
||||
);
|
||||
await session.flush();
|
||||
});
|
||||
await tester.pump();
|
||||
final search = find.byKey(const ValueKey('caption-search'));
|
||||
final searchBounds = tester.getRect(search);
|
||||
final wrapBounds = tester.getRect(
|
||||
find.byKey(const ValueKey('caption-wrap-toggle')),
|
||||
);
|
||||
expect(searchBounds.height, 28);
|
||||
expect(wrapBounds.height, desktop ? 24 : 28);
|
||||
expect(searchBounds.center.dy, wrapBounds.center.dy);
|
||||
await tester.enterText(search, ' searchable ');
|
||||
await tester.pump();
|
||||
expect(find.byKey(ValueKey('caption-list-$firstId')), findsNothing);
|
||||
expect(find.byKey(ValueKey('caption-list-$secondId')), findsOneWidget);
|
||||
expect(
|
||||
tester
|
||||
.widget<Text>(find.byKey(ValueKey('caption-number-$secondId')))
|
||||
.data,
|
||||
'2',
|
||||
);
|
||||
expect(
|
||||
tester.getSize(find.byKey(ValueKey('caption-list-$secondId'))).height,
|
||||
28,
|
||||
);
|
||||
await tester.enterText(search, 'no such caption');
|
||||
await tester.pump();
|
||||
expect(find.text('没有匹配的字幕'), findsOneWidget);
|
||||
await tester.enterText(search, '');
|
||||
await tester.pump();
|
||||
expect(find.byKey(ValueKey('caption-list-$firstId')), findsOneWidget);
|
||||
final toolbarPosition = tester.getTopLeft(search);
|
||||
await tester.tap(find.byKey(const ValueKey('caption-wrap-toggle')));
|
||||
await tester.pump();
|
||||
expect(
|
||||
tester.getSize(find.byKey(ValueKey('caption-list-$secondId'))).height,
|
||||
greaterThan(28),
|
||||
);
|
||||
expect(tester.getTopLeft(search), toolbarPosition);
|
||||
final list = find.byKey(const ValueKey('caption-scroll-list'));
|
||||
expect(list, findsOneWidget);
|
||||
expect(
|
||||
find.ancestor(of: search, matching: find.byType(ShaderMask)),
|
||||
findsNothing,
|
||||
);
|
||||
expect(
|
||||
find.ancestor(of: list, matching: find.byType(ShaderMask)),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
tester.widget<ListView>(list).physics,
|
||||
isA<ClampingScrollPhysics>(),
|
||||
);
|
||||
final scroll = tester
|
||||
.state<ScrollableState>(
|
||||
find.descendant(of: list, matching: find.byType(Scrollable)),
|
||||
)
|
||||
.position;
|
||||
expect(scroll.extentBefore, 0);
|
||||
expect(scroll.extentAfter, greaterThan(24));
|
||||
await tester.drag(list, const Offset(0, -60));
|
||||
await tester.pumpAndSettle();
|
||||
expect(scroll.pixels, greaterThan(0));
|
||||
scroll.jumpTo(scroll.maxScrollExtent / 2);
|
||||
await tester.pumpAndSettle();
|
||||
expect(scroll.extentBefore, greaterThan(0));
|
||||
expect(scroll.extentAfter, greaterThan(0));
|
||||
scroll.jumpTo(scroll.maxScrollExtent);
|
||||
await tester.pumpAndSettle();
|
||||
expect(scroll.extentAfter, 0);
|
||||
expect(tester.getTopLeft(search), toolbarPosition);
|
||||
expect(tester.takeException(), isNull);
|
||||
await tester.tap(find.byKey(const ValueKey('caption-wrap-toggle')));
|
||||
await tester.pump();
|
||||
expect(
|
||||
tester.getSize(find.byKey(ValueKey('caption-list-$secondId'))).height,
|
||||
28,
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(scroll.extentAfter, 0);
|
||||
expect(scroll.extentBefore, 0);
|
||||
await tester.tap(find.byKey(ValueKey('caption-action-$secondId')));
|
||||
await tester.pump();
|
||||
|
||||
testWidgets('caption overview selects the chosen text cue', (tester) async {
|
||||
await tester.binding.setSurfaceSize(const Size(280, 240));
|
||||
addTearDown(() => tester.binding.setSurfaceSize(null));
|
||||
late String firstId;
|
||||
late String secondId;
|
||||
await tester.runAsync(() async {
|
||||
final task = await applyFixture();
|
||||
final first = await session.applyTranscription(
|
||||
sequence,
|
||||
ApplyTranscription(taskId: task, clipId: 'clip'),
|
||||
);
|
||||
final second = await session.applyTranscription(
|
||||
sequence,
|
||||
ApplyTranscription(taskId: task, clipId: 'clip'),
|
||||
);
|
||||
firstId = (first['captionIds'] as List).single as String;
|
||||
secondId = (second['captionIds'] as List).single as String;
|
||||
});
|
||||
Widget panel(String clipId) => MaterialApp(
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
locale: const Locale('zh'),
|
||||
|
||||
home: Scaffold(
|
||||
body: SizedBox(
|
||||
width: 280,
|
||||
child: CaptionProperties(
|
||||
session: session,
|
||||
sequence: sequence,
|
||||
clipId: clipId,
|
||||
final identity = session.view(sequence).selectedIdentities.single;
|
||||
expect(identity, isA<LayoutBodyId>());
|
||||
final selected = session.resolveCaptionComponent(
|
||||
sequence,
|
||||
identity as LayoutBodyId,
|
||||
);
|
||||
expect(
|
||||
session.persistence
|
||||
.timeline(sequence)
|
||||
.current
|
||||
.query()
|
||||
.element(selected!)
|
||||
.id
|
||||
.value,
|
||||
secondId,
|
||||
);
|
||||
await tester.pumpWidget(panel(secondId));
|
||||
await tester.pumpAndSettle();
|
||||
final selectedRow = find.byKey(ValueKey('caption-list-$secondId'));
|
||||
expect(selectedRow, findsOneWidget);
|
||||
expect(find.byKey(const ValueKey('caption-search')), findsOneWidget);
|
||||
expect(find.byKey(const Key('caption-fontSize')), findsNothing);
|
||||
final selectedColor = Theme.of(tester.element(selectedRow))
|
||||
.colorScheme
|
||||
.onSurface
|
||||
.withValues(alpha: .05);
|
||||
expect(
|
||||
find.ancestor(
|
||||
of: selectedRow,
|
||||
matching: find.byWidgetPredicate(
|
||||
(widget) => widget is Material && widget.color == selectedColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
await tester.tap(selectedRow);
|
||||
await tester.pump();
|
||||
expect(selectedRow, findsOneWidget);
|
||||
expect(find.byKey(const Key('caption-fontSize')), findsNothing);
|
||||
},
|
||||
);
|
||||
await tester.pumpWidget(panel(firstId));
|
||||
await tester.tap(
|
||||
find.byKey(const ValueKey('caption-property-tab-captions')),
|
||||
);
|
||||
await tester.pump();
|
||||
for (final id in [firstId, secondId]) {
|
||||
final row = tester.getRect(find.byKey(ValueKey('caption-list-$id')));
|
||||
final number = tester.getRect(find.byKey(ValueKey('caption-number-$id')));
|
||||
final content = tester.getRect(
|
||||
find.byKey(ValueKey('caption-content-$id')),
|
||||
);
|
||||
final action = tester.getRect(find.byKey(ValueKey('caption-action-$id')));
|
||||
expect(row.height, 28);
|
||||
final list = tester.getRect(
|
||||
find.ancestor(
|
||||
of: find.byKey(ValueKey('caption-list-$id')),
|
||||
matching: find.byType(ListView),
|
||||
),
|
||||
);
|
||||
expect(row.left - list.left, 14);
|
||||
expect(number.left - row.left, 0);
|
||||
expect(content.left - number.right, 6);
|
||||
expect(number.right, lessThan(content.left));
|
||||
expect(content.right, lessThan(action.left));
|
||||
expect(number.center.dy, closeTo(content.center.dy, 0.1));
|
||||
expect(content.center.dy, closeTo(action.center.dy, 0.1));
|
||||
expect(action.right, lessThanOrEqualTo(row.right));
|
||||
}
|
||||
await tester.runAsync(() async {
|
||||
session.setCaption(
|
||||
sequence,
|
||||
SetCaption(captionId: secondId, text: 'Searchable CAPTION ' * 20),
|
||||
);
|
||||
await session.flush();
|
||||
});
|
||||
await tester.pump();
|
||||
final search = find.byKey(const ValueKey('caption-search'));
|
||||
final searchBounds = tester.getRect(search);
|
||||
final wrapBounds = tester.getRect(
|
||||
find.byKey(const ValueKey('caption-wrap-toggle')),
|
||||
);
|
||||
expect(searchBounds.height, 28);
|
||||
expect(wrapBounds.height, 28);
|
||||
expect(searchBounds.top, wrapBounds.top);
|
||||
expect(searchBounds.bottom, wrapBounds.bottom);
|
||||
await tester.enterText(search, ' searchable ');
|
||||
await tester.pump();
|
||||
expect(find.byKey(ValueKey('caption-list-$firstId')), findsNothing);
|
||||
expect(find.byKey(ValueKey('caption-list-$secondId')), findsOneWidget);
|
||||
expect(
|
||||
tester
|
||||
.widget<Text>(find.byKey(ValueKey('caption-number-$secondId')))
|
||||
.data,
|
||||
'2',
|
||||
);
|
||||
expect(
|
||||
tester.getSize(find.byKey(ValueKey('caption-list-$secondId'))).height,
|
||||
28,
|
||||
);
|
||||
await tester.enterText(search, 'no such caption');
|
||||
await tester.pump();
|
||||
expect(find.text('没有匹配的字幕'), findsOneWidget);
|
||||
await tester.enterText(search, '');
|
||||
await tester.pump();
|
||||
expect(find.byKey(ValueKey('caption-list-$firstId')), findsOneWidget);
|
||||
final toolbarPosition = tester.getTopLeft(search);
|
||||
await tester.tap(find.byKey(const ValueKey('caption-wrap-toggle')));
|
||||
await tester.pump();
|
||||
expect(
|
||||
tester.getSize(find.byKey(ValueKey('caption-list-$secondId'))).height,
|
||||
greaterThan(28),
|
||||
);
|
||||
expect(tester.getTopLeft(search), toolbarPosition);
|
||||
final list = find.byKey(const ValueKey('caption-scroll-list'));
|
||||
expect(list, findsOneWidget);
|
||||
expect(
|
||||
find.ancestor(of: search, matching: find.byType(ShaderMask)),
|
||||
findsNothing,
|
||||
);
|
||||
expect(
|
||||
find.ancestor(of: list, matching: find.byType(ShaderMask)),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(tester.widget<ListView>(list).physics, isA<ClampingScrollPhysics>());
|
||||
final scroll = tester
|
||||
.state<ScrollableState>(
|
||||
find.descendant(of: list, matching: find.byType(Scrollable)),
|
||||
)
|
||||
.position;
|
||||
expect(scroll.extentBefore, 0);
|
||||
expect(scroll.extentAfter, greaterThan(24));
|
||||
await tester.drag(list, const Offset(0, -60));
|
||||
await tester.pumpAndSettle();
|
||||
expect(scroll.pixels, greaterThan(0));
|
||||
scroll.jumpTo(scroll.maxScrollExtent / 2);
|
||||
await tester.pumpAndSettle();
|
||||
expect(scroll.extentBefore, greaterThan(0));
|
||||
expect(scroll.extentAfter, greaterThan(0));
|
||||
scroll.jumpTo(scroll.maxScrollExtent);
|
||||
await tester.pumpAndSettle();
|
||||
expect(scroll.extentAfter, 0);
|
||||
expect(tester.getTopLeft(search), toolbarPosition);
|
||||
expect(tester.takeException(), isNull);
|
||||
await tester.tap(find.byKey(const ValueKey('caption-wrap-toggle')));
|
||||
await tester.pump();
|
||||
expect(
|
||||
tester.getSize(find.byKey(ValueKey('caption-list-$secondId'))).height,
|
||||
28,
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(scroll.extentAfter, 0);
|
||||
expect(scroll.extentBefore, 0);
|
||||
await tester.tap(find.byKey(ValueKey('caption-action-$secondId')));
|
||||
await tester.pump();
|
||||
|
||||
final identity = session.view(sequence).selectedIdentities.single;
|
||||
expect(identity, isA<LayoutBodyId>());
|
||||
final selected = session.resolveCaptionComponent(
|
||||
sequence,
|
||||
identity as LayoutBodyId,
|
||||
);
|
||||
expect(
|
||||
session.persistence
|
||||
.timeline(sequence)
|
||||
.current
|
||||
.query()
|
||||
.element(selected!)
|
||||
.id
|
||||
.value,
|
||||
secondId,
|
||||
);
|
||||
await tester.pumpWidget(panel(secondId));
|
||||
await tester.pumpAndSettle();
|
||||
final selectedRow = find.byKey(ValueKey('caption-list-$secondId'));
|
||||
expect(selectedRow, findsOneWidget);
|
||||
expect(find.byKey(const ValueKey('caption-search')), findsOneWidget);
|
||||
expect(find.byKey(const Key('caption-fontSize')), findsNothing);
|
||||
final selectedColor = Theme.of(tester.element(selectedRow))
|
||||
.colorScheme
|
||||
.onSurface
|
||||
.withValues(alpha: .05);
|
||||
expect(
|
||||
find.ancestor(
|
||||
of: selectedRow,
|
||||
matching: find.byWidgetPredicate(
|
||||
(widget) => widget is Material && widget.color == selectedColor,
|
||||
),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
await tester.tap(selectedRow);
|
||||
await tester.pump();
|
||||
expect(selectedRow, findsOneWidget);
|
||||
expect(find.byKey(const Key('caption-fontSize')), findsNothing);
|
||||
});
|
||||
}
|
||||
|
||||
test(
|
||||
'completed transcription output is reused and persists inside the project',
|
||||
@@ -2552,7 +2581,7 @@ void main() {
|
||||
maxHeight: 180,
|
||||
builder: (_, toggle) => IconButton(
|
||||
onPressed: toggle,
|
||||
icon: const Icon(Icons.task_alt),
|
||||
icon: const Icon(AppIcons.success),
|
||||
),
|
||||
child: BackgroundTasksContent(session: session),
|
||||
),
|
||||
@@ -2566,7 +2595,7 @@ void main() {
|
||||
expect(find.text('后台任务'), findsNothing);
|
||||
expect(find.textContaining('字幕已生成'), findsOneWidget);
|
||||
expect(find.text('应用原文字幕'), findsNothing);
|
||||
expect(find.byIcon(Icons.chevron_right), findsNothing);
|
||||
expect(find.byIcon(AppIcons.chevronRight), findsNothing);
|
||||
final taskRow = find
|
||||
.ancestor(of: find.text('source'), matching: find.byType(InkWell))
|
||||
.first;
|
||||
|
||||
Reference in new issue
Block a user