OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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/renderer/media/midi_message_filter.h" | 5 #include "content/renderer/media/midi_message_filter.h" |
6 | 6 |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "media/midi/midi_service.mojom.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
9 | 10 |
10 namespace content { | 11 namespace content { |
11 | 12 |
12 namespace { | 13 namespace { |
13 using BlinkState = blink::WebMIDIAccessorClient::MIDIPortState; | 14 |
14 } // namespace | 15 using midi::mojom::PortState; |
15 | 16 |
16 TEST(MidiMessageFilterTest, CastMidiPortState) { | 17 TEST(MidiMessageFilterTest, CastMidiPortState) { |
17 // Check if static_cast of ToMIDIPortState() just works fine for all states. | 18 // Check if static_cast of ToMIDIPortState() just works fine for all states. |
18 EXPECT_EQ( | 19 EXPECT_EQ(PortState::DISCONNECTED, |
19 BlinkState::MIDIPortStateDisconnected, | 20 MidiMessageFilter::ToBlinkState(PortState::DISCONNECTED)); |
20 MidiMessageFilter::ToBlinkState(midi::MIDI_PORT_DISCONNECTED)); | 21 EXPECT_EQ(PortState::CONNECTED, |
21 EXPECT_EQ(BlinkState::MIDIPortStateConnected, | 22 MidiMessageFilter::ToBlinkState(PortState::CONNECTED)); |
22 MidiMessageFilter::ToBlinkState(midi::MIDI_PORT_CONNECTED)); | |
23 // Web MIDI API manages DeviceState and ConnectionState separately. | 23 // Web MIDI API manages DeviceState and ConnectionState separately. |
24 // "open", "pending", or "closed" are managed separately for ConnectionState | 24 // "open", "pending", or "closed" are managed separately for ConnectionState |
25 // by Blink per MIDIAccess instance. So, MIDI_PORT_OPENED in content can be | 25 // by Blink per MIDIAccess instance. So, MIDI_PORT_OPENED in content can be |
26 // converted to MIDIPortStateConnected. | 26 // converted to MIDIPortStateConnected. |
27 EXPECT_EQ(BlinkState::MIDIPortStateConnected, | 27 EXPECT_EQ(PortState::CONNECTED, |
28 MidiMessageFilter::ToBlinkState(midi::MIDI_PORT_OPENED)); | 28 MidiMessageFilter::ToBlinkState(PortState::OPENED)); |
29 | 29 |
30 // Check if we do not have any unknown MidiPortState that is added later. | 30 // Check if we do not have any unknown MidiPortState that is added later. |
31 EXPECT_EQ(midi::MIDI_PORT_OPENED, midi::MIDI_PORT_STATE_LAST); | 31 EXPECT_EQ(PortState::OPENED, PortState::LAST); |
32 } | 32 } |
33 | 33 |
| 34 } // namespace |
| 35 |
34 } // namespace content | 36 } // namespace content |
OLD | NEW |