/* * Copyright 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include #include #include #include #include #include #include "test_channel_transport.h" #include "test_model.h" namespace rootcanal { class TestCommandHandler { public: // Sets all of the methods to be used as callbacks in the HciHandler. TestCommandHandler(TestModel& test_model); ~TestCommandHandler() = default; // Dispatches the action corresponding to the command specified by |name|. void HandleCommand(const std::string& name, const std::vector& args); // Dispatches the action corresponding to the command specified by |name|. void RegisterSendResponse(std::function callback); // Commands: // Add a device void AddDevice(const std::vector& args); // Add a remote device void AddRemote(const std::vector& args); // Remove devices by index void RemoveDevice(const std::vector& args); // Add phy void AddPhy(const std::vector& args); // Remove phy by name void RemovePhy(const std::vector& args); // Add device to phy void AddDeviceToPhy(const std::vector& args); // Remove device from phy void RemoveDeviceFromPhy(const std::vector& args); // List the devices that the test knows about void List(const std::vector& args); // Change the device's MAC address void SetDeviceAddress(const std::vector& args); // Change the device's configuration void SetDeviceConfiguration(const std::vector& args); // Timer management functions void SetTimerPeriod(const std::vector& args); void StartTimer(const std::vector& args); void StopTimer(const std::vector& args); void Reset(const std::vector& args); // For manual testing void AddDefaults(); private: TestModel& model_; std::string response_string_; std::unordered_map&)>> active_commands_; std::function send_response_; TestCommandHandler(const TestCommandHandler& cmdPckt) = delete; TestCommandHandler& operator=(const TestCommandHandler& cmdPckt) = delete; }; } // namespace rootcanal