Enable multiline RTL alignment in RTHB on mac
[chromium-blink-merge.git] / device / serial / test_serial_io_handler.h
blob52cb16a520f76f095ed61b8cb6352881e96eb9dc
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef DEVICE_SERIAL_TEST_SERIAL_IO_HANDLER_H_
6 #define DEVICE_SERIAL_TEST_SERIAL_IO_HANDLER_H_
8 #include <string>
10 #include "base/callback.h"
11 #include "device/serial/serial.mojom.h"
12 #include "device/serial/serial_io_handler.h"
14 namespace device {
16 class TestSerialIoHandler : public SerialIoHandler {
17 public:
18 TestSerialIoHandler();
20 static scoped_refptr<SerialIoHandler> Create();
22 // SerialIoHandler overrides.
23 void Open(const std::string& port,
24 const serial::ConnectionOptions& options,
25 const OpenCompleteCallback& callback) override;
26 void ReadImpl() override;
27 void CancelReadImpl() override;
28 void WriteImpl() override;
29 void CancelWriteImpl() override;
30 bool ConfigurePortImpl() override;
31 serial::DeviceControlSignalsPtr GetControlSignals() const override;
32 serial::ConnectionInfoPtr GetPortInfo() const override;
33 bool Flush() const override;
34 bool SetControlSignals(const serial::HostControlSignals& signals) override;
36 serial::ConnectionInfo* connection_info() { return &info_; }
37 serial::DeviceControlSignals* device_control_signals() {
38 return &device_control_signals_;
40 bool dtr() { return dtr_; }
41 bool rts() { return rts_; }
42 int flushes() { return flushes_; }
43 // This callback will be called when this IoHandler processes its next write,
44 // instead of the normal behavior of echoing the data to reads.
45 void set_send_callback(const base::Closure& callback) {
46 send_callback_ = callback;
49 protected:
50 ~TestSerialIoHandler() override;
52 private:
53 bool opened_;
54 serial::ConnectionInfo info_;
55 serial::DeviceControlSignals device_control_signals_;
56 bool dtr_;
57 bool rts_;
58 mutable int flushes_;
59 std::string buffer_;
60 base::Closure send_callback_;
62 DISALLOW_COPY_AND_ASSIGN(TestSerialIoHandler);
65 } // namespace device
67 #endif // DEVICE_SERIAL_TEST_SERIAL_IO_HANDLER_H_