OLD | NEW |
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 Loading... |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |