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

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

Issue 2404443002: Web MIDI: use midi_service.mojom for media::midi::Result (Closed)
Patch Set: yhirano@ review Created 4 years, 2 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
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::Result;
18
17 namespace test_runner { 19 namespace test_runner {
18 20
19 MockWebMIDIAccessor::MockWebMIDIAccessor(blink::WebMIDIAccessorClient* client, 21 MockWebMIDIAccessor::MockWebMIDIAccessor(blink::WebMIDIAccessorClient* client,
20 TestInterfaces* interfaces) 22 TestInterfaces* interfaces)
21 : client_(client), interfaces_(interfaces), weak_factory_(this) {} 23 : client_(client), interfaces_(interfaces), weak_factory_(this) {}
22 24
23 MockWebMIDIAccessor::~MockWebMIDIAccessor() { 25 MockWebMIDIAccessor::~MockWebMIDIAccessor() {
24 } 26 }
25 27
26 void MockWebMIDIAccessor::startSession() { 28 void MockWebMIDIAccessor::startSession() {
27 // Add a mock input and output port. 29 // Add a mock input and output port.
28 blink::WebMIDIAccessorClient::MIDIPortState state = 30 blink::WebMIDIAccessorClient::MIDIPortState state =
29 blink::WebMIDIAccessorClient::MIDIPortStateConnected; 31 blink::WebMIDIAccessorClient::MIDIPortStateConnected;
30 client_->didAddInputPort("MockInputID", 32 client_->didAddInputPort("MockInputID",
31 "MockInputManufacturer", 33 "MockInputManufacturer",
32 "MockInputName", 34 "MockInputName",
33 "MockInputVersion", 35 "MockInputVersion",
34 state); 36 state);
35 client_->didAddOutputPort("MockOutputID", 37 client_->didAddOutputPort("MockOutputID",
36 "MockOutputManufacturer", 38 "MockOutputManufacturer",
37 "MockOutputName", 39 "MockOutputName",
38 "MockOutputVersion", 40 "MockOutputVersion",
39 state); 41 state);
40 interfaces_->GetDelegate()->PostTask(base::Bind( 42 interfaces_->GetDelegate()->PostTask(base::Bind(
41 &MockWebMIDIAccessor::ReportStartedSession, weak_factory_.GetWeakPtr(), 43 &MockWebMIDIAccessor::ReportStartedSession, weak_factory_.GetWeakPtr(),
42 interfaces_->GetTestRunner()->midiAccessorResult())); 44 interfaces_->GetTestRunner()->midiAccessorResult()));
43 } 45 }
44 46
45 void MockWebMIDIAccessor::ReportStartedSession(bool success) { 47 void MockWebMIDIAccessor::ReportStartedSession(Result result) {
46 client_->didStartSession(success, "InvalidStateError", ""); 48 client_->didStartSession(result);
47 } 49 }
48 50
49 void MockWebMIDIAccessor::sendMIDIData(unsigned port_index, 51 void MockWebMIDIAccessor::sendMIDIData(unsigned port_index,
50 const unsigned char* data, 52 const unsigned char* data,
51 size_t length, 53 size_t length,
52 double timestamp) { 54 double timestamp) {
53 // Emulate a loopback device for testing. 55 // Emulate a loopback device for testing.
54 client_->didReceiveMIDIData(port_index, data, length, timestamp); 56 client_->didReceiveMIDIData(port_index, data, length, timestamp);
55 } 57 }
56 58
57 } // namespace test_runner 59 } // namespace test_runner
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698