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 "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 namespace content { | 10 namespace content { |
11 | 11 |
12 namespace { | 12 namespace { |
13 using BlinkState = blink::WebMIDIAccessorClient::MIDIPortState; | 13 using BlinkState = blink::WebMIDIAccessorClient::MIDIPortState; |
14 } // namespace | 14 } // namespace |
15 | 15 |
16 TEST(MidiMessageFilterTest, CastMidiPortState) { | 16 TEST(MidiMessageFilterTest, CastMidiPortState) { |
17 // Check if static_cast of ToMIDIPortState() just works fine for all states. | 17 // Check if static_cast of ToMIDIPortState() just works fine for all states. |
18 EXPECT_EQ( | 18 EXPECT_EQ( |
19 BlinkState::MIDIPortStateDisconnected, | 19 BlinkState::MIDIPortStateDisconnected, |
20 MidiMessageFilter::ToBlinkState(media::midi::MIDI_PORT_DISCONNECTED)); | 20 MidiMessageFilter::ToBlinkState(midi::MIDI_PORT_DISCONNECTED)); |
21 EXPECT_EQ(BlinkState::MIDIPortStateConnected, | 21 EXPECT_EQ(BlinkState::MIDIPortStateConnected, |
22 MidiMessageFilter::ToBlinkState(media::midi::MIDI_PORT_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(BlinkState::MIDIPortStateConnected, |
28 MidiMessageFilter::ToBlinkState(media::midi::MIDI_PORT_OPENED)); | 28 MidiMessageFilter::ToBlinkState(midi::MIDI_PORT_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(media::midi::MIDI_PORT_OPENED, media::midi::MIDI_PORT_STATE_LAST); | 31 EXPECT_EQ(midi::MIDI_PORT_OPENED, midi::MIDI_PORT_STATE_LAST); |
32 } | 32 } |
33 | 33 |
34 } // namespace content | 34 } // namespace content |
OLD | NEW |