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

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

Issue 662853003: Manage MIDI related objects and sessions' lifecycles correctly (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: one line bug fix Created 6 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
« no previous file with comments | « media/midi/midi_manager_unittest.cc ('k') | media/midi/midi_result.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 }; 71 };
72 72
73 class FakeMidiManagerClient : public MidiManagerClient { 73 class FakeMidiManagerClient : public MidiManagerClient {
74 public: 74 public:
75 explicit FakeMidiManagerClient(Logger* logger) 75 explicit FakeMidiManagerClient(Logger* logger)
76 : complete_start_session_(false), 76 : complete_start_session_(false),
77 result_(MIDI_NOT_SUPPORTED), 77 result_(MIDI_NOT_SUPPORTED),
78 logger_(logger) {} 78 logger_(logger) {}
79 ~FakeMidiManagerClient() override {} 79 ~FakeMidiManagerClient() override {}
80 80
81 void CompleteStartSession(int client_id, MidiResult result) override { 81 void CompleteStartSession(MidiResult result) override {
82 complete_start_session_ = true; 82 complete_start_session_ = true;
83 result_ = result; 83 result_ = result;
84 } 84 }
85 85
86 void ReceiveMidiData(uint32 port_index, 86 void ReceiveMidiData(uint32 port_index,
87 const uint8* data, 87 const uint8* data,
88 size_t size, 88 size_t size,
89 double timestamp) override { 89 double timestamp) override {
90 logger_->AddLog("MidiManagerClient::ReceiveMidiData "); 90 logger_->AddLog("MidiManagerClient::ReceiveMidiData ");
91 logger_->AddLog(base::StringPrintf("port_index = %d data =", port_index)); 91 logger_->AddLog(base::StringPrintf("port_index = %d data =", port_index));
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 virtual ~MidiManagerUsbTest() { 152 virtual ~MidiManagerUsbTest() {
153 std::string leftover_logs = logger_.TakeLog(); 153 std::string leftover_logs = logger_.TakeLog();
154 if (!leftover_logs.empty()) { 154 if (!leftover_logs.empty()) {
155 ADD_FAILURE() << "Log should be empty: " << leftover_logs; 155 ADD_FAILURE() << "Log should be empty: " << leftover_logs;
156 } 156 }
157 } 157 }
158 158
159 protected: 159 protected:
160 void Initialize() { 160 void Initialize() {
161 client_.reset(new FakeMidiManagerClient(&logger_)); 161 client_.reset(new FakeMidiManagerClient(&logger_));
162 manager_->StartSession(client_.get(), 0); 162 manager_->StartSession(client_.get());
163 } 163 }
164 164
165 void Finalize() { 165 void Finalize() {
166 manager_->EndSession(client_.get()); 166 manager_->EndSession(client_.get());
167 } 167 }
168 168
169 bool IsInitializationCallbackInvoked() { 169 bool IsInitializationCallbackInvoked() {
170 return client_->complete_start_session_; 170 return client_->complete_start_session_;
171 } 171 }
172 172
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 "data = 0x90 0x45 0x7f\n" 347 "data = 0x90 0x45 0x7f\n"
348 "MidiManagerClient::ReceiveMidiData port_index = 0 " 348 "MidiManagerClient::ReceiveMidiData port_index = 0 "
349 "data = 0xf0 0x00 0x01\n" 349 "data = 0xf0 0x00 0x01\n"
350 "MidiManagerClient::ReceiveMidiData port_index = 0 data = 0xf7\n", 350 "MidiManagerClient::ReceiveMidiData port_index = 0 data = 0xf7\n",
351 logger_.TakeLog()); 351 logger_.TakeLog());
352 } 352 }
353 353
354 } // namespace 354 } // namespace
355 355
356 } // namespace media 356 } // namespace media
OLDNEW
« no previous file with comments | « media/midi/midi_manager_unittest.cc ('k') | media/midi/midi_result.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698