mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Named parameters for the mock_events.dart TestPointer class
This commit is contained in:
parent
7791acd81d
commit
b8286be18d
@ -11,7 +11,7 @@ class TestPointer {
|
||||
bool isDown = false;
|
||||
ui.Point location;
|
||||
|
||||
PointerInputEvent down([ui.Point newLocation = ui.Point.origin, double timeStamp = 0.0 ]) {
|
||||
PointerInputEvent down(ui.Point newLocation, { double timeStamp: 0.0 }) {
|
||||
assert(!isDown);
|
||||
isDown = true;
|
||||
location = newLocation;
|
||||
@ -24,7 +24,7 @@ class TestPointer {
|
||||
);
|
||||
}
|
||||
|
||||
PointerInputEvent move([ui.Point newLocation = ui.Point.origin, double timeStamp = 0.0]) {
|
||||
PointerInputEvent move(ui.Point newLocation, { double timeStamp: 0.0 }) {
|
||||
assert(isDown);
|
||||
ui.Offset delta = newLocation - location;
|
||||
location = newLocation;
|
||||
@ -39,7 +39,7 @@ class TestPointer {
|
||||
);
|
||||
}
|
||||
|
||||
PointerInputEvent up([ double timeStamp = 0.0 ]) {
|
||||
PointerInputEvent up({ double timeStamp: 0.0 }) {
|
||||
assert(isDown);
|
||||
isDown = false;
|
||||
return new PointerInputEvent(
|
||||
@ -51,7 +51,7 @@ class TestPointer {
|
||||
);
|
||||
}
|
||||
|
||||
PointerInputEvent cancel([ double timeStamp = 0.0 ]) {
|
||||
PointerInputEvent cancel({ double timeStamp: 0.0 }) {
|
||||
assert(isDown);
|
||||
isDown = false;
|
||||
return new PointerInputEvent(
|
||||
|
@ -15,9 +15,9 @@ void main() {
|
||||
|
||||
PointerRouter router = new PointerRouter();
|
||||
router.addRoute(3, callback);
|
||||
router.route(pointer2.down());
|
||||
router.route(pointer2.down(Point.origin));
|
||||
expect(callbackRan, isFalse);
|
||||
router.route(pointer3.down());
|
||||
router.route(pointer3.down(Point.origin));
|
||||
expect(callbackRan, isTrue);
|
||||
callbackRan = false;
|
||||
router.removeRoute(3, callback);
|
||||
|
@ -156,13 +156,13 @@ class WidgetTester {
|
||||
final kMoveCount = 50; // Needs to be >= kHistorySize, see _LeastSquaresVelocityTrackerStrategy
|
||||
final double timeStampDelta = 1000.0 * offset.distance / (kMoveCount * velocity);
|
||||
double timeStamp = 0.0;
|
||||
_dispatchEvent(p.down(startLocation, timeStamp), result);
|
||||
_dispatchEvent(p.down(startLocation, timeStamp: timeStamp), result);
|
||||
for(int i = 0; i < kMoveCount; i++) {
|
||||
final Point location = startLocation + Offset.lerp(Offset.zero, offset, i / kMoveCount);
|
||||
_dispatchEvent(p.move(location, timeStamp), result);
|
||||
_dispatchEvent(p.move(location, timeStamp: timeStamp), result);
|
||||
timeStamp += timeStampDelta;
|
||||
}
|
||||
_dispatchEvent(p.up(timeStamp), result);
|
||||
_dispatchEvent(p.up(timeStamp: timeStamp), result);
|
||||
}
|
||||
|
||||
void scroll(Element element, Offset offset, { int pointer: 1 }) {
|
||||
|
Loading…
Reference in New Issue
Block a user