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

Side by Side Diff: media/audio/fake_audio_consumer_unittest.cc

Issue 922663002: Moved the fake input stream's processing onto the audio worker thread. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moving browser test updates to a separate patch (this one is big enough) Created 5 years, 10 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 | « no previous file | media/audio/fake_audio_input_stream.h » ('j') | media/audio/fake_audio_provider.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/message_loop/message_loop.h" 6 #include "base/message_loop/message_loop.h"
7 #include "base/time/time.h" 7 #include "base/time/time.h"
8 #include "media/audio/audio_parameters.h" 8 #include "media/audio/audio_parameters.h"
9 #include "media/audio/fake_audio_consumer.h" 9 #include "media/audio/fake_audio_consumer.h"
10 #include "media/audio/simple_sources.h" 10 #include "media/audio/simple_sources.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 message_loop_.PostTask(FROM_HERE, base::Bind( 106 message_loop_.PostTask(FROM_HERE, base::Bind(
107 &FakeAudioConsumerTest::TimeCallbacksOnAudioThread, 107 &FakeAudioConsumerTest::TimeCallbacksOnAudioThread,
108 base::Unretained(this), kTestCallbacks)); 108 base::Unretained(this), kTestCallbacks));
109 message_loop_.Run(); 109 message_loop_.Run();
110 110
111 // There are only (kTestCallbacks - 1) intervals between kTestCallbacks. 111 // There are only (kTestCallbacks - 1) intervals between kTestCallbacks.
112 base::TimeDelta actual_time_between_callbacks = 112 base::TimeDelta actual_time_between_callbacks =
113 (end_time_ - start_time_) / (source_.callbacks() - 1); 113 (end_time_ - start_time_) / (source_.callbacks() - 1);
114 114
115 // Ensure callback time is no faster than the expected time between callbacks. 115 // Ensure callback time is no faster than the expected time between callbacks.
116 EXPECT_TRUE(actual_time_between_callbacks >= time_between_callbacks_); 116 EXPECT_GE(actual_time_between_callbacks, time_between_callbacks_);
117 117
118 // Softly check if the callback time is no slower than twice the expected time 118 // Softly check if the callback time is no slower than twice the expected time
119 // between callbacks. Since this test runs on the bots we can't be too strict 119 // between callbacks. Since this test runs on the bots we can't be too strict
120 // with the bounds. 120 // with the bounds.
121 if (actual_time_between_callbacks > 2 * time_between_callbacks_) 121 if (actual_time_between_callbacks > 2 * time_between_callbacks_)
122 LOG(ERROR) << "Time between fake audio callbacks is too large!"; 122 LOG(ERROR) << "Time between fake audio callbacks is too large!";
123 } 123 }
124 124
125 // Ensure Start()/Stop() on the stream doesn't generate too many callbacks. See 125 // Ensure Start()/Stop() on the stream doesn't generate too many callbacks. See
126 // http://crbug.com/159049 126 // http://crbug.com/159049
127 TEST_F(FakeAudioConsumerTest, StartStopClearsCallbacks) { 127 TEST_F(FakeAudioConsumerTest, StartStopClearsCallbacks) {
128 message_loop_.PostTask(FROM_HERE, base::Bind( 128 message_loop_.PostTask(FROM_HERE, base::Bind(
129 &FakeAudioConsumerTest::TimeCallbacksOnAudioThread, 129 &FakeAudioConsumerTest::TimeCallbacksOnAudioThread,
130 base::Unretained(this), kTestCallbacks)); 130 base::Unretained(this), kTestCallbacks));
131 131
132 // Issue a Stop() / Start() in between expected callbacks to maximize the 132 // Issue a Stop() / Start() in between expected callbacks to maximize the
133 // chance of catching the FakeAudioOutputStream doing the wrong thing. 133 // chance of catching the FakeAudioOutputStream doing the wrong thing.
134 message_loop_.PostDelayedTask(FROM_HERE, base::Bind( 134 message_loop_.PostDelayedTask(FROM_HERE, base::Bind(
135 &FakeAudioConsumerTest::StopStartOnAudioThread, 135 &FakeAudioConsumerTest::StopStartOnAudioThread,
136 base::Unretained(this)), time_between_callbacks_ / 2); 136 base::Unretained(this)), time_between_callbacks_ / 2);
137 137
138 // EndTest() will ensure the proper number of callbacks have occurred. 138 // EndTest() will ensure the proper number of callbacks have occurred.
139 message_loop_.Run(); 139 message_loop_.Run();
140 } 140 }
141 141
142 } // namespace media 142 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/audio/fake_audio_input_stream.h » ('j') | media/audio/fake_audio_provider.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698