Commit 6d57a2a2 authored by Hans Muller's avatar Hans Muller

Merge pull request #306 from HansMuller/named_parameters

Named parameters for the mock_events.dart TestPointer class
parents 7791acd8 b8286be1
......@@ -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 }) {
......
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