OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 "content/browser/media/midi_host.h" | 5 #include "content/browser/media/midi_host.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
14 #include "content/common/media/midi_messages.h" | 14 #include "content/common/media/midi_messages.h" |
15 #include "content/public/test/test_browser_thread.h" | 15 #include "content/public/test/test_browser_thread.h" |
16 #include "media/midi/midi_manager.h" | 16 #include "media/midi/midi_manager.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
18 | 18 |
19 namespace content { | 19 namespace content { |
20 namespace { | 20 namespace { |
21 | 21 |
| 22 using midi::mojom::PortState; |
| 23 |
22 const uint8_t kNoteOn[] = {0x90, 0x3c, 0x7f}; | 24 const uint8_t kNoteOn[] = {0x90, 0x3c, 0x7f}; |
23 const int kRenderProcessId = 0; | 25 const int kRenderProcessId = 0; |
24 | 26 |
25 enum MidiEventType { | 27 enum MidiEventType { |
26 DISPATCH_SEND_MIDI_DATA, | 28 DISPATCH_SEND_MIDI_DATA, |
27 }; | 29 }; |
28 | 30 |
29 struct MidiEvent { | 31 struct MidiEvent { |
30 MidiEvent(MidiEventType in_type, | 32 MidiEvent(MidiEventType in_type, |
31 uint32_t in_port_index, | 33 uint32_t in_port_index, |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 manager_.Shutdown(); | 85 manager_.Shutdown(); |
84 RunLoopUntilIdle(); | 86 RunLoopUntilIdle(); |
85 } | 87 } |
86 | 88 |
87 protected: | 89 protected: |
88 void AddOutputPort() { | 90 void AddOutputPort() { |
89 const std::string id = base::StringPrintf("i-can-%d", port_id_++); | 91 const std::string id = base::StringPrintf("i-can-%d", port_id_++); |
90 const std::string manufacturer("yukatan"); | 92 const std::string manufacturer("yukatan"); |
91 const std::string name("doki-doki-pi-pine"); | 93 const std::string name("doki-doki-pi-pine"); |
92 const std::string version("3.14159265359"); | 94 const std::string version("3.14159265359"); |
93 midi::MidiPortState state = midi::MIDI_PORT_CONNECTED; | 95 PortState state = PortState::CONNECTED; |
94 midi::MidiPortInfo info(id, manufacturer, name, version, state); | 96 midi::MidiPortInfo info(id, manufacturer, name, version, state); |
95 | 97 |
96 host_->AddOutputPort(info); | 98 host_->AddOutputPort(info); |
97 } | 99 } |
98 | 100 |
99 void OnSendData(uint32_t port) { | 101 void OnSendData(uint32_t port) { |
100 std::unique_ptr<IPC::Message> message( | 102 std::unique_ptr<IPC::Message> message( |
101 new MidiHostMsg_SendData(port, data_, 0.0)); | 103 new MidiHostMsg_SendData(port, data_, 0.0)); |
102 host_->OnMessageReceived(*message.get()); | 104 host_->OnMessageReceived(*message.get()); |
103 } | 105 } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 // Sending data to port 0 and 1 should be delivered now. | 158 // Sending data to port 0 and 1 should be delivered now. |
157 OnSendData(port0); | 159 OnSendData(port0); |
158 OnSendData(port1); | 160 OnSendData(port1); |
159 RunLoopUntilIdle(); | 161 RunLoopUntilIdle(); |
160 EXPECT_EQ(3U, GetEventSize()); | 162 EXPECT_EQ(3U, GetEventSize()); |
161 CheckSendEventAt(1, port0); | 163 CheckSendEventAt(1, port0); |
162 CheckSendEventAt(2, port1); | 164 CheckSendEventAt(2, port1); |
163 } | 165 } |
164 | 166 |
165 } // namespace conent | 167 } // namespace conent |
OLD | NEW |