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}
This commit is contained in:
55
talk/app/webrtc/java/jni/jni_onload.cc
Normal file
55
talk/app/webrtc/java/jni/jni_onload.cc
Normal file
@ -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
|
@ -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(
|
||||
|
@ -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() {
|
||||
|
@ -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());
|
||||
|
||||
|
@ -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,
|
||||
|
5
talk/app/webrtc/test/DEPS
Normal file
5
talk/app/webrtc/test/DEPS
Normal file
@ -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",
|
||||
]
|
74
talk/app/webrtc/test/androidtestinitializer.cc
Normal file
74
talk/app/webrtc/test/androidtestinitializer.cc
Normal file
@ -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
|
37
talk/app/webrtc/test/androidtestinitializer.h
Normal file
37
talk/app/webrtc/test/androidtestinitializer.h
Normal file
@ -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_
|
@ -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);
|
||||
|
@ -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',
|
||||
@ -61,6 +61,55 @@
|
||||
'include_dirs': [
|
||||
'<(libyuv_dir)/include',
|
||||
],
|
||||
'conditions': [
|
||||
['OS=="linux"', {
|
||||
'include_dirs': [
|
||||
'<(java_home)/include',
|
||||
'<(java_home)/include/linux',
|
||||
],
|
||||
}],
|
||||
['build_json==1', {
|
||||
'dependencies': [
|
||||
'<(DEPTH)/third_party/jsoncpp/jsoncpp.gyp:jsoncpp',
|
||||
],
|
||||
'export_dependent_settings': [
|
||||
'<(DEPTH)/third_party/jsoncpp/jsoncpp.gyp:jsoncpp',
|
||||
],
|
||||
}],
|
||||
['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',
|
||||
'app/webrtc/java/jni/androidmediaencoder_jni.cc',
|
||||
'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',
|
||||
]
|
||||
}],
|
||||
],
|
||||
},
|
||||
{
|
||||
'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': [
|
||||
@ -81,30 +130,6 @@
|
||||
}],
|
||||
],
|
||||
}],
|
||||
['OS=="android"', {
|
||||
'sources': [
|
||||
'app/webrtc/java/jni/androidvideocapturer_jni.cc',
|
||||
'app/webrtc/java/jni/androidvideocapturer_jni.h',
|
||||
],
|
||||
'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', {
|
||||
'sources': [
|
||||
'app/webrtc/java/jni/androidmediacodeccommon.h',
|
||||
'app/webrtc/java/jni/androidmediadecoder_jni.cc',
|
||||
'app/webrtc/java/jni/androidmediadecoder_jni.h',
|
||||
'app/webrtc/java/jni/androidmediaencoder_jni.cc',
|
||||
'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/surfacetexturehelper_jni.cc',
|
||||
'app/webrtc/java/jni/surfacetexturehelper_jni.h',
|
||||
]
|
||||
}],
|
||||
],
|
||||
},
|
||||
{
|
||||
@ -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
|
||||
],
|
||||
}
|
||||
|
@ -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': [
|
||||
{
|
||||
|
@ -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',
|
||||
|
40
webrtc/build/apk_test.gypi
Normal file
40
webrtc/build/apk_test.gypi
Normal file
@ -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
|
||||
}
|
@ -60,6 +60,23 @@
|
||||
'../../build/apk_test.gypi',
|
||||
],
|
||||
},
|
||||
{
|
||||
'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',
|
||||
|
@ -21,6 +21,10 @@
|
||||
'target_name': 'common_video_unittests_apk',
|
||||
'type': 'none',
|
||||
},
|
||||
{
|
||||
'target_name': 'libjingle_peerconnection_unittest_apk',
|
||||
'type': 'none',
|
||||
},
|
||||
{
|
||||
'target_name': 'modules_tests_apk',
|
||||
'type': 'none',
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -27,6 +27,7 @@ source_set("field_trial") {
|
||||
deps = [
|
||||
"..:webrtc_common",
|
||||
"../system_wrappers",
|
||||
"../system_wrappers:field_trial_default",
|
||||
]
|
||||
|
||||
configs += [ "..:common_config" ]
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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',
|
||||
],
|
||||
},
|
||||
|
Reference in New Issue
Block a user