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

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

Issue 261263002: Web MIDI: add an unit test to check MidiManager instantiation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: clean up for review Created 6 years, 7 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_manager_usb.h" 5 #include "media/midi/midi_manager_usb.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/message_loop/message_loop.h"
9 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
10 #include "base/time/time.h" 11 #include "base/time/time.h"
11 #include "media/midi/usb_midi_device.h" 12 #include "media/midi/usb_midi_device.h"
12 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
13 14
14 namespace media { 15 namespace media {
15 16
16 namespace { 17 namespace {
17 18
18 template<typename T, size_t N> 19 template<typename T, size_t N>
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 void CallCompleteInitialization(MidiResult result) { 135 void CallCompleteInitialization(MidiResult result) {
135 CompleteInitialization(result); 136 CompleteInitialization(result);
136 } 137 }
137 138
138 private: 139 private:
139 DISALLOW_COPY_AND_ASSIGN(MidiManagerUsbForTesting); 140 DISALLOW_COPY_AND_ASSIGN(MidiManagerUsbForTesting);
140 }; 141 };
141 142
142 class MidiManagerUsbTest : public ::testing::Test { 143 class MidiManagerUsbTest : public ::testing::Test {
143 public: 144 public:
144 MidiManagerUsbTest() { 145 MidiManagerUsbTest() : message_loop_(new base::MessageLoop) {
145 scoped_ptr<TestUsbMidiDeviceFactory> factory(new TestUsbMidiDeviceFactory); 146 scoped_ptr<TestUsbMidiDeviceFactory> factory(new TestUsbMidiDeviceFactory);
146 factory_ = factory.get(); 147 factory_ = factory.get();
147 manager_.reset( 148 manager_.reset(
148 new MidiManagerUsbForTesting(factory.PassAs<UsbMidiDevice::Factory>())); 149 new MidiManagerUsbForTesting(factory.PassAs<UsbMidiDevice::Factory>()));
149 } 150 }
150 virtual ~MidiManagerUsbTest() { 151 virtual ~MidiManagerUsbTest() {
151 std::string leftover_logs = logger_.TakeLog(); 152 std::string leftover_logs = logger_.TakeLog();
152 if (!leftover_logs.empty()) { 153 if (!leftover_logs.empty()) {
153 ADD_FAILURE() << "Log should be empty: " << leftover_logs; 154 ADD_FAILURE() << "Log should be empty: " << leftover_logs;
154 } 155 }
(...skipping 17 matching lines...) Expand all
172 return client_->result_; 173 return client_->result_;
173 } 174 }
174 175
175 scoped_ptr<MidiManagerUsbForTesting> manager_; 176 scoped_ptr<MidiManagerUsbForTesting> manager_;
176 scoped_ptr<FakeMidiManagerClient> client_; 177 scoped_ptr<FakeMidiManagerClient> client_;
177 // Owned by manager_. 178 // Owned by manager_.
178 TestUsbMidiDeviceFactory* factory_; 179 TestUsbMidiDeviceFactory* factory_;
179 Logger logger_; 180 Logger logger_;
180 181
181 private: 182 private:
183 scoped_ptr<base::MessageLoop> message_loop_;
184
182 DISALLOW_COPY_AND_ASSIGN(MidiManagerUsbTest); 185 DISALLOW_COPY_AND_ASSIGN(MidiManagerUsbTest);
183 }; 186 };
184 187
185 188
186 TEST_F(MidiManagerUsbTest, Initialize) { 189 TEST_F(MidiManagerUsbTest, Initialize) {
187 scoped_ptr<FakeUsbMidiDevice> device(new FakeUsbMidiDevice(&logger_)); 190 scoped_ptr<FakeUsbMidiDevice> device(new FakeUsbMidiDevice(&logger_));
188 uint8 descriptor[] = { 191 uint8 descriptor[] = {
189 0x12, 0x01, 0x10, 0x01, 0x00, 0x00, 0x00, 0x08, 0x86, 0x1a, 192 0x12, 0x01, 0x10, 0x01, 0x00, 0x00, 0x00, 0x08, 0x86, 0x1a,
190 0x2d, 0x75, 0x54, 0x02, 0x00, 0x02, 0x00, 0x01, 0x09, 0x02, 193 0x2d, 0x75, 0x54, 0x02, 0x00, 0x02, 0x00, 0x01, 0x09, 0x02,
191 0x75, 0x00, 0x02, 0x01, 0x00, 0x80, 0x30, 0x09, 0x04, 0x00, 194 0x75, 0x00, 0x02, 0x01, 0x00, 0x80, 0x30, 0x09, 0x04, 0x00,
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 "data = 0x90 0x45 0x7f\n" 342 "data = 0x90 0x45 0x7f\n"
340 "MidiManagerClient::ReceiveMidiData port_index = 0 " 343 "MidiManagerClient::ReceiveMidiData port_index = 0 "
341 "data = 0xf0 0x00 0x01\n" 344 "data = 0xf0 0x00 0x01\n"
342 "MidiManagerClient::ReceiveMidiData port_index = 0 data = 0xf7\n", 345 "MidiManagerClient::ReceiveMidiData port_index = 0 data = 0xf7\n",
343 logger_.TakeLog()); 346 logger_.TakeLog());
344 } 347 }
345 348
346 } // namespace 349 } // namespace
347 350
348 } // namespace media 351 } // namespace media
OLDNEW
« media/midi/midi_manager_unittest.cc ('K') | « media/midi/midi_manager_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698