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

Side by Side Diff: content/browser/renderer_host/media/midi_host_unittest.cc

Issue 151343002: Web MIDI: make naming convention be consistent (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review boliu #2 Created 6 years, 10 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 | Annotate | Revision Log
OLDNEW
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/renderer_host/media/midi_host.h" 5 #include "content/browser/renderer_host/media/midi_host.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 namespace content { 9 namespace content {
10 namespace { 10 namespace {
(...skipping 23 matching lines...) Expand all
34 return buffer; 34 return buffer;
35 } 35 }
36 36
37 template <typename T, size_t N> 37 template <typename T, size_t N>
38 void PushToVector(const T(&data)[N], std::vector<T>* buffer) { 38 void PushToVector(const T(&data)[N], std::vector<T>* buffer) {
39 buffer->insert(buffer->end(), data, data + N); 39 buffer->insert(buffer->end(), data, data + N);
40 } 40 }
41 41
42 } // namespace 42 } // namespace
43 43
44 TEST(MIDIHostTest, IsValidWebMIDIData) { 44 TEST(MidiHostTest, IsValidWebMIDIData) {
45 // Test single event scenario 45 // Test single event scenario
46 EXPECT_TRUE(MIDIHost::IsValidWebMIDIData(AsVector(kGMOn))); 46 EXPECT_TRUE(MidiHost::IsValidWebMIDIData(AsVector(kGMOn)));
47 EXPECT_TRUE(MIDIHost::IsValidWebMIDIData(AsVector(kGSOn))); 47 EXPECT_TRUE(MidiHost::IsValidWebMIDIData(AsVector(kGSOn)));
48 EXPECT_TRUE(MIDIHost::IsValidWebMIDIData(AsVector(kNoteOn))); 48 EXPECT_TRUE(MidiHost::IsValidWebMIDIData(AsVector(kNoteOn)));
49 EXPECT_TRUE(MIDIHost::IsValidWebMIDIData(AsVector(kChannelPressure))); 49 EXPECT_TRUE(MidiHost::IsValidWebMIDIData(AsVector(kChannelPressure)));
50 EXPECT_TRUE(MIDIHost::IsValidWebMIDIData(AsVector(kTimingClock))); 50 EXPECT_TRUE(MidiHost::IsValidWebMIDIData(AsVector(kTimingClock)));
51 EXPECT_FALSE(MIDIHost::IsValidWebMIDIData(AsVector(kBrokenData1))); 51 EXPECT_FALSE(MidiHost::IsValidWebMIDIData(AsVector(kBrokenData1)));
52 EXPECT_FALSE(MIDIHost::IsValidWebMIDIData(AsVector(kBrokenData2))); 52 EXPECT_FALSE(MidiHost::IsValidWebMIDIData(AsVector(kBrokenData2)));
53 EXPECT_FALSE(MIDIHost::IsValidWebMIDIData(AsVector(kBrokenData3))); 53 EXPECT_FALSE(MidiHost::IsValidWebMIDIData(AsVector(kBrokenData3)));
54 EXPECT_FALSE(MIDIHost::IsValidWebMIDIData(AsVector(kDataByte0))); 54 EXPECT_FALSE(MidiHost::IsValidWebMIDIData(AsVector(kDataByte0)));
55 55
56 // MIDI running status should be disallowed 56 // MIDI running status should be disallowed
57 EXPECT_FALSE(MIDIHost::IsValidWebMIDIData( 57 EXPECT_FALSE(MidiHost::IsValidWebMIDIData(
58 AsVector(kNoteOnWithRunningStatus))); 58 AsVector(kNoteOnWithRunningStatus)));
59 EXPECT_FALSE(MIDIHost::IsValidWebMIDIData( 59 EXPECT_FALSE(MidiHost::IsValidWebMIDIData(
60 AsVector(kChannelPressureWithRunningStatus))); 60 AsVector(kChannelPressureWithRunningStatus)));
61 61
62 // Multiple messages are allowed as long as each of them is complete. 62 // Multiple messages are allowed as long as each of them is complete.
63 { 63 {
64 std::vector<uint8> buffer; 64 std::vector<uint8> buffer;
65 PushToVector(kGMOn, &buffer); 65 PushToVector(kGMOn, &buffer);
66 PushToVector(kNoteOn, &buffer); 66 PushToVector(kNoteOn, &buffer);
67 PushToVector(kGSOn, &buffer); 67 PushToVector(kGSOn, &buffer);
68 PushToVector(kTimingClock, &buffer); 68 PushToVector(kTimingClock, &buffer);
69 PushToVector(kNoteOn, &buffer); 69 PushToVector(kNoteOn, &buffer);
70 EXPECT_TRUE(MIDIHost::IsValidWebMIDIData(buffer)); 70 EXPECT_TRUE(MidiHost::IsValidWebMIDIData(buffer));
71 PushToVector(kBrokenData1, &buffer); 71 PushToVector(kBrokenData1, &buffer);
72 EXPECT_FALSE(MIDIHost::IsValidWebMIDIData(buffer)); 72 EXPECT_FALSE(MidiHost::IsValidWebMIDIData(buffer));
73 } 73 }
74 74
75 // MIDI realtime message can be placed at any position. 75 // MIDI realtime message can be placed at any position.
76 { 76 {
77 const uint8 kNoteOnWithRealTimeClock[] = { 77 const uint8 kNoteOnWithRealTimeClock[] = {
78 0x90, 0xf8, 0x3c, 0x7f, 0x90, 0xf8, 0x3c, 0xf8, 0x7f, 0xf8, 78 0x90, 0xf8, 0x3c, 0x7f, 0x90, 0xf8, 0x3c, 0xf8, 0x7f, 0xf8,
79 }; 79 };
80 EXPECT_TRUE(MIDIHost::IsValidWebMIDIData( 80 EXPECT_TRUE(MidiHost::IsValidWebMIDIData(
81 AsVector(kNoteOnWithRealTimeClock))); 81 AsVector(kNoteOnWithRealTimeClock)));
82 82
83 const uint8 kGMOnWithRealTimeClock[] = { 83 const uint8 kGMOnWithRealTimeClock[] = {
84 0xf0, 0xf8, 0x7e, 0x7f, 0x09, 0x01, 0xf8, 0xf7, 84 0xf0, 0xf8, 0x7e, 0x7f, 0x09, 0x01, 0xf8, 0xf7,
85 }; 85 };
86 EXPECT_TRUE(MIDIHost::IsValidWebMIDIData(AsVector(kGMOnWithRealTimeClock))); 86 EXPECT_TRUE(MidiHost::IsValidWebMIDIData(
87 AsVector(kGMOnWithRealTimeClock)));
87 } 88 }
88 } 89 }
89 90
90 } // namespace conent 91 } // namespace conent
OLDNEW
« no previous file with comments | « content/browser/renderer_host/media/midi_host.cc ('k') | content/browser/renderer_host/render_process_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698