summaryrefslogtreecommitdiff
path: root/src/components/functional_module
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/functional_module')
-rw-r--r--src/components/functional_module/CMakeLists.txt58
-rw-r--r--src/components/functional_module/include/functional_module/function_ids.h63
-rw-r--r--src/components/functional_module/include/functional_module/generic_module.h180
-rw-r--r--src/components/functional_module/include/functional_module/module_observer.h54
-rw-r--r--src/components/functional_module/include/functional_module/plugin_manager.h159
-rw-r--r--src/components/functional_module/include/functional_module/timer/module_timer.h246
-rw-r--r--src/components/functional_module/include/functional_module/timer/timer_director.h92
-rw-r--r--src/components/functional_module/src/generic_module.cc54
-rw-r--r--src/components/functional_module/src/plugin_manager.cc396
-rw-r--r--src/components/functional_module/src/timer/timer_director.cc156
-rw-r--r--src/components/functional_module/test/CMakeLists.txt53
-rw-r--r--src/components/functional_module/test/include/driver_generic_module_test.h80
-rw-r--r--src/components/functional_module/test/include/mock_application.h250
-rw-r--r--src/components/functional_module/test/include/mock_module_observer.h50
-rw-r--r--src/components/functional_module/test/include/mock_service.h76
-rw-r--r--src/components/functional_module/test/include/module_timer_test.h56
-rw-r--r--src/components/functional_module/test/plugins/CMakeLists.txt17
-rw-r--r--src/components/functional_module/test/plugins/mock_generic_module.cc23
-rw-r--r--src/components/functional_module/test/plugins/mock_generic_module.h71
-rw-r--r--src/components/functional_module/test/src/generic_module_test.cc106
-rw-r--r--src/components/functional_module/test/src/module_timer_test.cc123
-rw-r--r--src/components/functional_module/test/src/plugin_manager_test.cc148
22 files changed, 0 insertions, 2511 deletions
diff --git a/src/components/functional_module/CMakeLists.txt b/src/components/functional_module/CMakeLists.txt
deleted file mode 100644
index 07db91fc38..0000000000
--- a/src/components/functional_module/CMakeLists.txt
+++ /dev/null
@@ -1,58 +0,0 @@
-if (ENABLE_GCOV)
- set(GCOV_FLAGS "-ftest-coverage -fprofile-arcs")
-else()
- set(GCOV_FLAGS "")
-endif()
-
-set(CMAKE_CXX_FLAGS "-fPIC -std=gnu++0x -Wno-deprecated-declarations -Wall -Werror ${GCOV_FLAGS}")
-
-if (CMAKE_BUILD_TYPE)
- if (${CMAKE_BUILD_TYPE} STREQUAL "Release")
- set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
- set(CMAKE_CXX_FLAGS_DEBUG "")
- else ()
- set(CMAKE_CXX_FLAGS_RELEASE "")
- set(CMAKE_CXX_FLAGS_DEBUG "-g3 -ggdb3 -DDEBUG")
- endif()
-endif()
-
-set(GCOV gcov)
-
-include_directories (
- ${COMPONENTS_DIR}/functional_module/include/
- ${COMPONENTS_DIR}/remote_control/include/
- ${COMPONENTS_DIR}/include/
- ${COMPONENTS_DIR}/application_manager/include
- ${COMPONENTS_DIR}/connection_handler/include/
- ${COMPONENTS_DIR}/utils/include
- ${POLICY_PATH}/include/
- ${POLICY_GLOBAL_INCLUDE_PATH}/
- ${COMPONENTS_DIR}/config_profile/include
- ${COMPONENTS_DIR}/smart_objects/include
- ${JSONCPP_INCLUDE_DIRECTORY}
- ${LOG4CXX_INCLUDE_DIRECTORY}
- ${CMAKE_BINARY_DIR}/src/components/
-
- ${COMPONENTS_DIR}/application_manager/test/include/
-)
-
-set (SOURCES
- ./src/generic_module.cc
- ./src/plugin_manager.cc
- ./src/timer/timer_director.cc
-)
-set (LIBRARIES
- ApplicationManager
- jsoncpp
-)
-
-add_library("FunctionalModule" ${SOURCES})
-target_link_libraries("FunctionalModule" ${LIBRARIES} )
-
-if(ENABLE_LOG)
- target_link_libraries("FunctionalModule" log4cxx -L${LOG4CXX_LIBS_DIRECTORY} ${GCOV})
-endif()
-
-if(BUILD_TESTS)
- add_subdirectory(test)
-endif()
diff --git a/src/components/functional_module/include/functional_module/function_ids.h b/src/components/functional_module/include/functional_module/function_ids.h
deleted file mode 100644
index 1a504df6c9..0000000000
--- a/src/components/functional_module/include/functional_module/function_ids.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (c) 2017, Ford Motor Company
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of the Ford Motor Company nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef SRC_COMPONENTS_FUNCTIONAL_MODULE_INCLUDE_FUNCTIONAL_MODULE_FUNCTION_IDS_H_
-#define SRC_COMPONENTS_FUNCTIONAL_MODULE_INCLUDE_FUNCTIONAL_MODULE_FUNCTION_IDS_H_
-#include "interfaces/MOBILE_API.h"
-#include "interfaces/HMI_API.h"
-
-namespace functional_modules {
-
-enum RCFunctionID {
- // Remote SDL functions ids
- BUTTON_PRESS = mobile_apis::FunctionID::ButtonPressID,
- GET_INTERIOR_VEHICLE_DATA = mobile_apis::FunctionID::GetInteriorVehicleDataID,
- SET_INTERIOR_VEHICLE_DATA = mobile_apis::FunctionID::SetInteriorVehicleDataID,
- ON_INTERIOR_VEHICLE_DATA = mobile_apis::FunctionID::OnInteriorVehicleDataID,
- ON_REMOTE_CONTROL_SETTINGS = hmi_apis::FunctionID::RC_OnRemoteControlSettings,
-};
-
-namespace hmi_api {
-const char get_interior_vehicle_data[] = "RC.GetInteriorVehicleData";
-const char set_interior_vehicle_data[] = "RC.SetInteriorVehicleData";
-const char on_interior_vehicle_data[] = "RC.OnInteriorVehicleData";
-const char button_press[] = "Buttons.ButtonPress";
-const char on_remote_control_settings[] = "RC.OnRemoteControlSettings";
-
-const char get_user_consent[] = "RC.GetInteriorVehicleDataConsent";
-const char on_app_deactivated[] = "BasicCommunication.OnAppDeactivated";
-const char sdl_activate_app[] = "SDL.ActivateApp";
-}
-
-} // namespace functional_modules
-
-#endif // SRC_COMPONENTS_FUNCTIONAL_MODULE_INCLUDE_FUNCTIONAL_MODULE_FUNCTION_IDS_H_
diff --git a/src/components/functional_module/include/functional_module/generic_module.h b/src/components/functional_module/include/functional_module/generic_module.h
deleted file mode 100644
index 15d572be6d..0000000000
--- a/src/components/functional_module/include/functional_module/generic_module.h
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Copyright (c) 2017, Ford Motor Company
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of the Ford Motor Company nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef SRC_COMPONENTS_FUNCTIONAL_MODULE_INCLUDE_FUNCTIONAL_MODULE_GENERIC_MODULE_H_
-#define SRC_COMPONENTS_FUNCTIONAL_MODULE_INCLUDE_FUNCTIONAL_MODULE_GENERIC_MODULE_H_
-
-#include <deque>
-#include <string>
-#include "functional_module/module_observer.h"
-#include "functional_module/function_ids.h"
-#include "utils/shared_ptr.h"
-#include "application_manager/service.h"
-
-namespace functional_modules {
-
-/**
- * @brief The PolicyEvent enum defines events related to policy
- */
-enum PolicyEvent { kApplicationPolicyUpdated = 0, kApplicationsDisabled };
-
-/**
- * @brief The ApplicationEvent enum defines events related to single application
- */
-enum ApplicationEvent { kApplicationExit = 0, kApplicationUnregistered };
-
-enum ProcessResult {
- NONE = -1,
- PROCESSED,
- PARTIALLY_PROCESSED,
- CANNOT_PROCESS,
- FAILED
-};
-
-enum ServiceState { IDLE = 0, SUSPENDED, LOWVOLTAGE, HMI_ADAPTER_INITIALIZED };
-
-typedef std::string HMIFunctionID;
-
-class GenericModule;
-typedef utils::SharedPtr<GenericModule> ModulePtr;
-
-struct PluginInfo {
- std::string name;
- int version;
- std::deque<RCFunctionID> rc_function_list;
- std::deque<HMIFunctionID> hmi_function_list;
-};
-
-class GenericModule {
- public:
- typedef std::deque<ModuleObserver*> Observers;
-
- virtual ~GenericModule();
- ModuleID GetModuleID() const {
- return kModuleId_;
- }
- virtual PluginInfo GetPluginInfo() const = 0;
-
- /**
- * @brief Setter for service (interface for plugin t access SDL functionality)
- * @param service pointer to new service instance
- */
- virtual void set_service(application_manager::ServicePtr service);
-
- /**
- * @brief Returns pointer to SDL core service interface
- * @return pointer to core service interface
- */
- virtual application_manager::ServicePtr service();
-
- virtual ProcessResult ProcessMessage(application_manager::MessagePtr msg) = 0;
- virtual ProcessResult ProcessHMIMessage(
- application_manager::MessagePtr msg) = 0;
- virtual void OnServiceStateChanged(ServiceState state);
-
- /**
- * @brief Adds pointer to observer of module to be notified about
- * exceptional sutiations in module.
- * Raw pointer is passed to avoid circular dependencies.
- * Module is not responsible for freeing observer's memory.
- */
- void AddObserver(ModuleObserver* const observer);
-
- /**
- * @brief Removes pointer to observer of module when it's no loger
- * wants to be notified about exceptional sutiations in module.
- * Raw pointer is passed to avoid circular dependencies.
- * Module is not responsible for freeing observer's memory.
- */
- void RemoveObserver(ModuleObserver* const observer);
-
- /**
- * @brief Remove extension created for specified application
- * @param app_id application id
- */
- virtual void RemoveAppExtension(uint32_t app_id) = 0;
-
- /**
- * @brief Check registering app can be handled by plugin
- * @param msg Registration message
- * @param app Application basis already create by Core
- */
- virtual bool IsAppForPlugin(
- application_manager::ApplicationSharedPtr app) = 0;
-
- /**
- * @brief Notify about change of HMILevel of plugin's app
- * @param app App with new HMILevel
- * @param old_level Old HMILevel of app
- */
- virtual void OnAppHMILevelChanged(
- application_manager::ApplicationSharedPtr app,
- mobile_apis::HMILevel::eType old_level) = 0;
-
- /**
- * @brief OnApplicationEvent Processes application related events
- * @param event Event
- * @param application Pointer to application struct
- */
- virtual void OnApplicationEvent(
- ApplicationEvent event,
- application_manager::ApplicationSharedPtr application) = 0;
-
- /**
- * @brief OnPolicyEvent Processes policy related events
- * @param event Policy event
- */
- virtual void OnPolicyEvent(PolicyEvent event) = 0;
-
- protected:
- explicit GenericModule(ModuleID module_id);
- void NotifyObservers(ModuleObserver::Errors error);
-
- /**
- * @brief Remove extension for all applications
- */
- virtual void RemoveAppExtensions() = 0;
-
- private:
- application_manager::ServicePtr service_;
- const ModuleID kModuleId_;
-
- Observers observers_;
- ServiceState state_;
-
- friend class DriverGenericModuleTest;
- DISALLOW_COPY_AND_ASSIGN(GenericModule);
-};
-
-} // namespace functional_modules
-
-#endif // SRC_COMPONENTS_FUNCTIONAL_MODULE_INCLUDE_FUNCTIONAL_MODULE_GENERIC_MODULE_H_
diff --git a/src/components/functional_module/include/functional_module/module_observer.h b/src/components/functional_module/include/functional_module/module_observer.h
deleted file mode 100644
index a5e34db040..0000000000
--- a/src/components/functional_module/include/functional_module/module_observer.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2017, Ford Motor Company
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of the Ford Motor Company nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef SRC_COMPONENTS_FUNCTIONAL_MODULE_INCLUDE_FUNCTIONAL_MODULE_MODULE_OBSERVER_H_
-#define SRC_COMPONENTS_FUNCTIONAL_MODULE_INCLUDE_FUNCTIONAL_MODULE_MODULE_OBSERVER_H_
-
-namespace functional_modules {
-
-typedef int ModuleID;
-
-class ModuleObserver {
- public:
- enum Errors { NONE = -1, OUT_OF_MEMORY, FS_FAILURE };
- virtual ~ModuleObserver() {}
-
- /**
- * @brief OnError callback for module to notify SDL about internal error
- * @param error error type
- * @param module_id module that triggered error
- */
- virtual void OnError(Errors error, ModuleID module_id) = 0;
-};
-} // namespace functional_modules {
-
-#endif // SRC_COMPONENTS_FUNCTIONAL_MODULE_INCLUDE_FUNCTIONAL_MODULE_MODULE_OBSERVER_H_
diff --git a/src/components/functional_module/include/functional_module/plugin_manager.h b/src/components/functional_module/include/functional_module/plugin_manager.h
deleted file mode 100644
index c573d843b2..0000000000
--- a/src/components/functional_module/include/functional_module/plugin_manager.h
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Copyright (c) 2017, Ford Motor Company
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of the Ford Motor Company nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef SRC_COMPONENTS_FUNCTIONAL_MODULE_INCLUDE_FUNCTIONAL_MODULE_PLUGIN_MANAGER_H_
-#define SRC_COMPONENTS_FUNCTIONAL_MODULE_INCLUDE_FUNCTIONAL_MODULE_PLUGIN_MANAGER_H_
-
-#include <map>
-#include <string>
-#include "functional_module/generic_module.h"
-#include "application_manager/service.h"
-#include "application_manager/message.h"
-
-namespace functional_modules {
-
-class PluginManager : public ModuleObserver {
- public:
- PluginManager();
- ~PluginManager();
- typedef std::map<ModuleID, ModulePtr> Modules;
-
- /**
- * @brief LoadPlugins initialize loading plugins
- * @param plugin_path path to search to plugin shared libraries
- * @return count of loaded plugins
- */
- int LoadPlugins(const std::string& plugin_path);
-
- /**
- * @brief UnloadPlugins unload from memory all plugins
- */
- void UnloadPlugins();
-
- /**
- * @brief IsMessageForPlugin Verifies whether mobile message will be processed
- * by plugins
- * @param msg Mobile message
- * @return True if any of plugins will process the message, otherwise - false
- */
- bool IsMessageForPlugin(application_manager::MessagePtr msg);
-
- /**
- * @brief IsHMIMessageForPlugin Verifies whether HMI message will be processed
- * by plugins
- * @param msg HMI message
- * @return True if any of plugins will process the message, otherwise - false
- */
- bool IsHMIMessageForPlugin(application_manager::MessagePtr msg);
-
- /**
- * @brief ProcessMessage forwards mobile message to modules if any is
- * subsribed for the message.
- * @param msg Mobile message to process
- * @return Result of processing
- */
- ProcessResult ProcessMessage(application_manager::MessagePtr msg);
-
- /**
- * @brief ProcessHMIMessage forwards HMI message to modules if any is
- * subscribed for the message
- * @param msg HMI message to process
- * @return Result of processing
- */
- ProcessResult ProcessHMIMessage(application_manager::MessagePtr msg);
- void SetServiceHandler(application_manager::ServicePtr service) {
- service_ = service;
- }
- void OnServiceStateChanged(ServiceState state);
- void OnError(ModuleObserver::Errors error, ModuleID module_id) FINAL;
-
- /**
- * @brief Remove extension created for specified application
- * @param app_id application id
- */
- void RemoveAppExtension(uint32_t app_id);
-
- /**
- * @brief Check if app cooperates with one or more plugins, init it
- * inside plugin accordingly if needed.
- * @param app Application in question.
- */
- bool IsAppForPlugins(application_manager::ApplicationSharedPtr app);
-
- /**
- * Check if app cooperates with plugin
- * @param app application
- * @param module_id unique identifier of plugin
- * @return true if application cooperates with this plugin
- */
- bool IsAppForPlugin(application_manager::ApplicationSharedPtr app,
- ModuleID module_id) const;
-
- /**
- * @brief Notify plugins about change of HMILevel of app
- * if app is related to plugin
- * @param app App with new HMILevel
- * @param old_level Old HMILevel of app
- */
- void OnAppHMILevelChanged(application_manager::ApplicationSharedPtr app,
- mobile_apis::HMILevel::eType old_level);
-
- /**
- * @brief OnApplicationEvent Notifies modules on certain application events
- * @param event Event
- * @param application Pointer to application struct
- */
- void OnApplicationEvent(
- functional_modules::ApplicationEvent event,
- application_manager::ApplicationSharedPtr application);
-
- /**
- * @brief OnPolicyEvent Notifies modules on certain events from policy
- * @param event Policy event
- */
- void OnPolicyEvent(functional_modules::PolicyEvent event);
-
- Modules& plugins();
-
- private:
- Modules plugins_;
- std::map<ModuleID, void*> dlls_;
- std::map<RCFunctionID, ModulePtr> mobile_subscribers_;
- std::map<HMIFunctionID, ModulePtr> hmi_subscribers_;
- application_manager::ServicePtr service_;
-
- DISALLOW_COPY_AND_ASSIGN(PluginManager);
-};
-
-} // namespace functional_modules
-
-#endif // SRC_COMPONENTS_FUNCTIONAL_MODULE_INCLUDE_FUNCTIONAL_MODULE_PLUGIN_MANAGER_H_
diff --git a/src/components/functional_module/include/functional_module/timer/module_timer.h b/src/components/functional_module/include/functional_module/timer/module_timer.h
deleted file mode 100644
index e24259241b..0000000000
--- a/src/components/functional_module/include/functional_module/timer/module_timer.h
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * Copyright (c) 2017, Ford Motor Company
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of the Ford Motor Company nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef SRC_COMPONENTS_FUNCTIONAL_MODULE_INCLUDE_FUNCTIONAL_MODULE_TIMER_MODULE_TIMER_H_
-#define SRC_COMPONENTS_FUNCTIONAL_MODULE_INCLUDE_FUNCTIONAL_MODULE_TIMER_MODULE_TIMER_H_
-
-#include <list>
-#include <deque>
-#include <algorithm>
-#include <time.h>
-#include "utils/lock.h"
-
-namespace functional_modules {
-
-typedef unsigned int TimeUnit; // seconds
-
-class Trackable {
- public:
- Trackable() : start_time_(0) {}
- virtual ~Trackable() {}
-
- /**
- * @brief custom_interval getter for custom interval
- * @return return timer interval for trackable message
- */
- virtual TimeUnit custom_interval() const {
- return 0;
- }
-
- /**
- * @brief start_time getter for start time of message
- * @return start time of message
- */
- virtual TimeUnit start_time() const {
- return start_time_;
- }
-
- /**
- * @brief set_start_time setting start time of message
- * @param start_time start time
- */
- virtual void set_start_time(TimeUnit start_time) {
- start_time_ = start_time;
- }
-
- private:
- TimeUnit start_time_;
-};
-
-template <class Trackable>
-class TimerObserver {
- public:
- virtual ~TimerObserver() {}
- virtual void OnTimeoutTriggered(const Trackable& expired) = 0;
-};
-
-template <class Trackable>
-class ModuleTimer {
- public:
- ModuleTimer();
- ~ModuleTimer();
- void set_period(TimeUnit period) {
- period_ = period;
- }
- TimeUnit period() const {
- return period_;
- }
- void AddObserver(TimerObserver<Trackable>* observer);
- void RemoveObserver(TimerObserver<Trackable>* observer);
-
- void CheckTimeout();
- /**
- * @brief Gets time in seconds when the nearest request timeout will be
- * triggered
- * @return time in seconds when the nearest request timeout will be triggered
- */
- TimeUnit GetSecondsToNearestTimeout();
-
- /*
- * @brief Adds object to be tracked by timer.
- If same object is already added replaces it with new one
- correspondingly updating start time of tracking.
- */
- void AddTrackable(const Trackable& object);
- void RemoveTrackable(const Trackable& object);
-
- protected:
- void Notify(const Trackable& object);
- void OnTimeout(const Trackable& object);
- TimeUnit CurrentTime() const;
- typename std::list<Trackable> trackables_;
- volatile TimeUnit period_;
-
- private:
- std::deque<TimerObserver<Trackable>*> observers_;
- mutable sync_primitives::Lock trackables_lock_;
- friend class ModuleTimerTest;
-};
-
-template <class Trackable>
-ModuleTimer<Trackable>::ModuleTimer()
- : period_(10) {}
-
-template <class Trackable>
-ModuleTimer<Trackable>::~ModuleTimer() {
- observers_.clear();
- sync_primitives::AutoLock auto_lock(trackables_lock_);
- trackables_.clear();
-}
-
-template <class Trackable>
-void ModuleTimer<Trackable>::AddObserver(TimerObserver<Trackable>* observer) {
- DCHECK(observer);
- if (!observer) {
- return;
- }
- observers_.push_back(observer);
-}
-
-template <class Trackable>
-void ModuleTimer<Trackable>::RemoveObserver(
- TimerObserver<Trackable>* observer) {
- DCHECK(observer);
- if (!observer) {
- return;
- }
- for (typename std::deque<TimerObserver<Trackable>*>::iterator it =
- observers_.begin();
- observers_.end() != it;
- ++it) {
- if (*it == observer) {
- observers_.erase(it);
- return;
- }
- }
-}
-
-template <class Trackable>
-void ModuleTimer<Trackable>::CheckTimeout() {
- sync_primitives::AutoLock trackables_lock(trackables_lock_);
- for (typename std::list<Trackable>::iterator it = trackables_.begin();
- trackables_.end() != it;
- ++it) {
- TimeUnit period = it->custom_interval();
- if (!period) {
- period = period_;
- }
- if (CurrentTime() - it->start_time() >= period) {
- OnTimeout(*it);
- it = trackables_.erase(it);
- }
- }
-}
-
-template <class Trackable>
-TimeUnit ModuleTimer<Trackable>::GetSecondsToNearestTimeout() {
- sync_primitives::AutoLock trackables_lock(trackables_lock_);
- TimeUnit result = period_;
- for (typename std::list<Trackable>::iterator it = trackables_.begin();
- trackables_.end() != it;
- ++it) {
- TimeUnit period = it->custom_interval();
- if (!period) {
- period = period_;
- }
- const TimeUnit current_secs_to_timeout =
- period - (CurrentTime() - it->start_time());
- if (result > current_secs_to_timeout) {
- result = current_secs_to_timeout;
- }
- }
- return result;
-}
-
-template <class Trackable>
-void ModuleTimer<Trackable>::AddTrackable(const Trackable& object) {
- sync_primitives::AutoLock trackables_lock(trackables_lock_);
- trackables_.remove(object);
- trackables_.push_back(object);
- trackables_.back().set_start_time(CurrentTime());
-}
-
-template <class Trackable>
-void ModuleTimer<Trackable>::RemoveTrackable(const Trackable& object) {
- sync_primitives::AutoLock trackables_lock(trackables_lock_);
- trackables_.remove(object);
-}
-
-template <class Trackable>
-void ModuleTimer<Trackable>::Notify(const Trackable& object) {
- for (typename std::deque<TimerObserver<Trackable>*>::const_iterator it =
- observers_.begin();
- observers_.end() != it;
- ++it) {
- (*it)->OnTimeoutTriggered(object);
- }
-}
-
-template <class Trackable>
-void ModuleTimer<Trackable>::OnTimeout(const Trackable& object) {
- Notify(object);
-}
-
-template <class Trackable>
-TimeUnit ModuleTimer<Trackable>::CurrentTime() const {
- // TODO(PV): move outside to platform-dependant parts
- struct timespec current_time;
- if (0 == clock_gettime(CLOCK_MONOTONIC, &current_time)) {
- return current_time.tv_sec;
- } else {
- return 0;
- }
-}
-
-} // namespace functional_modules
-
-#endif // SRC_COMPONENTS_FUNCTIONAL_MODULE_INCLUDE_FUNCTIONAL_MODULE_TIMER_MODULE_TIMER_H_
diff --git a/src/components/functional_module/include/functional_module/timer/timer_director.h b/src/components/functional_module/include/functional_module/timer/timer_director.h
deleted file mode 100644
index fb67b9b5de..0000000000
--- a/src/components/functional_module/include/functional_module/timer/timer_director.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (c) 2017, Ford Motor Company
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of the Ford Motor Company nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef SRC_COMPONENTS_FUNCTIONAL_MODULE_INCLUDE_FUNCTIONAL_MODULE_TIMER_TIMER_DIRECTOR_H_
-#define SRC_COMPONENTS_FUNCTIONAL_MODULE_INCLUDE_FUNCTIONAL_MODULE_TIMER_TIMER_DIRECTOR_H_
-
-#include <map>
-#include "utils/threads/thread.h"
-#include "utils/conditional_variable.h"
-#include "functional_module/timer/module_timer.h"
-
-namespace functional_modules {
-
-template <class T>
-class TimerThreadDelegate : public threads::ThreadDelegate {
- public:
- explicit TimerThreadDelegate(ModuleTimer<T>& timer);
- void threadMain();
- void exitThreadMain();
-
- /**
- * @brief Reset awaiting timer by notifying cond var
- */
- void ResetTimer();
-
- private:
- ModuleTimer<T>& timer_;
- volatile bool keep_running_;
- mutable sync_primitives::Lock keep_running_lock_;
- mutable sync_primitives::ConditionalVariable keep_running_cond_;
- friend class TimerThreadDelegateTest;
-};
-
-class TimerDirector {
- public:
- TimerDirector();
- ~TimerDirector();
-
- /**
- * @brief Register timer for execution in separate thread.
- Registers only one timer of a type. Attempt to register timer
- of already existing type will fail.
- */
- template <class T>
- void RegisterTimer(ModuleTimer<T>& timer);
- template <class T>
- void UnregisterTimer(const ModuleTimer<T>& timer);
- void UnregisterAllTimers();
- /**
- * @brief Reset awaiting timeout for specified module timer
- * @param timer timer to reset awaiting timeout
- */
- template <class T>
- void ResetTimer(ModuleTimer<T>& timer);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(TimerDirector);
- std::map<std::string, threads::Thread*> timer_threads_;
-};
-
-} // namespace functional_modules
-
-#endif // SRC_COMPONENTS_FUNCTIONAL_MODULE_INCLUDE_FUNCTIONAL_MODULE_TIMER_TIMER_DIRECTOR_H_
diff --git a/src/components/functional_module/src/generic_module.cc b/src/components/functional_module/src/generic_module.cc
deleted file mode 100644
index 142b1ef58c..0000000000
--- a/src/components/functional_module/src/generic_module.cc
+++ /dev/null
@@ -1,54 +0,0 @@
-#include "functional_module/generic_module.h"
-namespace functional_modules {
-
-typedef std::deque<ModuleObserver*>::iterator ModuleObserverIterator;
-
-GenericModule::GenericModule(ModuleID module_id)
- : kModuleId_(module_id), state_(ServiceState::IDLE) {}
-
-GenericModule::~GenericModule() {
- observers_.clear();
-}
-
-void GenericModule::AddObserver(ModuleObserver* const observer) {
- DCHECK(observer);
- if (!observer) {
- return;
- }
- observers_.push_back(observer);
-}
-
-void GenericModule::RemoveObserver(ModuleObserver* const observer) {
- DCHECK(observer);
- if (!observer) {
- return;
- }
- for (ModuleObserverIterator it = observers_.begin(); observers_.end() != it;
- ++it) {
- if (*it == observer) {
- observers_.erase(it);
- return;
- }
- }
-}
-
-void GenericModule::NotifyObservers(ModuleObserver::Errors error) {
- for (ModuleObserverIterator it = observers_.begin(); observers_.end() != it;
- ++it) {
- (*it)->OnError(error, kModuleId_);
- }
-}
-
-void GenericModule::set_service(application_manager::ServicePtr service) {
- service_ = service;
-}
-
-void GenericModule::OnServiceStateChanged(ServiceState state) {
- state_ = state;
-}
-
-application_manager::ServicePtr GenericModule::service() {
- return service_;
-}
-
-} // namespace functional_modules
diff --git a/src/components/functional_module/src/plugin_manager.cc b/src/components/functional_module/src/plugin_manager.cc
deleted file mode 100644
index a32fdbf773..0000000000
--- a/src/components/functional_module/src/plugin_manager.cc
+++ /dev/null
@@ -1,396 +0,0 @@
-/*
- * Copyright (c) 2017, Ford Motor Company
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of the Ford Motor Company nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <dlfcn.h>
-#include <algorithm>
-#include "functional_module/plugin_manager.h"
-#include "functional_module/function_ids.h"
-#include "protocol/common.h"
-#include "utils/file_system.h"
-#include "utils/logger.h"
-#include "json/json.h"
-
-namespace functional_modules {
-
-CREATE_LOGGERPTR_GLOBAL(logger_, "PluginManager")
-
-namespace {
-const std::string ExtractMethodName(application_manager::MessagePtr msg) {
- DCHECK_OR_RETURN(msg, "");
- Json::Value value;
- Json::Reader reader;
- reader.parse(msg->json_message(), value);
-
- const char* kMethod = "method";
- const char* kResult = "result";
- const char* kError = "error";
- const char* kData = "data";
-
- if (value.isMember(kMethod)) {
- return value.get(kMethod, "").asCString();
- }
- if (value.isMember(kResult)) {
- const Json::Value& result = value.get(kResult, Json::Value());
- return result.get(kMethod, "").asCString();
- }
- if (value.isMember(kError)) {
- const Json::Value& error = value.get(kError, Json::Value());
- const Json::Value& data = error.get(kData, Json::Value());
- return data.get(kMethod, "").asCString();
- }
-
- return std::string();
-}
-} // namespace
-
-typedef std::map<ModuleID, ModulePtr>::iterator PluginsIterator;
-typedef std::map<RCFunctionID, ModulePtr>::iterator PluginFunctionsIterator;
-typedef std::map<HMIFunctionID, ModulePtr>::iterator PluginHMIFunctionsIterator;
-
-PluginManager::PluginManager() : service_() {
- LOG4CXX_DEBUG(logger_, "Creating plugin mgr");
-}
-
-PluginManager::~PluginManager() {
- mobile_subscribers_.clear();
- hmi_subscribers_.clear();
- UnloadPlugins();
-}
-
-int PluginManager::LoadPlugins(const std::string& plugin_path) {
- LOG4CXX_INFO(logger_, "Loading plugins from " << plugin_path);
- std::vector<std::string> plugin_files = file_system::ListFiles(plugin_path);
- for (size_t i = 0; i < plugin_files.size(); ++i) {
- size_t pos = plugin_files[i].find_last_of(".");
- if (std::string::npos != pos) {
- if (plugin_files[i].substr(pos + 1).compare("so") != 0) {
- continue;
- }
- } else {
- continue;
- }
- std::string full_name = plugin_path + '/' + plugin_files[i];
- void* generic_plugin_dll = dlopen(full_name.c_str(), RTLD_LAZY);
- if (NULL == generic_plugin_dll) {
- LOG4CXX_ERROR(logger_,
- "Failed to open dll " << plugin_files[i] << "\n"
- << dlerror());
- continue;
- }
- typedef GenericModule* (*Create)();
- Create create_manager =
- reinterpret_cast<Create>(dlsym(generic_plugin_dll, "Create"));
- char* error_string = dlerror();
- if (NULL != error_string) {
- LOG4CXX_ERROR(logger_,
- "Failed to export dll's " << plugin_files[i] << " symbols\n"
- << error_string);
- dlclose(generic_plugin_dll);
- continue;
- }
- ModulePtr module = create_manager();
- if (!module) {
- LOG4CXX_ERROR(logger_,
- "Failed to create plugin main class " << plugin_files[i]);
- dlclose(generic_plugin_dll);
- continue;
- } else {
- LOG4CXX_DEBUG(logger_,
- "Opened and working plugin from " << plugin_files[i]
- << " with id "
- << module->GetModuleID());
- dlls_.insert(std::pair<ModuleID, void*>(module->GetModuleID(),
- generic_plugin_dll));
- plugins_.insert(
- std::pair<ModuleID, ModulePtr>(module->GetModuleID(), module));
- std::deque<RCFunctionID> subscribers =
- module->GetPluginInfo().rc_function_list;
- for (size_t i = 0; i < subscribers.size(); ++i) {
- mobile_subscribers_.insert(
- std::pair<RCFunctionID, ModulePtr>(subscribers[i], module));
- }
-
- std::deque<HMIFunctionID> hmi_subscribers =
- module->GetPluginInfo().hmi_function_list;
- for (size_t i = 0; i < hmi_subscribers.size(); ++i) {
- hmi_subscribers_.insert(
- std::pair<HMIFunctionID, ModulePtr>(hmi_subscribers[i], module));
- }
- module->set_service(service_);
- module->AddObserver(this);
- }
- }
- return plugins_.size();
-}
-
-void PluginManager::UnloadPlugins() {
- for (Modules::iterator it = plugins_.begin(); plugins_.end() != it; ++it) {
- it->second->RemoveObserver(this);
- }
- plugins_.clear();
-
- for (std::map<ModuleID, void*>::iterator it = dlls_.begin();
- dlls_.end() != it;
- ++it) {
- dlclose(it->second);
- }
- dlls_.clear();
-}
-
-bool PluginManager::IsMessageForPlugin(application_manager::MessagePtr msg) {
- DCHECK(msg);
- if (!msg) {
- LOG4CXX_ERROR(logger_, "Null pointer message was received.");
- return false;
- }
- if (protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_UNKNOWN !=
- msg->protocol_version() &&
- protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_HMI !=
- msg->protocol_version()) {
- RCFunctionID id = static_cast<RCFunctionID>(msg->function_id());
- return (mobile_subscribers_.find(id) != mobile_subscribers_.end());
- } else {
- return false;
- }
-}
-
-bool PluginManager::IsHMIMessageForPlugin(application_manager::MessagePtr msg) {
- DCHECK(msg);
- if (!msg) {
- LOG4CXX_ERROR(logger_, "Null pointer message was received.");
- return false;
- }
-
- Json::Value value;
- Json::Reader reader;
- reader.parse(msg->json_message(), value);
- if (protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_HMI ==
- msg->protocol_version()) {
- std::string msg_method;
- // Request or notification from HMI
- if (value.isMember("method") && value["method"].isString()) {
- msg_method = value["method"].asCString();
- // Response from HMI
- } else if (value.isMember("result") && value["result"].isMember("method") &&
- value["result"]["method"].isString()) {
- msg_method = value["result"]["method"].asCString();
- // Error response from HMI
- } else if (value.isMember("error") && value["error"].isMember("data") &&
- value["error"]["data"].isMember("method") &&
- value["error"]["data"]["method"].isString()) {
- msg_method = value["error"]["data"]["method"].asCString();
- } else {
- LOG4CXX_WARN(logger_,
- "Message with HMI protocol version can not be handled by "
- "plugin manager, because required 'method' field was not "
- "found, or was containing an invalid string.");
- return false;
- }
-
- return (hmi_subscribers_.find(msg_method) != hmi_subscribers_.end());
- }
-
- return false;
-}
-
-ProcessResult PluginManager::ProcessMessage(
- application_manager::MessagePtr msg) {
- DCHECK(msg);
- if (!msg) {
- LOG4CXX_ERROR(logger_, "Null pointer message was received.");
- return ProcessResult::CANNOT_PROCESS;
- }
-
- protocol_handler::MajorProtocolVersion version = msg->protocol_version();
- if (protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_UNKNOWN ==
- version ||
- protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_HMI == version) {
- return ProcessResult::CANNOT_PROCESS;
- }
-
- ProcessResult result = ProcessResult::CANNOT_PROCESS;
- PluginFunctionsIterator subscribed_plugin_itr =
- mobile_subscribers_.find(static_cast<RCFunctionID>(msg->function_id()));
- if (mobile_subscribers_.end() != subscribed_plugin_itr) {
- result = subscribed_plugin_itr->second->ProcessMessage(msg);
- if (ProcessResult::PROCESSED != result) {
- LOG4CXX_ERROR(logger_, "Plugin failed to process message.");
- }
- }
-
- return result;
-}
-
-ProcessResult PluginManager::ProcessHMIMessage(
- application_manager::MessagePtr msg) {
- DCHECK_OR_RETURN(msg, ProcessResult::CANNOT_PROCESS);
-
- if (protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_HMI !=
- msg->protocol_version()) {
- return ProcessResult::CANNOT_PROCESS;
- }
-
- const std::string& msg_method = ExtractMethodName(msg);
- if (msg_method.empty()) {
- LOG4CXX_WARN(logger_,
- "Message with HMI protocol version can not be handled by "
- "plugin manager, because required 'method' field was not "
- "found, or was containing an invalid string.");
- return ProcessResult::CANNOT_PROCESS;
- }
-
- LOG4CXX_DEBUG(logger_, "Parsed method name is " << msg_method);
-
- ProcessResult result = ProcessResult::CANNOT_PROCESS;
- PluginHMIFunctionsIterator subscribed_plugin_itr =
- hmi_subscribers_.find(msg_method);
- if (hmi_subscribers_.end() != subscribed_plugin_itr) {
- result = subscribed_plugin_itr->second->ProcessHMIMessage(msg);
- }
-
- return result;
-}
-
-void PluginManager::OnServiceStateChanged(ServiceState state) {
- for (PluginsIterator it = plugins_.begin(); plugins_.end() != it; ++it) {
- it->second->OnServiceStateChanged(state);
- }
-}
-
-void PluginManager::OnError(ModuleObserver::Errors error, ModuleID module_id) {
- std::string error_string;
- switch (error) {
- case ModuleObserver::Errors::OUT_OF_MEMORY:
- error_string = "Module run out of memory.";
- break;
- case ModuleObserver::Errors::FS_FAILURE:
- error_string = "Plugin failed to run file system operation.";
- break;
- default: {
- LOG4CXX_ERROR(logger_,
- "Error " << error_string << " was received from module "
- << module_id);
- } break;
- }
-}
-
-void PluginManager::RemoveAppExtension(uint32_t app_id) {
- for (PluginsIterator it = plugins_.begin(); plugins_.end() != it; ++it) {
- it->second->RemoveAppExtension(app_id);
- }
-}
-
-bool PluginManager::IsAppForPlugins(
- application_manager::ApplicationSharedPtr app) {
- DCHECK(app);
- if (!app) {
- return false;
- }
-
- bool res = false;
- for (PluginsIterator it = plugins_.begin(); plugins_.end() != it; ++it) {
- res = res || it->second->IsAppForPlugin(app);
- }
- return res;
-}
-
-bool PluginManager::IsAppForPlugin(
- application_manager::ApplicationSharedPtr app, ModuleID module_id) const {
- DCHECK_OR_RETURN(app, false);
- Modules::const_iterator i = plugins_.find(module_id);
- return i != plugins_.end() ? i->second->IsAppForPlugin(app) : false;
-}
-
-void PluginManager::OnAppHMILevelChanged(
- application_manager::ApplicationSharedPtr app,
- mobile_apis::HMILevel::eType old_level) {
- DCHECK_OR_RETURN_VOID(app);
- for (PluginsIterator it = plugins_.begin(); plugins_.end() != it; ++it) {
- if (it->second->IsAppForPlugin(app)) {
- LOG4CXX_DEBUG(logger_,
- "Application " << app->name().AsMBString() << " of plugin "
- << it->second->GetModuleID()
- << " has changed level from " << old_level
- << " to " << app->hmi_level());
- it->second->OnAppHMILevelChanged(app, old_level);
- }
- }
-}
-
-typedef std::map<ModuleID, ModulePtr>::value_type PluginsValueType;
-
-struct HandleApplicationEvent {
- private:
- const functional_modules::ApplicationEvent event_;
- application_manager::ApplicationSharedPtr application_;
-
- public:
- HandleApplicationEvent(functional_modules::ApplicationEvent e,
- application_manager::ApplicationSharedPtr application)
- : event_(e), application_(application) {}
- void operator()(PluginsValueType& p) {
- p.second->OnApplicationEvent(event_, application_);
- }
-};
-
-struct HandlePolicyEvent {
- private:
- const functional_modules::PolicyEvent event_;
-
- public:
- HandlePolicyEvent(functional_modules::PolicyEvent e) : event_(e) {}
- void operator()(PluginsValueType& p) {
- p.second->OnPolicyEvent(event_);
- }
-};
-
-void PluginManager::OnApplicationEvent(
- functional_modules::ApplicationEvent event,
- application_manager::ApplicationSharedPtr application) {
- LOG4CXX_AUTO_TRACE(logger_);
- if (application) {
- std::for_each(plugins_.begin(),
- plugins_.end(),
- HandleApplicationEvent(event, application));
- }
-}
-
-void PluginManager::OnPolicyEvent(PolicyEvent event) {
- LOG4CXX_AUTO_TRACE(logger_);
- std::for_each(plugins_.begin(), plugins_.end(), HandlePolicyEvent(event));
-}
-
-PluginManager::Modules& PluginManager::plugins() {
- return plugins_;
-}
-
-} // namespace functional_modules
diff --git a/src/components/functional_module/src/timer/timer_director.cc b/src/components/functional_module/src/timer/timer_director.cc
deleted file mode 100644
index 81ce117851..0000000000
--- a/src/components/functional_module/src/timer/timer_director.cc
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Copyright (c) 2017, Ford Motor Company
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of the Ford Motor Company nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#include <typeinfo>
-#include "functional_module/timer/timer_director.h"
-#include "remote_control/rc_module_timer.h"
-#include "utils/logger.h"
-
-namespace functional_modules {
-
-template <class T>
-TimerThreadDelegate<T>::TimerThreadDelegate(ModuleTimer<T>& timer)
- : timer_(timer), keep_running_(false) {}
-
-template <class T>
-void TimerThreadDelegate<T>::threadMain() {
- if (keep_running_) {
- this->exitThreadMain();
- }
- {
- sync_primitives::AutoLock run_lock(keep_running_lock_);
- keep_running_ = true;
- }
- sync_primitives::AutoLock run_lock(keep_running_lock_);
- while (keep_running_) {
- const TimeUnit msecs_to_wait = timer_.GetSecondsToNearestTimeout() * 1000;
- sync_primitives::ConditionalVariable::WaitStatus wait_status =
- keep_running_cond_.WaitFor(run_lock, msecs_to_wait);
- if (sync_primitives::ConditionalVariable::kTimeout == wait_status &&
- keep_running_) {
- timer_.CheckTimeout();
- }
- }
-}
-
-template <class T>
-void TimerThreadDelegate<T>::exitThreadMain() {
- if (keep_running_) {
- sync_primitives::AutoLock run_lock(keep_running_lock_);
- keep_running_ = false;
- keep_running_cond_.NotifyOne();
- }
-}
-
-template <class T>
-void TimerThreadDelegate<T>::ResetTimer() {
- if (keep_running_) {
- sync_primitives::AutoLock run_lock(keep_running_lock_);
- keep_running_cond_.NotifyOne();
- }
-}
-
-TimerDirector::TimerDirector() {}
-
-TimerDirector::~TimerDirector() {
- UnregisterAllTimers();
-}
-
-template <class T>
-void TimerDirector::RegisterTimer(ModuleTimer<T>& timer) {
- std::string type_name = typeid(timer).name();
- std::map<std::string, threads::Thread*>::iterator it =
- timer_threads_.find(type_name);
- if (timer_threads_.end() != it) {
- // Attempt to register timer of already existing type fail.
- return;
- }
- TimerThreadDelegate<T>* delegate = new TimerThreadDelegate<T>(timer);
- threads::Thread* thread = threads::CreateThread(type_name.c_str(), delegate);
-
- const size_t kStackSize = 16384;
- if (thread->start(threads::ThreadOptions(kStackSize))) {
- timer_threads_.insert(std::make_pair(type_name, thread));
- } else {
- // Failed to start timer thread for
- }
-}
-
-template void TimerDirector::RegisterTimer<remote_control::TrackableMessage>(
- ModuleTimer<remote_control::TrackableMessage>& timer);
-
-template <class T>
-void TimerDirector::UnregisterTimer(const ModuleTimer<T>& timer) {
- std::string type_name = typeid(timer).name();
- std::map<std::string, threads::Thread*>::iterator it =
- timer_threads_.find(type_name);
- if (timer_threads_.end() == it) {
- /// Failed to unregister timer that was not registered
- return;
- }
- threads::ThreadDelegate* delegate = it->second->delegate();
- DeleteThread(it->second);
- delete delegate;
- timer_threads_.erase(it);
-}
-
-template void TimerDirector::UnregisterTimer<remote_control::TrackableMessage>(
- const ModuleTimer<remote_control::TrackableMessage>& timer);
-
-template <class T>
-void TimerDirector::ResetTimer(ModuleTimer<T>& timer) {
- const std::string type_name = typeid(timer).name();
- std::map<std::string, threads::Thread*>::iterator it =
- timer_threads_.find(type_name);
- if (timer_threads_.end() == it) {
- return;
- }
- TimerThreadDelegate<T>* delegate =
- static_cast<TimerThreadDelegate<T>*>(it->second->delegate());
- delegate->ResetTimer();
-}
-
-template void TimerDirector::ResetTimer<remote_control::TrackableMessage>(
- ModuleTimer<remote_control::TrackableMessage>& timer);
-
-void TimerDirector::UnregisterAllTimers() {
- for (std::map<std::string, threads::Thread*>::iterator it =
- timer_threads_.begin();
- timer_threads_.end() != it;
- ++it) {
- threads::ThreadDelegate* delegate = it->second->delegate();
- DeleteThread(it->second);
- delete delegate;
- }
- timer_threads_.clear();
-}
-
-} // namespace functional_modules
diff --git a/src/components/functional_module/test/CMakeLists.txt b/src/components/functional_module/test/CMakeLists.txt
deleted file mode 100644
index c4e966c84e..0000000000
--- a/src/components/functional_module/test/CMakeLists.txt
+++ /dev/null
@@ -1,53 +0,0 @@
-include_directories (
- ${LOG4CXX_INCLUDE_DIRECTORY}
- ${GMOCK_INCLUDE_DIRECTORY}
- ${CMAKE_SOURCE_DIR}/src/components/functional_module/include/
- ${CMAKE_SOURCE_DIR}/src/components/include/
- ${CMAKE_SOURCE_DIR}/src/components/application_manager/include
- ${CMAKE_SOURCE_DIR}/src/components/connection_handler/include
- ${CMAKE_SOURCE_DIR}/src/components/utils/include
- ${CMAKE_SOURCE_DIR}/src/components/policy/include
- ${CMAKE_SOURCE_DIR}/src/components/smart_objects/include
- ${JSONCPP_INCLUDE_DIRECTORY}
- ${CMAKE_BINARY_DIR}/src/components/
- include
- plugins
-)
-
-set (LIBRARIES
- gtest
- gmock
- gmock_main
- FunctionalModule
- dl
- ApplicationManager
- jsoncpp
- Utils
- ConfigProfile
- gcov
-)
-
-set(SOURCES
- ./src/generic_module_test.cc
- ./src/plugin_manager_test.cc
- ./src/module_timer_test.cc
-)
-
-# use, i.e. don't skip the full RPATH for the build tree
-SET(CMAKE_SKIP_BUILD_RPATH FALSE)
-
-# when building, don't use the install RPATH already
-# (but later on when installing)
-SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
-
-SET(RPATH_DIRECTORIES
- /usr/local/lib
- /usr/local
- ${CMAKE_BINARY_DIR}/src/components/utils
-)
-
-SET(CMAKE_INSTALL_RPATH "${RPATH_DIRECTORIES}")
-
-add_subdirectory(plugins)
-
-create_test("function_module_test" "${SOURCES}" "${LIBRARIES}")
diff --git a/src/components/functional_module/test/include/driver_generic_module_test.h b/src/components/functional_module/test/include/driver_generic_module_test.h
deleted file mode 100644
index 23751f51c2..0000000000
--- a/src/components/functional_module/test/include/driver_generic_module_test.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 2015, 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_FUNCTIONAL_MODULE_TEST_INCLUDE_DRIVER_GENERIC_MODULE_TEST_H_
-#define SRC_COMPONENTS_FUNCTIONAL_MODULE_TEST_INCLUDE_DRIVER_GENERIC_MODULE_TEST_H_
-
-#include "functional_module/generic_module.h"
-
-namespace functional_modules {
-
-class DriverGenericModuleTest : public GenericModule {
- public:
- explicit DriverGenericModuleTest(ModuleID module_id)
- : GenericModule(module_id) {}
- virtual ~DriverGenericModuleTest() {}
- virtual PluginInfo GetPluginInfo() const {
- PluginInfo info;
- info.name = "DriverGenericModuleTest";
- info.version = 1;
- return info;
- }
- virtual ProcessResult ProcessMessage(application_manager::MessagePtr msg) {
- NotifyObservers(ModuleObserver::FS_FAILURE);
- return ProcessResult::FAILED;
- }
- virtual ProcessResult ProcessHMIMessage(application_manager::MessagePtr msg) {
- return ProcessResult::PROCESSED;
- }
- virtual void RemoveAppExtension(uint32_t app_id) {}
- virtual void RemoveAppExtensions() {}
- bool IsAppForPlugin(application_manager::ApplicationSharedPtr app) {
- return true;
- }
-
- void OnAppHMILevelChanged(application_manager::ApplicationSharedPtr,
- mobile_apis::HMILevel::eType) {}
-
- const Observers& observers() {
- return observers_;
- }
-
- void OnApplicationEvent(functional_modules::ApplicationEvent event,
- application_manager::ApplicationSharedPtr app) {}
-
- void OnPolicyEvent(functional_modules::PolicyEvent event) {}
-
- void OnUnregisterApplication(const uint32_t app_id) {}
-};
-
-} // namespace functional_modules
-
-#endif // SRC_COMPONENTS_FUNCTIONAL_MODULE_TEST_INCLUDE_DRIVER_GENERIC_MODULE_TEST_H_
diff --git a/src/components/functional_module/test/include/mock_application.h b/src/components/functional_module/test/include/mock_application.h
deleted file mode 100644
index 95bd4a0505..0000000000
--- a/src/components/functional_module/test/include/mock_application.h
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * Copyright (c) 2015, 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_FUNCTIONAL_MODULE_TEST_INCLUDE_MOCK_APPLICATION_H_
-#define SRC_COMPONENTS_FUNCTIONAL_MODULE_TEST_INCLUDE_MOCK_APPLICATION_H_
-
-#include "gmock/gmock.h"
-#include "application_manager/application.h"
-#include "application_manager/usage_statistics.h"
-#include "smart_objects/smart_object.h"
-
-namespace application_manager {
-
-class MockApplication : public Application {
- public:
- MOCK_CONST_METHOD0(active_message, const smart_objects::SmartObject*());
- MOCK_CONST_METHOD0(curHash, const std::string&());
- MOCK_METHOD0(UpdateHash, void());
- MOCK_METHOD0(CloseActiveMessage, void());
- MOCK_CONST_METHOD0(IsFullscreen, bool());
- MOCK_METHOD0(MakeFullscreen, bool());
- MOCK_CONST_METHOD0(IsAudible, bool());
- MOCK_METHOD0(MakeNotAudible, void());
- MOCK_CONST_METHOD0(allowed_support_navigation, bool());
- MOCK_METHOD1(set_allowed_support_navigation, void(bool allow));
- MOCK_CONST_METHOD0(hmi_supports_navi_streaming, bool());
- MOCK_METHOD1(set_hmi_supports_navi_streaming, void(const bool& supports));
- MOCK_CONST_METHOD0(app_allowed, bool());
- MOCK_CONST_METHOD0(has_been_activated, bool());
- MOCK_CONST_METHOD0(version, const Version&());
- MOCK_METHOD1(set_hmi_application_id, void(uint32_t hmi_app_id));
- MOCK_CONST_METHOD0(hmi_app_id, uint32_t());
- MOCK_CONST_METHOD0(app_id, uint32_t());
- MOCK_CONST_METHOD0(name, const std::string&());
- MOCK_CONST_METHOD0(folder_name, const std::string());
- MOCK_CONST_METHOD0(is_media_application, bool());
- MOCK_CONST_METHOD0(hmi_level, const mobile_api::HMILevel::eType&());
- MOCK_CONST_METHOD0(put_file_in_none_count, const uint32_t());
- MOCK_CONST_METHOD0(delete_file_in_none_count, const uint32_t());
- MOCK_CONST_METHOD0(list_files_in_none_count, const uint32_t());
- MOCK_CONST_METHOD0(system_context, const mobile_api::SystemContext::eType&());
- MOCK_CONST_METHOD0(audio_streaming_state,
- const mobile_api::AudioStreamingState::eType&());
- MOCK_CONST_METHOD0(app_icon_path, const std::string&());
- MOCK_CONST_METHOD0(device, connection_handler::DeviceHandle());
- MOCK_METHOD1(set_tts_speak_state, void(bool state_tts_speak));
- MOCK_METHOD0(tts_speak_state, bool());
- MOCK_METHOD1(set_tts_properties_in_none, void(bool active));
- MOCK_METHOD0(tts_properties_in_none, bool());
- MOCK_METHOD1(set_tts_properties_in_full, void(bool active));
- MOCK_METHOD0(tts_properties_in_full, bool());
- MOCK_METHOD1(set_version, void(const Version& version));
- MOCK_METHOD1(set_name, void(const std::string& name));
- MOCK_METHOD1(set_is_media_application, void(bool is_media));
- MOCK_METHOD1(set_hmi_level,
- void(const mobile_api::HMILevel::eType& hmi_level));
- MOCK_METHOD0(increment_put_file_in_none_count, void());
- MOCK_METHOD0(increment_delete_file_in_none_count, void());
- MOCK_METHOD0(increment_list_files_in_none_count, void());
- MOCK_METHOD1(set_system_context,
- void(const mobile_api::SystemContext::eType& system_context));
- MOCK_METHOD1(set_audio_streaming_state,
- void(const mobile_api::AudioStreamingState::eType& state));
- MOCK_METHOD1(set_app_icon_path, bool(const std::string& file_name));
- MOCK_METHOD1(set_app_allowed, void(const bool& allowed));
- MOCK_METHOD1(set_device, void(connection_handler::DeviceHandle device));
- MOCK_CONST_METHOD0(get_grammar_id, uint32_t());
- MOCK_METHOD1(set_grammar_id, void(uint32_t value));
- MOCK_METHOD1(set_protocol_version,
- void(const ProtocolVersion& protocol_version));
- MOCK_CONST_METHOD0(protocol_version, ProtocolVersion());
- MOCK_METHOD1(AddFile, bool(AppFile& file));
- MOCK_CONST_METHOD0(getAppFiles, const AppFilesMap&());
- MOCK_METHOD1(UpdateFile, bool(AppFile& file));
- MOCK_METHOD1(DeleteFile, bool(const std::string& file_name));
- MOCK_METHOD1(GetFile, const AppFile*(const std::string& file_name));
- MOCK_METHOD1(SubscribeToButton,
- bool(mobile_apis::ButtonName::eType btn_name));
- MOCK_METHOD1(IsSubscribedToButton,
- bool(mobile_apis::ButtonName::eType btn_name));
- MOCK_METHOD1(UnsubscribeFromButton,
- bool(mobile_apis::ButtonName::eType btn_name));
- MOCK_METHOD1(SubscribeToIVI, bool(uint32_t vehicle_info_type_));
- MOCK_METHOD1(IsSubscribedToIVI, bool(uint32_t vehicle_info_type_));
- MOCK_METHOD1(UnsubscribeFromIVI, bool(uint32_t vehicle_info_type_));
- MOCK_METHOD2(IsCommandLimitsExceeded,
- bool(mobile_apis::FunctionID::eType cmd_id,
- TLimitSource source));
- MOCK_METHOD0(usage_report, UsageStatistics&());
- MOCK_METHOD1(SetInitialState, void(HmiStatePtr state));
- MOCK_METHOD2(SubscribeToSoftButtons,
- void(int32_t cmd_id, const SoftButtonID& softbuttons_id));
- MOCK_METHOD1(IsSubscribedToSoftButton, bool(const uint32_t softbutton_id));
- MOCK_METHOD1(UnsubscribeFromSoftButtons, void(int32_t cmd_id));
- MOCK_METHOD1(QueryInterface, AppExtensionPtr(AppExtensionUID uid));
- MOCK_METHOD1(AddExtension, bool(AppExtensionPtr extention));
- MOCK_METHOD1(RemoveExtension, bool(AppExtensionUID uid));
- MOCK_METHOD0(RemoveExtensions, void());
- MOCK_CONST_METHOD0(help_prompt, const smart_objects::SmartObject*());
- MOCK_CONST_METHOD0(timeout_prompt, const smart_objects::SmartObject*());
- MOCK_CONST_METHOD0(vr_help_title, const smart_objects::SmartObject*());
- MOCK_CONST_METHOD0(vr_help, const smart_objects::SmartObject*());
- MOCK_CONST_METHOD0(tbt_state, const mobile_api::TBTState::eType&());
- MOCK_CONST_METHOD0(show_command, const smart_objects::SmartObject*());
- MOCK_CONST_METHOD0(tbt_show_command, const smart_objects::SmartObject*());
- MOCK_CONST_METHOD0(SubscribedButtons,
- const std::set<mobile_apis::ButtonName::eType>&());
- MOCK_CONST_METHOD0(SubscribesIVI,
- const application_manager::VehicleInfoSubscriptions&());
- MOCK_CONST_METHOD0(keyboard_props, const smart_objects::SmartObject*());
- MOCK_CONST_METHOD0(menu_title, const smart_objects::SmartObject*());
- MOCK_CONST_METHOD0(menu_icon, const smart_objects::SmartObject*());
- MOCK_METHOD1(set_help_prompt,
- void(const smart_objects::SmartObject& help_prompt));
- MOCK_METHOD1(set_timeout_prompt,
- void(const smart_objects::SmartObject& timeout_prompt));
- MOCK_METHOD1(set_vr_help_title,
- void(const smart_objects::SmartObject& vr_help_title));
- MOCK_METHOD0(reset_vr_help_title, void());
- MOCK_METHOD1(set_vr_help, void(const smart_objects::SmartObject& vr_help));
- MOCK_METHOD0(reset_vr_help, void());
- MOCK_METHOD1(set_tbt_state,
- void(const mobile_api::TBTState::eType& tbt_state));
- MOCK_METHOD1(set_show_command,
- void(const smart_objects::SmartObject& show_command));
- MOCK_METHOD1(set_tbt_show_command,
- void(const smart_objects::SmartObject& tbt_show));
- MOCK_METHOD1(set_keyboard_props,
- void(const smart_objects::SmartObject& keyboard_props));
- MOCK_METHOD1(set_menu_title,
- void(const smart_objects::SmartObject& menu_title));
- MOCK_METHOD1(set_menu_icon,
- void(const smart_objects::SmartObject& menu_icon));
- MOCK_METHOD2(AddCommand,
- void(uint32_t cmd_id,
- const smart_objects::SmartObject& command));
- MOCK_METHOD1(RemoveCommand, void(uint32_t cmd_id));
- MOCK_METHOD1(FindCommand, smart_objects::SmartObject*(uint32_t cmd_id));
- MOCK_METHOD2(AddSubMenu,
- void(uint32_t menu_id, const smart_objects::SmartObject& menu));
- MOCK_METHOD1(RemoveSubMenu, void(uint32_t menu_id));
- MOCK_CONST_METHOD1(FindSubMenu,
- smart_objects::SmartObject*(uint32_t menu_id));
- MOCK_METHOD1(IsSubMenuNameAlreadyExist, bool(const std::string& name));
- MOCK_METHOD2(AddChoiceSet,
- void(uint32_t choice_set_id,
- const smart_objects::SmartObject& choice_set));
- MOCK_METHOD1(RemoveChoiceSet, void(uint32_t choice_set_id));
- MOCK_METHOD1(FindChoiceSet,
- smart_objects::SmartObject*(uint32_t choice_set_id));
- MOCK_METHOD2(AddPerformInteractionChoiceSet,
- void(uint32_t choice_set_id,
- const smart_objects::SmartObject& choice_set));
- MOCK_METHOD0(DeletePerformInteractionChoiceSetMap, void());
- MOCK_CONST_METHOD0(performinteraction_choice_set_map,
- DataAccessor<PerformChoiceSetMap>());
- MOCK_CONST_METHOD1(FindPerformInteractionChoiceSet,
- smart_objects::SmartObject*(uint32_t choice_set_id));
- MOCK_CONST_METHOD0(commands_map, DataAccessor<CommandsMap>());
- MOCK_CONST_METHOD0(sub_menu_map, DataAccessor<SubMenuMap>());
- MOCK_CONST_METHOD0(choice_set_map, DataAccessor<ChoiceSetMap>());
- MOCK_METHOD1(set_perform_interaction_active, void(uint32_t active));
- MOCK_CONST_METHOD0(is_perform_interaction_active, uint32_t());
- MOCK_METHOD1(set_perform_interaction_ui_corrid, void(uint32_t choice));
- MOCK_CONST_METHOD0(perform_interaction_ui_corrid, uint32_t());
- MOCK_METHOD1(set_perform_interaction_mode, void(int32_t mode));
- MOCK_CONST_METHOD0(perform_interaction_mode, int32_t());
- MOCK_METHOD1(set_reset_global_properties_active, void(bool active));
- MOCK_CONST_METHOD0(is_reset_global_properties_active, bool());
- MOCK_CONST_METHOD0(app_types, const smart_objects::SmartObject*());
- MOCK_CONST_METHOD0(vr_synonyms, const smart_objects::SmartObject*());
- MOCK_CONST_METHOD0(mobile_app_id, std::string());
- MOCK_CONST_METHOD0(tts_name, const smart_objects::SmartObject*());
- MOCK_CONST_METHOD0(ngn_media_screen_name,
- const smart_objects::SmartObject*());
- MOCK_CONST_METHOD0(language, const mobile_api::Language::eType&());
- MOCK_CONST_METHOD0(ui_language, const mobile_api::Language::eType&());
- MOCK_METHOD1(set_app_types,
- void(const smart_objects::SmartObject& app_types));
- MOCK_METHOD1(set_vr_synonyms,
- void(const smart_objects::SmartObject& vr_synonyms));
- MOCK_METHOD1(set_mobile_app_id,
- void(const smart_objects::SmartObject& mobile_app_id));
- MOCK_METHOD1(set_tts_name, void(const smart_objects::SmartObject& tts_name));
- MOCK_METHOD1(set_ngn_media_screen_name,
- void(const smart_objects::SmartObject& ngn_name));
- MOCK_METHOD1(set_language, void(const mobile_api::Language::eType& language));
- MOCK_METHOD1(set_ui_language,
- void(const mobile_api::Language::eType& ui_language));
- MOCK_METHOD1(load_global_properties,
- void(const smart_objects::SmartObject& so));
- MOCK_METHOD1(set_mobile_app_id, void(const std::string& mobile_app_id));
- MOCK_METHOD0(ChangeSupportingAppHMIType, void());
- MOCK_CONST_METHOD0(is_navi, bool());
- MOCK_METHOD1(set_is_navi, void(bool allow));
- MOCK_CONST_METHOD0(hmi_supports_navi_video_streaming, bool());
- MOCK_METHOD1(set_hmi_supports_navi_video_streaming, void(bool supports));
- MOCK_CONST_METHOD0(hmi_supports_navi_audio_streaming, bool());
- MOCK_METHOD1(set_hmi_supports_navi_audio_streaming, void(bool supports));
- MOCK_CONST_METHOD0(is_voice_communication_supported, bool());
- MOCK_METHOD1(set_voice_communication_supported, void(bool));
- MOCK_METHOD1(set_activated, bool(bool is_active));
- MOCK_CONST_METHOD0(is_foreground, bool());
- MOCK_METHOD1(set_foreground, void(bool is_foreground));
- MOCK_CONST_METHOD0(IsAudioApplication, bool());
- MOCK_CONST_METHOD0(video_stream_retry_active, bool());
- MOCK_METHOD1(set_video_stream_retry_active, void(bool active));
- MOCK_CONST_METHOD0(audio_stream_retry_active, bool());
- MOCK_METHOD1(set_audio_stream_retry_active, void(bool active));
- MOCK_METHOD0(OnVideoStreamRetry, void());
- MOCK_METHOD0(OnAudioStreamRetry, void());
- MOCK_METHOD1(SubscribeToInteriorVehicleData,
- bool(smart_objects::SmartObject module));
- MOCK_METHOD1(IsSubscribedToInteriorVehicleData,
- bool(smart_objects::SmartObject module));
- MOCK_METHOD1(UnsubscribeFromInteriorVehicleData,
- bool(smart_objects::SmartObject module));
-};
-
-} // namespace application_manager
-
-#endif // SRC_COMPONENTS_FUNCTIONAL_MODULE_TEST_INCLUDE_MOCK_APPLICATION_H_
diff --git a/src/components/functional_module/test/include/mock_module_observer.h b/src/components/functional_module/test/include/mock_module_observer.h
deleted file mode 100644
index bfa5117b29..0000000000
--- a/src/components/functional_module/test/include/mock_module_observer.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 2015, 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_FUNCTIONAL_MODULE_TEST_INCLUDE_MOCK_MODULE_OBSERVER_H_
-#define SRC_COMPONENTS_FUNCTIONAL_MODULE_TEST_INCLUDE_MOCK_MODULE_OBSERVER_H_
-
-#include "gmock/gmock.h"
-#include "functional_module/module_observer.h"
-
-namespace functional_modules {
-
-class MockModuleObserver : public ModuleObserver {
- public:
- MOCK_METHOD2(OnError, void(Errors error, ModuleID module_id));
- int ObserverMethod() {
- return 13;
- }
-};
-
-} // namespace functional_modules
-
-#endif // SRC_COMPONENTS_FUNCTIONAL_MODULE_TEST_INCLUDE_MOCK_MODULE_OBSERVER_H_
diff --git a/src/components/functional_module/test/include/mock_service.h b/src/components/functional_module/test/include/mock_service.h
deleted file mode 100644
index d1fa7f2747..0000000000
--- a/src/components/functional_module/test/include/mock_service.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (c) 2015, 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_FUNCTIONAL_MODULE_TEST_INCLUDE_MOCK_SERVICE_H_
-#define SRC_COMPONENTS_FUNCTIONAL_MODULE_TEST_INCLUDE_MOCK_SERVICE_H_
-
-#include "gmock/gmock.h"
-#include "application_manager/service.h"
-
-namespace application_manager {
-
-class MockService : public Service {
- public:
- MOCK_METHOD1(CheckPolicyPermissions,
- mobile_apis::Result::eType(MessagePtr msg));
- MOCK_METHOD1(GetApplication, ApplicationSharedPtr(ApplicationId app_id));
- MOCK_METHOD1(SendMessageToHMI, void(const MessagePtr& message));
- MOCK_METHOD1(SendMessageToMobile, void(const MessagePtr& message));
- MOCK_METHOD0(GetNextCorrelationID, uint32_t());
- MOCK_METHOD1(GetApplications,
- std::vector<ApplicationSharedPtr>(AppExtensionUID));
- MOCK_METHOD2(ChangeNotifyHMILevel,
- void(ApplicationSharedPtr app,
- mobile_apis::HMILevel::eType level));
- MOCK_METHOD2(NotifyHMIAboutHMILevel,
- void(ApplicationSharedPtr app,
- mobile_apis::HMILevel::eType level));
- MOCK_CONST_METHOD0(GetRCCapabilities, const smart_objects::SmartObject*());
- MOCK_METHOD2(CheckModule,
- bool(const ApplicationId& app_id, const std::string& module));
- MOCK_METHOD1(RemoveHMIFakeParameters,
- void(application_manager::MessagePtr& message));
- MOCK_CONST_METHOD1(IsRemoteControlApplication,
- bool(ApplicationSharedPtr app));
- MOCK_CONST_METHOD1(IsInterfaceAvailable,
- bool(const HmiInterfaces::InterfaceID interface));
- MOCK_CONST_METHOD2(GetModuleTypes,
- bool(const std::string& application_id,
- std::vector<std::string>* modules));
- MOCK_METHOD1(ValidateMessageBySchema,
- application_manager::MessageValidationResult(
- const application_manager::Message& message));
- MOCK_CONST_METHOD0(GetSettings, const ApplicationManagerSettings&());
-};
-}
-// namespace application_manager
-
-#endif // SRC_COMPONENTS_FUNCTIONAL_MODULE_TEST_INCLUDE_MOCK_SERVICE_H_
diff --git a/src/components/functional_module/test/include/module_timer_test.h b/src/components/functional_module/test/include/module_timer_test.h
deleted file mode 100644
index 456346b544..0000000000
--- a/src/components/functional_module/test/include/module_timer_test.h
+++ /dev/null
@@ -1,56 +0,0 @@
-#include "utils/macro.h"
-#include "functional_module/timer/module_timer.h"
-
-namespace functional_modules {
-
-class TestTrackable : public Trackable {
- public:
- explicit TestTrackable(TimeUnit interval = 0)
- : Trackable(), custom_interval_(interval) {}
-
- virtual TimeUnit custom_interval() const {
- return custom_interval_;
- }
-
- bool operator==(const TestTrackable& other) const {
- return custom_interval_ == other.custom_interval_;
- }
-
- private:
- TimeUnit custom_interval_;
-};
-
-class ModuleTimerTest {
- public:
- ModuleTimerTest(ModuleTimer<TestTrackable>& timer) : timer_(timer) {}
-
- TimeUnit period() const {
- return timer_.period_;
- }
-
- int observers_size() const {
- return timer_.observers_.size();
- }
-
- int trackables_size() const {
- return timer_.trackables_.size();
- }
-
- TestTrackable trackable(const TestTrackable& track) const {
- return *std::find(
- timer_.trackables_.begin(), timer_.trackables_.end(), track);
- }
-
- TimeUnit current_time() const {
- return timer_.CurrentTime();
- }
-
- private:
- ModuleTimer<TestTrackable>& timer_;
-};
-
-class MockTimerObserver : public TimerObserver<TestTrackable> {
- public:
- MOCK_METHOD1(OnTimeoutTriggered, void(const TestTrackable& expired));
-};
-} // namespace functional_modules
diff --git a/src/components/functional_module/test/plugins/CMakeLists.txt b/src/components/functional_module/test/plugins/CMakeLists.txt
deleted file mode 100644
index 7afe8387b8..0000000000
--- a/src/components/functional_module/test/plugins/CMakeLists.txt
+++ /dev/null
@@ -1,17 +0,0 @@
-set(target PluginMock)
-
-include_directories (
- ${LOG4CXX_INCLUDE_DIRECTORY}
- ${GMOCK_INCLUDE_DIRECTORY}
- ${CMAKE_SOURCE_DIR}/src/components/functional_module/include/
- ${CMAKE_SOURCE_DIR}/src/components/include/
- ${JSONCPP_INCLUDE_DIRECTORY}
-)
-
-set(SOURCES
- ./mock_generic_module.cc
-)
-
-add_library(${target} SHARED ${SOURCES})
-target_link_libraries(${target})
-add_dependencies(${target} MOBILE_API HMI_API)
diff --git a/src/components/functional_module/test/plugins/mock_generic_module.cc b/src/components/functional_module/test/plugins/mock_generic_module.cc
deleted file mode 100644
index dcf6d7d4fe..0000000000
--- a/src/components/functional_module/test/plugins/mock_generic_module.cc
+++ /dev/null
@@ -1,23 +0,0 @@
-#include "mock_generic_module.h"
-
-using functional_modules::GenericModule;
-using functional_modules::RCFunctionID;
-using functional_modules::PluginInfo;
-
-using ::testing::_;
-using ::testing::Return;
-
-MockGenericModule::MockGenericModule() : GenericModule(19) {
- PluginInfo info;
- info.name = "MockGenericModule";
- info.version = 1;
- info.rc_function_list.push_back(static_cast<RCFunctionID>(101));
- info.hmi_function_list.push_back("HMI-Func-1");
-
- EXPECT_CALL(*this, GetPluginInfo()).Times(2).WillRepeatedly(Return(info));
- EXPECT_CALL(*this, set_service(_)).Times(1);
-}
-
-extern "C" GenericModule* Create() {
- return new MockGenericModule();
-}
diff --git a/src/components/functional_module/test/plugins/mock_generic_module.h b/src/components/functional_module/test/plugins/mock_generic_module.h
deleted file mode 100644
index faea0f135d..0000000000
--- a/src/components/functional_module/test/plugins/mock_generic_module.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 2015, 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 TEST_COMPONENTS_FUNCTIONAL_MODULE_PLUGINS_MOCK_GENERIC_MODULE_H_
-#define TEST_COMPONENTS_FUNCTIONAL_MODULE_PLUGINS_MOCK_GENERIC_MODULE_H_
-
-#include "gmock/gmock.h"
-#include "functional_module/generic_module.h"
-
-using functional_modules::GenericModule;
-using functional_modules::PluginInfo;
-using functional_modules::ProcessResult;
-using functional_modules::ServiceState;
-
-using ::testing::_;
-using ::testing::Return;
-
-class MockGenericModule : public GenericModule {
- public:
- MockGenericModule();
- MOCK_CONST_METHOD0(GetPluginInfo, PluginInfo());
- MOCK_METHOD1(set_service, void(application_manager::ServicePtr service));
- MOCK_METHOD0(service, application_manager::ServicePtr());
- MOCK_METHOD1(ProcessMessage,
- ProcessResult(application_manager::MessagePtr msg));
- MOCK_METHOD1(ProcessHMIMessage,
- ProcessResult(application_manager::MessagePtr msg));
- MOCK_METHOD1(OnServiceStateChanged, void(ServiceState state));
- MOCK_METHOD1(RemoveAppExtension, void(uint32_t app_id));
- MOCK_METHOD1(IsAppForPlugin,
- bool(application_manager::ApplicationSharedPtr app));
- MOCK_METHOD2(OnAppHMILevelChanged,
- void(application_manager::ApplicationSharedPtr app,
- mobile_apis::HMILevel::eType old_level));
- MOCK_METHOD1(OnUnregisterApplication, void(const uint32_t app_id));
- MOCK_METHOD2(OnApplicationEvent,
- void(functional_modules::ApplicationEvent event,
- application_manager::ApplicationSharedPtr application));
- MOCK_METHOD1(OnPolicyEvent, void(functional_modules::PolicyEvent event));
- MOCK_METHOD0(RemoveAppExtensions, void());
-};
-
-#endif // TEST_COMPONENTS_FUNCTIONAL_MODULE_PLUGINS_MOCK_GENERIC_MODULE_H_
diff --git a/src/components/functional_module/test/src/generic_module_test.cc b/src/components/functional_module/test/src/generic_module_test.cc
deleted file mode 100644
index 71d8325f6d..0000000000
--- a/src/components/functional_module/test/src/generic_module_test.cc
+++ /dev/null
@@ -1,106 +0,0 @@
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-
-#include "driver_generic_module_test.h"
-
-#include "mock_module_observer.h"
-#include "mock_service.h"
-
-using application_manager::ServicePtr;
-using application_manager::MockService;
-
-using ::testing::_;
-
-namespace functional_modules {
-
-TEST(GenericModuleTest, SetService) {
- DriverGenericModuleTest module(18);
- MockService* mock_service = new MockService();
- ServicePtr exp_service(mock_service);
-
- module.set_service(exp_service);
- ServicePtr out_service = module.service();
-
- EXPECT_EQ(exp_service.get(), out_service.get());
-}
-
-TEST(GenericModuleTest, RemoveObserver) {
- DriverGenericModuleTest module(18);
- MockModuleObserver* observer = new MockModuleObserver();
- module.AddObserver(observer);
-
- module.RemoveObserver(observer);
- const DriverGenericModuleTest::Observers& empty = module.observers();
- ASSERT_TRUE(empty.empty());
- delete observer;
-}
-
-TEST(GenericModuleTest, EmptyRemoveObserver) {
- DriverGenericModuleTest module(18);
- MockModuleObserver* observer = new MockModuleObserver();
- module.RemoveObserver(observer);
- const DriverGenericModuleTest::Observers& empty = module.observers();
- ASSERT_TRUE(empty.empty());
- delete observer;
-}
-
-TEST(GenericModuleTest, WrongRemoveObserver) {
- DriverGenericModuleTest module(18);
- MockModuleObserver observer;
- module.AddObserver(&observer);
-
- MockModuleObserver* wrong_observer = new MockModuleObserver();
- module.RemoveObserver(wrong_observer);
- const DriverGenericModuleTest::Observers& empty = module.observers();
- ASSERT_EQ(1u, empty.size());
- EXPECT_EQ(&observer, empty[0]);
- delete wrong_observer;
-}
-
-TEST(GenericModuleTest, CrashRemovedObserver) {
- DriverGenericModuleTest module(18);
- MockModuleObserver* observer = new MockModuleObserver();
- module.AddObserver(observer);
- EXPECT_EQ(13, observer->ObserverMethod());
- module.RemoveObserver(observer);
- EXPECT_EQ(13, observer->ObserverMethod());
- delete observer;
- MockModuleObserver second_observer;
- module.AddObserver(&second_observer);
- EXPECT_EQ(13, second_observer.ObserverMethod());
- module.RemoveObserver(&second_observer);
- EXPECT_EQ(13, second_observer.ObserverMethod());
-}
-
-TEST(GenericModuleTest, NotifyObservers) {
- DriverGenericModuleTest module(3);
- MockModuleObserver observer;
- module.AddObserver(&observer);
-
- EXPECT_CALL(observer, OnError(ModuleObserver::FS_FAILURE, 3)).Times(1);
-
- application_manager::MessagePtr message;
- module.ProcessMessage(message);
-}
-
-TEST(GenericModuleTest, NotifyObserversComplex) {
- DriverGenericModuleTest module(3);
- MockModuleObserver observer_1;
- module.AddObserver(&observer_1);
- MockModuleObserver observer_2;
- module.AddObserver(&observer_2);
-
- EXPECT_CALL(observer_1, OnError(ModuleObserver::FS_FAILURE, 3)).Times(1);
- EXPECT_CALL(observer_2, OnError(ModuleObserver::FS_FAILURE, 3)).Times(1);
-
- application_manager::MessagePtr message;
- module.ProcessMessage(message);
-
- module.RemoveObserver(&observer_1);
- EXPECT_CALL(observer_1, OnError(ModuleObserver::FS_FAILURE, 3)).Times(0);
- EXPECT_CALL(observer_2, OnError(ModuleObserver::FS_FAILURE, 3)).Times(1);
-
- module.ProcessMessage(message);
-}
-
-} // namespace functional_modules
diff --git a/src/components/functional_module/test/src/module_timer_test.cc b/src/components/functional_module/test/src/module_timer_test.cc
deleted file mode 100644
index 668c3e2955..0000000000
--- a/src/components/functional_module/test/src/module_timer_test.cc
+++ /dev/null
@@ -1,123 +0,0 @@
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-#include "module_timer_test.h"
-
-namespace functional_modules {
-
-TEST(ModuleTimerTest, set_period) {
- ModuleTimer<TestTrackable> timer;
- timer.set_period(10000);
- ModuleTimerTest test(timer);
- EXPECT_EQ(10000u, test.period());
-}
-
-TEST(ModuleTimerTest, add_observer) {
- ModuleTimer<TestTrackable> timer;
- ModuleTimerTest test(timer);
- for (size_t i = 0; i < 5; ++i) {
- MockTimerObserver observer;
- timer.AddObserver(&observer);
- }
- EXPECT_EQ(5, test.observers_size());
-}
-
-TEST(ModuleTimerTest, remove_observer) {
- ModuleTimer<TestTrackable> timer;
- ModuleTimerTest test(timer);
-
- MockTimerObserver observer;
- timer.AddObserver(&observer);
- MockTimerObserver observer2;
- timer.AddObserver(&observer2);
- timer.RemoveObserver(&observer);
- EXPECT_EQ(1, test.observers_size());
- MockTimerObserver observer3;
- timer.RemoveObserver(&observer3);
- EXPECT_EQ(1, test.observers_size());
- timer.RemoveObserver(&observer2);
- EXPECT_EQ(0, test.observers_size());
-}
-
-TEST(ModuleTimerTest, start) {
- ModuleTimer<TestTrackable> timer;
- ModuleTimerTest test(timer);
- timer.set_period(1);
- MockTimerObserver observer;
- timer.AddObserver(&observer);
- TestTrackable track;
- timer.AddTrackable(track);
- sleep(2);
- EXPECT_CALL(observer, OnTimeoutTriggered(track)).Times(1);
- timer.CheckTimeout();
- EXPECT_EQ(0, test.trackables_size());
- timer.set_period(4);
- timer.AddTrackable(track);
- sleep(2);
- EXPECT_CALL(observer, OnTimeoutTriggered(track)).Times(0);
- timer.CheckTimeout();
- EXPECT_EQ(1, test.trackables_size());
- TestTrackable track2(1);
- timer.AddTrackable(track2);
- timer.AddTrackable(track);
- sleep(2);
- EXPECT_CALL(observer, OnTimeoutTriggered(track2)).Times(1);
- EXPECT_CALL(observer, OnTimeoutTriggered(track)).Times(0);
- timer.CheckTimeout();
- EXPECT_EQ(1, test.trackables_size());
-}
-
-TEST(ModuleTimerTest, add_trackable) {
- ModuleTimer<TestTrackable> timer;
- ModuleTimerTest test(timer);
- timer.AddTrackable(TestTrackable());
- ASSERT_EQ(1, test.trackables_size());
- // adding the same object twice
- timer.AddTrackable(TestTrackable());
- EXPECT_EQ(1, test.trackables_size());
- // adding another object
- TestTrackable track(3);
- timer.AddTrackable(track);
- ASSERT_EQ(2, test.trackables_size());
- EXPECT_TRUE(test.trackable(track).start_time() - test.current_time() < 1);
- timer.AddTrackable(track);
- sleep(3);
- EXPECT_TRUE(test.current_time() - test.trackable(track).start_time() < 4 &&
- test.current_time() - test.trackable(track).start_time() > 2);
-}
-
-TEST(ModuleTimerTest, remove_trackable) {
- ModuleTimer<TestTrackable> timer;
- ModuleTimerTest test(timer);
- EXPECT_EQ(0, test.trackables_size());
- TestTrackable track1;
- TestTrackable track2(1);
- timer.AddTrackable(track1);
- timer.AddTrackable(track2);
- EXPECT_EQ(2, test.trackables_size());
- timer.RemoveTrackable(track2);
- ASSERT_EQ(1, test.trackables_size());
- TestTrackable track3(2);
- timer.RemoveTrackable(track3);
- ASSERT_EQ(1, test.trackables_size());
- timer.RemoveTrackable(track1);
- ASSERT_EQ(0, test.trackables_size());
-}
-
-TEST(ModuleTimerTest, notify) {
- ModuleTimer<TestTrackable> timer;
- ModuleTimerTest test(timer);
- timer.set_period(1);
- MockTimerObserver observer;
- timer.AddObserver(&observer);
- TestTrackable track;
- timer.AddTrackable(track);
- TestTrackable track2(2);
- timer.AddTrackable(track2);
- sleep(2);
- EXPECT_CALL(observer, OnTimeoutTriggered(track)).Times(1);
- EXPECT_CALL(observer, OnTimeoutTriggered(track2)).Times(0);
- timer.CheckTimeout();
- EXPECT_EQ(1, test.trackables_size());
-}
-
-} // namespace functional_modules
diff --git a/src/components/functional_module/test/src/plugin_manager_test.cc b/src/components/functional_module/test/src/plugin_manager_test.cc
deleted file mode 100644
index f99b8b798e..0000000000
--- a/src/components/functional_module/test/src/plugin_manager_test.cc
+++ /dev/null
@@ -1,148 +0,0 @@
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-#include "functional_module/plugin_manager.h"
-#include "mock_generic_module.h"
-#include "mock_service.h"
-#include "application_manager/mock_application.h"
-#include "utils/shared_ptr.h"
-#include "utils/make_shared.h"
-
-using application_manager::Message;
-using protocol_handler::MajorProtocolVersion;
-using application_manager::MockService;
-using test::components::application_manager_test::MockApplication;
-using ::testing::NiceMock;
-using ::testing::Expectation;
-using ::testing::ReturnRef;
-
-namespace functional_modules {
-
-class PluginManagerTest : public ::testing::Test {
- public:
- PluginManagerTest()
- : manager(utils::MakeShared<PluginManager>())
- , service(utils::MakeShared<MockService>()) {}
-
- protected:
- utils::SharedPtr<PluginManager> manager;
- utils::SharedPtr<MockService> service;
- MockGenericModule* module;
-
- void SetUp() OVERRIDE {
- manager->SetServiceHandler(service);
-
- ASSERT_EQ(1, manager->LoadPlugins("./plugins/"));
- const PluginManager::Modules& plugins = manager->plugins();
- PluginManager::Modules::const_iterator i = plugins.begin();
- module = static_cast<MockGenericModule*>(i->second.get());
- }
-};
-
-TEST_F(PluginManagerTest, ChangePluginsState) {
- ServiceState kState = ServiceState::SUSPENDED;
- EXPECT_CALL(*module, OnServiceStateChanged(kState));
- manager->OnServiceStateChanged(kState);
-}
-
-TEST_F(PluginManagerTest, RemoveAppExtension) {
- const uint32_t kAppId = 2;
- EXPECT_CALL(*module, RemoveAppExtension(kAppId)).Times(1);
- manager->RemoveAppExtension(kAppId);
-}
-
-TEST_F(PluginManagerTest, ProcessMessageFail) {
- Message* msg = new Message(protocol_handler::MessagePriority::FromServiceType(
- protocol_handler::ServiceType::kRpc));
- application_manager::MessagePtr message(msg);
- msg->set_protocol_version(MajorProtocolVersion::PROTOCOL_VERSION_UNKNOWN);
- EXPECT_CALL(*module, ProcessMessage(message)).Times(0);
- manager->ProcessMessage(message);
-}
-
-TEST_F(PluginManagerTest, ProcessMessagePass) {
- Message* msg = new Message(protocol_handler::MessagePriority::FromServiceType(
- protocol_handler::ServiceType::kRpc));
- application_manager::MessagePtr message(msg);
- msg->set_protocol_version(MajorProtocolVersion::PROTOCOL_VERSION_3);
- msg->set_function_id(101); // see MockGenericModule
- EXPECT_CALL(*module, ProcessMessage(message))
- .Times(1)
- .WillOnce(Return(ProcessResult::PROCESSED));
- manager->ProcessMessage(message);
-}
-
-TEST_F(PluginManagerTest, SDL_events_triggers_module) {
- using namespace functional_modules;
- std::vector<ApplicationEvent> app_events;
- app_events.push_back(ApplicationEvent::kApplicationExit);
- app_events.push_back(ApplicationEvent::kApplicationUnregistered);
-
- application_manager::ApplicationSharedPtr dummy_ptr =
- utils::MakeShared<MockApplication>();
- std::vector<ApplicationEvent>::const_iterator ev = app_events.begin();
- for (; app_events.end() != ev; ++ev) {
- EXPECT_CALL(*module, OnApplicationEvent(*ev, dummy_ptr));
- manager->OnApplicationEvent(*ev, dummy_ptr);
- }
-
- std::vector<PolicyEvent> policy_events;
- policy_events.push_back(PolicyEvent::kApplicationPolicyUpdated);
- policy_events.push_back(PolicyEvent::kApplicationsDisabled);
-
- std::vector<PolicyEvent>::const_iterator ev_policy = policy_events.begin();
- for (; policy_events.end() != ev_policy; ++ev_policy) {
- EXPECT_CALL(*module, OnPolicyEvent(*ev_policy));
- manager->OnPolicyEvent(*ev_policy);
- }
-}
-
-TEST_F(PluginManagerTest, ProcessHMIMessageFail) {
- Message* msg = new Message(protocol_handler::MessagePriority::FromServiceType(
- protocol_handler::ServiceType::kRpc));
- application_manager::MessagePtr message(msg);
- message->set_protocol_version(MajorProtocolVersion::PROTOCOL_VERSION_UNKNOWN);
- EXPECT_CALL(*module, ProcessHMIMessage(message)).Times(0);
- manager->ProcessHMIMessage(message);
-}
-
-TEST_F(PluginManagerTest, ProcessHMIMessagePass) {
- Message* msg = new Message(protocol_handler::MessagePriority::FromServiceType(
- protocol_handler::ServiceType::kRpc));
- application_manager::MessagePtr message(msg);
- message->set_protocol_version(MajorProtocolVersion::PROTOCOL_VERSION_HMI);
- std::string json = "{\"method\": \"HMI-Func-1\"}"; // see MockGenericModule
- message->set_json_message(json);
- EXPECT_CALL(*module, ProcessHMIMessage(message))
- .Times(1)
- .WillOnce(Return(ProcessResult::PROCESSED));
- manager->ProcessHMIMessage(message);
-}
-
-TEST_F(PluginManagerTest, IsAppForPlugins) {
- using test::components::application_manager_test::MockApplication;
- MockApplication* app = new MockApplication();
- application_manager::ApplicationSharedPtr app_ptr(app);
- EXPECT_CALL(*module, IsAppForPlugin(app_ptr)).Times(1);
- manager->IsAppForPlugins(app_ptr);
-}
-
-TEST_F(PluginManagerTest, OnAppHMILevelChanged) {
- using test::components::application_manager_test::MockApplication;
- NiceMock<MockApplication>* app = new NiceMock<MockApplication>();
- application_manager::ApplicationSharedPtr app_ptr(app);
-
- const application_manager::custom_str::CustomString name("name");
- ON_CALL(*app, name()).WillByDefault(ReturnRef(name));
- mobile_apis::HMILevel::eType level = mobile_apis::HMILevel::eType::HMI_NONE;
- ON_CALL(*app, hmi_level()).WillByDefault(Return(level));
-
- Expectation is_for_plugin =
- EXPECT_CALL(*module, IsAppForPlugin(app_ptr)).WillOnce(Return(true));
- EXPECT_CALL(*module, OnAppHMILevelChanged(app_ptr, _))
- .Times(1)
- .After(is_for_plugin);
- manager->OnAppHMILevelChanged(app_ptr,
- mobile_apis::HMILevel::eType::HMI_FULL);
-}
-
-} // namespace functional_modules