summaryrefslogtreecommitdiff
path: root/src/components/application_manager/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/application_manager/test')
-rwxr-xr-xsrc/components/application_manager/test/CMakeLists.txt1
-rw-r--r--src/components/application_manager/test/app_service_manager_test.cc439
-rw-r--r--src/components/application_manager/test/application_impl_test.cc8
-rw-r--r--src/components/application_manager/test/application_manager_impl_test.cc271
-rw-r--r--src/components/application_manager/test/command_holder_test.cc14
-rw-r--r--src/components/application_manager/test/commands/CMakeLists.txt1
-rw-r--r--src/components/application_manager/test/commands/command_impl_test.cc11
-rw-r--r--src/components/application_manager/test/commands/command_request_impl_test.cc92
-rw-r--r--src/components/application_manager/test/help_prompt_manager_test.cc9
-rw-r--r--src/components/application_manager/test/hmi_capabilities_test.cc2
-rw-r--r--src/components/application_manager/test/include/application_manager/commands/command_request_test.h2
-rw-r--r--src/components/application_manager/test/include/application_manager/mock_app_service_manager.h95
-rw-r--r--src/components/application_manager/test/include/application_manager/mock_application.h15
-rw-r--r--src/components/application_manager/test/include/application_manager/mock_event_dispatcher.h20
-rw-r--r--src/components/application_manager/test/include/application_manager/mock_message_helper.h8
-rwxr-xr-xsrc/components/application_manager/test/message_helper/CMakeLists.txt1
-rw-r--r--src/components/application_manager/test/message_helper/message_helper_test.cc11
-rw-r--r--src/components/application_manager/test/mock_message_helper.cc17
-rw-r--r--src/components/application_manager/test/policy_handler_test.cc168
-rw-r--r--src/components/application_manager/test/resumption/resume_ctrl_test.cc1
-rw-r--r--src/components/application_manager/test/sdl_preloaded_pt.json4
-rw-r--r--src/components/application_manager/test/sdl_pt_update.json12
-rw-r--r--src/components/application_manager/test/state_controller/state_controller_test.cc141
23 files changed, 1247 insertions, 96 deletions
diff --git a/src/components/application_manager/test/CMakeLists.txt b/src/components/application_manager/test/CMakeLists.txt
index 02cf58485a..4851a6b37e 100755
--- a/src/components/application_manager/test/CMakeLists.txt
+++ b/src/components/application_manager/test/CMakeLists.txt
@@ -63,6 +63,7 @@ set(testSources
${AM_TEST_DIR}/application_state_test.cc
${AM_TEST_DIR}/usage_statistics_test.cc
${AM_TEST_DIR}/policy_handler_test.cc
+ ${AM_TEST_DIR}/app_service_manager_test.cc
${AM_TEST_DIR}/application_manager_impl_test.cc
${AM_TEST_DIR}/application_helper_test.cc
${AM_TEST_DIR}/command_holder_test.cc
diff --git a/src/components/application_manager/test/app_service_manager_test.cc b/src/components/application_manager/test/app_service_manager_test.cc
new file mode 100644
index 0000000000..960e8e31f6
--- /dev/null
+++ b/src/components/application_manager/test/app_service_manager_test.cc
@@ -0,0 +1,439 @@
+/*
+ * Copyright (c) 2017, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <gmock/gmock.h>
+
+#include "application_manager/commands/command.h"
+#include "application_manager/mock_application.h"
+#include "application_manager/mock_application_manager.h"
+#include "application_manager/mock_application_manager_settings.h"
+#include "application_manager/mock_message_helper.h"
+#include "application_manager/smart_object_keys.h"
+#include "resumption/mock_last_state.h"
+#include "smart_objects/smart_object.h"
+
+namespace test {
+namespace components {
+namespace application_manager_test {
+
+using testing::_;
+using ::testing::DoAll;
+using ::testing::Mock;
+using ::testing::Return;
+using ::testing::ReturnRef;
+using ::testing::SaveArg;
+
+namespace am = application_manager;
+
+const char* kAppServiceSection = "AppServices";
+const char* kDefaults = "defaults";
+const std::string kServiceType = "MEDIA";
+const std::string kServiceName = "service_name";
+const std::string kServiceId = "service_id";
+const std::string kPolicyAppId = "p_app_id";
+const uint32_t kConnectionKey = 43629;
+const uint32_t kHMIConnectionKey = 0;
+
+MATCHER_P(CapabilityUpdateMatcher, reason, "") {
+ smart_objects::SmartObject& services_updated =
+ arg[am::strings::system_capability]
+ [am::strings::app_services_capabilities][am::strings::app_services];
+ if (smart_objects::SmartType_Array != services_updated.getType()) {
+ return false;
+ }
+ for (size_t i = 0; i < services_updated.length(); i++) {
+ smart_objects::SmartObject& service_cap = services_updated[i];
+ if (reason == service_cap[am::strings::update_reason].asInt()) {
+ return true;
+ }
+ }
+ return false;
+}
+
+class AppServiceManagerTest : public testing::Test {
+ public:
+ AppServiceManagerTest()
+ : mock_app_ptr_(new MockApplication)
+ , app_service_manager_(mock_app_manager_, mock_last_state_)
+ , mock_message_helper_(
+ application_manager::MockMessageHelper::message_helper_mock()) {
+ Mock::VerifyAndClearExpectations(mock_message_helper_);
+ }
+ ~AppServiceManagerTest() {
+ Mock::VerifyAndClearExpectations(mock_message_helper_);
+ }
+
+ void SetUp() OVERRIDE {
+ ON_CALL(*mock_message_helper_, BroadcastCapabilityUpdate(_, _))
+ .WillByDefault(Return());
+ ON_CALL(mock_settings_, embedded_services())
+ .WillByDefault(ReturnRef(embedded_services_));
+ ON_CALL(mock_app_manager_, get_settings())
+ .WillByDefault(ReturnRef(mock_settings_));
+ ON_CALL(*mock_app_ptr_, policy_app_id())
+ .WillByDefault(Return(kPolicyAppId));
+ ON_CALL(mock_last_state_, get_dictionary()).WillByDefault(ReturnRef(dict_));
+ auto app_ptr = std::static_pointer_cast<am::Application>(mock_app_ptr_);
+ ON_CALL(mock_app_manager_, application(kConnectionKey))
+ .WillByDefault(Return(app_ptr));
+ }
+
+ protected:
+ smart_objects::SmartObject GenerateMediaManifest(
+ bool allow_app_consumers, std::string app_service_name = kServiceName) {
+ smart_objects::SmartObject manifest(smart_objects::SmartType_Map);
+ manifest[am::strings::service_type] = "MEDIA";
+ manifest[am::strings::service_name] = app_service_name;
+ manifest[am::strings::allow_app_consumers] = allow_app_consumers;
+ manifest[am::strings::media_service_manifest] =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ return manifest;
+ }
+
+ smart_objects::SmartObject PublishService(
+ uint32_t connection_key = kConnectionKey, bool first_run = true) {
+ smart_objects::SmartObject manifest = GenerateMediaManifest(true);
+
+ Json::Value empty_json;
+ EXPECT_CALL(mock_last_state_, get_dictionary())
+ .WillOnce(ReturnRef(empty_json));
+
+ EXPECT_CALL(*mock_message_helper_,
+ BroadcastCapabilityUpdate(
+ CapabilityUpdateMatcher(
+ mobile_apis::ServiceUpdateReason::PUBLISHED),
+ _)).WillOnce(Return());
+ if (first_run) {
+ EXPECT_CALL(*mock_message_helper_,
+ BroadcastCapabilityUpdate(
+ CapabilityUpdateMatcher(
+ mobile_apis::ServiceUpdateReason::ACTIVATED),
+ _)).WillOnce(Return());
+ }
+ bool mobile_service = connection_key != kHMIConnectionKey;
+ return app_service_manager_.PublishAppService(
+ manifest, mobile_service, connection_key);
+ }
+
+ void CheckCapabilityUpdate(smart_objects::SmartObject& msg_params,
+ size_t length,
+ std::string service_id,
+ mobile_apis::ServiceUpdateReason::eType reason,
+ bool published,
+ bool active) {
+ smart_objects::SmartObject& services_updated = msg_params
+ [am::strings::system_capability][am::strings::app_services_capabilities]
+ [am::strings::app_services];
+ ASSERT_EQ(smart_objects::SmartType_Array, services_updated.getType());
+ EXPECT_EQ(length, services_updated.length());
+ for (size_t i = 0; i < services_updated.length(); i++) {
+ smart_objects::SmartObject& service_cap = services_updated[i];
+ if (service_id ==
+ service_cap[am::strings::updated_app_service_record]
+ [am::strings::service_id].asString()) {
+ CheckCapability(service_cap, service_id, reason, published, active);
+ return;
+ }
+ }
+ FAIL() << "Unable to find service in capability update with service_id: "
+ << service_id;
+ }
+
+ void CheckCapability(smart_objects::SmartObject& app_service_capability,
+ std::string service_id,
+ mobile_apis::ServiceUpdateReason::eType reason,
+ bool published,
+ bool active) {
+ EXPECT_EQ(reason,
+ app_service_capability[am::strings::update_reason].asInt());
+ smart_objects::SmartObject& updated_record =
+ app_service_capability[am::strings::updated_app_service_record];
+ EXPECT_EQ(service_id, updated_record[am::strings::service_id].asString());
+ EXPECT_EQ(published,
+ updated_record[am::strings::service_published].asBool());
+ EXPECT_EQ(active, updated_record[am::strings::service_active].asBool());
+ }
+
+ Json::Value dict_;
+ std::vector<std::string> embedded_services_;
+ std::shared_ptr<MockApplication> mock_app_ptr_;
+ MockApplicationManager mock_app_manager_;
+ resumption_test::MockLastState mock_last_state_;
+ MockApplicationManagerSettings mock_settings_;
+ application_manager::AppServiceManager app_service_manager_;
+ application_manager::MockMessageHelper* mock_message_helper_;
+};
+
+TEST_F(AppServiceManagerTest, PublishAppService_Mobile_SUCCESS) {
+ smart_objects::SmartObject manifest = GenerateMediaManifest(true);
+
+ Json::Value empty_json;
+ EXPECT_CALL(mock_last_state_, get_dictionary())
+ .WillOnce(ReturnRef(empty_json));
+
+ smart_objects::SmartObject syscap_update_published;
+ EXPECT_CALL(
+ *mock_message_helper_,
+ BroadcastCapabilityUpdate(
+ CapabilityUpdateMatcher(mobile_apis::ServiceUpdateReason::PUBLISHED),
+ _)).WillOnce(DoAll(SaveArg<0>(&syscap_update_published), Return()));
+
+ smart_objects::SmartObject syscap_update_activated;
+ EXPECT_CALL(
+ *mock_message_helper_,
+ BroadcastCapabilityUpdate(
+ CapabilityUpdateMatcher(mobile_apis::ServiceUpdateReason::ACTIVATED),
+ _)).WillOnce(DoAll(SaveArg<0>(&syscap_update_activated), Return()));
+
+ auto record =
+ app_service_manager_.PublishAppService(manifest, true, kConnectionKey);
+
+ // Check final record
+ std::string service_id = record[am::strings::service_id].asString();
+ EXPECT_EQ(manifest, record[am::strings::service_manifest]);
+ EXPECT_TRUE(record[am::strings::service_published].asBool());
+ EXPECT_TRUE(record[am::strings::service_active].asBool());
+
+ // Check first capability update
+ CheckCapabilityUpdate(syscap_update_published,
+ 1,
+ service_id,
+ mobile_apis::ServiceUpdateReason::PUBLISHED,
+ true,
+ false);
+
+ // Check second capability update
+ CheckCapabilityUpdate(syscap_update_activated,
+ 1,
+ service_id,
+ mobile_apis::ServiceUpdateReason::ACTIVATED,
+ true,
+ true);
+}
+
+TEST_F(AppServiceManagerTest, PublishAppService_HMI_SUCCESS) {
+ smart_objects::SmartObject manifest = GenerateMediaManifest(true);
+
+ Json::Value empty_json;
+ EXPECT_CALL(mock_last_state_, get_dictionary())
+ .WillOnce(ReturnRef(empty_json));
+
+ smart_objects::SmartObject syscap_update_published;
+ EXPECT_CALL(
+ *mock_message_helper_,
+ BroadcastCapabilityUpdate(
+ CapabilityUpdateMatcher(mobile_apis::ServiceUpdateReason::PUBLISHED),
+ _)).WillOnce(DoAll(SaveArg<0>(&syscap_update_published), Return()));
+
+ smart_objects::SmartObject syscap_update_activated;
+ EXPECT_CALL(
+ *mock_message_helper_,
+ BroadcastCapabilityUpdate(
+ CapabilityUpdateMatcher(mobile_apis::ServiceUpdateReason::ACTIVATED),
+ _)).WillOnce(DoAll(SaveArg<0>(&syscap_update_activated), Return()));
+
+ auto record = app_service_manager_.PublishAppService(manifest, false);
+
+ // Check final record
+ std::string service_id = record[am::strings::service_id].asString();
+ EXPECT_EQ(manifest, record[am::strings::service_manifest]);
+ EXPECT_TRUE(record[am::strings::service_published].asBool());
+ EXPECT_TRUE(record[am::strings::service_active].asBool());
+
+ // Check first capability update
+ CheckCapabilityUpdate(syscap_update_published,
+ 1,
+ service_id,
+ mobile_apis::ServiceUpdateReason::PUBLISHED,
+ true,
+ false);
+
+ // Check second capability update
+ CheckCapabilityUpdate(syscap_update_activated,
+ 1,
+ service_id,
+ mobile_apis::ServiceUpdateReason::ACTIVATED,
+ true,
+ true);
+}
+
+TEST_F(AppServiceManagerTest, UnpublishAppService_SUCCESS) {
+ auto record = PublishService();
+
+ smart_objects::SmartObject syscap_update_unpublished;
+ EXPECT_CALL(
+ *mock_message_helper_,
+ BroadcastCapabilityUpdate(
+ CapabilityUpdateMatcher(mobile_apis::ServiceUpdateReason::REMOVED),
+ _)).WillOnce(DoAll(SaveArg<0>(&syscap_update_unpublished), Return()));
+ std::string service_id = record[am::strings::service_id].asString();
+
+ EXPECT_TRUE(app_service_manager_.UnpublishAppService(service_id));
+
+ // Check removed capability update
+ CheckCapabilityUpdate(syscap_update_unpublished,
+ 1,
+ service_id,
+ mobile_apis::ServiceUpdateReason::REMOVED,
+ false,
+ false);
+}
+
+TEST_F(AppServiceManagerTest, ActivateAppService_AlreadyActivated) {
+ auto record = PublishService();
+
+ // No capability update
+ EXPECT_CALL(
+ *mock_message_helper_,
+ BroadcastCapabilityUpdate(
+ CapabilityUpdateMatcher(mobile_apis::ServiceUpdateReason::ACTIVATED),
+ _)).Times(0);
+ std::string service_id = record[am::strings::service_id].asString();
+
+ EXPECT_TRUE(app_service_manager_.ActivateAppService(service_id));
+}
+
+TEST_F(AppServiceManagerTest, ActivateAppService_TwoApps_SUCCESS) {
+ // Register two services with the same service type, the first is activated
+ // automatically
+ auto record = PublishService();
+ auto record2 = PublishService(kConnectionKey + 1, false);
+
+ // No capability update
+ smart_objects::SmartObject syscap_update_activated;
+ EXPECT_CALL(
+ *mock_message_helper_,
+ BroadcastCapabilityUpdate(
+ CapabilityUpdateMatcher(mobile_apis::ServiceUpdateReason::ACTIVATED),
+ _)).WillOnce(DoAll(SaveArg<0>(&syscap_update_activated), Return()));
+ std::string service_id = record[am::strings::service_id].asString();
+ std::string service_id2 = record2[am::strings::service_id].asString();
+
+ // Activate the second service
+ EXPECT_TRUE(app_service_manager_.ActivateAppService(service_id2));
+
+ // Check that the first service is deactivated
+ CheckCapabilityUpdate(syscap_update_activated,
+ 2,
+ service_id,
+ mobile_apis::ServiceUpdateReason::DEACTIVATED,
+ true,
+ false);
+
+ // Check that the second service is activated
+ CheckCapabilityUpdate(syscap_update_activated,
+ 2,
+ service_id2,
+ mobile_apis::ServiceUpdateReason::ACTIVATED,
+ true,
+ true);
+}
+
+TEST_F(AppServiceManagerTest, DeactivateAppService_SUCCESS) {
+ auto record = PublishService();
+
+ smart_objects::SmartObject syscap_update_deactivated;
+ EXPECT_CALL(*mock_message_helper_,
+ BroadcastCapabilityUpdate(
+ CapabilityUpdateMatcher(
+ mobile_apis::ServiceUpdateReason::DEACTIVATED),
+ _))
+ .WillOnce(DoAll(SaveArg<0>(&syscap_update_deactivated), Return()));
+ std::string service_id = record[am::strings::service_id].asString();
+
+ EXPECT_TRUE(app_service_manager_.DeactivateAppService(service_id));
+
+ // Check deactivated capability update
+ CheckCapabilityUpdate(syscap_update_deactivated,
+ 1,
+ service_id,
+ mobile_apis::ServiceUpdateReason::DEACTIVATED,
+ true,
+ false);
+}
+
+TEST_F(AppServiceManagerTest, ActiveServiceForType_SUCCESS) {
+ auto record = PublishService();
+
+ auto service = app_service_manager_.ActiveServiceForType(kServiceType);
+
+ ASSERT_FALSE(service == NULL);
+ EXPECT_EQ(record, service->record);
+ EXPECT_EQ(kConnectionKey, service->connection_key);
+ EXPECT_TRUE(service->mobile_service);
+}
+
+TEST_F(AppServiceManagerTest, EmbeddedServiceForType_SUCCESS) {
+ auto record = PublishService(kHMIConnectionKey);
+
+ auto service = app_service_manager_.EmbeddedServiceForType(kServiceType);
+
+ ASSERT_FALSE(service == NULL);
+ EXPECT_EQ(record, service->record);
+ EXPECT_FALSE(service->mobile_service);
+}
+
+TEST_F(AppServiceManagerTest, FindServiceByID_SUCCESS) {
+ auto record = PublishService();
+
+ std::string service_id = record[am::strings::service_id].asString();
+ auto service = app_service_manager_.FindServiceByID(service_id);
+
+ ASSERT_FALSE(service == NULL);
+ EXPECT_EQ(record, service->record);
+ EXPECT_EQ(kConnectionKey, service->connection_key);
+ EXPECT_TRUE(service->mobile_service);
+}
+
+TEST_F(AppServiceManagerTest, GetAllServiceRecords_OneService_SUCCESS) {
+ auto record = PublishService();
+
+ auto records = app_service_manager_.GetAllServiceRecords();
+
+ ASSERT_EQ(1u, records.size());
+ EXPECT_EQ(record, records[0]);
+}
+
+TEST_F(AppServiceManagerTest, GetActiveServices_OneService_SUCCESS) {
+ auto record = PublishService();
+
+ auto services = app_service_manager_.GetActiveServices();
+
+ ASSERT_EQ(1u, services.size());
+ EXPECT_EQ(record, services[0].record);
+ EXPECT_EQ(kConnectionKey, services[0].connection_key);
+ EXPECT_TRUE(services[0].mobile_service);
+}
+
+} // namespace application_manager_test
+} // namespace components
+} // namespace test \ No newline at end of file
diff --git a/src/components/application_manager/test/application_impl_test.cc b/src/components/application_manager/test/application_impl_test.cc
index 301ed227b8..437f567538 100644
--- a/src/components/application_manager/test/application_impl_test.cc
+++ b/src/components/application_manager/test/application_impl_test.cc
@@ -118,6 +118,13 @@ class ApplicationImplTest : public ::testing::Test {
AddSet hmi_action);
void CheckCurrentHMIState();
+ // 'directory_name' has to be declared prior to 'app_impl' so that when
+ // deleting ApplicationImplTest class, 'directory_name' will be removed
+ // after 'app_impl' runs its destructor.
+ // (ApplicationImpl's destructor calls CleanupFiles(), which will call
+ // application_manager_.get_settings().app_storage_folder() and will
+ // access 'directory_name'.)
+ const std::string directory_name = "./test_storage";
MockApplicationManagerSettings mock_application_manager_settings_;
MockApplicationManager mock_application_manager_;
std::shared_ptr<ApplicationImpl> app_impl;
@@ -126,7 +133,6 @@ class ApplicationImplTest : public ::testing::Test {
std::string mac_address;
connection_handler::DeviceHandle device_handle;
custom_str::CustomString app_name;
- const std::string directory_name = "./test_storage";
HmiState::StateID state_id;
HmiStatePtr testHmiState;
HMILevel::eType test_lvl;
diff --git a/src/components/application_manager/test/application_manager_impl_test.cc b/src/components/application_manager/test/application_manager_impl_test.cc
index 7e57b51329..e4951880de 100644
--- a/src/components/application_manager/test/application_manager_impl_test.cc
+++ b/src/components/application_manager/test/application_manager_impl_test.cc
@@ -29,38 +29,43 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
+#include <bson_object.h>
#include <stdint.h>
#include <memory>
#include <set>
#include <string>
#include <vector>
-#include <bson_object.h>
-#include "gtest/gtest.h"
#include "application_manager/application.h"
#include "application_manager/application_impl.h"
#include "application_manager/application_manager_impl.h"
#include "application_manager/mock_application.h"
#include "application_manager/mock_application_manager_settings.h"
#include "application_manager/mock_resumption_data.h"
-#include "application_manager/mock_rpc_service.h"
+#include "application_manager/mock_app_service_manager.h"
#include "application_manager/mock_rpc_plugin_manager.h"
+#include "application_manager/mock_rpc_service.h"
+#include "application_manager/policies/mock_policy_handler_interface.h"
#include "application_manager/resumption/resume_ctrl_impl.h"
#include "application_manager/test/include/application_manager/mock_message_helper.h"
#include "connection_handler/mock_connection_handler.h"
+#include "gtest/gtest.h"
#include "hmi_message_handler/mock_hmi_message_handler.h"
#include "media_manager/mock_media_manager.h"
#include "policy/mock_policy_settings.h"
#include "policy/usage_statistics/mock_statistics_manager.h"
#include "protocol/bson_object_keys.h"
-#include "protocol_handler/mock_session_observer.h"
#include "protocol_handler/mock_protocol_handler.h"
+#include "protocol_handler/mock_session_observer.h"
+#include "resumption/mock_last_state.h"
#include "utils/custom_string.h"
#include "utils/file_system.h"
#include "utils/lock.h"
-#include "utils/push_log.h"
#include "encryption/hashing.h"
+#ifdef ENABLE_LOG
+#include "utils/push_log.h"
+#endif
namespace test {
namespace components {
@@ -72,15 +77,16 @@ namespace con_test = connection_handler_test;
using testing::_;
using ::testing::An;
-using ::testing::Matcher;
using ::testing::ByRef;
using ::testing::DoAll;
+using ::testing::Matcher;
using ::testing::Mock;
+using ::testing::NiceMock;
using ::testing::Return;
using ::testing::ReturnRef;
-using ::testing::NiceMock;
using ::testing::SaveArg;
using ::testing::SetArgPointee;
+using ::testing::SetArgReferee;
using namespace application_manager;
@@ -96,6 +102,17 @@ connection_handler::DeviceHandle kDeviceId = 12345u;
const std::string kAppId = "someID";
const uint32_t kConnectionKey = 1232u;
const std::string kAppName = "appName";
+
+// Cloud application params
+const std::string kEndpoint = "endpoint";
+const std::string kEndpoint2 = "https://fakesdlcloudapptesting.com:8080";
+const std::string kAuthToken = "auth_token";
+const std::string kCertificate = "cert";
+const std::string kTransportType = "WS";
+const mobile_api::HybridAppPreference::eType kHybridAppPreference =
+ mobile_api::HybridAppPreference::CLOUD;
+const std::string kHybridAppPreferenceStr = "CLOUD";
+const bool kEnabled = true;
} // namespace
class ApplicationManagerImplTest : public ::testing::Test {
@@ -106,6 +123,10 @@ class ApplicationManagerImplTest : public ::testing::Test {
std::make_shared<NiceMock<resumption_test::MockResumptionData> >(
mock_app_mngr_))
, mock_rpc_service_(new MockRPCService)
+ , mock_policy_handler_(
+ new test::components::policy_test::MockPolicyHandlerInterface)
+ , mock_app_service_manager_(
+ new MockAppServiceManager(mock_app_mngr_, mock_last_state_))
, mock_message_helper_(
application_manager::MockMessageHelper::message_helper_mock())
@@ -122,14 +143,21 @@ class ApplicationManagerImplTest : public ::testing::Test {
protected:
void SetUp() OVERRIDE {
CreateAppManager();
- ON_CALL(mock_connection_handler_, GetDataOnSessionKey(_, _, _, &kDeviceId))
- .WillByDefault(DoAll(SetArgPointee<3u>(app_id_), Return(0)));
+ ON_CALL(mock_session_observer_, GetDataOnSessionKey(_, _, _, _))
+ .WillByDefault(DoAll(SetArgPointee<3u>(kDeviceId), Return(0)));
ON_CALL(mock_connection_handler_, get_session_observer())
.WillByDefault(ReturnRef(mock_session_observer_));
- app_manager_impl_->SetRPCService(mock_rpc_service_);
+ app_manager_impl_->SetMockRPCService(mock_rpc_service_);
app_manager_impl_->resume_controller().set_resumption_storage(
mock_storage_);
app_manager_impl_->set_connection_handler(&mock_connection_handler_);
+ ON_CALL(*mock_app_service_manager_, UnpublishServices(_))
+ .WillByDefault(Return());
+ ON_CALL(*mock_app_service_manager_, OnAppActivated(_))
+ .WillByDefault(Return());
+ app_manager_impl_->SetAppServiceManager(mock_app_service_manager_);
+ Json::Value empty;
+ ON_CALL(mock_last_state_, get_dictionary()).WillByDefault(ReturnRef(empty));
}
void CreateAppManager() {
@@ -196,16 +224,22 @@ class ApplicationManagerImplTest : public ::testing::Test {
connection_handler::DeviceHandle secondary_device_handle,
std::string secondary_transport_device_string);
+ void AddCloudAppToPendingDeviceMap();
+
uint32_t app_id_;
NiceMock<policy_test::MockPolicySettings> mock_policy_settings_;
std::shared_ptr<NiceMock<resumption_test::MockResumptionData> > mock_storage_;
- std::unique_ptr<rpc_service::RPCService> mock_rpc_service_;
+ MockRPCService* mock_rpc_service_;
+ resumption_test::MockLastState mock_last_state_;
NiceMock<con_test::MockConnectionHandler> mock_connection_handler_;
NiceMock<protocol_handler_test::MockSessionObserver> mock_session_observer_;
NiceMock<MockApplicationManagerSettings> mock_application_manager_settings_;
+ test::components::policy_test::MockPolicyHandlerInterface*
+ mock_policy_handler_;
application_manager_test::MockApplicationManager mock_app_mngr_;
std::unique_ptr<am::ApplicationManagerImpl> app_manager_impl_;
+ MockAppServiceManager* mock_app_service_manager_;
application_manager::MockMessageHelper* mock_message_helper_;
std::shared_ptr<MockApplication> mock_app_ptr_;
@@ -1413,6 +1447,219 @@ TEST_F(ApplicationManagerImplTest,
EXPECT_TRUE(file_system::RemoveDirectory(kDirectoryName, true));
}
-} // application_manager_test
+void ApplicationManagerImplTest::AddCloudAppToPendingDeviceMap() {
+ app_manager_impl_->SetMockPolicyHandler(mock_policy_handler_);
+ std::vector<std::string> enabled_apps{"1234"};
+ EXPECT_CALL(*mock_policy_handler_, GetEnabledCloudApps(_))
+ .WillOnce(SetArgReferee<0>(enabled_apps));
+ EXPECT_CALL(*mock_policy_handler_, GetCloudAppParameters(_, _, _, _, _, _, _))
+ .WillOnce(DoAll(SetArgReferee<1>(kEnabled),
+ SetArgReferee<2>(kEndpoint2),
+ SetArgReferee<3>(kCertificate),
+ SetArgReferee<4>(kAuthToken),
+ SetArgReferee<5>(kTransportType),
+ SetArgReferee<6>(kHybridAppPreferenceStr),
+ Return(true)));
+
+ std::vector<std::string> nicknames{"CloudApp"};
+ EXPECT_CALL(*mock_policy_handler_, GetInitialAppData(_, _, _))
+ .WillOnce(DoAll(SetArgPointee<1>(nicknames), Return(true)));
+
+ EXPECT_CALL(*mock_policy_handler_, GetIconUrl(_)).WillOnce(Return(""));
+
+ app_manager_impl_->RefreshCloudAppInformation();
+}
+
+TEST_F(ApplicationManagerImplTest, CreatePendingApplication) {
+ // Add to pending device map. Calls refresh cloud app
+ AddCloudAppToPendingDeviceMap();
+
+ // CreatePendingApplication
+ transport_manager::DeviceInfo device_info(
+ 1, "mac", kEndpoint2, "CLOUD_WEBSOCKET");
+ std::vector<std::string> nicknames{"CloudApp"};
+ EXPECT_CALL(*mock_policy_handler_, GetInitialAppData(_, _, _))
+ .WillOnce(DoAll(SetArgPointee<1>(nicknames), Return(true)));
+ std::vector<std::string> enabled_apps{"1234"};
+
+ EXPECT_CALL(*mock_policy_handler_, GetStatisticManager())
+ .WillOnce(Return(std::shared_ptr<usage_statistics::StatisticsManager>(
+ new usage_statistics_test::MockStatisticsManager())));
+ EXPECT_CALL(*mock_policy_handler_, GetCloudAppParameters(_, _, _, _, _, _, _))
+ .WillOnce(DoAll(SetArgReferee<1>(kEnabled),
+ SetArgReferee<2>(kEndpoint2),
+ SetArgReferee<3>(kCertificate),
+ SetArgReferee<4>(kAuthToken),
+ SetArgReferee<5>(kTransportType),
+ SetArgReferee<6>(kHybridAppPreferenceStr),
+ Return(true)));
+ // Expect Update app list
+ EXPECT_CALL(*mock_rpc_service_, ManageHMICommand(_, _)).Times(1);
+ app_manager_impl_->CreatePendingApplication(1, device_info, 1);
+ AppsWaitRegistrationSet app_list =
+ app_manager_impl_->AppsWaitingForRegistration().GetData();
+ EXPECT_EQ(1u, app_list.size());
+}
+
+TEST_F(ApplicationManagerImplTest, SetPendingState) {
+ AddCloudAppToPendingDeviceMap();
+ AddMockApplication();
+ AppsWaitRegistrationSet app_list =
+ app_manager_impl_->AppsWaitingForRegistration().GetData();
+ EXPECT_EQ(0u, app_list.size());
+ EXPECT_CALL(*mock_app_ptr_, policy_app_id()).WillRepeatedly(Return("1234"));
+ EXPECT_CALL(*mock_app_ptr_, app_id()).WillRepeatedly(Return(123));
+ std::string mac = "MAC_ADDRESS";
+ EXPECT_CALL(*mock_app_ptr_, mac_address()).WillRepeatedly(ReturnRef(mac));
+ transport_manager::DeviceInfo device_info(
+ 1, "mac", kEndpoint2, "CLOUD_WEBSOCKET");
+
+ std::vector<std::string> enabled_apps{"1234"};
+
+ EXPECT_CALL(*mock_policy_handler_, GetEnabledCloudApps(_))
+ .WillOnce(SetArgReferee<0>(enabled_apps));
+ EXPECT_CALL(*mock_policy_handler_, GetCloudAppParameters(_, _, _, _, _, _, _))
+ .WillOnce(DoAll(SetArgReferee<1>(kEnabled),
+ SetArgReferee<2>(kEndpoint2),
+ SetArgReferee<3>(kCertificate),
+ SetArgReferee<4>(kAuthToken),
+ SetArgReferee<5>(kTransportType),
+ SetArgReferee<6>(kHybridAppPreferenceStr),
+ Return(true)));
+
+ std::vector<std::string> nicknames{"CloudApp"};
+ EXPECT_CALL(*mock_policy_handler_, GetInitialAppData(_, _, _))
+ .WillOnce(DoAll(SetArgPointee<1>(nicknames), Return(true)));
+
+ EXPECT_CALL(*mock_policy_handler_, GetIconUrl(_)).WillOnce(Return(""));
+
+ plugin_manager::MockRPCPluginManager* mock_rpc_plugin_manager =
+ new plugin_manager::MockRPCPluginManager;
+ std::unique_ptr<plugin_manager::RPCPluginManager> mock_rpc_plugin_manager_ptr(
+ mock_rpc_plugin_manager);
+ app_manager_impl_->SetPluginManager(mock_rpc_plugin_manager_ptr);
+
+ EXPECT_CALL(mock_connection_handler_, GetDeviceID(_, _))
+ .WillOnce(DoAll(SetArgPointee<1>(0), Return(true)));
+ app_manager_impl_->SetPendingApplicationState(1, device_info);
+ app_list = app_manager_impl_->AppsWaitingForRegistration().GetData();
+ EXPECT_EQ(1u, app_list.size());
+}
+
+TEST_F(ApplicationManagerImplTest,
+ RegisterApplication_CloudAppRegisterSuccess) {
+ std::shared_ptr<MockApplication> waiting_app =
+ std::make_shared<MockApplication>();
+ ON_CALL(*waiting_app, device()).WillByDefault(Return(kDeviceId));
+ EXPECT_CALL(*waiting_app, cloud_app_endpoint())
+ .WillOnce(ReturnRef(kEndpoint));
+ EXPECT_CALL(*waiting_app, auth_token()).WillOnce(ReturnRef(kAuthToken));
+ EXPECT_CALL(*waiting_app, cloud_app_certificate())
+ .WillOnce(ReturnRef(kCertificate));
+ EXPECT_CALL(*waiting_app, cloud_app_transport_type())
+ .WillOnce(ReturnRef(kTransportType));
+ EXPECT_CALL(*waiting_app, hybrid_app_preference())
+ .WillOnce(ReturnRef(kHybridAppPreference));
+ ON_CALL(*waiting_app, is_cloud_app()).WillByDefault(Return(true));
+ EXPECT_CALL(*waiting_app, policy_app_id()).WillRepeatedly(Return(kAppId));
+ app_manager_impl_->AddMockPendingApplication(waiting_app);
+
+ EXPECT_CALL(
+ mock_session_observer_,
+ GetDataOnSessionKey(kConnectionKey,
+ _,
+ _,
+ testing::An<connection_handler::DeviceHandle*>()))
+ .WillOnce(DoAll(SetArgPointee<3u>(kDeviceId), Return(0)));
+ EXPECT_CALL(*mock_rpc_service_,
+ ManageMobileCommand(_, commands::Command::SOURCE_SDL)).Times(0);
+ smart_objects::SmartObject request_for_registration(
+ smart_objects::SmartType_Map);
+
+ smart_objects::SmartObject& params =
+ request_for_registration[strings::msg_params];
+ params[strings::app_id] = kAppId;
+ params[strings::language_desired] = mobile_api::Language::EN_US;
+ params[strings::hmi_display_language_desired] = mobile_api::Language::EN_US;
+
+ request_for_registration[strings::params][strings::connection_key] =
+ kConnectionKey;
+ request_for_registration[strings::msg_params][strings::app_name] = kAppName;
+ request_for_registration[strings::msg_params][strings::sync_msg_version]
+ [strings::minor_version] = APIVersion::kAPIV2;
+ request_for_registration[strings::msg_params][strings::sync_msg_version]
+ [strings::major_version] = APIVersion::kAPIV3;
+
+ request_for_registration[strings::params][strings::protocol_version] =
+ protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_2;
+
+ smart_objects::SmartObjectSPtr request_for_registration_ptr =
+ std::make_shared<smart_objects::SmartObject>(request_for_registration);
+
+ ApplicationSharedPtr application =
+ app_manager_impl_->RegisterApplication(request_for_registration_ptr);
+
+ EXPECT_EQ(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_2,
+ application->protocol_version());
+ EXPECT_EQ(APIVersion::kAPIV2,
+ application->version().min_supported_api_version);
+ EXPECT_EQ(APIVersion::kAPIV3,
+ application->version().max_supported_api_version);
+ EXPECT_EQ(kEndpoint, application->cloud_app_endpoint());
+ EXPECT_EQ(kAuthToken, application->auth_token());
+ EXPECT_EQ(kCertificate, application->cloud_app_certificate());
+ EXPECT_EQ(kTransportType, application->cloud_app_transport_type());
+ EXPECT_EQ(kHybridAppPreference, application->hybrid_app_preference());
+}
+
+TEST_F(ApplicationManagerImplTest,
+ RegisterApplication_CloudAppRegisterFailed_DISALLOWED) {
+ std::shared_ptr<MockApplication> waiting_app =
+ std::make_shared<MockApplication>();
+ EXPECT_CALL(*waiting_app, device()).WillRepeatedly(Return(kDeviceId));
+ EXPECT_CALL(*waiting_app, is_cloud_app()).WillRepeatedly(Return(true));
+ EXPECT_CALL(*waiting_app, policy_app_id())
+ .WillRepeatedly(Return("Fake" + kAppId));
+ app_manager_impl_->AddMockPendingApplication(waiting_app);
+
+ EXPECT_CALL(
+ mock_session_observer_,
+ GetDataOnSessionKey(kConnectionKey,
+ _,
+ _,
+ testing::An<connection_handler::DeviceHandle*>()))
+ .WillOnce(DoAll(SetArgPointee<3u>(kDeviceId), Return(0)));
+ EXPECT_CALL(*mock_rpc_service_,
+ ManageMobileCommand(_, commands::Command::SOURCE_SDL))
+ .WillOnce(Return(true));
+ smart_objects::SmartObject request_for_registration(
+ smart_objects::SmartType_Map);
+
+ smart_objects::SmartObject& params =
+ request_for_registration[strings::msg_params];
+ params[strings::app_id] = kAppId;
+ params[strings::language_desired] = mobile_api::Language::EN_US;
+ params[strings::hmi_display_language_desired] = mobile_api::Language::EN_US;
+
+ request_for_registration[strings::params][strings::connection_key] =
+ kConnectionKey;
+ request_for_registration[strings::msg_params][strings::app_name] = kAppName;
+ request_for_registration[strings::msg_params][strings::sync_msg_version]
+ [strings::minor_version] = APIVersion::kAPIV2;
+ request_for_registration[strings::msg_params][strings::sync_msg_version]
+ [strings::major_version] = APIVersion::kAPIV3;
+
+ request_for_registration[strings::params][strings::protocol_version] =
+ protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_2;
+
+ smart_objects::SmartObjectSPtr request_for_registration_ptr =
+ std::make_shared<smart_objects::SmartObject>(request_for_registration);
+
+ ApplicationSharedPtr application =
+ app_manager_impl_->RegisterApplication(request_for_registration_ptr);
+ EXPECT_EQ(0, application.use_count());
+}
+
+} // namespace application_manager_test
} // namespace components
} // namespace test
diff --git a/src/components/application_manager/test/command_holder_test.cc b/src/components/application_manager/test/command_holder_test.cc
index 56e24b8d29..9496e37924 100644
--- a/src/components/application_manager/test/command_holder_test.cc
+++ b/src/components/application_manager/test/command_holder_test.cc
@@ -84,7 +84,7 @@ TEST_F(CommandHolderImplTest, HoldOne_ExpectReleaseOne) {
mock_app_ptr_, am::CommandHolder::CommandType::kHmiCommand, cmd_ptr_);
// Act
- EXPECT_CALL(mock_rpc_service_, ManageHMICommand(cmd_ptr_));
+ EXPECT_CALL(mock_rpc_service_, ManageHMICommand(cmd_ptr_, _));
cmd_holder.Resume(mock_app_ptr_, am::CommandHolder::CommandType::kHmiCommand);
}
@@ -99,7 +99,8 @@ TEST_F(CommandHolderImplTest, HoldMany_ExpectReleaseSame) {
} while (iterations < 5);
// Act
- EXPECT_CALL(mock_rpc_service_, ManageHMICommand(cmd_ptr_)).Times(iterations);
+ EXPECT_CALL(mock_rpc_service_, ManageHMICommand(cmd_ptr_, _))
+ .Times(iterations);
cmd_holder.Resume(mock_app_ptr_, am::CommandHolder::CommandType::kHmiCommand);
}
@@ -112,7 +113,7 @@ TEST_F(CommandHolderImplTest, Hold_Drop_ExpectNoReleased) {
// Act
cmd_holder.Clear(mock_app_ptr_);
- EXPECT_CALL(mock_rpc_service_, ManageHMICommand(cmd_ptr_)).Times(0);
+ EXPECT_CALL(mock_rpc_service_, ManageHMICommand(cmd_ptr_, _)).Times(0);
cmd_holder.Resume(mock_app_ptr_, am::CommandHolder::CommandType::kHmiCommand);
}
@@ -127,7 +128,7 @@ TEST_F(CommandHolderImplTest, Hold_ReleaseAnotherId_ExpectNoReleased) {
std::shared_ptr<MockApplication> another_app =
std::make_shared<MockApplication>();
- EXPECT_CALL(mock_rpc_service_, ManageHMICommand(cmd_ptr_)).Times(0);
+ EXPECT_CALL(mock_rpc_service_, ManageHMICommand(cmd_ptr_, _)).Times(0);
cmd_holder.Resume(another_app, am::CommandHolder::CommandType::kHmiCommand);
}
@@ -146,7 +147,8 @@ TEST_F(CommandHolderImplTest, Hold_DropAnotherId_ExpectReleased) {
std::make_shared<MockApplication>();
cmd_holder.Clear(another_app);
- EXPECT_CALL(mock_rpc_service_, ManageHMICommand(cmd_ptr_)).Times(iterations);
+ EXPECT_CALL(mock_rpc_service_, ManageHMICommand(cmd_ptr_, _))
+ .Times(iterations);
cmd_holder.Resume(mock_app_ptr_, am::CommandHolder::CommandType::kHmiCommand);
}
@@ -160,7 +162,7 @@ TEST_F(CommandHolderImplTest, Hold_Mobile_and_HMI_commands_ExpectReleased) {
mock_app_ptr_, am::CommandHolder::CommandType::kMobileCommand, cmd_ptr_);
// Act
- EXPECT_CALL(mock_rpc_service_, ManageHMICommand(cmd_ptr_));
+ EXPECT_CALL(mock_rpc_service_, ManageHMICommand(cmd_ptr_, _));
cmd_holder.Resume(mock_app_ptr_, am::CommandHolder::CommandType::kHmiCommand);
EXPECT_CALL(
diff --git a/src/components/application_manager/test/commands/CMakeLists.txt b/src/components/application_manager/test/commands/CMakeLists.txt
index 33258e60db..556f3a5032 100644
--- a/src/components/application_manager/test/commands/CMakeLists.txt
+++ b/src/components/application_manager/test/commands/CMakeLists.txt
@@ -59,6 +59,7 @@ set(LIBRARIES
ApplicationManager
jsoncpp
Policy
+ Resumption
)
create_test("commands_test" "${SOURCES}" "${LIBRARIES}")
diff --git a/src/components/application_manager/test/commands/command_impl_test.cc b/src/components/application_manager/test/commands/command_impl_test.cc
index 222f16ef46..53e8534c2b 100644
--- a/src/components/application_manager/test/commands/command_impl_test.cc
+++ b/src/components/application_manager/test/commands/command_impl_test.cc
@@ -85,11 +85,12 @@ class CommandImplTest : public CommandsTest<CommandsTestMocks::kIsNice> {
using CommandImpl::ReplaceMobileWithHMIAppId;
using CommandImpl::ReplaceHMIWithMobileAppId;
- UnwrappedCommandImpl(const MessageSharedPtr& message,
- ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handler)
+ UnwrappedCommandImpl(
+ const MessageSharedPtr& message,
+ ApplicationManager& application_manager,
+ application_manager::rpc_service::RPCService& rpc_service,
+ application_manager::HMICapabilities& hmi_capabilities,
+ policy::PolicyHandlerInterface& policy_handler)
: CommandImpl(message,
application_manager,
rpc_service,
diff --git a/src/components/application_manager/test/commands/command_request_impl_test.cc b/src/components/application_manager/test/commands/command_request_impl_test.cc
index c70dd14852..6d80a11440 100644
--- a/src/components/application_manager/test/commands/command_request_impl_test.cc
+++ b/src/components/application_manager/test/commands/command_request_impl_test.cc
@@ -51,6 +51,9 @@
#include "application_manager/mock_hmi_interface.h"
#include "interfaces/MOBILE_API.h"
+#include "application_manager/mock_app_service_manager.h"
+#include "resumption/last_state_impl.h"
+
namespace test {
namespace components {
namespace commands_test {
@@ -64,6 +67,7 @@ using ::testing::_;
using ::testing::Return;
using ::testing::SaveArg;
using ::testing::DoAll;
+using ::testing::SetArgReferee;
using am::commands::MessageSharedPtr;
using am::CommandParametersPermissions;
@@ -74,6 +78,7 @@ using am::ApplicationManager;
using am::ApplicationSet;
using am::RPCParams;
using am::MockHmiInterfaces;
+using test::components::application_manager_test::MockAppServiceManager;
typedef am::commands::CommandRequestImpl::RequestState RequestState;
@@ -258,7 +263,7 @@ TEST_F(CommandRequestImplTest, CreateHMINotification_SUCCESS) {
MessageSharedPtr result;
- EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_))
+ EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _))
.WillOnce(DoAll(SaveArg<0>(&result), Return(true)));
command->CreateHMINotification(kInvalidFunctionId, *msg_params);
@@ -280,7 +285,7 @@ TEST_F(CommandRequestImplTest, SendHMIRequest_NoUseEvent_SUCCESS) {
.WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE));
// Return `true` prevents call of `SendResponse` method;
- EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).WillOnce(Return(true));
+ EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).WillOnce(Return(true));
EXPECT_EQ(kCorrelationId,
command->SendHMIRequest(kInvalidFunctionId, NULL, false));
@@ -298,7 +303,7 @@ TEST_F(CommandRequestImplTest, SendHMIRequest_UseEvent_SUCCESS) {
.WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE));
// Return `true` prevents call of `SendResponse` method;
- EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).WillOnce(Return(true));
+ EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).WillOnce(Return(true));
EXPECT_CALL(event_dispatcher_, add_observer(_, _, _));
EXPECT_EQ(kCorrelationId,
@@ -585,6 +590,87 @@ TEST_F(CommandRequestImplTest, AppNotFound_HashUpdateNotExpected) {
command.reset();
}
+TEST_F(CommandRequestImplTest, SendProviderRequest_ByServiceType) {
+ resumption::LastStateImpl last_state("app_storage_folder",
+ "app_info_storage");
+ MockAppServiceManager app_service_manager(app_mngr_, last_state);
+ MockAppPtr mock_app = CreateMockApp();
+ EXPECT_CALL(app_mngr_, GetAppServiceManager())
+ .WillRepeatedly(ReturnRef(app_service_manager));
+ EXPECT_CALL(app_service_manager, GetProviderByType("MEDIA", _, _, _))
+ .WillOnce(DoAll(SetArgReferee<2>(mock_app), SetArgReferee<3>(false)));
+
+ MessageSharedPtr result;
+ EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _))
+ .WillOnce(DoAll(SaveArg<0>(&result), Return(true)));
+
+ MessageSharedPtr msg = CreateMessage();
+ (*msg)[strings::params][strings::function_id] =
+ mobile_apis::FunctionID::GetAppServiceDataID;
+ (*msg)[strings::msg_params][strings::service_type] = "MEDIA";
+
+ CommandPtr command = CreateCommand<UCommandRequestImpl>(msg);
+ command->SendProviderRequest(
+ mobile_apis::FunctionID::GetAppServiceDataID,
+ hmi_apis::FunctionID::AppService_GetAppServiceData,
+ &(*msg),
+ true);
+}
+
+TEST_F(CommandRequestImplTest, SendProviderRequest_ByProviderID) {
+ resumption::LastStateImpl last_state("app_storage_folder",
+ "app_info_storage");
+ MockAppServiceManager app_service_manager(app_mngr_, last_state);
+ MockAppPtr mock_app = CreateMockApp();
+ EXPECT_CALL(app_mngr_, GetAppServiceManager())
+ .WillRepeatedly(ReturnRef(app_service_manager));
+ EXPECT_CALL(app_service_manager, GetProviderByID("serviceid12345", _, _, _))
+ .WillOnce(DoAll(SetArgReferee<2>(mock_app), SetArgReferee<3>(false)));
+
+ MessageSharedPtr result;
+ EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _))
+ .WillOnce(DoAll(SaveArg<0>(&result), Return(true)));
+
+ MessageSharedPtr msg = CreateMessage();
+ (*msg)[strings::params][strings::function_id] =
+ mobile_apis::FunctionID::GetAppServiceDataID;
+ (*msg)[strings::msg_params][strings::service_id] = "serviceid12345";
+
+ CommandPtr command = CreateCommand<UCommandRequestImpl>(msg);
+ command->SendProviderRequest(
+ mobile_apis::FunctionID::GetAppServiceDataID,
+ hmi_apis::FunctionID::AppService_GetAppServiceData,
+ &(*msg),
+ true);
+}
+
+TEST_F(CommandRequestImplTest, SendProviderRequestToHMI_ByProviderID) {
+ resumption::LastStateImpl last_state("app_storage_folder",
+ "app_info_storage");
+ MockAppServiceManager app_service_manager(app_mngr_, last_state);
+ MockAppPtr mock_app = CreateMockApp();
+ EXPECT_CALL(app_mngr_, GetAppServiceManager())
+ .WillRepeatedly(ReturnRef(app_service_manager));
+ EXPECT_CALL(app_service_manager, GetProviderByID("serviceid12345", _, _, _))
+ .WillOnce(DoAll(SetArgReferee<2>(mock_app), SetArgReferee<3>(true)));
+
+ MessageSharedPtr result;
+ EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _))
+ .WillOnce(DoAll(SaveArg<0>(&result), Return(true)));
+
+ MessageSharedPtr msg = CreateMessage();
+ (*msg)[strings::params][strings::function_id] =
+ mobile_apis::FunctionID::GetAppServiceDataID;
+ (*msg)[strings::msg_params][strings::service_id] = "serviceid12345";
+
+ CommandPtr command = CreateCommand<UCommandRequestImpl>(msg);
+ command->SendProviderRequest(
+ mobile_apis::FunctionID::GetAppServiceDataID,
+ hmi_apis::FunctionID::AppService_GetAppServiceData,
+ &(*msg),
+ true);
+}
+
} // namespace command_request_impl
} // namespace commands_test
} // namespace components
diff --git a/src/components/application_manager/test/help_prompt_manager_test.cc b/src/components/application_manager/test/help_prompt_manager_test.cc
index f921eb1dde..dc6635b049 100644
--- a/src/components/application_manager/test/help_prompt_manager_test.cc
+++ b/src/components/application_manager/test/help_prompt_manager_test.cc
@@ -136,10 +136,12 @@ class HelpPromptManagerTest : public ::testing::Test {
typedef CommandsTest<CommandsTestMocks::kIsNice>::MockAppManager
MockAppManager;
MockAppManager app_mngr_;
+ // put this before ApplicationImplTest instance, so that app_mngr_settings_
+ // will still exist during app_impl_'s destructor.
+ NiceMock<MockApplicationManagerSettings> app_mngr_settings_;
std::shared_ptr<ApplicationImplTest> app_impl_;
MockHmiInterfaces mock_hmi_interfaces_;
NiceMock<event_engine_test::MockEventDispatcher> mock_event_dispatcher_;
- NiceMock<MockApplicationManagerSettings> app_mngr_settings_;
std::shared_ptr<application_manager_test::MockApplication> mock_app_;
sync_primitives::Lock app_lock_;
MockRPCService mock_rpc_service_;
@@ -175,11 +177,6 @@ void HelpPromptManagerTest::SetUp() {
mock_help_prompt_manager_ =
std::shared_ptr<MockHelpPromptManager>(new MockHelpPromptManager());
- HmiStatePtr state = std::make_shared<HmiState>(
- static_cast<std::shared_ptr<Application> >(mock_app_),
- app_mngr_,
- HmiState::STATE_ID_REGULAR);
-
std::string path = file_system::CreateDirectory("storage");
file_system::CreateFile(path + "/" + "certificate");
diff --git a/src/components/application_manager/test/hmi_capabilities_test.cc b/src/components/application_manager/test/hmi_capabilities_test.cc
index ae95fca35f..d67dfebaa5 100644
--- a/src/components/application_manager/test/hmi_capabilities_test.cc
+++ b/src/components/application_manager/test/hmi_capabilities_test.cc
@@ -583,7 +583,7 @@ void HMICapabilitiesTest::SetCooperating() {
smart_objects::SmartObjectSPtr test_so;
EXPECT_CALL(*(MockMessageHelper::message_helper_mock()),
CreateModuleInfoSO(_, _)).WillRepeatedly(Return(test_so));
- EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_))
+ EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _))
.WillRepeatedly(Return(true));
}
diff --git a/src/components/application_manager/test/include/application_manager/commands/command_request_test.h b/src/components/application_manager/test/include/application_manager/commands/command_request_test.h
index 1980ffa100..8dd29ce244 100644
--- a/src/components/application_manager/test/include/application_manager/commands/command_request_test.h
+++ b/src/components/application_manager/test/include/application_manager/commands/command_request_test.h
@@ -105,7 +105,7 @@ class CommandRequestTest : public CommandsTest<kIsNice> {
MessageSharedPtr CatchHMICommandResult(CallableT delegate,
bool call_return = true) {
MessageSharedPtr result_msg;
- EXPECT_CALL(this->mock_rpc_service_, ManageHMICommand(_))
+ EXPECT_CALL(this->mock_rpc_service_, ManageHMICommand(_, _))
.WillOnce(DoAll(SaveArg<0>(&result_msg), Return(call_return)));
delegate();
return result_msg;
diff --git a/src/components/application_manager/test/include/application_manager/mock_app_service_manager.h b/src/components/application_manager/test/include/application_manager/mock_app_service_manager.h
new file mode 100644
index 0000000000..f77b5685da
--- /dev/null
+++ b/src/components/application_manager/test/include/application_manager/mock_app_service_manager.h
@@ -0,0 +1,95 @@
+/*
+ Copyright (c) 2019, Ford Motor Company, Livio
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided with the
+ distribution.
+
+ Neither the name of the the copyright holders nor the names of their
+ contributors may be used to endorse or promote products derived from this
+ software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_APP_SERVICE_MANAGER_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_APP_SERVICE_MANAGER_H_
+
+#include <gmock/gmock.h>
+#include "application_manager/app_service_manager.h"
+#include "application_manager/commands/command.h"
+#include "application_manager/commands/command_impl.h"
+
+namespace test {
+namespace components {
+namespace application_manager_test {
+
+class MockAppServiceManager : public application_manager::AppServiceManager {
+ public:
+ MockAppServiceManager(application_manager::ApplicationManager& app_manager,
+ resumption::LastState& last_state)
+ : application_manager::AppServiceManager(app_manager, last_state) {}
+ MOCK_METHOD3(
+ PublishAppService,
+ smart_objects::SmartObject(const smart_objects::SmartObject& manifest,
+ const bool mobile_service,
+ const uint32_t connection_key));
+ MOCK_METHOD1(UnpublishAppService, bool(const std::string service_id));
+ MOCK_METHOD1(UnpublishServices, void(const uint32_t connection_key));
+ MOCK_METHOD1(OnAppActivated,
+ void(application_manager::ApplicationConstSharedPtr app));
+ MOCK_METHOD1(SetDefaultService, bool(const std::string service_id));
+ MOCK_METHOD1(RemoveDefaultService, bool(const std::string service_id));
+ MOCK_METHOD1(ActivateAppService, bool(const std::string service_id));
+ MOCK_METHOD1(DeactivateAppService, bool(const std::string service_id));
+ MOCK_METHOD0(GetAllServiceRecords, std::vector<smart_objects::SmartObject>());
+ MOCK_METHOD0(GetActiveServices,
+ std::vector<application_manager::AppService>());
+ MOCK_METHOD4(GetProviderByType,
+ void(const std::string& service_type,
+ const bool mobile_consumer,
+ application_manager::ApplicationSharedPtr& app,
+ bool& hmi_service));
+ MOCK_METHOD4(GetProviderByID,
+ void(const std::string& service_id,
+ const bool mobile_consumer,
+ application_manager::ApplicationSharedPtr& app,
+ bool& hmi_service));
+ MOCK_METHOD1(
+ ActiveServiceForType,
+ application_manager::AppService*(const std::string service_type));
+ MOCK_METHOD1(
+ EmbeddedServiceForType,
+ application_manager::AppService*(const std::string service_type));
+ MOCK_METHOD1(FindServiceByID,
+ application_manager::AppService*(const std::string service_id));
+ MOCK_METHOD2(SetServicePublished,
+ void(const std::string service_id,
+ const bool service_published));
+ MOCK_METHOD1(UpdateNavigationCapabilities,
+ bool(smart_objects::SmartObject& out_params));
+};
+
+} // namespace application_manager_test
+} // namespace components
+} // namespace test
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_APP_SERVICE_MANAGER_H_
diff --git a/src/components/application_manager/test/include/application_manager/mock_application.h b/src/components/application_manager/test/include/application_manager/mock_application.h
index fe16e8ce6e..36d20f227d 100644
--- a/src/components/application_manager/test/include/application_manager/mock_application.h
+++ b/src/components/application_manager/test/include/application_manager/mock_application.h
@@ -342,6 +342,21 @@ class MockApplication : public ::application_manager::Application {
const std::list<application_manager::AppExtensionPtr>&());
MOCK_CONST_METHOD0(is_remote_control_supported, bool());
MOCK_METHOD1(set_remote_control_supported, void(const bool allow));
+ MOCK_CONST_METHOD0(cloud_app_endpoint, const std::string&());
+ MOCK_CONST_METHOD0(auth_token, const std::string&());
+ MOCK_CONST_METHOD0(cloud_app_transport_type, const std::string&());
+ MOCK_CONST_METHOD0(hybrid_app_preference,
+ const mobile_apis::HybridAppPreference::eType&());
+ MOCK_CONST_METHOD0(cloud_app_certificate, const std::string&());
+ MOCK_CONST_METHOD0(is_cloud_app, bool());
+ MOCK_METHOD1(set_cloud_app_endpoint, void(const std::string& endpoint));
+ MOCK_METHOD1(set_auth_token, void(const std::string& auth_token));
+ MOCK_METHOD1(set_cloud_app_transport_type,
+ void(const std::string& transport_type));
+ MOCK_METHOD1(set_hybrid_app_preference,
+ void(const mobile_apis::HybridAppPreference::eType&
+ hybrid_app_preference));
+ MOCK_METHOD1(set_cloud_app_certificate, void(const std::string& certificate));
};
} // namespace application_manager_test
diff --git a/src/components/application_manager/test/include/application_manager/mock_event_dispatcher.h b/src/components/application_manager/test/include/application_manager/mock_event_dispatcher.h
index 916f4a69f0..c5aedba029 100644
--- a/src/components/application_manager/test/include/application_manager/mock_event_dispatcher.h
+++ b/src/components/application_manager/test/include/application_manager/mock_event_dispatcher.h
@@ -59,6 +59,26 @@ class MockEventDispatcher
MOCK_METHOD1(
remove_observer,
void(::application_manager::event_engine::EventObserver& observer));
+
+ MOCK_METHOD1(
+ raise_mobile_event,
+ void(const ::application_manager::event_engine::MobileEvent& event));
+ MOCK_METHOD3(
+ add_mobile_observer,
+ void(
+ const ::application_manager::event_engine::MobileEvent::MobileEventID&
+ event_id,
+ int32_t mobile_correlation_id,
+ ::application_manager::event_engine::EventObserver& observer));
+ MOCK_METHOD2(
+ remove_mobile_observer,
+ void(
+ const ::application_manager::event_engine::MobileEvent::MobileEventID&
+ event_id,
+ ::application_manager::event_engine::EventObserver& observer));
+ MOCK_METHOD1(
+ remove_mobile_observer,
+ void(::application_manager::event_engine::EventObserver& observer));
};
} // namespace event_engine_test
diff --git a/src/components/application_manager/test/include/application_manager/mock_message_helper.h b/src/components/application_manager/test/include/application_manager/mock_message_helper.h
index 84a3b6bc87..ac39c39f22 100644
--- a/src/components/application_manager/test/include/application_manager/mock_message_helper.h
+++ b/src/components/application_manager/test/include/application_manager/mock_message_helper.h
@@ -164,6 +164,8 @@ class MockMessageHelper {
ApplicationManager& app_mngr));
MOCK_METHOD1(CommonLanguageFromString,
hmi_apis::Common_Language::eType(const std::string& language));
+ MOCK_METHOD1(CommonLightNameFromString,
+ hmi_apis::Common_LightName::eType(const std::string& lightName));
MOCK_METHOD1(CommonLanguageToString,
std::string(hmi_apis::Common_Language::eType));
MOCK_METHOD2(CreateModuleInfoSO,
@@ -308,6 +310,12 @@ class MockMessageHelper {
void(mobile_apis::ButtonName::eType button,
ApplicationSharedPtr application,
ApplicationManager& app_mngr));
+ MOCK_METHOD1(CreateAppServiceCapabilities,
+ smart_objects::SmartObject(
+ std::vector<smart_objects::SmartObject>& all_services));
+ MOCK_METHOD2(BroadcastCapabilityUpdate,
+ void(smart_objects::SmartObject& msg_params,
+ ApplicationManager& app_mngr));
static MockMessageHelper* message_helper_mock();
};
diff --git a/src/components/application_manager/test/message_helper/CMakeLists.txt b/src/components/application_manager/test/message_helper/CMakeLists.txt
index d115ad8b40..99031849f6 100755
--- a/src/components/application_manager/test/message_helper/CMakeLists.txt
+++ b/src/components/application_manager/test/message_helper/CMakeLists.txt
@@ -40,6 +40,7 @@ set(LIBRARIES
ApplicationManager
MessageHelper
jsoncpp
+ Policy
connectionHandler
MediaManager
Resumption
diff --git a/src/components/application_manager/test/message_helper/message_helper_test.cc b/src/components/application_manager/test/message_helper/message_helper_test.cc
index 15a09c33cc..92be221ec9 100644
--- a/src/components/application_manager/test/message_helper/message_helper_test.cc
+++ b/src/components/application_manager/test/message_helper/message_helper_test.cc
@@ -42,13 +42,16 @@
#include "utils/custom_string.h"
#include "utils/lock.h"
#include "policy/mock_policy_settings.h"
-#include "application_manager/policies/policy_handler.h"
+#include "application_manager/commands/command_impl.h"
#include "application_manager/mock_application_manager.h"
#include "application_manager/mock_rpc_service.h"
#include "application_manager/event_engine/event_dispatcher.h"
#include "application_manager/state_controller.h"
#include "application_manager/resumption/resume_ctrl.h"
+#include "policy/policy_table/types.h"
+#include "rpc_base/rpc_base_json_inl.h"
+
#ifdef EXTERNAL_PROPRIETARY_MODE
#include "policy/policy_external/include/policy/policy_types.h"
#endif
@@ -964,7 +967,7 @@ TEST_F(MessageHelperTest, SendGetListOfPermissionsResponse_SUCCESS) {
ON_CALL(mock_application_manager, GetRPCService())
.WillByDefault(ReturnRef(mock_rpc_service_));
- EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_))
+ EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _))
.WillOnce(DoAll(SaveArg<0>(&result), Return(true)));
const uint32_t correlation_id = 0u;
@@ -1004,7 +1007,7 @@ TEST_F(MessageHelperTest,
ON_CALL(mock_application_manager, GetRPCService())
.WillByDefault(ReturnRef(mock_rpc_service_));
- EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_))
+ EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _))
.WillOnce(DoAll(SaveArg<0>(&result), Return(true)));
const uint32_t correlation_id = 0u;
@@ -1050,7 +1053,7 @@ TEST_F(MessageHelperTest, SendNaviSetVideoConfigRequest) {
smart_objects::SmartObjectSPtr result;
ON_CALL(mock_application_manager, GetRPCService())
.WillByDefault(ReturnRef(mock_rpc_service_));
- EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_))
+ EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _))
.WillOnce(DoAll(SaveArg<0>(&result), Return(true)));
int32_t app_id = 123;
diff --git a/src/components/application_manager/test/mock_message_helper.cc b/src/components/application_manager/test/mock_message_helper.cc
index f091e183dc..518761c315 100644
--- a/src/components/application_manager/test/mock_message_helper.cc
+++ b/src/components/application_manager/test/mock_message_helper.cc
@@ -277,6 +277,12 @@ hmi_apis::Common_Language::eType MessageHelper::CommonLanguageFromString(
language);
}
+hmi_apis::Common_LightName::eType MessageHelper::CommonLightNameFromString(
+ const std::string& lightName) {
+ return MockMessageHelper::message_helper_mock()->CommonLightNameFromString(
+ lightName);
+}
+
smart_objects::SmartObjectSPtr MessageHelper::CreateModuleInfoSO(
uint32_t function_id, ApplicationManager& app_mngr) {
return MockMessageHelper::message_helper_mock()->CreateModuleInfoSO(
@@ -572,4 +578,15 @@ void MessageHelper::SendUnsubscribeButtonNotification(
->SendUnsubscribeButtonNotification(button, application, app_mngr);
}
+smart_objects::SmartObject MessageHelper::CreateAppServiceCapabilities(
+ std::vector<smart_objects::SmartObject>& all_services) {
+ return MockMessageHelper::message_helper_mock()->CreateAppServiceCapabilities(
+ all_services);
+}
+
+void MessageHelper::BroadcastCapabilityUpdate(
+ smart_objects::SmartObject& msg_params, ApplicationManager& app_mngr) {
+ MockMessageHelper::message_helper_mock()->BroadcastCapabilityUpdate(
+ msg_params, app_mngr);
+}
} // namespace application_manager
diff --git a/src/components/application_manager/test/policy_handler_test.cc b/src/components/application_manager/test/policy_handler_test.cc
index a1471eff36..af21a705bf 100644
--- a/src/components/application_manager/test/policy_handler_test.cc
+++ b/src/components/application_manager/test/policy_handler_test.cc
@@ -81,15 +81,13 @@ using namespace application_manager;
using namespace policy;
using namespace utils::custom_string;
using testing::_;
+using ::testing::DoAll;
using ::testing::Mock;
+using ::testing::NiceMock;
using ::testing::Return;
using ::testing::ReturnRef;
-using ::testing::NiceMock;
-using ::testing::SetArgReferee;
using ::testing::SetArgPointee;
-using ::testing::DoAll;
using ::testing::SetArgReferee;
-using ::testing::Mock;
typedef NiceMock<application_manager_test::MockRPCService> MockRPCService;
@@ -380,6 +378,70 @@ TEST_F(PolicyHandlerTest, ClearUserConsent) {
policy_handler_.ClearUserConsent();
}
+TEST_F(PolicyHandlerTest, AppServiceUpdate_CheckAppService) {
+ // Arrange
+ EnablePolicy();
+ EXPECT_TRUE(policy_handler_.LoadPolicyLibrary());
+ // Check
+ EXPECT_TRUE(policy_handler_.InitPolicyTable());
+ ChangePolicyManagerToMock();
+ std::string file_name("sdl_pt_update.json");
+ std::ifstream ifile(file_name);
+ Json::Reader reader;
+ std::string json;
+ Json::Value root(Json::objectValue);
+ if (ifile.is_open() && reader.parse(ifile, root, true)) {
+ json = root.toStyledString();
+ }
+ ifile.close();
+ BinaryMessage msg(json.begin(), json.end());
+ // Checks
+ EXPECT_CALL(*mock_policy_manager_, LoadPT("", msg)).WillOnce(Return(true));
+ policy_handler_.ReceiveMessageFromSDK("", msg);
+
+ policy_table::AppServiceParameters app_service_params =
+ policy_table::AppServiceParameters();
+ std::string kServiceType = "MEDIA";
+ std::string as_app_id = "1010101010";
+ std::string service_name1 = "SDL Music";
+ std::string service_name2 = "SDL App";
+ (app_service_params)[kServiceType] = policy_table::AppServiceInfo();
+ (app_service_params)[kServiceType].service_names->push_back(service_name2);
+ (app_service_params)[kServiceType].service_names->push_back(service_name1);
+ (app_service_params)[kServiceType].service_names->mark_initialized();
+ policy_table::AppServiceHandledRpc handled_rpc;
+ handled_rpc.function_id = 41;
+ (app_service_params)[kServiceType].handled_rpcs.push_back(handled_rpc);
+ EXPECT_CALL(*mock_policy_manager_, GetAppServiceParameters(_, _))
+ .WillRepeatedly(SetArgPointee<1>(app_service_params));
+
+ ns_smart_device_link::ns_smart_objects::SmartArray requested_handled_rpcs;
+ ns_smart_device_link::ns_smart_objects::SmartObject rpc_id(41);
+ requested_handled_rpcs.push_back(rpc_id);
+
+ ns_smart_device_link::ns_smart_objects::SmartArray fake_handled_rpcs;
+ ns_smart_device_link::ns_smart_objects::SmartObject fake_rpc_id(40);
+ fake_handled_rpcs.push_back(fake_rpc_id);
+
+ EXPECT_TRUE(policy_handler_.CheckAppServiceParameters(
+ as_app_id, service_name1, kServiceType, &requested_handled_rpcs));
+ EXPECT_TRUE(policy_handler_.CheckAppServiceParameters(
+ as_app_id, service_name2, kServiceType, &requested_handled_rpcs));
+ EXPECT_TRUE(policy_handler_.CheckAppServiceParameters(
+ as_app_id, service_name2, kServiceType, NULL));
+ EXPECT_TRUE(policy_handler_.CheckAppServiceParameters(
+ as_app_id, "", kServiceType, NULL));
+
+ EXPECT_FALSE(
+ policy_handler_.CheckAppServiceParameters(as_app_id, "", "", NULL));
+ EXPECT_FALSE(policy_handler_.CheckAppServiceParameters(
+ as_app_id, service_name2, "NAVIGATION", &requested_handled_rpcs));
+ EXPECT_FALSE(policy_handler_.CheckAppServiceParameters(
+ as_app_id, "MUSIC", kServiceType, &requested_handled_rpcs));
+ EXPECT_FALSE(policy_handler_.CheckAppServiceParameters(
+ as_app_id, service_name2, kServiceType, &fake_handled_rpcs));
+}
+
TEST_F(PolicyHandlerTest, ReceiveMessageFromSDK) {
// Arrange
EnablePolicy();
@@ -2536,6 +2598,104 @@ TEST_F(PolicyHandlerTest, RemoteAppsUrl_SUCCESS) {
EXPECT_EQ(url, policy_handler_.RemoteAppsUrl());
}
+TEST_F(PolicyHandlerTest, OnSetCloudAppProperties_AllProperties_SUCCESS) {
+ EnablePolicyAndPolicyManagerMock();
+
+ bool enabled = true;
+ std::string app_name = "anAppName";
+ std::string auth_token = "anAuthToken";
+ std::string cloud_transport_type = "aTransportType";
+ mobile_apis::HybridAppPreference::eType hybrid_app_preference =
+ mobile_apis::HybridAppPreference::CLOUD;
+ std::string hybrid_app_preference_str = "CLOUD";
+ std::string endpoint = "anEndpoint";
+
+ StringArray nicknames_vec;
+ nicknames_vec.push_back(app_name);
+
+ smart_objects::SmartObject message(smart_objects::SmartType_Map);
+ smart_objects::SmartObject properties(smart_objects::SmartType_Map);
+ smart_objects::SmartObject nicknames(smart_objects::SmartType_Array);
+
+ properties[strings::app_id] = kPolicyAppId_;
+ nicknames[0] = app_name;
+ properties[strings::nicknames] = nicknames;
+ properties[strings::enabled] = enabled;
+ properties[strings::auth_token] = auth_token;
+ properties[strings::cloud_transport_type] = cloud_transport_type;
+ properties[strings::hybrid_app_preference] = hybrid_app_preference;
+ properties[strings::endpoint] = endpoint;
+ message[strings::msg_params][strings::properties] = properties;
+
+ application_manager_test::MockPolicyHandlerObserver policy_handler_observer;
+ policy_handler_.add_listener(&policy_handler_observer);
+
+ EXPECT_CALL(*mock_policy_manager_, InitCloudApp(kPolicyAppId_));
+ EXPECT_CALL(*mock_policy_manager_,
+ SetCloudAppEnabled(kPolicyAppId_, enabled));
+ EXPECT_CALL(*mock_policy_manager_,
+ SetAppNicknames(kPolicyAppId_, nicknames_vec));
+ EXPECT_CALL(*mock_policy_manager_,
+ SetAppAuthToken(kPolicyAppId_, auth_token));
+ EXPECT_CALL(*mock_policy_manager_,
+ SetAppCloudTransportType(kPolicyAppId_, cloud_transport_type));
+ EXPECT_CALL(*mock_policy_manager_,
+ SetHybridAppPreference(kPolicyAppId_, hybrid_app_preference_str));
+ EXPECT_CALL(*mock_policy_manager_, SetAppEndpoint(kPolicyAppId_, endpoint));
+ EXPECT_CALL(*mock_policy_manager_,
+ GetCloudAppParameters(kPolicyAppId_, _, _, _, _, _, _))
+ .WillOnce(DoAll(SetArgReferee<4>(auth_token), Return(true)));
+ EXPECT_CALL(app_manager_, RefreshCloudAppInformation());
+ EXPECT_CALL(policy_handler_observer,
+ OnAuthTokenUpdated(kPolicyAppId_, auth_token));
+
+ policy_handler_.OnSetCloudAppProperties(message);
+}
+
+TEST_F(PolicyHandlerTest, GetCloudAppParameters_AllProperties_SUCCESS) {
+ EnablePolicyAndPolicyManagerMock();
+
+ bool enabled = true;
+ std::string certificate = "aCertificate";
+ std::string auth_token = "anAuthToken";
+ std::string cloud_transport_type = "aTransportType";
+ std::string hybrid_app_preference_str = "CLOUD";
+ std::string endpoint = "anEndpoint";
+
+ application_manager_test::MockPolicyHandlerObserver policy_handler_observer;
+ policy_handler_.add_listener(&policy_handler_observer);
+
+ EXPECT_CALL(*mock_policy_manager_,
+ GetCloudAppParameters(kPolicyAppId_, _, _, _, _, _, _))
+ .WillOnce(DoAll(SetArgReferee<1>(enabled),
+ SetArgReferee<2>(endpoint),
+ SetArgReferee<3>(certificate),
+ SetArgReferee<4>(auth_token),
+ SetArgReferee<5>(cloud_transport_type),
+ SetArgReferee<6>(hybrid_app_preference_str),
+ Return(true)));
+
+ bool enabled_out;
+ std::string endpoint_out;
+ std::string cert_out;
+ std::string auth_token_out;
+ std::string ctt_out;
+ std::string hap_out;
+ EXPECT_TRUE(policy_handler_.GetCloudAppParameters(kPolicyAppId_,
+ enabled_out,
+ endpoint_out,
+ cert_out,
+ auth_token_out,
+ ctt_out,
+ hap_out));
+ EXPECT_EQ(enabled, enabled_out);
+ EXPECT_EQ(endpoint, endpoint_out);
+ EXPECT_EQ(certificate, cert_out);
+ EXPECT_EQ(auth_token, auth_token_out);
+ EXPECT_EQ(cloud_transport_type, ctt_out);
+ EXPECT_EQ(hybrid_app_preference_str, hap_out);
+}
+
} // namespace policy_handler_test
} // namespace components
} // namespace test
diff --git a/src/components/application_manager/test/resumption/resume_ctrl_test.cc b/src/components/application_manager/test/resumption/resume_ctrl_test.cc
index 1c2339096c..2413421c7f 100644
--- a/src/components/application_manager/test/resumption/resume_ctrl_test.cc
+++ b/src/components/application_manager/test/resumption/resume_ctrl_test.cc
@@ -153,6 +153,7 @@ class ResumeCtrlTest : public ::testing::Test {
ON_CALL(*mock_app_, mac_address()).WillByDefault(ReturnRef(kMacAddress_));
ON_CALL(*mock_app_, device()).WillByDefault(Return(kTestDevId_));
ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kTestAppId_));
+ ON_CALL(*mock_app_, is_cloud_app()).WillByDefault(Return(false));
}
NiceMock<event_engine_test::MockEventDispatcher> mock_event_dispatcher_;
diff --git a/src/components/application_manager/test/sdl_preloaded_pt.json b/src/components/application_manager/test/sdl_preloaded_pt.json
index 59e3f947c3..ad264c8518 100644
--- a/src/components/application_manager/test/sdl_preloaded_pt.json
+++ b/src/components/application_manager/test/sdl_preloaded_pt.json
@@ -363,6 +363,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -383,6 +384,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -403,6 +405,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"]
@@ -422,6 +425,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"]
diff --git a/src/components/application_manager/test/sdl_pt_update.json b/src/components/application_manager/test/sdl_pt_update.json
index 23c75e8475..aea3f7700b 100644
--- a/src/components/application_manager/test/sdl_pt_update.json
+++ b/src/components/application_manager/test/sdl_pt_update.json
@@ -20,7 +20,13 @@
"nicknames" : [ "SyncProxyTester" ],
"priority" : "EMERGENCY",
"steal_focus" : true,
- "watchdog_timer_ms" : 20000
+ "watchdog_timer_ms" : 20000,
+ "app_services": {
+ "MEDIA": {
+ "service_names" : ["SDL App", "SDL Music"],
+ "handled_rpcs" : [{"function_id": 41}]
+ }
+ }
},
"default" : {
"default_hmi" : "NONE",
@@ -1600,6 +1606,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -1618,6 +1625,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"vin",
@@ -1636,6 +1644,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"
@@ -1653,6 +1662,7 @@
"headLampStatus",
"instantFuelConsumption",
"fuelRange",
+ "cloudAppVehicleID",
"odometer",
"tirePressure",
"wiperStatus"
diff --git a/src/components/application_manager/test/state_controller/state_controller_test.cc b/src/components/application_manager/test/state_controller/state_controller_test.cc
index 1d4cead52b..9574f8d00f 100644
--- a/src/components/application_manager/test/state_controller/state_controller_test.cc
+++ b/src/components/application_manager/test/state_controller/state_controller_test.cc
@@ -170,34 +170,42 @@ class StateControllerImplTest : public ::testing::Test {
am::ApplicationSharedPtr simple_app_;
NiceMock<application_manager_test::MockApplication>* simple_app_ptr_;
uint32_t simple_app_id_ = 1721;
+ uint32_t simple_hmi_app_id_ = 22770; // random number
am::ApplicationSharedPtr navi_app_;
NiceMock<application_manager_test::MockApplication>* navi_app_ptr_;
uint32_t navi_app_id_ = 1762;
+ uint32_t navi_hmi_app_id_ = 17559;
am::ApplicationSharedPtr media_app_;
NiceMock<application_manager_test::MockApplication>* media_app_ptr_;
uint32_t media_app_id_ = 1801;
+ uint32_t media_hmi_app_id_ = 12751;
am::ApplicationSharedPtr vc_app_;
NiceMock<application_manager_test::MockApplication>* vc_app_ptr_;
uint32_t vc_app_id_ = 1825;
+ uint32_t vc_hmi_app_id_ = 14986;
am::ApplicationSharedPtr media_navi_app_;
NiceMock<application_manager_test::MockApplication>* media_navi_app_ptr_;
uint32_t media_navi_app_id_ = 1855;
+ uint32_t media_navi_hmi_app_id_ = 16194;
am::ApplicationSharedPtr media_vc_app_;
NiceMock<application_manager_test::MockApplication>* media_vc_app_ptr_;
uint32_t media_vc_app_id_ = 1881;
+ uint32_t media_vc_hmi_app_id_ = 12798;
am::ApplicationSharedPtr navi_vc_app_;
NiceMock<application_manager_test::MockApplication>* navi_vc_app_ptr_;
uint32_t navi_vc_app_id_ = 1894;
+ uint32_t navi_vc_hmi_app_id_ = 10807;
am::ApplicationSharedPtr media_navi_vc_app_;
NiceMock<application_manager_test::MockApplication>* media_navi_vc_app_ptr_;
uint32_t media_navi_vc_app_id_ = 1922;
+ uint32_t media_navi_vc_hmi_app_id_ = 21419;
std::vector<am::HmiStatePtr> valid_states_for_audio_app_;
std::vector<am::HmiStatePtr> valid_states_for_not_audio_app_;
@@ -661,6 +669,7 @@ class StateControllerImplTest : public ::testing::Test {
am::ApplicationSharedPtr ConfigureApp(
NiceMock<application_manager_test::MockApplication>** app_mock,
uint32_t app_id,
+ uint32_t hmi_app_id,
bool media,
bool navi,
bool vc) {
@@ -670,6 +679,7 @@ class StateControllerImplTest : public ::testing::Test {
am::ApplicationSharedPtr app(*app_mock);
ON_CALL(**app_mock, app_id()).WillByDefault(Return(app_id));
+ ON_CALL(**app_mock, hmi_app_id()).WillByDefault(Return(hmi_app_id));
ON_CALL(**app_mock, is_media_application()).WillByDefault(Return(media));
ON_CALL(**app_mock, is_navi()).WillByDefault(Return(navi));
ON_CALL(**app_mock, is_voice_communication_supported())
@@ -871,21 +881,50 @@ class StateControllerImplTest : public ::testing::Test {
}
void ConfigureApps() {
- simple_app_ = ConfigureApp(
- &simple_app_ptr_, simple_app_id_, NOT_MEDIA, NOT_NAVI, NOT_VC);
- media_app_ =
- ConfigureApp(&media_app_ptr_, media_app_id_, MEDIA, NOT_NAVI, NOT_VC);
- navi_app_ =
- ConfigureApp(&navi_app_ptr_, navi_app_id_, NOT_MEDIA, NAVI, NOT_VC);
- vc_app_ = ConfigureApp(&vc_app_ptr_, vc_app_id_, NOT_MEDIA, NOT_NAVI, VC);
- media_navi_app_ = ConfigureApp(
- &media_navi_app_ptr_, media_navi_app_id_, MEDIA, NAVI, NOT_VC);
- media_vc_app_ =
- ConfigureApp(&media_vc_app_ptr_, media_vc_app_id_, MEDIA, NOT_NAVI, VC);
- navi_vc_app_ =
- ConfigureApp(&navi_vc_app_ptr_, navi_vc_app_id_, NOT_MEDIA, NAVI, VC);
- media_navi_vc_app_ = ConfigureApp(
- &media_navi_vc_app_ptr_, media_navi_vc_app_id_, MEDIA, NAVI, VC);
+ simple_app_ = ConfigureApp(&simple_app_ptr_,
+ simple_app_id_,
+ simple_hmi_app_id_,
+ NOT_MEDIA,
+ NOT_NAVI,
+ NOT_VC);
+ media_app_ = ConfigureApp(&media_app_ptr_,
+ media_app_id_,
+ media_hmi_app_id_,
+ MEDIA,
+ NOT_NAVI,
+ NOT_VC);
+ navi_app_ = ConfigureApp(&navi_app_ptr_,
+ navi_app_id_,
+ navi_hmi_app_id_,
+ NOT_MEDIA,
+ NAVI,
+ NOT_VC);
+ vc_app_ = ConfigureApp(
+ &vc_app_ptr_, vc_app_id_, vc_hmi_app_id_, NOT_MEDIA, NOT_NAVI, VC);
+ media_navi_app_ = ConfigureApp(&media_navi_app_ptr_,
+ media_navi_app_id_,
+ media_navi_hmi_app_id_,
+ MEDIA,
+ NAVI,
+ NOT_VC);
+ media_vc_app_ = ConfigureApp(&media_vc_app_ptr_,
+ media_vc_app_id_,
+ media_vc_hmi_app_id_,
+ MEDIA,
+ NOT_NAVI,
+ VC);
+ navi_vc_app_ = ConfigureApp(&navi_vc_app_ptr_,
+ navi_vc_app_id_,
+ navi_vc_hmi_app_id_,
+ NOT_MEDIA,
+ NAVI,
+ VC);
+ media_navi_vc_app_ = ConfigureApp(&media_navi_vc_app_ptr_,
+ media_navi_vc_app_id_,
+ media_navi_vc_hmi_app_id_,
+ MEDIA,
+ NAVI,
+ VC);
applications_list_.push_back(simple_app_);
applications_list_.push_back(media_app_);
applications_list_.push_back(navi_app_);
@@ -914,6 +953,15 @@ class StateControllerImplTest : public ::testing::Test {
ASSERT_EQ(navi_vc_app_->app_id(), navi_vc_app_id_);
ASSERT_EQ(media_navi_vc_app_->app_id(), media_navi_vc_app_id_);
+ ASSERT_EQ(simple_app_->hmi_app_id(), simple_hmi_app_id_);
+ ASSERT_EQ(media_app_->hmi_app_id(), media_hmi_app_id_);
+ ASSERT_EQ(navi_app_->hmi_app_id(), navi_hmi_app_id_);
+ ASSERT_EQ(vc_app_->hmi_app_id(), vc_hmi_app_id_);
+ ASSERT_EQ(media_navi_app_->hmi_app_id(), media_navi_hmi_app_id_);
+ ASSERT_EQ(media_vc_app_->hmi_app_id(), media_vc_hmi_app_id_);
+ ASSERT_EQ(navi_vc_app_->hmi_app_id(), navi_vc_hmi_app_id_);
+ ASSERT_EQ(media_navi_vc_app_->hmi_app_id(), media_navi_vc_hmi_app_id_);
+
ASSERT_FALSE(simple_app_->IsAudioApplication());
ASSERT_TRUE(media_app_->IsAudioApplication());
ASSERT_TRUE(navi_app_->IsAudioApplication());
@@ -992,7 +1040,7 @@ class StateControllerImplTest : public ::testing::Test {
.WillByDefault(Return(bc_activate_app_request));
ON_CALL(app_manager_mock_, GetRPCService())
.WillByDefault(ReturnRef(mock_rpc_service_));
- ON_CALL(mock_rpc_service_, ManageHMICommand(bc_activate_app_request))
+ ON_CALL(mock_rpc_service_, ManageHMICommand(bc_activate_app_request, _))
.WillByDefault(Return(true));
}
@@ -1040,6 +1088,8 @@ class StateControllerImplTest : public ::testing::Test {
application_set_.insert(app);
ON_CALL(app_manager_mock_, application(app->app_id()))
.WillByDefault(Return(app));
+ ON_CALL(app_manager_mock_, application_by_hmi_app(app->hmi_app_id()))
+ .WillByDefault(Return(app));
}
am::HmiStatePtr NoneNotAudibleState() {
@@ -1475,9 +1525,9 @@ TEST_F(StateControllerImplTest,
NiceMock<application_manager_test::MockApplication>* app_moved_to_full_mock;
app_in_full =
- ConfigureApp(&app_in_full_mock, 1761, NOT_MEDIA, NOT_NAVI, NOT_VC);
- app_moved_to_full =
- ConfigureApp(&app_moved_to_full_mock, 1796, NOT_MEDIA, NOT_NAVI, NOT_VC);
+ ConfigureApp(&app_in_full_mock, 1761, 15685, NOT_MEDIA, NOT_NAVI, NOT_VC);
+ app_moved_to_full = ConfigureApp(
+ &app_moved_to_full_mock, 1796, 30093, NOT_MEDIA, NOT_NAVI, NOT_VC);
InsertApplication(app_in_full);
InsertApplication(app_moved_to_full);
@@ -1549,11 +1599,11 @@ TEST_F(StateControllerImplTest,
namespace SystemContext = mobile_apis::SystemContext;
NiceMock<application_manager_test::MockApplication>* app_in_full_mock;
am::ApplicationSharedPtr app_in_full =
- ConfigureApp(&app_in_full_mock, 1761, MEDIA, NOT_NAVI, NOT_VC);
+ ConfigureApp(&app_in_full_mock, 1761, 15685, MEDIA, NOT_NAVI, NOT_VC);
NiceMock<application_manager_test::MockApplication>* app_moved_to_full_mock;
- am::ApplicationSharedPtr app_moved_to_full =
- ConfigureApp(&app_moved_to_full_mock, 1796, MEDIA, NOT_NAVI, NOT_VC);
+ am::ApplicationSharedPtr app_moved_to_full = ConfigureApp(
+ &app_moved_to_full_mock, 1796, 30093, MEDIA, NOT_NAVI, NOT_VC);
InsertApplication(app_in_full);
InsertApplication(app_moved_to_full);
@@ -1575,11 +1625,11 @@ TEST_F(StateControllerImplTest,
NiceMock<application_manager_test::MockApplication>* app_in_limited_mock;
am::ApplicationSharedPtr app_in_limited =
- ConfigureApp(&app_in_limited_mock, 1761, NOT_MEDIA, NAVI, NOT_VC);
+ ConfigureApp(&app_in_limited_mock, 1761, 15685, NOT_MEDIA, NAVI, NOT_VC);
NiceMock<application_manager_test::MockApplication>* app_moved_to_full_mock;
am::ApplicationSharedPtr app_moved_to_full =
- ConfigureApp(&app_moved_to_full_mock, 1796, NOT_MEDIA, NAVI, VC);
+ ConfigureApp(&app_moved_to_full_mock, 1796, 30093, NOT_MEDIA, NAVI, VC);
InsertApplication(app_in_limited);
InsertApplication(app_moved_to_full);
@@ -1600,12 +1650,12 @@ TEST_F(StateControllerImplTest,
namespace SystemContext = mobile_apis::SystemContext;
NiceMock<application_manager_test::MockApplication>* app_in_limited_mock;
am::ApplicationSharedPtr app_in_limited =
- ConfigureApp(&app_in_limited_mock, 1761, NOT_MEDIA, NOT_NAVI, VC);
+ ConfigureApp(&app_in_limited_mock, 1761, 15685, NOT_MEDIA, NOT_NAVI, VC);
NiceMock<application_manager_test::MockApplication>*
app_moved_to_limited_mock;
- am::ApplicationSharedPtr app_moved_to_limited =
- ConfigureApp(&app_moved_to_limited_mock, 1796, NOT_MEDIA, NOT_NAVI, VC);
+ am::ApplicationSharedPtr app_moved_to_limited = ConfigureApp(
+ &app_moved_to_limited_mock, 1796, 30093, NOT_MEDIA, NOT_NAVI, VC);
InsertApplication(app_in_limited);
InsertApplication(app_moved_to_limited);
@@ -1749,8 +1799,8 @@ TEST_F(StateControllerImplTest,
namespace SystemContext = mobile_apis::SystemContext;
NiceMock<application_manager_test::MockApplication>* app_moved_to_full_mock;
- am::ApplicationSharedPtr app_moved_to_full =
- ConfigureApp(&app_moved_to_full_mock, 1761, NOT_MEDIA, NOT_NAVI, NOT_VC);
+ am::ApplicationSharedPtr app_moved_to_full = ConfigureApp(
+ &app_moved_to_full_mock, 1761, 15685, NOT_MEDIA, NOT_NAVI, NOT_VC);
am::ApplicationSharedPtr limited_app = media_app_;
NiceMock<application_manager_test::MockApplication>* limited_app_mock =
@@ -1758,7 +1808,7 @@ TEST_F(StateControllerImplTest,
NiceMock<application_manager_test::MockApplication>* full_app_mock;
am::ApplicationSharedPtr full_app =
- ConfigureApp(&full_app_mock, 1796, NOT_MEDIA, NOT_NAVI, NOT_VC);
+ ConfigureApp(&full_app_mock, 1796, 30093, NOT_MEDIA, NOT_NAVI, NOT_VC);
InsertApplication(app_moved_to_full);
InsertApplication(limited_app);
@@ -1786,16 +1836,16 @@ TEST_F(
namespace SystemContext = mobile_apis::SystemContext;
NiceMock<application_manager_test::MockApplication>* app_moved_to_full_mock;
- am::ApplicationSharedPtr app_moved_to_full =
- ConfigureApp(&app_moved_to_full_mock, 1761, MEDIA, NOT_NAVI, NOT_VC);
+ am::ApplicationSharedPtr app_moved_to_full = ConfigureApp(
+ &app_moved_to_full_mock, 1761, 15685, MEDIA, NOT_NAVI, NOT_VC);
NiceMock<application_manager_test::MockApplication>* limited_app_mock;
am::ApplicationSharedPtr limited_app =
- ConfigureApp(&limited_app_mock, 1762, MEDIA, NOT_NAVI, NOT_VC);
+ ConfigureApp(&limited_app_mock, 1762, 17559, MEDIA, NOT_NAVI, NOT_VC);
NiceMock<application_manager_test::MockApplication>* full_app_mock;
am::ApplicationSharedPtr full_app =
- ConfigureApp(&full_app_mock, 1796, NOT_MEDIA, NOT_NAVI, NOT_VC);
+ ConfigureApp(&full_app_mock, 1796, 30093, NOT_MEDIA, NOT_NAVI, NOT_VC);
InsertApplication(app_moved_to_full);
InsertApplication(limited_app);
@@ -1823,16 +1873,16 @@ TEST_F(
namespace SystemContext = mobile_apis::SystemContext;
NiceMock<application_manager_test::MockApplication>* app_moved_to_full_mock;
- am::ApplicationSharedPtr app_moved_to_full =
- ConfigureApp(&app_moved_to_full_mock, 1761, MEDIA, NOT_NAVI, NOT_VC);
+ am::ApplicationSharedPtr app_moved_to_full = ConfigureApp(
+ &app_moved_to_full_mock, 1761, 15685, MEDIA, NOT_NAVI, NOT_VC);
NiceMock<application_manager_test::MockApplication>* limited_app_mock;
am::ApplicationSharedPtr limited_app =
- ConfigureApp(&limited_app_mock, 1762, MEDIA, NOT_NAVI, NOT_VC);
+ ConfigureApp(&limited_app_mock, 1762, 17559, MEDIA, NOT_NAVI, NOT_VC);
NiceMock<application_manager_test::MockApplication>* full_app_mock;
am::ApplicationSharedPtr full_app =
- ConfigureApp(&full_app_mock, 1796, NOT_MEDIA, NAVI, NOT_VC);
+ ConfigureApp(&full_app_mock, 1796, 30093, NOT_MEDIA, NAVI, NOT_VC);
InsertApplication(app_moved_to_full);
InsertApplication(limited_app);
@@ -1941,7 +1991,7 @@ TEST_F(StateControllerImplTest, DISABLED_ActivateAppSuccessReceivedFromHMI) {
SetBCActivateAppRequestToHMI(hmi_level, corr_id);
ON_CALL(app_manager_mock_, GetRPCService())
.WillByDefault(ReturnRef(mock_rpc_service_));
- ON_CALL(mock_rpc_service_, ManageHMICommand(bc_activate_app_request))
+ ON_CALL(mock_rpc_service_, ManageHMICommand(bc_activate_app_request, _))
.WillByDefault(Return(true));
EXPECT_CALL(app_manager_mock_, application_id(corr_id))
@@ -2845,14 +2895,7 @@ TEST_F(StateControllerImplTest,
am::event_engine::Event event(event_id);
event.set_smart_object(msg);
- const HmiStatePtr state =
- createHmiState(mobile_apis::HMILevel::HMI_FULL,
- mobile_apis::AudioStreamingState::AUDIBLE,
- mobile_apis::VideoStreamingState::NOT_STREAMABLE,
- mobile_apis::SystemContext::SYSCTXT_MAIN);
-
EXPECT_CALL(*simple_app_ptr_, keep_context()).WillOnce(Return(true));
- EXPECT_CALL(*simple_app_ptr_, RegularHmiState()).WillOnce(Return(state));
EXPECT_CALL(*simple_app_ptr_, IsAudioApplication())
.WillRepeatedly(Return(true));
EXPECT_CALL(*simple_app_ptr_, CurrentHmiState())
@@ -2884,12 +2927,6 @@ TEST_F(StateControllerImplTest, OnEventChangedAudioSourceAppToBackground) {
am::event_engine::Event event(event_id);
event.set_smart_object(msg);
- const HmiStatePtr state =
- createHmiState(mobile_apis::HMILevel::HMI_LIMITED,
- mobile_apis::AudioStreamingState::AUDIBLE,
- mobile_apis::VideoStreamingState::NOT_STREAMABLE,
- mobile_apis::SystemContext::SYSCTXT_MAIN);
- EXPECT_CALL(*simple_app_ptr_, RegularHmiState()).WillOnce(Return(state));
EXPECT_CALL(*simple_app_ptr_, IsAudioApplication())
.WillRepeatedly(Return(true));
EXPECT_CALL(*simple_app_ptr_, CurrentHmiState())