aboutsummaryrefslogtreecommitdiffstats
path: root/lint/cli
diff options
context:
space:
mode:
Diffstat (limited to 'lint/cli')
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/MainTest.java5
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/ApiDetectorTest.java54
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/styles2.xml8
3 files changed, 67 insertions, 0 deletions
diff --git a/lint/cli/src/test/java/com/android/tools/lint/MainTest.java b/lint/cli/src/test/java/com/android/tools/lint/MainTest.java
index 2ff470e..8ba40aa 100644
--- a/lint/cli/src/test/java/com/android/tools/lint/MainTest.java
+++ b/lint/cli/src/test/java/com/android/tools/lint/MainTest.java
@@ -139,6 +139,11 @@ public class MainTest extends AbstractCheckTest {
"@TargetApi(11), such that this check considers 11 rather than your manifest\n" +
"file's minimum SDK as the required API level.\n" +
"\n" +
+ "If you are deliberately setting android: attributes in style definitions, make\n" +
+ "sure you place this in a values-v11 folder in order to avoid running into\n" +
+ "runtime conflicts on certain devices where manufacturers have added custom\n" +
+ "attributes whose ids conflict with the new ones on later platforms.\n" +
+ "\n" +
"Similarly, you can use tools:targetApi=\"11\" in an XML file to indicate that\n" +
"the element will only be inflated in an adequate context.\n" +
"\n" +
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/ApiDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/ApiDetectorTest.java
index 1bcbfaa..a4c7e4a 100644
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/ApiDetectorTest.java
+++ b/lint/cli/src/test/java/com/android/tools/lint/checks/ApiDetectorTest.java
@@ -786,4 +786,58 @@ public class ApiDetectorTest extends AbstractCheckTest {
"apicheck/ApiSourceCheck.class.data=>bin/classes/test/pkg/ApiSourceCheck.class"
));
}
+
+ public void testStyleDeclaration() throws Exception {
+ assertEquals(""
+ + "res/values/styles2.xml:5: Error: android:actionBarStyle requires API level 11 (current min is 10) [NewApi]\n"
+ + " <item name=\"android:actionBarStyle\">...</item>\n"
+ + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
+ + "1 errors, 0 warnings\n",
+
+ lintProject(
+ "apicheck/classpath=>.classpath",
+ "apicheck/minsdk10.xml=>AndroidManifest.xml",
+ "project.properties1=>project.properties",
+ "res/values/styles2.xml"
+ ));
+ }
+
+ public void testStyleDeclarationInV9() throws Exception {
+ assertEquals(""
+ + "res/values-v9/styles2.xml:5: Error: android:actionBarStyle requires API level 11 (current min is 10) [NewApi]\n"
+ + " <item name=\"android:actionBarStyle\">...</item>\n"
+ + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
+ + "1 errors, 0 warnings\n",
+
+ lintProject(
+ "apicheck/classpath=>.classpath",
+ "apicheck/minsdk10.xml=>AndroidManifest.xml",
+ "project.properties1=>project.properties",
+ "res/values/styles2.xml=>res/values-v9/styles2.xml"
+ ));
+ }
+
+ public void testStyleDeclarationInV11() throws Exception {
+ assertEquals(
+ "No warnings.",
+
+ lintProject(
+ "apicheck/classpath=>.classpath",
+ "apicheck/minsdk10.xml=>AndroidManifest.xml",
+ "project.properties1=>project.properties",
+ "res/values/styles2.xml=>res/values-v11/styles2.xml"
+ ));
+ }
+
+ public void testStyleDeclarationInV14() throws Exception {
+ assertEquals(
+ "No warnings.",
+
+ lintProject(
+ "apicheck/classpath=>.classpath",
+ "apicheck/minsdk10.xml=>AndroidManifest.xml",
+ "project.properties1=>project.properties",
+ "res/values/styles2.xml=>res/values-v14/styles2.xml"
+ ));
+ }
}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/styles2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/styles2.xml
new file mode 100644
index 0000000..45422cb
--- /dev/null
+++ b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/styles2.xml
@@ -0,0 +1,8 @@
+<resources xmlns:android="http://schemas.android.com/apk/res/android">
+ <style android:name="MyStyle" parent="android:Theme.Light">
+ <!-- if the minSdk level is less then 11, then this should be a lint error, since android:actionBarStyle is since API 11,
+ unless this is in a -v11 (or better) resource folder -->
+ <item name="android:actionBarStyle">...</item>
+ <item name="android:textColor">#999999</item>
+ </style>
+</resources>