Reenable lint tests turned off for AGP upgrade
Test: Un-ignores tests
Bug: 251883059
Change-Id: Ibc5d39c8be2f5eb118e0a37ce5c2b17f2a203648
diff --git a/lint-checks/src/test/java/androidx/build/lint/BanUncheckedReflectionTest.kt b/lint-checks/src/test/java/androidx/build/lint/BanUncheckedReflectionTest.kt
index 34809e2..6f60c61 100644
--- a/lint-checks/src/test/java/androidx/build/lint/BanUncheckedReflectionTest.kt
+++ b/lint-checks/src/test/java/androidx/build/lint/BanUncheckedReflectionTest.kt
@@ -19,8 +19,6 @@
package androidx.build.lint
import androidx.build.lint.Stubs.Companion.RestrictTo
-import com.android.tools.lint.checks.infrastructure.TestMode
-import org.junit.Ignore
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
@@ -32,7 +30,6 @@
stubs = arrayOf(Stubs.ChecksSdkIntAtLeast),
) {
- @Ignore("b/251883059")
@Test
fun `Detection of unchecked reflection in real-world Java sources`() {
val input = arrayOf(
@@ -42,23 +39,19 @@
/* ktlint-disable max-line-length */
val expected = """
-src/androidx/sample/core/app/ActivityRecreator.java:145: Error: Calling Method.invoke without an SDK check [BanUncheckedReflection]
- requestRelaunchActivityMethod.invoke(activityThread,
- ^
src/androidx/sample/core/app/ActivityRecreator.java:262: Error: Calling Method.invoke without an SDK check [BanUncheckedReflection]
performStopActivity3ParamsMethod.invoke(activityThread,
^
src/androidx/sample/core/app/ActivityRecreator.java:265: Error: Calling Method.invoke without an SDK check [BanUncheckedReflection]
performStopActivity2ParamsMethod.invoke(activityThread,
^
-3 errors, 0 warnings
+2 errors, 0 warnings
""".trimIndent()
/* ktlint-enable max-line-length */
check(*input).expect(expected)
}
- @Ignore("b/251883059")
@Test
fun `Detection of unchecked reflection in real-world Kotlin sources`() {
val input = arrayOf(
@@ -68,23 +61,18 @@
/* ktlint-disable max-line-length */
val expected = """
-src/androidx/sample/core/app/ActivityRecreatorKt.kt:130: Error: Calling Method.invoke without an SDK check [BanUncheckedReflection]
- requestRelaunchActivityMethod!!.invoke(
- ^
src/androidx/sample/core/app/ActivityRecreatorKt.kt:177: Error: Calling Method.invoke without an SDK check [BanUncheckedReflection]
performStopActivity3ParamsMethod!!.invoke(
^
src/androidx/sample/core/app/ActivityRecreatorKt.kt:182: Error: Calling Method.invoke without an SDK check [BanUncheckedReflection]
performStopActivity2ParamsMethod!!.invoke(
^
-3 errors, 0 warnings
+2 errors, 0 warnings
""".trimIndent()
/* ktlint-enable max-line-length */
lint()
.files(*input)
- // TODO: b/247135738 re-enable IF_TO_WHEN mode
- .skipTestModes(TestMode.IF_TO_WHEN)
.run()
.expect(expected)
}
diff --git a/lint-checks/src/test/java/androidx/build/lint/ClassVerificationFailureDetectorTest.kt b/lint-checks/src/test/java/androidx/build/lint/ClassVerificationFailureDetectorTest.kt
index 318e34a..55398d8 100644
--- a/lint-checks/src/test/java/androidx/build/lint/ClassVerificationFailureDetectorTest.kt
+++ b/lint-checks/src/test/java/androidx/build/lint/ClassVerificationFailureDetectorTest.kt
@@ -21,7 +21,6 @@
import androidx.build.lint.Stubs.Companion.DoNotInline
import androidx.build.lint.Stubs.Companion.RequiresApi
import androidx.build.lint.Stubs.Companion.IntRange
-import org.junit.Ignore
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
@@ -187,7 +186,6 @@
check(*input).expect(expected)
}
- @Ignore("b/251883059")
@Test
fun `Auto-fix unsafe void-type method reference in Java source`() {
val input = arrayOf(
@@ -201,13 +199,13 @@
- view.setBackgroundTintList(new ColorStateList(null, null));
+ Api21Impl.setBackgroundTintList(view, new ColorStateList(null, null));
@@ -37 +37
-+ @annotation.RequiresApi(21)
++ @androidx.annotation.RequiresApi(21)
+ static class Api21Impl {
+ private Api21Impl() {
+ // This class is not instantiable.
+ }
+
-+ @annotation.DoNotInline
++ @androidx.annotation.DoNotInline
+ static void setBackgroundTintList(View view, ColorStateList tint) {
+ view.setBackgroundTintList(tint);
+ }
@@ -220,7 +218,6 @@
check(*input).expectFixDiffs(expectedFix)
}
- @Ignore("b/251883059")
@Test
fun `Auto-fix unsafe constructor reference in Java source`() {
val input = arrayOf(
@@ -234,13 +231,13 @@
- AccessibilityNodeInfo node = new AccessibilityNodeInfo(new View(context), 1);
+ AccessibilityNodeInfo node = Api30Impl.createAccessibilityNodeInfo(new View(context), 1);
@@ -38 +38
-+ @annotation.RequiresApi(30)
++ @androidx.annotation.RequiresApi(30)
+ static class Api30Impl {
+ private Api30Impl() {
+ // This class is not instantiable.
+ }
+
-+ @annotation.DoNotInline
++ @androidx.annotation.DoNotInline
+ static AccessibilityNodeInfo createAccessibilityNodeInfo(View root, int virtualDescendantId) {
+ return new AccessibilityNodeInfo(root, virtualDescendantId);
+ }
@@ -253,7 +250,6 @@
check(*input).expectFixDiffs(expectedFix)
}
- @Ignore("b/251883059")
@Test
fun `Auto-fix unsafe static method reference in Java source`() {
val input = arrayOf(
@@ -267,13 +263,13 @@
- return View.generateViewId();
+ return Api17Impl.generateViewId();
@@ -37 +37
-+ @annotation.RequiresApi(17)
++ @androidx.annotation.RequiresApi(17)
+ static class Api17Impl {
+ private Api17Impl() {
+ // This class is not instantiable.
+ }
+
-+ @annotation.DoNotInline
++ @androidx.annotation.DoNotInline
+ static int generateViewId() {
+ return View.generateViewId();
+ }
@@ -286,7 +282,6 @@
check(*input).expectFixDiffs(expectedFix)
}
- @Ignore("b/251883059")
@Test
fun `Auto-fix unsafe generic-type method reference in Java source`() {
val input = arrayOf(
@@ -300,13 +295,13 @@
- return context.getSystemService(serviceClass);
+ return Api23Impl.getSystemService(context, serviceClass);
@@ -38 +38
-+ @annotation.RequiresApi(23)
++ @androidx.annotation.RequiresApi(23)
+ static class Api23Impl {
+ private Api23Impl() {
+ // This class is not instantiable.
+ }
+
-+ @annotation.DoNotInline
++ @androidx.annotation.DoNotInline
+ static <T> T getSystemService(Context context, java.lang.Class<T> serviceClass) {
+ return context.getSystemService(serviceClass);
+ }
@@ -352,7 +347,6 @@
check(*input).expectFixDiffs(expectedFix)
}
- @Ignore("b/251883059")
@Test
fun `Auto-fix unsafe reference in Java source when the fix code already exists`() {
val input = arrayOf(
@@ -383,7 +377,7 @@
+ Api21Impl.getOutline(drawable, null);
@@ -58 +58
- }
-+ @annotation.DoNotInline
++ @DoNotInline
+ static void getOutline(Drawable drawable, android.graphics.Outline outline) {
+ drawable.getOutline(outline);
@@ -60 +62
@@ -395,7 +389,6 @@
check(*input).expect(expected).expectFixDiffs(expectedFix)
}
- @Ignore("Ignored until the fix for b/241573146 is in the current version of studio")
@Test
fun `Detection and auto-fix for qualified expressions (issue 205026874)`() {
val input = arrayOf(
@@ -495,7 +488,6 @@
check(*input).expect(expected).expectFixDiffs(expectedFixDiffs)
}
- @Ignore("b/251883059")
@Test
fun `Auto-fix for unsafe method call on this`() {
val input = arrayOf(
@@ -522,13 +514,13 @@
- getClipToPadding();
+ Api21Impl.getClipToPadding(this);
@@ -60 +60
-+ @annotation.RequiresApi(21)
++ @androidx.annotation.RequiresApi(21)
+ static class Api21Impl {
+ private Api21Impl() {
+ // This class is not instantiable.
+ }
+
-+ @annotation.DoNotInline
++ @androidx.annotation.DoNotInline
+ static boolean getClipToPadding(ViewGroup viewGroup) {
+ return viewGroup.getClipToPadding();
+ }
@@ -540,13 +532,13 @@
- this.getClipToPadding();
+ Api21Impl.getClipToPadding(this);
@@ -60 +60
-+ @annotation.RequiresApi(21)
++ @androidx.annotation.RequiresApi(21)
+ static class Api21Impl {
+ private Api21Impl() {
+ // This class is not instantiable.
+ }
+
-+ @annotation.DoNotInline
++ @androidx.annotation.DoNotInline
+ static boolean getClipToPadding(ViewGroup viewGroup) {
+ return viewGroup.getClipToPadding();
+ }
@@ -558,13 +550,13 @@
- super.getClipToPadding();
+ Api21Impl.getClipToPadding(super);
@@ -60 +60
-+ @annotation.RequiresApi(21)
++ @androidx.annotation.RequiresApi(21)
+ static class Api21Impl {
+ private Api21Impl() {
+ // This class is not instantiable.
+ }
+
-+ @annotation.DoNotInline
++ @androidx.annotation.DoNotInline
+ static boolean getClipToPadding(ViewGroup viewGroup) {
+ return viewGroup.getClipToPadding();
+ }
@@ -577,7 +569,6 @@
check(*input).expect(expected).expectFixDiffs(expectedFix)
}
- @Ignore("b/251883059")
@Test
fun `Auto-fix for unsafe method call on cast object (issue 206111383)`() {
val input = arrayOf(
@@ -598,13 +589,13 @@
- ((DisplayCutout) secretDisplayCutout).getSafeInsetTop();
+ Api28Impl.getSafeInsetTop((DisplayCutout) secretDisplayCutout);
@@ -35 +35
-+ @annotation.RequiresApi(28)
++ @androidx.annotation.RequiresApi(28)
+ static class Api28Impl {
+ private Api28Impl() {
+ // This class is not instantiable.
+ }
+
-+ @annotation.DoNotInline
++ @androidx.annotation.DoNotInline
+ static int getSafeInsetTop(DisplayCutout displayCutout) {
+ return displayCutout.getSafeInsetTop();
+ }