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

Unified Diff: content/browser/renderer_host/media/midi_host_unittest.cc

Issue 335993002: Convert MIDI permission requests to use WebContents in preparation for switching the code to using … (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/media/midi_host_unittest.cc
diff --git a/content/browser/renderer_host/media/midi_host_unittest.cc b/content/browser/renderer_host/media/midi_host_unittest.cc
deleted file mode 100644
index fe365ddbdb06cd16bccc6de9a62fe3c3dc9fe24a..0000000000000000000000000000000000000000
--- a/content/browser/renderer_host/media/midi_host_unittest.cc
+++ /dev/null
@@ -1,91 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "content/browser/renderer_host/media/midi_host.h"
-
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace content {
-namespace {
-
-const uint8 kGMOn[] = { 0xf0, 0x7e, 0x7f, 0x09, 0x01, 0xf7 };
-const uint8 kGSOn[] = {
- 0xf0, 0x41, 0x10, 0x42, 0x12, 0x40, 0x00, 0x7f, 0x00, 0x41, 0xf7,
-};
-const uint8 kNoteOn[] = { 0x90, 0x3c, 0x7f };
-const uint8 kNoteOnWithRunningStatus[] = {
- 0x90, 0x3c, 0x7f, 0x3c, 0x7f, 0x3c, 0x7f,
-};
-const uint8 kChannelPressure[] = { 0xd0, 0x01 };
-const uint8 kChannelPressureWithRunningStatus[] = {
- 0xd0, 0x01, 0x01, 0x01,
-};
-const uint8 kTimingClock[] = { 0xf8 };
-const uint8 kBrokenData1[] = { 0x90 };
-const uint8 kBrokenData2[] = { 0xf7 };
-const uint8 kBrokenData3[] = { 0xf2, 0x00 };
-const uint8 kDataByte0[] = { 0x00 };
-
-template <typename T, size_t N>
-const std::vector<T> AsVector(const T(&data)[N]) {
- std::vector<T> buffer;
- buffer.insert(buffer.end(), data, data + N);
- return buffer;
-}
-
-template <typename T, size_t N>
-void PushToVector(const T(&data)[N], std::vector<T>* buffer) {
- buffer->insert(buffer->end(), data, data + N);
-}
-
-} // namespace
-
-TEST(MidiHostTest, IsValidWebMIDIData) {
- // Test single event scenario
- EXPECT_TRUE(MidiHost::IsValidWebMIDIData(AsVector(kGMOn)));
- EXPECT_TRUE(MidiHost::IsValidWebMIDIData(AsVector(kGSOn)));
- EXPECT_TRUE(MidiHost::IsValidWebMIDIData(AsVector(kNoteOn)));
- EXPECT_TRUE(MidiHost::IsValidWebMIDIData(AsVector(kChannelPressure)));
- EXPECT_TRUE(MidiHost::IsValidWebMIDIData(AsVector(kTimingClock)));
- EXPECT_FALSE(MidiHost::IsValidWebMIDIData(AsVector(kBrokenData1)));
- EXPECT_FALSE(MidiHost::IsValidWebMIDIData(AsVector(kBrokenData2)));
- EXPECT_FALSE(MidiHost::IsValidWebMIDIData(AsVector(kBrokenData3)));
- EXPECT_FALSE(MidiHost::IsValidWebMIDIData(AsVector(kDataByte0)));
-
- // MIDI running status should be disallowed
- EXPECT_FALSE(MidiHost::IsValidWebMIDIData(
- AsVector(kNoteOnWithRunningStatus)));
- EXPECT_FALSE(MidiHost::IsValidWebMIDIData(
- AsVector(kChannelPressureWithRunningStatus)));
-
- // Multiple messages are allowed as long as each of them is complete.
- {
- std::vector<uint8> buffer;
- PushToVector(kGMOn, &buffer);
- PushToVector(kNoteOn, &buffer);
- PushToVector(kGSOn, &buffer);
- PushToVector(kTimingClock, &buffer);
- PushToVector(kNoteOn, &buffer);
- EXPECT_TRUE(MidiHost::IsValidWebMIDIData(buffer));
- PushToVector(kBrokenData1, &buffer);
- EXPECT_FALSE(MidiHost::IsValidWebMIDIData(buffer));
- }
-
- // MIDI realtime message can be placed at any position.
- {
- const uint8 kNoteOnWithRealTimeClock[] = {
- 0x90, 0xf8, 0x3c, 0x7f, 0x90, 0xf8, 0x3c, 0xf8, 0x7f, 0xf8,
- };
- EXPECT_TRUE(MidiHost::IsValidWebMIDIData(
- AsVector(kNoteOnWithRealTimeClock)));
-
- const uint8 kGMOnWithRealTimeClock[] = {
- 0xf0, 0xf8, 0x7e, 0x7f, 0x09, 0x01, 0xf8, 0xf7,
- };
- EXPECT_TRUE(MidiHost::IsValidWebMIDIData(
- AsVector(kGMOnWithRealTimeClock)));
- }
-}
-
-} // namespace conent
« 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