Home | History | Annotate | Download | only in multidexlegacyandexception
      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  */
     16 package com.android.multidexlegacyandexception;
     17 
     18 /**
     19  * Run the tests with: <code>adb shell am instrument -w
     20  com.android.multidexlegacyandexception/android.test.InstrumentationTestRunner
     21 </code>
     22  */
     23 @SuppressWarnings("deprecation")
     24 public class Test extends android.test.ActivityInstrumentationTestCase2<MainActivity> {
     25     public Test() {
     26         super(MainActivity.class);
     27     }
     28 
     29     public void testExceptionInMainDex() {
     30         assertEquals(10, TestApplication.get(true));
     31     }
     32 
     33     public void testExceptionInSecondaryDex() {
     34         assertEquals(10, getActivity().get1(true));
     35         assertEquals(11, getActivity().get2(true));
     36     }
     37 
     38     public void testExceptionInIntermediate() {
     39         assertEquals(11, IntermediateClass.get3(true));
     40         assertEquals(11, MiniIntermediateClass.get3(true));
     41         assertEquals(11, IntermediateClass.get4(true));
     42         assertEquals(1, IntermediateClass.get5(null));
     43         assertEquals(10, IntermediateClass.get5(new ExceptionInMainDex()));
     44         assertEquals(11, IntermediateClass.get5(new ExceptionInSecondaryDex()));
     45         assertEquals(12, IntermediateClass.get5(new ExceptionInMainDex2()));
     46         assertEquals(13, IntermediateClass.get5(new ExceptionInSecondaryDex2()));
     47         assertEquals(14, IntermediateClass.get5(new OutOfMemoryError()));
     48         assertEquals(17, IntermediateClass.get5(new CaughtOnlyException()));
     49         assertEquals(39, IntermediateClass.get5(new ExceptionInSecondaryDexWithSuperInMain()));
     50         assertEquals(23, IntermediateClass.get5(new SuperExceptionInSecondaryDex()));
     51         assertEquals(23, IntermediateClass.get5(new SuperExceptionInMainDex()));
     52         assertEquals(23, IntermediateClass.get5(new CaughtOnlyByIntermediateException()));
     53         assertEquals(37, IntermediateClass.get5(new ArrayIndexOutOfBoundsException()));
     54     }
     55 
     56 }
     57