Add tests for curve2_d.0.dart (#150984)
Contributes to https://github.com/flutter/flutter/issues/130459 It adds a test for - `examples/api/lib/animation/curves/curve2_d.0.dart`
This commit is contained in:
parent
fde041869e
commit
f84139b665
@ -378,6 +378,5 @@ final Set<String> _knownMissingTests = <String>{
|
||||
'examples/api/test/widgets/actions/focusable_action_detector.0_test.dart',
|
||||
'examples/api/test/widgets/focus_scope/focus_scope.0_test.dart',
|
||||
'examples/api/test/widgets/scroll_view/custom_scroll_view.1_test.dart',
|
||||
'examples/api/test/animation/curves/curve2_d.0_test.dart',
|
||||
'examples/api/test/gestures/pointer_signal_resolver/pointer_signal_resolver.0_test.dart',
|
||||
};
|
||||
|
@ -48,10 +48,6 @@ void main() {
|
||||
final File barExample = examplesLib.childFile('bar_example.0.dart')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('// Example for bar');
|
||||
final File curvesExample =
|
||||
examples.childDirectory('lib').childDirectory('animation').childDirectory('curves').childFile('curve2_d.0.dart')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('// Missing a test, but OK');
|
||||
if (missingLinks) {
|
||||
examplesLib.childFile('missing_example.0.dart')
|
||||
..createSync(recursive: true)
|
||||
@ -77,11 +73,9 @@ void main() {
|
||||
if (malformedLinks) {
|
||||
writeLink(source: flutterPackage.childDirectory('layer').childFile('foo.dart'), example: fooExample, alternateLink: '*See Code *');
|
||||
writeLink(source: flutterPackage.childDirectory('layer').childFile('bar.dart'), example: barExample, alternateLink: ' ** See code examples/api/lib/layer/bar_example.0.dart **');
|
||||
writeLink(source: flutterPackage.childDirectory('animation').childFile('curves.dart'), example: curvesExample, alternateLink: '* see code in examples/api/lib/animation/curves/curve2_d.0.dart *');
|
||||
} else {
|
||||
writeLink(source: flutterPackage.childDirectory('layer').childFile('foo.dart'), example: fooExample);
|
||||
writeLink(source: flutterPackage.childDirectory('layer').childFile('bar.dart'), example: barExample);
|
||||
writeLink(source: flutterPackage.childDirectory('animation').childFile('curves.dart'), example: curvesExample);
|
||||
}
|
||||
}
|
||||
|
||||
@ -144,20 +138,16 @@ void main() {
|
||||
final String lines = <String>[
|
||||
'╔═╡ERROR #1╞════════════════════════════════════════════════════════════════════',
|
||||
'║ The following examples are not linked from any source file API doc comments:',
|
||||
if (!isWindows) '║ examples/api/lib/animation/curves/curve2_d.0.dart',
|
||||
if (!isWindows) '║ examples/api/lib/layer/foo_example.0.dart',
|
||||
if (!isWindows) '║ examples/api/lib/layer/bar_example.0.dart',
|
||||
if (isWindows) r'║ examples\api\lib\animation\curves\curve2_d.0.dart',
|
||||
if (isWindows) r'║ examples\api\lib\layer\foo_example.0.dart',
|
||||
if (isWindows) r'║ examples\api\lib\layer\bar_example.0.dart',
|
||||
'║ Either link them to a source file API doc comment, or remove them.',
|
||||
'╚═══════════════════════════════════════════════════════════════════════════════',
|
||||
'╔═╡ERROR #2╞════════════════════════════════════════════════════════════════════',
|
||||
'║ The following malformed links were found in API doc comments:',
|
||||
if (!isWindows) '║ /flutter sdk/packages/flutter/lib/src/animation/curves.dart:6: ///* see code in examples/api/lib/animation/curves/curve2_d.0.dart *',
|
||||
if (!isWindows) '║ /flutter sdk/packages/flutter/lib/src/layer/foo.dart:6: ///*See Code *',
|
||||
if (!isWindows) '║ /flutter sdk/packages/flutter/lib/src/layer/bar.dart:6: /// ** See code examples/api/lib/layer/bar_example.0.dart **',
|
||||
if (isWindows) r'║ C:\flutter sdk\packages\flutter\lib\src\animation\curves.dart:6: ///* see code in examples/api/lib/animation/curves/curve2_d.0.dart *',
|
||||
if (isWindows) r'║ C:\flutter sdk\packages\flutter\lib\src\layer\foo.dart:6: ///*See Code *',
|
||||
if (isWindows) r'║ C:\flutter sdk\packages\flutter\lib\src\layer\bar.dart:6: /// ** See code examples/api/lib/layer/bar_example.0.dart **',
|
||||
'║ Correct the formatting of these links so that they match the exact pattern:',
|
||||
|
40
examples/api/test/animation/curves/curve2_d.0_test.dart
Normal file
40
examples/api/test/animation/curves/curve2_d.0_test.dart
Normal file
@ -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/animation/curves/curve2_d.0.dart' as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('The buzz widget should move around', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.Curve2DExampleApp(),
|
||||
);
|
||||
|
||||
final Finder textFinder = find.widgetWithText(CircleAvatar, 'B');
|
||||
expect(tester.getCenter(textFinder), const Offset(58, 440));
|
||||
|
||||
const List<Offset> expectedOffsets= <Offset>[
|
||||
Offset(43, 407),
|
||||
Offset(81, 272),
|
||||
Offset(185, 103),
|
||||
Offset(378, 92),
|
||||
Offset(463, 392),
|
||||
Offset(479, 124),
|
||||
Offset(745, 389),
|
||||
Offset(450, 555),
|
||||
Offset(111, 475),
|
||||
Offset(58, 440),
|
||||
Offset(43, 407),
|
||||
];
|
||||
|
||||
const int steps = 10;
|
||||
for (int i = 0; i <= steps; i++) {
|
||||
await tester.pump(const Duration(seconds: 3) * (1 / steps));
|
||||
final Offset center = tester.getCenter(textFinder);
|
||||
expect(center.dx, moreOrLessEquals(expectedOffsets[i].dx, epsilon: 1));
|
||||
expect(center.dy, moreOrLessEquals(expectedOffsets[i].dy, epsilon: 1));
|
||||
}
|
||||
});
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user