Unverified Commit 1c535de7 authored by Tong Mu's avatar Tong Mu Committed by GitHub

Soften layer breakage (#42953)

* Replace hard break of Layer.find/All with findAllAnnotations
* Deprecate findAll
parent 124dc661
...@@ -123,7 +123,7 @@ class MouseTracker extends ChangeNotifier { ...@@ -123,7 +123,7 @@ class MouseTracker extends ChangeNotifier {
/// ///
/// The second parameter is a function with which the [MouseTracker] can /// The second parameter is a function with which the [MouseTracker] can
/// search for [MouseTrackerAnnotation]s at a given position. /// search for [MouseTrackerAnnotation]s at a given position.
/// Usually it is [Layer.findAll] of the root layer. /// Usually it is [Layer.findAllAnnotations] of the root layer.
/// ///
/// All of the parameters must not be null. /// All of the parameters must not be null.
MouseTracker(this._router, this.annotationFinder) MouseTracker(this._router, this.annotationFinder)
......
...@@ -18,8 +18,7 @@ import 'debug.dart'; ...@@ -18,8 +18,7 @@ import 'debug.dart';
/// ///
/// See also: /// See also:
/// ///
/// * [Layer.find], [Layer.findAll], and [Layer.findAnnotations], which create /// * [Layer.findAnnotations], which create and use objects of this class.
/// and use objects of this class.
@immutable @immutable
class AnnotationEntry<T> { class AnnotationEntry<T> {
/// Create an entry of found annotation by providing the oject and related /// Create an entry of found annotation by providing the oject and related
...@@ -48,8 +47,8 @@ class AnnotationEntry<T> { ...@@ -48,8 +47,8 @@ class AnnotationEntry<T> {
/// See also: /// See also:
/// ///
/// * [AnnotationEntry], which are members of this class. /// * [AnnotationEntry], which are members of this class.
/// * [Layer.findAll], and [Layer.findAnnotations], which create and use an /// * [Layer.findAllAnnotations], and [Layer.findAnnotations], which create and
/// object of this class. /// use an object of this class.
class AnnotationResult<T> { class AnnotationResult<T> {
final List<AnnotationEntry<T>> _entries = <AnnotationEntry<T>>[]; final List<AnnotationEntry<T>> _entries = <AnnotationEntry<T>>[];
...@@ -280,23 +279,28 @@ abstract class Layer extends AbstractNode with DiagnosticableTreeMixin { ...@@ -280,23 +279,28 @@ abstract class Layer extends AbstractNode with DiagnosticableTreeMixin {
/// location described by `localPosition`. /// location described by `localPosition`.
/// ///
/// This method is called by the default implementation of [find] and /// This method is called by the default implementation of [find] and
/// [findAll]. Override this method to customize how the layer should search /// [findAllAnnotations]. Override this method to customize how the layer
/// for annotations, or if the layer has its own annotations to add. /// should search for annotations, or if the layer has its own annotations to
/// add.
///
/// The default implementation simply returns `false`, which means neither
/// the layer nor its children has annotations, and the annotation search
/// is not absorbed either (see below for explanation).
/// ///
/// ## About layer annotations /// ## About layer annotations
/// ///
/// {@template flutter.rendering.layer.findAnnotations.aboutAnnotations} /// {@template flutter.rendering.layer.findAnnotations.aboutAnnotations}
/// Annotation is an optional object of any type that can be carried with a /// An annotation is an optional object of any type that can be carried with a
/// layer. An annotation can be found at a location as long as the owner layer /// layer. An annotation can be found at a location as long as the owner layer
/// contains the location and is walked to. /// contains the location and is walked to.
/// ///
/// The annotations are searched by first visitng each child recursively, then /// The annotations are searched by first visiting each child recursively,
/// this layer, resulting in an order from visually front to back. Annotations /// then this layer, resulting in an order from visually front to back.
/// must meet the given restrictions, such as type and position. /// Annotations must meet the given restrictions, such as type and position.
/// ///
/// The common way for a value to be found here is by pushing an /// The common way for a value to be found here is by pushing an
/// [AnnotatedRegionLayer] into the layer tree, or by adding the desired /// [AnnotatedRegionLayer] into the layer tree, or by adding the desired
/// annotation by overriding `findAnnotations`. /// annotation by overriding [findAnnotations].
/// {@endtemplate} /// {@endtemplate}
/// ///
/// ## Parameters and return value /// ## Parameters and return value
...@@ -326,7 +330,9 @@ abstract class Layer extends AbstractNode with DiagnosticableTreeMixin { ...@@ -326,7 +330,9 @@ abstract class Layer extends AbstractNode with DiagnosticableTreeMixin {
AnnotationResult<S> result, AnnotationResult<S> result,
Offset localPosition, { Offset localPosition, {
@required bool onlyFirst, @required bool onlyFirst,
}); }) {
return false;
}
/// Search this layer and its subtree for the first annotation of type `S` /// Search this layer and its subtree for the first annotation of type `S`
/// under the point described by `localPosition`. /// under the point described by `localPosition`.
...@@ -334,8 +340,10 @@ abstract class Layer extends AbstractNode with DiagnosticableTreeMixin { ...@@ -334,8 +340,10 @@ abstract class Layer extends AbstractNode with DiagnosticableTreeMixin {
/// Returns null if no matching annotations are found. /// Returns null if no matching annotations are found.
/// ///
/// By default this method simply calls [findAnnotations] with `onlyFirst: /// By default this method simply calls [findAnnotations] with `onlyFirst:
/// true` and returns the first result. It is encouraged to override /// true` and returns the annotation of the first result. Prefer overriding
/// [findAnnotations] instead of this method. /// [findAnnotations] instead of this method, because during an annotation
/// search, only [findAnnotations] is recursively called, while custom
/// behavior in this method is ignored.
/// ///
/// ## About layer annotations /// ## About layer annotations
/// ///
...@@ -343,13 +351,43 @@ abstract class Layer extends AbstractNode with DiagnosticableTreeMixin { ...@@ -343,13 +351,43 @@ abstract class Layer extends AbstractNode with DiagnosticableTreeMixin {
/// ///
/// See also: /// See also:
/// ///
/// * [findAll], which is similar but returns all annotations found at the /// * [findAllAnnotations], which is similar but returns all annotations found
/// given position. /// at the given position.
/// * [AnnotatedRegionLayer], for placing values in the layer tree. /// * [AnnotatedRegionLayer], for placing values in the layer tree.
AnnotationEntry<S> find<S>(Offset localPosition) { S find<S>(Offset localPosition) {
final AnnotationResult<S> result = AnnotationResult<S>(); final AnnotationResult<S> result = AnnotationResult<S>();
findAnnotations<S>(result, localPosition, onlyFirst: true); findAnnotations<S>(result, localPosition, onlyFirst: true);
return result.entries.isEmpty ? null : result.entries.first; return result.entries.isEmpty ? null : result.entries.first.annotation;
}
/// Search this layer and its subtree for all annotations of type `S` under
/// the point described by `localPosition`.
///
/// Returns a result with empty entries if no matching annotations are found.
///
/// By default this method simply calls [findAnnotations] with `onlyFirst:
/// false` and returns the annotations of its result. Prefer overriding
/// [findAnnotations] instead of this method, because during an annotation
/// search, only [findAnnotations] is recursively called, while custom
/// behavior in this method is ignored.
///
/// ## About layer annotations
///
/// {@macro flutter.rendering.layer.findAnnotations.aboutAnnotations}
///
/// See also:
///
/// * [find], which is similar but returns the first annotation found at the
/// given position.
/// * [findAllAnnotations], which is similar but returns an
/// [AnnotationResult], which contains more information, such as the local
/// position of the event related to each annotation, and is equally fast,
/// hence is preferred over [findAll].
/// * [AnnotatedRegionLayer], for placing values in the layer tree.
@Deprecated('Use findAllAnnotations instead. This API will be removed in early 2020.')
Iterable<S> findAll<S>(Offset localPosition) {
final AnnotationResult<S> result = findAllAnnotations(localPosition);
return result.entries.map((AnnotationEntry<S> entry) => entry.annotation);
} }
/// Search this layer and its subtree for all annotations of type `S` under /// Search this layer and its subtree for all annotations of type `S` under
...@@ -358,8 +396,10 @@ abstract class Layer extends AbstractNode with DiagnosticableTreeMixin { ...@@ -358,8 +396,10 @@ abstract class Layer extends AbstractNode with DiagnosticableTreeMixin {
/// Returns a result with empty entries if no matching annotations are found. /// Returns a result with empty entries if no matching annotations are found.
/// ///
/// By default this method simply calls [findAnnotations] with `onlyFirst: /// By default this method simply calls [findAnnotations] with `onlyFirst:
/// false` and returns its result. It is encouraged to override /// false` and returns the annotations of its result. Prefer overriding
/// [findAnnotations] instead of this method. /// [findAnnotations] instead of this method, because during an annotation
/// search, only [findAnnotations] is recursively called, while custom
/// behavior in this method is ignored.
/// ///
/// ## About layer annotations /// ## About layer annotations
/// ///
...@@ -370,7 +410,7 @@ abstract class Layer extends AbstractNode with DiagnosticableTreeMixin { ...@@ -370,7 +410,7 @@ abstract class Layer extends AbstractNode with DiagnosticableTreeMixin {
/// * [find], which is similar but returns the first annotation found at the /// * [find], which is similar but returns the first annotation found at the
/// given position. /// given position.
/// * [AnnotatedRegionLayer], for placing values in the layer tree. /// * [AnnotatedRegionLayer], for placing values in the layer tree.
AnnotationResult<S> findAll<S>(Offset localPosition) { AnnotationResult<S> findAllAnnotations<S>(Offset localPosition) {
final AnnotationResult<S> result = AnnotationResult<S>(); final AnnotationResult<S> result = AnnotationResult<S>();
findAnnotations<S>(result, localPosition, onlyFirst: false); findAnnotations<S>(result, localPosition, onlyFirst: false);
return result; return result;
...@@ -2247,10 +2287,10 @@ class FollowerLayer extends ContainerLayer { ...@@ -2247,10 +2287,10 @@ class FollowerLayer extends ContainerLayer {
/// layer to the tree is the common way of adding an annotation. /// layer to the tree is the common way of adding an annotation.
/// ///
/// An annotation is an optional object of any type that, when attached with a /// An annotation is an optional object of any type that, when attached with a
/// layer, can be retrieved using [Layer.find] or [Layer.findAll] with a /// layer, can be retrieved using [Layer.find] or [Layer.findAllAnnotations]
/// position. The search process is done recursively, controlled by a concept /// with a position. The search process is done recursively, controlled by a
/// of being opaque to a type of annotation, explained in the document of /// concept of being opaque to a type of annotation, explained in the document
/// [Layer.findAnnotations]. /// of [Layer.findAnnotations].
/// ///
/// When an annotation search arrives, this layer defers the same search to each /// When an annotation search arrives, this layer defers the same search to each
/// of this layer's children, respecting their opacity. Then it adds this /// of this layer's children, respecting their opacity. Then it adds this
......
...@@ -190,13 +190,13 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox> ...@@ -190,13 +190,13 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
/// ///
/// See also: /// See also:
/// ///
/// * [Layer.findAll], which is used by this method to find all /// * [Layer.findAllAnnotations], which is used by this method to find all
/// [AnnotatedRegionLayer]s annotated for mouse tracking. /// [AnnotatedRegionLayer]s annotated for mouse tracking.
Iterable<MouseTrackerAnnotation> hitTestMouseTrackers(Offset position) { Iterable<MouseTrackerAnnotation> hitTestMouseTrackers(Offset position) {
// Layer hit testing is done using device pixels, so we have to convert // Layer hit testing is done using device pixels, so we have to convert
// the logical coordinates of the event location back to device pixels // the logical coordinates of the event location back to device pixels
// here. // here.
return layer.findAll<MouseTrackerAnnotation>( return layer.findAllAnnotations<MouseTrackerAnnotation>(
position * configuration.devicePixelRatio position * configuration.devicePixelRatio
).annotations; ).annotations;
} }
...@@ -243,12 +243,12 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox> ...@@ -243,12 +243,12 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
final Rect bounds = paintBounds; final Rect bounds = paintBounds;
final Offset top = Offset(bounds.center.dx, _window.padding.top / _window.devicePixelRatio); final Offset top = Offset(bounds.center.dx, _window.padding.top / _window.devicePixelRatio);
final Offset bottom = Offset(bounds.center.dx, bounds.center.dy - _window.padding.bottom / _window.devicePixelRatio); final Offset bottom = Offset(bounds.center.dx, bounds.center.dy - _window.padding.bottom / _window.devicePixelRatio);
final SystemUiOverlayStyle upperOverlayStyle = layer.find<SystemUiOverlayStyle>(top)?.annotation; final SystemUiOverlayStyle upperOverlayStyle = layer.find<SystemUiOverlayStyle>(top);
// Only android has a customizable system navigation bar. // Only android has a customizable system navigation bar.
SystemUiOverlayStyle lowerOverlayStyle; SystemUiOverlayStyle lowerOverlayStyle;
switch (defaultTargetPlatform) { switch (defaultTargetPlatform) {
case TargetPlatform.android: case TargetPlatform.android:
lowerOverlayStyle = layer.find<SystemUiOverlayStyle>(bottom)?.annotation; lowerOverlayStyle = layer.find<SystemUiOverlayStyle>(bottom);
break; break;
case TargetPlatform.iOS: case TargetPlatform.iOS:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
......
...@@ -22,9 +22,9 @@ void main() { ...@@ -22,9 +22,9 @@ void main() {
i += 1; i += 1;
} }
expect(containerLayer.find<int>(const Offset(0.0, 1.0)).annotation, 0); expect(containerLayer.find<int>(const Offset(0.0, 1.0)), 0);
expect(containerLayer.find<int>(const Offset(0.0, 101.0)).annotation, 1); expect(containerLayer.find<int>(const Offset(0.0, 101.0)), 1);
expect(containerLayer.find<int>(const Offset(0.0, 201.0)).annotation, 2); expect(containerLayer.find<int>(const Offset(0.0, 201.0)), 2);
}); });
test('finds a value within the clip in a ClipRectLayer', () { test('finds a value within the clip in a ClipRectLayer', () {
...@@ -41,9 +41,9 @@ void main() { ...@@ -41,9 +41,9 @@ void main() {
i += 1; i += 1;
} }
expect(containerLayer.find<int>(const Offset(0.0, 1.0)).annotation, 0); expect(containerLayer.find<int>(const Offset(0.0, 1.0)), 0);
expect(containerLayer.find<int>(const Offset(0.0, 101.0)).annotation, 1); expect(containerLayer.find<int>(const Offset(0.0, 101.0)), 1);
expect(containerLayer.find<int>(const Offset(0.0, 201.0)).annotation, 2); expect(containerLayer.find<int>(const Offset(0.0, 201.0)), 2);
}); });
...@@ -61,9 +61,9 @@ void main() { ...@@ -61,9 +61,9 @@ void main() {
i += 1; i += 1;
} }
expect(containerLayer.find<int>(const Offset(5.0, 5.0)).annotation, 0); expect(containerLayer.find<int>(const Offset(5.0, 5.0)), 0);
expect(containerLayer.find<int>(const Offset(5.0, 105.0)).annotation, 1); expect(containerLayer.find<int>(const Offset(5.0, 105.0)), 1);
expect(containerLayer.find<int>(const Offset(5.0, 205.0)).annotation, 2); expect(containerLayer.find<int>(const Offset(5.0, 205.0)), 2);
}); });
test('finds a value under a TransformLayer', () { test('finds a value under a TransformLayer', () {
...@@ -87,11 +87,11 @@ void main() { ...@@ -87,11 +87,11 @@ void main() {
i += 1; i += 1;
} }
expect(transformLayer.find<int>(const Offset(0.0, 100.0)).annotation, 0); expect(transformLayer.find<int>(const Offset(0.0, 100.0)), 0);
expect(transformLayer.find<int>(const Offset(0.0, 200.0)).annotation, 0); expect(transformLayer.find<int>(const Offset(0.0, 200.0)), 0);
expect(transformLayer.find<int>(const Offset(0.0, 270.0)).annotation, 1); expect(transformLayer.find<int>(const Offset(0.0, 270.0)), 1);
expect(transformLayer.find<int>(const Offset(0.0, 400.0)).annotation, 1); expect(transformLayer.find<int>(const Offset(0.0, 400.0)), 1);
expect(transformLayer.find<int>(const Offset(0.0, 530.0)).annotation, 2); expect(transformLayer.find<int>(const Offset(0.0, 530.0)), 2);
}); });
test('looks for child AnnotatedRegions before parents', () { test('looks for child AnnotatedRegions before parents', () {
...@@ -101,7 +101,7 @@ void main() { ...@@ -101,7 +101,7 @@ void main() {
parent.append(child); parent.append(child);
layer.append(parent); layer.append(parent);
expect(parent.find<int>(Offset.zero).annotation, 2); expect(parent.find<int>(Offset.zero), 2);
}); });
test('looks for correct type', () { test('looks for correct type', () {
...@@ -111,7 +111,7 @@ void main() { ...@@ -111,7 +111,7 @@ void main() {
layer.append(child2); layer.append(child2);
layer.append(child1); layer.append(child1);
expect(layer.find<String>(Offset.zero).annotation, 'hello'); expect(layer.find<String>(Offset.zero), 'hello');
}); });
test('does not clip Layer.find on an AnnotatedRegion with an unrelated type', () { test('does not clip Layer.find on an AnnotatedRegion with an unrelated type', () {
...@@ -121,7 +121,7 @@ void main() { ...@@ -121,7 +121,7 @@ void main() {
parent.append(child); parent.append(child);
layer.append(parent); layer.append(parent);
expect(layer.find<int>(const Offset(100.0, 100.0)).annotation, 1); expect(layer.find<int>(const Offset(100.0, 100.0)), 1);
}); });
test('handles non-invertable transforms', () { test('handles non-invertable transforms', () {
...@@ -133,10 +133,10 @@ void main() { ...@@ -133,10 +133,10 @@ void main() {
parent.transform = Matrix4.diagonal3Values(1.0, 1.0, 1.0); parent.transform = Matrix4.diagonal3Values(1.0, 1.0, 1.0);
expect(parent.find<int>(const Offset(0.0, 0.0)).annotation, 1); expect(parent.find<int>(const Offset(0.0, 0.0)), 1);
}); });
}); });
group('$AnnotatedRegion findAll', () { group('$AnnotatedRegion findAllAnnotations', () {
test('finds the first value in a OffsetLayer when sized', () { test('finds the first value in a OffsetLayer when sized', () {
final ContainerLayer containerLayer = ContainerLayer(); final ContainerLayer containerLayer = ContainerLayer();
final List<OffsetLayer> layers = <OffsetLayer>[ final List<OffsetLayer> layers = <OffsetLayer>[
...@@ -151,9 +151,9 @@ void main() { ...@@ -151,9 +151,9 @@ void main() {
i += 1; i += 1;
} }
expect(containerLayer.findAll<int>(const Offset(0.0, 1.0)).annotations.toList(), equals(<int>[0])); expect(containerLayer.findAllAnnotations<int>(const Offset(0.0, 1.0)).annotations.toList(), equals(<int>[0]));
expect(containerLayer.findAll<int>(const Offset(0.0, 101.0)).annotations.toList(), equals(<int>[1])); expect(containerLayer.findAllAnnotations<int>(const Offset(0.0, 101.0)).annotations.toList(), equals(<int>[1]));
expect(containerLayer.findAll<int>(const Offset(0.0, 201.0)).annotations.toList(), equals(<int>[2])); expect(containerLayer.findAllAnnotations<int>(const Offset(0.0, 201.0)).annotations.toList(), equals(<int>[2]));
}); });
test('finds a value within the clip in a ClipRectLayer', () { test('finds a value within the clip in a ClipRectLayer', () {
...@@ -170,9 +170,9 @@ void main() { ...@@ -170,9 +170,9 @@ void main() {
i += 1; i += 1;
} }
expect(containerLayer.findAll<int>(const Offset(0.0, 1.0)).annotations.toList(), equals(<int>[0])); expect(containerLayer.findAllAnnotations<int>(const Offset(0.0, 1.0)).annotations.toList(), equals(<int>[0]));
expect(containerLayer.findAll<int>(const Offset(0.0, 101.0)).annotations.toList(), equals(<int>[1])); expect(containerLayer.findAllAnnotations<int>(const Offset(0.0, 101.0)).annotations.toList(), equals(<int>[1]));
expect(containerLayer.findAll<int>(const Offset(0.0, 201.0)).annotations.toList(), equals(<int>[2])); expect(containerLayer.findAllAnnotations<int>(const Offset(0.0, 201.0)).annotations.toList(), equals(<int>[2]));
}); });
...@@ -190,9 +190,9 @@ void main() { ...@@ -190,9 +190,9 @@ void main() {
i += 1; i += 1;
} }
expect(containerLayer.findAll<int>(const Offset(5.0, 5.0)).annotations.toList(), equals(<int>[0])); expect(containerLayer.findAllAnnotations<int>(const Offset(5.0, 5.0)).annotations.toList(), equals(<int>[0]));
expect(containerLayer.findAll<int>(const Offset(5.0, 105.0)).annotations.toList(), equals(<int>[1])); expect(containerLayer.findAllAnnotations<int>(const Offset(5.0, 105.0)).annotations.toList(), equals(<int>[1]));
expect(containerLayer.findAll<int>(const Offset(5.0, 205.0)).annotations.toList(), equals(<int>[2])); expect(containerLayer.findAllAnnotations<int>(const Offset(5.0, 205.0)).annotations.toList(), equals(<int>[2]));
}); });
test('finds a value under a TransformLayer', () { test('finds a value under a TransformLayer', () {
...@@ -216,11 +216,11 @@ void main() { ...@@ -216,11 +216,11 @@ void main() {
i += 1; i += 1;
} }
expect(transformLayer.findAll<int>(const Offset(0.0, 100.0)).annotations.toList(), equals(<int>[0])); expect(transformLayer.findAllAnnotations<int>(const Offset(0.0, 100.0)).annotations.toList(), equals(<int>[0]));
expect(transformLayer.findAll<int>(const Offset(0.0, 200.0)).annotations.toList(), equals(<int>[0])); expect(transformLayer.findAllAnnotations<int>(const Offset(0.0, 200.0)).annotations.toList(), equals(<int>[0]));
expect(transformLayer.findAll<int>(const Offset(0.0, 270.0)).annotations.toList(), equals(<int>[1])); expect(transformLayer.findAllAnnotations<int>(const Offset(0.0, 270.0)).annotations.toList(), equals(<int>[1]));
expect(transformLayer.findAll<int>(const Offset(0.0, 400.0)).annotations.toList(), equals(<int>[1])); expect(transformLayer.findAllAnnotations<int>(const Offset(0.0, 400.0)).annotations.toList(), equals(<int>[1]));
expect(transformLayer.findAll<int>(const Offset(0.0, 530.0)).annotations.toList(), equals(<int>[2])); expect(transformLayer.findAllAnnotations<int>(const Offset(0.0, 530.0)).annotations.toList(), equals(<int>[2]));
}); });
test('finds multiple nested, overlapping regions', () { test('finds multiple nested, overlapping regions', () {
...@@ -237,7 +237,7 @@ void main() { ...@@ -237,7 +237,7 @@ void main() {
parent.append(layer); parent.append(layer);
} }
expect(parent.findAll<int>(const Offset(0.0, 0.0)).annotations.toList(), equals(<int>[3, 1, 2, 0,])); expect(parent.findAllAnnotations<int>(const Offset(0.0, 0.0)).annotations.toList(), equals(<int>[3, 1, 2, 0,]));
}); });
test('looks for child AnnotatedRegions before parents', () { test('looks for child AnnotatedRegions before parents', () {
...@@ -251,7 +251,7 @@ void main() { ...@@ -251,7 +251,7 @@ void main() {
parent.append(child3); parent.append(child3);
layer.append(parent); layer.append(parent);
expect(parent.findAll<int>(Offset.zero).annotations.toList(), equals(<int>[4, 3, 2, 1])); expect(parent.findAllAnnotations<int>(Offset.zero).annotations.toList(), equals(<int>[4, 3, 2, 1]));
}); });
test('looks for correct type', () { test('looks for correct type', () {
...@@ -261,7 +261,7 @@ void main() { ...@@ -261,7 +261,7 @@ void main() {
layer.append(child2); layer.append(child2);
layer.append(child1); layer.append(child1);
expect(layer.findAll<String>(Offset.zero).annotations.toList(), equals(<String>['hello'])); expect(layer.findAllAnnotations<String>(Offset.zero).annotations.toList(), equals(<String>['hello']));
}); });
test('does not clip Layer.find on an AnnotatedRegion with an unrelated type', () { test('does not clip Layer.find on an AnnotatedRegion with an unrelated type', () {
...@@ -271,7 +271,7 @@ void main() { ...@@ -271,7 +271,7 @@ void main() {
parent.append(child); parent.append(child);
layer.append(parent); layer.append(parent);
expect(layer.findAll<int>(const Offset(100.0, 100.0)).annotations.toList(), equals(<int>[1])); expect(layer.findAllAnnotations<int>(const Offset(100.0, 100.0)).annotations.toList(), equals(<int>[1]));
}); });
test('handles non-invertable transforms', () { test('handles non-invertable transforms', () {
...@@ -279,11 +279,11 @@ void main() { ...@@ -279,11 +279,11 @@ void main() {
final TransformLayer parent = TransformLayer(transform: Matrix4.diagonal3Values(0.0, 1.0, 1.0)); final TransformLayer parent = TransformLayer(transform: Matrix4.diagonal3Values(0.0, 1.0, 1.0));
parent.append(child); parent.append(child);
expect(parent.findAll<int>(const Offset(0.0, 0.0)).annotations.toList(), equals(<int>[])); expect(parent.findAllAnnotations<int>(const Offset(0.0, 0.0)).annotations.toList(), equals(<int>[]));
parent.transform = Matrix4.diagonal3Values(1.0, 1.0, 1.0); parent.transform = Matrix4.diagonal3Values(1.0, 1.0, 1.0);
expect(parent.findAll<int>(const Offset(0.0, 0.0)).annotations.toList(), equals(<int>[1])); expect(parent.findAllAnnotations<int>(const Offset(0.0, 0.0)).annotations.toList(), equals(<int>[1]));
}); });
}); });
} }
...@@ -10,7 +10,7 @@ import 'package:flutter_test/flutter_test.dart'; ...@@ -10,7 +10,7 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:vector_math/vector_math_64.dart'; import 'package:vector_math/vector_math_64.dart';
void main() { void main() {
test('ContainerLayer.findAll returns all results from its children', () { test('ContainerLayer.findAllAnnotations returns all results from its children', () {
final Layer root = _Layers( final Layer root = _Layers(
ContainerLayer(), ContainerLayer(),
children: <Object>[ children: <Object>[
...@@ -21,7 +21,7 @@ void main() { ...@@ -21,7 +21,7 @@ void main() {
).build(); ).build();
expect( expect(
root.findAll<int>(Offset.zero).entries.toList(), root.findAllAnnotations<int>(Offset.zero).entries.toList(),
_equalToAnnotationResult<int>(<AnnotationEntry<int>>[ _equalToAnnotationResult<int>(<AnnotationEntry<int>>[
const AnnotationEntry<int>(annotation: 3, localPosition: Offset.zero), const AnnotationEntry<int>(annotation: 3, localPosition: Offset.zero),
const AnnotationEntry<int>(annotation: 2, localPosition: Offset.zero), const AnnotationEntry<int>(annotation: 2, localPosition: Offset.zero),
...@@ -40,12 +40,11 @@ void main() { ...@@ -40,12 +40,11 @@ void main() {
] ]
).build(); ).build();
final AnnotationEntry<int> result = root.find<int>(Offset.zero); final int result = root.find<int>(Offset.zero);
expect(result.annotation, 3); expect(result, 3);
expect(result.localPosition, Offset.zero);
}); });
test('ContainerLayer.findAll returns empty result when finding nothing', () { test('ContainerLayer.findAllAnnotations returns empty result when finding nothing', () {
final Layer root = _Layers( final Layer root = _Layers(
ContainerLayer(), ContainerLayer(),
children: <Object>[ children: <Object>[
...@@ -55,7 +54,7 @@ void main() { ...@@ -55,7 +54,7 @@ void main() {
] ]
).build(); ).build();
expect(root.findAll<double>(Offset.zero).entries.isEmpty, isTrue); expect(root.findAllAnnotations<double>(Offset.zero).entries.isEmpty, isTrue);
}); });
test('ContainerLayer.find returns null when finding nothing', () { test('ContainerLayer.find returns null when finding nothing', () {
...@@ -71,7 +70,7 @@ void main() { ...@@ -71,7 +70,7 @@ void main() {
expect(root.find<double>(Offset.zero), isNull); expect(root.find<double>(Offset.zero), isNull);
}); });
test('ContainerLayer.findAll stops at the first opaque child', () { test('ContainerLayer.findAllAnnotations stops at the first opaque child', () {
final Layer root = _Layers( final Layer root = _Layers(
ContainerLayer(), ContainerLayer(),
children: <Object>[ children: <Object>[
...@@ -82,7 +81,7 @@ void main() { ...@@ -82,7 +81,7 @@ void main() {
).build(); ).build();
expect( expect(
root.findAll<int>(Offset.zero).entries.toList(), root.findAllAnnotations<int>(Offset.zero).entries.toList(),
_equalToAnnotationResult<int>(<AnnotationEntry<int>>[ _equalToAnnotationResult<int>(<AnnotationEntry<int>>[
const AnnotationEntry<int>(annotation: 3, localPosition: Offset(0, 0)), const AnnotationEntry<int>(annotation: 3, localPosition: Offset(0, 0)),
const AnnotationEntry<int>(annotation: 2, localPosition: Offset(0, 0)), const AnnotationEntry<int>(annotation: 2, localPosition: Offset(0, 0)),
...@@ -90,7 +89,7 @@ void main() { ...@@ -90,7 +89,7 @@ void main() {
); );
}); });
test('ContainerLayer.findAll returns children\'s opacity (true)', () { test('ContainerLayer.findAllAnnotations returns children\'s opacity (true)', () {
final Layer root = _appendAnnotationIfNotOpaque(1000, final Layer root = _appendAnnotationIfNotOpaque(1000,
_Layers( _Layers(
ContainerLayer(), ContainerLayer(),
...@@ -101,14 +100,14 @@ void main() { ...@@ -101,14 +100,14 @@ void main() {
); );
expect( expect(
root.findAll<int>(Offset.zero).entries.toList(), root.findAllAnnotations<int>(Offset.zero).entries.toList(),
_equalToAnnotationResult<int>(<AnnotationEntry<int>>[ _equalToAnnotationResult<int>(<AnnotationEntry<int>>[
const AnnotationEntry<int>(annotation: 2, localPosition: Offset(0, 0)), const AnnotationEntry<int>(annotation: 2, localPosition: Offset(0, 0)),
]), ]),
); );
}); });
test('ContainerLayer.findAll returns children\'s opacity (false)', () { test('ContainerLayer.findAllAnnotations returns children\'s opacity (false)', () {
final Layer root = _appendAnnotationIfNotOpaque(1000, final Layer root = _appendAnnotationIfNotOpaque(1000,
_Layers( _Layers(
ContainerLayer(), ContainerLayer(),
...@@ -119,7 +118,7 @@ void main() { ...@@ -119,7 +118,7 @@ void main() {
); );
expect( expect(
root.findAll<int>(Offset.zero).entries.toList(), root.findAllAnnotations<int>(Offset.zero).entries.toList(),
_equalToAnnotationResult<int>(<AnnotationEntry<int>>[ _equalToAnnotationResult<int>(<AnnotationEntry<int>>[
const AnnotationEntry<int>(annotation: 2, localPosition: Offset(0, 0)), const AnnotationEntry<int>(annotation: 2, localPosition: Offset(0, 0)),
const AnnotationEntry<int>(annotation: 1000, localPosition: Offset(0, 0)), const AnnotationEntry<int>(annotation: 1000, localPosition: Offset(0, 0)),
...@@ -127,7 +126,7 @@ void main() { ...@@ -127,7 +126,7 @@ void main() {
); );
}); });
test('ContainerLayer.findAll returns false as opacity when finding nothing', () { test('ContainerLayer.findAllAnnotations returns false as opacity when finding nothing', () {
final Layer root = _appendAnnotationIfNotOpaque(1000, final Layer root = _appendAnnotationIfNotOpaque(1000,
_Layers( _Layers(
ContainerLayer(), ContainerLayer(),
...@@ -138,14 +137,14 @@ void main() { ...@@ -138,14 +137,14 @@ void main() {
); );
expect( expect(
root.findAll<int>(Offset.zero).entries.toList(), root.findAllAnnotations<int>(Offset.zero).entries.toList(),
_equalToAnnotationResult<int>(<AnnotationEntry<int>>[ _equalToAnnotationResult<int>(<AnnotationEntry<int>>[
const AnnotationEntry<int>(annotation: 1000, localPosition: Offset(0, 0)), const AnnotationEntry<int>(annotation: 1000, localPosition: Offset(0, 0)),
]), ]),
); );
}); });
test('OffsetLayer.findAll respects offset', () { test('OffsetLayer.findAllAnnotations respects offset', () {
const Offset insidePosition = Offset(-5, 5); const Offset insidePosition = Offset(-5, 5);
const Offset outsidePosition = Offset(5, 5); const Offset outsidePosition = Offset(5, 5);
...@@ -159,20 +158,20 @@ void main() { ...@@ -159,20 +158,20 @@ void main() {
); );
expect( expect(
root.findAll<int>(insidePosition).entries.toList(), root.findAllAnnotations<int>(insidePosition).entries.toList(),
_equalToAnnotationResult<int>(<AnnotationEntry<int>>[ _equalToAnnotationResult<int>(<AnnotationEntry<int>>[
const AnnotationEntry<int>(annotation: 1, localPosition: Offset(5, 5)), const AnnotationEntry<int>(annotation: 1, localPosition: Offset(5, 5)),
]), ]),
); );
expect( expect(
root.findAll<int>(outsidePosition).entries.toList(), root.findAllAnnotations<int>(outsidePosition).entries.toList(),
_equalToAnnotationResult<int>(<AnnotationEntry<int>>[ _equalToAnnotationResult<int>(<AnnotationEntry<int>>[
const AnnotationEntry<int>(annotation: 1000, localPosition: Offset(5, 5)), const AnnotationEntry<int>(annotation: 1000, localPosition: Offset(5, 5)),
]), ]),
); );
}); });
test('ClipRectLayer.findAll respects clipRect', () { test('ClipRectLayer.findAllAnnotations respects clipRect', () {
const Offset insidePosition = Offset(11, 11); const Offset insidePosition = Offset(11, 11);
const Offset outsidePosition = Offset(19, 19); const Offset outsidePosition = Offset(19, 19);
...@@ -191,20 +190,20 @@ void main() { ...@@ -191,20 +190,20 @@ void main() {
); );
expect( expect(
root.findAll<int>(insidePosition).entries.toList(), root.findAllAnnotations<int>(insidePosition).entries.toList(),
_equalToAnnotationResult<int>(<AnnotationEntry<int>>[ _equalToAnnotationResult<int>(<AnnotationEntry<int>>[
const AnnotationEntry<int>(annotation: 1, localPosition: insidePosition), const AnnotationEntry<int>(annotation: 1, localPosition: insidePosition),
]), ]),
); );
expect( expect(
root.findAll<int>(outsidePosition).entries.toList(), root.findAllAnnotations<int>(outsidePosition).entries.toList(),
_equalToAnnotationResult<int>(<AnnotationEntry<int>>[ _equalToAnnotationResult<int>(<AnnotationEntry<int>>[
const AnnotationEntry<int>(annotation: 1000, localPosition: outsidePosition), const AnnotationEntry<int>(annotation: 1000, localPosition: outsidePosition),
]), ]),
); );
}); });
test('ClipRRectLayer.findAll respects clipRRect', () { test('ClipRRectLayer.findAllAnnotations respects clipRRect', () {
// For a curve of radius 4 centered at (4, 4), // For a curve of radius 4 centered at (4, 4),
// location (1, 1) is outside, while (2, 2) is inside. // location (1, 1) is outside, while (2, 2) is inside.
// Here we shift this RRect by (10, 10). // Here we shift this RRect by (10, 10).
...@@ -230,20 +229,20 @@ void main() { ...@@ -230,20 +229,20 @@ void main() {
); );
expect( expect(
root.findAll<int>(insidePosition).entries.toList(), root.findAllAnnotations<int>(insidePosition).entries.toList(),
_equalToAnnotationResult<int>(<AnnotationEntry<int>>[ _equalToAnnotationResult<int>(<AnnotationEntry<int>>[
const AnnotationEntry<int>(annotation: 1, localPosition: insidePosition), const AnnotationEntry<int>(annotation: 1, localPosition: insidePosition),
]), ]),
); );
expect( expect(
root.findAll<int>(outsidePosition).entries.toList(), root.findAllAnnotations<int>(outsidePosition).entries.toList(),
_equalToAnnotationResult<int>(<AnnotationEntry<int>>[ _equalToAnnotationResult<int>(<AnnotationEntry<int>>[
const AnnotationEntry<int>(annotation: 1000, localPosition: outsidePosition), const AnnotationEntry<int>(annotation: 1000, localPosition: outsidePosition),
]), ]),
); );
}); });
test('ClipPathLayer.findAll respects clipPath', () { test('ClipPathLayer.findAllAnnotations respects clipPath', () {
// For this triangle, location (1, 1) is inside, while (2, 2) is outside. // For this triangle, location (1, 1) is inside, while (2, 2) is outside.
// 2 // 2
// ————— // —————
...@@ -274,20 +273,20 @@ void main() { ...@@ -274,20 +273,20 @@ void main() {
); );
expect( expect(
root.findAll<int>(insidePosition).entries.toList(), root.findAllAnnotations<int>(insidePosition).entries.toList(),
_equalToAnnotationResult<int>(<AnnotationEntry<int>>[ _equalToAnnotationResult<int>(<AnnotationEntry<int>>[
const AnnotationEntry<int>(annotation: 1, localPosition: insidePosition), const AnnotationEntry<int>(annotation: 1, localPosition: insidePosition),
]), ]),
); );
expect( expect(
root.findAll<int>(outsidePosition).entries.toList(), root.findAllAnnotations<int>(outsidePosition).entries.toList(),
_equalToAnnotationResult<int>(<AnnotationEntry<int>>[ _equalToAnnotationResult<int>(<AnnotationEntry<int>>[
const AnnotationEntry<int>(annotation: 1000, localPosition: outsidePosition), const AnnotationEntry<int>(annotation: 1000, localPosition: outsidePosition),
]), ]),
); );
}); });
test('TransformLayer.findAll respects transform', () { test('TransformLayer.findAllAnnotations respects transform', () {
// Matrix `transform` enlarges the target by (2x, 4x), then shift it by // Matrix `transform` enlarges the target by (2x, 4x), then shift it by
// (10, 20). // (10, 20).
final Matrix4 transform = Matrix4.diagonal3Values(2, 4, 1) final Matrix4 transform = Matrix4.diagonal3Values(2, 4, 1)
...@@ -312,20 +311,20 @@ void main() { ...@@ -312,20 +311,20 @@ void main() {
); );
expect( expect(
root.findAll<int>(insidePosition).entries.toList(), root.findAllAnnotations<int>(insidePosition).entries.toList(),
_equalToAnnotationResult<int>(<AnnotationEntry<int>>[ _equalToAnnotationResult<int>(<AnnotationEntry<int>>[
const AnnotationEntry<int>(annotation: 1, localPosition: Offset(15, 15)), const AnnotationEntry<int>(annotation: 1, localPosition: Offset(15, 15)),
]), ]),
); );
expect( expect(
root.findAll<int>(outsidePosition).entries.toList(), root.findAllAnnotations<int>(outsidePosition).entries.toList(),
_equalToAnnotationResult<int>(<AnnotationEntry<int>>[ _equalToAnnotationResult<int>(<AnnotationEntry<int>>[
const AnnotationEntry<int>(annotation: 1000, localPosition: outsidePosition), const AnnotationEntry<int>(annotation: 1000, localPosition: outsidePosition),
]), ]),
); );
}); });
test('TransformLayer.findAll skips when transform is irreversible', () { test('TransformLayer.findAllAnnotations skips when transform is irreversible', () {
final Matrix4 transform = Matrix4.diagonal3Values(1, 0, 1); final Matrix4 transform = Matrix4.diagonal3Values(1, 0, 1);
final Layer root = _appendAnnotationIfNotOpaque(1000, final Layer root = _appendAnnotationIfNotOpaque(1000,
...@@ -338,14 +337,14 @@ void main() { ...@@ -338,14 +337,14 @@ void main() {
); );
expect( expect(
root.findAll<int>(Offset.zero).entries.toList(), root.findAllAnnotations<int>(Offset.zero).entries.toList(),
_equalToAnnotationResult<int>(<AnnotationEntry<int>>[ _equalToAnnotationResult<int>(<AnnotationEntry<int>>[
const AnnotationEntry<int>(annotation: 1000, localPosition: Offset.zero), const AnnotationEntry<int>(annotation: 1000, localPosition: Offset.zero),
]), ]),
); );
}); });
test('PhysicalModelLayer.findAll respects clipPath', () { test('PhysicalModelLayer.findAllAnnotations respects clipPath', () {
// For this triangle, location (1, 1) is inside, while (2, 2) is outside. // For this triangle, location (1, 1) is inside, while (2, 2) is outside.
// 2 // 2
// ————— // —————
...@@ -381,13 +380,13 @@ void main() { ...@@ -381,13 +380,13 @@ void main() {
); );
expect( expect(
root.findAll<int>(insidePosition).entries.toList(), root.findAllAnnotations<int>(insidePosition).entries.toList(),
_equalToAnnotationResult<int>(<AnnotationEntry<int>>[ _equalToAnnotationResult<int>(<AnnotationEntry<int>>[
const AnnotationEntry<int>(annotation: 1, localPosition: insidePosition), const AnnotationEntry<int>(annotation: 1, localPosition: insidePosition),
]), ]),
); );
expect( expect(
root.findAll<int>(outsidePosition).entries.toList(), root.findAllAnnotations<int>(outsidePosition).entries.toList(),
_equalToAnnotationResult<int>(<AnnotationEntry<int>>[ _equalToAnnotationResult<int>(<AnnotationEntry<int>>[
const AnnotationEntry<int>(annotation: 1000, localPosition: outsidePosition), const AnnotationEntry<int>(annotation: 1000, localPosition: outsidePosition),
]), ]),
...@@ -395,7 +394,7 @@ void main() { ...@@ -395,7 +394,7 @@ void main() {
}); });
test('LeaderLayer.findAll respects offset', () { test('LeaderLayer.findAllAnnotations respects offset', () {
const Offset insidePosition = Offset(-5, 5); const Offset insidePosition = Offset(-5, 5);
const Offset outsidePosition = Offset(5, 5); const Offset outsidePosition = Offset(5, 5);
...@@ -412,20 +411,20 @@ void main() { ...@@ -412,20 +411,20 @@ void main() {
); );
expect( expect(
root.findAll<int>(insidePosition).entries.toList(), root.findAllAnnotations<int>(insidePosition).entries.toList(),
_equalToAnnotationResult<int>(<AnnotationEntry<int>>[ _equalToAnnotationResult<int>(<AnnotationEntry<int>>[
const AnnotationEntry<int>(annotation: 1, localPosition: Offset(5, 5)), const AnnotationEntry<int>(annotation: 1, localPosition: Offset(5, 5)),
]), ]),
); );
expect( expect(
root.findAll<int>(outsidePosition).entries.toList(), root.findAllAnnotations<int>(outsidePosition).entries.toList(),
_equalToAnnotationResult<int>(<AnnotationEntry<int>>[ _equalToAnnotationResult<int>(<AnnotationEntry<int>>[
const AnnotationEntry<int>(annotation: 1000, localPosition: outsidePosition), const AnnotationEntry<int>(annotation: 1000, localPosition: outsidePosition),
]), ]),
); );
}); });
test('AnnotatedRegionLayer.findAll should append to the list ' test('AnnotatedRegionLayer.findAllAnnotations should append to the list '
'and return the given opacity (false) during a successful hit', () { 'and return the given opacity (false) during a successful hit', () {
const Offset position = Offset(5, 5); const Offset position = Offset(5, 5);
...@@ -439,7 +438,7 @@ void main() { ...@@ -439,7 +438,7 @@ void main() {
); );
expect( expect(
root.findAll<int>(position).entries.toList(), root.findAllAnnotations<int>(position).entries.toList(),
_equalToAnnotationResult<int>(<AnnotationEntry<int>>[ _equalToAnnotationResult<int>(<AnnotationEntry<int>>[
const AnnotationEntry<int>(annotation: 2, localPosition: position), const AnnotationEntry<int>(annotation: 2, localPosition: position),
const AnnotationEntry<int>(annotation: 1, localPosition: position), const AnnotationEntry<int>(annotation: 1, localPosition: position),
...@@ -448,7 +447,7 @@ void main() { ...@@ -448,7 +447,7 @@ void main() {
); );
}); });
test('AnnotatedRegionLayer.findAll should append to the list ' test('AnnotatedRegionLayer.findAllAnnotations should append to the list '
'and return the given opacity (true) during a successful hit', () { 'and return the given opacity (true) during a successful hit', () {
const Offset position = Offset(5, 5); const Offset position = Offset(5, 5);
...@@ -462,7 +461,7 @@ void main() { ...@@ -462,7 +461,7 @@ void main() {
); );
expect( expect(
root.findAll<int>(position).entries.toList(), root.findAllAnnotations<int>(position).entries.toList(),
_equalToAnnotationResult<int>(<AnnotationEntry<int>>[ _equalToAnnotationResult<int>(<AnnotationEntry<int>>[
const AnnotationEntry<int>(annotation: 2, localPosition: position), const AnnotationEntry<int>(annotation: 2, localPosition: position),
const AnnotationEntry<int>(annotation: 1, localPosition: position), const AnnotationEntry<int>(annotation: 1, localPosition: position),
...@@ -470,7 +469,7 @@ void main() { ...@@ -470,7 +469,7 @@ void main() {
); );
}); });
test('AnnotatedRegionLayer.findAll has default opacity as false', () { test('AnnotatedRegionLayer.findAllAnnotations has default opacity as false', () {
const Offset position = Offset(5, 5); const Offset position = Offset(5, 5);
final Layer root = _appendAnnotationIfNotOpaque(1000, final Layer root = _appendAnnotationIfNotOpaque(1000,
...@@ -483,7 +482,7 @@ void main() { ...@@ -483,7 +482,7 @@ void main() {
); );
expect( expect(
root.findAll<int>(position).entries.toList(), root.findAllAnnotations<int>(position).entries.toList(),
_equalToAnnotationResult<int>(<AnnotationEntry<int>>[ _equalToAnnotationResult<int>(<AnnotationEntry<int>>[
const AnnotationEntry<int>(annotation: 2, localPosition: position), const AnnotationEntry<int>(annotation: 2, localPosition: position),
const AnnotationEntry<int>(annotation: 1, localPosition: position), const AnnotationEntry<int>(annotation: 1, localPosition: position),
...@@ -492,7 +491,7 @@ void main() { ...@@ -492,7 +491,7 @@ void main() {
); );
}); });
test('AnnotatedRegionLayer.findAll should still check children and return' test('AnnotatedRegionLayer.findAllAnnotations should still check children and return'
'children\'s opacity (false) during a failed hit', () { 'children\'s opacity (false) during a failed hit', () {
const Offset position = Offset(5, 5); const Offset position = Offset(5, 5);
...@@ -506,7 +505,7 @@ void main() { ...@@ -506,7 +505,7 @@ void main() {
); );
expect( expect(
root.findAll<int>(position).entries.toList(), root.findAllAnnotations<int>(position).entries.toList(),
_equalToAnnotationResult<int>(<AnnotationEntry<int>>[ _equalToAnnotationResult<int>(<AnnotationEntry<int>>[
const AnnotationEntry<int>(annotation: 2, localPosition: position), const AnnotationEntry<int>(annotation: 2, localPosition: position),
const AnnotationEntry<int>(annotation: 1000, localPosition: position), const AnnotationEntry<int>(annotation: 1000, localPosition: position),
...@@ -514,7 +513,7 @@ void main() { ...@@ -514,7 +513,7 @@ void main() {
); );
}); });
test('AnnotatedRegionLayer.findAll should still check children and return' test('AnnotatedRegionLayer.findAllAnnotations should still check children and return'
'children\'s opacity (true) during a failed hit', () { 'children\'s opacity (true) during a failed hit', () {
const Offset position = Offset(5, 5); const Offset position = Offset(5, 5);
...@@ -528,14 +527,14 @@ void main() { ...@@ -528,14 +527,14 @@ void main() {
); );
expect( expect(
root.findAll<int>(position).entries.toList(), root.findAllAnnotations<int>(position).entries.toList(),
_equalToAnnotationResult<int>(<AnnotationEntry<int>>[ _equalToAnnotationResult<int>(<AnnotationEntry<int>>[
const AnnotationEntry<int>(annotation: 2, localPosition: position), const AnnotationEntry<int>(annotation: 2, localPosition: position),
]), ]),
); );
}); });
test('AnnotatedRegionLayer.findAll should not add to children\'s opacity ' test('AnnotatedRegionLayer.findAllAnnotations should not add to children\'s opacity '
'during a successful hit if it is not opaque', () { 'during a successful hit if it is not opaque', () {
const Offset position = Offset(5, 5); const Offset position = Offset(5, 5);
...@@ -549,7 +548,7 @@ void main() { ...@@ -549,7 +548,7 @@ void main() {
); );
expect( expect(
root.findAll<int>(position).entries.toList(), root.findAllAnnotations<int>(position).entries.toList(),
_equalToAnnotationResult<int>(<AnnotationEntry<int>>[ _equalToAnnotationResult<int>(<AnnotationEntry<int>>[
const AnnotationEntry<int>(annotation: 2, localPosition: position), const AnnotationEntry<int>(annotation: 2, localPosition: position),
const AnnotationEntry<int>(annotation: 1, localPosition: position), const AnnotationEntry<int>(annotation: 1, localPosition: position),
...@@ -558,7 +557,7 @@ void main() { ...@@ -558,7 +557,7 @@ void main() {
); );
}); });
test('AnnotatedRegionLayer.findAll should add to children\'s opacity ' test('AnnotatedRegionLayer.findAllAnnotations should add to children\'s opacity '
'during a successful hit if it is opaque', () { 'during a successful hit if it is opaque', () {
const Offset position = Offset(5, 5); const Offset position = Offset(5, 5);
...@@ -572,7 +571,7 @@ void main() { ...@@ -572,7 +571,7 @@ void main() {
); );
expect( expect(
root.findAll<int>(position).entries.toList(), root.findAllAnnotations<int>(position).entries.toList(),
_equalToAnnotationResult<int>(<AnnotationEntry<int>>[ _equalToAnnotationResult<int>(<AnnotationEntry<int>>[
const AnnotationEntry<int>(annotation: 2, localPosition: position), const AnnotationEntry<int>(annotation: 2, localPosition: position),
const AnnotationEntry<int>(annotation: 1, localPosition: position), const AnnotationEntry<int>(annotation: 1, localPosition: position),
...@@ -580,7 +579,7 @@ void main() { ...@@ -580,7 +579,7 @@ void main() {
); );
}); });
test('AnnotatedRegionLayer.findAll should clip its annotation ' test('AnnotatedRegionLayer.findAllAnnotations should clip its annotation '
'using size and offset (positive)', () { 'using size and offset (positive)', () {
// The target position would have fallen outside if not for the offset. // The target position would have fallen outside if not for the offset.
const Offset position = Offset(100, 100); const Offset position = Offset(100, 100);
...@@ -606,7 +605,7 @@ void main() { ...@@ -606,7 +605,7 @@ void main() {
); );
expect( expect(
root.findAll<int>(position).entries.toList(), root.findAllAnnotations<int>(position).entries.toList(),
_equalToAnnotationResult<int>(<AnnotationEntry<int>>[ _equalToAnnotationResult<int>(<AnnotationEntry<int>>[
const AnnotationEntry<int>(annotation: 2, localPosition: position), const AnnotationEntry<int>(annotation: 2, localPosition: position),
const AnnotationEntry<int>(annotation: 1, localPosition: position), const AnnotationEntry<int>(annotation: 1, localPosition: position),
...@@ -615,7 +614,7 @@ void main() { ...@@ -615,7 +614,7 @@ void main() {
); );
}); });
test('AnnotatedRegionLayer.findAll should clip its annotation ' test('AnnotatedRegionLayer.findAllAnnotations should clip its annotation '
'using size and offset (negative)', () { 'using size and offset (negative)', () {
// The target position would have fallen inside if not for the offset. // The target position would have fallen inside if not for the offset.
const Offset position = Offset(10, 10); const Offset position = Offset(10, 10);
...@@ -634,7 +633,7 @@ void main() { ...@@ -634,7 +633,7 @@ void main() {
); );
expect( expect(
root.findAll<int>(position).entries.toList(), root.findAllAnnotations<int>(position).entries.toList(),
_equalToAnnotationResult<int>(<AnnotationEntry<int>>[ _equalToAnnotationResult<int>(<AnnotationEntry<int>>[
const AnnotationEntry<int>(annotation: 2, localPosition: position), const AnnotationEntry<int>(annotation: 2, localPosition: position),
const AnnotationEntry<int>(annotation: 1000, localPosition: position), const AnnotationEntry<int>(annotation: 1000, localPosition: position),
......
...@@ -34,12 +34,12 @@ void main() { ...@@ -34,12 +34,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,
))?.annotation; ));
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,
)).annotation; ));
expect(result, 1); expect(result, 1);
}); });
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment