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
@@ -1,11 +1,199 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:cutdex/app/editor_theme.dart';
|
||||
import 'package:cutdex/l10n/app_localizations.dart';
|
||||
import 'package:cutdex_ui/theme.dart';
|
||||
import 'package:cutdex/features/projects/widgets/name_dialog.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('name collision keeps the dialog open and allows correction', (
|
||||
tester,
|
||||
) async {
|
||||
final validation = Completer<String?>();
|
||||
final submitted = <String>[];
|
||||
String? result;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: EditorTheme.penDark,
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
locale: const Locale('zh'),
|
||||
home: Scaffold(
|
||||
body: Builder(
|
||||
builder: (context) => TextButton(
|
||||
onPressed: () async {
|
||||
result = await askName(
|
||||
context,
|
||||
title: '新建项目',
|
||||
label: '项目名称',
|
||||
validateName: (name) async {
|
||||
submitted.add(name);
|
||||
return name == 'Existing' ? validation.future : null;
|
||||
},
|
||||
);
|
||||
},
|
||||
child: const Text('Open'),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.tap(find.text('Open'));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.enterText(find.byType(TextFormField), 'Existing');
|
||||
await tester.tap(find.byType(FilledButton));
|
||||
await tester.pump();
|
||||
expect(
|
||||
tester.widget<FilledButton>(find.byType(FilledButton)).onPressed,
|
||||
isNull,
|
||||
);
|
||||
await tester.testTextInput.receiveAction(TextInputAction.done);
|
||||
expect(submitted, ['Existing']);
|
||||
|
||||
final error = lookupAppLocalizations(const Locale('zh'))
|
||||
.projectAlreadyExists;
|
||||
validation.complete(error);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text(error), findsOneWidget);
|
||||
expect(find.byType(TextFormField), findsOneWidget);
|
||||
expect(
|
||||
tester.widget<EditableText>(find.byType(EditableText)).controller.text,
|
||||
'Existing',
|
||||
);
|
||||
expect(result, isNull);
|
||||
expect(tester.takeException(), isNull);
|
||||
|
||||
await tester.enterText(find.byType(TextFormField), 'Another');
|
||||
await tester.pump();
|
||||
expect(find.text(error), findsNothing);
|
||||
await tester.tap(find.byType(FilledButton));
|
||||
await tester.pumpAndSettle();
|
||||
expect(result, 'Another');
|
||||
expect(submitted, ['Existing', 'Another']);
|
||||
expect(find.byType(TextFormField), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('cancel during validation does not pop the underlying page', (
|
||||
tester,
|
||||
) async {
|
||||
final validation = Completer<String?>();
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: EditorTheme.penDark,
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
home: Builder(
|
||||
builder: (context) => TextButton(
|
||||
onPressed: () => askName(
|
||||
context,
|
||||
title: 'New project',
|
||||
label: 'Name',
|
||||
validateName: (_) => validation.future,
|
||||
),
|
||||
child: const Text('Open'),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.tap(find.text('Open'));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.enterText(find.byType(TextFormField), 'Name');
|
||||
await tester.tap(find.byType(FilledButton));
|
||||
await tester.pump();
|
||||
await tester.tap(find.text('Cancel'));
|
||||
validation.complete(null);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Open'), findsOneWidget);
|
||||
expect(find.byType(TextFormField), findsNothing);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
testWidgets('rename hint, text line and caret share the vertical center', (
|
||||
tester,
|
||||
) async {
|
||||
addTearDown(() => debugDefaultTargetPlatformOverride = null);
|
||||
for (final platform in [TargetPlatform.macOS, TargetPlatform.windows]) {
|
||||
debugDefaultTargetPlatformOverride = platform;
|
||||
for (final brightness in Brightness.values) {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: EditorTheme.desktop(
|
||||
EditorTheme.forPalette(AppPalette.graphite, brightness),
|
||||
),
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
locale: const Locale('zh'),
|
||||
home: Scaffold(
|
||||
body: Builder(
|
||||
builder: (context) => TextButton(
|
||||
onPressed: () => askName(
|
||||
context,
|
||||
title: '重命名',
|
||||
label: '项目名称',
|
||||
submitLabel: '重命名',
|
||||
),
|
||||
child: const Text('Open'),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.tap(find.text('Open'));
|
||||
await tester.pumpAndSettle();
|
||||
final field = find.byType(TextFormField);
|
||||
final editable = find.byType(EditableText);
|
||||
final input = tester.widget<EditableText>(editable);
|
||||
final decoration = tester
|
||||
.widget<TextField>(find.byType(TextField))
|
||||
.decoration!
|
||||
.applyDefaults(
|
||||
Theme.of(tester.element(field)).inputDecorationTheme,
|
||||
);
|
||||
expect(decoration.hintStyle!.fontSize, input.style.fontSize);
|
||||
expect(decoration.hintStyle!.height, input.style.height);
|
||||
final hint = tester.renderObject<RenderParagraph>(find.text('项目名称'));
|
||||
final hintBox = hint
|
||||
.getBoxesForSelection(
|
||||
const TextSelection(baseOffset: 0, extentOffset: 4),
|
||||
)
|
||||
.first
|
||||
.toRect();
|
||||
expect(
|
||||
hint.localToGlobal(hintBox.center).dy,
|
||||
closeTo(tester.getCenter(field).dy, 1),
|
||||
);
|
||||
for (final text in ['', '剪辑项目', 'Cutdex project']) {
|
||||
await tester.enterText(field, text);
|
||||
await tester.pump();
|
||||
final render = tester
|
||||
.state<EditableTextState>(editable)
|
||||
.renderEditable;
|
||||
final caret = render.getLocalRectForCaret(
|
||||
TextPosition(offset: text.length),
|
||||
);
|
||||
expect(
|
||||
render.localToGlobal(caret.center).dy,
|
||||
closeTo(tester.getCenter(field).dy, 1),
|
||||
reason: '$platform / $brightness / "$text"',
|
||||
);
|
||||
expect(
|
||||
render.localToGlobal(render.size.center(Offset.zero)).dy,
|
||||
closeTo(tester.getCenter(field).dy, 1),
|
||||
);
|
||||
expect(tester.getSize(field).height, 36);
|
||||
}
|
||||
await tester.tap(find.text('取消'));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.pumpWidget(const SizedBox());
|
||||
}
|
||||
}
|
||||
debugDefaultTargetPlatformOverride = null;
|
||||
});
|
||||
|
||||
testWidgets('rename chat uses the same dialog and compact input', (
|
||||
tester,
|
||||
) async {
|
||||
|
||||
Reference in new issue
Block a user