mirror of
https://github.com/flutter/flutter
synced 2024-09-12 21:01:59 +00:00
Add tests for gesture_detector.0.dart and gesture_detector.1.dart API examples. (#146724)
This PR contributes to https://github.com/flutter/flutter/issues/130459 ### Description - Adds `examples/api/test/widgets/gesture_detector/gesture_detector.0_test.dart` test - Adds `examples/api/test/widgets/gesture_detector/gesture_detector.1_test.dart` test
This commit is contained in:
parent
24def4d417
commit
142e247fab
|
@ -453,8 +453,6 @@ final Set<String> _knownMissingTests = <String>{
|
|||
'examples/api/test/widgets/interactive_viewer/interactive_viewer.transformation_controller.0_test.dart',
|
||||
'examples/api/test/widgets/interactive_viewer/interactive_viewer.0_test.dart',
|
||||
'examples/api/test/widgets/notification_listener/notification.0_test.dart',
|
||||
'examples/api/test/widgets/gesture_detector/gesture_detector.1_test.dart',
|
||||
'examples/api/test/widgets/gesture_detector/gesture_detector.0_test.dart',
|
||||
'examples/api/test/widgets/editable_text/text_editing_controller.0_test.dart',
|
||||
'examples/api/test/widgets/editable_text/editable_text.on_changed.0_test.dart',
|
||||
'examples/api/test/widgets/undo_history/undo_history_controller.0_test.dart',
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_api_samples/widgets/gesture_detector/gesture_detector.0.dart'
|
||||
as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets(
|
||||
'GestureDetector updates icon color and text on tap',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.GestureDetectorExampleApp(),
|
||||
);
|
||||
|
||||
Icon icon = tester.widget(find.byIcon(Icons.lightbulb_outline));
|
||||
|
||||
expect(find.text('TURN LIGHT ON'), findsOneWidget);
|
||||
expect(icon.color, Colors.black);
|
||||
|
||||
await tester.tap(find.byType(GestureDetector));
|
||||
await tester.pump();
|
||||
|
||||
icon = tester.widget(find.byIcon(Icons.lightbulb_outline));
|
||||
|
||||
expect(find.text('TURN LIGHT OFF'), findsOneWidget);
|
||||
expect(icon.color, Colors.yellow.shade600);
|
||||
|
||||
await tester.tap(find.byType(GestureDetector));
|
||||
await tester.pump();
|
||||
|
||||
icon = tester.widget(find.byIcon(Icons.lightbulb_outline));
|
||||
|
||||
expect(find.text('TURN LIGHT ON'), findsOneWidget);
|
||||
expect(icon.color, Colors.black);
|
||||
},
|
||||
);
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_api_samples/widgets/gesture_detector/gesture_detector.1.dart'
|
||||
as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets(
|
||||
'GestureDetector updates Container color on tap',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.GestureDetectorExampleApp(),
|
||||
);
|
||||
|
||||
Container container = tester.widget(
|
||||
find.ancestor(
|
||||
of: find.byType(GestureDetector),
|
||||
matching: find.byType(Container),
|
||||
),
|
||||
);
|
||||
|
||||
expect(container.color, Colors.white);
|
||||
|
||||
await tester.tap(find.byType(GestureDetector));
|
||||
await tester.pump();
|
||||
|
||||
container = tester.widget(
|
||||
find.ancestor(
|
||||
of: find.byType(GestureDetector),
|
||||
matching: find.byType(Container),
|
||||
),
|
||||
);
|
||||
|
||||
expect(container.color, Colors.yellow);
|
||||
|
||||
await tester.tap(find.byType(GestureDetector));
|
||||
await tester.pump();
|
||||
|
||||
container = tester.widget(
|
||||
find.ancestor(
|
||||
of: find.byType(GestureDetector),
|
||||
matching: find.byType(Container),
|
||||
),
|
||||
);
|
||||
|
||||
expect(container.color, Colors.white);
|
||||
},
|
||||
);
|
||||
}
|
Loading…
Reference in a new issue