| 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/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 | 69 |
| 70 conn->Write(0, buffer, base::Bind(OnWriteNormal)); | 70 conn->Write(0, buffer, base::Bind(OnWriteNormal)); |
| 71 } | 71 } |
| 72 | 72 |
| 73 } // namespace | 73 } // namespace |
| 74 | 74 |
| 75 class HidConnectionTest : public testing::Test { | 75 class HidConnectionTest : public testing::Test { |
| 76 protected: | 76 protected: |
| 77 virtual void SetUp() OVERRIDE { | 77 virtual void SetUp() OVERRIDE { |
| 78 message_loop_.reset(new base::MessageLoopForIO()); | 78 message_loop_.reset(new base::MessageLoopForIO()); |
| 79 service_.reset(HidService::CreateInstance()); | 79 service_.reset(HidService::Create(message_loop_->message_loop_proxy())); |
| 80 ASSERT_TRUE(service_); | 80 ASSERT_TRUE(service_); |
| 81 | 81 |
| 82 std::vector<HidDeviceInfo> devices; | 82 std::vector<HidDeviceInfo> devices; |
| 83 service_->GetDevices(&devices); | 83 service_->GetDevices(&devices); |
| 84 device_id_ = kInvalidHidDeviceId; | 84 device_id_ = kInvalidHidDeviceId; |
| 85 for (std::vector<HidDeviceInfo>::iterator it = devices.begin(); | 85 for (std::vector<HidDeviceInfo>::iterator it = devices.begin(); |
| 86 it != devices.end(); | 86 it != devices.end(); |
| 87 ++it) { | 87 ++it) { |
| 88 if (it->vendor_id == kUSBLUFADemoVID && | 88 if (it->vendor_id == kUSBLUFADemoVID && |
| 89 it->product_id == kUSBLUFADemoPID) { | 89 it->product_id == kUSBLUFADemoPID) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 119 TEST_F(HidConnectionTest, Write) { | 119 TEST_F(HidConnectionTest, Write) { |
| 120 scoped_refptr<HidConnection> connection = service_->Connect(device_id_); | 120 scoped_refptr<HidConnection> connection = service_->Connect(device_id_); |
| 121 | 121 |
| 122 if (connection) { | 122 if (connection) { |
| 123 message_loop_->PostTask(FROM_HERE, base::Bind(WriteNormal, connection)); | 123 message_loop_->PostTask(FROM_HERE, base::Bind(WriteNormal, connection)); |
| 124 message_loop_->Run(); | 124 message_loop_->Run(); |
| 125 } | 125 } |
| 126 } | 126 } |
| 127 | 127 |
| 128 } // namespace device | 128 } // namespace device |
| OLD | NEW |