Skip to content

Commit

Permalink
Upgrade from android.support.test to androidx.test. (#139)
Browse files Browse the repository at this point in the history
* Upgrade from android.support.test to androidx.test. See https://developer.android.com/jetpack/androidx/migrate

* Convert MemoryLeaks to androidx.test

* Fix merge conflicts
  • Loading branch information
brettchabot authored and hongbinh committed Mar 13, 2019
1 parent 9cee741 commit 7828afb
Show file tree
Hide file tree
Showing 13 changed files with 94 additions and 87 deletions.
6 changes: 3 additions & 3 deletions dexmaker-mockito-inline-extended-tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ android {
targetSdkVersion 28
versionName VERSION_NAME

testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}

compileOptions {
Expand All @@ -47,8 +47,8 @@ dependencies {
androidTestImplementation project(':dexmaker-mockito-inline-extended')

implementation 'junit:junit:4.12'
implementation 'com.android.support.test:runner:1.0.2'
implementation 'com.android.support.test:rules:1.0.2'
implementation 'androidx.test:runner:1.1.1'
implementation 'androidx.test:rules:1.1.1'

api 'org.mockito:mockito-core:2.25.0', { exclude group: 'net.bytebuddy' }
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,8 @@

package com.android.dx.mockito.inline.extended.tests;

import android.content.ContentResolver;
import android.provider.Settings;
import android.support.test.InstrumentationRegistry;

import org.junit.Test;
import org.mockito.MockingDetails;
import org.mockito.MockitoSession;
import org.mockito.exceptions.misusing.MissingMethodInvocationException;
import org.mockito.quality.Strictness;

import static android.provider.Settings.Global.DEVICE_NAME;

import static com.android.dx.mockito.inline.extended.ExtendedMockito.clearInvocations;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.mock;
Expand All @@ -36,6 +27,7 @@
import static com.android.dx.mockito.inline.extended.ExtendedMockito.staticMockMarker;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.verifyZeroInteractions;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.when;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
Expand All @@ -45,6 +37,17 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;

import android.content.ContentResolver;
import android.provider.Settings;

import androidx.test.InstrumentationRegistry;

import org.junit.Test;
import org.mockito.MockingDetails;
import org.mockito.MockitoSession;
import org.mockito.exceptions.misusing.MissingMethodInvocationException;
import org.mockito.quality.Strictness;

public class MockStatic {
private static class SuperClass {
final String returnA() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,24 @@

package com.android.dx.mockito.inline.extended.tests;

import android.app.Instrumentation;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;

import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import static com.android.dx.mockito.inline.extended.ExtendedMockito.doAnswer;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.mock;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.spy;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.when;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;

import androidx.test.rule.ActivityTestRule;
import androidx.test.runner.AndroidJUnit4;

import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

@RunWith(AndroidJUnit4.class)
public class SpyOn {
@Rule
Expand Down
4 changes: 2 additions & 2 deletions dexmaker-mockito-inline-tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ android {
targetSdkVersion 28
versionName VERSION_NAME

testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}

externalNativeBuild {
Expand All @@ -49,6 +49,6 @@ dependencies {
androidTestImplementation project(':dexmaker-mockito-inline')

implementation 'junit:junit:4.12'
implementation 'com.android.support.test:runner:1.0.2'
implementation 'androidx.test:runner:1.1.1'
api 'org.mockito:mockito-core:2.25.0', { exclude group: 'net.bytebuddy' }
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;

import android.support.test.runner.AndroidJUnit4;
import androidx.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,6 @@

package com.android.dx.mockito.inline.tests;

import android.content.Intent;
import android.os.IBinder;
import android.print.PrintAttributes;
import android.printservice.PrintService;
import android.support.test.runner.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
Expand All @@ -33,6 +24,16 @@
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;

import android.content.Intent;
import android.os.IBinder;
import android.print.PrintAttributes;
import android.printservice.PrintService;

import androidx.test.runner.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

@RunWith(AndroidJUnit4.class)
public class MockFinal {
@Test
Expand Down
4 changes: 2 additions & 2 deletions dexmaker-mockito-tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ android {
targetSdkVersion 28
versionName VERSION_NAME

testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
}

Expand All @@ -40,7 +40,7 @@ dependencies {
compileOnly project(':dexmaker-mockito')
androidTestImplementation project(':dexmaker-mockito')

implementation 'com.android.support.test:runner:0.5'
implementation 'androidx.test:runner:1.1.1'
implementation 'junit:junit:4.12'
api 'org.mockito:mockito-core:2.25.0', { exclude group: 'net.bytebuddy' }
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@
import android.content.pm.PackageManager;
import android.os.Build;
import android.provider.Settings;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import android.view.View;
import android.widget.FrameLayout;

import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,7 @@

package com.android.dx.mockito.tests;

import android.support.test.runner.AndroidJUnit4;

import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.exceptions.base.MockitoException;
import org.mockito.exceptions.verification.NoInteractionsWanted;

import java.util.ArrayList;
import java.util.Arrays;

import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
Expand All @@ -41,6 +28,13 @@
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;

import androidx.test.runner.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.exceptions.base.MockitoException;
import org.mockito.exceptions.verification.NoInteractionsWanted;

@RunWith(AndroidJUnit4.class)
public class GeneralMocking {
public static class TestClass {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,19 @@

package com.android.dx.mockito.tests;

import android.support.test.runner.AndroidJUnit4;
import android.util.Log;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import android.util.Log;

import androidx.test.runner.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

@RunWith(AndroidJUnit4.class)
public class Stress {
private static final String LOG_TAG = Stress.class.getSimpleName();
Expand Down
4 changes: 2 additions & 2 deletions dexmaker-tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ android {
versionCode 1
versionName VERSION_NAME

testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
}

Expand All @@ -36,6 +36,6 @@ dependencies {
implementation project(":dexmaker")

//noinspection GradleDependency
androidTestImplementation 'com.android.support.test:runner:0.5'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'junit:junit:4.12'
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,29 @@
*/
package com.android.dx;

import static com.android.dx.TypeId.*;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeTrue;

import android.os.Build;
import android.support.test.InstrumentationRegistry;

import androidx.test.InstrumentationRegistry;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import static java.lang.reflect.Modifier.PUBLIC;

import java.io.File;
import java.lang.annotation.*;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static com.android.dx.TypeId.*;
import static java.lang.reflect.Modifier.PUBLIC;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeTrue;

public final class AnnotationIdTest {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,36 @@

package com.android.dx;

import static com.android.dx.util.TestUtil.DELTA_DOUBLE;
import static com.android.dx.util.TestUtil.DELTA_FLOAT;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeTrue;

import android.os.Build;
import android.support.test.InstrumentationRegistry;

import androidx.test.InstrumentationRegistry;

import dalvik.system.BaseDexClassLoader;

import org.junit.Before;
import org.junit.Test;

import static java.lang.reflect.Modifier.ABSTRACT;
import static java.lang.reflect.Modifier.FINAL;
import static java.lang.reflect.Modifier.NATIVE;
import static java.lang.reflect.Modifier.PRIVATE;
import static java.lang.reflect.Modifier.PROTECTED;
import static java.lang.reflect.Modifier.PUBLIC;
import static java.lang.reflect.Modifier.STATIC;
import static java.lang.reflect.Modifier.SYNCHRONIZED;

import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
Expand All @@ -33,27 +57,6 @@
import java.util.List;
import java.util.concurrent.Callable;

import dalvik.system.BaseDexClassLoader;

import static com.android.dx.util.TestUtil.DELTA_DOUBLE;
import static com.android.dx.util.TestUtil.DELTA_FLOAT;
import static java.lang.reflect.Modifier.ABSTRACT;
import static java.lang.reflect.Modifier.FINAL;
import static java.lang.reflect.Modifier.NATIVE;
import static java.lang.reflect.Modifier.PRIVATE;
import static java.lang.reflect.Modifier.PROTECTED;
import static java.lang.reflect.Modifier.PUBLIC;
import static java.lang.reflect.Modifier.STATIC;
import static java.lang.reflect.Modifier.SYNCHRONIZED;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeTrue;

/**
* This generates a class named 'Generated' with one or more generated methods
* and fields. In loads the generated class into the current VM and uses
Expand Down

0 comments on commit 7828afb

Please sign in to comment.