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

Side by Side Diff: components/test_runner/mock_web_midi_accessor.cc

Issue 2422163002: Web MIDI: use midi_service.mojom for media::midi::PortState (Closed)
Patch Set: gn --check fix Created 4 years, 1 month 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 | « no previous file | content/browser/media/midi_host.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 "components/test_runner/mock_web_midi_accessor.h" 5 #include "components/test_runner/mock_web_midi_accessor.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "components/test_runner/test_interfaces.h" 10 #include "components/test_runner/test_interfaces.h"
11 #include "components/test_runner/test_runner.h" 11 #include "components/test_runner/test_runner.h"
12 #include "components/test_runner/web_test_delegate.h" 12 #include "components/test_runner/web_test_delegate.h"
13 #include "components/test_runner/web_test_runner.h" 13 #include "components/test_runner/web_test_runner.h"
14 #include "third_party/WebKit/public/platform/WebString.h" 14 #include "third_party/WebKit/public/platform/WebString.h"
15 #include "third_party/WebKit/public/platform/modules/webmidi/WebMIDIAccessorClie nt.h" 15 #include "third_party/WebKit/public/platform/modules/webmidi/WebMIDIAccessorClie nt.h"
16 16
17 using midi::mojom::PortState;
17 using midi::mojom::Result; 18 using midi::mojom::Result;
18 19
19 namespace test_runner { 20 namespace test_runner {
20 21
21 MockWebMIDIAccessor::MockWebMIDIAccessor(blink::WebMIDIAccessorClient* client, 22 MockWebMIDIAccessor::MockWebMIDIAccessor(blink::WebMIDIAccessorClient* client,
22 TestInterfaces* interfaces) 23 TestInterfaces* interfaces)
23 : client_(client), interfaces_(interfaces), weak_factory_(this) {} 24 : client_(client), interfaces_(interfaces), weak_factory_(this) {}
24 25
25 MockWebMIDIAccessor::~MockWebMIDIAccessor() { 26 MockWebMIDIAccessor::~MockWebMIDIAccessor() {
26 } 27 }
27 28
28 void MockWebMIDIAccessor::startSession() { 29 void MockWebMIDIAccessor::startSession() {
29 // Add a mock input and output port. 30 // Add a mock input and output port.
30 blink::WebMIDIAccessorClient::MIDIPortState state = 31 client_->didAddInputPort("MockInputID", "MockInputManufacturer",
31 blink::WebMIDIAccessorClient::MIDIPortStateConnected; 32 "MockInputName", "MockInputVersion",
32 client_->didAddInputPort("MockInputID", 33 PortState::CONNECTED);
33 "MockInputManufacturer", 34 client_->didAddOutputPort("MockOutputID", "MockOutputManufacturer",
34 "MockInputName", 35 "MockOutputName", "MockOutputVersion",
35 "MockInputVersion", 36 PortState::CONNECTED);
36 state);
37 client_->didAddOutputPort("MockOutputID",
38 "MockOutputManufacturer",
39 "MockOutputName",
40 "MockOutputVersion",
41 state);
42 interfaces_->GetDelegate()->PostTask(base::Bind( 37 interfaces_->GetDelegate()->PostTask(base::Bind(
43 &MockWebMIDIAccessor::ReportStartedSession, weak_factory_.GetWeakPtr(), 38 &MockWebMIDIAccessor::ReportStartedSession, weak_factory_.GetWeakPtr(),
44 interfaces_->GetTestRunner()->midiAccessorResult())); 39 interfaces_->GetTestRunner()->midiAccessorResult()));
45 } 40 }
46 41
47 void MockWebMIDIAccessor::ReportStartedSession(Result result) { 42 void MockWebMIDIAccessor::ReportStartedSession(Result result) {
48 client_->didStartSession(result); 43 client_->didStartSession(result);
49 } 44 }
50 45
51 void MockWebMIDIAccessor::sendMIDIData(unsigned port_index, 46 void MockWebMIDIAccessor::sendMIDIData(unsigned port_index,
52 const unsigned char* data, 47 const unsigned char* data,
53 size_t length, 48 size_t length,
54 double timestamp) { 49 double timestamp) {
55 // Emulate a loopback device for testing. 50 // Emulate a loopback device for testing.
56 client_->didReceiveMIDIData(port_index, data, length, timestamp); 51 client_->didReceiveMIDIData(port_index, data, length, timestamp);
57 } 52 }
58 53
59 } // namespace test_runner 54 } // namespace test_runner
OLDNEW
« no previous file with comments | « no previous file | content/browser/media/midi_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698