aboutsummaryrefslogtreecommitdiff
path: root/vendor_libs/test_vendor_lib/desktop/test_environment.h
diff options
context:
space:
mode:
Diffstat (limited to 'vendor_libs/test_vendor_lib/desktop/test_environment.h')
-rw-r--r--vendor_libs/test_vendor_lib/desktop/test_environment.h39
1 files changed, 31 insertions, 8 deletions
diff --git a/vendor_libs/test_vendor_lib/desktop/test_environment.h b/vendor_libs/test_vendor_lib/desktop/test_environment.h
index f48789b5f..815721eea 100644
--- a/vendor_libs/test_vendor_lib/desktop/test_environment.h
+++ b/vendor_libs/test_vendor_lib/desktop/test_environment.h
@@ -30,8 +30,16 @@ namespace root_canal {
class TestEnvironment {
public:
- TestEnvironment(uint16_t test_port, uint16_t hci_server_port, uint16_t link_server_port)
- : test_port_(test_port), hci_server_port_(hci_server_port), link_server_port_(link_server_port) {}
+ TestEnvironment(uint16_t test_port, uint16_t hci_server_port,
+ uint16_t link_server_port,
+ const std::string& controller_properties_file = "",
+ const std::string& default_commands_file = "")
+ : test_port_(test_port),
+ hci_server_port_(hci_server_port),
+ link_server_port_(link_server_port),
+ default_commands_file_(default_commands_file),
+ controller_(std::make_shared<test_vendor_lib::DualModeController>(
+ controller_properties_file)) {}
void initialize(std::promise<void> barrier);
@@ -41,6 +49,8 @@ class TestEnvironment {
uint16_t test_port_;
uint16_t hci_server_port_;
uint16_t link_server_port_;
+ std::string default_commands_file_;
+ bool test_channel_open_{false};
std::promise<void> barrier_;
test_vendor_lib::AsyncManager async_manager_;
@@ -57,18 +67,31 @@ class TestEnvironment {
test_vendor_lib::TestChannelTransport remote_link_layer_transport_;
test_vendor_lib::TestModel test_model_{
- [this](std::chrono::milliseconds delay, const test_vendor_lib::TaskCallback& task) {
- return async_manager_.ExecAsync(delay, task);
+ [this]() { return async_manager_.GetNextUserId(); },
+ [this](test_vendor_lib::AsyncUserId user_id,
+ std::chrono::milliseconds delay,
+ const test_vendor_lib::TaskCallback& task) {
+ return async_manager_.ExecAsync(user_id, delay, task);
},
- [this](std::chrono::milliseconds delay, std::chrono::milliseconds period,
+ [this](test_vendor_lib::AsyncUserId user_id,
+ std::chrono::milliseconds delay, std::chrono::milliseconds period,
const test_vendor_lib::TaskCallback& task) {
- return async_manager_.ExecAsyncPeriodically(delay, period, task);
+ return async_manager_.ExecAsyncPeriodically(user_id, delay, period,
+ task);
+ },
+
+ [this](test_vendor_lib::AsyncUserId user) {
+ async_manager_.CancelAsyncTasksFromUser(user);
},
- [this](test_vendor_lib::AsyncTaskId task) { async_manager_.CancelAsyncTask(task); },
+ [this](test_vendor_lib::AsyncTaskId task) {
+ async_manager_.CancelAsyncTask(task);
+ },
- [this](const std::string& server, int port) { return ConnectToRemoteServer(server, port); }};
+ [this](const std::string& server, int port) {
+ return ConnectToRemoteServer(server, port);
+ }};
test_vendor_lib::TestCommandHandler test_channel_{test_model_};
};