summaryrefslogtreecommitdiffstats
path: root/media/midi/midi_manager_unittest.cc
diff options
context:
space:
mode:
authortoyoshim <toyoshim@chromium.org>2014-10-20 02:37:10 -0700
committerCommit bot <commit-bot@chromium.org>2014-10-20 09:37:51 +0000
commita42e46ee2110aeebb70d9787a0aa05997ec9c67a (patch)
treeaa92af5038dcfa5d2521cbaa64af7b9877ca9699 /media/midi/midi_manager_unittest.cc
parent0e460196fdf18f1312d34cab99e736a7f545f7d4 (diff)
downloadchromium_src-a42e46ee2110aeebb70d9787a0aa05997ec9c67a.zip
chromium_src-a42e46ee2110aeebb70d9787a0aa05997ec9c67a.tar.gz
chromium_src-a42e46ee2110aeebb70d9787a0aa05997ec9c67a.tar.bz2
Use RunLoop, but do not call RunUntilIdle() multiple times
In unit tests for MidiManager, RunLoop was used, and is used to wait a posted task finished. But, RunUntilIdle() can not be called multiple times. To avoid this restriction, we can just create new instance again for another iteration. TEST=media_unittests Review URL: https://codereview.chromium.org/656793004 Cr-Commit-Position: refs/heads/master@{#300240}
Diffstat (limited to 'media/midi/midi_manager_unittest.cc')
-rw-r--r--media/midi/midi_manager_unittest.cc21
1 files changed, 4 insertions, 17 deletions
diff --git a/media/midi/midi_manager_unittest.cc b/media/midi/midi_manager_unittest.cc
index 5782b72..cd81770 100644
--- a/media/midi/midi_manager_unittest.cc
+++ b/media/midi/midi_manager_unittest.cc
@@ -75,24 +75,11 @@ class FakeMidiManagerClient : public MidiManagerClient {
int client_id() const { return client_id_; }
MidiResult result() const { return result_; }
- void HandleContinuationMessage() {
- // Stop posting a dummy message once CompleteStartSession() is invoked.
- if (!wait_for_result_)
- return;
- base::MessageLoop::current()->PostTask(
- FROM_HERE,
- base::Bind(&FakeMidiManagerClient::HandleContinuationMessage,
- base::Unretained(this)));
- }
-
-
MidiResult WaitForResult() {
- base::RunLoop run_loop;
- // Post a dummy task not to stop the following event loop.
- HandleContinuationMessage();
- // CompleteStartSession() is called inside the message loop on the same
- // thread. Protection for |wait_for_result_| is not needed.
- run_loop.RunUntilIdle();
+ while (wait_for_result_) {
+ base::RunLoop run_loop;
+ run_loop.RunUntilIdle();
+ }
return result();
}