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

Side by Side Diff: media/midi/midi_message_util_unittest.cc

Issue 2431393002: Web MIDI: move MIDI message validating logic into message_util.{cc|h} (Closed)
Patch Set: build fix 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
« no previous file with comments | « media/midi/midi_message_util.cc ('k') | media/midi/usb_midi_output_stream.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 "media/midi/midi_message_util.h"
6
7 #include <stdint.h>
8
9 #include "base/macros.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11
12 namespace midi {
13 namespace {
14
15 const uint8_t kGMOn[] = {0xf0, 0x7e, 0x7f, 0x09, 0x01, 0xf7};
16 const uint8_t kNoteOn[] = {0x90, 0x3c, 0x7f};
17 const uint8_t kSystemCommonMessageReserved1[] = {0xf4};
18 const uint8_t kSystemCommonMessageReserved2[] = {0xf5};
19 const uint8_t kSystemCommonMessageTuneRequest[] = {0xf6};
20 const uint8_t kChannelPressure[] = {0xd0, 0x01};
21 const uint8_t kTimingClock[] = {0xf8};
22
23 TEST(MidiMessageUtilTest, GetMidiMessageLength) {
24 // Check basic functionarity
25 EXPECT_EQ(arraysize(kNoteOn), GetMidiMessageLength(kNoteOn[0]));
26 EXPECT_EQ(arraysize(kChannelPressure),
27 GetMidiMessageLength(kChannelPressure[0]));
28 EXPECT_EQ(arraysize(kTimingClock), GetMidiMessageLength(kTimingClock[0]));
29 EXPECT_EQ(arraysize(kSystemCommonMessageTuneRequest),
30 GetMidiMessageLength(kSystemCommonMessageTuneRequest[0]));
31
32 // SysEx message should be mapped to 0-length
33 EXPECT_EQ(0u, GetMidiMessageLength(kGMOn[0]));
34
35 // Any reserved message should be mapped to 0-length
36 EXPECT_EQ(0u, GetMidiMessageLength(kSystemCommonMessageReserved1[0]));
37 EXPECT_EQ(0u, GetMidiMessageLength(kSystemCommonMessageReserved2[0]));
38
39 // Any data byte should be mapped to 0-length
40 EXPECT_EQ(0u, GetMidiMessageLength(kGMOn[1]));
41 EXPECT_EQ(0u, GetMidiMessageLength(kNoteOn[1]));
42 EXPECT_EQ(0u, GetMidiMessageLength(kChannelPressure[1]));
43 }
44
45 } // namespace
46 } // namespace midi
OLDNEW
« no previous file with comments | « media/midi/midi_message_util.cc ('k') | media/midi/usb_midi_output_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698