diff options
21 files changed, 86 insertions, 358 deletions
diff --git a/talk/app/webrtc/java/jni/jni_onload.cc b/talk/app/webrtc/java/jni/jni_onload.cc deleted file mode 100644 index 9664ecdca6..0000000000 --- a/talk/app/webrtc/java/jni/jni_onload.cc +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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 67ddc8a3b1..c5de965474 100644 --- a/talk/app/webrtc/java/jni/peerconnection_jni.cc +++ b/talk/app/webrtc/java/jni/peerconnection_jni.cc @@ -142,6 +142,22 @@ 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 79826ec49d..1d7bb9211e 100644 --- a/talk/app/webrtc/peerconnectionendtoend_unittest.cc +++ b/talk/app/webrtc/peerconnectionendtoend_unittest.cc @@ -27,9 +27,6 @@ #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" @@ -117,9 +114,6 @@ 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 c0edac9fe9..f1d5353abd 100644 --- a/talk/app/webrtc/peerconnectionfactory_unittest.cc +++ b/talk/app/webrtc/peerconnectionfactory_unittest.cc @@ -30,9 +30,6 @@ #include "talk/app/webrtc/fakeportallocatorfactory.h" #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" @@ -106,9 +103,6 @@ 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, @@ -156,10 +150,6 @@ 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 1118ea7e26..edf75931a4 100644 --- a/talk/app/webrtc/peerconnectioninterface_unittest.cc +++ b/talk/app/webrtc/peerconnectioninterface_unittest.cc @@ -37,9 +37,6 @@ #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" @@ -518,12 +515,6 @@ 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 deleted file mode 100644 index a814b152f2..0000000000 --- a/talk/app/webrtc/test/DEPS +++ /dev/null @@ -1,5 +0,0 @@ -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 deleted file mode 100644 index 883c2d8178..0000000000 --- a/talk/app/webrtc/test/androidtestinitializer.cc +++ /dev/null @@ -1,74 +0,0 @@ -/* - * 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 deleted file mode 100644 index e6992825dd..0000000000 --- a/talk/app/webrtc/test/androidtestinitializer.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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 796cfe32b5..fb55e31c9c 100644 --- a/talk/app/webrtc/webrtcsdp_unittest.cc +++ b/talk/app/webrtc/webrtcsdp_unittest.cc @@ -30,9 +30,6 @@ #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" @@ -541,9 +538,6 @@ 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 257dcfeb62..c004aad875 100755 --- a/talk/libjingle.gyp +++ b/talk/libjingle.gyp @@ -43,8 +43,8 @@ ['OS=="linux" or OS=="android"', { 'targets': [ { - 'target_name': 'libjingle_peerconnection_jni', - 'type': 'static_library', + 'target_name': 'libjingle_peerconnection_so', + 'type': 'shared_library', 'dependencies': [ '<(webrtc_root)/system_wrappers/system_wrappers.gyp:field_trial_default', 'libjingle_peerconnection', @@ -63,23 +63,37 @@ ], 'conditions': [ ['OS=="linux"', { + 'defines': [ + 'HAVE_GTK', + ], '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', + '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/androidvideocapturer.cc', - 'app/webrtc/androidvideocapturer.h', + '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', @@ -87,8 +101,6 @@ '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', ] @@ -96,43 +108,6 @@ ], }, { - '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': [ @@ -819,6 +794,14 @@ '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 20cbd035fc..511f7d5ffc 100755 --- a/talk/libjingle_tests.gyp +++ b/talk/libjingle_tests.gyp @@ -176,7 +176,7 @@ }, # target libjingle_p2p_unittest { 'target_name': 'libjingle_peerconnection_unittest', - 'type': '<(gtest_target_type)', + 'type': 'executable', 'dependencies': [ '<(DEPTH)/testing/gmock.gyp:gmock', '<(webrtc_root)/base/base_tests.gyp:rtc_base_tests_utils', @@ -207,6 +207,7 @@ # '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', @@ -227,14 +228,17 @@ ], 'conditions': [ ['OS=="android"', { - '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', - ], + # 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', + ], }], ], }, # target libjingle_peerconnection_unittest @@ -389,17 +393,6 @@ }, # 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 78a7a190b2..5b3f3d9e74 100755 --- a/webrtc/build/android/test_runner.py +++ b/webrtc/build/android/test_runner.py @@ -38,8 +38,6 @@ 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 deleted file mode 100644 index a41e436a48..0000000000 --- a/webrtc/build/apk_test.gypi +++ /dev/null @@ -1,40 +0,0 @@ -# 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 02a13421f9..fe05c0848a 100644 --- a/webrtc/build/apk_tests.gyp +++ b/webrtc/build/apk_tests.gyp @@ -61,23 +61,6 @@ ], }, { - '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 ed9249aec5..489f2eea63 100644 --- a/webrtc/build/apk_tests_noop.gyp +++ b/webrtc/build/apk_tests_noop.gyp @@ -22,10 +22,6 @@ '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 7417ced39d..d098ea1d91 100644 --- a/webrtc/system_wrappers/include/field_trial_default.h +++ b/webrtc/system_wrappers/include/field_trial_default.h @@ -20,8 +20,6 @@ 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 0e2c286117..1a9bd6bc79 100644 --- a/webrtc/system_wrappers/source/field_trial_default.cc +++ b/webrtc/system_wrappers/source/field_trial_default.cc @@ -58,9 +58,5 @@ 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 45913a9bc3..2fbd6df58a 100644 --- a/webrtc/test/BUILD.gn +++ b/webrtc/test/BUILD.gn @@ -27,7 +27,6 @@ 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 c40d0783d8..613fb67679 100644 --- a/webrtc/test/field_trial.cc +++ b/webrtc/test/field_trial.cc @@ -18,13 +18,27 @@ #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. @@ -39,7 +53,6 @@ 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) @@ -54,18 +67,15 @@ 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()) { - webrtc::field_trial::InitFieldTrialsFromString(trials_string.c_str()); + if (next_item == trials_string.length()) return; - } } // Using fprintf as LOG does not print when this is called early in main. fprintf(stderr, "Invalid field trials string.\n"); @@ -75,18 +85,18 @@ void InitFieldTrialsFromString(const std::string& trials_string) { } ScopedFieldTrials::ScopedFieldTrials(const std::string& config) - : previous_field_trials_(webrtc::field_trial::GetFieldTrialString()) { + : previous_field_trials_(field_trials_) { assert(field_trials_initiated_); field_trials_initiated_ = false; - current_field_trials_ = config; - InitFieldTrialsFromString(current_field_trials_); + field_trials_.clear(); + InitFieldTrialsFromString(config); } 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_); - webrtc::field_trial::InitFieldTrialsFromString(previous_field_trials_); + field_trials_ = previous_field_trials_; } } // namespace test diff --git a/webrtc/test/field_trial.h b/webrtc/test/field_trial.h index 735aa1f833..d448f3411d 100644 --- a/webrtc/test/field_trial.h +++ b/webrtc/test/field_trial.h @@ -39,8 +39,7 @@ class ScopedFieldTrials { explicit ScopedFieldTrials(const std::string& config); ~ScopedFieldTrials(); private: - std::string current_field_trials_; - const char* previous_field_trials_; + const std::map<std::string, std::string> previous_field_trials_; }; } // namespace test diff --git a/webrtc/test/test.gyp b/webrtc/test/test.gyp index dbb1be9ad0..0af17f793b 100644 --- a/webrtc/test/test.gyp +++ b/webrtc/test/test.gyp @@ -79,7 +79,6 @@ ], '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', ], }, |