OLD | NEW |
| (Empty) |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "content/shell/renderer/test_runner/MockWebMIDIAccessor.h" | |
6 | |
7 #include "content/shell/renderer/test_runner/TestInterfaces.h" | |
8 #include "content/shell/renderer/test_runner/WebTestDelegate.h" | |
9 #include "content/shell/renderer/test_runner/test_runner.h" | |
10 #include "content/shell/renderer/test_runner/web_test_runner.h" | |
11 #include "third_party/WebKit/public/platform/WebMIDIAccessorClient.h" | |
12 | |
13 using namespace blink; | |
14 | |
15 namespace content { | |
16 | |
17 namespace { | |
18 | |
19 class DidStartSessionTask : public WebMethodTask<MockWebMIDIAccessor> { | |
20 public: | |
21 DidStartSessionTask(MockWebMIDIAccessor* object, blink::WebMIDIAccessorClien
t* client, bool result) | |
22 : WebMethodTask<MockWebMIDIAccessor>(object) | |
23 , m_client(client) | |
24 , m_result(result) | |
25 { | |
26 } | |
27 | |
28 virtual void runIfValid() OVERRIDE | |
29 { | |
30 m_client->didStartSession(m_result, "InvalidStateError", ""); | |
31 } | |
32 | |
33 private: | |
34 blink::WebMIDIAccessorClient* m_client; | |
35 bool m_result; | |
36 }; | |
37 | |
38 } // namespace | |
39 | |
40 MockWebMIDIAccessor::MockWebMIDIAccessor(blink::WebMIDIAccessorClient* client, T
estInterfaces* interfaces) | |
41 : m_client(client) | |
42 , m_interfaces(interfaces) | |
43 { | |
44 } | |
45 | |
46 MockWebMIDIAccessor::~MockWebMIDIAccessor() | |
47 { | |
48 } | |
49 | |
50 void MockWebMIDIAccessor::startSession() | |
51 { | |
52 // Add a mock input and output port. | |
53 m_client->didAddInputPort("MockInputID", "MockInputManufacturer", "MockInput
Name", "MockInputVersion"); | |
54 m_client->didAddOutputPort("MockOutputID", "MockOutputManufacturer", "MockOu
tputName", "MockOutputVersion"); | |
55 m_interfaces->delegate()->postTask(new DidStartSessionTask(this, m_client, m
_interfaces->testRunner()->midiAccessorResult())); | |
56 } | |
57 | |
58 } // namespace content | |
OLD | NEW |