diff options
author | Veronica Veremjova <vveremjova@luxoft.com> | 2017-05-11 14:51:31 +0300 |
---|---|---|
committer | Veronica Veremjova <vveremjova@luxoft.com> | 2017-05-11 14:52:47 +0300 |
commit | d86665a8585761ceebfaf5b11c328058a0475f2f (patch) | |
tree | 18a9c12724d52e6ebe4176a5a426d9090e88fc82 /src | |
parent | 2e6ac91bda35d0fae679b692ba78fb9a5b09dedb (diff) | |
download | sdl_core-d86665a8585761ceebfaf5b11c328058a0475f2f.tar.gz |
Fix unit test for retry sequence
Diffstat (limited to 'src')
-rw-r--r-- | src/components/policy/policy_regular/test/policy_manager_impl_test.cc | 34 |
1 files changed, 23 insertions, 11 deletions
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 e341e68214..e6d246b748 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 @@ -870,18 +870,30 @@ TEST_F(PolicyManagerImplTest2, NextRetryTimeout_ExpectTimeoutsFromPT) { Json::Value seconds_between_retries = Json::Value(Json::arrayValue); seconds_between_retries = root["policy_table"]["module_config"]["seconds_between_retries"]; - uint32_t size = seconds_between_retries.size(); CreateLocalPT("sdl_preloaded_pt.json"); - - uint32_t waiting_timeout = 0u; - - for (uint32_t retry_number = 0u; retry_number < size; ++retry_number) { - waiting_timeout += seconds_between_retries[retry_number].asInt() * 1000; - waiting_timeout += manager->TimeoutExchangeMSec(); - - // it's in miliseconds - EXPECT_EQ(waiting_timeout, manager->NextRetryTimeout()); - } + // Check data + uint32_t timeout_after_x_seconds = + root["policy_table"]["module_config"]["timeout_after_x_seconds"] + .asInt() * + date_time::DateTime::MILLISECONDS_IN_SECOND; + const uint32_t first_retry = timeout_after_x_seconds; + EXPECT_EQ(first_retry, manager->NextRetryTimeout()); + uint32_t next_retry = first_retry + + seconds_between_retries[0].asInt() * + date_time::DateTime::MILLISECONDS_IN_SECOND; + EXPECT_EQ(next_retry, manager->NextRetryTimeout()); + next_retry = first_retry + next_retry + + seconds_between_retries[1].asInt() * + date_time::DateTime::MILLISECONDS_IN_SECOND; + EXPECT_EQ(next_retry, manager->NextRetryTimeout()); + next_retry = first_retry + next_retry + + seconds_between_retries[2].asInt() * + date_time::DateTime::MILLISECONDS_IN_SECOND; + EXPECT_EQ(next_retry, manager->NextRetryTimeout()); + next_retry = first_retry + next_retry + + seconds_between_retries[3].asInt() * + date_time::DateTime::MILLISECONDS_IN_SECOND; + EXPECT_EQ(next_retry, manager->NextRetryTimeout()); } } |