message: Fix OnUpdateSentOut unit test
  Avoid using sleep in OnUpdateSentOut_WaitForTimeoutExpired_ExpectStatusUpdateNeeded unit test, use WaitAsync class that can wait for checking functionality of OnUpdateSentOut function.
diff: #include "policy/policy_manager_impl.h"
  #include "policy/update_status_manager.h"
  #include "utils/make_shared.h"
  +#include "utils/conditional_variable.h"
  namespace test {
  namespace components {
  @@ -58,7 +59,7 @@ class UpdateStatusManagerTest : public ::testing::Test {
  public:
  UpdateStatusManagerTest()
  : manager_(utils::MakeShared<UpdateStatusManager>())
  - , k_timeout_(1)
  + , k_timeout_(1000)
  , listener_()
  , up_to_date_status_("UP_TO_DATE")
  , update_needed_status_("UPDATE_NEEDED")
  @@ -72,18 +73,59 @@ class UpdateStatusManagerTest : public ::testing::Test {
  void TearDown() OVERRIDE {}
  };
  -// TODO(AKutsan) : APPLINK-31222 use miliseconds as parameter of OnUpdateSentOut
  -// function
  -TEST_F(
  - UpdateStatusManagerTest,
  - DISABLED_OnUpdateSentOut_WaitForTimeoutExpired_ExpectStatusUpdateNeeded) {
  +namespace {
  +/**
  + * @brief The WaitAsync class
  + * can wait for a certain amount of function calls from different
  + * threads, or a timeout expires.
  + */
  +class WaitAsync {
  + public:
  + WaitAsync(const uint32_t count, const uint32_t timeout)
  + : count_(count), timeout_(timeout) {}
  +
  + void Notify() {
  + count_--;
  + cond_var_.NotifyOne();
  + }
  +
  + bool Wait(sync_primitives::AutoLock& auto_lock) {
  + while (count_ > 0) {
  + sync_primitives::ConditionalVariable::WaitStatus wait_status =
  + cond_var_.WaitFor(auto_lock, timeout_);
  + if (wait_status == sync_primitives::ConditionalVariable::kTimeout) {
  + return false;
  + }
  + }
  + return true;
  + }
  +
  + private:
  + int count_;
  + const uint32_t timeout_;
  + sync_primitives::ConditionalVariable cond_var_;
  +};
  +}
  +
  +ACTION_P(NotifyAsync, waiter) {
  + waiter->Notify();
  +}
  +
  +TEST_F(UpdateStatusManagerTest,
  + OnUpdateSentOut_WaitForTimeoutExpired_ExpectStatusUpdateNeeded) {
  // Arrange
  + sync_primitives::Lock lock;
  + sync_primitives::AutoLock auto_lock(lock);
  + const uint32_t count = 3u;
  + const uint32_t timeout = 2u * k_timeout_;
  + WaitAsync waiter(count, timeout);
  + EXPECT_CALL(listener_, OnUpdateStatusChanged(_))
  + .WillRepeatedly(NotifyAsync(&waiter));
  manager_->ScheduleUpdate();
  manager_->OnUpdateSentOut(k_timeout_);
  status_ = manager_->GetLastUpdateStatus();
  EXPECT_EQ(StatusUpdatePending, status_);
  - // Wait until timeout expired
  - sleep(k_timeout_ + 1);
  + EXPECT_TRUE(waiter.Wait(auto_lock));
  status_ = manager_->GetLastUpdateStatus();
  // Check
  EXPECT_EQ(StatusUpdateRequired, status_);
  