Merge pull request #435 from abarth/event_duration
Convert PointerInputEvent to Duration for timestamp
This commit is contained in:
@@ -11,7 +11,7 @@ class TestPointer {
|
||||
bool isDown = false;
|
||||
ui.Point location;
|
||||
|
||||
PointerInputEvent down(ui.Point newLocation, { double timeStamp: 0.0 }) {
|
||||
PointerInputEvent down(ui.Point newLocation, { Duration timeStamp: const Duration() }) {
|
||||
assert(!isDown);
|
||||
isDown = true;
|
||||
location = newLocation;
|
||||
@@ -24,7 +24,7 @@ class TestPointer {
|
||||
);
|
||||
}
|
||||
|
||||
PointerInputEvent move(ui.Point newLocation, { double timeStamp: 0.0 }) {
|
||||
PointerInputEvent move(ui.Point newLocation, { Duration timeStamp: const Duration() }) {
|
||||
assert(isDown);
|
||||
ui.Offset delta = newLocation - location;
|
||||
location = newLocation;
|
||||
@@ -39,7 +39,7 @@ class TestPointer {
|
||||
);
|
||||
}
|
||||
|
||||
PointerInputEvent up({ double timeStamp: 0.0 }) {
|
||||
PointerInputEvent up({ Duration timeStamp: const Duration() }) {
|
||||
assert(isDown);
|
||||
isDown = false;
|
||||
return new PointerInputEvent(
|
||||
@@ -51,7 +51,7 @@ class TestPointer {
|
||||
);
|
||||
}
|
||||
|
||||
PointerInputEvent cancel({ double timeStamp: 0.0 }) {
|
||||
PointerInputEvent cancel({ Duration timeStamp: const Duration() }) {
|
||||
assert(isDown);
|
||||
isDown = false;
|
||||
return new PointerInputEvent(
|
||||
|
||||
@@ -24,7 +24,7 @@ List<PointerInputEvent> _eventFromMap(List<Map> intermediate) {
|
||||
PointerInputEvent _eventFor(Map entry) {
|
||||
PointerInputEvent result = new PointerInputEvent(
|
||||
type: entry['type'],
|
||||
timeStamp: entry['timeStamp'],
|
||||
timeStamp: new Duration(milliseconds: entry['timeStamp'].round()),
|
||||
pointer: entry['pointer'],
|
||||
x: entry['x'],
|
||||
y: entry['y']
|
||||
|
||||
@@ -165,13 +165,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: timeStamp), result);
|
||||
_dispatchEvent(p.down(startLocation, timeStamp: new Duration(milliseconds: timeStamp.round())), result);
|
||||
for(int i = 0; i < kMoveCount; i++) {
|
||||
final Point location = startLocation + Offset.lerp(Offset.zero, offset, i / kMoveCount);
|
||||
_dispatchEvent(p.move(location, timeStamp: timeStamp), result);
|
||||
_dispatchEvent(p.move(location, timeStamp: new Duration(milliseconds: timeStamp.round())), result);
|
||||
timeStamp += timeStampDelta;
|
||||
}
|
||||
_dispatchEvent(p.up(timeStamp: timeStamp), result);
|
||||
_dispatchEvent(p.up(timeStamp: new Duration(milliseconds: timeStamp.round())), result);
|
||||
}
|
||||
|
||||
void scroll(Element element, Offset offset, { int pointer: 1 }) {
|
||||
|
||||
Reference in New Issue
Block a user