Skip to content

Commit 6f752bd

Browse files
committed
Fix UTs
1 parent 08f56aa commit 6f752bd

File tree

17 files changed

+74
-88
lines changed

17 files changed

+74
-88
lines changed

src/components/application_manager/test/include/application_manager/mock_message_helper.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ class MockMessageHelper {
139139
MOCK_METHOD2(SendDecryptCertificateToHMI,
140140
void(const std::string& file_name,
141141
ApplicationManager& app_mngr));
142+
MOCK_METHOD2(
143+
CreateOnSystemRequestNotificationToMobile,
144+
smart_objects::SmartObjectSPtr(const std::vector<uint8_t>& policy_data,
145+
const uint32_t connection_key));
142146
#ifdef EXTERNAL_PROPRIETARY_MODE
143147
MOCK_METHOD4(
144148
SendGetListOfPermissionsResponse,

src/components/application_manager/test/mock_message_helper.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,13 @@ MessageHelper::ServiceStatusUpdateNotificationBuilder::notification() const {
612612
return MockMessageHelper::on_service_update_builder_mock()->notification();
613613
}
614614

615+
smart_objects::SmartObjectSPtr
616+
MessageHelper::CreateOnSystemRequestNotificationToMobile(
617+
const std::vector<uint8_t>& policy_data, const uint32_t connection_key) {
618+
return MockMessageHelper::message_helper_mock()
619+
->CreateOnSystemRequestNotificationToMobile(policy_data, connection_key);
620+
}
621+
615622
smart_objects::SmartObject MessageHelper::CreateAppServiceCapabilities(
616623
std::vector<smart_objects::SmartObject>& all_services) {
617624
return MockMessageHelper::message_helper_mock()->CreateAppServiceCapabilities(

src/components/application_manager/test/policy_event_observer_test.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838
#include "policy/policy_types.h"
3939
#include "smart_objects/smart_object.h"
4040

41+
#ifdef EXTERNAL_PROPRIETARY_MODE
42+
#include "policy/ptu_retry_handler.h"
43+
#endif
44+
4145
namespace test {
4246
namespace components {
4347
namespace policy_test {

src/components/application_manager/test/policy_handler_test.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,7 +1722,8 @@ TEST_F(PolicyHandlerTest, OnSnapshotCreated_UrlNotAdded) {
17221722
.WillRepeatedly(SetArgReferee<1>(test_data));
17231723
policy_handler_.OnSnapshotCreated(msg, retry_delay_seconds, timeout_exchange);
17241724
#else // EXTERNAL_PROPRIETARY_MODE
1725-
policy_handler_.OnSnapshotCreated(msg);
1725+
policy_handler_.OnSnapshotCreated(msg,
1726+
policy::PTUIterationType::DefaultIteration);
17261727
#endif // EXTERNAL_PROPRIETARY_MODE
17271728
}
17281729

@@ -1800,7 +1801,8 @@ TEST_F(PolicyHandlerTest, DISABLED_OnSnapshotCreated_UrlAdded) {
18001801
#endif // PROPRIETARY_MODE
18011802

18021803
EXPECT_CALL(*mock_policy_manager_, OnUpdateStarted());
1803-
policy_handler_.OnSnapshotCreated(msg);
1804+
policy_handler_.OnSnapshotCreated(msg,
1805+
policy::PTUIterationType::DefaultIteration);
18041806
}
18051807
#endif // EXTERNAL_PROPRIETARY_MODE
18061808

src/components/include/test/application_manager/policies/mock_policy_handler_interface.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface {
7171
const std::vector<int>& retry_delay_seconds,
7272
uint32_t timeout_exchange));
7373
#else // EXTERNAL_PROPRIETARY_MODE
74-
MOCK_METHOD1(OnSnapshotCreated, void(const policy::BinaryMessage& pt_string));
74+
MOCK_METHOD2(OnSnapshotCreated,
75+
void(const policy::BinaryMessage& pt_string,
76+
const policy::PTUIterationType iteration_type));
7577
#endif // EXTERNAL_PROPRIETARY_MODE
7678

7779
MOCK_CONST_METHOD2(GetPriority,
@@ -243,6 +245,7 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface {
243245
#ifdef EXTERNAL_PROPRIETARY_MODE
244246
MOCK_CONST_METHOD0(GetMetaInfo, const policy::MetaInfo());
245247
MOCK_METHOD0(IncrementRetryIndex, void());
248+
MOCK_CONST_METHOD0(ptu_retry_handler, policy::PTURetryHandler&());
246249
#endif // EXTERNAL_PROPRIETARY_MODE
247250

248251
MOCK_METHOD1(Increment, void(usage_statistics::GlobalCounterId type));

src/components/include/test/policy/policy_external/policy/mock_policy_listener.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class MockPolicyListener : public ::policy::PolicyListener {
105105
const std::string& hmi_level));
106106
MOCK_METHOD1(OnCertDecryptFinished, void(bool));
107107
MOCK_METHOD0(IncrementRetryIndex, void());
108-
MOCK_CONST_METHOD0(IsAllowedPTURetriesExceeded, bool());
108+
MOCK_CONST_METHOD0(ptu_retry_handler, policy::PTURetryHandler&());
109109
};
110110

111111
} // namespace policy_test

src/components/include/test/policy/policy_external/policy/mock_policy_manager.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ class MockPolicyManager : public PolicyManager {
8080
MOCK_METHOD0(IncrementIgnitionCycles, void());
8181
MOCK_METHOD0(ForcePTExchange, std::string());
8282
MOCK_METHOD0(ForcePTExchangeAtUserRequest, std::string());
83-
MOCK_METHOD1(ResetRetrySequence, void(const bool send_event));
83+
MOCK_METHOD1(ResetRetrySequence,
84+
void(const policy::ResetRetryCountType send_event));
8485
MOCK_METHOD0(NextRetryTimeout, int());
8586
MOCK_METHOD0(TimeoutExchangeMSec, uint32_t());
8687
MOCK_METHOD0(RetrySequenceDelaysSeconds, const std::vector<int>());
Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -29,38 +29,20 @@
2929
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3030
POSSIBILITY OF SUCH DAMAGE.
3131
*/
32-
#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_POLICIES_PTU_RETRY_HANDLER_H_
33-
#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_POLICIES_PTU_RETRY_HANDLER_H_
3432

35-
namespace policy {
36-
37-
class PTURetryHandler {
38-
public:
39-
/**
40-
* @brief Check whether allowed retry sequence count is exceeded
41-
* @return bool value - true is allowed count is exceeded, otherwise - false
42-
*/
43-
virtual bool IsAllowedRetryCountExceeded() const = 0;
33+
#ifndef SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_MOCK_PTU_RETRY_HANDLER_H_
34+
#define SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_MOCK_PTU_RETRY_HANDLER_H_
4435

45-
/**
46-
* @brief Begins new retry sequence
47-
*/
48-
virtual void BeginRetrySequence() = 0;
49-
/**
50-
* @brief Start timer waiting for OnSystemRequest from HMI.
51-
*/
52-
virtual void StartWaitingPTURetry() = 0;
36+
#include "policy/ptu_retry_handler.h"
5337

54-
/**
55-
* @brief Stop timer waiting for git OnSystemRequest from HMI.
56-
*/
57-
virtual void StopWaitingPTURetry() = 0;
38+
namespace policy {
5839

59-
/**
60-
* @brief Handle retry sequence failure
61-
*/
62-
virtual void RetrySequenceFailed() = 0;
40+
class MockPTURetryHandler : public PTURetryHandler {
41+
public:
42+
MOCK_CONST_METHOD0(IsAllowedRetryCountExceeded, bool());
43+
MOCK_METHOD0(OnSystemRequestReceived, void());
44+
MOCK_METHOD0(RetrySequenceFailed, void());
6345
};
6446
} // namespace policy
6547

66-
#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_POLICIES_PTU_RETRY_HANDLER_H_
48+
#endif // SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_MOCK_PTU_RETRY_HANDLER_H_

src/components/include/test/policy/policy_regular/policy/mock_policy_listener.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ class MockPolicyListener : public ::policy::PolicyListener {
7272
MOCK_METHOD1(OnUpdateHMIAppType,
7373
void(std::map<std::string, policy::StringArray>));
7474
MOCK_METHOD1(GetAvailableApps, void(std::queue<std::string>&));
75-
MOCK_METHOD1(OnSnapshotCreated, void(const policy::BinaryMessage& pt_string));
75+
MOCK_METHOD2(OnSnapshotCreated,
76+
void(const policy::BinaryMessage& pt_string,
77+
const policy::PTUIterationType iteration_type));
7678
MOCK_METHOD0(CanUpdate, bool());
7779
MOCK_METHOD1(OnCertificateUpdated, void(const std::string&));
7880
MOCK_METHOD2(OnAuthTokenUpdated,

src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ class MockPolicyManager : public PolicyManager {
6868
MOCK_METHOD2(GetUpdateUrls,
6969
void(const std::string& service_type,
7070
EndpointUrls& out_end_points));
71-
MOCK_METHOD0(RequestPTUpdate, bool());
71+
MOCK_METHOD1(RequestPTUpdate,
72+
bool(const policy::PTUIterationType iteration_type));
7273
MOCK_METHOD5(CheckPermissions,
7374
void(const PTString& app_id,
7475
const PTString& hmi_level,
@@ -81,7 +82,8 @@ class MockPolicyManager : public PolicyManager {
8182
MOCK_METHOD0(IncrementIgnitionCycles, void());
8283
MOCK_METHOD0(ForcePTExchange, std::string());
8384
MOCK_METHOD0(ForcePTExchangeAtUserRequest, std::string());
84-
MOCK_METHOD0(ResetRetrySequence, void());
85+
MOCK_METHOD1(ResetRetrySequence,
86+
void(const policy::ResetRetryCountType send_event));
8587
MOCK_METHOD0(NextRetryTimeout, uint32_t());
8688
MOCK_METHOD0(TimeoutExchangeMSec, uint32_t());
8789
MOCK_METHOD0(RetrySequenceDelaysSeconds, const std::vector<int>());

0 commit comments

Comments
 (0)