Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix SpeechAnnouncementListener example and add tests
- Loading branch information
1 parent
d8dbb39
commit ba4e66a
Showing
3 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
.../test/java/com/mapbox/services/android/navigation/ui/v5/voice/SpeechAnnouncementTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.mapbox.services.android.navigation.ui.v5.voice; | ||
|
||
import com.mapbox.services.android.navigation.v5.milestone.VoiceInstructionMilestone; | ||
|
||
import org.junit.Test; | ||
|
||
import static junit.framework.Assert.assertEquals; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
public class SpeechAnnouncementTest { | ||
|
||
@Test | ||
public void milestoneAnnouncement_isUsedWhenProvided() { | ||
VoiceInstructionMilestone milestone = mock(VoiceInstructionMilestone.class); | ||
String announcement = "Milestone announcement"; | ||
when(milestone.getAnnouncement()).thenReturn(announcement); | ||
|
||
SpeechAnnouncement speechAnnouncement = SpeechAnnouncement.builder() | ||
.voiceInstructionMilestone(milestone) | ||
.build(); | ||
|
||
assertEquals(announcement, speechAnnouncement.announcement()); | ||
} | ||
|
||
@Test | ||
public void milestoneSsmlAnnouncement_isUsedWhenProvided() { | ||
VoiceInstructionMilestone milestone = mock(VoiceInstructionMilestone.class); | ||
String announcement = "Milestone announcement"; | ||
when(milestone.getAnnouncement()).thenReturn(announcement); | ||
String ssmlAnnouncement = "Milestone SSML announcement"; | ||
when(milestone.getSsmlAnnouncement()).thenReturn(ssmlAnnouncement); | ||
|
||
SpeechAnnouncement speechAnnouncement = SpeechAnnouncement.builder() | ||
.voiceInstructionMilestone(milestone) | ||
.build(); | ||
|
||
assertEquals(ssmlAnnouncement, speechAnnouncement.ssmlAnnouncement()); | ||
} | ||
} |