summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Kutsan <AKutsan@luxoft.com>2016-01-14 17:13:08 +0200
committerAlexander Kutsan <AKutsan@luxoft.com>2016-01-19 11:40:44 +0200
commit7cd8b4faecb78a2b2f4d05ce481e408ee4827420 (patch)
tree485874e3859ac5eb79b026dc253563429fabb394
parent787cba7d339f4ed46395355f3c978f4c5198ea41 (diff)
downloadsdl_core-7cd8b4faecb78a2b2f4d05ce481e408ee4827420.tar.gz
Extract MessageHelper to separate library
For testing parts of ApplicationManager it is nessesary to mock static functions of MessageHelper. But to mock static fuctions of MessageHelper and avoid double definition it is nessesary to extract MessageHelper implementation from ApplicationManager library to separate library and link it if needed.
-rw-r--r--src/appMain/CMakeLists.txt1
-rw-r--r--src/components/application_manager/CMakeLists.txt6
-rw-r--r--src/components/application_manager/src/message_helper/message_helper.cc (renamed from src/components/application_manager/src/message_helper.cc)0
-rw-r--r--src/components/application_manager/test/mock_message_helper.cc5
-rw-r--r--src/components/application_manager/test/mock_message_helper.h6
-rw-r--r--src/components/application_manager/test/state_controller/CMakeLists.txt1
-rw-r--r--src/components/application_manager/test/state_controller/state_controller_test.cc20
-rw-r--r--src/components/media_manager/test/CMakeLists.txt1
-rw-r--r--src/components/time_tester/test/CMakeLists.txt1
9 files changed, 26 insertions, 15 deletions
diff --git a/src/appMain/CMakeLists.txt b/src/appMain/CMakeLists.txt
index 742bd46a96..f82f6563ae 100644
--- a/src/appMain/CMakeLists.txt
+++ b/src/appMain/CMakeLists.txt
@@ -59,6 +59,7 @@ endif()
set(LIBRARIES
MediaManager
ApplicationManager
+ MessageHelperLibrary
HMI_API
MOBILE_API
v4_protocol_v1_2_no_extra
diff --git a/src/components/application_manager/CMakeLists.txt b/src/components/application_manager/CMakeLists.txt
index 04ea17ada6..a2b0dd6fb8 100644
--- a/src/components/application_manager/CMakeLists.txt
+++ b/src/components/application_manager/CMakeLists.txt
@@ -75,6 +75,10 @@ file (GLOB SOURCES
${AM_SOURCE_DIR}/src/*
)
+set (MESSAGE_HELPER_SOURCES
+ ${AM_SOURCE_DIR}/src/message_helper/message_helper.cc
+)
+
set (POLICIES_MANAGER
${AM_SOURCE_DIR}/src/policies/policy_handler.cc
${AM_SOURCE_DIR}/src/policies/policy_event_observer.cc
@@ -369,6 +373,8 @@ target_link_libraries("AMPolicyLibrary" ${LIBRARIES} AMEventEngine)
add_library("AMHMICommandsLibrary" ${HMI_COMMANDS_SOURCES})
target_link_libraries("AMHMICommandsLibrary" ${LIBRARIES} AMEventEngine)
+add_library("MessageHelperLibrary" ${MESSAGE_HELPER_SOURCES})
+
add_library("AMMobileCommandsLibrary" ${MOBILE_COMMANDS_SOURCES} )
target_link_libraries("AMMobileCommandsLibrary" ${LIBRARIES} AMEventEngine)
diff --git a/src/components/application_manager/src/message_helper.cc b/src/components/application_manager/src/message_helper/message_helper.cc
index 4475a57171..4475a57171 100644
--- a/src/components/application_manager/src/message_helper.cc
+++ b/src/components/application_manager/src/message_helper/message_helper.cc
diff --git a/src/components/application_manager/test/mock_message_helper.cc b/src/components/application_manager/test/mock_message_helper.cc
index c8de9821a7..82c17a0eb1 100644
--- a/src/components/application_manager/test/mock_message_helper.cc
+++ b/src/components/application_manager/test/mock_message_helper.cc
@@ -217,11 +217,6 @@ void MessageHelper::SendUpdateSDLResponse(const std::string& result,
result, correlation_id);
}
-void MessageHelper::SendDecryptCertificateToHMI(const std::string& file_name) {
- MockMessageHelper::message_helper_mock()->SendDecryptCertificateToHMI(
- file_name);
-}
-
hmi_apis::Common_Language::eType MessageHelper::CommonLanguageFromString(
const std::string& language) {
return MockMessageHelper::message_helper_mock()->CommonLanguageFromString(
diff --git a/src/components/application_manager/test/mock_message_helper.h b/src/components/application_manager/test/mock_message_helper.h
index 9d26cfaaae..1d543f9b89 100644
--- a/src/components/application_manager/test/mock_message_helper.h
+++ b/src/components/application_manager/test/mock_message_helper.h
@@ -126,6 +126,12 @@ class MockMessageHelper {
smart_objects::SmartObjectSPtr(uint32_t function_id));
MOCK_METHOD1(SendAllOnButtonSubscriptionNotificationsForApp,
void(ApplicationConstSharedPtr app));
+
+ MOCK_METHOD3(SendActivateAppToHMI,
+ uint32_t(uint32_t const app_id,
+ hmi_apis::Common_HMILevel::eType level,
+ bool send_policy_priority));
+
MOCK_METHOD1(SendOnResumeAudioSourceToHMI, void(uint32_t app_id));
MOCK_METHOD1(CreateAddSubMenuRequestToHMI,
smart_objects::SmartObjectList(ApplicationConstSharedPtr app));
diff --git a/src/components/application_manager/test/state_controller/CMakeLists.txt b/src/components/application_manager/test/state_controller/CMakeLists.txt
index 243e6218ed..305db68b9a 100644
--- a/src/components/application_manager/test/state_controller/CMakeLists.txt
+++ b/src/components/application_manager/test/state_controller/CMakeLists.txt
@@ -44,6 +44,7 @@ set(LIBRARIES
set(SOURCES
state_controller_test.cc
+ ${COMPONENTS_DIR}/application_manager/test/mock_message_helper.cc
)
create_test("state_controller_test" "${SOURCES}" "${LIBRARIES}")
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 698737ad5e..5dcf06e8b0 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
@@ -41,6 +41,7 @@
#include "utils/data_accessor.h"
#include "utils/make_shared.h"
#include "application_manager/message_helper.h"
+#include "application_manager/test/mock_message_helper.h"
#include "application_manager/event_engine/event.h"
#include "application_manager/smart_object_keys.h"
@@ -54,16 +55,15 @@ using ::testing::NiceMock;
using ::testing::InSequence;
using ::testing::Truly;
-class MessageHelperMock {
- public:
- MOCK_METHOD3(SendActivateAppToHMI,
- uint32_t(uint32_t const app_id,
- hmi_apis::Common_HMILevel::eType level,
- bool send_policy_priority));
-};
-
-static MessageHelperMock* message_helper_mock_;
+static application_manager::MockMessageHelper* message_helper_mock_;
+uint32_t application_manager::MessageHelper::SendActivateAppToHMI(
+ uint32_t const app_id,
+ hmi_apis::Common_HMILevel::eType level,
+ bool send_policy_priority) {
+ return message_helper_mock_->SendActivateAppToHMI(
+ app_id, level, send_policy_priority);
+}
namespace state_controller_test {
@@ -212,7 +212,7 @@ class StateControllerTest : public ::testing::Test {
namespace AudioStreamingState = mobile_apis::AudioStreamingState;
namespace SystemContext = mobile_apis::SystemContext;
// Valid states for not audio app
- message_helper_mock_ = new MessageHelperMock;
+ message_helper_mock_ = new application_manager::MockMessageHelper;
valid_states_for_not_audio_app_.push_back(
createHmiState(HMILevel::HMI_NONE,
AudioStreamingState::NOT_AUDIBLE,
diff --git a/src/components/media_manager/test/CMakeLists.txt b/src/components/media_manager/test/CMakeLists.txt
index 17eb178cca..f80f913638 100644
--- a/src/components/media_manager/test/CMakeLists.txt
+++ b/src/components/media_manager/test/CMakeLists.txt
@@ -50,6 +50,7 @@ set(SOURCES
set(LIBRARIES
MediaManager
ApplicationManager
+ MessageHelperLibrary
ProtocolHandler
gmock
connectionHandler
diff --git a/src/components/time_tester/test/CMakeLists.txt b/src/components/time_tester/test/CMakeLists.txt
index cdf002e227..6992d0485d 100644
--- a/src/components/time_tester/test/CMakeLists.txt
+++ b/src/components/time_tester/test/CMakeLists.txt
@@ -67,6 +67,7 @@ set(testLibraries
ConfigProfile
connectionHandler
ApplicationManager
+ MessageHelperLibrary
Resumption
jsoncpp
transport_manager