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
608e971f
Commit
608e971f
authored
Oct 22, 2015
by
Kris Giesing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add another double-tap test
parent
219e189a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
119 additions
and
2 deletions
+119
-2
double_tap_test.dart
packages/unit/test/gestures/double_tap_test.dart
+44
-2
lsq_solver_test_disabled.dart
packages/unit/test/gestures/lsq_solver_test_disabled.dart
+75
-0
No files found.
packages/unit/test/gestures/double_tap_test.dart
View file @
608e971f
...
...
@@ -3,8 +3,14 @@ import 'package:quiver/testing/async.dart';
import
'package:test/test.dart'
;
class
TestGestureArenaMember
extends
GestureArenaMember
{
void
acceptGesture
(
Object
key
)
{}
void
rejectGesture
(
Object
key
)
{}
void
acceptGesture
(
Object
key
)
{
accepted
=
true
;
}
void
rejectGesture
(
Object
key
)
{
rejected
=
true
;
}
bool
accepted
=
false
;
bool
rejected
=
false
;
}
void
main
(
)
{
...
...
@@ -354,6 +360,7 @@ void main() {
router
.
route
(
up1
);
expect
(
doubleTapRecognized
,
isFalse
);
entry
.
resolve
(
GestureDisposition
.
accepted
);
expect
(
member
.
accepted
,
isTrue
);
expect
(
doubleTapRecognized
,
isFalse
);
GestureArena
.
instance
.
sweep
(
1
);
expect
(
doubleTapRecognized
,
isFalse
);
...
...
@@ -395,6 +402,7 @@ void main() {
expect
(
doubleTapRecognized
,
isFalse
);
entry
.
resolve
(
GestureDisposition
.
accepted
);
expect
(
member
.
accepted
,
isTrue
);
tap
.
addPointer
(
down2
);
GestureArena
.
instance
.
close
(
2
);
...
...
@@ -439,6 +447,7 @@ void main() {
expect
(
doubleTapRecognized
,
isFalse
);
entry
.
resolve
(
GestureDisposition
.
accepted
);
expect
(
member
.
accepted
,
isTrue
);
router
.
route
(
up2
);
expect
(
doubleTapRecognized
,
isFalse
);
...
...
@@ -448,4 +457,37 @@ void main() {
tap
.
dispose
();
});
test
(
'Passive gesture should trigger on double tap cancel'
,
()
{
PointerRouter
router
=
new
PointerRouter
();
DoubleTapGestureRecognizer
tap
=
new
DoubleTapGestureRecognizer
(
router:
router
);
bool
doubleTapRecognized
=
false
;
tap
.
onDoubleTap
=
()
{
doubleTapRecognized
=
true
;
};
new
FakeAsync
().
run
((
FakeAsync
async
)
{
tap
.
addPointer
(
down1
);
TestGestureArenaMember
member
=
new
TestGestureArenaMember
();
GestureArena
.
instance
.
add
(
1
,
member
);
GestureArena
.
instance
.
close
(
1
);
expect
(
doubleTapRecognized
,
isFalse
);
router
.
route
(
down1
);
expect
(
doubleTapRecognized
,
isFalse
);
router
.
route
(
up1
);
expect
(
doubleTapRecognized
,
isFalse
);
GestureArena
.
instance
.
sweep
(
1
);
expect
(
doubleTapRecognized
,
isFalse
);
expect
(
member
.
accepted
,
isFalse
);
async
.
elapse
(
new
Duration
(
milliseconds:
5000
));
expect
(
member
.
accepted
,
isTrue
);
});
tap
.
dispose
();
});
}
packages/unit/test/gestures/lsq_solver_test_disabled.dart
0 → 100644
View file @
608e971f
import
'package:flutter/gestures.dart'
;
import
'package:test/test.dart'
;
void
main
(
)
{
void
printFit
(
PolynomialFit
fit
)
{
print
(
"Confidence: "
+
fit
.
confidence
.
toString
());
for
(
int
i
=
0
;
i
<
fit
.
coefficients
.
length
;
i
++)
print
(
i
.
toString
()
+
": "
+
fit
.
coefficients
[
i
].
toString
());
}
approx
(
double
value
,
double
expectation
)
{
const
double
eps
=
1
e
-
6
;
return
(
value
-
expectation
).
abs
()
<
eps
;
}
test
(
'Least-squares fit: linear polynomial to line'
,
()
{
List
<
double
>
x
=
[
0.0
,
1.0
,
2.0
,
3.0
,
4.0
,
5.0
,
6.0
,
7.0
,
8.0
];
List
<
double
>
y
=
[
1.0
,
1.0
,
1.0
,
1.0
,
1.0
,
1.0
,
1.0
,
1.0
,
1.0
];
List
<
double
>
w
=
[
1.0
,
1.0
,
1.0
,
1.0
,
1.0
,
1.0
,
1.0
,
1.0
,
1.0
];
LeastSquaresSolver
solver
=
new
LeastSquaresSolver
(
x
,
y
,
w
);
PolynomialFit
fit
=
solver
.
solve
(
1
);
expect
(
fit
.
coefficients
.
length
,
2
);
expect
(
approx
(
fit
.
coefficients
[
0
],
1.0
),
isTrue
);
expect
(
approx
(
fit
.
coefficients
[
1
],
0.0
),
isTrue
);
expect
(
approx
(
fit
.
confidence
,
1.0
),
isTrue
);
});
test
(
'Least-squares fit: linear polynomial to sloped line'
,
()
{
List
<
double
>
x
=
[
0.0
,
1.0
,
2.0
,
3.0
,
4.0
,
5.0
,
6.0
,
7.0
,
8.0
];
List
<
double
>
y
=
[
1.0
,
2.0
,
3.0
,
4.0
,
5.0
,
6.0
,
7.0
,
8.0
,
9.0
];
List
<
double
>
w
=
[
1.0
,
1.0
,
1.0
,
1.0
,
1.0
,
1.0
,
1.0
,
1.0
,
1.0
];
LeastSquaresSolver
solver
=
new
LeastSquaresSolver
(
x
,
y
,
w
);
PolynomialFit
fit
=
solver
.
solve
(
1
);
expect
(
fit
.
coefficients
.
length
,
2
);
expect
(
approx
(
fit
.
coefficients
[
0
],
1.0
),
isTrue
);
expect
(
approx
(
fit
.
coefficients
[
1
],
1.0
),
isTrue
);
expect
(
approx
(
fit
.
confidence
,
1.0
),
isTrue
);
});
test
(
'Least-squares fit: quadratic polynomial to line'
,
()
{
List
<
double
>
x
=
[
0.0
,
1.0
,
2.0
,
3.0
,
4.0
,
5.0
,
6.0
,
7.0
,
8.0
];
List
<
double
>
y
=
[
1.0
,
1.0
,
1.0
,
1.0
,
1.0
,
1.0
,
1.0
,
1.0
,
1.0
];
List
<
double
>
w
=
[
1.0
,
1.0
,
1.0
,
1.0
,
1.0
,
1.0
,
1.0
,
1.0
,
1.0
];
LeastSquaresSolver
solver
=
new
LeastSquaresSolver
(
x
,
y
,
w
);
PolynomialFit
fit
=
solver
.
solve
(
2
);
expect
(
fit
.
coefficients
.
length
,
3
);
expect
(
approx
(
fit
.
coefficients
[
0
],
1.0
),
isTrue
);
expect
(
approx
(
fit
.
coefficients
[
1
],
0.0
),
isTrue
);
expect
(
approx
(
fit
.
coefficients
[
2
],
0.0
),
isTrue
);
expect
(
approx
(
fit
.
confidence
,
1.0
),
isTrue
);
});
test
(
'Least-squares fit: quadratic polynomial to sloped line'
,
()
{
List
<
double
>
x
=
[
0.0
,
1.0
,
2.0
,
3.0
,
4.0
,
5.0
,
6.0
,
7.0
,
8.0
];
List
<
double
>
y
=
[
1.0
,
2.0
,
3.0
,
4.0
,
5.0
,
6.0
,
7.0
,
8.0
,
9.0
];
List
<
double
>
w
=
[
1.0
,
1.0
,
1.0
,
1.0
,
1.0
,
1.0
,
1.0
,
1.0
,
1.0
];
LeastSquaresSolver
solver
=
new
LeastSquaresSolver
(
x
,
y
,
w
);
PolynomialFit
fit
=
solver
.
solve
(
2
);
expect
(
fit
.
coefficients
.
length
,
3
);
expect
(
approx
(
fit
.
coefficients
[
0
],
1.0
),
isTrue
);
expect
(
approx
(
fit
.
coefficients
[
1
],
1.0
),
isTrue
);
expect
(
approx
(
fit
.
coefficients
[
2
],
0.0
),
isTrue
);
expect
(
approx
(
fit
.
confidence
,
1.0
),
isTrue
);
});
}
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