1/*
2 * Copyright (C) 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "java/AnnotationProcessor.h"
18
19#include "test/Test.h"
20
21namespace aapt {
22
23TEST(AnnotationProcessorTest, EmitsDeprecated) {
24  const char* comment =
25      "Some comment, and it should contain a marker word, "
26      "something that marks this resource as nor needed. "
27      "{@deprecated That's the marker! }";
28
29  AnnotationProcessor processor;
30  processor.AppendComment(comment);
31
32  std::stringstream result;
33  processor.WriteToStream(&result, "");
34  std::string annotations = result.str();
35
36  EXPECT_NE(std::string::npos, annotations.find("@Deprecated"));
37}
38
39TEST(AnnotationProcessorTest, EmitsSystemApiAnnotationAndRemovesFromComment) {
40  AnnotationProcessor processor;
41  processor.AppendComment("@SystemApi This is a system API");
42
43  std::stringstream result;
44  processor.WriteToStream(&result, "");
45  std::string annotations = result.str();
46
47  EXPECT_NE(std::string::npos,
48            annotations.find("@android.annotation.SystemApi"));
49  EXPECT_EQ(std::string::npos, annotations.find("@SystemApi"));
50  EXPECT_NE(std::string::npos, annotations.find("This is a system API"));
51}
52
53}  // namespace aapt
54