Merge "A test application for Art bug 14256107"
This commit is contained in:
committed by
Android (Google) Code Review
commit
f2fa9994ab
@@ -0,0 +1,42 @@
|
||||
# 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
|
||||
LOCAL_MODULE_TAGS := tests
|
||||
|
||||
LOCAL_SRC_FILES := $(call all-java-files-under, src)
|
||||
|
||||
LOCAL_SDK_VERSION := current
|
||||
|
||||
LOCAL_PACKAGE_NAME := MultiDexLegacyAndException
|
||||
|
||||
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
|
||||
|
||||
include $(BUILD_PACKAGE)
|
||||
|
||||
$(mainDexList): $(full_classes_proguard_jar) | $(HOST_OUT_EXECUTABLES)/mainDexClasses
|
||||
$(HOST_OUT_EXECUTABLES)/mainDexClasses $< 1>$@
|
||||
echo "com/android/multidexlegacyandexception/Test.class" >> $@
|
||||
|
||||
$(built_dex_intermediate): $(mainDexList)
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.android.multidexlegacyandexception"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0" >
|
||||
|
||||
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="18"/>
|
||||
|
||||
<application
|
||||
android:name="com.android.multidexlegacyandexception.TestApplication"
|
||||
android:label="multidexlegacyandexception"
|
||||
>
|
||||
<activity
|
||||
android:name="com.android.multidexlegacyandexception.MainActivity"
|
||||
android:label="multidexlegacyandexception" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<uses-library android:name="android.test.runner" />
|
||||
</application>
|
||||
|
||||
<instrumentation android:name="android.test.InstrumentationTestRunner"
|
||||
android:targetPackage="com.android.multidexlegacyandexception"
|
||||
android:label="Test for MultiDexLegacyAndException" />
|
||||
</manifest>
|
||||
@@ -0,0 +1,13 @@
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
tools:context=".MainActivity" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/label_nb"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/label_nb" />
|
||||
|
||||
</RelativeLayout>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string name="app_name">MultidexLegacyAndException</string>
|
||||
<string name="action_settings">Settings</string>
|
||||
<string name="label_nb">Here\'s the count: </string>
|
||||
|
||||
</resources>
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
public class CaughtOnlyByIntermediateException extends RuntimeException {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
public class CaughtOnlyException extends RuntimeException {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
public class ClassInSecondaryDex {
|
||||
private boolean condition;
|
||||
|
||||
public ClassInSecondaryDex(boolean condition) {
|
||||
this.condition = condition;
|
||||
}
|
||||
|
||||
public void canThrow1() throws ExceptionInMainDex, ExceptionInMainDex2,
|
||||
ExceptionInSecondaryDexWithSuperInMain {
|
||||
if (condition) {
|
||||
throw new ExceptionInMainDex();
|
||||
}
|
||||
}
|
||||
|
||||
public void canThrow2() throws ExceptionInSecondaryDex, ExceptionInSecondaryDex2,
|
||||
ExceptionInSecondaryDexWithSuperInMain {
|
||||
if (condition) {
|
||||
throw new ExceptionInSecondaryDex();
|
||||
}
|
||||
}
|
||||
|
||||
public static void canThrowAll(Throwable toThrow) throws Throwable {
|
||||
if (toThrow != null) {
|
||||
throw toThrow;
|
||||
}
|
||||
}
|
||||
|
||||
public int get1() {
|
||||
try {
|
||||
canThrow1();
|
||||
canThrow2();
|
||||
return 1;
|
||||
} catch (ExceptionInMainDex e) {
|
||||
return 10;
|
||||
} catch (ExceptionInSecondaryDex e) {
|
||||
return 11;
|
||||
} catch (OutOfMemoryError e) {
|
||||
return 12;
|
||||
} catch (CaughtOnlyException e) {
|
||||
return 17;
|
||||
} catch (SuperExceptionInSecondaryDex|SuperExceptionInMainDex e) {
|
||||
return 23;
|
||||
}
|
||||
}
|
||||
|
||||
public int get2() {
|
||||
try {
|
||||
canThrow2();
|
||||
canThrow1();
|
||||
return 1;
|
||||
} catch (ExceptionInMainDex e) {
|
||||
return 10;
|
||||
} catch (ExceptionInSecondaryDex e) {
|
||||
return 11;
|
||||
} catch (OutOfMemoryError e) {
|
||||
return 12;
|
||||
} catch (CaughtOnlyException e) {
|
||||
return 17;
|
||||
} catch (SuperExceptionInSecondaryDex e) {
|
||||
return 23;
|
||||
} catch (SuperExceptionInMainDex e) {
|
||||
return 27;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
public class ExceptionInMainDex extends SuperExceptionInMainDex {
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
public class ExceptionInMainDex2 extends SuperExceptionInMainDex {
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
public class ExceptionInSecondaryDex extends SuperExceptionInSecondaryDex {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
public class ExceptionInSecondaryDex2 extends SuperExceptionInSecondaryDex {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
public class ExceptionInSecondaryDexWithSuperInMain extends SuperExceptionInMainDex {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
public class IntermediateClass {
|
||||
|
||||
public static int get1(boolean condition) {
|
||||
return new ClassInSecondaryDex(condition).get1();
|
||||
}
|
||||
|
||||
public static int get2(boolean condition) {
|
||||
return new ClassInSecondaryDex(condition).get2();
|
||||
}
|
||||
|
||||
public static int get3(boolean condition) {
|
||||
ClassInSecondaryDex thrower = new ClassInSecondaryDex(condition);
|
||||
try {
|
||||
thrower.canThrow2();
|
||||
thrower.canThrow1();
|
||||
return 1;
|
||||
} catch (ExceptionInMainDex e) {
|
||||
return 10;
|
||||
} catch (ExceptionInSecondaryDex e) {
|
||||
return 11;
|
||||
} catch (ExceptionInMainDex2 e) {
|
||||
return 10;
|
||||
} catch (ExceptionInSecondaryDex2 e) {
|
||||
return 11;
|
||||
} catch (OutOfMemoryError e) {
|
||||
return 12;
|
||||
} catch (CaughtOnlyException e) {
|
||||
return 17;
|
||||
} catch (ExceptionInSecondaryDexWithSuperInMain e) {
|
||||
return 39;
|
||||
} catch (SuperExceptionInSecondaryDex|SuperExceptionInMainDex|CaughtOnlyByIntermediateException e) {
|
||||
return 23;
|
||||
}
|
||||
}
|
||||
|
||||
public static int get4(boolean condition) {
|
||||
ClassInSecondaryDex thrower = new ClassInSecondaryDex(condition);
|
||||
try {
|
||||
thrower.canThrow2();
|
||||
thrower.canThrow1();
|
||||
return 1;
|
||||
} catch (ExceptionInSecondaryDexWithSuperInMain e) {
|
||||
return 39;
|
||||
} catch (ExceptionInSecondaryDex e) {
|
||||
return 11;
|
||||
} catch (ExceptionInSecondaryDex2 e) {
|
||||
return 11;
|
||||
} catch (OutOfMemoryError e) {
|
||||
return 12;
|
||||
} catch (ExceptionInMainDex2 e) {
|
||||
return 10;
|
||||
} catch (ExceptionInMainDex e) {
|
||||
return 10;
|
||||
} catch (CaughtOnlyException e) {
|
||||
return 17;
|
||||
} catch (SuperExceptionInSecondaryDex e) {
|
||||
} catch (SuperExceptionInMainDex e) {
|
||||
} catch (CaughtOnlyByIntermediateException e) {
|
||||
return 35;
|
||||
}
|
||||
return 39;
|
||||
}
|
||||
|
||||
|
||||
public static int get5(Throwable thrown) {
|
||||
try {
|
||||
ClassInSecondaryDex.canThrowAll(thrown);
|
||||
return 1;
|
||||
} catch (ExceptionInMainDex e) {
|
||||
return 10;
|
||||
} catch (ExceptionInSecondaryDex e) {
|
||||
return 11;
|
||||
} catch (ExceptionInMainDex2 e) {
|
||||
return 12;
|
||||
} catch (ExceptionInSecondaryDex2 e) {
|
||||
return 13;
|
||||
} catch (OutOfMemoryError e) {
|
||||
return 14;
|
||||
} catch (CaughtOnlyException e) {
|
||||
return 17;
|
||||
} catch (ExceptionInSecondaryDexWithSuperInMain e) {
|
||||
return 39;
|
||||
} catch (SuperExceptionInSecondaryDex|SuperExceptionInMainDex|CaughtOnlyByIntermediateException e) {
|
||||
return 23;
|
||||
} catch (Throwable e) {
|
||||
return 37;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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.multidexlegacyandexception;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
|
||||
public class MainActivity extends Activity {
|
||||
|
||||
public MainActivity() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
}
|
||||
|
||||
public int get1(boolean condition) {
|
||||
return IntermediateClass.get1(condition);
|
||||
}
|
||||
|
||||
public int get2(boolean condition) {
|
||||
return IntermediateClass.get2(condition);
|
||||
}
|
||||
public int get3(boolean condition) {
|
||||
return MiniIntermediateClass.get3(condition);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
public class MiniIntermediateClass {
|
||||
|
||||
public static int get3(boolean condition) {
|
||||
ClassInSecondaryDex thrower = new ClassInSecondaryDex(condition);
|
||||
try {
|
||||
thrower.canThrow2();
|
||||
thrower.canThrow1();
|
||||
return 1;
|
||||
} catch (ExceptionInMainDex e) {
|
||||
return 10;
|
||||
} catch (ExceptionInSecondaryDex e) {
|
||||
return 11;
|
||||
} catch (SuperExceptionInSecondaryDex|SuperExceptionInMainDex e) {
|
||||
return 23;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
public class SuperExceptionInMainDex extends Exception {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
public class SuperExceptionInSecondaryDex extends Exception {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import android.test.ActivityInstrumentationTestCase2;
|
||||
|
||||
/**
|
||||
* Run the tests with: <code>adb shell am instrument -w
|
||||
com.android.multidexlegacyandexception/android.test.InstrumentationTestRunner
|
||||
</code>
|
||||
*/
|
||||
public class Test extends ActivityInstrumentationTestCase2<MainActivity> {
|
||||
public Test() {
|
||||
super(MainActivity.class);
|
||||
}
|
||||
|
||||
public void testExceptionInMainDex() {
|
||||
assertEquals(10, TestApplication.get(true));
|
||||
}
|
||||
|
||||
public void testExceptionInSecondaryDex() {
|
||||
assertEquals(10, getActivity().get1(true));
|
||||
assertEquals(11, getActivity().get2(true));
|
||||
}
|
||||
|
||||
public void testExceptionInIntermediate() {
|
||||
assertEquals(11, IntermediateClass.get3(true));
|
||||
assertEquals(11, MiniIntermediateClass.get3(true));
|
||||
assertEquals(11, IntermediateClass.get4(true));
|
||||
assertEquals(1, IntermediateClass.get5(null));
|
||||
assertEquals(10, IntermediateClass.get5(new ExceptionInMainDex()));
|
||||
assertEquals(11, IntermediateClass.get5(new ExceptionInSecondaryDex()));
|
||||
assertEquals(12, IntermediateClass.get5(new ExceptionInMainDex2()));
|
||||
assertEquals(13, IntermediateClass.get5(new ExceptionInSecondaryDex2()));
|
||||
assertEquals(14, IntermediateClass.get5(new OutOfMemoryError()));
|
||||
assertEquals(17, IntermediateClass.get5(new CaughtOnlyException()));
|
||||
assertEquals(39, IntermediateClass.get5(new ExceptionInSecondaryDexWithSuperInMain()));
|
||||
assertEquals(23, IntermediateClass.get5(new SuperExceptionInSecondaryDex()));
|
||||
assertEquals(23, IntermediateClass.get5(new SuperExceptionInMainDex()));
|
||||
assertEquals(23, IntermediateClass.get5(new CaughtOnlyByIntermediateException()));
|
||||
assertEquals(37, IntermediateClass.get5(new ArrayIndexOutOfBoundsException()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import android.support.multidex.MultiDexApplication;
|
||||
|
||||
public class TestApplication extends MultiDexApplication {
|
||||
|
||||
private static void canThrow1(boolean condition) throws ExceptionInMainDex {
|
||||
if (condition) {
|
||||
throw new ExceptionInMainDex();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static int get(boolean condition) {
|
||||
try {
|
||||
canThrow1(condition);
|
||||
return 1;
|
||||
} catch (ExceptionInMainDex e) {
|
||||
return 10;
|
||||
} catch (OutOfMemoryError e) {
|
||||
return 12;
|
||||
} catch (CaughtOnlyException e) {
|
||||
return 17;
|
||||
} catch (SuperExceptionInMainDex e) {
|
||||
return 27;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user