Prepare product layout and reusable Flutter theme
Relocate the existing Astro website and preserve its assets and hosting configuration. Add the consumer/backend scaffold and themed Flutter package with consumer tests. Related to #1.
This commit is contained in:
1 parent
ef65a40213
commit
d9318053e8
46 files changed
+703
-1
No files matched your search
@@ -0,0 +1,51 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import 'package:sxchnge_theme_example/main.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('consumer bundles the package font and its license', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(const ThemeExample());
|
||||
final manifest =
|
||||
jsonDecode(await rootBundle.loadString('FontManifest.json')) as List;
|
||||
final family = manifest.cast<Map>().singleWhere(
|
||||
(font) => font['family'] == 'packages/sxchnge_theme/Onest',
|
||||
);
|
||||
final asset = (family['fonts'] as List).first['asset'] as String;
|
||||
expect((await rootBundle.load(asset)).lengthInBytes, greaterThan(1000));
|
||||
expect(
|
||||
await rootBundle.loadString(
|
||||
'packages/sxchnge_theme/assets/fonts/OFL.txt',
|
||||
),
|
||||
contains('SIL OPEN FONT LICENSE'),
|
||||
);
|
||||
});
|
||||
|
||||
for (final mode in [ThemeMode.light, ThemeMode.dark]) {
|
||||
testWidgets(
|
||||
'$mode renders on a narrow screen with large text and accepts input',
|
||||
(tester) async {
|
||||
tester.view.physicalSize = const Size(320, 900);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
tester.platformDispatcher.textScaleFactorTestValue = 2;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);
|
||||
await tester.pumpWidget(ThemeExample(mode: mode));
|
||||
await tester.pumpAndSettle();
|
||||
expect(tester.takeException(), isNull);
|
||||
await tester.enterText(find.byType(TextField).first, '125.50');
|
||||
expect(find.text('125.50'), findsOneWidget);
|
||||
await tester.ensureVisible(find.text('Continue'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(tester.takeException(), isNull);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user