Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ maven.install(
"androidx.concurrent:concurrent-futures-ktx:1.2.0",
"androidx.core:core:1.6.0",
"androidx.lifecycle:lifecycle-common:2.3.1",
"androidx.multidex:multidex:2.0.0",
"androidx.tracing:tracing:1.1.0",
"androidx.window:window-java:1.1.0",
"androidx.window:window-core:1.1.0",
Expand Down
1 change: 0 additions & 1 deletion build_extensions/android_library_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ def axt_android_library_test(
data = [],
device_list = None,
manifest = None,
multidex = None,
deps = [],
**kwargs):
"""Placeholder for future instrumentation test support.
Expand Down
20 changes: 0 additions & 20 deletions build_extensions/mainDexClasses.rules

This file was deleted.

2 changes: 1 addition & 1 deletion core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

**API Changes**

* Update to minSdkVersion 23
* Update to minSdkVersion 23 and remove all related logic for SDKs < 23

**Breaking API Changes**

Expand Down
2 changes: 0 additions & 2 deletions core/javatests/androidx/test/core/app/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@ licenses(["notice"])
android_binary(
name = "ActivityScenarioTest_target",
manifest = "AndroidManifest_target.xml",
multidex = "legacy",
deps = [
"//core/javatests/androidx/test/core/app/testing",
"//core/javatests/androidx/test/core/app/testing:manifest",
"@maven//:androidx_multidex_multidex",
],
)

Expand Down
2 changes: 1 addition & 1 deletion espresso/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The following artifacts were released:

**API Changes**

* Update to minSdkVersion 23
* Update to minSdkVersion 23 and remove all related logic for SDKs < 23

**Breaking API Changes**

Expand Down
2 changes: 1 addition & 1 deletion espresso/device/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

**API Changes**

* Update to minSdkVersion 23
* Update to minSdkVersion 23 and remove all related logic for SDKs < 23

**Breaking API Changes**

Expand Down
2 changes: 1 addition & 1 deletion ext/junit/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ are released.

**API Changes**

* Update to minSdkVersion 23
* Update to minSdkVersion 23 and remove all related logic for SDKs < 23

**Breaking API Changes**

Expand Down
2 changes: 1 addition & 1 deletion ext/truth/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

**API Changes**

* Update to minSdkVersion 23
* Update to minSdkVersion 23 and remove all related logic for SDKs < 23

**Breaking API Changes**

Expand Down
2 changes: 0 additions & 2 deletions gradle-tests/espresso/accessibility/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ android {
defaultConfig {
minSdk rootProject.ext.minSdk
targetSdk rootProject.ext.targetSdk
multiDexEnabled = true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

Expand Down Expand Up @@ -44,7 +43,6 @@ android {
}

dependencies {
androidTestImplementation "androidx.multidex:multidex:2.0.0"
androidTestImplementation libs.ext.junit
androidTestImplementation libs.espresso.accessibility
androidTestImplementation libs.espresso.core
Expand Down
2 changes: 0 additions & 2 deletions gradle-tests/espresso/contrib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ android {
defaultConfig {
minSdk rootProject.ext.minSdk
targetSdk rootProject.ext.targetSdk
multiDexEnabled true

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down Expand Up @@ -46,7 +45,6 @@ android {
}

dependencies {
implementation "androidx.multidex:multidex:2.0.0"
implementation "androidx.recyclerview:recyclerview:1.2.1"
androidTestImplementation libs.espresso.contrib
androidTestImplementation libs.ext.junit
Expand Down
1 change: 0 additions & 1 deletion gradle-tests/espresso/device/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ android {
defaultConfig {
minSdk rootProject.ext.minSdk
targetSdk rootProject.ext.targetSdk
multiDexEnabled true

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
2 changes: 0 additions & 2 deletions gradle-tests/espresso/idling_resource/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ android {
defaultConfig {
minSdk rootProject.ext.minSdk
targetSdk rootProject.ext.targetSdk
multiDexEnabled true

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down Expand Up @@ -47,7 +46,6 @@ android {

dependencies {
implementation "androidx.annotation:annotation:1.7.0-beta01"
implementation "androidx.multidex:multidex:2.0.0"
implementation libs.espresso.idlingresource
androidTestImplementation libs.espresso.core
androidTestImplementation libs.espresso.intents
Expand Down
2 changes: 1 addition & 1 deletion runner/android_junit_runner/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

**API Changes**

* Update to minSdkVersion 23
* Update to minSdkVersion 23 and remove all related logic for SDKs < 23

**Breaking API Changes**

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,16 @@
package androidx.test.internal.runner;

import android.app.Instrumentation;
import android.content.pm.ApplicationInfo;
import android.os.Build.VERSION;
import android.util.Log;
import dalvik.system.DexFile;
import java.io.File;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.regex.Pattern;

/**
* Finds class entries in provided paths to scan.
Expand Down Expand Up @@ -205,46 +198,11 @@ public ClassPathScanner(Collection<String> paths) {
* <p>This will only scan for tests in the current Apk aka testContext. Note that this represents
* a change from InstrumentationTestRunner where getTargetContext().getPackageCodePath() aka app
* under test was also scanned.
*
* <p>This method will also handle cases where test apk is using multidex.
*/
public static Collection<String> getDefaultClasspaths(Instrumentation instrumentation) {
Collection<String> classPaths = new ArrayList<>();
// add the test apk to claspath
classPaths.add(instrumentation.getContext().getPackageCodePath());

if (VERSION.SDK_INT <= 20) {
// for platforms that do not support multidex natively, getPackageCodePath is not sufficient -
// each individual class.dex needs to be added.
Pattern extractedSecondaryName = Pattern.compile(".*\\.classes\\d+\\.zip");
ApplicationInfo applicationInfo;
try {
// need to get target context's application info, because the test apk classes.dex are
// extracted there
applicationInfo = instrumentation.getTargetContext().getApplicationInfo();
} catch (RuntimeException re) {
Log.w(
TAG,
"Failed to retrieve ApplicationInfo, no additional .dex files add for "
+ "app under test",
re);
return Collections.emptyList();
}
File root = new File(applicationInfo.dataDir);
ArrayDeque<File> directoriesToScan = new ArrayDeque<>();
directoriesToScan.add(root);
while (!directoriesToScan.isEmpty()) {
File directory = directoriesToScan.pop();
for (File element : directory.listFiles()) {
if (element.isDirectory()) {
directoriesToScan.add(element);
} else if (element.isFile()
&& extractedSecondaryName.matcher(element.getName()).matches()) {
classPaths.add(element.getPath());
}
}
}
}
return classPaths;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
package androidx.test.runner;

import android.app.Activity;
import android.app.Application;
import android.app.Instrumentation;
import android.content.Context;
import android.os.Bundle;
import android.os.Debug;
import android.os.StrictMode;
Expand Down Expand Up @@ -277,28 +275,14 @@ public class AndroidJUnitRunner extends MonitoringInstrumentation
private static final String LOG_TAG = "AndroidJUnitRunner";

private Bundle arguments;
private InstrumentationResultPrinter instrumentationResultPrinter;
private final InstrumentationResultPrinter instrumentationResultPrinter =
new InstrumentationResultPrinter();
;
private RunnerArgs runnerArgs;
private TestEventClient testEventClient = TestEventClient.NO_OP_CLIENT;
private final Set<Throwable> appExceptionsHandled =
Collections.newSetFromMap(new WeakHashMap<>());

@Override
public Application newApplication(ClassLoader cl, String className, Context context)
throws InstantiationException, IllegalAccessException, ClassNotFoundException {
Log.i(LOG_TAG, "newApplication " + className);
// install multidex as soon as possible
installMultidex();

if (instrumentationResultPrinter == null) {
// Create instrumentationResultPrinter as early as possible to assist with
// exception handling. InstrumentationResultPrinter use ConcurrentLinkedList,
// and as that is desugared (see b/246860430) it cannot be instantiated before
// multidex is loaded.
instrumentationResultPrinter = new InstrumentationResultPrinter();
}
return super.newApplication(cl, className, context);
}

/** {@inheritDoc} */
@Override
Expand All @@ -307,16 +291,6 @@ public void onCreate(Bundle arguments) {
Trace.beginSection("AndroidJUnitRunner#onCreate");
try {
super.onCreate(arguments);
if (instrumentationResultPrinter == null) {
// Create instrumentationResultPrinter as early as possible to assist with
// exception handling. InstrumentationResultPrinter use ConcurrentLinkedList,
// and as that is desugared (see b/246860430) it cannot be instantiated before
// multidex is loaded.
// On API level <= 15, #onCreate is called earlier than #newApplication so it
// can be null, or if the system server itself is being instrumented. See
// MonitoringInstrumentation#onCreate.
instrumentationResultPrinter = new InstrumentationResultPrinter();
}
this.arguments = arguments;
registerTestStorage(this.arguments);
parseRunnerArgs(this.arguments);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
# Description: Tests for Runner

load("@build_bazel_rules_android//android:rules.bzl", "android_binary")
load("//build_extensions:android_library_test.bzl", "axt_android_library_test")
load("//build_extensions:axt_android_application_test.bzl", "axt_android_application_test")
load("//build_extensions:axt_android_local_test.bzl", "axt_android_local_test")
load(
"//build_extensions:phone_devices.bzl",
"apis",
"devices",
)

package(
default_applicable_licenses = ["//:license"],
Expand All @@ -17,76 +10,6 @@ package(

licenses(["notice"])

# test classpath scanning for a multidex self-instrumenting apk
axt_android_library_test(
name = "ClassPathScannerTest",
srcs = ["ClassPathScannerTest.java"],
# api 15 is flaky
# dex2oat fails on 24 + 25 for an unknown reason
device_list = devices(apis(
exclude_apis = [
24,
25,
],
)),
deps = [
# include the large number of methods that will force classes off main dex
"//testapps/multidex_testapp/java/androidx/test/multidex/app:src",
"//core",
"//ext/junit",
"//runner/android_junit_runner",
"@maven//:junit_junit",
"@maven//:org_mockito_mockito_core",
"@maven//:com_google_truth_truth",
],
)

# # test classpath scanning for a multidex test apk, with a small app apk
android_binary(
name = "stub_target_app",
manifest = "//build_extensions:AndroidManifest_target_stub.xml",
manifest_values = {
"applicationId": "androidx.test.multidex",
},
multidex = "legacy",
deps = [
"//runner/android_junit_runner/javatests/androidx/test/testing/fixtures",
"@maven//:androidx_multidex_multidex",
],
)

axt_android_application_test(
name = "ClassPathScannerTest_stub_application_under_test",
srcs = ["ClassPathScannerTest.java"],
# TODO(b/116007991): enable more APIs once fixed
device_list = devices([
23,
26,
27,
28,
29,
30,
]),
instruments = ":stub_target_app",
manifest = "//build_extensions:AndroidManifest_instrumentation_test_template.xml",
manifest_values = {
"applicationId": "androidx.test.tests",
"instrumentationTargetPackage": "androidx.test.multidex",
"minSdkVersion": "21",
},
multidex = "legacy",
deps = [
# include the large number of methods that will force classes off main dex
"//testapps/multidex_testapp/java/androidx/test/multidex/app:src",
"//core",
"//ext/junit",
"//runner/android_junit_runner",
"@maven//:junit_junit",
"@maven//:org_mockito_mockito_core",
"@maven//:com_google_truth_truth",
],
)

axt_android_library_test(
name = "AndroidLogOnlyBuilderTest",
srcs = [
Expand Down
Loading
Loading