feat(workspace): refresh desktop editing experience and prepare 0.1.2
Gitea CI / Build Android APK (pull_request) Canceled after 0s
Gitea CI / Build Windows x64 app (pull_request) Canceled after 0s
Gitea CI / Audit and package Windows x64 (pull_request) Canceled after 0s
Gitea CI / Assemble and validate CI artifacts (pull_request) Canceled after 0s
Gitea CI / Gitea CI passed (pull_request) Canceled after 0s
Gitea CI / Check code and tests (pull_request) Canceled after 6m29s
Gitea CI / Build Android APK (pull_request) Canceled after 0s
Gitea CI / Build Windows x64 app (pull_request) Canceled after 0s
Gitea CI / Audit and package Windows x64 (pull_request) Canceled after 0s
Gitea CI / Assemble and validate CI artifacts (pull_request) Canceled after 0s
Gitea CI / Gitea CI passed (pull_request) Canceled after 0s
Gitea CI / Check code and tests (pull_request) Canceled after 6m29s
This commit is contained in:
1 parent
aa5255d1e4
commit
2e0033ce2d
260 files changed
+43963
-5591
No files matched your search
@@ -0,0 +1,173 @@
|
||||
import 'package:cutdex/features/media/resource_navigation.dart';
|
||||
import 'package:cutdex/l10n/app_localizations.dart';
|
||||
import 'package:cutdex_ui/theme.dart';
|
||||
import 'package:cutdex_ui/widgets.dart';
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
Future<void> mount(
|
||||
WidgetTester tester, {
|
||||
double width = 240,
|
||||
double scale = 1,
|
||||
Locale locale = const Locale('zh'),
|
||||
AppPalette palette = AppPalette.graphite,
|
||||
Brightness brightness = Brightness.dark,
|
||||
}) async {
|
||||
var selected = ResourceSection.imported;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: AppTheme.desktopWorkspaceTheme(
|
||||
AppTheme.forPalette(palette, brightness),
|
||||
),
|
||||
locale: locale,
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
home: Scaffold(
|
||||
body: Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: SizedBox(
|
||||
width: width,
|
||||
child: MediaQuery(
|
||||
data: MediaQueryData(textScaler: TextScaler.linear(scale)),
|
||||
child: StatefulBuilder(
|
||||
builder: (context, setState) => ResourceSectionTabs(
|
||||
selected: selected,
|
||||
onSelected: (value) => setState(() => selected = value),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
testWidgets('translated tabs fit scaled text in all desktop palettes', (
|
||||
tester,
|
||||
) async {
|
||||
for (final palette in AppPalette.values) {
|
||||
for (final brightness in Brightness.values) {
|
||||
for (final locale in [
|
||||
const Locale('zh'),
|
||||
const Locale('en'),
|
||||
const Locale('de'),
|
||||
const Locale('ru'),
|
||||
]) {
|
||||
for (final width in [120.0, 240.0, 400.0, 640.0]) {
|
||||
await mount(
|
||||
tester,
|
||||
width: width,
|
||||
scale: 1.3,
|
||||
locale: locale,
|
||||
palette: palette,
|
||||
brightness: brightness,
|
||||
);
|
||||
expect(
|
||||
tester.takeException(),
|
||||
isNull,
|
||||
reason: '$palette $brightness $locale $width',
|
||||
);
|
||||
expect(
|
||||
tester
|
||||
.getSize(find.byKey(const Key('resource-section-tabs')))
|
||||
.height,
|
||||
36,
|
||||
);
|
||||
final header = tester.getRect(
|
||||
find.byKey(const Key('resource-section-tabs')),
|
||||
);
|
||||
for (final button in find.byType(TextButton).evaluate()) {
|
||||
final bounds = tester.getRect(find.byWidget(button.widget));
|
||||
expect(bounds.top, greaterThanOrEqualTo(header.top));
|
||||
expect(bounds.bottom, lessThanOrEqualTo(header.bottom));
|
||||
expect(bounds.height, AppDesktopMetrics.timelineTabControl);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'narrow tabs scroll with wheel and drag through the shared edge fade',
|
||||
(tester) async {
|
||||
await mount(tester, width: 160);
|
||||
final list = find.byKey(const Key('resource-tabs-list'));
|
||||
final scroll = tester.widget<SingleChildScrollView>(list);
|
||||
final fade = tester.widget<ScrollEdgeFade>(find.byType(ScrollEdgeFade));
|
||||
expect(fade.axis, Axis.horizontal);
|
||||
expect(fade.controller, same(scroll.controller));
|
||||
final position = scroll.controller!.position;
|
||||
expect(position.pixels, 0);
|
||||
expect(position.extentAfter, greaterThan(0));
|
||||
expect(find.byKey(const Key('resource-tabs-more')), findsNothing);
|
||||
for (final section in ResourceSection.values) {
|
||||
expect(
|
||||
find.byKey(ValueKey('resource-tab-${section.name}')),
|
||||
findsOneWidget,
|
||||
);
|
||||
}
|
||||
await tester.sendEventToBinding(
|
||||
PointerScrollEvent(
|
||||
position: tester.getCenter(list),
|
||||
scrollDelta: const Offset(0, 70),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(position.pixels, 70);
|
||||
expect(position.extentBefore, greaterThan(0));
|
||||
expect(position.extentAfter, greaterThan(0));
|
||||
await tester.drag(list, const Offset(-600, 0));
|
||||
await tester.pumpAndSettle();
|
||||
expect(position.pixels, position.maxScrollExtent);
|
||||
await tester.tap(find.byKey(const ValueKey('resource-tab-transitions')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
tester
|
||||
.widget<ResourceSectionTabs>(find.byType(ResourceSectionTabs))
|
||||
.selected,
|
||||
ResourceSection.transitions,
|
||||
);
|
||||
tester
|
||||
.widget<ResourceSectionTabs>(find.byType(ResourceSectionTabs))
|
||||
.onSelected!(ResourceSection.imported);
|
||||
await tester.pumpAndSettle();
|
||||
expect(position.pixels, 0);
|
||||
expect(tester.takeException(), isNull);
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('a programmatically selected tab scrolls into view', (
|
||||
tester,
|
||||
) async {
|
||||
await mount(tester, width: 160);
|
||||
tester
|
||||
.widget<ResourceSectionTabs>(find.byType(ResourceSectionTabs))
|
||||
.onSelected!(ResourceSection.transitions);
|
||||
await tester.pumpAndSettle();
|
||||
final viewport = tester.getRect(
|
||||
find.byKey(const Key('resource-tabs-list')),
|
||||
);
|
||||
final selected = tester.getRect(
|
||||
find.byKey(const ValueKey('resource-tab-transitions')),
|
||||
);
|
||||
expect(selected.left, greaterThanOrEqualTo(viewport.left));
|
||||
expect(selected.right, lessThanOrEqualTo(viewport.right));
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
testWidgets('wide panel exposes every category directly', (tester) async {
|
||||
await mount(tester, width: 640);
|
||||
for (final section in ResourceSection.values) {
|
||||
expect(
|
||||
find.byKey(ValueKey('resource-tab-${section.name}')),
|
||||
findsOneWidget,
|
||||
);
|
||||
}
|
||||
expect(find.byKey(const Key('resource-tabs-more')), findsNothing);
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user