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

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

Issue 2422163002: Web MIDI: use midi_service.mojom for media::midi::PortState (Closed)
Patch Set: review #16 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
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/media/midi_host.h" 5 #include "content/browser/media/midi_host.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/run_loop.h" 12 #include "base/run_loop.h"
13 #include "base/strings/stringprintf.h" 13 #include "base/strings/stringprintf.h"
14 #include "content/common/media/midi_messages.h" 14 #include "content/common/media/midi_messages.h"
15 #include "content/public/test/test_browser_thread.h" 15 #include "content/public/test/test_browser_thread.h"
16 #include "media/midi/midi_manager.h" 16 #include "media/midi/midi_manager.h"
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 18
19 namespace content { 19 namespace content {
20 namespace { 20 namespace {
21 21
22 using midi::mojom::PortState;
23
22 const uint8_t kGMOn[] = {0xf0, 0x7e, 0x7f, 0x09, 0x01, 0xf7}; 24 const uint8_t kGMOn[] = {0xf0, 0x7e, 0x7f, 0x09, 0x01, 0xf7};
23 const uint8_t kGSOn[] = { 25 const uint8_t kGSOn[] = {
24 0xf0, 0x41, 0x10, 0x42, 0x12, 0x40, 0x00, 0x7f, 0x00, 0x41, 0xf7, 26 0xf0, 0x41, 0x10, 0x42, 0x12, 0x40, 0x00, 0x7f, 0x00, 0x41, 0xf7,
25 }; 27 };
26 const uint8_t kNoteOn[] = {0x90, 0x3c, 0x7f}; 28 const uint8_t kNoteOn[] = {0x90, 0x3c, 0x7f};
27 const uint8_t kNoteOnWithRunningStatus[] = { 29 const uint8_t kNoteOnWithRunningStatus[] = {
28 0x90, 0x3c, 0x7f, 0x3c, 0x7f, 0x3c, 0x7f, 30 0x90, 0x3c, 0x7f, 0x3c, 0x7f, 0x3c, 0x7f,
29 }; 31 };
30 const uint8_t kChannelPressure[] = {0xd0, 0x01}; 32 const uint8_t kChannelPressure[] = {0xd0, 0x01};
31 const uint8_t kChannelPressureWithRunningStatus[] = { 33 const uint8_t kChannelPressureWithRunningStatus[] = {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 manager_.Shutdown(); 114 manager_.Shutdown();
113 RunLoopUntilIdle(); 115 RunLoopUntilIdle();
114 } 116 }
115 117
116 protected: 118 protected:
117 void AddOutputPort() { 119 void AddOutputPort() {
118 const std::string id = base::StringPrintf("i-can-%d", port_id_++); 120 const std::string id = base::StringPrintf("i-can-%d", port_id_++);
119 const std::string manufacturer("yukatan"); 121 const std::string manufacturer("yukatan");
120 const std::string name("doki-doki-pi-pine"); 122 const std::string name("doki-doki-pi-pine");
121 const std::string version("3.14159265359"); 123 const std::string version("3.14159265359");
122 midi::MidiPortState state = midi::MIDI_PORT_CONNECTED; 124 PortState state = PortState::CONNECTED;
123 midi::MidiPortInfo info(id, manufacturer, name, version, state); 125 midi::MidiPortInfo info(id, manufacturer, name, version, state);
124 126
125 host_->AddOutputPort(info); 127 host_->AddOutputPort(info);
126 } 128 }
127 129
128 void OnSendData(uint32_t port) { 130 void OnSendData(uint32_t port) {
129 std::unique_ptr<IPC::Message> message( 131 std::unique_ptr<IPC::Message> message(
130 new MidiHostMsg_SendData(port, data_, 0.0)); 132 new MidiHostMsg_SendData(port, data_, 0.0));
131 host_->OnMessageReceived(*message.get()); 133 host_->OnMessageReceived(*message.get());
132 } 134 }
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 // Sending data to port 0 and 1 should be delivered now. 234 // Sending data to port 0 and 1 should be delivered now.
233 OnSendData(port0); 235 OnSendData(port0);
234 OnSendData(port1); 236 OnSendData(port1);
235 RunLoopUntilIdle(); 237 RunLoopUntilIdle();
236 EXPECT_EQ(3U, GetEventSize()); 238 EXPECT_EQ(3U, GetEventSize());
237 CheckSendEventAt(1, port0); 239 CheckSendEventAt(1, port0);
238 CheckSendEventAt(2, port1); 240 CheckSendEventAt(2, port1);
239 } 241 }
240 242
241 } // namespace conent 243 } // namespace conent
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698