From 4d1f0e8ef4cb0a2f2cfb4ee289938b28ee0745e4 Mon Sep 17 00:00:00 2001 From: Vladimir Byko-Ianko Date: Thu, 30 Jul 2015 10:59:26 +0300 Subject: [PATCH] Adding test for GetTtsText class and for accessory functionality. --- routing/routing_tests/routing_tests.pro | 1 + .../routing_tests/turns_tts_text_tests.cpp | 68 +++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 routing/routing_tests/turns_tts_text_tests.cpp diff --git a/routing/routing_tests/routing_tests.pro b/routing/routing_tests/routing_tests.pro index 0c85530df4..1a83bd6e05 100644 --- a/routing/routing_tests/routing_tests.pro +++ b/routing/routing_tests/routing_tests.pro @@ -37,6 +37,7 @@ SOURCES += \ routing_mapping_test.cpp \ turns_generator_test.cpp \ turns_sound_test.cpp \ + turns_tts_text_tests.cpp \ vehicle_model_test.cpp \ HEADERS += \ diff --git a/routing/routing_tests/turns_tts_text_tests.cpp b/routing/routing_tests/turns_tts_text_tests.cpp new file mode 100644 index 0000000000..019f623afe --- /dev/null +++ b/routing/routing_tests/turns_tts_text_tests.cpp @@ -0,0 +1,68 @@ +#include "testing/testing.hpp" + +#include "routing/turns_sound_settings.hpp" +#include "routing/turns_tts_text.hpp" + +namespace +{ +using namespace routing::turns; +using namespace routing::turns::sound; + +UNIT_TEST(GetDistanceTextIdMetersTest) +{ + //Notification(uint32_t distanceUnits, uint8_t exitNum, bool useThenInsteadOfDistance, + // TurnDirection turnDir, LengthUnits lengthUnits) + Notification const notifiation1(500, 0, false, TurnDirection::TurnRight, LengthUnits::Meters); + TEST_EQUAL(GetDistanceTextId(notifiation1), "in_500_meters", ()); + Notification const notifiation2(500, 0, true, TurnDirection::TurnRight, LengthUnits::Meters); + TEST_EQUAL(GetDistanceTextId(notifiation2), "then", ()); + Notification const notifiation3(200, 0, false, TurnDirection::TurnRight, LengthUnits::Meters); + TEST_EQUAL(GetDistanceTextId(notifiation3), "in_200_meters", ()); + Notification const notifiation4(2000, 0, false, TurnDirection::TurnRight, LengthUnits::Meters); + TEST_EQUAL(GetDistanceTextId(notifiation4), "in_2_kilometers", ()); +} + +UNIT_TEST(GetDistanceTextIdFeetTest) +{ + Notification const notifiation1(500, 0, false, TurnDirection::TurnRight, LengthUnits::Feet); + TEST_EQUAL(GetDistanceTextId(notifiation1), "in_500_feet", ()); + Notification const notifiation2(500, 0, true, TurnDirection::TurnRight, LengthUnits::Feet); + TEST_EQUAL(GetDistanceTextId(notifiation2), "then", ()); + Notification const notifiation3(800, 0, false, TurnDirection::TurnRight, LengthUnits::Feet); + TEST_EQUAL(GetDistanceTextId(notifiation3), "in_800_feet", ()); + Notification const notifiation4(5000, 0, false, TurnDirection::TurnRight, LengthUnits::Feet); + TEST_EQUAL(GetDistanceTextId(notifiation4), "in_5000_feet", ()); +} + +UNIT_TEST(GetDirectionTextIdTest) +{ + Notification const notifiation1(500, 0, false, TurnDirection::TurnRight, LengthUnits::Feet); + TEST_EQUAL(GetDirectionTextId(notifiation1), "make_a_right_turn", ()); + Notification const notifiation2(1000, 0, false, TurnDirection::GoStraight, LengthUnits::Meters); + TEST_EQUAL(GetDirectionTextId(notifiation2), "go_straight", ()); + Notification const notifiation3(700, 0, false, TurnDirection::UTurn, LengthUnits::Meters); + TEST_EQUAL(GetDirectionTextId(notifiation3), "make_a_u_turn", ()); +} + +UNIT_TEST(GetTtsTextTest) +{ + //Notification(uint32_t distanceUnits, uint8_t exitNum, bool useThenInsteadOfDistance, + // TurnDirection turnDir, LengthUnits lengthUnits) + GetTtsText getTtsText; + + Notification const notifiation1(500, 0, false, TurnDirection::TurnRight, LengthUnits::Meters); + Notification const notifiation2(300, 0, false, TurnDirection::TurnLeft, LengthUnits::Meters); + Notification const notifiation3(0, 0, false, TurnDirection::ReachedYourDestination, + LengthUnits::Meters); + + getTtsText.SetLocale("en"); + 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.", ()); + + getTtsText.SetLocale("ru"); + TEST_EQUAL(getTtsText(notifiation1), "Через 500 метров. Поворот направо.", ()); + TEST_EQUAL(getTtsText(notifiation2), "Через 300 метров. Поворот налево.", ()); + TEST_EQUAL(getTtsText(notifiation3), "Вы достигли конца маршрута.", ()); +} +} // namespace