From cfb673b6a04573df0bd94a7b5348f36e7092b672 Mon Sep 17 00:00:00 2001 From: Paul Adenot Date: Tue, 25 Feb 2014 14:21:59 +0100 Subject: [PATCH] Bug 946618 - Add native tests for cubeb. r=kinetik --HG-- extra : rebase_source : 9b2e8e702ce5f8ea4d5416f3b45c91bc4cd94432 --- layout/media/symbols.def.in | 1 + media/libcubeb/moz.build | 1 + media/libcubeb/src/moz.build | 2 ++ media/libcubeb/tests/Makefile.in | 26 ++++++++++++++++++++++++++ media/libcubeb/tests/moz.build | 19 +++++++++++++++++++ media/libcubeb/update.sh | 6 ++++++ 6 files changed, 55 insertions(+) create mode 100644 media/libcubeb/tests/Makefile.in create mode 100644 media/libcubeb/tests/moz.build diff --git a/layout/media/symbols.def.in b/layout/media/symbols.def.in index c43406716d6..85a5d95722c 100644 --- a/layout/media/symbols.def.in +++ b/layout/media/symbols.def.in @@ -134,6 +134,7 @@ speex_resampler_reset_mem speex_resampler_strerror cubeb_destroy cubeb_init +cubeb_get_backend_id cubeb_get_max_channel_count cubeb_get_min_latency cubeb_get_preferred_sample_rate diff --git a/media/libcubeb/moz.build b/media/libcubeb/moz.build index e9b8e10b831..7fd2825404a 100644 --- a/media/libcubeb/moz.build +++ b/media/libcubeb/moz.build @@ -5,4 +5,5 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. DIRS += ['include', 'src'] +TEST_TOOL_DIRS += ['tests'] diff --git a/media/libcubeb/src/moz.build b/media/libcubeb/src/moz.build index d4d540bb005..64a6146f50e 100644 --- a/media/libcubeb/src/moz.build +++ b/media/libcubeb/src/moz.build @@ -4,6 +4,8 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. +LIBRARY_NAME = 'cubeb' + SOURCES += [ 'cubeb.c', ] diff --git a/media/libcubeb/tests/Makefile.in b/media/libcubeb/tests/Makefile.in new file mode 100644 index 00000000000..b16ee8aa1b5 --- /dev/null +++ b/media/libcubeb/tests/Makefile.in @@ -0,0 +1,26 @@ +# -*- Mode: makefile; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- # +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +ifeq ($(OS_ARCH),WINNT) + # On windows, the WASAPI backend needs the resampler we have in + # /media/libspeex_resampler, so we can't get away with just linking cubeb's .o + LIBS = $(call EXPAND_LIBNAME_PATH,gkmedias,$(DEPTH)/layout/media) \ + $(NULL) +else + # Otherwise, we can just grab all the compiled .o and compile against that, + # linking the appriopriate libraries. + LIBS = $(call EXPAND_LIBNAME_PATH,cubeb,$(DEPTH)/media/libcubeb/src) + ifeq ($(OS_TARGET),Darwin) + LIBS += -framework AudioUnit -framework CoreAudio + else + ifeq ($(OS_TARGET), OpenBSD) + LIBS += -lsndio + else + LIBS += $(MOZ_ALSA_LIBS) \ + $(MOZ_PULSEAUDIO_LIBS) + endif + endif + LIBS += $(NULL) +endif diff --git a/media/libcubeb/tests/moz.build b/media/libcubeb/tests/moz.build new file mode 100644 index 00000000000..4f531e0f03b --- /dev/null +++ b/media/libcubeb/tests/moz.build @@ -0,0 +1,19 @@ +# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +CPP_UNIT_TESTS += [ + 'test_audio.cpp', + 'test_latency.cpp', + 'test_sanity.cpp', + 'test_tone.cpp' +] + +LOCAL_INCLUDES += [ + '../include' +] + +FAIL_ON_WARNINGS = True + diff --git a/media/libcubeb/update.sh b/media/libcubeb/update.sh index 5d012b7301a..1d055dece22 100644 --- a/media/libcubeb/update.sh +++ b/media/libcubeb/update.sh @@ -18,6 +18,12 @@ cp $1/src/android/sles_definitions.h src/android cp $1/LICENSE . cp $1/README . cp $1/AUTHORS . +cp $1/test/common.h tests/common.h +cp $1/test/test_audio.c tests/test_audio.cpp +cp $1/test/test_tone.c tests/test_tone.cpp +cp $1/test/test_sanity.c tests/test_sanity.cpp +cp $1/test/test_latency.c tests/test_latency.cpp + if [ -d $1/.git ]; then rev=$(cd $1 && git rev-parse --verify HEAD) dirty=$(cd $1 && git diff-index --name-only HEAD)