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

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

Issue 2566673002: Web MIDI: introduce MidiService class (Closed)
Patch Set: merge master Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/media/midi_host.cc ('k') | content/browser/renderer_host/render_process_host_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/media/midi_host_unittest.cc
diff --git a/content/browser/media/midi_host_unittest.cc b/content/browser/media/midi_host_unittest.cc
index 866d4469be7c8e7167d857ef8b340ea75305b2ff..8fea9a56cefb7657b949786cd475dc2703a7de77 100644
--- a/content/browser/media/midi_host_unittest.cc
+++ b/content/browser/media/midi_host_unittest.cc
@@ -8,12 +8,14 @@
#include <stdint.h>
#include "base/macros.h"
+#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "content/common/media/midi_messages.h"
#include "content/public/test/test_browser_thread.h"
#include "media/midi/midi_manager.h"
+#include "media/midi/midi_service.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace content {
@@ -60,9 +62,8 @@ class FakeMidiManager : public midi::MidiManager {
class MidiHostForTesting : public MidiHost {
public:
- MidiHostForTesting(int renderer_process_id,
- midi::MidiManager* midi_manager)
- : MidiHost(renderer_process_id, midi_manager) {}
+ MidiHostForTesting(int renderer_process_id, midi::MidiService* midi_service)
+ : MidiHost(renderer_process_id, midi_service) {}
private:
~MidiHostForTesting() override {}
@@ -78,11 +79,14 @@ class MidiHostTest : public testing::Test {
public:
MidiHostTest()
: io_browser_thread_(BrowserThread::IO, &message_loop_),
- host_(new MidiHostForTesting(kRenderProcessId, &manager_)),
data_(kNoteOn, kNoteOn + arraysize(kNoteOn)),
- port_id_(0) {}
+ port_id_(0) {
+ manager_ = new FakeMidiManager;
+ service_.reset(new midi::MidiService(base::WrapUnique(manager_)));
+ host_ = new MidiHostForTesting(kRenderProcessId, service_.get());
+ }
~MidiHostTest() override {
- manager_.Shutdown();
+ service_->Shutdown();
RunLoopUntilIdle();
}
@@ -104,15 +108,13 @@ class MidiHostTest : public testing::Test {
host_->OnMessageReceived(*message.get());
}
- size_t GetEventSize() const {
- return manager_.events_.size();
- }
+ size_t GetEventSize() const { return manager_->events_.size(); }
void CheckSendEventAt(size_t at, uint32_t port) {
- EXPECT_EQ(DISPATCH_SEND_MIDI_DATA, manager_.events_[at].type);
- EXPECT_EQ(port, manager_.events_[at].port_index);
- EXPECT_EQ(data_, manager_.events_[at].data);
- EXPECT_EQ(0.0, manager_.events_[at].timestamp);
+ EXPECT_EQ(DISPATCH_SEND_MIDI_DATA, manager_->events_[at].type);
+ EXPECT_EQ(port, manager_->events_[at].port_index);
+ EXPECT_EQ(data_, manager_->events_[at].data);
+ EXPECT_EQ(0.0, manager_->events_[at].timestamp);
}
void RunLoopUntilIdle() {
@@ -124,10 +126,11 @@ class MidiHostTest : public testing::Test {
base::MessageLoop message_loop_;
TestBrowserThread io_browser_thread_;
- FakeMidiManager manager_;
- scoped_refptr<MidiHostForTesting> host_;
std::vector<uint8_t> data_;
int32_t port_id_;
+ FakeMidiManager* manager_; // Raw pointer for testing, owned by |service_|.
+ std::unique_ptr<midi::MidiService> service_;
+ scoped_refptr<MidiHostForTesting> host_;
DISALLOW_COPY_AND_ASSIGN(MidiHostTest);
};
« no previous file with comments | « content/browser/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