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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 ASSERT_NE(device_id_, kInvalidHidDeviceId); | 93 ASSERT_NE(device_id_, kInvalidHidDeviceId); |
94 } | 94 } |
95 | 95 |
96 void FindDevice(const base::Closure& done, int retries) { | 96 void FindDevice(const base::Closure& done, int retries) { |
97 std::vector<HidDeviceInfo> devices; | 97 std::vector<HidDeviceInfo> devices; |
98 service_->GetDevices(&devices); | 98 service_->GetDevices(&devices); |
99 | 99 |
100 for (std::vector<HidDeviceInfo>::iterator it = devices.begin(); | 100 for (std::vector<HidDeviceInfo>::iterator it = devices.begin(); |
101 it != devices.end(); | 101 it != devices.end(); |
102 ++it) { | 102 ++it) { |
103 if (it->serial_number == test_gadget_->GetSerial()) { | 103 if (it->serial_number == test_gadget_->GetSerialNumber()) { |
104 device_id_ = it->device_id; | 104 device_id_ = it->device_id; |
105 break; | 105 break; |
106 } | 106 } |
107 } | 107 } |
108 | 108 |
109 if (device_id_ == kInvalidHidDeviceId && --retries > 0) { | 109 if (device_id_ == kInvalidHidDeviceId && --retries > 0) { |
110 message_loop_->PostDelayedTask( | 110 message_loop_->PostDelayedTask( |
111 FROM_HERE, | 111 FROM_HERE, |
112 base::Bind(&HidConnectionTest::FindDevice, base::Unretained(this), | 112 base::Bind(&HidConnectionTest::FindDevice, base::Unretained(this), |
113 done, retries), | 113 done, retries), |
(...skipping 31 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 |