summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Jenkinsfile88
-rw-r--r--src/appMain/life_cycle.cc6
-rw-r--r--src/components/application_manager/src/message.cc45
-rw-r--r--src/components/application_manager/src/request_controller.cc10
-rw-r--r--src/components/application_manager/test/commands/mobile/alert_request_test.cc3
-rw-r--r--src/components/application_manager/test/commands/mobile/delete_sub_menu_test.cc10
-rw-r--r--src/components/application_manager/test/commands/mobile/get_way_points_request_test.cc3
-rw-r--r--src/components/application_manager/test/commands/mobile/reset_global_properties_test.cc6
-rw-r--r--src/components/application_manager/test/commands/mobile/set_display_layout_test.cc4
-rw-r--r--src/components/application_manager/test/commands/mobile/show_test.cc12
-rw-r--r--src/components/connection_handler/src/connection_handler_impl.cc4
-rw-r--r--src/components/formatters/test/meta_formatter_test.cc43
-rw-r--r--src/components/formatters/test/src/create_smartSchema.cc1
-rw-r--r--src/components/formatters/test/src/meta_formatter_test_helper.cc27
-rw-r--r--src/components/hmi_message_handler/test/hmi_message_adapter_test.cc4
-rw-r--r--src/components/hmi_message_handler/test/hmi_message_handler_impl_test.cc6
-rw-r--r--src/components/include/hmi_message_handler/hmi_message_observer.h1
-rw-r--r--src/components/include/hmi_message_handler/hmi_message_sender.h1
-rw-r--r--src/components/include/policy/policy_external/policy/usage_statistics/app_stopwatch.h8
-rw-r--r--src/components/include/policy/policy_external/policy/usage_statistics/statistics_manager.h6
-rw-r--r--src/components/include/policy/policy_regular/policy/usage_statistics/statistics_manager.h6
-rw-r--r--src/components/include/utils/custom_string.h14
-rw-r--r--src/components/media_manager/include/media_manager/media_manager_impl.h7
-rw-r--r--src/components/media_manager/src/media_manager_impl.cc8
-rw-r--r--src/components/media_manager/test/media_manager_impl_test.cc423
-rw-r--r--src/components/policy/policy_external/include/policy/cache_manager_interface.h4
-rw-r--r--src/components/policy/policy_external/test/include/policy/mock_cache_manager.h256
-rw-r--r--src/components/policy/policy_external/test/policy_manager_impl_test_base.cc2
-rw-r--r--src/components/policy/policy_regular/include/policy/policy_listener.h116
-rw-r--r--src/components/telemetry_monitor/src/telemetry_monitor.cc64
-rw-r--r--src/components/telemetry_monitor/test/telemetry_monitor_test.cc8
-rw-r--r--src/components/transport_manager/test/transport_manager_impl_test.cc8
-rw-r--r--src/components/utils/include/utils/file_system.h1
-rw-r--r--src/components/utils/include/utils/log_message_loop_thread.h2
-rw-r--r--src/components/utils/src/custom_string.cc8
-rw-r--r--src/components/utils/src/file_system.cc43
-rw-r--r--src/components/utils/src/log_message_loop_thread.cc4
-rw-r--r--src/components/utils/src/threads/thread_delegate.cc1
-rw-r--r--src/components/utils/test/async_runner_test.cc112
-rw-r--r--src/components/utils/test/conditional_variable_test.cc2
-rw-r--r--src/components/utils/test/messagemeter_test.cc10
-rw-r--r--src/components/utils/test/scope_guard_test.cc18
-rw-r--r--src/components/utils/test/shared_ptr_test.cc2
-rw-r--r--src/components/utils/test/sqlite_wrapper/sql_query_test.cc4
44 files changed, 668 insertions, 743 deletions
diff --git a/Jenkinsfile b/Jenkinsfile
new file mode 100644
index 0000000000..ad3405c0fe
--- /dev/null
+++ b/Jenkinsfile
@@ -0,0 +1,88 @@
+pipeline {
+
+ triggers
+ {
+ pollSCM('H/5 * * * *')
+ }
+
+ options
+ {
+ timeout(time: 2, unit: 'HOURS')
+ timestamps()
+ }
+
+agent { node { label 'atf_slave3' } }
+
+stages {
+ stage ("Code Style Check")
+ {
+ steps
+ {
+ sh 'bash -e tools/infrastructure/check_style.sh'
+ sh '''cppcheck --enable=all --inconclusive -i "src/3rd_party-static" -i "src/3rd_party" --xml --xml-version=2 -q src 2> cppcheck.xml'''
+ }
+ }
+
+ stage ('Build && Unit Testing')
+ {
+ steps
+ {
+ sh '''rm -rf build
+ mkdir build
+ cd build
+ export THIRD_PARTY_INSTALL_PREFIX=${WORKSPACE}/build/src/3rdparty/LINUX
+ export THIRD_PARTY_INSTALL_PREFIX_ARCH=${THIRD_PARTY_INSTALL_PREFIX}/x86
+ export LD_LIBRARY_PATH=$THIRD_PARTY_INSTALL_PREFIX_ARCH/lib
+ cmake ${WORKSPACE} -DCMAKE_BUILD_TYPE="Debug" -DBUILD_TESTS=ON -DENABLE_GCOV=ON -DREMOTE_CONTROL=ON
+ make -j6 install
+ make test | tee ut.log || true; result=${PIPESTATUS[0]};
+ if [ $result -ne 0 ]; then
+ COREFILE=$(find /tmp/corefiles -type f -name "core*");
+ echo $COREFILE;
+ grep -w "SegFault" ut.log | while read -r line; do
+ arr=($line);
+ echo ${arr[3]};
+ done > res.txt;
+ test_file=$(find ${WORKSPACE}/build/src/components/ -type f -name $(cat res.txt));
+ echo $test_file;
+ echo "Started gdb!";
+ echo thread apply all bt | gdb $test_file $COREFILE;
+ exit 1;
+ fi'''
+ junit allowEmptyResults: true, testResults: '${WORKSPACE}/build/test_results/*.xml'
+ }
+ }
+
+ stage ('Packaging')
+ {
+ steps
+ {
+ parallel(
+ Packaging:
+ {
+ sh '''cp -r ${WORKSPACE}/build/src/3rdparty/LINUX/x86/lib/. ${WORKSPACE}/build/bin/
+ mkdir ${WORKSPACE}/build/bin/api
+ cp -r ${WORKSPACE}/src/components/interfaces/. ${WORKSPACE}/build/bin/api/
+ tar -zcvf OpenSDL_${TESTS}.tar.gz bin/
+ curl -u admin:1qaz@WSX -X PUT "http://172.30.23.4:8081/artifactory/OpenSDL_${GIT_BRANCH}/${BUILD_NUMBER}/${RC}/OpenSDL_${TESTS}.tar.gz" -T OpenSDL.tar.gz'''
+ },
+ Artifacts:
+ {
+ junit allowEmptyResults: true, testResults: '${WORKSPACE}/build/test_results/*.xml'
+ })
+ }
+ }
+}
+ post {
+ success {
+ junit allowEmptyResults: true, testResults: '${WORKSPACE}/build/test_results/*.xml'
+ build job: 'RC_PULL_REQUEST/ATF_RC_SMOKE', parameters: [string(name: 'SDL_BUILD', value: '${BUILD_NUMBER}'), string(name: 'POLICY', value: 'BASE'), string(name: 'PULL_ID', value: '0'), string(name: 'TEST_SET', value: 'smoke_tests.txt'), string(name: 'BRANCH', value: 'feature/sdl_remote_control_baseline'), string(name: 'ATF_REPOSITORY', value: 'https://github.com/smartdevicelink/sdl_atf_test_scripts'), string(name: 'SDL_FOLDER', value: '${GIT_BRANCH}'), string(name: 'RC', value: '')], wait: false
+ emailext attachLog: true, body: '', recipientProviders: [[$class: 'DevelopersRecipientProvider']], replyTo: 'mailer@lc-jenkinsdockerhost.luxoft.com', subject: '', to: 'AKutsan@luxoft.com, MGhiumiusliu@luxoft.com, IIKovalenko@luxoft.com, OVVasyliev@luxoft.com'
+ }
+
+ failure {
+ junit allowEmptyResults: true, testResults: '${WORKSPACE}/build/test_results/*.xml'
+ emailext attachLog: true, body: '', recipientProviders: [[$class: 'DevelopersRecipientProvider']], replyTo: 'mailer@lc-jenkinsdockerhost.luxoft.com', subject: '', to: 'AKutsan@luxoft.com, MGhiumiusliu@luxoft.com, IIKovalenko@luxoft.com, OVVasyliev@luxoft.com'
+ }
+ }
+}
diff --git a/src/appMain/life_cycle.cc b/src/appMain/life_cycle.cc
index 9b4910585f..3bf0e62f87 100644
--- a/src/appMain/life_cycle.cc
+++ b/src/appMain/life_cycle.cc
@@ -127,6 +127,9 @@ bool LifeCycle::StartComponents() {
DCHECK(!hmi_handler_);
hmi_handler_ = new hmi_message_handler::HMIMessageHandlerImpl(profile_);
+ hmi_handler_->set_message_observer(app_manager_);
+ app_manager_->set_hmi_message_handler(hmi_handler_);
+
media_manager_ = new media_manager::MediaManagerImpl(*app_manager_, profile_);
app_manager_->set_connection_handler(connection_handler_);
if (!app_manager_->Init(*last_state_, media_manager_)) {
@@ -157,8 +160,6 @@ bool LifeCycle::StartComponents() {
transport_manager_->AddEventListener(protocol_handler_);
transport_manager_->AddEventListener(connection_handler_);
- hmi_handler_->set_message_observer(app_manager_);
-
protocol_handler_->AddProtocolObserver(media_manager_);
protocol_handler_->AddProtocolObserver(app_manager_);
@@ -178,7 +179,6 @@ bool LifeCycle::StartComponents() {
// It's important to initialise TM after setting up listener chain
// [TM -> CH -> AM], otherwise some events from TM could arrive at nowhere
app_manager_->set_protocol_handler(protocol_handler_);
- app_manager_->set_hmi_message_handler(hmi_handler_);
transport_manager_->Init(*last_state_);
// start transport manager
diff --git a/src/components/application_manager/src/message.cc b/src/components/application_manager/src/message.cc
index 41a7eea0b6..1094d7cf8c 100644
--- a/src/components/application_manager/src/message.cc
+++ b/src/components/application_manager/src/message.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Ford Motor Company
+ * Copyright (c) 2017, Ford Motor Company
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -68,7 +68,15 @@ Message::Message(protocol_handler::MessagePriority priority)
protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_UNKNOWN) {}
Message::Message(const Message& message)
- : priority_(message.priority_), binary_data_(NULL) {
+ : function_id_(0)
+ , correlation_id_(0)
+ , type_(kUnknownType)
+ , priority_(message.priority_)
+ , connection_key_(0)
+ , binary_data_(NULL)
+ , data_size_(0)
+ , payload_size_(0)
+ , version_(kUnknownProtocol) {
*this = message;
}
@@ -89,7 +97,7 @@ Message& Message::operator=(const Message& message) {
return *this;
}
-bool Message::operator==(const Message& message) {
+bool Message::operator==(const Message& message) const {
bool function_id = function_id_ == message.function_id_;
bool correlation_id = correlation_id_ == message.correlation_id_;
bool connection_key = connection_key_ == message.connection_key_;
@@ -98,11 +106,13 @@ bool Message::operator==(const Message& message) {
bool version = version_ == message.version_;
bool data_size = data_size_ == message.data_size_;
bool payload_size = payload_size_ == message.payload_size_;
-
- bool binary_data = std::equal(binary_data_->begin(),
- binary_data_->end(),
- message.binary_data_->begin(),
- BinaryDataPredicate);
+ bool binary_data = true;
+ if (binary_data_) {
+ binary_data = std::equal(binary_data_->begin(),
+ binary_data_->end(),
+ message.binary_data_->begin(),
+ BinaryDataPredicate);
+ }
return function_id && correlation_id && connection_key && type &&
binary_data && json_message && version && data_size && payload_size;
@@ -118,6 +128,12 @@ int32_t Message::function_id() const {
return function_id_;
}
+#ifdef SDL_REMOTE_CONTROL
+std::string Message::function_name() const {
+ return function_name_;
+}
+#endif // SDL_REMOTE_CONTROL
+
int32_t Message::correlation_id() const {
return correlation_id_;
}
@@ -130,7 +146,7 @@ MessageType Message::type() const {
return type_;
}
-protocol_handler::MajorProtocolVersion Message::protocol_version() const {
+ProtocolVersion Message::protocol_version() const {
return version_;
}
@@ -158,6 +174,12 @@ void Message::set_function_id(int32_t id) {
function_id_ = id;
}
+#ifdef SDL_REMOTE_CONTROL
+void Message::set_function_name(const std::string& name) {
+ function_name_ = name;
+}
+#endif // SDL_REMOTE_CONTROL
+
void Message::set_correlation_id(int32_t id) {
correlation_id_ = id;
}
@@ -180,15 +202,14 @@ void Message::set_binary_data(BinaryData* data) {
delete binary_data_;
}
- binary_data_ = data;
+ binary_data_ = new BinaryData(*data);
}
void Message::set_json_message(const std::string& json_message) {
json_message_ = json_message;
}
-void Message::set_protocol_version(
- protocol_handler::MajorProtocolVersion version) {
+void Message::set_protocol_version(ProtocolVersion version) {
version_ = version;
}
diff --git a/src/components/application_manager/src/request_controller.cc b/src/components/application_manager/src/request_controller.cc
index 77a1853a39..1b9bd7ffb9 100644
--- a/src/components/application_manager/src/request_controller.cc
+++ b/src/components/application_manager/src/request_controller.cc
@@ -63,8 +63,11 @@ RequestController::RequestController(const RequestControlerSettings& settings)
RequestController::~RequestController() {
LOG4CXX_AUTO_TRACE(logger_);
- timer_stop_flag_ = true;
- timer_condition_.Broadcast();
+ {
+ sync_primitives::AutoLock auto_lock(timer_lock);
+ timer_stop_flag_ = true;
+ timer_condition_.Broadcast();
+ }
timer_.Stop();
if (pool_state_ != TPoolState::STOPPED) {
DestroyThreadpool();
@@ -370,11 +373,11 @@ void RequestController::TimeoutThread() {
LOG4CXX_DEBUG(
logger_,
"ENTER Waiting fore response count: " << waiting_for_response_.Size());
+ sync_primitives::AutoLock auto_lock(timer_lock);
while (!timer_stop_flag_) {
RequestInfoPtr probably_expired =
waiting_for_response_.FrontWithNotNullTimeout();
if (!probably_expired) {
- sync_primitives::AutoLock auto_lock(timer_lock);
timer_condition_.Wait(auto_lock);
continue;
}
@@ -388,7 +391,6 @@ void RequestController::TimeoutThread() {
<< " request id: " << probably_expired->requestId()
<< " connection_key: " << probably_expired->app_id()
<< " NOT expired");
- sync_primitives::AutoLock auto_lock(timer_lock);
const TimevalStruct current_time = date_time::DateTime::getCurrentTime();
const TimevalStruct end_time = probably_expired->end_time();
if (current_time < end_time) {
diff --git a/src/components/application_manager/test/commands/mobile/alert_request_test.cc b/src/components/application_manager/test/commands/mobile/alert_request_test.cc
index 43151c2d98..b52c7911c1 100644
--- a/src/components/application_manager/test/commands/mobile/alert_request_test.cc
+++ b/src/components/application_manager/test/commands/mobile/alert_request_test.cc
@@ -267,6 +267,9 @@ TEST_F(AlertRequestTest, OnEvent_UI_HmiSendSuccess_UNSUPPORTED_RESOURCE) {
event.set_smart_object(*msg);
MessageSharedPtr ui_command_result;
+ ON_CALL(mock_message_helper_,
+ HMIToMobileResult(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE))
+ .WillByDefault(Return(am::mobile_api::Result::UNSUPPORTED_RESOURCE));
EXPECT_CALL(
app_mngr_,
ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
diff --git a/src/components/application_manager/test/commands/mobile/delete_sub_menu_test.cc b/src/components/application_manager/test/commands/mobile/delete_sub_menu_test.cc
index dd57d5f8c6..24b7d0f356 100644
--- a/src/components/application_manager/test/commands/mobile/delete_sub_menu_test.cc
+++ b/src/components/application_manager/test/commands/mobile/delete_sub_menu_test.cc
@@ -241,9 +241,11 @@ TEST_F(DeleteSubMenuRequestTest, OnEvent_UnknownEventId_UNSUCCESS) {
TEST_F(DeleteSubMenuRequestTest, OnEvent_InvalidApp_UNSUCCESS) {
Event event(hmi_apis::FunctionID::UI_DeleteSubMenu);
(*message_)[am::strings::params][am::hmi_response::code] =
- am::mobile_api::Result::SUCCESS;
+ hmi_apis::Common_Result::eType::SUCCESS;
event.set_smart_object(*message_);
-
+ ON_CALL(mock_message_helper_,
+ HMIToMobileResult(hmi_apis::Common_Result::eType::SUCCESS))
+ .WillByDefault(Return(am::mobile_api::Result::SUCCESS));
MockAppPtr invalid_app;
EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(invalid_app));
EXPECT_CALL(*app_, RemoveSubMenu(_)).Times(0);
@@ -311,6 +313,10 @@ TEST_F(DeleteSubMenuRequestTest,
commands_map_.insert(
std::make_pair(0, &((*message_)[am::strings::msg_params])));
+ ON_CALL(mock_message_helper_,
+ HMIToMobileResult(hmi_apis::Common_Result::SUCCESS))
+ .WillByDefault(Return(am::mobile_api::Result::SUCCESS));
+
EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(app_));
EXPECT_CALL(app_mngr_, ManageHMICommand(_)).Times(0);
EXPECT_CALL(*app_, commands_map()).Times(2).WillRepeatedly(Return(accessor_));
diff --git a/src/components/application_manager/test/commands/mobile/get_way_points_request_test.cc b/src/components/application_manager/test/commands/mobile/get_way_points_request_test.cc
index 4b13576a39..320117d34d 100644
--- a/src/components/application_manager/test/commands/mobile/get_way_points_request_test.cc
+++ b/src/components/application_manager/test/commands/mobile/get_way_points_request_test.cc
@@ -126,7 +126,8 @@ class GetWayPointsRequestOnEventTest
}
event.set_smart_object(*event_msg);
-
+ ON_CALL(message_helper_mock_, HMIToMobileResult(_))
+ .WillByDefault(Return(ResultCode));
MessageSharedPtr result_msg(
CatchMobileCommandResult(CallOnEvent(*command, event)));
EXPECT_EQ(
diff --git a/src/components/application_manager/test/commands/mobile/reset_global_properties_test.cc b/src/components/application_manager/test/commands/mobile/reset_global_properties_test.cc
index 29c52bb0d5..fdfb862449 100644
--- a/src/components/application_manager/test/commands/mobile/reset_global_properties_test.cc
+++ b/src/components/application_manager/test/commands/mobile/reset_global_properties_test.cc
@@ -293,6 +293,8 @@ TEST_F(ResetGlobalPropertiesRequestTest,
event.set_smart_object(*msg_);
+ ON_CALL(*mock_message_helper_, HMIToMobileResult(result_code))
+ .WillByDefault(Return(am::mobile_api::Result::SUCCESS));
EXPECT_CALL(app_mngr_,
ManageMobileCommand(
MobileResultCodeIs(mobile_apis::Result::eType::SUCCESS),
@@ -390,7 +392,9 @@ TEST_F(ResetGlobalPropertiesRequestTest, OnEvent_InvalidApp_UNSUCCESS) {
command_->Run();
event.set_smart_object(*msg_);
-
+ ON_CALL(*mock_message_helper_,
+ HMIToMobileResult(hmi_apis::Common_Result::eType::SUCCESS))
+ .WillByDefault(Return(am::mobile_api::Result::SUCCESS));
EXPECT_CALL(app_mngr_,
ManageMobileCommand(
MobileResultCodeIs(mobile_apis::Result::eType::SUCCESS),
diff --git a/src/components/application_manager/test/commands/mobile/set_display_layout_test.cc b/src/components/application_manager/test/commands/mobile/set_display_layout_test.cc
index 0518b325ea..c454e6516d 100644
--- a/src/components/application_manager/test/commands/mobile/set_display_layout_test.cc
+++ b/src/components/application_manager/test/commands/mobile/set_display_layout_test.cc
@@ -256,7 +256,9 @@ TEST_F(SetDisplayLayoutRequestTest, OnEvent_SUCCESS) {
EXPECT_CALL(hmi_capabilities, display_capabilities())
.WillOnce(Return(dispaly_capabilities_msg.get()));
-
+ ON_CALL(mock_message_helper_,
+ HMIToMobileResult(hmi_apis::Common_Result::eType::SUCCESS))
+ .WillByDefault(Return(am::mobile_api::Result::SUCCESS));
EXPECT_CALL(
app_mngr_,
ManageMobileCommand(MobileResultCodeIs(mobile_result::SUCCESS),
diff --git a/src/components/application_manager/test/commands/mobile/show_test.cc b/src/components/application_manager/test/commands/mobile/show_test.cc
index 2d2e19cbf2..49c23c4b64 100644
--- a/src/components/application_manager/test/commands/mobile/show_test.cc
+++ b/src/components/application_manager/test/commands/mobile/show_test.cc
@@ -760,12 +760,17 @@ TEST_F(ShowRequestTest, Run_EmptyParams_Canceled) {
TEST_F(ShowRequestTest, OnEvent_SuccessResultCode_SUCCESS) {
MessageSharedPtr msg = CreateMessage();
(*msg)[am::strings::params][am::hmi_response::code] =
- mobile_apis::Result::SUCCESS;
+ hmi_apis::Common_Result::eType::SUCCESS;
(*msg)[am::strings::msg_params] = SmartObject(smart_objects::SmartType_Map);
SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg));
- EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _));
+ ON_CALL(mock_message_helper_,
+ HMIToMobileResult(hmi_apis::Common_Result::eType::SUCCESS))
+ .WillByDefault(Return(am::mobile_api::Result::SUCCESS));
+ EXPECT_CALL(app_mngr_,
+ ManageMobileCommand(
+ MobileResultCodeIs(mobile_apis::Result::eType::SUCCESS), _));
Event event(hmi_apis::FunctionID::UI_Show);
event.set_smart_object(*msg);
@@ -782,6 +787,9 @@ TEST_F(ShowRequestTest, OnEvent_WarningsResultCode_SUCCESS) {
SharedPtr<ShowRequest> command(CreateCommand<ShowRequest>(msg));
+ EXPECT_CALL(mock_message_helper_,
+ HMIToMobileResult(hmi_apis::Common_Result::WARNINGS))
+ .WillOnce(Return(mobile_apis::Result::WARNINGS));
EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _));
Event event(hmi_apis::FunctionID::UI_Show);
diff --git a/src/components/connection_handler/src/connection_handler_impl.cc b/src/components/connection_handler/src/connection_handler_impl.cc
index daca42d3c2..6dd4fe06d7 100644
--- a/src/components/connection_handler/src/connection_handler_impl.cc
+++ b/src/components/connection_handler/src/connection_handler_impl.cc
@@ -174,12 +174,12 @@ void ConnectionHandlerImpl::OnDeviceRemoved(
RemoveConnection(*it);
}
- device_list_.erase(device_info.device_handle());
sync_primitives::AutoReadLock read_lock(connection_handler_observer_lock_);
if (connection_handler_observer_) {
connection_handler_observer_->RemoveDevice(device_info.device_handle());
connection_handler_observer_->OnDeviceListUpdated(device_list_);
}
+ device_list_.erase(device_info.device_handle());
}
void ConnectionHandlerImpl::OnScanDevicesFinished() {
@@ -296,6 +296,7 @@ uint32_t ConnectionHandlerImpl::OnSessionStartedCallback(
if (hash_id) {
*hash_id = protocol_handler::HASH_ID_WRONG;
}
+
#ifdef ENABLE_SECURITY
if (!AllowProtection(get_settings(), service_type, is_protected)) {
return 0;
@@ -844,6 +845,7 @@ security_manager::SSLContext::HandshakeContext
ConnectionHandlerImpl::GetHandshakeContext(uint32_t key) const {
return connection_handler_observer_->GetHandshakeContext(key);
}
+
#endif // ENABLE_SECURITY
void ConnectionHandlerImpl::StartDevicesDiscovery() {
diff --git a/src/components/formatters/test/meta_formatter_test.cc b/src/components/formatters/test/meta_formatter_test.cc
index 293f881c4a..87f05ab50e 100644
--- a/src/components/formatters/test/meta_formatter_test.cc
+++ b/src/components/formatters/test/meta_formatter_test.cc
@@ -68,20 +68,6 @@ TEST_F(CMetaFormatterTestHelper,
CMetaFormatter::CreateObjectByPattern(object2, schema, result_object2);
EXPECT_TRUE(creationresult);
- // Uncomment code to print objects in console
- // std::string formatted_string;
- // CFormatterJsonSDLRPCv1::toString(object1, formatted_string);
- // printf("object1 %s\n", formatted_string.c_str());
- //
- // CFormatterJsonSDLRPCv1::toString(result_object1, formatted_string);
- // printf("result_object1 %s\n", formatted_string.c_str());
- //
- // CFormatterJsonSDLRPCv1::toString(object2, formatted_string);
- // printf("object2 %s\n", formatted_string.c_str());
- //
- // CFormatterJsonSDLRPCv1::toString(result_object2, formatted_string);
- // printf("result_object2 %s\n", formatted_string.c_str());
-
CompareObjects(object1, result_object1);
CompareObjects(object2, result_object2);
@@ -112,13 +98,6 @@ TEST_F(CMetaFormatterTestHelper, NormalSchemaWithEmptyObject) {
FillObjectWithDefaultValues(expected_object);
CompareObjects(expected_object, result_object);
-
- // Uncomment code to print objects in console
- // std::string str;
- // AnyObjectToJsonString(result_object, str);
- // printf("result_object(default) %s", str.c_str());
- // AnyObjectToJsonString(expected_object, str);
- // printf("expected_object %s", str.c_str());
}
TEST_F(CMetaFormatterTestHelper,
@@ -140,11 +119,6 @@ TEST_F(CMetaFormatterTestHelper,
0, result_object[S_MSG_PARAMS]["syncMsgVersion"]["minorVersion"].asInt());
EXPECT_EQ(
0, result_object[S_MSG_PARAMS]["syncMsgVersion"]["patchVersion"].asInt());
-
- // Uncomment code to print object in console
- // std::string str;
- // AnyObjectToJsonString(result_object, str);
- // printf("result_object %s", str.c_str());
}
TEST_F(CMetaFormatterTestHelper, ObjectWithEmptyMap) {
@@ -191,11 +165,6 @@ TEST_F(CMetaFormatterTestHelper, ObjectWithEmptyMap) {
EXPECT_EQ(SmartType_Map, result_object_empty_map.getType())
<< "smartObject is not map type";
EXPECT_EQ(0u, result_object_empty_map.length()) << "non empty map";
-
- // Uncomment code to print object in console
- // std::string str;
- // AnyObjectToJsonString(result_object_empty_map, str);
- // printf("result_object(empty map) %s", str.c_str());
}
TEST_F(CMetaFormatterTestHelper, ObjectWithEmptyArray) {
@@ -233,11 +202,6 @@ TEST_F(CMetaFormatterTestHelper, ObjectWithEmptyArray) {
EXPECT_EQ(SmartType_Array, result_object_empty_array.getType())
<< "smartObject is not array type";
EXPECT_EQ(0u, result_object_empty_array.length()) << "non empty array";
-
- // Uncomment code to print object in console
- // std::string str;
- // AnyObjectToJsonString(result_object_empty_array, str);
- // printf("result_object(empty array) %s", str.c_str());
}
TEST_F(CMetaFormatterTestHelper,
@@ -325,13 +289,6 @@ TEST_F(CMetaFormatterTestHelper,
CMetaFormatter::CreateObjectByPattern(object, schema, result_object);
- // Uncomment code to print object in console
- // std::string str;
- // AnyObjectToJsonString(object, str);
- // printf("object %s", str.c_str());
- // AnyObjectToJsonString(result_object, str);
- // printf("result_object %s", str.c_str());
-
// Assert
EXPECT_EQ(500, result_object[S_PARAMS][S_FUNCTION_ID].asInt());
EXPECT_EQ(-1, result_object[S_PARAMS][S_MESSAGE_TYPE].asInt());
diff --git a/src/components/formatters/test/src/create_smartSchema.cc b/src/components/formatters/test/src/create_smartSchema.cc
index 4ae692429c..1497fbf281 100644
--- a/src/components/formatters/test/src/create_smartSchema.cc
+++ b/src/components/formatters/test/src/create_smartSchema.cc
@@ -339,7 +339,6 @@ CSmartSchema initSchemaForMetaFormatter() {
ISchemaItemPtr majorVersion_SchemaItem = TNumberSchemaItem<int>::create();
ISchemaItemPtr minorVersion_SchemaItem = TNumberSchemaItem<int>::create();
ISchemaItemPtr patchVersion_SchemaItem = TNumberSchemaItem<int>::create();
-
ISchemaItemPtr syncMsg_SchemaItem =
CStringSchemaItem::create(TSchemaItemParameter<size_t>(0),
TSchemaItemParameter<size_t>(1000),
diff --git a/src/components/formatters/test/src/meta_formatter_test_helper.cc b/src/components/formatters/test/src/meta_formatter_test_helper.cc
index a29c1bceb3..897c8d364d 100644
--- a/src/components/formatters/test/src/meta_formatter_test_helper.cc
+++ b/src/components/formatters/test/src/meta_formatter_test_helper.cc
@@ -109,17 +109,6 @@ void CMetaFormatterTestHelper::
obj[S_MSG_PARAMS]["languageDesired"] = Language::EN_EU;
obj[S_MSG_PARAMS]["hmiDisplayLanguageDesired"] = Language::RU_RU;
obj[S_MSG_PARAMS]["appID"] = "APP ID";
-
- // Commented not mandatory params for check creation object without them
- // obj[S_MSG_PARAMS]["ttsName"][0]["text"] = "ABC";
- // obj[S_MSG_PARAMS]["ttsName"][0]["type"] =
- // SpeechCapabilities::SC_TEXT;
-
- // obj[S_MSG_PARAMS]["vrSynonyms"][0] = "Synonym1";
- // obj[S_MSG_PARAMS]["vrSynonyms"][1] = "Synonym2";
-
- // obj[S_MSG_PARAMS]["appType"][0] = AppTypeTest::SYSTEM; // not mandatory
- // obj[S_MSG_PARAMS]["appType"][1] = AppTypeTest::MEDIA;
}
void CMetaFormatterTestHelper::FillObjectWithoutSomeMandatoryFields(
@@ -130,11 +119,6 @@ void CMetaFormatterTestHelper::FillObjectWithoutSomeMandatoryFields(
obj[S_PARAMS][S_PROTOCOL_VERSION] = 1;
obj[S_PARAMS][S_PROTOCOL_TYPE] = 0;
- // Commented mandatory params for check creation object without them
- // obj[S_PARAMS][S_CORRELATION_ID] = 12;
- // obj[S_MSG_PARAMS]["syncMsgVersion"]["majorVersion"] = 2;
- // obj[S_MSG_PARAMS]["syncMsgVersion"]["minorVersion"] = 10;
-
obj[S_MSG_PARAMS]["appName"] = "APP NAME";
obj[S_MSG_PARAMS]["ttsName"][0]["text"] = "ABC";
obj[S_MSG_PARAMS]["ttsName"][0]["type"] = SpeechCapabilities::SC_TEXT;
@@ -200,17 +184,6 @@ void CMetaFormatterTestHelper::FillObjectWithDefaultValues(SmartObject& obj) {
obj[S_MSG_PARAMS]["languageDesired"] = -1;
obj[S_MSG_PARAMS]["hmiDisplayLanguageDesired"] = -1;
obj[S_MSG_PARAMS]["appID"] = "";
-
- // Commented params for check creation object with only default values
- // obj[S_MSG_PARAMS]["ttsName"][0]["text"] = "ABC";
- // obj[S_MSG_PARAMS]["ttsName"][0]["type"] =
- // SpeechCapabilities::SC_TEXT;
-
- // obj[S_MSG_PARAMS]["vrSynonyms"][0] = "Synonym1";
- // obj[S_MSG_PARAMS]["vrSynonyms"][1] = "Synonym2";
-
- // obj[S_MSG_PARAMS]["appType"][0] = AppTypeTest::SYSTEM;
- // obj[S_MSG_PARAMS]["appType"][1] = AppTypeTest::MEDIA;
}
} // namespace formatters
diff --git a/src/components/hmi_message_handler/test/hmi_message_adapter_test.cc b/src/components/hmi_message_handler/test/hmi_message_adapter_test.cc
index b0f63c6a0c..eead7106c6 100644
--- a/src/components/hmi_message_handler/test/hmi_message_adapter_test.cc
+++ b/src/components/hmi_message_handler/test/hmi_message_adapter_test.cc
@@ -42,7 +42,7 @@ namespace test {
namespace components {
namespace hmi_message_handler_test {
-using ::testing::ReturnRef;
+using ::testing::Return;
using hmi_message_handler::HMIMessageHandlerImpl;
typedef utils::SharedPtr<MockHMIMessageAdapterImpl>
@@ -53,7 +53,7 @@ TEST(HMIMessageAdapterImplTest, Handler_CorrectPointer_CorrectReturnedPointer) {
mock_hmi_message_handler_settings;
const uint64_t stack_size = 1000u;
ON_CALL(mock_hmi_message_handler_settings, thread_min_stack_size())
- .WillByDefault(ReturnRef(stack_size));
+ .WillByDefault(Return(stack_size));
HMIMessageHandler* message_handler =
new hmi_message_handler::HMIMessageHandlerImpl(
mock_hmi_message_handler_settings);
diff --git a/src/components/hmi_message_handler/test/hmi_message_handler_impl_test.cc b/src/components/hmi_message_handler/test/hmi_message_handler_impl_test.cc
index 09f20ed75d..33be4a9228 100644
--- a/src/components/hmi_message_handler/test/hmi_message_handler_impl_test.cc
+++ b/src/components/hmi_message_handler/test/hmi_message_handler_impl_test.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Ford Motor Company
+ * Copyright (c) 2017, Ford Motor Company
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -43,7 +43,7 @@ namespace test {
namespace components {
namespace hmi_message_handler_test {
-using ::testing::ReturnRef;
+using ::testing::Return;
using ::testing::_;
class HMIMessageHandlerImplTest : public ::testing::Test {
@@ -63,7 +63,7 @@ class HMIMessageHandlerImplTest : public ::testing::Test {
virtual void SetUp() OVERRIDE {
ON_CALL(mock_hmi_message_handler_settings, thread_min_stack_size())
- .WillByDefault(ReturnRef(stack_size));
+ .WillByDefault(Return(stack_size));
hmi_handler_ = new hmi_message_handler::HMIMessageHandlerImpl(
mock_hmi_message_handler_settings);
ASSERT_TRUE(NULL != hmi_handler_);
diff --git a/src/components/include/hmi_message_handler/hmi_message_observer.h b/src/components/include/hmi_message_handler/hmi_message_observer.h
index aef1e33379..0676615b53 100644
--- a/src/components/include/hmi_message_handler/hmi_message_observer.h
+++ b/src/components/include/hmi_message_handler/hmi_message_observer.h
@@ -43,6 +43,7 @@ namespace hmi_message_handler {
class HMIMessageObserver {
public:
+ virtual ~HMIMessageObserver() {}
virtual void OnMessageReceived(
utils::SharedPtr<application_manager::Message> message) = 0;
virtual void OnErrorSending(
diff --git a/src/components/include/hmi_message_handler/hmi_message_sender.h b/src/components/include/hmi_message_handler/hmi_message_sender.h
index 95ed2c63c4..91c20a1986 100644
--- a/src/components/include/hmi_message_handler/hmi_message_sender.h
+++ b/src/components/include/hmi_message_handler/hmi_message_sender.h
@@ -40,6 +40,7 @@ typedef utils::SharedPtr<application_manager::Message> MessageSharedPointer;
class HMIMessageSender {
public:
+ virtual ~HMIMessageSender() {}
virtual void SendMessageToHMI(MessageSharedPointer message) = 0;
};
}
diff --git a/src/components/include/policy/policy_external/policy/usage_statistics/app_stopwatch.h b/src/components/include/policy/policy_external/policy/usage_statistics/app_stopwatch.h
index 45883163c4..3f01a30a62 100644
--- a/src/components/include/policy/policy_external/policy/usage_statistics/app_stopwatch.h
+++ b/src/components/include/policy/policy_external/policy/usage_statistics/app_stopwatch.h
@@ -30,10 +30,10 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef SRC_COMPONENTS_INCLUDE_POLICY_USAGE_STATISTICS_APP_STOPWATCH_H_
-#define SRC_COMPONENTS_INCLUDE_POLICY_USAGE_STATISTICS_APP_STOPWATCH_H_
+#ifndef SRC_COMPONENTS_INCLUDE_POLICY_POLICY_EXTERNAL_POLICY_USAGE_STATISTICS_APP_STOPWATCH_H_
+#define SRC_COMPONENTS_INCLUDE_POLICY_POLICY_EXTERNAL_POLICY_USAGE_STATISTICS_APP_STOPWATCH_H_
-#include "statistics_manager.h"
+#include "policy/usage_statistics/statistics_manager.h"
namespace usage_statistics {
@@ -47,4 +47,4 @@ class AppStopwatch {
} // namespace usage_statistics
-#endif // SRC_COMPONENTS_INCLUDE_POLICY_USAGE_STATISTICS_APP_STOPWATCH_H_
+#endif // SRC_COMPONENTS_INCLUDE_POLICY_POLICY_EXTERNAL_POLICY_USAGE_STATISTICS_APP_STOPWATCH_H_
diff --git a/src/components/include/policy/policy_external/policy/usage_statistics/statistics_manager.h b/src/components/include/policy/policy_external/policy/usage_statistics/statistics_manager.h
index 8cf3beaa55..dac553b547 100644
--- a/src/components/include/policy/policy_external/policy/usage_statistics/statistics_manager.h
+++ b/src/components/include/policy/policy_external/policy/usage_statistics/statistics_manager.h
@@ -30,8 +30,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef SRC_COMPONENTS_INCLUDE_POLICY_USAGE_STATISTICS_STATISTICS_MANAGER_H_
-#define SRC_COMPONENTS_INCLUDE_POLICY_USAGE_STATISTICS_STATISTICS_MANAGER_H_
+#ifndef SRC_COMPONENTS_INCLUDE_POLICY_POLICY_EXTERNAL_POLICY_USAGE_STATISTICS_STATISTICS_MANAGER_H_
+#define SRC_COMPONENTS_INCLUDE_POLICY_POLICY_EXTERNAL_POLICY_USAGE_STATISTICS_STATISTICS_MANAGER_H_
#include <stdint.h>
#include <string>
@@ -83,4 +83,4 @@ class StatisticsManager {
} // namespace usage_statistics
-#endif // SRC_COMPONENTS_INCLUDE_POLICY_USAGE_STATISTICS_STATISTICS_MANAGER_H_
+#endif // SRC_COMPONENTS_INCLUDE_POLICY_POLICY_EXTERNAL_POLICY_USAGE_STATISTICS_STATISTICS_MANAGER_H_
diff --git a/src/components/include/policy/policy_regular/policy/usage_statistics/statistics_manager.h b/src/components/include/policy/policy_regular/policy/usage_statistics/statistics_manager.h
index 8cf3beaa55..13fa5ce90b 100644
--- a/src/components/include/policy/policy_regular/policy/usage_statistics/statistics_manager.h
+++ b/src/components/include/policy/policy_regular/policy/usage_statistics/statistics_manager.h
@@ -30,8 +30,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef SRC_COMPONENTS_INCLUDE_POLICY_USAGE_STATISTICS_STATISTICS_MANAGER_H_
-#define SRC_COMPONENTS_INCLUDE_POLICY_USAGE_STATISTICS_STATISTICS_MANAGER_H_
+#ifndef SRC_COMPONENTS_INCLUDE_POLICY_POLICY_REGULAR_POLICY_USAGE_STATISTICS_STATISTICS_MANAGER_H_
+#define SRC_COMPONENTS_INCLUDE_POLICY_POLICY_REGULAR_POLICY_USAGE_STATISTICS_STATISTICS_MANAGER_H_
#include <stdint.h>
#include <string>
@@ -83,4 +83,4 @@ class StatisticsManager {
} // namespace usage_statistics
-#endif // SRC_COMPONENTS_INCLUDE_POLICY_USAGE_STATISTICS_STATISTICS_MANAGER_H_
+#endif // SRC_COMPONENTS_INCLUDE_POLICY_POLICY_REGULAR_POLICY_USAGE_STATISTICS_STATISTICS_MANAGER_H_
diff --git a/src/components/include/utils/custom_string.h b/src/components/include/utils/custom_string.h
index 7b21e7a64d..0d9b27e47c 100644
--- a/src/components/include/utils/custom_string.h
+++ b/src/components/include/utils/custom_string.h
@@ -180,6 +180,20 @@ class CustomString {
bool CompareIgnoreCase(const char* str) const;
/**
+ * @brief Compares the value of the string (case sensitive).
+ * @param Contains string for comparing
+ * @return Returns TRUE if strings is equal otherwise returns FALSE.
+ */
+ bool Compare(const CustomString& str) const;
+
+ /**
+ * @brief Compares the value of the string (case sensitive).
+ * @param Contains string for comparing
+ * @return Returns TRUE if strings is equal otherwise returns FALSE.
+ */
+ bool Compare(const char* str) const;
+
+ /**
* @brief Returns a pointer to string from CustomString.
*/
const char* c_str() const;
diff --git a/src/components/media_manager/include/media_manager/media_manager_impl.h b/src/components/media_manager/include/media_manager/media_manager_impl.h
index c84a5a884f..7fbd4f2f6f 100644
--- a/src/components/media_manager/include/media_manager/media_manager_impl.h
+++ b/src/components/media_manager/include/media_manager/media_manager_impl.h
@@ -86,9 +86,10 @@ class MediaManagerImpl : public MediaManager,
void set_mock_mic_listener(MediaListenerPtr media_listener);
void set_mock_mic_recorder(MediaAdapterImpl* media_adapter);
void set_mock_streamer(protocol_handler::ServiceType stype,
- MediaAdapterImpl* mock_stream);
- void set_mock_streamer_listener(protocol_handler::ServiceType stype,
- MediaAdapterListener* mock_stream);
+ ::utils::SharedPtr<MediaAdapterImpl> mock_stream);
+ void set_mock_streamer_listener(
+ protocol_handler::ServiceType stype,
+ ::utils::SharedPtr<MediaAdapterListener> mock_stream);
#endif // BUILD_TESTS
protected:
diff --git a/src/components/media_manager/src/media_manager_impl.cc b/src/components/media_manager/src/media_manager_impl.cc
index b89fc4c71f..6a9ded9029 100644
--- a/src/components/media_manager/src/media_manager_impl.cc
+++ b/src/components/media_manager/src/media_manager_impl.cc
@@ -96,13 +96,15 @@ void MediaManagerImpl::set_mock_mic_recorder(MediaAdapterImpl* media_adapter) {
#endif // EXTENDED_MEDIA_MODE
-void MediaManagerImpl::set_mock_streamer(protocol_handler::ServiceType stype,
- MediaAdapterImpl* mock_stream) {
+void MediaManagerImpl::set_mock_streamer(
+ protocol_handler::ServiceType stype,
+ ::utils::SharedPtr<MediaAdapterImpl> mock_stream) {
streamer_[stype] = mock_stream;
}
void MediaManagerImpl::set_mock_streamer_listener(
- protocol_handler::ServiceType stype, MediaAdapterListener* mock_stream) {
+ protocol_handler::ServiceType stype,
+ ::utils::SharedPtr<MediaAdapterListener> mock_stream) {
streamer_listener_[stype] = mock_stream;
}
diff --git a/src/components/media_manager/test/media_manager_impl_test.cc b/src/components/media_manager/test/media_manager_impl_test.cc
index f9618c7fb8..7d0226fa67 100644
--- a/src/components/media_manager/test/media_manager_impl_test.cc
+++ b/src/components/media_manager/test/media_manager_impl_test.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Ford Motor Company
+ * Copyright (c) 2017, Ford Motor Company
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -33,147 +33,376 @@
#include "gmock/gmock.h"
#include "media_manager/media_manager_impl.h"
#include "media_manager/mock_media_adapter.h"
-#include "media_manager/mock_media_adapter_listener.h"
#include "media_manager/mock_media_adapter_impl.h"
-#include "protocol_handler/mock_protocol_handler.h"
+#include "media_manager/mock_media_adapter_listener.h"
#include "media_manager/mock_media_manager_settings.h"
-#include "application_manager/mock_application_manager.h"
-#include "utils/shared_ptr.h"
-#include "utils/make_shared.h"
#include "application_manager/event_engine/event_dispatcher.h"
-#include "application_manager/state_controller.h"
+#include "application_manager/message.h"
+#include "application_manager/mock_application.h"
+#include "application_manager/mock_application_manager.h"
#include "application_manager/resumption/resume_ctrl.h"
-#include "resumption/last_state.h"
+#include "application_manager/state_controller.h"
+#include "protocol_handler/mock_protocol_handler.h"
+#include "protocol/common.h"
+#include "utils/make_shared.h"
+#include "utils/shared_ptr.h"
+#include "utils/file_system.h"
+#include "utils/scope_guard.h"
namespace test {
namespace components {
namespace media_manager_test {
+using namespace file_system;
+using namespace ::media_manager;
using ::testing::_;
+using ::testing::Return;
using ::testing::ReturnRef;
-using protocol_handler::ServiceType;
+using ::utils::SharedPtr;
+using ::utils::ScopeGuard;
+using ::utils::MakeGuard;
+using ::testing::NiceMock;
+using ::protocol_handler::ServiceType;
+using ::protocol_handler::RawMessagePtr;
+using application_manager::ApplicationSharedPtr;
+using application_manager::BinaryData;
+
+namespace {
+const uint16_t kVideoStreamingPort = 8901u;
+const uint16_t kAudioStreamingPort = 8000u;
+const int32_t kApplicationKey = 1;
+const int32_t kDuration = 1000;
+const std::string kStorageFolder = "test_storage_folder";
+const std::string kOutputFile = "test_output_file";
+const std::string kResourceFolder = "test_resource_folder";
+const std::string kRecordingFileSource = "test_recording_file_source";
+const std::string kNamedVideoPipePath = "named_video_pipe_path";
+const std::string kNamedAudioPipePath = "named_audio_pipe_path";
+const std::string kVideoStreamFile = "video_stream_file";
+const std::string kAudioStreamFile = "audio_stream_file";
+const std::string kServerAddress = "server_address";
+const std::string kSocketValue = "socket";
+const std::string kPipeValue = "pipe";
+const std::string kFileValue = "file";
+const std::string kDefaultValue = "";
+const std::string kOutputFilePath = kStorageFolder + "/" + kOutputFile;
+const uint32_t kProtocolVersion = ::protocol_handler::PROTOCOL_VERSION_2;
+const uint32_t kConnectionKey = 1u;
+
+void dealloc_data(uint8_t* data) {
+ delete[] data;
+}
+
+void dealloc_file(std::ofstream* test_file) {
+ delete test_file;
+}
+} // namespace
+
+typedef NiceMock<application_manager_test::MockApplication> MockApp;
+typedef SharedPtr<MockApp> MockAppPtr;
+typedef SharedPtr<MockMediaAdapterImpl> MockMediaAdapterImplPtr;
class MediaManagerImplTest : public ::testing::Test {
+ public:
+ // media_adapter_mock_ will be deleted in media_manager_impl (dtor)
+ MediaManagerImplTest() : media_adapter_mock_(new MockMediaAdapter()) {
+ media_adapter_listener_mock_ =
+ utils::MakeShared<MockMediaAdapterListener>();
+ ON_CALL(mock_media_manager_settings_, video_server_type())
+ .WillByDefault(ReturnRef(kDefaultValue));
+ ON_CALL(mock_media_manager_settings_, audio_server_type())
+ .WillByDefault(ReturnRef(kDefaultValue));
+ mock_app_ = ::utils::MakeShared<MockApp>();
+ media_manager_impl_.reset(
+ new MediaManagerImpl(app_mngr_, mock_media_manager_settings_));
+ }
+
protected:
+ void StartMicrophoneCheckHelper() {
+ EXPECT_CALL(app_mngr_, application(kApplicationKey))
+ .WillOnce(Return(mock_app_));
+ EXPECT_CALL(mock_media_manager_settings_, app_storage_folder())
+ .WillOnce(ReturnRef(kStorageFolder));
+ EXPECT_CALL(mock_media_manager_settings_, app_resource_folder())
+ .WillOnce(ReturnRef(kResourceFolder));
+ EXPECT_CALL(mock_media_manager_settings_, recording_file_source())
+ .WillOnce(ReturnRef(kRecordingFileSource));
+ }
+
+ void InitMediaManagerPrecondition(const std::string& server_type) {
+ EXPECT_CALL(mock_media_manager_settings_, video_server_type())
+ .WillRepeatedly(ReturnRef(server_type));
+ EXPECT_CALL(mock_media_manager_settings_, audio_server_type())
+ .WillRepeatedly(ReturnRef(server_type));
+ }
+
+ void InitMediaManagerSocketServerType() {
+ InitMediaManagerPrecondition(kSocketValue);
+ EXPECT_CALL(mock_media_manager_settings_, server_address())
+ .WillRepeatedly(ReturnRef(kServerAddress));
+ EXPECT_CALL(mock_media_manager_settings_, video_streaming_port())
+ .WillOnce(Return(kVideoStreamingPort));
+ EXPECT_CALL(mock_media_manager_settings_, audio_streaming_port())
+ .WillOnce(Return(kAudioStreamingPort));
+ media_manager_impl_.reset(
+ new MediaManagerImpl(app_mngr_, mock_media_manager_settings_));
+ }
+
+ void InitMediaManagerPipeServerType() {
+ InitMediaManagerPrecondition(kPipeValue);
+ EXPECT_CALL(mock_media_manager_settings_, named_video_pipe_path())
+ .WillOnce(ReturnRef(kNamedAudioPipePath));
+ EXPECT_CALL(mock_media_manager_settings_, named_audio_pipe_path())
+ .WillOnce(ReturnRef(kNamedAudioPipePath));
+ EXPECT_CALL(mock_media_manager_settings_, app_storage_folder())
+ .WillRepeatedly(ReturnRef(kStorageFolder));
+ media_manager_impl_.reset(
+ new MediaManagerImpl(app_mngr_, mock_media_manager_settings_));
+ }
+
+ void InitMediaManagerFileServerType() {
+ InitMediaManagerPrecondition(kFileValue);
+ EXPECT_CALL(mock_media_manager_settings_, video_stream_file())
+ .WillOnce(ReturnRef(kVideoStreamFile));
+ EXPECT_CALL(mock_media_manager_settings_, audio_stream_file())
+ .WillOnce(ReturnRef(kAudioStreamFile));
+ EXPECT_CALL(mock_media_manager_settings_, app_storage_folder())
+ .WillRepeatedly(ReturnRef(kStorageFolder));
+ media_manager_impl_.reset(
+ new MediaManagerImpl(app_mngr_, mock_media_manager_settings_));
+ }
+
+ void ReceivedMessage(const ServiceType service_type) {
+ EXPECT_CALL(app_mngr_, CanAppStream(kConnectionKey, service_type))
+ .WillOnce(Return(true));
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(mock_app_));
+ EXPECT_CALL(*mock_app_, WakeUpStreaming(service_type));
+ MockMediaAdapterImplPtr mock_media_streamer =
+ utils::MakeShared<MockMediaAdapterImpl>();
+ media_manager_impl_->set_mock_streamer(service_type, mock_media_streamer);
+ media_manager_impl_->set_mock_streamer_listener(
+ service_type, media_adapter_listener_mock_);
+ EXPECT_CALL(*mock_media_streamer, SendData(kConnectionKey, _));
+ EmulateMobileMessage(service_type);
+ }
+
+ void EmulateMobileMessage(const ServiceType serviceType) {
+ const uint32_t data_sending_size = 3u;
+ unsigned char data_sending[data_sending_size] = {0x20, 0x07, 0x01};
+ const RawMessagePtr raw_message_ptr(
+ new ::protocol_handler::RawMessage(kConnectionKey,
+ kProtocolVersion,
+ data_sending,
+ data_sending_size,
+ serviceType));
+ media_manager_impl_->OnMessageReceived(raw_message_ptr);
+ media_manager_impl_->OnMobileMessageSent(raw_message_ptr);
+ }
+
+ application_manager_test::MockApplicationManager app_mngr_;
+ MockAppPtr mock_app_;
+ SharedPtr<MockMediaAdapterListener> media_adapter_listener_mock_;
+ MockMediaAdapter* media_adapter_mock_;
const ::testing::NiceMock<MockMediaManagerSettings>
mock_media_manager_settings_;
- const std::string kDefaultValue_ = "";
+ SharedPtr<MediaManagerImpl> media_manager_impl_;
};
-TEST_F(MediaManagerImplTest, PlayA2DPSource) {
- MockMediaAdapter* media_mock_ = new MockMediaAdapter();
+TEST_F(MediaManagerImplTest,
+ OnMessageReceived_WithUnsupportedServiceType_Cancelled) {
+ EXPECT_CALL(app_mngr_, CanAppStream(_, _)).Times(0);
+ EXPECT_CALL(app_mngr_, application(_)).Times(0);
+ EmulateMobileMessage(ServiceType::kInvalidServiceType);
+}
- application_manager_test::MockApplicationManager mock_application_manager;
+TEST_F(MediaManagerImplTest,
+ OnMessageReceived_WithAudioServiceType_ApplicationNotFound_Cancelled) {
+ const ServiceType audio_type = ServiceType::kAudio;
+ EXPECT_CALL(app_mngr_, CanAppStream(kConnectionKey, audio_type))
+ .WillOnce(Return(true));
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(ApplicationSharedPtr()));
+ EmulateMobileMessage(audio_type);
+}
- ON_CALL(mock_media_manager_settings_, video_server_type())
- .WillByDefault(ReturnRef(kDefaultValue_));
- ON_CALL(mock_media_manager_settings_, audio_server_type())
- .WillByDefault(ReturnRef(kDefaultValue_));
- MediaManagerImpl mediaManagerImpl(mock_application_manager,
- mock_media_manager_settings_);
- int32_t application_key = 1;
+TEST_F(MediaManagerImplTest,
+ OnMessageReceived_WithVideoServiceType_ApplicationNotFound_Cancelled) {
+ const ServiceType video_type = ServiceType::kMobileNav;
+ EXPECT_CALL(app_mngr_, CanAppStream(kConnectionKey, video_type))
+ .WillOnce(Return(true));
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(ApplicationSharedPtr()));
+ EmulateMobileMessage(video_type);
+}
- mediaManagerImpl.set_mock_a2dp_player(media_mock_);
- EXPECT_CALL(*media_mock_, StartActivity(application_key));
- mediaManagerImpl.PlayA2DPSource(application_key);
+TEST_F(MediaManagerImplTest,
+ OnMessageReceived_WithAudioServiceType_ForbidStreaming_Cancelled) {
+ const ServiceType audio_type = ServiceType::kAudio;
+ EXPECT_CALL(app_mngr_, CanAppStream(kConnectionKey, audio_type))
+ .WillOnce(Return(false));
+ EXPECT_CALL(app_mngr_, ForbidStreaming(kConnectionKey));
+ EmulateMobileMessage(audio_type);
}
-TEST_F(MediaManagerImplTest, StopA2DPSource) {
- MockMediaAdapter* media_mock_ = new MockMediaAdapter();
- application_manager_test::MockApplicationManager mock_application_manager;
+TEST_F(MediaManagerImplTest,
+ OnMessageReceived_WithVideoServiceType_ForbidStreaming_Cancelled) {
+ const ServiceType video_type = ServiceType::kMobileNav;
+ EXPECT_CALL(app_mngr_, CanAppStream(kConnectionKey, video_type))
+ .WillOnce(Return(false));
+ EXPECT_CALL(app_mngr_, ForbidStreaming(kConnectionKey));
+ EmulateMobileMessage(video_type);
+}
- ON_CALL(mock_media_manager_settings_, video_server_type())
- .WillByDefault(ReturnRef(kDefaultValue_));
- ON_CALL(mock_media_manager_settings_, audio_server_type())
- .WillByDefault(ReturnRef(kDefaultValue_));
- MediaManagerImpl mediaManagerImpl(mock_application_manager,
- mock_media_manager_settings_);
- int32_t application_key = 1;
+TEST_F(MediaManagerImplTest, OnMessageReceived_WithAudioServiceType_SUCCESS) {
+ ReceivedMessage(ServiceType::kAudio);
+}
- mediaManagerImpl.set_mock_a2dp_player(media_mock_);
- EXPECT_CALL(*media_mock_, StopActivity(application_key));
- mediaManagerImpl.StopA2DPSource(application_key);
+TEST_F(MediaManagerImplTest, OnMessageReceived_WithVideoServiceType_SUCCESS) {
+ ReceivedMessage(ServiceType::kMobileNav);
}
-TEST_F(MediaManagerImplTest, StopMicrophoneRecording) {
- MockMediaAdapterListener* media_adapter_listener_mock_ =
- new MockMediaAdapterListener();
- application_manager_test::MockApplicationManager mock_application_manager;
+TEST_F(MediaManagerImplTest, Init_Settings_ExpectSocketValue) {
+ InitMediaManagerSocketServerType();
+}
- ON_CALL(mock_media_manager_settings_, video_server_type())
- .WillByDefault(ReturnRef(kDefaultValue_));
- ON_CALL(mock_media_manager_settings_, audio_server_type())
- .WillByDefault(ReturnRef(kDefaultValue_));
- MediaManagerImpl mediaManagerImpl(mock_application_manager,
- mock_media_manager_settings_);
- int32_t application_key = 1;
+TEST_F(MediaManagerImplTest, Init_Settings_ExpectPipeValue) {
+ InitMediaManagerPipeServerType();
+}
+
+TEST_F(MediaManagerImplTest, Init_Settings_ExpectFileValue) {
+ InitMediaManagerFileServerType();
+}
+
+TEST_F(MediaManagerImplTest, PlayA2DPSource_WithCorrectA2DP_SUCCESS) {
+ media_manager_impl_->set_mock_a2dp_player(media_adapter_mock_);
+ EXPECT_CALL(*media_adapter_mock_, StartActivity(kApplicationKey));
+ media_manager_impl_->PlayA2DPSource(kApplicationKey);
+}
+
+TEST_F(MediaManagerImplTest, StopA2DPSource_WithCorrectA2DP_SUCCESS) {
+ media_manager_impl_->set_mock_a2dp_player(media_adapter_mock_);
+ EXPECT_CALL(*media_adapter_mock_, StopActivity(kApplicationKey));
+ media_manager_impl_->StopA2DPSource(kApplicationKey);
+}
+
+TEST_F(MediaManagerImplTest,
+ StartMicrophoneRecording_SourceFileIsWritable_ExpectTrue) {
+ StartMicrophoneCheckHelper();
+ if (!DirectoryExists(kStorageFolder)) {
+ CreateDirectory(kStorageFolder);
+ }
+ EXPECT_FALSE(FileExists(kOutputFilePath));
+ EXPECT_TRUE(CreateFile(kOutputFilePath));
- mediaManagerImpl.set_mock_mic_listener(media_adapter_listener_mock_);
+ const std::string record_file_path =
+ kResourceFolder + "/" + kRecordingFileSource;
+ if (!DirectoryExists(kResourceFolder)) {
+ CreateDirectory(kResourceFolder);
+ }
+ EXPECT_FALSE(FileExists(record_file_path));
+ EXPECT_TRUE(CreateFile(record_file_path));
+ std::ofstream* test_file = Open(record_file_path);
+ ScopeGuard file_guard = MakeGuard(dealloc_file, test_file);
+ UNUSED(file_guard);
+ EXPECT_TRUE(test_file->is_open());
+ const uint32_t data_size = 4u;
+ uint8_t* data = new uint8_t[data_size];
+ ScopeGuard data_guard = MakeGuard(dealloc_data, data);
+ UNUSED(data_guard);
+ for (uint32_t i = 0u; i < data_size; ++i) {
+ data[i] = i;
+ }
+ EXPECT_TRUE(Write(test_file, data, data_size));
+ Close(test_file);
+ EXPECT_FALSE(test_file->is_open());
+ BinaryData result;
+ EXPECT_TRUE(ReadBinaryFile(record_file_path, result));
+ EXPECT_FALSE(result.empty());
+ for (uint32_t i = 0u; i < data_size; ++i) {
+ EXPECT_EQ(data[i], result[i]);
+ }
+ media_manager_impl_->StartMicrophoneRecording(
+ kApplicationKey, kOutputFile, kDuration);
+ EXPECT_TRUE(RemoveDirectory(kResourceFolder, true));
+ EXPECT_TRUE(RemoveDirectory(kStorageFolder, true));
+}
+
+TEST_F(MediaManagerImplTest,
+ StartMicrophoneRecording_OutputFileNotExists_ExpectFalse) {
+ StartMicrophoneCheckHelper();
+ media_manager_impl_->set_mock_mic_listener(media_adapter_listener_mock_);
+ EXPECT_FALSE(FileExists(kOutputFilePath));
+ media_manager_impl_->StartMicrophoneRecording(
+ kApplicationKey, kOutputFile, kDuration);
+}
+
+TEST_F(MediaManagerImplTest,
+ StartMicrophoneRecording_OutputFileCouldNotDeleted_ExpectTrue) {
+ StartMicrophoneCheckHelper();
+ if (!DirectoryExists(kStorageFolder)) {
+ CreateDirectory(kStorageFolder);
+ }
+ EXPECT_FALSE(FileExists(kOutputFilePath));
+ EXPECT_TRUE(CreateFile(kOutputFilePath));
+ chmod(kOutputFilePath.c_str(), S_IRUSR);
+ EXPECT_FALSE(DeleteFile(kOutputFilePath));
+ media_manager_impl_->set_mock_mic_listener(media_adapter_listener_mock_);
+ EXPECT_TRUE(FileExists(kOutputFilePath));
+ media_manager_impl_->StartMicrophoneRecording(
+ kApplicationKey, kOutputFile, kDuration);
+ chmod(kOutputFilePath.c_str(), S_IWUSR);
+ EXPECT_TRUE(RemoveDirectory(kStorageFolder, true));
+}
+
+TEST_F(MediaManagerImplTest, StopMicrophoneRecording_SUCCESS) {
+ media_manager_impl_->set_mock_mic_listener(media_adapter_listener_mock_);
#ifdef EXTENDED_MEDIA_MODE
MockMediaAdapterImpl* media_adapter_recorder_mock =
new MockMediaAdapterImpl();
- mediaManagerImpl.set_mock_mic_recorder(media_adapter_recorder_mock);
- EXPECT_CALL(*media_adapter_recorder_mock, StopActivity(application_key));
+ media_manager_impl_->set_mock_mic_recorder(media_adapter_recorder_mock);
+ EXPECT_CALL(*media_adapter_recorder_mock, StopActivity(kApplicationKey));
#endif // EXTENDED_MEDIA_MODE
- EXPECT_CALL(*media_adapter_listener_mock_, OnActivityEnded(application_key));
+ EXPECT_CALL(*media_adapter_listener_mock_, OnActivityEnded(kApplicationKey));
#ifdef EXTENDED_MEDIA_MODE
EXPECT_CALL(*media_adapter_recorder_mock, RemoveListener(_));
#endif // EXTENDED_MEDIA_MODE
- mediaManagerImpl.StopMicrophoneRecording(application_key);
+ media_manager_impl_->StopMicrophoneRecording(kApplicationKey);
}
-TEST_F(MediaManagerImplTest, StartStopStreaming) {
- application_manager_test::MockApplicationManager mock_application_manager;
+TEST_F(MediaManagerImplTest,
+ StartStopStreaming_AudioAndVideoServiceType_SUCCESS) {
+ MockMediaAdapterImplPtr mock_audio_media_streamer =
+ utils::MakeShared<MockMediaAdapterImpl>();
+ media_manager_impl_->set_mock_streamer(ServiceType::kAudio,
+ mock_audio_media_streamer);
+ MockMediaAdapterImplPtr mock_nav_media_streamer =
+ utils::MakeShared<MockMediaAdapterImpl>();
+ media_manager_impl_->set_mock_streamer(ServiceType::kMobileNav,
+ mock_nav_media_streamer);
- ON_CALL(mock_media_manager_settings_, video_server_type())
- .WillByDefault(ReturnRef(kDefaultValue_));
- ON_CALL(mock_media_manager_settings_, audio_server_type())
- .WillByDefault(ReturnRef(kDefaultValue_));
- MediaManagerImpl mediaManagerImpl(mock_application_manager,
- mock_media_manager_settings_);
-
- int32_t application_key = 1;
- MockMediaAdapterImpl* mock_audio_media_streamer = new MockMediaAdapterImpl();
- mediaManagerImpl.set_mock_streamer(protocol_handler::ServiceType::kAudio,
- mock_audio_media_streamer);
- MockMediaAdapterImpl* mock_nav_media_streamer = new MockMediaAdapterImpl();
- mediaManagerImpl.set_mock_streamer(protocol_handler::ServiceType::kMobileNav,
- mock_nav_media_streamer);
-
- EXPECT_CALL(*mock_audio_media_streamer, StartActivity(application_key));
- mediaManagerImpl.StartStreaming(application_key,
- protocol_handler::ServiceType::kAudio);
-
- EXPECT_CALL(*mock_nav_media_streamer, StartActivity(application_key));
- mediaManagerImpl.StartStreaming(application_key,
- protocol_handler::ServiceType::kMobileNav);
-
- EXPECT_CALL(*mock_audio_media_streamer, StopActivity(application_key));
- mediaManagerImpl.StopStreaming(application_key,
- protocol_handler::ServiceType::kAudio);
-
- EXPECT_CALL(*mock_nav_media_streamer, StopActivity(application_key));
- mediaManagerImpl.StopStreaming(application_key,
- protocol_handler::ServiceType::kMobileNav);
+ EXPECT_CALL(*mock_audio_media_streamer, StartActivity(kApplicationKey));
+ media_manager_impl_->StartStreaming(kApplicationKey, ServiceType::kAudio);
+ EXPECT_CALL(*mock_nav_media_streamer, StartActivity(kApplicationKey));
+ media_manager_impl_->StartStreaming(kApplicationKey, ServiceType::kMobileNav);
+ EXPECT_CALL(*mock_audio_media_streamer, StopActivity(kApplicationKey));
+ media_manager_impl_->StopStreaming(kApplicationKey, ServiceType::kAudio);
+ EXPECT_CALL(*mock_nav_media_streamer, StopActivity(kApplicationKey));
+ media_manager_impl_->StopStreaming(kApplicationKey, ServiceType::kMobileNav);
}
-TEST_F(MediaManagerImplTest, CheckFramesProcessed) {
- application_manager_test::MockApplicationManager mock_application_manager;
-
+TEST_F(MediaManagerImplTest,
+ CheckFramesProcessed_WithCorrectFramesNumber_SUCCESS) {
ON_CALL(mock_media_manager_settings_, video_server_type())
- .WillByDefault(ReturnRef(kDefaultValue_));
+ .WillByDefault(ReturnRef(kDefaultValue));
ON_CALL(mock_media_manager_settings_, audio_server_type())
- .WillByDefault(ReturnRef(kDefaultValue_));
- MediaManagerImpl mediaManagerImpl(mock_application_manager,
- mock_media_manager_settings_);
+ .WillByDefault(ReturnRef(kDefaultValue));
protocol_handler_test::MockProtocolHandler mock_protocol_handler;
- mediaManagerImpl.SetProtocolHandler(&mock_protocol_handler);
- int32_t application_key = 1;
- int32_t frame_number = 10;
-
+ media_manager_impl_->SetProtocolHandler(&mock_protocol_handler);
+ const int32_t frame_number = 10;
EXPECT_CALL(mock_protocol_handler,
- SendFramesNumber(application_key, frame_number));
- mediaManagerImpl.FramesProcessed(application_key, frame_number);
+ SendFramesNumber(kApplicationKey, frame_number));
+ media_manager_impl_->FramesProcessed(kApplicationKey, frame_number);
}
} // namespace media_manager_test
diff --git a/src/components/policy/policy_external/include/policy/cache_manager_interface.h b/src/components/policy/policy_external/include/policy/cache_manager_interface.h
index 66631f32cf..ae1f8922ba 100644
--- a/src/components/policy/policy_external/include/policy/cache_manager_interface.h
+++ b/src/components/policy/policy_external/include/policy/cache_manager_interface.h
@@ -36,8 +36,10 @@
#include <string>
#include <vector>
+#include "policy/policy_table/types.h"
+#include "policy/pt_representation.h"
#include "utils/shared_ptr.h"
-#include "usage_statistics/counter.h"
+#include "policy/usage_statistics/counter.h"
#include "policy/policy_types.h"
#include "policy/policy_settings.h"
diff --git a/src/components/policy/policy_external/test/include/policy/mock_cache_manager.h b/src/components/policy/policy_external/test/include/policy/mock_cache_manager.h
deleted file mode 100644
index 617e99358e..0000000000
--- a/src/components/policy/policy_external/test/include/policy/mock_cache_manager.h
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
- * Copyright (c) 2016, 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.
- */
-#ifndef SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_TEST_INCLUDE_POLICY_MOCK_CACHE_MANAGER_H_
-#define SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_TEST_INCLUDE_POLICY_MOCK_CACHE_MANAGER_H_
-
-#include <string>
-#include <vector>
-
-#include "gmock/gmock.h"
-
-#include "policy/cache_manager_interface.h"
-
-namespace policy_table = rpc::policy_table_interface_base;
-
-using namespace ::policy;
-
-namespace test {
-namespace components {
-namespace policy_test {
-
-class MockCacheManagerInterface : public ::policy::CacheManagerInterface {
- public:
- MOCK_CONST_METHOD2(GetConsentsPriority,
- ConsentPriorityType(const std::string& device_id,
- const std::string& application_id));
- MOCK_METHOD4(CheckPermissions,
- void(const PTString& app_id,
- const PTString& hmi_level,
- const PTString& rpc,
- CheckPermissionResult& result));
- MOCK_METHOD0(IsPTPreloaded, bool());
- MOCK_METHOD0(IgnitionCyclesBeforeExchange, int());
- MOCK_METHOD1(KilometersBeforeExchange, int(int current));
- MOCK_CONST_METHOD1(GetPermissionsList, bool(StringArray& perm_list));
- MOCK_METHOD2(SetCountersPassedForSuccessfulUpdate,
- bool(Counters counter, int value));
- MOCK_METHOD1(DaysBeforeExchange, int(uint16_t current));
- MOCK_METHOD0(IncrementIgnitionCycles, void());
-
- MOCK_METHOD2(SaveDeviceConsentToCache,
- void(const std::string& device_id, const bool is_allowed));
-
- MOCK_METHOD1(ResetCalculatedPermissionsForDevice,
- void(const std::string& device_id));
- MOCK_METHOD0(ResetIgnitionCycles, void());
- MOCK_METHOD0(TimeoutResponse, int());
- MOCK_METHOD1(SecondsBetweenRetries, bool(std::vector<int>& seconds));
- MOCK_CONST_METHOD1(IsDeviceConsentCached, bool(const std::string& device_id));
- MOCK_CONST_METHOD0(GetVehicleInfo, const VehicleInfo());
- MOCK_CONST_METHOD1(GetDeviceConsent,
- DeviceConsent(const std::string& device_id));
- MOCK_METHOD2(SetDeviceConsent,
- void(const std::string& device_id, bool is_allowed));
-
- MOCK_CONST_METHOD2(HasDeviceSpecifiedConsent,
- bool(const std::string& device_id, const bool is_allowed));
- MOCK_CONST_METHOD1(GetCachedDeviceConsent,
- DeviceConsent(const std::string& device_id));
- MOCK_METHOD1(SetVINValue, bool(const std::string& value));
- MOCK_METHOD3(GetUserFriendlyMsg,
- std::vector<UserFriendlyMessage>(
- const std::vector<std::string>& msg_codes,
- const std::string& language,
- const std::string& active_hmi_language));
- MOCK_METHOD2(GetUpdateUrls,
- void(const std::string& service_type,
- EndpointUrls& out_end_points));
- MOCK_METHOD2(GetUpdateUrls,
- void(const uint32_t service_type, EndpointUrls& out_end_points));
- MOCK_CONST_METHOD0(GetLockScreenIconUrl, std::string());
- MOCK_METHOD1(
- GetNotificationsNumber,
- policy_table::NumberOfNotificationsType(const std::string& priority));
- MOCK_CONST_METHOD2(GetPriority,
- bool(const std::string& policy_app_id,
- std::string& priority));
- MOCK_METHOD2(Init,
- bool(const std::string& file_name,
- const PolicySettings* settings));
- MOCK_METHOD0(GenerateSnapshot, utils::SharedPtr<policy_table::Table>());
- MOCK_METHOD1(ApplyUpdate, bool(const policy_table::Table& update_pt));
- MOCK_METHOD1(Save, bool(const policy_table::Table& table));
- MOCK_CONST_METHOD0(UpdateRequired, bool());
- MOCK_METHOD1(SaveUpdateRequired, void(bool status));
- MOCK_METHOD3(GetInitialAppData,
- bool(const std::string& app_id,
- StringArray& nicknames,
- StringArray& app_hmi_types));
- MOCK_CONST_METHOD1(IsApplicationRevoked, bool(const std::string& app_id));
- MOCK_METHOD1(GetFunctionalGroupings,
- bool(policy_table::FunctionalGroupings& groups));
- MOCK_CONST_METHOD1(IsApplicationRepresented, bool(const std::string& app_id));
- MOCK_CONST_METHOD1(IsDefaultPolicy, bool(const std::string& app_id));
- MOCK_METHOD1(SetIsDefault, bool(const std::string& app_id));
- MOCK_METHOD1(SetIsPredata, bool(const std::string& app_id));
- MOCK_CONST_METHOD1(IsPredataPolicy, bool(const std::string& app_id));
- MOCK_METHOD1(SetDefaultPolicy, bool(const std::string& app_id));
- MOCK_CONST_METHOD1(CanAppKeepContext, bool(const std::string& app_id));
- MOCK_CONST_METHOD1(CanAppStealFocus, bool(const std::string& app_id));
- MOCK_CONST_METHOD2(GetDefaultHMI,
- bool(const std::string& app_id, std::string& default_hmi));
- MOCK_METHOD0(ResetUserConsent, bool());
- MOCK_CONST_METHOD3(GetUserPermissionsForDevice,
- bool(const std::string& device_id,
- StringArray& consented_groups,
- StringArray& disallowed_groups));
- MOCK_METHOD3(GetPermissionsForApp,
- bool(const std::string& device_id,
- const std::string& app_id,
- FunctionalIdType& group_types));
- MOCK_CONST_METHOD2(
- GetDeviceGroupsFromPolicies,
- bool(rpc::policy_table_interface_base::Strings& groups,
- rpc::policy_table_interface_base::Strings& preconsented_groups));
- MOCK_METHOD2(AddDevice,
- bool(const std::string& device_id,
- const std::string& connection_type));
- MOCK_METHOD8(SetDeviceData,
- bool(const std::string& device_id,
- const std::string& hardware,
- const std::string& firmware,
- const std::string& os,
- const std::string& os_version,
- const std::string& carrier,
- const uint32_t number_of_ports,
- const std::string& connection_type));
- MOCK_METHOD3(SetUserPermissionsForDevice,
- bool(const std::string& device_id,
- const StringArray& consented_groups,
- const StringArray& disallowed_groups));
- MOCK_METHOD2(ReactOnUserDevConsentForApp,
- bool(const std::string& app_id, bool is_device_allowed));
- MOCK_METHOD2(SetUserPermissionsForApp,
- bool(const PermissionConsent& permissions,
- bool* out_app_permissions_changed));
- MOCK_METHOD3(SetMetaInfo,
- bool(const std::string& ccpu_version,
- const std::string& wers_country_code,
- const std::string& language));
- MOCK_CONST_METHOD0(IsMetaInfoPresent, bool());
- MOCK_METHOD1(SetSystemLanguage, bool(const std::string& language));
- MOCK_METHOD1(Increment, void(usage_statistics::GlobalCounterId type));
- MOCK_METHOD2(Increment,
- void(const std::string& app_id,
- usage_statistics::AppCounterId type));
- MOCK_METHOD3(Set,
- void(const std::string& app_id,
- usage_statistics::AppInfoId type,
- const std::string& value));
- MOCK_METHOD3(Add,
- void(const std::string& app_id,
- usage_statistics::AppStopwatchId type,
- int seconds));
- MOCK_METHOD2(CountUnconsentedGroups,
- int(const std::string& policy_app_id,
- const std::string& device_id));
- MOCK_METHOD1(GetFunctionalGroupNames, bool(FunctionalGroupNames& names));
- MOCK_METHOD2(GetAllAppGroups,
- void(const std::string& app_id,
- FunctionalGroupIDs& all_group_ids));
- MOCK_METHOD2(GetPreConsentedGroups,
- void(const std::string& app_id,
- FunctionalGroupIDs& preconsented_groups));
- MOCK_METHOD4(GetConsentedGroups,
- void(const std::string& device_id,
- const std::string& app_id,
- FunctionalGroupIDs& allowed_groups,
- FunctionalGroupIDs& disallowed_groups));
- MOCK_METHOD3(GetUnconsentedGroups,
- void(const std::string& device_id,
- const std::string& policy_app_id,
- FunctionalGroupIDs& unconsented_groups));
- MOCK_METHOD2(RemoveAppConsentForGroup,
- void(const std::string& app_id, const std::string& group_name));
- MOCK_METHOD1(SetPredataPolicy, bool(const std::string& app_id));
- MOCK_METHOD0(CleanupUnpairedDevices, bool());
- MOCK_METHOD2(SetUnpairedDevice,
- bool(const std::string& device_id, bool unpaired));
- MOCK_METHOD1(UnpairedDevicesList, bool(DeviceIds& device_ids));
- MOCK_METHOD1(ResetPT, bool(const std::string& file_name));
- MOCK_METHOD0(LoadFromBackup, bool());
- MOCK_METHOD2(LoadFromFile,
- bool(const std::string& file_name, policy_table::Table&));
- MOCK_METHOD0(Backup, void());
- MOCK_CONST_METHOD1(HeartBeatTimeout, uint32_t(const std::string& app_id));
- MOCK_CONST_METHOD2(GetAppRequestTypes,
- void(const std::string& policy_app_id,
- std::vector<std::string>& request_types));
- MOCK_METHOD1(GetHMIAppTypeAfterUpdate,
- void(std::map<std::string, StringArray>& app_hmi_types));
-
- MOCK_CONST_METHOD2(AppHasHMIType,
- bool(const std::string& application_id,
- policy_table::AppHMIType hmi_type));
-
- MOCK_METHOD0(ResetCalculatedPermissions, void());
- MOCK_METHOD3(AddCalculatedPermissions,
- void(const std::string& device_id,
- const std::string& policy_app_id,
- const policy::Permissions& permissions));
- MOCK_METHOD3(IsPermissionsCalculated,
- bool(const std::string& device_id,
- const std::string& policy_app_id,
- policy::Permissions& permission));
- MOCK_CONST_METHOD0(GetPT, utils::SharedPtr<policy_table::Table>());
- MOCK_CONST_METHOD0(GetMetaInfo, const MetaInfo());
- MOCK_CONST_METHOD0(GetCertificate, std::string());
- MOCK_METHOD1(SetDecryptedCertificate, void(const std::string&));
- MOCK_METHOD1(set_settings, void(const PolicySettings* settings));
- MOCK_METHOD1(GetHMITypes,
- const policy_table::AppHMITypes*(const std::string& app_id));
- MOCK_METHOD1(GetGroups, const policy_table::Strings&(const PTString& app_id));
-
- MOCK_METHOD1(SetExternalConsentStatus, bool(const ExternalConsentStatus&));
- MOCK_METHOD0(GetExternalConsentStatus, ExternalConsentStatus());
- MOCK_METHOD0(GetExternalConsentEntities, ExternalConsentStatus());
- MOCK_METHOD1(GetGroupsWithSameEntities,
- GroupsByExternalConsentStatus(const ExternalConsentStatus&));
- MOCK_METHOD0(GetKnownLinksFromPT, std::map<std::string, std::string>());
- MOCK_METHOD1(SetExternalConsentForApp, void(const PermissionConsent&));
-};
-
-} // namespace policy_test
-} // namespace components
-} // namespace test
-
-#endif // SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_TEST_INCLUDE_POLICY_MOCK_CACHE_MANAGER_H_
diff --git a/src/components/policy/policy_external/test/policy_manager_impl_test_base.cc b/src/components/policy/policy_external/test/policy_manager_impl_test_base.cc
index ce34ca4400..0608799535 100644
--- a/src/components/policy/policy_external/test/policy_manager_impl_test_base.cc
+++ b/src/components/policy/policy_external/test/policy_manager_impl_test_base.cc
@@ -243,7 +243,7 @@ PolicyManagerImplTest2::PolicyManagerImplTest2()
, device_id_1_("XXX123456789ZZZ")
, device_id_2_("08-00-27-CE-76-FE")
, application_id_("1234")
- , app_storage_folder_("storage1")
+ , app_storage_folder_("storage_PolicyManagerImplTest2")
, preloaded_pt_filename_(kSdlPreloadedPtJson)
, in_memory_(true)
, policy_manager_(NULL)
diff --git a/src/components/policy/policy_regular/include/policy/policy_listener.h b/src/components/policy/policy_regular/include/policy/policy_listener.h
deleted file mode 100644
index 0170f421e4..0000000000
--- a/src/components/policy/policy_regular/include/policy/policy_listener.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- Copyright (c) 2016, 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.
- */
-
-#ifndef SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_POLICY_LISTENER_H_
-#define SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_POLICY_LISTENER_H_
-
-#include <queue>
-
-#include "policy/policy_types.h"
-#include "utils/custom_string.h"
-
-namespace policy {
-
-namespace custom_str = utils::custom_string;
-
-class PolicyListener {
- public:
- virtual ~PolicyListener() {}
- virtual void OnPermissionsUpdated(const std::string& policy_app_id,
- const Permissions& permissions,
- const policy::HMILevel& default_hmi) = 0;
- virtual void OnPermissionsUpdated(const std::string& policy_app_id,
- const Permissions& permissions) = 0;
- virtual void OnPendingPermissionChange(const std::string& policy_app_id) = 0;
- virtual void OnUpdateStatusChanged(const std::string&) = 0;
- virtual std::string OnCurrentDeviceIdUpdateRequired(
- const std::string& policy_app_id) = 0;
- virtual void OnSystemInfoUpdateRequired() = 0;
- virtual custom_str::CustomString GetAppName(
- const std::string& policy_app_id) = 0;
- virtual void OnUpdateHMIAppType(
- std::map<std::string, StringArray> app_hmi_types) = 0;
-
- /**
- * @brief CanUpdate allows to find active application
- * and check whether related device consented.
- *
- * @return true if there are at least one application has been registered
- * with consented device.
- */
- virtual bool CanUpdate() = 0;
-
- /**
- * @brief OnSnapshotCreated the notification which will be sent
- * when snapshot for PTU has been created.
- *
- * @param pt_string the snapshot
- *
- * @param retry_seconds retry sequence timeouts.
- *
- * @param timeout_exceed timeout.
- */
- virtual void OnSnapshotCreated(const BinaryMessage& pt_string) = 0;
-
- /**
- * @brief Make appropriate changes for related applications permissions and
- * notify them, if it possible
- * @param device_id Unique device id, which consent had been changed
- * @param device_consent Device consent, which is done by user
- */
- virtual void OnDeviceConsentChanged(const std::string& device_id,
- bool is_allowed) = 0;
-
- /**
- * @brief Sends OnAppPermissionsChanged notification to HMI
- * @param permissions contains parameter for OnAppPermisionChanged
- * @param policy_app_id contains policy application id
- */
- virtual void SendOnAppPermissionsChanged(
- const AppPermissions& permissions,
- const std::string& policy_app_id) const = 0;
-
- /**
- * @brief GetAvailableApps allows to obtain list of registered applications.
- */
- virtual void GetAvailableApps(std::queue<std::string>&) = 0;
-
- /**
- * @brief OnCertificateUpdated the callback which signals if certificate field
- * has been updated during PTU
- *
- * @param certificate_data the value of the updated field.
- */
- virtual void OnCertificateUpdated(const std::string& certificate_data) = 0;
-};
-} // namespace policy
-#endif // SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_POLICY_LISTENER_H_
diff --git a/src/components/telemetry_monitor/src/telemetry_monitor.cc b/src/components/telemetry_monitor/src/telemetry_monitor.cc
index 759b843961..88c484ffd4 100644
--- a/src/components/telemetry_monitor/src/telemetry_monitor.cc
+++ b/src/components/telemetry_monitor/src/telemetry_monitor.cc
@@ -1,34 +1,34 @@
/*
- * Copyright (c) 2014, 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.
- */
+* Copyright (c) 2014, 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 "telemetry_monitor/telemetry_monitor.h"
@@ -59,7 +59,7 @@ TelemetryMonitor::TelemetryMonitor(const std::string& server_address,
, ph_observer(this) {}
void TelemetryMonitor::Start() {
- streamer_ = new Streamer(this);
+ streamer_ = streamer_ ? streamer_ : new Streamer(this);
thread_ = threads::CreateThread("TelemetryMonitor", streamer_);
}
@@ -86,6 +86,7 @@ int16_t TelemetryMonitor::port() const {
TelemetryMonitor::~TelemetryMonitor() {
Stop();
+ delete streamer_;
}
void TelemetryMonitor::Init(
@@ -170,6 +171,7 @@ void Streamer::exitThreadMain() {
LOG4CXX_AUTO_TRACE(logger_);
Stop();
messages_.Shutdown();
+ ThreadDelegate::exitThreadMain();
}
void Streamer::Start() {
diff --git a/src/components/telemetry_monitor/test/telemetry_monitor_test.cc b/src/components/telemetry_monitor/test/telemetry_monitor_test.cc
index 5043524a06..090c7ab5b7 100644
--- a/src/components/telemetry_monitor/test/telemetry_monitor_test.cc
+++ b/src/components/telemetry_monitor/test/telemetry_monitor_test.cc
@@ -90,14 +90,14 @@ TEST(TelemetryMonitorTest, MessageProcess) {
EXPECT_CALL(am_observeble, SetTelemetryObserver(_));
EXPECT_CALL(transport_manager_mock, SetTelemetryObserver(_));
telemetry_monitor::TelemetryMonitor telemetry_monitor(server_address, port);
- StreamerMock streamer_mock(&telemetry_monitor);
+ StreamerMock* streamer_mock = new StreamerMock(&telemetry_monitor);
+ // streamer_mock will be freed by telemetry_monitor on destruction
telemetry_monitor.Start();
-
- telemetry_monitor.set_streamer(&streamer_mock);
+ telemetry_monitor.set_streamer(streamer_mock);
telemetry_monitor.Init(
&protocol_handler_mock, &am_observeble, &transport_manager_mock);
utils::SharedPtr<telemetry_monitor::MetricWrapper> test_metric;
- EXPECT_CALL(streamer_mock, PushMessage(test_metric));
+ EXPECT_CALL(*streamer_mock, PushMessage(test_metric));
telemetry_monitor.SendMetric(test_metric);
}
diff --git a/src/components/transport_manager/test/transport_manager_impl_test.cc b/src/components/transport_manager/test/transport_manager_impl_test.cc
index 14362050a2..c7cf3b2cb2 100644
--- a/src/components/transport_manager/test/transport_manager_impl_test.cc
+++ b/src/components/transport_manager/test/transport_manager_impl_test.cc
@@ -70,10 +70,10 @@ const uint32_t kAsyncExpectationsTimeout = 10000u;
class TransportManagerImplTest : public ::testing::Test {
protected:
TransportManagerImplTest()
- : tm_(settings)
- , device_handle_(1)
+ : device_handle_(1)
, mac_address_("MA:CA:DR:ES:S")
- , dev_info_(device_handle_, mac_address_, "TestDeviceName", "BTMAC") {}
+ , dev_info_(device_handle_, mac_address_, "TestDeviceName", "BTMAC")
+ , tm_(settings) {}
void SetUp() OVERRIDE {
resumption::LastStateImpl last_state_("app_storage_folder",
@@ -313,7 +313,6 @@ class TransportManagerImplTest : public ::testing::Test {
ASSERT_EQ(E_SUCCESS, tm_.Stop());
}
MockTransportManagerSettings settings;
- MockTransportManagerImpl tm_;
#ifdef TELEMETRY_MONITOR
MockTMTelemetryObserver mock_metric_observer_;
#endif // TELEMETRY_MONITOR
@@ -329,6 +328,7 @@ class TransportManagerImplTest : public ::testing::Test {
const DeviceInfo dev_info_;
DeviceList device_list_;
BaseErrorPtr error_;
+ MockTransportManagerImpl tm_;
};
TEST_F(TransportManagerImplTest, SearchDevices_AdaptersNotAdded) {
diff --git a/src/components/utils/include/utils/file_system.h b/src/components/utils/include/utils/file_system.h
index a46135a47b..22c200934f 100644
--- a/src/components/utils/include/utils/file_system.h
+++ b/src/components/utils/include/utils/file_system.h
@@ -38,6 +38,7 @@
#include <string>
#include <vector>
#include <iostream>
+#include <fstream>
namespace file_system {
diff --git a/src/components/utils/include/utils/log_message_loop_thread.h b/src/components/utils/include/utils/log_message_loop_thread.h
index deea1a07c0..d6a9edd072 100644
--- a/src/components/utils/include/utils/log_message_loop_thread.h
+++ b/src/components/utils/include/utils/log_message_loop_thread.h
@@ -66,6 +66,8 @@ class LogMessageLoopThread : public LogMessageLoopThreadTemplate {
LogMessageLoopThread();
~LogMessageLoopThread();
+ private:
+ LogMessageHandler* handler_;
DISALLOW_COPY_AND_ASSIGN(LogMessageLoopThread);
};
diff --git a/src/components/utils/src/custom_string.cc b/src/components/utils/src/custom_string.cc
index 8254a98180..545b28d9c3 100644
--- a/src/components/utils/src/custom_string.cc
+++ b/src/components/utils/src/custom_string.cc
@@ -172,6 +172,14 @@ bool CustomString::CompareIgnoreCase(const char* str) const {
return CompareIgnoreCase(CustomString(str));
}
+bool CustomString::Compare(const CustomString& str) const {
+ return mb_string_ == str.mb_string_;
+}
+
+bool CustomString::Compare(const char* str) const {
+ return Compare(CustomString(str));
+}
+
const char* CustomString::c_str() const {
return mb_string_.c_str();
}
diff --git a/src/components/utils/src/file_system.cc b/src/components/utils/src/file_system.cc
index d31582c8e1..62a91ad1f3 100644
--- a/src/components/utils/src/file_system.cc
+++ b/src/components/utils/src/file_system.cc
@@ -73,15 +73,8 @@ size_t file_system::DirectorySize(const std::string& path) {
size_t size = 0;
int32_t return_code = 0;
DIR* directory = NULL;
-
-#ifndef __QNXNTO__
struct dirent dir_element_;
struct dirent* dir_element = &dir_element_;
-#else
- char* direntbuffer = new char[offsetof(struct dirent, d_name) +
- pathconf(path.c_str(), _PC_NAME_MAX) + 1];
- struct dirent* dir_element = new (direntbuffer) dirent;
-#endif
struct dirent* result = NULL;
struct stat file_info = {0};
directory = opendir(path.c_str());
@@ -97,19 +90,12 @@ size_t file_system::DirectorySize(const std::string& path) {
if (file_system::IsDirectory(full_element_path)) {
size += DirectorySize(full_element_path);
} else {
- if (0 != stat(full_element_path.c_str(), &file_info)) {
- LOG4CXX_WARN_WITH_ERRNO(
- logger_, "Could not get file info: " << full_element_path);
- } else {
- size += file_info.st_size;
- }
+ stat(full_element_path.c_str(), &file_info);
+ size += file_info.st_size;
}
}
}
closedir(directory);
-#ifdef __QNXNTO__
- delete[] direntbuffer;
-#endif
return size;
}
@@ -245,15 +231,8 @@ bool file_system::DeleteFile(const std::string& name) {
void file_system::remove_directory_content(const std::string& directory_name) {
int32_t return_code = 0;
DIR* directory = NULL;
-#ifndef __QNXNTO__
struct dirent dir_element_;
struct dirent* dir_element = &dir_element_;
-#else
- char* direntbuffer =
- new char[offsetof(struct dirent, d_name) +
- pathconf(directory_name.c_str(), _PC_NAME_MAX) + 1];
- struct dirent* dir_element = new (direntbuffer) dirent;
-#endif
struct dirent* result = NULL;
directory = opendir(directory_name.c_str());
@@ -283,9 +262,6 @@ void file_system::remove_directory_content(const std::string& directory_name) {
}
closedir(directory);
-#ifdef __QNXNTO__
- delete[] direntbuffer;
-#endif
}
bool file_system::RemoveDirectory(const std::string& directory_name,
@@ -321,15 +297,8 @@ std::vector<std::string> file_system::ListFiles(
int32_t return_code = 0;
DIR* directory = NULL;
-#ifndef __QNXNTO__
struct dirent dir_element_;
struct dirent* dir_element = &dir_element_;
-#else
- char* direntbuffer =
- new char[offsetof(struct dirent, d_name) +
- pathconf(directory_name.c_str(), _PC_NAME_MAX) + 1];
- struct dirent* dir_element = new (direntbuffer) dirent;
-#endif
struct dirent* result = NULL;
directory = opendir(directory_name.c_str());
@@ -349,10 +318,6 @@ std::vector<std::string> file_system::ListFiles(
closedir(directory);
}
-#ifdef __QNXNTO__
- delete[] direntbuffer;
-#endif
-
return listFiles;
}
@@ -430,11 +395,7 @@ uint64_t file_system::GetFileModificationTime(const std::string& path) {
if (0 != stat(path.c_str(), &info)) {
LOG4CXX_WARN_WITH_ERRNO(logger_, "Could not get file mod time: " << path);
}
-#ifndef __QNXNTO__
return static_cast<uint64_t>(info.st_mtim.tv_nsec);
-#else
- return static_cast<uint64_t>(info.st_mtime);
-#endif
}
bool file_system::CopyFile(const std::string& src, const std::string& dst) {
diff --git a/src/components/utils/src/log_message_loop_thread.cc b/src/components/utils/src/log_message_loop_thread.cc
index 77bc8107eb..2b7f28fbfd 100644
--- a/src/components/utils/src/log_message_loop_thread.cc
+++ b/src/components/utils/src/log_message_loop_thread.cc
@@ -44,12 +44,14 @@ void LogMessageHandler::Handle(const LogMessage message) {
}
LogMessageLoopThread::LogMessageLoopThread()
- : LogMessageLoopThreadTemplate("Logger", new LogMessageHandler()) {}
+ : LogMessageLoopThreadTemplate("Logger",
+ handler_ = new LogMessageHandler()) {}
LogMessageLoopThread::~LogMessageLoopThread() {
// we'll have to drop messages
// while deleting logger thread
logger_status = DeletingLoggerThread;
+ delete handler_;
}
} // namespace logger
diff --git a/src/components/utils/src/threads/thread_delegate.cc b/src/components/utils/src/threads/thread_delegate.cc
index 7bdce000da..917603f92c 100644
--- a/src/components/utils/src/threads/thread_delegate.cc
+++ b/src/components/utils/src/threads/thread_delegate.cc
@@ -52,6 +52,7 @@ void ThreadDelegate::exitThreadMain() {
} else {
pthread_cancel(thread_->thread_handle());
}
+ thread_ = NULL;
}
}
diff --git a/src/components/utils/test/async_runner_test.cc b/src/components/utils/test/async_runner_test.cc
index 3dd6383588..65abad65c2 100644
--- a/src/components/utils/test/async_runner_test.cc
+++ b/src/components/utils/test/async_runner_test.cc
@@ -30,57 +30,72 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <ctime>
#include <stdlib.h>
-
-#include "gtest/gtest.h"
-
+#include <ctime>
+#include <memory>
#include "utils/lock.h"
-#include "utils/conditional_variable.h"
#include "utils/threads/async_runner.h"
+#include "utils/conditional_variable.h"
+#include "utils/shared_ptr.h"
+#include "utils/make_shared.h"
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
namespace test {
namespace components {
-namespace utils_test {
+namespace utils {
-using namespace sync_primitives;
using namespace threads;
namespace {
-uint32_t check_value = 0;
+size_t kCheckValue = 0u;
+const size_t kDelegatesAmount = 4u;
}
// ThreadDelegate successor
class TestThreadDelegate : public ThreadDelegate {
public:
+ TestThreadDelegate(sync_primitives::ConditionalVariable& cond_var,
+ sync_primitives::Lock& test_lock)
+ : cond_var_(cond_var), test_lock_(test_lock) {}
+
void threadMain() {
- ++check_value;
+ sync_primitives::AutoLock lock(test_lock_);
+ ++kCheckValue;
+ cond_var_.NotifyOne();
}
+
+ protected:
+ sync_primitives::ConditionalVariable& cond_var_;
+ sync_primitives::Lock& test_lock_;
+};
+
+class MockThreadDelegate : public ThreadDelegate {
+ public:
+ MOCK_METHOD0(threadMain, void());
+ MOCK_METHOD0(exitThreadMain, void());
};
class AsyncRunnerTest : public ::testing::Test {
public:
- AsyncRunnerTest() : kDelegatesNum_(1), asr_pt_(NULL) {
+ AsyncRunnerTest() {
+ // Clear global value before test execution
+ kCheckValue = 0;
CreateAsyncRunner();
CreateThreadsArray();
}
~AsyncRunnerTest() {
- DeleteAsyncRunner();
DeleteThreadsArray();
}
protected:
- Lock test_lock_;
- uint32_t kDelegatesNum_;
- ConditionalVariable cond_var_;
- TestThreadDelegate** delegates_;
- AsyncRunner* asr_pt_;
+ ThreadDelegate** delegates_;
+ ::utils::SharedPtr<AsyncRunner> async_runner_;
void CreateThreadsArray() {
- srand(std::time(NULL));
- kDelegatesNum_ = (rand() % 20 + 1);
- delegates_ = new TestThreadDelegate* [kDelegatesNum_];
+ delegates_ = new ThreadDelegate* [kDelegatesAmount];
}
void DeleteThreadsArray() {
@@ -88,53 +103,38 @@ class AsyncRunnerTest : public ::testing::Test {
}
void CreateAsyncRunner() {
- asr_pt_ = new AsyncRunner("test");
- }
- void DeleteAsyncRunner() {
- delete asr_pt_;
+ async_runner_ = ::utils::MakeShared<AsyncRunner>("test");
}
};
TEST_F(AsyncRunnerTest, ASyncRunManyDelegates_ExpectSuccessfulAllDelegatesRun) {
- AutoLock lock(test_lock_);
- // Clear global value before test
- check_value = 0;
// Create Delegates and run
- for (unsigned int i = 0; i < kDelegatesNum_; ++i) {
- delegates_[i] = new TestThreadDelegate();
- asr_pt_->AsyncRun(delegates_[i]);
+ sync_primitives::ConditionalVariable cond_var;
+ sync_primitives::Lock test_lock;
+ for (size_t i = 0; i < kDelegatesAmount; ++i) {
+ sync_primitives::AutoLock lock(test_lock);
+ delegates_[i] = new TestThreadDelegate(cond_var, test_lock);
+ async_runner_->AsyncRun(delegates_[i]);
+ // Wait for delegate to be run
+ cond_var.WaitFor(lock, 1500);
}
- // Wait for 2 secs. Give this time to delegates to be run
- cond_var_.WaitFor(lock, 2000);
- // Expect all delegates run successfully
- EXPECT_EQ(kDelegatesNum_, check_value);
+ // Expect all delegates started successfully
+ EXPECT_EQ(kDelegatesAmount, kCheckValue);
}
-// TODO(VVeremjova) APPLINK-12834 Sometimes delegates do not run
-TEST_F(AsyncRunnerTest,
- DISABLED_RunManyDelegatesAndStop_ExpectSuccessfulDelegatesStop) {
- AutoLock lock(test_lock_);
- // Clear global value before test
- check_value = 0;
- // Create Delegates
- for (unsigned int i = 0; i < kDelegatesNum_; ++i) {
- delegates_[i] = new TestThreadDelegate();
- }
- // Wait for 2 secs
- cond_var_.WaitFor(lock, 2000);
- // Run created delegates
- for (unsigned int i = 0; i < kDelegatesNum_; ++i) {
- if (kDelegatesNum_ > 1) {
- if (i == kDelegatesNum_ / 2) {
- asr_pt_->Stop();
- }
- }
- asr_pt_->AsyncRun(delegates_[i]);
+TEST_F(AsyncRunnerTest, StopThenRun_ExpectDelegateNotStarted) {
+ // Create Delegate mock
+ MockThreadDelegate mock_thread_delegate;
+ // Check that delegate was not started due to Stop() called before AsyncRun()
+ EXPECT_CALL(mock_thread_delegate, threadMain()).Times(0);
+ {
+ ::utils::SharedPtr<AsyncRunner> async_runner =
+ ::utils::MakeShared<AsyncRunner>("test");
+ async_runner->Stop();
+ async_runner->AsyncRun(&mock_thread_delegate);
}
- // Expect 3 delegates run successlully. The other stopped.
- EXPECT_EQ(kDelegatesNum_ / 2, check_value);
}
-} // namespace utils_test
+} // namespace utils
} // namespace components
} // namespace test
diff --git a/src/components/utils/test/conditional_variable_test.cc b/src/components/utils/test/conditional_variable_test.cc
index 86c9dfa2e0..524d53cafa 100644
--- a/src/components/utils/test/conditional_variable_test.cc
+++ b/src/components/utils/test/conditional_variable_test.cc
@@ -123,7 +123,7 @@ TEST_F(
CheckWaitForWithTimeout1sec_ThreadBlockedForTimeout_ExpectSuccessfulWakeUp) {
sync_primitives::AutoLock test_lock(test_mutex_);
sync_primitives::ConditionalVariable::WaitStatus wait_st =
- cond_var_.WaitFor(test_lock, 1000);
+ cond_var_.WaitFor(test_lock, 10);
EXPECT_EQ(sync_primitives::ConditionalVariable::kTimeout, wait_st);
}
diff --git a/src/components/utils/test/messagemeter_test.cc b/src/components/utils/test/messagemeter_test.cc
index efaaa41252..4ec14ac1cc 100644
--- a/src/components/utils/test/messagemeter_test.cc
+++ b/src/components/utils/test/messagemeter_test.cc
@@ -126,7 +126,8 @@ TEST(MessageMeterTest, AddingWithNullTimeRange) {
}
}
-TEST_P(MessageMeterTest, TrackMessage_AddingOverPeriod_CorrectCountOfMessages) {
+TEST_P(MessageMeterTest,
+ DISABLED_TrackMessage_AddingOverPeriod_CorrectCountOfMessages) {
size_t messages = 0;
const TimevalStruct start_time = date_time::DateTime::getCurrentTime();
// Add messages for less range period
@@ -150,7 +151,7 @@ TEST_P(MessageMeterTest, TrackMessage_AddingOverPeriod_CorrectCountOfMessages) {
}
TEST_P(MessageMeterTest,
- TrackMessage_AddingOverPeriodMultiIds_CorrectCountOfMessages) {
+ DISABLED_TrackMessage_AddingOverPeriodMultiIds_CorrectCountOfMessages) {
size_t messages = 0;
const TimevalStruct start_time = date_time::DateTime::getCurrentTime();
// Add messages for less range period
@@ -184,7 +185,8 @@ TEST_P(MessageMeterTest,
}
}
-TEST_P(MessageMeterTest, Frequency_CountingOverPeriod_CorrectCountOfMessages) {
+TEST_P(MessageMeterTest,
+ DISABLED_Frequency_CountingOverPeriod_CorrectCountOfMessages) {
const size_t one_message = 1;
const TimevalStruct start_time = date_time::DateTime::getCurrentTime();
EXPECT_EQ(one_message, meter.TrackMessage(id1));
@@ -206,7 +208,7 @@ TEST_P(MessageMeterTest, Frequency_CountingOverPeriod_CorrectCountOfMessages) {
}
}
-TEST_P(MessageMeterTest, CountingOutOfPeriod) {
+TEST_P(MessageMeterTest, DISABLED_CountingOutOfPeriod) {
const size_t one_message = 1;
EXPECT_EQ(one_message, meter.TrackMessage(id1));
EXPECT_EQ(one_message, meter.TrackMessage(id2));
diff --git a/src/components/utils/test/scope_guard_test.cc b/src/components/utils/test/scope_guard_test.cc
index 85abbd90de..5e685d6aba 100644
--- a/src/components/utils/test/scope_guard_test.cc
+++ b/src/components/utils/test/scope_guard_test.cc
@@ -43,7 +43,7 @@ using ::utils::MakeGuard;
using ::utils::MakeObjGuard;
using ::testing::Mock;
-class TestObject {
+class TestCalleeObject {
public:
MOCK_METHOD0(function_to_call, void());
MOCK_METHOD1(function_to_call_with_param, void(void*));
@@ -68,21 +68,21 @@ TEST(ScopeGuardTest, CallFreeFunctionWithParam) {
}
TEST(ScopeGuardTest, CallObjectFunction) {
- TestObject obj;
+ TestCalleeObject obj;
Mock::AllowLeak(&obj); // Google tests bug
EXPECT_CALL(obj, function_to_call()).Times(1);
{
- ScopeGuard guard = MakeObjGuard(obj, &TestObject::function_to_call);
+ ScopeGuard guard = MakeObjGuard(obj, &TestCalleeObject::function_to_call);
UNUSED(guard);
}
}
TEST(ScopeGuardTest, CallObjectFunctionWithParam) {
- TestObject obj;
+ TestCalleeObject obj;
EXPECT_CALL(obj, function_to_call_with_param(&obj)).Times(1);
{
ScopeGuard guard =
- MakeObjGuard(obj, &TestObject::function_to_call_with_param, &obj);
+ MakeObjGuard(obj, &TestCalleeObject::function_to_call_with_param, &obj);
UNUSED(guard);
}
}
@@ -98,20 +98,20 @@ TEST(ScopeGuardTest, DismissCallFreeFunctionWithParam) {
}
TEST(ScopeGuardTest, DismissCallObjectFunction) {
- TestObject obj;
+ TestCalleeObject obj;
EXPECT_CALL(obj, function_to_call()).Times(0);
{
- ScopeGuard guard = MakeObjGuard(obj, &TestObject::function_to_call);
+ ScopeGuard guard = MakeObjGuard(obj, &TestCalleeObject::function_to_call);
guard.Dismiss();
}
}
TEST(ScopeGuardTest, DismissCallObjectFunctionWithParam) {
- TestObject obj;
+ TestCalleeObject obj;
EXPECT_CALL(obj, function_to_call_with_param(&obj)).Times(0);
{
ScopeGuard guard =
- MakeObjGuard(obj, &TestObject::function_to_call_with_param, &obj);
+ MakeObjGuard(obj, &TestCalleeObject::function_to_call_with_param, &obj);
guard.Dismiss();
}
}
diff --git a/src/components/utils/test/shared_ptr_test.cc b/src/components/utils/test/shared_ptr_test.cc
index a30f2f66eb..99fe4f7dd7 100644
--- a/src/components/utils/test/shared_ptr_test.cc
+++ b/src/components/utils/test/shared_ptr_test.cc
@@ -507,7 +507,7 @@ TEST(SharedPtrTest, ValidMethodTest_ExpectCorrectValidation) {
ASSERT_FALSE(p2.valid());
}
-TEST(SharedPtrTest, StressTest) {
+TEST(SharedPtrTest, DISABLED_StressTest) {
// Arrange
const size_t kNumIterations = 1024U * 1024U;
diff --git a/src/components/utils/test/sqlite_wrapper/sql_query_test.cc b/src/components/utils/test/sqlite_wrapper/sql_query_test.cc
index b481e45fd3..c10c26a2c7 100644
--- a/src/components/utils/test/sqlite_wrapper/sql_query_test.cc
+++ b/src/components/utils/test/sqlite_wrapper/sql_query_test.cc
@@ -97,7 +97,9 @@ class SQLQueryTest : public ::testing::Test {
};
sqlite3* SQLQueryTest::conn = 0;
-const std::string SQLQueryTest::kDatabaseName = "test-query";
+
+// mounting /tmp as tmpfs will descrease utils unit tests runing time
+const std::string SQLQueryTest::kDatabaseName = "/tmp/test-query";
TEST_F(SQLQueryTest, Query_CreateQuery_QueryInDBEqualCreated) {
// arrange