summaryrefslogtreecommitdiff
path: root/src/components/application_manager/rpc_plugins/sdl_rpc_plugin
diff options
context:
space:
mode:
authorPavel Zhdanov (GitHub) <39907184+ZhdanovP@users.noreply.github.com>2020-06-08 18:03:06 +0300
committerGitHub <noreply@github.com>2020-06-08 11:03:06 -0400
commit908b473c971e98581dbc7fd026361406766b81c0 (patch)
treed40f55b46e0336fc3ff8b1d5ca28a7136a7ab8e0 /src/components/application_manager/rpc_plugins/sdl_rpc_plugin
parent343f003df46a3abfbc3c88e0716c37c5a2638559 (diff)
downloadsdl_core-908b473c971e98581dbc7fd026361406766b81c0.tar.gz
Sdl must store onWayPointChange internally (#2490)
* Add saving way points during notification - When OnWayPointNotification appeared the wayPoint is saving - When new app subscribing on wayPointNotification stored way points are sending to app * Add unit tests * fix style, update to remove (uint32_t) overload of SubscribeAppForWayPoints Co-authored-by: collin <collin+i@collinmcqueen.com>
Diffstat (limited to 'src/components/application_manager/rpc_plugins/sdl_rpc_plugin')
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_way_point_change_notification.cc1
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_way_point_change_notification_test.cc66
2 files changed, 60 insertions, 7 deletions
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_way_point_change_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_way_point_change_notification.cc
index e89ede53b9..39e0735013 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_way_point_change_notification.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_way_point_change_notification.cc
@@ -65,6 +65,7 @@ void OnWayPointChangeNotification::Run() {
(*message_)[strings::params][strings::connection_key] = *app_id;
SendNotification();
}
+ application_manager_.SaveWayPointsMessage(message_);
}
} // namespace commands
} // namespace sdl_rpc_plugin
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_way_point_change_notification_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_way_point_change_notification_test.cc
index 83958954cd..ec401ae2a8 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_way_point_change_notification_test.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_way_point_change_notification_test.cc
@@ -59,19 +59,40 @@ using sdl_rpc_plugin::commands::OnWayPointChangeNotification;
typedef std::shared_ptr<OnWayPointChangeNotification> NotificationPtr;
namespace {
-const uint32_t kAppId = 1u;
+const uint32_t kApp1Id = 1u;
+const uint32_t kApp2Id = 2u;
} // namespace
class OnWayPointChangeNotificationTest
: public CommandsTest<CommandsTestMocks::kIsNice> {
public:
- OnWayPointChangeNotificationTest()
- : command_(CreateCommand<OnWayPointChangeNotification>()) {}
+ OnWayPointChangeNotificationTest() {}
+
+ void SetUp() OVERRIDE {
+ command_ = CreateCommand();
+ }
+
+ std::shared_ptr<OnWayPointChangeNotification> CreateCommand() {
+ InitCommand(CommandsTest<CommandsTestMocks::kIsNice>::kDefaultTimeout_);
+ message_ = CreateMessage();
+ return std::make_shared<OnWayPointChangeNotification>(
+ message_,
+ app_mngr_,
+ mock_rpc_service_,
+ mock_hmi_capabilities_,
+ mock_policy_handler_);
+ }
+
+ MessageSharedPtr CreateMessage(
+ const smart_objects::SmartType type = smart_objects::SmartType_Null) {
+ return std::make_shared<SmartObject>(type);
+ }
NotificationPtr command_;
+ MessageSharedPtr message_;
};
-MATCHER(CheckMessageData, "") {
+MATCHER_P(CheckMessageData, appID, "") {
const bool kIsMobileProtocolTypeCorrect =
(*arg)[am::strings::params][am::strings::protocol_type].asInt() ==
am::commands::CommandImpl::mobile_protocol_type_;
@@ -86,7 +107,7 @@ MATCHER(CheckMessageData, "") {
const bool kIsConnectionKeyCorrect =
(*arg)[am::strings::params][am::strings::connection_key].asUInt() ==
- kAppId;
+ appID;
using namespace helpers;
return Compare<bool, EQ, ALL>(true,
@@ -99,11 +120,42 @@ MATCHER(CheckMessageData, "") {
TEST_F(OnWayPointChangeNotificationTest,
Run_NotEmptyListOfAppsSubscribedForWayPoints_SUCCESS) {
std::set<uint32_t> apps_subscribed_for_way_points;
- apps_subscribed_for_way_points.insert(kAppId);
+ apps_subscribed_for_way_points.insert(kApp1Id);
EXPECT_CALL(app_mngr_, GetAppsSubscribedForWayPoints())
.WillOnce(Return(apps_subscribed_for_way_points));
- EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(CheckMessageData(), _));
+ EXPECT_CALL(mock_rpc_service_,
+ SendMessageToMobile(CheckMessageData(kApp1Id), _));
+
+ command_->Run();
+}
+
+TEST_F(OnWayPointChangeNotificationTest,
+ Run_StoreWayPointsDuringNotification_SUCCESS) {
+ std::set<uint32_t> apps_subscribed_for_way_points;
+ apps_subscribed_for_way_points.insert(kApp1Id);
+
+ EXPECT_CALL(app_mngr_, GetAppsSubscribedForWayPoints())
+ .WillOnce(Return(apps_subscribed_for_way_points));
+ EXPECT_CALL(mock_rpc_service_,
+ SendMessageToMobile(CheckMessageData(kApp1Id), _));
+ EXPECT_CALL(app_mngr_, SaveWayPointsMessage(message_));
+
+ command_->Run();
+}
+
+TEST_F(OnWayPointChangeNotificationTest,
+ Run_BroadcastingWayPointsToAllApps_SUCCESS) {
+ std::set<uint32_t> apps_subscribed_for_way_points;
+ apps_subscribed_for_way_points.insert(kApp1Id);
+ apps_subscribed_for_way_points.insert(kApp2Id);
+
+ EXPECT_CALL(app_mngr_, GetAppsSubscribedForWayPoints())
+ .WillOnce(Return(apps_subscribed_for_way_points));
+ EXPECT_CALL(mock_rpc_service_,
+ SendMessageToMobile(CheckMessageData(kApp1Id), _));
+ EXPECT_CALL(mock_rpc_service_,
+ SendMessageToMobile(CheckMessageData(kApp2Id), _));
command_->Run();
}