Merge pull request #202 from bykoianko/different-notification-near-end-of-the-route

Different notification near end of the route
This commit is contained in:
Lev Dragunov 2015-10-13 19:02:19 +03:00
commit a3ef25245a
4 changed files with 57 additions and 2 deletions

View file

@ -19,7 +19,7 @@ bool PairDistEquals(PairDist const & lhs, PairDist const & rhs)
UNIT_TEST(GetDistanceTextIdMetersTest)
{
// Notification(uint32_t distanceUnits, uint8_t exitNum, bool useThenInsteadOfDistance,
// TurnDirection turnDir, Settings::Units lengthUnits)
// TurnDirection turnDir, ::Settings::Units lengthUnits)
Notification const notifiation1(500, 0, false, TurnDirection::TurnRight, ::Settings::Metric);
TEST_EQUAL(GetDistanceTextId(notifiation1), "in_500_meters", ());
Notification const notifiation2(500, 0, true, TurnDirection::TurnRight, ::Settings::Metric);
@ -32,6 +32,8 @@ UNIT_TEST(GetDistanceTextIdMetersTest)
UNIT_TEST(GetDistanceTextIdFeetTest)
{
// Notification(uint32_t distanceUnits, uint8_t exitNum, bool useThenInsteadOfDistance,
// TurnDirection turnDir, ::Settings::Units lengthUnits)
Notification const notifiation1(500, 0, false, TurnDirection::TurnRight, ::Settings::Foot);
TEST_EQUAL(GetDistanceTextId(notifiation1), "in_500_feet", ());
Notification const notifiation2(500, 0, true, TurnDirection::TurnRight, ::Settings::Foot);
@ -42,14 +44,46 @@ UNIT_TEST(GetDistanceTextIdFeetTest)
TEST_EQUAL(GetDistanceTextId(notifiation4), "in_5000_feet", ());
}
UNIT_TEST(GetRoundaboutTextIdTest)
{
// Notification(uint32_t distanceUnits, uint8_t exitNum, bool useThenInsteadOfDistance,
// TurnDirection turnDir, ::Settings::Units lengthUnits)
Notification const notifiation1(500, 0, false, TurnDirection::LeaveRoundAbout, ::Settings::Foot);
TEST_EQUAL(GetRoundaboutTextId(notifiation1), "leave_the_roundabout", ());
Notification const notifiation2(0, 3, true, TurnDirection::LeaveRoundAbout, ::Settings::Foot);
TEST_EQUAL(GetRoundaboutTextId(notifiation2), "take_the_3rd_exit", ());
Notification const notifiation3(0, 7, true, TurnDirection::LeaveRoundAbout, ::Settings::Metric);
TEST_EQUAL(GetRoundaboutTextId(notifiation3), "take_the_7th_exit", ());
Notification const notifiation4(0, 15, true, TurnDirection::LeaveRoundAbout, ::Settings::Metric);
TEST_EQUAL(GetRoundaboutTextId(notifiation4), "leave_the_roundabout", ());
}
UNIT_TEST(GetYouArriveTextIdTest)
{
// Notification(uint32_t distanceUnits, uint8_t exitNum, bool useThenInsteadOfDistance,
// TurnDirection turnDir, ::Settings::Units lengthUnits)
Notification const notifiation1(500, 0, false, TurnDirection::ReachedYourDestination, ::Settings::Foot);
TEST_EQUAL(GetYouArriveTextId(notifiation1), "destination", ());
Notification const notifiation2(0, 0, false, TurnDirection::ReachedYourDestination, ::Settings::Metric);
TEST_EQUAL(GetYouArriveTextId(notifiation2), "you_have_reached_the_destination", ());
Notification const notifiation3(0, 0, true, TurnDirection::ReachedYourDestination, ::Settings::Metric);
TEST_EQUAL(GetYouArriveTextId(notifiation3), "destination", ());
}
UNIT_TEST(GetDirectionTextIdTest)
{
// Notification(uint32_t distanceUnits, uint8_t exitNum, bool useThenInsteadOfDistance,
// TurnDirection turnDir, ::Settings::Units lengthUnits)
Notification const notifiation1(500, 0, false, TurnDirection::TurnRight, ::Settings::Foot);
TEST_EQUAL(GetDirectionTextId(notifiation1), "make_a_right_turn", ());
Notification const notifiation2(1000, 0, false, TurnDirection::GoStraight, ::Settings::Metric);
TEST_EQUAL(GetDirectionTextId(notifiation2), "go_straight", ());
Notification const notifiation3(700, 0, false, TurnDirection::UTurn, ::Settings::Metric);
TEST_EQUAL(GetDirectionTextId(notifiation3), "make_a_u_turn", ());
Notification const notifiation4(200, 0, false, TurnDirection::ReachedYourDestination, ::Settings::Metric);
TEST_EQUAL(GetDirectionTextId(notifiation4), "destination", ());
Notification const notifiation5(0, 0, false, TurnDirection::ReachedYourDestination, ::Settings::Metric);
TEST_EQUAL(GetDirectionTextId(notifiation5), "you_have_reached_the_destination", ());
}
UNIT_TEST(GetTtsTextTest)

View file

@ -76,8 +76,13 @@ public:
/// notification to pronounce.
struct Notification
{
/// m_distanceUnits is a distance to the turn in m_lengthUnits (meters or feet).
/// If m_distanceUnits == 0 then the information about distance to the turn shall
/// not be pronounced.
uint32_t m_distanceUnits;
uint8_t m_exitNum;
/// if m_useThenInsteadOfDistance == true the m_distanceUnits is ignored.
/// The word "Then" shall be pronounced intead of the distance.
bool m_useThenInsteadOfDistance;
TurnDirection m_turnDir;
::Settings::Units m_lengthUnits;

View file

@ -124,6 +124,19 @@ string GetRoundaboutTextId(Notification const & notification)
return "take_the_" + strings::to_string(static_cast<int>(notification.m_exitNum)) + "th_exit";
}
string GetYouArriveTextId(Notification const & notification)
{
if (notification.m_turnDir != TurnDirection::ReachedYourDestination)
{
ASSERT(false, ());
return string();
}
if (notification.m_distanceUnits != 0 || notification.m_useThenInsteadOfDistance)
return "destination";
return "you_have_reached_the_destination";
}
string GetDirectionTextId(Notification const & notification)
{
switch (notification.m_turnDir)
@ -149,7 +162,7 @@ string GetDirectionTextId(Notification const & notification)
case TurnDirection::LeaveRoundAbout:
return GetRoundaboutTextId(notification);
case TurnDirection::ReachedYourDestination:
return "you_have_reached_the_destination";
return GetYouArriveTextId(notification);
case TurnDirection::StayOnRoundAbout:
case TurnDirection::StartAtEndOfStreet:
case TurnDirection::TakeTheExit:

View file

@ -39,6 +39,9 @@ string GetDistanceTextId(Notification const & notification);
/// Generates text message id for roundabouts.
/// For example: leave_the_roundabout or take_the_3rd_exit
string GetRoundaboutTextId(Notification const & notification);
/// Generates text message id for the finish of the route.
/// For example: destination or you_have_reached_the_destination
string GetYouArriveTextId(Notification const & notification);
/// Generates text message id about the direction of the notification. For example: Make a right
/// turn.
string GetDirectionTextId(Notification const & notification);