-
Notifications
You must be signed in to change notification settings - Fork 320
Added checks for low point ammounts #1108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -89,6 +89,21 @@ public void isUserOffRoute_AssertTrueWhenTooFarFromStep() throws Exception { | |
| assertTrue(isUserOffRoute); | ||
| } | ||
|
|
||
| @Test | ||
| public void isUserOffRoute_StepPointSize() throws Exception { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Normally is good to structure the tests following the triple A 👀 https://speakerdeck.com/guardiola31337/elegant-unit-testing-mobilization-2016?slide=40 http://wiki.c2.com/?ArrangeActAssert
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point, I thought I had to delete the points, after the first off route check, it turns out, it's ok to do it before as well. Changed the order.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NIT - You can also remove some "unnecessary" new lines so that the 3 parts of the test ( @Test
public void test() {
RouteProgress routeProgress = buildDefaultTestRouteProgress();
// ...
boolean isUserOffRoute = offRouteDetector.isUserOffRoute(secondUpdate, routeProgress, options);
assertFalse(isUserOffRoute);
}
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure that's not a problem. |
||
| RouteProgress routeProgress = buildDefaultTestRouteProgress(); | ||
| Point stepManeuverPoint = routeProgress.directionsRoute().legs().get(0).steps().get(0).maneuver().location(); | ||
| removeAllButOneStepPoints(routeProgress); | ||
| Location firstUpdate = buildDefaultLocationUpdate(-77.0339782574523, 38.89993519985637); | ||
| offRouteDetector.isUserOffRoute(firstUpdate, routeProgress, options); | ||
| Point offRoutePoint = buildPointAwayFromPoint(stepManeuverPoint, 50, 90); | ||
| Location secondUpdate = buildDefaultLocationUpdate(offRoutePoint.longitude(), offRoutePoint.latitude()); | ||
|
|
||
| boolean isUserOffRoute = offRouteDetector.isUserOffRoute(secondUpdate, routeProgress, options); | ||
|
|
||
| assertFalse(isUserOffRoute); | ||
| } | ||
|
|
||
| @Test | ||
| public void isUserOffRoute_AssertFalseWhenOnStep() throws Exception { | ||
| RouteProgress routeProgress = buildDefaultTestRouteProgress(); | ||
|
|
@@ -225,4 +240,10 @@ public void isUserOffRoute_assertTrueWhenRouteDistanceRemainingIsZero() { | |
|
|
||
| assertTrue(isOffRoute); | ||
| } | ||
|
|
||
| private void removeAllButOneStepPoints(RouteProgress routeProgress) { | ||
| for (int i = routeProgress.currentStepPoints().size() - 2; i >= 0; i--) { | ||
| routeProgress.currentStepPoints().remove(i); | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is duplicated now in
OffRouteDetectorandNavigationMapRoute, but since it's two different packages and the duplication is rather small, I prefered to duplicate it.