summaryrefslogtreecommitdiff
path: root/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc')
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc117
1 files changed, 109 insertions, 8 deletions
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc
index 66280eb183..f7718a7248 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc
@@ -34,7 +34,6 @@
#include "application_manager/application.h"
#include "application_manager/commands/command_request_test.h"
#include "application_manager/mock_application.h"
-#include "gtest/gtest.h"
#include "interfaces/MOBILE_API.h"
#include "rc_rpc_plugin/mock/mock_interior_data_cache.h"
#include "rc_rpc_plugin/mock/mock_interior_data_manager.h"
@@ -42,15 +41,20 @@
#include "rc_rpc_plugin/rc_module_constants.h"
#include "rc_rpc_plugin/rc_rpc_plugin.h"
+#include <stdint.h>
+#include "gtest/gtest.h"
+
using application_manager::ApplicationSet;
using application_manager::commands::MessageSharedPtr;
using test::components::application_manager_test::MockApplication;
using test::components::application_manager_test::MockApplicationManager;
using test::components::commands_test::CommandRequestTest;
using test::components::commands_test::CommandsTestMocks;
+using test::components::commands_test::HMIResultCodeIs;
using ::testing::_;
using ::testing::NiceMock;
using ::testing::Return;
+using ::testing::SaveArg;
namespace {
const uint32_t kAppId = 0u;
@@ -140,8 +144,11 @@ TEST_F(SetInteriorVehicleDataRequestTest,
(*mobile_message)[application_manager::strings::msg_params];
msg_params[message_params::kModuleData][message_params::kModuleType] =
mobile_apis::ModuleType::CLIMATE;
+ smart_objects::SmartObject climate_control_data(smart_objects::SmartType_Map);
+ climate_control_data[message_params::kFanSpeed] = 10;
+
msg_params[message_params::kModuleData][message_params::kClimateControlData] =
- smart_objects::SmartObject(smart_objects::SmartType_Map);
+ climate_control_data;
// Expectations
EXPECT_CALL(mock_policy_handler_, CheckModule(kPolicyAppId, _))
.WillOnce(Return(rc_rpc_plugin::TypeAccess::kAllowed));
@@ -151,14 +158,15 @@ TEST_F(SetInteriorVehicleDataRequestTest,
EXPECT_CALL(
mock_rpc_service_,
- ManageMobileCommand(test::components::commands_test::MobileResultCodeIs(
- mobile_apis::Result::READ_ONLY),
- application_manager::commands::Command::SOURCE_SDL));
+ ManageHMICommand(
+ HMIResultCodeIs(hmi_apis::FunctionID::RC_SetInteriorVehicleData), _))
+ .WillOnce(Return(true));
// Act
std::shared_ptr<rc_rpc_plugin::commands::SetInteriorVehicleDataRequest>
command = CreateRCCommand<
rc_rpc_plugin::commands::SetInteriorVehicleDataRequest>(
mobile_message);
+ ASSERT_TRUE(command->Init());
command->Run();
}
@@ -189,15 +197,16 @@ TEST_F(
EXPECT_CALL(
mock_rpc_service_,
- ManageMobileCommand(test::components::commands_test::MobileResultCodeIs(
- mobile_apis::Result::OUT_OF_MEMORY),
- application_manager::commands::Command::SOURCE_SDL));
+ ManageHMICommand(
+ HMIResultCodeIs(hmi_apis::FunctionID::RC_SetInteriorVehicleData), _))
+ .WillOnce(Return(true));
// Act
std::shared_ptr<rc_rpc_plugin::commands::SetInteriorVehicleDataRequest>
command = CreateRCCommand<
rc_rpc_plugin::commands::SetInteriorVehicleDataRequest>(
mobile_message);
+ ASSERT_TRUE(command->Init());
command->Run();
}
@@ -229,7 +238,99 @@ TEST_F(
command = CreateRCCommand<
rc_rpc_plugin::commands::SetInteriorVehicleDataRequest>(
mobile_message);
+ ASSERT_TRUE(command->Init());
command->Run();
}
+TEST_F(SetInteriorVehicleDataRequestTest,
+ Execute_ValidWithSettableParams_SUCCESSSendToHMI) {
+ MessageSharedPtr mobile_message = CreateBasicMessage();
+ auto& msg_params =
+ (*mobile_message)[application_manager::strings::msg_params];
+ msg_params[message_params::kModuleData][message_params::kModuleType] =
+ mobile_apis::ModuleType::CLIMATE;
+
+ msg_params[message_params::kModuleData][message_params::kClimateControlData] =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+
+ msg_params[message_params::kModuleData][message_params::kClimateControlData]
+ [message_params::kClimateEnable] = true;
+
+ // Expectations
+ EXPECT_CALL(mock_policy_handler_, CheckModule(kPolicyAppId, _))
+ .WillOnce(Return(rc_rpc_plugin::TypeAccess::kAllowed));
+
+ EXPECT_CALL(mock_hmi_capabilities_, rc_capability())
+ .WillOnce(Return(nullptr));
+
+ MessageSharedPtr message_from_mobile = CreateBasicMessage();
+
+ EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _))
+ .WillOnce(DoAll(SaveArg<0>(&message_from_mobile), Return(true)));
+
+ std::shared_ptr<rc_rpc_plugin::commands::SetInteriorVehicleDataRequest>
+ command = CreateRCCommand<
+ rc_rpc_plugin::commands::SetInteriorVehicleDataRequest>(
+ mobile_message);
+
+ ASSERT_TRUE(command->Init());
+ command->Run();
+
+ auto& msg_params_from_mobile =
+ (*message_from_mobile)[application_manager::strings::msg_params];
+
+ const bool climate_enable =
+ msg_params_from_mobile[message_params::kModuleData]
+ [message_params::kClimateControlData]
+ [message_params::kClimateEnable]
+ .asBool();
+ EXPECT_TRUE(climate_enable);
+}
+
+TEST_F(SetInteriorVehicleDataRequestTest,
+ Execute_ValidWithSettableParams_SUCCESSSendToHMI_HDChannel) {
+ MessageSharedPtr mobile_message = CreateBasicMessage();
+ auto& msg_params =
+ (*mobile_message)[application_manager::strings::msg_params];
+ msg_params[message_params::kModuleData][message_params::kModuleType] =
+ mobile_apis::ModuleType::RADIO;
+
+ msg_params[message_params::kModuleData][message_params::kRadioControlData] =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+
+ const std::uint32_t hd_channel = 2u;
+ msg_params[message_params::kModuleData][message_params::kRadioControlData]
+ [message_params::kHdChannel] = hd_channel;
+
+ // Expectations
+ EXPECT_CALL(mock_policy_handler_, CheckModule(kPolicyAppId, _))
+ .WillOnce(Return(rc_rpc_plugin::TypeAccess::kAllowed));
+
+ EXPECT_CALL(mock_hmi_capabilities_, rc_capability())
+ .WillOnce(Return(nullptr));
+
+ auto message_from_mobile = CreateBasicMessage();
+
+ EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _))
+ .WillOnce(DoAll(SaveArg<0>(&message_from_mobile), Return(true)));
+
+ std::shared_ptr<rc_rpc_plugin::commands::SetInteriorVehicleDataRequest>
+ command = CreateRCCommand<
+ rc_rpc_plugin::commands::SetInteriorVehicleDataRequest>(
+ mobile_message);
+
+ command->Init();
+ command->Run();
+
+ auto& msg_params_from_mobile =
+ (*message_from_mobile)[application_manager::strings::msg_params];
+
+ const uint64_t hd_channel_from_hmi =
+ msg_params_from_mobile[message_params::kModuleData]
+ [message_params::kRadioControlData]
+ [message_params::kHdChannel]
+ .asUInt();
+
+ EXPECT_EQ(hd_channel, hd_channel_from_hmi);
+}
} // namespace rc_rpc_plugin_test