| 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 }; | 91 }; |
| 92 | 92 |
| 93 } // namespace | 93 } // namespace |
| 94 | 94 |
| 95 class HidConnectionTest : public testing::Test { | 95 class HidConnectionTest : public testing::Test { |
| 96 protected: | 96 protected: |
| 97 void SetUp() override { | 97 void SetUp() override { |
| 98 if (!UsbTestGadget::IsTestEnabled()) return; | 98 if (!UsbTestGadget::IsTestEnabled()) return; |
| 99 | 99 |
| 100 message_loop_.reset(new base::MessageLoopForIO()); | 100 message_loop_.reset(new base::MessageLoopForIO()); |
| 101 service_ = HidService::GetInstance( | 101 service_ = HidService::GetInstance(message_loop_->message_loop_proxy()); |
| 102 message_loop_->message_loop_proxy(), | |
| 103 message_loop_->message_loop_proxy()); | |
| 104 ASSERT_TRUE(service_); | 102 ASSERT_TRUE(service_); |
| 105 | 103 |
| 106 test_gadget_ = UsbTestGadget::Claim(); | 104 test_gadget_ = UsbTestGadget::Claim(); |
| 107 ASSERT_TRUE(test_gadget_); | 105 ASSERT_TRUE(test_gadget_); |
| 108 ASSERT_TRUE(test_gadget_->SetType(UsbTestGadget::HID_ECHO)); | 106 ASSERT_TRUE(test_gadget_->SetType(UsbTestGadget::HID_ECHO)); |
| 109 | 107 |
| 110 device_id_ = kInvalidHidDeviceId; | 108 device_id_ = kInvalidHidDeviceId; |
| 111 | 109 |
| 112 base::RunLoop run_loop; | 110 base::RunLoop run_loop; |
| 113 message_loop_->PostDelayedTask( | 111 message_loop_->PostDelayedTask( |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 ASSERT_EQ(0, read_callback.buffer()->data()[0]); | 175 ASSERT_EQ(0, read_callback.buffer()->data()[0]); |
| 178 for (unsigned char j = 1; j < kBufferSize; ++j) { | 176 for (unsigned char j = 1; j < kBufferSize; ++j) { |
| 179 ASSERT_EQ(i + j - 1, read_callback.buffer()->data()[j]); | 177 ASSERT_EQ(i + j - 1, read_callback.buffer()->data()[j]); |
| 180 } | 178 } |
| 181 } | 179 } |
| 182 | 180 |
| 183 conn->Close(); | 181 conn->Close(); |
| 184 } | 182 } |
| 185 | 183 |
| 186 } // namespace device | 184 } // namespace device |
| OLD | NEW |