mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00

This PR writes tests for a few of the API examples (not all), as requested in #130459. For the test names, I used the existing tests in the `api` folder as guide.
36 lines
1.2 KiB
Dart
36 lines
1.2 KiB
Dart
// 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/material/icon_button/icon_button.0.dart' as example;
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
void main() {
|
|
testWidgets('IconButton increments volume when tapped', (WidgetTester tester) async {
|
|
await tester.pumpWidget(
|
|
const example.IconButtonExampleApp(),
|
|
);
|
|
|
|
expect(find.byIcon(Icons.volume_up), findsOneWidget);
|
|
expect(find.text('Volume : 0.0'), findsOneWidget);
|
|
|
|
await tester.tap(find.byType(IconButton));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.text('Volume : 10.0'), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('IconButton shows tooltip when long pressed', (WidgetTester tester) async {
|
|
await tester.pumpWidget(
|
|
const example.IconButtonExampleApp(),
|
|
);
|
|
|
|
expect(find.text('Increase volume by 10'), findsNothing);
|
|
await tester.longPress(find.byType(IconButton));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.text('Increase volume by 10'), findsOneWidget);
|
|
});
|
|
}
|