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

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: unittest 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
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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 }; 72 };
73 73
74 class FakeMidiManagerClient : public MidiManagerClient { 74 class FakeMidiManagerClient : public MidiManagerClient {
75 public: 75 public:
76 explicit FakeMidiManagerClient(Logger* logger) 76 explicit FakeMidiManagerClient(Logger* logger)
77 : complete_start_session_(false), 77 : complete_start_session_(false),
78 result_(MIDI_NOT_SUPPORTED), 78 result_(MIDI_NOT_SUPPORTED),
79 logger_(logger) {} 79 logger_(logger) {}
80 virtual ~FakeMidiManagerClient() {} 80 virtual ~FakeMidiManagerClient() {}
81 81
82 virtual void CompleteStartSession(int client_id, MidiResult result) override { 82 virtual void CompleteStartSession(MidiResult result) override {
83 complete_start_session_ = true; 83 complete_start_session_ = true;
84 result_ = result; 84 result_ = result;
85 } 85 }
86 86
87 virtual void ReceiveMidiData(uint32 port_index, 87 virtual void ReceiveMidiData(uint32 port_index,
88 const uint8* data, 88 const uint8* data,
89 size_t size, 89 size_t size,
90 double timestamp) override { 90 double timestamp) override {
91 logger_->AddLog("MidiManagerClient::ReceiveMidiData "); 91 logger_->AddLog("MidiManagerClient::ReceiveMidiData ");
92 logger_->AddLog(base::StringPrintf("port_index = %d data =", port_index)); 92 logger_->AddLog(base::StringPrintf("port_index = %d data =", port_index));
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 virtual ~MidiManagerUsbTest() { 154 virtual ~MidiManagerUsbTest() {
155 std::string leftover_logs = logger_.TakeLog(); 155 std::string leftover_logs = logger_.TakeLog();
156 if (!leftover_logs.empty()) { 156 if (!leftover_logs.empty()) {
157 ADD_FAILURE() << "Log should be empty: " << leftover_logs; 157 ADD_FAILURE() << "Log should be empty: " << leftover_logs;
158 } 158 }
159 } 159 }
160 160
161 protected: 161 protected:
162 void Initialize() { 162 void Initialize() {
163 client_.reset(new FakeMidiManagerClient(&logger_)); 163 client_.reset(new FakeMidiManagerClient(&logger_));
164 manager_->StartSession(client_.get(), 0); 164 manager_->StartSession(client_.get());
165 } 165 }
166 166
167 void Finalize() { 167 void Finalize() {
168 manager_->EndSession(client_.get()); 168 manager_->EndSession(client_.get());
169 } 169 }
170 170
171 bool IsInitializationCallbackInvoked() { 171 bool IsInitializationCallbackInvoked() {
172 return client_->complete_start_session_; 172 return client_->complete_start_session_;
173 } 173 }
174 174
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 "data = 0x90 0x45 0x7f\n" 348 "data = 0x90 0x45 0x7f\n"
349 "MidiManagerClient::ReceiveMidiData port_index = 0 " 349 "MidiManagerClient::ReceiveMidiData port_index = 0 "
350 "data = 0xf0 0x00 0x01\n" 350 "data = 0xf0 0x00 0x01\n"
351 "MidiManagerClient::ReceiveMidiData port_index = 0 data = 0xf7\n", 351 "MidiManagerClient::ReceiveMidiData port_index = 0 data = 0xf7\n",
352 logger_.TakeLog()); 352 logger_.TakeLog());
353 } 353 }
354 354
355 } // namespace 355 } // namespace
356 356
357 } // namespace media 357 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698