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

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

Issue 1052983002: Web MIDI: add MidiScheduler for send() with timestamp (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: final Created 5 years, 8 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') | media/midi/midi_scheduler.h » ('j') | 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 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 347
348 Initialize(); 348 Initialize();
349 ScopedVector<UsbMidiDevice> devices; 349 ScopedVector<UsbMidiDevice> devices;
350 devices.push_back(device.release()); 350 devices.push_back(device.release());
351 EXPECT_FALSE(IsInitializationCallbackInvoked()); 351 EXPECT_FALSE(IsInitializationCallbackInvoked());
352 RunCallbackUntilCallbackInvoked(true, &devices); 352 RunCallbackUntilCallbackInvoked(true, &devices);
353 EXPECT_EQ(MIDI_OK, GetInitializationResult()); 353 EXPECT_EQ(MIDI_OK, GetInitializationResult());
354 ASSERT_EQ(2u, manager_->output_streams().size()); 354 ASSERT_EQ(2u, manager_->output_streams().size());
355 355
356 manager_->DispatchSendMidiData(&client, 1, ToVector(data), 0); 356 manager_->DispatchSendMidiData(&client, 1, ToVector(data), 0);
357 // Since UsbMidiDevice::Send is posted as a task, RunLoop should run to
358 // invoke the task.
359 // TODO(crbug.com/467442): AccumulateMidiBytesSent is recorded before
360 // UsbMidiDevice is invoked for now, but this should be after the invocation.
361 base::RunLoop run_loop;
362 run_loop.RunUntilIdle();
357 EXPECT_EQ("UsbMidiDevice::GetDescriptor\n" 363 EXPECT_EQ("UsbMidiDevice::GetDescriptor\n"
364 "MidiManagerClient::AccumulateMidiBytesSent size = 7\n"
358 "UsbMidiDevice::Send endpoint = 2 data = " 365 "UsbMidiDevice::Send endpoint = 2 data = "
359 "0x19 0x90 0x45 0x7f " 366 "0x19 0x90 0x45 0x7f "
360 "0x14 0xf0 0x00 0x01 " 367 "0x14 0xf0 0x00 0x01 "
361 "0x15 0xf7 0x00 0x00\n" 368 "0x15 0xf7 0x00 0x00\n",
362 "MidiManagerClient::AccumulateMidiBytesSent size = 7\n",
363 logger_.TakeLog()); 369 logger_.TakeLog());
364 } 370 }
365 371
366 TEST_F(MidiManagerUsbTest, SendFromCompromizedRenderer) { 372 TEST_F(MidiManagerUsbTest, SendFromCompromizedRenderer) {
367 scoped_ptr<FakeUsbMidiDevice> device(new FakeUsbMidiDevice(&logger_)); 373 scoped_ptr<FakeUsbMidiDevice> device(new FakeUsbMidiDevice(&logger_));
368 FakeMidiManagerClient client(&logger_); 374 FakeMidiManagerClient client(&logger_);
369 uint8 descriptor[] = { 375 uint8 descriptor[] = {
370 0x12, 0x01, 0x10, 0x01, 0x00, 0x00, 0x00, 0x08, 0x86, 0x1a, 376 0x12, 0x01, 0x10, 0x01, 0x00, 0x00, 0x00, 0x08, 0x86, 0x1a,
371 0x2d, 0x75, 0x54, 0x02, 0x00, 0x02, 0x00, 0x01, 0x09, 0x02, 377 0x2d, 0x75, 0x54, 0x02, 0x00, 0x02, 0x00, 0x01, 0x09, 0x02,
372 0x75, 0x00, 0x02, 0x01, 0x00, 0x80, 0x30, 0x09, 0x04, 0x00, 378 0x75, 0x00, 0x02, 0x01, 0x00, 0x80, 0x30, 0x09, 0x04, 0x00,
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 EXPECT_EQ(2u, manager_->output_streams()[0]->jack().jack_id); 505 EXPECT_EQ(2u, manager_->output_streams()[0]->jack().jack_id);
500 EXPECT_EQ(3u, manager_->output_streams()[1]->jack().jack_id); 506 EXPECT_EQ(3u, manager_->output_streams()[1]->jack().jack_id);
501 ASSERT_EQ(1u, jacks.size()); 507 ASSERT_EQ(1u, jacks.size());
502 EXPECT_EQ(2, jacks[0].endpoint_number()); 508 EXPECT_EQ(2, jacks[0].endpoint_number());
503 EXPECT_EQ("UsbMidiDevice::GetDescriptor\n", logger_.TakeLog()); 509 EXPECT_EQ("UsbMidiDevice::GetDescriptor\n", logger_.TakeLog());
504 } 510 }
505 511
506 } // namespace 512 } // namespace
507 513
508 } // namespace media 514 } // namespace media
OLDNEW
« no previous file with comments | « media/midi/midi_manager_usb.cc ('k') | media/midi/midi_scheduler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698