diff options
author | John Wu <topjohnwu@google.com> | 2022-09-16 00:38:14 +0000 |
---|---|---|
committer | John Wu <topjohnwu@google.com> | 2022-09-26 18:11:33 +0000 |
commit | d61bf9eaf51eb0478fc045b6cc3309794a7ef3fe (patch) | |
tree | 377b97acdc9589837a3b1c6ff73ace50a169cba9 /dexmaker-mockito-inline-extended-tests | |
parent | 6f5561ba7bd7cf224771168f7549542e47a25e35 (diff) | |
download | dexmaker-d61bf9eaf51eb0478fc045b6cc3309794a7ef3fe.tar.gz |
Revert^2 "Update to upstream dexmaker"
Cherry-pick "Do not read Build.VERSION to allow non-standard Android distributions (Ia8c4ba4c82cd6f193c565f1bfe48faffc4aac08f)" to fix ART host tests.
783d1254b1698492fd8ae7e04a20115d1283ba60
Change-Id: Iec6a60d0016f50101fe9151931065dc04148c767
Diffstat (limited to 'dexmaker-mockito-inline-extended-tests')
-rw-r--r-- | dexmaker-mockito-inline-extended-tests/build.gradle | 31 | ||||
-rw-r--r-- | dexmaker-mockito-inline-extended-tests/src/main/java/com/android/dx/mockito/inline/extended/tests/StaticMockitoSession.java | 24 |
2 files changed, 28 insertions, 27 deletions
diff --git a/dexmaker-mockito-inline-extended-tests/build.gradle b/dexmaker-mockito-inline-extended-tests/build.gradle index b5664f2..e5dc213 100644 --- a/dexmaker-mockito-inline-extended-tests/build.gradle +++ b/dexmaker-mockito-inline-extended-tests/build.gradle @@ -1,20 +1,7 @@ -buildscript { - repositories { - maven { - url "https://plugins.gradle.org/m2/" - } - } - dependencies { - classpath "net.ltgt.gradle:gradle-errorprone-plugin:0.0.13" - } -} - -apply plugin: "net.ltgt.errorprone" apply plugin: 'com.android.library' android { - compileSdkVersion 28 - buildToolsVersion '28.0.3' + compileSdkVersion 32 android { lintOptions { @@ -24,8 +11,7 @@ android { defaultConfig { minSdkVersion 28 - targetSdkVersion 28 - versionName VERSION_NAME + targetSdkVersion 32 testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' } @@ -36,19 +22,14 @@ android { } } -repositories { - jcenter() - google() -} - dependencies { implementation project(':dexmaker-mockito-inline-tests') compileOnly project(':dexmaker-mockito-inline-extended') 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 'junit:junit:4.13.2' + implementation 'androidx.test:runner:1.4.0' + implementation 'androidx.test:rules:1.4.0' - api 'org.mockito:mockito-core:2.25.0', { exclude group: 'net.bytebuddy' } + api 'org.mockito:mockito-core:2.28.2', { exclude group: 'net.bytebuddy' } } diff --git a/dexmaker-mockito-inline-extended-tests/src/main/java/com/android/dx/mockito/inline/extended/tests/StaticMockitoSession.java b/dexmaker-mockito-inline-extended-tests/src/main/java/com/android/dx/mockito/inline/extended/tests/StaticMockitoSession.java index 7c7941b..eff42ab 100644 --- a/dexmaker-mockito-inline-extended-tests/src/main/java/com/android/dx/mockito/inline/extended/tests/StaticMockitoSession.java +++ b/dexmaker-mockito-inline-extended-tests/src/main/java/com/android/dx/mockito/inline/extended/tests/StaticMockitoSession.java @@ -16,6 +16,7 @@ package com.android.dx.mockito.inline.extended.tests; +import android.app.PendingIntent; import android.content.ContentResolver; import android.provider.Settings; @@ -33,8 +34,9 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; public class StaticMockitoSession { + @Test - public void strictUnnecessaryStubbing() throws Exception { + public void strictUnnecessaryStubbing() { MockitoSession session = mockitoSession().spyStatic(Settings.Global.class).startMocking(); // Set up unnecessary stubbing @@ -51,7 +53,7 @@ public class StaticMockitoSession { } @Test - public void lenientUnnecessaryStubbing() throws Exception { + public void lenientUnnecessaryStubbing() { MockitoSession session = mockitoSession().strictness(Strictness.LENIENT) .spyStatic(Settings.Global.class).startMocking(); @@ -61,4 +63,22 @@ public class StaticMockitoSession { session.finishMocking(); } + + @Test + public void spyStatic() { + mockitoSession() + .initMocks(this) + .spyStatic(PendingIntent.class) + .startMocking() + .finishMocking(); + } + + @Test + public void mockStatic() { + mockitoSession() + .initMocks(this) + .mockStatic(PendingIntent.class) + .startMocking() + .finishMocking(); + } } |