AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
alexaClientSDK::avsCommon::utils::timing::test::TimerTest Class Reference

Test harness for Timer class. More...

Inheritance diagram for alexaClientSDK::avsCommon::utils::timing::test::TimerTest:
Inheritance graph
[legend]
Collaboration diagram for alexaClientSDK::avsCommon::utils::timing::test::TimerTest:
Collaboration graph
[legend]

Public Member Functions

void SetUp () override
 Set up the test harness for running a test. More...
 
void simpleTask (std::chrono::milliseconds duration)
 
- Public Member Functions inherited from testing::Test
virtual ~Test ()
 

Protected Member Functions

void verifyTimestamps (std::chrono::time_point< std::chrono::steady_clock > startTime, std::chrono::milliseconds delay, std::chrono::milliseconds period, Timer::PeriodType periodType, std::chrono::milliseconds duration, size_t iterations=1)
 
bool waitForInactive ()
 
- Protected Member Functions inherited from testing::Test
 Test ()
 
virtual void TearDown ()
 

Protected Attributes

std::mutex m_mutex
 Mutex which protects access to m_timestamps. More...
 
std::condition_variable m_conditionVariable
 Condition variable to notify about changes to m_timestamps. More...
 
std::deque< std::chrono::time_point< std::chrono::steady_clock > > m_timestamps
 This deque accumulates timestamps from timer calls to simpleTask(). More...
 
std::shared_ptr< Timerm_timer
 The timer to use in the tests. More...
 

Additional Inherited Members

- Public Types inherited from testing::Test
typedef internal::SetUpTestCaseFunc SetUpTestCaseFunc
 
typedef internal::TearDownTestCaseFunc TearDownTestCaseFunc
 
- Static Public Member Functions inherited from testing::Test
static void SetUpTestCase ()
 
static void TearDownTestCase ()
 
static bool HasFatalFailure ()
 
static bool HasNonfatalFailure ()
 
static bool HasFailure ()
 
static void RecordProperty (const std::string &key, const std::string &value)
 
static void RecordProperty (const std::string &key, int value)
 

Detailed Description

Test harness for Timer class.

Member Function Documentation

◆ SetUp()

void alexaClientSDK::avsCommon::utils::timing::test::TimerTest::SetUp ( )
overridevirtual

Set up the test harness for running a test.

Reimplemented from testing::Test.

◆ simpleTask()

void alexaClientSDK::avsCommon::utils::timing::test::TimerTest::simpleTask ( std::chrono::milliseconds  duration)

A simple task to test Timer instances with. This task records its start time in m_timestamps and then waits for the specified duration before returning.

Parameters
durationThe number of milliseconds to sleep before returning.

◆ verifyTimestamps()

void alexaClientSDK::avsCommon::utils::timing::test::TimerTest::verifyTimestamps ( std::chrono::time_point< std::chrono::steady_clock >  startTime,
std::chrono::milliseconds  delay,
std::chrono::milliseconds  period,
Timer::PeriodType  periodType,
std::chrono::milliseconds  duration,
size_t  iterations = 1 
)
protected

Utility function which verifies the size and values of m_timestamps after runnning a timer.

Parameters
startTimeThe start time for a timer, against which m_timestamps should be verified.
periodThe period of the timer.
periodTypeThe type of period used for the timer.
durationThe runtime duration of the timer task.
iterationsThe expected number of task calls made by the timer.

◆ waitForInactive()

bool alexaClientSDK::avsCommon::utils::timing::test::TimerTest::waitForInactive ( )
protected

Utility function which polls for a timer to go inactive. This function will time out and fail if the timer does not go inactive within SHORT_DELAY.

Returns
true if timer is inactive, else false.

Member Data Documentation

◆ m_conditionVariable

std::condition_variable alexaClientSDK::avsCommon::utils::timing::test::TimerTest::m_conditionVariable
protected

Condition variable to notify about changes to m_timestamps.

◆ m_mutex

std::mutex alexaClientSDK::avsCommon::utils::timing::test::TimerTest::m_mutex
protected

Mutex which protects access to m_timestamps.

◆ m_timer

std::shared_ptr<Timer> alexaClientSDK::avsCommon::utils::timing::test::TimerTest::m_timer
protected

The timer to use in the tests.

◆ m_timestamps

std::deque<std::chrono::time_point<std::chrono::steady_clock> > alexaClientSDK::avsCommon::utils::timing::test::TimerTest::m_timestamps
protected

This deque accumulates timestamps from timer calls to simpleTask().


The documentation for this class was generated from the following file:

AlexaClientSDK 3.0.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0