blob: 601873b6a8c78fb8d4bb0c33967dc9e36a2ada6a [file] [log] [blame]
package com.android.tools.metalava
import org.junit.Test
/**
* Tests for the ARG_FORCE_CONVERT_TO_WARNING_NULLABILITY_ANNOTATIONS functionality,
* which replaces @Nullable/@NonNull with @RecentlyNullable/@RecentlyNonNull
*/
class MarkPackagesAsRecentTest : DriverTest() {
@Test
fun `Basic MarkPackagesAsRecentTest test`() {
check(
sourceFiles = arrayOf(
java(
"""
package test.pkg;
import androidx.annotation.Nullable;
public class Foo {
@Nullable
public void method() { }
}
"""
),
androidxNullableSource
),
extraArguments = arrayOf(
ARG_FORCE_CONVERT_TO_WARNING_NULLABILITY_ANNOTATIONS, "*"
),
stubFiles = arrayOf(
java(
"""
package test.pkg;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class Foo {
public Foo() { throw new RuntimeException("Stub!"); }
@androidx.annotation.RecentlyNullable
public void method() { throw new RuntimeException("Stub!"); }
}
"""
)
)
)
}
@Test
fun `MarkPackagesAsRecent test with showAnnotation arguments`() {
check(
sourceFiles = arrayOf(
java(
"""
package test.pkg;
import androidx.annotation.Nullable;
public class Foo {
@Nullable
public void method() { }
}
"""
),
androidxNullableSource
),
extraArguments = arrayOf(
ARG_FORCE_CONVERT_TO_WARNING_NULLABILITY_ANNOTATIONS, "*",
ARG_SHOW_ANNOTATION, "androidx.annotation.RestrictTo"
),
stubFiles = arrayOf(
java(
"""
package test.pkg;
@SuppressWarnings({"unchecked", "deprecation", "all"})
public class Foo {
public Foo() { throw new RuntimeException("Stub!"); }
@androidx.annotation.RecentlyNullable
public void method() { throw new RuntimeException("Stub!"); }
}
"""
)
)
)
}
}