Add OWNERS to content/browser/quota
[chromium-blink-merge.git] / device / serial / test_serial_io_handler.h
blobedded0e987ccc5fcf10f0ec303a970db64b1d08c
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;
35 bool SetBreak() override;
36 bool ClearBreak() override;
38 serial::ConnectionInfo* connection_info() { return &info_; }
39 serial::DeviceControlSignals* device_control_signals() {
40 return &device_control_signals_;
42 bool dtr() { return dtr_; }
43 bool rts() { return rts_; }
44 int flushes() { return flushes_; }
45 // This callback will be called when this IoHandler processes its next write,
46 // instead of the normal behavior of echoing the data to reads.
47 void set_send_callback(const base::Closure& callback) {
48 send_callback_ = callback;
51 protected:
52 ~TestSerialIoHandler() override;
54 private:
55 bool opened_;
56 serial::ConnectionInfo info_;
57 serial::DeviceControlSignals device_control_signals_;
58 bool dtr_;
59 bool rts_;
60 mutable int flushes_;
61 std::string buffer_;
62 base::Closure send_callback_;
64 DISALLOW_COPY_AND_ASSIGN(TestSerialIoHandler);
67 } // namespace device
69 #endif // DEVICE_SERIAL_TEST_SERIAL_IO_HANDLER_H_