aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorphoglund <phoglund@webrtc.org>2016-01-08 05:04:57 -0800
committerCommit bot <commit-bot@chromium.org>2016-01-08 13:05:01 +0000
commit37ebcf0ce5ad1685bcf659ea75960beb96019647 (patch)
tree3253e50cbc9204438e139d4356e0fe1b0d38a0b1
parentb71b4f0c7af57ef5b676c6ed70bf945282c90e3a (diff)
downloadwebrtc-37ebcf0ce5ad1685bcf659ea75960beb96019647.tar.gz
Reland "Add APK targets to build libjingle tests for Android."
patchset #10 id:180001 of https://codereview.webrtc.org/1511633002/ This reverts commit bc14164aad254e72ce4d1e381b912b7d3acf5391. We have made more preparations downstream, so this should work now. Original CL by perkj@. BUG=webrtc:2365 The work started from the work by kjellander@ in https://codereview.webrtc.org/1413663003/ Review URL: https://codereview.webrtc.org/1570513004 Cr-Commit-Position: refs/heads/master@{#11186}
-rw-r--r--talk/app/webrtc/java/jni/jni_onload.cc55
-rw-r--r--talk/app/webrtc/java/jni/peerconnection_jni.cc16
-rw-r--r--talk/app/webrtc/peerconnectionendtoend_unittest.cc6
-rw-r--r--talk/app/webrtc/peerconnectionfactory_unittest.cc10
-rw-r--r--talk/app/webrtc/peerconnectioninterface_unittest.cc9
-rw-r--r--talk/app/webrtc/test/DEPS5
-rw-r--r--talk/app/webrtc/test/androidtestinitializer.cc74
-rw-r--r--talk/app/webrtc/test/androidtestinitializer.h37
-rw-r--r--talk/app/webrtc/webrtcsdp_unittest.cc6
-rwxr-xr-xtalk/libjingle.gyp83
-rwxr-xr-xtalk/libjingle_tests.gyp33
-rwxr-xr-xwebrtc/build/android/test_runner.py2
-rw-r--r--webrtc/build/apk_test.gypi40
-rw-r--r--webrtc/build/apk_tests.gyp17
-rw-r--r--webrtc/build/apk_tests_noop.gyp4
-rw-r--r--webrtc/system_wrappers/include/field_trial_default.h2
-rw-r--r--webrtc/system_wrappers/source/field_trial_default.cc4
-rw-r--r--webrtc/test/BUILD.gn1
-rw-r--r--webrtc/test/field_trial.cc36
-rw-r--r--webrtc/test/field_trial.h3
-rw-r--r--webrtc/test/test.gyp1
21 files changed, 358 insertions, 86 deletions
diff --git a/talk/app/webrtc/java/jni/jni_onload.cc b/talk/app/webrtc/java/jni/jni_onload.cc
new file mode 100644
index 0000000000..9664ecdca6
--- /dev/null
+++ b/talk/app/webrtc/java/jni/jni_onload.cc
@@ -0,0 +1,55 @@
+/*
+ * libjingle
+ * Copyright 2015 Google Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+ * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <jni.h>
+#undef JNIEXPORT
+#define JNIEXPORT __attribute__((visibility("default")))
+
+#include "talk/app/webrtc/java/jni/classreferenceholder.h"
+#include "talk/app/webrtc/java/jni/jni_helpers.h"
+#include "webrtc/base/ssladapter.h"
+
+namespace webrtc_jni {
+
+extern "C" jint JNIEXPORT JNICALL JNI_OnLoad(JavaVM *jvm, void *reserved) {
+ jint ret = InitGlobalJniVariables(jvm);
+ RTC_DCHECK_GE(ret, 0);
+ if (ret < 0)
+ return -1;
+
+ RTC_CHECK(rtc::InitializeSSL()) << "Failed to InitializeSSL()";
+ LoadGlobalClassReferenceHolder();
+
+ return ret;
+}
+
+extern "C" void JNIEXPORT JNICALL JNI_OnUnLoad(JavaVM *jvm, void *reserved) {
+ FreeGlobalClassReferenceHolder();
+ RTC_CHECK(rtc::CleanupSSL()) << "Failed to CleanupSSL()";
+}
+
+} // namespace webrtc_jni
diff --git a/talk/app/webrtc/java/jni/peerconnection_jni.cc b/talk/app/webrtc/java/jni/peerconnection_jni.cc
index 5e90043c3f..5ea63f74ae 100644
--- a/talk/app/webrtc/java/jni/peerconnection_jni.cc
+++ b/talk/app/webrtc/java/jni/peerconnection_jni.cc
@@ -143,22 +143,6 @@ static bool factory_static_initialized = false;
static bool video_hw_acceleration_enabled = true;
#endif
-extern "C" jint JNIEXPORT JNICALL JNI_OnLoad(JavaVM *jvm, void *reserved) {
- jint ret = InitGlobalJniVariables(jvm);
- if (ret < 0)
- return -1;
-
- RTC_CHECK(rtc::InitializeSSL()) << "Failed to InitializeSSL()";
- LoadGlobalClassReferenceHolder();
-
- return ret;
-}
-
-extern "C" void JNIEXPORT JNICALL JNI_OnUnLoad(JavaVM *jvm, void *reserved) {
- FreeGlobalClassReferenceHolder();
- RTC_CHECK(rtc::CleanupSSL()) << "Failed to CleanupSSL()";
-}
-
// Return the (singleton) Java Enum object corresponding to |index|;
// |state_class_fragment| is something like "MediaSource$State".
static jobject JavaEnumFromIndex(
diff --git a/talk/app/webrtc/peerconnectionendtoend_unittest.cc b/talk/app/webrtc/peerconnectionendtoend_unittest.cc
index 7413b9d0bc..1a180317ac 100644
--- a/talk/app/webrtc/peerconnectionendtoend_unittest.cc
+++ b/talk/app/webrtc/peerconnectionendtoend_unittest.cc
@@ -27,6 +27,9 @@
#include "talk/app/webrtc/test/peerconnectiontestwrapper.h"
#include "talk/app/webrtc/test/mockpeerconnectionobservers.h"
+#ifdef WEBRTC_ANDROID
+#include "talk/app/webrtc/test/androidtestinitializer.h"
+#endif
#include "webrtc/base/gunit.h"
#include "webrtc/base/logging.h"
#include "webrtc/base/ssladapter.h"
@@ -64,6 +67,9 @@ class PeerConnectionEndToEndTest
"caller")),
callee_(new rtc::RefCountedObject<PeerConnectionTestWrapper>(
"callee")) {
+#ifdef WEBRTC_ANDROID
+ webrtc::InitializeAndroidObjects();
+#endif
}
void CreatePcs() {
diff --git a/talk/app/webrtc/peerconnectionfactory_unittest.cc b/talk/app/webrtc/peerconnectionfactory_unittest.cc
index 050d5dbb12..9fb013b54f 100644
--- a/talk/app/webrtc/peerconnectionfactory_unittest.cc
+++ b/talk/app/webrtc/peerconnectionfactory_unittest.cc
@@ -30,6 +30,9 @@
#include "talk/app/webrtc/mediastreaminterface.h"
#include "talk/app/webrtc/peerconnectionfactory.h"
+#ifdef WEBRTC_ANDROID
+#include "talk/app/webrtc/test/androidtestinitializer.h"
+#endif
#include "talk/app/webrtc/test/fakedtlsidentitystore.h"
#include "talk/app/webrtc/test/fakevideotrackrenderer.h"
#include "talk/app/webrtc/videosourceinterface.h"
@@ -98,6 +101,9 @@ class NullPeerConnectionObserver : public PeerConnectionObserver {
class PeerConnectionFactoryTest : public testing::Test {
void SetUp() {
+#ifdef WEBRTC_ANDROID
+ webrtc::InitializeAndroidObjects();
+#endif
factory_ = webrtc::CreatePeerConnectionFactory(rtc::Thread::Current(),
rtc::Thread::Current(),
NULL,
@@ -143,6 +149,10 @@ class PeerConnectionFactoryTest : public testing::Test {
// Verify creation of PeerConnection using internal ADM, video factory and
// internal libjingle threads.
TEST(PeerConnectionFactoryTestInternal, CreatePCUsingInternalModules) {
+#ifdef WEBRTC_ANDROID
+ webrtc::InitializeAndroidObjects();
+#endif
+
rtc::scoped_refptr<PeerConnectionFactoryInterface> factory(
webrtc::CreatePeerConnectionFactory());
diff --git a/talk/app/webrtc/peerconnectioninterface_unittest.cc b/talk/app/webrtc/peerconnectioninterface_unittest.cc
index 7b49e45874..b705da4bb3 100644
--- a/talk/app/webrtc/peerconnectioninterface_unittest.cc
+++ b/talk/app/webrtc/peerconnectioninterface_unittest.cc
@@ -37,6 +37,9 @@
#include "talk/app/webrtc/rtpreceiverinterface.h"
#include "talk/app/webrtc/rtpsenderinterface.h"
#include "talk/app/webrtc/streamcollection.h"
+#ifdef WEBRTC_ANDROID
+#include "talk/app/webrtc/test/androidtestinitializer.h"
+#endif
#include "talk/app/webrtc/test/fakeconstraints.h"
#include "talk/app/webrtc/test/fakedtlsidentitystore.h"
#include "talk/app/webrtc/test/mockpeerconnectionobservers.h"
@@ -514,6 +517,12 @@ class MockPeerConnectionObserver : public PeerConnectionObserver {
class PeerConnectionInterfaceTest : public testing::Test {
protected:
+ PeerConnectionInterfaceTest() {
+#ifdef WEBRTC_ANDROID
+ webrtc::InitializeAndroidObjects();
+#endif
+ }
+
virtual void SetUp() {
pc_factory_ = webrtc::CreatePeerConnectionFactory(
rtc::Thread::Current(), rtc::Thread::Current(), NULL, NULL,
diff --git a/talk/app/webrtc/test/DEPS b/talk/app/webrtc/test/DEPS
new file mode 100644
index 0000000000..a814b152f2
--- /dev/null
+++ b/talk/app/webrtc/test/DEPS
@@ -0,0 +1,5 @@
+include_rules = [
+ # Allow include of Chrome base/android to allow inclusion of headers needed
+ # for accessing the JVM and Application context in gtest.
+ "+base/android",
+]
diff --git a/talk/app/webrtc/test/androidtestinitializer.cc b/talk/app/webrtc/test/androidtestinitializer.cc
new file mode 100644
index 0000000000..883c2d8178
--- /dev/null
+++ b/talk/app/webrtc/test/androidtestinitializer.cc
@@ -0,0 +1,74 @@
+/*
+ * libjingle
+ * Copyright 2015 Google Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+ * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "talk/app/webrtc/test/androidtestinitializer.h"
+
+#include <pthread.h>
+
+// Note: this dependency is dangerous since it reaches into Chromium's base.
+// There's a risk of e.g. macro clashes. This file may only be used in tests.
+// Since we use Chromes build system for creating the gtest binary, this should
+// be fine.
+#include "base/android/context_utils.h"
+#include "base/android/jni_android.h"
+
+#include "talk/app/webrtc/java/jni/classreferenceholder.h"
+#include "talk/app/webrtc/java/jni/jni_helpers.h"
+#include "webrtc/base/checks.h"
+#include "webrtc/base/ssladapter.h"
+#include "webrtc/voice_engine/include/voe_base.h"
+
+namespace webrtc {
+
+namespace {
+
+static pthread_once_t g_initialize_once = PTHREAD_ONCE_INIT;
+
+// There can only be one JNI_OnLoad in each binary. So since this is a GTEST
+// C++ runner binary, we want to initialize the same global objects we normally
+// do if this had been a Java binary.
+void EnsureInitializedOnce() {
+ RTC_CHECK(::base::android::IsVMInitialized());
+ JNIEnv* jni = ::base::android::AttachCurrentThread();
+ JavaVM* jvm = NULL;
+ RTC_CHECK_EQ(0, jni->GetJavaVM(&jvm));
+ jobject context = ::base::android::GetApplicationContext();
+
+ RTC_CHECK_GE(webrtc_jni::InitGlobalJniVariables(jvm), 0);
+ RTC_CHECK(rtc::InitializeSSL()) << "Failed to InitializeSSL()";
+ webrtc_jni::LoadGlobalClassReferenceHolder();
+
+ webrtc::VoiceEngine::SetAndroidObjects(jvm, context);
+}
+
+} // anonymous namespace
+
+void InitializeAndroidObjects() {
+ RTC_CHECK_EQ(0, pthread_once(&g_initialize_once, &EnsureInitializedOnce));
+}
+
+} // namespace webrtc
diff --git a/talk/app/webrtc/test/androidtestinitializer.h b/talk/app/webrtc/test/androidtestinitializer.h
new file mode 100644
index 0000000000..e6992825dd
--- /dev/null
+++ b/talk/app/webrtc/test/androidtestinitializer.h
@@ -0,0 +1,37 @@
+/*
+ * libjingle
+ * Copyright 2015 Google Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+ * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef TALK_APP_WEBRTC_TEST_ANDROIDTESTINITIALIZER_H_
+#define TALK_APP_WEBRTC_TEST_ANDROIDTESTINITIALIZER_H_
+
+namespace webrtc {
+
+void InitializeAndroidObjects();
+
+} // namespace webrtc
+
+#endif // TALK_APP_WEBRTC_TEST_ANDROIDTESTINITIALIZER_H_
diff --git a/talk/app/webrtc/webrtcsdp_unittest.cc b/talk/app/webrtc/webrtcsdp_unittest.cc
index 1bf3e681c3..15fc8083b4 100644
--- a/talk/app/webrtc/webrtcsdp_unittest.cc
+++ b/talk/app/webrtc/webrtcsdp_unittest.cc
@@ -30,6 +30,9 @@
#include <vector>
#include "talk/app/webrtc/jsepsessiondescription.h"
+#ifdef WEBRTC_ANDROID
+#include "talk/app/webrtc/test/androidtestinitializer.h"
+#endif
#include "talk/app/webrtc/webrtcsdp.h"
#include "talk/media/base/constants.h"
#include "webrtc/p2p/base/constants.h"
@@ -544,6 +547,9 @@ class WebRtcSdpTest : public testing::Test {
public:
WebRtcSdpTest()
: jdesc_(kDummyString) {
+#ifdef WEBRTC_ANDROID
+ webrtc::InitializeAndroidObjects();
+#endif
// AudioContentDescription
audio_desc_ = CreateAudioContentDescription();
AudioCodec opus(111, "opus", 48000, 0, 2, 3);
diff --git a/talk/libjingle.gyp b/talk/libjingle.gyp
index bc7c0b4ed3..da7f80b60d 100755
--- a/talk/libjingle.gyp
+++ b/talk/libjingle.gyp
@@ -43,8 +43,8 @@
['OS=="linux" or OS=="android"', {
'targets': [
{
- 'target_name': 'libjingle_peerconnection_so',
- 'type': 'shared_library',
+ 'target_name': 'libjingle_peerconnection_jni',
+ 'type': 'static_library',
'dependencies': [
'<(webrtc_root)/system_wrappers/system_wrappers.gyp:field_trial_default',
'libjingle_peerconnection',
@@ -63,37 +63,23 @@
],
'conditions': [
['OS=="linux"', {
- 'defines': [
- 'HAVE_GTK',
- ],
'include_dirs': [
'<(java_home)/include',
'<(java_home)/include/linux',
],
- 'conditions': [
- ['use_gtk==1', {
- 'link_settings': {
- 'libraries': [
- '<!@(pkg-config --libs-only-l gobject-2.0 gthread-2.0'
- ' gtk+-2.0)',
- ],
- },
- }],
- ],
}],
- ['OS=="android"', {
- 'sources': [
- 'app/webrtc/java/jni/androidvideocapturer_jni.cc',
- 'app/webrtc/java/jni/androidvideocapturer_jni.h',
+ ['build_json==1', {
+ 'dependencies': [
+ '<(DEPTH)/third_party/jsoncpp/jsoncpp.gyp:jsoncpp',
+ ],
+ 'export_dependent_settings': [
+ '<(DEPTH)/third_party/jsoncpp/jsoncpp.gyp:jsoncpp',
],
- 'variables': {
- # This library uses native JNI exports; tell GYP so that the
- # required symbols will be kept.
- 'use_native_jni_exports': 1,
- },
}],
- ['OS=="android" and build_with_chromium==0', {
+ ['OS=="android"', {
'sources': [
+ 'app/webrtc/androidvideocapturer.cc',
+ 'app/webrtc/androidvideocapturer.h',
'app/webrtc/java/jni/androidmediacodeccommon.h',
'app/webrtc/java/jni/androidmediadecoder_jni.cc',
'app/webrtc/java/jni/androidmediadecoder_jni.h',
@@ -101,6 +87,8 @@
'app/webrtc/java/jni/androidmediaencoder_jni.h',
'app/webrtc/java/jni/androidnetworkmonitor_jni.cc',
'app/webrtc/java/jni/androidnetworkmonitor_jni.h',
+ 'app/webrtc/java/jni/androidvideocapturer_jni.cc',
+ 'app/webrtc/java/jni/androidvideocapturer_jni.h',
'app/webrtc/java/jni/surfacetexturehelper_jni.cc',
'app/webrtc/java/jni/surfacetexturehelper_jni.h',
]
@@ -108,6 +96,43 @@
],
},
{
+ 'target_name': 'libjingle_peerconnection_so',
+ 'type': 'shared_library',
+ 'dependencies': [
+ 'libjingle_peerconnection',
+ 'libjingle_peerconnection_jni',
+ ],
+ 'sources': [
+ 'app/webrtc/java/jni/jni_onload.cc',
+ ],
+ 'variables': {
+ # This library uses native JNI exports; tell GYP so that the
+ # required symbols will be kept.
+ 'use_native_jni_exports': 1,
+ },
+ 'conditions': [
+ ['OS=="linux"', {
+ 'defines': [
+ 'HAVE_GTK',
+ ],
+ 'include_dirs': [
+ '<(java_home)/include',
+ '<(java_home)/include/linux',
+ ],
+ 'conditions': [
+ ['use_gtk==1', {
+ 'link_settings': {
+ 'libraries': [
+ '<!@(pkg-config --libs-only-l gobject-2.0 gthread-2.0'
+ ' gtk+-2.0)',
+ ],
+ },
+ }],
+ ],
+ }],
+ ],
+ },
+ {
'target_name': 'libjingle_peerconnection_jar',
'type': 'none',
'actions': [
@@ -795,14 +820,6 @@
'app/webrtc/webrtcsessiondescriptionfactory.cc',
'app/webrtc/webrtcsessiondescriptionfactory.h',
],
- 'conditions': [
- ['OS=="android" and build_with_chromium==0', {
- 'sources': [
- 'app/webrtc/androidvideocapturer.h',
- 'app/webrtc/androidvideocapturer.cc',
- ],
- }],
- ],
}, # target libjingle_peerconnection
],
}
diff --git a/talk/libjingle_tests.gyp b/talk/libjingle_tests.gyp
index e7b354b126..1dc3649186 100755
--- a/talk/libjingle_tests.gyp
+++ b/talk/libjingle_tests.gyp
@@ -187,7 +187,7 @@
}, # target libjingle_p2p_unittest
{
'target_name': 'libjingle_peerconnection_unittest',
- 'type': 'executable',
+ 'type': '<(gtest_target_type)',
'dependencies': [
'<(DEPTH)/testing/gmock.gyp:gmock',
'<(webrtc_root)/base/base_tests.gyp:rtc_base_tests_utils',
@@ -218,7 +218,6 @@
# 'app/webrtc/peerconnectionproxy_unittest.cc',
'app/webrtc/remotevideocapturer_unittest.cc',
'app/webrtc/rtpsenderreceiver_unittest.cc',
- 'app/webrtc/sctputils.cc',
'app/webrtc/statscollector_unittest.cc',
'app/webrtc/test/fakeaudiocapturemodule.cc',
'app/webrtc/test/fakeaudiocapturemodule.h',
@@ -239,17 +238,14 @@
],
'conditions': [
['OS=="android"', {
- # We want gmock features that use tr1::tuple, but we currently
- # don't support the variadic templates used by libstdc++'s
- # implementation. gmock supports this scenario by providing its
- # own implementation but we must opt in to it.
- 'defines': [
- 'GTEST_USE_OWN_TR1_TUPLE=1',
- # GTEST_USE_OWN_TR1_TUPLE only works if GTEST_HAS_TR1_TUPLE is set.
- # gmock r625 made it so that GTEST_HAS_TR1_TUPLE is set to 0
- # automatically on android, so it has to be set explicitly here.
- 'GTEST_HAS_TR1_TUPLE=1',
- ],
+ 'sources': [
+ 'app/webrtc/test/androidtestinitializer.cc',
+ 'app/webrtc/test/androidtestinitializer.h',
+ ],
+ 'dependencies': [
+ '<(DEPTH)/testing/android/native_test.gyp:native_test_native_code',
+ 'libjingle.gyp:libjingle_peerconnection_jni',
+ ],
}],
['OS=="win" and clang==1', {
'msvs_settings': {
@@ -415,6 +411,17 @@
}, # target apprtc_signaling_gunit_test
],
}],
+ ['OS=="android"', {
+ 'targets': [
+ {
+ 'target_name': 'libjingle_peerconnection_unittest_apk_target',
+ 'type': 'none',
+ 'dependencies': [
+ '<(DEPTH)/webrtc/build/apk_tests.gyp:libjingle_peerconnection_unittest_apk',
+ ],
+ },
+ ],
+ }],
['test_isolation_mode != "noop"', {
'targets': [
{
diff --git a/webrtc/build/android/test_runner.py b/webrtc/build/android/test_runner.py
index 5b3f3d9e74..78a7a190b2 100755
--- a/webrtc/build/android/test_runner.py
+++ b/webrtc/build/android/test_runner.py
@@ -38,6 +38,8 @@ def main():
'webrtc/common_audio/common_audio_unittests.isolate',
'common_video_unittests':
'webrtc/common_video/common_video_unittests.isolate',
+ 'libjingle_peerconnection_unittest':
+ 'talk/libjingle_peerconnection_unittest.isolate',
'modules_tests': 'webrtc/modules/modules_tests.isolate',
'modules_unittests': 'webrtc/modules/modules_unittests.isolate',
'rtc_unittests': 'webrtc/rtc_unittests.isolate',
diff --git a/webrtc/build/apk_test.gypi b/webrtc/build/apk_test.gypi
new file mode 100644
index 0000000000..a41e436a48
--- /dev/null
+++ b/webrtc/build/apk_test.gypi
@@ -0,0 +1,40 @@
+# 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.
+
+# This is almost an identical copy of src/build/apk_test.gypi with minor
+# modifications to allow test executables starting with "lib".
+# See http://crbug.com/543820 for more details.
+
+{
+ 'dependencies': [
+ '<(DEPTH)/base/base.gyp:base_java',
+ '<(DEPTH)/build/android/pylib/device/commands/commands.gyp:chromium_commands',
+ '<(DEPTH)/build/android/pylib/remote/device/dummy/dummy.gyp:remote_device_dummy_apk',
+ '<(DEPTH)/testing/android/appurify_support.gyp:appurify_support_java',
+ '<(DEPTH)/testing/android/on_device_instrumentation.gyp:reporter_java',
+ '<(DEPTH)/tools/android/android_tools.gyp:android_tools',
+ ],
+ 'conditions': [
+ ['OS == "android"', {
+ 'variables': {
+ # These are used to configure java_apk.gypi included below.
+ 'test_type': 'gtest',
+ 'apk_name': '<(test_suite_name)',
+ 'intermediate_dir': '<(PRODUCT_DIR)/<(test_suite_name)_apk',
+ 'final_apk_path': '<(intermediate_dir)/<(test_suite_name)-debug.apk',
+ 'java_in_dir': '<(DEPTH)/testing/android/native_test/java',
+ 'native_lib_target': '<(test_suite_name)',
+ 'gyp_managed_install': 0,
+ },
+ 'includes': [
+ '../../build/java_apk.gypi',
+ '../../build/android/test_runner.gypi',
+ ],
+ }], # 'OS == "android"
+ ], # conditions
+}
diff --git a/webrtc/build/apk_tests.gyp b/webrtc/build/apk_tests.gyp
index fe05c0848a..02a13421f9 100644
--- a/webrtc/build/apk_tests.gyp
+++ b/webrtc/build/apk_tests.gyp
@@ -61,6 +61,23 @@
],
},
{
+ 'target_name': 'libjingle_peerconnection_unittest_apk',
+ 'type': 'none',
+ 'variables': {
+ 'test_suite_name': 'libjingle_peerconnection_unittest',
+ 'input_shlib_path': '<(SHARED_LIB_DIR)/<(SHARED_LIB_PREFIX)libjingle_peerconnection_unittest<(SHARED_LIB_SUFFIX)',
+ },
+ 'dependencies': [
+ '<(DEPTH)/talk/libjingle_tests.gyp:libjingle_peerconnection_unittest',
+ '<(DEPTH)/talk/libjingle.gyp:libjingle_peerconnection_java',
+ ],
+ 'includes': [
+ # Use webrtc copy of apk_test.gypi to allow test executables starting
+ # with "lib". See http://crbug.com/543820 for more details.
+ '../build/apk_test.gypi',
+ ],
+ },
+ {
'target_name': 'modules_tests_apk',
'type': 'none',
'variables': {
diff --git a/webrtc/build/apk_tests_noop.gyp b/webrtc/build/apk_tests_noop.gyp
index 489f2eea63..ed9249aec5 100644
--- a/webrtc/build/apk_tests_noop.gyp
+++ b/webrtc/build/apk_tests_noop.gyp
@@ -22,6 +22,10 @@
'type': 'none',
},
{
+ 'target_name': 'libjingle_peerconnection_unittest_apk',
+ 'type': 'none',
+ },
+ {
'target_name': 'modules_tests_apk',
'type': 'none',
},
diff --git a/webrtc/system_wrappers/include/field_trial_default.h b/webrtc/system_wrappers/include/field_trial_default.h
index d098ea1d91..7417ced39d 100644
--- a/webrtc/system_wrappers/include/field_trial_default.h
+++ b/webrtc/system_wrappers/include/field_trial_default.h
@@ -20,6 +20,8 @@ namespace field_trial {
// Note: trials_string must never be destroyed.
void InitFieldTrialsFromString(const char* trials_string);
+const char* GetFieldTrialString();
+
} // namespace field_trial
} // namespace webrtc
diff --git a/webrtc/system_wrappers/source/field_trial_default.cc b/webrtc/system_wrappers/source/field_trial_default.cc
index 1a9bd6bc79..0e2c286117 100644
--- a/webrtc/system_wrappers/source/field_trial_default.cc
+++ b/webrtc/system_wrappers/source/field_trial_default.cc
@@ -58,5 +58,9 @@ void InitFieldTrialsFromString(const char* trials_string) {
trials_init_string = trials_string;
}
+const char* GetFieldTrialString() {
+ return trials_init_string;
+}
+
} // namespace field_trial
} // namespace webrtc
diff --git a/webrtc/test/BUILD.gn b/webrtc/test/BUILD.gn
index b4dba1e37f..3ecd903522 100644
--- a/webrtc/test/BUILD.gn
+++ b/webrtc/test/BUILD.gn
@@ -27,6 +27,7 @@ source_set("field_trial") {
deps = [
"..:webrtc_common",
"../system_wrappers",
+ "../system_wrappers:field_trial_default",
]
configs += [ "..:common_config" ]
diff --git a/webrtc/test/field_trial.cc b/webrtc/test/field_trial.cc
index 613fb67679..c40d0783d8 100644
--- a/webrtc/test/field_trial.cc
+++ b/webrtc/test/field_trial.cc
@@ -18,27 +18,13 @@
#include <string>
#include "webrtc/system_wrappers/include/field_trial.h"
+#include "webrtc/system_wrappers/include/field_trial_default.h"
namespace webrtc {
namespace {
-// Clients of this library have show a clear intent to setup field trials by
-// linking with it. As so try to crash if they forget to call
-// InitFieldTrialsFromString before webrtc tries to access a field trial.
bool field_trials_initiated_ = false;
-std::map<std::string, std::string> field_trials_;
} // namespace
-namespace field_trial {
-std::string FindFullName(const std::string& trial_name) {
- assert(field_trials_initiated_);
- std::map<std::string, std::string>::const_iterator it =
- field_trials_.find(trial_name);
- if (it == field_trials_.end())
- return std::string();
- return it->second;
-}
-} // namespace field_trial
-
namespace test {
// Note: this code is copied from src/base/metrics/field_trial.cc since the aim
// is to mimic chromium --force-fieldtrials.
@@ -53,6 +39,7 @@ void InitFieldTrialsFromString(const std::string& trials_string) {
return;
size_t next_item = 0;
+ std::map<std::string, std::string> field_trials;
while (next_item < trials_string.length()) {
size_t name_end = trials_string.find(kPersistentStringSeparator, next_item);
if (name_end == trials_string.npos || next_item == name_end)
@@ -67,15 +54,18 @@ void InitFieldTrialsFromString(const std::string& trials_string) {
next_item = group_name_end + 1;
// Fail if duplicate with different group name.
- if (field_trials_.find(name) != field_trials_.end() &&
- field_trials_.find(name)->second != group_name)
+ if (field_trials.find(name) != field_trials.end() &&
+ field_trials.find(name)->second != group_name) {
break;
+ }
- field_trials_[name] = group_name;
+ field_trials[name] = group_name;
// Successfully parsed all field trials from the string.
- if (next_item == trials_string.length())
+ if (next_item == trials_string.length()) {
+ webrtc::field_trial::InitFieldTrialsFromString(trials_string.c_str());
return;
+ }
}
// Using fprintf as LOG does not print when this is called early in main.
fprintf(stderr, "Invalid field trials string.\n");
@@ -85,18 +75,18 @@ void InitFieldTrialsFromString(const std::string& trials_string) {
}
ScopedFieldTrials::ScopedFieldTrials(const std::string& config)
- : previous_field_trials_(field_trials_) {
+ : previous_field_trials_(webrtc::field_trial::GetFieldTrialString()) {
assert(field_trials_initiated_);
field_trials_initiated_ = false;
- field_trials_.clear();
- InitFieldTrialsFromString(config);
+ current_field_trials_ = config;
+ InitFieldTrialsFromString(current_field_trials_);
}
ScopedFieldTrials::~ScopedFieldTrials() {
// Should still be initialized, since InitFieldTrials is called from ctor.
// That's why we don't restore the flag.
assert(field_trials_initiated_);
- field_trials_ = previous_field_trials_;
+ webrtc::field_trial::InitFieldTrialsFromString(previous_field_trials_);
}
} // namespace test
diff --git a/webrtc/test/field_trial.h b/webrtc/test/field_trial.h
index d448f3411d..735aa1f833 100644
--- a/webrtc/test/field_trial.h
+++ b/webrtc/test/field_trial.h
@@ -39,7 +39,8 @@ class ScopedFieldTrials {
explicit ScopedFieldTrials(const std::string& config);
~ScopedFieldTrials();
private:
- const std::map<std::string, std::string> previous_field_trials_;
+ std::string current_field_trials_;
+ const char* previous_field_trials_;
};
} // namespace test
diff --git a/webrtc/test/test.gyp b/webrtc/test/test.gyp
index 8f04ce8fde..5bb7793842 100644
--- a/webrtc/test/test.gyp
+++ b/webrtc/test/test.gyp
@@ -97,6 +97,7 @@
],
'dependencies': [
'<(webrtc_root)/common.gyp:webrtc_common',
+ '<(webrtc_root)/system_wrappers/system_wrappers.gyp:field_trial_default',
'<(webrtc_root)/system_wrappers/system_wrappers.gyp:system_wrappers',
],
},