src/connectivity/wlan/drivers/testing/lib/sim-env/test/event_unittests.cc
// Verify that events can be added in any order and are processed sequentially
Verify that events can be added in any order and are processed sequentially
Verify that events can be added in any order and are processed sequentially
TEST_F(EventTest, SequentialEvents) {
  for (int32_t i = 0; i <= kSequentialTestSecs; i += 2) {
    zx::duration delay = zx::sec(i);
    auto squential_handler = std::make_unique<std::function<void()>>();
    *squential_handler = std::bind(&EventTest::SequentialEventCallback, this);
    EXPECT_EQ(env_.ScheduleNotification(std::move(squential_handler), delay), ZX_OK);
  }
  for (int32_t i = (kSequentialTestSecs % 2) ? kSequentialTestSecs : (kSequentialTestSecs - 1);
       i > 0; i -= 2) {
    zx::duration delay = zx::sec(i);
    auto squential_handler = std::make_unique<std::function<void()>>();
    *squential_handler = std::bind(&EventTest::SequentialEventCallback, this);
    EXPECT_EQ(env_.ScheduleNotification(std::move(squential_handler), delay), ZX_OK);
  }
  env_.Run();
  EXPECT_EQ(completed_, true);
  EXPECT_EQ(env_.GetTime(), ABSOLUTE_TIME(zx::sec(kSequentialTestSecs)));
}
TEST_F ( EventTest , SequentialEvents ) { for ( int32_t i = 0 ; i <= kSequentialTestSecs ; i += 2 ) { zx :: duration delay = zx :: sec ( i ) ; auto squential_handler = std :: make_unique < std :: function < void ( ) > > ( ) ; * squential_handler = std :: bind ( & EventTest :: SequentialEventCallback , this ) ; EXPECT_EQ ( env_ . ScheduleNotification ( std :: move ( squential_handler ) , delay ) , ZX_OK ) ; } for ( int32_t i = ( kSequentialTestSecs % 2 ) ? kSequentialTestSecs : ( kSequentialTestSecs - 1 ) ; i > 0 ; i -= 2 ) { zx :: duration delay = zx :: sec ( i ) ; auto squential_handler = std :: make_unique < std :: function < void ( ) > > ( ) ; * squential_handler = std :: bind ( & EventTest :: SequentialEventCallback , this ) ; EXPECT_EQ ( env_ . ScheduleNotification ( std :: move ( squential_handler ) , delay ) , ZX_OK ) ; } env_ . Run ( ) ; EXPECT_EQ ( completed_ , true ) ; EXPECT_EQ ( env_ . GetTime ( ) , ABSOLUTE_TIME ( zx :: sec ( kSequentialTestSecs ) ) ) ; }
Verify that events can be added in any order and are processed sequentially
Verify that events can be added in any order and are processed sequentially
// Add the even-second events // Add the odd-second events