OLD | NEW |
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 <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/android/build_info.h" | 9 #include "base/android/build_info.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
15 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
16 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
17 #include "base/synchronization/lock.h" | 17 #include "base/synchronization/lock.h" |
18 #include "base/synchronization/waitable_event.h" | 18 #include "base/synchronization/waitable_event.h" |
19 #include "base/test/test_timeouts.h" | 19 #include "base/test/test_timeouts.h" |
20 #include "base/threading/thread_task_runner_handle.h" | 20 #include "base/threading/thread_task_runner_handle.h" |
21 #include "base/time/time.h" | 21 #include "base/time/time.h" |
22 #include "build/build_config.h" | 22 #include "build/build_config.h" |
23 #include "media/audio/android/audio_manager_android.h" | 23 #include "media/audio/android/audio_manager_android.h" |
24 #include "media/audio/audio_device_description.h" | 24 #include "media/audio/audio_device_description.h" |
25 #include "media/audio/audio_io.h" | 25 #include "media/audio/audio_io.h" |
26 #include "media/audio/audio_unittest_util.h" | 26 #include "media/audio/audio_unittest_util.h" |
27 #include "media/audio/mock_audio_source_callback.h" | 27 #include "media/audio/mock_audio_source_callback.h" |
| 28 #include "media/audio/test_audio_thread.h" |
28 #include "media/base/decoder_buffer.h" | 29 #include "media/base/decoder_buffer.h" |
29 #include "media/base/seekable_buffer.h" | 30 #include "media/base/seekable_buffer.h" |
30 #include "media/base/test_data_util.h" | 31 #include "media/base/test_data_util.h" |
31 #include "testing/gmock/include/gmock/gmock.h" | 32 #include "testing/gmock/include/gmock/gmock.h" |
32 #include "testing/gtest/include/gtest/gtest.h" | 33 #include "testing/gtest/include/gtest/gtest.h" |
33 | 34 |
34 using ::testing::_; | 35 using ::testing::_; |
35 using ::testing::AtLeast; | 36 using ::testing::AtLeast; |
36 using ::testing::DoAll; | 37 using ::testing::DoAll; |
37 using ::testing::Invoke; | 38 using ::testing::Invoke; |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 bool started_; | 416 bool started_; |
416 | 417 |
417 DISALLOW_COPY_AND_ASSIGN(FullDuplexAudioSinkSource); | 418 DISALLOW_COPY_AND_ASSIGN(FullDuplexAudioSinkSource); |
418 }; | 419 }; |
419 | 420 |
420 // Test fixture class for tests which only exercise the output path. | 421 // Test fixture class for tests which only exercise the output path. |
421 class AudioAndroidOutputTest : public testing::Test { | 422 class AudioAndroidOutputTest : public testing::Test { |
422 public: | 423 public: |
423 AudioAndroidOutputTest() | 424 AudioAndroidOutputTest() |
424 : loop_(new base::MessageLoopForUI()), | 425 : loop_(new base::MessageLoopForUI()), |
425 audio_manager_(AudioManager::CreateForTesting(loop_->task_runner())), | 426 audio_manager_(AudioManager::CreateForTesting( |
| 427 base::MakeUnique<TestAudioThread>())), |
426 audio_output_stream_(NULL) { | 428 audio_output_stream_(NULL) { |
427 // Flush the message loop to ensure that AudioManager is fully initialized. | 429 // Flush the message loop to ensure that AudioManager is fully initialized. |
428 base::RunLoop().RunUntilIdle(); | 430 base::RunLoop().RunUntilIdle(); |
429 } | 431 } |
430 | 432 |
431 ~AudioAndroidOutputTest() override { | 433 ~AudioAndroidOutputTest() override { |
432 audio_manager_.reset(); | 434 audio_manager_->Shutdown(); |
433 base::RunLoop().RunUntilIdle(); | 435 base::RunLoop().RunUntilIdle(); |
434 } | 436 } |
435 | 437 |
436 protected: | 438 protected: |
437 AudioManager* audio_manager() { return audio_manager_.get(); } | 439 AudioManager* audio_manager() { return audio_manager_.get(); } |
438 const AudioParameters& audio_output_parameters() { | 440 const AudioParameters& audio_output_parameters() { |
439 return audio_output_parameters_; | 441 return audio_output_parameters_; |
440 } | 442 } |
441 | 443 |
442 // Synchronously runs the provided callback/closure on the audio thread. | 444 // Synchronously runs the provided callback/closure on the audio thread. |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 } | 572 } |
571 | 573 |
572 void StopAndClose() { | 574 void StopAndClose() { |
573 DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread()); | 575 DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread()); |
574 audio_output_stream_->Stop(); | 576 audio_output_stream_->Stop(); |
575 audio_output_stream_->Close(); | 577 audio_output_stream_->Close(); |
576 audio_output_stream_ = NULL; | 578 audio_output_stream_ = NULL; |
577 } | 579 } |
578 | 580 |
579 std::unique_ptr<base::MessageLoopForUI> loop_; | 581 std::unique_ptr<base::MessageLoopForUI> loop_; |
580 ScopedAudioManagerPtr audio_manager_; | 582 std::unique_ptr<AudioManager> audio_manager_; |
581 AudioParameters audio_output_parameters_; | 583 AudioParameters audio_output_parameters_; |
582 AudioOutputStream* audio_output_stream_; | 584 AudioOutputStream* audio_output_stream_; |
583 base::TimeTicks start_time_; | 585 base::TimeTicks start_time_; |
584 base::TimeTicks end_time_; | 586 base::TimeTicks end_time_; |
585 | 587 |
586 private: | 588 private: |
587 DISALLOW_COPY_AND_ASSIGN(AudioAndroidOutputTest); | 589 DISALLOW_COPY_AND_ASSIGN(AudioAndroidOutputTest); |
588 }; | 590 }; |
589 | 591 |
590 // Test fixture class for tests which exercise the input path, or both input and | 592 // Test fixture class for tests which exercise the input path, or both input and |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
963 printf("\n"); | 965 printf("\n"); |
964 StopAndCloseAudioOutputStreamOnAudioThread(); | 966 StopAndCloseAudioOutputStreamOnAudioThread(); |
965 StopAndCloseAudioInputStreamOnAudioThread(); | 967 StopAndCloseAudioInputStreamOnAudioThread(); |
966 } | 968 } |
967 | 969 |
968 INSTANTIATE_TEST_CASE_P(AudioAndroidInputTest, | 970 INSTANTIATE_TEST_CASE_P(AudioAndroidInputTest, |
969 AudioAndroidInputTest, | 971 AudioAndroidInputTest, |
970 testing::Bool()); | 972 testing::Bool()); |
971 | 973 |
972 } // namespace media | 974 } // namespace media |
OLD | NEW |