Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 50f811c8 authored by Yohann Roussel's avatar Yohann Roussel
Browse files

Add tests on MultiDex.installInstrumentation

Either with dedicated Instrumentation or with MultiDexTestRunner.

Bug: 30575093

Test: Those are tests

Change-Id: I97a22625409fd587e1d63fa4207eb72ca67f2c82
parent ed112e3c
Loading
Loading
Loading
Loading
+4 −9
Original line number Diff line number Diff line
@@ -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)

+9 −1
Original line number Diff line number Diff line
@@ -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>
+20 −5
Original line number Diff line number Diff line
@@ -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);
    }

+31 −0
Original line number Diff line number Diff line
/*
 * 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);
  }

}
+25 −0
Original line number Diff line number Diff line
/*
 * 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();
  }

}
Loading