1/* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 * use this file except in compliance with the License. You may obtain a copy of 6 * the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 * License for the specific language governing permissions and limitations under 14 * the License. 15 */ 16package com.android.multidexlegacyandexception; 17 18import android.test.ActivityInstrumentationTestCase2; 19 20/** 21 * Run the tests with: <code>adb shell am instrument -w 22 com.android.multidexlegacyandexception/android.test.InstrumentationTestRunner 23</code> 24 */ 25public class Test extends ActivityInstrumentationTestCase2<MainActivity> { 26 public Test() { 27 super(MainActivity.class); 28 } 29 30 public void testExceptionInMainDex() { 31 assertEquals(10, TestApplication.get(true)); 32 } 33 34 public void testExceptionInSecondaryDex() { 35 assertEquals(10, getActivity().get1(true)); 36 assertEquals(11, getActivity().get2(true)); 37 } 38 39 public void testExceptionInIntermediate() { 40 assertEquals(11, IntermediateClass.get3(true)); 41 assertEquals(11, MiniIntermediateClass.get3(true)); 42 assertEquals(11, IntermediateClass.get4(true)); 43 assertEquals(1, IntermediateClass.get5(null)); 44 assertEquals(10, IntermediateClass.get5(new ExceptionInMainDex())); 45 assertEquals(11, IntermediateClass.get5(new ExceptionInSecondaryDex())); 46 assertEquals(12, IntermediateClass.get5(new ExceptionInMainDex2())); 47 assertEquals(13, IntermediateClass.get5(new ExceptionInSecondaryDex2())); 48 assertEquals(14, IntermediateClass.get5(new OutOfMemoryError())); 49 assertEquals(17, IntermediateClass.get5(new CaughtOnlyException())); 50 assertEquals(39, IntermediateClass.get5(new ExceptionInSecondaryDexWithSuperInMain())); 51 assertEquals(23, IntermediateClass.get5(new SuperExceptionInSecondaryDex())); 52 assertEquals(23, IntermediateClass.get5(new SuperExceptionInMainDex())); 53 assertEquals(23, IntermediateClass.get5(new CaughtOnlyByIntermediateException())); 54 assertEquals(37, IntermediateClass.get5(new ArrayIndexOutOfBoundsException())); 55 } 56 57} 58