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

Commit 5dfa9686 authored by Myles Watson's avatar Myles Watson
Browse files

Add responses for timer commands

Bug: 154020729
Test: cert/run --host
   manual testing:
      out/host/linux-x86/bin/root-canal & sleep 1 && \
          python3 scripts/test_channel.py 6401 < scripts/start_and_stop
Change-Id: I0c9a5257e495af4174b3280cc969ebd449136cd9
parent ad463825
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -148,14 +148,14 @@ int TestEnvironment::ConnectToRemoteServer(const std::string& server, int port)


void TestEnvironment::SetUpTestChannel() {
void TestEnvironment::SetUpTestChannel() {
  int socket_fd = test_channel_transport_.SetUp(test_port_);
  int socket_fd = test_channel_transport_.SetUp(test_port_);
  test_channel_.RegisterSendResponse([](const std::string& response) {
    LOG_INFO("No test channel: %s", response.c_str());
  });
  test_channel_.AddPhy({"BR_EDR"});
  test_channel_.AddPhy({"BR_EDR"});
  test_channel_.AddPhy({"LOW_ENERGY"});
  test_channel_.AddPhy({"LOW_ENERGY"});
  test_channel_.SetTimerPeriod({"5"});
  test_channel_.SetTimerPeriod({"5"});
  test_channel_.StartTimer({});
  test_channel_.StartTimer({});


  test_channel_.RegisterSendResponse(
      [](const std::string& response) { LOG_INFO("No test channel: %s", response.c_str()); });

  if (socket_fd == -1) {
  if (socket_fd == -1) {
    LOG_ERROR("Test channel SetUp(%d) failed.", test_port_);
    LOG_ERROR("Test channel SetUp(%d) failed.", test_port_);
    return;
    return;
+13 −1
Original line number Original line Diff line number Diff line
@@ -234,7 +234,15 @@ void TestCommandHandler::SetTimerPeriod(const vector<std::string>& args) {
    LOG_INFO("SetTimerPeriod takes 1 argument");
    LOG_INFO("SetTimerPeriod takes 1 argument");
  }
  }
  size_t period = std::stoi(args[0]);
  size_t period = std::stoi(args[0]);
  if (period != 0) {
    response_string_ = "set timer period to ";
    response_string_ += args[0];
    model_.SetTimerPeriod(std::chrono::milliseconds(period));
    model_.SetTimerPeriod(std::chrono::milliseconds(period));
  } else {
    response_string_ = "invalid timer period ";
    response_string_ += args[0];
  }
  send_response_(response_string_);
}
}


void TestCommandHandler::StartTimer(const vector<std::string>& args) {
void TestCommandHandler::StartTimer(const vector<std::string>& args) {
@@ -242,6 +250,8 @@ void TestCommandHandler::StartTimer(const vector<std::string>& args) {
    LOG_INFO("Unused args: arg[0] = %s", args[0].c_str());
    LOG_INFO("Unused args: arg[0] = %s", args[0].c_str());
  }
  }
  model_.StartTimer();
  model_.StartTimer();
  response_string_ = "timer started";
  send_response_(response_string_);
}
}


void TestCommandHandler::StopTimer(const vector<std::string>& args) {
void TestCommandHandler::StopTimer(const vector<std::string>& args) {
@@ -249,6 +259,8 @@ void TestCommandHandler::StopTimer(const vector<std::string>& args) {
    LOG_INFO("Unused args: arg[0] = %s", args[0].c_str());
    LOG_INFO("Unused args: arg[0] = %s", args[0].c_str());
  }
  }
  model_.StopTimer();
  model_.StopTimer();
  response_string_ = "timer stopped";
  send_response_(response_string_);
}
}


}  // namespace test_vendor_lib
}  // namespace test_vendor_lib