From b0860333448a1d8a11937dcd4eab459848beb54e Mon Sep 17 00:00:00 2001 From: Alex Kutsan Date: Thu, 12 Jan 2017 13:24:28 +0200 Subject: Use secconds against ms in RPCs Related issue : APPLINK-31433 --- .../policy/policy_external/include/policy/policy_manager_impl.h | 2 +- src/components/policy/policy_external/src/policy_manager_impl.cc | 6 +++--- .../policy/policy_external/test/policy_manager_impl_test.cc | 2 +- .../policy/policy_regular/include/policy/cache_manager.h | 2 +- .../policy/policy_regular/include/policy/policy_manager.h | 2 +- .../policy/policy_regular/include/policy/policy_manager_impl.h | 4 ++-- src/components/policy/policy_regular/include/policy/status.h | 1 - .../policy/policy_regular/include/policy/update_status_manager.h | 2 +- src/components/policy/policy_regular/src/policy_manager_impl.cc | 8 ++++---- .../policy_regular/test/include/policy/mock_policy_manager.h | 2 +- .../policy/policy_regular/test/policy_manager_impl_test.cc | 4 ++-- 11 files changed, 17 insertions(+), 18 deletions(-) (limited to 'src/components/policy') diff --git a/src/components/policy/policy_external/include/policy/policy_manager_impl.h b/src/components/policy/policy_external/include/policy/policy_manager_impl.h index db0fd6f122..505c9f71ce 100644 --- a/src/components/policy/policy_external/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_external/include/policy/policy_manager_impl.h @@ -77,7 +77,7 @@ class PolicyManagerImpl : public PolicyManager { virtual std::string GetPolicyTableStatus() const; virtual void ResetRetrySequence(); virtual int NextRetryTimeout(); - virtual int TimeoutExchange(); + virtual uint32_t TimeoutExchangeMSec(); virtual const std::vector RetrySequenceDelaysSeconds(); virtual void OnExceededTimeout(); virtual std::string GetLockScreenIconUrl() const OVERRIDE; diff --git a/src/components/policy/policy_external/src/policy_manager_impl.cc b/src/components/policy/policy_external/src/policy_manager_impl.cc index 64dcadf1ab..737fbf16f8 100644 --- a/src/components/policy/policy_external/src/policy_manager_impl.cc +++ b/src/components/policy/policy_external/src/policy_manager_impl.cc @@ -236,7 +236,7 @@ void PolicyManagerImpl::RequestPTUpdate() { BinaryMessage update(message_string.begin(), message_string.end()); listener_->OnSnapshotCreated( - update, RetrySequenceDelaysSeconds(), TimeoutExchange()); + update, RetrySequenceDelaysSeconds(), TimeoutExchangeMSec()); } else { LOG4CXX_ERROR(logger_, "Invalid Policy table snapshot - PTUpdate failed"); } @@ -1059,7 +1059,7 @@ void PolicyManagerImpl::ResetRetrySequence() { update_status_manager_.OnResetRetrySequence(); } -int PolicyManagerImpl::TimeoutExchange() { +uint32_t PolicyManagerImpl::TimeoutExchangeMSec() { return retry_sequence_timeout_; } @@ -1073,7 +1073,7 @@ void PolicyManagerImpl::OnExceededTimeout() { } void PolicyManagerImpl::OnUpdateStarted() { - int update_timeout = TimeoutExchange(); + uint32_t update_timeout = TimeoutExchangeMSec(); LOG4CXX_DEBUG(logger_, "Update timeout will be set to (milisec): " << update_timeout); update_status_manager_.OnUpdateSentOut(update_timeout); diff --git a/src/components/policy/policy_external/test/policy_manager_impl_test.cc b/src/components/policy/policy_external/test/policy_manager_impl_test.cc index af7923918d..bc9f5ac8e6 100644 --- a/src/components/policy/policy_external/test/policy_manager_impl_test.cc +++ b/src/components/policy/policy_external/test/policy_manager_impl_test.cc @@ -223,7 +223,7 @@ TEST_F(PolicyManagerImplTest2, TimeOutExchange) { // Arrange CreateLocalPT(preloadet_pt_filename_); // Check value taken from PT - EXPECT_EQ(70000, manager_->TimeoutExchange()); + EXPECT_EQ(70000u, manager_->TimeoutExchangeMSec()); } TEST_F(PolicyManagerImplTest, diff --git a/src/components/policy/policy_regular/include/policy/cache_manager.h b/src/components/policy/policy_regular/include/policy/cache_manager.h index c3fa6f1e34..47d8e69551 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager.h @@ -114,7 +114,7 @@ class CacheManager : public CacheManagerInterface { /** * @brief Returns timeout to wait for a response of PT update - * @return value in seconds + * @return value in msec */ virtual int TimeoutResponse(); diff --git a/src/components/policy/policy_regular/include/policy/policy_manager.h b/src/components/policy/policy_regular/include/policy/policy_manager.h index 87db06acdb..1f726d308e 100644 --- a/src/components/policy/policy_regular/include/policy/policy_manager.h +++ b/src/components/policy/policy_regular/include/policy/policy_manager.h @@ -159,7 +159,7 @@ class PolicyManager : public usage_statistics::StatisticsManager { * Gets timeout to wait until receive response * @return timeout in seconds */ - virtual int TimeoutExchange() = 0; + virtual uint32_t TimeoutExchangeMSec() = 0; /** * @brief List of timeouts in seconds between retries diff --git a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h index e77158c157..31e4ab454c 100644 --- a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h @@ -84,7 +84,7 @@ class PolicyManagerImpl : public PolicyManager { virtual std::string GetPolicyTableStatus() const; virtual void ResetRetrySequence(); virtual uint32_t NextRetryTimeout(); - virtual int TimeoutExchange(); + virtual uint32_t TimeoutExchangeMSec(); virtual const std::vector RetrySequenceDelaysSeconds(); virtual void OnExceededTimeout(); virtual void OnUpdateStarted(); @@ -313,7 +313,7 @@ class PolicyManagerImpl : public PolicyManager { std::map app_permissions_diff_; /** - * Timeout to wait response with UpdatePT + * Timeout to wait response with UpdatePT (msec) */ uint32_t retry_sequence_timeout_; diff --git a/src/components/policy/policy_regular/include/policy/status.h b/src/components/policy/policy_regular/include/policy/status.h index e5f464d10a..1d9ae97f8e 100644 --- a/src/components/policy/policy_regular/include/policy/status.h +++ b/src/components/policy/policy_regular/include/policy/status.h @@ -55,7 +55,6 @@ enum UpdateEvent { kOnResetRetrySequence }; - const std::string kUpToDate = "UP_TO_DATE"; const std::string kUpdateNeeded = "UPDATE_NEEDED"; const std::string kUpdating = "UPDATING"; diff --git a/src/components/policy/policy_regular/include/policy/update_status_manager.h b/src/components/policy/policy_regular/include/policy/update_status_manager.h index c6c94cd420..ccd55e040a 100644 --- a/src/components/policy/policy_regular/include/policy/update_status_manager.h +++ b/src/components/policy/policy_regular/include/policy/update_status_manager.h @@ -83,7 +83,7 @@ class UpdateStatusManager : public UpdateStatusManagerInterface { /** * @brief Update status hanlder for PTS sending out - * @param update_timeout Timeout for waiting of incoming PTU + * @param update_timeout Timeout for waiting of incoming PTU (msec) */ void OnUpdateSentOut(uint32_t update_timeout); diff --git a/src/components/policy/policy_regular/src/policy_manager_impl.cc b/src/components/policy/policy_regular/src/policy_manager_impl.cc index ef678dd852..ac82c9ebcb 100644 --- a/src/components/policy/policy_regular/src/policy_manager_impl.cc +++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc @@ -58,7 +58,7 @@ void DeleteManager(policy::PolicyManager* pm) { } namespace { -const uint32_t kDefaultRetryTimeoutInSec = 60u; +const uint32_t kDefaultRetryTimeoutInMSec = 60u * date_time::DateTime::MILLISECONDS_IN_SECOND; } // namespace namespace policy { @@ -69,7 +69,7 @@ PolicyManagerImpl::PolicyManagerImpl() : PolicyManager() , listener_(NULL) , cache_(new CacheManager) - , retry_sequence_timeout_(kDefaultRetryTimeoutInSec) + , retry_sequence_timeout_(kDefaultRetryTimeoutInMSec) , retry_sequence_index_(0) , timer_retry_sequence_("Retry sequence timer", new timer::TimerTaskImpl( @@ -796,7 +796,7 @@ void PolicyManagerImpl::ResetRetrySequence() { update_status_manager_.OnResetRetrySequence(); } -int PolicyManagerImpl::TimeoutExchange() { +uint32_t PolicyManagerImpl::TimeoutExchangeMSec() { return retry_sequence_timeout_; } @@ -810,7 +810,7 @@ void PolicyManagerImpl::OnExceededTimeout() { } void PolicyManagerImpl::OnUpdateStarted() { - int update_timeout = TimeoutExchange(); + uint32_t update_timeout = TimeoutExchangeMSec(); LOG4CXX_DEBUG(logger_, "Update timeout will be set to (milisec): " << update_timeout); update_status_manager_.OnUpdateSentOut(update_timeout); diff --git a/src/components/policy/policy_regular/test/include/policy/mock_policy_manager.h b/src/components/policy/policy_regular/test/include/policy/mock_policy_manager.h index ea931d1637..b63bdf2d19 100644 --- a/src/components/policy/policy_regular/test/include/policy/mock_policy_manager.h +++ b/src/components/policy/policy_regular/test/include/policy/mock_policy_manager.h @@ -78,7 +78,7 @@ class MockPolicyManager : public PolicyManager { MOCK_METHOD0(ForcePTExchange, std::string()); MOCK_METHOD0(ResetRetrySequence, void()); MOCK_METHOD0(NextRetryTimeout, int()); - MOCK_METHOD0(TimeoutExchange, int()); + MOCK_METHOD0(TimeoutExchangeMSec, uint32_t()); MOCK_METHOD0(RetrySequenceDelaysSeconds, const std::vector()); MOCK_METHOD0(OnExceededTimeout, void()); MOCK_METHOD0(OnUpdateStarted, void()); diff --git a/src/components/policy/policy_regular/test/policy_manager_impl_test.cc b/src/components/policy/policy_regular/test/policy_manager_impl_test.cc index 2b6da8e5fd..2f241fa069 100644 --- a/src/components/policy/policy_regular/test/policy_manager_impl_test.cc +++ b/src/components/policy/policy_regular/test/policy_manager_impl_test.cc @@ -881,7 +881,7 @@ TEST_F(PolicyManagerImplTest2, NextRetryTimeout_ExpectTimeoutsFromPT) { for (uint32_t retry_number = 0u; retry_number < size; ++retry_number) { waiting_timeout += seconds_between_retries[retry_number].asInt(); - waiting_timeout += manager->TimeoutExchange(); + waiting_timeout += manager->TimeoutExchangeMSec(); // it's in miliseconds EXPECT_EQ(waiting_timeout * date_time::DateTime::MILLISECONDS_IN_SECOND, @@ -894,7 +894,7 @@ TEST_F(PolicyManagerImplTest2, TimeOutExchange) { // Arrange CreateLocalPT("sdl_preloaded_pt.json"); // Check value taken from PT - EXPECT_EQ(70000, manager->TimeoutExchange()); + EXPECT_EQ(70000u, manager->TimeoutExchangeMSec()); } TEST_F(PolicyManagerImplTest2, UpdatedPreloadedPT_ExpectLPT_IsUpdated) { -- cgit v1.2.1 From 81d6f8e743b734d6f1957d29b4c193f9bebd531a Mon Sep 17 00:00:00 2001 From: Alex Kutsan Date: Thu, 12 Jan 2017 20:27:42 +0200 Subject: Init variable before read fix OnValidUpdateReceived_SetValidUpdateReceived_ExpectStatusUpToDate test Related issue : APPLINK-31433 --- src/components/policy/policy_external/test/update_status_manager_test.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'src/components/policy') diff --git a/src/components/policy/policy_external/test/update_status_manager_test.cc b/src/components/policy/policy_external/test/update_status_manager_test.cc index cb8cc98410..5546984ff4 100644 --- a/src/components/policy/policy_external/test/update_status_manager_test.cc +++ b/src/components/policy/policy_external/test/update_status_manager_test.cc @@ -148,6 +148,7 @@ TEST_F(UpdateStatusManagerTest, // Arrange EXPECT_CALL(listener_, OnUpdateStatusChanged(update_needed_status_)); manager_->ScheduleUpdate(); + status_ = manager_->GetLastUpdateStatus(); EXPECT_EQ(StatusUpdateRequired, status_); EXPECT_CALL(listener_, OnUpdateStatusChanged(updating_status_)); manager_->OnUpdateSentOut(k_timeout_); -- cgit v1.2.1