aboutsummaryrefslogtreecommitdiffstats
path: root/lint/cli
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2013-01-18 19:03:39 -0800
committerTor Norbye <tnorbye@google.com>2013-01-22 09:56:11 -0800
commit2060ee027eb80eb0ddb2ec213daeec7e32f38587 (patch)
treeed10bddd86e4648aa7fe337486cd271dd4a55f7b /lint/cli
parent964c1c4f49bb58533f4a8d1ce5b23cee3fbb7ca1 (diff)
downloadsdk-2060ee027eb80eb0ddb2ec213daeec7e32f38587.zip
sdk-2060ee027eb80eb0ddb2ec213daeec7e32f38587.tar.gz
sdk-2060ee027eb80eb0ddb2ec213daeec7e32f38587.tar.bz2
Lint bug fixes
This CL contains a number of unrelated lint bug fixes: * Fix API detector such that it warns about ?android:name attrs * Fix API detector for inlined constants such that it's more rigorous in how it determines whether a constant is used in a valid (if conditional or case value) context * Fix 43070: Analytics resources should not be flagged as needing translations * Fix 42994: Android lint should not complain about 'Custom view is missing constructor used by tools' for classes that are declared abstract * Finally, pass in the right node context for a few places it was missing it (when missing, adding suppress annotations only works on the root class AST node) Change-Id: I044140c865dbd3d0e964dae7f13c66eeb450509e
Diffstat (limited to 'lint/cli')
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/ApiDetectorTest.java13
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/TranslationDetectorTest.java11
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/ViewConstructorDetectorTest.java12
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/divider.xml37
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AbstractCustomView.class.databin0 -> 334 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AbstractCustomView.java.txt9
6 files changed, 82 insertions, 0 deletions
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 1d8cdc8..43d3727 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
@@ -60,6 +60,19 @@ public class ApiDetectorTest extends AbstractCheckTest {
));
}
+ public void testAttrWithoutSlash() throws Exception {
+ assertEquals(""
+ + "res/layout/divider.xml:7: Error: ?android:dividerHorizontal requires API level 11 (current min is 1) [NewApi]\n"
+ + " android:divider=\"?android:dividerHorizontal\"\n"
+ + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
+ + "1 errors, 0 warnings\n",
+
+ lintProject(
+ "apicheck/minsdk1.xml=>AndroidManifest.xml",
+ "apicheck/divider.xml=>res/layout/divider.xml"
+ ));
+ }
+
public void testXmlApi14() throws Exception {
assertEquals(
"No warnings.",
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/TranslationDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/TranslationDetectorTest.java
index f13cff1..ee1a2f2 100644
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/TranslationDetectorTest.java
+++ b/lint/cli/src/test/java/com/android/tools/lint/checks/TranslationDetectorTest.java
@@ -209,4 +209,15 @@ public class TranslationDetectorTest extends AbstractCheckTest {
"res/values-es/strings_locale.xml=>res/values/strings.xml",
"res/values-es-rUS/strings.xml"));
}
+
+ public void testAnalytics() throws Exception {
+ // See http://code.google.com/p/android/issues/detail?id=43070
+ assertEquals(
+ "No warnings.",
+
+ lintProject(
+ "res/values/analytics.xml",
+ "res/values-es/donottranslate.xml" // to make app multilingual
+ ));
+ }
}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/ViewConstructorDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/ViewConstructorDetectorTest.java
index 5517646..a84a74f 100644
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/ViewConstructorDetectorTest.java
+++ b/lint/cli/src/test/java/com/android/tools/lint/checks/ViewConstructorDetectorTest.java
@@ -61,4 +61,16 @@ public class ViewConstructorDetectorTest extends AbstractCheckTest {
"bin/classes/test/pkg/Intermediate$IntermediateCustomV.class"
));
}
+
+ public void testAbstract() throws Exception {
+ assertEquals(
+ "No warnings.",
+
+ lintProject(
+ "bytecode/.classpath=>.classpath",
+ "bytecode/AndroidManifest.xml=>AndroidManifest.xml",
+ "bytecode/AbstractCustomView.java.txt=>src/test/bytecode/AbstractCustomView.java",
+ "bytecode/AbstractCustomView.class.data=>bin/classes/test/bytecode/AbstractCustomView.class"
+ ));
+ }
}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/divider.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/divider.xml
new file mode 100644
index 0000000..4244319
--- /dev/null
+++ b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/divider.xml
@@ -0,0 +1,37 @@
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_marginLeft="16dp"
+ android:layout_marginRight="16dp"
+ android:divider="?android:dividerHorizontal"
+ android:orientation="horizontal"
+ android:showDividers="middle"
+ tools:context=".ItemListActivity" >
+
+ <!--
+ This layout is a two-pane layout for the Items
+ master/detail flow. See res/values-large/refs.xml and
+ res/values-sw600dp/refs.xml for an example of layout aliases
+ that replace the single-pane version of the layout with
+ this two-pane version.
+
+ For more on layout aliases, see:
+ http://developer.android.com/training/multiscreen/screensizes.html#TaskUseAliasFilters
+ -->
+
+ <fragment
+ android:id="@+id/item_list"
+ android:name="com.example.master.ItemListFragment"
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ tools:layout="@android:layout/list_content" />
+
+ <FrameLayout
+ android:id="@+id/item_detail_container"
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:layout_weight="3" />
+
+</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AbstractCustomView.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AbstractCustomView.class.data
new file mode 100644
index 0000000..8dc3dc6
--- /dev/null
+++ b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AbstractCustomView.class.data
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AbstractCustomView.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AbstractCustomView.java.txt
new file mode 100644
index 0000000..aedbafd
--- /dev/null
+++ b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AbstractCustomView.java.txt
@@ -0,0 +1,9 @@
+package test.pkg;
+
+import android.view.View;
+
+public abstract class AbstractCustomView extends View {
+ public AbstractCustomView() {
+ super(null);
+ }
+}