1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-08 13:58:47 +00:00
Files
samples/material_3_demo/test/typography_screen_test.dart
Qun Cheng 6694b00dae Added M3 demo app (#1189)
* Added M3 demo app

* Changed to use the centralized lint configuration.

* Moved the app at the root level

* Added to CI

* Added app to beta CI and commented app on stable CI file

* Update README.md

* Addressed comments

* fixed comments

* Reverted app name in CI files.

* Added project to the Pub Dependabot config

* Linting pass for current beta channel standards

Co-authored-by: Qun Cheng <quncheng@google.com>
Co-authored-by: Craig Labenz <craig.labenz@gmail.com>
2022-05-06 08:29:31 -07:00

73 lines
3.1 KiB
Dart

// ignore_for_file: avoid_types_on_closure_parameters
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:material_3_demo/main.dart';
import 'package:material_3_demo/typography_screen.dart';
import 'component_screen_test.dart';
void main() {
testWidgets(
'Typography screen shows correctly when the corresponding icon is '
'selected on NavigationBar', (WidgetTester tester) async {
widgetSetup(tester, 449);
addTearDown(tester.binding.window.clearPhysicalSizeTestValue);
await tester.pumpWidget(const Material3Demo());
expect(find.text("Display Large"), findsNothing);
expect(find.byType(NavigationBar), findsOneWidget);
Finder textIconOnBar = find.byIcon(Icons.text_snippet_outlined);
expect(textIconOnBar, findsOneWidget);
await tester.tap(textIconOnBar);
await tester.pumpAndSettle(const Duration(microseconds: 500));
expect(textIconOnBar, findsNothing);
expect(find.byIcon(Icons.text_snippet), findsOneWidget);
expect(find.text("Display Large"), findsOneWidget);
});
testWidgets(
'Typography screen shows correctly when the corresponding icon is '
'selected on NavigationRail', (WidgetTester tester) async {
widgetSetup(tester, 450); // NavigationRail shows only when width is >= 450.
addTearDown(tester.binding.window.clearPhysicalSizeTestValue);
await tester.pumpWidget(const Material3Demo());
expect(find.text("Display Large"), findsNothing);
expect(find.byType(NavigationRail), findsOneWidget);
Finder textIconOnRail = find.byIcon(Icons.text_snippet_outlined);
expect(textIconOnRail, findsOneWidget);
await tester.tap(textIconOnRail);
await tester.pumpAndSettle(const Duration(microseconds: 500));
expect(textIconOnRail, findsNothing);
expect(find.byIcon(Icons.text_snippet), findsOneWidget);
expect(find.text("Display Large"), findsOneWidget);
});
testWidgets('Typography screen shows correct content',
(WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(
home: Scaffold(body: Row(children: const [TypographyScreen()])),
));
expect(find.text("Display Large"), findsOneWidget);
expect(find.text("Display Medium"), findsOneWidget);
expect(find.text("Display Small"), findsOneWidget);
expect(find.text("Headline Large"), findsOneWidget);
expect(find.text("Headline Medium"), findsOneWidget);
expect(find.text("Headline Small"), findsOneWidget);
expect(find.text("Title Large"), findsOneWidget);
expect(find.text("Title Medium"), findsOneWidget);
expect(find.text("Title Small"), findsOneWidget);
await tester.scrollUntilVisible(
find.text("Body Small"),
500.0,
);
expect(find.text("Label Large"), findsOneWidget);
expect(find.text("Label Medium"), findsOneWidget);
expect(find.text("Label Small"), findsOneWidget);
expect(find.text("Body Large"), findsOneWidget);
expect(find.text("Body Medium"), findsOneWidget);
expect(find.text("Body Small"), findsOneWidget);
expect(find.byType(TextStyleExample), findsNWidgets(15));
});
}