diff --git a/routing/routing_tests/turns_sound_test.cpp b/routing/routing_tests/turns_sound_test.cpp index 1a81e5f2c3..4cdc9f7d1e 100644 --- a/routing/routing_tests/turns_sound_test.cpp +++ b/routing/routing_tests/turns_sound_test.cpp @@ -405,10 +405,11 @@ UNIT_TEST(TurnsSoundRoundaboutTurnTest) {\ \"enter_the_roundabout\":\"Enter the roundabout.\",\ \"leave_the_roundabout\":\"Leave the roundabout.\",\ + \"take_the_1st_exit\":\"Take the first exit.\",\ \"take_the_2nd_exit\":\"Take the second exit.\",\ + \"take_the_4th_exit\":\"Take the fourth exit.\",\ \"in_600_meters\":\"In 600 meters.\",\ - \"then\":\"Then.\",\ - \"you_have_reached_the_destination\":\"You have reached the destination.\"\ + \"then\":\"Then.\"\ }"; turnSound.m_getTtsText.ForTestingSetLocaleWithJson(engShortJson); turnSound.m_settings.ForTestingSetNotificationTimeSecond(30); @@ -449,7 +450,7 @@ UNIT_TEST(TurnsSoundRoundaboutTurnTest) // 900 meters till the second turn. vector const turns4 = {{{10 /* idx */, TurnDirection::LeaveRoundAbout, 2 /* m_exitNum */}, 900. /* m_distMeters */}, - {{15 /* idx */, TurnDirection::ReachedYourDestination}, + {{15 /* idx */, TurnDirection::EnterRoundAbout, 1 /* m_exitNum */}, 1900. /* m_distMeters */}}; turnSound.GenerateTurnSound(turns4, turnNotifications); TEST(turnNotifications.empty(), ()); @@ -457,7 +458,7 @@ UNIT_TEST(TurnsSoundRoundaboutTurnTest) // 300 meters till the second turn. vector const turns5 = {{{10 /* idx */, TurnDirection::LeaveRoundAbout, 2 /* m_exitNum */}, 300. /* m_distMeters */}, - {{15 /* idx */, TurnDirection::ReachedYourDestination}, + {{15 /* idx */, TurnDirection::EnterRoundAbout, 1 /* m_exitNum */}, 1300. /* m_distMeters */}}; turnSound.GenerateTurnSound(turns5, turnNotifications); TEST(turnNotifications.empty(), ()); @@ -465,11 +466,41 @@ UNIT_TEST(TurnsSoundRoundaboutTurnTest) // 3 meters till the second turn. vector const turns6 = {{{10 /* idx */, TurnDirection::LeaveRoundAbout, 2 /* m_exitNum */}, 3. /* m_distMeters */}, - {{15 /* idx */, TurnDirection::ReachedYourDestination}, + {{15 /* idx */, TurnDirection::EnterRoundAbout, 1 /* m_exitNum */}, 1003. /* m_distMeters */}}; vector const expectedNotification6 = {{"Leave the roundabout."}}; turnSound.GenerateTurnSound(turns6, turnNotifications); TEST_EQUAL(turnNotifications, expectedNotification6, ()); + + // 5 meters till the third turn. + vector const turns7 = {{{15 /* idx */, TurnDirection::EnterRoundAbout, 1 /* m_exitNum */}, + 5. /* m_distMeters */}, + {{20 /* idx */, TurnDirection::LeaveRoundAbout, 1 /* m_exitNum */}, + 1005. /* m_distMeters */}}; + vector const expectedNotification7 = {{"Enter the roundabout."}, + {"Then. Take the first exit."}}; + turnSound.GenerateTurnSound(turns7, turnNotifications); // The first notification fast forwarding. + turnSound.GenerateTurnSound(turns7, turnNotifications); + TEST_EQUAL(turnNotifications, expectedNotification7, ()); + + // 900 meters till the 4th turn. + turnSound.Reset(); + vector const turns8 = {{{25 /* idx */, TurnDirection::EnterRoundAbout, 4 /* m_exitNum */}, + 900. /* m_distMeters */}, + {{30 /* idx */, TurnDirection::LeaveRoundAbout, 4 /* m_exitNum */}, + 1200. /* m_distMeters */}}; + turnSound.GenerateTurnSound(turns8, turnNotifications); + TEST(turnNotifications.empty(), ()); + + // 620 meters till the 4th turn. + vector const turns9 = {{{25 /* idx */, TurnDirection::EnterRoundAbout, 4 /* m_exitNum */}, + 620. /* m_distMeters */}, + {{30 /* idx */, TurnDirection::LeaveRoundAbout, 4 /* m_exitNum */}, + 920. /* m_distMeters */}}; + vector const expectedNotification9 = {{"In 600 meters. Enter the roundabout."}, + {"Then. Take the fourth exit."}}; + turnSound.GenerateTurnSound(turns9, turnNotifications); + TEST_EQUAL(turnNotifications, expectedNotification9, ()); } } // namespace sound } // namespace turns diff --git a/routing/turns_tts_text.cpp b/routing/turns_tts_text.cpp index 904290f278..38946b1732 100644 --- a/routing/turns_tts_text.cpp +++ b/routing/turns_tts_text.cpp @@ -1,6 +1,8 @@ #include "routing/turns_sound_settings.hpp" #include "routing/turns_tts_text.hpp" +#include "base/string_utils.hpp" + #include "std/algorithm.hpp" #include "std/string.hpp" #include "std/utility.hpp" @@ -110,37 +112,25 @@ string GetRoundaboutTextId(Notification const & notification) if (!notification.m_useThenInsteadOfDistance) return "leave_the_roundabout"; // Notification just before leaving a roundabout. - uint8_t const maxTranslatedExit = 11; - if (notification.m_exitNum == 0 || notification.m_exitNum > maxTranslatedExit) + static const uint8_t kMaxSoundedExit = 11; + if (notification.m_exitNum == 0 || notification.m_exitNum > kMaxSoundedExit) return "leave_the_roundabout"; - switch (notification.m_exitNum) + if (notification.m_exitNum < 4) { - case 1: - return "take_the_1st_exit"; - case 2: - return "take_the_2nd_exit"; - case 3: - return "take_the_3rd_exit"; - case 4: - return "take_the_4th_exit"; - case 5: - return "take_the_5th_exit"; - case 6: - return "take_the_6th_exit"; - case 7: - return "take_the_7th_exit"; - case 8: - return "take_the_8th_exit"; - case 9: - return "take_the_9th_exit"; - case 10: - return "take_the_10th_exit"; - case 11: - return "take_the_11th_exit"; + switch (notification.m_exitNum) + { + case 1: + return "take_the_1st_exit"; + case 2: + return "take_the_2nd_exit"; + case 3: + return "take_the_3rd_exit"; + } + ASSERT(false, ()); + return string(); } - ASSERT(false, ()); - return string(); + return "take_the_" + strings::to_string(static_cast(notification.m_exitNum)) + "th_exit"; } string GetDirectionTextId(Notification const & notification) diff --git a/routing/turns_tts_text.hpp b/routing/turns_tts_text.hpp index 7c1922936f..43390e7463 100644 --- a/routing/turns_tts_text.hpp +++ b/routing/turns_tts_text.hpp @@ -37,7 +37,7 @@ private: /// Generates text message id about the distance of the notification. For example: In 300 meters. string GetDistanceTextId(Notification const & notification); /// Generates text message id for roundabouts. -/// For example: "Leave the roundabout." or "Take the third exit." +/// For example: leave_the_roundabout or take_the_3rd_exit string GetRoundaboutTextId(Notification const & notification); /// Generates text message id about the direction of the notification. For example: Make a right /// turn.