Merge "Add tests on MultiDex.installInstrumentation"
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
test:
|
||||
@@com.android.jack.annotations.ForceInMainDex
|
||||
class com.android.multidexlegacyandexception.Test
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
@@ -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>
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.android.multidexlegacytestapp.test;
|
||||
|
||||
public class Intermediate {
|
||||
|
||||
public static int get() {
|
||||
return SubTest.get();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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)
|
||||
@@ -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>
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.android.multidexlegacytestapp.test2;
|
||||
|
||||
public class Intermediate {
|
||||
|
||||
public static int get() {
|
||||
return SubTest.get();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user