mirror of
https://github.com/flutter/samples.git
synced 2025-11-10 14:58:34 +00:00
* Added components * Added test * Added README * Run flutter format * Added all the updated components and tests * Added README file * Update README.md * Add textfields to M3 demo app * move textfield to exprerimental/ * Update component_screen_test.dart * Fixed comment: changed sdk version * Changed all double quotes to single * Added trailing comma, changed all private fields to public except private state classes * Added enum for screen selection * Removed comment for material_3_demo * Added experimental m3 demo app to master CI pipeline * fixed failing tests * Modified the analysis_options.yaml * Fixed warning * Ran flutter format command Co-authored-by: Qun Cheng <quncheng@google.com> Co-authored-by: hangyu <108393416+hangyujin@users.noreply.github.com>
60 lines
2.5 KiB
Dart
60 lines
2.5 KiB
Dart
// Copyright 2021 The Flutter team. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
// 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/elevation_screen.dart';
|
|
import 'package:material_3_demo/main.dart';
|
|
|
|
import 'component_screen_test.dart';
|
|
|
|
void main() {
|
|
testWidgets(
|
|
'Surface Tones screen shows correctly when the corresponding icon is '
|
|
'selected on NavigationBar', (tester) async {
|
|
widgetSetup(tester, 449);
|
|
addTearDown(tester.binding.window.clearPhysicalSizeTestValue);
|
|
await tester.pumpWidget(const Material3Demo());
|
|
|
|
expect(find.text('Surface Tint only'), findsNothing);
|
|
expect(find.byType(NavigationBar), findsOneWidget);
|
|
Finder tintIconOnBar = find.byIcon(Icons.invert_colors_on_outlined);
|
|
expect(tintIconOnBar, findsOneWidget);
|
|
await tester.tap(tintIconOnBar);
|
|
await tester.pumpAndSettle(const Duration(microseconds: 500));
|
|
expect(tintIconOnBar, findsNothing);
|
|
expect(find.byIcon(Icons.opacity), findsOneWidget);
|
|
expect(find.text('Surface Tint only'), findsOneWidget);
|
|
});
|
|
|
|
testWidgets(
|
|
'Surface Tones screen shows correctly when the corresponding icon is '
|
|
'selected on NavigationRail', (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('Surface Tint only'), findsNothing);
|
|
expect(find.byType(NavigationRail), findsOneWidget);
|
|
Finder tintIconOnRail = find.byIcon(Icons.invert_colors_on_outlined);
|
|
expect(tintIconOnRail, findsOneWidget);
|
|
await tester.tap(tintIconOnRail);
|
|
await tester.pumpAndSettle(const Duration(microseconds: 500));
|
|
expect(tintIconOnRail, findsNothing);
|
|
expect(find.byIcon(Icons.opacity), findsOneWidget);
|
|
expect(find.text('Surface Tint only'), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('Surface Tones screen shows correct content', (tester) async {
|
|
await tester.pumpWidget(MaterialApp(
|
|
home: Scaffold(body: Row(children: const [ElevationScreen()])),
|
|
));
|
|
expect(find.text('Surface Tint only'), findsOneWidget);
|
|
expect(find.text('Surface Tint and Shadow'), findsOneWidget);
|
|
expect(find.text('Shadow only'), findsOneWidget);
|
|
expect(find.byType(ElevationGrid), findsNWidgets(3));
|
|
expect(find.byType(ElevationCard), findsNWidgets(18));
|
|
});
|
|
}
|