From 667f9a8a8155c41970a83be1414b57b5e37de336 Mon Sep 17 00:00:00 2001 From: Maurice Chu Date: Wed, 16 Oct 2013 13:12:22 -0700 Subject: Initial move of code from frameworks/support/multidex to here Also, - Removed extraneous Eclipse-specific configuration files that are unnecessary in the Android build tree - Includes the patch to support API level 19 from https://googleplex-android-review.git.corp.google.com/#/c/348129 - Checks for null and returns without patching the classloader when getting the package manager or package name from the passed in Context to MultiDex.install(...) since the Context object is probably a mock context for testing. - Moved the test runners to package com.android.test.runner, which seems to be the standard place for all test runners. Bug: 10674263 Change-Id: Idc894b360bd17db4acb50dd7daa2839ea8ea37e0 --- instrumentation/Android.mk | 22 +++++++++++++++ instrumentation/README.txt | 6 ++++ .../test/runner/MultiDexAndroidJUnitRunner.java | 33 ++++++++++++++++++++++ .../android/test/runner/MultiDexTestRunner.java | 31 ++++++++++++++++++++ 4 files changed, 92 insertions(+) create mode 100644 instrumentation/Android.mk create mode 100644 instrumentation/README.txt create mode 100644 instrumentation/src/com/android/test/runner/MultiDexAndroidJUnitRunner.java create mode 100644 instrumentation/src/com/android/test/runner/MultiDexTestRunner.java (limited to 'instrumentation') diff --git a/instrumentation/Android.mk b/instrumentation/Android.mk new file mode 100644 index 0000000..22ee642 --- /dev/null +++ b/instrumentation/Android.mk @@ -0,0 +1,22 @@ +# Copyright (C) 2013 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) +LOCAL_MODULE := android-support-multidex-instrumentation +LOCAL_JAVA_LIBRARIES := android-support-multidex android-test-lib +LOCAL_SDK_VERSION := 4 +LOCAL_SRC_FILES := $(call all-java-files-under, src) +include $(BUILD_STATIC_JAVA_LIBRARY) diff --git a/instrumentation/README.txt b/instrumentation/README.txt new file mode 100644 index 0000000..322676b --- /dev/null +++ b/instrumentation/README.txt @@ -0,0 +1,6 @@ +Library Project including compatibility IntrumentationTestRunner +for multiple dex applications. + +This can be used by an Android test project to set up the classloader +of applications with multiple dexes. + diff --git a/instrumentation/src/com/android/test/runner/MultiDexAndroidJUnitRunner.java b/instrumentation/src/com/android/test/runner/MultiDexAndroidJUnitRunner.java new file mode 100644 index 0000000..afb6e08 --- /dev/null +++ b/instrumentation/src/com/android/test/runner/MultiDexAndroidJUnitRunner.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.test.runner; + +import com.android.test.runner.AndroidJUnitRunner; + +import android.os.Bundle; +import android.support.multidex.MultiDex; + +/** + * Extends AndroidJUnitRunner to patch up things for GMS Core multi-dex support. + */ +public class MultiDexAndroidJUnitRunner extends AndroidJUnitRunner { + @Override + public void onCreate(Bundle arguments) { + MultiDex.install(getTargetContext()); + super.onCreate(arguments); + } +} diff --git a/instrumentation/src/com/android/test/runner/MultiDexTestRunner.java b/instrumentation/src/com/android/test/runner/MultiDexTestRunner.java new file mode 100644 index 0000000..a93a740 --- /dev/null +++ b/instrumentation/src/com/android/test/runner/MultiDexTestRunner.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.test.runner; + +import android.os.Bundle; +import android.support.multidex.MultiDex; +import android.test.InstrumentationTestRunner; + +public class MultiDexTestRunner extends InstrumentationTestRunner { + + @Override + public void onCreate(Bundle arguments) { + MultiDex.install(getTargetContext()); + super.onCreate(arguments); + } + +} -- cgit v1.2.3