| 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 std::string device_version_; | 84 std::string device_version_; |
| 85 Logger* logger_; | 85 Logger* logger_; |
| 86 | 86 |
| 87 DISALLOW_COPY_AND_ASSIGN(FakeUsbMidiDevice); | 87 DISALLOW_COPY_AND_ASSIGN(FakeUsbMidiDevice); |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 class FakeMidiManagerClient : public MidiManagerClient { | 90 class FakeMidiManagerClient : public MidiManagerClient { |
| 91 public: | 91 public: |
| 92 explicit FakeMidiManagerClient(Logger* logger) | 92 explicit FakeMidiManagerClient(Logger* logger) |
| 93 : complete_start_session_(false), | 93 : complete_start_session_(false), |
| 94 result_(MIDI_NOT_SUPPORTED), | 94 result_(Result::NOT_SUPPORTED), |
| 95 logger_(logger) {} | 95 logger_(logger) {} |
| 96 ~FakeMidiManagerClient() override {} | 96 ~FakeMidiManagerClient() override {} |
| 97 | 97 |
| 98 void AddInputPort(const MidiPortInfo& info) override { | 98 void AddInputPort(const MidiPortInfo& info) override { |
| 99 input_ports_.push_back(info); | 99 input_ports_.push_back(info); |
| 100 } | 100 } |
| 101 | 101 |
| 102 void AddOutputPort(const MidiPortInfo& info) override { | 102 void AddOutputPort(const MidiPortInfo& info) override { |
| 103 output_ports_.push_back(info); | 103 output_ports_.push_back(info); |
| 104 } | 104 } |
| 105 | 105 |
| 106 void SetInputPortState(uint32 port_index, MidiPortState state) override {} | 106 void SetInputPortState(uint32 port_index, MidiPortState state) override {} |
| 107 | 107 |
| 108 void SetOutputPortState(uint32 port_index, MidiPortState state) override {} | 108 void SetOutputPortState(uint32 port_index, MidiPortState state) override {} |
| 109 | 109 |
| 110 void CompleteStartSession(MidiResult result) override { | 110 void CompleteStartSession(Result result) override { |
| 111 complete_start_session_ = true; | 111 complete_start_session_ = true; |
| 112 result_ = result; | 112 result_ = result; |
| 113 } | 113 } |
| 114 | 114 |
| 115 void ReceiveMidiData(uint32 port_index, | 115 void ReceiveMidiData(uint32 port_index, |
| 116 const uint8* data, | 116 const uint8* data, |
| 117 size_t size, | 117 size_t size, |
| 118 double timestamp) override { | 118 double timestamp) override { |
| 119 logger_->AddLog("MidiManagerClient::ReceiveMidiData "); | 119 logger_->AddLog("MidiManagerClient::ReceiveMidiData "); |
| 120 logger_->AddLog(base::StringPrintf("port_index = %d data =", port_index)); | 120 logger_->AddLog(base::StringPrintf("port_index = %d data =", port_index)); |
| 121 for (size_t i = 0; i < size; ++i) | 121 for (size_t i = 0; i < size; ++i) |
| 122 logger_->AddLog(base::StringPrintf(" 0x%02x", data[i])); | 122 logger_->AddLog(base::StringPrintf(" 0x%02x", data[i])); |
| 123 logger_->AddLog("\n"); | 123 logger_->AddLog("\n"); |
| 124 } | 124 } |
| 125 | 125 |
| 126 void AccumulateMidiBytesSent(size_t size) override { | 126 void AccumulateMidiBytesSent(size_t size) override { |
| 127 logger_->AddLog("MidiManagerClient::AccumulateMidiBytesSent "); | 127 logger_->AddLog("MidiManagerClient::AccumulateMidiBytesSent "); |
| 128 // Windows has no "%zu". | 128 // Windows has no "%zu". |
| 129 logger_->AddLog(base::StringPrintf("size = %u\n", | 129 logger_->AddLog(base::StringPrintf("size = %u\n", |
| 130 static_cast<unsigned>(size))); | 130 static_cast<unsigned>(size))); |
| 131 } | 131 } |
| 132 | 132 |
| 133 bool complete_start_session_; | 133 bool complete_start_session_; |
| 134 MidiResult result_; | 134 Result result_; |
| 135 MidiPortInfoList input_ports_; | 135 MidiPortInfoList input_ports_; |
| 136 MidiPortInfoList output_ports_; | 136 MidiPortInfoList output_ports_; |
| 137 | 137 |
| 138 private: | 138 private: |
| 139 Logger* logger_; | 139 Logger* logger_; |
| 140 | 140 |
| 141 DISALLOW_COPY_AND_ASSIGN(FakeMidiManagerClient); | 141 DISALLOW_COPY_AND_ASSIGN(FakeMidiManagerClient); |
| 142 }; | 142 }; |
| 143 | 143 |
| 144 class TestUsbMidiDeviceFactory : public UsbMidiDevice::Factory { | 144 class TestUsbMidiDeviceFactory : public UsbMidiDevice::Factory { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 156 DISALLOW_COPY_AND_ASSIGN(TestUsbMidiDeviceFactory); | 156 DISALLOW_COPY_AND_ASSIGN(TestUsbMidiDeviceFactory); |
| 157 }; | 157 }; |
| 158 | 158 |
| 159 class MidiManagerUsbForTesting : public MidiManagerUsb { | 159 class MidiManagerUsbForTesting : public MidiManagerUsb { |
| 160 public: | 160 public: |
| 161 explicit MidiManagerUsbForTesting( | 161 explicit MidiManagerUsbForTesting( |
| 162 scoped_ptr<UsbMidiDevice::Factory> device_factory) | 162 scoped_ptr<UsbMidiDevice::Factory> device_factory) |
| 163 : MidiManagerUsb(device_factory.Pass()) {} | 163 : MidiManagerUsb(device_factory.Pass()) {} |
| 164 ~MidiManagerUsbForTesting() override {} | 164 ~MidiManagerUsbForTesting() override {} |
| 165 | 165 |
| 166 void CallCompleteInitialization(MidiResult result) { | 166 void CallCompleteInitialization(Result result) { |
| 167 CompleteInitialization(result); | 167 CompleteInitialization(result); |
| 168 base::RunLoop run_loop; | 168 base::RunLoop run_loop; |
| 169 run_loop.RunUntilIdle(); | 169 run_loop.RunUntilIdle(); |
| 170 } | 170 } |
| 171 | 171 |
| 172 private: | 172 private: |
| 173 DISALLOW_COPY_AND_ASSIGN(MidiManagerUsbForTesting); | 173 DISALLOW_COPY_AND_ASSIGN(MidiManagerUsbForTesting); |
| 174 }; | 174 }; |
| 175 | 175 |
| 176 class MidiManagerUsbTest : public ::testing::Test { | 176 class MidiManagerUsbTest : public ::testing::Test { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 194 } | 194 } |
| 195 | 195 |
| 196 void Finalize() { | 196 void Finalize() { |
| 197 manager_->EndSession(client_.get()); | 197 manager_->EndSession(client_.get()); |
| 198 } | 198 } |
| 199 | 199 |
| 200 bool IsInitializationCallbackInvoked() { | 200 bool IsInitializationCallbackInvoked() { |
| 201 return client_->complete_start_session_; | 201 return client_->complete_start_session_; |
| 202 } | 202 } |
| 203 | 203 |
| 204 MidiResult GetInitializationResult() { | 204 Result GetInitializationResult() { return client_->result_; } |
| 205 return client_->result_; | |
| 206 } | |
| 207 | 205 |
| 208 void RunCallbackUntilCallbackInvoked( | 206 void RunCallbackUntilCallbackInvoked( |
| 209 bool result, UsbMidiDevice::Devices* devices) { | 207 bool result, UsbMidiDevice::Devices* devices) { |
| 210 factory_->callback_.Run(result, devices); | 208 factory_->callback_.Run(result, devices); |
| 211 while (!client_->complete_start_session_) { | 209 while (!client_->complete_start_session_) { |
| 212 base::RunLoop run_loop; | 210 base::RunLoop run_loop; |
| 213 run_loop.RunUntilIdle(); | 211 run_loop.RunUntilIdle(); |
| 214 } | 212 } |
| 215 } | 213 } |
| 216 | 214 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 device->SetDescriptors(ToVector(descriptors)); | 249 device->SetDescriptors(ToVector(descriptors)); |
| 252 device->SetManufacturer("vendor1"); | 250 device->SetManufacturer("vendor1"); |
| 253 device->SetProductName("device1"); | 251 device->SetProductName("device1"); |
| 254 device->SetDeviceVersion("1.02"); | 252 device->SetDeviceVersion("1.02"); |
| 255 | 253 |
| 256 Initialize(); | 254 Initialize(); |
| 257 ScopedVector<UsbMidiDevice> devices; | 255 ScopedVector<UsbMidiDevice> devices; |
| 258 devices.push_back(device.Pass()); | 256 devices.push_back(device.Pass()); |
| 259 EXPECT_FALSE(IsInitializationCallbackInvoked()); | 257 EXPECT_FALSE(IsInitializationCallbackInvoked()); |
| 260 RunCallbackUntilCallbackInvoked(true, &devices); | 258 RunCallbackUntilCallbackInvoked(true, &devices); |
| 261 EXPECT_EQ(MIDI_OK, GetInitializationResult()); | 259 EXPECT_EQ(Result::OK, GetInitializationResult()); |
| 262 | 260 |
| 263 ASSERT_EQ(1u, input_ports().size()); | 261 ASSERT_EQ(1u, input_ports().size()); |
| 264 EXPECT_EQ("port-0-2", input_ports()[0].id); | 262 EXPECT_EQ("port-0-2", input_ports()[0].id); |
| 265 EXPECT_EQ("vendor1", input_ports()[0].manufacturer); | 263 EXPECT_EQ("vendor1", input_ports()[0].manufacturer); |
| 266 EXPECT_EQ("device1", input_ports()[0].name); | 264 EXPECT_EQ("device1", input_ports()[0].name); |
| 267 EXPECT_EQ("1.02", input_ports()[0].version); | 265 EXPECT_EQ("1.02", input_ports()[0].version); |
| 268 | 266 |
| 269 ASSERT_EQ(2u, output_ports().size()); | 267 ASSERT_EQ(2u, output_ports().size()); |
| 270 EXPECT_EQ("port-0-0", output_ports()[0].id); | 268 EXPECT_EQ("port-0-0", output_ports()[0].id); |
| 271 EXPECT_EQ("vendor1", output_ports()[0].manufacturer); | 269 EXPECT_EQ("vendor1", output_ports()[0].manufacturer); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 device2->SetManufacturer("vendor2"); | 310 device2->SetManufacturer("vendor2"); |
| 313 device2->SetProductName("device2"); | 311 device2->SetProductName("device2"); |
| 314 device2->SetDeviceVersion("98.76"); | 312 device2->SetDeviceVersion("98.76"); |
| 315 | 313 |
| 316 Initialize(); | 314 Initialize(); |
| 317 ScopedVector<UsbMidiDevice> devices; | 315 ScopedVector<UsbMidiDevice> devices; |
| 318 devices.push_back(device1.Pass()); | 316 devices.push_back(device1.Pass()); |
| 319 devices.push_back(device2.Pass()); | 317 devices.push_back(device2.Pass()); |
| 320 EXPECT_FALSE(IsInitializationCallbackInvoked()); | 318 EXPECT_FALSE(IsInitializationCallbackInvoked()); |
| 321 RunCallbackUntilCallbackInvoked(true, &devices); | 319 RunCallbackUntilCallbackInvoked(true, &devices); |
| 322 EXPECT_EQ(MIDI_OK, GetInitializationResult()); | 320 EXPECT_EQ(Result::OK, GetInitializationResult()); |
| 323 | 321 |
| 324 ASSERT_EQ(2u, input_ports().size()); | 322 ASSERT_EQ(2u, input_ports().size()); |
| 325 EXPECT_EQ("port-0-2", input_ports()[0].id); | 323 EXPECT_EQ("port-0-2", input_ports()[0].id); |
| 326 EXPECT_EQ("vendor1", input_ports()[0].manufacturer); | 324 EXPECT_EQ("vendor1", input_ports()[0].manufacturer); |
| 327 EXPECT_EQ("device1", input_ports()[0].name); | 325 EXPECT_EQ("device1", input_ports()[0].name); |
| 328 EXPECT_EQ("1.02", input_ports()[0].version); | 326 EXPECT_EQ("1.02", input_ports()[0].version); |
| 329 EXPECT_EQ("port-1-2", input_ports()[1].id); | 327 EXPECT_EQ("port-1-2", input_ports()[1].id); |
| 330 EXPECT_EQ("vendor2", input_ports()[1].manufacturer); | 328 EXPECT_EQ("vendor2", input_ports()[1].manufacturer); |
| 331 EXPECT_EQ("device2", input_ports()[1].name); | 329 EXPECT_EQ("device2", input_ports()[1].name); |
| 332 EXPECT_EQ("98.76", input_ports()[1].version); | 330 EXPECT_EQ("98.76", input_ports()[1].version); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 361 "UsbMidiDevice::GetDescriptors\n" | 359 "UsbMidiDevice::GetDescriptors\n" |
| 362 "UsbMidiDevice::GetDescriptors\n", | 360 "UsbMidiDevice::GetDescriptors\n", |
| 363 logger_.TakeLog()); | 361 logger_.TakeLog()); |
| 364 } | 362 } |
| 365 | 363 |
| 366 TEST_F(MidiManagerUsbTest, InitializeFail) { | 364 TEST_F(MidiManagerUsbTest, InitializeFail) { |
| 367 Initialize(); | 365 Initialize(); |
| 368 | 366 |
| 369 EXPECT_FALSE(IsInitializationCallbackInvoked()); | 367 EXPECT_FALSE(IsInitializationCallbackInvoked()); |
| 370 RunCallbackUntilCallbackInvoked(false, NULL); | 368 RunCallbackUntilCallbackInvoked(false, NULL); |
| 371 EXPECT_EQ(MIDI_INITIALIZATION_ERROR, GetInitializationResult()); | 369 EXPECT_EQ(Result::INITIALIZATION_ERROR, GetInitializationResult()); |
| 372 } | 370 } |
| 373 | 371 |
| 374 TEST_F(MidiManagerUsbTest, InitializeFailBecauseOfInvalidDescriptors) { | 372 TEST_F(MidiManagerUsbTest, InitializeFailBecauseOfInvalidDescriptors) { |
| 375 scoped_ptr<FakeUsbMidiDevice> device(new FakeUsbMidiDevice(&logger_)); | 373 scoped_ptr<FakeUsbMidiDevice> device(new FakeUsbMidiDevice(&logger_)); |
| 376 uint8 descriptors[] = {0x04}; | 374 uint8 descriptors[] = {0x04}; |
| 377 device->SetDescriptors(ToVector(descriptors)); | 375 device->SetDescriptors(ToVector(descriptors)); |
| 378 | 376 |
| 379 Initialize(); | 377 Initialize(); |
| 380 ScopedVector<UsbMidiDevice> devices; | 378 ScopedVector<UsbMidiDevice> devices; |
| 381 devices.push_back(device.Pass()); | 379 devices.push_back(device.Pass()); |
| 382 EXPECT_FALSE(IsInitializationCallbackInvoked()); | 380 EXPECT_FALSE(IsInitializationCallbackInvoked()); |
| 383 RunCallbackUntilCallbackInvoked(true, &devices); | 381 RunCallbackUntilCallbackInvoked(true, &devices); |
| 384 EXPECT_EQ(MIDI_INITIALIZATION_ERROR, GetInitializationResult()); | 382 EXPECT_EQ(Result::INITIALIZATION_ERROR, GetInitializationResult()); |
| 385 EXPECT_EQ("UsbMidiDevice::GetDescriptors\n", logger_.TakeLog()); | 383 EXPECT_EQ("UsbMidiDevice::GetDescriptors\n", logger_.TakeLog()); |
| 386 } | 384 } |
| 387 | 385 |
| 388 TEST_F(MidiManagerUsbTest, Send) { | 386 TEST_F(MidiManagerUsbTest, Send) { |
| 389 Initialize(); | 387 Initialize(); |
| 390 scoped_ptr<FakeUsbMidiDevice> device(new FakeUsbMidiDevice(&logger_)); | 388 scoped_ptr<FakeUsbMidiDevice> device(new FakeUsbMidiDevice(&logger_)); |
| 391 uint8 descriptors[] = { | 389 uint8 descriptors[] = { |
| 392 0x12, 0x01, 0x10, 0x01, 0x00, 0x00, 0x00, 0x08, 0x86, 0x1a, | 390 0x12, 0x01, 0x10, 0x01, 0x00, 0x00, 0x00, 0x08, 0x86, 0x1a, |
| 393 0x2d, 0x75, 0x54, 0x02, 0x00, 0x02, 0x00, 0x01, 0x09, 0x02, | 391 0x2d, 0x75, 0x54, 0x02, 0x00, 0x02, 0x00, 0x01, 0x09, 0x02, |
| 394 0x75, 0x00, 0x02, 0x01, 0x00, 0x80, 0x30, 0x09, 0x04, 0x00, | 392 0x75, 0x00, 0x02, 0x01, 0x00, 0x80, 0x30, 0x09, 0x04, 0x00, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 408 device->SetDescriptors(ToVector(descriptors)); | 406 device->SetDescriptors(ToVector(descriptors)); |
| 409 uint8 data[] = { | 407 uint8 data[] = { |
| 410 0x90, 0x45, 0x7f, | 408 0x90, 0x45, 0x7f, |
| 411 0xf0, 0x00, 0x01, 0xf7, | 409 0xf0, 0x00, 0x01, 0xf7, |
| 412 }; | 410 }; |
| 413 | 411 |
| 414 ScopedVector<UsbMidiDevice> devices; | 412 ScopedVector<UsbMidiDevice> devices; |
| 415 devices.push_back(device.Pass()); | 413 devices.push_back(device.Pass()); |
| 416 EXPECT_FALSE(IsInitializationCallbackInvoked()); | 414 EXPECT_FALSE(IsInitializationCallbackInvoked()); |
| 417 RunCallbackUntilCallbackInvoked(true, &devices); | 415 RunCallbackUntilCallbackInvoked(true, &devices); |
| 418 EXPECT_EQ(MIDI_OK, GetInitializationResult()); | 416 EXPECT_EQ(Result::OK, GetInitializationResult()); |
| 419 ASSERT_EQ(2u, manager_->output_streams().size()); | 417 ASSERT_EQ(2u, manager_->output_streams().size()); |
| 420 | 418 |
| 421 manager_->DispatchSendMidiData(client_.get(), 1, ToVector(data), 0); | 419 manager_->DispatchSendMidiData(client_.get(), 1, ToVector(data), 0); |
| 422 // Since UsbMidiDevice::Send is posted as a task, RunLoop should run to | 420 // Since UsbMidiDevice::Send is posted as a task, RunLoop should run to |
| 423 // invoke the task. | 421 // invoke the task. |
| 424 base::RunLoop run_loop; | 422 base::RunLoop run_loop; |
| 425 run_loop.RunUntilIdle(); | 423 run_loop.RunUntilIdle(); |
| 426 EXPECT_EQ("UsbMidiDevice::GetDescriptors\n" | 424 EXPECT_EQ("UsbMidiDevice::GetDescriptors\n" |
| 427 "UsbMidiDevice::Send endpoint = 2 data = " | 425 "UsbMidiDevice::Send endpoint = 2 data = " |
| 428 "0x19 0x90 0x45 0x7f " | 426 "0x19 0x90 0x45 0x7f " |
| (...skipping 26 matching lines...) Expand all Loading... |
| 455 uint8 data[] = { | 453 uint8 data[] = { |
| 456 0x90, 0x45, 0x7f, | 454 0x90, 0x45, 0x7f, |
| 457 0xf0, 0x00, 0x01, 0xf7, | 455 0xf0, 0x00, 0x01, 0xf7, |
| 458 }; | 456 }; |
| 459 | 457 |
| 460 Initialize(); | 458 Initialize(); |
| 461 ScopedVector<UsbMidiDevice> devices; | 459 ScopedVector<UsbMidiDevice> devices; |
| 462 devices.push_back(device.Pass()); | 460 devices.push_back(device.Pass()); |
| 463 EXPECT_FALSE(IsInitializationCallbackInvoked()); | 461 EXPECT_FALSE(IsInitializationCallbackInvoked()); |
| 464 RunCallbackUntilCallbackInvoked(true, &devices); | 462 RunCallbackUntilCallbackInvoked(true, &devices); |
| 465 EXPECT_EQ(MIDI_OK, GetInitializationResult()); | 463 EXPECT_EQ(Result::OK, GetInitializationResult()); |
| 466 ASSERT_EQ(2u, manager_->output_streams().size()); | 464 ASSERT_EQ(2u, manager_->output_streams().size()); |
| 467 EXPECT_EQ("UsbMidiDevice::GetDescriptors\n", logger_.TakeLog()); | 465 EXPECT_EQ("UsbMidiDevice::GetDescriptors\n", logger_.TakeLog()); |
| 468 | 466 |
| 469 // The specified port index is invalid. The manager must ignore the request. | 467 // The specified port index is invalid. The manager must ignore the request. |
| 470 manager_->DispatchSendMidiData(client_.get(), 99, ToVector(data), 0); | 468 manager_->DispatchSendMidiData(client_.get(), 99, ToVector(data), 0); |
| 471 EXPECT_EQ("", logger_.TakeLog()); | 469 EXPECT_EQ("", logger_.TakeLog()); |
| 472 | 470 |
| 473 // The specified port index is invalid. The manager must ignore the request. | 471 // The specified port index is invalid. The manager must ignore the request. |
| 474 manager_->DispatchSendMidiData(client_.get(), 2, ToVector(data), 0); | 472 manager_->DispatchSendMidiData(client_.get(), 2, ToVector(data), 0); |
| 475 EXPECT_EQ("", logger_.TakeLog()); | 473 EXPECT_EQ("", logger_.TakeLog()); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 501 0x49, 0x90, 0x88, 0x99, // This data should be ignored (CN = 4). | 499 0x49, 0x90, 0x88, 0x99, // This data should be ignored (CN = 4). |
| 502 0x05, 0xf7, 0x00, 0x00, | 500 0x05, 0xf7, 0x00, 0x00, |
| 503 }; | 501 }; |
| 504 | 502 |
| 505 Initialize(); | 503 Initialize(); |
| 506 ScopedVector<UsbMidiDevice> devices; | 504 ScopedVector<UsbMidiDevice> devices; |
| 507 UsbMidiDevice* device_raw = device.get(); | 505 UsbMidiDevice* device_raw = device.get(); |
| 508 devices.push_back(device.Pass()); | 506 devices.push_back(device.Pass()); |
| 509 EXPECT_FALSE(IsInitializationCallbackInvoked()); | 507 EXPECT_FALSE(IsInitializationCallbackInvoked()); |
| 510 RunCallbackUntilCallbackInvoked(true, &devices); | 508 RunCallbackUntilCallbackInvoked(true, &devices); |
| 511 EXPECT_EQ(MIDI_OK, GetInitializationResult()); | 509 EXPECT_EQ(Result::OK, GetInitializationResult()); |
| 512 | 510 |
| 513 manager_->ReceiveUsbMidiData(device_raw, 2, data, arraysize(data), | 511 manager_->ReceiveUsbMidiData(device_raw, 2, data, arraysize(data), |
| 514 base::TimeTicks()); | 512 base::TimeTicks()); |
| 515 Finalize(); | 513 Finalize(); |
| 516 | 514 |
| 517 EXPECT_EQ("UsbMidiDevice::GetDescriptors\n" | 515 EXPECT_EQ("UsbMidiDevice::GetDescriptors\n" |
| 518 "MidiManagerClient::ReceiveMidiData port_index = 0 " | 516 "MidiManagerClient::ReceiveMidiData port_index = 0 " |
| 519 "data = 0x90 0x45 0x7f\n" | 517 "data = 0x90 0x45 0x7f\n" |
| 520 "MidiManagerClient::ReceiveMidiData port_index = 0 " | 518 "MidiManagerClient::ReceiveMidiData port_index = 0 " |
| 521 "data = 0xf0 0x00 0x01\n" | 519 "data = 0xf0 0x00 0x01\n" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 538 0x02, 0x05, 0x01, 0x03, 0x01, 0x00, 0x09, 0x05, 0x02, 0x02, | 536 0x02, 0x05, 0x01, 0x03, 0x01, 0x00, 0x09, 0x05, 0x02, 0x02, |
| 539 0x20, 0x00, 0x00, 0x00, 0x00, 0x06, 0x25, 0x01, 0x02, 0x02, | 537 0x20, 0x00, 0x00, 0x00, 0x00, 0x06, 0x25, 0x01, 0x02, 0x02, |
| 540 0x03, 0x09, 0x05, 0x82, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, | 538 0x03, 0x09, 0x05, 0x82, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, |
| 541 0x05, 0x25, 0x01, 0x01, 0x07, | 539 0x05, 0x25, 0x01, 0x01, 0x07, |
| 542 }; | 540 }; |
| 543 | 541 |
| 544 Initialize(); | 542 Initialize(); |
| 545 ScopedVector<UsbMidiDevice> devices; | 543 ScopedVector<UsbMidiDevice> devices; |
| 546 EXPECT_FALSE(IsInitializationCallbackInvoked()); | 544 EXPECT_FALSE(IsInitializationCallbackInvoked()); |
| 547 RunCallbackUntilCallbackInvoked(true, &devices); | 545 RunCallbackUntilCallbackInvoked(true, &devices); |
| 548 EXPECT_EQ(MIDI_OK, GetInitializationResult()); | 546 EXPECT_EQ(Result::OK, GetInitializationResult()); |
| 549 | 547 |
| 550 ASSERT_EQ(0u, input_ports().size()); | 548 ASSERT_EQ(0u, input_ports().size()); |
| 551 ASSERT_EQ(0u, output_ports().size()); | 549 ASSERT_EQ(0u, output_ports().size()); |
| 552 ASSERT_TRUE(manager_->input_stream()); | 550 ASSERT_TRUE(manager_->input_stream()); |
| 553 std::vector<UsbMidiJack> jacks = manager_->input_stream()->jacks(); | 551 std::vector<UsbMidiJack> jacks = manager_->input_stream()->jacks(); |
| 554 ASSERT_EQ(0u, manager_->output_streams().size()); | 552 ASSERT_EQ(0u, manager_->output_streams().size()); |
| 555 ASSERT_EQ(0u, jacks.size()); | 553 ASSERT_EQ(0u, jacks.size()); |
| 556 EXPECT_EQ("", logger_.TakeLog()); | 554 EXPECT_EQ("", logger_.TakeLog()); |
| 557 | 555 |
| 558 scoped_ptr<FakeUsbMidiDevice> new_device(new FakeUsbMidiDevice(&logger_)); | 556 scoped_ptr<FakeUsbMidiDevice> new_device(new FakeUsbMidiDevice(&logger_)); |
| 559 new_device->SetDescriptors(ToVector(descriptors)); | 557 new_device->SetDescriptors(ToVector(descriptors)); |
| 560 manager_->OnDeviceAttached(new_device.Pass()); | 558 manager_->OnDeviceAttached(new_device.Pass()); |
| 561 | 559 |
| 562 ASSERT_EQ(1u, input_ports().size()); | 560 ASSERT_EQ(1u, input_ports().size()); |
| 563 ASSERT_EQ(2u, output_ports().size()); | 561 ASSERT_EQ(2u, output_ports().size()); |
| 564 ASSERT_TRUE(manager_->input_stream()); | 562 ASSERT_TRUE(manager_->input_stream()); |
| 565 jacks = manager_->input_stream()->jacks(); | 563 jacks = manager_->input_stream()->jacks(); |
| 566 ASSERT_EQ(2u, manager_->output_streams().size()); | 564 ASSERT_EQ(2u, manager_->output_streams().size()); |
| 567 EXPECT_EQ(2u, manager_->output_streams()[0]->jack().jack_id); | 565 EXPECT_EQ(2u, manager_->output_streams()[0]->jack().jack_id); |
| 568 EXPECT_EQ(3u, manager_->output_streams()[1]->jack().jack_id); | 566 EXPECT_EQ(3u, manager_->output_streams()[1]->jack().jack_id); |
| 569 ASSERT_EQ(1u, jacks.size()); | 567 ASSERT_EQ(1u, jacks.size()); |
| 570 EXPECT_EQ(2, jacks[0].endpoint_number()); | 568 EXPECT_EQ(2, jacks[0].endpoint_number()); |
| 571 EXPECT_EQ("UsbMidiDevice::GetDescriptors\n", logger_.TakeLog()); | 569 EXPECT_EQ("UsbMidiDevice::GetDescriptors\n", logger_.TakeLog()); |
| 572 } | 570 } |
| 573 | 571 |
| 574 } // namespace | 572 } // namespace |
| 575 | 573 |
| 576 } // namespace midi | 574 } // namespace midi |
| 577 } // namespace media | 575 } // namespace media |
| OLD | NEW |