Adding a unit test on turn sound generation with word Then.

This commit is contained in:
Vladimir Byko-Ianko 2015-10-07 14:02:18 +03:00
parent 89c4e7ae1c
commit f8631533d6
2 changed files with 70 additions and 0 deletions

View file

@ -325,6 +325,75 @@ UNIT_TEST(TurnsSoundFeetTest)
TEST(turnSound.IsEnabled(), ());
}
UNIT_TEST(TurnsSoundComposedTurnTest)
{
TurnsSound turnSound;
turnSound.Enable(true);
turnSound.SetLengthUnits(routing::turns::sound::LengthUnits::Meters);
string const engShortJson =
"\
{\
\"in_600_meters\":\"In 600 meters.\",\
\"make_a_right_turn\":\"Turn right.\",\
\"enter_the_roundabout\":\"Enter the roundabout.\",\
\"then\":\"Then.\",\
\"you_have_reached_the_destination\":\"You have reached the destination.\"\
}";
turnSound.m_getTtsText.ForTestingSetLocaleWithJson(engShortJson);
turnSound.m_settings.ForTestingSetNotificationTimeSecond(30);
turnSound.Reset();
turnSound.SetSpeedMetersPerSecond(20.);
vector<string> turnNotifications;
// Starting nearing the first turn.
// 800 meters till the first turn.
vector<TurnItemDist> const turns1 = {{{5 /* idx */, TurnDirection::TurnRight}, 800. /* m_distMeters */},
{{10 /* idx */, TurnDirection::EnterRoundAbout}, 1000. /* m_distMeters */}};
turnSound.GenerateTurnSound(turns1, turnNotifications);
TEST(turnNotifications.empty(), ());
// 620 meters till the first turn.
turnNotifications.clear();
vector<TurnItemDist> const turns2 = {{{5 /* idx */, TurnDirection::TurnRight}, 620. /* m_distMeters */},
{{10 /* idx */, TurnDirection::EnterRoundAbout}, 820. /* m_distMeters */}};
vector<string> const expectedNotification2 = {{"In 600 meters. Turn right."},
{"Then. Enter the roundabout."}};
turnSound.GenerateTurnSound(turns2, turnNotifications);
TEST_EQUAL(turnNotifications, expectedNotification2, ());
// 300 meters till the first turn.
turnNotifications.clear();
vector<TurnItemDist> const turns3 = {{{5 /* idx */, TurnDirection::TurnRight}, 300. /* m_distMeters */},
{{10 /* idx */, TurnDirection::EnterRoundAbout}, 500. /* m_distMeters */}};
turnSound.GenerateTurnSound(turns3, turnNotifications);
TEST(turnNotifications.empty(), ());
// 20 meters till the first turn.
turnNotifications.clear();
vector<TurnItemDist> const turns4 = {{{5 /* idx */, TurnDirection::TurnRight}, 20. /* m_distMeters */},
{{10 /* idx */, TurnDirection::EnterRoundAbout}, 220. /* m_distMeters */}};
vector<string> const expectedNotification4 = {{"Turn right."},
{"Then. Enter the roundabout."}};
turnSound.GenerateTurnSound(turns4, turnNotifications);
TEST_EQUAL(turnNotifications, expectedNotification4, ());
// After the first turn.
turnNotifications.clear();
vector<TurnItemDist> const turns5 = {{{10 /* idx */, TurnDirection::EnterRoundAbout}, 180. /* m_distMeters */},
{{15 /* idx */, TurnDirection::ReachedYourDestination}, 1180. /* m_distMeters */}};
turnSound.GenerateTurnSound(turns5, turnNotifications);
TEST(turnNotifications.empty(), ());
// Just before the second turn.
turnNotifications.clear();
vector<TurnItemDist> const turns6 = {{{10 /* idx */, TurnDirection::EnterRoundAbout}, 10. /* m_distMeters */},
{{15 /* idx */, TurnDirection::ReachedYourDestination}, 1010. /* m_distMeters */}};
vector<string> const expectedNotification6 = {{"Enter the roundabout."}};
turnSound.GenerateTurnSound(turns6, turnNotifications);
TEST_EQUAL(turnNotifications, expectedNotification6, ());
}
} // namespace sound
} // namespace turns
} // namespace routing

View file

@ -36,6 +36,7 @@ class TurnsSound
friend void UnitTest_TurnsSoundMetersTest();
friend void UnitTest_TurnsSoundMetersTwoTurnsTest();
friend void UnitTest_TurnsSoundFeetTest();
friend void UnitTest_TurnsSoundComposedTurnTest();
/// m_enabled == true when tts is turned on.
/// Important! Clients (iOS/Android) implies that m_enabled is false by default.