-
Notifications
You must be signed in to change notification settings - Fork 319
Use last BannerInstruction for arrival event #943
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
Conversation
526fe42 to
5d4efa0
Compare
0167cc0 to
abfa6de
Compare
abfa6de to
db1a0af
Compare
devotaaabel
left a comment
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.
A lot of the refactoring looks good! Though I had a couple of things to bring up, especially about how we're testing.
| } | ||
| } | ||
|
|
||
| private void sendEventIsRunning(boolean isRunning) { |
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.
Should this be sendEventIfRunning? It's kind of a confusing name, maybe sendStatusEvent?
| if (!(milestone instanceof BannerInstructionMilestone)) { | ||
| return false; | ||
| } | ||
| if (upcomingStepIsArrival(routeProgress) || currentStepIsArrival(routeProgress)) { |
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.
Can you explain what this is doing/why? Maybe this can be refactored to make it more clear
| } | ||
|
|
||
| protected RouteProgress buildDefaultTestRouteProgress(DirectionsRoute testRoute) throws Exception { | ||
| return routeProgressBuilder.buildDefaultTestRouteProgress(testRoute); |
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.
I don't like BaseTest being the place to put all of our builders for test objects, can't the test classes call the TestBuilders directly? Also, I think we need to decide between Test..Builder and ...Faker for naming for consistency because they seem to be doing the same thing
| mock(LocationEngine.class)); | ||
| } | ||
|
|
||
| private int searchVoiceInstructionMilestone(MapboxNavigation navigation) { |
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.
searchForVoiceInstructionMilestone?
| return identifier; | ||
| } | ||
|
|
||
| private int searchBannerInstructionMilestone(MapboxNavigation navigation) { |
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.
searchForBannerInstructionMilestone?
| 100, 100, lastStepIndex, 0); | ||
| navigationEventDispatcher.onMilestoneEvent(routeProgress, instruction, bannerInstructionMilestone); | ||
|
|
||
| verify(arrivalListener, times(0)).onArrival(routeProgress); |
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.
Shouldn't this be broken into two different tests? Since you're verifying two different things
| navigationEventDispatcher.onProgressChange(location, routeProgressDidNotArrive); | ||
| verify(eventListeners, times(1)).onRouteProgressUpdate(routeProgressDidNotArrive); | ||
| verify(arrivalListener, times(0)).onArrival(location, routeProgressDidNotArrive); | ||
| navigationEventDispatcher.onMilestoneEvent(routeProgress, instruction, bannerInstructionMilestone); |
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.
If you make RouteUtils non-static and "inject" it, then you can mock it and shouldn't have to deal with all of the complexity of creating all of this (i.e., mock routeProgress and routeUtils, and add when(routeUtils.isArrivalEvent(routeProgress)).thenReturn(true), etc.)
|
|
||
| boolean isArrivalEvent = RouteUtils.isArrivalEvent(theRouteProgress); | ||
| public void isArrivalEvent_returnsTrueWhenManeuverTypeIsArrival_andIsLastInstruction() throws Exception { | ||
| DirectionsRoute route = buildTestDirectionsRoute(); |
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.
shouldn't these all be mocked instead of test objects? Because really, this is reliant on the other implementations to work (DirectionsRoute, RouteLeg, etc.)
ae988ed to
2a448d1
Compare
devotaaabel
left a comment
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.
Looks good, that's exactly what I meant, but see comment.
| progressChangeListeners = new CopyOnWriteArrayList<>(); | ||
| offRouteListeners = new CopyOnWriteArrayList<>(); | ||
| fasterRouteListeners = new CopyOnWriteArrayList<>(); | ||
| routeUtils = new RouteUtils(); |
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.
You can replace the first constructor with NavigationEventDispatcher() { this(new RouteUtils()); } so you avoid the duplicate code and the chance that the two constructors diverge
2a448d1 to
da26b8c
Compare
|
@dsilvera thanks for the feedback -- could you please provide a real-world example for investigation? |
|
@akitchen It works finaly. |
|
We would still like to understand your frustration or what event caused you to reply here. Please open a new ticket with more details if you could, we would really appreciate it! |
|
I'm not frustrated, you do an excellent job ;) |
Closes #926
TODO:
cc @akitchen