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

Side by Side Diff: media/audio/android/audio_android_unittest.cc

Issue 1901583005: Revert of Pass task runners to AudioManager constructor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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/audio/alsa/audio_manager_alsa.cc ('k') | media/audio/android/audio_manager_android.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include "base/android/build_info.h" 7 #include "base/android/build_info.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 bool started_; 408 bool started_;
409 409
410 DISALLOW_COPY_AND_ASSIGN(FullDuplexAudioSinkSource); 410 DISALLOW_COPY_AND_ASSIGN(FullDuplexAudioSinkSource);
411 }; 411 };
412 412
413 // Test fixture class for tests which only exercise the output path. 413 // Test fixture class for tests which only exercise the output path.
414 class AudioAndroidOutputTest : public testing::Test { 414 class AudioAndroidOutputTest : public testing::Test {
415 public: 415 public:
416 AudioAndroidOutputTest() 416 AudioAndroidOutputTest()
417 : loop_(new base::MessageLoopForUI()), 417 : loop_(new base::MessageLoopForUI()),
418 audio_manager_(AudioManager::CreateForTesting(loop_->task_runner())), 418 audio_manager_(AudioManager::CreateForTesting()),
419 audio_output_stream_(NULL) { 419 audio_output_stream_(NULL) {
420 // Flush the message loop to ensure that AudioManager is fully initialized.
421 loop_->RunUntilIdle();
422 } 420 }
423 421
424 ~AudioAndroidOutputTest() override { 422 ~AudioAndroidOutputTest() override {}
425 audio_manager_.reset();
426 loop_->RunUntilIdle();
427 }
428 423
429 protected: 424 protected:
430 AudioManager* audio_manager() { return audio_manager_.get(); } 425 AudioManager* audio_manager() { return audio_manager_.get(); }
431 base::MessageLoopForUI* loop() { return loop_.get(); } 426 base::MessageLoopForUI* loop() { return loop_.get(); }
432 const AudioParameters& audio_output_parameters() { 427 const AudioParameters& audio_output_parameters() {
433 return audio_output_parameters_; 428 return audio_output_parameters_;
434 } 429 }
435 430
436 // Synchronously runs the provided callback/closure on the audio thread. 431 // Synchronously runs the provided callback/closure on the audio thread.
437 void RunOnAudioThread(const base::Closure& closure) { 432 void RunOnAudioThread(const base::Closure& closure) {
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 } 554 }
560 555
561 void StopAndClose() { 556 void StopAndClose() {
562 DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread()); 557 DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread());
563 audio_output_stream_->Stop(); 558 audio_output_stream_->Stop();
564 audio_output_stream_->Close(); 559 audio_output_stream_->Close();
565 audio_output_stream_ = NULL; 560 audio_output_stream_ = NULL;
566 } 561 }
567 562
568 scoped_ptr<base::MessageLoopForUI> loop_; 563 scoped_ptr<base::MessageLoopForUI> loop_;
569 ScopedAudioManagerPtr audio_manager_; 564 scoped_ptr<AudioManager> audio_manager_;
570 AudioParameters audio_output_parameters_; 565 AudioParameters audio_output_parameters_;
571 AudioOutputStream* audio_output_stream_; 566 AudioOutputStream* audio_output_stream_;
572 base::TimeTicks start_time_; 567 base::TimeTicks start_time_;
573 base::TimeTicks end_time_; 568 base::TimeTicks end_time_;
574 569
575 private: 570 private:
576 DISALLOW_COPY_AND_ASSIGN(AudioAndroidOutputTest); 571 DISALLOW_COPY_AND_ASSIGN(AudioAndroidOutputTest);
577 }; 572 };
578 573
579 // AudioRecordInputStream should only be created on Jelly Bean and higher. This 574 // AudioRecordInputStream should only be created on Jelly Bean and higher. This
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
958 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(20)); 953 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(20));
959 printf("\n"); 954 printf("\n");
960 StopAndCloseAudioOutputStreamOnAudioThread(); 955 StopAndCloseAudioOutputStreamOnAudioThread();
961 StopAndCloseAudioInputStreamOnAudioThread(); 956 StopAndCloseAudioInputStreamOnAudioThread();
962 } 957 }
963 958
964 INSTANTIATE_TEST_CASE_P(AudioAndroidInputTest, AudioAndroidInputTest, 959 INSTANTIATE_TEST_CASE_P(AudioAndroidInputTest, AudioAndroidInputTest,
965 testing::ValuesIn(RunAudioRecordInputPathTests())); 960 testing::ValuesIn(RunAudioRecordInputPathTests()));
966 961
967 } // namespace media 962 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/alsa/audio_manager_alsa.cc ('k') | media/audio/android/audio_manager_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698