diff options
| author | 2016-08-03 17:34:45 +0200 | |
|---|---|---|
| committer | 2017-05-12 15:42:47 +0200 | |
| commit | 50f811c8fc31fbae4ae41f825d5d7b1166c6b4d4 (patch) | |
| tree | 3b7c284912d99a71835e0345a6f45b962e985d81 | |
| parent | ed112e3c11286bb8263185c2d30ab6a933686fff (diff) | |
Add tests on MultiDex.installInstrumentation
Either with dedicated Instrumentation or with MultiDexTestRunner.
Bug: 30575093
Test: Those are tests
Change-Id: I97a22625409fd587e1d63fa4207eb72ca67f2c82
21 files changed, 505 insertions, 18 deletions
diff --git a/core/tests/hosttests/test-apps/MultiDexLegacyAndException/Android.mk b/core/tests/hosttests/test-apps/MultiDexLegacyAndException/Android.mk index 14b032e37f4c..c66a10cc31f7 100644 --- a/core/tests/hosttests/test-apps/MultiDexLegacyAndException/Android.mk +++ b/core/tests/hosttests/test-apps/MultiDexLegacyAndException/Android.mk @@ -18,7 +18,7 @@ LOCAL_PATH:= $(call my-dir) ## The application with a minimal main dex include $(CLEAR_VARS) -LOCAL_STATIC_JAVA_LIBRARIES := android-support-multidex +LOCAL_STATIC_JAVA_LIBRARIES := android-support-multidex android-support-multidex-instrumentation android-support-test LOCAL_MODULE_TAGS := tests LOCAL_SRC_FILES := $(call all-java-files-under, src) @@ -35,16 +35,11 @@ mainDexList:= \ $(call intermediates-dir-for,APPS,$(LOCAL_PACKAGE_NAME),$(LOCAL_IS_HOST_MODULE),common)/maindex.list LOCAL_DX_FLAGS := --multi-dex --main-dex-list=$(mainDexList) --minimal-main-dex -LOCAL_JACK_FLAGS := -D jack.dex.output.policy=minimal-multidex -D jack.preprocessor=true\ - -D jack.preprocessor.file=$(LOCAL_PATH)/test.jpp -D jack.dex.output.multidex.legacy=true -################################# -include $(BUILD_SYSTEM)/configure_local_jack.mk -################################# +LOCAL_MIN_SDK_VERSION := 8 -ifdef LOCAL_JACK_ENABLED -LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/test.jpp -endif +LOCAL_JACK_FLAGS := -D jack.dex.output.policy=minimal-multidex \ + -D jack.dex.output.multidex.legacy=true include $(BUILD_PACKAGE) diff --git a/core/tests/hosttests/test-apps/MultiDexLegacyAndException/AndroidManifest.xml b/core/tests/hosttests/test-apps/MultiDexLegacyAndException/AndroidManifest.xml index 7fff71118604..98d8f27179fd 100644 --- a/core/tests/hosttests/test-apps/MultiDexLegacyAndException/AndroidManifest.xml +++ b/core/tests/hosttests/test-apps/MultiDexLegacyAndException/AndroidManifest.xml @@ -22,7 +22,15 @@ <uses-library android:name="android.test.runner" /> </application> - <instrumentation android:name="android.test.InstrumentationTestRunner" + <instrumentation android:name="com.android.test.runner.MultiDexTestRunner" + android:targetPackage="com.android.multidexlegacyandexception" + android:label="Test for MultiDexLegacyAndException" /> + + <instrumentation android:name="com.android.multidexlegacyandexception.tests.MultiDexAndroidJUnitRunner" + android:targetPackage="com.android.multidexlegacyandexception" + android:label="Test for MultiDexLegacyAndException" /> + + <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner" android:targetPackage="com.android.multidexlegacyandexception" android:label="Test for MultiDexLegacyAndException" /> </manifest> diff --git a/core/tests/hosttests/test-apps/MultiDexLegacyAndException/src/com/android/multidexlegacyandexception/Test.java b/core/tests/hosttests/test-apps/MultiDexLegacyAndException/src/com/android/multidexlegacyandexception/tests/ActivityTest.java index 8d065a43ac61..d6ac3e57242b 100644 --- a/core/tests/hosttests/test-apps/MultiDexLegacyAndException/src/com/android/multidexlegacyandexception/Test.java +++ b/core/tests/hosttests/test-apps/MultiDexLegacyAndException/src/com/android/multidexlegacyandexception/tests/ActivityTest.java @@ -13,16 +13,31 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.android.multidexlegacyandexception; +package com.android.multidexlegacyandexception.tests; + +import com.android.multidexlegacyandexception.CaughtOnlyByIntermediateException; +import com.android.multidexlegacyandexception.CaughtOnlyException; +import com.android.multidexlegacyandexception.ExceptionInMainDex; +import com.android.multidexlegacyandexception.ExceptionInMainDex2; +import com.android.multidexlegacyandexception.ExceptionInSecondaryDex; +import com.android.multidexlegacyandexception.ExceptionInSecondaryDex2; +import com.android.multidexlegacyandexception.ExceptionInSecondaryDexWithSuperInMain; +import com.android.multidexlegacyandexception.IntermediateClass; +import com.android.multidexlegacyandexception.MainActivity; +import com.android.multidexlegacyandexception.MiniIntermediateClass; +import com.android.multidexlegacyandexception.SuperExceptionInMainDex; +import com.android.multidexlegacyandexception.SuperExceptionInSecondaryDex; +import com.android.multidexlegacyandexception.TestApplication; /** - * Run the tests with: <code>adb shell am instrument -w - com.android.multidexlegacyandexception/android.test.InstrumentationTestRunner + * Run the tests with: + * <code> +adb shell am instrument -w com.android.multidexlegacyandexception/com.android.multidexlegacyandexception.tests.MultiDexAndroidJUnitRunner </code> */ @SuppressWarnings("deprecation") -public class Test extends android.test.ActivityInstrumentationTestCase2<MainActivity> { - public Test() { +public class ActivityTest extends android.test.ActivityInstrumentationTestCase2<MainActivity> { + public ActivityTest() { super(MainActivity.class); } diff --git a/core/tests/hosttests/test-apps/MultiDexLegacyAndException/src/com/android/multidexlegacyandexception/tests/MultiDexAndroidJUnitRunner.java b/core/tests/hosttests/test-apps/MultiDexLegacyAndException/src/com/android/multidexlegacyandexception/tests/MultiDexAndroidJUnitRunner.java new file mode 100644 index 000000000000..758ac1dcb4a0 --- /dev/null +++ b/core/tests/hosttests/test-apps/MultiDexLegacyAndException/src/com/android/multidexlegacyandexception/tests/MultiDexAndroidJUnitRunner.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2016 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.multidexlegacyandexception.tests; + +import android.os.Bundle; +import android.support.multidex.MultiDex; +import android.support.test.runner.AndroidJUnitRunner; + +public class MultiDexAndroidJUnitRunner extends AndroidJUnitRunner { + + @Override + public void onCreate(Bundle arguments) { + MultiDex.installInstrumentation(getContext(), getTargetContext()); + super.onCreate(arguments); + } + +} diff --git a/core/tests/hosttests/test-apps/MultiDexLegacyAndException/src/com/android/multidexlegacyandexception/tests/NoActivityIntermediate.java b/core/tests/hosttests/test-apps/MultiDexLegacyAndException/src/com/android/multidexlegacyandexception/tests/NoActivityIntermediate.java new file mode 100644 index 000000000000..3a8acc6b59be --- /dev/null +++ b/core/tests/hosttests/test-apps/MultiDexLegacyAndException/src/com/android/multidexlegacyandexception/tests/NoActivityIntermediate.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2016 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.multidexlegacyandexception.tests; + +public class NoActivityIntermediate { + + public static int get() { + return NoActivitySubTest.get(); + } + +} diff --git a/core/tests/hosttests/test-apps/MultiDexLegacyAndException/src/com/android/multidexlegacyandexception/tests/NoActivityJUnit3Test.java b/core/tests/hosttests/test-apps/MultiDexLegacyAndException/src/com/android/multidexlegacyandexception/tests/NoActivityJUnit3Test.java new file mode 100644 index 000000000000..31cb939813d3 --- /dev/null +++ b/core/tests/hosttests/test-apps/MultiDexLegacyAndException/src/com/android/multidexlegacyandexception/tests/NoActivityJUnit3Test.java @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2014 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.multidexlegacyandexception.tests; + +import android.test.InstrumentationTestCase; +import com.android.multidexlegacyandexception.CaughtOnlyByIntermediateException; +import com.android.multidexlegacyandexception.CaughtOnlyException; +import com.android.multidexlegacyandexception.ExceptionInMainDex; +import com.android.multidexlegacyandexception.ExceptionInMainDex2; +import com.android.multidexlegacyandexception.ExceptionInSecondaryDex; +import com.android.multidexlegacyandexception.ExceptionInSecondaryDex2; +import com.android.multidexlegacyandexception.ExceptionInSecondaryDexWithSuperInMain; +import com.android.multidexlegacyandexception.IntermediateClass; +import com.android.multidexlegacyandexception.MiniIntermediateClass; +import com.android.multidexlegacyandexception.SuperExceptionInMainDex; +import com.android.multidexlegacyandexception.SuperExceptionInSecondaryDex; +import com.android.multidexlegacyandexception.TestApplication; +import junit.framework.Assert; + +/** + * Run the tests with: <code> +adb shell am instrument -w com.android.multidexlegacyandexception/com.android.test.runner.MultiDexTestRunner +</code> + * or <code> +adb shell am instrument -w com.android.multidexlegacyandexception/com.android.multidexlegacyandexception.tests.MultiDexAndroidJUnitRunner +</code> + */ +@SuppressWarnings("deprecation") +public class NoActivityJUnit3Test extends InstrumentationTestCase { + + @org.junit.Test + public void testExceptionInMainDex() { + Assert.assertEquals(10, TestApplication.get(true)); + } + + @org.junit.Test + public void testExceptionInIntermediate() { + Assert.assertEquals(11, IntermediateClass.get3(true)); + Assert.assertEquals(11, MiniIntermediateClass.get3(true)); + Assert.assertEquals(11, IntermediateClass.get4(true)); + Assert.assertEquals(1, IntermediateClass.get5(null)); + Assert.assertEquals(10, IntermediateClass.get5(new ExceptionInMainDex())); + Assert.assertEquals(11, IntermediateClass.get5(new ExceptionInSecondaryDex())); + Assert.assertEquals(12, IntermediateClass.get5(new ExceptionInMainDex2())); + Assert.assertEquals(13, IntermediateClass.get5(new ExceptionInSecondaryDex2())); + Assert.assertEquals(14, IntermediateClass.get5(new OutOfMemoryError())); + Assert.assertEquals(17, IntermediateClass.get5(new CaughtOnlyException())); + Assert.assertEquals(39, IntermediateClass.get5(new ExceptionInSecondaryDexWithSuperInMain())); + Assert.assertEquals(23, IntermediateClass.get5(new SuperExceptionInSecondaryDex())); + Assert.assertEquals(23, IntermediateClass.get5(new SuperExceptionInMainDex())); + Assert.assertEquals(23, IntermediateClass.get5(new CaughtOnlyByIntermediateException())); + Assert.assertEquals(37, IntermediateClass.get5(new ArrayIndexOutOfBoundsException())); + } + + @org.junit.Test + public void testMultidexedTest() { + Assert.assertEquals(7, NoActivityIntermediate.get()); + } + +} diff --git a/core/tests/hosttests/test-apps/MultiDexLegacyAndException/src/com/android/multidexlegacyandexception/tests/NoActivityJUnit4Test.java b/core/tests/hosttests/test-apps/MultiDexLegacyAndException/src/com/android/multidexlegacyandexception/tests/NoActivityJUnit4Test.java new file mode 100644 index 000000000000..94a5b7fa66f2 --- /dev/null +++ b/core/tests/hosttests/test-apps/MultiDexLegacyAndException/src/com/android/multidexlegacyandexception/tests/NoActivityJUnit4Test.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2016 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.multidexlegacyandexception.tests; + +import android.support.test.runner.AndroidJUnit4; +import org.junit.runner.RunWith; + +/** + * Run the tests with: <code> +adb shell am instrument -w com.android.multidexlegacyandexception/com.android.test.runner.MultiDexTestRunner +</code> + * or <code> +adb shell am instrument -w com.android.multidexlegacyandexception/com.android.multidexlegacyandexception.tests.MultiDexAndroidJUnitRunner +</code> + */ +@RunWith(AndroidJUnit4.class) +public class NoActivityJUnit4Test extends NoActivityJUnit3Test { + + @org.junit.Test + public void multidexedTestJUnit4() { + super.testMultidexedTest(); + } + +} diff --git a/core/tests/hosttests/test-apps/MultiDexLegacyAndException/src/com/android/multidexlegacyandexception/tests/NoActivitySubTest.java b/core/tests/hosttests/test-apps/MultiDexLegacyAndException/src/com/android/multidexlegacyandexception/tests/NoActivitySubTest.java new file mode 100644 index 000000000000..4885c2ef5865 --- /dev/null +++ b/core/tests/hosttests/test-apps/MultiDexLegacyAndException/src/com/android/multidexlegacyandexception/tests/NoActivitySubTest.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2016 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.multidexlegacyandexception.tests; + +public class NoActivitySubTest { + + public static int get() { + return 7; + } + +} diff --git a/core/tests/hosttests/test-apps/MultiDexLegacyAndException/test.jpp b/core/tests/hosttests/test-apps/MultiDexLegacyAndException/test.jpp deleted file mode 100644 index 0d027ed236fb..000000000000 --- a/core/tests/hosttests/test-apps/MultiDexLegacyAndException/test.jpp +++ /dev/null @@ -1,3 +0,0 @@ -test: - @@com.android.jack.annotations.ForceInMainDex - class com.android.multidexlegacyandexception.Test diff --git a/core/tests/hosttests/test-apps/MultiDexLegacyTestApp/Android.mk b/core/tests/hosttests/test-apps/MultiDexLegacyTestApp/Android.mk index 208eceb6273d..278419315779 100644 --- a/core/tests/hosttests/test-apps/MultiDexLegacyTestApp/Android.mk +++ b/core/tests/hosttests/test-apps/MultiDexLegacyTestApp/Android.mk @@ -44,6 +44,8 @@ ifdef LOCAL_JACK_ENABLED LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/test.jpp endif +LOCAL_MIN_SDK_VERSION := 8 + include $(BUILD_PACKAGE) ifndef LOCAL_JACK_ENABLED @@ -85,6 +87,8 @@ ifdef LOCAL_JACK_ENABLED LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/test.jpp endif +LOCAL_MIN_SDK_VERSION := 8 + include $(BUILD_PACKAGE) ifndef LOCAL_JACK_ENABLED diff --git a/core/tests/hosttests/test-apps/MultiDexLegacyTestAppTests/Android.mk b/core/tests/hosttests/test-apps/MultiDexLegacyTestAppTests/Android.mk new file mode 100644 index 000000000000..69ec5ceb1daf --- /dev/null +++ b/core/tests/hosttests/test-apps/MultiDexLegacyTestAppTests/Android.mk @@ -0,0 +1,40 @@ +# Copyright (C) 2014 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) + + +## The application with a minimal main dex +include $(CLEAR_VARS) + +LOCAL_STATIC_JAVA_LIBRARIES := android-support-multidex-instrumentation +LOCAL_MODULE_TAGS := tests + +LOCAL_SRC_FILES := $(call all-java-files-under, src) + +LOCAL_SDK_VERSION := 8 + +LOCAL_PACKAGE_NAME := MultiDexLegacyTestAppTests + +LOCAL_DEX_PREOPT := false + +LOCAL_JAVACFLAGS := -nowarn + +LOCAL_MIN_SDK_VERSION := 8 + +LOCAL_INSTRUMENTATION_FOR := MultiDexLegacyTestApp + +LOCAL_JACK_FLAGS := -D jack.dex.output.policy=minimal-multidex -D jack.dex.output.multidex.legacy=true + +include $(BUILD_PACKAGE) diff --git a/core/tests/hosttests/test-apps/MultiDexLegacyTestAppTests/AndroidManifest.xml b/core/tests/hosttests/test-apps/MultiDexLegacyTestAppTests/AndroidManifest.xml new file mode 100644 index 000000000000..35369c7da6a1 --- /dev/null +++ b/core/tests/hosttests/test-apps/MultiDexLegacyTestAppTests/AndroidManifest.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.android.multidexlegacytestapp.test" + android:versionCode="1" + android:versionName="1.0" > + + <uses-sdk android:minSdkVersion="8" /> + <instrumentation + android:name="com.android.test.runner.MultiDexTestRunner" + android:targetPackage="com.android.multidexlegacytestapp" /> + <instrumentation + android:name="android.test.InstrumentationTestRunner" + android:targetPackage="com.android.multidexlegacytestapp" /> + + <application + android:label="multidexlegacytestapp.test" > + <uses-library android:name="android.test.runner" /> + </application> +</manifest>
\ No newline at end of file diff --git a/core/tests/hosttests/test-apps/MultiDexLegacyTestAppTests/src/com/android/multidexlegacytestapp/test/InstrumentationTest.java b/core/tests/hosttests/test-apps/MultiDexLegacyTestAppTests/src/com/android/multidexlegacytestapp/test/InstrumentationTest.java new file mode 100644 index 000000000000..a0288f2e0d9c --- /dev/null +++ b/core/tests/hosttests/test-apps/MultiDexLegacyTestAppTests/src/com/android/multidexlegacytestapp/test/InstrumentationTest.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2014 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.multidexlegacytestapp.test; + +import android.test.InstrumentationTestCase; +import com.android.multidexlegacytestapp.manymethods.Big001; +import com.android.multidexlegacytestapp.manymethods.Big079; +import junit.framework.Assert; + +/** + * Run the tests with: <code> +adb shell am instrument -w com.android.multidexlegacytestapp.test/com.android.test.runner.MultiDexTestRunner +</code> + */ +public class InstrumentationTest extends InstrumentationTestCase { + + public void testExceptionInMainDex() { + Assert.assertEquals(0, new Big001().get0()); + Assert.assertEquals(100, new Big079().get100()); + } + + public void testMultidexedTest() { + Assert.assertEquals(7, Intermediate.get()); + } + +} diff --git a/core/tests/hosttests/test-apps/MultiDexLegacyTestAppTests/src/com/android/multidexlegacytestapp/test/Intermediate.java b/core/tests/hosttests/test-apps/MultiDexLegacyTestAppTests/src/com/android/multidexlegacytestapp/test/Intermediate.java new file mode 100644 index 000000000000..9a79c7aa4db7 --- /dev/null +++ b/core/tests/hosttests/test-apps/MultiDexLegacyTestAppTests/src/com/android/multidexlegacytestapp/test/Intermediate.java @@ -0,0 +1,9 @@ +package com.android.multidexlegacytestapp.test; + +public class Intermediate { + + public static int get() { + return SubTest.get(); + } + +} diff --git a/core/tests/hosttests/test-apps/MultiDexLegacyTestAppTests/src/com/android/multidexlegacytestapp/test/SubTest.java b/core/tests/hosttests/test-apps/MultiDexLegacyTestAppTests/src/com/android/multidexlegacytestapp/test/SubTest.java new file mode 100644 index 000000000000..e28584b5f321 --- /dev/null +++ b/core/tests/hosttests/test-apps/MultiDexLegacyTestAppTests/src/com/android/multidexlegacytestapp/test/SubTest.java @@ -0,0 +1,11 @@ +package com.android.multidexlegacytestapp.test; + +import com.android.multidexlegacytestapp.manymethods.Big080; + +public class SubTest { + + public static int get() { + return new Big080().get7(); + } + +} diff --git a/core/tests/hosttests/test-apps/MultiDexLegacyTestAppTests2/Android.mk b/core/tests/hosttests/test-apps/MultiDexLegacyTestAppTests2/Android.mk new file mode 100644 index 000000000000..f2bd35363003 --- /dev/null +++ b/core/tests/hosttests/test-apps/MultiDexLegacyTestAppTests2/Android.mk @@ -0,0 +1,63 @@ +# Copyright (C) 2014 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) + + +## The tests with only one dex +include $(CLEAR_VARS) + +LOCAL_STATIC_JAVA_LIBRARIES := android-support-multidex-instrumentation android-support-test +LOCAL_MODULE_TAGS := tests + +LOCAL_SRC_FILES := $(call all-java-files-under, src) + +LOCAL_SDK_VERSION := current + +LOCAL_PACKAGE_NAME := MultiDexLegacyTestAppTests2 + +LOCAL_DEX_PREOPT := false + +LOCAL_JAVACFLAGS := -nowarn + +LOCAL_MIN_SDK_VERSION := 8 + +LOCAL_INSTRUMENTATION_FOR := MultiDexLegacyTestApp + +include $(BUILD_PACKAGE) + + +## The tests with a minimal main dex +include $(CLEAR_VARS) + +LOCAL_STATIC_JAVA_LIBRARIES := android-support-multidex-instrumentation android-support-test +LOCAL_MODULE_TAGS := tests + +LOCAL_SRC_FILES := $(call all-java-files-under, src) + +LOCAL_SDK_VERSION := 8 + +LOCAL_PACKAGE_NAME := MultiDexLegacyTestAppTests2-multidex + +LOCAL_DEX_PREOPT := false + +LOCAL_JAVACFLAGS := -nowarn + +LOCAL_MIN_SDK_VERSION := 8 + +LOCAL_INSTRUMENTATION_FOR := MultiDexLegacyTestApp + +LOCAL_JACK_FLAGS := -D jack.dex.output.policy=minimal-multidex -D jack.dex.output.multidex.legacy=true + +include $(BUILD_PACKAGE) diff --git a/core/tests/hosttests/test-apps/MultiDexLegacyTestAppTests2/AndroidManifest.xml b/core/tests/hosttests/test-apps/MultiDexLegacyTestAppTests2/AndroidManifest.xml new file mode 100644 index 000000000000..1cadfcdf3b81 --- /dev/null +++ b/core/tests/hosttests/test-apps/MultiDexLegacyTestAppTests2/AndroidManifest.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.android.multidexlegacytestapp.test2" + android:versionCode="1" + android:versionName="1.0" > + + <uses-sdk android:minSdkVersion="8" /> + <instrumentation + android:name="com.android.multidexlegacytestapp.test2.MultiDexAndroidJUnitRunner" + android:targetPackage="com.android.multidexlegacytestapp" /> + + <application + android:label="multidexlegacytestapp.test" > + <uses-library android:name="android.test.runner" /> + </application> +</manifest>
\ No newline at end of file diff --git a/core/tests/hosttests/test-apps/MultiDexLegacyTestAppTests2/src/com/android/multidexlegacytestapp/test2/InstrumentationTest.java b/core/tests/hosttests/test-apps/MultiDexLegacyTestAppTests2/src/com/android/multidexlegacytestapp/test2/InstrumentationTest.java new file mode 100644 index 000000000000..4e6ec142e690 --- /dev/null +++ b/core/tests/hosttests/test-apps/MultiDexLegacyTestAppTests2/src/com/android/multidexlegacytestapp/test2/InstrumentationTest.java @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2014 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.multidexlegacytestapp.test2; + +import android.support.test.runner.AndroidJUnit4; +import com.android.multidexlegacytestapp.manymethods.Big001; +import com.android.multidexlegacytestapp.manymethods.Big079; +import junit.framework.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; + +/** + * Run the tests with: <code>adb shell am instrument -w + com.android.multidexlegacytestapp.test2/com.android.multidexlegacytestapp.test2.MultiDexAndroidJUnitRunner +</code> + */ +@RunWith(AndroidJUnit4.class) +public class InstrumentationTest { + + @Test + public void exceptionInMainDex() { + Assert.assertEquals(0, new Big001().get0()); + Assert.assertEquals(100, new Big079().get100()); + } + + @Test + public void multidexedTest() { + Assert.assertEquals(7, Intermediate.get()); + } + +} diff --git a/core/tests/hosttests/test-apps/MultiDexLegacyTestAppTests2/src/com/android/multidexlegacytestapp/test2/Intermediate.java b/core/tests/hosttests/test-apps/MultiDexLegacyTestAppTests2/src/com/android/multidexlegacytestapp/test2/Intermediate.java new file mode 100644 index 000000000000..3e5e81e5babb --- /dev/null +++ b/core/tests/hosttests/test-apps/MultiDexLegacyTestAppTests2/src/com/android/multidexlegacytestapp/test2/Intermediate.java @@ -0,0 +1,9 @@ +package com.android.multidexlegacytestapp.test2; + +public class Intermediate { + + public static int get() { + return SubTest.get(); + } + +} diff --git a/core/tests/hosttests/test-apps/MultiDexLegacyTestAppTests2/src/com/android/multidexlegacytestapp/test2/MultiDexAndroidJUnitRunner.java b/core/tests/hosttests/test-apps/MultiDexLegacyTestAppTests2/src/com/android/multidexlegacytestapp/test2/MultiDexAndroidJUnitRunner.java new file mode 100644 index 000000000000..963f90432dd7 --- /dev/null +++ b/core/tests/hosttests/test-apps/MultiDexLegacyTestAppTests2/src/com/android/multidexlegacytestapp/test2/MultiDexAndroidJUnitRunner.java @@ -0,0 +1,15 @@ +package com.android.multidexlegacytestapp.test2; + +import android.os.Bundle; +import android.support.multidex.MultiDex; +import android.support.test.runner.AndroidJUnitRunner; + +public class MultiDexAndroidJUnitRunner extends AndroidJUnitRunner { + + @Override + public void onCreate(Bundle arguments) { + MultiDex.installInstrumentation(getContext(), getTargetContext()); + super.onCreate(arguments); + } + +} diff --git a/core/tests/hosttests/test-apps/MultiDexLegacyTestAppTests2/src/com/android/multidexlegacytestapp/test2/SubTest.java b/core/tests/hosttests/test-apps/MultiDexLegacyTestAppTests2/src/com/android/multidexlegacytestapp/test2/SubTest.java new file mode 100644 index 000000000000..acff80fdd846 --- /dev/null +++ b/core/tests/hosttests/test-apps/MultiDexLegacyTestAppTests2/src/com/android/multidexlegacytestapp/test2/SubTest.java @@ -0,0 +1,11 @@ +package com.android.multidexlegacytestapp.test2; + +import com.android.multidexlegacytestapp.manymethods.Big080; + +public class SubTest { + + public static int get() { + return new Big080().get7(); + } + +} |