| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "tools/battor_agent/battor_connection_impl.h" | 5 #include "tools/battor_agent/battor_connection_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 void NullReadCallback(int, device::serial::ReceiveError) {} | 21 void NullReadCallback(int, device::serial::ReceiveError) {} |
| 22 | 22 |
| 23 } // namespace | 23 } // namespace |
| 24 | 24 |
| 25 namespace battor { | 25 namespace battor { |
| 26 | 26 |
| 27 // TestableBattOrConnection uses a fake serial connection be testable. | 27 // TestableBattOrConnection uses a fake serial connection be testable. |
| 28 class TestableBattOrConnection : public BattOrConnectionImpl { | 28 class TestableBattOrConnection : public BattOrConnectionImpl { |
| 29 public: | 29 public: |
| 30 TestableBattOrConnection(BattOrConnection::Listener* listener) | 30 TestableBattOrConnection(BattOrConnection::Listener* listener) |
| 31 : BattOrConnectionImpl("/dev/test", listener, nullptr, nullptr) {} | 31 : BattOrConnectionImpl("/dev/test", listener, nullptr) {} |
| 32 scoped_refptr<device::SerialIoHandler> CreateIoHandler() override { | 32 scoped_refptr<device::SerialIoHandler> CreateIoHandler() override { |
| 33 return device::TestSerialIoHandler::Create(); | 33 return device::TestSerialIoHandler::Create(); |
| 34 } | 34 } |
| 35 | 35 |
| 36 scoped_refptr<device::SerialIoHandler> GetIoHandler() { return io_handler_; } | 36 scoped_refptr<device::SerialIoHandler> GetIoHandler() { return io_handler_; } |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 // BattOrConnectionImplTest provides a BattOrConnection and captures the | 39 // BattOrConnectionImplTest provides a BattOrConnection and captures the |
| 40 // results of all its commands. | 40 // results of all its commands. |
| 41 class BattOrConnectionImplTest : public testing::Test, | 41 class BattOrConnectionImplTest : public testing::Test, |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 BATTOR_CONTROL_BYTE_END, | 390 BATTOR_CONTROL_BYTE_END, |
| 391 }; | 391 }; |
| 392 SendBytesRaw(data, 3); | 392 SendBytesRaw(data, 3); |
| 393 ReadMessage(BATTOR_MESSAGE_TYPE_PRINT); | 393 ReadMessage(BATTOR_MESSAGE_TYPE_PRINT); |
| 394 | 394 |
| 395 ASSERT_TRUE(IsReadComplete()); | 395 ASSERT_TRUE(IsReadComplete()); |
| 396 ASSERT_FALSE(GetReadSuccess()); | 396 ASSERT_FALSE(GetReadSuccess()); |
| 397 } | 397 } |
| 398 | 398 |
| 399 } // namespace battor | 399 } // namespace battor |
| OLD | NEW |