webrtc_m130/test/android/org/webrtc/native_test/RTCNativeUnitTest.java
Björn Terelius 711e1a8beb Create a custom test launcher for android
Set use_default_launcher=false in rtc_test on android

Bug: webrtc:42223878
Change-Id: If05da40b420d5da8f9e0f39560eb07380ebada14
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/368921
Owners-Override: Jeremy Leconte <jleconte@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Jeremy Leconte <jleconte@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Jeremy Leconte <jleconte@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#43505}
2024-12-06 09:30:37 +00:00

49 lines
1.7 KiB
Java

/*
* Copyright 2017 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.native_test;
import android.app.Activity;
import android.util.Log;
import org.chromium.build.NativeLibraries;
import org.webrtc.native_test.NativeTestWebrtc;
import org.webrtc.ContextUtils;
/**
* Native unit test that calls ContextUtils.initialize for WebRTC.
*/
public class RTCNativeUnitTest extends NativeTestWebrtc {
private static final String TAG = "RTCNativeUnitTest";
private static final String LIBRARY_UNDER_TEST_NAME =
"org.chromium.native_test.NativeTestInstrumentationTestRunner.LibraryUnderTest";
@Override
public void preCreate(Activity activity) {
super.preCreate(activity);
// For NativeActivity based tests, dependency libraries must be loaded before
// NativeActivity::OnCreate, otherwise loading android.app.lib_name will fail
String libraryToLoad = activity.getIntent().getStringExtra(LIBRARY_UNDER_TEST_NAME);
loadLibraries(
libraryToLoad != null ? new String[] {libraryToLoad} : NativeLibraries.LIBRARIES);
ContextUtils.initialize(activity.getApplicationContext());
}
private void loadLibraries(String[] librariesToLoad) {
for (String library : librariesToLoad) {
Log.i(TAG, "loading: " + library);
System.loadLibrary(library);
Log.i(TAG, "loaded: " + library);
}
}
}