-
Notifications
You must be signed in to change notification settings - Fork 319
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
Use BannerText roundabout degrees + Banner and Voice Milestone Tests #854
Conversation
fc70b86
to
77cb3ed
Compare
@devotaaabel @Guardiola31337 tests added, this PR is good to go for 👀 |
3c96e97
to
a730bcf
Compare
6bcd008
to
7f3b205
Compare
@danesfeder Do we know when this will be complete? I'm just waiting on the stable |
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.
Nice test coverage @danesfeder ❤️ it!
This is looking great. A few comments / cleanup.
public class InstructionModel { | ||
|
||
private BannerText primaryBannerText; | ||
private BannerText secondaryBannerText; | ||
private BannerText thenBannerText; | ||
private Float roundaboutAngle = null; | ||
private InstructionStepResources stepResources; | ||
private RouteProgress progress; | ||
private Locale locale; |
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.
Minor thing annotations normally are on top of the definition like 👇
@NavigationUnitType.UnitType
private int unitType;
👇
@@ -135,7 +135,7 @@ protected void onDraw(Canvas canvas) { | |||
case STEP_MANEUVER_TYPE_ROUNDABOUT: |
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.
What about decomposing the switch
somehow? It's too long... There's even another switch
in one of the branches 😅
|
||
import static org.junit.Assert.assertNotNull; | ||
import static org.junit.Assert.assertTrue; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.times; | ||
import static org.mockito.Mockito.verify; | ||
|
||
@RunWith(RobolectricTestRunner.class) | ||
@Config(constants = com.mapbox.services.android.navigation.BuildConfig.class, manifest = Config.DEFAULT_MANIFEST_NAME) | ||
public class NavigationViewEventDispatcherTest { |
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.
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
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.
In general, we should avoid inline setup 👀 https://speakerdeck.com/guardiola31337/elegant-unit-testing-mobilization-2016?slide=65
Could you extract this block of code into private "factory" methods and use them only in the tests that actually need it/across the rest of the tests?
IMO, it reflects better what's going on in the test and you don't break the triple A "rule".
return validInstructions(stepBannerInstructions) | ||
&& validInstructions(instructions) | ||
&& instructions.get(0).equals(stepBannerInstructions.get(0)); | ||
private boolean isFirstInstruction(BannerInstructions instructions) { |
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.
Why not inlining it and use an explaining variable as with the rest of the boolean
s in shouldBeShown
?
@@ -64,7 +55,10 @@ public String buildInstruction(RouteProgress routeProgress) { | |||
* @since 0.8.0 | |||
*/ | |||
public String getSsmlAnnouncement() { | |||
return ssmlAnnouncement; | |||
if (instructions == null) { | |||
return ""; |
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.
NIT magic number
public void onNullMilestoneInstructions_emptyInstructionsAreReturned() throws Exception { | ||
VoiceInstructionMilestone milestone = buildVoiceInstructionMilestone(); | ||
|
||
assertEquals("", milestone.getAnnouncement()); |
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.
Generally is preferable having only 1 assertion per test 👀 https://speakerdeck.com/guardiola31337/elegant-unit-testing-mobilization-2016?slide=57
What's the value of adding assertEquals("", milestone.getSsmlAnnouncement());
if you're already testing it in onNullMilestoneInstructions_emptySsmlInstructionsAreReturned
?
import static junit.framework.Assert.assertEquals; | ||
import static junit.framework.Assert.assertNotNull; | ||
import static junit.framework.Assert.assertNotSame; | ||
import static junit.framework.Assert.assertNull; | ||
import static junit.framework.Assert.assertTrue; | ||
|
||
public class RouteLegProgressTest extends BaseTest { |
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.
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.
👀 asserts inside a for loop are weird. What are we trying to test in fractionTraveled_equalsCorrectValueAtIntervals
test?
double durationRemaining = route.duration(); | ||
double progressDurationRemaining = beginningRouteProgress.durationRemaining(); | ||
|
||
assertEquals(durationRemaining, progressDurationRemaining, BaseTest.DELTA); | ||
} | ||
|
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.
👀 asserts inside a for loop are weird. What are we trying to test in fractionTraveled_equalsCorrectValueAtIntervals
and multiLeg_getFractionTraveled_equalsCorrectValueAtIntervals
tests?
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.
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.
@@ -242,19 +242,23 @@ public void fractionTraveled_equalsOneAtEndOfStep() throws Exception { | |||
} | |||
|
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.
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.
👀 asserts inside a for loop are weird.
currentStep, stepDistanceRemaining | ||
); | ||
|
||
assertEquals(null, currentBannerInstructions); |
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.
We could use assertNull
instead.
The same thing happens with another tests included in RouteUtilsTest
👇
7f3b205
to
8d04e83
Compare
8d04e83
to
4d7f353
Compare
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.
There are still some comments not addressed but this is in really good shape to 🚢
Great job @danesfeder
Loved how you completely removed that switch
in ManeuverView
🙇
The directions API now provides a
float
degrees inBannerText
indicating the where you will be exiting the roundabout. This PR takes this value from the API and uses it to draw the roundabout in theManeuverView
dynamically.This is also a good opportunity to clean up some of the model work. Currently in a bit of a 🍝 state. Going to exercise the boyscout rule and clean it up a bit in this PR.
TODO:
VoiceInstructionsMilestoneTest
BannerInstructionsMilestoneTest