diff options
author | Ivo Stoilov (GitHub) <istoilov@luxoft.com> | 2017-01-16 16:28:51 +0200 |
---|---|---|
committer | Ivo Stoilov (GitHub) <istoilov@luxoft.com> | 2017-01-25 16:50:55 +0200 |
commit | 5a628b6ac03ea0e973cb65b48e479099e61d147b (patch) | |
tree | c91abc449ed02994749e643c796969d9bead3087 | |
parent | 0f5676b6170b37e2244657fe6e7f7dbc0866b529 (diff) | |
download | sdl_core-5a628b6ac03ea0e973cb65b48e479099e61d147b.tar.gz |
Add all not existed mocks for interfaces in src/components/include
Related tasks APPLINK-30588 APPLINK-30974
12 files changed, 623 insertions, 157 deletions
diff --git a/src/components/include/test/connection_handler/mock_connection_handler_observer.h b/src/components/include/test/connection_handler/mock_connection_handler_observer.h new file mode 100644 index 0000000000..db89668a85 --- /dev/null +++ b/src/components/include/test/connection_handler/mock_connection_handler_observer.h @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2016, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_INCLUDE_TEST_CONNECTION_HANDLER_MOCK_CONNECTION_HANDLER_OBSERVER_H_ +#define SRC_COMPONENTS_INCLUDE_TEST_CONNECTION_HANDLER_MOCK_CONNECTION_HANDLER_OBSERVER_H_ + +#include "gmock/gmock.h" +#include "connection_handler/connection_handler_observer.h" + +namespace test { +namespace components { +namespace connection_handler_test { + +class MockConnectionHandlerObserver : public ConnectionHandlerObserver { + public: + MOCK_METHOD1(OnDeviceListUpdated, + void(const connection_handler::DeviceMap& device_list)); + MOCK_METHOD0(OnFindNewApplicationsRequest, + void()); + MOCK_METHOD1(RemoveDevice, + void(const connection_handler::DeviceHandle& device_handle)); + MOCK_METHOD3(OnServiceStartedCallback, + bool(const connection_handler::DeviceHandle& device_handle, const int32_t& session_key, const protocol_handler::ServiceType& type)); + MOCK_METHOD3(OnServiceEndedCallback, + void(const int32_t& session_key, const protocol_handler::ServiceType& type, const connection_handler::CloseSessionReason& close_reason)); + MOCK_CONST_METHOD1(GetHandshakeContext, + security_manager::SSLContext::HandshakeContext(uint32_t key)); +}; + + +} // namespace connection_handler_test +} // namespace components +} // namespace test + +#endif // SRC_COMPONENTS_INCLUDE_TEST_CONNECTION_HANDLER_MOCK_CONNECTION_HANDLER_OBSERVER_H_ diff --git a/src/components/include/test/policy/mock_statistics_manager.h b/src/components/include/test/hmi_message_handler/mock_hmi_message_adapter.h index 74807658c8..1906a55fa8 100644 --- a/src/components/include/test/policy/mock_statistics_manager.h +++ b/src/components/include/test/hmi_message_handler/mock_hmi_message_adapter.h @@ -1,4 +1,5 @@ -/* Copyright (c) 2016, Ford Motor Company +/* + * Copyright (c) 2015, Ford Motor Company * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -28,36 +29,27 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_INCLUDE_TEST_POLICY_MOCK_STATISTICS_MANAGER_H_ -#define SRC_COMPONENTS_INCLUDE_TEST_POLICY_MOCK_STATISTICS_MANAGER_H_ -#include <string> +#ifndef SRC_COMPONENTS_INCLUDE_TEST_HMI_MESSAGE_HANDLER_MOCK_HMI_MESSAGE_ADAPTER_H_ +#define SRC_COMPONENTS_INCLUDE_TEST_HMI_MESSAGE_HANDLER_MOCK_HMI_MESSAGE_ADAPTER_H_ #include "gmock/gmock.h" -#include "policy/usage_statistics/statistics_manager.h" +#include "hmi_message_handler/hmi_message_adapter.h" namespace test { namespace components { -namespace usage_statistics_test { +namespace hmi_message_handler_test { -class MockStatisticsManager : public usage_statistics::StatisticsManager { +using hmi_message_handler::HMIMessageAdapter; + +class MockHMIMessageAdapter : public HMIMessageAdapter { public: - MOCK_METHOD1(Increment, void(usage_statistics::GlobalCounterId type)); - MOCK_METHOD2(Increment, - void(const std::string& app_id, - usage_statistics::AppCounterId type)); - MOCK_METHOD3(Set, - void(const std::string& app_id, - usage_statistics::AppInfoId type, - const std::string& value)); - MOCK_METHOD3(Add, - void(const std::string& app_id, - usage_statistics::AppStopwatchId type, - int32_t timespan_seconds)); + MOCK_METHOD0(SubscribeTo, + void()); }; -} // namespace usage_statistics_test +} // namespace hmi_message_handler_test } // namespace components } // namespace test -#endif // SRC_COMPONENTS_INCLUDE_TEST_POLICY_MOCK_STATISTICS_MANAGER_H_ +#endif // SRC_COMPONENTS_INCLUDE_TEST_HMI_MESSAGE_HANDLER_MOCK_HMI_MESSAGE_ADAPTER_H_ diff --git a/src/components/include/test/hmi_message_handler/mock_hmi_message_observer.h b/src/components/include/test/hmi_message_handler/mock_hmi_message_observer.h new file mode 100644 index 0000000000..6c70080f54 --- /dev/null +++ b/src/components/include/test/hmi_message_handler/mock_hmi_message_observer.h @@ -0,0 +1,56 @@ +/* + * 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_INCLUDE_TEST_HMI_MESSAGE_HANDLER_MOCK_HMI_MESSAGE_OBSERVER_H_ +#define SRC_COMPONENTS_INCLUDE_TEST_HMI_MESSAGE_HANDLER_MOCK_HMI_MESSAGE_OBSERVER_H_ + +#include "gmock/gmock.h" +#include "hmi_message_handler/hmi_message_observer.h" + +namespace test { +namespace components { +namespace hmi_message_handler_test { + +class MockHMIMessageObserver : public hmi_message_handler::HMIMessageObserver { + public: + MOCK_METHOD1(OnMessageReceived, + void(utils::SharedPtr<application_manager::Message> message)); + MOCK_METHOD1(OnErrorSending, + void(utils::SharedPtr<application_manager::Message> message)); +}; + + +} // namespace hmi_message_handler_test +} // namespace components +} // namespace test + +#endif // SRC_COMPONENTS_INCLUDE_TEST_HMI_MESSAGE_HANDLER_MOCK_HMI_MESSAGE_OBSERVER_H_ diff --git a/src/components/include/test/hmi_message_handler/mock_hmi_message_sender.h b/src/components/include/test/hmi_message_handler/mock_hmi_message_sender.h new file mode 100644 index 0000000000..d544b8bd62 --- /dev/null +++ b/src/components/include/test/hmi_message_handler/mock_hmi_message_sender.h @@ -0,0 +1,53 @@ +/* + * 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_INCLUDE_TEST_HMI_MESSAGE_HANDLER_MOCK_HMI_MESSAGE_SENDER_H_ +#define SRC_COMPONENTS_INCLUDE_TEST_HMI_MESSAGE_HANDLER_MOCK_HMI_MESSAGE_SENDER_H_ + +#include "gmock/gmock.h" +#include "hmi_message_handler/hmi_message_handler.h" + +namespace test { +namespace components { +namespace hmi_message_handler_test { + +class MockHMIMessageSender : public hmi_message_handler::HMIMessageSender { + public: + MOCK_METHOD1(SendMessageToHMI, + void(MessageSharedPointer message)); +}; + +} // namespace hmi_message_handler_test +} // namespace components +} // namespace test + +#endif // SRC_COMPONENTS_INCLUDE_TEST_HMI_MESSAGE_HANDLER_MOCK_HMI_MESSAGE_SENDER_H_ diff --git a/src/components/include/test/media_manager/mock_media_manager.h b/src/components/include/test/media_manager/mock_media_manager.h new file mode 100644 index 0000000000..7708f3b667 --- /dev/null +++ b/src/components/include/test/media_manager/mock_media_manager.h @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2016, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef SRC_COMPONENTS_INCLUDE_TEST_MEDIA_MANAGER_MOCK_MEDIA_MANAGER_H_ +#define SRC_COMPONENTS_INCLUDE_TEST_MEDIA_MANAGER_MOCK_MEDIA_MANAGER_H_ + +#include "gmock/gmock.h" +#include "media_manager/media_manager.h" + +namespace test { +namespace components { +namespace media_manager_test { + +class MockMediaManager : public media_manager::MediaManager { + public: + MOCK_METHOD1(PlayA2DPSource, + void(int32_t application_key)); + MOCK_METHOD1(StopA2DPSource, + void(int32_t application_key)); + MOCK_METHOD3(StartMicrophoneRecording, + void(int32_t application_key, const std::string& outputFileName, int32_t duration)); + MOCK_METHOD1(StopMicrophoneRecording, + void(int32_t application_key)); + MOCK_METHOD2(StartStreaming, + void(int32_t application_key, protocol_handler::ServiceType service_type)); + MOCK_METHOD2(StopStreaming, + void(int32_t application_key, protocol_handler::ServiceType service_type)); + MOCK_METHOD2(FramesProcessed, + void(int32_t application_key, int32_t frame_number)); + MOCK_CONST_METHOD0(settings, + const MediaManagerSettings&()); +}; + +} // namespace media_manager_test +} // namespace components +} // namespace test + +#endif // SRC_COMPONENTS_INCLUDE_TEST_MEDIA_MANAGER_MOCK_MEDIA_MANAGER_H_ diff --git a/src/components/include/test/policy/mock_policy_manager.h b/src/components/include/test/policy/mock_policy_manager.h index a6169cdebc..0d9967af95 100644 --- a/src/components/include/test/policy/mock_policy_manager.h +++ b/src/components/include/test/policy/mock_policy_manager.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Ford Motor Company + * Copyright (c) 2016, Ford Motor Company * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -33,151 +33,154 @@ #ifndef SRC_COMPONENTS_INCLUDE_TEST_POLICY_MOCK_POLICY_MANAGER_H_ #define SRC_COMPONENTS_INCLUDE_TEST_POLICY_MOCK_POLICY_MANAGER_H_ -#include <string> -#include <vector> #include "gmock/gmock.h" -#include "policy/policy_listener.h" -#include "policy/policy_types.h" -#include "policy/usage_statistics/statistics_manager.h" - -#include "rpc_base/rpc_base.h" #include "policy/policy_manager.h" -namespace policy_table = ::rpc::policy_table_interface_base; - -using namespace policy; - namespace test { namespace components { namespace policy_manager_test { +namespace { + using namespace policy; +} + class MockPolicyManager : public PolicyManager { public: - MOCK_METHOD1(set_listener, void(PolicyListener* listener)); + MOCK_METHOD1(set_listener, + void(PolicyListener* listener)); MOCK_METHOD2(InitPT, - bool(const std::string& file_name, - const PolicySettings* settings)); + bool(const std::string& file_name, const PolicySettings* settings)); MOCK_METHOD2(LoadPT, - bool(const std::string& file, const BinaryMessage& pt_content)); - MOCK_METHOD1(ResetPT, bool(const std::string& file_name)); - MOCK_CONST_METHOD1(GetUpdateUrl, std::string(int service_type)); - MOCK_METHOD2(GetUpdateUrls, void(int service_type, EndpointUrls& end_points)); - MOCK_METHOD0(RequestPTUpdate, bool()); + bool(const std::string& file, const BinaryMessage& pt_content)); + MOCK_METHOD1(ResetPT, + bool(const std::string& file_name)); + MOCK_CONST_METHOD0(GetLockScreenIconUrl, + std::string()); + MOCK_METHOD2(GetServiceUrls, + void(const std::string& service_type, EndpointUrls& end_points)); + MOCK_METHOD0(RequestPTUpdate, + bool()); MOCK_METHOD5(CheckPermissions, - void(const PTString& app_id, - const PTString& hmi_level, - const PTString& rpc, - const RPCParams& rpc_params, - CheckPermissionResult& result)); - MOCK_METHOD0(ResetUserConsent, bool()); - MOCK_CONST_METHOD0(GetPolicyTableStatus, std::string()); - MOCK_METHOD1(KmsChanged, void(int kilometers)); - MOCK_METHOD0(IncrementIgnitionCycles, void()); - MOCK_METHOD0(ForcePTExchange, std::string()); - MOCK_METHOD0(ResetRetrySequence, void()); - MOCK_METHOD0(NextRetryTimeout, uint32_t()); - MOCK_METHOD0(TimeoutExchange, int()); - MOCK_METHOD0(RetrySequenceDelaysSeconds, const std::vector<int>()); - MOCK_METHOD0(OnExceededTimeout, void()); - MOCK_METHOD0(OnUpdateStarted, void()); + void(const PTString& app_id, const PTString& hmi_level, const PTString& rpc, const RPCParams& rpc_params, CheckPermissionResult& result)); + MOCK_METHOD0(ResetUserConsent, + bool()); + MOCK_CONST_METHOD0(GetPolicyTableStatus, + std::string()); + MOCK_METHOD1(KmsChanged, + void(int kilometers)); + MOCK_METHOD0(IncrementIgnitionCycles, + void()); + MOCK_METHOD0(ForcePTExchange, + std::string()); + MOCK_METHOD0(ResetRetrySequence, + void()); + MOCK_METHOD0(NextRetryTimeout, + uint32_t()); + MOCK_METHOD0(TimeoutExchange, + int()); + MOCK_METHOD0(RetrySequenceDelaysSeconds, + const std::vector<int>()); + MOCK_METHOD0(OnExceededTimeout, + void()); + MOCK_METHOD0(OnUpdateStarted, + void()); MOCK_CONST_METHOD1(GetUserConsentForDevice, - DeviceConsent(const std::string& device_id)); - MOCK_METHOD3( - GetUserConsentForApp, - void(const std::string& device_id, - const std::string& policy_app_id, - std::vector<policy::FunctionalGroupPermission>& permissions)); + DeviceConsent(const std::string& device_id)); + MOCK_METHOD3(GetUserConsentForApp, + void(const std::string& device_id, const std::string& policy_app_id, std::vector<FunctionalGroupPermission>& permissions)); MOCK_METHOD2(SetUserConsentForDevice, - void(const std::string& device_id, const bool is_allowed)); + void(const std::string& device_id, bool is_allowed)); MOCK_METHOD2(ReactOnUserDevConsentForApp, - bool(const std::string app_id, bool is_device_allowed)); - MOCK_METHOD2(PTUpdatedAt, void(policy::Counters counter, int value)); - + bool(const std::string app_id, bool is_device_allowed)); + MOCK_METHOD2(PTUpdatedAt, + void(Counters counter, int value)); MOCK_METHOD3(GetInitialAppData, - bool(const std::string&, - policy::StringArray*, - policy::StringArray*)); - + bool(const std::string& str, StringArray* arr1, StringArray* arr2)); MOCK_METHOD2(AddDevice, - void(const std::string& device_id, - const std::string& connection_type)); + void(const std::string& device_id, const std::string& connection_type)); MOCK_METHOD2(SetDeviceInfo, - void(const std::string& device_id, - const policy::DeviceInfo& device_info)); + void(const std::string& device_id, const DeviceInfo& device_info)); MOCK_METHOD1(SetUserConsentForApp, - void(const policy::PermissionConsent& permissions)); + void(const PermissionConsent& permissions)); MOCK_CONST_METHOD2(GetDefaultHmi, - bool(const std::string& policy_app_id, - std::string* default_hmi)); + bool(const std::string& policy_app_id, std::string* default_hmi)); MOCK_CONST_METHOD2(GetPriority, - bool(const std::string& policy_app_id, - std::string* priority)); + bool(const std::string& policy_app_id, std::string* priority)); MOCK_METHOD2(GetUserFriendlyMessages, - std::vector<policy::UserFriendlyMessage>( - const std::vector<std::string>& message_code, - const std::string& language)); - MOCK_CONST_METHOD1(IsApplicationRevoked, bool(const std::string& app_id)); - MOCK_METHOD3( - GetPermissionsForApp, - void(const std::string& device_id, - const std::string& policy_app_id, - std::vector<policy::FunctionalGroupPermission>& permissions)); + std::vector<UserFriendlyMessage>(const std::vector<std::string>& message_code, const std::string& language)); + MOCK_CONST_METHOD1(IsApplicationRevoked, + bool(const std::string& app_id)); + MOCK_METHOD3(GetPermissionsForApp, + void(const std::string& device_id, const std::string& policy_app_id, std::vector<FunctionalGroupPermission>& permissions)); MOCK_METHOD1(GetAppPermissionsChanges, - policy::AppPermissions(const std::string& policy_app_id)); - MOCK_METHOD1(RemovePendingPermissionChanges, void(const std::string& app_id)); + AppPermissions(const std::string& policy_app_id)); + MOCK_METHOD1(RemovePendingPermissionChanges, + void(const std::string& app_id)); MOCK_CONST_METHOD1(GetCurrentDeviceId, - std::string&(const std::string& policy_app_id)); - MOCK_METHOD1(SetSystemLanguage, void(const std::string& language)); + std::string&(const std::string& policy_app_id)); + MOCK_METHOD1(SetSystemLanguage, + void(const std::string& language)); MOCK_METHOD3(SetSystemInfo, - void(const std::string& ccpu_version, - const std::string& wers_country_code, - const std::string& language)); + void(const std::string& ccpu_version, const std::string& wers_country_code, const std::string& language)); MOCK_METHOD1(SendNotificationOnPermissionsUpdated, - void(const std::string& application_id)); - MOCK_METHOD1(MarkUnpairedDevice, void(const std::string& device_id)); - MOCK_METHOD1(AddApplication, void(const std::string& application_id)); - MOCK_METHOD0(CleanupUnpairedDevices, bool()); - MOCK_CONST_METHOD1(CanAppKeepContext, bool(const std::string& app_id)); - MOCK_CONST_METHOD1(CanAppStealFocus, bool(const std::string& app_id)); - MOCK_METHOD0(OnSystemReady, void()); + void(const std::string& application_id)); + MOCK_METHOD1(MarkUnpairedDevice, + void(const std::string& device_id)); + MOCK_METHOD1(AddApplication, + void(const std::string& application_id)); + MOCK_METHOD0(CleanupUnpairedDevices, + bool()); + MOCK_CONST_METHOD1(CanAppKeepContext, + bool(const std::string& app_id)); + MOCK_CONST_METHOD1(CanAppStealFocus, + bool(const std::string& app_id)); + MOCK_METHOD0(OnSystemReady, + void()); MOCK_CONST_METHOD1(GetNotificationsNumber, - uint32_t(const std::string& priority)); - MOCK_METHOD1(SetVINValue, void(const std::string& value)); - MOCK_METHOD1(IsPredataPolicy, bool(const std::string& policy_app_id)); - MOCK_CONST_METHOD1(HeartBeatTimeout, uint32_t(const std::string& app_id)); - MOCK_METHOD1(SaveUpdateStatusRequired, void(bool is_update_needed)); - MOCK_METHOD0(OnAppsSearchStarted, void()); - MOCK_METHOD0(OnAppsSearchCompleted, void()); - MOCK_METHOD1(OnAppRegisteredOnMobile, - void(const std::string& application_id)); - MOCK_CONST_METHOD1( - GetAppRequestTypes, + uint32_t(const std::string& priority)); + MOCK_METHOD1(SetVINValue, + void(const std::string& value)); + MOCK_METHOD1(IsPredataPolicy, + bool(const std::string& policy_app_id)); + MOCK_CONST_METHOD1(HeartBeatTimeout, + uint32_t(const std::string& app_id)); + MOCK_METHOD1(SaveUpdateStatusRequired, + void(bool is_update_needed)); + MOCK_METHOD0(OnAppsSearchStarted, + void()); + MOCK_METHOD0(OnAppsSearchCompleted, + void()); + MOCK_CONST_METHOD1(GetAppRequestTypes, const std::vector<std::string>(const std::string policy_app_id)); - MOCK_CONST_METHOD0(GetVehicleInfo, const policy::VehicleInfo()); - MOCK_CONST_METHOD0(GetMetaInfo, const policy::MetaInfo()); - MOCK_CONST_METHOD0(RetrieveCertificate, std::string()); - MOCK_METHOD1(SetDecryptedCertificate, void(const std::string&)); - MOCK_METHOD0(ExceededIgnitionCycles, bool()); - MOCK_METHOD0(ExceededDays, bool()); - MOCK_METHOD0(StartPTExchange, void()); + MOCK_CONST_METHOD0(GetVehicleInfo, + const VehicleInfo()); + MOCK_METHOD1(OnAppRegisteredOnMobile, + void(const std::string& application_id)); + MOCK_CONST_METHOD0(RetrieveCertificate, + std::string()); + MOCK_CONST_METHOD0(get_settings, + const PolicySettings&()); + MOCK_METHOD0(ExceededIgnitionCycles, + bool()); + MOCK_METHOD0(ExceededDays, + bool()); + MOCK_METHOD0(StartPTExchange, + void()); + + // --- Statistics Manager section MOCK_METHOD1(Increment, void(usage_statistics::GlobalCounterId type)); - MOCK_METHOD2(Increment, - void(const std::string& app_id, - usage_statistics::AppCounterId type)); - MOCK_METHOD3(Set, - void(const std::string& app_id, - usage_statistics::AppInfoId type, - const std::string& value)); - MOCK_METHOD3(Add, - void(const std::string& app_id, - usage_statistics::AppStopwatchId type, - int32_t timespan_seconds)); - MOCK_CONST_METHOD0(get_settings, const PolicySettings&()); - MOCK_METHOD1(set_settings, void(const PolicySettings* get_settings)); - MOCK_CONST_METHOD0(GetLockScreenIconUrl, std::string()); - MOCK_METHOD2(GetServiceUrls, - void(const std::string& service_type, EndpointUrls& end_points)); + MOCK_METHOD2(Increment, void(const std::string& app_id, + usage_statistics::AppCounterId type)); + MOCK_METHOD3(Set, void(const std::string& app_id, + usage_statistics::AppInfoId type, + const std::string& value)); + MOCK_METHOD3(Add, void(const std::string& app_id, + usage_statistics::AppStopwatchId type, + int32_t timespan_seconds)); }; + + + } // namespace policy_manager_test } // namespace components } // namespace test diff --git a/src/components/include/test/policy/usage_statistics/mock_app_stopwatch.h b/src/components/include/test/policy/usage_statistics/mock_app_stopwatch.h index 481d887cb2..aa29d2c78b 100644 --- a/src/components/include/test/policy/usage_statistics/mock_app_stopwatch.h +++ b/src/components/include/test/policy/usage_statistics/mock_app_stopwatch.h @@ -34,7 +34,6 @@ #include "gmock/gmock.h" #include "policy/usage_statistics/app_stopwatch.h" -#include "policy/usage_statistics/statistics_manager.h" namespace test { namespace components { diff --git a/src/components/include/test/protocol_handler/mock_telemetry_observer.h b/src/components/include/test/protocol_handler/mock_telemetry_observer.h new file mode 100644 index 0000000000..5901460cd2 --- /dev/null +++ b/src/components/include/test/protocol_handler/mock_telemetry_observer.h @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2014, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_INCLUDE_TEST_PROTOCOL_HANDLER_MOCK_TELEMETRY_OBSERVER_H_ +#define SRC_COMPONENTS_INCLUDE_TEST_PROTOCOL_HANDLER_MOCK_TELEMETRY_OBSERVER_H_ + +#include "gmock/gmock.h" + +#include "protocol_handler/telemetry_observer.h" + +namespace test { +namespace components { +namespace protocol_handler_test { + +class MockPHTelemetryObserver : public PHTelemetryObserver { + public: + MOCK_METHOD2(StartMessageProcess, + void(uint32_t message_id, const TimevalStruct& start_time)); + MOCK_METHOD1(EndMessageProcess, + void(utils::SharedPtr<MessageMetric> m)); +}; + +} // namespace protocol_handler_test +} // namespace components +} // namespace test +#endif // SRC_COMPONENTS_INCLUDE_TEST_PROTOCOL_HANDLER_MOCK_TELEMETRY_OBSERVER_H_ diff --git a/src/components/include/test/transport_manager/mock_transport_manager_listener.h b/src/components/include/test/transport_manager/mock_transport_manager_listener.h new file mode 100644 index 0000000000..c989556ace --- /dev/null +++ b/src/components/include/test/transport_manager/mock_transport_manager_listener.h @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2014, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_INCLUDE_TEST_TRANSPORT_MANAGER_MOCK_TRANSPORT_MANAGER_LISTENER_H_ +#define SRC_COMPONENTS_INCLUDE_TEST_TRANSPORT_MANAGER_MOCK_TRANSPORT_MANAGER_LISTENER_H_ + +#include "gmock/gmock.h" + +#include "transport_manager/transport_manager_listener.h" + +namespace test { +namespace components { +namespace transport_manager_test { + +class MockTransportManagerListener + : public transport_manager::TransportManagerListener { + public: + MOCK_METHOD1(OnDeviceListUpdated, + void(const std::vector<DeviceInfo>)); + MOCK_METHOD0(OnFindNewApplicationsRequest, + void()); + MOCK_METHOD1(OnDeviceFound, + void(const DeviceInfo& device_info)); + MOCK_METHOD1(OnDeviceAdded, + void(const DeviceInfo& device_info)); + MOCK_METHOD1(OnDeviceRemoved, + void(const DeviceInfo& device_info)); + MOCK_METHOD0(OnScanDevicesFinished, + void()); + MOCK_METHOD1(OnScanDevicesFailed, + void(const SearchDeviceError& error)); + MOCK_METHOD2(OnConnectionEstablished, + void(const DeviceInfo& device_info, const ConnectionUID connection_id)); + MOCK_METHOD2(OnConnectionFailed, + void(const DeviceInfo& device_info, const ConnectError& error)); + MOCK_METHOD1(OnConnectionClosed, + void(const ConnectionUID connection_id)); + MOCK_METHOD2(OnUnexpectedDisconnect, + void(const ConnectionUID connection_id, const CommunicationError& error)); + MOCK_METHOD2(OnConnectionClosedFailure, + void(const ConnectionUID connection_id, const DisconnectError& error)); + MOCK_METHOD2(OnDeviceConnectionLost, + void(const DeviceHandle& device, const DisconnectDeviceError& error)); + MOCK_METHOD2(OnDisconnectFailed, + void(const DeviceHandle& device, const DisconnectDeviceError& error)); + MOCK_METHOD1(OnTMMessageReceived, + void(const ::protocol_handler::RawMessagePtr message)); + MOCK_METHOD1(OnTMMessageReceiveFailed, + void(const DataReceiveError& error)); + MOCK_METHOD1(OnTMMessageSend, + void(const ::protocol_handler::RawMessagePtr message)); + MOCK_METHOD2(OnTMMessageSendFailed, + void(const DataSendError& error, const ::protocol_handler::RawMessagePtr message)); +}; + + +} // namespace transport_manager_test +} // namespace components +} // namespace test + +#endif // SRC_COMPONENTS_INCLUDE_TEST_TRANSPORT_MANAGER_MOCK_TRANSPORT_MANAGER_LISTENER_H_ diff --git a/src/components/include/test/telemetry_monitor/mock_telemetry_observer.h b/src/components/include/test/transport_manager/transport_adapter/mock_device.h index 0543613ca8..557a490ea6 100644 --- a/src/components/include/test/telemetry_monitor/mock_telemetry_observer.h +++ b/src/components/include/test/transport_manager/transport_adapter/mock_device.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Ford Motor Company + * Copyright (c) 2014, Ford Motor Company * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -30,25 +30,30 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_INCLUDE_TEST_TELEMETRY_MONITOR_MOCK_TELEMETRY_OBSERVER_H_ -#define SRC_COMPONENTS_INCLUDE_TEST_TELEMETRY_MONITOR_MOCK_TELEMETRY_OBSERVER_H_ +#ifndef SRC_COMPONENTS_INCLUDE_TEST_TRANSPORT_MANAGER_TRANSPORT_ADAPTER_MOCK_DEVICE_H_ +#define SRC_COMPONENTS_INCLUDE_TEST_TRANSPORT_MANAGER_TRANSPORT_ADAPTER_MOCK_DEVICE_H_ -#include <string> #include "gmock/gmock.h" -#include "transport_manager/telemetry_observer.h" -#include "protocol/raw_message.h" +#include "transport_manager/transport_adapter/device.h" + namespace test { namespace components { namespace transport_manager_test { -class TMTelemetryObserverMock - : public ::transport_manager::TMTelemetryObserver { +using transport_manager::transport_adapter::Device; + +class MockDevice : public Device { public: - MOCK_METHOD1(StartRawMsg, void(const protocol_handler::RawMessage* ptr)); - MOCK_METHOD1(StopRawMsg, void(const protocol_handler::RawMessage* ptr)); + MOCK_CONST_METHOD1(IsSameAs, + bool(const Device* other_device)); + MOCK_CONST_METHOD0(GetApplicationList, + transport_manager::ApplicationList()); + MOCK_METHOD0(Stop, + void()); }; + } // namespace transport_manager_test } // namespace components } // namespace test -#endif // SRC_COMPONENTS_INCLUDE_TEST_TELEMETRY_MONITOR_MOCK_TELEMETRY_OBSERVER_H_ +#endif // SRC_COMPONENTS_INCLUDE_TEST_TRANSPORT_MANAGER_TRANSPORT_ADAPTER_MOCK_DEVICE_H_ diff --git a/src/components/include/test/transport_manager/transport_adapter/mock_transport_adapter.h b/src/components/include/test/transport_manager/transport_adapter/mock_transport_adapter.h new file mode 100644 index 0000000000..618e85a4fa --- /dev/null +++ b/src/components/include/test/transport_manager/transport_adapter/mock_transport_adapter.h @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2014, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_INCLUDE_TEST_TRANSPORT_MANAGER_MOCK_TRANSPORT_MANAGER_H_ +#define SRC_COMPONENTS_INCLUDE_TEST_TRANSPORT_MANAGER_MOCK_TRANSPORT_MANAGER_H_ + +#include "gmock/gmock.h" +#include <string> +#include "transport_manager/transport_manager.h" +#include "transport_manager/transport_adapter/transport_adapter_event.h" +#include "telemetry_monitor/telemetry_observable.h" +#include "resumption/last_state.h" + +namespace test { +namespace components { +namespace transport_manager_test { + +using ::transport_manager::DeviceHandle; +using ::transport_manager::ConnectionUID; +using ::transport_manager::transport_adapter::TransportAdapter; +using ::transport_manager::TransportAdapterEvent; +using ::transport_manager::TransportManagerListener; +/* + * MOCK implementation of ::transport_manager::TransportManager interface + */ +class MockTransportManager : public ::transport_manager::TransportManager, + public ::telemetry_monitor::TelemetryObservable< + transport_manager::TMTelemetryObserver> { + public: + MOCK_METHOD1(Init, int(resumption::LastState& last_state)); + MOCK_METHOD0(Reinit, int()); + MOCK_METHOD0(SearchDevices, int()); + MOCK_METHOD1(ConnectDevice, int(const DeviceHandle)); + MOCK_METHOD1(DisconnectDevice, int(const DeviceHandle)); + MOCK_METHOD1(Disconnect, int(const ConnectionUID)); + MOCK_METHOD1(DisconnectForce, int(const ConnectionUID)); + MOCK_METHOD1(SendMessageToDevice, + int(const ::protocol_handler::RawMessagePtr)); + MOCK_METHOD1(ReceiveEventFromDevice, int(const TransportAdapterEvent&)); + MOCK_METHOD1(AddTransportAdapter, int(TransportAdapter* adapter)); + MOCK_METHOD1(AddEventListener, int(TransportManagerListener* listener)); + MOCK_METHOD0(Stop, int()); + MOCK_METHOD1(RemoveDevice, int(const DeviceHandle)); + MOCK_CONST_METHOD1(Visibility, int(const bool&)); + MOCK_METHOD1(SetTelemetryObserver, + void(transport_manager::TMTelemetryObserver* observer)); +}; + +} // namespace transport_manager_test +} // namespace components +} // namespace test +#endif // SRC_COMPONENTS_INCLUDE_TEST_TRANSPORT_MANAGER_MOCK_TRANSPORT_MANAGER_H_ diff --git a/src/components/transport_manager/test/include/transport_manager/mock_telemetry_observer.h b/src/components/transport_manager/test/include/transport_manager/mock_telemetry_observer.h index de433c2e0f..eb7da8ace3 100644 --- a/src/components/transport_manager/test/include/transport_manager/mock_telemetry_observer.h +++ b/src/components/transport_manager/test/include/transport_manager/mock_telemetry_observer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Ford Motor Company + * Copyright (c) 2016, Ford Motor Company * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -40,14 +40,16 @@ namespace test { namespace components { namespace transport_manager_test { -class MockTMTelemetryObserver - : public ::transport_manager::TMTelemetryObserver { +class MockTMTelemetryObserver : public TMTelemetryObserver { public: - MOCK_METHOD1(StartRawMsg, void(const protocol_handler::RawMessage* ptr)); - MOCK_METHOD1(StopRawMsg, void(const protocol_handler::RawMessage* ptr)); + MOCK_METHOD1(StartRawMsg, + void(const protocol_handler::RawMessage* ptr)); + MOCK_METHOD1(StopRawMsg, + void(const protocol_handler::RawMessage* ptr)); }; -} // transport_manager_test -} // components -} // test +} // namespace transport_manager_test +} // namespace components +} // namespace test + #endif // SRC_COMPONENTS_TRANSPORT_MANAGER_TEST_INCLUDE_TRANSPORT_MANAGER_MOCK_TELEMETRY_OBSERVER_H_ |