Migrate framework tests for rendering, semantics, widgets to null safety (#67453)
Migrate framework tests for rendering, semantics, widgets to null safety.
This commit is contained in:
parent
2462f6964a
commit
af0c7aed1c
@ -2,11 +2,8 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:flutter/animation.dart';
|
import 'package:flutter/animation.dart';
|
||||||
import 'package:meta/meta.dart';
|
|
||||||
|
|
||||||
import '../flutter_test_alternative.dart';
|
import '../flutter_test_alternative.dart';
|
||||||
|
|
||||||
@ -14,22 +11,21 @@ import 'rendering_tester.dart';
|
|||||||
|
|
||||||
class TestRenderSliverBoxChildManager extends RenderSliverBoxChildManager {
|
class TestRenderSliverBoxChildManager extends RenderSliverBoxChildManager {
|
||||||
TestRenderSliverBoxChildManager({
|
TestRenderSliverBoxChildManager({
|
||||||
this.children,
|
required this.children,
|
||||||
});
|
});
|
||||||
|
|
||||||
RenderSliverList _renderObject;
|
late RenderSliverList _renderObject;
|
||||||
List<RenderBox> children;
|
List<RenderBox> children;
|
||||||
|
|
||||||
RenderSliverList createRenderObject() {
|
RenderSliverList createRenderObject() {
|
||||||
assert(_renderObject == null);
|
|
||||||
_renderObject = RenderSliverList(childManager: this);
|
_renderObject = RenderSliverList(childManager: this);
|
||||||
return _renderObject;
|
return _renderObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
int _currentlyUpdatingChildIndex;
|
int? _currentlyUpdatingChildIndex;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void createChild(int index, { @required RenderBox after }) {
|
void createChild(int index, { required RenderBox? after }) {
|
||||||
if (index < 0 || index >= children.length)
|
if (index < 0 || index >= children.length)
|
||||||
return;
|
return;
|
||||||
try {
|
try {
|
||||||
@ -48,13 +44,13 @@ class TestRenderSliverBoxChildManager extends RenderSliverBoxChildManager {
|
|||||||
@override
|
@override
|
||||||
double estimateMaxScrollOffset(
|
double estimateMaxScrollOffset(
|
||||||
SliverConstraints constraints, {
|
SliverConstraints constraints, {
|
||||||
int firstIndex,
|
int? firstIndex,
|
||||||
int lastIndex,
|
int? lastIndex,
|
||||||
double leadingScrollOffset,
|
double? leadingScrollOffset,
|
||||||
double trailingScrollOffset,
|
double? trailingScrollOffset,
|
||||||
}) {
|
}) {
|
||||||
assert(lastIndex >= firstIndex);
|
assert(lastIndex! >= firstIndex!);
|
||||||
return children.length * (trailingScrollOffset - leadingScrollOffset) / (lastIndex - firstIndex + 1);
|
return children.length * (trailingScrollOffset! - leadingScrollOffset!) / (lastIndex! - firstIndex! + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -104,8 +100,8 @@ class ViewportOffsetSpy extends ViewportOffset {
|
|||||||
@override
|
@override
|
||||||
Future<void> animateTo(
|
Future<void> animateTo(
|
||||||
double to, {
|
double to, {
|
||||||
@required Duration duration,
|
required Duration duration,
|
||||||
@required Curve curve,
|
required Curve curve,
|
||||||
}) async {
|
}) async {
|
||||||
// Do nothing, not required in test.
|
// Do nothing, not required in test.
|
||||||
}
|
}
|
||||||
@ -301,7 +297,7 @@ void main() {
|
|||||||
root.offset = ViewportOffset.fixed(0.0);
|
root.offset = ViewportOffset.fixed(0.0);
|
||||||
pumpFrame();
|
pumpFrame();
|
||||||
|
|
||||||
expect(inner.geometry.scrollOffsetCorrection, isNull);
|
expect(inner.geometry?.scrollOffsetCorrection, isNull);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('SliverList - no correction when tiny double precision error', () {
|
test('SliverList - no correction when tiny double precision error', () {
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
import '../flutter_test_alternative.dart';
|
import '../flutter_test_alternative.dart';
|
||||||
|
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
@ -872,8 +870,7 @@ void main() {
|
|||||||
crossAxisOffset: 0.0,
|
crossAxisOffset: 0.0,
|
||||||
mainAxisPosition: 0.0,
|
mainAxisPosition: 0.0,
|
||||||
crossAxisPosition: 0.0,
|
crossAxisPosition: 0.0,
|
||||||
hitTest: (SliverHitTestResult result, { double mainAxisPosition, double crossAxisPosition }) {
|
hitTest: (SliverHitTestResult result, { required double mainAxisPosition, required double crossAxisPosition }) {
|
||||||
expect(result, isNotNull);
|
|
||||||
mainAxisPositions.add(mainAxisPosition);
|
mainAxisPositions.add(mainAxisPosition);
|
||||||
crossAxisPositions.add(crossAxisPosition);
|
crossAxisPositions.add(crossAxisPosition);
|
||||||
return true;
|
return true;
|
||||||
@ -891,8 +888,7 @@ void main() {
|
|||||||
crossAxisOffset: 6.0,
|
crossAxisOffset: 6.0,
|
||||||
mainAxisPosition: 10.0,
|
mainAxisPosition: 10.0,
|
||||||
crossAxisPosition: 20.0,
|
crossAxisPosition: 20.0,
|
||||||
hitTest: (SliverHitTestResult result, { double mainAxisPosition, double crossAxisPosition }) {
|
hitTest: (SliverHitTestResult result, { required double mainAxisPosition, required double crossAxisPosition }) {
|
||||||
expect(result, isNotNull);
|
|
||||||
mainAxisPositions.add(mainAxisPosition);
|
mainAxisPositions.add(mainAxisPosition);
|
||||||
crossAxisPositions.add(crossAxisPosition);
|
crossAxisPositions.add(crossAxisPosition);
|
||||||
return false;
|
return false;
|
||||||
@ -910,8 +906,7 @@ void main() {
|
|||||||
crossAxisOffset: -6.0,
|
crossAxisOffset: -6.0,
|
||||||
mainAxisPosition: 10.0,
|
mainAxisPosition: 10.0,
|
||||||
crossAxisPosition: 20.0,
|
crossAxisPosition: 20.0,
|
||||||
hitTest: (SliverHitTestResult result, { double mainAxisPosition, double crossAxisPosition }) {
|
hitTest: (SliverHitTestResult result, { required double mainAxisPosition, required double crossAxisPosition }) {
|
||||||
expect(result, isNotNull);
|
|
||||||
mainAxisPositions.add(mainAxisPosition);
|
mainAxisPositions.add(mainAxisPosition);
|
||||||
crossAxisPositions.add(crossAxisPosition);
|
crossAxisPositions.add(crossAxisPosition);
|
||||||
return false;
|
return false;
|
||||||
@ -926,8 +921,8 @@ void main() {
|
|||||||
|
|
||||||
test('addWithAxisOffset with non zero paintOffset', () {
|
test('addWithAxisOffset with non zero paintOffset', () {
|
||||||
final SliverHitTestResult result = SliverHitTestResult();
|
final SliverHitTestResult result = SliverHitTestResult();
|
||||||
double recordedMainAxisPosition;
|
late double recordedMainAxisPosition;
|
||||||
double recordedCrossAxisPosition;
|
late double recordedCrossAxisPosition;
|
||||||
final HitTestEntry entry = HitTestEntry(_DummyHitTestTarget());
|
final HitTestEntry entry = HitTestEntry(_DummyHitTestTarget());
|
||||||
const Offset paintOffset = Offset(7, 11);
|
const Offset paintOffset = Offset(7, 11);
|
||||||
|
|
||||||
@ -937,8 +932,7 @@ void main() {
|
|||||||
crossAxisOffset: 6.0,
|
crossAxisOffset: 6.0,
|
||||||
mainAxisPosition: 10.0,
|
mainAxisPosition: 10.0,
|
||||||
crossAxisPosition: 20.0,
|
crossAxisPosition: 20.0,
|
||||||
hitTest: (SliverHitTestResult result, { double mainAxisPosition, double crossAxisPosition }) {
|
hitTest: (SliverHitTestResult result, { required double mainAxisPosition, required double crossAxisPosition }) {
|
||||||
expect(result, isNotNull);
|
|
||||||
recordedMainAxisPosition = mainAxisPosition;
|
recordedMainAxisPosition = mainAxisPosition;
|
||||||
recordedCrossAxisPosition = crossAxisPosition;
|
recordedCrossAxisPosition = crossAxisPosition;
|
||||||
result.add(entry);
|
result.add(entry);
|
||||||
@ -949,7 +943,7 @@ void main() {
|
|||||||
expect(recordedMainAxisPosition, 10.0 - 5.0);
|
expect(recordedMainAxisPosition, 10.0 - 5.0);
|
||||||
expect(recordedCrossAxisPosition, 20.0 - 6.0);
|
expect(recordedCrossAxisPosition, 20.0 - 6.0);
|
||||||
expect(
|
expect(
|
||||||
entry.transform..translate(paintOffset.dx, paintOffset.dy),
|
entry.transform!..translate(paintOffset.dx, paintOffset.dy),
|
||||||
Matrix4.identity(),
|
Matrix4.identity(),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
import '../flutter_test_alternative.dart';
|
import '../flutter_test_alternative.dart';
|
||||||
|
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
@ -104,8 +102,8 @@ void main() {
|
|||||||
expect(TableBorder.lerp(tableA, tableC, 0.5), tableB);
|
expect(TableBorder.lerp(tableA, tableC, 0.5), tableB);
|
||||||
expect(TableBorder.lerp(tableA, tableB, 2.0), tableC);
|
expect(TableBorder.lerp(tableA, tableB, 2.0), tableC);
|
||||||
expect(TableBorder.lerp(tableB, tableC, -1.0), tableA);
|
expect(TableBorder.lerp(tableB, tableC, -1.0), tableA);
|
||||||
expect(TableBorder.lerp(tableA, tableC, 0.9195).isUniform, isFalse);
|
expect(TableBorder.lerp(tableA, tableC, 0.9195)!.isUniform, isFalse);
|
||||||
expect(TableBorder.lerp(tableA, tableC, 0.9195).dimensions,
|
expect(TableBorder.lerp(tableA, tableC, 0.9195)!.dimensions,
|
||||||
EdgeInsets.lerp(tableA.dimensions, tableC.dimensions, 0.9195));
|
EdgeInsets.lerp(tableA.dimensions, tableC.dimensions, 0.9195));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
|
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
// This file is separate from viewport_test.dart because we can't use both
|
// This file is separate from viewport_test.dart because we can't use both
|
||||||
// testWidgets and rendering_tester in the same file - testWidgets will
|
// testWidgets and rendering_tester in the same file - testWidgets will
|
||||||
// initialize a binding, which rendering_tester will attempt to re-initialize
|
// initialize a binding, which rendering_tester will attempt to re-initialize
|
||||||
@ -18,7 +16,7 @@ void main() {
|
|||||||
const double width = 800;
|
const double width = 800;
|
||||||
const double height = 600;
|
const double height = 600;
|
||||||
Rect rectExpandedOnAxis(double value) => Rect.fromLTRB(0.0, 0.0 - value, width, height + value);
|
Rect rectExpandedOnAxis(double value) => Rect.fromLTRB(0.0, 0.0 - value, width, height + value);
|
||||||
List<RenderSliver> children;
|
late List<RenderSliver> children;
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
children = <RenderSliver>[
|
children = <RenderSliver>[
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
// This file is separate from viewport_caching_test.dart because we can't use
|
// This file is separate from viewport_caching_test.dart because we can't use
|
||||||
// both testWidgets and rendering_tester in the same file - testWidgets will
|
// both testWidgets and rendering_tester in the same file - testWidgets will
|
||||||
// initialize a binding, which rendering_tester will attempt to re-initialize
|
// initialize a binding, which rendering_tester will attempt to re-initialize
|
||||||
@ -19,15 +17,15 @@ import 'package:flutter/widgets.dart';
|
|||||||
class _TestSliverPersistentHeaderDelegate extends SliverPersistentHeaderDelegate {
|
class _TestSliverPersistentHeaderDelegate extends SliverPersistentHeaderDelegate {
|
||||||
_TestSliverPersistentHeaderDelegate({
|
_TestSliverPersistentHeaderDelegate({
|
||||||
this.key,
|
this.key,
|
||||||
this.minExtent,
|
required this.minExtent,
|
||||||
this.maxExtent,
|
required this.maxExtent,
|
||||||
this.child,
|
this.child,
|
||||||
this.vsync = const TestVSync(),
|
this.vsync = const TestVSync(),
|
||||||
this.showOnScreenConfiguration = const PersistentHeaderShowOnScreenConfiguration(),
|
this.showOnScreenConfiguration = const PersistentHeaderShowOnScreenConfiguration(),
|
||||||
});
|
});
|
||||||
|
|
||||||
final Key key;
|
final Key? key;
|
||||||
final Widget child;
|
final Widget? child;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
final double maxExtent;
|
final double maxExtent;
|
||||||
@ -36,7 +34,7 @@ class _TestSliverPersistentHeaderDelegate extends SliverPersistentHeaderDelegate
|
|||||||
final double minExtent;
|
final double minExtent;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
final TickerProvider vsync;
|
final TickerProvider? vsync;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
final PersistentHeaderShowOnScreenConfiguration showOnScreenConfiguration;
|
final PersistentHeaderShowOnScreenConfiguration showOnScreenConfiguration;
|
||||||
@ -537,11 +535,19 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Nested Viewports showOnScreen', (WidgetTester tester) async {
|
testWidgets('Nested Viewports showOnScreen', (WidgetTester tester) async {
|
||||||
final List<List<Widget>> children = List<List<Widget>>(10);
|
|
||||||
final List<ScrollController> controllersX = List<ScrollController>.generate(10, (int i) => ScrollController(initialScrollOffset: 400.0));
|
final List<ScrollController> controllersX = List<ScrollController>.generate(10, (int i) => ScrollController(initialScrollOffset: 400.0));
|
||||||
final ScrollController controllerY = ScrollController(initialScrollOffset: 400.0);
|
final ScrollController controllerY = ScrollController(initialScrollOffset: 400.0);
|
||||||
|
final List<List<Widget>> children = List<List<Widget>>.generate(10, (int y) {
|
||||||
|
return List<Widget>.generate(10, (int x) {
|
||||||
|
return Container(
|
||||||
|
height: 100.0,
|
||||||
|
width: 100.0,
|
||||||
|
child: Text('$x,$y'),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
/// Builds a gird:
|
/// Builds a grid:
|
||||||
///
|
///
|
||||||
/// <- x ->
|
/// <- x ->
|
||||||
/// 0 1 2 3 4 5 6 7 8 9
|
/// 0 1 2 3 4 5 6 7 8 9
|
||||||
@ -574,13 +580,7 @@ void main() {
|
|||||||
child: ListView(
|
child: ListView(
|
||||||
scrollDirection: Axis.horizontal,
|
scrollDirection: Axis.horizontal,
|
||||||
controller: controllersX[y],
|
controller: controllersX[y],
|
||||||
children: children[y] = List<Widget>.generate(10, (int x) {
|
children: children[y],
|
||||||
return Container(
|
|
||||||
height: 100.0,
|
|
||||||
width: 100.0,
|
|
||||||
child: Text('$x,$y'),
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
@ -695,9 +695,15 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
group('Nested viewports (same orientation) showOnScreen', () {
|
group('Nested viewports (same orientation) showOnScreen', () {
|
||||||
List<Widget> children;
|
final List<Widget> children = List<Widget>.generate(10, (int i) {
|
||||||
|
return Container(
|
||||||
|
height: 100.0,
|
||||||
|
width: 300.0,
|
||||||
|
child: Text('$i'),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
Future<void> buildNestedScroller({ WidgetTester tester, ScrollController inner, ScrollController outer }) {
|
Future<void> buildNestedScroller({ required WidgetTester tester, required ScrollController inner, required ScrollController outer }) {
|
||||||
return tester.pumpWidget(
|
return tester.pumpWidget(
|
||||||
Directionality(
|
Directionality(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
@ -716,13 +722,7 @@ void main() {
|
|||||||
width: 300.0,
|
width: 300.0,
|
||||||
child: ListView(
|
child: ListView(
|
||||||
controller: inner,
|
controller: inner,
|
||||||
children: children = List<Widget>.generate(10, (int i) {
|
children: children,
|
||||||
return Container(
|
|
||||||
height: 100.0,
|
|
||||||
width: 300.0,
|
|
||||||
child: Text('$i'),
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
@ -1127,12 +1127,12 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
void testFloatingHeaderShowOnScreen({ bool animated = true, Axis axis = Axis.vertical }) {
|
void testFloatingHeaderShowOnScreen({ bool animated = true, Axis axis = Axis.vertical }) {
|
||||||
final TickerProvider vsync = animated ? const TestVSync() : null;
|
final TickerProvider? vsync = animated ? const TestVSync() : null;
|
||||||
const Key headerKey = Key('header');
|
const Key headerKey = Key('header');
|
||||||
List<Widget> children;
|
late List<Widget> children;
|
||||||
ScrollController controller;
|
final ScrollController controller = ScrollController(initialScrollOffset: 300.0);
|
||||||
|
|
||||||
Widget buildList({ SliverPersistentHeader floatingHeader, bool reversed = false }) {
|
Widget buildList({ required SliverPersistentHeader floatingHeader, bool reversed = false }) {
|
||||||
return Directionality(
|
return Directionality(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: Center(
|
child: Center(
|
||||||
@ -1142,7 +1142,7 @@ void main() {
|
|||||||
child: CustomScrollView(
|
child: CustomScrollView(
|
||||||
scrollDirection: axis,
|
scrollDirection: axis,
|
||||||
center: reversed ? const Key('19') : null,
|
center: reversed ? const Key('19') : null,
|
||||||
controller: controller = ScrollController(initialScrollOffset: 300.0),
|
controller: controller,
|
||||||
slivers: children = List<Widget>.generate(20, (int i) {
|
slivers: children = List<Widget>.generate(20, (int i) {
|
||||||
return i == 10
|
return i == 10
|
||||||
? floatingHeader
|
? floatingHeader
|
||||||
@ -1164,7 +1164,7 @@ void main() {
|
|||||||
double mainAxisExtent(WidgetTester tester, Finder finder) {
|
double mainAxisExtent(WidgetTester tester, Finder finder) {
|
||||||
final RenderObject renderObject = tester.renderObject(finder);
|
final RenderObject renderObject = tester.renderObject(finder);
|
||||||
if (renderObject is RenderSliver) {
|
if (renderObject is RenderSliver) {
|
||||||
return renderObject.geometry.paintExtent;
|
return renderObject.geometry!.paintExtent;
|
||||||
}
|
}
|
||||||
|
|
||||||
final RenderBox renderBox = renderObject as RenderBox;
|
final RenderBox renderBox = renderObject as RenderBox;
|
||||||
@ -1174,8 +1174,6 @@ void main() {
|
|||||||
case Axis.vertical:
|
case Axis.vertical:
|
||||||
return renderBox.size.height;
|
return renderBox.size.height;
|
||||||
}
|
}
|
||||||
assert(false);
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
group('animated: $animated, scrollDirection: $axis', () {
|
group('animated: $animated, scrollDirection: $axis', () {
|
||||||
@ -1437,7 +1435,7 @@ void main() {
|
|||||||
group('RenderViewport getOffsetToReveal renderBox to sliver coordinates conversion', () {
|
group('RenderViewport getOffsetToReveal renderBox to sliver coordinates conversion', () {
|
||||||
const EdgeInsets padding = EdgeInsets.fromLTRB(22, 22, 34, 34);
|
const EdgeInsets padding = EdgeInsets.fromLTRB(22, 22, 34, 34);
|
||||||
const Key centerKey = Key('5');
|
const Key centerKey = Key('5');
|
||||||
Widget buildList({ Axis axis, bool reverse = false, bool reverseGrowth = false }) {
|
Widget buildList({ required Axis axis, bool reverse = false, bool reverseGrowth = false }) {
|
||||||
return Directionality(
|
return Directionality(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: Center(
|
child: Center(
|
||||||
@ -1613,12 +1611,12 @@ void main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> expectFlutterError({
|
Future<void> expectFlutterError({
|
||||||
Widget widget,
|
required Widget widget,
|
||||||
WidgetTester tester,
|
required WidgetTester tester,
|
||||||
String message,
|
required String message,
|
||||||
}) async {
|
}) async {
|
||||||
final List<FlutterErrorDetails> errors = <FlutterErrorDetails>[];
|
final List<FlutterErrorDetails> errors = <FlutterErrorDetails>[];
|
||||||
final FlutterExceptionHandler oldHandler = FlutterError.onError;
|
final FlutterExceptionHandler? oldHandler = FlutterError.onError;
|
||||||
FlutterError.onError = (FlutterErrorDetails error) => errors.add(error);
|
FlutterError.onError = (FlutterErrorDetails error) => errors.add(error);
|
||||||
try {
|
try {
|
||||||
await tester.pumpWidget(widget);
|
await tester.pumpWidget(widget);
|
||||||
@ -1705,13 +1703,12 @@ void main() {
|
|||||||
final RenderViewport renderViewport = RenderViewport(
|
final RenderViewport renderViewport = RenderViewport(
|
||||||
crossAxisDirection: AxisDirection.right, offset: ViewportOffset.zero()
|
crossAxisDirection: AxisDirection.right, offset: ViewportOffset.zero()
|
||||||
);
|
);
|
||||||
FlutterError error;
|
late FlutterError error;
|
||||||
try {
|
try {
|
||||||
renderViewport.computeMinIntrinsicHeight(0);
|
renderViewport.computeMinIntrinsicHeight(0);
|
||||||
} on FlutterError catch (e) {
|
} on FlutterError catch (e) {
|
||||||
error = e;
|
error = e;
|
||||||
}
|
}
|
||||||
expect(error, isNotNull);
|
|
||||||
expect(
|
expect(
|
||||||
error.toStringDeep(),
|
error.toStringDeep(),
|
||||||
'FlutterError\n'
|
'FlutterError\n'
|
||||||
@ -1728,7 +1725,6 @@ void main() {
|
|||||||
final RenderShrinkWrappingViewport renderShrinkWrappingViewport = RenderShrinkWrappingViewport(
|
final RenderShrinkWrappingViewport renderShrinkWrappingViewport = RenderShrinkWrappingViewport(
|
||||||
crossAxisDirection: AxisDirection.right, offset: ViewportOffset.zero()
|
crossAxisDirection: AxisDirection.right, offset: ViewportOffset.zero()
|
||||||
);
|
);
|
||||||
error = null;
|
|
||||||
try {
|
try {
|
||||||
renderShrinkWrappingViewport.computeMinIntrinsicHeight(0);
|
renderShrinkWrappingViewport.computeMinIntrinsicHeight(0);
|
||||||
} on FlutterError catch (e) {
|
} on FlutterError catch (e) {
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter/semantics.dart';
|
import 'package:flutter/semantics.dart';
|
||||||
|
|
||||||
import '../flutter_test_alternative.dart';
|
import '../flutter_test_alternative.dart';
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
@ -236,16 +234,16 @@ void main() {
|
|||||||
|
|
||||||
// TODO(goderbauer): remove awkward workaround when accessing force-merged
|
// TODO(goderbauer): remove awkward workaround when accessing force-merged
|
||||||
// SemanticsData becomes easier, https://github.com/flutter/flutter/issues/25669
|
// SemanticsData becomes easier, https://github.com/flutter/flutter/issues/25669
|
||||||
SemanticsData mergedChildData;
|
SemanticsData? mergedChildData;
|
||||||
elevation10.visitChildren((SemanticsNode child) {
|
elevation10.visitChildren((SemanticsNode child) {
|
||||||
expect(mergedChildData, isNull);
|
expect(mergedChildData, isNull);
|
||||||
mergedChildData = child.getSemanticsData();
|
mergedChildData = child.getSemanticsData();
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(mergedChildData.thickness, 15.0);
|
expect(mergedChildData!.thickness, 15.0);
|
||||||
expect(mergedChildData.elevation, 10.0);
|
expect(mergedChildData!.elevation, 10.0);
|
||||||
expect(mergedChildData.label, 'abs. elevation 25.0\nabs. elevation 15.0');
|
expect(mergedChildData!.label, 'abs. elevation 25.0\nabs. elevation 15.0');
|
||||||
|
|
||||||
semantics.dispose();
|
semantics.dispose();
|
||||||
});
|
});
|
||||||
@ -291,16 +289,16 @@ void main() {
|
|||||||
|
|
||||||
// TODO(goderbauer): remove awkward workaround when accessing force-merged
|
// TODO(goderbauer): remove awkward workaround when accessing force-merged
|
||||||
// SemanticsData becomes easier, https://github.com/flutter/flutter/issues/25669
|
// SemanticsData becomes easier, https://github.com/flutter/flutter/issues/25669
|
||||||
SemanticsData mergedChildData;
|
SemanticsData? mergedChildData;
|
||||||
elevation10.visitChildren((SemanticsNode child) {
|
elevation10.visitChildren((SemanticsNode child) {
|
||||||
expect(mergedChildData, isNull);
|
expect(mergedChildData, isNull);
|
||||||
mergedChildData = child.getSemanticsData();
|
mergedChildData = child.getSemanticsData();
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(mergedChildData.thickness, 15.0);
|
expect(mergedChildData!.thickness, 15.0);
|
||||||
expect(mergedChildData.elevation, 10.0);
|
expect(mergedChildData!.elevation, 10.0);
|
||||||
expect(mergedChildData.label, 'abs. elevation 15.0\nabs. elevation 25.0');
|
expect(mergedChildData!.label, 'abs. elevation 15.0\nabs. elevation 25.0');
|
||||||
|
|
||||||
semantics.dispose();
|
semantics.dispose();
|
||||||
});
|
});
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'dart:ui' show TextDirection;
|
import 'dart:ui' show TextDirection;
|
||||||
|
|
||||||
import 'package:flutter/semantics.dart';
|
import 'package:flutter/semantics.dart';
|
||||||
@ -17,11 +15,12 @@ void main() {
|
|||||||
|
|
||||||
test('Semantic announcement', () async {
|
test('Semantic announcement', () async {
|
||||||
final List<Map<dynamic, dynamic>> log = <Map<dynamic, dynamic>>[];
|
final List<Map<dynamic, dynamic>> log = <Map<dynamic, dynamic>>[];
|
||||||
|
Future<dynamic> handleMessage(dynamic mockMessage) async {
|
||||||
SystemChannels.accessibility.setMockMessageHandler((Object mockMessage) async {
|
|
||||||
final Map<dynamic, dynamic> message = mockMessage as Map<dynamic, dynamic>;
|
final Map<dynamic, dynamic> message = mockMessage as Map<dynamic, dynamic>;
|
||||||
log.add(message);
|
log.add(message);
|
||||||
});
|
}
|
||||||
|
|
||||||
|
SystemChannels.accessibility.setMockMessageHandler(handleMessage);
|
||||||
|
|
||||||
await SemanticsService.announce('announcement 1', TextDirection.ltr);
|
await SemanticsService.announce('announcement 1', TextDirection.ltr);
|
||||||
await SemanticsService.announce('announcement 2', TextDirection.rtl);
|
await SemanticsService.announce('announcement 2', TextDirection.rtl);
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:flutter/semantics.dart';
|
import 'package:flutter/semantics.dart';
|
||||||
import 'package:vector_math/vector_math_64.dart';
|
import 'package:vector_math/vector_math_64.dart';
|
||||||
@ -11,7 +9,6 @@ import 'package:flutter_test/flutter_test.dart';
|
|||||||
|
|
||||||
import '../rendering/rendering_tester.dart';
|
import '../rendering/rendering_tester.dart';
|
||||||
|
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
setUp(() {
|
setUp(() {
|
||||||
debugResetSemanticsIdCounter();
|
debugResetSemanticsIdCounter();
|
||||||
@ -32,7 +29,7 @@ void main() {
|
|||||||
expect(node.isTagged(tag1), isTrue);
|
expect(node.isTagged(tag1), isTrue);
|
||||||
expect(node.isTagged(tag2), isFalse);
|
expect(node.isTagged(tag2), isFalse);
|
||||||
|
|
||||||
node.tags.add(tag2);
|
node.tags!.add(tag2);
|
||||||
expect(node.isTagged(tag1), isTrue);
|
expect(node.isTagged(tag1), isTrue);
|
||||||
expect(node.isTagged(tag2), isTrue);
|
expect(node.isTagged(tag2), isTrue);
|
||||||
});
|
});
|
||||||
@ -90,7 +87,7 @@ void main() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
{
|
{
|
||||||
FlutterError error;
|
late FlutterError error;
|
||||||
try {
|
try {
|
||||||
node.updateWith(
|
node.updateWith(
|
||||||
config: config,
|
config: config,
|
||||||
@ -99,7 +96,6 @@ void main() {
|
|||||||
} on FlutterError catch (e) {
|
} on FlutterError catch (e) {
|
||||||
error = e;
|
error = e;
|
||||||
}
|
}
|
||||||
expect(error, isNotNull);
|
|
||||||
expect(error.toString(), equalsIgnoringHashCodes(
|
expect(error.toString(), equalsIgnoringHashCodes(
|
||||||
'Failed to replace child semantics nodes because the list of `SemanticsNode`s was mutated.\n'
|
'Failed to replace child semantics nodes because the list of `SemanticsNode`s was mutated.\n'
|
||||||
'Instead of mutating the existing list, create a new list containing the desired `SemanticsNode`s.\n'
|
'Instead of mutating the existing list, create a new list containing the desired `SemanticsNode`s.\n'
|
||||||
@ -113,7 +109,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
FlutterError error;
|
late FlutterError error;
|
||||||
final List<SemanticsNode> modifiedChildren = <SemanticsNode>[
|
final List<SemanticsNode> modifiedChildren = <SemanticsNode>[
|
||||||
SemanticsNode()
|
SemanticsNode()
|
||||||
..isMergedIntoParent = true
|
..isMergedIntoParent = true
|
||||||
@ -140,7 +136,6 @@ void main() {
|
|||||||
} on FlutterError catch (e) {
|
} on FlutterError catch (e) {
|
||||||
error = e;
|
error = e;
|
||||||
}
|
}
|
||||||
expect(error, isNotNull);
|
|
||||||
expect(error.toStringDeep(), equalsIgnoringHashCodes(
|
expect(error.toStringDeep(), equalsIgnoringHashCodes(
|
||||||
'FlutterError\n'
|
'FlutterError\n'
|
||||||
' Failed to replace child semantics nodes because the list of\n'
|
' Failed to replace child semantics nodes because the list of\n'
|
||||||
@ -195,7 +190,7 @@ void main() {
|
|||||||
pumpFrame(phase: EnginePhase.flushSemantics);
|
pumpFrame(phase: EnginePhase.flushSemantics);
|
||||||
|
|
||||||
int expectedActions = SemanticsAction.tap.index | SemanticsAction.longPress.index | SemanticsAction.scrollLeft.index | SemanticsAction.scrollRight.index;
|
int expectedActions = SemanticsAction.tap.index | SemanticsAction.longPress.index | SemanticsAction.scrollLeft.index | SemanticsAction.scrollRight.index;
|
||||||
expect(root.debugSemantics.getSemanticsData().actions, expectedActions);
|
expect(root.debugSemantics!.getSemanticsData().actions, expectedActions);
|
||||||
|
|
||||||
middle
|
middle
|
||||||
..hasScrollLeftAction = false
|
..hasScrollLeftAction = false
|
||||||
@ -205,7 +200,7 @@ void main() {
|
|||||||
pumpFrame(phase: EnginePhase.flushSemantics);
|
pumpFrame(phase: EnginePhase.flushSemantics);
|
||||||
|
|
||||||
expectedActions = SemanticsAction.tap.index | SemanticsAction.longPress.index | SemanticsAction.scrollDown.index | SemanticsAction.scrollRight.index;
|
expectedActions = SemanticsAction.tap.index | SemanticsAction.longPress.index | SemanticsAction.scrollDown.index | SemanticsAction.scrollRight.index;
|
||||||
expect(root.debugSemantics.getSemanticsData().actions, expectedActions);
|
expect(root.debugSemantics!.getSemanticsData().actions, expectedActions);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -683,8 +678,8 @@ class TestRender extends RenderProxyBox {
|
|||||||
this.hasScrollRightAction = false,
|
this.hasScrollRightAction = false,
|
||||||
this.hasScrollUpAction = false,
|
this.hasScrollUpAction = false,
|
||||||
this.hasScrollDownAction = false,
|
this.hasScrollDownAction = false,
|
||||||
this.isSemanticBoundary,
|
this.isSemanticBoundary = false,
|
||||||
RenderBox child,
|
RenderBox? child,
|
||||||
}) : super(child);
|
}) : super(child);
|
||||||
|
|
||||||
bool hasTapAction;
|
bool hasTapAction;
|
||||||
@ -695,7 +690,6 @@ class TestRender extends RenderProxyBox {
|
|||||||
bool hasScrollDownAction;
|
bool hasScrollDownAction;
|
||||||
bool isSemanticBoundary;
|
bool isSemanticBoundary;
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void describeSemanticsConfiguration(SemanticsConfiguration config) {
|
void describeSemanticsConfiguration(SemanticsConfiguration config) {
|
||||||
super.describeSemanticsConfiguration(config);
|
super.describeSemanticsConfiguration(config);
|
||||||
@ -717,5 +711,5 @@ class TestRender extends RenderProxyBox {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class CustomSortKey extends OrdinalSortKey {
|
class CustomSortKey extends OrdinalSortKey {
|
||||||
const CustomSortKey(double order, {String name}) : super(order, name: name);
|
const CustomSortKey(double order, {String? name}) : super(order, name: name);
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
import 'dart:ui' as ui;
|
import 'dart:ui' as ui;
|
||||||
|
|
||||||
@ -48,12 +46,12 @@ void main() {
|
|||||||
expect(SemanticsUpdateBuilderSpy.observations.length, 2);
|
expect(SemanticsUpdateBuilderSpy.observations.length, 2);
|
||||||
|
|
||||||
expect(SemanticsUpdateBuilderSpy.observations.containsKey(0), isTrue);
|
expect(SemanticsUpdateBuilderSpy.observations.containsKey(0), isTrue);
|
||||||
expect(SemanticsUpdateBuilderSpy.observations[0].childrenInTraversalOrder.length, 1);
|
expect(SemanticsUpdateBuilderSpy.observations[0]!.childrenInTraversalOrder.length, 1);
|
||||||
expect(SemanticsUpdateBuilderSpy.observations[0].childrenInTraversalOrder[0], 1);
|
expect(SemanticsUpdateBuilderSpy.observations[0]!.childrenInTraversalOrder[0], 1);
|
||||||
|
|
||||||
expect(SemanticsUpdateBuilderSpy.observations.containsKey(1), isTrue);
|
expect(SemanticsUpdateBuilderSpy.observations.containsKey(1), isTrue);
|
||||||
expect(SemanticsUpdateBuilderSpy.observations[1].childrenInTraversalOrder.length, 0);
|
expect(SemanticsUpdateBuilderSpy.observations[1]!.childrenInTraversalOrder.length, 0);
|
||||||
expect(SemanticsUpdateBuilderSpy.observations[1].label, 'outer\ninner\ntext');
|
expect(SemanticsUpdateBuilderSpy.observations[1]!.label, 'outer\ninner\ntext');
|
||||||
|
|
||||||
SemanticsUpdateBuilderSpy.observations.clear();
|
SemanticsUpdateBuilderSpy.observations.clear();
|
||||||
|
|
||||||
@ -79,8 +77,8 @@ void main() {
|
|||||||
expect(SemanticsUpdateBuilderSpy.observations.length, 1);
|
expect(SemanticsUpdateBuilderSpy.observations.length, 1);
|
||||||
|
|
||||||
expect(SemanticsUpdateBuilderSpy.observations.containsKey(1), isTrue);
|
expect(SemanticsUpdateBuilderSpy.observations.containsKey(1), isTrue);
|
||||||
expect(SemanticsUpdateBuilderSpy.observations[1].childrenInTraversalOrder.length, 0);
|
expect(SemanticsUpdateBuilderSpy.observations[1]!.childrenInTraversalOrder.length, 0);
|
||||||
expect(SemanticsUpdateBuilderSpy.observations[1].label, 'outer\ninner-updated\ntext');
|
expect(SemanticsUpdateBuilderSpy.observations[1]!.label, 'outer\ninner-updated\ntext');
|
||||||
|
|
||||||
SemanticsUpdateBuilderSpy.observations.clear();
|
SemanticsUpdateBuilderSpy.observations.clear();
|
||||||
handle.dispose();
|
handle.dispose();
|
||||||
@ -99,32 +97,32 @@ class SemanticsUpdateBuilderSpy extends ui.SemanticsUpdateBuilder {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void updateNode({
|
void updateNode({
|
||||||
@required int id,
|
required int id,
|
||||||
@required int flags,
|
required int flags,
|
||||||
@required int actions,
|
required int actions,
|
||||||
@required int maxValueLength,
|
required int maxValueLength,
|
||||||
@required int currentValueLength,
|
required int currentValueLength,
|
||||||
@required int textSelectionBase,
|
required int textSelectionBase,
|
||||||
@required int textSelectionExtent,
|
required int textSelectionExtent,
|
||||||
@required int platformViewId,
|
required int platformViewId,
|
||||||
@required int scrollChildren,
|
required int scrollChildren,
|
||||||
@required int scrollIndex,
|
required int scrollIndex,
|
||||||
@required double scrollPosition,
|
required double scrollPosition,
|
||||||
@required double scrollExtentMax,
|
required double scrollExtentMax,
|
||||||
@required double scrollExtentMin,
|
required double scrollExtentMin,
|
||||||
@required double elevation,
|
required double elevation,
|
||||||
@required double thickness,
|
required double thickness,
|
||||||
@required Rect rect,
|
required Rect rect,
|
||||||
@required String label,
|
required String label,
|
||||||
@required String hint,
|
required String hint,
|
||||||
@required String value,
|
required String value,
|
||||||
@required String increasedValue,
|
required String increasedValue,
|
||||||
@required String decreasedValue,
|
required String decreasedValue,
|
||||||
TextDirection textDirection,
|
TextDirection? textDirection,
|
||||||
@required Float64List transform,
|
required Float64List transform,
|
||||||
@required Int32List childrenInTraversalOrder,
|
required Int32List childrenInTraversalOrder,
|
||||||
@required Int32List childrenInHitTestOrder,
|
required Int32List childrenInHitTestOrder,
|
||||||
@required Int32List additionalActions,
|
required Int32List additionalActions,
|
||||||
}) {
|
}) {
|
||||||
// Makes sure we don't send the same id twice.
|
// Makes sure we don't send the same id twice.
|
||||||
assert(!observations.containsKey(id));
|
assert(!observations.containsKey(id));
|
||||||
@ -161,32 +159,32 @@ class SemanticsUpdateBuilderSpy extends ui.SemanticsUpdateBuilder {
|
|||||||
|
|
||||||
class SemanticsNodeUpdateObservation {
|
class SemanticsNodeUpdateObservation {
|
||||||
const SemanticsNodeUpdateObservation({
|
const SemanticsNodeUpdateObservation({
|
||||||
@required this.id,
|
required this.id,
|
||||||
@required this.flags,
|
required this.flags,
|
||||||
@required this.actions,
|
required this.actions,
|
||||||
@required this.maxValueLength,
|
required this.maxValueLength,
|
||||||
@required this.currentValueLength,
|
required this.currentValueLength,
|
||||||
@required this.textSelectionBase,
|
required this.textSelectionBase,
|
||||||
@required this.textSelectionExtent,
|
required this.textSelectionExtent,
|
||||||
@required this.platformViewId,
|
required this.platformViewId,
|
||||||
@required this.scrollChildren,
|
required this.scrollChildren,
|
||||||
@required this.scrollIndex,
|
required this.scrollIndex,
|
||||||
@required this.scrollPosition,
|
required this.scrollPosition,
|
||||||
@required this.scrollExtentMax,
|
required this.scrollExtentMax,
|
||||||
@required this.scrollExtentMin,
|
required this.scrollExtentMin,
|
||||||
@required this.elevation,
|
required this.elevation,
|
||||||
@required this.thickness,
|
required this.thickness,
|
||||||
@required this.rect,
|
required this.rect,
|
||||||
@required this.label,
|
required this.label,
|
||||||
@required this.hint,
|
required this.hint,
|
||||||
@required this.value,
|
required this.value,
|
||||||
@required this.increasedValue,
|
required this.increasedValue,
|
||||||
@required this.decreasedValue,
|
required this.decreasedValue,
|
||||||
this.textDirection,
|
this.textDirection,
|
||||||
@required this.transform,
|
required this.transform,
|
||||||
@required this.childrenInTraversalOrder,
|
required this.childrenInTraversalOrder,
|
||||||
@required this.childrenInHitTestOrder,
|
required this.childrenInHitTestOrder,
|
||||||
@required this.additionalActions,
|
required this.additionalActions,
|
||||||
});
|
});
|
||||||
|
|
||||||
final int id;
|
final int id;
|
||||||
@ -210,7 +208,7 @@ class SemanticsNodeUpdateObservation {
|
|||||||
final String value;
|
final String value;
|
||||||
final String increasedValue;
|
final String increasedValue;
|
||||||
final String decreasedValue;
|
final String decreasedValue;
|
||||||
final TextDirection textDirection;
|
final TextDirection? textDirection;
|
||||||
final Float64List transform;
|
final Float64List transform;
|
||||||
final Int32List childrenInTraversalOrder;
|
final Int32List childrenInTraversalOrder;
|
||||||
final Int32List childrenInHitTestOrder;
|
final Int32List childrenInHitTestOrder;
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@ -28,7 +26,7 @@ class ThirdTestIntent extends SecondTestIntent {
|
|||||||
|
|
||||||
class TestAction extends CallbackAction<TestIntent> {
|
class TestAction extends CallbackAction<TestIntent> {
|
||||||
TestAction({
|
TestAction({
|
||||||
@required OnInvokeCallback onInvoke,
|
required OnInvokeCallback onInvoke,
|
||||||
}) : assert(onInvoke != null),
|
}) : assert(onInvoke != null),
|
||||||
super(onInvoke: onInvoke);
|
super(onInvoke: onInvoke);
|
||||||
|
|
||||||
@ -64,23 +62,23 @@ class TestAction extends CallbackAction<TestIntent> {
|
|||||||
class TestDispatcher extends ActionDispatcher {
|
class TestDispatcher extends ActionDispatcher {
|
||||||
const TestDispatcher({this.postInvoke});
|
const TestDispatcher({this.postInvoke});
|
||||||
|
|
||||||
final PostInvokeCallback postInvoke;
|
final PostInvokeCallback? postInvoke;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Object invokeAction(Action<Intent> action, Intent intent, [BuildContext context]) {
|
Object? invokeAction(Action<Intent> action, Intent intent, [BuildContext? context]) {
|
||||||
final Object result = super.invokeAction(action, intent, context);
|
final Object? result = super.invokeAction(action, intent, context);
|
||||||
postInvoke?.call(action: action, intent: intent, dispatcher: this);
|
postInvoke?.call(action: action, intent: intent, dispatcher: this);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class TestDispatcher1 extends TestDispatcher {
|
class TestDispatcher1 extends TestDispatcher {
|
||||||
const TestDispatcher1({PostInvokeCallback postInvoke}) : super(postInvoke: postInvoke);
|
const TestDispatcher1({PostInvokeCallback? postInvoke}) : super(postInvoke: postInvoke);
|
||||||
}
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
testWidgets('CallbackAction passes correct intent when invoked.', (WidgetTester tester) async {
|
testWidgets('CallbackAction passes correct intent when invoked.', (WidgetTester tester) async {
|
||||||
Intent passedIntent;
|
late Intent passedIntent;
|
||||||
final TestAction action = TestAction(onInvoke: (Intent intent) {
|
final TestAction action = TestAction(onInvoke: (Intent intent) {
|
||||||
passedIntent = intent;
|
passedIntent = intent;
|
||||||
return true;
|
return true;
|
||||||
@ -94,7 +92,7 @@ void main() {
|
|||||||
await tester.pumpWidget(Container());
|
await tester.pumpWidget(Container());
|
||||||
bool invoked = false;
|
bool invoked = false;
|
||||||
const ActionDispatcher dispatcher = ActionDispatcher();
|
const ActionDispatcher dispatcher = ActionDispatcher();
|
||||||
final Object result = dispatcher.invokeAction(
|
final Object? result = dispatcher.invokeAction(
|
||||||
TestAction(
|
TestAction(
|
||||||
onInvoke: (Intent intent) {
|
onInvoke: (Intent intent) {
|
||||||
invoked = true;
|
invoked = true;
|
||||||
@ -108,11 +106,11 @@ void main() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
group(Actions, () {
|
group(Actions, () {
|
||||||
Intent invokedIntent;
|
Intent? invokedIntent;
|
||||||
Action<Intent> invokedAction;
|
Action<Intent>? invokedAction;
|
||||||
ActionDispatcher invokedDispatcher;
|
ActionDispatcher? invokedDispatcher;
|
||||||
|
|
||||||
void collect({Action<Intent> action, Intent intent, ActionDispatcher dispatcher}) {
|
void collect({Action<Intent>? action, Intent? intent, ActionDispatcher? dispatcher}) {
|
||||||
invokedIntent = intent;
|
invokedIntent = intent;
|
||||||
invokedAction = action;
|
invokedAction = action;
|
||||||
invokedDispatcher = dispatcher;
|
invokedDispatcher = dispatcher;
|
||||||
@ -145,8 +143,8 @@ void main() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
final Object result = Actions.invoke(
|
final Object? result = Actions.invoke(
|
||||||
containerKey.currentContext,
|
containerKey.currentContext!,
|
||||||
const TestIntent(),
|
const TestIntent(),
|
||||||
);
|
);
|
||||||
expect(result, isTrue);
|
expect(result, isTrue);
|
||||||
@ -174,8 +172,8 @@ void main() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
final Object result = Actions.invoke<TestIntent>(
|
final Object? result = Actions.invoke<TestIntent>(
|
||||||
containerKey.currentContext,
|
containerKey.currentContext!,
|
||||||
intent,
|
intent,
|
||||||
);
|
);
|
||||||
expect(result, isTrue);
|
expect(result, isTrue);
|
||||||
@ -208,8 +206,8 @@ void main() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
final Object result = Actions.invoke<TestIntent>(
|
final Object? result = Actions.invoke<TestIntent>(
|
||||||
containerKey.currentContext,
|
containerKey.currentContext!,
|
||||||
intent,
|
intent,
|
||||||
);
|
);
|
||||||
expect(result, isTrue);
|
expect(result, isTrue);
|
||||||
@ -243,8 +241,8 @@ void main() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
final Object result = Actions.invoke<TestIntent>(
|
final Object? result = Actions.invoke<TestIntent>(
|
||||||
containerKey.currentContext,
|
containerKey.currentContext!,
|
||||||
intent,
|
intent,
|
||||||
);
|
);
|
||||||
expect(result, isTrue);
|
expect(result, isTrue);
|
||||||
@ -267,7 +265,7 @@ void main() {
|
|||||||
|
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
final ActionDispatcher dispatcher = Actions.of(
|
final ActionDispatcher dispatcher = Actions.of(
|
||||||
containerKey.currentContext,
|
containerKey.currentContext!,
|
||||||
nullOk: true,
|
nullOk: true,
|
||||||
);
|
);
|
||||||
expect(dispatcher, equals(testDispatcher));
|
expect(dispatcher, equals(testDispatcher));
|
||||||
@ -296,9 +294,9 @@ void main() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
expect(Actions.find<TestIntent>(containerKey.currentContext), equals(testAction));
|
expect(Actions.find<TestIntent>(containerKey.currentContext!), equals(testAction));
|
||||||
expect(() => Actions.find<DoNothingIntent>(containerKey.currentContext), throwsAssertionError);
|
expect(() => Actions.find<DoNothingIntent>(containerKey.currentContext!), throwsAssertionError);
|
||||||
expect(Actions.find<DoNothingIntent>(containerKey.currentContext, nullOk: true), isNull);
|
expect(Actions.find<DoNothingIntent>(containerKey.currentContext!, nullOk: true), isNull);
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Actions(
|
Actions(
|
||||||
@ -316,9 +314,9 @@ void main() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
expect(Actions.find<TestIntent>(containerKey.currentContext), equals(testAction));
|
expect(Actions.find<TestIntent>(containerKey.currentContext!), equals(testAction));
|
||||||
expect(() => Actions.find<DoNothingIntent>(containerKey.currentContext), throwsAssertionError);
|
expect(() => Actions.find<DoNothingIntent>(containerKey.currentContext!), throwsAssertionError);
|
||||||
expect(Actions.find<DoNothingIntent>(containerKey.currentContext, nullOk: true), isNull);
|
expect(Actions.find<DoNothingIntent>(containerKey.currentContext!, nullOk: true), isNull);
|
||||||
});
|
});
|
||||||
testWidgets('FocusableActionDetector keeps track of focus and hover even when disabled.', (WidgetTester tester) async {
|
testWidgets('FocusableActionDetector keeps track of focus and hover even when disabled.', (WidgetTester tester) async {
|
||||||
FocusManager.instance.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
|
FocusManager.instance.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
|
||||||
@ -407,7 +405,7 @@ void main() {
|
|||||||
addTearDown(gesture.removePointer);
|
addTearDown(gesture.removePointer);
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
|
|
||||||
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.text);
|
expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.text);
|
||||||
|
|
||||||
// Test default
|
// Test default
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
@ -421,7 +419,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.forbidden);
|
expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.forbidden);
|
||||||
});
|
});
|
||||||
testWidgets('Actions.invoke returns the value of Action.invoke', (WidgetTester tester) async {
|
testWidgets('Actions.invoke returns the value of Action.invoke', (WidgetTester tester) async {
|
||||||
final GlobalKey containerKey = GlobalKey();
|
final GlobalKey containerKey = GlobalKey();
|
||||||
@ -446,8 +444,8 @@ void main() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
final Object result = Actions.invoke<TestIntent>(
|
final Object? result = Actions.invoke<TestIntent>(
|
||||||
containerKey.currentContext,
|
containerKey.currentContext!,
|
||||||
intent,
|
intent,
|
||||||
);
|
);
|
||||||
expect(identical(result, sentinel), isTrue);
|
expect(identical(result, sentinel), isTrue);
|
||||||
@ -509,8 +507,8 @@ void main() {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
Object result = Actions.invoke(
|
Object? result = Actions.invoke(
|
||||||
containerKey.currentContext,
|
containerKey.currentContext!,
|
||||||
const TestIntent(),
|
const TestIntent(),
|
||||||
);
|
);
|
||||||
expect(enabled1, isFalse);
|
expect(enabled1, isFalse);
|
||||||
@ -519,14 +517,14 @@ void main() {
|
|||||||
|
|
||||||
action1.enabled = true;
|
action1.enabled = true;
|
||||||
result = Actions.invoke(
|
result = Actions.invoke(
|
||||||
containerKey.currentContext,
|
containerKey.currentContext!,
|
||||||
const TestIntent(),
|
const TestIntent(),
|
||||||
);
|
);
|
||||||
expect(enabled1, isTrue);
|
expect(enabled1, isTrue);
|
||||||
expect(result, isTrue);
|
expect(result, isTrue);
|
||||||
expect(invoked1, isTrue);
|
expect(invoked1, isTrue);
|
||||||
|
|
||||||
bool enabledChanged;
|
bool? enabledChanged;
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Actions(
|
Actions(
|
||||||
actions: <Type, Action<Intent>>{
|
actions: <Type, Action<Intent>>{
|
||||||
@ -548,7 +546,7 @@ void main() {
|
|||||||
|
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
result = Actions.invoke<TestIntent>(
|
result = Actions.invoke<TestIntent>(
|
||||||
containerKey.currentContext,
|
containerKey.currentContext!,
|
||||||
const SecondTestIntent(),
|
const SecondTestIntent(),
|
||||||
);
|
);
|
||||||
expect(enabledChanged, isNull);
|
expect(enabledChanged, isNull);
|
||||||
@ -559,7 +557,7 @@ void main() {
|
|||||||
action2.enabled = true;
|
action2.enabled = true;
|
||||||
expect(enabledChanged, isTrue);
|
expect(enabledChanged, isTrue);
|
||||||
result = Actions.invoke<TestIntent>(
|
result = Actions.invoke<TestIntent>(
|
||||||
containerKey.currentContext,
|
containerKey.currentContext!,
|
||||||
const SecondTestIntent(),
|
const SecondTestIntent(),
|
||||||
);
|
);
|
||||||
expect(enabled2, isTrue);
|
expect(enabled2, isTrue);
|
||||||
@ -622,18 +620,18 @@ void main() {
|
|||||||
|
|
||||||
group(FocusableActionDetector, () {
|
group(FocusableActionDetector, () {
|
||||||
const Intent intent = TestIntent();
|
const Intent intent = TestIntent();
|
||||||
bool invoked;
|
late bool invoked;
|
||||||
bool hovering;
|
late bool hovering;
|
||||||
bool focusing;
|
late bool focusing;
|
||||||
FocusNode focusNode;
|
late FocusNode focusNode;
|
||||||
Action<Intent> testAction;
|
late Action<Intent> testAction;
|
||||||
|
|
||||||
Future<void> pumpTest(
|
Future<void> pumpTest(
|
||||||
WidgetTester tester, {
|
WidgetTester tester, {
|
||||||
bool enabled = true,
|
bool enabled = true,
|
||||||
bool directional = false,
|
bool directional = false,
|
||||||
bool supplyCallbacks = true,
|
bool supplyCallbacks = true,
|
||||||
@required Key key,
|
required Key key,
|
||||||
}) async {
|
}) async {
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
MediaQuery(
|
MediaQuery(
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
@ -26,20 +24,17 @@ void main() {
|
|||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
const Align(
|
const Align(
|
||||||
key: GlobalObjectKey<State<StatefulWidget>>(null),
|
|
||||||
alignment: Alignment.topLeft,
|
alignment: Alignment.topLeft,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
await tester.pumpWidget(const Directionality(
|
await tester.pumpWidget(const Directionality(
|
||||||
textDirection: TextDirection.rtl,
|
textDirection: TextDirection.rtl,
|
||||||
child: Align(
|
child: Align(
|
||||||
key: GlobalObjectKey<State<StatefulWidget>>(null),
|
|
||||||
alignment: AlignmentDirectional.topStart,
|
alignment: AlignmentDirectional.topStart,
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
const Align(
|
const Align(
|
||||||
key: GlobalObjectKey<State<StatefulWidget>>(null),
|
|
||||||
alignment: Alignment.topLeft,
|
alignment: Alignment.topLeft,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -108,7 +103,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
final Size size = alignKey.currentContext.size;
|
final Size size = alignKey.currentContext!.size!;
|
||||||
expect(size.width, equals(800.0));
|
expect(size.width, equals(800.0));
|
||||||
expect(size.height, equals(10.0));
|
expect(size.height, equals(10.0));
|
||||||
});
|
});
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
@ -47,7 +45,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
final RenderDecoratedBox box = key.currentContext.findRenderObject() as RenderDecoratedBox;
|
final RenderDecoratedBox box = key.currentContext!.findRenderObject() as RenderDecoratedBox;
|
||||||
actualDecoration = box.decoration as BoxDecoration;
|
actualDecoration = box.decoration as BoxDecoration;
|
||||||
expect(actualDecoration.color, equals(decorationA.color));
|
expect(actualDecoration.color, equals(decorationA.color));
|
||||||
|
|
||||||
@ -59,7 +57,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(key.currentContext.findRenderObject(), equals(box));
|
expect(key.currentContext!.findRenderObject(), equals(box));
|
||||||
actualDecoration = box.decoration as BoxDecoration;
|
actualDecoration = box.decoration as BoxDecoration;
|
||||||
expect(actualDecoration.color, equals(decorationA.color));
|
expect(actualDecoration.color, equals(decorationA.color));
|
||||||
|
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter/scheduler.dart';
|
import 'package:flutter/scheduler.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
@ -373,7 +371,7 @@ class _TickerWatchingWidget extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _TickerWatchingWidgetState extends State<_TickerWatchingWidget> with SingleTickerProviderStateMixin {
|
class _TickerWatchingWidgetState extends State<_TickerWatchingWidget> with SingleTickerProviderStateMixin {
|
||||||
Ticker ticker;
|
late Ticker ticker;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:flutter/src/foundation/diagnostics.dart';
|
import 'package:flutter/src/foundation/diagnostics.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
@ -37,11 +35,11 @@ void main() {
|
|||||||
&& widget.itemBuilder == builder;
|
&& widget.itemBuilder == builder;
|
||||||
}), findsOneWidget);
|
}), findsOneWidget);
|
||||||
|
|
||||||
listKey.currentState.insertItem(0);
|
listKey.currentState!.insertItem(0);
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
expect(find.text('item 2'), findsOneWidget);
|
expect(find.text('item 2'), findsOneWidget);
|
||||||
|
|
||||||
listKey.currentState.removeItem(
|
listKey.currentState!.removeItem(
|
||||||
2,
|
2,
|
||||||
(BuildContext context, Animation<double> animation) {
|
(BuildContext context, Animation<double> animation) {
|
||||||
return const SizedBox(
|
return const SizedBox(
|
||||||
@ -90,8 +88,8 @@ void main() {
|
|||||||
expect(find.text('item 1'), findsOneWidget);
|
expect(find.text('item 1'), findsOneWidget);
|
||||||
expect(animations.containsKey(0), true);
|
expect(animations.containsKey(0), true);
|
||||||
expect(animations.containsKey(1), true);
|
expect(animations.containsKey(1), true);
|
||||||
expect(animations[0].value, 1.0);
|
expect(animations[0]!.value, 1.0);
|
||||||
expect(animations[1].value, 1.0);
|
expect(animations[1]!.value, 1.0);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('insert', (WidgetTester tester) async {
|
testWidgets('insert', (WidgetTester tester) async {
|
||||||
@ -125,7 +123,7 @@ void main() {
|
|||||||
double itemTop(int index) => tester.getTopLeft(find.byKey(ValueKey<int>(index), skipOffstage: false)).dy;
|
double itemTop(int index) => tester.getTopLeft(find.byKey(ValueKey<int>(index), skipOffstage: false)).dy;
|
||||||
double itemBottom(int index) => tester.getBottomLeft(find.byKey(ValueKey<int>(index), skipOffstage: false)).dy;
|
double itemBottom(int index) => tester.getBottomLeft(find.byKey(ValueKey<int>(index), skipOffstage: false)).dy;
|
||||||
|
|
||||||
listKey.currentState.insertItem(
|
listKey.currentState!.insertItem(
|
||||||
0,
|
0,
|
||||||
duration: const Duration(milliseconds: 100),
|
duration: const Duration(milliseconds: 100),
|
||||||
);
|
);
|
||||||
@ -143,11 +141,11 @@ void main() {
|
|||||||
expect(itemTop(0), 0.0);
|
expect(itemTop(0), 0.0);
|
||||||
expect(itemBottom(0), 100.0);
|
expect(itemBottom(0), 100.0);
|
||||||
|
|
||||||
listKey.currentState.insertItem(
|
listKey.currentState!.insertItem(
|
||||||
0,
|
0,
|
||||||
duration: const Duration(milliseconds: 100),
|
duration: const Duration(milliseconds: 100),
|
||||||
);
|
);
|
||||||
listKey.currentState.insertItem(
|
listKey.currentState!.insertItem(
|
||||||
0,
|
0,
|
||||||
duration: const Duration(milliseconds: 100),
|
duration: const Duration(milliseconds: 100),
|
||||||
);
|
);
|
||||||
@ -223,7 +221,7 @@ void main() {
|
|||||||
expect(find.text('item 2'), findsOneWidget);
|
expect(find.text('item 2'), findsOneWidget);
|
||||||
|
|
||||||
items.removeAt(0);
|
items.removeAt(0);
|
||||||
listKey.currentState.removeItem(
|
listKey.currentState!.removeItem(
|
||||||
0,
|
0,
|
||||||
(BuildContext context, Animation<double> animation) => buildItem(context, 0, animation),
|
(BuildContext context, Animation<double> animation) => buildItem(context, 0, animation),
|
||||||
duration: const Duration(milliseconds: 100),
|
duration: const Duration(milliseconds: 100),
|
||||||
@ -289,11 +287,11 @@ void main() {
|
|||||||
expect(tester.getTopLeft(find.text('item 0')).dy, 200);
|
expect(tester.getTopLeft(find.text('item 0')).dy, 200);
|
||||||
expect(tester.getTopLeft(find.text('item 1')).dy, 300);
|
expect(tester.getTopLeft(find.text('item 1')).dy, 300);
|
||||||
|
|
||||||
listKey.currentState.insertItem(3);
|
listKey.currentState!.insertItem(3);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(tester.getTopLeft(find.text('item 3')).dy, 500);
|
expect(tester.getTopLeft(find.text('item 3')).dy, 500);
|
||||||
|
|
||||||
listKey.currentState.removeItem(0,
|
listKey.currentState!.removeItem(0,
|
||||||
(BuildContext context, Animation<double> animation) {
|
(BuildContext context, Animation<double> animation) {
|
||||||
return SizeTransition(
|
return SizeTransition(
|
||||||
sizeFactor: animation,
|
sizeFactor: animation,
|
||||||
@ -327,13 +325,12 @@ void main() {
|
|||||||
(WidgetTester tester) async {
|
(WidgetTester tester) async {
|
||||||
final GlobalKey key = GlobalKey();
|
final GlobalKey key = GlobalKey();
|
||||||
await tester.pumpWidget(Container(key: key));
|
await tester.pumpWidget(Container(key: key));
|
||||||
FlutterError error;
|
late FlutterError error;
|
||||||
try {
|
try {
|
||||||
AnimatedList.of(key.currentContext);
|
AnimatedList.of(key.currentContext!);
|
||||||
} on FlutterError catch (e) {
|
} on FlutterError catch (e) {
|
||||||
error = e;
|
error = e;
|
||||||
}
|
}
|
||||||
expect(error, isNotNull);
|
|
||||||
expect(error.diagnostics.length, 4);
|
expect(error.diagnostics.length, 4);
|
||||||
expect(error.diagnostics[2].level, DiagnosticLevel.hint);
|
expect(error.diagnostics[2].level, DiagnosticLevel.hint);
|
||||||
expect(
|
expect(
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
@ -44,12 +42,12 @@ void main() {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
box = key.currentContext.findRenderObject() as RenderBox;
|
box = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0 + 70.0 / 2.0, 30.0 + 110.0 / 2.0)));
|
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0 + 70.0 / 2.0, 30.0 + 110.0 / 2.0)));
|
||||||
|
|
||||||
await tester.pump(const Duration(seconds: 1));
|
await tester.pump(const Duration(seconds: 1));
|
||||||
|
|
||||||
box = key.currentContext.findRenderObject() as RenderBox;
|
box = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0 + 70.0 / 2.0, 30.0 + 110.0 / 2.0)));
|
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0 + 70.0 / 2.0, 30.0 + 110.0 / 2.0)));
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
@ -71,17 +69,17 @@ void main() {
|
|||||||
const Offset first = Offset(50.0 + 70.0 / 2.0, 30.0 + 110.0 / 2.0);
|
const Offset first = Offset(50.0 + 70.0 / 2.0, 30.0 + 110.0 / 2.0);
|
||||||
const Offset last = Offset(37.0 + 59.0 / 2.0, 31.0 + 71.0 / 2.0);
|
const Offset last = Offset(37.0 + 59.0 / 2.0, 31.0 + 71.0 / 2.0);
|
||||||
|
|
||||||
box = key.currentContext.findRenderObject() as RenderBox;
|
box = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(first));
|
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(first));
|
||||||
|
|
||||||
await tester.pump(const Duration(seconds: 1));
|
await tester.pump(const Duration(seconds: 1));
|
||||||
|
|
||||||
box = key.currentContext.findRenderObject() as RenderBox;
|
box = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(Offset.lerp(first, last, 0.5)));
|
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(Offset.lerp(first, last, 0.5)));
|
||||||
|
|
||||||
await tester.pump(const Duration(seconds: 1));
|
await tester.pump(const Duration(seconds: 1));
|
||||||
|
|
||||||
box = key.currentContext.findRenderObject() as RenderBox;
|
box = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(last));
|
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(last));
|
||||||
|
|
||||||
expect(box, hasAGoodToStringDeep);
|
expect(box, hasAGoodToStringDeep);
|
||||||
@ -128,12 +126,12 @@ void main() {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
box = key.currentContext.findRenderObject() as RenderBox;
|
box = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0 + 70.0 / 2.0, 30.0 + 110.0 / 2.0)));
|
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0 + 70.0 / 2.0, 30.0 + 110.0 / 2.0)));
|
||||||
|
|
||||||
await tester.pump(const Duration(seconds: 1));
|
await tester.pump(const Duration(seconds: 1));
|
||||||
|
|
||||||
box = key.currentContext.findRenderObject() as RenderBox;
|
box = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0 + 70.0 / 2.0, 30.0 + 110.0 / 2.0)));
|
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0 + 70.0 / 2.0, 30.0 + 110.0 / 2.0)));
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
@ -157,17 +155,17 @@ void main() {
|
|||||||
const Offset first = Offset(50.0 + 70.0 / 2.0, 30.0 + 110.0 / 2.0);
|
const Offset first = Offset(50.0 + 70.0 / 2.0, 30.0 + 110.0 / 2.0);
|
||||||
const Offset last = Offset(37.0 + 59.0 / 2.0, 31.0 + 71.0 / 2.0);
|
const Offset last = Offset(37.0 + 59.0 / 2.0, 31.0 + 71.0 / 2.0);
|
||||||
|
|
||||||
box = key.currentContext.findRenderObject() as RenderBox;
|
box = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(first));
|
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(first));
|
||||||
|
|
||||||
await tester.pump(const Duration(seconds: 1));
|
await tester.pump(const Duration(seconds: 1));
|
||||||
|
|
||||||
box = key.currentContext.findRenderObject() as RenderBox;
|
box = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(Offset.lerp(first, last, 0.5)));
|
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(Offset.lerp(first, last, 0.5)));
|
||||||
|
|
||||||
await tester.pump(const Duration(seconds: 1));
|
await tester.pump(const Duration(seconds: 1));
|
||||||
|
|
||||||
box = key.currentContext.findRenderObject() as RenderBox;
|
box = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(last));
|
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(last));
|
||||||
|
|
||||||
expect(box, hasAGoodToStringDeep);
|
expect(box, hasAGoodToStringDeep);
|
||||||
@ -214,12 +212,12 @@ void main() {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
box = key.currentContext.findRenderObject() as RenderBox;
|
box = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(800.0 - 50.0 - 70.0 / 2.0, 30.0 + 110.0 / 2.0)));
|
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(800.0 - 50.0 - 70.0 / 2.0, 30.0 + 110.0 / 2.0)));
|
||||||
|
|
||||||
await tester.pump(const Duration(seconds: 1));
|
await tester.pump(const Duration(seconds: 1));
|
||||||
|
|
||||||
box = key.currentContext.findRenderObject() as RenderBox;
|
box = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(800.0 - 50.0 - 70.0 / 2.0, 30.0 + 110.0 / 2.0)));
|
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(800.0 - 50.0 - 70.0 / 2.0, 30.0 + 110.0 / 2.0)));
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
@ -243,17 +241,17 @@ void main() {
|
|||||||
const Offset first = Offset(800.0 - 50.0 - 70.0 / 2.0, 30.0 + 110.0 / 2.0);
|
const Offset first = Offset(800.0 - 50.0 - 70.0 / 2.0, 30.0 + 110.0 / 2.0);
|
||||||
const Offset last = Offset(800.0 - 37.0 - 59.0 / 2.0, 31.0 + 71.0 / 2.0);
|
const Offset last = Offset(800.0 - 37.0 - 59.0 / 2.0, 31.0 + 71.0 / 2.0);
|
||||||
|
|
||||||
box = key.currentContext.findRenderObject() as RenderBox;
|
box = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(first));
|
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(first));
|
||||||
|
|
||||||
await tester.pump(const Duration(seconds: 1));
|
await tester.pump(const Duration(seconds: 1));
|
||||||
|
|
||||||
box = key.currentContext.findRenderObject() as RenderBox;
|
box = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(Offset.lerp(first, last, 0.5)));
|
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(Offset.lerp(first, last, 0.5)));
|
||||||
|
|
||||||
await tester.pump(const Duration(seconds: 1));
|
await tester.pump(const Duration(seconds: 1));
|
||||||
|
|
||||||
box = key.currentContext.findRenderObject() as RenderBox;
|
box = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(last));
|
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(last));
|
||||||
|
|
||||||
expect(box, hasAGoodToStringDeep);
|
expect(box, hasAGoodToStringDeep);
|
||||||
@ -298,12 +296,12 @@ void main() {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
box = key.currentContext.findRenderObject() as RenderBox;
|
box = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0)));
|
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0)));
|
||||||
|
|
||||||
await tester.pump(const Duration(seconds: 1));
|
await tester.pump(const Duration(seconds: 1));
|
||||||
|
|
||||||
box = key.currentContext.findRenderObject() as RenderBox;
|
box = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0)));
|
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0)));
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
@ -322,12 +320,12 @@ void main() {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
box = key.currentContext.findRenderObject() as RenderBox;
|
box = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0)));
|
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0)));
|
||||||
|
|
||||||
await tester.pump(const Duration(seconds: 1));
|
await tester.pump(const Duration(seconds: 1));
|
||||||
|
|
||||||
box = key.currentContext.findRenderObject() as RenderBox;
|
box = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(100.0, 100.0)));
|
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(100.0, 100.0)));
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
@ -346,17 +344,17 @@ void main() {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
box = key.currentContext.findRenderObject() as RenderBox;
|
box = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(100.0, 100.0)));
|
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(100.0, 100.0)));
|
||||||
|
|
||||||
await tester.pump(const Duration(seconds: 1));
|
await tester.pump(const Duration(seconds: 1));
|
||||||
|
|
||||||
box = key.currentContext.findRenderObject() as RenderBox;
|
box = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(150.0, 150.0)));
|
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(150.0, 150.0)));
|
||||||
|
|
||||||
await tester.pump(const Duration(seconds: 1));
|
await tester.pump(const Duration(seconds: 1));
|
||||||
|
|
||||||
box = key.currentContext.findRenderObject() as RenderBox;
|
box = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(200.0, 200.0)));
|
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(200.0, 200.0)));
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -381,12 +379,12 @@ void main() {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
box = key.currentContext.findRenderObject() as RenderBox;
|
box = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0)));
|
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0)));
|
||||||
|
|
||||||
await tester.pump(const Duration(seconds: 1));
|
await tester.pump(const Duration(seconds: 1));
|
||||||
|
|
||||||
box = key.currentContext.findRenderObject() as RenderBox;
|
box = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0)));
|
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0)));
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
@ -405,17 +403,17 @@ void main() {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
box = key.currentContext.findRenderObject() as RenderBox;
|
box = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(350.0, 50.0)));
|
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(350.0, 50.0)));
|
||||||
|
|
||||||
await tester.pump(const Duration(seconds: 1));
|
await tester.pump(const Duration(seconds: 1));
|
||||||
|
|
||||||
box = key.currentContext.findRenderObject() as RenderBox;
|
box = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(350.0, 100.0)));
|
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(350.0, 100.0)));
|
||||||
|
|
||||||
await tester.pump(const Duration(seconds: 1));
|
await tester.pump(const Duration(seconds: 1));
|
||||||
|
|
||||||
box = key.currentContext.findRenderObject() as RenderBox;
|
box = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(350.0, 150.0)));
|
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(350.0, 150.0)));
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -442,12 +440,12 @@ void main() {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
box = key.currentContext.findRenderObject() as RenderBox;
|
box = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0)));
|
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0)));
|
||||||
|
|
||||||
await tester.pump(const Duration(seconds: 1));
|
await tester.pump(const Duration(seconds: 1));
|
||||||
|
|
||||||
box = key.currentContext.findRenderObject() as RenderBox;
|
box = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0)));
|
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0)));
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
@ -468,12 +466,12 @@ void main() {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
box = key.currentContext.findRenderObject() as RenderBox;
|
box = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0)));
|
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0)));
|
||||||
|
|
||||||
await tester.pump(const Duration(seconds: 1));
|
await tester.pump(const Duration(seconds: 1));
|
||||||
|
|
||||||
box = key.currentContext.findRenderObject() as RenderBox;
|
box = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(100.0, 100.0)));
|
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(100.0, 100.0)));
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
@ -494,17 +492,17 @@ void main() {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
box = key.currentContext.findRenderObject() as RenderBox;
|
box = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(100.0, 100.0)));
|
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(100.0, 100.0)));
|
||||||
|
|
||||||
await tester.pump(const Duration(seconds: 1));
|
await tester.pump(const Duration(seconds: 1));
|
||||||
|
|
||||||
box = key.currentContext.findRenderObject() as RenderBox;
|
box = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(150.0, 150.0)));
|
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(150.0, 150.0)));
|
||||||
|
|
||||||
await tester.pump(const Duration(seconds: 1));
|
await tester.pump(const Duration(seconds: 1));
|
||||||
|
|
||||||
box = key.currentContext.findRenderObject() as RenderBox;
|
box = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(200.0, 200.0)));
|
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(200.0, 200.0)));
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -531,12 +529,12 @@ void main() {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
box = key.currentContext.findRenderObject() as RenderBox;
|
box = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0)));
|
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0)));
|
||||||
|
|
||||||
await tester.pump(const Duration(seconds: 1));
|
await tester.pump(const Duration(seconds: 1));
|
||||||
|
|
||||||
box = key.currentContext.findRenderObject() as RenderBox;
|
box = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0)));
|
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0)));
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
@ -557,17 +555,17 @@ void main() {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
box = key.currentContext.findRenderObject() as RenderBox;
|
box = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(350.0, 50.0)));
|
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(350.0, 50.0)));
|
||||||
|
|
||||||
await tester.pump(const Duration(seconds: 1));
|
await tester.pump(const Duration(seconds: 1));
|
||||||
|
|
||||||
box = key.currentContext.findRenderObject() as RenderBox;
|
box = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(350.0, 100.0)));
|
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(350.0, 100.0)));
|
||||||
|
|
||||||
await tester.pump(const Duration(seconds: 1));
|
await tester.pump(const Duration(seconds: 1));
|
||||||
|
|
||||||
box = key.currentContext.findRenderObject() as RenderBox;
|
box = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(350.0, 150.0)));
|
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(350.0, 150.0)));
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -594,12 +592,12 @@ void main() {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
box = key.currentContext.findRenderObject() as RenderBox;
|
box = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(750.0, 50.0)));
|
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(750.0, 50.0)));
|
||||||
|
|
||||||
await tester.pump(const Duration(seconds: 1));
|
await tester.pump(const Duration(seconds: 1));
|
||||||
|
|
||||||
box = key.currentContext.findRenderObject() as RenderBox;
|
box = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(750.0, 50.0)));
|
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(750.0, 50.0)));
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
@ -620,12 +618,12 @@ void main() {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
box = key.currentContext.findRenderObject() as RenderBox;
|
box = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(750.0, 50.0)));
|
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(750.0, 50.0)));
|
||||||
|
|
||||||
await tester.pump(const Duration(seconds: 1));
|
await tester.pump(const Duration(seconds: 1));
|
||||||
|
|
||||||
box = key.currentContext.findRenderObject() as RenderBox;
|
box = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(700.0, 100.0)));
|
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(700.0, 100.0)));
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
@ -646,17 +644,17 @@ void main() {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
box = key.currentContext.findRenderObject() as RenderBox;
|
box = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(700.0, 100.0)));
|
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(700.0, 100.0)));
|
||||||
|
|
||||||
await tester.pump(const Duration(seconds: 1));
|
await tester.pump(const Duration(seconds: 1));
|
||||||
|
|
||||||
box = key.currentContext.findRenderObject() as RenderBox;
|
box = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(650.0, 150.0)));
|
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(650.0, 150.0)));
|
||||||
|
|
||||||
await tester.pump(const Duration(seconds: 1));
|
await tester.pump(const Duration(seconds: 1));
|
||||||
|
|
||||||
box = key.currentContext.findRenderObject() as RenderBox;
|
box = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(600.0, 200.0)));
|
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(600.0, 200.0)));
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -683,12 +681,12 @@ void main() {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
box = key.currentContext.findRenderObject() as RenderBox;
|
box = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(750.0, 50.0)));
|
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(750.0, 50.0)));
|
||||||
|
|
||||||
await tester.pump(const Duration(seconds: 1));
|
await tester.pump(const Duration(seconds: 1));
|
||||||
|
|
||||||
box = key.currentContext.findRenderObject() as RenderBox;
|
box = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(750.0, 50.0)));
|
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(750.0, 50.0)));
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
@ -709,17 +707,17 @@ void main() {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
box = key.currentContext.findRenderObject() as RenderBox;
|
box = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(450.0, 50.0)));
|
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(450.0, 50.0)));
|
||||||
|
|
||||||
await tester.pump(const Duration(seconds: 1));
|
await tester.pump(const Duration(seconds: 1));
|
||||||
|
|
||||||
box = key.currentContext.findRenderObject() as RenderBox;
|
box = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(450.0, 100.0)));
|
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(450.0, 100.0)));
|
||||||
|
|
||||||
await tester.pump(const Duration(seconds: 1));
|
await tester.pump(const Duration(seconds: 1));
|
||||||
|
|
||||||
box = key.currentContext.findRenderObject() as RenderBox;
|
box = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(450.0, 150.0)));
|
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(450.0, 150.0)));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
@ -144,7 +142,7 @@ void main() {
|
|||||||
await tester.pump(Duration(milliseconds: millis));
|
await tester.pump(Duration(milliseconds: millis));
|
||||||
}
|
}
|
||||||
|
|
||||||
void verify({ double size, RenderAnimatedSizeState state }) {
|
void verify({ double? size, RenderAnimatedSizeState? state }) {
|
||||||
assert(size != null || state != null);
|
assert(size != null || state != null);
|
||||||
final RenderAnimatedSize box = tester.renderObject(find.byType(AnimatedSize));
|
final RenderAnimatedSize box = tester.renderObject(find.byType(AnimatedSize));
|
||||||
if (size != null) {
|
if (size != null) {
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
@ -211,9 +209,12 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('AnimatedSwitcher uses custom layout.', (WidgetTester tester) async {
|
testWidgets('AnimatedSwitcher uses custom layout.', (WidgetTester tester) async {
|
||||||
Widget newLayoutBuilder(Widget currentChild, List<Widget> previousChildren) {
|
Widget newLayoutBuilder(Widget? currentChild, List<Widget> previousChildren) {
|
||||||
return Column(
|
return Column(
|
||||||
children: previousChildren + <Widget>[currentChild],
|
children: <Widget>[
|
||||||
|
...previousChildren,
|
||||||
|
if (currentChild != null) currentChild,
|
||||||
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,16 +231,13 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('AnimatedSwitcher uses custom transitions.', (WidgetTester tester) async {
|
testWidgets('AnimatedSwitcher uses custom transitions.', (WidgetTester tester) async {
|
||||||
final List<Widget> foundChildren = <Widget>[];
|
late List<Widget> foundChildren;
|
||||||
Widget newLayoutBuilder(Widget currentChild, List<Widget> previousChildren) {
|
Widget newLayoutBuilder(Widget? currentChild, List<Widget> previousChildren) {
|
||||||
foundChildren.clear();
|
foundChildren = <Widget>[
|
||||||
if (currentChild != null) {
|
if (currentChild != null) currentChild,
|
||||||
foundChildren.add(currentChild);
|
...previousChildren,
|
||||||
}
|
];
|
||||||
foundChildren.addAll(previousChildren);
|
return Column(children: foundChildren);
|
||||||
return Column(
|
|
||||||
children: foundChildren,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget newTransitionBuilder(Widget child, Animation<double> animation) {
|
Widget newTransitionBuilder(Widget child, Animation<double> animation) {
|
||||||
@ -381,16 +379,13 @@ void main() {
|
|||||||
final UniqueKey containerTwo = UniqueKey();
|
final UniqueKey containerTwo = UniqueKey();
|
||||||
final UniqueKey containerThree = UniqueKey();
|
final UniqueKey containerThree = UniqueKey();
|
||||||
|
|
||||||
final List<Widget> foundChildren = <Widget>[];
|
late List<Widget> foundChildren;
|
||||||
Widget newLayoutBuilder(Widget currentChild, List<Widget> previousChildren) {
|
Widget newLayoutBuilder(Widget? currentChild, List<Widget> previousChildren) {
|
||||||
foundChildren.clear();
|
foundChildren = <Widget>[
|
||||||
if (currentChild != null) {
|
if (currentChild != null) currentChild,
|
||||||
foundChildren.add(currentChild);
|
...previousChildren,
|
||||||
}
|
];
|
||||||
foundChildren.addAll(previousChildren);
|
return Column(children: foundChildren);
|
||||||
return Column(
|
|
||||||
children: foundChildren,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Insert three unique children so that we have some previous children.
|
// Insert three unique children so that we have some previous children.
|
||||||
@ -472,7 +467,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class StatefulTest extends StatefulWidget {
|
class StatefulTest extends StatefulWidget {
|
||||||
const StatefulTest({Key key}) : super(key: key);
|
const StatefulTest({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
StatefulTestState createState() => StatefulTestState();
|
StatefulTestState createState() => StatefulTestState();
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'dart:ui' show window;
|
import 'dart:ui' show window;
|
||||||
|
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
@ -32,12 +30,12 @@ void main() {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
int result = RendererBinding.instance.renderView.debugLayer.find<int>(Offset(
|
int? result = RendererBinding.instance!.renderView.debugLayer!.find<int>(Offset(
|
||||||
10.0 * window.devicePixelRatio,
|
10.0 * window.devicePixelRatio,
|
||||||
10.0 * window.devicePixelRatio,
|
10.0 * window.devicePixelRatio,
|
||||||
));
|
));
|
||||||
expect(result, null);
|
expect(result, null);
|
||||||
result = RendererBinding.instance.renderView.debugLayer.find<int>(Offset(
|
result = RendererBinding.instance!.renderView.debugLayer!.find<int>(Offset(
|
||||||
50.0 * window.devicePixelRatio,
|
50.0 * window.devicePixelRatio,
|
||||||
50.0 * window.devicePixelRatio,
|
50.0 * window.devicePixelRatio,
|
||||||
));
|
));
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user