Skip to content

Commit b3dc24c

Browse files
Add test for inherited_notifier.0.dart (flutter#150344)
Contributes to flutter#130459 It adds a test for - `examples/api/lib/widgets/inherited_notifier/inherited_notifier.0.dart`
1 parent 8e4f704 commit b3dc24c

File tree

2 files changed

+60
-1
lines changed

2 files changed

+60
-1
lines changed

dev/bots/check_code_samples.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,6 @@ final Set<String> _knownMissingTests = <String>{
385385
'examples/api/test/widgets/color_filter/color_filtered.0_test.dart',
386386
'examples/api/test/widgets/focus_scope/focus_scope.0_test.dart',
387387
'examples/api/test/widgets/scroll_view/custom_scroll_view.1_test.dart',
388-
'examples/api/test/widgets/inherited_notifier/inherited_notifier.0_test.dart',
389388
'examples/api/test/animation/curves/curve2_d.0_test.dart',
390389
'examples/api/test/gestures/pointer_signal_resolver/pointer_signal_resolver.0_test.dart',
391390
};
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// Copyright 2014 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import 'dart:math' as math;
6+
7+
import 'package:flutter/material.dart';
8+
import 'package:flutter_api_samples/widgets/inherited_notifier/inherited_notifier.0.dart' as example;
9+
import 'package:flutter_test/flutter_test.dart';
10+
11+
void main() {
12+
testWidgets('It rotates the spinners', (WidgetTester tester) async {
13+
await tester.pumpWidget(
14+
const example.InheritedNotifierExampleApp(),
15+
);
16+
17+
final Iterable<Transform> widgets = tester.widgetList<Transform>(
18+
find.ancestor(
19+
of: find.text('Whee!'),
20+
matching: find.byType(Transform),
21+
),
22+
);
23+
24+
Matcher transformMatcher(Matrix4 matrix) {
25+
return everyElement(isA<Transform>().having((Transform widget) => widget.transform, 'transform', matrix));
26+
}
27+
28+
expect(widgets, transformMatcher(Matrix4.identity()));
29+
30+
await tester.pump(const Duration(seconds: 1));
31+
expect(widgets, transformMatcher(Matrix4.rotationZ(0.2 * math.pi)));
32+
33+
await tester.pump(const Duration(seconds: 1));
34+
expect(widgets, transformMatcher(Matrix4.rotationZ(0.4 * math.pi)));
35+
36+
await tester.pump(const Duration(seconds: 1));
37+
expect(widgets, transformMatcher(Matrix4.rotationZ(0.6 * math.pi)));
38+
39+
await tester.pump(const Duration(seconds: 1));
40+
expect(widgets, transformMatcher(Matrix4.rotationZ(0.8 * math.pi)));
41+
42+
await tester.pump(const Duration(seconds: 1));
43+
expect(widgets, transformMatcher(Matrix4.identity()..storage[0] = -1..storage[5] = -1));
44+
45+
await tester.pump(const Duration(seconds: 1));
46+
expect(widgets, transformMatcher(Matrix4.rotationZ(1.2 * math.pi)));
47+
48+
await tester.pump(const Duration(seconds: 1));
49+
expect(widgets, transformMatcher(Matrix4.rotationZ(1.4 * math.pi)));
50+
51+
await tester.pump(const Duration(seconds: 1));
52+
expect(widgets, transformMatcher(Matrix4.rotationZ(1.6 * math.pi)));
53+
54+
await tester.pump(const Duration(seconds: 1));
55+
expect(widgets, transformMatcher(Matrix4.rotationZ(1.8 * math.pi)));
56+
57+
await tester.pump(const Duration(seconds: 1));
58+
expect(widgets, transformMatcher(Matrix4.identity()));
59+
});
60+
}

0 commit comments

Comments
 (0)