Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f7bf513f authored by Chris Manton's avatar Chris Manton Committed by Automerger Merge Worker
Browse files

Merge "Add sco_state_text" am: 1e270b64 am: 2fad5f83 am: 18f20dc0

parents 27b4c297 18f20dc0
Loading
Loading
Loading
Loading
+24 −0
Original line number Original line Diff line number Diff line
@@ -22,6 +22,7 @@
#include <iomanip>
#include <iomanip>
#include <iostream>
#include <iostream>
#include <map>
#include <map>
#include <sstream>
#include <vector>
#include <vector>


#include "btif/include/btif_hh.h"
#include "btif/include/btif_hh.h"
@@ -397,3 +398,26 @@ TEST_F(StackBtmWithInitFreeTest, BTM_SetEncryption) {


  wipe_secrets_and_remove(device_record);
  wipe_secrets_and_remove(device_record);
}
}

TEST_F(StackBtmTest, sco_state_text) {
  std::vector<std::pair<tSCO_STATE, std::string>> states = {
      std::make_pair(SCO_ST_UNUSED, "SCO_ST_UNUSED"),
      std::make_pair(SCO_ST_LISTENING, "SCO_ST_LISTENING"),
      std::make_pair(SCO_ST_W4_CONN_RSP, "SCO_ST_W4_CONN_RSP"),
      std::make_pair(SCO_ST_CONNECTING, "SCO_ST_CONNECTING"),
      std::make_pair(SCO_ST_CONNECTED, "SCO_ST_CONNECTED"),
      std::make_pair(SCO_ST_DISCONNECTING, "SCO_ST_DISCONNECTING"),
      std::make_pair(SCO_ST_PEND_UNPARK, "SCO_ST_PEND_UNPARK"),
      std::make_pair(SCO_ST_PEND_ROLECHANGE, "SCO_ST_PEND_ROLECHANGE"),
      std::make_pair(SCO_ST_PEND_MODECHANGE, "SCO_ST_PEND_MODECHANGE"),
  };
  for (const auto& state : states) {
    ASSERT_STREQ(state.second.c_str(), sco_state_text(state.first).c_str());
  }
  std::ostringstream oss;
  oss << "unknown_sco_state: " << std::numeric_limits<std::uint16_t>::max();
  ASSERT_STREQ(oss.str().c_str(),
               sco_state_text(static_cast<tSCO_STATE>(
                                  std::numeric_limits<std::uint16_t>::max()))
                   .c_str());
}