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

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

Issue 1315793008: Web MIDI: introduce MidiManager::Shutdown to shutdown gracefully (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: build fix (mac typo) Created 5 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 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/message_loop/message_loop.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 logger_->AddLog("\n"); 124 logger_->AddLog("\n");
125 } 125 }
126 126
127 void AccumulateMidiBytesSent(size_t size) override { 127 void AccumulateMidiBytesSent(size_t size) override {
128 logger_->AddLog("MidiManagerClient::AccumulateMidiBytesSent "); 128 logger_->AddLog("MidiManagerClient::AccumulateMidiBytesSent ");
129 // Windows has no "%zu". 129 // Windows has no "%zu".
130 logger_->AddLog(base::StringPrintf("size = %u\n", 130 logger_->AddLog(base::StringPrintf("size = %u\n",
131 static_cast<unsigned>(size))); 131 static_cast<unsigned>(size)));
132 } 132 }
133 133
134 void Detached() override {}
135
134 bool complete_start_session_; 136 bool complete_start_session_;
135 Result result_; 137 Result result_;
136 MidiPortInfoList input_ports_; 138 MidiPortInfoList input_ports_;
137 MidiPortInfoList output_ports_; 139 MidiPortInfoList output_ports_;
138 140
139 private: 141 private:
140 Logger* logger_; 142 Logger* logger_;
141 143
142 DISALLOW_COPY_AND_ASSIGN(FakeMidiManagerClient); 144 DISALLOW_COPY_AND_ASSIGN(FakeMidiManagerClient);
143 }; 145 };
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 }; 177 };
176 178
177 class MidiManagerUsbTest : public ::testing::Test { 179 class MidiManagerUsbTest : public ::testing::Test {
178 public: 180 public:
179 MidiManagerUsbTest() : message_loop_(new base::MessageLoop) { 181 MidiManagerUsbTest() : message_loop_(new base::MessageLoop) {
180 scoped_ptr<TestUsbMidiDeviceFactory> factory(new TestUsbMidiDeviceFactory); 182 scoped_ptr<TestUsbMidiDeviceFactory> factory(new TestUsbMidiDeviceFactory);
181 factory_ = factory.get(); 183 factory_ = factory.get();
182 manager_.reset(new MidiManagerUsbForTesting(factory.Pass())); 184 manager_.reset(new MidiManagerUsbForTesting(factory.Pass()));
183 } 185 }
184 ~MidiManagerUsbTest() override { 186 ~MidiManagerUsbTest() override {
187 manager_->Shutdown();
188 base::RunLoop run_loop;
189 run_loop.RunUntilIdle();
190
185 std::string leftover_logs = logger_.TakeLog(); 191 std::string leftover_logs = logger_.TakeLog();
186 if (!leftover_logs.empty()) { 192 if (!leftover_logs.empty()) {
187 ADD_FAILURE() << "Log should be empty: " << leftover_logs; 193 ADD_FAILURE() << "Log should be empty: " << leftover_logs;
188 } 194 }
189 } 195 }
190 196
191 protected: 197 protected:
192 void Initialize() { 198 void Initialize() {
193 client_.reset(new FakeMidiManagerClient(&logger_)); 199 client_.reset(new FakeMidiManagerClient(&logger_));
194 manager_->StartSession(client_.get()); 200 manager_->StartSession(client_.get());
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 EXPECT_EQ(3u, manager_->output_streams()[1]->jack().jack_id); 574 EXPECT_EQ(3u, manager_->output_streams()[1]->jack().jack_id);
569 ASSERT_EQ(1u, jacks.size()); 575 ASSERT_EQ(1u, jacks.size());
570 EXPECT_EQ(2, jacks[0].endpoint_number()); 576 EXPECT_EQ(2, jacks[0].endpoint_number());
571 EXPECT_EQ("UsbMidiDevice::GetDescriptors\n", logger_.TakeLog()); 577 EXPECT_EQ("UsbMidiDevice::GetDescriptors\n", logger_.TakeLog());
572 } 578 }
573 579
574 } // namespace 580 } // namespace
575 581
576 } // namespace midi 582 } // namespace midi
577 } // namespace media 583 } // namespace media
OLDNEW
« media/midi/midi_manager.h ('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