diff options
Diffstat (limited to 'src/components/include/test/policy')
13 files changed, 1153 insertions, 15 deletions
diff --git a/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h new file mode 100644 index 0000000000..5aa92446b6 --- /dev/null +++ b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h @@ -0,0 +1,259 @@ +/* + * 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_POLICY_POLICY_EXTERNAL_POLICY_MOCK_CACHE_MANAGER_H_ +#define SRC_COMPONENTS_INCLUDE_TEST_POLICY_POLICY_EXTERNAL_POLICY_MOCK_CACHE_MANAGER_H_ + +#include <string> +#include <vector> + +#include "gmock/gmock.h" + +#include "policy/cache_manager_interface.h" + +namespace policy_table = rpc::policy_table_interface_base; + +using namespace ::policy; + +namespace test { +namespace components { +namespace policy_test { + +class MockCacheManagerInterface : public ::policy::CacheManagerInterface { + public: + MOCK_CONST_METHOD2(GetConsentsPriority, + ConsentPriorityType(const std::string& device_id, + const std::string& application_id)); + MOCK_METHOD4(CheckPermissions, + void(const PTString& app_id, + const PTString& hmi_level, + const PTString& rpc, + CheckPermissionResult& result)); + MOCK_METHOD0(IsPTPreloaded, bool()); + MOCK_METHOD0(IgnitionCyclesBeforeExchange, int()); + MOCK_METHOD1(KilometersBeforeExchange, int(int current)); + MOCK_CONST_METHOD1(GetPermissionsList, bool(StringArray& perm_list)); + MOCK_METHOD2(SetCountersPassedForSuccessfulUpdate, + bool(Counters counter, int value)); + MOCK_METHOD1(DaysBeforeExchange, int(uint16_t current)); + MOCK_METHOD0(IncrementIgnitionCycles, void()); + + MOCK_METHOD2(SaveDeviceConsentToCache, + void(const std::string& device_id, const bool is_allowed)); + + MOCK_METHOD1(ResetCalculatedPermissionsForDevice, + void(const std::string& device_id)); + MOCK_METHOD0(ResetIgnitionCycles, void()); + MOCK_METHOD0(TimeoutResponse, int()); + MOCK_METHOD1(SecondsBetweenRetries, bool(std::vector<int>& seconds)); + MOCK_CONST_METHOD1(IsDeviceConsentCached, bool(const std::string& device_id)); + MOCK_CONST_METHOD0(GetVehicleInfo, const VehicleInfo()); + MOCK_CONST_METHOD1(GetDeviceConsent, + DeviceConsent(const std::string& device_id)); + MOCK_METHOD2(SetDeviceConsent, + void(const std::string& device_id, bool is_allowed)); + + MOCK_CONST_METHOD2(HasDeviceSpecifiedConsent, + bool(const std::string& device_id, const bool is_allowed)); + MOCK_CONST_METHOD1(GetCachedDeviceConsent, + DeviceConsent(const std::string& device_id)); + MOCK_METHOD1(SetVINValue, bool(const std::string& value)); + MOCK_METHOD3(GetUserFriendlyMsg, + std::vector<UserFriendlyMessage>( + const std::vector<std::string>& msg_codes, + const std::string& language, + const std::string& active_hmi_language)); + MOCK_METHOD2(GetUpdateUrls, + void(const std::string& service_type, + EndpointUrls& out_end_points)); + MOCK_METHOD2(GetUpdateUrls, + void(const uint32_t service_type, EndpointUrls& out_end_points)); + MOCK_CONST_METHOD0(GetLockScreenIconUrl, std::string()); + MOCK_METHOD1( + GetNotificationsNumber, + policy_table::NumberOfNotificationsType(const std::string& priority)); + MOCK_CONST_METHOD2(GetPriority, + bool(const std::string& policy_app_id, + std::string& priority)); + MOCK_METHOD2(Init, + bool(const std::string& file_name, + const PolicySettings* settings)); + MOCK_METHOD0(GenerateSnapshot, utils::SharedPtr<policy_table::Table>()); + MOCK_METHOD1(ApplyUpdate, bool(const policy_table::Table& update_pt)); + MOCK_METHOD1(Save, bool(const policy_table::Table& table)); + MOCK_CONST_METHOD0(UpdateRequired, bool()); + MOCK_METHOD1(SaveUpdateRequired, void(bool status)); + MOCK_METHOD3(GetInitialAppData, + bool(const std::string& app_id, + StringArray& nicknames, + StringArray& app_hmi_types)); + MOCK_CONST_METHOD1(IsApplicationRevoked, bool(const std::string& app_id)); + MOCK_METHOD1(GetFunctionalGroupings, + bool(policy_table::FunctionalGroupings& groups)); + MOCK_CONST_METHOD1(IsApplicationRepresented, bool(const std::string& app_id)); + MOCK_CONST_METHOD1(IsDefaultPolicy, bool(const std::string& app_id)); + MOCK_METHOD1(SetIsDefault, bool(const std::string& app_id)); + MOCK_METHOD1(SetIsPredata, bool(const std::string& app_id)); + MOCK_CONST_METHOD1(IsPredataPolicy, bool(const std::string& app_id)); + MOCK_METHOD1(SetDefaultPolicy, bool(const std::string& app_id)); + MOCK_CONST_METHOD1(CanAppKeepContext, bool(const std::string& app_id)); + MOCK_CONST_METHOD1(CanAppStealFocus, bool(const std::string& app_id)); + MOCK_CONST_METHOD2(GetDefaultHMI, + bool(const std::string& app_id, std::string& default_hmi)); + MOCK_METHOD0(ResetUserConsent, bool()); + MOCK_CONST_METHOD3(GetUserPermissionsForDevice, + bool(const std::string& device_id, + StringArray& consented_groups, + StringArray& disallowed_groups)); + MOCK_METHOD3(GetPermissionsForApp, + bool(const std::string& device_id, + const std::string& app_id, + FunctionalIdType& group_types)); + MOCK_CONST_METHOD2( + GetDeviceGroupsFromPolicies, + bool(rpc::policy_table_interface_base::Strings& groups, + rpc::policy_table_interface_base::Strings& preconsented_groups)); + MOCK_METHOD2(AddDevice, + bool(const std::string& device_id, + const std::string& connection_type)); + MOCK_METHOD8(SetDeviceData, + bool(const std::string& device_id, + const std::string& hardware, + const std::string& firmware, + const std::string& os, + const std::string& os_version, + const std::string& carrier, + const uint32_t number_of_ports, + const std::string& connection_type)); + MOCK_METHOD3(SetUserPermissionsForDevice, + bool(const std::string& device_id, + const StringArray& consented_groups, + const StringArray& disallowed_groups)); + MOCK_METHOD2(ReactOnUserDevConsentForApp, + bool(const std::string& app_id, bool is_device_allowed)); + MOCK_METHOD2(SetUserPermissionsForApp, + bool(const PermissionConsent& permissions, + bool* out_app_permissions_changed)); + MOCK_METHOD3(SetMetaInfo, + bool(const std::string& ccpu_version, + const std::string& wers_country_code, + const std::string& language)); + MOCK_CONST_METHOD0(IsMetaInfoPresent, bool()); + MOCK_METHOD1(SetSystemLanguage, bool(const std::string& language)); + MOCK_METHOD1(Increment, void(usage_statistics::GlobalCounterId type)); + MOCK_METHOD2(Increment, + void(const std::string& app_id, + usage_statistics::AppCounterId type)); + MOCK_METHOD3(Set, + void(const std::string& app_id, + usage_statistics::AppInfoId type, + const std::string& value)); + MOCK_METHOD3(Add, + void(const std::string& app_id, + usage_statistics::AppStopwatchId type, + int seconds)); + MOCK_METHOD2(CountUnconsentedGroups, + int(const std::string& policy_app_id, + const std::string& device_id)); + MOCK_METHOD1(GetFunctionalGroupNames, bool(FunctionalGroupNames& names)); + MOCK_METHOD2(GetAllAppGroups, + void(const std::string& app_id, + FunctionalGroupIDs& all_group_ids)); + MOCK_METHOD2(GetPreConsentedGroups, + void(const std::string& app_id, + FunctionalGroupIDs& preconsented_groups)); + MOCK_METHOD4(GetConsentedGroups, + void(const std::string& device_id, + const std::string& app_id, + FunctionalGroupIDs& allowed_groups, + FunctionalGroupIDs& disallowed_groups)); + MOCK_METHOD3(GetUnconsentedGroups, + void(const std::string& device_id, + const std::string& policy_app_id, + FunctionalGroupIDs& unconsented_groups)); + MOCK_METHOD2(RemoveAppConsentForGroup, + void(const std::string& app_id, const std::string& group_name)); + MOCK_METHOD1(SetPredataPolicy, bool(const std::string& app_id)); + MOCK_METHOD0(CleanupUnpairedDevices, bool()); + MOCK_METHOD2(SetUnpairedDevice, + bool(const std::string& device_id, bool unpaired)); + MOCK_METHOD1(UnpairedDevicesList, bool(DeviceIds& device_ids)); + MOCK_METHOD1(ResetPT, bool(const std::string& file_name)); + MOCK_METHOD0(LoadFromBackup, bool()); + MOCK_METHOD2(LoadFromFile, + bool(const std::string& file_name, policy_table::Table&)); + MOCK_METHOD0(Backup, void()); + MOCK_CONST_METHOD1(HeartBeatTimeout, uint32_t(const std::string& app_id)); + MOCK_CONST_METHOD2(GetAppRequestTypes, + void(const std::string& policy_app_id, + std::vector<std::string>& request_types)); + MOCK_METHOD1(GetHMIAppTypeAfterUpdate, + void(std::map<std::string, StringArray>& app_hmi_types)); + + MOCK_CONST_METHOD2(AppHasHMIType, + bool(const std::string& application_id, + policy_table::AppHMIType hmi_type)); + + MOCK_METHOD0(ResetCalculatedPermissions, void()); + MOCK_METHOD3(AddCalculatedPermissions, + void(const std::string& device_id, + const std::string& policy_app_id, + const policy::Permissions& permissions)); + MOCK_METHOD3(IsPermissionsCalculated, + bool(const std::string& device_id, + const std::string& policy_app_id, + policy::Permissions& permission)); + MOCK_CONST_METHOD0(GetPT, utils::SharedPtr<policy_table::Table>()); + MOCK_CONST_METHOD0(GetMetaInfo, const MetaInfo()); + MOCK_CONST_METHOD0(GetCertificate, std::string()); + MOCK_METHOD1(SetDecryptedCertificate, void(const std::string&)); + MOCK_METHOD1(set_settings, void(const PolicySettings* settings)); + MOCK_METHOD1(GetHMITypes, + const policy_table::AppHMITypes*(const std::string& app_id)); + MOCK_METHOD1(GetGroups, const policy_table::Strings&(const PTString& app_id)); + + MOCK_METHOD1(SetExternalConsentStatus, bool(const ExternalConsentStatus&)); + MOCK_METHOD0(GetExternalConsentStatus, ExternalConsentStatus()); + MOCK_METHOD0(GetExternalConsentEntities, ExternalConsentStatus()); + MOCK_METHOD1(GetGroupsWithSameEntities, + GroupsByExternalConsentStatus(const ExternalConsentStatus&)); + MOCK_METHOD0(GetKnownLinksFromPT, std::map<std::string, std::string>()); + MOCK_METHOD1(SetExternalConsentForApp, void(const PermissionConsent&)); + MOCK_METHOD2(OnDeviceSwitching, + void(const std::string& device_id_from, + const std::string& device_id_to)); +}; + +} // namespace policy_test +} // namespace components +} // namespace test + +#endif // SRC_COMPONENTS_INCLUDE_TEST_POLICY_POLICY_EXTERNAL_POLICY_MOCK_CACHE_MANAGER_H_ diff --git a/src/components/include/test/policy/policy_external/policy/mock_policy_listener.h b/src/components/include/test/policy/policy_external/policy/mock_policy_listener.h new file mode 100644 index 0000000000..ad2f1fd56c --- /dev/null +++ b/src/components/include/test/policy/policy_external/policy/mock_policy_listener.h @@ -0,0 +1,111 @@ +/* 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_POLICY_POLICY_EXTERNAL_POLICY_MOCK_POLICY_LISTENER_H_ +#define SRC_COMPONENTS_INCLUDE_TEST_POLICY_POLICY_EXTERNAL_POLICY_MOCK_POLICY_LISTENER_H_ + +#include <string> +#include <map> +#include <queue> +#include <vector> + +#include "gmock/gmock.h" + +#include "policy/policy_listener.h" +#include "rpc_base/rpc_base.h" +#include "policy/policy_table/types.h" +#include "utils/custom_string.h" + +namespace policy_table = ::rpc::policy_table_interface_base; + +namespace test { +namespace components { +namespace policy_test { + +namespace custom_str = utils::custom_string; + +class MockPolicyListener : public ::policy::PolicyListener { + public: + MOCK_METHOD3(OnPermissionsUpdated, + void(const std::string& policy_app_id, + const policy::Permissions& permissions, + const policy::HMILevel& default_hmi)); + MOCK_METHOD2(OnPermissionsUpdated, + void(const std::string& policy_app_id, + const policy::Permissions& permissions)); + MOCK_METHOD1(OnPendingPermissionChange, + void(const std::string& policy_app_id)); + MOCK_METHOD1(OnUpdateStatusChanged, void(const std::string& status)); + MOCK_METHOD1(OnCurrentDeviceIdUpdateRequired, + std::string(const std::string& policy_app_id)); + MOCK_METHOD0(OnSystemInfoUpdateRequired, void()); + MOCK_METHOD1(GetAppName, + custom_str::CustomString(const std::string& policy_app_id)); + MOCK_METHOD0(OnUserRequestedUpdateCheckRequired, void()); + MOCK_METHOD2(OnDeviceConsentChanged, + void(const std::string& device_id, bool is_allowed)); + MOCK_METHOD1(OnUpdateHMIAppType, + void(std::map<std::string, policy::StringArray>)); + MOCK_METHOD1(GetAvailableApps, void(std::queue<std::string>&)); + MOCK_METHOD3(OnSnapshotCreated, + void(const policy::BinaryMessage& pt_string, + const std::vector<int>& retry_seconds, + uint32_t timeout_exceed)); + MOCK_METHOD0(CanUpdate, bool()); + MOCK_METHOD1(OnCertificateUpdated, void(const std::string&)); + MOCK_METHOD1(OnPTUFinished, void(const bool ptu_result)); + MOCK_CONST_METHOD2(SendOnAppPermissionsChanged, + void(const policy::AppPermissions&, const std::string&)); + MOCK_METHOD1(GetDevicesIds, + std::vector<std::string>(const std::string& policy_app_id)); + MOCK_METHOD3(OnUpdateHMILevel, + void(const std::string& device_id, + const std::string& policy_app_id, + const std::string& hmi_level)); + MOCK_CONST_METHOD1(GetRegisteredLinks, + void(std::map<std::string, std::string>&)); +#ifdef SDL_REMOTE_CONTROL + MOCK_METHOD1(OnRemoteAllowedChanged, void(bool new_consent)); + MOCK_METHOD2(OnRemoteAppPermissionsChanged, + void(const std::string& device_id, + const std::string& application_id)); + MOCK_METHOD3(OnUpdateHMIStatus, + void(const std::string& device_id, + const std::string& policy_app_id, + const std::string& hmi_level)); +#endif // SDL_REMOTE_CONTROL +}; + +} // namespace policy_test +} // namespace components +} // namespace test + +#endif // SRC_COMPONENTS_INCLUDE_TEST_POLICY_POLICY_EXTERNAL_POLICY_MOCK_POLICY_LISTENER_H_ diff --git a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h new file mode 100644 index 0000000000..9e487da4ba --- /dev/null +++ b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h @@ -0,0 +1,226 @@ +/* + * 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_POLICY_POLICY_EXTERNAL_POLICY_MOCK_POLICY_MANAGER_H_ +#define SRC_COMPONENTS_INCLUDE_TEST_POLICY_POLICY_EXTERNAL_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_table/types.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 { + +class MockPolicyManager : public PolicyManager { + public: + MOCK_METHOD1(set_listener, void(PolicyListener* listener)); + MOCK_METHOD2(InitPT, + 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_METHOD1(GetUpdateUrl, std::string(int service_type)); + MOCK_METHOD2(GetUpdateUrls, + void(const uint32_t service_type, EndpointUrls& out_end_points)); + MOCK_METHOD2(GetUpdateUrls, + void(const std::string& service_type, + EndpointUrls& out_end_points)); + MOCK_METHOD0(RequestPTUpdate, void()); + 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(ForcePTExchangeAtUserRequest, std::string()); + MOCK_METHOD0(ResetRetrySequence, void()); + MOCK_METHOD0(NextRetryTimeout, int()); + MOCK_METHOD0(TimeoutExchangeMSec, uint32_t()); + 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)); + MOCK_METHOD2(SetUserConsentForDevice, + void(const std::string& device_id, const 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)); + + MOCK_METHOD3(GetInitialAppData, + bool(const std::string&, + policy::StringArray*, + policy::StringArray*)); + + MOCK_METHOD2(AddDevice, + 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)); + MOCK_METHOD2(SetUserConsentForApp, + void(const policy::PermissionConsent& permissions, + const NotificationMode mode)); + MOCK_CONST_METHOD2(GetDefaultHmi, + 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)); + MOCK_METHOD3(GetUserFriendlyMessages, + std::vector<policy::UserFriendlyMessage>( + const std::vector<std::string>& message_code, + const std::string& language, + const std::string& active_hmi_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)); + MOCK_METHOD1(GetAppPermissionsChanges, + policy::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)); + MOCK_METHOD3(SetSystemInfo, + 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_METHOD2( + AddApplication, + StatusNotifier( + const std::string& application_id, + const rpc::policy_table_interface_base::AppHmiTypes& hmi_types)); +#ifdef SDL_REMOTE_CONTROL + MOCK_METHOD2(SetDefaultHmiTypes, + void(const std::string& application_id, + const std::vector<int>& hmi_types)); + MOCK_METHOD2(GetHMITypes, + bool(const std::string& application_id, + std::vector<int>* app_types)); + MOCK_METHOD2(CheckModule, + bool(const PTString& app_id, const PTString& module)); + MOCK_METHOD2(SendAppPermissionsChanged, + void(const std::string& device_id, + const std::string& application_id)); + MOCK_CONST_METHOD2(GetModuleTypes, + bool(const std::string& policy_app_id, + std::vector<std::string>* modules)); + MOCK_METHOD1(set_access_remote, + void(utils::SharedPtr<AccessRemote> access_remote)); +#endif // SDL_REMOTE_CONTROL + + 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_CONST_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_METHOD1(OnAppsSearchCompleted, void(const bool trigger_ptu)); + MOCK_METHOD1(OnAppRegisteredOnMobile, + void(const std::string& application_id)); + MOCK_CONST_METHOD0(GetLockScreenIconUrl, std::string()); + 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_CONST_METHOD0(HasCertificate, bool()); + MOCK_METHOD1(SetDecryptedCertificate, void(const std::string&)); + MOCK_METHOD0(ExceededIgnitionCycles, bool()); + MOCK_METHOD0(ExceededDays, bool()); + MOCK_METHOD0(StartPTExchange, void()); + 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_METHOD1(GetNextUpdateUrl, AppIdURL(const EndpointUrls& urls)); + MOCK_CONST_METHOD2(RetrySequenceUrl, + AppIdURL(const struct RetrySequenceURL&, + const EndpointUrls& urls)); + MOCK_METHOD1(SetExternalConsentStatus, bool(const ExternalConsentStatus&)); + MOCK_METHOD0(GetExternalConsentStatus, ExternalConsentStatus()); + MOCK_CONST_METHOD1(IsNeedToUpdateExternalConsentStatus, + bool(const ExternalConsentStatus&)); + MOCK_METHOD2(OnDeviceSwitching, + void(const std::string& device_id_from, + const std::string& device_id_to)); +}; +} // namespace policy_manager_test +} // namespace components +} // namespace test + +#endif // SRC_COMPONENTS_INCLUDE_TEST_POLICY_POLICY_EXTERNAL_POLICY_MOCK_POLICY_MANAGER_H_ diff --git a/src/components/include/test/policy/policy_external/policy/mock_policy_settings.h b/src/components/include/test/policy/policy_external/policy/mock_policy_settings.h new file mode 100644 index 0000000000..eafc1df4fe --- /dev/null +++ b/src/components/include/test/policy/policy_external/policy/mock_policy_settings.h @@ -0,0 +1,58 @@ +/* + * 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_POLICY_MOCK_POLICY_SETTINGS_H_ +#define SRC_COMPONENTS_INCLUDE_TEST_POLICY_MOCK_POLICY_SETTINGS_H_ + +#include "gmock/gmock.h" +#include <string> +#include "policy/policy_settings.h" + +namespace test { +namespace components { +namespace policy_handler_test { + +class MockPolicySettings : public ::policy::PolicySettings { + public: + MOCK_CONST_METHOD0(enable_policy, bool()); + MOCK_CONST_METHOD0(preloaded_pt_file, const std::string&()); + MOCK_CONST_METHOD0(app_storage_folder, const std::string&()); + MOCK_CONST_METHOD0(attempts_to_open_policy_db, uint16_t()); + MOCK_CONST_METHOD0(open_attempt_timeout_ms, uint16_t()); + MOCK_CONST_METHOD0(policies_snapshot_file_name, const std::string&()); + MOCK_CONST_METHOD0(system_files_path, const std::string&()); +}; + +} // namespace policy_test +} // namespace components +} // namespace test + +#endif // SRC_COMPONENTS_INCLUDE_TEST_POLICY_MOCK_POLICY_SETTINGS_H_ diff --git a/src/components/include/test/policy/policy_external/policy/usage_statistics/mock_app_stopwatch.h b/src/components/include/test/policy/policy_external/policy/usage_statistics/mock_app_stopwatch.h new file mode 100644 index 0000000000..3cbb878655 --- /dev/null +++ b/src/components/include/test/policy/policy_external/policy/usage_statistics/mock_app_stopwatch.h @@ -0,0 +1,54 @@ +/* Copyright (c) 2016, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_POLICY_POLICY_REGULAR_TEST_INCLUDE_MOCK_APP_STOPWATCH_H_ +#define SRC_COMPONENTS_POLICY_POLICY_REGULAR_TEST_INCLUDE_MOCK_APP_STOPWATCH_H_ + +#include "gmock/gmock.h" +#include "policy/usage_statistics/app_stopwatch.h" +#include "policy/usage_statistics/statistics_manager.h" + +namespace test { +namespace components { +namespace usage_statistics_test { + +class MockAppStopwatch : public usage_statistics::AppStopwatch { + public: + MOCK_METHOD1(Start, void(usage_statistics::AppStopwatchId stopwatch_type)); + MOCK_METHOD1(Switch, void(usage_statistics::AppStopwatchId stopwatch_type)); + MOCK_METHOD0(WriteTime, void()); +}; + +} // namespace usage_statistics_test +} // namespace components +} // namespace test + +#endif // SRC_COMPONENTS_POLICY_POLICY_REGULAR_TEST_INCLUDE_MOCK_APP_STOPWATCH_H_ diff --git a/src/components/include/test/policy/mock_statistics_manager.h b/src/components/include/test/policy/policy_external/policy/usage_statistics/mock_statistics_manager.h index e58adea124..e58adea124 100644 --- a/src/components/include/test/policy/mock_statistics_manager.h +++ b/src/components/include/test/policy/policy_external/policy/usage_statistics/mock_statistics_manager.h diff --git a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h new file mode 100644 index 0000000000..ed3a5088c1 --- /dev/null +++ b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h @@ -0,0 +1,223 @@ +/* + * 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_POLICY_POLICY_REGULAR_POLICY_MOCK_CACHE_MANAGER_H_ +#define SRC_COMPONENTS_INCLUDE_TEST_POLICY_POLICY_REGULAR_POLICY_MOCK_CACHE_MANAGER_H_ + +#include <string> +#include <vector> + +#include "gmock/gmock.h" + +#include "policy/cache_manager_interface.h" + +namespace test { +namespace components { +namespace policy_test { +namespace policy_table = rpc::policy_table_interface_base; +using namespace ::policy; + +class MockCacheManagerInterface : public CacheManagerInterface { + public: + MOCK_METHOD4(CheckPermissions, + void(const policy_table::Strings& groups, + const PTString& hmi_level, + const PTString& rpc, + CheckPermissionResult& result)); + MOCK_METHOD0(IsPTPreloaded, bool()); + MOCK_METHOD0(IgnitionCyclesBeforeExchange, int()); + MOCK_METHOD1(KilometersBeforeExchange, int(int current)); + MOCK_METHOD2(SetCountersPassedForSuccessfulUpdate, + bool(Counters counter, int value)); + MOCK_METHOD1(DaysBeforeExchange, int(int current)); + MOCK_METHOD0(IncrementIgnitionCycles, void()); + MOCK_METHOD0(ResetIgnitionCycles, void()); + MOCK_METHOD0(TimeoutResponse, int()); + MOCK_METHOD1(SecondsBetweenRetries, bool(std::vector<int>& seconds)); + MOCK_CONST_METHOD0(GetVehicleInfo, const VehicleInfo()); + MOCK_METHOD1(SetVINValue, bool(const std::string& value)); + MOCK_METHOD2(GetUserFriendlyMsg, + std::vector<UserFriendlyMessage>( + const std::vector<std::string>& msg_codes, + const std::string& language)); + + MOCK_METHOD1( + GetNotificationsNumber, + policy_table::NumberOfNotificationsType(const std::string& priority)); + MOCK_CONST_METHOD2(GetPriority, + bool(const std::string& policy_app_id, + std::string& priority)); + MOCK_METHOD2(GetUpdateUrls, + void(const std::string& service_type, + EndpointUrls& out_end_points)); + MOCK_METHOD2(GetUpdateUrls, + void(const uint32_t service_type, EndpointUrls& out_end_points)); + MOCK_CONST_METHOD0(GetLockScreenIconUrl, std::string()); + MOCK_METHOD2(Init, + bool(const std::string& file_name, + const PolicySettings* settings)); + MOCK_METHOD0(GenerateSnapshot, utils::SharedPtr<policy_table::Table>()); + MOCK_METHOD1(ApplyUpdate, bool(const policy_table::Table& update_pt)); + MOCK_METHOD1(Save, bool(const policy_table::Table& table)); + MOCK_CONST_METHOD0(UpdateRequired, bool()); + MOCK_METHOD1(SaveUpdateRequired, void(bool status)); + MOCK_METHOD3(GetInitialAppData, + bool(const std::string& app_id, + StringArray& nicknames, + StringArray& app_hmi_types)); + MOCK_CONST_METHOD1(IsApplicationRevoked, bool(const std::string& app_id)); + MOCK_METHOD1(GetFunctionalGroupings, + bool(policy_table::FunctionalGroupings& groups)); + MOCK_CONST_METHOD1(IsApplicationRepresented, bool(const std::string& app_id)); + MOCK_CONST_METHOD1(IsDefaultPolicy, bool(const std::string& app_id)); + MOCK_METHOD1(SetIsDefault, bool(const std::string& app_id)); + MOCK_CONST_METHOD1(IsPredataPolicy, bool(const std::string& app_id)); + MOCK_METHOD1(SetDefaultPolicy, bool(const std::string& app_id)); + MOCK_CONST_METHOD1(CanAppKeepContext, bool(const std::string& app_id)); + MOCK_CONST_METHOD1(CanAppStealFocus, bool(const std::string& app_id)); + MOCK_CONST_METHOD2(GetDefaultHMI, + bool(const std::string& app_id, std::string& default_hmi)); + MOCK_METHOD0(ResetUserConsent, bool()); + MOCK_CONST_METHOD3(GetUserPermissionsForDevice, + bool(const std::string& device_id, + StringArray& consented_groups, + StringArray& disallowed_groups)); + MOCK_METHOD3(GetPermissionsForApp, + bool(const std::string& device_id, + const std::string& app_id, + FunctionalIdType& group_types)); + MOCK_CONST_METHOD2( + GetDeviceGroupsFromPolicies, + bool(rpc::policy_table_interface_base::Strings& groups, + rpc::policy_table_interface_base::Strings& preconsented_groups)); + MOCK_METHOD2(AddDevice, + bool(const std::string& device_id, + const std::string& connection_type)); + MOCK_METHOD8(SetDeviceData, + bool(const std::string& device_id, + const std::string& hardware, + const std::string& firmware, + const std::string& os, + const std::string& os_version, + const std::string& carrier, + const uint32_t number_of_ports, + const std::string& connection_type)); + MOCK_METHOD3(SetUserPermissionsForDevice, + bool(const std::string& device_id, + const StringArray& consented_groups, + const StringArray& disallowed_groups)); + MOCK_METHOD2(ReactOnUserDevConsentForApp, + bool(const std::string& app_id, bool is_device_allowed)); + MOCK_METHOD1(SetUserPermissionsForApp, + bool(const PermissionConsent& permissions)); + MOCK_METHOD3(SetMetaInfo, + bool(const std::string& ccpu_version, + const std::string& wers_country_code, + const std::string& language)); + MOCK_CONST_METHOD0(IsMetaInfoPresent, bool()); + MOCK_METHOD1(SetSystemLanguage, bool(const std::string& language)); + MOCK_METHOD1(Increment, void(usage_statistics::GlobalCounterId type)); + MOCK_METHOD2(Increment, + void(const std::string& app_id, + usage_statistics::AppCounterId type)); + MOCK_METHOD3(Set, + void(const std::string& app_id, + usage_statistics::AppInfoId type, + const std::string& value)); + MOCK_METHOD3(Add, + void(const std::string& app_id, + usage_statistics::AppStopwatchId type, + int seconds)); + MOCK_METHOD2(CountUnconsentedGroups, + int(const std::string& policy_app_id, + const std::string& device_id)); + MOCK_METHOD1(GetFunctionalGroupNames, bool(FunctionalGroupNames& names)); + MOCK_METHOD2(GetAllAppGroups, + void(const std::string& app_id, + FunctionalGroupIDs& all_group_ids)); + MOCK_METHOD2(GetPreConsentedGroups, + void(const std::string& app_id, + FunctionalGroupIDs& preconsented_groups)); + MOCK_METHOD4(GetConsentedGroups, + void(const std::string& device_id, + const std::string& app_id, + FunctionalGroupIDs& allowed_groups, + FunctionalGroupIDs& disallowed_groups)); + MOCK_METHOD3(GetUnconsentedGroups, + void(const std::string& device_id, + const std::string& policy_app_id, + FunctionalGroupIDs& unconsented_groups)); + MOCK_METHOD2(RemoveAppConsentForGroup, + void(const std::string& app_id, const std::string& group_name)); + MOCK_METHOD1(SetPredataPolicy, bool(const std::string& app_id)); + MOCK_METHOD0(CleanupUnpairedDevices, bool()); + MOCK_METHOD2(SetUnpairedDevice, + bool(const std::string& device_id, bool unpaired)); + MOCK_METHOD1(UnpairedDevicesList, bool(DeviceIds& device_ids)); + MOCK_METHOD1(ResetPT, bool(const std::string& file_name)); + MOCK_METHOD0(LoadFromBackup, bool()); + MOCK_METHOD2(LoadFromFile, + bool(const std::string& file_name, policy_table::Table&)); + MOCK_METHOD0(Backup, void()); + MOCK_CONST_METHOD1(HeartBeatTimeout, uint32_t(const std::string& app_id)); + MOCK_CONST_METHOD2(GetAppRequestTypes, + void(const std::string& policy_app_id, + std::vector<std::string>& request_types)); + MOCK_METHOD1(GetHMIAppTypeAfterUpdate, + void(std::map<std::string, StringArray>& app_hmi_types)); + MOCK_METHOD0(ResetCalculatedPermissions, void()); + MOCK_METHOD3(AddCalculatedPermissions, + void(const std::string& device_id, + const std::string& policy_app_id, + const policy::Permissions& permissions)); + MOCK_METHOD3(IsPermissionsCalculated, + bool(const std::string& device_id, + const std::string& policy_app_id, + policy::Permissions& permission)); + MOCK_CONST_METHOD0(pt, utils::SharedPtr<policy_table::Table>()); + MOCK_METHOD1(GetHMITypes, + const policy_table::AppHMITypes*(const std::string& app_id)); + MOCK_CONST_METHOD0(GetCertificate, std::string()); + MOCK_METHOD1(SetDecryptedCertificate, void(const std::string&)); + MOCK_METHOD1(GetGroups, const policy_table::Strings&(const PTString& app_id)); + MOCK_CONST_METHOD2(AppHasHMIType, + bool(const std::string& application_id, + policy_table::AppHMIType hmi_type)); + MOCK_METHOD2(OnDeviceSwitching, + void(const std::string& device_id_from, + const std::string& device_id_to)); +}; + +} // namespace policy_test +} // namespace components +} // namespace test + +#endif // SRC_COMPONENTS_INCLUDE_TEST_POLICY_POLICY_REGULAR_POLICY_MOCK_CACHE_MANAGER_H_ diff --git a/src/components/include/test/policy/policy_regular/policy/mock_policy_listener.h b/src/components/include/test/policy/policy_regular/policy/mock_policy_listener.h new file mode 100644 index 0000000000..d98a0279d7 --- /dev/null +++ b/src/components/include/test/policy/policy_regular/policy/mock_policy_listener.h @@ -0,0 +1,104 @@ +/* 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_POLICY_POLICY_REGULAR_POLICY_MOCK_POLICY_LISTENER_H_ +#define SRC_COMPONENTS_INCLUDE_TEST_POLICY_POLICY_REGULAR_POLICY_MOCK_POLICY_LISTENER_H_ + +#include <string> + +#include "gmock/gmock.h" + +#include "policy/policy_listener.h" +#include "rpc_base/rpc_base.h" +#include "policy/policy_table/types.h" +#include "utils/custom_string.h" + +namespace policy_table = ::rpc::policy_table_interface_base; + +namespace test { +namespace components { +namespace policy_test { + +namespace custom_str = utils::custom_string; + +class MockPolicyListener : public ::policy::PolicyListener { + public: + MOCK_METHOD3(OnPermissionsUpdated, + void(const std::string& policy_app_id, + const policy::Permissions& permissions, + const policy::HMILevel& default_hmi)); + MOCK_METHOD2(OnPermissionsUpdated, + void(const std::string& policy_app_id, + const policy::Permissions& permissions)); + MOCK_METHOD1(OnPendingPermissionChange, + void(const std::string& policy_app_id)); + MOCK_METHOD1(OnUpdateStatusChanged, void(const std::string& status)); + MOCK_METHOD1(OnCurrentDeviceIdUpdateRequired, + std::string(const std::string& policy_app_id)); + MOCK_METHOD0(OnSystemInfoUpdateRequired, void()); + MOCK_METHOD1(GetAppName, + custom_str::CustomString(const std::string& policy_app_id)); + MOCK_METHOD0(OnUserRequestedUpdateCheckRequired, void()); + MOCK_METHOD2(OnDeviceConsentChanged, + void(const std::string& device_id, bool is_allowed)); + MOCK_METHOD1(OnUpdateHMIAppType, + void(std::map<std::string, policy::StringArray>)); + MOCK_METHOD1(GetAvailableApps, void(std::queue<std::string>&)); + MOCK_METHOD1(OnSnapshotCreated, void(const policy::BinaryMessage& pt_string)); + MOCK_METHOD0(CanUpdate, bool()); + MOCK_METHOD1(OnCertificateUpdated, void(const std::string&)); + MOCK_CONST_METHOD2(SendOnAppPermissionsChanged, + void(const policy::AppPermissions&, const std::string&)); + MOCK_METHOD3(OnUpdateHMILevel, + void(const std::string& device_id, + const std::string& policy_app_id, + const std::string& hmi_level)); + MOCK_METHOD1(GetDevicesIds, + std::vector<std::string>(const std::string& policy_app_id)); + MOCK_CONST_METHOD1(GetRegisteredLinks, + void(std::map<std::string, std::string>&)); +#ifdef SDL_REMOTE_CONTROL + MOCK_METHOD1(OnRemoteAllowedChanged, void(bool new_consent)); + MOCK_METHOD2(OnRemoteAppPermissionsChanged, + void(const std::string& device_id, + const std::string& application_id)); + MOCK_METHOD3(OnUpdateHMIStatus, + void(const std::string& device_id, + const std::string& policy_app_id, + const std::string& hmi_level)); +#endif // SDL_REMOTE_CONTROL +}; + +} // namespace policy_test +} // namespace components +} // namespace test + +#endif // SRC_COMPONENTS_INCLUDE_TEST_POLICY_POLICY_REGULAR_POLICY_MOCK_POLICY_LISTENER_H_ diff --git a/src/components/include/test/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h index a6169cdebc..82012b83c7 100644 --- a/src/components/include/test/policy/mock_policy_manager.h +++ b/src/components/include/test/policy/policy_regular/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 @@ -30,8 +30,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_INCLUDE_TEST_POLICY_MOCK_POLICY_MANAGER_H_ -#define SRC_COMPONENTS_INCLUDE_TEST_POLICY_MOCK_POLICY_MANAGER_H_ +#ifndef SRC_COMPONENTS_INCLUDE_TEST_POLICY_POLICY_REGULAR_POLICY_MOCK_POLICY_MANAGER_H_ +#define SRC_COMPONENTS_INCLUDE_TEST_POLICY_POLICY_REGULAR_POLICY_MOCK_POLICY_MANAGER_H_ #include <string> #include <vector> @@ -45,12 +45,14 @@ 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)); @@ -60,8 +62,12 @@ class MockPolicyManager : public PolicyManager { 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_METHOD2(GetUpdateUrls, + void(const uint32_t service_type, EndpointUrls& out_end_points)); + MOCK_METHOD2(GetUpdateUrls, + void(const std::string& service_type, + EndpointUrls& out_end_points)); MOCK_METHOD0(RequestPTUpdate, bool()); MOCK_METHOD5(CheckPermissions, void(const PTString& app_id, @@ -74,9 +80,10 @@ class MockPolicyManager : public PolicyManager { MOCK_METHOD1(KmsChanged, void(int kilometers)); MOCK_METHOD0(IncrementIgnitionCycles, void()); MOCK_METHOD0(ForcePTExchange, std::string()); + MOCK_METHOD0(ForcePTExchangeAtUserRequest, std::string()); MOCK_METHOD0(ResetRetrySequence, void()); MOCK_METHOD0(NextRetryTimeout, uint32_t()); - MOCK_METHOD0(TimeoutExchange, int()); + MOCK_METHOD0(TimeoutExchangeMSec, uint32_t()); MOCK_METHOD0(RetrySequenceDelaysSeconds, const std::vector<int>()); MOCK_METHOD0(OnExceededTimeout, void()); MOCK_METHOD0(OnUpdateStarted, void()); @@ -135,7 +142,29 @@ class MockPolicyManager : public PolicyManager { 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_METHOD2( + AddApplication, + StatusNotifier( + const std::string& application_id, + const rpc::policy_table_interface_base::AppHmiTypes& hmi_types)); +#ifdef SDL_REMOTE_CONTROL + MOCK_METHOD2(SetDefaultHmiTypes, + void(const std::string& application_id, + const std::vector<int>& hmi_types)); + MOCK_METHOD2(GetHMITypes, + bool(const std::string& application_id, + std::vector<int>* app_types)); + MOCK_METHOD2(CheckModule, + bool(const PTString& app_id, const PTString& module)); + MOCK_METHOD2(SendAppPermissionsChanged, + void(const std::string& device_id, + const std::string& application_id)); + MOCK_CONST_METHOD2(GetModuleTypes, + bool(const std::string& policy_app_id, + std::vector<std::string>* modules)); + MOCK_METHOD1(set_access_remote, + void(utils::SharedPtr<AccessRemote> access_remote)); +#endif // SDL_REMOTE_CONTROL MOCK_METHOD0(CleanupUnpairedDevices, bool()); MOCK_CONST_METHOD1(CanAppKeepContext, bool(const std::string& app_id)); MOCK_CONST_METHOD1(CanAppStealFocus, bool(const std::string& app_id)); @@ -143,11 +172,11 @@ class MockPolicyManager : public PolicyManager { 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(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(OnAppsSearchCompleted, void(const bool trigger_ptu)); MOCK_METHOD1(OnAppRegisteredOnMobile, void(const std::string& application_id)); MOCK_CONST_METHOD1( @@ -156,10 +185,13 @@ class MockPolicyManager : public PolicyManager { MOCK_CONST_METHOD0(GetVehicleInfo, const policy::VehicleInfo()); MOCK_CONST_METHOD0(GetMetaInfo, const policy::MetaInfo()); MOCK_CONST_METHOD0(RetrieveCertificate, std::string()); + MOCK_CONST_METHOD0(HasCertificate, bool()); MOCK_METHOD1(SetDecryptedCertificate, void(const std::string&)); 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, @@ -175,11 +207,29 @@ class MockPolicyManager : public PolicyManager { 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_METHOD1(GetNextUpdateUrl, AppIdURL(const EndpointUrls& urls)); + MOCK_CONST_METHOD2(RetrySequenceUrl, + AppIdURL(const struct RetrySequenceURL&, + const EndpointUrls& urls)); + MOCK_METHOD6(CheckPermissions, + void(const PTString& device_id, + const PTString& app_id, + const PTString& hmi_level, + const PTString& rpc, + const RPCParams& rpc_params, + CheckPermissionResult& result)); + MOCK_METHOD2( + CheckPendingPermissionsChanges, + void(const std::string& policy_app_id, + const std::vector<FunctionalGroupPermission>& current_permissions)); + + MOCK_METHOD2(OnDeviceSwitching, + void(const std::string& device_id_from, + const std::string& device_id_to)); }; + } // namespace policy_manager_test } // namespace components } // namespace test -#endif // SRC_COMPONENTS_INCLUDE_TEST_POLICY_MOCK_POLICY_MANAGER_H_ +#endif // SRC_COMPONENTS_INCLUDE_TEST_POLICY_POLICY_REGULAR_POLICY_MOCK_POLICY_MANAGER_H_ diff --git a/src/components/include/test/policy/mock_policy_settings.h b/src/components/include/test/policy/policy_regular/policy/mock_policy_settings.h index 438e697c51..438e697c51 100644 --- a/src/components/include/test/policy/mock_policy_settings.h +++ b/src/components/include/test/policy/policy_regular/policy/mock_policy_settings.h diff --git a/src/components/include/test/policy/policy_regular/policy/usage_statistics/mock_app_stopwatch.h b/src/components/include/test/policy/policy_regular/policy/usage_statistics/mock_app_stopwatch.h new file mode 100644 index 0000000000..481d887cb2 --- /dev/null +++ b/src/components/include/test/policy/policy_regular/policy/usage_statistics/mock_app_stopwatch.h @@ -0,0 +1,54 @@ +/* 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_POLICY_USAGE_STATISTICS_MOCK_APP_STOPWATCH_H_ +#define SRC_COMPONENTS_INCLUDE_TEST_POLICY_USAGE_STATISTICS_MOCK_APP_STOPWATCH_H_ + +#include "gmock/gmock.h" +#include "policy/usage_statistics/app_stopwatch.h" +#include "policy/usage_statistics/statistics_manager.h" + +namespace test { +namespace components { +namespace usage_statistics_test { + +class MockAppStopwatch : public usage_statistics::AppStopwatch { + public: + MOCK_METHOD1(Start, void(usage_statistics::AppStopwatchId stopwatch_type)); + MOCK_METHOD1(Switch, void(usage_statistics::AppStopwatchId stopwatch_type)); + MOCK_METHOD0(WriteTime, void()); +}; + +} // namespace usage_statistics_test +} // namespace components +} // namespace test + +#endif // SRC_COMPONENTS_INCLUDE_TEST_POLICY_USAGE_STATISTICS_MOCK_APP_STOPWATCH_H_ diff --git a/src/components/include/test/policy/usage_statistics/mock_statistics_manager.h b/src/components/include/test/policy/policy_regular/policy/usage_statistics/mock_statistics_manager.h index e58adea124..e58adea124 100644 --- a/src/components/include/test/policy/usage_statistics/mock_statistics_manager.h +++ b/src/components/include/test/policy/policy_regular/policy/usage_statistics/mock_statistics_manager.h 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 { |