diff --git a/routing/routing_tests/turns_sound_test.cpp b/routing/routing_tests/turns_sound_test.cpp index 05e6c0cfa6..feece5f9d6 100644 --- a/routing/routing_tests/turns_sound_test.cpp +++ b/routing/routing_tests/turns_sound_test.cpp @@ -7,14 +7,19 @@ namespace { -using namespace location; -using namespace routing::turns; -using namespace routing::turns::sound; - // A error to compare two double after conversion feet to meters. double const kEps = 1.; // A error to compare two doubles which are almost equal. double const kSmallEps = .001; +} // namespace + +namespace routing +{ +namespace turns +{ +namespace sound +{ +using namespace location; UNIT_TEST(TurnNotificationSettingsMetersTest) { @@ -96,8 +101,8 @@ UNIT_TEST(TurnsSoundMetersTest) \"in_600_meters\":\"In 600 meters.\",\ \"make_a_right_turn\":\"Make a right turn.\"\ }"; - turnSound.SetLocaleWithJson(engShortJson); - turnSound.SetNotificationTimeSecond(20); + turnSound.m_getTtsText.ForTestingSetLocaleWithJson(engShortJson); + turnSound.m_settings.ForTestingSetNotificationTimeSecond(20); turnSound.Reset(); turnSound.SetSpeedMetersPerSecond(30.); @@ -179,8 +184,8 @@ UNIT_TEST(TurnsSoundMetersTwoTurnsTest) \"make_a_sharp_right_turn\":\"Make a sharp right turn.\",\ \"enter_the_roundabout\":\"Enter the roundabout.\"\ }"; - turnSound.SetLocaleWithJson(engShortJson); - turnSound.SetNotificationTimeSecond(20); + turnSound.m_getTtsText.ForTestingSetLocaleWithJson(engShortJson); + turnSound.m_settings.ForTestingSetNotificationTimeSecond(20); turnSound.Reset(); turnSound.SetSpeedMetersPerSecond(35.); @@ -243,8 +248,8 @@ UNIT_TEST(TurnsSoundFeetTest) \"in_2000_feet\":\"In 2000 feet.\",\ \"enter_the_roundabout\":\"Enter the roundabout.\"\ }"; - turnSound.SetLocaleWithJson(engShortJson); - turnSound.SetNotificationTimeSecond(20); + turnSound.m_getTtsText.ForTestingSetLocaleWithJson(engShortJson); + turnSound.m_settings.ForTestingSetNotificationTimeSecond(20); turnSound.Reset(); turnSound.SetSpeedMetersPerSecond(30.); @@ -308,4 +313,6 @@ UNIT_TEST(TurnsSoundFeetTest) TEST(turnSound.IsEnabled(), ()); } -} // namespace +} // namespace sound +} // namespace turns +} // namespace routing diff --git a/routing/routing_tests/turns_tts_text_tests.cpp b/routing/routing_tests/turns_tts_text_tests.cpp index ce6e8cdc79..6aef4b4dc0 100644 --- a/routing/routing_tests/turns_tts_text_tests.cpp +++ b/routing/routing_tests/turns_tts_text_tests.cpp @@ -85,13 +85,13 @@ UNIT_TEST(GetTtsTextTest) LengthUnits::Meters); Notification const notifiation4(0, 0, true, TurnDirection::TurnLeft, LengthUnits::Meters); - getTtsText.SetLocaleWithJson(engShortJson); + getTtsText.ForTestingSetLocaleWithJson(engShortJson); TEST_EQUAL(getTtsText(notifiation1), "In 500 meters. Make a right turn.", ()); TEST_EQUAL(getTtsText(notifiation2), "In 300 meters. Make a left turn.", ()); TEST_EQUAL(getTtsText(notifiation3), "You have reached the destination.", ()); TEST_EQUAL(getTtsText(notifiation4), "Then. Make a left turn.", ()); - getTtsText.SetLocaleWithJson(rusShortJson); + getTtsText.ForTestingSetLocaleWithJson(rusShortJson); TEST_EQUAL(getTtsText(notifiation1), "Через 500 метров. Поворот направо.", ()); TEST_EQUAL(getTtsText(notifiation2), "Через 300 метров. Поворот налево.", ()); TEST_EQUAL(getTtsText(notifiation3), "Вы достигли конца маршрута.", ()); diff --git a/routing/turns_sound.hpp b/routing/turns_sound.hpp index a20359b573..27f50bc04d 100644 --- a/routing/turns_sound.hpp +++ b/routing/turns_sound.hpp @@ -33,6 +33,10 @@ string DebugPrint(PronouncedNotification const notificationProgress); /// and relevant speed. class TurnsSound { + friend void UnitTest_TurnsSoundMetersTest(); + friend void UnitTest_TurnsSoundMetersTwoTurnsTest(); + friend void UnitTest_TurnsSoundFeetTest(); + /// m_enabled == true when tts is turned on. /// Important! Clients (iOS/Android) implies that m_enabled is false by default. bool m_enabled; @@ -69,10 +73,6 @@ public: inline LengthUnits GetLengthUnits() const { return m_settings.GetLengthUnits(); } inline void SetLocale(string const & locale) { m_getTtsText.SetLocale(locale); } inline string GetLocale() const { return m_getTtsText.GetLocale(); } - /// SetLocaleWithJson is used for writing unit tests only. - void SetLocaleWithJson(string const & jsonBuffer) { m_getTtsText.SetLocaleWithJson(jsonBuffer); } - /// SetNotificationTimeSecond is used for writing unit tests only. - void SetNotificationTimeSecond(uint32_t time) { m_settings.SetNotificationTimeSecond(time); } void SetSpeedMetersPerSecond(double speed); /// \brief GenerateTurnSound updates information about the next turn notification. diff --git a/routing/turns_sound_settings.hpp b/routing/turns_sound_settings.hpp index 904d4effe1..74fd7ebf25 100644 --- a/routing/turns_sound_settings.hpp +++ b/routing/turns_sound_settings.hpp @@ -72,8 +72,7 @@ public: inline void SetLengthUnits(LengthUnits units) { m_lengthUnits = units; } double ConvertMetersPerSecondToUnitsPerSecond(double speedInMetersPerSecond) const; double ConvertUnitsToMeters(double distanceInUnits) const; - /// SetNotificationTimeSecond is used for writing unit tests only. - void SetNotificationTimeSecond(uint32_t time) { m_timeSeconds = time; } + void ForTestingSetNotificationTimeSecond(uint32_t time) { m_timeSeconds = time; } }; /// \brief The Notification struct contains all the information about the next sound diff --git a/routing/turns_tts_text.cpp b/routing/turns_tts_text.cpp index 44caafbbae..3c43db3441 100644 --- a/routing/turns_tts_text.cpp +++ b/routing/turns_tts_text.cpp @@ -40,7 +40,7 @@ void GetTtsText::SetLocale(string const & locale) ASSERT(m_getCurLang, ()); } -void GetTtsText::SetLocaleWithJson(string const & jsonBuffer) +void GetTtsText::ForTestingSetLocaleWithJson(string const & jsonBuffer) { m_getCurLang.reset(new platform::GetTextById(jsonBuffer)); ASSERT(m_getCurLang && m_getCurLang->IsValid(), ()); diff --git a/routing/turns_tts_text.hpp b/routing/turns_tts_text.hpp index a160d27a05..26a4df1a54 100644 --- a/routing/turns_tts_text.hpp +++ b/routing/turns_tts_text.hpp @@ -25,8 +25,7 @@ public: /// TODO(vbykoianko) Check if locale is available. If not use default (en) locale. void SetLocale(string const & locale); inline string GetLocale() const { return m_locale; } - /// SetLocaleWithJson is used for writing unit tests only. - void SetLocaleWithJson(string const & jsonBuffer); + void ForTestingSetLocaleWithJson(string const & jsonBuffer); private: string GetTextById(string const & textId) const;