Add unit tests for Android audio device module

The tests are a combination of the old audio_device_unittest.cc and
audio_manager_unittest.cc, with the exception of a few that were no
longer relevant.

RunPlayoutAndRecordingInFullDuplex remains disabled according to its
comment, but has been verified to pass on at least one device.
MeasureLoopbackLatency also remains disabled, but has not been tested due
to lack of necessary hardware.

Bug: webrtc:7452
Change-Id: Ie361bc8f5e1990729d7b4699faf2a73abe3cbe8d
Reviewed-on: https://webrtc-review.googlesource.com/69340
Reviewed-by: Henrik Andreassson <henrika@webrtc.org>
Reviewed-by: Magnus Jedvert <magjed@webrtc.org>
Commit-Queue: Paulina Hensman <phensman@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22836}
This commit is contained in:
Paulina Hensman
2018-04-11 17:08:17 +02:00
committed by Commit Bot
parent 2ed62b3c9b
commit a2a9875dc2
5 changed files with 1244 additions and 0 deletions

View File

@ -1203,6 +1203,8 @@ generate_jni("generated_native_unittests_jni") {
testonly = true testonly = true
sources = [ sources = [
"native_unittests/org/webrtc/ApplicationContextProvider.java",
"native_unittests/org/webrtc/BuildInfo.java",
"native_unittests/org/webrtc/JavaTypesTestHelper.java", "native_unittests/org/webrtc/JavaTypesTestHelper.java",
"native_unittests/org/webrtc/PeerConnectionFactoryInitializationHelper.java", "native_unittests/org/webrtc/PeerConnectionFactoryInitializationHelper.java",
] ]
@ -1214,12 +1216,15 @@ rtc_android_library("native_unittests_java") {
testonly = true testonly = true
java_files = [ java_files = [
"native_unittests/org/webrtc/ApplicationContextProvider.java",
"native_unittests/org/webrtc/BuildInfo.java",
"native_unittests/org/webrtc/JavaTypesTestHelper.java", "native_unittests/org/webrtc/JavaTypesTestHelper.java",
"native_unittests/org/webrtc/PeerConnectionFactoryInitializationHelper.java", "native_unittests/org/webrtc/PeerConnectionFactoryInitializationHelper.java",
] ]
deps = [ deps = [
":libjingle_peerconnection_java", ":libjingle_peerconnection_java",
"//third_party/android_support_test_runner:runner_java",
] ]
} }
@ -1227,11 +1232,17 @@ rtc_source_set("native_unittests") {
testonly = true testonly = true
sources = [ sources = [
"native_unittests/audio_device/audio_device_unittest.cc",
"native_unittests/java_types_unittest.cc", "native_unittests/java_types_unittest.cc",
"native_unittests/peerconnection/peerconnectionfactory_unittest.cc", "native_unittests/peerconnection/peerconnectionfactory_unittest.cc",
"native_unittests/test_jni_onload.cc", "native_unittests/test_jni_onload.cc",
] ]
data = [
"../../resources/audio_device/audio_short44.pcm",
"../../resources/audio_device/audio_short48.pcm",
]
if (is_clang) { if (is_clang) {
# Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163). # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
suppressed_configs += [ suppressed_configs += [
@ -1241,24 +1252,33 @@ rtc_source_set("native_unittests") {
} }
deps = [ deps = [
":audio_device_base_jni",
":audio_jni", ":audio_jni",
":base_jni",
":generated_native_unittests_jni", ":generated_native_unittests_jni",
":java_audio_device_jni",
":media_jni", ":media_jni",
":native_api_audio_device_module",
":native_api_base", ":native_api_base",
":native_api_jni", ":native_api_jni",
":native_api_peerconnection", ":native_api_peerconnection",
":native_unittests_java", ":native_unittests_java",
":opensles_audio_device_jni",
":video_jni", ":video_jni",
"../../system_wrappers:system_wrappers",
"//api/audio_codecs:builtin_audio_decoder_factory", "//api/audio_codecs:builtin_audio_decoder_factory",
"//api/audio_codecs:builtin_audio_encoder_factory", "//api/audio_codecs:builtin_audio_encoder_factory",
"//media:rtc_audio_video", "//media:rtc_audio_video",
"//media:rtc_internal_video_codecs", "//media:rtc_internal_video_codecs",
"//media:rtc_media_base", "//media:rtc_media_base",
"//modules/audio_device:audio_device",
"//modules/audio_device:mock_audio_device",
"//modules/audio_processing:audio_processing", "//modules/audio_processing:audio_processing",
"//modules/utility:utility", "//modules/utility:utility",
"//pc:libjingle_peerconnection", "//pc:libjingle_peerconnection",
"//rtc_base:checks", "//rtc_base:checks",
"//rtc_base:rtc_base_approved", "//rtc_base:rtc_base_approved",
"//test:fileutils",
"//test:test_support", "//test:test_support",
"//testing/gtest", "//testing/gtest",
] ]

View File

@ -0,0 +1,5 @@
include_rules = [
"+modules/audio_device/include/audio_device.h",
"+modules/audio_device/include/mock_audio_transport.h",
"+system_wrappers/include",
]

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,20 @@
/*
* Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
package org.webrtc;
import android.content.Context;
public class ApplicationContextProvider {
@CalledByNative
public static Context getApplicationContextForTest() {
return ContextUtils.getApplicationContext();
}
}

View File

@ -0,0 +1,59 @@
/*
* Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
package org.webrtc;
import android.os.Build;
import org.webrtc.CalledByNative;
public final class BuildInfo {
public static String getDevice() {
return Build.DEVICE;
}
@CalledByNative
public static String getDeviceModel() {
return Build.MODEL;
}
public static String getProduct() {
return Build.PRODUCT;
}
@CalledByNative
public static String getBrand() {
return Build.BRAND;
}
@CalledByNative
public static String getDeviceManufacturer() {
return Build.MANUFACTURER;
}
@CalledByNative
public static String getAndroidBuildId() {
return Build.ID;
}
@CalledByNative
public static String getBuildType() {
return Build.TYPE;
}
@CalledByNative
public static String getBuildRelease() {
return Build.VERSION.RELEASE;
}
@CalledByNative
public static int getSdkVersion() {
return Build.VERSION.SDK_INT;
}
}