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

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

Issue 1892433002: Moving device description utils from AudioManager[Base] into AudioDeviceDescription; to be shared b… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: another rebase Created 4 years, 7 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.cc » ('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 <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/time/time.h" 20 #include "base/time/time.h"
21 #include "build/build_config.h" 21 #include "build/build_config.h"
22 #include "media/audio/android/audio_manager_android.h" 22 #include "media/audio/android/audio_manager_android.h"
23 #include "media/audio/audio_device_description.h"
23 #include "media/audio/audio_io.h" 24 #include "media/audio/audio_io.h"
24 #include "media/audio/audio_manager_base.h"
25 #include "media/audio/audio_unittest_util.h" 25 #include "media/audio/audio_unittest_util.h"
26 #include "media/audio/mock_audio_source_callback.h" 26 #include "media/audio/mock_audio_source_callback.h"
27 #include "media/base/decoder_buffer.h" 27 #include "media/base/decoder_buffer.h"
28 #include "media/base/seekable_buffer.h" 28 #include "media/base/seekable_buffer.h"
29 #include "media/base/test_data_util.h" 29 #include "media/base/test_data_util.h"
30 #include "testing/gmock/include/gmock/gmock.h" 30 #include "testing/gmock/include/gmock/gmock.h"
31 #include "testing/gtest/include/gtest/gtest.h" 31 #include "testing/gtest/include/gtest/gtest.h"
32 32
33 using ::testing::_; 33 using ::testing::_;
34 using ::testing::AtLeast; 34 using ::testing::AtLeast;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 // Log a warning so we can see the status on the build bots. No need to 99 // Log a warning so we can see the status on the build bots. No need to
100 // break the test though since this does successfully test the code and 100 // break the test though since this does successfully test the code and
101 // some failure cases. 101 // some failure cases.
102 LOG(WARNING) << "No input devices detected"; 102 LOG(WARNING) << "No input devices detected";
103 return; 103 return;
104 } 104 }
105 105
106 AudioDeviceNames::const_iterator it = device_names.begin(); 106 AudioDeviceNames::const_iterator it = device_names.begin();
107 107
108 // The first device in the list should always be the default device. 108 // The first device in the list should always be the default device.
109 EXPECT_EQ(AudioManager::GetDefaultDeviceName(), it->device_name); 109 EXPECT_EQ(AudioDeviceDescription::GetDefaultDeviceName(), it->device_name);
110 EXPECT_EQ(std::string(AudioManagerBase::kDefaultDeviceId), it->unique_id); 110 EXPECT_EQ(std::string(AudioDeviceDescription::kDefaultDeviceId),
111 it->unique_id);
111 ++it; 112 ++it;
112 113
113 // Other devices should have non-empty name and id and should not contain 114 // Other devices should have non-empty name and id and should not contain
114 // default name or id. 115 // default name or id.
115 while (it != device_names.end()) { 116 while (it != device_names.end()) {
116 EXPECT_FALSE(it->device_name.empty()); 117 EXPECT_FALSE(it->device_name.empty());
117 EXPECT_FALSE(it->unique_id.empty()); 118 EXPECT_FALSE(it->unique_id.empty());
118 DVLOG(2) << "Device ID(" << it->unique_id 119 DVLOG(2) << "Device ID(" << it->unique_id
119 << "), label: " << it->device_name; 120 << "), label: " << it->device_name;
120 EXPECT_NE(AudioManager::GetDefaultDeviceName(), it->device_name); 121 EXPECT_NE(AudioDeviceDescription::GetDefaultDeviceName(), it->device_name);
121 EXPECT_NE(std::string(AudioManagerBase::kDefaultDeviceId), it->unique_id); 122 EXPECT_NE(std::string(AudioDeviceDescription::kDefaultDeviceId),
123 it->unique_id);
122 ++it; 124 ++it;
123 } 125 }
124 } 126 }
125 127
126 // We clear the data bus to ensure that the test does not cause noise. 128 // We clear the data bus to ensure that the test does not cause noise.
127 int RealOnMoreData(AudioBus* dest, 129 int RealOnMoreData(AudioBus* dest,
128 uint32_t total_bytes_delay, 130 uint32_t total_bytes_delay,
129 uint32_t frames_skipped) { 131 uint32_t frames_skipped) {
130 dest->Zero(); 132 dest->Zero();
131 return dest->frames(); 133 return dest->frames();
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 << average_time_between_callbacks_ms << " ms"; 679 << average_time_between_callbacks_ms << " ms";
678 EXPECT_GE(average_time_between_callbacks_ms, 680 EXPECT_GE(average_time_between_callbacks_ms,
679 0.70 * expected_time_between_callbacks_ms); 681 0.70 * expected_time_between_callbacks_ms);
680 EXPECT_LE(average_time_between_callbacks_ms, 682 EXPECT_LE(average_time_between_callbacks_ms,
681 1.30 * expected_time_between_callbacks_ms); 683 1.30 * expected_time_between_callbacks_ms);
682 } 684 }
683 685
684 void GetDefaultInputStreamParameters() { 686 void GetDefaultInputStreamParameters() {
685 DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread()); 687 DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread());
686 audio_input_parameters_ = audio_manager()->GetInputStreamParameters( 688 audio_input_parameters_ = audio_manager()->GetInputStreamParameters(
687 AudioManagerBase::kDefaultDeviceId); 689 AudioDeviceDescription::kDefaultDeviceId);
688 } 690 }
689 691
690 void MakeInputStream(const AudioParameters& params) { 692 void MakeInputStream(const AudioParameters& params) {
691 DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread()); 693 DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread());
692 audio_input_stream_ = audio_manager()->MakeAudioInputStream( 694 audio_input_stream_ = audio_manager()->MakeAudioInputStream(
693 params, AudioManagerBase::kDefaultDeviceId); 695 params, AudioDeviceDescription::kDefaultDeviceId);
694 EXPECT_TRUE(audio_input_stream_); 696 EXPECT_TRUE(audio_input_stream_);
695 } 697 }
696 698
697 void OpenAndClose() { 699 void OpenAndClose() {
698 DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread()); 700 DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread());
699 EXPECT_TRUE(audio_input_stream_->Open()); 701 EXPECT_TRUE(audio_input_stream_->Open());
700 audio_input_stream_->Close(); 702 audio_input_stream_->Close();
701 audio_input_stream_ = NULL; 703 audio_input_stream_ = NULL;
702 } 704 }
703 705
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(20)); 961 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(20));
960 printf("\n"); 962 printf("\n");
961 StopAndCloseAudioOutputStreamOnAudioThread(); 963 StopAndCloseAudioOutputStreamOnAudioThread();
962 StopAndCloseAudioInputStreamOnAudioThread(); 964 StopAndCloseAudioInputStreamOnAudioThread();
963 } 965 }
964 966
965 INSTANTIATE_TEST_CASE_P(AudioAndroidInputTest, AudioAndroidInputTest, 967 INSTANTIATE_TEST_CASE_P(AudioAndroidInputTest, AudioAndroidInputTest,
966 testing::ValuesIn(RunAudioRecordInputPathTests())); 968 testing::ValuesIn(RunAudioRecordInputPathTests()));
967 969
968 } // namespace media 970 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/alsa/audio_manager_alsa.cc ('k') | media/audio/android/audio_manager_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698