From d61bf9eaf51eb0478fc045b6cc3309794a7ef3fe Mon Sep 17 00:00:00 2001 From: John Wu Date: Fri, 16 Sep 2022 00:38:14 +0000 Subject: 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 --- .../build.gradle | 31 +++++----------------- .../extended/tests/StaticMockitoSession.java | 24 +++++++++++++++-- 2 files changed, 28 insertions(+), 27 deletions(-) (limited to 'dexmaker-mockito-inline-extended-tests') 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(); + } } -- cgit v1.2.3