OLD | NEW |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 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 <string> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 size_t size_; | 62 size_t size_; |
63 scoped_refptr<net::IOBuffer> buffer_; | 63 scoped_refptr<net::IOBuffer> buffer_; |
64 HidConnection::ReadCallback read_callback_; | 64 HidConnection::ReadCallback read_callback_; |
65 HidConnection::WriteCallback write_callback_; | 65 HidConnection::WriteCallback write_callback_; |
66 }; | 66 }; |
67 | 67 |
68 } // namespace | 68 } // namespace |
69 | 69 |
70 class HidConnectionTest : public testing::Test { | 70 class HidConnectionTest : public testing::Test { |
71 protected: | 71 protected: |
72 virtual void SetUp() OVERRIDE { | 72 virtual void SetUp() override { |
73 if (!UsbTestGadget::IsTestEnabled()) return; | 73 if (!UsbTestGadget::IsTestEnabled()) return; |
74 | 74 |
75 message_loop_.reset(new base::MessageLoopForIO()); | 75 message_loop_.reset(new base::MessageLoopForIO()); |
76 service_ = HidService::GetInstance(message_loop_->message_loop_proxy()); | 76 service_ = HidService::GetInstance(message_loop_->message_loop_proxy()); |
77 ASSERT_TRUE(service_); | 77 ASSERT_TRUE(service_); |
78 | 78 |
79 test_gadget_ = UsbTestGadget::Claim(); | 79 test_gadget_ = UsbTestGadget::Claim(); |
80 ASSERT_TRUE(test_gadget_); | 80 ASSERT_TRUE(test_gadget_); |
81 ASSERT_TRUE(test_gadget_->SetType(UsbTestGadget::HID_ECHO)); | 81 ASSERT_TRUE(test_gadget_->SetType(UsbTestGadget::HID_ECHO)); |
82 | 82 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 ASSERT_TRUE(read_callback.WaitForResult()); | 145 ASSERT_TRUE(read_callback.WaitForResult()); |
146 ASSERT_EQ(9UL, read_callback.size()); | 146 ASSERT_EQ(9UL, read_callback.size()); |
147 ASSERT_EQ(0, read_callback.buffer()->data()[0]); | 147 ASSERT_EQ(0, read_callback.buffer()->data()[0]); |
148 for (int j = 1; j < buffer->size(); ++j) { | 148 for (int j = 1; j < buffer->size(); ++j) { |
149 ASSERT_EQ(i + j - 1, read_callback.buffer()->data()[j]); | 149 ASSERT_EQ(i + j - 1, read_callback.buffer()->data()[j]); |
150 } | 150 } |
151 } | 151 } |
152 } | 152 } |
153 | 153 |
154 } // namespace device | 154 } // namespace device |
OLD | NEW |