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

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

Issue 1534273002: Switch to standard integer types in media/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more Created 5 years 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
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 "media/midi/midi_message_queue.h" 5 #include "media/midi/midi_message_queue.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 namespace media { 9 namespace media {
10 namespace midi { 10 namespace midi {
11 namespace { 11 namespace {
12 12
13 const uint8 kGMOn[] = { 0xf0, 0x7e, 0x7f, 0x09, 0x01, 0xf7 }; 13 const uint8_t kGMOn[] = {0xf0, 0x7e, 0x7f, 0x09, 0x01, 0xf7};
14 const uint8 kPartialGMOn1st[] = { 0xf0 }; 14 const uint8_t kPartialGMOn1st[] = {0xf0};
15 const uint8 kPartialGMOn2nd[] = { 0x7e, 0x7f, 0x09, 0x01 }; 15 const uint8_t kPartialGMOn2nd[] = {0x7e, 0x7f, 0x09, 0x01};
16 const uint8 kPartialGMOn3rd[] = { 0xf7 }; 16 const uint8_t kPartialGMOn3rd[] = {0xf7};
17 const uint8 kGSOn[] = { 17 const uint8_t kGSOn[] = {
18 0xf0, 0x41, 0x10, 0x42, 0x12, 0x40, 0x00, 0x7f, 0x00, 0x41, 0xf7, 18 0xf0, 0x41, 0x10, 0x42, 0x12, 0x40, 0x00, 0x7f, 0x00, 0x41, 0xf7,
19 }; 19 };
20 const uint8 kNoteOn[] = { 0x90, 0x3c, 0x7f }; 20 const uint8_t kNoteOn[] = {0x90, 0x3c, 0x7f};
21 const uint8 kPartialNoteOn1st[] = { 0x90 }; 21 const uint8_t kPartialNoteOn1st[] = {0x90};
22 const uint8 kPartialNoteOn2nd[] = { 0x3c }; 22 const uint8_t kPartialNoteOn2nd[] = {0x3c};
23 const uint8 kPartialNoteOn3rd[] = { 0x7f }; 23 const uint8_t kPartialNoteOn3rd[] = {0x7f};
24 24
25 const uint8 kNoteOnWithRunningStatus[] = { 25 const uint8_t kNoteOnWithRunningStatus[] = {
26 0x90, 0x3c, 0x7f, 0x3c, 0x7f, 0x3c, 0x7f, 26 0x90, 0x3c, 0x7f, 0x3c, 0x7f, 0x3c, 0x7f,
27 }; 27 };
28 const uint8 kChannelPressure[] = { 0xd0, 0x01 }; 28 const uint8_t kChannelPressure[] = {0xd0, 0x01};
29 const uint8 kChannelPressureWithRunningStatus[] = { 29 const uint8_t kChannelPressureWithRunningStatus[] = {
30 0xd0, 0x01, 0x01, 0x01, 30 0xd0, 0x01, 0x01, 0x01,
31 }; 31 };
32 const uint8 kTimingClock[] = { 0xf8 }; 32 const uint8_t kTimingClock[] = {0xf8};
33 const uint8 kSystemCommonMessageTuneRequest[] = { 0xf6 }; 33 const uint8_t kSystemCommonMessageTuneRequest[] = {0xf6};
34 const uint8 kMTCFrame[] = { 0xf1, 0x00 }; 34 const uint8_t kMTCFrame[] = {0xf1, 0x00};
35 const uint8 kBrokenData1[] = { 0x92 }; 35 const uint8_t kBrokenData1[] = {0x92};
36 const uint8 kBrokenData2[] = { 0xf7 }; 36 const uint8_t kBrokenData2[] = {0xf7};
37 const uint8 kBrokenData3[] = { 0xf2, 0x00 }; 37 const uint8_t kBrokenData3[] = {0xf2, 0x00};
38 const uint8 kDataByte0[] = { 0x00 }; 38 const uint8_t kDataByte0[] = {0x00};
39 39
40 const uint8 kReservedMessage1[] = { 0xf4 }; 40 const uint8_t kReservedMessage1[] = {0xf4};
41 const uint8 kReservedMessage2[] = { 0xf5 }; 41 const uint8_t kReservedMessage2[] = {0xf5};
42 const uint8 kReservedMessage1WithDataBytes[] = { 42 const uint8_t kReservedMessage1WithDataBytes[] = {0xf4, 0x01, 0x01,
43 0xf4, 0x01, 0x01, 0x01, 0x01, 0x01 43 0x01, 0x01, 0x01};
44 };
45 44
46 template <typename T, size_t N> 45 template <typename T, size_t N>
47 void Add(MidiMessageQueue* queue, const T(&array)[N]) { 46 void Add(MidiMessageQueue* queue, const T(&array)[N]) {
48 queue->Add(array, N); 47 queue->Add(array, N);
49 } 48 }
50 49
51 template <typename T, size_t N> 50 template <typename T, size_t N>
52 ::testing::AssertionResult ExpectEqualSequence( 51 ::testing::AssertionResult ExpectEqualSequence(
53 const char* expr1, const char* expr2, 52 const char* expr1, const char* expr2,
54 const T(&expected)[N], const std::vector<T>& actual) { 53 const T(&expected)[N], const std::vector<T>& actual) {
(...skipping 10 matching lines...) Expand all
65 } 64 }
66 } 65 }
67 return ::testing::AssertionSuccess(); 66 return ::testing::AssertionSuccess();
68 } 67 }
69 68
70 #define EXPECT_MESSAGE(expected, actual) \ 69 #define EXPECT_MESSAGE(expected, actual) \
71 EXPECT_PRED_FORMAT2(ExpectEqualSequence, expected, actual) 70 EXPECT_PRED_FORMAT2(ExpectEqualSequence, expected, actual)
72 71
73 TEST(MidiMessageQueueTest, EmptyData) { 72 TEST(MidiMessageQueueTest, EmptyData) {
74 MidiMessageQueue queue(false); 73 MidiMessageQueue queue(false);
75 std::vector<uint8> message; 74 std::vector<uint8_t> message;
76 queue.Get(&message); 75 queue.Get(&message);
77 EXPECT_TRUE(message.empty()); 76 EXPECT_TRUE(message.empty());
78 } 77 }
79 78
80 TEST(MidiMessageQueueTest, RunningStatusDisabled) { 79 TEST(MidiMessageQueueTest, RunningStatusDisabled) {
81 MidiMessageQueue queue(false); 80 MidiMessageQueue queue(false);
82 Add(&queue, kGMOn); 81 Add(&queue, kGMOn);
83 Add(&queue, kBrokenData1); 82 Add(&queue, kBrokenData1);
84 Add(&queue, kNoteOnWithRunningStatus); 83 Add(&queue, kNoteOnWithRunningStatus);
85 Add(&queue, kBrokenData2); 84 Add(&queue, kBrokenData2);
86 Add(&queue, kChannelPressureWithRunningStatus); 85 Add(&queue, kChannelPressureWithRunningStatus);
87 Add(&queue, kBrokenData3); 86 Add(&queue, kBrokenData3);
88 Add(&queue, kNoteOn); 87 Add(&queue, kNoteOn);
89 Add(&queue, kBrokenData1); 88 Add(&queue, kBrokenData1);
90 Add(&queue, kGSOn); 89 Add(&queue, kGSOn);
91 Add(&queue, kBrokenData2); 90 Add(&queue, kBrokenData2);
92 Add(&queue, kTimingClock); 91 Add(&queue, kTimingClock);
93 Add(&queue, kBrokenData3); 92 Add(&queue, kBrokenData3);
94 93
95 std::vector<uint8> message; 94 std::vector<uint8_t> message;
96 queue.Get(&message); 95 queue.Get(&message);
97 EXPECT_MESSAGE(kGMOn, message); 96 EXPECT_MESSAGE(kGMOn, message);
98 queue.Get(&message); 97 queue.Get(&message);
99 EXPECT_MESSAGE(kNoteOn, message) << "Running status should be ignored"; 98 EXPECT_MESSAGE(kNoteOn, message) << "Running status should be ignored";
100 queue.Get(&message); 99 queue.Get(&message);
101 EXPECT_MESSAGE(kChannelPressure, message) 100 EXPECT_MESSAGE(kChannelPressure, message)
102 << "Running status should be ignored"; 101 << "Running status should be ignored";
103 queue.Get(&message); 102 queue.Get(&message);
104 EXPECT_MESSAGE(kNoteOn, message); 103 EXPECT_MESSAGE(kNoteOn, message);
105 queue.Get(&message); 104 queue.Get(&message);
(...skipping 12 matching lines...) Expand all
118 Add(&queue, kBrokenData2); 117 Add(&queue, kBrokenData2);
119 Add(&queue, kChannelPressureWithRunningStatus); 118 Add(&queue, kChannelPressureWithRunningStatus);
120 Add(&queue, kBrokenData3); 119 Add(&queue, kBrokenData3);
121 Add(&queue, kNoteOn); 120 Add(&queue, kNoteOn);
122 Add(&queue, kBrokenData1); 121 Add(&queue, kBrokenData1);
123 Add(&queue, kGSOn); 122 Add(&queue, kGSOn);
124 Add(&queue, kBrokenData2); 123 Add(&queue, kBrokenData2);
125 Add(&queue, kTimingClock); 124 Add(&queue, kTimingClock);
126 Add(&queue, kDataByte0); 125 Add(&queue, kDataByte0);
127 126
128 std::vector<uint8> message; 127 std::vector<uint8_t> message;
129 queue.Get(&message); 128 queue.Get(&message);
130 EXPECT_MESSAGE(kGMOn, message); 129 EXPECT_MESSAGE(kGMOn, message);
131 queue.Get(&message); 130 queue.Get(&message);
132 EXPECT_MESSAGE(kNoteOn, message); 131 EXPECT_MESSAGE(kNoteOn, message);
133 queue.Get(&message); 132 queue.Get(&message);
134 EXPECT_MESSAGE(kNoteOn, message) 133 EXPECT_MESSAGE(kNoteOn, message)
135 << "Running status should be converted into a canonical MIDI message"; 134 << "Running status should be converted into a canonical MIDI message";
136 queue.Get(&message); 135 queue.Get(&message);
137 EXPECT_MESSAGE(kNoteOn, message) 136 EXPECT_MESSAGE(kNoteOn, message)
138 << "Running status should be converted into a canonical MIDI message"; 137 << "Running status should be converted into a canonical MIDI message";
(...skipping 11 matching lines...) Expand all
150 EXPECT_MESSAGE(kGSOn, message); 149 EXPECT_MESSAGE(kGSOn, message);
151 queue.Get(&message); 150 queue.Get(&message);
152 EXPECT_MESSAGE(kTimingClock, message); 151 EXPECT_MESSAGE(kTimingClock, message);
153 queue.Get(&message); 152 queue.Get(&message);
154 EXPECT_TRUE(message.empty()) 153 EXPECT_TRUE(message.empty())
155 << "Running status must not be applied to real time messages"; 154 << "Running status must not be applied to real time messages";
156 } 155 }
157 156
158 TEST(MidiMessageQueueTest, RunningStatusEnabledWithRealTimeEvent) { 157 TEST(MidiMessageQueueTest, RunningStatusEnabledWithRealTimeEvent) {
159 MidiMessageQueue queue(true); 158 MidiMessageQueue queue(true);
160 const uint8 kNoteOnWithRunningStatusWithTimingClock[] = { 159 const uint8_t kNoteOnWithRunningStatusWithTimingClock[] = {
161 0x90, 0xf8, 0x3c, 0xf8, 0x7f, 0xf8, 0x3c, 0xf8, 0x7f, 0xf8, 0x3c, 0xf8, 160 0x90, 0xf8, 0x3c, 0xf8, 0x7f, 0xf8, 0x3c,
162 0x7f, 161 0xf8, 0x7f, 0xf8, 0x3c, 0xf8, 0x7f,
163 }; 162 };
164 Add(&queue, kNoteOnWithRunningStatusWithTimingClock); 163 Add(&queue, kNoteOnWithRunningStatusWithTimingClock);
165 std::vector<uint8> message; 164 std::vector<uint8_t> message;
166 queue.Get(&message); 165 queue.Get(&message);
167 EXPECT_MESSAGE(kTimingClock, message); 166 EXPECT_MESSAGE(kTimingClock, message);
168 queue.Get(&message); 167 queue.Get(&message);
169 EXPECT_MESSAGE(kTimingClock, message); 168 EXPECT_MESSAGE(kTimingClock, message);
170 queue.Get(&message); 169 queue.Get(&message);
171 EXPECT_MESSAGE(kNoteOn, message); 170 EXPECT_MESSAGE(kNoteOn, message);
172 queue.Get(&message); 171 queue.Get(&message);
173 EXPECT_MESSAGE(kTimingClock, message); 172 EXPECT_MESSAGE(kTimingClock, message);
174 queue.Get(&message); 173 queue.Get(&message);
175 EXPECT_MESSAGE(kTimingClock, message); 174 EXPECT_MESSAGE(kTimingClock, message);
176 queue.Get(&message); 175 queue.Get(&message);
177 EXPECT_MESSAGE(kNoteOn, message); 176 EXPECT_MESSAGE(kNoteOn, message);
178 queue.Get(&message); 177 queue.Get(&message);
179 EXPECT_MESSAGE(kTimingClock, message); 178 EXPECT_MESSAGE(kTimingClock, message);
180 queue.Get(&message); 179 queue.Get(&message);
181 EXPECT_MESSAGE(kTimingClock, message); 180 EXPECT_MESSAGE(kTimingClock, message);
182 queue.Get(&message); 181 queue.Get(&message);
183 EXPECT_MESSAGE(kNoteOn, message); 182 EXPECT_MESSAGE(kNoteOn, message);
184 queue.Get(&message); 183 queue.Get(&message);
185 EXPECT_TRUE(message.empty()); 184 EXPECT_TRUE(message.empty());
186 } 185 }
187 186
188 TEST(MidiMessageQueueTest, RunningStatusEnabledWithSystemCommonMessage) { 187 TEST(MidiMessageQueueTest, RunningStatusEnabledWithSystemCommonMessage) {
189 MidiMessageQueue queue(true); 188 MidiMessageQueue queue(true);
190 const uint8 kNoteOnWithRunningStatusWithSystemCommonMessage[] = { 189 const uint8_t kNoteOnWithRunningStatusWithSystemCommonMessage[] = {
191 0x90, 0x3c, 0x7f, 0xf1, 0x00, 0x3c, 0x7f, 0xf8, 0x90, 0x3c, 0x7f, 190 0x90, 0x3c, 0x7f, 0xf1, 0x00, 0x3c, 0x7f, 0xf8, 0x90, 0x3c, 0x7f,
192 }; 191 };
193 Add(&queue, kNoteOnWithRunningStatusWithSystemCommonMessage); 192 Add(&queue, kNoteOnWithRunningStatusWithSystemCommonMessage);
194 std::vector<uint8> message; 193 std::vector<uint8_t> message;
195 queue.Get(&message); 194 queue.Get(&message);
196 EXPECT_MESSAGE(kNoteOn, message); 195 EXPECT_MESSAGE(kNoteOn, message);
197 queue.Get(&message); 196 queue.Get(&message);
198 EXPECT_MESSAGE(kMTCFrame, message); 197 EXPECT_MESSAGE(kMTCFrame, message);
199 queue.Get(&message); 198 queue.Get(&message);
200 EXPECT_MESSAGE(kTimingClock, message) << "Running status should be reset"; 199 EXPECT_MESSAGE(kTimingClock, message) << "Running status should be reset";
201 queue.Get(&message); 200 queue.Get(&message);
202 EXPECT_MESSAGE(kNoteOn, message); 201 EXPECT_MESSAGE(kNoteOn, message);
203 queue.Get(&message); 202 queue.Get(&message);
204 EXPECT_TRUE(message.empty()); 203 EXPECT_TRUE(message.empty());
205 } 204 }
206 205
207 TEST(MidiMessageQueueTest, Issue540016) { 206 TEST(MidiMessageQueueTest, Issue540016) {
208 const uint8 kData[] = { 0xf4, 0x3a }; 207 const uint8_t kData[] = {0xf4, 0x3a};
209 MidiMessageQueue queue(false); 208 MidiMessageQueue queue(false);
210 Add(&queue, kData); 209 Add(&queue, kData);
211 std::vector<uint8> message; 210 std::vector<uint8_t> message;
212 queue.Get(&message); 211 queue.Get(&message);
213 EXPECT_TRUE(message.empty()); 212 EXPECT_TRUE(message.empty());
214 } 213 }
215 214
216 TEST(MidiMessageQueueTest, ReconstructNonSysExMessage) { 215 TEST(MidiMessageQueueTest, ReconstructNonSysExMessage) {
217 MidiMessageQueue queue(true); 216 MidiMessageQueue queue(true);
218 std::vector<uint8> message; 217 std::vector<uint8_t> message;
219 218
220 Add(&queue, kPartialNoteOn1st); 219 Add(&queue, kPartialNoteOn1st);
221 queue.Get(&message); 220 queue.Get(&message);
222 EXPECT_TRUE(message.empty()); 221 EXPECT_TRUE(message.empty());
223 222
224 Add(&queue, kPartialNoteOn2nd); 223 Add(&queue, kPartialNoteOn2nd);
225 queue.Get(&message); 224 queue.Get(&message);
226 EXPECT_TRUE(message.empty()); 225 EXPECT_TRUE(message.empty());
227 226
228 Add(&queue, kPartialNoteOn3rd); 227 Add(&queue, kPartialNoteOn3rd);
229 queue.Get(&message); 228 queue.Get(&message);
230 EXPECT_MESSAGE(kNoteOn, message); 229 EXPECT_MESSAGE(kNoteOn, message);
231 230
232 queue.Get(&message); 231 queue.Get(&message);
233 EXPECT_TRUE(message.empty()); 232 EXPECT_TRUE(message.empty());
234 } 233 }
235 234
236 TEST(MidiMessageQueueTest, ReconstructBrokenNonSysExMessage) { 235 TEST(MidiMessageQueueTest, ReconstructBrokenNonSysExMessage) {
237 MidiMessageQueue queue(true); 236 MidiMessageQueue queue(true);
238 std::vector<uint8> message; 237 std::vector<uint8_t> message;
239 238
240 Add(&queue, kPartialNoteOn1st); 239 Add(&queue, kPartialNoteOn1st);
241 queue.Get(&message); 240 queue.Get(&message);
242 EXPECT_TRUE(message.empty()); 241 EXPECT_TRUE(message.empty());
243 242
244 Add(&queue, kPartialNoteOn2nd); 243 Add(&queue, kPartialNoteOn2nd);
245 queue.Get(&message); 244 queue.Get(&message);
246 EXPECT_TRUE(message.empty()); 245 EXPECT_TRUE(message.empty());
247 246
248 Add(&queue, kPartialGMOn1st); 247 Add(&queue, kPartialGMOn1st);
249 queue.Get(&message); 248 queue.Get(&message);
250 EXPECT_TRUE(message.empty()); 249 EXPECT_TRUE(message.empty());
251 250
252 Add(&queue, kPartialNoteOn3rd); 251 Add(&queue, kPartialNoteOn3rd);
253 queue.Get(&message); 252 queue.Get(&message);
254 EXPECT_TRUE(message.empty()); 253 EXPECT_TRUE(message.empty());
255 } 254 }
256 255
257 TEST(MidiMessageQueueTest, ReconstructSysExMessage) { 256 TEST(MidiMessageQueueTest, ReconstructSysExMessage) {
258 MidiMessageQueue queue(true); 257 MidiMessageQueue queue(true);
259 std::vector<uint8> message; 258 std::vector<uint8_t> message;
260 259
261 Add(&queue, kPartialGMOn1st); 260 Add(&queue, kPartialGMOn1st);
262 queue.Get(&message); 261 queue.Get(&message);
263 EXPECT_TRUE(message.empty()); 262 EXPECT_TRUE(message.empty());
264 263
265 Add(&queue, kPartialGMOn2nd); 264 Add(&queue, kPartialGMOn2nd);
266 queue.Get(&message); 265 queue.Get(&message);
267 EXPECT_TRUE(message.empty()); 266 EXPECT_TRUE(message.empty());
268 267
269 Add(&queue, kPartialGMOn3rd); 268 Add(&queue, kPartialGMOn3rd);
270 queue.Get(&message); 269 queue.Get(&message);
271 EXPECT_MESSAGE(kGMOn, message); 270 EXPECT_MESSAGE(kGMOn, message);
272 271
273 queue.Get(&message); 272 queue.Get(&message);
274 EXPECT_TRUE(message.empty()); 273 EXPECT_TRUE(message.empty());
275 } 274 }
276 275
277 TEST(MidiMessageQueueTest, ReconstructBrokenSysExMessage) { 276 TEST(MidiMessageQueueTest, ReconstructBrokenSysExMessage) {
278 MidiMessageQueue queue(true); 277 MidiMessageQueue queue(true);
279 std::vector<uint8> message; 278 std::vector<uint8_t> message;
280 279
281 Add(&queue, kPartialGMOn1st); 280 Add(&queue, kPartialGMOn1st);
282 queue.Get(&message); 281 queue.Get(&message);
283 EXPECT_TRUE(message.empty()); 282 EXPECT_TRUE(message.empty());
284 283
285 Add(&queue, kPartialGMOn2nd); 284 Add(&queue, kPartialGMOn2nd);
286 queue.Get(&message); 285 queue.Get(&message);
287 EXPECT_TRUE(message.empty()); 286 EXPECT_TRUE(message.empty());
288 287
289 Add(&queue, kPartialNoteOn1st); 288 Add(&queue, kPartialNoteOn1st);
290 queue.Get(&message); 289 queue.Get(&message);
291 EXPECT_TRUE(message.empty()); 290 EXPECT_TRUE(message.empty());
292 291
293 Add(&queue, kPartialGMOn3rd); 292 Add(&queue, kPartialGMOn3rd);
294 queue.Get(&message); 293 queue.Get(&message);
295 EXPECT_TRUE(message.empty()); 294 EXPECT_TRUE(message.empty());
296 295
297 queue.Get(&message); 296 queue.Get(&message);
298 EXPECT_TRUE(message.empty()); 297 EXPECT_TRUE(message.empty());
299 } 298 }
300 299
301 TEST(MidiMessageQueueTest, OneByteMessage) { 300 TEST(MidiMessageQueueTest, OneByteMessage) {
302 MidiMessageQueue queue(true); 301 MidiMessageQueue queue(true);
303 std::vector<uint8> message; 302 std::vector<uint8_t> message;
304 303
305 Add(&queue, kSystemCommonMessageTuneRequest); 304 Add(&queue, kSystemCommonMessageTuneRequest);
306 Add(&queue, kSystemCommonMessageTuneRequest); 305 Add(&queue, kSystemCommonMessageTuneRequest);
307 Add(&queue, kSystemCommonMessageTuneRequest); 306 Add(&queue, kSystemCommonMessageTuneRequest);
308 Add(&queue, kSystemCommonMessageTuneRequest); 307 Add(&queue, kSystemCommonMessageTuneRequest);
309 Add(&queue, kNoteOn); 308 Add(&queue, kNoteOn);
310 Add(&queue, kSystemCommonMessageTuneRequest); 309 Add(&queue, kSystemCommonMessageTuneRequest);
311 Add(&queue, kNoteOn); 310 Add(&queue, kNoteOn);
312 Add(&queue, kNoteOn); 311 Add(&queue, kNoteOn);
313 Add(&queue, kSystemCommonMessageTuneRequest); 312 Add(&queue, kSystemCommonMessageTuneRequest);
(...skipping 15 matching lines...) Expand all
329 queue.Get(&message); 328 queue.Get(&message);
330 EXPECT_MESSAGE(kNoteOn, message); 329 EXPECT_MESSAGE(kNoteOn, message);
331 queue.Get(&message); 330 queue.Get(&message);
332 EXPECT_MESSAGE(kSystemCommonMessageTuneRequest, message); 331 EXPECT_MESSAGE(kSystemCommonMessageTuneRequest, message);
333 queue.Get(&message); 332 queue.Get(&message);
334 EXPECT_TRUE(message.empty()); 333 EXPECT_TRUE(message.empty());
335 } 334 }
336 335
337 TEST(MidiMessageQueueTest, OneByteMessageInjectedInNonSysExMessage) { 336 TEST(MidiMessageQueueTest, OneByteMessageInjectedInNonSysExMessage) {
338 MidiMessageQueue queue(true); 337 MidiMessageQueue queue(true);
339 std::vector<uint8> message; 338 std::vector<uint8_t> message;
340 339
341 Add(&queue, kPartialNoteOn1st); 340 Add(&queue, kPartialNoteOn1st);
342 queue.Get(&message); 341 queue.Get(&message);
343 EXPECT_TRUE(message.empty()); 342 EXPECT_TRUE(message.empty());
344 343
345 Add(&queue, kPartialNoteOn2nd); 344 Add(&queue, kPartialNoteOn2nd);
346 queue.Get(&message); 345 queue.Get(&message);
347 EXPECT_TRUE(message.empty()); 346 EXPECT_TRUE(message.empty());
348 347
349 Add(&queue, kSystemCommonMessageTuneRequest); 348 Add(&queue, kSystemCommonMessageTuneRequest);
350 queue.Get(&message); 349 queue.Get(&message);
351 EXPECT_MESSAGE(kSystemCommonMessageTuneRequest, message); 350 EXPECT_MESSAGE(kSystemCommonMessageTuneRequest, message);
352 351
353 queue.Get(&message); 352 queue.Get(&message);
354 EXPECT_TRUE(message.empty()); 353 EXPECT_TRUE(message.empty());
355 354
356 Add(&queue, kPartialNoteOn3rd); 355 Add(&queue, kPartialNoteOn3rd);
357 queue.Get(&message); 356 queue.Get(&message);
358 EXPECT_TRUE(message.empty()); 357 EXPECT_TRUE(message.empty());
359 } 358 }
360 359
361 TEST(MidiMessageQueueTest, OneByteMessageInjectedInSysExMessage) { 360 TEST(MidiMessageQueueTest, OneByteMessageInjectedInSysExMessage) {
362 MidiMessageQueue queue(true); 361 MidiMessageQueue queue(true);
363 std::vector<uint8> message; 362 std::vector<uint8_t> message;
364 363
365 Add(&queue, kPartialGMOn1st); 364 Add(&queue, kPartialGMOn1st);
366 queue.Get(&message); 365 queue.Get(&message);
367 EXPECT_TRUE(message.empty()); 366 EXPECT_TRUE(message.empty());
368 367
369 Add(&queue, kPartialGMOn2nd); 368 Add(&queue, kPartialGMOn2nd);
370 queue.Get(&message); 369 queue.Get(&message);
371 EXPECT_TRUE(message.empty()); 370 EXPECT_TRUE(message.empty());
372 371
373 Add(&queue, kSystemCommonMessageTuneRequest); 372 Add(&queue, kSystemCommonMessageTuneRequest);
374 queue.Get(&message); 373 queue.Get(&message);
375 EXPECT_MESSAGE(kSystemCommonMessageTuneRequest, message); 374 EXPECT_MESSAGE(kSystemCommonMessageTuneRequest, message);
376 375
377 queue.Get(&message); 376 queue.Get(&message);
378 EXPECT_TRUE(message.empty()); 377 EXPECT_TRUE(message.empty());
379 378
380 Add(&queue, kPartialGMOn3rd); 379 Add(&queue, kPartialGMOn3rd);
381 queue.Get(&message); 380 queue.Get(&message);
382 EXPECT_TRUE(message.empty()); 381 EXPECT_TRUE(message.empty());
383 } 382 }
384 383
385 TEST(MidiMessageQueueTest, ReservedMessage) { 384 TEST(MidiMessageQueueTest, ReservedMessage) {
386 MidiMessageQueue queue(true); 385 MidiMessageQueue queue(true);
387 std::vector<uint8> message; 386 std::vector<uint8_t> message;
388 387
389 Add(&queue, kReservedMessage1); 388 Add(&queue, kReservedMessage1);
390 Add(&queue, kNoteOn); 389 Add(&queue, kNoteOn);
391 Add(&queue, kReservedMessage2); 390 Add(&queue, kReservedMessage2);
392 Add(&queue, kNoteOn); 391 Add(&queue, kNoteOn);
393 Add(&queue, kReservedMessage1WithDataBytes); 392 Add(&queue, kReservedMessage1WithDataBytes);
394 Add(&queue, kNoteOn); 393 Add(&queue, kNoteOn);
395 Add(&queue, kReservedMessage2); 394 Add(&queue, kReservedMessage2);
396 Add(&queue, kReservedMessage1WithDataBytes); 395 Add(&queue, kReservedMessage1WithDataBytes);
397 Add(&queue, kNoteOn); 396 Add(&queue, kNoteOn);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 467
469 Add(&queue, kNoteOn); 468 Add(&queue, kNoteOn);
470 queue.Get(&message); 469 queue.Get(&message);
471 EXPECT_MESSAGE(kNoteOn, message); 470 EXPECT_MESSAGE(kNoteOn, message);
472 queue.Get(&message); 471 queue.Get(&message);
473 EXPECT_TRUE(message.empty()); 472 EXPECT_TRUE(message.empty());
474 } 473 }
475 474
476 TEST(MidiMessageQueueTest, ReservedMessageInjectedInNonSysExMessage) { 475 TEST(MidiMessageQueueTest, ReservedMessageInjectedInNonSysExMessage) {
477 MidiMessageQueue queue(true); 476 MidiMessageQueue queue(true);
478 std::vector<uint8> message; 477 std::vector<uint8_t> message;
479 478
480 // Inject |kReservedMessage1| 479 // Inject |kReservedMessage1|
481 Add(&queue, kPartialNoteOn1st); 480 Add(&queue, kPartialNoteOn1st);
482 queue.Get(&message); 481 queue.Get(&message);
483 EXPECT_TRUE(message.empty()); 482 EXPECT_TRUE(message.empty());
484 Add(&queue, kPartialNoteOn2nd); 483 Add(&queue, kPartialNoteOn2nd);
485 queue.Get(&message); 484 queue.Get(&message);
486 EXPECT_TRUE(message.empty()); 485 EXPECT_TRUE(message.empty());
487 Add(&queue, kReservedMessage1); 486 Add(&queue, kReservedMessage1);
488 queue.Get(&message); 487 queue.Get(&message);
(...skipping 26 matching lines...) Expand all
515 Add(&queue, kReservedMessage1WithDataBytes); 514 Add(&queue, kReservedMessage1WithDataBytes);
516 queue.Get(&message); 515 queue.Get(&message);
517 EXPECT_TRUE(message.empty()); 516 EXPECT_TRUE(message.empty());
518 Add(&queue, kPartialNoteOn3rd); 517 Add(&queue, kPartialNoteOn3rd);
519 queue.Get(&message); 518 queue.Get(&message);
520 EXPECT_TRUE(message.empty()); 519 EXPECT_TRUE(message.empty());
521 } 520 }
522 521
523 TEST(MidiMessageQueueTest, ReservedMessageInjectedInSysExMessage) { 522 TEST(MidiMessageQueueTest, ReservedMessageInjectedInSysExMessage) {
524 MidiMessageQueue queue(true); 523 MidiMessageQueue queue(true);
525 std::vector<uint8> message; 524 std::vector<uint8_t> message;
526 525
527 // Inject |kReservedMessage1| 526 // Inject |kReservedMessage1|
528 Add(&queue, kPartialGMOn1st); 527 Add(&queue, kPartialGMOn1st);
529 queue.Get(&message); 528 queue.Get(&message);
530 EXPECT_TRUE(message.empty()); 529 EXPECT_TRUE(message.empty());
531 Add(&queue, kPartialGMOn2nd); 530 Add(&queue, kPartialGMOn2nd);
532 queue.Get(&message); 531 queue.Get(&message);
533 EXPECT_TRUE(message.empty()); 532 EXPECT_TRUE(message.empty());
534 Add(&queue, kReservedMessage1); 533 Add(&queue, kReservedMessage1);
535 queue.Get(&message); 534 queue.Get(&message);
(...skipping 27 matching lines...) Expand all
563 queue.Get(&message); 562 queue.Get(&message);
564 EXPECT_TRUE(message.empty()); 563 EXPECT_TRUE(message.empty());
565 Add(&queue, kPartialGMOn3rd); 564 Add(&queue, kPartialGMOn3rd);
566 queue.Get(&message); 565 queue.Get(&message);
567 EXPECT_TRUE(message.empty()); 566 EXPECT_TRUE(message.empty());
568 } 567 }
569 568
570 } // namespace 569 } // namespace
571 } // namespace midi 570 } // namespace midi
572 } // namespace media 571 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698