Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: media/midi/midi_manager_usb_unittest.cc

Issue 943333006: MidiManagerUsb should be able to accept multiple devices. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/midi/midi_manager_usb.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 manager_->input_stream()->RegisteredJackKeysForTesting(); 243 manager_->input_stream()->RegisteredJackKeysForTesting();
244 ASSERT_EQ(2u, manager_->output_streams().size()); 244 ASSERT_EQ(2u, manager_->output_streams().size());
245 EXPECT_EQ(2u, manager_->output_streams()[0]->jack().jack_id); 245 EXPECT_EQ(2u, manager_->output_streams()[0]->jack().jack_id);
246 EXPECT_EQ(3u, manager_->output_streams()[1]->jack().jack_id); 246 EXPECT_EQ(3u, manager_->output_streams()[1]->jack().jack_id);
247 ASSERT_EQ(1u, keys.size()); 247 ASSERT_EQ(1u, keys.size());
248 EXPECT_EQ(2, keys[0].endpoint_number); 248 EXPECT_EQ(2, keys[0].endpoint_number);
249 249
250 EXPECT_EQ("UsbMidiDevice::GetDescriptor\n", logger_.TakeLog()); 250 EXPECT_EQ("UsbMidiDevice::GetDescriptor\n", logger_.TakeLog());
251 } 251 }
252 252
253 TEST_F(MidiManagerUsbTest, InitializeMultipleDevices) {
254 scoped_ptr<FakeUsbMidiDevice> device1(new FakeUsbMidiDevice(&logger_));
255 scoped_ptr<FakeUsbMidiDevice> device2(new FakeUsbMidiDevice(&logger_));
256 uint8 descriptor[] = {
257 0x12, 0x01, 0x10, 0x01, 0x00, 0x00, 0x00, 0x08, 0x86, 0x1a, 0x2d, 0x75,
258 0x54, 0x02, 0x00, 0x02, 0x00, 0x01, 0x09, 0x02, 0x75, 0x00, 0x02, 0x01,
259 0x00, 0x80, 0x30, 0x09, 0x04, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00,
260 0x09, 0x24, 0x01, 0x00, 0x01, 0x09, 0x00, 0x01, 0x01, 0x09, 0x04, 0x01,
261 0x00, 0x02, 0x01, 0x03, 0x00, 0x00, 0x07, 0x24, 0x01, 0x00, 0x01, 0x51,
262 0x00, 0x06, 0x24, 0x02, 0x01, 0x02, 0x00, 0x06, 0x24, 0x02, 0x01, 0x03,
263 0x00, 0x06, 0x24, 0x02, 0x02, 0x06, 0x00, 0x09, 0x24, 0x03, 0x01, 0x07,
264 0x01, 0x06, 0x01, 0x00, 0x09, 0x24, 0x03, 0x02, 0x04, 0x01, 0x02, 0x01,
265 0x00, 0x09, 0x24, 0x03, 0x02, 0x05, 0x01, 0x03, 0x01, 0x00, 0x09, 0x05,
266 0x02, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x06, 0x25, 0x01, 0x02, 0x02,
267 0x03, 0x09, 0x05, 0x82, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x05, 0x25,
268 0x01, 0x01, 0x07,
269 };
270 device1->SetDescriptor(ToVector(descriptor));
271 device2->SetDescriptor(ToVector(descriptor));
272
273 Initialize();
274 ScopedVector<UsbMidiDevice> devices;
275 devices.push_back(device1.release());
276 devices.push_back(device2.release());
277 EXPECT_FALSE(IsInitializationCallbackInvoked());
278 RunCallbackUntilCallbackInvoked(true, &devices);
279 EXPECT_EQ(MIDI_OK, GetInitializationResult());
280
281 ASSERT_EQ(2u, input_ports().size());
282 ASSERT_EQ(4u, output_ports().size());
283 ASSERT_TRUE(manager_->input_stream());
284 std::vector<UsbMidiInputStream::JackUniqueKey> keys =
285 manager_->input_stream()->RegisteredJackKeysForTesting();
286 ASSERT_EQ(4u, manager_->output_streams().size());
287 EXPECT_EQ(2u, manager_->output_streams()[0]->jack().jack_id);
288 EXPECT_EQ(3u, manager_->output_streams()[1]->jack().jack_id);
289 ASSERT_EQ(2u, keys.size());
290 EXPECT_EQ(2, keys[0].endpoint_number);
291
292 EXPECT_EQ(
293 "UsbMidiDevice::GetDescriptor\n"
294 "UsbMidiDevice::GetDescriptor\n",
295 logger_.TakeLog());
296 }
297
253 TEST_F(MidiManagerUsbTest, InitializeFail) { 298 TEST_F(MidiManagerUsbTest, InitializeFail) {
254 Initialize(); 299 Initialize();
255 300
256 EXPECT_FALSE(IsInitializationCallbackInvoked()); 301 EXPECT_FALSE(IsInitializationCallbackInvoked());
257 RunCallbackUntilCallbackInvoked(false, NULL); 302 RunCallbackUntilCallbackInvoked(false, NULL);
258 EXPECT_EQ(MIDI_INITIALIZATION_ERROR, GetInitializationResult()); 303 EXPECT_EQ(MIDI_INITIALIZATION_ERROR, GetInitializationResult());
259 } 304 }
260 305
261 TEST_F(MidiManagerUsbTest, InitializeFailBecauseOfInvalidDescriptor) { 306 TEST_F(MidiManagerUsbTest, InitializeFailBecauseOfInvalidDescriptor) {
262 scoped_ptr<FakeUsbMidiDevice> device(new FakeUsbMidiDevice(&logger_)); 307 scoped_ptr<FakeUsbMidiDevice> device(new FakeUsbMidiDevice(&logger_));
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 "data = 0x90 0x45 0x7f\n" 449 "data = 0x90 0x45 0x7f\n"
405 "MidiManagerClient::ReceiveMidiData port_index = 0 " 450 "MidiManagerClient::ReceiveMidiData port_index = 0 "
406 "data = 0xf0 0x00 0x01\n" 451 "data = 0xf0 0x00 0x01\n"
407 "MidiManagerClient::ReceiveMidiData port_index = 0 data = 0xf7\n", 452 "MidiManagerClient::ReceiveMidiData port_index = 0 data = 0xf7\n",
408 logger_.TakeLog()); 453 logger_.TakeLog());
409 } 454 }
410 455
411 } // namespace 456 } // namespace
412 457
413 } // namespace media 458 } // namespace media
OLDNEW
« no previous file with comments | « media/midi/midi_manager_usb.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698