Loading core/tests/hosttests/test-apps/MultiDexLegacyTestAppWithCorruptedDex/Android.mk 0 → 100644 +38 −0 Original line number Diff line number Diff line # 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) include $(CLEAR_VARS) LOCAL_MODULE_TAGS := tests LOCAL_SRC_FILES := $(call all-java-files-under, src) LOCAL_SDK_VERSION := 18 LOCAL_PACKAGE_NAME := MultiDexLegacyTestApp_corrupted LOCAL_STATIC_JAVA_LIBRARIES := android-support-multidex LOCAL_DEX_PREOPT := false include $(BUILD_PACKAGE) corrupted_classes2_dex := $(dir $(built_dex))/classes2.dex $(corrupted_classes2_dex): $(built_dex) $(hide) touch $@ $(LOCAL_BUILT_MODULE): $(corrupted_classes2_dex) core/tests/hosttests/test-apps/MultiDexLegacyTestAppWithCorruptedDex/AndroidManifest.xml 0 → 100644 +31 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.android.framework.multidexlegacycorrupteddex" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="18" android:targetSdkVersion="18" /> <application android:name="android.support.multidex.MultiDexApplication" android:allowBackup="true" android:label="MultiDexLegacyTestApp_corrupted"> <activity android:name="com.android.framework.multidexlegacycorrupteddex.MainActivity" android:label="MultiDexLegacyTestApp_corrupted" > <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.framework.multidexlegacycorrupteddex" android:label="Test for MultiDexLegacyTestApp_corrupted" /> </manifest> core/tests/hosttests/test-apps/MultiDexLegacyTestAppWithCorruptedDex/res/layout/activity_main.xml 0 → 100644 +7 −0 Original line number Diff line number Diff line <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" > </RelativeLayout> core/tests/hosttests/test-apps/MultiDexLegacyTestAppWithCorruptedDex/src/com/android/framework/multidexlegacycorrupteddex/CorruptedDexTest.java 0 → 100644 +68 −0 Original line number Diff line number Diff line /* * 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.framework.multidexlegacycorrupteddex; import android.test.ActivityInstrumentationTestCase2; import java.io.ByteArrayOutputStream; import java.io.PrintStream; /** * Run the tests with: <code>adb shell am instrument -w com.android.framework.multidexlegacycorrupteddex/android.test.InstrumentationTestRunner </code> */ public class CorruptedDexTest extends ActivityInstrumentationTestCase2<MainActivity> { public CorruptedDexTest() { super(MainActivity.class); } /** * Tests that when a {@link ClassNotFoundException} is thrown, the message also contains * something about the suppressed IOException. */ public void testSupressedExceptions() { try { Class.forName("notapackage.NotAClass"); throw new AssertionError(); } catch (ClassNotFoundException e) { // expected // This the check we should do but API is not yet available in 19 // Throwable[] suppressed = e.getSuppressed(); // assertTrue(suppressed.length > 0); // boolean ioFound = false; // for (Throwable throwable : suppressed) { // if (throwable instanceof IOException) { // ioFound = true; // break; // } // } // assertTrue(ioFound); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); e.printStackTrace(ps); ps.close(); assertTrue("Exception message should mention IOException but is not: " + baos.toString(), baos.toString().contains("IOException")); } } } core/tests/hosttests/test-apps/MultiDexLegacyTestAppWithCorruptedDex/src/com/android/framework/multidexlegacycorrupteddex/MainActivity.java 0 → 100644 +30 −0 Original line number Diff line number Diff line /* * 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.framework.multidexlegacycorrupteddex; import android.app.Activity; import android.os.Bundle; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } } Loading
core/tests/hosttests/test-apps/MultiDexLegacyTestAppWithCorruptedDex/Android.mk 0 → 100644 +38 −0 Original line number Diff line number Diff line # 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) include $(CLEAR_VARS) LOCAL_MODULE_TAGS := tests LOCAL_SRC_FILES := $(call all-java-files-under, src) LOCAL_SDK_VERSION := 18 LOCAL_PACKAGE_NAME := MultiDexLegacyTestApp_corrupted LOCAL_STATIC_JAVA_LIBRARIES := android-support-multidex LOCAL_DEX_PREOPT := false include $(BUILD_PACKAGE) corrupted_classes2_dex := $(dir $(built_dex))/classes2.dex $(corrupted_classes2_dex): $(built_dex) $(hide) touch $@ $(LOCAL_BUILT_MODULE): $(corrupted_classes2_dex)
core/tests/hosttests/test-apps/MultiDexLegacyTestAppWithCorruptedDex/AndroidManifest.xml 0 → 100644 +31 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.android.framework.multidexlegacycorrupteddex" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="18" android:targetSdkVersion="18" /> <application android:name="android.support.multidex.MultiDexApplication" android:allowBackup="true" android:label="MultiDexLegacyTestApp_corrupted"> <activity android:name="com.android.framework.multidexlegacycorrupteddex.MainActivity" android:label="MultiDexLegacyTestApp_corrupted" > <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.framework.multidexlegacycorrupteddex" android:label="Test for MultiDexLegacyTestApp_corrupted" /> </manifest>
core/tests/hosttests/test-apps/MultiDexLegacyTestAppWithCorruptedDex/res/layout/activity_main.xml 0 → 100644 +7 −0 Original line number Diff line number Diff line <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" > </RelativeLayout>
core/tests/hosttests/test-apps/MultiDexLegacyTestAppWithCorruptedDex/src/com/android/framework/multidexlegacycorrupteddex/CorruptedDexTest.java 0 → 100644 +68 −0 Original line number Diff line number Diff line /* * 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.framework.multidexlegacycorrupteddex; import android.test.ActivityInstrumentationTestCase2; import java.io.ByteArrayOutputStream; import java.io.PrintStream; /** * Run the tests with: <code>adb shell am instrument -w com.android.framework.multidexlegacycorrupteddex/android.test.InstrumentationTestRunner </code> */ public class CorruptedDexTest extends ActivityInstrumentationTestCase2<MainActivity> { public CorruptedDexTest() { super(MainActivity.class); } /** * Tests that when a {@link ClassNotFoundException} is thrown, the message also contains * something about the suppressed IOException. */ public void testSupressedExceptions() { try { Class.forName("notapackage.NotAClass"); throw new AssertionError(); } catch (ClassNotFoundException e) { // expected // This the check we should do but API is not yet available in 19 // Throwable[] suppressed = e.getSuppressed(); // assertTrue(suppressed.length > 0); // boolean ioFound = false; // for (Throwable throwable : suppressed) { // if (throwable instanceof IOException) { // ioFound = true; // break; // } // } // assertTrue(ioFound); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); e.printStackTrace(ps); ps.close(); assertTrue("Exception message should mention IOException but is not: " + baos.toString(), baos.toString().contains("IOException")); } } }
core/tests/hosttests/test-apps/MultiDexLegacyTestAppWithCorruptedDex/src/com/android/framework/multidexlegacycorrupteddex/MainActivity.java 0 → 100644 +30 −0 Original line number Diff line number Diff line /* * 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.framework.multidexlegacycorrupteddex; import android.app.Activity; import android.os.Bundle; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } }