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

Write Tests for API Examples of `cupertino_text_field.0`, `data_table.0`, `icon_button.2` & `ink_well.0` Note: test for `cupertino_text_field.0` was already there but it was named `cupertino_text_field.0.dart`. I renamed it to `cupertino_text_field.0_test.dart`. Part of #130459
24 lines
924 B
Dart
24 lines
924 B
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.2.dart' as example;
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
void main() {
|
|
testWidgets('IconButton Types', (WidgetTester tester) async {
|
|
await tester.pumpWidget(
|
|
const example.IconButtonApp(),
|
|
);
|
|
expect(find.widgetWithIcon(IconButton, Icons.filter_drama), findsNWidgets(8));
|
|
final Finder iconButtons = find.widgetWithIcon(IconButton, Icons.filter_drama);
|
|
for (int i = 0; i <= 3; i++) {
|
|
expect(tester.widget<IconButton>(iconButtons.at(i)).onPressed is VoidCallback, isTrue);
|
|
}
|
|
for (int i = 4; i <= 7; i++) {
|
|
expect(tester.widget<IconButton>(iconButtons.at(i)).onPressed, isNull);
|
|
}
|
|
});
|
|
}
|