OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "media/midi/midi_manager_usb.h" | 5 #include "media/midi/midi_manager_usb.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <memory> |
9 #include <string> | 10 #include <string> |
10 #include <utility> | 11 #include <utility> |
11 | 12 |
12 #include "base/macros.h" | 13 #include "base/macros.h" |
13 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
14 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
15 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
16 #include "base/time/time.h" | 17 #include "base/time/time.h" |
17 #include "media/midi/usb_midi_device.h" | 18 #include "media/midi/usb_midi_device.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 | 160 |
160 Callback callback_; | 161 Callback callback_; |
161 | 162 |
162 private: | 163 private: |
163 DISALLOW_COPY_AND_ASSIGN(TestUsbMidiDeviceFactory); | 164 DISALLOW_COPY_AND_ASSIGN(TestUsbMidiDeviceFactory); |
164 }; | 165 }; |
165 | 166 |
166 class MidiManagerUsbForTesting : public MidiManagerUsb { | 167 class MidiManagerUsbForTesting : public MidiManagerUsb { |
167 public: | 168 public: |
168 explicit MidiManagerUsbForTesting( | 169 explicit MidiManagerUsbForTesting( |
169 scoped_ptr<UsbMidiDevice::Factory> device_factory) | 170 std::unique_ptr<UsbMidiDevice::Factory> device_factory) |
170 : MidiManagerUsb(std::move(device_factory)) {} | 171 : MidiManagerUsb(std::move(device_factory)) {} |
171 ~MidiManagerUsbForTesting() override {} | 172 ~MidiManagerUsbForTesting() override {} |
172 | 173 |
173 void CallCompleteInitialization(Result result) { | 174 void CallCompleteInitialization(Result result) { |
174 CompleteInitialization(result); | 175 CompleteInitialization(result); |
175 base::RunLoop run_loop; | 176 base::RunLoop run_loop; |
176 run_loop.RunUntilIdle(); | 177 run_loop.RunUntilIdle(); |
177 } | 178 } |
178 | 179 |
179 private: | 180 private: |
180 DISALLOW_COPY_AND_ASSIGN(MidiManagerUsbForTesting); | 181 DISALLOW_COPY_AND_ASSIGN(MidiManagerUsbForTesting); |
181 }; | 182 }; |
182 | 183 |
183 class MidiManagerUsbTest : public ::testing::Test { | 184 class MidiManagerUsbTest : public ::testing::Test { |
184 public: | 185 public: |
185 MidiManagerUsbTest() : message_loop_(new base::MessageLoop) { | 186 MidiManagerUsbTest() : message_loop_(new base::MessageLoop) { |
186 scoped_ptr<TestUsbMidiDeviceFactory> factory(new TestUsbMidiDeviceFactory); | 187 std::unique_ptr<TestUsbMidiDeviceFactory> factory( |
| 188 new TestUsbMidiDeviceFactory); |
187 factory_ = factory.get(); | 189 factory_ = factory.get(); |
188 manager_.reset(new MidiManagerUsbForTesting(std::move(factory))); | 190 manager_.reset(new MidiManagerUsbForTesting(std::move(factory))); |
189 } | 191 } |
190 ~MidiManagerUsbTest() override { | 192 ~MidiManagerUsbTest() override { |
191 manager_->Shutdown(); | 193 manager_->Shutdown(); |
192 base::RunLoop run_loop; | 194 base::RunLoop run_loop; |
193 run_loop.RunUntilIdle(); | 195 run_loop.RunUntilIdle(); |
194 | 196 |
195 std::string leftover_logs = logger_.TakeLog(); | 197 std::string leftover_logs = logger_.TakeLog(); |
196 if (!leftover_logs.empty()) { | 198 if (!leftover_logs.empty()) { |
(...skipping 22 matching lines...) Expand all Loading... |
219 factory_->callback_.Run(result, devices); | 221 factory_->callback_.Run(result, devices); |
220 while (!client_->complete_start_session_) { | 222 while (!client_->complete_start_session_) { |
221 base::RunLoop run_loop; | 223 base::RunLoop run_loop; |
222 run_loop.RunUntilIdle(); | 224 run_loop.RunUntilIdle(); |
223 } | 225 } |
224 } | 226 } |
225 | 227 |
226 const MidiPortInfoList& input_ports() { return client_->input_ports_; } | 228 const MidiPortInfoList& input_ports() { return client_->input_ports_; } |
227 const MidiPortInfoList& output_ports() { return client_->output_ports_; } | 229 const MidiPortInfoList& output_ports() { return client_->output_ports_; } |
228 | 230 |
229 scoped_ptr<MidiManagerUsbForTesting> manager_; | 231 std::unique_ptr<MidiManagerUsbForTesting> manager_; |
230 scoped_ptr<FakeMidiManagerClient> client_; | 232 std::unique_ptr<FakeMidiManagerClient> client_; |
231 // Owned by manager_. | 233 // Owned by manager_. |
232 TestUsbMidiDeviceFactory* factory_; | 234 TestUsbMidiDeviceFactory* factory_; |
233 Logger logger_; | 235 Logger logger_; |
234 | 236 |
235 private: | 237 private: |
236 scoped_ptr<base::MessageLoop> message_loop_; | 238 std::unique_ptr<base::MessageLoop> message_loop_; |
237 | 239 |
238 DISALLOW_COPY_AND_ASSIGN(MidiManagerUsbTest); | 240 DISALLOW_COPY_AND_ASSIGN(MidiManagerUsbTest); |
239 }; | 241 }; |
240 | 242 |
241 | 243 |
242 TEST_F(MidiManagerUsbTest, Initialize) { | 244 TEST_F(MidiManagerUsbTest, Initialize) { |
243 scoped_ptr<FakeUsbMidiDevice> device(new FakeUsbMidiDevice(&logger_)); | 245 std::unique_ptr<FakeUsbMidiDevice> device(new FakeUsbMidiDevice(&logger_)); |
244 uint8_t descriptors[] = { | 246 uint8_t descriptors[] = { |
245 0x12, 0x01, 0x10, 0x01, 0x00, 0x00, 0x00, 0x08, 0x86, 0x1a, 0x2d, 0x75, | 247 0x12, 0x01, 0x10, 0x01, 0x00, 0x00, 0x00, 0x08, 0x86, 0x1a, 0x2d, 0x75, |
246 0x54, 0x02, 0x00, 0x02, 0x00, 0x01, 0x09, 0x02, 0x75, 0x00, 0x02, 0x01, | 248 0x54, 0x02, 0x00, 0x02, 0x00, 0x01, 0x09, 0x02, 0x75, 0x00, 0x02, 0x01, |
247 0x00, 0x80, 0x30, 0x09, 0x04, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, | 249 0x00, 0x80, 0x30, 0x09, 0x04, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, |
248 0x09, 0x24, 0x01, 0x00, 0x01, 0x09, 0x00, 0x01, 0x01, 0x09, 0x04, 0x01, | 250 0x09, 0x24, 0x01, 0x00, 0x01, 0x09, 0x00, 0x01, 0x01, 0x09, 0x04, 0x01, |
249 0x00, 0x02, 0x01, 0x03, 0x00, 0x00, 0x07, 0x24, 0x01, 0x00, 0x01, 0x51, | 251 0x00, 0x02, 0x01, 0x03, 0x00, 0x00, 0x07, 0x24, 0x01, 0x00, 0x01, 0x51, |
250 0x00, 0x06, 0x24, 0x02, 0x01, 0x02, 0x00, 0x06, 0x24, 0x02, 0x01, 0x03, | 252 0x00, 0x06, 0x24, 0x02, 0x01, 0x02, 0x00, 0x06, 0x24, 0x02, 0x01, 0x03, |
251 0x00, 0x06, 0x24, 0x02, 0x02, 0x06, 0x00, 0x09, 0x24, 0x03, 0x01, 0x07, | 253 0x00, 0x06, 0x24, 0x02, 0x02, 0x06, 0x00, 0x09, 0x24, 0x03, 0x01, 0x07, |
252 0x01, 0x06, 0x01, 0x00, 0x09, 0x24, 0x03, 0x02, 0x04, 0x01, 0x02, 0x01, | 254 0x01, 0x06, 0x01, 0x00, 0x09, 0x24, 0x03, 0x02, 0x04, 0x01, 0x02, 0x01, |
253 0x00, 0x09, 0x24, 0x03, 0x02, 0x05, 0x01, 0x03, 0x01, 0x00, 0x09, 0x05, | 255 0x00, 0x09, 0x24, 0x03, 0x02, 0x05, 0x01, 0x03, 0x01, 0x00, 0x09, 0x05, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 ASSERT_EQ(2u, manager_->output_streams().size()); | 290 ASSERT_EQ(2u, manager_->output_streams().size()); |
289 EXPECT_EQ(2u, manager_->output_streams()[0]->jack().jack_id); | 291 EXPECT_EQ(2u, manager_->output_streams()[0]->jack().jack_id); |
290 EXPECT_EQ(3u, manager_->output_streams()[1]->jack().jack_id); | 292 EXPECT_EQ(3u, manager_->output_streams()[1]->jack().jack_id); |
291 ASSERT_EQ(1u, jacks.size()); | 293 ASSERT_EQ(1u, jacks.size()); |
292 EXPECT_EQ(2, jacks[0].endpoint_number()); | 294 EXPECT_EQ(2, jacks[0].endpoint_number()); |
293 | 295 |
294 EXPECT_EQ("UsbMidiDevice::GetDescriptors\n", logger_.TakeLog()); | 296 EXPECT_EQ("UsbMidiDevice::GetDescriptors\n", logger_.TakeLog()); |
295 } | 297 } |
296 | 298 |
297 TEST_F(MidiManagerUsbTest, InitializeMultipleDevices) { | 299 TEST_F(MidiManagerUsbTest, InitializeMultipleDevices) { |
298 scoped_ptr<FakeUsbMidiDevice> device1(new FakeUsbMidiDevice(&logger_)); | 300 std::unique_ptr<FakeUsbMidiDevice> device1(new FakeUsbMidiDevice(&logger_)); |
299 scoped_ptr<FakeUsbMidiDevice> device2(new FakeUsbMidiDevice(&logger_)); | 301 std::unique_ptr<FakeUsbMidiDevice> device2(new FakeUsbMidiDevice(&logger_)); |
300 uint8_t descriptors[] = { | 302 uint8_t descriptors[] = { |
301 0x12, 0x01, 0x10, 0x01, 0x00, 0x00, 0x00, 0x08, 0x86, 0x1a, 0x2d, 0x75, | 303 0x12, 0x01, 0x10, 0x01, 0x00, 0x00, 0x00, 0x08, 0x86, 0x1a, 0x2d, 0x75, |
302 0x54, 0x02, 0x00, 0x02, 0x00, 0x01, 0x09, 0x02, 0x75, 0x00, 0x02, 0x01, | 304 0x54, 0x02, 0x00, 0x02, 0x00, 0x01, 0x09, 0x02, 0x75, 0x00, 0x02, 0x01, |
303 0x00, 0x80, 0x30, 0x09, 0x04, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, | 305 0x00, 0x80, 0x30, 0x09, 0x04, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, |
304 0x09, 0x24, 0x01, 0x00, 0x01, 0x09, 0x00, 0x01, 0x01, 0x09, 0x04, 0x01, | 306 0x09, 0x24, 0x01, 0x00, 0x01, 0x09, 0x00, 0x01, 0x01, 0x09, 0x04, 0x01, |
305 0x00, 0x02, 0x01, 0x03, 0x00, 0x00, 0x07, 0x24, 0x01, 0x00, 0x01, 0x51, | 307 0x00, 0x02, 0x01, 0x03, 0x00, 0x00, 0x07, 0x24, 0x01, 0x00, 0x01, 0x51, |
306 0x00, 0x06, 0x24, 0x02, 0x01, 0x02, 0x00, 0x06, 0x24, 0x02, 0x01, 0x03, | 308 0x00, 0x06, 0x24, 0x02, 0x01, 0x02, 0x00, 0x06, 0x24, 0x02, 0x01, 0x03, |
307 0x00, 0x06, 0x24, 0x02, 0x02, 0x06, 0x00, 0x09, 0x24, 0x03, 0x01, 0x07, | 309 0x00, 0x06, 0x24, 0x02, 0x02, 0x06, 0x00, 0x09, 0x24, 0x03, 0x01, 0x07, |
308 0x01, 0x06, 0x01, 0x00, 0x09, 0x24, 0x03, 0x02, 0x04, 0x01, 0x02, 0x01, | 310 0x01, 0x06, 0x01, 0x00, 0x09, 0x24, 0x03, 0x02, 0x04, 0x01, 0x02, 0x01, |
309 0x00, 0x09, 0x24, 0x03, 0x02, 0x05, 0x01, 0x03, 0x01, 0x00, 0x09, 0x05, | 311 0x00, 0x09, 0x24, 0x03, 0x02, 0x05, 0x01, 0x03, 0x01, 0x00, 0x09, 0x05, |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 | 374 |
373 TEST_F(MidiManagerUsbTest, InitializeFail) { | 375 TEST_F(MidiManagerUsbTest, InitializeFail) { |
374 Initialize(); | 376 Initialize(); |
375 | 377 |
376 EXPECT_FALSE(IsInitializationCallbackInvoked()); | 378 EXPECT_FALSE(IsInitializationCallbackInvoked()); |
377 RunCallbackUntilCallbackInvoked(false, NULL); | 379 RunCallbackUntilCallbackInvoked(false, NULL); |
378 EXPECT_EQ(Result::INITIALIZATION_ERROR, GetInitializationResult()); | 380 EXPECT_EQ(Result::INITIALIZATION_ERROR, GetInitializationResult()); |
379 } | 381 } |
380 | 382 |
381 TEST_F(MidiManagerUsbTest, InitializeFailBecauseOfInvalidDescriptors) { | 383 TEST_F(MidiManagerUsbTest, InitializeFailBecauseOfInvalidDescriptors) { |
382 scoped_ptr<FakeUsbMidiDevice> device(new FakeUsbMidiDevice(&logger_)); | 384 std::unique_ptr<FakeUsbMidiDevice> device(new FakeUsbMidiDevice(&logger_)); |
383 uint8_t descriptors[] = {0x04}; | 385 uint8_t descriptors[] = {0x04}; |
384 device->SetDescriptors(ToVector(descriptors)); | 386 device->SetDescriptors(ToVector(descriptors)); |
385 | 387 |
386 Initialize(); | 388 Initialize(); |
387 ScopedVector<UsbMidiDevice> devices; | 389 ScopedVector<UsbMidiDevice> devices; |
388 devices.push_back(std::move(device)); | 390 devices.push_back(std::move(device)); |
389 EXPECT_FALSE(IsInitializationCallbackInvoked()); | 391 EXPECT_FALSE(IsInitializationCallbackInvoked()); |
390 RunCallbackUntilCallbackInvoked(true, &devices); | 392 RunCallbackUntilCallbackInvoked(true, &devices); |
391 EXPECT_EQ(Result::INITIALIZATION_ERROR, GetInitializationResult()); | 393 EXPECT_EQ(Result::INITIALIZATION_ERROR, GetInitializationResult()); |
392 EXPECT_EQ("UsbMidiDevice::GetDescriptors\n", logger_.TakeLog()); | 394 EXPECT_EQ("UsbMidiDevice::GetDescriptors\n", logger_.TakeLog()); |
393 } | 395 } |
394 | 396 |
395 TEST_F(MidiManagerUsbTest, Send) { | 397 TEST_F(MidiManagerUsbTest, Send) { |
396 Initialize(); | 398 Initialize(); |
397 scoped_ptr<FakeUsbMidiDevice> device(new FakeUsbMidiDevice(&logger_)); | 399 std::unique_ptr<FakeUsbMidiDevice> device(new FakeUsbMidiDevice(&logger_)); |
398 uint8_t descriptors[] = { | 400 uint8_t descriptors[] = { |
399 0x12, 0x01, 0x10, 0x01, 0x00, 0x00, 0x00, 0x08, 0x86, 0x1a, 0x2d, 0x75, | 401 0x12, 0x01, 0x10, 0x01, 0x00, 0x00, 0x00, 0x08, 0x86, 0x1a, 0x2d, 0x75, |
400 0x54, 0x02, 0x00, 0x02, 0x00, 0x01, 0x09, 0x02, 0x75, 0x00, 0x02, 0x01, | 402 0x54, 0x02, 0x00, 0x02, 0x00, 0x01, 0x09, 0x02, 0x75, 0x00, 0x02, 0x01, |
401 0x00, 0x80, 0x30, 0x09, 0x04, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, | 403 0x00, 0x80, 0x30, 0x09, 0x04, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, |
402 0x09, 0x24, 0x01, 0x00, 0x01, 0x09, 0x00, 0x01, 0x01, 0x09, 0x04, 0x01, | 404 0x09, 0x24, 0x01, 0x00, 0x01, 0x09, 0x00, 0x01, 0x01, 0x09, 0x04, 0x01, |
403 0x00, 0x02, 0x01, 0x03, 0x00, 0x00, 0x07, 0x24, 0x01, 0x00, 0x01, 0x51, | 405 0x00, 0x02, 0x01, 0x03, 0x00, 0x00, 0x07, 0x24, 0x01, 0x00, 0x01, 0x51, |
404 0x00, 0x06, 0x24, 0x02, 0x01, 0x02, 0x00, 0x06, 0x24, 0x02, 0x01, 0x03, | 406 0x00, 0x06, 0x24, 0x02, 0x01, 0x02, 0x00, 0x06, 0x24, 0x02, 0x01, 0x03, |
405 0x00, 0x06, 0x24, 0x02, 0x02, 0x06, 0x00, 0x09, 0x24, 0x03, 0x01, 0x07, | 407 0x00, 0x06, 0x24, 0x02, 0x02, 0x06, 0x00, 0x09, 0x24, 0x03, 0x01, 0x07, |
406 0x01, 0x06, 0x01, 0x00, 0x09, 0x24, 0x03, 0x02, 0x04, 0x01, 0x02, 0x01, | 408 0x01, 0x06, 0x01, 0x00, 0x09, 0x24, 0x03, 0x02, 0x04, 0x01, 0x02, 0x01, |
407 0x00, 0x09, 0x24, 0x03, 0x02, 0x05, 0x01, 0x03, 0x01, 0x00, 0x09, 0x05, | 409 0x00, 0x09, 0x24, 0x03, 0x02, 0x05, 0x01, 0x03, 0x01, 0x00, 0x09, 0x05, |
(...skipping 22 matching lines...) Expand all Loading... |
430 EXPECT_EQ("UsbMidiDevice::GetDescriptors\n" | 432 EXPECT_EQ("UsbMidiDevice::GetDescriptors\n" |
431 "UsbMidiDevice::Send endpoint = 2 data = " | 433 "UsbMidiDevice::Send endpoint = 2 data = " |
432 "0x19 0x90 0x45 0x7f " | 434 "0x19 0x90 0x45 0x7f " |
433 "0x14 0xf0 0x00 0x01 " | 435 "0x14 0xf0 0x00 0x01 " |
434 "0x15 0xf7 0x00 0x00\n" | 436 "0x15 0xf7 0x00 0x00\n" |
435 "MidiManagerClient::AccumulateMidiBytesSent size = 7\n", | 437 "MidiManagerClient::AccumulateMidiBytesSent size = 7\n", |
436 logger_.TakeLog()); | 438 logger_.TakeLog()); |
437 } | 439 } |
438 | 440 |
439 TEST_F(MidiManagerUsbTest, SendFromCompromizedRenderer) { | 441 TEST_F(MidiManagerUsbTest, SendFromCompromizedRenderer) { |
440 scoped_ptr<FakeUsbMidiDevice> device(new FakeUsbMidiDevice(&logger_)); | 442 std::unique_ptr<FakeUsbMidiDevice> device(new FakeUsbMidiDevice(&logger_)); |
441 uint8_t descriptors[] = { | 443 uint8_t descriptors[] = { |
442 0x12, 0x01, 0x10, 0x01, 0x00, 0x00, 0x00, 0x08, 0x86, 0x1a, 0x2d, 0x75, | 444 0x12, 0x01, 0x10, 0x01, 0x00, 0x00, 0x00, 0x08, 0x86, 0x1a, 0x2d, 0x75, |
443 0x54, 0x02, 0x00, 0x02, 0x00, 0x01, 0x09, 0x02, 0x75, 0x00, 0x02, 0x01, | 445 0x54, 0x02, 0x00, 0x02, 0x00, 0x01, 0x09, 0x02, 0x75, 0x00, 0x02, 0x01, |
444 0x00, 0x80, 0x30, 0x09, 0x04, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, | 446 0x00, 0x80, 0x30, 0x09, 0x04, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, |
445 0x09, 0x24, 0x01, 0x00, 0x01, 0x09, 0x00, 0x01, 0x01, 0x09, 0x04, 0x01, | 447 0x09, 0x24, 0x01, 0x00, 0x01, 0x09, 0x00, 0x01, 0x01, 0x09, 0x04, 0x01, |
446 0x00, 0x02, 0x01, 0x03, 0x00, 0x00, 0x07, 0x24, 0x01, 0x00, 0x01, 0x51, | 448 0x00, 0x02, 0x01, 0x03, 0x00, 0x00, 0x07, 0x24, 0x01, 0x00, 0x01, 0x51, |
447 0x00, 0x06, 0x24, 0x02, 0x01, 0x02, 0x00, 0x06, 0x24, 0x02, 0x01, 0x03, | 449 0x00, 0x06, 0x24, 0x02, 0x01, 0x02, 0x00, 0x06, 0x24, 0x02, 0x01, 0x03, |
448 0x00, 0x06, 0x24, 0x02, 0x02, 0x06, 0x00, 0x09, 0x24, 0x03, 0x01, 0x07, | 450 0x00, 0x06, 0x24, 0x02, 0x02, 0x06, 0x00, 0x09, 0x24, 0x03, 0x01, 0x07, |
449 0x01, 0x06, 0x01, 0x00, 0x09, 0x24, 0x03, 0x02, 0x04, 0x01, 0x02, 0x01, | 451 0x01, 0x06, 0x01, 0x00, 0x09, 0x24, 0x03, 0x02, 0x04, 0x01, 0x02, 0x01, |
450 0x00, 0x09, 0x24, 0x03, 0x02, 0x05, 0x01, 0x03, 0x01, 0x00, 0x09, 0x05, | 452 0x00, 0x09, 0x24, 0x03, 0x02, 0x05, 0x01, 0x03, 0x01, 0x00, 0x09, 0x05, |
(...skipping 19 matching lines...) Expand all Loading... |
470 // The specified port index is invalid. The manager must ignore the request. | 472 // The specified port index is invalid. The manager must ignore the request. |
471 manager_->DispatchSendMidiData(client_.get(), 99, ToVector(data), 0); | 473 manager_->DispatchSendMidiData(client_.get(), 99, ToVector(data), 0); |
472 EXPECT_EQ("", logger_.TakeLog()); | 474 EXPECT_EQ("", logger_.TakeLog()); |
473 | 475 |
474 // The specified port index is invalid. The manager must ignore the request. | 476 // The specified port index is invalid. The manager must ignore the request. |
475 manager_->DispatchSendMidiData(client_.get(), 2, ToVector(data), 0); | 477 manager_->DispatchSendMidiData(client_.get(), 2, ToVector(data), 0); |
476 EXPECT_EQ("", logger_.TakeLog()); | 478 EXPECT_EQ("", logger_.TakeLog()); |
477 } | 479 } |
478 | 480 |
479 TEST_F(MidiManagerUsbTest, Receive) { | 481 TEST_F(MidiManagerUsbTest, Receive) { |
480 scoped_ptr<FakeUsbMidiDevice> device(new FakeUsbMidiDevice(&logger_)); | 482 std::unique_ptr<FakeUsbMidiDevice> device(new FakeUsbMidiDevice(&logger_)); |
481 uint8_t descriptors[] = { | 483 uint8_t descriptors[] = { |
482 0x12, 0x01, 0x10, 0x01, 0x00, 0x00, 0x00, 0x08, 0x86, 0x1a, 0x2d, 0x75, | 484 0x12, 0x01, 0x10, 0x01, 0x00, 0x00, 0x00, 0x08, 0x86, 0x1a, 0x2d, 0x75, |
483 0x54, 0x02, 0x00, 0x02, 0x00, 0x01, 0x09, 0x02, 0x75, 0x00, 0x02, 0x01, | 485 0x54, 0x02, 0x00, 0x02, 0x00, 0x01, 0x09, 0x02, 0x75, 0x00, 0x02, 0x01, |
484 0x00, 0x80, 0x30, 0x09, 0x04, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, | 486 0x00, 0x80, 0x30, 0x09, 0x04, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, |
485 0x09, 0x24, 0x01, 0x00, 0x01, 0x09, 0x00, 0x01, 0x01, 0x09, 0x04, 0x01, | 487 0x09, 0x24, 0x01, 0x00, 0x01, 0x09, 0x00, 0x01, 0x01, 0x09, 0x04, 0x01, |
486 0x00, 0x02, 0x01, 0x03, 0x00, 0x00, 0x07, 0x24, 0x01, 0x00, 0x01, 0x51, | 488 0x00, 0x02, 0x01, 0x03, 0x00, 0x00, 0x07, 0x24, 0x01, 0x00, 0x01, 0x51, |
487 0x00, 0x06, 0x24, 0x02, 0x01, 0x02, 0x00, 0x06, 0x24, 0x02, 0x01, 0x03, | 489 0x00, 0x06, 0x24, 0x02, 0x01, 0x02, 0x00, 0x06, 0x24, 0x02, 0x01, 0x03, |
488 0x00, 0x06, 0x24, 0x02, 0x02, 0x06, 0x00, 0x09, 0x24, 0x03, 0x01, 0x07, | 490 0x00, 0x06, 0x24, 0x02, 0x02, 0x06, 0x00, 0x09, 0x24, 0x03, 0x01, 0x07, |
489 0x01, 0x06, 0x01, 0x00, 0x09, 0x24, 0x03, 0x02, 0x04, 0x01, 0x02, 0x01, | 491 0x01, 0x06, 0x01, 0x00, 0x09, 0x24, 0x03, 0x02, 0x04, 0x01, 0x02, 0x01, |
490 0x00, 0x09, 0x24, 0x03, 0x02, 0x05, 0x01, 0x03, 0x01, 0x00, 0x09, 0x05, | 492 0x00, 0x09, 0x24, 0x03, 0x02, 0x05, 0x01, 0x03, 0x01, 0x00, 0x09, 0x05, |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 EXPECT_EQ(Result::OK, GetInitializationResult()); | 547 EXPECT_EQ(Result::OK, GetInitializationResult()); |
546 | 548 |
547 ASSERT_EQ(0u, input_ports().size()); | 549 ASSERT_EQ(0u, input_ports().size()); |
548 ASSERT_EQ(0u, output_ports().size()); | 550 ASSERT_EQ(0u, output_ports().size()); |
549 ASSERT_TRUE(manager_->input_stream()); | 551 ASSERT_TRUE(manager_->input_stream()); |
550 std::vector<UsbMidiJack> jacks = manager_->input_stream()->jacks(); | 552 std::vector<UsbMidiJack> jacks = manager_->input_stream()->jacks(); |
551 ASSERT_EQ(0u, manager_->output_streams().size()); | 553 ASSERT_EQ(0u, manager_->output_streams().size()); |
552 ASSERT_EQ(0u, jacks.size()); | 554 ASSERT_EQ(0u, jacks.size()); |
553 EXPECT_EQ("", logger_.TakeLog()); | 555 EXPECT_EQ("", logger_.TakeLog()); |
554 | 556 |
555 scoped_ptr<FakeUsbMidiDevice> new_device(new FakeUsbMidiDevice(&logger_)); | 557 std::unique_ptr<FakeUsbMidiDevice> new_device( |
| 558 new FakeUsbMidiDevice(&logger_)); |
556 new_device->SetDescriptors(ToVector(descriptors)); | 559 new_device->SetDescriptors(ToVector(descriptors)); |
557 manager_->OnDeviceAttached(std::move(new_device)); | 560 manager_->OnDeviceAttached(std::move(new_device)); |
558 | 561 |
559 ASSERT_EQ(1u, input_ports().size()); | 562 ASSERT_EQ(1u, input_ports().size()); |
560 ASSERT_EQ(2u, output_ports().size()); | 563 ASSERT_EQ(2u, output_ports().size()); |
561 ASSERT_TRUE(manager_->input_stream()); | 564 ASSERT_TRUE(manager_->input_stream()); |
562 jacks = manager_->input_stream()->jacks(); | 565 jacks = manager_->input_stream()->jacks(); |
563 ASSERT_EQ(2u, manager_->output_streams().size()); | 566 ASSERT_EQ(2u, manager_->output_streams().size()); |
564 EXPECT_EQ(2u, manager_->output_streams()[0]->jack().jack_id); | 567 EXPECT_EQ(2u, manager_->output_streams()[0]->jack().jack_id); |
565 EXPECT_EQ(3u, manager_->output_streams()[1]->jack().jack_id); | 568 EXPECT_EQ(3u, manager_->output_streams()[1]->jack().jack_id); |
566 ASSERT_EQ(1u, jacks.size()); | 569 ASSERT_EQ(1u, jacks.size()); |
567 EXPECT_EQ(2, jacks[0].endpoint_number()); | 570 EXPECT_EQ(2, jacks[0].endpoint_number()); |
568 EXPECT_EQ("UsbMidiDevice::GetDescriptors\n", logger_.TakeLog()); | 571 EXPECT_EQ("UsbMidiDevice::GetDescriptors\n", logger_.TakeLog()); |
569 } | 572 } |
570 | 573 |
571 } // namespace | 574 } // namespace |
572 | 575 |
573 } // namespace midi | 576 } // namespace midi |
574 } // namespace media | 577 } // namespace media |
OLD | NEW |