src/connectivity/wlan/drivers/testing/lib/sim-fake-ap/test/assoc_unittests.cc
/* Verify that several association requests sent in quick succession are all answered, and that
   only the first from a client is successful.

   Timeline for this test:
   50 usec: send assoc request
   100 usec: send assoc request
   150 usec: send assoc request
 */
Verify that several association requests sent in quick succession are all answered, and that
only the first from a client is successful.

Timeline for this test:
50 usec: send assoc request
100 usec: send assoc request
150 usec: send assoc request
Verify that several association requests sent in quick succession are all answered and that only the first from a client is successful . Timeline for this test : 50 usec : send assoc request 100 usec : send assoc request 150 usec : send assoc request
TEST_F(AssocTest, BasicUse) {
  FinishAuth();
  auto handler = std::make_unique<std::function<void()>>();
  simulation::SimAssocReqFrame assoc_req_frame(kClientMacAddr, kApBssid, kApSsid);
  *handler = std::bind(&simulation::Environment::Tx, &env_, assoc_req_frame, kDefaultTxInfo, this);
  env_.ScheduleNotification(std::move(handler), zx::usec(50));
  handler = std::make_unique<std::function<void()>>();
  *handler = std::bind(&simulation::Environment::Tx, &env_, assoc_req_frame, kDefaultTxInfo, this);
  env_.ScheduleNotification(std::move(handler), zx::usec(100));
  handler = std::make_unique<std::function<void()>>();
  *handler = std::bind(&simulation::Environment::Tx, &env_, assoc_req_frame, kDefaultTxInfo, this);
  env_.ScheduleNotification(std::move(handler), zx::usec(150));
  env_.Run();
  EXPECT_EQ(assoc_resp_count_, 3U);
  ASSERT_EQ(assoc_status_list_.size(), (size_t)3);
  EXPECT_EQ(assoc_status_list_.front(), (uint16_t)WLAN_STATUS_CODE_SUCCESS);
  assoc_status_list_.pop_front();
  EXPECT_EQ(assoc_status_list_.front(), (uint16_t)WLAN_STATUS_CODE_REFUSED_TEMPORARILY);
  assoc_status_list_.pop_front();
  EXPECT_EQ(assoc_status_list_.front(), (uint16_t)WLAN_STATUS_CODE_REFUSED_TEMPORARILY);
  assoc_status_list_.pop_front();
}
TEST_F ( AssocTest , BasicUse ) { FinishAuth ( ) ; auto handler = std :: make_unique < std :: function < void ( ) > > ( ) ; simulation :: SimAssocReqFrame assoc_req_frame ( kClientMacAddr , kApBssid , kApSsid ) ; * handler = std :: bind ( & simulation :: Environment :: Tx , & env_ , assoc_req_frame , kDefaultTxInfo , this ) ; env_ . ScheduleNotification ( std :: move ( handler ) , zx :: usec ( 50 ) ) ; handler = std :: make_unique < std :: function < void ( ) > > ( ) ; * handler = std :: bind ( & simulation :: Environment :: Tx , & env_ , assoc_req_frame , kDefaultTxInfo , this ) ; env_ . ScheduleNotification ( std :: move ( handler ) , zx :: usec ( 100 ) ) ; handler = std :: make_unique < std :: function < void ( ) > > ( ) ; * handler = std :: bind ( & simulation :: Environment :: Tx , & env_ , assoc_req_frame , kDefaultTxInfo , this ) ; env_ . ScheduleNotification ( std :: move ( handler ) , zx :: usec ( 150 ) ) ; env_ . Run ( ) ; EXPECT_EQ ( assoc_resp_count_ , 3U ) ; ASSERT_EQ ( assoc_status_list_ . size ( ) , ( size_t ) 3 ) ; EXPECT_EQ ( assoc_status_list_ . front ( ) , ( uint16_t ) WLAN_STATUS_CODE_SUCCESS ) ; assoc_status_list_ . pop_front ( ) ; EXPECT_EQ ( assoc_status_list_ . front ( ) , ( uint16_t ) WLAN_STATUS_CODE_REFUSED_TEMPORARILY ) ; assoc_status_list_ . pop_front ( ) ; EXPECT_EQ ( assoc_status_list_ . front ( ) , ( uint16_t ) WLAN_STATUS_CODE_REFUSED_TEMPORARILY ) ; assoc_status_list_ . pop_front ( ) ; }
Verify that several association requests sent in quick succession are all answered, and that
only the first from a client is successful.
Verify that several association requests sent in quick succession are all answered and that only the first from a client is successful .
// Schedule first request // Schedule second request // Schedule third request