diff options
Diffstat (limited to 'media/audio/virtual_audio_input_stream_unittest.cc')
-rw-r--r-- | media/audio/virtual_audio_input_stream_unittest.cc | 38 |
1 files changed, 9 insertions, 29 deletions
diff --git a/media/audio/virtual_audio_input_stream_unittest.cc b/media/audio/virtual_audio_input_stream_unittest.cc index d444cf7..144ce82 100644 --- a/media/audio/virtual_audio_input_stream_unittest.cc +++ b/media/audio/virtual_audio_input_stream_unittest.cc @@ -97,11 +97,10 @@ class TestAudioSource : public SineWaveAudioSource { } // namespace -class VirtualAudioInputStreamTest : public testing::TestWithParam<bool> { +class VirtualAudioInputStreamTest : public testing::Test { public: VirtualAudioInputStreamTest() : audio_thread_(new base::Thread("AudioThread")), - worker_thread_(new base::Thread("AudioWorkerThread")), stream_(NULL), closed_stream_(false, false) { audio_thread_->Start(); @@ -116,9 +115,8 @@ class VirtualAudioInputStreamTest : public testing::TestWithParam<bool> { } void Create() { - const bool worker_is_separate_thread = GetParam(); stream_ = new VirtualAudioInputStream( - kParams, GetWorkerLoop(worker_is_separate_thread), + kParams, audio_message_loop_, base::Bind(&base::DeletePointer<VirtualAudioInputStream>)); stream_->Open(); } @@ -136,6 +134,7 @@ class VirtualAudioInputStreamTest : public testing::TestWithParam<bool> { ASSERT_TRUE(!!stream_); AudioOutputStream* const output_stream = new VirtualAudioOutputStream( kParams, + audio_message_loop_.get(), stream_, base::Bind(&base::DeletePointer<VirtualAudioOutputStream>)); output_streams_.push_back(output_stream); @@ -213,19 +212,6 @@ class VirtualAudioInputStreamTest : public testing::TestWithParam<bool> { return audio_message_loop_; } - const scoped_refptr<base::MessageLoopProxy>& GetWorkerLoop( - bool worker_is_separate_thread) { - if (worker_is_separate_thread) { - if (!worker_thread_->IsRunning()) { - worker_thread_->Start(); - worker_message_loop_ = worker_thread_->message_loop_proxy(); - } - return worker_message_loop_; - } else { - return audio_message_loop_; - } - } - private: void SyncWithAudioThread() { base::WaitableEvent done(false, false); @@ -237,8 +223,6 @@ class VirtualAudioInputStreamTest : public testing::TestWithParam<bool> { scoped_ptr<base::Thread> audio_thread_; scoped_refptr<base::MessageLoopProxy> audio_message_loop_; - scoped_ptr<base::Thread> worker_thread_; - scoped_refptr<base::MessageLoopProxy> worker_message_loop_; VirtualAudioInputStream* stream_; MockInputCallback input_callback_; @@ -256,13 +240,13 @@ class VirtualAudioInputStreamTest : public testing::TestWithParam<bool> { FROM_HERE, base::Bind(&VirtualAudioInputStreamTest::method, \ base::Unretained(this))) -TEST_P(VirtualAudioInputStreamTest, CreateAndClose) { +TEST_F(VirtualAudioInputStreamTest, CreateAndClose) { RUN_ON_AUDIO_THREAD(Create); RUN_ON_AUDIO_THREAD(Close); WaitUntilClosed(); } -TEST_P(VirtualAudioInputStreamTest, NoOutputs) { +TEST_F(VirtualAudioInputStreamTest, NoOutputs) { RUN_ON_AUDIO_THREAD(Create); RUN_ON_AUDIO_THREAD(Start); WaitForDataToFlow(); @@ -271,7 +255,7 @@ TEST_P(VirtualAudioInputStreamTest, NoOutputs) { WaitUntilClosed(); } -TEST_P(VirtualAudioInputStreamTest, SingleOutput) { +TEST_F(VirtualAudioInputStreamTest, SingleOutput) { RUN_ON_AUDIO_THREAD(Create); RUN_ON_AUDIO_THREAD(Start); RUN_ON_AUDIO_THREAD(CreateAndStartOneOutputStream); @@ -282,7 +266,7 @@ TEST_P(VirtualAudioInputStreamTest, SingleOutput) { WaitUntilClosed(); } -TEST_P(VirtualAudioInputStreamTest, SingleOutputPausedAndRestarted) { +TEST_F(VirtualAudioInputStreamTest, SingleOutputPausedAndRestarted) { RUN_ON_AUDIO_THREAD(Create); RUN_ON_AUDIO_THREAD(Start); RUN_ON_AUDIO_THREAD(CreateAndStartOneOutputStream); @@ -296,7 +280,7 @@ TEST_P(VirtualAudioInputStreamTest, SingleOutputPausedAndRestarted) { WaitUntilClosed(); } -TEST_P(VirtualAudioInputStreamTest, MultipleOutputs) { +TEST_F(VirtualAudioInputStreamTest, MultipleOutputs) { RUN_ON_AUDIO_THREAD(Create); RUN_ON_AUDIO_THREAD(Start); RUN_ON_AUDIO_THREAD(CreateAndStartOneOutputStream); @@ -319,7 +303,7 @@ TEST_P(VirtualAudioInputStreamTest, MultipleOutputs) { } // A combination of all of the above tests with many output streams. -TEST_P(VirtualAudioInputStreamTest, ComprehensiveTest) { +TEST_F(VirtualAudioInputStreamTest, ComprehensiveTest) { static const int kNumOutputs = 8; static const int kHalfNumOutputs = kNumOutputs / 2; static const int kPauseIterations = 5; @@ -351,8 +335,4 @@ TEST_P(VirtualAudioInputStreamTest, ComprehensiveTest) { WaitUntilClosed(); } -INSTANTIATE_TEST_CASE_P(SingleVersusMultithreaded, - VirtualAudioInputStreamTest, - ::testing::Values(false, true)); - } // namespace media |