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

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

Issue 1806313003: Pass task runners to AudioManager constructor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments from patch 48 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()), 418 audio_manager_(AudioManager::CreateForTesting(loop_->task_runner())),
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();
420 } 422 }
421 423
422 ~AudioAndroidOutputTest() override {} 424 ~AudioAndroidOutputTest() override {
425 audio_manager_.reset();
426 loop_->RunUntilIdle();
427 }
423 428
424 protected: 429 protected:
425 AudioManager* audio_manager() { return audio_manager_.get(); } 430 AudioManager* audio_manager() { return audio_manager_.get(); }
426 base::MessageLoopForUI* loop() { return loop_.get(); } 431 base::MessageLoopForUI* loop() { return loop_.get(); }
427 const AudioParameters& audio_output_parameters() { 432 const AudioParameters& audio_output_parameters() {
428 return audio_output_parameters_; 433 return audio_output_parameters_;
429 } 434 }
430 435
431 // Synchronously runs the provided callback/closure on the audio thread. 436 // Synchronously runs the provided callback/closure on the audio thread.
432 void RunOnAudioThread(const base::Closure& closure) { 437 void RunOnAudioThread(const base::Closure& closure) {
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 } 559 }
555 560
556 void StopAndClose() { 561 void StopAndClose() {
557 DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread()); 562 DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread());
558 audio_output_stream_->Stop(); 563 audio_output_stream_->Stop();
559 audio_output_stream_->Close(); 564 audio_output_stream_->Close();
560 audio_output_stream_ = NULL; 565 audio_output_stream_ = NULL;
561 } 566 }
562 567
563 scoped_ptr<base::MessageLoopForUI> loop_; 568 scoped_ptr<base::MessageLoopForUI> loop_;
564 scoped_ptr<AudioManager> audio_manager_; 569 ScopedAudioManagerPtr audio_manager_;
565 AudioParameters audio_output_parameters_; 570 AudioParameters audio_output_parameters_;
566 AudioOutputStream* audio_output_stream_; 571 AudioOutputStream* audio_output_stream_;
567 base::TimeTicks start_time_; 572 base::TimeTicks start_time_;
568 base::TimeTicks end_time_; 573 base::TimeTicks end_time_;
569 574
570 private: 575 private:
571 DISALLOW_COPY_AND_ASSIGN(AudioAndroidOutputTest); 576 DISALLOW_COPY_AND_ASSIGN(AudioAndroidOutputTest);
572 }; 577 };
573 578
574 // AudioRecordInputStream should only be created on Jelly Bean and higher. This 579 // AudioRecordInputStream should only be created on Jelly Bean and higher. This
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(20)); 958 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(20));
954 printf("\n"); 959 printf("\n");
955 StopAndCloseAudioOutputStreamOnAudioThread(); 960 StopAndCloseAudioOutputStreamOnAudioThread();
956 StopAndCloseAudioInputStreamOnAudioThread(); 961 StopAndCloseAudioInputStreamOnAudioThread();
957 } 962 }
958 963
959 INSTANTIATE_TEST_CASE_P(AudioAndroidInputTest, AudioAndroidInputTest, 964 INSTANTIATE_TEST_CASE_P(AudioAndroidInputTest, AudioAndroidInputTest,
960 testing::ValuesIn(RunAudioRecordInputPathTests())); 965 testing::ValuesIn(RunAudioRecordInputPathTests()));
961 966
962 } // namespace media 967 } // 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