summaryrefslogtreecommitdiff
path: root/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile
diff options
context:
space:
mode:
authorcollin <collin+i@collinmcqueen.com>2020-05-13 14:15:31 -0400
committercollin <collin+i@collinmcqueen.com>2020-05-13 14:15:31 -0400
commit236bdbaa283147044a6144f8c96cc43b82ff1014 (patch)
treeba76d0566cb98b9b726ba7a78834e55f2f5dcf02 /src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile
parentbfacfcb45b067b987cc38b98fe70657559c330ed (diff)
downloadsdl_core-236bdbaa283147044a6144f8c96cc43b82ff1014.tar.gz
RAI reply DUPLICATE_NAME when app has same id and name as existing app
Diffstat (limited to 'src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile')
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc58
1 files changed, 57 insertions, 1 deletions
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc
index 6376570106..74c292efa7 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc
@@ -530,6 +530,10 @@ TEST_F(RegisterAppInterfaceRequestTest,
const std::string request_hash_id = "abc123";
(*msg_)[am::strings::msg_params][am::strings::hash_id] = request_hash_id;
+ ON_CALL(app_mngr_, applications())
+ .WillByDefault(
+ Return(DataAccessor<am::ApplicationSet>(app_set_, lock_ptr_)));
+
MockAppPtr mock_app = CreateBasicMockedApp();
app_set_.insert(mock_app);
EXPECT_CALL(app_mngr_, reregister_application_by_policy_id(kAppId1))
@@ -543,7 +547,7 @@ TEST_F(RegisterAppInterfaceRequestTest,
ON_CALL(mock_session_observer_, GetDataOnDeviceID(device_id, _, _, _, _))
.WillByDefault(DoAll(SetArgPointee<3>(kMacAddress1), Return(0)));
- EXPECT_CALL(*mock_app, device()).WillOnce(Return(kDeviceHandle));
+ ON_CALL(*mock_app, device()).WillByDefault(Return(kDeviceHandle));
EXPECT_CALL(app_mngr_, ProcessReconnection(_, kConnectionKey));
@@ -577,6 +581,10 @@ TEST_F(RegisterAppInterfaceRequestTest,
const std::string request_hash_id = "abc123";
(*msg_)[am::strings::msg_params][am::strings::hash_id] = request_hash_id;
+ ON_CALL(app_mngr_, applications())
+ .WillByDefault(
+ Return(DataAccessor<am::ApplicationSet>(app_set_, lock_ptr_)));
+
connection_handler::DeviceHandle device_id = 1;
ON_CALL(mock_connection_handler_,
GetDataOnSessionKey(kConnectionKey, _, _, _))
@@ -620,6 +628,10 @@ TEST_F(RegisterAppInterfaceRequestTest,
SwitchApplication_NoHash_ExpectCleanupResumeFailed) {
InitBasicMessage();
+ ON_CALL(app_mngr_, applications())
+ .WillByDefault(
+ Return(DataAccessor<am::ApplicationSet>(app_set_, lock_ptr_)));
+
connection_handler::DeviceHandle device_id = 1;
ON_CALL(mock_connection_handler_,
GetDataOnSessionKey(kConnectionKey, _, _, _))
@@ -654,6 +666,50 @@ TEST_F(RegisterAppInterfaceRequestTest,
}
TEST_F(RegisterAppInterfaceRequestTest,
+ Run_Other_App_With_Same_App_Name_DUPLICATE_NAME) {
+ InitBasicMessage();
+
+ app_set_.insert(CreateBasicMockedApp());
+
+ const uint32_t kConnection_key_ = 2u;
+ const std::string kApp_Id = "other_app_id";
+ (*msg_)[am::strings::params][am::strings::connection_key] = kConnection_key_;
+ (*msg_)[am::strings::msg_params][am::strings::app_id] = kApp_Id;
+
+ ON_CALL(app_mngr_, applications())
+ .WillByDefault(
+ Return(DataAccessor<am::ApplicationSet>(app_set_, lock_ptr_)));
+
+ EXPECT_CALL(mock_rpc_service_,
+ ManageMobileCommand(
+ MobileResultCodeIs(mobile_apis::Result::DUPLICATE_NAME), _));
+
+ command_->Run();
+}
+
+TEST_F(RegisterAppInterfaceRequestTest,
+ Run_Other_App_With_Same_App_ID_DUPLICATE_NAME) {
+ InitBasicMessage();
+
+ app_set_.insert(CreateBasicMockedApp());
+
+ const uint32_t kConnection_key_ = 2u;
+ const std::string kApp_Name = "other_app_name";
+ (*msg_)[am::strings::params][am::strings::connection_key] = kConnection_key_;
+ (*msg_)[am::strings::msg_params][am::strings::app_name] = kApp_Name;
+
+ ON_CALL(app_mngr_, applications())
+ .WillByDefault(
+ Return(DataAccessor<am::ApplicationSet>(app_set_, lock_ptr_)));
+
+ EXPECT_CALL(mock_rpc_service_,
+ ManageMobileCommand(
+ MobileResultCodeIs(mobile_apis::Result::DUPLICATE_NAME), _));
+
+ command_->Run();
+}
+
+TEST_F(RegisterAppInterfaceRequestTest,
RegisterApp_SameAppId_SameDeviceFailed) {
using namespace am;