summaryrefslogtreecommitdiff
path: root/tools/aapt2/java/AnnotationProcessor_test.cpp
diff options
context:
space:
mode:
authorMakoto Onuki <omakoto@google.com>2020-06-22 10:17:02 -0700
committerMakoto Onuki <omakoto@google.com>2020-06-22 16:33:53 -0700
commitde6e6f2098042bb91f7dac965d2b047c74c920f2 (patch)
tree021eaed668646fbd3fff57e9b53ef21285540e0d /tools/aapt2/java/AnnotationProcessor_test.cpp
parent42a637d4ee4b35f13bfd8424765b1c8ae5e2844e (diff)
Don't add API annotations in the internal R.java
I'm trying to enable a check for the following structure: ``` /** @hide */ public class Class1 { /** @hide */ @SystemApi // Invalid because the class is hidden. public void method1() { } } ``` The internal R.java file violates this, which this change is going to fix. Bug: 159162473 Test: build (treehugger) Test: atest aapt2_tests Change-Id: I613e8611ddaf5f8e4761d351d4cd0142d59c7cc9
Diffstat (limited to 'tools/aapt2/java/AnnotationProcessor_test.cpp')
-rw-r--r--tools/aapt2/java/AnnotationProcessor_test.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/tools/aapt2/java/AnnotationProcessor_test.cpp b/tools/aapt2/java/AnnotationProcessor_test.cpp
index 7d0a4e9af632..6bc8902a6dcf 100644
--- a/tools/aapt2/java/AnnotationProcessor_test.cpp
+++ b/tools/aapt2/java/AnnotationProcessor_test.cpp
@@ -91,6 +91,21 @@ TEST(AnnotationProcessorTest, EmitsTestApiAnnotationAndRemovesFromComment) {
EXPECT_THAT(annotations, HasSubstr("This is a test API"));
}
+TEST(AnnotationProcessorTest, NotEmitSystemApiAnnotation) {
+ AnnotationProcessor processor;
+ processor.AppendComment("@SystemApi This is a system API");
+
+ std::string annotations;
+ StringOutputStream out(&annotations);
+ Printer printer(&out);
+ processor.Print(&printer, true /* strip_api_annotations */);
+ out.Flush();
+
+ EXPECT_THAT(annotations, Not(HasSubstr("@android.annotation.SystemApi")));
+ EXPECT_THAT(annotations, Not(HasSubstr("@SystemApi")));
+ EXPECT_THAT(annotations, HasSubstr("This is a system API"));
+}
+
TEST(AnnotationProcessor, ExtractsFirstSentence) {
EXPECT_THAT(AnnotationProcessor::ExtractFirstSentence("This is the only sentence"),
Eq("This is the only sentence"));