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,77 @@
|
||||
import 'package:cutdex/features/assistant/breakable_selectable_text.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('long path wraps by character and copies without soft breaks', (
|
||||
tester,
|
||||
) async {
|
||||
const path = '/Users/example/Desktop/包含中文的长截图文件名.png';
|
||||
String? copied;
|
||||
final messenger =
|
||||
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger;
|
||||
messenger.setMockMethodCallHandler(SystemChannels.platform, (call) async {
|
||||
if (call.method == 'Clipboard.setData') {
|
||||
copied = (call.arguments as Map<dynamic, dynamic>)['text'] as String?;
|
||||
}
|
||||
return null;
|
||||
});
|
||||
addTearDown(
|
||||
() => messenger.setMockMethodCallHandler(SystemChannels.platform, null),
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
const MaterialApp(
|
||||
home: Scaffold(
|
||||
body: SizedBox(
|
||||
width: 220,
|
||||
child: BreakableSelectableText(
|
||||
text: path,
|
||||
style: TextStyle(fontSize: 16),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final selectable = tester.widget<SelectableText>(
|
||||
find.byType(SelectableText),
|
||||
);
|
||||
expect(selectable.data, contains('\u200B'));
|
||||
expect(selectable.data!.replaceAll('\u200B', ''), path);
|
||||
final paragraph = TextPainter(
|
||||
text: TextSpan(text: selectable.data, style: selectable.style),
|
||||
textDirection: TextDirection.ltr,
|
||||
)..layout(maxWidth: 220);
|
||||
expect(paragraph.computeLineMetrics().first.width, greaterThan(190));
|
||||
|
||||
await tester.tap(find.byType(SelectableText));
|
||||
final editable = tester.state<EditableTextState>(find.byType(EditableText));
|
||||
editable.userUpdateTextEditingValue(
|
||||
editable.textEditingValue.copyWith(
|
||||
selection: TextSelection(
|
||||
baseOffset: 0,
|
||||
extentOffset: selectable.data!.length,
|
||||
),
|
||||
),
|
||||
SelectionChangedCause.keyboard,
|
||||
);
|
||||
await tester.pump();
|
||||
await tester.sendKeyDownEvent(LogicalKeyboardKey.metaLeft);
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.keyC);
|
||||
await tester.sendKeyUpEvent(LogicalKeyboardKey.metaLeft);
|
||||
await tester.pump();
|
||||
expect(copied, path);
|
||||
|
||||
copied = null;
|
||||
final menu = selectable.contextMenuBuilder!(
|
||||
tester.element(find.byType(SelectableText)),
|
||||
editable,
|
||||
) as AdaptiveTextSelectionToolbar;
|
||||
menu.buttonItems!
|
||||
.singleWhere((button) => button.type == ContextMenuButtonType.copy)
|
||||
.onPressed!();
|
||||
await tester.pump();
|
||||
expect(copied, path);
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user