Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
6dd58b21
Commit
6dd58b21
authored
Sep 17, 2015
by
Collin Jackson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add a test for scale gestures
parent
6d78b050
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
184 additions
and
0 deletions
+184
-0
scale_test.dart
packages/unit/test/gestures/scale_test.dart
+184
-0
No files found.
packages/unit/test/gestures/scale_test.dart
0 → 100644
View file @
6dd58b21
import
'dart:sky'
as
sky
;
import
'package:sky/gestures.dart'
;
import
'package:test/test.dart'
;
import
'../engine/mock_events.dart'
;
void
main
(
)
{
test
(
'Should recognize scale gestures'
,
()
{
PointerRouter
router
=
new
PointerRouter
();
ScaleGestureRecognizer
scale
=
new
ScaleGestureRecognizer
(
router:
router
);
TapGestureRecognizer
tap
=
new
TapGestureRecognizer
(
router:
router
);
bool
didStartScale
=
false
;
sky
.
Point
updatedFocalPoint
;
scale
.
onStart
=
(
sky
.
Point
focalPoint
)
{
didStartScale
=
true
;
updatedFocalPoint
=
focalPoint
;
};
double
updatedScale
;
scale
.
onUpdate
=
(
double
scale
,
sky
.
Point
focalPoint
)
{
updatedScale
=
scale
;
updatedFocalPoint
=
focalPoint
;
};
bool
didEndScale
=
false
;
scale
.
onEnd
=
()
{
didEndScale
=
true
;
};
bool
didTap
=
false
;
tap
.
onTap
=
()
{
didTap
=
true
;
};
TestPointer
pointer1
=
new
TestPointer
(
1
);
sky
.
PointerEvent
down
=
pointer1
.
down
(
new
Point
(
10.0
,
10.0
));
scale
.
addPointer
(
down
);
tap
.
addPointer
(
down
);
GestureArena
.
instance
.
close
(
1
);
expect
(
didStartScale
,
isFalse
);
expect
(
updatedScale
,
isNull
);
expect
(
updatedFocalPoint
,
isNull
);
expect
(
didEndScale
,
isFalse
);
expect
(
didTap
,
isFalse
);
// One-finger panning
router
.
route
(
down
);
expect
(
didStartScale
,
isFalse
);
expect
(
updatedScale
,
isNull
);
expect
(
updatedFocalPoint
,
isNull
);
expect
(
didEndScale
,
isFalse
);
expect
(
didTap
,
isFalse
);
router
.
route
(
pointer1
.
move
(
new
Point
(
20.0
,
30.0
)));
expect
(
didStartScale
,
isTrue
);
didStartScale
=
false
;
expect
(
updatedFocalPoint
,
new
sky
.
Point
(
20.0
,
30.0
));
updatedFocalPoint
=
null
;
expect
(
updatedScale
,
1.0
);
updatedScale
=
null
;
expect
(
didEndScale
,
isFalse
);
expect
(
didTap
,
isFalse
);
// Two-finger scaling
TestPointer
pointer2
=
new
TestPointer
(
2
);
sky
.
PointerEvent
down2
=
pointer2
.
down
(
new
Point
(
10.0
,
20.0
));
scale
.
addPointer
(
down2
);
tap
.
addPointer
(
down2
);
GestureArena
.
instance
.
close
(
2
);
router
.
route
(
down2
);
expect
(
didEndScale
,
isTrue
);
didEndScale
=
false
;
expect
(
updatedScale
,
isNull
);
expect
(
updatedFocalPoint
,
isNull
);
expect
(
didStartScale
,
isFalse
);
// Zoom in
router
.
route
(
pointer2
.
move
(
new
Point
(
0.0
,
10.0
)));
expect
(
didStartScale
,
isTrue
);
didStartScale
=
false
;
expect
(
updatedFocalPoint
,
new
sky
.
Point
(
10.0
,
20.0
));
updatedFocalPoint
=
null
;
expect
(
updatedScale
,
2.0
);
updatedScale
=
null
;
expect
(
didEndScale
,
isFalse
);
expect
(
didTap
,
isFalse
);
// Zoom out
router
.
route
(
pointer2
.
move
(
new
Point
(
15.0
,
25.0
)));
expect
(
updatedFocalPoint
,
new
sky
.
Point
(
17.5
,
27.5
));
updatedFocalPoint
=
null
;
expect
(
updatedScale
,
0.5
);
updatedScale
=
null
;
expect
(
didTap
,
isFalse
);
// Three-finger scaling
TestPointer
pointer3
=
new
TestPointer
(
3
);
sky
.
PointerEvent
down3
=
pointer3
.
down
(
new
Point
(
25.0
,
35.0
));
scale
.
addPointer
(
down3
);
tap
.
addPointer
(
down3
);
GestureArena
.
instance
.
close
(
3
);
router
.
route
(
down3
);
expect
(
didEndScale
,
isTrue
);
didEndScale
=
false
;
expect
(
updatedScale
,
isNull
);
expect
(
updatedFocalPoint
,
isNull
);
expect
(
didStartScale
,
isFalse
);
// Zoom in
router
.
route
(
pointer3
.
move
(
new
Point
(
55.0
,
65.0
)));
expect
(
didStartScale
,
isTrue
);
didStartScale
=
false
;
expect
(
updatedFocalPoint
,
new
sky
.
Point
(
30.0
,
40.0
));
updatedFocalPoint
=
null
;
expect
(
updatedScale
,
5.0
);
updatedScale
=
null
;
expect
(
didEndScale
,
isFalse
);
expect
(
didTap
,
isFalse
);
// Return to original positions but with different fingers
router
.
route
(
pointer1
.
move
(
new
Point
(
25.0
,
35.0
)));
router
.
route
(
pointer2
.
move
(
new
Point
(
20.0
,
30.0
)));
router
.
route
(
pointer3
.
move
(
new
Point
(
15.0
,
25.0
)));
expect
(
didStartScale
,
isFalse
);
expect
(
updatedFocalPoint
,
new
sky
.
Point
(
20.0
,
30.0
));
updatedFocalPoint
=
null
;
expect
(
updatedScale
,
1.0
);
updatedScale
=
null
;
expect
(
didEndScale
,
isFalse
);
expect
(
didTap
,
isFalse
);
router
.
route
(
pointer1
.
up
());
expect
(
didStartScale
,
isFalse
);
expect
(
updatedFocalPoint
,
isNull
);
expect
(
updatedScale
,
isNull
);
expect
(
didEndScale
,
isTrue
);
didEndScale
=
false
;
expect
(
didTap
,
isFalse
);
// Continue scaling with two fingers
router
.
route
(
pointer3
.
move
(
new
Point
(
10.0
,
20.0
)));
expect
(
didStartScale
,
isTrue
);
didStartScale
=
false
;
expect
(
updatedFocalPoint
,
new
sky
.
Point
(
15.0
,
25.0
));
updatedFocalPoint
=
null
;
expect
(
updatedScale
,
2.0
);
updatedScale
=
null
;
router
.
route
(
pointer2
.
up
());
expect
(
didStartScale
,
isFalse
);
expect
(
updatedFocalPoint
,
isNull
);
expect
(
updatedScale
,
isNull
);
expect
(
didEndScale
,
isTrue
);
didEndScale
=
false
;
expect
(
didTap
,
isFalse
);
// Continue panning with one finger
router
.
route
(
pointer3
.
move
(
new
Point
(
0.0
,
0.0
)));
expect
(
didStartScale
,
isTrue
);
didStartScale
=
false
;
expect
(
updatedFocalPoint
,
new
sky
.
Point
(
0.0
,
0.0
));
updatedFocalPoint
=
null
;
expect
(
updatedScale
,
1.0
);
updatedScale
=
null
;
// We are done
router
.
route
(
pointer3
.
up
());
expect
(
didStartScale
,
isFalse
);
expect
(
updatedFocalPoint
,
isNull
);
expect
(
updatedScale
,
isNull
);
expect
(
didEndScale
,
isTrue
);
didEndScale
=
false
;
expect
(
didTap
,
isFalse
);
scale
.
dispose
();
tap
.
dispose
();
});
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment