diff options
author | Raphael Moll <ralf@android.com> | 2013-03-12 10:39:00 -0700 |
---|---|---|
committer | Raphael Moll <ralf@android.com> | 2013-03-13 20:34:20 -0700 |
commit | f6a5b596f5473558ecc859e8af931a9f1b80a7ea (patch) | |
tree | 885f0080f18c5ba1a94781b9d61077d2c67e3add /lint/cli | |
parent | bc982e5d2a6ffc0fa5c76eaf39e77e4ec415e637 (diff) | |
download | sdk-f6a5b596f5473558ecc859e8af931a9f1b80a7ea.zip sdk-f6a5b596f5473558ecc859e8af931a9f1b80a7ea.tar.gz sdk-f6a5b596f5473558ecc859e8af931a9f1b80a7ea.tar.bz2 |
SDK: Delete projects moved to tools/base or tools/swt.
Change-Id: Iba15f82cb00d19217382c78d8ff37dda1e97ea59
Diffstat (limited to 'lint/cli')
601 files changed, 0 insertions, 26294 deletions
diff --git a/lint/cli/.classpath b/lint/cli/.classpath deleted file mode 100644 index f698d34..0000000 --- a/lint/cli/.classpath +++ /dev/null @@ -1,15 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="src" path="src/main/java"/> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> - <classpathentry combineaccessrules="false" kind="src" path="/common"/> - <classpathentry combineaccessrules="false" kind="src" path="/lint-api"/> - <classpathentry combineaccessrules="false" kind="src" path="/lint-checks"/> - <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/asm-tools/asm-4.0.jar" sourcepath="/ANDROID_SRC/prebuilts/tools/common/asm-tools/src-4.0.zip"/> - <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/asm-tools/asm-tree-4.0.jar" sourcepath="/ANDROID_SRC/prebuilts/tools/common/asm-tools/src-4.0.zip"/> - <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/asm-tools/asm-analysis-4.0.jar" sourcepath="/ANDROID_SRC/prebuilts/tools/common/asm-tools/src-4.0.zip"/> - <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/guava-tools/guava-13.0.1.jar" sourcepath="/ANDROID_SRC/prebuilts/tools/common/guava-tools/src-4.0.zip"/> - <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/lombok-ast/lombok-ast-0.2.jar" sourcepath="/ANDROID_SRC/prebuilts/tools/common/lombok-ast/src-4.0.zip"/> - <classpathentry combineaccessrules="false" kind="src" path="/sdklib"/> - <classpathentry kind="output" path="bin"/> -</classpath> diff --git a/lint/cli/.project b/lint/cli/.project deleted file mode 100644 index 2809612..0000000 --- a/lint/cli/.project +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>lint-cli</name> - <comment></comment> - <projects> - </projects> - <buildSpec> - <buildCommand> - <name>org.eclipse.jdt.core.javabuilder</name> - <arguments> - </arguments> - </buildCommand> - </buildSpec> - <natures> - <nature>org.eclipse.jdt.core.javanature</nature> - </natures> -</projectDescription> diff --git a/lint/cli/.settings/org.eclipse.jdt.core.prefs b/lint/cli/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 9dbff07..0000000 --- a/lint/cli/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,98 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore -org.eclipse.jdt.core.compiler.annotation.nonnull=com.android.annotations.NonNull -org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=com.android.annotations.NonNullByDefault -org.eclipse.jdt.core.compiler.annotation.nonnullisdefault=disabled -org.eclipse.jdt.core.compiler.annotation.nullable=com.android.annotations.Nullable -org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.autoboxing=ignore -org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning -org.eclipse.jdt.core.compiler.problem.deadCode=warning -org.eclipse.jdt.core.compiler.problem.deprecation=warning -org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled -org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled -org.eclipse.jdt.core.compiler.problem.discouragedReference=warning -org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore -org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning -org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled -org.eclipse.jdt.core.compiler.problem.fieldHiding=warning -org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning -org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning -org.eclipse.jdt.core.compiler.problem.forbiddenReference=error -org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning -org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled -org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning -org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning -org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore -org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning -org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning -org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore -org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning -org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled -org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning -org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error -org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled -org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning -org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore -org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning -org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning -org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore -org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error -org.eclipse.jdt.core.compiler.problem.nullReference=error -org.eclipse.jdt.core.compiler.problem.nullSpecInsufficientInfo=warning -org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error -org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=ignore -org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning -org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore -org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning -org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning -org.eclipse.jdt.core.compiler.problem.potentialNullSpecViolation=error -org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=warning -org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning -org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning -org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore -org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore -org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning -org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore -org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore -org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled -org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning -org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=enabled -org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled -org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore -org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning -org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled -org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning -org.eclipse.jdt.core.compiler.problem.unclosedCloseable=error -org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore -org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning -org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore -org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning -org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled -org.eclipse.jdt.core.compiler.problem.unusedImport=warning -org.eclipse.jdt.core.compiler.problem.unusedLabel=warning -org.eclipse.jdt.core.compiler.problem.unusedLocal=warning -org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning -org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore -org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled -org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning -org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning -org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.6 diff --git a/lint/cli/Android.mk b/lint/cli/Android.mk deleted file mode 100644 index 0f29dae..0000000 --- a/lint/cli/Android.mk +++ /dev/null @@ -1,42 +0,0 @@ -# Copyright 2011 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -# The lint code has moved to tools/base/lint. -# The rule below uses the prebuilt lint.jar. -# -# If you want to run the tests, cd to tools/base/lint -# and run ./gradlew :lint:test - -LOCAL_JAVA_LIBRARIES := \ - common \ - sdklib \ - lint_api \ - lint_checks \ - lombok-ast-0.2 \ - asm-tools \ - asm-tree-tools \ - asm-analysis-tools \ - guava-tools - -LOCAL_MODULE := lint -LOCAL_MODULE_TAGS := optional - -LOCAL_PREBUILT_JAVA_LIBRARIES := \ - ../../../prebuilts/devtools/tools/lib/$(LOCAL_MODULE)$(COMMON_JAVA_PACKAGE_SUFFIX) - -include $(BUILD_HOST_PREBUILT) - diff --git a/lint/cli/NOTICE b/lint/cli/NOTICE deleted file mode 100644 index becc120..0000000 --- a/lint/cli/NOTICE +++ /dev/null @@ -1,190 +0,0 @@ - - Copyright (c) 2011, The Android Open Source Project - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - diff --git a/lint/cli/etc/Android.mk b/lint/cli/etc/Android.mk deleted file mode 100644 index 987b452..0000000 --- a/lint/cli/etc/Android.mk +++ /dev/null @@ -1,10 +0,0 @@ -# Copyright 2011 The Android Open Source Project -# -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_PREBUILT_EXECUTABLES := lint -LOCAL_MODULE_TAGS := optional - -include $(BUILD_HOST_PREBUILT) - diff --git a/lint/cli/etc/lint b/lint/cli/etc/lint deleted file mode 100755 index 6a75288..0000000 --- a/lint/cli/etc/lint +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash -# Copyright 2011, The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Set up prog to be the path of this script, including following symlinks, -# and set up progdir to be the fully-qualified pathname of its directory. -prog="$0" -while [ -h "${prog}" ]; do - newProg=`/bin/ls -ld "${prog}"` - newProg=`expr "${newProg}" : ".* -> \(.*\)$"` - if expr "x${newProg}" : 'x/' >/dev/null; then - prog="${newProg}" - else - progdir=`dirname "${prog}"` - prog="${progdir}/${newProg}" - fi -done -oldwd=`pwd` -progdir=`dirname "${prog}"` -cd "${progdir}" -progdir=`pwd` -prog="${progdir}"/`basename "${prog}"` -cd "${oldwd}" - -jarfile=lint.jar -frameworkdir="$progdir" -libdir="$progdir" -if [ ! -r "$frameworkdir/$jarfile" ] -then - frameworkdir=`dirname "$progdir"`/tools/lib - libdir=`dirname "$progdir"`/tools/lib -fi -if [ ! -r "$frameworkdir/$jarfile" ] -then - frameworkdir=`dirname "$progdir"`/framework - libdir=`dirname "$progdir"`/lib -fi -if [ ! -r "$frameworkdir/$jarfile" ] -then - echo `basename "$prog"`": can't find $jarfile" - exit 1 -fi - -# Check args. -if [ debug = "$1" ]; then - # add this in for debugging - java_debug=-agentlib:jdwp=transport=dt_socket,server=y,address=8050,suspend=y - shift 1 -else - java_debug= -fi - -javaCmd="java" - -jarpath="$frameworkdir/$jarfile" - -exec "$javaCmd" \ - -Xmx512m $os_opts $java_debug \ - -Dcom.android.tools.lint.bindir="$progdir" \ - -classpath "$jarpath" \ - com.android.tools.lint.Main "$@" diff --git a/lint/cli/etc/lint.bat b/lint/cli/etc/lint.bat deleted file mode 100755 index 08ae1c3..0000000 --- a/lint/cli/etc/lint.bat +++ /dev/null @@ -1,58 +0,0 @@ -@echo off -rem Copyright (C) 2011 The Android Open Source Project -rem -rem Licensed under the Apache License, Version 2.0 (the "License"); -rem you may not use this file except in compliance with the License. -rem You may obtain a copy of the License at -rem -rem http://www.apache.org/licenses/LICENSE-2.0 -rem -rem Unless required by applicable law or agreed to in writing, software -rem distributed under the License is distributed on an "AS IS" BASIS, -rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -rem See the License for the specific language governing permissions and -rem limitations under the License. - -rem don't modify the caller's environment -setlocal - -rem Set up prog to be the path of this script, including following symlinks, -rem and set up progdir to be the fully-qualified pathname of its directory. -set prog=%~f0 - -rem Grab current directory before we change it -set work_dir="%cd%" - -rem Change current directory and drive to where the script is, to avoid -rem issues with directories containing whitespaces. -cd /d %~dp0 - -rem Get the CWD as a full path with short names only (without spaces) -for %%i in ("%cd%") do set prog_dir=%%~fsi - -rem Check we have a valid Java.exe in the path. -set java_exe= -call lib\find_java.bat -if not defined java_exe goto :EOF - -set jarfile=lint.jar -set frameworkdir= - -if exist %frameworkdir%%jarfile% goto JarFileOk - set frameworkdir=lib\ - -if exist %frameworkdir%%jarfile% goto JarFileOk - set frameworkdir=..\framework\ - -:JarFileOk - -if debug NEQ "%1" goto NoDebug - set java_debug=-agentlib:jdwp=transport=dt_socket,server=y,address=8050,suspend=y - shift 1 -:NoDebug - -set jarpath=%frameworkdir%%jarfile% -set javaextdirs=%frameworkdir% - -call %java_exe% %java_debug% -Xmx512m -Dcom.android.tools.lint.bindir=%prog_dir% -Dcom.android.tools.lint.workdir=%work_dir% -classpath "%jarpath%" com.android.tools.lint.Main %* - diff --git a/lint/cli/etc/manifest.txt b/lint/cli/etc/manifest.txt deleted file mode 100644 index ff04772..0000000 --- a/lint/cli/etc/manifest.txt +++ /dev/null @@ -1,2 +0,0 @@ -Main-Class: com.android.tools.lint.Main -Class-Path: common.jar layout_lib.jar lint_api.jar lint_checks.jar asm-4.0.jar asm-tree-4.0.jar asm-analysis-4.0.jar guava-13.0.1.jar lombok-ast-0.2.jar sdklib.jar diff --git a/lint/cli/src/main/java/com/android/tools/lint/HtmlReporter.java b/lint/cli/src/main/java/com/android/tools/lint/HtmlReporter.java deleted file mode 100644 index 83cd76d..0000000 --- a/lint/cli/src/main/java/com/android/tools/lint/HtmlReporter.java +++ /dev/null @@ -1,773 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint; - -import static com.android.SdkConstants.DOT_JPG; -import static com.android.SdkConstants.DOT_PNG; -import static com.android.tools.lint.detector.api.LintUtils.endsWith; - -import com.android.tools.lint.checks.BuiltinIssueRegistry; -import com.android.tools.lint.client.api.Configuration; -import com.android.tools.lint.detector.api.Category; -import com.android.tools.lint.detector.api.Issue; -import com.android.tools.lint.detector.api.Location; -import com.android.tools.lint.detector.api.Position; -import com.android.tools.lint.detector.api.Project; -import com.android.tools.lint.detector.api.Severity; -import com.google.common.annotations.Beta; -import com.google.common.base.Charsets; -import com.google.common.collect.Maps; -import com.google.common.io.ByteStreams; -import com.google.common.io.Closeables; -import com.google.common.io.Files; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.Writer; -import java.net.URL; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.Date; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * A reporter which emits lint results into an HTML report. - * <p> - * <b>NOTE: This is not a public or final API; if you rely on this be prepared - * to adjust your code for the next tools release.</b> - */ -@Beta -public class HtmlReporter extends Reporter { - private static final boolean USE_HOLO_STYLE = true; - private static final String CSS = USE_HOLO_STYLE - ? "hololike.css" : "default.css"; //$NON-NLS-1$ //$NON-NLS-2$ - - /** - * Maximum number of warnings allowed for a single issue type before we - * split up and hide all but the first {@link #SHOWN_COUNT} items. - */ - private static final int SPLIT_LIMIT = 8; - /** - * When a warning has at least {@link #SPLIT_LIMIT} items, then we show the - * following number of items before the "Show more" button/link. - */ - private static final int SHOWN_COUNT = SPLIT_LIMIT - 3; - - protected final Writer mWriter; - private String mStripPrefix; - private String mFixUrl; - - /** - * Creates a new {@link HtmlReporter} - * - * @param client the associated client - * @param output the output file - * @throws IOException if an error occurs - */ - public HtmlReporter(Main client, File output) throws IOException { - super(client, output); - mWriter = new BufferedWriter(Files.newWriter(output, Charsets.UTF_8)); - } - - @Override - public void write(int errorCount, int warningCount, List<Warning> issues) throws IOException { - Map<Issue, String> missing = computeMissingIssues(issues); - - mWriter.write( - "<html>\n" + //$NON-NLS-1$ - "<head>\n" + //$NON-NLS-1$ - "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>" + //$NON-NLS-1$ - "<title>" + mTitle + "</title>\n"); //$NON-NLS-1$//$NON-NLS-2$ - - writeStyleSheet(); - - if (!mSimpleFormat) { - // JavaScript for collapsing/expanding long lists - mWriter.write( - "<script language=\"javascript\"> \n" + //$NON-NLS-1$ - "<!--\n" + //$NON-NLS-1$ - "function reveal(id) {\n" + //$NON-NLS-1$ - "if (document.getElementById) {\n" + //$NON-NLS-1$ - "document.getElementById(id).style.display = 'block';\n" + //$NON-NLS-1$ - "document.getElementById(id+'Link').style.display = 'none';\n" + //$NON-NLS-1$ - "}\n" + //$NON-NLS-1$ - "}\n" + //$NON-NLS-1$ - "//--> \n" + //$NON-NLS-1$ - "</script>\n"); //$NON-NLS-1$ - } - - mWriter.write( - "</head>\n" + //$NON-NLS-1$ - "<body>\n" + //$NON-NLS-1$ - "<h1>" + //$NON-NLS-1$ - mTitle + - "<div class=\"titleSeparator\"></div>\n" + //$NON-NLS-1$ - "</h1>\n"); //$NON-NLS-1$ - - mWriter.write(String.format("Check performed at %1$s.", - new Date().toString())); - mWriter.write("<br/>"); //$NON-NLS-1$ - mWriter.write(String.format("%1$d errors and %2$d warnings found:", - errorCount, warningCount)); - mWriter.write("<br/><br/>"); //$NON-NLS-1$ - - Issue previousIssue = null; - if (!issues.isEmpty()) { - List<List<Warning>> related = new ArrayList<List<Warning>>(); - List<Warning> currentList = null; - for (Warning warning : issues) { - if (warning.issue != previousIssue) { - previousIssue = warning.issue; - currentList = new ArrayList<Warning>(); - related.add(currentList); - } - assert currentList != null; - currentList.add(warning); - } - - writeOverview(related, missing.size()); - - Category previousCategory = null; - for (List<Warning> warnings : related) { - Warning first = warnings.get(0); - Issue issue = first.issue; - - if (issue.getCategory() != previousCategory) { - previousCategory = issue.getCategory(); - mWriter.write("\n<a name=\""); //$NON-NLS-1$ - mWriter.write(issue.getCategory().getFullName()); - mWriter.write("\"></a>\n"); //$NON-NLS-1$ - mWriter.write("<div class=\"category\"><a href=\"#\" title=\"Return to top\">"); //$NON-NLS-1$ - mWriter.write(issue.getCategory().getFullName()); - mWriter.write("</a><div class=\"categorySeparator\"></div>\n");//$NON-NLS-1$ - mWriter.write("</div>\n"); //$NON-NLS-1$ - } - - mWriter.write("<a name=\"" + issue.getId() + "\"></a>\n"); //$NON-NLS-1$ //$NON-NLS-2$ - mWriter.write("<div class=\"issue\">\n"); //$NON-NLS-1$ - - // Explain this issue - mWriter.write("<div class=\"id\"><a href=\"#\" title=\"Return to top\">"); //$NON-NLS-1$ - mWriter.write(issue.getId()); - mWriter.write("</a><div class=\"issueSeparator\"></div>\n"); //$NON-NLS-1$ - mWriter.write("</div>\n"); //$NON-NLS-1$ - - mWriter.write("<div class=\"warningslist\">\n"); //$NON-NLS-1$ - boolean partialHide = !mSimpleFormat && warnings.size() > SPLIT_LIMIT; - - int count = 0; - for (Warning warning : warnings) { - if (partialHide && count == SHOWN_COUNT) { - String id = warning.issue.getId() + "Div"; //$NON-NLS-1$ - mWriter.write("<button id=\""); //$NON-NLS-1$ - mWriter.write(id); - mWriter.write("Link\" onclick=\"reveal('"); //$NON-NLS-1$ - mWriter.write(id); - mWriter.write("');\" />"); //$NON-NLS-1$ - mWriter.write(String.format("+ %1$d More Occurrences...", - warnings.size() - SHOWN_COUNT)); - mWriter.write("</button>\n"); //$NON-NLS-1$ - mWriter.write("<div id=\""); //$NON-NLS-1$ - mWriter.write(id); - mWriter.write("\" style=\"display: none\">\n"); //$NON-NLS-1$ - } - count++; - String url = null; - if (warning.path != null) { - url = writeLocation(warning.file, warning.path, warning.line); - mWriter.write(':'); - mWriter.write(' '); - } - - // Is the URL for a single image? If so, place it here near the top - // of the error floating on the right. If there are multiple images, - // they will instead be placed in a horizontal box below the error - boolean addedImage = false; - if (url != null && warning.location != null - && warning.location.getSecondary() == null) { - addedImage = addImage(url, warning.location); - } - mWriter.write("<span class=\"message\">"); //$NON-NLS-1$ - appendEscapedText(warning.message); - mWriter.write("</span>"); //$NON-NLS-1$ - if (addedImage) { - mWriter.write("<br clear=\"right\"/>"); //$NON-NLS-1$ - } else { - mWriter.write("<br />"); //$NON-NLS-1$ - } - - // Insert surrounding code block window - if (warning.line >= 0 && warning.fileContents != null) { - mWriter.write("<pre class=\"errorlines\">\n"); //$NON-NLS-1$ - appendCodeBlock(warning.fileContents, warning.line, warning.offset); - mWriter.write("\n</pre>"); //$NON-NLS-1$ - } - mWriter.write('\n'); - if (warning.location != null && warning.location.getSecondary() != null) { - mWriter.write("<ul>"); - Location l = warning.location.getSecondary(); - int otherLocations = 0; - while (l != null) { - String message = l.getMessage(); - if (message != null && !message.isEmpty()) { - Position start = l.getStart(); - int line = start != null ? start.getLine() : -1; - String path = mClient.getDisplayPath(warning.project, l.getFile()); - writeLocation(l.getFile(), path, line); - mWriter.write(':'); - mWriter.write(' '); - mWriter.write("<span class=\"message\">"); //$NON-NLS-1$ - appendEscapedText(message); - mWriter.write("</span>"); //$NON-NLS-1$ - mWriter.write("<br />"); //$NON-NLS-1$ - - String name = l.getFile().getName(); - if (!(endsWith(name, DOT_PNG) || endsWith(name, DOT_JPG))) { - String s = mClient.readFile(l.getFile()); - if (s != null && !s.isEmpty()) { - mWriter.write("<pre class=\"errorlines\">\n"); //$NON-NLS-1$ - int offset = start != null ? start.getOffset() : -1; - appendCodeBlock(s, line, offset); - mWriter.write("\n</pre>"); //$NON-NLS-1$ - } - } - } else { - otherLocations++; - } - - l = l.getSecondary(); - } - mWriter.write("</ul>"); - if (otherLocations > 0) { - - String id = "Location" + count + "Div"; //$NON-NLS-1$ - mWriter.write("<button id=\""); //$NON-NLS-1$ - mWriter.write(id); - mWriter.write("Link\" onclick=\"reveal('"); //$NON-NLS-1$ - mWriter.write(id); - mWriter.write("');\" />"); //$NON-NLS-1$ - mWriter.write(String.format("+ %1$d Additional Locations...", - otherLocations)); - mWriter.write("</button>\n"); //$NON-NLS-1$ - mWriter.write("<div id=\""); //$NON-NLS-1$ - mWriter.write(id); - mWriter.write("\" style=\"display: none\">\n"); //$NON-NLS-1$ - - mWriter.write("Additional locations: "); - mWriter.write("<ul>\n"); //$NON-NLS-1$ - l = warning.location.getSecondary(); - while (l != null) { - Position start = l.getStart(); - int line = start != null ? start.getLine() : -1; - String path = mClient.getDisplayPath(warning.project, l.getFile()); - mWriter.write("<li> "); //$NON-NLS-1$ - writeLocation(l.getFile(), path, line); - mWriter.write("\n"); //$NON-NLS-1$ - l = l.getSecondary(); - } - mWriter.write("</ul>\n"); //$NON-NLS-1$ - - mWriter.write("</div><br/><br/>\n"); //$NON-NLS-1$ - } - } - - // Place a block of images? - if (!addedImage && url != null && warning.location != null - && warning.location.getSecondary() != null) { - addImage(url, warning.location); - } - } - if (partialHide) { // Close up the extra div - mWriter.write("</div>\n"); //$NON-NLS-1$ - } - - mWriter.write("</div>\n"); //$NON-NLS-1$ - writeIssueMetadata(issue, first.severity, null); - } - - if (!mClient.isCheckingSpecificIssues()) { - writeMissingIssues(missing); - } - - writeSuppressInfo(); - } else { - mWriter.write("Congratulations!"); - } - mWriter.write("\n</body>\n</html>"); //$NON-NLS-1$ - mWriter.close(); - - String path = mOutput.getAbsolutePath(); - System.out.println(String.format("Wrote HTML report to %1$s", path)); - } - - private void writeIssueMetadata(Issue issue, Severity severity, String disabledBy) - throws IOException { - mWriter.write("<div class=\"metadata\">"); //$NON-NLS-1$ - - if (mClient.getRegistry() instanceof BuiltinIssueRegistry && - ((BuiltinIssueRegistry) mClient.getRegistry()).hasAutoFix("adt", issue)) { //$NON-NLS-1$ - mWriter.write("Note: This issue has an associated quickfix operation in Eclipse/ADT"); - if (mFixUrl != null) { - mWriter.write(" <img border=\"0\" align=\"top\" src=\""); //$NON-NLS-1$ - mWriter.write(mFixUrl); - mWriter.write("\" />\n"); //$NON-NLS-1$ - } - - mWriter.write("<br>\n"); - } - - if (disabledBy != null) { - mWriter.write(String.format("Disabled By: %1$s<br/>\n", disabledBy)); - } - - mWriter.write("Priority: "); - mWriter.write(String.format("%1$d / 10", issue.getPriority())); - mWriter.write("<br/>\n"); //$NON-NLS-1$ - mWriter.write("Category: "); - mWriter.write(issue.getCategory().getFullName()); - mWriter.write("</div>\n"); //$NON-NLS-1$ - - mWriter.write("Severity: "); - if (severity == Severity.ERROR || severity == Severity.FATAL) { - mWriter.write("<span class=\"error\">"); //$NON-NLS-1$ - } else if (severity == Severity.WARNING) { - mWriter.write("<span class=\"warning\">"); //$NON-NLS-1$ - } else { - mWriter.write("<span>"); //$NON-NLS-1$ - } - appendEscapedText(severity.getDescription()); - mWriter.write("</span>"); //$NON-NLS-1$ - - mWriter.write("<div class=\"summary\">\n"); //$NON-NLS-1$ - mWriter.write("Explanation: "); - String description = issue.getDescription(); - mWriter.write(description); - if (!description.isEmpty() - && Character.isLetter(description.charAt(description.length() - 1))) { - mWriter.write('.'); - } - mWriter.write("</div>\n"); //$NON-NLS-1$ - mWriter.write("<div class=\"explanation\">\n"); //$NON-NLS-1$ - String explanationHtml = issue.getExplanationAsHtml(); - mWriter.write(explanationHtml); - mWriter.write("\n</div>\n"); //$NON-NLS-1$; - if (issue.getMoreInfo() != null) { - mWriter.write("<br/>"); //$NON-NLS-1$ - mWriter.write("<div class=\"moreinfo\">"); //$NON-NLS-1$ - mWriter.write("More info: "); - mWriter.write("<a href=\""); //$NON-NLS-1$ - mWriter.write(issue.getMoreInfo()); - mWriter.write("\">"); //$NON-NLS-1$ - mWriter.write(issue.getMoreInfo()); - mWriter.write("</a></div>\n"); //$NON-NLS-1$ - } - - mWriter.write("<br/>"); //$NON-NLS-1$ - mWriter.write(String.format( - "To suppress this error, use the issue id \"%1$s\" as explained in the " + - "%2$sSuppressing Warnings and Errors%3$s section.", - issue.getId(), - "<a href=\"#SuppressInfo\">", "</a>")); //$NON-NLS-1$ //$NON-NLS-2$ - mWriter.write("<br/>\n"); - - mWriter.write("</div>"); //$NON-NLS-1$ - } - - private void writeSuppressInfo() throws IOException { - //getSuppressHelp - mWriter.write("\n<a name=\"SuppressInfo\"></a>\n"); //$NON-NLS-1$ - mWriter.write("<div class=\"category\">"); //$NON-NLS-1$ - mWriter.write("Suppressing Warnings and Errors"); - mWriter.write("<div class=\"categorySeparator\"></div>\n");//$NON-NLS-1$ - mWriter.write("</div>\n"); //$NON-NLS-1$ - appendEscapedText(Main.getSuppressHelp()); - mWriter.write('\n'); - } - - protected Map<Issue, String> computeMissingIssues(List<Warning> warnings) { - Set<Project> projects = new HashSet<Project>(); - Set<Issue> seen = new HashSet<Issue>(); - for (Warning warning : warnings) { - projects.add(warning.project); - seen.add(warning.issue); - } - Configuration cliConfiguration = mClient.getConfiguration(); - Map<Issue, String> map = Maps.newHashMap(); - for (Issue issue : mClient.getRegistry().getIssues()) { - if (!seen.contains(issue)) { - if (mClient.isSuppressed(issue)) { - map.put(issue, "Command line flag"); - continue; - } - - if (!issue.isEnabledByDefault() && !mClient.isAllEnabled()) { - map.put(issue, "Default"); - continue; - } - - if (cliConfiguration != null && !cliConfiguration.isEnabled(issue)) { - map.put(issue, "Command line supplied --config lint.xml file"); - continue; - } - - // See if any projects disable this warning - for (Project project : projects) { - if (!project.getConfiguration().isEnabled(issue)) { - map.put(issue, "Project lint.xml file"); - break; - } - } - } - } - - return map; - } - - private void writeMissingIssues(Map<Issue, String> missing) throws IOException { - mWriter.write("\n<a name=\"MissingIssues\"></a>\n"); //$NON-NLS-1$ - mWriter.write("<div class=\"category\">"); //$NON-NLS-1$ - mWriter.write("Disabled Checks"); - mWriter.write("<div class=\"categorySeparator\"></div>\n");//$NON-NLS-1$ - mWriter.write("</div>\n");//$NON-NLS-1$ - - mWriter.write( - "The following issues were not run by lint, either " + - "because the check is not enabled by default, or because " + - "it was disabled with a command line flag or via one or " + - "more lint.xml configuration files in the project directories."); - mWriter.write("\n<br/><br/>\n"); //$NON-NLS-1$ - - List<Issue> list = new ArrayList<Issue>(missing.keySet()); - Collections.sort(list); - - - for (Issue issue : list) { - mWriter.write("<a name=\"" + issue.getId() + "\"></a>\n"); //$NON-NLS-1$ //$NON-NLS-2$ - mWriter.write("<div class=\"issue\">\n"); //$NON-NLS-1$ - - // Explain this issue - mWriter.write("<div class=\"id\">"); //$NON-NLS-1$ - mWriter.write(issue.getId()); - mWriter.write("<div class=\"issueSeparator\"></div>\n"); //$NON-NLS-1$ - mWriter.write("</div>\n"); //$NON-NLS-1$ - String disabledBy = missing.get(issue); - writeIssueMetadata(issue, issue.getDefaultSeverity(), disabledBy); - } - } - - protected void writeStyleSheet() throws IOException { - if (USE_HOLO_STYLE) { - mWriter.write( - "<link rel=\"stylesheet\" type=\"text/css\" " + //$NON-NLS-1$ - "href=\"http://fonts.googleapis.com/css?family=Roboto\">" );//$NON-NLS-1$ - } - - URL cssUrl = HtmlReporter.class.getResource(CSS); - if (mSimpleFormat) { - // Inline the CSS - mWriter.write("<style>\n"); //$NON-NLS-1$ - @SuppressWarnings("resource") // Eclipse doesn't know about Closeables.closeQuietly - InputStream input = cssUrl.openStream(); - byte[] bytes = ByteStreams.toByteArray(input); - Closeables.closeQuietly(input); - String css = new String(bytes, Charsets.UTF_8); - mWriter.write(css); - mWriter.write("</style>\n"); //$NON-NLS-1$ - } else { - String ref = addLocalResources(cssUrl); - if (ref != null) { - mWriter.write( - "<link rel=\"stylesheet\" type=\"text/css\" href=\"" //$NON-NLS-1$ - + ref + "\">\n"); //$NON-NLS-1$ - } - } - } - - private void writeOverview(List<List<Warning>> related, int missingCount) - throws IOException { - // Write issue id summary - mWriter.write("<table class=\"overview\">\n"); //$NON-NLS-1$ - - String errorUrl = null; - String warningUrl = null; - if (!mSimpleFormat) { - errorUrl = addLocalResources(getErrorIconUrl()); - warningUrl = addLocalResources(getWarningIconUrl()); - mFixUrl = addLocalResources(HtmlReporter.class.getResource("lint-run.png")); //$NON-NLS-1$) - } - - Category previousCategory = null; - for (List<Warning> warnings : related) { - Issue issue = warnings.get(0).issue; - - boolean isError = false; - for (Warning warning : warnings) { - if (warning.severity == Severity.ERROR || warning.severity == Severity.FATAL) { - isError = true; - break; - } - } - - if (issue.getCategory() != previousCategory) { - mWriter.write("<tr><td></td><td class=\"categoryColumn\">"); - previousCategory = issue.getCategory(); - String categoryName = issue.getCategory().getFullName(); - mWriter.write("<a href=\"#"); //$NON-NLS-1$ - mWriter.write(categoryName); - mWriter.write("\">"); //$NON-NLS-1$ - mWriter.write(categoryName); - mWriter.write("</a>\n"); //$NON-NLS-1$ - mWriter.write("</td></tr>"); //$NON-NLS-1$ - mWriter.write("\n"); //$NON-NLS-1$ - } - mWriter.write("<tr>\n"); //$NON-NLS-1$ - - // Count column - mWriter.write("<td class=\"countColumn\">"); //$NON-NLS-1$ - mWriter.write(Integer.toString(warnings.size())); - mWriter.write("</td>"); //$NON-NLS-1$ - - mWriter.write("<td class=\"issueColumn\">"); //$NON-NLS-1$ - - String imageUrl = isError ? errorUrl : warningUrl; - if (imageUrl != null) { - mWriter.write("<img border=\"0\" align=\"top\" src=\""); //$NON-NLS-1$ - mWriter.write(imageUrl); - mWriter.write("\" />\n"); //$NON-NLS-1$ - } - - mWriter.write("<a href=\"#"); //$NON-NLS-1$ - mWriter.write(issue.getId()); - mWriter.write("\">"); //$NON-NLS-1$ - mWriter.write(issue.getId()); - mWriter.write("</a>\n"); //$NON-NLS-1$ - - mWriter.write("</td></tr>\n"); - } - - if (missingCount > 0 && !mClient.isCheckingSpecificIssues()) { - mWriter.write("<tr><td></td>"); //$NON-NLS-1$ - mWriter.write("<td class=\"categoryColumn\">"); //$NON-NLS-1$ - mWriter.write("<a href=\"#MissingIssues\">"); //$NON-NLS-1$ - mWriter.write(String.format("Disabled Checks (%1$d)", - missingCount)); - - mWriter.write("</a>\n"); //$NON-NLS-1$ - mWriter.write("</td></tr>"); //$NON-NLS-1$ - } - - mWriter.write("</table>\n"); //$NON-NLS-1$ - mWriter.write("<br/>"); //$NON-NLS-1$ - } - - private String writeLocation(File file, String path, int line) throws IOException { - String url; - mWriter.write("<span class=\"location\">"); //$NON-NLS-1$ - - url = getUrl(file); - if (url != null) { - mWriter.write("<a href=\""); //$NON-NLS-1$ - mWriter.write(url); - mWriter.write("\">"); //$NON-NLS-1$ - } - mWriter.write(stripPath(path)); - if (url != null) { - mWriter.write("</a>"); //$NON-NLS-1$ - } - if (line >= 0) { - // 0-based line numbers, but display 1-based - mWriter.write(':'); - mWriter.write(Integer.toString(line + 1)); - } - mWriter.write("</span>"); //$NON-NLS-1$ - return url; - } - - private boolean addImage(String url, Location location) throws IOException { - if (url != null && endsWith(url, DOT_PNG)) { - if (location.getSecondary() != null) { - // Emit many images - // Add in linked images as well - List<String> urls = new ArrayList<String>(); - while (location != null && location.getFile() != null) { - String imageUrl = getUrl(location.getFile()); - if (imageUrl != null - && endsWith(imageUrl, DOT_PNG)) { - urls.add(imageUrl); - } - location = location.getSecondary(); - } - if (!urls.isEmpty()) { - // Sort in order - Collections.sort(urls, new Comparator<String>() { - @Override - public int compare(String s1, String s2) { - return getDpiRank(s1) - getDpiRank(s2); - } - }); - mWriter.write("<table>"); //$NON-NLS-1$ - mWriter.write("<tr>"); //$NON-NLS-1$ - for (String linkedUrl : urls) { - // Image series: align top - mWriter.write("<td>"); //$NON-NLS-1$ - mWriter.write("<a href=\""); //$NON-NLS-1$ - mWriter.write(linkedUrl); - mWriter.write("\">"); //$NON-NLS-1$ - mWriter.write("<img border=\"0\" align=\"top\" src=\""); //$NON-NLS-1$ - mWriter.write(linkedUrl); - mWriter.write("\" /></a>\n"); //$NON-NLS-1$ - mWriter.write("</td>"); //$NON-NLS-1$ - } - mWriter.write("</tr>"); //$NON-NLS-1$ - - mWriter.write("<tr>"); //$NON-NLS-1$ - for (String linkedUrl : urls) { - mWriter.write("<th>"); //$NON-NLS-1$ - int index = linkedUrl.lastIndexOf("drawable-"); //$NON-NLS-1$ - if (index != -1) { - index += "drawable-".length(); //$NON-NLS-1$ - int end = linkedUrl.indexOf('/', index); - if (end != -1) { - mWriter.write(linkedUrl.substring(index, end)); - } - } - mWriter.write("</th>"); //$NON-NLS-1$ - } - mWriter.write("</tr>\n"); //$NON-NLS-1$ - - mWriter.write("</table>\n"); //$NON-NLS-1$ - } - } else { - // Just this image: float to the right - mWriter.write("<img class=\"embedimage\" align=\"right\" src=\""); //$NON-NLS-1$ - mWriter.write(url); - mWriter.write("\" />"); //$NON-NLS-1$ - } - - return true; - } - - return false; - } - - /** Provide a sorting rank for a url */ - private static int getDpiRank(String url) { - if (url.contains("-xhdpi")) { //$NON-NLS-1$ - return 0; - } else if (url.contains("-hdpi")) { //$NON-NLS-1$ - return 1; - } else if (url.contains("-mdpi")) { //$NON-NLS-1$ - return 2; - } else if (url.contains("-ldpi")) { //$NON-NLS-1$ - return 3; - } else { - return 4; - } - } - - private void appendCodeBlock(String contents, int lineno, int offset) - throws IOException { - int max = lineno + 3; - int min = lineno - 3; - for (int l = min; l < max; l++) { - if (l >= 0) { - int lineOffset = Main.getLineOffset(contents, l); - if (lineOffset == -1) { - break; - } - - mWriter.write(String.format("<span class=\"lineno\">%1$4d</span> ", (l + 1))); //$NON-NLS-1$ - - String line = Main.getLineOfOffset(contents, lineOffset); - if (offset != -1 && lineOffset <= offset && lineOffset+line.length() >= offset) { - // Text nodes do not always have correct lines/offsets - //assert l == lineno; - - // This line contains the beginning of the offset - // First print everything before - int delta = offset - lineOffset; - appendEscapedText(line.substring(0, delta)); - mWriter.write("<span class=\"errorspan\">"); //$NON-NLS-1$ - appendEscapedText(line.substring(delta)); - mWriter.write("</span>"); //$NON-NLS-1$ - } else if (offset == -1 && l == lineno) { - mWriter.write("<span class=\"errorline\">"); //$NON-NLS-1$ - appendEscapedText(line); - mWriter.write("</span>"); //$NON-NLS-1$ - } else { - appendEscapedText(line); - } - if (l < max - 1) { - mWriter.write("\n"); //$NON-NLS-1$ - } - } - } - } - - private void appendEscapedText(String textValue) throws IOException { - for (int i = 0, n = textValue.length(); i < n; i++) { - char c = textValue.charAt(i); - if (c == '<') { - mWriter.write("<"); //$NON-NLS-1$ - } else if (c == '&') { - mWriter.write("&"); //$NON-NLS-1$ - } else if (c == '\n') { - mWriter.write("<br/>"); - } else { - if (c > 255) { - mWriter.write("&#"); //$NON-NLS-1$ - mWriter.write(Integer.toString(c)); - mWriter.write(';'); - } else { - mWriter.write(c); - } - } - } - } - - private String stripPath(String path) { - if (mStripPrefix != null && path.startsWith(mStripPrefix) - && path.length() > mStripPrefix.length()) { - int index = mStripPrefix.length(); - if (path.charAt(index) == File.separatorChar) { - index++; - } - return path.substring(index); - } - - return path; - } - - /** Sets path prefix to strip from displayed file names */ - void setStripPrefix(String prefix) { - mStripPrefix = prefix; - } - - static URL getWarningIconUrl() { - return HtmlReporter.class.getResource("lint-warning.png"); //$NON-NLS-1$ - } - - static URL getErrorIconUrl() { - return HtmlReporter.class.getResource("lint-error.png"); //$NON-NLS-1$ - } -} diff --git a/lint/cli/src/main/java/com/android/tools/lint/LintCliXmlParser.java b/lint/cli/src/main/java/com/android/tools/lint/LintCliXmlParser.java deleted file mode 100644 index bfbe7cb..0000000 --- a/lint/cli/src/main/java/com/android/tools/lint/LintCliXmlParser.java +++ /dev/null @@ -1,222 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint; - -import com.android.annotations.NonNull; -import com.android.annotations.Nullable; -import com.android.tools.lint.client.api.IDomParser; -import com.android.tools.lint.client.api.IssueRegistry; -import com.android.tools.lint.detector.api.Location; -import com.android.tools.lint.detector.api.Location.Handle; -import com.android.tools.lint.detector.api.XmlContext; -import com.android.utils.PositionXmlParser; - -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import org.xml.sax.SAXException; - -import java.io.File; -import java.io.UnsupportedEncodingException; - -/** - * A customization of the {@link PositionXmlParser} which creates position - * objects that directly extend the lint - * {@link com.android.tools.lint.detector.api.Position} class. - * <p> - * It also catches and reports parser errors as lint errors. - */ -public class LintCliXmlParser extends PositionXmlParser implements IDomParser { - @Override - public Document parseXml(@NonNull XmlContext context) { - String xml = null; - try { - // Do we need to provide an input stream for encoding? - xml = context.getContents(); - if (xml != null) { - return super.parse(xml); - } - } catch (UnsupportedEncodingException e) { - context.report( - // Must provide an issue since API guarantees that the issue parameter - // is valid - IssueRegistry.PARSER_ERROR, Location.create(context.file), - e.getCause() != null ? e.getCause().getLocalizedMessage() : - e.getLocalizedMessage(), - null); - } catch (SAXException e) { - Location location = Location.create(context.file); - String message = e.getCause() != null ? e.getCause().getLocalizedMessage() : - e.getLocalizedMessage(); - if (message.startsWith("The processing instruction target matching " - + "\"[xX][mM][lL]\" is not allowed.")) { - int prologue = xml.indexOf("<?xml "); - int comment = xml.indexOf("<!--"); - if (prologue != -1 && comment != -1 && comment < prologue) { - message = "The XML prologue should appear before, not after, the first XML " - + "header/copyright comment. " + message; - } - } - context.report( - // Must provide an issue since API guarantees that the issue parameter - // is valid - IssueRegistry.PARSER_ERROR, location, - message, - null); - } catch (Throwable t) { - context.log(t, null); - } - return null; - } - - @NonNull - @Override - public Location getLocation(@NonNull XmlContext context, @NonNull Node node) { - OffsetPosition pos = (OffsetPosition) getPosition(node, -1, -1); - if (pos != null) { - return Location.create(context.file, pos, (OffsetPosition) pos.getEnd()); - } - - return Location.create(context.file); - } - - @NonNull - @Override - public Location getLocation(@NonNull XmlContext context, @NonNull Node node, - int start, int end) { - OffsetPosition pos = (OffsetPosition) getPosition(node, start, end); - if (pos != null) { - return Location.create(context.file, pos, (OffsetPosition) pos.getEnd()); - } - - return Location.create(context.file); - } - - @NonNull - @Override - public Handle createLocationHandle(@NonNull XmlContext context, @NonNull Node node) { - return new LocationHandle(context.file, node); - } - - @NonNull - @Override - protected OffsetPosition createPosition(int line, int column, int offset) { - return new OffsetPosition(line, column, offset); - } - - private static class OffsetPosition extends com.android.tools.lint.detector.api.Position - implements PositionXmlParser.Position { - /** The line number (0-based where the first line is line 0) */ - private final int mLine; - - /** - * The column number (where the first character on the line is 0), or -1 if - * unknown - */ - private final int mColumn; - - /** The character offset */ - private final int mOffset; - - /** - * Linked position: for a begin offset this will point to the end - * offset, and for an end offset this will be null - */ - private PositionXmlParser.Position mEnd; - - /** - * Creates a new {@link OffsetPosition} - * - * @param line the 0-based line number, or -1 if unknown - * @param column the 0-based column number, or -1 if unknown - * @param offset the offset, or -1 if unknown - */ - public OffsetPosition(int line, int column, int offset) { - mLine = line; - mColumn = column; - mOffset = offset; - } - - @Override - public int getLine() { - return mLine; - } - - @Override - public int getOffset() { - return mOffset; - } - - @Override - public int getColumn() { - return mColumn; - } - - @Override - public PositionXmlParser.Position getEnd() { - return mEnd; - } - - @Override - public void setEnd(@NonNull PositionXmlParser.Position end) { - mEnd = end; - } - - @Override - public String toString() { - return "OffsetPosition [line=" + mLine + ", column=" + mColumn + ", offset=" - + mOffset + ", end=" + mEnd + ']'; - } - } - - @Override - public void dispose(@NonNull XmlContext context, @NonNull Document document) { - } - - /* Handle for creating DOM positions cheaply and returning full fledged locations later */ - private class LocationHandle implements Handle { - private final File mFile; - private final Node mNode; - private Object mClientData; - - public LocationHandle(File file, Node node) { - mFile = file; - mNode = node; - } - - @NonNull - @Override - public Location resolve() { - OffsetPosition pos = (OffsetPosition) getPosition(mNode); - if (pos != null) { - return Location.create(mFile, pos, (OffsetPosition) pos.getEnd()); - } - - return Location.create(mFile); - } - - @Override - public void setClientData(@Nullable Object clientData) { - mClientData = clientData; - } - - @Override - @Nullable - public Object getClientData() { - return mClientData; - } - } -} diff --git a/lint/cli/src/main/java/com/android/tools/lint/LombokParser.java b/lint/cli/src/main/java/com/android/tools/lint/LombokParser.java deleted file mode 100644 index 26845a9..0000000 --- a/lint/cli/src/main/java/com/android/tools/lint/LombokParser.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint; - -import com.android.annotations.NonNull; -import com.android.annotations.Nullable; -import com.android.tools.lint.client.api.IJavaParser; -import com.android.tools.lint.detector.api.JavaContext; -import com.android.tools.lint.detector.api.Location; -import com.android.tools.lint.detector.api.Location.Handle; - -import java.io.File; -import java.util.List; - -import lombok.ast.CompilationUnit; -import lombok.ast.Node; -import lombok.ast.Position; -import lombok.ast.grammar.ParseProblem; -import lombok.ast.grammar.Source; - -/** - * Java parser which uses the Lombok parser directly. This is a pretty slow parser - * (2.5 times slower than javac, which in turn is about 3 times slower than EJC for - * some benchmarks). - */ -public class LombokParser implements IJavaParser { - - @Override - public Node parseJava(@NonNull JavaContext context) { - try { - Source source = new Source(context.getContents(), context.file.getName()); - List<Node> nodes = source.getNodes(); - - // Don't analyze files containing errors - List<ParseProblem> problems = source.getProblems(); - if (problems != null && !problems.isEmpty()) { - context.getDriver().setHasParserErrors(true); - - /* Silently ignore the errors. There are still some bugs in Lombok/Parboiled - * (triggered if you run lint on the AOSP framework directory for example), - * and having these show up as fatal errors when it's really a tool bug - * is bad. To make matters worse, the error messages aren't clear: - * http://code.google.com/p/projectlombok/issues/detail?id=313 - for (ParseProblem problem : problems) { - Position position = problem.getPosition(); - Location location = Location.create(context.file, - context.getContents(), position.getStart(), position.getEnd()); - // Sanitize the message? - // See http://code.google.com/p/projectlombok/issues/detail?id=313 - String message = problem.getMessage(); - context.report( - com.android.tools.lint.client.api.IssueRegistry.PARSER_ERROR, location, - message, - null); - - } - */ - return null; - } - - // There could be more than one node when there are errors; pick out the - // compilation unit node - for (Node node : nodes) { - if (node instanceof CompilationUnit) { - return node; - } - } - return null; - } catch (Throwable e) { - /* Silently ignore the errors. There are still some bugs in Lombok/Parboiled - * (triggered if you run lint on the AOSP framework directory for example), - * and having these show up as fatal errors when it's really a tool bug - * is bad. To make matters worse, the error messages aren't clear: - * http://code.google.com/p/projectlombok/issues/detail?id=313 - context.report( - IssueRegistry.PARSER_ERROR, Location.create(context.file), - e.getCause() != null ? e.getCause().getLocalizedMessage() : - e.getLocalizedMessage(), - null); - */ - - return null; - } - } - - @NonNull - @Override - public Location getLocation( - @NonNull JavaContext context, - @NonNull Node node) { - Position position = node.getPosition(); - return Location.create(context.file, context.getContents(), - position.getStart(), position.getEnd()); - } - - @NonNull - @Override - public Handle createLocationHandle(@NonNull JavaContext context, @NonNull Node node) { - return new LocationHandle(context.file, node); - } - - @Override - public void dispose(@NonNull JavaContext context, @NonNull Node compilationUnit) { - } - - /* Handle for creating positions cheaply and returning full fledged locations later */ - private static class LocationHandle implements Handle { - private final File mFile; - private final Node mNode; - private Object mClientData; - - public LocationHandle(File file, Node node) { - mFile = file; - mNode = node; - } - - @NonNull - @Override - public Location resolve() { - Position pos = mNode.getPosition(); - return Location.create(mFile, null /*contents*/, pos.getStart(), pos.getEnd()); - } - - - @Override - public void setClientData(@Nullable Object clientData) { - mClientData = clientData; - } - - @Override - @Nullable - public Object getClientData() { - return mClientData; - } - } -} diff --git a/lint/cli/src/main/java/com/android/tools/lint/Main.java b/lint/cli/src/main/java/com/android/tools/lint/Main.java deleted file mode 100644 index c53469e..0000000 --- a/lint/cli/src/main/java/com/android/tools/lint/Main.java +++ /dev/null @@ -1,1459 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint; - -import static com.android.SdkConstants.DOT_XML; -import static com.android.tools.lint.client.api.IssueRegistry.LINT_ERROR; -import static com.android.tools.lint.client.api.IssueRegistry.PARSER_ERROR; -import static com.android.tools.lint.detector.api.LintUtils.endsWith; - -import com.android.annotations.NonNull; -import com.android.annotations.Nullable; -import com.android.annotations.VisibleForTesting; -import com.android.tools.lint.checks.BuiltinIssueRegistry; -import com.android.tools.lint.client.api.Configuration; -import com.android.tools.lint.client.api.DefaultConfiguration; -import com.android.tools.lint.client.api.IDomParser; -import com.android.tools.lint.client.api.IJavaParser; -import com.android.tools.lint.client.api.IssueRegistry; -import com.android.tools.lint.client.api.LintClient; -import com.android.tools.lint.client.api.LintDriver; -import com.android.tools.lint.client.api.LintListener; -import com.android.tools.lint.detector.api.Category; -import com.android.tools.lint.detector.api.Context; -import com.android.tools.lint.detector.api.Issue; -import com.android.tools.lint.detector.api.LintUtils; -import com.android.tools.lint.detector.api.Location; -import com.android.tools.lint.detector.api.Position; -import com.android.tools.lint.detector.api.Project; -import com.android.tools.lint.detector.api.Severity; -import com.android.utils.SdkUtils; -import com.google.common.base.Splitter; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import com.google.common.io.Closeables; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileWriter; -import java.io.IOException; -import java.io.PrintStream; -import java.io.PrintWriter; -import java.io.Writer; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.Set; - -/** - * Command line driver for the lint framework - */ -public class Main extends LintClient { - static final int MAX_LINE_WIDTH = 78; - private static final String ARG_ENABLE = "--enable"; //$NON-NLS-1$ - private static final String ARG_DISABLE = "--disable"; //$NON-NLS-1$ - private static final String ARG_CHECK = "--check"; //$NON-NLS-1$ - private static final String ARG_IGNORE = "--ignore"; //$NON-NLS-1$ - private static final String ARG_LISTIDS = "--list"; //$NON-NLS-1$ - private static final String ARG_SHOW = "--show"; //$NON-NLS-1$ - private static final String ARG_QUIET = "--quiet"; //$NON-NLS-1$ - private static final String ARG_FULLPATH = "--fullpath"; //$NON-NLS-1$ - private static final String ARG_SHOWALL = "--showall"; //$NON-NLS-1$ - private static final String ARG_HELP = "--help"; //$NON-NLS-1$ - private static final String ARG_NOLINES = "--nolines"; //$NON-NLS-1$ - private static final String ARG_HTML = "--html"; //$NON-NLS-1$ - private static final String ARG_SIMPLEHTML = "--simplehtml"; //$NON-NLS-1$ - private static final String ARG_XML = "--xml"; //$NON-NLS-1$ - private static final String ARG_TEXT = "--text"; //$NON-NLS-1$ - private static final String ARG_CONFIG = "--config"; //$NON-NLS-1$ - private static final String ARG_URL = "--url"; //$NON-NLS-1$ - private static final String ARG_VERSION = "--version"; //$NON-NLS-1$ - private static final String ARG_EXITCODE = "--exitcode"; //$NON-NLS-1$ - private static final String ARG_CLASSES = "--classpath"; //$NON-NLS-1$ - private static final String ARG_SOURCES = "--sources"; //$NON-NLS-1$ - private static final String ARG_RESOURCES = "--resources"; //$NON-NLS-1$ - private static final String ARG_LIBRARIES = "--libraries"; //$NON-NLS-1$ - - private static final String ARG_NOWARN2 = "--nowarn"; //$NON-NLS-1$ - // GCC style flag names for options - private static final String ARG_NOWARN1 = "-w"; //$NON-NLS-1$ - private static final String ARG_WARNALL = "-Wall"; //$NON-NLS-1$ - private static final String ARG_ALLERROR = "-Werror"; //$NON-NLS-1$ - - private static final String VALUE_NONE = "none"; //$NON-NLS-1$ - - private static final String PROP_WORK_DIR = "com.android.tools.lint.workdir"; //$NON-NLS-1$ - - private static final int ERRNO_ERRORS = 1; - private static final int ERRNO_USAGE = 2; - private static final int ERRNO_EXISTS = 3; - private static final int ERRNO_HELP = 4; - private static final int ERRNO_INVALIDARGS = 5; - - protected final List<Warning> mWarnings = new ArrayList<Warning>(); - protected final Set<String> mSuppress = new HashSet<String>(); - protected final Set<String> mEnabled = new HashSet<String>(); - /** If non-null, only run the specified checks (possibly modified by enable/disables) */ - protected Set<String> mCheck = null; - protected boolean mHasErrors; - protected boolean mSetExitCode; - protected boolean mFullPath; - protected int mErrorCount; - protected int mWarningCount; - protected boolean mShowLines = true; - protected final List<Reporter> mReporters = Lists.newArrayList(); - protected boolean mQuiet; - protected boolean mWarnAll; - protected boolean mNoWarnings; - protected boolean mAllErrors; - protected List<File> mSources; - protected List<File> mClasses; - protected List<File> mLibraries; - protected List<File> mResources; - - protected Configuration mDefaultConfiguration; - protected IssueRegistry mRegistry; - protected LintDriver mDriver; - protected boolean mShowAll; - - /** Creates a CLI driver */ - public Main() { - } - - /** - * Runs the static analysis command line driver - * - * @param args program arguments - */ - public static void main(String[] args) { - new Main().run(args); - } - - /** - * Runs the static analysis command line driver - * - * @param args program arguments - */ - public void run(String[] args) { - if (args.length < 1) { - printUsage(System.err); - System.exit(ERRNO_USAGE); - } - - IssueRegistry registry = mRegistry = new BuiltinIssueRegistry(); - - // Mapping from file path prefix to URL. Applies only to HTML reports - String urlMap = null; - - List<File> files = new ArrayList<File>(); - for (int index = 0; index < args.length; index++) { - String arg = args[index]; - - if (arg.equals(ARG_HELP) - || arg.equals("-h") || arg.equals("-?")) { //$NON-NLS-1$ //$NON-NLS-2$ - if (index < args.length - 1) { - String topic = args[index + 1]; - if (topic.equals("suppress") || topic.equals("ignore")) { - printHelpTopicSuppress(); - System.exit(ERRNO_HELP); - } else { - System.err.println(String.format("Unknown help topic \"%1$s\"", topic)); - System.exit(ERRNO_INVALIDARGS); - } - } - printUsage(System.out); - System.exit(ERRNO_HELP); - } else if (arg.equals(ARG_LISTIDS)) { - // Did the user provide a category list? - if (index < args.length - 1 && !args[index + 1].startsWith("-")) { //$NON-NLS-1$ - String[] ids = args[++index].split(","); - for (String id : ids) { - if (registry.isCategoryName(id)) { - // List all issues with the given category - String category = id; - for (Issue issue : registry.getIssues()) { - // Check prefix such that filtering on the "Usability" category - // will match issue category "Usability:Icons" etc. - if (issue.getCategory().getName().startsWith(category) || - issue.getCategory().getFullName().startsWith(category)) { - listIssue(System.out, issue); - } - } - } else { - System.err.println("Invalid category \"" + id + "\".\n"); - displayValidIds(registry, System.err); - System.exit(ERRNO_INVALIDARGS); - } - } - } else { - displayValidIds(registry, System.out); - } - System.exit(0); - } else if (arg.equals(ARG_SHOW)) { - // Show specific issues? - if (index < args.length - 1 && !args[index + 1].startsWith("-")) { //$NON-NLS-1$ - String[] ids = args[++index].split(","); - for (String id : ids) { - if (registry.isCategoryName(id)) { - // Show all issues in the given category - String category = id; - for (Issue issue : registry.getIssues()) { - // Check prefix such that filtering on the "Usability" category - // will match issue category "Usability:Icons" etc. - if (issue.getCategory().getName().startsWith(category) || - issue.getCategory().getFullName().startsWith(category)) { - describeIssue(issue); - System.out.println(); - } - } - } else if (registry.isIssueId(id)) { - describeIssue(registry.getIssue(id)); - System.out.println(); - } else { - System.err.println("Invalid id or category \"" + id + "\".\n"); - displayValidIds(registry, System.err); - System.exit(ERRNO_INVALIDARGS); - } - } - } else { - showIssues(registry); - } - System.exit(0); - } else if (arg.equals(ARG_FULLPATH) - || arg.equals(ARG_FULLPATH + "s")) { // allow "--fullpaths" too - mFullPath = true; - } else if (arg.equals(ARG_SHOWALL)) { - mShowAll = true; - } else if (arg.equals(ARG_QUIET) || arg.equals("-q")) { - mQuiet = true; - } else if (arg.equals(ARG_NOLINES)) { - mShowLines = false; - } else if (arg.equals(ARG_EXITCODE)) { - mSetExitCode = true; - } else if (arg.equals(ARG_VERSION)) { - printVersion(); - System.exit(0); - } else if (arg.equals(ARG_URL)) { - if (index == args.length - 1) { - System.err.println("Missing URL mapping string"); - System.exit(ERRNO_INVALIDARGS); - } - String map = args[++index]; - // Allow repeated usage of the argument instead of just comma list - if (urlMap != null) { - urlMap = urlMap + ',' + map; - } else { - urlMap = map; - } - } else if (arg.equals(ARG_CONFIG)) { - if (index == args.length - 1 || !endsWith(args[index + 1], DOT_XML)) { - System.err.println("Missing XML configuration file argument"); - System.exit(ERRNO_INVALIDARGS); - } - File file = getInArgumentPath(args[++index]); - if (!file.exists()) { - System.err.println(file.getAbsolutePath() + " does not exist"); - System.exit(ERRNO_INVALIDARGS); - } - mDefaultConfiguration = new CliConfiguration(file); - } else if (arg.equals(ARG_HTML) || arg.equals(ARG_SIMPLEHTML)) { - if (index == args.length - 1) { - System.err.println("Missing HTML output file name"); - System.exit(ERRNO_INVALIDARGS); - } - File output = getOutArgumentPath(args[++index]); - // Get an absolute path such that we can ask its parent directory for - // write permission etc. - output = output.getAbsoluteFile(); - if (output.isDirectory() || - (!output.exists() && output.getName().indexOf('.') == -1)) { - if (!output.exists()) { - boolean mkdirs = output.mkdirs(); - if (!mkdirs) { - log(null, "Could not create output directory %1$s", output); - System.exit(ERRNO_EXISTS); - } - } - try { - MultiProjectHtmlReporter reporter = - new MultiProjectHtmlReporter(this, output); - if (arg.equals(ARG_SIMPLEHTML)) { - reporter.setSimpleFormat(true); - } - mReporters.add(reporter); - } catch (IOException e) { - log(e, null); - System.exit(ERRNO_INVALIDARGS); - } - continue; - } - if (output.exists()) { - boolean delete = output.delete(); - if (!delete) { - System.err.println("Could not delete old " + output); - System.exit(ERRNO_EXISTS); - } - } - if (output.getParentFile() != null && !output.getParentFile().canWrite()) { - System.err.println("Cannot write HTML output file " + output); - System.exit(ERRNO_EXISTS); - } - try { - HtmlReporter htmlReporter = new HtmlReporter(this, output); - if (arg.equals(ARG_SIMPLEHTML)) { - htmlReporter.setSimpleFormat(true); - } - mReporters.add(htmlReporter); - } catch (IOException e) { - log(e, null); - System.exit(ERRNO_INVALIDARGS); - } - } else if (arg.equals(ARG_XML)) { - if (index == args.length - 1) { - System.err.println("Missing XML output file name"); - System.exit(ERRNO_INVALIDARGS); - } - File output = getOutArgumentPath(args[++index]); - if (output.exists()) { - boolean delete = output.delete(); - if (!delete) { - System.err.println("Could not delete old " + output); - System.exit(ERRNO_EXISTS); - } - } - if (output.canWrite()) { - System.err.println("Cannot write XML output file " + output); - System.exit(ERRNO_EXISTS); - } - try { - mReporters.add(new XmlReporter(this, output)); - } catch (IOException e) { - log(e, null); - System.exit(ERRNO_INVALIDARGS); - } - } else if (arg.equals(ARG_TEXT)) { - if (index == args.length - 1) { - System.err.println("Missing XML output file name"); - System.exit(ERRNO_INVALIDARGS); - } - - Writer writer = null; - boolean closeWriter; - String outputName = args[++index]; - if (outputName.equals("stdout")) { //$NON-NLS-1$ - writer = new PrintWriter(System.out, true); - closeWriter = false; - } else { - File output = getOutArgumentPath(outputName); - if (output.exists()) { - boolean delete = output.delete(); - if (!delete) { - System.err.println("Could not delete old " + output); - System.exit(ERRNO_EXISTS); - } - } - if (output.canWrite()) { - System.err.println("Cannot write XML output file " + output); - System.exit(ERRNO_EXISTS); - } - try { - writer = new BufferedWriter(new FileWriter(output)); - } catch (IOException e) { - log(e, null); - System.exit(ERRNO_INVALIDARGS); - } - closeWriter = true; - } - mReporters.add(new TextReporter(this, writer, closeWriter)); - } else if (arg.equals(ARG_DISABLE) || arg.equals(ARG_IGNORE)) { - if (index == args.length - 1) { - System.err.println("Missing categories or id's to disable"); - System.exit(ERRNO_INVALIDARGS); - } - String[] ids = args[++index].split(","); - for (String id : ids) { - if (registry.isCategoryName(id)) { - // Suppress all issues with the given category - String category = id; - for (Issue issue : registry.getIssues()) { - // Check prefix such that filtering on the "Usability" category - // will match issue category "Usability:Icons" etc. - if (issue.getCategory().getName().startsWith(category) || - issue.getCategory().getFullName().startsWith(category)) { - mSuppress.add(issue.getId()); - } - } - } else if (!registry.isIssueId(id)) { - System.err.println("Invalid id or category \"" + id + "\".\n"); - displayValidIds(registry, System.err); - System.exit(ERRNO_INVALIDARGS); - } else { - mSuppress.add(id); - } - } - } else if (arg.equals(ARG_ENABLE)) { - if (index == args.length - 1) { - System.err.println("Missing categories or id's to enable"); - System.exit(ERRNO_INVALIDARGS); - } - String[] ids = args[++index].split(","); - for (String id : ids) { - if (registry.isCategoryName(id)) { - // Enable all issues with the given category - String category = id; - for (Issue issue : registry.getIssues()) { - if (issue.getCategory().getName().startsWith(category) || - issue.getCategory().getFullName().startsWith(category)) { - mEnabled.add(issue.getId()); - } - } - } else if (!registry.isIssueId(id)) { - System.err.println("Invalid id or category \"" + id + "\".\n"); - displayValidIds(registry, System.err); - System.exit(ERRNO_INVALIDARGS); - } else { - mEnabled.add(id); - } - } - } else if (arg.equals(ARG_CHECK)) { - if (index == args.length - 1) { - System.err.println("Missing categories or id's to check"); - System.exit(ERRNO_INVALIDARGS); - } - mCheck = new HashSet<String>(); - String[] ids = args[++index].split(","); - for (String id : ids) { - if (registry.isCategoryName(id)) { - // Check all issues with the given category - String category = id; - for (Issue issue : registry.getIssues()) { - // Check prefix such that filtering on the "Usability" category - // will match issue category "Usability:Icons" etc. - if (issue.getCategory().getName().startsWith(category) || - issue.getCategory().getFullName().startsWith(category)) { - mCheck.add(issue.getId()); - } - } - } else if (!registry.isIssueId(id)) { - System.err.println("Invalid id or category \"" + id + "\".\n"); - displayValidIds(registry, System.err); - System.exit(ERRNO_INVALIDARGS); - } else { - mCheck.add(id); - } - } - } else if (arg.equals(ARG_NOWARN1) || arg.equals(ARG_NOWARN2)) { - mNoWarnings = true; - } else if (arg.equals(ARG_WARNALL)) { - mWarnAll = true; - } else if (arg.equals(ARG_ALLERROR)) { - mAllErrors = true; - } else if (arg.equals(ARG_CLASSES)) { - if (index == args.length - 1) { - System.err.println("Missing class folder name"); - System.exit(ERRNO_INVALIDARGS); - } - String paths = args[++index]; - for (String path : LintUtils.splitPath(paths)) { - File input = getInArgumentPath(path); - if (!input.exists()) { - System.err.println("Class path entry " + input + " does not exist."); - System.exit(ERRNO_INVALIDARGS); - } - if (mClasses == null) { - mClasses = new ArrayList<File>(); - } - mClasses.add(input); - } - } else if (arg.equals(ARG_SOURCES)) { - if (index == args.length - 1) { - System.err.println("Missing source folder name"); - System.exit(ERRNO_INVALIDARGS); - } - String paths = args[++index]; - for (String path : LintUtils.splitPath(paths)) { - File input = getInArgumentPath(path); - if (!input.exists()) { - System.err.println("Source folder " + input + " does not exist."); - System.exit(ERRNO_INVALIDARGS); - } - if (mSources == null) { - mSources = new ArrayList<File>(); - } - mSources.add(input); - } - } else if (arg.equals(ARG_RESOURCES)) { - if (index == args.length - 1) { - System.err.println("Missing resource folder name"); - System.exit(ERRNO_INVALIDARGS); - } - String paths = args[++index]; - for (String path : LintUtils.splitPath(paths)) { - File input = getInArgumentPath(path); - if (!input.exists()) { - System.err.println("Resource folder " + input + " does not exist."); - System.exit(ERRNO_INVALIDARGS); - } - if (mResources == null) { - mResources = new ArrayList<File>(); - } - mResources.add(input); - } - } else if (arg.equals(ARG_LIBRARIES)) { - if (index == args.length - 1) { - System.err.println("Missing library folder name"); - System.exit(ERRNO_INVALIDARGS); - } - String paths = args[++index]; - for (String path : LintUtils.splitPath(paths)) { - File input = getInArgumentPath(path); - if (!input.exists()) { - System.err.println("Library " + input + " does not exist."); - System.exit(ERRNO_INVALIDARGS); - } - if (mLibraries == null) { - mLibraries = new ArrayList<File>(); - } - mLibraries.add(input); - } - } else if (arg.startsWith("--")) { - System.err.println("Invalid argument " + arg + "\n"); - printUsage(System.err); - System.exit(ERRNO_INVALIDARGS); - } else { - String filename = arg; - File file = getInArgumentPath(filename); - - if (!file.exists()) { - System.err.println(String.format("%1$s does not exist.", filename)); - System.exit(ERRNO_EXISTS); - } - files.add(file); - } - } - - if (files.isEmpty()) { - System.err.println("No files to analyze."); - System.exit(ERRNO_INVALIDARGS); - } else if (files.size() > 1 - && (mClasses != null || mSources != null || mLibraries != null - || mResources != null)) { - System.err.println(String.format( - "The %1$s, %2$s, %3$s and %4$s arguments can only be used with a single project", - ARG_SOURCES, ARG_CLASSES, ARG_LIBRARIES, ARG_RESOURCES)); - System.exit(ERRNO_INVALIDARGS); - } - - if (mReporters.isEmpty()) { - if (urlMap != null) { - System.err.println(String.format( - "Warning: The %1$s option only applies to HTML reports (%2$s)", - ARG_URL, ARG_HTML)); - } - - mReporters.add(new TextReporter(this, new PrintWriter(System.out, true), false)); - } else { - if (urlMap == null) { - // By default just map from /foo to file:///foo - // TODO: Find out if we need file:// on Windows. - urlMap = "=file://"; //$NON-NLS-1$ - } else { - for (Reporter reporter : mReporters) { - if (!reporter.isSimpleFormat()) { - reporter.setBundleResources(true); - } - } - } - - if (!urlMap.equals(VALUE_NONE)) { - Map<String, String> map = new HashMap<String, String>(); - String[] replace = urlMap.split(","); //$NON-NLS-1$ - for (String s : replace) { - // Allow ='s in the suffix part - int index = s.indexOf('='); - if (index == -1) { - System.err.println( - "The URL map argument must be of the form 'path_prefix=url_prefix'"); - System.exit(ERRNO_INVALIDARGS); - } - String key = s.substring(0, index); - String value = s.substring(index + 1); - map.put(key, value); - } - for (Reporter reporter : mReporters) { - reporter.setUrlMap(map); - } - } - } - - mDriver = new LintDriver(registry, this); - - mDriver.setAbbreviating(!mShowAll); - if (!mQuiet) { - mDriver.addLintListener(new ProgressPrinter()); - } - - mDriver.analyze(files, null /* scope */); - - Collections.sort(mWarnings); - - for (Reporter reporter : mReporters) { - try { - reporter.write(mErrorCount, mWarningCount, mWarnings); - } catch (IOException e) { - log(e, null); - System.exit(ERRNO_INVALIDARGS); - } - } - - System.exit(mSetExitCode ? (mHasErrors ? ERRNO_ERRORS : 0) : 0); - } - - /** - * Converts a relative or absolute command-line argument into an input file. - * - * @param filename The filename given as a command-line argument. - * @return A File matching filename, either absolute or relative to lint.workdir if defined. - */ - private static File getInArgumentPath(String filename) { - File file = new File(filename); - - if (!file.isAbsolute()) { - File workDir = getLintWorkDir(); - if (workDir != null) { - File file2 = new File(workDir, filename); - if (file2.exists()) { - try { - file = file2.getCanonicalFile(); - } catch (IOException e) { - file = file2; - } - } - } - } - return file; - } - - /** - * Converts a relative or absolute command-line argument into an output file. - * <p/> - * The difference with {@code getInArgumentPath} is that we can't check whether the - * a relative path turned into an absolute compared to lint.workdir actually exists. - * - * @param filename The filename given as a command-line argument. - * @return A File matching filename, either absolute or relative to lint.workdir if defined. - */ - private static File getOutArgumentPath(String filename) { - File file = new File(filename); - - if (!file.isAbsolute()) { - File workDir = getLintWorkDir(); - if (workDir != null) { - File file2 = new File(workDir, filename); - try { - file = file2.getCanonicalFile(); - } catch (IOException e) { - file = file2; - } - } - } - return file; - } - - - /** - * Returns the File corresponding to the system property or the environment variable - * for {@link #PROP_WORK_DIR}. - * This property is typically set by the SDK/tools/lint[.bat] wrapper. - * It denotes the path where the command-line client was originally invoked from - * and can be used to convert relative input/output paths. - * - * @return A new File corresponding to {@link #PROP_WORK_DIR} or null. - */ - @Nullable - private static File getLintWorkDir() { - // First check the Java properties (e.g. set using "java -jar ... -Dname=value") - String path = System.getProperty(PROP_WORK_DIR); - if (path == null || path.isEmpty()) { - // If not found, check environment variables. - path = System.getenv(PROP_WORK_DIR); - } - if (path != null && !path.isEmpty()) { - return new File(path); - } - return null; - } - - private static void printHelpTopicSuppress() { - System.out.println(wrap(getSuppressHelp())); - } - - static String getSuppressHelp() { - return - "Lint errors can be suppressed in a variety of ways:\n" + - "\n" + - "1. With a @SuppressLint annotation in the Java code\n" + - "2. With a tools:ignore attribute in the XML file\n" + - "3. With a lint.xml configuration file in the project\n" + - "4. With a lint.xml configuration file passed to lint " + - "via the " + ARG_CONFIG + " flag\n" + - "5. With the " + ARG_IGNORE + " flag passed to lint.\n" + - "\n" + - "To suppress a lint warning with an annotation, add " + - "a @SuppressLint(\"id\") annotation on the class, method " + - "or variable declaration closest to the warning instance " + - "you want to disable. The id can be one or more issue " + - "id's, such as \"UnusedResources\" or {\"UnusedResources\"," + - "\"UnusedIds\"}, or it can be \"all\" to suppress all lint " + - "warnings in the given scope.\n" + - "\n" + - "To suppress a lint warning in an XML file, add a " + - "tools:ignore=\"id\" attribute on the element containing " + - "the error, or one of its surrounding elements. You also " + - "need to define the namespace for the tools prefix on the " + - "root element in your document, next to the xmlns:android " + - "declaration:\n" + - "* xmlns:tools=\"http://schemas.android.com/tools\"\n" + - "\n" + - "To suppress lint warnings with a configuration XML file, " + - "create a file named lint.xml and place it at the root " + - "directory of the project in which it applies. (If you " + - "use the Eclipse plugin's Lint view, you can suppress " + - "errors there via the toolbar and Eclipse will create the " + - "lint.xml file for you.).\n" + - "\n" + - "The format of the lint.xml file is something like the " + - "following:\n" + - "\n" + - "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + - "<lint>\n" + - " <!-- Disable this given check in this project -->\n" + - " <issue id=\"IconMissingDensityFolder\" severity=\"ignore\" />\n" + - "\n" + - " <!-- Ignore the ObsoleteLayoutParam issue in the given files -->\n" + - " <issue id=\"ObsoleteLayoutParam\">\n" + - " <ignore path=\"res/layout/activation.xml\" />\n" + - " <ignore path=\"res/layout-xlarge/activation.xml\" />\n" + - " </issue>\n" + - "\n" + - " <!-- Ignore the UselessLeaf issue in the given file -->\n" + - " <issue id=\"UselessLeaf\">\n" + - " <ignore path=\"res/layout/main.xml\" />\n" + - " </issue>\n" + - "\n" + - " <!-- Change the severity of hardcoded strings to \"error\" -->\n" + - " <issue id=\"HardcodedText\" severity=\"error\" />\n" + - "</lint>\n" + - "\n" + - "To suppress lint checks from the command line, pass the " + ARG_IGNORE + " " + - "flag with a comma separated list of ids to be suppressed, such as:\n" + - "\"lint --ignore UnusedResources,UselessLeaf /my/project/path\"\n"; - } - - private void printVersion() { - String revision = getRevision(); - if (revision != null) { - System.out.println(String.format("lint: version %1$s", revision)); - } else { - System.out.println("lint: unknown version"); - } - } - - @SuppressWarnings("resource") // Eclipse doesn't know about Closeables.closeQuietly - @Nullable - String getRevision() { - File file = findResource("tools" + File.separator + //$NON-NLS-1$ - "source.properties"); //$NON-NLS-1$ - if (file != null && file.exists()) { - FileInputStream input = null; - try { - input = new FileInputStream(file); - Properties properties = new Properties(); - properties.load(input); - - String revision = properties.getProperty("Pkg.Revision"); //$NON-NLS-1$ - if (revision != null && !revision.isEmpty()) { - return revision; - } - } catch (IOException e) { - // Couldn't find or read the version info: just print out unknown below - } finally { - Closeables.closeQuietly(input); - } - } - - return null; - } - - private static void displayValidIds(IssueRegistry registry, PrintStream out) { - List<Category> categories = registry.getCategories(); - out.println("Valid issue categories:"); - for (Category category : categories) { - out.println(" " + category.getFullName()); - } - out.println(); - List<Issue> issues = registry.getIssues(); - out.println("Valid issue id's:"); - for (Issue issue : issues) { - listIssue(out, issue); - } - } - - private static void listIssue(PrintStream out, Issue issue) { - out.print(wrapArg("\"" + issue.getId() + "\": " + issue.getDescription())); - } - - private static void showIssues(IssueRegistry registry) { - List<Issue> issues = registry.getIssues(); - List<Issue> sorted = new ArrayList<Issue>(issues); - Collections.sort(sorted, new Comparator<Issue>() { - @Override - public int compare(Issue issue1, Issue issue2) { - int d = issue1.getCategory().compareTo(issue2.getCategory()); - if (d != 0) { - return d; - } - d = issue2.getPriority() - issue1.getPriority(); - if (d != 0) { - return d; - } - - return issue1.getId().compareTo(issue2.getId()); - } - }); - - System.out.println("Available issues:\n"); - Category previousCategory = null; - for (Issue issue : sorted) { - Category category = issue.getCategory(); - if (!category.equals(previousCategory)) { - String name = category.getFullName(); - System.out.println(name); - for (int i = 0, n = name.length(); i < n; i++) { - System.out.print('='); - } - System.out.println('\n'); - previousCategory = category; - } - - describeIssue(issue); - System.out.println(); - } - } - - private static void describeIssue(Issue issue) { - System.out.println(issue.getId()); - for (int i = 0; i < issue.getId().length(); i++) { - System.out.print('-'); - } - System.out.println(); - System.out.println(wrap("Summary: " + issue.getDescription())); - System.out.println("Priority: " + issue.getPriority() + " / 10"); - System.out.println("Severity: " + issue.getDefaultSeverity().getDescription()); - System.out.println("Category: " + issue.getCategory().getFullName()); - - if (!issue.isEnabledByDefault()) { - System.out.println("NOTE: This issue is disabled by default!"); - System.out.println(String.format("You can enable it by adding %1$s %2$s", ARG_ENABLE, - issue.getId())); - } - - if (issue.getExplanation() != null) { - System.out.println(); - System.out.println(wrap(issue.getExplanationAsSimpleText())); - } - if (issue.getMoreInfo() != null) { - System.out.println("More information: " + issue.getMoreInfo()); - } - } - - static String wrapArg(String explanation) { - // Wrap arguments such that the wrapped lines are not showing up in the left column - return wrap(explanation, MAX_LINE_WIDTH, " "); - } - - static String wrap(String explanation) { - return wrap(explanation, MAX_LINE_WIDTH, ""); - } - - static String wrap(String explanation, int lineWidth, String hangingIndent) { - return SdkUtils.wrap(explanation, lineWidth, hangingIndent); - } - - private static void printUsage(PrintStream out) { - // TODO: Look up launcher script name! - String command = "lint"; //$NON-NLS-1$ - - out.println("Usage: " + command + " [flags] <project directories>\n"); - out.println("Flags:\n"); - - printUsage(out, new String[] { - ARG_HELP, "This message.", - ARG_HELP + " <topic>", "Help on the given topic, such as \"suppress\".", - ARG_LISTIDS, "List the available issue id's and exit.", - ARG_VERSION, "Output version information and exit.", - ARG_EXITCODE, "Set the exit code to " + ERRNO_ERRORS + " if errors are found.", - ARG_SHOW, "List available issues along with full explanations.", - ARG_SHOW + " <ids>", "Show full explanations for the given list of issue id's.", - - "", "\nEnabled Checks:", - ARG_DISABLE + " <list>", "Disable the list of categories or " + - "specific issue id's. The list should be a comma-separated list of issue " + - "id's or categories.", - ARG_ENABLE + " <list>", "Enable the specific list of issues. " + - "This checks all the default issues plus the specifically enabled issues. The " + - "list should be a comma-separated list of issue id's or categories.", - ARG_CHECK + " <list>", "Only check the specific list of issues. " + - "This will disable everything and re-enable the given list of issues. " + - "The list should be a comma-separated list of issue id's or categories.", - ARG_NOWARN1 + ", " + ARG_NOWARN2, "Only check for errors (ignore warnings)", - ARG_WARNALL, "Check all warnings, including those off by default", - ARG_ALLERROR, "Treat all warnings as errors", - ARG_CONFIG + " <filename>", "Use the given configuration file to " + - "determine whether issues are enabled or disabled. If a project contains " + - "a lint.xml file, then this config file will be used as a fallback.", - - - "", "\nOutput Options:", - ARG_QUIET, "Don't show progress.", - ARG_FULLPATH, "Use full paths in the error output.", - ARG_SHOWALL, "Do not truncate long messages, lists of alternate locations, etc.", - ARG_NOLINES, "Do not include the source file lines with errors " + - "in the output. By default, the error output includes snippets of source code " + - "on the line containing the error, but this flag turns it off.", - ARG_HTML + " <filename>", "Create an HTML report instead. If the filename is a " + - "directory (or a new filename without an extension), lint will create a " + - "separate report for each scanned project.", - ARG_URL + " filepath=url", "Add links to HTML report, replacing local " + - "path prefixes with url prefix. The mapping can be a comma-separated list of " + - "path prefixes to corresponding URL prefixes, such as " + - "C:\\temp\\Proj1=http://buildserver/sources/temp/Proj1. To turn off linking " + - "to files, use " + ARG_URL + " " + VALUE_NONE, - ARG_SIMPLEHTML + " <filename>", "Create a simple HTML report", - ARG_XML + " <filename>", "Create an XML report instead.", - - "", "\nProject Options:", - ARG_RESOURCES + " <dir>", "Add the given folder (or path) as a resource directory " + - "for the project. Only valid when running lint on a single project.", - ARG_SOURCES + " <dir>", "Add the given folder (or path) as a source directory for " + - "the project. Only valid when running lint on a single project.", - ARG_CLASSES + " <dir>", "Add the given folder (or jar file, or path) as a class " + - "directory for the project. Only valid when running lint on a single project.", - ARG_LIBRARIES + " <dir>", "Add the given folder (or jar file, or path) as a class " + - "library for the project. Only valid when running lint on a single project.", - - "", "\nExit Status:", - "0", "Success.", - Integer.toString(ERRNO_ERRORS), "Lint errors detected.", - Integer.toString(ERRNO_USAGE), "Lint usage.", - Integer.toString(ERRNO_EXISTS), "Cannot clobber existing file.", - Integer.toString(ERRNO_HELP), "Lint help.", - Integer.toString(ERRNO_INVALIDARGS), "Invalid command-line argument.", - }); - } - - private static void printUsage(PrintStream out, String[] args) { - int argWidth = 0; - for (int i = 0; i < args.length; i += 2) { - String arg = args[i]; - argWidth = Math.max(argWidth, arg.length()); - } - argWidth += 2; - StringBuilder sb = new StringBuilder(20); - for (int i = 0; i < argWidth; i++) { - sb.append(' '); - } - String indent = sb.toString(); - String formatString = "%1$-" + argWidth + "s%2$s"; //$NON-NLS-1$ - - for (int i = 0; i < args.length; i += 2) { - String arg = args[i]; - String description = args[i + 1]; - if (arg.isEmpty()) { - out.println(description); - } else { - out.print(wrap(String.format(formatString, arg, description), - MAX_LINE_WIDTH, indent)); - } - } - } - - @Override - public void log( - @NonNull Severity severity, - @Nullable Throwable exception, - @Nullable String format, - @Nullable Object... args) { - System.out.flush(); - if (!mQuiet) { - // Place the error message on a line of its own since we're printing '.' etc - // with newlines during analysis - System.err.println(); - } - if (format != null) { - System.err.println(String.format(format, args)); - } - if (exception != null) { - exception.printStackTrace(); - } - } - - @Override - public IDomParser getDomParser() { - return new LintCliXmlParser(); - } - - @Override - public Configuration getConfiguration(@NonNull Project project) { - return new CliConfiguration(mDefaultConfiguration, project); - } - - /** File content cache */ - private final Map<File, String> mFileContents = new HashMap<File, String>(100); - - /** Read the contents of the given file, possibly cached */ - private String getContents(File file) { - String s = mFileContents.get(file); - if (s == null) { - s = readFile(file); - mFileContents.put(file, s); - } - - return s; - } - - @Override - public IJavaParser getJavaParser() { - return new LombokParser(); - } - - @Override - public void report( - @NonNull Context context, - @NonNull Issue issue, - @NonNull Severity severity, - @Nullable Location location, - @NonNull String message, - @Nullable Object data) { - assert context.isEnabled(issue); - - if (severity == Severity.IGNORE) { - return; - } - - if (severity == Severity.ERROR || severity == Severity.FATAL) { - mHasErrors = true; - mErrorCount++; - } else { - mWarningCount++; - } - - Warning warning = new Warning(issue, message, severity, context.getProject(), data); - mWarnings.add(warning); - - if (location != null) { - warning.location = location; - File file = location.getFile(); - if (file != null) { - warning.file = file; - warning.path = getDisplayPath(context.getProject(), file); - } - - Position startPosition = location.getStart(); - if (startPosition != null) { - int line = startPosition.getLine(); - warning.line = line; - warning.offset = startPosition.getOffset(); - if (line >= 0) { - if (context.file == location.getFile()) { - warning.fileContents = context.getContents(); - } - if (warning.fileContents == null) { - warning.fileContents = getContents(location.getFile()); - } - - if (mShowLines) { - // Compute error line contents - warning.errorLine = getLine(warning.fileContents, line); - if (warning.errorLine != null) { - // Replace tabs with spaces such that the column - // marker (^) lines up properly: - warning.errorLine = warning.errorLine.replace('\t', ' '); - int column = startPosition.getColumn(); - if (column < 0) { - column = 0; - for (int i = 0; i < warning.errorLine.length(); i++, column++) { - if (!Character.isWhitespace(warning.errorLine.charAt(i))) { - break; - } - } - } - StringBuilder sb = new StringBuilder(100); - sb.append(warning.errorLine); - sb.append('\n'); - for (int i = 0; i < column; i++) { - sb.append(' '); - } - - boolean displayCaret = true; - Position endPosition = location.getEnd(); - if (endPosition != null) { - int endLine = endPosition.getLine(); - int endColumn = endPosition.getColumn(); - if (endLine == line && endColumn > column) { - for (int i = column; i < endColumn; i++) { - sb.append('~'); - } - displayCaret = false; - } - } - - if (displayCaret) { - sb.append('^'); - } - sb.append('\n'); - warning.errorLine = sb.toString(); - } - } - } - } - } - } - - /** Look up the contents of the given line */ - static String getLine(String contents, int line) { - int index = getLineOffset(contents, line); - if (index != -1) { - return getLineOfOffset(contents, index); - } else { - return null; - } - } - - static String getLineOfOffset(String contents, int offset) { - int end = contents.indexOf('\n', offset); - if (end == -1) { - end = contents.indexOf('\r', offset); - } - return contents.substring(offset, end != -1 ? end : contents.length()); - } - - - /** Look up the contents of the given line */ - static int getLineOffset(String contents, int line) { - int index = 0; - for (int i = 0; i < line; i++) { - index = contents.indexOf('\n', index); - if (index == -1) { - return -1; - } - index++; - } - - return index; - } - - @NonNull - @Override - public String readFile(@NonNull File file) { - try { - return LintUtils.getEncodedString(this, file); - } catch (IOException e) { - return ""; //$NON-NLS-1$ - } - } - - boolean isCheckingSpecificIssues() { - return mCheck != null; - } - - private Map<Project, ClassPathInfo> mProjectInfo; - - @Override - @NonNull - protected ClassPathInfo getClassPath(@NonNull Project project) { - ClassPathInfo classPath = super.getClassPath(project); - - if (mClasses == null && mSources == null && mLibraries == null) { - return classPath; - } - - ClassPathInfo info; - if (mProjectInfo == null) { - mProjectInfo = Maps.newHashMap(); - info = null; - } else { - info = mProjectInfo.get(project); - } - - if (info == null) { - List<File> sources; - if (mSources != null) { - sources = mSources; - } else { - sources = classPath.getSourceFolders(); - } - List<File> classes; - if (mClasses != null) { - classes = mClasses; - } else { - classes = classPath.getClassFolders(); - } - List<File> libraries; - if (mLibraries != null) { - libraries = mLibraries; - } else { - libraries = classPath.getLibraries(); - } - - info = new ClassPathInfo(sources, classes, libraries); - mProjectInfo.put(project, info); - } - - return info; - } - - @NonNull - @Override - public List<File> getResourceFolders(@NonNull Project project) { - if (mResources == null) { - return super.getResourceFolders(project); - } - - return mResources; - } - - /** - * Consult the lint.xml file, but override with the --enable and --disable - * flags supplied on the command line - */ - class CliConfiguration extends DefaultConfiguration { - CliConfiguration(@NonNull Configuration parent, @NonNull Project project) { - super(Main.this, project, parent); - } - - CliConfiguration(File lintFile) { - super(Main.this, null /*project*/, null /*parent*/, lintFile); - } - - @NonNull - @Override - public Severity getSeverity(@NonNull Issue issue) { - Severity severity = computeSeverity(issue); - - if (mAllErrors && severity != Severity.IGNORE) { - severity = Severity.ERROR; - } - - if (mNoWarnings && severity == Severity.WARNING) { - severity = Severity.IGNORE; - } - - return severity; - } - - @NonNull - @Override - protected Severity getDefaultSeverity(@NonNull Issue issue) { - if (mWarnAll) { - return issue.getDefaultSeverity(); - } - - return super.getDefaultSeverity(issue); - } - - private Severity computeSeverity(@NonNull Issue issue) { - Severity severity = super.getSeverity(issue); - - String id = issue.getId(); - if (mSuppress.contains(id)) { - return Severity.IGNORE; - } - - if (mEnabled.contains(id) || (mCheck != null && mCheck.contains(id))) { - // Overriding default - // Detectors shouldn't be returning ignore as a default severity, - // but in case they do, force it up to warning here to ensure that - // it's run - if (severity == Severity.IGNORE) { - severity = issue.getDefaultSeverity(); - if (severity == Severity.IGNORE) { - severity = Severity.WARNING; - } - } - - return severity; - } - - if (mCheck != null && issue != LINT_ERROR && issue != PARSER_ERROR) { - return Severity.IGNORE; - } - - return severity; - } - } - - private static class ProgressPrinter implements LintListener { - @Override - public void update( - @NonNull LintDriver lint, - @NonNull EventType type, - @Nullable Context context) { - switch (type) { - case SCANNING_PROJECT: { - String name = context != null ? context.getProject().getName() : "?"; - if (lint.getPhase() > 1) { - System.out.print(String.format( - "\nScanning %1$s (Phase %2$d): ", - name, - lint.getPhase())); - } else { - System.out.print(String.format( - "\nScanning %1$s: ", - name)); - } - break; - } - case SCANNING_LIBRARY_PROJECT: { - String name = context != null ? context.getProject().getName() : "?"; - System.out.print(String.format( - "\n - %1$s: ", - name)); - break; - } - case SCANNING_FILE: - System.out.print('.'); - break; - case NEW_PHASE: - // Ignored for now: printing status as part of next project's status - break; - case CANCELED: - case COMPLETED: - System.out.println(); - break; - case STARTING: - // Ignored for now - break; - } - } - } - - /** - * Given a file, it produces a cleaned up path from the file. - * This will clean up the path such that - * <ul> - * <li> {@code foo/./bar} becomes {@code foo/bar} - * <li> {@code foo/bar/../baz} becomes {@code foo/baz} - * </ul> - * - * Unlike {@link File#getCanonicalPath()} however, it will <b>not</b> attempt - * to make the file canonical, such as expanding symlinks and network mounts. - * - * @param file the file to compute a clean path for - * @return the cleaned up path - */ - @VisibleForTesting - @NonNull - static String getCleanPath(@NonNull File file) { - String path = file.getPath(); - StringBuilder sb = new StringBuilder(path.length()); - - if (path.startsWith(File.separator)) { - sb.append(File.separator); - } - elementLoop: - for (String element : Splitter.on(File.separatorChar).omitEmptyStrings().split(path)) { - if (element.equals(".")) { //$NON-NLS-1$ - continue; - } else if (element.equals("..")) { //$NON-NLS-1$ - if (sb.length() > 0) { - for (int i = sb.length() - 1; i >= 0; i--) { - char c = sb.charAt(i); - if (c == File.separatorChar) { - sb.setLength(i == 0 ? 1 : i); - continue elementLoop; - } - } - sb.setLength(0); - continue; - } - } - - if (sb.length() > 1) { - sb.append(File.separatorChar); - } else if (sb.length() > 0 && sb.charAt(0) != File.separatorChar) { - sb.append(File.separatorChar); - } - sb.append(element); - } - if (path.endsWith(File.separator) && sb.length() > 0 - && sb.charAt(sb.length() - 1) != File.separatorChar) { - sb.append(File.separator); - } - - return sb.toString(); - } - - String getDisplayPath(Project project, File file) { - String path = file.getPath(); - if (!mFullPath && path.startsWith(project.getReferenceDir().getPath())) { - int chop = project.getReferenceDir().getPath().length(); - if (path.length() > chop && path.charAt(chop) == File.separatorChar) { - chop++; - } - path = path.substring(chop); - if (path.isEmpty()) { - path = file.getName(); - } - } else if (mFullPath) { - path = getCleanPath(file.getAbsoluteFile()); - } - - return path; - } - - /** Returns whether all warnings are enabled, including those disabled by default */ - boolean isAllEnabled() { - return mWarnAll; - } - - /** Returns the issue registry used by this client */ - IssueRegistry getRegistry() { - return mRegistry; - } - - /** Returns the driver running the lint checks */ - LintDriver getDriver() { - return mDriver; - } - - /** Returns the configuration used by this client */ - Configuration getConfiguration() { - return mDefaultConfiguration; - } - - /** Returns true if the given issue has been explicitly disabled */ - boolean isSuppressed(Issue issue) { - return mSuppress.contains(issue.getId()); - } -} diff --git a/lint/cli/src/main/java/com/android/tools/lint/MultiProjectHtmlReporter.java b/lint/cli/src/main/java/com/android/tools/lint/MultiProjectHtmlReporter.java deleted file mode 100644 index 6035c29..0000000 --- a/lint/cli/src/main/java/com/android/tools/lint/MultiProjectHtmlReporter.java +++ /dev/null @@ -1,246 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint; - -import com.android.tools.lint.detector.api.Project; -import com.android.tools.lint.detector.api.Severity; -import com.google.common.collect.Lists; -import com.google.common.collect.Sets; -import com.google.common.io.Closeables; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Set; - -/** - * "Multiplexing" reporter which allows output to be split up into a separate - * report for each separate project. It also adds an overview index. - */ -public class MultiProjectHtmlReporter extends HtmlReporter { - private static final String INDEX_NAME = "index.html"; //$NON-NLS-1$ - private final File mDir; - - public MultiProjectHtmlReporter(Main client, File dir) throws IOException { - super(client, new File(dir, INDEX_NAME)); - mDir = dir; - } - - @Override - public void write(int errorCount, int warningCount, List<Warning> allIssues) throws IOException { - Map<Project, List<Warning>> projectToWarnings = new HashMap<Project, List<Warning>>(); - for (Warning warning : allIssues) { - List<Warning> list = projectToWarnings.get(warning.project); - if (list == null) { - list = new ArrayList<Warning>(); - projectToWarnings.put(warning.project, list); - } - list.add(warning); - } - - - // Set of unique file names: lowercase names to avoid case conflicts in web environment - Set<String> unique = Sets.newHashSet(); - unique.add(INDEX_NAME.toLowerCase(Locale.US)); - List<ProjectEntry> projects = Lists.newArrayList(); - - for (Project project : projectToWarnings.keySet()) { - // TODO: Can I get the project name from the Android manifest file instead? - String projectName = project.getName(); - - // Produce file names of the form Project.html, Project1.html, Project2.html, etc - int number = 1; - String fileName; - while (true) { - String numberString = number > 1 ? Integer.toString(number) : ""; - fileName = String.format("%1$s%2$s.html", projectName, numberString); //$NON-NLS-1$ - String lowercase = fileName.toLowerCase(Locale.US); - if (!unique.contains(lowercase)) { - unique.add(lowercase); - break; - } - number++; - } - - File output = new File(mDir, fileName); - if (output.exists()) { - boolean deleted = output.delete(); - if (!deleted) { - mClient.log(null, "Could not delete old file %1$s", output); - continue; - } - } - if (!output.getParentFile().canWrite()) { - mClient.log(null, "Cannot write output file %1$s", output); - continue; - } - HtmlReporter reporter = new HtmlReporter(mClient, output); - reporter.setBundleResources(mBundleResources); - reporter.setSimpleFormat(mSimpleFormat); - reporter.setUrlMap(mUrlMap); - - List<Warning> issues = projectToWarnings.get(project); - int projectErrorCount = 0; - int projectWarningCount = 0; - for (Warning warning: issues) { - if (warning.severity == Severity.ERROR || warning.severity == Severity.FATAL) { - projectErrorCount++; - } else if (warning.severity == Severity.WARNING) { - projectWarningCount++; - } - } - - String prefix = project.getReferenceDir().getPath(); - String path = project.getDir().getPath(); - String relative; - if (path.startsWith(prefix) && path.length() > prefix.length()) { - int i = prefix.length(); - if (path.charAt(i) == File.separatorChar) { - i++; - } - relative = path.substring(i); - } else { - relative = projectName; - } - reporter.setTitle(String.format("Lint Report for %1$s", relative)); - reporter.setStripPrefix(relative); - reporter.write(projectErrorCount, projectWarningCount, issues); - - projects.add(new ProjectEntry(fileName, projectErrorCount, projectWarningCount, - relative)); - } - - // Write overview index? - writeOverview(errorCount, warningCount, projects); - Closeables.closeQuietly(mWriter); - - File index = new File(mDir, INDEX_NAME); - System.out.println(); - System.out.println(String.format("Wrote overview index to %1$s", index)); - } - - private void writeOverview(int errorCount, int warningCount, List<ProjectEntry> projects) - throws IOException { - mWriter.write( - "<html>\n" + //$NON-NLS-1$ - "<head>\n" + //$NON-NLS-1$ - "<title>" + mTitle + "</title>\n"); //$NON-NLS-1$//$NON-NLS-2$ - writeStyleSheet(); - mWriter.write( - "</head>\n" + //$NON-NLS-1$ - "<body>\n" + //$NON-NLS-1$ - "<h1>" + //$NON-NLS-1$ - mTitle + - "<div class=\"titleSeparator\"></div>\n" + //$NON-NLS-1$ - "</h1>"); //$NON-NLS-1$ - - - // Sort project list in decreasing order of errors, warnings and names - Collections.sort(projects); - - mWriter.write(String.format("Check performed at %1$s.", - new Date().toString())); - mWriter.write("<br/>"); //$NON-NLS-1$ - mWriter.write(String.format("%1$d errors and %2$d warnings found:\n", - errorCount, warningCount)); - - mWriter.write("<br/><br/>"); //$NON-NLS-1$ - - if (errorCount == 0 && warningCount == 0) { - mWriter.write("Congratulations!"); - return; - } - - String errorUrl = null; - String warningUrl = null; - if (!mSimpleFormat) { - errorUrl = addLocalResources(HtmlReporter.getErrorIconUrl()); - warningUrl = addLocalResources(HtmlReporter.getWarningIconUrl()); - } - - mWriter.write("<table class=\"overview\">\n"); //$NON-NLS-1$ - mWriter.write("<tr><th>"); //$NON-NLS-1$ - mWriter.write("Project"); - mWriter.write("</th><th class=\"countColumn\">"); //$NON-NLS-1$ - - if (errorUrl != null) { - mWriter.write("<img border=\"0\" align=\"top\" src=\""); //$NON-NLS-1$ - mWriter.write(errorUrl); - mWriter.write("\" />\n"); //$NON-NLS-1$ - } - mWriter.write("Errors"); - mWriter.write("</th><th class=\"countColumn\">"); //$NON-NLS-1$ - - if (warningUrl != null) { - mWriter.write("<img border=\"0\" align=\"top\" src=\""); //$NON-NLS-1$ - mWriter.write(warningUrl); - mWriter.write("\" />\n"); //$NON-NLS-1$ - } - mWriter.write("Warnings"); - mWriter.write("</th></tr>\n"); //$NON-NLS-1$ - - for (ProjectEntry entry : projects) { - mWriter.write("<tr><td>"); //$NON-NLS-1$ - mWriter.write("<a href=\""); - mWriter.write(entry.fileName); // TODO: Escape? - mWriter.write("\">"); //$NON-NLS-1$ - mWriter.write(entry.path); - mWriter.write("</a></td><td class=\"countColumn\">"); //$NON-NLS-1$ - mWriter.write(Integer.toString(entry.errorCount)); - mWriter.write("</td><td class=\"countColumn\">"); //$NON-NLS-1$ - mWriter.write(Integer.toString(entry.warningCount)); - mWriter.write("</td></tr>\n"); //$NON-NLS-1$ - } - mWriter.write("</table>\n"); //$NON-NLS-1$ - } - - private static class ProjectEntry implements Comparable<ProjectEntry> { - public final int errorCount; - public final int warningCount; - public final String fileName; - public final String path; - - - public ProjectEntry(String fileName, int errorCount, int warningCount, String path) { - this.fileName = fileName; - this.errorCount = errorCount; - this.warningCount = warningCount; - this.path = path; - } - - @Override - public int compareTo(ProjectEntry other) { - int delta = other.errorCount - errorCount; - if (delta != 0) { - return delta; - } - - delta = other.warningCount - warningCount; - if (delta != 0) { - return delta; - } - - return path.compareTo(other.path); - } - } -} diff --git a/lint/cli/src/main/java/com/android/tools/lint/Reporter.java b/lint/cli/src/main/java/com/android/tools/lint/Reporter.java deleted file mode 100644 index 3086a7c..0000000 --- a/lint/cli/src/main/java/com/android/tools/lint/Reporter.java +++ /dev/null @@ -1,259 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint; - -import static com.android.SdkConstants.DOT_9PNG; -import static com.android.SdkConstants.DOT_PNG; -import static com.android.tools.lint.detector.api.LintUtils.endsWith; - -import com.google.common.annotations.Beta; -import com.google.common.io.ByteStreams; -import com.google.common.io.Closeables; -import com.google.common.io.Files; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.UnsupportedEncodingException; -import java.net.URL; -import java.net.URLEncoder; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** A reporter is an output generator for lint warnings - * <p> - * <b>NOTE: This is not a public or final API; if you rely on this be prepared - * to adjust your code for the next tools release.</b> - */ -@Beta -public abstract class Reporter { - protected final Main mClient; - protected final File mOutput; - protected String mTitle = "Lint Report"; - protected boolean mSimpleFormat; - protected boolean mBundleResources; - protected Map<String, String> mUrlMap; - protected File mResources; - protected final Map<File, String> mResourceUrl = new HashMap<File, String>(); - protected final Map<String, File> mNameToFile = new HashMap<String, File>(); - - /** - * Write the given warnings into the report - * - * @param errorCount the number of errors - * @param warningCount the number of warnings - * @param issues the issues to be reported - * @throws IOException if an error occurs - */ - public abstract void write(int errorCount, int warningCount, List<Warning> issues) - throws IOException; - - protected Reporter(Main client, File output) { - mClient = client; - mOutput = output; - } - - /** - * Sets the report title - * - * @param title the title of the report - */ - public void setTitle(String title) { - mTitle = title; - } - - /** @return the title of the report */ - public String getTitle() { - return mTitle; - } - - /** - * Sets whether the report should bundle up resources along with the HTML report. - * This implies a non-simple format (see {@link #setSimpleFormat(boolean)}). - * - * @param bundleResources if true, copy images into a directory relative to - * the report - */ - public void setBundleResources(boolean bundleResources) { - mBundleResources = bundleResources; - mSimpleFormat = false; - } - - /** - * Sets whether the report should use simple formatting (meaning no JavaScript, - * embedded images, etc). - * - * @param simpleFormat whether the formatting should be simple - */ - public void setSimpleFormat(boolean simpleFormat) { - mSimpleFormat = simpleFormat; - } - - /** - * Returns whether the report should use simple formatting (meaning no JavaScript, - * embedded images, etc). - * - * @return whether the report should use simple formatting - */ - public boolean isSimpleFormat() { - return mSimpleFormat; - } - - - String getUrl(File file) { - if (mBundleResources && !mSimpleFormat) { - String url = getRelativeResourceUrl(file); - if (url != null) { - return url; - } - } - - if (mUrlMap != null) { - String path = file.getAbsolutePath(); - try { - // Perform the comparison using URLs such that we properly escape spaces etc. - String pathUrl = URLEncoder.encode(path, "UTF-8"); //$NON-NLS-1$ - for (Map.Entry<String, String> entry : mUrlMap.entrySet()) { - String prefix = entry.getKey(); - String prefixUrl = URLEncoder.encode(prefix, "UTF-8"); //$NON-NLS-1$ - if (pathUrl.startsWith(prefixUrl)) { - String relative = pathUrl.substring(prefixUrl.length()); - return entry.getValue() - + relative.replace("%2F", "/"); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - } catch (UnsupportedEncodingException e) { - // This shouldn't happen for UTF-8 - System.err.println("Invalid URL map specification - " + e.getLocalizedMessage()); - } - } - - return null; - } - - /** Encodes the given String as a safe URL substring, escaping spaces etc */ - static String encodeUrl(String url) { - try { - return URLEncoder.encode(url, "UTF-8"); //$NON-NLS-1$ - } catch (UnsupportedEncodingException e) { - // This shouldn't happen for UTF-8 - System.err.println("Invalid string " + e.getLocalizedMessage()); - return url; - } - } - - /** Set mapping of path prefixes to corresponding URLs in the HTML report */ - void setUrlMap(Map<String, String> urlMap) { - mUrlMap = urlMap; - } - - /** Gets a pointer to the local resource directory, if any */ - File getResourceDir() { - if (mResources == null && mBundleResources) { - mResources = computeResourceDir(); - if (mResources == null) { - mBundleResources = false; - } - } - - return mResources; - } - - /** Finds/creates the local resource directory, if possible */ - File computeResourceDir() { - String fileName = mOutput.getName(); - int dot = fileName.indexOf('.'); - if (dot != -1) { - fileName = fileName.substring(0, dot); - } - - File resources = new File(mOutput.getParentFile(), fileName + "_files"); //$NON-NLS-1$ - if (!resources.exists() && !resources.mkdir()) { - resources = null; - } - - return resources; - } - - /** Returns a URL to a local copy of the given file, or null */ - protected String getRelativeResourceUrl(File file) { - String resource = mResourceUrl.get(file); - if (resource != null) { - return resource; - } - - String name = file.getName(); - if (!endsWith(name, DOT_PNG) || endsWith(name, DOT_9PNG)) { - return null; - } - - // Attempt to make local copy - File resourceDir = getResourceDir(); - if (resourceDir != null) { - String base = file.getName(); - - File path = mNameToFile.get(base); - if (path != null && !path.equals(file)) { - // That filename already exists and is associated with a different path: - // make a new unique version - for (int i = 0; i < 100; i++) { - base = '_' + base; - path = mNameToFile.get(base); - if (path == null || path.equals(file)) { - break; - } - } - } - - File target = new File(resourceDir, base); - try { - Files.copy(file, target); - } catch (IOException e) { - return null; - } - return resourceDir.getName() + '/' + encodeUrl(base); - } - return null; - } - - /** Returns a URL to a local copy of the given resource, or null. There is - * no filename conflict resolution. */ - protected String addLocalResources(URL url) { - // Attempt to make local copy - File resourceDir = computeResourceDir(); - if (resourceDir != null) { - String base = url.getFile(); - base = base.substring(base.lastIndexOf('/') + 1); - mNameToFile.put(base, new File(url.toExternalForm())); - - File target = new File(resourceDir, base); - try { - FileOutputStream output = new FileOutputStream(target); - InputStream input = url.openStream(); - ByteStreams.copy(input, output); - Closeables.closeQuietly(output); - Closeables.closeQuietly(input); - } catch (IOException e) { - return null; - } - return resourceDir.getName() + '/' + encodeUrl(base); - } - return null; - } -} diff --git a/lint/cli/src/main/java/com/android/tools/lint/TextReporter.java b/lint/cli/src/main/java/com/android/tools/lint/TextReporter.java deleted file mode 100644 index 8e9f776..0000000 --- a/lint/cli/src/main/java/com/android/tools/lint/TextReporter.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint; - -import com.android.tools.lint.detector.api.Location; -import com.android.tools.lint.detector.api.Position; -import com.android.tools.lint.detector.api.Severity; -import com.google.common.annotations.Beta; - -import java.io.IOException; -import java.io.Writer; -import java.util.List; - -/** - * A reporter which emits lint warnings as plain text strings - * <p> - * <b>NOTE: This is not a public or final API; if you rely on this be prepared - * to adjust your code for the next tools release.</b> - */ -@Beta -public class TextReporter extends Reporter { - private final Writer mWriter; - private final boolean mClose; - - /** - * Constructs a new {@link TextReporter} - * - * @param client the client - * @param writer the writer to write into - * @param close whether the writer should be closed when done - */ - public TextReporter(Main client, Writer writer, boolean close) { - super(client, null); - mWriter = writer; - mClose = close; - } - - @Override - public void write(int errorCount, int warningCount, List<Warning> issues) throws IOException { - boolean abbreviate = mClient.getDriver().isAbbreviating(); - - StringBuilder output = new StringBuilder(issues.size() * 200); - if (issues.isEmpty()) { - mWriter.write('\n'); - mWriter.write("No issues found."); - mWriter.write('\n'); - mWriter.flush(); - } else { - for (Warning warning : issues) { - int startLength = output.length(); - - if (warning.path != null) { - output.append(warning.path); - output.append(':'); - - if (warning.line >= 0) { - output.append(Integer.toString(warning.line + 1)); - output.append(':'); - } - if (startLength < output.length()) { - output.append(' '); - } - } - - Severity severity = warning.severity; - if (severity == Severity.FATAL) { - // Treat the fatal error as an error such that we don't display - // both "Fatal:" and "Error:" etc in the error output. - severity = Severity.ERROR; - } - output.append(severity.getDescription()); - output.append(':'); - output.append(' '); - - output.append(warning.message); - if (warning.issue != null) { - output.append(' ').append('['); - output.append(warning.issue.getId()); - output.append(']'); - } - - output.append('\n'); - - if (warning.errorLine != null && !warning.errorLine.isEmpty()) { - output.append(warning.errorLine); - } - - if (warning.location != null && warning.location.getSecondary() != null) { - Location location = warning.location.getSecondary(); - while (location != null) { - if (location.getMessage() != null - && !location.getMessage().isEmpty()) { - output.append(" "); //$NON-NLS-1$ - String path = mClient.getDisplayPath(warning.project, - location.getFile()); - output.append(path); - - Position start = location.getStart(); - if (start != null) { - int line = start.getLine(); - if (line >= 0) { - output.append(':'); - output.append(Integer.toString(line + 1)); - } - } - - if (location.getMessage() != null - && !location.getMessage().isEmpty()) { - output.append(':'); - output.append(' '); - output.append(location.getMessage()); - } - - output.append('\n'); - } - - location = location.getSecondary(); - } - - if (!abbreviate) { - location = warning.location.getSecondary(); - StringBuilder sb = new StringBuilder(100); - sb.append("Also affects: "); - int begin = sb.length(); - while (location != null) { - if (location.getMessage() == null - || !location.getMessage().isEmpty()) { - if (sb.length() > begin) { - sb.append(", "); - } - - String path = mClient.getDisplayPath(warning.project, - location.getFile()); - sb.append(path); - - Position start = location.getStart(); - if (start != null) { - int line = start.getLine(); - if (line >= 0) { - sb.append(':'); - sb.append(Integer.toString(line + 1)); - } - } - } - - location = location.getSecondary(); - } - String wrapped = Main.wrap(sb.toString(), Main.MAX_LINE_WIDTH, " "); //$NON-NLS-1$ - output.append(wrapped); - } - } - } - - mWriter.write(output.toString()); - - mWriter.write(String.format("%1$d errors, %2$d warnings", - errorCount, warningCount)); - mWriter.write('\n'); - mWriter.flush(); - if (mClose) { - mWriter.close(); - } - } - } -}
\ No newline at end of file diff --git a/lint/cli/src/main/java/com/android/tools/lint/Warning.java b/lint/cli/src/main/java/com/android/tools/lint/Warning.java deleted file mode 100644 index b6f413b..0000000 --- a/lint/cli/src/main/java/com/android/tools/lint/Warning.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint; - -import com.android.tools.lint.client.api.LintClient; -import com.android.tools.lint.detector.api.Issue; -import com.android.tools.lint.detector.api.Location; -import com.android.tools.lint.detector.api.Project; -import com.android.tools.lint.detector.api.Severity; - -import java.io.File; - -/** - * A {@link Warning} represents a specific warning that a {@link LintClient} - * has been told about. The context stores these as they are reported into a - * list of warnings such that it can sort them all before presenting them all at - * the end. - */ -class Warning implements Comparable<Warning> { - public final Issue issue; - public final String message; - public final Severity severity; - public final Object data; - public final Project project; - public Location location; - public File file; - public String path; - public int line = -1; - public int offset = -1; - public String errorLine; - public String fileContents; - - public Warning(Issue issue, String message, Severity severity, Project project, Object data) { - this.issue = issue; - this.message = message; - this.severity = severity; - this.project = project; - this.data = data; - } - - // ---- Implements Comparable<Warning> ---- - @Override - public int compareTo(Warning other) { - // Sort by category, then by priority, then by id, - // then by file, then by line - int categoryDelta = issue.getCategory().compareTo(other.issue.getCategory()); - if (categoryDelta != 0) { - return categoryDelta; - } - // DECREASING priority order - int priorityDelta = other.issue.getPriority() - issue.getPriority(); - if (priorityDelta != 0) { - return priorityDelta; - } - String id1 = issue.getId(); - String id2 = other.issue.getId(); - if (id1 == null || id2 == null) { - return file.getName().compareTo(other.file.getName()); - } - int idDelta = id1.compareTo(id2); - if (idDelta != 0) { - return idDelta; - } - if (file != null && other.file != null) { - int fileDelta = file.getName().compareTo( - other.file.getName()); - if (fileDelta != 0) { - return fileDelta; - } - } - if (line != other.line) { - return line - other.line; - } - - return message.compareTo(other.message); - } -} diff --git a/lint/cli/src/main/java/com/android/tools/lint/XmlReporter.java b/lint/cli/src/main/java/com/android/tools/lint/XmlReporter.java deleted file mode 100644 index c0dca75..0000000 --- a/lint/cli/src/main/java/com/android/tools/lint/XmlReporter.java +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint; - -import com.android.tools.lint.checks.BuiltinIssueRegistry; -import com.android.tools.lint.detector.api.Issue; -import com.android.tools.lint.detector.api.Location; -import com.android.tools.lint.detector.api.Position; -import com.google.common.annotations.Beta; -import com.google.common.base.Charsets; -import com.google.common.io.Files; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.IOException; -import java.io.Writer; -import java.util.List; - -/** - * A reporter which emits lint results into an XML report. - * <p> - * <b>NOTE: This is not a public or final API; if you rely on this be prepared - * to adjust your code for the next tools release.</b> - */ -@Beta -public class XmlReporter extends Reporter { - private final Writer mWriter; - - /** - * Constructs a new {@link XmlReporter} - * - * @param client the client - * @param output the output file - * @throws IOException if an error occurs - */ - public XmlReporter(Main client, File output) throws IOException { - super(client, output); - mWriter = new BufferedWriter(Files.newWriter(output, Charsets.UTF_8)); - } - - @Override - public void write(int errorCount, int warningCount, List<Warning> issues) throws IOException { - mWriter.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); //$NON-NLS-1$ - mWriter.write("<issues format=\"3\""); //$NON-NLS-1$ - String revision = mClient.getRevision(); - if (revision != null) { - mWriter.write(String.format(" by=\"lint %1$s\"", revision)); //$NON-NLS-1$ - } - mWriter.write(">\n"); //$NON-NLS-1$ - - if (!issues.isEmpty()) { - for (Warning warning : issues) { - mWriter.write('\n'); - indent(mWriter, 1); - mWriter.write("<issue"); //$NON-NLS-1$ - Issue issue = warning.issue; - writeAttribute(mWriter, 2, "id", issue.getId()); //$NON-NLS-1$ - writeAttribute(mWriter, 2, "severity", - warning.severity.getDescription()); - writeAttribute(mWriter, 2, "message", warning.message); //$NON-NLS-1$ - - writeAttribute(mWriter, 2, "category", //$NON-NLS-1$ - issue.getCategory().getFullName()); - writeAttribute(mWriter, 2, "priority", //$NON-NLS-1$ - Integer.toString(issue.getPriority())); - writeAttribute(mWriter, 2, "summary", issue.getDescription()); //$NON-NLS-1$ - writeAttribute(mWriter, 2, "explanation", issue.getExplanation()); //$NON-NLS-1$ - if (issue.getMoreInfo() != null) { - writeAttribute(mWriter, 2, "url", issue.getMoreInfo()); //$NON-NLS-1$ - } - if (warning.errorLine != null && !warning.errorLine.isEmpty()) { - String line = warning.errorLine; - int index1 = line.indexOf('\n'); - if (index1 != -1) { - int index2 = line.indexOf('\n', index1 + 1); - if (index2 != -1) { - String line1 = line.substring(0, index1); - String line2 = line.substring(index1 + 1, index2); - writeAttribute(mWriter, 2, "errorLine1", line1); //$NON-NLS-1$ - writeAttribute(mWriter, 2, "errorLine2", line2); //$NON-NLS-1$ - } - } - } - if (mClient.getRegistry() instanceof BuiltinIssueRegistry && - ((BuiltinIssueRegistry) mClient.getRegistry()).hasAutoFix( - "adt", issue)) { //$NON-NLS-1$ - writeAttribute(mWriter, 2, "quickfix", "adt"); //$NON-NLS-1$ //$NON-NLS-2$ - } - - assert (warning.file != null) == (warning.location != null); - - if (warning.file != null) { - assert warning.location.getFile() == warning.file; - } - - Location location = warning.location; - if (location != null) { - mWriter.write(">\n"); //$NON-NLS-1$ - while (location != null) { - indent(mWriter, 2); - mWriter.write("<location"); //$NON-NLS-1$ - String path = mClient.getDisplayPath(warning.project, location.getFile()); - writeAttribute(mWriter, 3, "file", path); //$NON-NLS-1$ - Position start = location.getStart(); - if (start != null) { - int line = start.getLine(); - int column = start.getColumn(); - if (line >= 0) { - // +1: Line numbers internally are 0-based, report should be - // 1-based. - writeAttribute(mWriter, 3, "line", //$NON-NLS-1$ - Integer.toString(line + 1)); - if (column >= 0) { - writeAttribute(mWriter, 3, "column", //$NON-NLS-1$ - Integer.toString(column + 1)); - } - } - } - - mWriter.write("/>\n"); //$NON-NLS-1$ - location = location.getSecondary(); - } - indent(mWriter, 1); - mWriter.write("</issue>\n"); //$NON-NLS-1$ - } else { - mWriter.write('\n'); - indent(mWriter, 1); - mWriter.write("/>\n"); //$NON-NLS-1$ - } - } - } - - mWriter.write("\n</issues>\n"); //$NON-NLS-1$ - mWriter.close(); - - String path = mOutput.getAbsolutePath(); - System.out.println(String.format("Wrote XML report to %1$s", path)); - } - - private static void writeAttribute(Writer writer, int indent, String name, String value) - throws IOException { - writer.write('\n'); - indent(writer, indent); - writer.write(name); - writer.write('='); - writer.write('"'); - for (int i = 0, n = value.length(); i < n; i++) { - char c = value.charAt(i); - switch (c) { - case '"': - writer.write("""); //$NON-NLS-1$ - break; - case '\'': - writer.write("'"); //$NON-NLS-1$ - break; - case '&': - writer.write("&"); //$NON-NLS-1$ - break; - case '<': - writer.write("<"); //$NON-NLS-1$ - break; - default: - writer.write(c); - break; - } - } - writer.write('"'); - } - - private static void indent(Writer writer, int indent) throws IOException { - for (int level = 0; level < indent; level++) { - writer.write(" "); //$NON-NLS-1$ - } - } -}
\ No newline at end of file diff --git a/lint/cli/src/main/java/com/android/tools/lint/default.css b/lint/cli/src/main/java/com/android/tools/lint/default.css deleted file mode 100644 index a7cfc24..0000000 --- a/lint/cli/src/main/java/com/android/tools/lint/default.css +++ /dev/null @@ -1,72 +0,0 @@ -body { - max-width: 800px; -} -.issue { - border: solid 1px #cccccc; - margin-top: 10px; - margin-bottom: 10px; - padding: 5px; - background-color: #eeeeee; -} -.id { - font-size: 14pt; - font-weight: bold; - margin: 5px 0px 5px 0px; -} -.category { - font-size: 18pt; - font-weight: bold; - margin: 10px 0px 5px 0px; -} -.explanation { - margin-top: 10px; -} -pre { - border: solid 1px #cccccc; - background-color: #dddddd; - margin: 10pt; - overflow: auto; -} -.lineno { - color: #4f4f4f; -} -.moreinfo { -} -.embedimage { - max-width: 200px; - max-height: 200px; -} -th { font-weight: normal; } -table { border: none; } -.metadata { } -.message { font-weight:bold; } -.errorlines { font-family: monospace; } -.errorspan { font-weight: bold; } -.errorline { font-weight: bold; } -.warningslist { margin-bottom: 20px; } -.overview { - padding: 10pt; - width: 100%; - border: solid 1px #cccccc; - background-color: #eeeeee; - overflow: auto; -} -.countColumn { - text-align: right; - padding-right: 20px; -} -.issueColumn { - padding-left: 50px; -} -.titleSeparator { - background-color: #000000; - height: 2px; -} -.categorySeparator { - background-color: #444444; - height: 2px; -} -.issueSeparator { - background-color: #444444; - height: 1px; -} diff --git a/lint/cli/src/main/java/com/android/tools/lint/hololike.css b/lint/cli/src/main/java/com/android/tools/lint/hololike.css deleted file mode 100644 index b12611f..0000000 --- a/lint/cli/src/main/java/com/android/tools/lint/hololike.css +++ /dev/null @@ -1,175 +0,0 @@ -body { - max-width: 800px; - background-color: #000000; - background: -webkit-gradient(linear, left top, left bottom, from(#000000), to(#272d33)); - background: -moz-linear-gradient(top, #000000, #272d33); - color: #f3f3f3; - font-family: 'Roboto', Sans-Serif; -} -.issue { - margin-top: 10px; - margin-bottom: 10px; - padding: 5px 0px 5px 5px; -} -.id { - font-size: 14pt; - color: #bebebe; - margin: 5px 0px 5px 0px; -} -.category { - font-size: 18pt; - color: #bebebe; - margin: 10px 0px 5px 0px; -} -.explanation { - margin-top: 10px; -} -.explanation b { - color: #ffbbbb; -} -.explanation code { - color: #bebebe; - font-family: 'Roboto', Sans-Serif; -} -pre { - background-color: #282828; - margin: 5px 0px 5px 5px; - padding: 5px 5px 5px 0px; - overflow: hidden; -} -.lineno { - color: #4f4f4f; -} -.embedimage { - max-width: 200px; - max-height: 200px; -} -th { font-weight: normal; } -table { border: none; } -.metadata { -} -.location { - color: #bebebe; -} -.message { } -.errorspan { color: #33b5e5; } -.errorline { color: #33b5e5; } -.warningslist { margin-bottom: 20px; } -.overview { - padding: 10pt; - width: 100%; - overflow: auto; - border-collapse:collapse; -} -.overview tr { - border-top: solid 1px #39393a; - border-bottom: solid 1px #39393a; -} -.countColumn { - text-align: right; - padding-right: 20px; -} -.issueColumn { - padding-left: 16px; -} -.categoryColumn { - position: relative; - left: -50px; - padding-top: 20px; - padding-bottom: 5px; -} -.titleSeparator { - background-color: #33b5e5; - height: 3px; - margin-bottom: 10px; -} -.categorySeparator { - background-color: #33b5e5; - height: 3px; - margin-bottom: 10px; -} -.issueSeparator { - background-color: #39393a; - height: 2px; - margin-bottom: 10px; -} -.location a:link { - text-decoration: none; - color: #bebebe; -} -.location a:hover { - text-decoration: underline; - color: #f3f3f3; -} -a:link { - text-decoration: none; - color: #f3f3f3; -} -a:visited { - text-decoration: none; - color: #bebebe; -} -a:hover { - text-decoration: underline; - color: #f3f3f3; -} -a:active { - text-decoration: underline; - color: #f3f3f3; -} -.moreinfo a:link { - text-decoration: underline; - color: #33b5e5; -} -.moreinfo a:visited { - text-decoration: underline; - color: #33b5e5; -} -.issue a:link { - text-decoration: underline; -} -.issue a:visited { - text-decoration: underline; -} -.id a:link { - text-decoration: none; - color: #bebebe; -} -.id a:visited { - text-decoration: none; - color: #bebebe; -} -.id a:hover { - text-decoration: underline; - color: #f3f3f3; -} -.id a:active { - text-decoration: underline; - color: #bebebe; -} -.category a:link { - text-decoration: none; - color: #bebebe; -} -.category a:visited { - text-decoration: none; - color: #bebebe; -} -.category a:hover { - text-decoration: underline; - color: #f3f3f3; -} -.category a:active { - text-decoration: underline; - color: #bebebe; -} -button { - color: #ffffff; - background-color: #353535; - border-left: none; - border-right: none; - border-bottom: none; - border-top: solid 1px #5b5b5b; - font-family: 'Roboto', Sans-Serif; - font-size: 12pt; -} diff --git a/lint/cli/src/main/java/com/android/tools/lint/lint-error.png b/lint/cli/src/main/java/com/android/tools/lint/lint-error.png Binary files differdeleted file mode 100644 index fb4c982..0000000 --- a/lint/cli/src/main/java/com/android/tools/lint/lint-error.png +++ /dev/null diff --git a/lint/cli/src/main/java/com/android/tools/lint/lint-run.png b/lint/cli/src/main/java/com/android/tools/lint/lint-run.png Binary files differdeleted file mode 100644 index d1a074b..0000000 --- a/lint/cli/src/main/java/com/android/tools/lint/lint-run.png +++ /dev/null diff --git a/lint/cli/src/main/java/com/android/tools/lint/lint-warning.png b/lint/cli/src/main/java/com/android/tools/lint/lint-warning.png Binary files differdeleted file mode 100644 index 3960cdd..0000000 --- a/lint/cli/src/main/java/com/android/tools/lint/lint-warning.png +++ /dev/null diff --git a/lint/cli/src/test/.classpath b/lint/cli/src/test/.classpath deleted file mode 100644 index e79b65f..0000000 --- a/lint/cli/src/test/.classpath +++ /dev/null @@ -1,19 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="src" path="java"/> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> - <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/> - <classpathentry kind="var" path="ANDROID_OUT_FRAMEWORK/easymock.jar"/> - <classpathentry combineaccessrules="false" kind="src" path="/lint-api"/> - <classpathentry combineaccessrules="false" kind="src" path="/lint-checks"/> - <classpathentry combineaccessrules="false" kind="src" path="/lint-cli"/> - <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/asm-tools/asm-4.0.jar" sourcepath="/ANDROID_SRC/prebuilts/tools/common/asm-tools/src-4.0.zip"/> - <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/asm-tools/asm-tree-4.0.jar" sourcepath="/ANDROID_SRC/prebuilts/tools/common/asm-tools/src-4.0.zip"/> - <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/guava-tools/guava-13.0.1.jar" sourcepath="/ANDROID_SRC/prebuilts/tools/common/guava-tools/src-4.0.zip"/> - <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/lombok-ast/lombok-ast-0.2.jar" sourcepath="/ANDROID_SRC/prebuilts/tools/common/lombok-ast/src-4.0.zip"/> - <classpathentry combineaccessrules="false" kind="src" path="/layoutlib_api"/> - <classpathentry combineaccessrules="false" kind="src" path="/common"/> - <classpathentry combineaccessrules="false" kind="src" path="/testutils"/> - <classpathentry combineaccessrules="false" kind="src" path="/SdkLib"/> - <classpathentry kind="output" path="bin"/> -</classpath> diff --git a/lint/cli/src/test/.project b/lint/cli/src/test/.project deleted file mode 100644 index 5713c07..0000000 --- a/lint/cli/src/test/.project +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>lint_check-tests</name> - <comment></comment> - <projects> - </projects> - <buildSpec> - <buildCommand> - <name>org.eclipse.jdt.core.javabuilder</name> - <arguments> - </arguments> - </buildCommand> - </buildSpec> - <natures> - <nature>org.eclipse.jdt.core.javanature</nature> - </natures> -</projectDescription> diff --git a/lint/cli/src/test/.settings/org.eclipse.core.resources.prefs b/lint/cli/src/test/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 609db57..0000000 --- a/lint/cli/src/test/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,5 +0,0 @@ -eclipse.preferences.version=1 -encoding//java/com/android/tools/lint/checks/TypoDetectorTest.java=UTF-8 -encoding//java/com/android/tools/lint/checks/TypoLookupTest.java=UTF-8 -encoding//java/com/android/tools/lint/checks/TypographyDetectorTest.java=UTF-8 -encoding//java/com/android/tools/lint/checks/data/res/values-nb/typos.xml=UTF-8 diff --git a/lint/cli/src/test/.settings/org.moreunit.prefs b/lint/cli/src/test/.settings/org.moreunit.prefs deleted file mode 100644 index 4bc8717..0000000 --- a/lint/cli/src/test/.settings/org.moreunit.prefs +++ /dev/null @@ -1,4 +0,0 @@ -eclipse.preferences.version=1 -org.moreunit.prefixes= -org.moreunit.unitsourcefolder=lint_check-tests\:java\:lint-api\:src/main/java\#lint_check-tests\:java\:lint-checks\:src/main/java\#lint_check-tests\:java\:lint-cli\:src/main/java -org.moreunit.useprojectsettings=true diff --git a/lint/cli/src/test/java/com/android/tools/lint/LintCliXmlParserTest.java b/lint/cli/src/test/java/com/android/tools/lint/LintCliXmlParserTest.java deleted file mode 100644 index 9fa310f..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/LintCliXmlParserTest.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint; - -import com.android.annotations.NonNull; -import com.android.annotations.Nullable; -import com.android.tools.lint.checks.BuiltinIssueRegistry; -import com.android.tools.lint.client.api.LintClient; -import com.android.tools.lint.client.api.LintDriver; -import com.android.tools.lint.detector.api.Context; -import com.android.tools.lint.detector.api.Issue; -import com.android.tools.lint.detector.api.Location; -import com.android.tools.lint.detector.api.Location.Handle; -import com.android.tools.lint.detector.api.Position; -import com.android.tools.lint.detector.api.Project; -import com.android.tools.lint.detector.api.Severity; -import com.android.tools.lint.detector.api.XmlContext; - -import org.w3c.dom.Attr; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.NodeList; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; -import java.io.Writer; - -import junit.framework.TestCase; - -@SuppressWarnings("javadoc") -public class LintCliXmlParserTest extends TestCase { - public void test() throws Exception { - String xml = - "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + - "<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" + - " android:layout_width=\"match_parent\"\n" + - " android:layout_height=\"wrap_content\"\n" + - " android:orientation=\"vertical\" >\n" + - "\n" + - " <Button\n" + - " android:id=\"@+id/button1\"\n" + - " android:layout_width=\"wrap_content\"\n" + - " android:layout_height=\"wrap_content\"\n" + - " android:text=\"Button\" />\n" + - "\n" + - " <Button\n" + - " android:id=\"@+id/button2\"\n" + - " android:layout_width=\"wrap_content\"\n" + - " android:layout_height=\"wrap_content\"\n" + - " android:text=\"Button\" />\n" + - "\n" + - "</LinearLayout>\n"; - LintCliXmlParser parser = new LintCliXmlParser(); - File file = File.createTempFile("parsertest", ".xml"); - Writer fw = new BufferedWriter(new FileWriter(file)); - fw.write(xml); - fw.close(); - LintClient client = new TestClient(); - LintDriver driver = new LintDriver(new BuiltinIssueRegistry(), client); - Project project = Project.create(client, file.getParentFile(), file.getParentFile()); - XmlContext context = new XmlContext(driver, project, null, file, null); - Document document = parser.parseXml(context); - assertNotNull(document); - - // Basic parsing heart beat tests - Element linearLayout = (Element) document.getElementsByTagName("LinearLayout").item(0); - assertNotNull(linearLayout); - NodeList buttons = document.getElementsByTagName("Button"); - assertEquals(2, buttons.getLength()); - final String ANDROID_URI = "http://schemas.android.com/apk/res/android"; - assertEquals("wrap_content", - linearLayout.getAttributeNS(ANDROID_URI, "layout_height")); - - // Check attribute positions - Attr attr = linearLayout.getAttributeNodeNS(ANDROID_URI, "layout_width"); - assertNotNull(attr); - Location location = parser.getLocation(context, attr); - Position start = location.getStart(); - Position end = location.getEnd(); - assertEquals(2, start.getLine()); - assertEquals(xml.indexOf("android:layout_width"), start.getOffset()); - assertEquals(2, end.getLine()); - String target = "android:layout_width=\"match_parent\""; - assertEquals(xml.indexOf(target) + target.length(), end.getOffset()); - - // Check element positions - Element button = (Element) buttons.item(0); - location = parser.getLocation(context, button); - start = location.getStart(); - end = location.getEnd(); - assertEquals(6, start.getLine()); - assertEquals(xml.indexOf("<Button"), start.getOffset()); - assertEquals(xml.indexOf("/>") + 2, end.getOffset()); - assertEquals(10, end.getLine()); - int button1End = end.getOffset(); - - Handle handle = parser.createLocationHandle(context, button); - Location location2 = handle.resolve(); - assertSame(location.getFile(), location.getFile()); - assertNotNull(location2.getStart()); - assertNotNull(location2.getEnd()); - assertEquals(6, location2.getStart().getLine()); - assertEquals(10, location2.getEnd().getLine()); - - Element button2 = (Element) buttons.item(1); - location = parser.getLocation(context, button2); - start = location.getStart(); - end = location.getEnd(); - assertEquals(12, start.getLine()); - assertEquals(xml.indexOf("<Button", button1End), start.getOffset()); - assertEquals(xml.indexOf("/>", start.getOffset()) + 2, end.getOffset()); - assertEquals(16, end.getLine()); - - parser.dispose(context, document); - - file.delete(); - } - - public void testLineEndings() throws Exception { - // Test for http://code.google.com/p/android/issues/detail?id=22925 - String xml = - "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" + - "<LinearLayout>\r\n" + - "\r" + - "<LinearLayout></LinearLayout>\r\n" + - "</LinearLayout>\r\n"; - LintCliXmlParser parser = new LintCliXmlParser(); - File file = File.createTempFile("parsertest2", ".xml"); - Writer fw = new BufferedWriter(new FileWriter(file)); - fw.write(xml); - fw.close(); - LintClient client = new TestClient(); - LintDriver driver = new LintDriver(new BuiltinIssueRegistry(), client); - Project project = Project.create(client, file.getParentFile(), file.getParentFile()); - XmlContext context = new XmlContext(driver, project, null, file, null); - Document document = parser.parseXml(context); - assertNotNull(document); - - file.delete(); - } - - private static class TestClient extends Main { - @Override - public void report( - @NonNull Context context, - @NonNull Issue issue, - @NonNull Severity severity, - @Nullable Location location, - @NonNull String message, - @Nullable Object data) { - System.out.println(location + ":" + message); - } - } -} 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 deleted file mode 100644 index 68a1ea3..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/MainTest.java +++ /dev/null @@ -1,382 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint; - -import com.android.tools.lint.checks.AbstractCheckTest; -import com.android.tools.lint.checks.AccessibilityDetector; -import com.android.tools.lint.detector.api.Detector; - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.PrintStream; -import java.security.Permission; -import java.util.List; - -@SuppressWarnings("javadoc") -public class MainTest extends AbstractCheckTest { - protected String checkLint(String[] args, List<File> files) throws Exception { - PrintStream previousOut = System.out; - try { - final ByteArrayOutputStream output = new ByteArrayOutputStream(); - System.setOut(new PrintStream(output)); - - Main.main(args); - - return output.toString(); - } finally { - System.setOut(previousOut); - } - } - - private void checkDriver(String expectedOutput, String expectedError, String[] args) - throws Exception { - PrintStream previousOut = System.out; - PrintStream previousErr = System.err; - try { - // Trap System.exit calls: - System.setSecurityManager(new SecurityManager() { - @Override - public void checkPermission(Permission perm) - { - // allow anything. - } - @Override - public void checkPermission(Permission perm, Object context) - { - // allow anything. - } - @Override - public void checkExit(int status) { - throw new ExitException(); - } - }); - - final ByteArrayOutputStream output = new ByteArrayOutputStream(); - System.setOut(new PrintStream(output)); - final ByteArrayOutputStream error = new ByteArrayOutputStream(); - System.setErr(new PrintStream(error)); - - try { - Main.main(args); - } catch (ExitException e) { - // Allow - } - - assertEquals(expectedError, cleanup(error.toString())); - assertEquals(expectedOutput, cleanup(output.toString())); - } finally { - // Re-enable system exit for unit test - System.setSecurityManager(null); - - System.setOut(previousOut); - System.setErr(previousErr); - } - } - - public void testArguments() throws Exception { - checkDriver( - // Expected output - "\n" + - "Scanning MainTest_testArguments: .\n" + - "res/layout/accessibility.xml:4: Warning: [Accessibility] Missing contentDescription attribute on image [ContentDescription]\n" + - " <ImageView android:id=\"@+id/android_logo\" android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:src=\"@drawable/android_button\" android:focusable=\"false\" android:clickable=\"false\" android:layout_weight=\"1.0\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/accessibility.xml:5: Warning: [Accessibility] Missing contentDescription attribute on image [ContentDescription]\n" + - " <ImageButton android:importantForAccessibility=\"yes\" android:id=\"@+id/android_logo2\" android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:src=\"@drawable/android_button\" android:focusable=\"false\" android:clickable=\"false\" android:layout_weight=\"1.0\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "0 errors, 2 warnings\n", - - // Expected error - "", - - // Args - new String[] { - "--check", - "ContentDescription", - "--disable", - "LintError", - getProjectDir(null, "res/layout/accessibility.xml").getPath() - - }); - } - - public void testShowDescription() throws Exception { - checkDriver( - // Expected output - "NewApi\n" + - "------\n" + - "Summary: Finds API accesses to APIs that are not supported in all targeted API\n" + - "versions\n" + - "\n" + - "Priority: 6 / 10\n" + - "Severity: Error\n" + - "Category: Correctness\n" + - "\n" + - "This check scans through all the Android API calls in the application and\n" + - "warns about any calls that are not available on all versions targeted by this\n" + - "application (according to its minimum SDK attribute in the manifest).\n" + - "\n" + - "If you really want to use this API and don't need to support older devices\n" + - "just set the minSdkVersion in your AndroidManifest.xml file.\n" + - "If your code is deliberately accessing newer APIs, and you have ensured (e.g.\n" + - "with conditional execution) that this code will only ever be called on a\n" + - "supported platform, then you can annotate your class or method with the\n" + - "@TargetApi annotation specifying the local minimum SDK to apply, such as\n" + - "@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" + - "\n", - - // Expected error - "", - - // Args - new String[] { - "--show", - "NewApi" - }); - } - - public void testNonexistentLibrary() throws Exception { - checkDriver( - "", - "Library foo.jar does not exist.\n", - - // Args - new String[] { - "--libraries", - "foo.jar", - "prj" - - }); - } - - public void testMultipleProjects() throws Exception { - File project = getProjectDir(null, "bytecode/classes.jar=>libs/classes.jar"); - checkDriver( - "", - "The --sources, --classpath, --libraries and --resources arguments can only be used with a single project\n", - - // Args - new String[] { - "--libraries", - new File(project, "libs/classes.jar").getPath(), - "--disable", - "LintError", - project.getPath(), - project.getPath() - - }); - } - - public void testCustomResourceDirs() throws Exception { - File project = getProjectDir(null, - "res/layout/accessibility.xml=>myres1/layout/accessibility1.xml", - "res/layout/accessibility.xml=>myres2/layout/accessibility1.xml" - ); - - checkDriver( - "\n" - + "Scanning MainTest_testCustomResourceDirs: ..\n" - + "myres1/layout/accessibility1.xml:4: Warning: [Accessibility] Missing contentDescription attribute on image [ContentDescription]\n" - + " <ImageView android:id=\"@+id/android_logo\" android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:src=\"@drawable/android_button\" android:focusable=\"false\" android:clickable=\"false\" android:layout_weight=\"1.0\" />\n" - + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" - + "myres2/layout/accessibility1.xml:4: Warning: [Accessibility] Missing contentDescription attribute on image [ContentDescription]\n" - + " <ImageView android:id=\"@+id/android_logo\" android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:src=\"@drawable/android_button\" android:focusable=\"false\" android:clickable=\"false\" android:layout_weight=\"1.0\" />\n" - + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" - + "myres1/layout/accessibility1.xml:5: Warning: [Accessibility] Missing contentDescription attribute on image [ContentDescription]\n" - + " <ImageButton android:importantForAccessibility=\"yes\" android:id=\"@+id/android_logo2\" android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:src=\"@drawable/android_button\" android:focusable=\"false\" android:clickable=\"false\" android:layout_weight=\"1.0\" />\n" - + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" - + "myres2/layout/accessibility1.xml:5: Warning: [Accessibility] Missing contentDescription attribute on image [ContentDescription]\n" - + " <ImageButton android:importantForAccessibility=\"yes\" android:id=\"@+id/android_logo2\" android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:src=\"@drawable/android_button\" android:focusable=\"false\" android:clickable=\"false\" android:layout_weight=\"1.0\" />\n" - + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" - + "0 errors, 4 warnings\n", // Expected output - "", - - // Args - new String[] { - "--check", - "ContentDescription", - "--disable", - "LintError", - "--resources", - new File(project, "myres1").getPath(), - "--resources", - new File(project, "myres2").getPath(), - project.getPath(), - }); - } - - public void testPathList() throws Exception { - File project = getProjectDir(null, - "res/layout/accessibility.xml=>myres1/layout/accessibility1.xml", - "res/layout/accessibility.xml=>myres2/layout/accessibility1.xml" - ); - - checkDriver( - "\n" - + "Scanning MainTest_testPathList: ..\n" - + "myres1/layout/accessibility1.xml:4: Warning: [Accessibility] Missing contentDescription attribute on image [ContentDescription]\n" - + " <ImageView android:id=\"@+id/android_logo\" android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:src=\"@drawable/android_button\" android:focusable=\"false\" android:clickable=\"false\" android:layout_weight=\"1.0\" />\n" - + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" - + "myres2/layout/accessibility1.xml:4: Warning: [Accessibility] Missing contentDescription attribute on image [ContentDescription]\n" - + " <ImageView android:id=\"@+id/android_logo\" android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:src=\"@drawable/android_button\" android:focusable=\"false\" android:clickable=\"false\" android:layout_weight=\"1.0\" />\n" - + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" - + "myres1/layout/accessibility1.xml:5: Warning: [Accessibility] Missing contentDescription attribute on image [ContentDescription]\n" - + " <ImageButton android:importantForAccessibility=\"yes\" android:id=\"@+id/android_logo2\" android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:src=\"@drawable/android_button\" android:focusable=\"false\" android:clickable=\"false\" android:layout_weight=\"1.0\" />\n" - + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" - + "myres2/layout/accessibility1.xml:5: Warning: [Accessibility] Missing contentDescription attribute on image [ContentDescription]\n" - + " <ImageButton android:importantForAccessibility=\"yes\" android:id=\"@+id/android_logo2\" android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:src=\"@drawable/android_button\" android:focusable=\"false\" android:clickable=\"false\" android:layout_weight=\"1.0\" />\n" - + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" - + "0 errors, 4 warnings\n", // Expected output - "", - - // Args - new String[] { - "--check", - "ContentDescription", - "--disable", - "LintError", - "--resources", - // Combine two paths with a single separator here - new File(project, "myres1").getPath() - + ':' + new File(project, "myres2").getPath(), - project.getPath(), - }); - } - - public void testClassPath() throws Exception { - File project = getProjectDir(null, - "apicheck/minsdk1.xml=>AndroidManifest.xml", - "bytecode/GetterTest.java.txt=>src/test/bytecode/GetterTest.java", - "bytecode/GetterTest.jar.data=>bin/classes.jar" - ); - checkDriver( - "\n" + - "Scanning MainTest_testClassPath: \n" + - "src/test/bytecode/GetterTest.java:47: Warning: Calling getter method getFoo1() on self is slower than field access (mFoo1) [FieldGetter]\n" + - " getFoo1();\n" + - " ~~~~~~~\n" + - "src/test/bytecode/GetterTest.java:48: Warning: Calling getter method getFoo2() on self is slower than field access (mFoo2) [FieldGetter]\n" + - " getFoo2();\n" + - " ~~~~~~~\n" + - "src/test/bytecode/GetterTest.java:52: Warning: Calling getter method isBar1() on self is slower than field access (mBar1) [FieldGetter]\n" + - " isBar1();\n" + - " ~~~~~~\n" + - "src/test/bytecode/GetterTest.java:54: Warning: Calling getter method getFoo1() on self is slower than field access (mFoo1) [FieldGetter]\n" + - " this.getFoo1();\n" + - " ~~~~~~~\n" + - "src/test/bytecode/GetterTest.java:55: Warning: Calling getter method getFoo2() on self is slower than field access (mFoo2) [FieldGetter]\n" + - " this.getFoo2();\n" + - " ~~~~~~~\n" + - "0 errors, 5 warnings\n", - "", - - // Args - new String[] { - "--check", - "FieldGetter", - "--classpath", - new File(project, "bin/classes.jar").getPath(), - "--disable", - "LintError", - project.getPath() - }); - } - - public void testLibraries() throws Exception { - File project = getProjectDir(null, - "apicheck/minsdk1.xml=>AndroidManifest.xml", - "bytecode/GetterTest.java.txt=>src/test/bytecode/GetterTest.java", - "bytecode/GetterTest.jar.data=>bin/classes.jar" - ); - checkDriver( - "\n" + - "Scanning MainTest_testLibraries: \n" + - "\n" + - "No issues found.\n", - "", - - // Args - new String[] { - "--check", - "FieldGetter", - "--libraries", - new File(project, "bin/classes.jar").getPath(), - "--disable", - "LintError", - project.getPath() - }); - } - - @Override - protected Detector getDetector() { - // Sample issue to check by the main driver - return new AccessibilityDetector(); - } - - private static class ExitException extends SecurityException { - private static final long serialVersionUID = 1L; - - private ExitException() { - super("Unit test"); - } - } - - public void test_getCleanPath() throws Exception { - assertEquals("foo", Main.getCleanPath(new File("foo"))); - String sep = File.separator; - assertEquals("foo" + sep + "bar", - Main.getCleanPath(new File("foo" + sep + "bar"))); - assertEquals(sep, - Main.getCleanPath(new File(sep))); - assertEquals("foo" + sep + "bar", - Main.getCleanPath(new File("foo" + sep + "." + sep + "bar"))); - assertEquals("bar", - Main.getCleanPath(new File("foo" + sep + ".." + sep + "bar"))); - assertEquals("", - Main.getCleanPath(new File("foo" + sep + ".."))); - assertEquals("foo", - Main.getCleanPath(new File("foo" + sep + "bar" + sep + ".."))); - assertEquals("foo" + sep + ".foo" + sep + "bar", - Main.getCleanPath(new File("foo" + sep + ".foo" + sep + "bar"))); - assertEquals("foo" + sep + "bar", - Main.getCleanPath(new File("foo" + sep + "bar" + sep + "."))); - assertEquals("foo" + sep + "...", - Main.getCleanPath(new File("foo" + sep + "..."))); - assertEquals(".." + sep + "foo", - Main.getCleanPath(new File(".." + sep + "foo"))); - assertEquals(sep + "foo", - Main.getCleanPath(new File(sep + "foo"))); - assertEquals(sep, - Main.getCleanPath(new File(sep + "foo" + sep + ".."))); - assertEquals(sep + "foo", - Main.getCleanPath(new File(sep + "foo" + sep + "bar " + sep + ".."))); - assertEquals(sep + "c:", - Main.getCleanPath(new File(sep + "c:"))); - assertEquals(sep + "c:" + sep + "foo", - Main.getCleanPath(new File(sep + "c:" + sep + "foo"))); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/XmlReporterTest.java b/lint/cli/src/test/java/com/android/tools/lint/XmlReporterTest.java deleted file mode 100644 index 9ada70f..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/XmlReporterTest.java +++ /dev/null @@ -1,244 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint; - -import com.android.tools.lint.checks.AbstractCheckTest; -import com.android.tools.lint.checks.HardcodedValuesDetector; -import com.android.tools.lint.checks.ManifestOrderDetector; -import com.android.tools.lint.detector.api.DefaultPosition; -import com.android.tools.lint.detector.api.Detector; -import com.android.tools.lint.detector.api.Location; -import com.android.tools.lint.detector.api.Project; -import com.android.tools.lint.detector.api.Severity; -import com.android.utils.PositionXmlParser; -import com.google.common.base.Charsets; -import com.google.common.io.Files; - -import org.w3c.dom.Document; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -@SuppressWarnings("javadoc") -public class XmlReporterTest extends AbstractCheckTest { - public void test() throws Exception { - File file = new File(getTargetDir(), "report"); - try { - Main client = new Main() { - @Override - String getRevision() { - return "unittest"; // Hardcode version to keep unit test output stable - } - }; - file.getParentFile().mkdirs(); - XmlReporter reporter = new XmlReporter(client, file); - Project project = Project.create(client, new File("/foo/bar/Foo"), - new File("/foo/bar/Foo")); - - Warning warning1 = new Warning(ManifestOrderDetector.USES_SDK, - "<uses-sdk> tag should specify a target API level (the highest verified " + - "version; when running on later versions, compatibility behaviors may " + - "be enabled) with android:targetSdkVersion=\"?\"", - Severity.WARNING, project, null); - warning1.line = 6; - warning1.file = new File("/foo/bar/Foo/AndroidManifest.xml"); - warning1.errorLine = " <uses-sdk android:minSdkVersion=\"8\" />\n ^\n"; - warning1.path = "AndroidManifest.xml"; - warning1.location = Location.create(warning1.file, - new DefaultPosition(6, 4, 198), new DefaultPosition(6, 42, 236)); - - Warning warning2 = new Warning(HardcodedValuesDetector.ISSUE, - "[I18N] Hardcoded string \"Fooo\", should use @string resource", - Severity.WARNING, project, null); - warning2.line = 11; - warning2.file = new File("/foo/bar/Foo/res/layout/main.xml"); - warning2.errorLine = " (java.lang.String) android:text=\"Fooo\" />\n" + - " ~~~~~~~~~~~~~~~~~~~\n"; - warning2.path = "res/layout/main.xml"; - warning2.location = Location.create(warning2.file, - new DefaultPosition(11, 8, 377), new DefaultPosition(11, 27, 396)); - - List<Warning> warnings = new ArrayList<Warning>(); - warnings.add(warning1); - warnings.add(warning2); - - reporter.write(0, 2, warnings); - - String report = Files.toString(file, Charsets.UTF_8); - assertEquals( - "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + - "<issues format=\"3\" by=\"lint unittest\">\n" + - "\n" + - " <issue\n" + - " id=\"UsesMinSdkAttributes\"\n" + - " severity=\"Warning\"\n" + - " message=\"<uses-sdk> tag should specify a target API level (the highest verified version; when running on later versions, compatibility behaviors may be enabled) with android:targetSdkVersion="?"\"\n" + - " category=\"Correctness\"\n" + - " priority=\"9\"\n" + - " summary=\"Checks that the minimum SDK and target SDK attributes are defined\"\n" + - " explanation=\"The manifest should contain a `<uses-sdk>` element which defines the minimum API Level required for the application to run, as well as the target version (the highest API level you have tested the version for.)\"\n" + - " url=\"http://developer.android.com/guide/topics/manifest/uses-sdk-element.html\"\n" + - " errorLine1=\" <uses-sdk android:minSdkVersion="8" />\"\n" + - " errorLine2=\" ^\">\n" + - " <location\n" + - " file=\"AndroidManifest.xml\"\n" + - " line=\"7\"\n" + - " column=\"5\"/>\n" + - " </issue>\n" + - "\n" + - " <issue\n" + - " id=\"HardcodedText\"\n" + - " severity=\"Warning\"\n" + - " message=\"[I18N] Hardcoded string "Fooo", should use @string resource\"\n" + - " category=\"Internationalization\"\n" + - " priority=\"5\"\n" + - " summary=\"Looks for hardcoded text attributes which should be converted to resource lookup\"\n" + - " explanation=\"Hardcoding text attributes directly in layout files is bad for several reasons:\n" + - "\n" + - "* When creating configuration variations (for example for landscape or portrait)you have to repeat the actual text (and keep it up to date when making changes)\n" + - "\n" + - "* The application cannot be translated to other languages by just adding new translations for existing string resources.\n" + - "\n" + - "In Eclipse there is a quickfix to automatically extract this hardcoded string into a resource lookup.\"\n" + - " errorLine1=\" (java.lang.String) android:text="Fooo" />\"\n" + - " errorLine2=\" ~~~~~~~~~~~~~~~~~~~\">\n" + - " <location\n" + - " file=\"res/layout/main.xml\"\n" + - " line=\"12\"\n" + - " column=\"9\"/>\n" + - " </issue>\n" + - "\n" + - "</issues>\n", - report); - - // Make sure the XML is valid - Document document = new PositionXmlParser().parse(report); - assertNotNull(document); - assertEquals(2, document.getElementsByTagName("issue").getLength()); - } finally { - file.delete(); - } - } - - public void testFullPaths() throws Exception { - File file = new File(getTargetDir(), "report"); - try { - Main client = new Main() { - @Override - String getRevision() { - return "unittest"; // Hardcode version to keep unit test output stable - } - }; - client.mFullPath = true; - - file.getParentFile().mkdirs(); - XmlReporter reporter = new XmlReporter(client, file); - Project project = Project.create(client, new File("/foo/bar/Foo"), - new File("/foo/bar/Foo")); - - Warning warning1 = new Warning(ManifestOrderDetector.USES_SDK, - "<uses-sdk> tag should specify a target API level (the highest verified " + - "version; when running on later versions, compatibility behaviors may " + - "be enabled) with android:targetSdkVersion=\"?\"", - Severity.WARNING, project, null); - warning1.line = 6; - warning1.file = new File("/foo/bar/../Foo/AndroidManifest.xml"); - warning1.errorLine = " <uses-sdk android:minSdkVersion=\"8\" />\n ^\n"; - warning1.path = "AndroidManifest.xml"; - warning1.location = Location.create(warning1.file, - new DefaultPosition(6, 4, 198), new DefaultPosition(6, 42, 236)); - - Warning warning2 = new Warning(HardcodedValuesDetector.ISSUE, - "[I18N] Hardcoded string \"Fooo\", should use @string resource", - Severity.WARNING, project, null); - warning2.line = 11; - warning2.file = new File("/foo/bar/Foo/res/layout/main.xml"); - warning2.errorLine = " (java.lang.String) android:text=\"Fooo\" />\n" + - " ~~~~~~~~~~~~~~~~~~~\n"; - warning2.path = "res/layout/main.xml"; - warning2.location = Location.create(warning2.file, - new DefaultPosition(11, 8, 377), new DefaultPosition(11, 27, 396)); - - List<Warning> warnings = new ArrayList<Warning>(); - warnings.add(warning1); - warnings.add(warning2); - - reporter.write(0, 2, warnings); - - String report = Files.toString(file, Charsets.UTF_8); - assertEquals( - "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + - "<issues format=\"3\" by=\"lint unittest\">\n" + - "\n" + - " <issue\n" + - " id=\"UsesMinSdkAttributes\"\n" + - " severity=\"Warning\"\n" + - " message=\"<uses-sdk> tag should specify a target API level (the highest verified version; when running on later versions, compatibility behaviors may be enabled) with android:targetSdkVersion="?"\"\n" + - " category=\"Correctness\"\n" + - " priority=\"9\"\n" + - " summary=\"Checks that the minimum SDK and target SDK attributes are defined\"\n" + - " explanation=\"The manifest should contain a `<uses-sdk>` element which defines the minimum API Level required for the application to run, as well as the target version (the highest API level you have tested the version for.)\"\n" + - " url=\"http://developer.android.com/guide/topics/manifest/uses-sdk-element.html\"\n" + - " errorLine1=\" <uses-sdk android:minSdkVersion="8" />\"\n" + - " errorLine2=\" ^\">\n" + - " <location\n" + - " file=\"/foo/Foo/AndroidManifest.xml\"\n" + - " line=\"7\"\n" + - " column=\"5\"/>\n" + - " </issue>\n" + - "\n" + - " <issue\n" + - " id=\"HardcodedText\"\n" + - " severity=\"Warning\"\n" + - " message=\"[I18N] Hardcoded string "Fooo", should use @string resource\"\n" + - " category=\"Internationalization\"\n" + - " priority=\"5\"\n" + - " summary=\"Looks for hardcoded text attributes which should be converted to resource lookup\"\n" + - " explanation=\"Hardcoding text attributes directly in layout files is bad for several reasons:\n" + - "\n" + - "* When creating configuration variations (for example for landscape or portrait)you have to repeat the actual text (and keep it up to date when making changes)\n" + - "\n" + - "* The application cannot be translated to other languages by just adding new translations for existing string resources.\n" + - "\n" + - "In Eclipse there is a quickfix to automatically extract this hardcoded string into a resource lookup.\"\n" + - " errorLine1=\" (java.lang.String) android:text="Fooo" />\"\n" + - " errorLine2=\" ~~~~~~~~~~~~~~~~~~~\">\n" + - " <location\n" + - " file=\"/foo/bar/Foo/res/layout/main.xml\"\n" + - " line=\"12\"\n" + - " column=\"9\"/>\n" + - " </issue>\n" + - "\n" + - "</issues>\n", - report); - - // Make sure the XML is valid - Document document = new PositionXmlParser().parse(report); - assertNotNull(document); - assertEquals(2, document.getElementsByTagName("issue").getLength()); - } finally { - file.delete(); - } - } - - @Override - protected Detector getDetector() { - fail("Not used in this test"); - return null; - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/AbstractCheckTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/AbstractCheckTest.java deleted file mode 100644 index b73db8c..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/AbstractCheckTest.java +++ /dev/null @@ -1,452 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.annotations.NonNull; -import com.android.annotations.Nullable; -import com.android.testutils.SdkTestCase; -import com.android.tools.lint.LintCliXmlParser; -import com.android.tools.lint.LombokParser; -import com.android.tools.lint.Main; -import com.android.tools.lint.Reporter; -import com.android.tools.lint.TextReporter; -import com.android.tools.lint.client.api.Configuration; -import com.android.tools.lint.client.api.DefaultConfiguration; -import com.android.tools.lint.client.api.IDomParser; -import com.android.tools.lint.client.api.IJavaParser; -import com.android.tools.lint.client.api.IssueRegistry; -import com.android.tools.lint.client.api.LintClient; -import com.android.tools.lint.client.api.LintDriver; -import com.android.tools.lint.detector.api.Context; -import com.android.tools.lint.detector.api.Detector; -import com.android.tools.lint.detector.api.Issue; -import com.android.tools.lint.detector.api.Location; -import com.android.tools.lint.detector.api.Project; -import com.android.tools.lint.detector.api.Scope; -import com.android.tools.lint.detector.api.Severity; - -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.InputStream; -import java.io.StringWriter; -import java.net.URISyntaxException; -import java.net.URL; -import java.security.CodeSource; -import java.util.ArrayList; -import java.util.Collections; -import java.util.EnumSet; -import java.util.List; - -/** Common utility methods for the various lint check tests */ -@SuppressWarnings("javadoc") -public abstract class AbstractCheckTest extends SdkTestCase { - @Override - protected void setUp() throws Exception { - super.setUp(); - BuiltinIssueRegistry.reset(); - } - - protected abstract Detector getDetector(); - - private Detector mDetector; - - private Detector getDetectorInstance() { - if (mDetector == null) { - mDetector = getDetector(); - } - - return mDetector; - } - - protected List<Issue> getIssues() { - List<Issue> issues = new ArrayList<Issue>(); - Class<? extends Detector> detectorClass = getDetectorInstance().getClass(); - // Get the list of issues from the registry and filter out others, to make sure - // issues are properly registered - List<Issue> candidates = new BuiltinIssueRegistry().getIssues(); - for (Issue issue : candidates) { - if (issue.getDetectorClass() == detectorClass) { - issues.add(issue); - } - } - - return issues; - } - - private class CustomIssueRegistry extends IssueRegistry { - @Override - public List<Issue> getIssues() { - return AbstractCheckTest.this.getIssues(); - } - } - - protected String lintFiles(String... relativePaths) throws Exception { - List<File> files = new ArrayList<File>(); - File targetDir = getTargetDir(); - for (String relativePath : relativePaths) { - File file = getTestfile(targetDir, relativePath); - assertNotNull(file); - files.add(file); - } - - addManifestFile(targetDir); - - return checkLint(files); - } - - protected String checkLint(List<File> files) throws Exception { - mOutput = new StringBuilder(); - TestLintClient lintClient = createClient(); - String result = lintClient.analyze(files); - - // The output typically contains a few directory/filenames. - // On Windows we need to change the separators to the unix-style - // forward slash to make the test as OS-agnostic as possible. - if (File.separatorChar != '/') { - result = result.replace(File.separatorChar, '/'); - } - - for (File f : files) { - deleteFile(f); - } - - return result; - } - - protected TestLintClient createClient() { - return new TestLintClient(); - } - - protected TestConfiguration getConfiguration(LintClient client, Project project) { - return new TestConfiguration(client, project, null); - } - - protected void configureDriver(LintDriver driver) { - } - - /** - * Run lint on the given files when constructed as a separate project - * @return The output of the lint check. On Windows, this transforms all directory - * separators to the unix-style forward slash. - */ - protected String lintProject(String... relativePaths) throws Exception { - File projectDir = getProjectDir(null, relativePaths); - return checkLint(Collections.singletonList(projectDir)); - } - - @Override - protected File getTargetDir() { - File targetDir = new File(getTempDir(), getClass().getSimpleName() + "_" + getName()); - addCleanupDir(targetDir); - return targetDir; - } - - /** Creates a project directory structure from the given files */ - protected File getProjectDir(String name, String ...relativePaths) throws Exception { - assertFalse("getTargetDir must be overridden to make a unique directory", - getTargetDir().equals(getTempDir())); - - File projectDir = getTargetDir(); - if (name != null) { - projectDir = new File(projectDir, name); - } - if (!projectDir.exists()) { - assertTrue(projectDir.getPath(), projectDir.mkdirs()); - } - - List<File> files = new ArrayList<File>(); - for (String relativePath : relativePaths) { - File file = getTestfile(projectDir, relativePath); - assertNotNull(file); - files.add(file); - } - - addManifestFile(projectDir); - return projectDir; - } - - private void addManifestFile(File projectDir) throws IOException { - // Ensure that there is at least a manifest file there to make it a valid project - // as far as Lint is concerned: - if (!new File(projectDir, "AndroidManifest.xml").exists()) { - File manifest = new File(projectDir, "AndroidManifest.xml"); - FileWriter fw = new FileWriter(manifest); - fw.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + - "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" + - " package=\"foo.bar2\"\n" + - " android:versionCode=\"1\"\n" + - " android:versionName=\"1.0\" >\n" + - "</manifest>\n"); - fw.close(); - } - } - - private StringBuilder mOutput = null; - - @Override - protected InputStream getTestResource(String relativePath, boolean expectExists) { - String path = "data" + File.separator + relativePath; //$NON-NLS-1$ - InputStream stream = - AbstractCheckTest.class.getResourceAsStream(path); - if (!expectExists && stream == null) { - return null; - } - return stream; - } - - protected boolean isEnabled(Issue issue) { - Class<? extends Detector> detectorClass = getDetectorInstance().getClass(); - if (issue.getDetectorClass() == detectorClass) { - return true; - } - - if (issue == IssueRegistry.LINT_ERROR || issue == IssueRegistry.PARSER_ERROR) { - return !ignoreSystemErrors(); - } - - return false; - } - - protected boolean includeParentPath() { - return false; - } - - protected EnumSet<Scope> getLintScope(List<File> file) { - return null; - } - - public String getSuperClass(Project project, String name) { - return null; - } - - protected boolean ignoreSystemErrors() { - return true; - } - - public class TestLintClient extends Main { - private StringWriter mWriter = new StringWriter(); - - public TestLintClient() { - mReporters.add(new TextReporter(this, mWriter, false)); - } - - @Override - public String getSuperClass(Project project, String name) { - String superClass = AbstractCheckTest.this.getSuperClass(project, name); - if (superClass != null) { - return superClass; - } - - return super.getSuperClass(project, name); - } - - public String analyze(List<File> files) throws Exception { - mDriver = new LintDriver(new CustomIssueRegistry(), this); - configureDriver(mDriver); - mDriver.analyze(files, getLintScope(files)); - - Collections.sort(mWarnings); - - for (Reporter reporter : mReporters) { - reporter.write(mErrorCount, mWarningCount, mWarnings); - } - - mOutput.append(mWriter.toString()); - - if (mOutput.length() == 0) { - mOutput.append("No warnings."); - } - - String result = mOutput.toString(); - if (result.equals("\nNo issues found.\n")) { - result = "No warnings."; - } - - result = cleanup(result); - - return result; - } - - public String getErrors() throws Exception { - return mWriter.toString(); - } - - @Override - public void report( - @NonNull Context context, - @NonNull Issue issue, - @NonNull Severity severity, - @Nullable Location location, - @NonNull String message, - @Nullable Object data) { - if (ignoreSystemErrors() && (issue == IssueRegistry.LINT_ERROR)) { - return; - } - - if (severity == Severity.FATAL) { - // Treat fatal errors like errors in the golden files. - severity = Severity.ERROR; - } - - // For messages into all secondary locations to ensure they get - // specifically included in the text report - if (location != null && location.getSecondary() != null) { - Location l = location.getSecondary(); - while (l != null) { - if (l.getMessage() == null) { - l.setMessage("<No location-specific message"); - } - l = l.getSecondary(); - } - } - - super.report(context, issue, severity, location, message, data); - } - - @Override - public void log(Throwable exception, String format, Object... args) { - if (exception != null) { - exception.printStackTrace(); - } - StringBuilder sb = new StringBuilder(); - if (format != null) { - sb.append(String.format(format, args)); - } - if (exception != null) { - sb.append(exception.toString()); - } - System.err.println(sb); - - if (exception != null) { - fail(exception.toString()); - } - } - - @Override - public IDomParser getDomParser() { - return new LintCliXmlParser(); - } - - @Override - public IJavaParser getJavaParser() { - return new LombokParser(); - } - - @Override - public Configuration getConfiguration(@NonNull Project project) { - return AbstractCheckTest.this.getConfiguration(this, project); - } - - @Override - public File findResource(String relativePath) { - if (relativePath.equals("platform-tools/api/api-versions.xml")) { - File rootDir = getRootDir(); - if (rootDir != null) { - File file = new File(rootDir, "development" + File.separator + "sdk" - + File.separator + "api-versions.xml"); - return file; - } - } else if (relativePath.startsWith("tools/support/")) { - String base = relativePath.substring("tools/support/".length()); - File rootDir = getRootDir(); - if (rootDir != null) { - File file = new File(rootDir, "sdk" + File.separator + "files" - + File.separator + "typos" - + File.separator + base); - return file; - } - } else { - fail("Unit tests don't support arbitrary resource lookup yet."); - } - - return super.findResource(relativePath); - } - } - - /** - * Returns the Android source tree root dir. - * @return the root dir or null if it couldn't be computed. - */ - private File getRootDir() { - CodeSource source = getClass().getProtectionDomain().getCodeSource(); - if (source != null) { - URL location = source.getLocation(); - try { - File dir = new File(location.toURI()); - assertTrue(dir.getPath(), dir.exists()); - while (dir != null) { - File settingsGradle = new File(dir, "settings.gradle"); //$NON-NLS-1$ - if (settingsGradle.exists()) { - return dir.getParentFile(); - } - dir = dir.getParentFile(); - } - - return null; - } catch (URISyntaxException e) { - fail(e.getLocalizedMessage()); - } - } - - return null; - } - - public class TestConfiguration extends DefaultConfiguration { - protected TestConfiguration( - @NonNull LintClient client, - @NonNull Project project, - @Nullable Configuration parent) { - super(client, project, parent); - } - - public TestConfiguration( - @NonNull LintClient client, - @Nullable Project project, - @Nullable Configuration parent, - @NonNull File configFile) { - super(client, project, parent, configFile); - } - - @Override - @NonNull - protected Severity getDefaultSeverity(@NonNull Issue issue) { - // In unit tests, include issues that are ignored by default - Severity severity = super.getDefaultSeverity(issue); - if (severity == Severity.IGNORE) { - return Severity.WARNING; - } - return severity; - } - - @Override - public boolean isEnabled(@NonNull Issue issue) { - return AbstractCheckTest.this.isEnabled(issue); - } - - @Override - public void ignore(@NonNull Context context, @NonNull Issue issue, - @Nullable Location location, @NonNull String message, @Nullable Object data) { - fail("Not supported in tests."); - } - - @Override - public void setSeverity(@NonNull Issue issue, @Nullable Severity severity) { - fail("Not supported in tests."); - } - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/AccessibilityDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/AccessibilityDetectorTest.java deleted file mode 100644 index fe24446..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/AccessibilityDetectorTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class AccessibilityDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new AccessibilityDetector(); - } - - public void testAccessibility() throws Exception { - assertEquals( - "res/layout/accessibility.xml:4: Warning: [Accessibility] Missing contentDescription attribute on image [ContentDescription]\n" + - " <ImageView android:id=\"@+id/android_logo\" android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:src=\"@drawable/android_button\" android:focusable=\"false\" android:clickable=\"false\" android:layout_weight=\"1.0\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/accessibility.xml:5: Warning: [Accessibility] Missing contentDescription attribute on image [ContentDescription]\n" + - " <ImageButton android:importantForAccessibility=\"yes\" android:id=\"@+id/android_logo2\" android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:src=\"@drawable/android_button\" android:focusable=\"false\" android:clickable=\"false\" android:layout_weight=\"1.0\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/accessibility.xml:9: Warning: Do not set both contentDescription and hint: the contentDescription will mask the hint [ContentDescription]\n" + - " <EditText android:hint=\"@string/label\" android:id=\"@+android:id/summary\" android:contentDescription=\"@string/label\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "0 errors, 3 warnings\n", - - lintProject("res/layout/accessibility2.xml=>res/layout/accessibility.xml")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/AlwaysShowActionDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/AlwaysShowActionDetectorTest.java deleted file mode 100644 index f7879bb..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/AlwaysShowActionDetectorTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class AlwaysShowActionDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new AlwaysShowActionDetector(); - } - - public void testXmlMenus() throws Exception { - assertEquals( - "res/menu-land/actions.xml:6: Warning: Prefer \"ifRoom\" instead of \"always\" [AlwaysShowAction]\n" + - " android:showAsAction=\"always|collapseActionView\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - " res/menu-land/actions.xml:13: <No location-specific message\n" + - " res/menu-land/actions.xml:18: <No location-specific message\n" + - " res/menu-land/actions.xml:54: <No location-specific message\n" + - "0 errors, 1 warnings\n" + - "", - - lintProject("res/menu-land/actions.xml")); - } - - public void testXmlMenusWithFlags() throws Exception { - assertEquals( - "res/menu-land/actions2.xml:6: Warning: Prefer \"ifRoom\" instead of \"always\" [AlwaysShowAction]\n" + - " android:showAsAction=\"always|collapseActionView\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - " res/menu-land/actions2.xml:13: <No location-specific message\n" + - " res/menu-land/actions2.xml:18: <No location-specific message\n" + - " res/menu-land/actions2.xml:54: <No location-specific message\n" + - "0 errors, 1 warnings\n" + - "", - - lintProject("res/menu-land/actions2.xml")); - } - - public void testJavaFail() throws Exception { - assertEquals( - "src/test/pkg/ActionTest1.java:7: Warning: Prefer \"SHOW_AS_ACTION_IF_ROOM\" instead of \"SHOW_AS_ACTION_ALWAYS\" [AlwaysShowAction]\n" + - " System.out.println(MenuItem.SHOW_AS_ACTION_ALWAYS);\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "0 errors, 1 warnings\n" + - "", - - // Only references to ALWAYS - lintProject("src/test/pkg/ActionTest1.java.txt=>src/test/pkg/ActionTest1.java")); - } - public void testJavaPass() throws Exception { - assertEquals( - "No warnings.", - - // Both references to ALWAYS and IF_ROOM - lintProject( - "src/test/pkg/ActionTest1.java.txt=>src/test/pkg/ActionTest1.java", - "src/test/pkg/ActionTest2.java.txt=>src/test/pkg/ActionTest2.java")); - } - - public void testSuppress() throws Exception { - assertEquals( - "No warnings.", - - lintProject( - "res/menu-land/actions2_ignore.xml", - "src/test/pkg/ActionTest1_ignore.java.txt=>src/test/pkg/ActionTest1.java")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/AnnotationDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/AnnotationDetectorTest.java deleted file mode 100644 index 7da1444..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/AnnotationDetectorTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; -import com.android.tools.lint.detector.api.Issue; - -import java.util.List; - -@SuppressWarnings("javadoc") -public class AnnotationDetectorTest extends AbstractCheckTest { - public void test() throws Exception { - assertEquals( - "src/test/pkg/WrongAnnotation.java:9: Error: The @SuppressLint annotation cannot be used on a local variable with the lint check 'NewApi': move out to the surrounding method [LocalSuppress]\n" + - " public static void foobar(View view, @SuppressLint(\"NewApi\") int foo) { // Invalid: class-file check\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~\n" + - "src/test/pkg/WrongAnnotation.java:10: Error: The @SuppressLint annotation cannot be used on a local variable with the lint check 'NewApi': move out to the surrounding method [LocalSuppress]\n" + - " @SuppressLint(\"NewApi\") // Invalid\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~\n" + - "src/test/pkg/WrongAnnotation.java:12: Error: The @SuppressLint annotation cannot be used on a local variable with the lint check 'NewApi': move out to the surrounding method [LocalSuppress]\n" + - " @SuppressLint({\"SdCardPath\", \"NewApi\"}) // Invalid: class-file based check on local variable\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "src/test/pkg/WrongAnnotation.java:14: Error: The @SuppressLint annotation cannot be used on a local variable with the lint check 'NewApi': move out to the surrounding method [LocalSuppress]\n" + - " @android.annotation.SuppressLint({\"SdCardPath\", \"NewApi\"}) // Invalid (FQN)\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "src/test/pkg/WrongAnnotation.java:28: Error: The @SuppressLint annotation cannot be used on a local variable with the lint check 'NewApi': move out to the surrounding method [LocalSuppress]\n" + - " @SuppressLint(\"NewApi\")\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~\n" + - "5 errors, 0 warnings\n", - - lintProject( - "src/test/pkg/WrongAnnotation.java.txt=>src/test/pkg/WrongAnnotation.java" - )); - } - - @Override - protected Detector getDetector() { - return new AnnotationDetector(); - } - - @Override - protected List<Issue> getIssues() { - List<Issue> issues = super.getIssues(); - - // Need these issues on to be found by the registry as well to look up scope - // in id references (these ids are referenced in the unit test java file below) - issues.add(ApiDetector.UNSUPPORTED); - issues.add(SdCardDetector.ISSUE); - - return issues; - } -} 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 deleted file mode 100644 index 947d27b..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/ApiDetectorTest.java +++ /dev/null @@ -1,900 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; -import com.android.tools.lint.detector.api.Project; - -@SuppressWarnings("javadoc") -public class ApiDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new ApiDetector(); - } - - public void testXmlApi1() throws Exception { - assertEquals( - "res/color/colors.xml:9: Error: @android:color/holo_red_light requires API level 14 (current min is 1) [NewApi]\n" + - " <item name=\"android:windowBackground\"> @android:color/holo_red_light </item>\n" + - " ^\n" + - "res/layout/layout.xml:9: Error: View requires API level 5 (current min is 1): <QuickContactBadge> [NewApi]\n" + - " <QuickContactBadge\n" + - " ^\n" + - "res/layout/layout.xml:15: Error: View requires API level 11 (current min is 1): <CalendarView> [NewApi]\n" + - " <CalendarView\n" + - " ^\n" + - "res/layout/layout.xml:21: Error: View requires API level 14 (current min is 1): <GridLayout> [NewApi]\n" + - " <GridLayout\n" + - " ^\n" + - "res/layout/layout.xml:22: Error: @android:attr/actionBarSplitStyle requires API level 14 (current min is 1) [NewApi]\n" + - " foo=\"@android:attr/actionBarSplitStyle\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/layout.xml:23: Error: @android:color/holo_red_light requires API level 14 (current min is 1) [NewApi]\n" + - " bar=\"@android:color/holo_red_light\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/values/themes.xml:9: Error: @android:color/holo_red_light requires API level 14 (current min is 1) [NewApi]\n" + - " <item name=\"android:windowBackground\"> @android:color/holo_red_light </item>\n" + - " ^\n" + - "7 errors, 0 warnings\n" + - "", - - lintProject( - "apicheck/minsdk1.xml=>AndroidManifest.xml", - "apicheck/layout.xml=>res/layout/layout.xml", - "apicheck/themes.xml=>res/values/themes.xml", - "apicheck/themes.xml=>res/color/colors.xml" - )); - } - - 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.", - - lintProject( - "apicheck/minsdk14.xml=>AndroidManifest.xml", - "apicheck/layout.xml=>res/layout/layout.xml", - "apicheck/themes.xml=>res/values/themes.xml", - "apicheck/themes.xml=>res/color/colors.xml" - )); - } - - public void testXmlApi1TargetApi() throws Exception { - assertEquals( - "No warnings.", - - lintProject( - "apicheck/minsdk1.xml=>AndroidManifest.xml", - "apicheck/layout_targetapi.xml=>res/layout/layout.xml" - )); - } - - public void testXmlApiFolderVersion11() throws Exception { - assertEquals( - "res/color-v11/colors.xml:9: Error: @android:color/holo_red_light requires API level 14 (current min is 1) [NewApi]\n" + - " <item name=\"android:windowBackground\"> @android:color/holo_red_light </item>\n" + - " ^\n" + - "res/layout-v11/layout.xml:21: Error: View requires API level 14 (current min is 1): <GridLayout> [NewApi]\n" + - " <GridLayout\n" + - " ^\n" + - "res/layout-v11/layout.xml:22: Error: @android:attr/actionBarSplitStyle requires API level 14 (current min is 1) [NewApi]\n" + - " foo=\"@android:attr/actionBarSplitStyle\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout-v11/layout.xml:23: Error: @android:color/holo_red_light requires API level 14 (current min is 1) [NewApi]\n" + - " bar=\"@android:color/holo_red_light\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/values-v11/themes.xml:9: Error: @android:color/holo_red_light requires API level 14 (current min is 1) [NewApi]\n" + - " <item name=\"android:windowBackground\"> @android:color/holo_red_light </item>\n" + - " ^\n" + - "5 errors, 0 warnings\n" + - "", - - lintProject( - "apicheck/minsdk1.xml=>AndroidManifest.xml", - "apicheck/layout.xml=>res/layout-v11/layout.xml", - "apicheck/themes.xml=>res/values-v11/themes.xml", - "apicheck/themes.xml=>res/color-v11/colors.xml" - )); - } - - public void testXmlApiFolderVersion14() throws Exception { - assertEquals( - "No warnings.", - - lintProject( - "apicheck/minsdk1.xml=>AndroidManifest.xml", - "apicheck/layout.xml=>res/layout-v14/layout.xml", - "apicheck/themes.xml=>res/values-v14/themes.xml", - "apicheck/themes.xml=>res/color-v14/colors.xml" - )); - } - - public void testApi1() throws Exception { - assertEquals( - "src/foo/bar/ApiCallTest.java:20: Error: Call requires API level 11 (current min is 1): android.app.Activity#getActionBar [NewApi]\n" + - " getActionBar(); // API 11\n" + - " ~~~~~~~~~~~~\n" + - "src/foo/bar/ApiCallTest.java:24: Error: Class requires API level 8 (current min is 1): org.w3c.dom.DOMErrorHandler [NewApi]\n" + - " Class<?> clz = DOMErrorHandler.class; // API 8\n" + - " ~~~~~~~~~~~~~~~\n" + - "src/foo/bar/ApiCallTest.java:27: Error: Call requires API level 3 (current min is 1): android.widget.Chronometer#getOnChronometerTickListener [NewApi]\n" + - " chronometer.getOnChronometerTickListener(); // API 3 \n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "src/foo/bar/ApiCallTest.java:30: Error: Call requires API level 11 (current min is 1): android.widget.Chronometer#setTextIsSelectable [NewApi]\n" + - " chronometer.setTextIsSelectable(true); // API 11\n" + - " ~~~~~~~~~~~~~~~~~~~\n" + - "src/foo/bar/ApiCallTest.java:33: Error: Field requires API level 11 (current min is 1): dalvik.bytecode.OpcodeInfo#MAXIMUM_VALUE [NewApi]\n" + - " int field = OpcodeInfo.MAXIMUM_VALUE; // API 11\n" + - " ~~~~~~~~~~~~~\n" + - "src/foo/bar/ApiCallTest.java:38: Error: Field requires API level 14 (current min is 1): android.app.ApplicationErrorReport#batteryInfo [NewApi]\n" + - " BatteryInfo batteryInfo = getReport().batteryInfo;\n" + - " ~~~~~~~~~~~\n" + - // Note: the above error range is wrong; should be pointing to the second - "src/foo/bar/ApiCallTest.java:41: Error: Field requires API level 11 (current min is 1): android.graphics.PorterDuff.Mode#OVERLAY [NewApi]\n" + - " Mode mode = PorterDuff.Mode.OVERLAY; // API 11\n" + - " ~~~~~~~\n" + - "7 errors, 0 warnings\n", - - lintProject( - "apicheck/classpath=>.classpath", - "apicheck/minsdk1.xml=>AndroidManifest.xml", - "apicheck/ApiCallTest.java.txt=>src/foo/bar/ApiCallTest.java", - "apicheck/ApiCallTest.class.data=>bin/classes/foo/bar/ApiCallTest.class" - )); - } - - public void testApi2() throws Exception { - assertEquals( - "src/foo/bar/ApiCallTest.java:20: Error: Call requires API level 11 (current min is 2): android.app.Activity#getActionBar [NewApi]\n" + - " getActionBar(); // API 11\n" + - " ~~~~~~~~~~~~\n" + - "src/foo/bar/ApiCallTest.java:24: Error: Class requires API level 8 (current min is 2): org.w3c.dom.DOMErrorHandler [NewApi]\n" + - " Class<?> clz = DOMErrorHandler.class; // API 8\n" + - " ~~~~~~~~~~~~~~~\n" + - "src/foo/bar/ApiCallTest.java:27: Error: Call requires API level 3 (current min is 2): android.widget.Chronometer#getOnChronometerTickListener [NewApi]\n" + - " chronometer.getOnChronometerTickListener(); // API 3 \n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "src/foo/bar/ApiCallTest.java:30: Error: Call requires API level 11 (current min is 2): android.widget.Chronometer#setTextIsSelectable [NewApi]\n" + - " chronometer.setTextIsSelectable(true); // API 11\n" + - " ~~~~~~~~~~~~~~~~~~~\n" + - "src/foo/bar/ApiCallTest.java:33: Error: Field requires API level 11 (current min is 2): dalvik.bytecode.OpcodeInfo#MAXIMUM_VALUE [NewApi]\n" + - " int field = OpcodeInfo.MAXIMUM_VALUE; // API 11\n" + - " ~~~~~~~~~~~~~\n" + - "src/foo/bar/ApiCallTest.java:38: Error: Field requires API level 14 (current min is 2): android.app.ApplicationErrorReport#batteryInfo [NewApi]\n" + - " BatteryInfo batteryInfo = getReport().batteryInfo;\n" + - " ~~~~~~~~~~~\n" + - "src/foo/bar/ApiCallTest.java:41: Error: Field requires API level 11 (current min is 2): android.graphics.PorterDuff.Mode#OVERLAY [NewApi]\n" + - " Mode mode = PorterDuff.Mode.OVERLAY; // API 11\n" + - " ~~~~~~~\n" + - "7 errors, 0 warnings\n", - - lintProject( - "apicheck/classpath=>.classpath", - "apicheck/minsdk2.xml=>AndroidManifest.xml", - "apicheck/ApiCallTest.java.txt=>src/foo/bar/ApiCallTest.java", - "apicheck/ApiCallTest.class.data=>bin/classes/foo/bar/ApiCallTest.class" - )); - } - - public void testApi4() throws Exception { - assertEquals( - "src/foo/bar/ApiCallTest.java:20: Error: Call requires API level 11 (current min is 4): android.app.Activity#getActionBar [NewApi]\n" + - " getActionBar(); // API 11\n" + - " ~~~~~~~~~~~~\n" + - "src/foo/bar/ApiCallTest.java:24: Error: Class requires API level 8 (current min is 4): org.w3c.dom.DOMErrorHandler [NewApi]\n" + - " Class<?> clz = DOMErrorHandler.class; // API 8\n" + - " ~~~~~~~~~~~~~~~\n" + - "src/foo/bar/ApiCallTest.java:30: Error: Call requires API level 11 (current min is 4): android.widget.Chronometer#setTextIsSelectable [NewApi]\n" + - " chronometer.setTextIsSelectable(true); // API 11\n" + - " ~~~~~~~~~~~~~~~~~~~\n" + - "src/foo/bar/ApiCallTest.java:33: Error: Field requires API level 11 (current min is 4): dalvik.bytecode.OpcodeInfo#MAXIMUM_VALUE [NewApi]\n" + - " int field = OpcodeInfo.MAXIMUM_VALUE; // API 11\n" + - " ~~~~~~~~~~~~~\n" + - "src/foo/bar/ApiCallTest.java:38: Error: Field requires API level 14 (current min is 4): android.app.ApplicationErrorReport#batteryInfo [NewApi]\n" + - " BatteryInfo batteryInfo = getReport().batteryInfo;\n" + - " ~~~~~~~~~~~\n" + - "src/foo/bar/ApiCallTest.java:41: Error: Field requires API level 11 (current min is 4): android.graphics.PorterDuff.Mode#OVERLAY [NewApi]\n" + - " Mode mode = PorterDuff.Mode.OVERLAY; // API 11\n" + - " ~~~~~~~\n" + - "6 errors, 0 warnings\n", - - lintProject( - "apicheck/classpath=>.classpath", - "apicheck/minsdk4.xml=>AndroidManifest.xml", - "apicheck/ApiCallTest.java.txt=>src/foo/bar/ApiCallTest.java", - "apicheck/ApiCallTest.class.data=>bin/classes/foo/bar/ApiCallTest.class" - )); - } - - public void testApi10() throws Exception { - assertEquals( - "src/foo/bar/ApiCallTest.java:20: Error: Call requires API level 11 (current min is 10): android.app.Activity#getActionBar [NewApi]\n" + - " getActionBar(); // API 11\n" + - " ~~~~~~~~~~~~\n" + - "src/foo/bar/ApiCallTest.java:30: Error: Call requires API level 11 (current min is 10): android.widget.Chronometer#setTextIsSelectable [NewApi]\n" + - " chronometer.setTextIsSelectable(true); // API 11\n" + - " ~~~~~~~~~~~~~~~~~~~\n" + - "src/foo/bar/ApiCallTest.java:33: Error: Field requires API level 11 (current min is 10): dalvik.bytecode.OpcodeInfo#MAXIMUM_VALUE [NewApi]\n" + - " int field = OpcodeInfo.MAXIMUM_VALUE; // API 11\n" + - " ~~~~~~~~~~~~~\n" + - "src/foo/bar/ApiCallTest.java:38: Error: Field requires API level 14 (current min is 10): android.app.ApplicationErrorReport#batteryInfo [NewApi]\n" + - " BatteryInfo batteryInfo = getReport().batteryInfo;\n" + - " ~~~~~~~~~~~\n" + - "src/foo/bar/ApiCallTest.java:41: Error: Field requires API level 11 (current min is 10): android.graphics.PorterDuff.Mode#OVERLAY [NewApi]\n" + - " Mode mode = PorterDuff.Mode.OVERLAY; // API 11\n" + - " ~~~~~~~\n" + - "5 errors, 0 warnings\n", - - lintProject( - "apicheck/classpath=>.classpath", - "apicheck/minsdk10.xml=>AndroidManifest.xml", - "apicheck/ApiCallTest.java.txt=>src/foo/bar/ApiCallTest.java", - "apicheck/ApiCallTest.class.data=>bin/classes/foo/bar/ApiCallTest.class" - )); - } - - public void testApi14() throws Exception { - assertEquals( - "No warnings.", - - lintProject( - "apicheck/classpath=>.classpath", - "apicheck/minsdk14.xml=>AndroidManifest.xml", - "apicheck/ApiCallTest.java.txt=>src/foo/bar/ApiCallTest.java", - "apicheck/ApiCallTest.class.data=>bin/classes/foo/bar/ApiCallTest.class" - )); - } - - public void testInheritStatic() throws Exception { - assertEquals( - "src/foo/bar/ApiCallTest5.java:16: Error: Call requires API level 11 (current min is 2): android.view.View#resolveSizeAndState [NewApi]\n" + - " int measuredWidth = View.resolveSizeAndState(widthMeasureSpec,\n" + - " ~~~~~~~~~~~~~~~~~~~\n" + - "src/foo/bar/ApiCallTest5.java:18: Error: Call requires API level 11 (current min is 2): android.view.View#resolveSizeAndState [NewApi]\n" + - " int measuredHeight = resolveSizeAndState(heightMeasureSpec,\n" + - " ~~~~~~~~~~~~~~~~~~~\n" + - "src/foo/bar/ApiCallTest5.java:20: Error: Call requires API level 11 (current min is 2): android.view.View#combineMeasuredStates [NewApi]\n" + - " View.combineMeasuredStates(0, 0);\n" + - " ~~~~~~~~~~~~~~~~~~~~~\n" + - "src/foo/bar/ApiCallTest5.java:21: Error: Call requires API level 11 (current min is 2): android.view.View#combineMeasuredStates [NewApi]\n" + - " ApiCallTest5.combineMeasuredStates(0, 0);\n" + - " ~~~~~~~~~~~~~~~~~~~~~\n" + - "4 errors, 0 warnings\n" + - "", - - lintProject( - "apicheck/classpath=>.classpath", - "apicheck/minsdk2.xml=>AndroidManifest.xml", - "apicheck/ApiCallTest5.java.txt=>src/foo/bar/ApiCallTest5.java", - "apicheck/ApiCallTest5.class.data=>bin/classes/foo/bar/ApiCallTest5.class" - )); - } - - public void testInheritLocal() throws Exception { - // Test virtual dispatch in a local class which extends some other local class (which - // in turn extends an Android API) - assertEquals( - "src/test/pkg/ApiCallTest3.java:10: Error: Call requires API level 11 (current min is 1): android.app.Activity#getActionBar [NewApi]\n" + - " getActionBar(); // API 11\n" + - " ~~~~~~~~~~~~\n" + - "1 errors, 0 warnings\n" + - "", - - lintProject( - "apicheck/classpath=>.classpath", - "apicheck/minsdk1.xml=>AndroidManifest.xml", - "apicheck/Intermediate.java.txt=>src/test/pkg/Intermediate.java", - "apicheck/ApiCallTest3.java.txt=>src/test/pkg/ApiCallTest3.java", - "apicheck/ApiCallTest3.class.data=>bin/classes/test/pkg/ApiCallTest3.class", - "apicheck/Intermediate.class.data=>bin/classes/test/pkg/Intermediate.class" - )); - } - - public void testViewClassLayoutReference() throws Exception { - assertEquals( - "res/layout/view.xml:9: Error: View requires API level 5 (current min is 1): <QuickContactBadge> [NewApi]\n" + - " <view\n" + - " ^\n" + - "res/layout/view.xml:16: Error: View requires API level 11 (current min is 1): <CalendarView> [NewApi]\n" + - " <view\n" + - " ^\n" + - "res/layout/view.xml:24: Error: ?android:attr/dividerHorizontal requires API level 11 (current min is 1) [NewApi]\n" + - " unknown=\"?android:attr/dividerHorizontal\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/view.xml:25: Error: ?android:attr/textColorLinkInverse requires API level 11 (current min is 1) [NewApi]\n" + - " android:textColor=\"?android:attr/textColorLinkInverse\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "4 errors, 0 warnings\n" + - "", - - lintProject( - "apicheck/minsdk1.xml=>AndroidManifest.xml", - "apicheck/view.xml=>res/layout/view.xml" - )); - } - - public void testIOException() throws Exception { - // See http://code.google.com/p/android/issues/detail?id=35190 - assertEquals( - "src/test/pkg/ApiCallTest6.java:8: Error: Call requires API level 9 (current min is 1): new java.io.IOException [NewApi]\n" + - " IOException ioException = new IOException(throwable);\n" + - " ~~~~~~~~~~~\n" + - "1 errors, 0 warnings\n", - - lintProject( - "apicheck/classpath=>.classpath", - "apicheck/minsdk1.xml=>AndroidManifest.xml", - "apicheck/Intermediate.java.txt=>src/test/pkg/Intermediate.java", - "apicheck/ApiCallTest6.java.txt=>src/test/pkg/ApiCallTest6.java", - "apicheck/ApiCallTest6.class.data=>bin/classes/test/pkg/ApiCallTest6.class" - )); - } - - - // Test suppressing errors -- on classes, methods etc. - - public void testSuppress() throws Exception { - assertEquals( - // These errors are correctly -not- suppressed because they - // appear in method3 (line 74-98) which is annotated with a - // @SuppressLint annotation specifying only an unrelated issue id - - "src/foo/bar/SuppressTest1.java:76: Error: Call requires API level 11 (current min is 1): android.app.Activity#getActionBar [NewApi]\n" + - " getActionBar(); // API 11\n" + - " ~~~~~~~~~~~~\n" + - "src/foo/bar/SuppressTest1.java:80: Error: Class requires API level 8 (current min is 1): org.w3c.dom.DOMErrorHandler [NewApi]\n" + - " Class<?> clz = DOMErrorHandler.class; // API 8\n" + - " ~~~~~~~~~~~~~~~\n" + - "src/foo/bar/SuppressTest1.java:83: Error: Call requires API level 3 (current min is 1): android.widget.Chronometer#getOnChronometerTickListener [NewApi]\n" + - " chronometer.getOnChronometerTickListener(); // API 3\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "src/foo/bar/SuppressTest1.java:86: Error: Call requires API level 11 (current min is 1): android.widget.Chronometer#setTextIsSelectable [NewApi]\n" + - " chronometer.setTextIsSelectable(true); // API 11\n" + - " ~~~~~~~~~~~~~~~~~~~\n" + - "src/foo/bar/SuppressTest1.java:89: Error: Field requires API level 11 (current min is 1): dalvik.bytecode.OpcodeInfo#MAXIMUM_VALUE [NewApi]\n" + - " int field = OpcodeInfo.MAXIMUM_VALUE; // API 11\n" + - " ~~~~~~~~~~~~~\n" + - "src/foo/bar/SuppressTest1.java:94: Error: Field requires API level 14 (current min is 1): android.app.ApplicationErrorReport#batteryInfo [NewApi]\n" + - " BatteryInfo batteryInfo = getReport().batteryInfo;\n" + - " ~~~~~~~~~~~\n" + - "src/foo/bar/SuppressTest1.java:97: Error: Field requires API level 11 (current min is 1): android.graphics.PorterDuff.Mode#OVERLAY [NewApi]\n" + - " Mode mode = PorterDuff.Mode.OVERLAY; // API 11\n" + - " ~~~~~~~\n" + - - // Note: These annotations are within the methods, not ON the methods, so they have - // no effect (because they don't end up in the bytecode) - - - "src/foo/bar/SuppressTest4.java:19: Error: Field requires API level 14 (current min is 1): android.app.ApplicationErrorReport#batteryInfo [NewApi]\n" + - " BatteryInfo batteryInfo = report.batteryInfo;\n" + - " ~~~~~~~~~~~\n" + - "8 errors, 0 warnings\n", - - lintProject( - "apicheck/classpath=>.classpath", - "apicheck/minsdk1.xml=>AndroidManifest.xml", - "apicheck/SuppressTest1.java.txt=>src/foo/bar/SuppressTest1.java", - "apicheck/SuppressTest1.class.data=>bin/classes/foo/bar/SuppressTest1.class", - "apicheck/SuppressTest2.java.txt=>src/foo/bar/SuppressTest2.java", - "apicheck/SuppressTest2.class.data=>bin/classes/foo/bar/SuppressTest2.class", - "apicheck/SuppressTest3.java.txt=>src/foo/bar/SuppressTest3.java", - "apicheck/SuppressTest3.class.data=>bin/classes/foo/bar/SuppressTest3.class", - "apicheck/SuppressTest4.java.txt=>src/foo/bar/SuppressTest4.java", - "apicheck/SuppressTest4.class.data=>bin/classes/foo/bar/SuppressTest4.class" - )); - } - - public void testSuppressInnerClasses() throws Exception { - assertEquals( - // These errors are correctly -not- suppressed because they - // appear outside the middle inner class suppressing its own errors - // and its child's errors - "src/test/pkg/ApiCallTest4.java:9: Error: Call requires API level 14 (current min is 1): new android.widget.GridLayout [NewApi]\n" + - " new GridLayout(null, null, 0);\n" + - " ~~~~~~~~~~\n" + - "src/test/pkg/ApiCallTest4.java:38: Error: Call requires API level 14 (current min is 1): new android.widget.GridLayout [NewApi]\n" + - " new GridLayout(null, null, 0);\n" + - " ~~~~~~~~~~\n" + - "2 errors, 0 warnings\n", - - lintProject( - "apicheck/classpath=>.classpath", - "apicheck/minsdk1.xml=>AndroidManifest.xml", - "apicheck/ApiCallTest4.java.txt=>src/test/pkg/ApiCallTest4.java", - "apicheck/ApiCallTest4.class.data=>bin/classes/test/pkg/ApiCallTest4.class", - "apicheck/ApiCallTest4$1.class.data=>bin/classes/test/pkg/ApiCallTest4$1.class", - "apicheck/ApiCallTest4$InnerClass1.class.data=>bin/classes/test/pkg/ApiCallTest4$InnerClass1.class", - "apicheck/ApiCallTest4$InnerClass2.class.data=>bin/classes/test/pkg/ApiCallTest4$InnerClass2.class", - "apicheck/ApiCallTest4$InnerClass1$InnerInnerClass1.class.data=>bin/classes/test/pkg/ApiCallTest4$InnerClass1$InnerInnerClass1.class" - )); - } - - public void testApiTargetAnnotation() throws Exception { - assertEquals( - "src/foo/bar/ApiTargetTest.java:13: Error: Class requires API level 8 (current min is 1): org.w3c.dom.DOMErrorHandler [NewApi]\n" + - " Class<?> clz = DOMErrorHandler.class; // API 8\n" + - " ~~~~~~~~~~~~~~~\n" + - "src/foo/bar/ApiTargetTest.java:25: Error: Class requires API level 8 (current min is 4): org.w3c.dom.DOMErrorHandler [NewApi]\n" + - " Class<?> clz = DOMErrorHandler.class; // API 8\n" + - " ~~~~~~~~~~~~~~~\n" + - "src/foo/bar/ApiTargetTest.java:39: Error: Class requires API level 8 (current min is 7): org.w3c.dom.DOMErrorHandler [NewApi]\n" + - " Class<?> clz = DOMErrorHandler.class; // API 8\n" + - " ~~~~~~~~~~~~~~~\n" + - "3 errors, 0 warnings\n" + - "", - - lintProject( - "apicheck/classpath=>.classpath", - "apicheck/minsdk1.xml=>AndroidManifest.xml", - "apicheck/ApiTargetTest.java.txt=>src/foo/bar/ApiTargetTest.java", - "apicheck/ApiTargetTest.class.data=>bin/classes/foo/bar/ApiTargetTest.class", - "apicheck/ApiTargetTest$LocalClass.class.data=>bin/classes/foo/bar/ApiTargetTest$LocalClass.class" - )); - } - - public void testTargetAnnotationInner() throws Exception { - assertEquals( - "src/test/pkg/ApiTargetTest2.java:32: Error: Call requires API level 14 (current min is 3): new android.widget.GridLayout [NewApi]\n" + - " new GridLayout(null, null, 0);\n" + - " ~~~~~~~~~~\n" + - "1 errors, 0 warnings\n", - - lintProject( - "apicheck/classpath=>.classpath", - "apicheck/minsdk1.xml=>AndroidManifest.xml", - "apicheck/ApiTargetTest2.java.txt=>src/test/pkg/ApiTargetTest2.java", - "apicheck/ApiTargetTest2.class.data=>bin/classes/test/pkg/ApiTargetTest2.class", - "apicheck/ApiTargetTest2$1.class.data=>bin/classes/test/pkg/ApiTargetTest2$1.class", - "apicheck/ApiTargetTest2$1$2.class.data=>bin/classes/test/pkg/ApiTargetTest2$1$2.class", - "apicheck/ApiTargetTest2$1$1.class.data=>bin/classes/test/pkg/ApiTargetTest2$1$1.class" - )); - } - - public void testSuper() throws Exception { - // See http://code.google.com/p/android/issues/detail?id=36384 - assertEquals( - "src/test/pkg/ApiCallTest7.java:8: Error: Call requires API level 9 (current min is 4): new java.io.IOException [NewApi]\n" + - " super(message, cause); // API 9\n" + - " ~~~~~\n" + - "src/test/pkg/ApiCallTest7.java:12: Error: Call requires API level 9 (current min is 4): new java.io.IOException [NewApi]\n" + - " super.toString(); throw new IOException((Throwable) null); // API 9\n" + - " ~~~~~~~~~~~\n" + - "2 errors, 0 warnings\n", - - lintProject( - "apicheck/classpath=>.classpath", - "apicheck/minsdk4.xml=>AndroidManifest.xml", - "apicheck/ApiCallTest7.java.txt=>src/test/pkg/ApiCallTest7.java", - "apicheck/ApiCallTest7.class.data=>bin/classes/test/pkg/ApiCallTest7.class" - )); - } - - public void testEnums() throws Exception { - // See http://code.google.com/p/android/issues/detail?id=36951 - assertEquals( - "src/test/pkg/TestEnum.java:26: Error: Enum value requires API level 11 (current min is 4): android.graphics.PorterDuff.Mode#OVERLAY [NewApi]\n" + - " case OVERLAY: {\n" + - " ~~~~~~~\n" + - "src/test/pkg/TestEnum.java:37: Error: Enum value requires API level 11 (current min is 4): android.graphics.PorterDuff.Mode#OVERLAY [NewApi]\n" + - " case OVERLAY: {\n" + - " ~~~~~~~\n" + - "src/test/pkg/TestEnum.java:61: Error: Enum for switch requires API level 11 (current min is 4): android.renderscript.Element.DataType [NewApi]\n" + - " switch (type) {\n" + - " ^\n" + - "3 errors, 0 warnings\n", - - lintProject( - "apicheck/classpath=>.classpath", - "apicheck/minsdk4.xml=>AndroidManifest.xml", - "apicheck/TestEnum.java.txt=>src/test/pkg/TestEnum.java", - "apicheck/TestEnum.class.data=>bin/classes/test/pkg/TestEnum.class" - )); - } - - @Override - public String getSuperClass(Project project, String name) { - // For testInterfaceInheritance - if (name.equals("android/database/sqlite/SQLiteStatement")) { - return "android/database/sqlite/SQLiteProgram"; - } else if (name.equals("android/database/sqlite/SQLiteProgram")) { - return "android/database/sqlite/SQLiteClosable"; - } else if (name.equals("android/database/sqlite/SQLiteClosable")) { - return "java/lang/Object"; - } - return null; - } - - public void testInterfaceInheritance() throws Exception { - // See http://code.google.com/p/android/issues/detail?id=38004 - assertEquals( - "No warnings.", - - lintProject( - "apicheck/classpath=>.classpath", - "apicheck/minsdk4.xml=>AndroidManifest.xml", - "apicheck/CloseTest.java.txt=>src/test/pkg/CloseTest.java", - "apicheck/CloseTest.class.data=>bin/classes/test/pkg/CloseTest.class" - )); - } - - public void testInnerClassPositions() throws Exception { - // See http://code.google.com/p/android/issues/detail?id=38113 - assertEquals( - "No warnings.", - - lintProject( - "apicheck/classpath=>.classpath", - "apicheck/minsdk4.xml=>AndroidManifest.xml", - "apicheck/ApiCallTest8.java.txt=>src/test/pkg/ApiCallTest8.java", - "apicheck/ApiCallTest8.class.data=>bin/classes/test/pkg/ApiCallTest8.class" - )); - } - - public void testManifestReferences() throws Exception { - assertEquals( - "AndroidManifest.xml:15: Error: @android:style/Theme.Holo requires API level 11 (current min is 4) [NewApi]\n" + - " android:theme=\"@android:style/Theme.Holo\" >\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "1 errors, 0 warnings\n", - - lintProject( - "apicheck/classpath=>.classpath", - "apicheck/holomanifest.xml=>AndroidManifest.xml" - )); - } - - public void testSuppressFieldAnnotations() throws Exception { - // See http://code.google.com/p/android/issues/detail?id=38626 - assertEquals( - "src/test/pkg/ApiCallTest9.java:9: Error: Call requires API level 14 (current min is 4): new android.widget.GridLayout [NewApi]\n" + - " private GridLayout field1 = new GridLayout(null);\n" + - " ~~~~~~~~~~\n" + - "src/test/pkg/ApiCallTest9.java:12: Error: Call requires API level 14 (current min is 4): new android.widget.GridLayout [NewApi]\n" + - " private static GridLayout field2 = new GridLayout(null);\n" + - " ~~~~~~~~~~\n" + - "2 errors, 0 warnings\n", - - lintProject( - "apicheck/classpath=>.classpath", - "apicheck/minsdk4.xml=>AndroidManifest.xml", - "apicheck/ApiCallTest9.java.txt=>src/test/pkg/ApiCallTest9.java", - "apicheck/ApiCallTest9.class.data=>bin/classes/test/pkg/ApiCallTest9.class" - )); - } - - public void test38195() throws Exception { - // See http://code.google.com/p/android/issues/detail?id=38195 - assertEquals( - "bin/classes/TestLint.class: Error: Call requires API level 16 (current min is 4): new android.database.SQLException [NewApi]\n" + - "bin/classes/TestLint.class: Error: Call requires API level 9 (current min is 4): java.lang.String#isEmpty [NewApi]\n" + - "bin/classes/TestLint.class: Error: Call requires API level 9 (current min is 4): new java.sql.SQLException [NewApi]\n" + - "3 errors, 0 warnings\n", - - lintProject( - "apicheck/classpath=>.classpath", - "apicheck/minsdk4.xml=>AndroidManifest.xml", - /* - Compiled from "TestLint.java" - public class test.pkg.TestLint extends java.lang.Object{ - public test.pkg.TestLint(); - Code: - 0: aload_0 - 1: invokespecial #8; //Method java/lang/Object."<init>":()V - 4: return - - public void test(java.lang.Exception) throws java.lang.Exception; - Code: - 0: ldc #19; //String - 2: invokevirtual #21; //Method java/lang/String.isEmpty:()Z - 5: istore_2 - 6: new #27; //class java/sql/SQLException - 9: dup - 10: ldc #29; //String error on upgrade: - 12: aload_1 - 13: invokespecial #31; //Method java/sql/SQLException."<init>": - (Ljava/lang/String;Ljava/lang/Throwable;)V - 16: athrow - - public void test2(java.lang.Exception) throws java.lang.Exception; - Code: - 0: new #39; //class android/database/SQLException - 3: dup - 4: ldc #29; //String error on upgrade: - 6: aload_1 - 7: invokespecial #41; //Method android/database/SQLException. - "<init>":(Ljava/lang/String;Ljava/lang/Throwable;)V - 10: athrow - } - */ - "apicheck/TestLint.class.data=>bin/classes/TestLint.class" - )); - } - - public void testAllowLocalMethodsImplementingInaccessible() throws Exception { - // See http://code.google.com/p/android/issues/detail?id=39030 - assertEquals( - "src/test/pkg/ApiCallTest10.java:25: Error: Call requires API level 14 (current min is 4): android.view.View#onPopulateAccessibilityEvent [NewApi]\n" + - " super.onPopulateAccessibilityEvent(event); // Valid lint warning\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "src/test/pkg/ApiCallTest10.java:31: Error: Call requires API level 14 (current min is 4): android.view.View#dispatchGenericFocusedEvent [NewApi]\n" + - " return super.dispatchGenericFocusedEvent(event); // Should flag this\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "src/test/pkg/ApiCallTest10.java:40: Error: Call requires API level 14 (current min is 4): android.view.View#dispatchHoverEvent [NewApi]\n" + - " dispatchHoverEvent(null);\n" + - " ~~~~~~~~~~~~~~~~~~\n" + - "3 errors, 0 warnings\n", - - lintProject( - "apicheck/classpath=>.classpath", - "apicheck/minsdk4.xml=>AndroidManifest.xml", - "apicheck/ApiCallTest10.java.txt=>src/test/pkg/ApiCallTest10.java", - "apicheck/ApiCallTest10.class.data=>bin/classes/test/pkg/ApiCallTest10.class" - )); - } - - public void testOverrideUnknownTarget() throws Exception { - assertEquals( - "No warnings.", - - lintProject( - "apicheck/classpath=>.classpath", - "apicheck/minsdk4.xml=>AndroidManifest.xml", - "apicheck/ApiCallTest11.java.txt=>src/test/pkg/ApiCallTest11.java", - "apicheck/ApiCallTest11.class.data=>bin/classes/test/pkg/ApiCallTest11.class" - )); - } - - public void testOverride() throws Exception { - assertEquals( - "src/test/pkg/ApiCallTest11.java:13: Error: This method is not overriding anything with the current build target, but will in API level 11 (current target is 3): test.pkg.ApiCallTest11#getActionBar [Override]\n" + - " public ActionBar getActionBar() {\n" + - " ~~~~~~~~~~~~\n" + - "src/test/pkg/ApiCallTest11.java:17: Error: This method is not overriding anything with the current build target, but will in API level 17 (current target is 3): test.pkg.ApiCallTest11#isDestroyed [Override]\n" + - " public boolean isDestroyed() {\n" + - " ~~~~~~~~~~~\n" + - "src/test/pkg/ApiCallTest11.java:39: Error: This method is not overriding anything with the current build target, but will in API level 11 (current target is 3): test.pkg.ApiCallTest11.MyLinear#setDividerDrawable [Override]\n" + - " public void setDividerDrawable(Drawable dividerDrawable) {\n" + - " ~~~~~~~~~~~~~~~~~~\n" + - "3 errors, 0 warnings\n", - - lintProject( - "apicheck/classpath=>.classpath", - "apicheck/minsdk4.xml=>AndroidManifest.xml", - "project.properties1=>project.properties", - "apicheck/ApiCallTest11.java.txt=>src/test/pkg/ApiCallTest11.java", - "apicheck/ApiCallTest11.class.data=>bin/classes/test/pkg/ApiCallTest11.class", - "apicheck/ApiCallTest11$MyLinear.class.data=>bin/classes/test/pkg/ApiCallTest11$MyLinear.class", - "apicheck/ApiCallTest11$MyActivity.class.data=>bin/classes/test/pkg/ApiCallTest11$MyActivity.class" - )); - } - - public void testDateFormat() throws Exception { - // See http://code.google.com/p/android/issues/detail?id=40876 - assertEquals( - "src/test/pkg/ApiCallTest12.java:18: Error: Call requires API level 9 (current min is 4): java.text.DateFormatSymbols#getInstance [NewApi]\n" + - " new SimpleDateFormat(\"yyyy-MM-dd\", DateFormatSymbols.getInstance());\n" + - " ~~~~~~~~~~~\n" + - "src/test/pkg/ApiCallTest12.java:23: Error: The pattern character 'L' requires API level 9 (current min is 4) : \"yyyy-MM-dd LL\" [NewApi]\n" + - " new SimpleDateFormat(\"yyyy-MM-dd LL\", Locale.US);\n" + - " ^\n" + - "src/test/pkg/ApiCallTest12.java:25: Error: The pattern character 'c' requires API level 9 (current min is 4) : \"cc yyyy-MM-dd\" [NewApi]\n" + - " SimpleDateFormat format = new SimpleDateFormat(\"cc yyyy-MM-dd\");\n" + - " ^\n" + - "3 errors, 0 warnings\n", - - lintProject( - "apicheck/classpath=>.classpath", - "apicheck/minsdk4.xml=>AndroidManifest.xml", - "project.properties1=>project.properties", - "apicheck/ApiCallTest12.java.txt=>src/test/pkg/ApiCallTest12.java", - "apicheck/ApiCallTest12.class.data=>bin/classes/test/pkg/ApiCallTest12.class" - )); - } - - public void testDateFormatOk() throws Exception { - assertEquals( - "No warnings.", - - lintProject( - "apicheck/classpath=>.classpath", - "apicheck/minsdk10.xml=>AndroidManifest.xml", - "project.properties1=>project.properties", - "apicheck/ApiCallTest12.java.txt=>src/test/pkg/ApiCallTest12.java", - "apicheck/ApiCallTest12.class.data=>bin/classes/test/pkg/ApiCallTest12.class" - )); - } - - public void testJavaConstants() throws Exception { - assertEquals("" - + "src/test/pkg/ApiSourceCheck.java:5: Warning: Field requires API level 11 (current min is 1): android.view.View#MEASURED_STATE_MASK [InlinedApi]\n" - + "import static android.view.View.MEASURED_STATE_MASK;\n" - + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" - + "src/test/pkg/ApiSourceCheck.java:30: Warning: Field requires API level 11 (current min is 1): android.widget.ZoomControls#MEASURED_STATE_MASK [InlinedApi]\n" - + " int x = MEASURED_STATE_MASK;\n" - + " ~~~~~~~~~~~~~~~~~~~\n" - + "src/test/pkg/ApiSourceCheck.java:33: Warning: Field requires API level 11 (current min is 1): android.view.View#MEASURED_STATE_MASK [InlinedApi]\n" - + " int y = android.view.View.MEASURED_STATE_MASK;\n" - + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" - + "src/test/pkg/ApiSourceCheck.java:36: Warning: Field requires API level 11 (current min is 1): android.view.View#MEASURED_STATE_MASK [InlinedApi]\n" - + " int z = View.MEASURED_STATE_MASK;\n" - + " ~~~~~~~~~~~~~~~~~~~~~~~~\n" - + "src/test/pkg/ApiSourceCheck.java:37: Warning: Field requires API level 14 (current min is 1): android.view.View#FIND_VIEWS_WITH_TEXT [InlinedApi]\n" - + " int find2 = View.FIND_VIEWS_WITH_TEXT; // requires API 14\n" - + " ~~~~~~~~~~~~~~~~~~~~~~~~~\n" - + "src/test/pkg/ApiSourceCheck.java:40: Warning: Field requires API level 12 (current min is 1): android.app.ActivityManager#MOVE_TASK_NO_USER_ACTION [InlinedApi]\n" - + " int w = ActivityManager.MOVE_TASK_NO_USER_ACTION;\n" - + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" - + "src/test/pkg/ApiSourceCheck.java:41: Warning: Field requires API level 14 (current min is 1): android.widget.ZoomButton#FIND_VIEWS_WITH_CONTENT_DESCRIPTION [InlinedApi]\n" - + " int find1 = ZoomButton.FIND_VIEWS_WITH_CONTENT_DESCRIPTION; // requires\n" - + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" - + "src/test/pkg/ApiSourceCheck.java:44: Warning: Field requires API level 9 (current min is 1): android.widget.ZoomControls#OVER_SCROLL_ALWAYS [InlinedApi]\n" - + " int overScroll = OVER_SCROLL_ALWAYS; // requires API 9\n" - + " ~~~~~~~~~~~~~~~~~~\n" - + "src/test/pkg/ApiSourceCheck.java:47: Warning: Field requires API level 16 (current min is 1): android.widget.ZoomControls#IMPORTANT_FOR_ACCESSIBILITY_AUTO [InlinedApi]\n" - + " int auto = IMPORTANT_FOR_ACCESSIBILITY_AUTO; // requires API 16\n" - + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" - + "src/test/pkg/ApiSourceCheck.java:54: Warning: Field requires API level 11 (current min is 1): android.view.View#MEASURED_STATE_MASK [InlinedApi]\n" - + " return (child.getMeasuredWidth() & View.MEASURED_STATE_MASK)\n" - + " ~~~~~~~~~~~~~~~~~~~~~~~~\n" - + "src/test/pkg/ApiSourceCheck.java:55: Warning: Field requires API level 11 (current min is 1): android.view.View#MEASURED_HEIGHT_STATE_SHIFT [InlinedApi]\n" - + " | ((child.getMeasuredHeight() >> View.MEASURED_HEIGHT_STATE_SHIFT) & (View.MEASURED_STATE_MASK >> View.MEASURED_HEIGHT_STATE_SHIFT));\n" - + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" - + "src/test/pkg/ApiSourceCheck.java:55: Warning: Field requires API level 11 (current min is 1): android.view.View#MEASURED_HEIGHT_STATE_SHIFT [InlinedApi]\n" - + " | ((child.getMeasuredHeight() >> View.MEASURED_HEIGHT_STATE_SHIFT) & (View.MEASURED_STATE_MASK >> View.MEASURED_HEIGHT_STATE_SHIFT));\n" - + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" - + "src/test/pkg/ApiSourceCheck.java:55: Warning: Field requires API level 11 (current min is 1): android.view.View#MEASURED_STATE_MASK [InlinedApi]\n" - + " | ((child.getMeasuredHeight() >> View.MEASURED_HEIGHT_STATE_SHIFT) & (View.MEASURED_STATE_MASK >> View.MEASURED_HEIGHT_STATE_SHIFT));\n" - + " ~~~~~~~~~~~~~~~~~~~~~~~~\n" - + "src/test/pkg/ApiSourceCheck.java:90: Warning: Field requires API level 8 (current min is 1): android.R.id#custom [InlinedApi]\n" - + " int custom = android.R.id.custom; // API 8\n" - + " ~~~~~~~~~~~~~~~~~~~\n" - + "src/test/pkg/ApiSourceCheck.java:94: Warning: Field requires API level 13 (current min is 1): android.Manifest.permission#SET_POINTER_SPEED [InlinedApi]\n" - + " String setPointerSpeed = permission.SET_POINTER_SPEED;\n" - + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" - + "src/test/pkg/ApiSourceCheck.java:95: Warning: Field requires API level 13 (current min is 1): android.Manifest.permission#SET_POINTER_SPEED [InlinedApi]\n" - + " String setPointerSpeed2 = Manifest.permission.SET_POINTER_SPEED;\n" - + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" - + "src/test/pkg/ApiSourceCheck.java:120: Warning: Field requires API level 11 (current min is 1): android.view.View#MEASURED_STATE_MASK [InlinedApi]\n" - + " int y = View.MEASURED_STATE_MASK; // Not OK\n" - + " ~~~~~~~~~~~~~~~~~~~~~~~~\n" - + "src/test/pkg/ApiSourceCheck.java:121: Warning: Field requires API level 11 (current min is 1): android.view.View#MEASURED_STATE_MASK [InlinedApi]\n" - + " testBenignUsages(View.MEASURED_STATE_MASK); // Not OK\n" - + " ~~~~~~~~~~~~~~~~~~~~~~~~\n" - + "src/test/pkg/ApiSourceCheck.java:51: Error: Field requires API level 14 (current min is 1): android.widget.ZoomButton#ROTATION_X [NewApi]\n" - + " Object rotationX = ZoomButton.ROTATION_X; // Requires API 14\n" - + " ~~~~~~~~~~\n" - + "1 errors, 18 warnings\n", - - lintProject( - "apicheck/classpath=>.classpath", - "apicheck/minsdk1.xml=>AndroidManifest.xml", - "project.properties1=>project.properties", - "apicheck/ApiSourceCheck.java.txt=>src/test/pkg/ApiSourceCheck.java", - "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" - )); - } - - public void testMovedConstants() throws Exception { - assertEquals("" - // These two constants were introduced in API 11; the other 3 were available - // on subclass ListView from API 1 - + "src/test/pkg/ApiSourceCheck2.java:10: Warning: Field requires API level 11 (current min is 1): android.widget.AbsListView#CHOICE_MODE_MULTIPLE_MODAL [InlinedApi]\n" - + " int mode2 = AbsListView.CHOICE_MODE_MULTIPLE_MODAL;\n" - + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" - + "src/test/pkg/ApiSourceCheck2.java:14: Warning: Field requires API level 11 (current min is 1): android.widget.ListView#CHOICE_MODE_MULTIPLE_MODAL [InlinedApi]\n" - + " int mode6 = ListView.CHOICE_MODE_MULTIPLE_MODAL;\n" - + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" - + "0 errors, 2 warnings\n", - - lintProject( - "apicheck/classpath=>.classpath", - "apicheck/minsdk1.xml=>AndroidManifest.xml", - "project.properties1=>project.properties", - "apicheck/ApiSourceCheck2.java.txt=>src/test/pkg/ApiSourceCheck2.java", - "apicheck/ApiSourceCheck2.class.data=>bin/classes/test/pkg/ApiSourceCheck2.class" - )); - } - - public void testInheritCompatLibrary() throws Exception { - assertEquals("" - + "src/test/pkg/MyActivityImpl.java:8: Error: Call requires API level 11 (current min is 1): android.app.Activity#isChangingConfigurations [NewApi]\n" - + " boolean isChanging = super.isChangingConfigurations();\n" - + " ~~~~~~~~~~~~~~~~~~~~~~~~\n" - + "src/test/pkg/MyActivityImpl.java:13: Error: Call requires API level 11 (current min is 1): android.app.Activity#isChangingConfigurations [NewApi]\n" - + " return super.isChangingConfigurations();\n" - + " ~~~~~~~~~~~~~~~~~~~~~~~~\n" - + "src/test/pkg/MyActivityImpl.java:12: Error: This method is not overriding anything with the current build target, but will in API level 11 (current target is 3): test.pkg.MyActivityImpl#isChangingConfigurations [Override]\n" - + " public boolean isChangingConfigurations() {\n" - + " ~~~~~~~~~~~~~~~~~~~~~~~~\n" - + "3 errors, 0 warnings\n", - - lintProject( - "apicheck/classpath=>.classpath", - "apicheck/minsdk1.xml=>AndroidManifest.xml", - "project.properties1=>project.properties", - "apicheck/MyActivityImpl.java.txt=>src/test/pkg/MyActivityImpl.java", - "apicheck/MyActivityImpl.class.data=>bin/classes/test/pkg/MyActivityImpl.class", - "apicheck/android-support-v4.jar.data=>libs/android-support-v4.jar" - )); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/ApiLookupTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/ApiLookupTest.java deleted file mode 100644 index eaba6e6..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/ApiLookupTest.java +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.annotations.NonNull; -import com.android.annotations.Nullable; -import com.android.tools.lint.detector.api.Detector; -import com.android.tools.lint.detector.api.Severity; - -import java.io.File; -import java.io.PrintWriter; -import java.io.RandomAccessFile; -import java.io.StringWriter; - -@SuppressWarnings("javadoc") -public class ApiLookupTest extends AbstractCheckTest { - private final ApiLookup mDb = ApiLookup.get(new TestLintClient()); - - public void test1() { - assertEquals(5, mDb.getFieldVersion("android/Manifest$permission", "AUTHENTICATE_ACCOUNTS")); - assertTrue(mDb.getFieldVersion("android/R$attr", "absListViewStyle") <= 1); - assertEquals(11, mDb.getFieldVersion("android/R$attr", "actionMenuTextAppearance")); - assertEquals(5, mDb.getCallVersion("android/graphics/drawable/BitmapDrawable", - "<init>", "(Landroid/content/res/Resources;Ljava/lang/String;)V")); - assertEquals(4, mDb.getCallVersion("android/graphics/drawable/BitmapDrawable", - "setTargetDensity", "(Landroid/util/DisplayMetrics;)V")); - assertEquals(7, mDb.getClassVersion("android/app/WallpaperInfo")); - assertEquals(11, mDb.getClassVersion("android/widget/StackView")); - assertTrue(mDb.getClassVersion("ava/text/ChoiceFormat") <= 1); - - // Class lookup: Unknown class - assertEquals(-1, mDb.getClassVersion("foo/Bar")); - // Field lookup: Unknown class - assertEquals(-1, mDb.getFieldVersion("foo/Bar", "FOOBAR")); - // Field lookup: Unknown field - assertEquals(-1, mDb.getFieldVersion("android/Manifest$permission", "FOOBAR")); - // Method lookup: Unknown class - assertEquals(-1, mDb.getCallVersion("foo/Bar", - "<init>", "(Landroid/content/res/Resources;Ljava/lang/String;)V")); - // Method lookup: Unknown name - assertEquals(-1, mDb.getCallVersion("android/graphics/drawable/BitmapDrawable", - "foo", "(Landroid/content/res/Resources;Ljava/lang/String;)V")); - // Method lookup: Unknown argument list - assertEquals(-1, mDb.getCallVersion("android/graphics/drawable/BitmapDrawable", - "<init>", "(I)V")); - } - - public void test2() { - // Regression test: - // This used to return 11 because of some wildcard syntax in the signature - assertTrue(mDb.getCallVersion("java/lang/Object", "getClass", "()") <= 1); - } - - public void testIssue26467() { - assertTrue(mDb.getCallVersion("java/nio/ByteBuffer", "array", "()") <= 1); - assertEquals(9, mDb.getCallVersion("java/nio/Buffer", "array", "()")); - } - - public void testNoInheritedConstructors() { - assertTrue(mDb.getCallVersion("java/util/zip/ZipOutputStream", "<init>", "()") <= 1); - assertTrue(mDb.getCallVersion("android/app/AliasActivity", "<init>", "(Landroid/content/Context;I)") <= 1); - } - - public void testIssue35190() { - assertEquals(9, mDb.getCallVersion("java/io/IOException", "<init>", - "(Ljava/lang/Throwable;)V")); - } - - public void testInheritInterfaces() { - // The onPreferenceStartFragment is inherited via the - // android/preference/PreferenceFragment$OnPreferenceStartFragmentCallback - // interface - assertEquals(11, mDb.getCallVersion("android/preference/PreferenceActivity", - "onPreferenceStartFragment", - "(Landroid/preference/PreferenceFragment;Landroid/preference/Preference;)")); - } - - public void testIsValidPackage() { - assertTrue(mDb.isValidJavaPackage("java/lang/Integer")); - assertTrue(mDb.isValidJavaPackage("javax/crypto/Cipher")); - assertTrue(mDb.isValidJavaPackage("java/awt/font/NumericShaper")); - - assertFalse(mDb.isValidJavaPackage("javax/swing/JButton")); - assertFalse(mDb.isValidJavaPackage("java/rmi/Naming")); - assertFalse(mDb.isValidJavaPackage("java/lang/instrument/Instrumentation")); - } - - @Override - protected Detector getDetector() { - fail("This is not used in the ApiDatabase test"); - return null; - } - - private File mCacheDir; - private StringBuilder mLogBuffer = new StringBuilder(); - - public void testCorruptedCacheHandling() throws Exception { - ApiLookup lookup; - - // Real cache: - mCacheDir = new TestLintClient().getCacheDir(true); - mLogBuffer.setLength(0); - lookup = ApiLookup.get(new LookupTestClient()); - assertEquals(11, lookup.getFieldVersion("android/R$attr", "actionMenuTextAppearance")); - assertNotNull(lookup); - assertEquals("", mLogBuffer.toString()); // No warnings - ApiLookup.dispose(); - - // Custom cache dir: should also work - mCacheDir = new File(getTempDir(), "test-cache"); - mCacheDir.mkdirs(); - mLogBuffer.setLength(0); - lookup = ApiLookup.get(new LookupTestClient()); - assertEquals(11, lookup.getFieldVersion("android/R$attr", "actionMenuTextAppearance")); - assertNotNull(lookup); - assertEquals("", mLogBuffer.toString()); // No warnings - ApiLookup.dispose(); - - // Now truncate cache file - File cacheFile = new File(mCacheDir, - ApiLookup.getCacheFileName("api-versions.xml")); //$NON-NLS-1$ - mLogBuffer.setLength(0); - assertTrue(cacheFile.exists()); - RandomAccessFile raf = new RandomAccessFile(cacheFile, "rw"); - // Truncate file in half - raf.setLength(100); // Broken header - raf.close(); - lookup = ApiLookup.get(new LookupTestClient()); - String message = mLogBuffer.toString(); - // NOTE: This test is incompatible with the DEBUG_FORCE_REGENERATE_BINARY and WRITE_STATS - // flags in the ApiLookup class, so if the test fails during development and those are - // set, clear them. - assertTrue(message.contains("Please delete the file and restart the IDE/lint:")); - assertTrue(message.contains(mCacheDir.getPath())); - ApiLookup.dispose(); - - mLogBuffer.setLength(0); - assertTrue(cacheFile.exists()); - raf = new RandomAccessFile(cacheFile, "rw"); - // Truncate file in half in the data portion - raf.setLength(raf.length() / 2); - raf.close(); - lookup = ApiLookup.get(new LookupTestClient()); - // This data is now truncated: lookup returns the wrong size. - try { - assertNotNull(lookup); - lookup.getFieldVersion("android/R$attr", "actionMenuTextAppearance"); - fail("Can't look up bogus data"); - } catch (Throwable t) { - // Expected this: the database is corrupted. - } - assertTrue(message.contains("Please delete the file and restart the IDE/lint:")); - assertTrue(message.contains(mCacheDir.getPath())); - ApiLookup.dispose(); - - mLogBuffer.setLength(0); - assertTrue(cacheFile.exists()); - raf = new RandomAccessFile(cacheFile, "rw"); - // Truncate file to 0 bytes - raf.setLength(0); - raf.close(); - lookup = ApiLookup.get(new LookupTestClient()); - assertEquals(11, lookup.getFieldVersion("android/R$attr", "actionMenuTextAppearance")); - assertNotNull(lookup); - assertEquals("", mLogBuffer.toString()); // No warnings - ApiLookup.dispose(); - } - - private final class LookupTestClient extends TestLintClient { - @Override - public File getCacheDir(boolean create) { - assertNotNull(mCacheDir); - if (create && !mCacheDir.exists()) { - mCacheDir.mkdirs(); - } - return mCacheDir; - } - - @Override - public void log( - @NonNull Severity severity, - @Nullable Throwable exception, - @Nullable String format, - @Nullable Object... args) { - if (format != null) { - mLogBuffer.append(String.format(format, args)); - mLogBuffer.append('\n'); - } - if (exception != null) { - StringWriter writer = new StringWriter(); - exception.printStackTrace(new PrintWriter(writer)); - mLogBuffer.append(writer.toString()); - mLogBuffer.append('\n'); - } - } - - @Override - public void log(Throwable exception, String format, Object... args) { - log(Severity.WARNING, exception, format, args); - } - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/ArraySizeDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/ArraySizeDetectorTest.java deleted file mode 100644 index 127e7f8..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/ArraySizeDetectorTest.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class ArraySizeDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new ArraySizeDetector(); - } - public void testArraySizes() throws Exception { - assertEquals( - "res/values/arrays.xml:3: Warning: Array security_questions has an inconsistent number of items (3 in values-nl-rNL/arrays.xml, 4 in values-cs/arrays.xml) [InconsistentArrays]\n" + - " <string-array name=\"security_questions\">\n" + - " ^\n" + - " res/values-cs/arrays.xml:3: Declaration with array size (4)\n" + - " res/values-es/strings.xml:12: Declaration with array size (4)\n" + - " res/values-nl-rNL/arrays.xml:3: Declaration with array size (3)\n" + - "res/values/arrays.xml:10: Warning: Array signal_strength has an inconsistent number of items (5 in values/arrays.xml, 6 in values-land/arrays.xml) [InconsistentArrays]\n" + - " <array name=\"signal_strength\">\n" + - " ^\n" + - " res/values-land/arrays.xml:2: Declaration with array size (6)\n" + - "0 errors, 2 warnings\n" + - "", - - lintProject( - "res/values/arrays.xml", - "res/values-cs/arrays.xml", - "res/values-land/arrays.xml", - "res/values-nl-rNL/arrays.xml", - "res/values-es/strings.xml")); - } - - public void testMultipleArrays() throws Exception { - assertEquals( - "res/values/stringarrays.xml:3: Warning: Array map_density_desc has an inconsistent number of items (5 in values/stringarrays.xml, 1 in values-it/stringarrays.xml) [InconsistentArrays]\n" + - " <string-array name=\"map_density_desc\">\n" + - " ^\n" + - " res/values-it/stringarrays.xml:6: Declaration with array size (1)\n" + - "0 errors, 1 warnings\n", - - lintProject( - "res/values-it/stringarrays.xml", - "res/values/stringarrays.xml")); - } - - public void testArraySizesSuppressed() throws Exception { - assertEquals( - "No warnings.", - - lintProject( - "res/values/arrays.xml", - "res/values-land/arrays_ignore.xml=>res/values-land/arrays.xml")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/ButtonDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/ButtonDetectorTest.java deleted file mode 100644 index 989f33c..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/ButtonDetectorTest.java +++ /dev/null @@ -1,415 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; -import com.android.tools.lint.detector.api.Issue; - -@SuppressWarnings("javadoc") -public class ButtonDetectorTest extends AbstractCheckTest { - private static Issue sTestIssue; - - @Override - protected boolean isEnabled(Issue issue) { - return super.isEnabled(issue) && sTestIssue == null || issue == sTestIssue; - - } - - @Override - protected Detector getDetector() { - return new ButtonDetector(); - } - - public void testButtonOrder() throws Exception { - sTestIssue = ButtonDetector.ORDER; - assertEquals( - "res/layout/buttonbar.xml:12: Warning: OK button should be on the right (was \"OK | Cancel\", should be \"Cancel | OK\") [ButtonOrder]\n" + - " <Button\n" + - " ^\n" + - "res/layout/buttonbar.xml:44: Warning: OK button should be on the right (was \"OK | Cancel\", should be \"Cancel | OK\") [ButtonOrder]\n" + - " <Button\n" + - " ^\n" + - "res/layout/buttonbar.xml:92: Warning: OK button should be on the right (was \"OK | Cancel\", should be \"Cancel | OK\") [ButtonOrder]\n" + - " <Button\n" + - " ^\n" + - "res/layout/buttonbar.xml:124: Warning: OK button should be on the right (was \"OK | Cancel\", should be \"Cancel | OK\") [ButtonOrder]\n" + - " <Button\n" + - " ^\n" + - "res/layout/buttonbar.xml:140: Warning: OK button should be on the right (was \"Ok | CANCEL\", should be \"CANCEL | Ok\") [ButtonOrder]\n" + - " <Button\n" + - " ^\n" + - "res/layout/buttonbar.xml:156: Warning: OK button should be on the right (was \"OK | Abort\", should be \"Abort | OK\") [ButtonOrder]\n" + - " <Button\n" + - " ^\n" + - "res/layout/buttonbar.xml:177: Warning: Cancel button should be on the left (was \"Send | Cancel\", should be \"Cancel | Send\") [ButtonOrder]\n" + - " <Button\n" + - " ^\n" + - "0 errors, 7 warnings\n" + - "", - - lintProject( - "apicheck/minsdk14.xml=>AndroidManifest.xml", - "res/layout/buttonbar.xml", - "res/values/buttonbar-values.xml")); - } - - public void testButtonOrder2() throws Exception { - // If the layout is in v14, it had better have the right order - sTestIssue = ButtonDetector.ORDER; - assertEquals( - "res/layout-v14/buttonbar.xml:12: Warning: OK button should be on the right (was \"OK | Cancel\", should be \"Cancel | OK\") [ButtonOrder]\n" + - " <Button\n" + - " ^\n" + - "res/layout-v14/buttonbar.xml:44: Warning: OK button should be on the right (was \"OK | Cancel\", should be \"Cancel | OK\") [ButtonOrder]\n" + - " <Button\n" + - " ^\n" + - "res/layout-v14/buttonbar.xml:92: Warning: OK button should be on the right (was \"OK | Cancel\", should be \"Cancel | OK\") [ButtonOrder]\n" + - " <Button\n" + - " ^\n" + - "res/layout-v14/buttonbar.xml:124: Warning: OK button should be on the right (was \"OK | Cancel\", should be \"Cancel | OK\") [ButtonOrder]\n" + - " <Button\n" + - " ^\n" + - "res/layout-v14/buttonbar.xml:140: Warning: OK button should be on the right (was \"Ok | CANCEL\", should be \"CANCEL | Ok\") [ButtonOrder]\n" + - " <Button\n" + - " ^\n" + - "res/layout-v14/buttonbar.xml:156: Warning: OK button should be on the right (was \"OK | Abort\", should be \"Abort | OK\") [ButtonOrder]\n" + - " <Button\n" + - " ^\n" + - "res/layout-v14/buttonbar.xml:177: Warning: Cancel button should be on the left (was \"Send | Cancel\", should be \"Cancel | Send\") [ButtonOrder]\n" + - " <Button\n" + - " ^\n" + - "0 errors, 7 warnings\n" + - "", - - lintProject( - "minsdk5targetsdk14.xml=>AndroidManifest.xml", - "res/layout/buttonbar.xml=>res/layout-v14/buttonbar.xml", - "res/values/buttonbar-values.xml")); - } - - public void testButtonOrder3() throws Exception { - // Similar to test 3, but also complain if the -v version is *higher* than 14 - sTestIssue = ButtonDetector.ORDER; - assertEquals( - "res/layout-v16/buttonbar.xml:12: Warning: OK button should be on the right (was \"OK | Cancel\", should be \"Cancel | OK\") [ButtonOrder]\n" + - " <Button\n" + - " ^\n" + - "res/layout-v16/buttonbar.xml:44: Warning: OK button should be on the right (was \"OK | Cancel\", should be \"Cancel | OK\") [ButtonOrder]\n" + - " <Button\n" + - " ^\n" + - "res/layout-v16/buttonbar.xml:92: Warning: OK button should be on the right (was \"OK | Cancel\", should be \"Cancel | OK\") [ButtonOrder]\n" + - " <Button\n" + - " ^\n" + - "res/layout-v16/buttonbar.xml:124: Warning: OK button should be on the right (was \"OK | Cancel\", should be \"Cancel | OK\") [ButtonOrder]\n" + - " <Button\n" + - " ^\n" + - "res/layout-v16/buttonbar.xml:140: Warning: OK button should be on the right (was \"Ok | CANCEL\", should be \"CANCEL | Ok\") [ButtonOrder]\n" + - " <Button\n" + - " ^\n" + - "res/layout-v16/buttonbar.xml:156: Warning: OK button should be on the right (was \"OK | Abort\", should be \"Abort | OK\") [ButtonOrder]\n" + - " <Button\n" + - " ^\n" + - "res/layout-v16/buttonbar.xml:177: Warning: Cancel button should be on the left (was \"Send | Cancel\", should be \"Cancel | Send\") [ButtonOrder]\n" + - " <Button\n" + - " ^\n" + - "0 errors, 7 warnings\n" + - "", - - lintProject( - "minsdk5targetsdk14.xml=>AndroidManifest.xml", - "res/layout/buttonbar.xml=>res/layout-v16/buttonbar.xml", - "res/values/buttonbar-values.xml")); - } - - public void testButtonOrder4() throws Exception { - // Targeting 14 but using a layout that also needs to work for older platforms: - sTestIssue = ButtonDetector.ORDER; - assertEquals( - "res/layout/buttonbar.xml:12: Warning: Layout uses the wrong button order for API >= 14: Create a layout-v14/buttonbar.xml file with opposite order: OK button should be on the right (was \"OK | Cancel\", should be \"Cancel | OK\") [ButtonOrder]\n" + - " <Button\n" + - " ^\n" + - "res/layout/buttonbar.xml:44: Warning: Layout uses the wrong button order for API >= 14: Create a layout-v14/buttonbar.xml file with opposite order: OK button should be on the right (was \"OK | Cancel\", should be \"Cancel | OK\") [ButtonOrder]\n" + - " <Button\n" + - " ^\n" + - "res/layout/buttonbar.xml:92: Warning: Layout uses the wrong button order for API >= 14: Create a layout-v14/buttonbar.xml file with opposite order: OK button should be on the right (was \"OK | Cancel\", should be \"Cancel | OK\") [ButtonOrder]\n" + - " <Button\n" + - " ^\n" + - "res/layout/buttonbar.xml:124: Warning: Layout uses the wrong button order for API >= 14: Create a layout-v14/buttonbar.xml file with opposite order: OK button should be on the right (was \"OK | Cancel\", should be \"Cancel | OK\") [ButtonOrder]\n" + - " <Button\n" + - " ^\n" + - "res/layout/buttonbar.xml:140: Warning: Layout uses the wrong button order for API >= 14: Create a layout-v14/buttonbar.xml file with opposite order: OK button should be on the right (was \"Ok | CANCEL\", should be \"CANCEL | Ok\") [ButtonOrder]\n" + - " <Button\n" + - " ^\n" + - "res/layout/buttonbar.xml:156: Warning: Layout uses the wrong button order for API >= 14: Create a layout-v14/buttonbar.xml file with opposite order: OK button should be on the right (was \"OK | Abort\", should be \"Abort | OK\") [ButtonOrder]\n" + - " <Button\n" + - " ^\n" + - "res/layout/buttonbar.xml:177: Warning: Layout uses the wrong button order for API >= 14: Create a layout-v14/buttonbar.xml file with opposite order: Cancel button should be on the left (was \"Send | Cancel\", should be \"Cancel | Send\") [ButtonOrder]\n" + - " <Button\n" + - " ^\n" + - "0 errors, 7 warnings\n" + - "", - - lintProject( - "minsdk5targetsdk14.xml=>AndroidManifest.xml", - "res/layout/buttonbar.xml", - "res/values/buttonbar-values.xml")); - } - - public void testButtonOrder5() throws Exception { - // If the layout is in a non-ICS folder and has the wrong button order, - // but there is a v14 version of the layout, don't complain about the non-v14 version - sTestIssue = ButtonDetector.ORDER; - assertEquals( - "No warnings.", - - lintProject( - "minsdk5targetsdk14.xml=>AndroidManifest.xml", - "res/layout/buttonbar.xml", - "res/layout/layout1.xml=>res/layout-v14/buttonbar.xml", - "res/values/buttonbar-values.xml")); - } - - public void testSuppressed() throws Exception { - sTestIssue = ButtonDetector.ORDER; - assertEquals( - "No warnings.", - - lintProject( - "apicheck/minsdk14.xml=>AndroidManifest.xml", - "res/layout/buttonbar_suppressed.xml", - "res/values/buttonbar-values.xml")); - } - - public void testButtonOrderRelativeLayout() throws Exception { - sTestIssue = ButtonDetector.ORDER; - assertEquals( - "No warnings.", - - lintProject("res/layout/buttonbar2.xml", "res/values/buttonbar-values.xml")); - } - - public void testButtonOrderRelativeLayout2() throws Exception { - sTestIssue = ButtonDetector.ORDER; - assertEquals( - "res/layout/buttonbar3.xml:27: Warning: Cancel button should be on the left [ButtonOrder]\n" + - " <Button\n" + - " ^\n" + - "0 errors, 1 warnings\n" + - "", - - lintProject( - "apicheck/minsdk14.xml=>AndroidManifest.xml", - "res/layout/buttonbar3.xml", - "res/values/buttonbar-values.xml")); - } - - public void testButtonOrderRelativeLayout3() throws Exception { - sTestIssue = ButtonDetector.ORDER; - assertEquals( - "No warnings.", - - lintProject("res/layout/buttonbar4.xml", "res/values/buttonbar-values.xml")); - } - - - public void testCase() throws Exception { - sTestIssue = ButtonDetector.CASE; - assertEquals( - "res/values/buttonbar-values.xml:9: Warning: The standard Android way to capitalize Ok is \"OK\" (tip: use @android:string/ok instead) [ButtonCase]\n" + - " <string name=\"resume2\"> Ok </string>\n" + - " ^\n" + - "res/values/buttonbar-values.xml:10: Warning: The standard Android way to capitalize CANCEL is \"Cancel\" (tip: use @android:string/ok instead) [ButtonCase]\n" + - " <string name=\"giveup2\">\"CANCEL\"</string>\n" + - " ^\n" + - "0 errors, 2 warnings\n" + - "", - - lintProject("res/layout/buttonbar.xml", "res/values/buttonbar-values.xml")); - } - - public void testBack() throws Exception { - sTestIssue = ButtonDetector.BACKBUTTON; - assertEquals( - "res/layout/buttonbar.xml:183: Warning: Back buttons are not standard on Android; see design guide's navigation section [BackButton]\n" + - " <Button\n" + - " ^\n" + - "0 errors, 1 warnings\n" + - "", - - lintProject("res/layout/buttonbar.xml", "res/values/buttonbar-values.xml")); - } - - public void testOldApp() throws Exception { - // Target SDK < 14 - no warnings on button order - sTestIssue = ButtonDetector.ORDER; - assertEquals( - "No warnings.", - - lintProject( - "minsdk5targetsdk9.xml=>AndroidManifest.xml", - "res/layout/buttonbar.xml", - "res/values/buttonbar-values.xml")); - } - - public void testEnglishLocales() throws Exception { - sTestIssue = ButtonDetector.ORDER; - assertEquals( - "res/layout-en-rGB/buttonbar.xml:12: Warning: OK button should be on the right (was \"OK | Cancel\", should be \"Cancel | OK\") [ButtonOrder]\n" + - " <Button\n" + - " ^\n" + - "res/layout-en-rGB/buttonbar.xml:44: Warning: OK button should be on the right (was \"OK | Cancel\", should be \"Cancel | OK\") [ButtonOrder]\n" + - " <Button\n" + - " ^\n" + - "res/layout-en-rGB/buttonbar.xml:92: Warning: OK button should be on the right (was \"OK | Cancel\", should be \"Cancel | OK\") [ButtonOrder]\n" + - " <Button\n" + - " ^\n" + - "res/layout-en-rGB/buttonbar.xml:124: Warning: OK button should be on the right (was \"OK | Cancel\", should be \"Cancel | OK\") [ButtonOrder]\n" + - " <Button\n" + - " ^\n" + - "res/layout-en-rGB/buttonbar.xml:140: Warning: OK button should be on the right (was \"Ok | CANCEL\", should be \"CANCEL | Ok\") [ButtonOrder]\n" + - " <Button\n" + - " ^\n" + - "res/layout-en-rGB/buttonbar.xml:156: Warning: OK button should be on the right (was \"OK | Abort\", should be \"Abort | OK\") [ButtonOrder]\n" + - " <Button\n" + - " ^\n" + - "res/layout-en-rGB/buttonbar.xml:177: Warning: Cancel button should be on the left (was \"Send | Cancel\", should be \"Cancel | Send\") [ButtonOrder]\n" + - " <Button\n" + - " ^\n" + - "0 errors, 7 warnings\n" + - "", - - lintProject( - "apicheck/minsdk14.xml=>AndroidManifest.xml", - "res/layout/buttonbar.xml=>res/layout-en-rGB/buttonbar.xml", - "res/values/buttonbar-values.xml=>res/values-en-rGB/buttonbar-values.xml")); - } - - public void testOtherLocales() throws Exception { - sTestIssue = ButtonDetector.ORDER; - assertEquals( - // Hardcoded values only - "res/layout-de/buttonbar.xml:12: Warning: OK button should be on the right (was \"OK | Cancel\", should be \"Cancel | OK\") [ButtonOrder]\n" + - " <Button\n" + - " ^\n" + - "res/layout-de/buttonbar.xml:44: Warning: OK button should be on the right (was \"OK | Cancel\", should be \"Cancel | OK\") [ButtonOrder]\n" + - " <Button\n" + - " ^\n" + - "0 errors, 2 warnings\n" + - "", - - lintProject( - "apicheck/minsdk14.xml=>AndroidManifest.xml", - "res/layout/buttonbar.xml=>res/layout-de/buttonbar.xml", - "res/values/buttonbar-values.xml=>res/values-de/buttonbar-values.xml")); - } - - public void testOtherLocales2() throws Exception { - sTestIssue = ButtonDetector.CASE; - assertEquals( - "No warnings.", - - lintProject("res/layout/buttonbar.xml=>res/layout-de/buttonbar.xml", - "res/values/buttonbar-values.xml=>res/values-de/buttonbar-values.xml")); - } - - public void testButtonStyle() throws Exception { - sTestIssue = ButtonDetector.STYLE; - assertEquals( - "res/layout/buttonbar.xml:12: Warning: Buttons in button bars should be borderless; use style=\"?android:attr/buttonBarButtonStyle\" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle]\n" + - " <Button\n" + - " ^\n" + - "res/layout/buttonbar.xml:17: Warning: Buttons in button bars should be borderless; use style=\"?android:attr/buttonBarButtonStyle\" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle]\n" + - " <Button\n" + - " ^\n" + - "res/layout/buttonbar.xml:28: Warning: Buttons in button bars should be borderless; use style=\"?android:attr/buttonBarButtonStyle\" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle]\n" + - " <Button\n" + - " ^\n" + - "res/layout/buttonbar.xml:33: Warning: Buttons in button bars should be borderless; use style=\"?android:attr/buttonBarButtonStyle\" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle]\n" + - " <Button\n" + - " ^\n" + - "res/layout/buttonbar.xml:44: Warning: Buttons in button bars should be borderless; use style=\"?android:attr/buttonBarButtonStyle\" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle]\n" + - " <Button\n" + - " ^\n" + - "res/layout/buttonbar.xml:49: Warning: Buttons in button bars should be borderless; use style=\"?android:attr/buttonBarButtonStyle\" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle]\n" + - " <Button\n" + - " ^\n" + - "res/layout/buttonbar.xml:60: Warning: Buttons in button bars should be borderless; use style=\"?android:attr/buttonBarButtonStyle\" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle]\n" + - " <Button\n" + - " ^\n" + - "res/layout/buttonbar.xml:65: Warning: Buttons in button bars should be borderless; use style=\"?android:attr/buttonBarButtonStyle\" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle]\n" + - " <Button\n" + - " ^\n" + - "res/layout/buttonbar.xml:76: Warning: Buttons in button bars should be borderless; use style=\"?android:attr/buttonBarButtonStyle\" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle]\n" + - " <Button\n" + - " ^\n" + - "res/layout/buttonbar.xml:81: Warning: Buttons in button bars should be borderless; use style=\"?android:attr/buttonBarButtonStyle\" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle]\n" + - " <Button\n" + - " ^\n" + - "res/layout/buttonbar.xml:92: Warning: Buttons in button bars should be borderless; use style=\"?android:attr/buttonBarButtonStyle\" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle]\n" + - " <Button\n" + - " ^\n" + - "res/layout/buttonbar.xml:97: Warning: Buttons in button bars should be borderless; use style=\"?android:attr/buttonBarButtonStyle\" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle]\n" + - " <Button\n" + - " ^\n" + - "res/layout/buttonbar.xml:108: Warning: Buttons in button bars should be borderless; use style=\"?android:attr/buttonBarButtonStyle\" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle]\n" + - " <Button\n" + - " ^\n" + - "res/layout/buttonbar.xml:113: Warning: Buttons in button bars should be borderless; use style=\"?android:attr/buttonBarButtonStyle\" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle]\n" + - " <Button\n" + - " ^\n" + - "res/layout/buttonbar.xml:124: Warning: Buttons in button bars should be borderless; use style=\"?android:attr/buttonBarButtonStyle\" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle]\n" + - " <Button\n" + - " ^\n" + - "res/layout/buttonbar.xml:129: Warning: Buttons in button bars should be borderless; use style=\"?android:attr/buttonBarButtonStyle\" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle]\n" + - " <Button\n" + - " ^\n" + - "res/layout/buttonbar.xml:140: Warning: Buttons in button bars should be borderless; use style=\"?android:attr/buttonBarButtonStyle\" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle]\n" + - " <Button\n" + - " ^\n" + - "res/layout/buttonbar.xml:145: Warning: Buttons in button bars should be borderless; use style=\"?android:attr/buttonBarButtonStyle\" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle]\n" + - " <Button\n" + - " ^\n" + - "res/layout/buttonbar.xml:156: Warning: Buttons in button bars should be borderless; use style=\"?android:attr/buttonBarButtonStyle\" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle]\n" + - " <Button\n" + - " ^\n" + - "res/layout/buttonbar.xml:161: Warning: Buttons in button bars should be borderless; use style=\"?android:attr/buttonBarButtonStyle\" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle]\n" + - " <Button\n" + - " ^\n" + - "0 errors, 20 warnings\n", - - lintProject( - "apicheck/minsdk14.xml=>AndroidManifest.xml", - "res/layout/buttonbar.xml", - "res/layout/buttonbar2.xml", - "res/layout/buttonbar3.xml", - "res/values/buttonbar-values.xml")); - } - - public void testButtonStyleOldMinSdk() throws Exception { - sTestIssue = ButtonDetector.STYLE; - assertEquals( - "No warnings.", - - lintProject( - "apicheck/minsdk4.xml=>AndroidManifest.xml", - "res/layout/buttonbar.xml", - "res/layout/buttonbar2.xml", - "res/layout/buttonbar3.xml", - "res/values/buttonbar-values.xml")); - } - -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/ChildCountDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/ChildCountDetectorTest.java deleted file mode 100644 index 517ca4d..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/ChildCountDetectorTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class ChildCountDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new ChildCountDetector(); - } - - public void testChildCount() throws Exception { - assertEquals( - "res/layout/has_children.xml:3: Warning: A list/grid should have no children declared in XML [AdapterViewChildren]\n" + - "<ListView\n" + - "^\n" + - "0 errors, 1 warnings\n" + - "", - lintFiles("res/layout/has_children.xml")); - } - - public void testChildCount2() throws Exception { - // A <requestFocus/> tag is okay. - assertEquals( - "No warnings.", - lintFiles("res/layout/has_children2.xml")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/CleanupDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/CleanupDetectorTest.java deleted file mode 100644 index 01d462a..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/CleanupDetectorTest.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class CleanupDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new CleanupDetector(); - } - - public void testRecycle() throws Exception { - assertEquals( - "src/test/pkg/RecycleTest.java:56: Warning: This TypedArray should be recycled after use with #recycle() [Recycle]\n" + - " final TypedArray a = getContext().obtainStyledAttributes(attrs,\n" + - " ~~~~~~~~~~~~~~~~~~~~~~\n" + - "src/test/pkg/RecycleTest.java:63: Warning: This TypedArray should be recycled after use with #recycle() [Recycle]\n" + - " final TypedArray a = getContext().obtainStyledAttributes(new int[0]);\n" + - " ~~~~~~~~~~~~~~~~~~~~~~\n" + - "src/test/pkg/RecycleTest.java:79: Warning: This VelocityTracker should be recycled after use with #recycle() [Recycle]\n" + - " VelocityTracker tracker = VelocityTracker.obtain();\n" + - " ~~~~~~\n" + - "src/test/pkg/RecycleTest.java:92: Warning: This MotionEvent should be recycled after use with #recycle() [Recycle]\n" + - " MotionEvent event1 = MotionEvent.obtain(null);\n" + - " ~~~~~~\n" + - "src/test/pkg/RecycleTest.java:93: Warning: This MotionEvent should be recycled after use with #recycle() [Recycle]\n" + - " MotionEvent event2 = MotionEvent.obtainNoHistory(null);\n" + - " ~~~~~~~~~~~~~~~\n" + - "src/test/pkg/RecycleTest.java:98: Warning: This MotionEvent should be recycled after use with #recycle() [Recycle]\n" + - " MotionEvent event2 = MotionEvent.obtainNoHistory(null); // Not recycled\n" + - " ~~~~~~~~~~~~~~~\n" + - "src/test/pkg/RecycleTest.java:103: Warning: This MotionEvent should be recycled after use with #recycle() [Recycle]\n" + - " MotionEvent event1 = MotionEvent.obtain(null); // Not recycled\n" + - " ~~~~~~\n" + - "src/test/pkg/RecycleTest.java:113: Warning: This MotionEvent has already been recycled [Recycle]\n" + - " int contents2 = event1.describeContents(); // BAD, after recycle\n" + - " ~~~~~~~~~~~~~~~~\n" + - "src/test/pkg/RecycleTest.java:117: Warning: This TypedArray has already been recycled [Recycle]\n" + - " example = a.getString(R.styleable.MyView_exampleString); // BAD, after recycle\n" + - " ~~~~~~~~~\n" + - "src/test/pkg/RecycleTest.java:129: Warning: This Parcel should be recycled after use with #recycle() [Recycle]\n" + - " Parcel myparcel = Parcel.obtain();\n" + - " ~~~~~~\n" + - "0 errors, 10 warnings\n", - - lintProject( - "apicheck/classpath=>.classpath", - "apicheck/minsdk4.xml=>AndroidManifest.xml", - "project.properties1=>project.properties", - "bytecode/RecycleTest.java.txt=>src/test/pkg/RecycleTest.java", - "bytecode/RecycleTest.class.data=>bin/classes/test/pkg/RecycleTest.class" - )); - } - - public void testCommit() throws Exception { - assertEquals("" + - "src/test/pkg/CommitTest.java:25: Warning: This transaction should be completed with a commit() call [CommitTransaction]\n" + - " getFragmentManager().beginTransaction(); // Missing commit\n" + - " ~~~~~~~~~~~~~~~~\n" + - "src/test/pkg/CommitTest.java:30: Warning: This transaction should be completed with a commit() call [CommitTransaction]\n" + - " FragmentTransaction transaction2 = getFragmentManager().beginTransaction(); // Missing commit\n" + - " ~~~~~~~~~~~~~~~~\n" + - "src/test/pkg/CommitTest.java:39: Warning: This transaction should be completed with a commit() call [CommitTransaction]\n" + - " getFragmentManager().beginTransaction(); // Missing commit\n" + - " ~~~~~~~~~~~~~~~~\n" + - "src/test/pkg/CommitTest.java:65: Warning: This transaction should be completed with a commit() call [Recycle]\n" + - " getSupportFragmentManager().beginTransaction();\n" + - " ~~~~~~~~~~~~~~~~\n" + - "0 errors, 4 warnings\n", - - lintProject( - "apicheck/classpath=>.classpath", - "apicheck/minsdk4.xml=>AndroidManifest.xml", - "project.properties1=>project.properties", - "bytecode/CommitTest.java.txt=>src/test/pkg/CommitTest.java", - "bytecode/CommitTest.class.data=>bin/classes/test/pkg/CommitTest.class" - )); - } - - public void testCommit2() throws Exception { - assertEquals("" - + "No warnings.", - - lintProject( - "apicheck/classpath=>.classpath", - "apicheck/minsdk4.xml=>AndroidManifest.xml", - "project.properties1=>project.properties", - "bytecode/DialogFragment.class.data=>bin/classes/test/pkg/DialogFragment.class" - )); - } - - public void testHasReturnType() throws Exception { - assertTrue(CleanupDetector.hasReturnType("android/app/FragmentTransaction", - "(Landroid/app/Fragment;)Landroid/app/FragmentTransaction;")); - assertTrue(CleanupDetector.hasReturnType("android/app/FragmentTransaction", - "()Landroid/app/FragmentTransaction;")); - assertFalse(CleanupDetector.hasReturnType("android/app/FragmentTransaction", - "()Landroid/app/FragmentTransactions;")); - assertFalse(CleanupDetector.hasReturnType("android/app/FragmentTransaction", - "()Landroid/app/FragmentTransactions")); - assertFalse(CleanupDetector.hasReturnType("android/app/FragmentTransaction", - "()android/app/FragmentTransaction;")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/ColorUsageDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/ColorUsageDetectorTest.java deleted file mode 100644 index d1a04e1..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/ColorUsageDetectorTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class ColorUsageDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new ColorUsageDetector(); - } - - public void test() throws Exception { - assertEquals( - "src/test/pkg/WrongColor.java:9: Error: Should pass resolved color instead of resource id here: getResources().getColor(R.color.blue) [ResourceAsColor]\n" + - " paint2.setColor(R.color.blue);\n" + - " ~~~~~~~~~~~~\n" + - "src/test/pkg/WrongColor.java:11: Error: Should pass resolved color instead of resource id here: getResources().getColor(R.color.red) [ResourceAsColor]\n" + - " textView.setTextColor(R.color.red);\n" + - " ~~~~~~~~~~~\n" + - "src/test/pkg/WrongColor.java:12: Error: Should pass resolved color instead of resource id here: getResources().getColor(android.R.color.red) [ResourceAsColor]\n" + - " textView.setTextColor(android.R.color.red);\n" + - " ~~~~~~~~~~~~~~~~~~~\n" + - "3 errors, 0 warnings\n" + - "", - - lintProject("src/test/pkg/WrongColor.java.txt=>src/test/pkg/WrongColor.java")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/CommentDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/CommentDetectorTest.java deleted file mode 100644 index c352962..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/CommentDetectorTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class CommentDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new CommentDetector(); - } - - public void test() throws Exception { - assertEquals( - "src/test/pkg/Hidden.java:11: Warning: STOPSHIP comment found; points to code which must be fixed prior to release [StopShip]\n" + - " // STOPSHIP\n" + - " ~~~~~~~~\n" + - "src/test/pkg/Hidden.java:12: Warning: STOPSHIP comment found; points to code which must be fixed prior to release [StopShip]\n" + - " /* We must STOPSHIP! */\n" + - " ~~~~~~~~\n" + - "src/test/pkg/Hidden.java:5: Warning: Code might be hidden here; found unicode escape sequence which is interpreted as comment end, compiled code follows [EasterEgg]\n" + - " /* \\u002a\\u002f static { System.out.println(\"I'm executed on class load\"); } \\u002f\\u002a */\n" + - " ~~~~~~~~~~~~\n" + - "src/test/pkg/Hidden.java:6: Warning: Code might be hidden here; found unicode escape sequence which is interpreted as comment end, compiled code follows [EasterEgg]\n" + - " /* \\u002A\\U002F static { System.out.println(\"I'm executed on class load\"); } \\u002f\\u002a */\n" + - " ~~~~~~~~~~~~\n" + - "0 errors, 4 warnings\n", - - lintProject("src/test/pkg/Hidden.java.txt=>src/test/pkg/Hidden.java")); - } - - public void test2() throws Exception { - assertEquals( - "No warnings.", - - lintProject("src/test/pkg/SdCardTest.java.txt=>src/test/pkg/SdCardTest.java")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/CutPasteDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/CutPasteDetectorTest.java deleted file mode 100644 index df02a41..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/CutPasteDetectorTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class CutPasteDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new CutPasteDetector(); - } - - public void test() throws Exception { - assertEquals( - "src/test/pkg/PasteError.java:15: Warning: The id R.id.textView1 has already been looked up in this method; possible cut & paste error? [CutPasteId]\n" + - " View view2 = findViewById(R.id.textView1);\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - " src/test/pkg/PasteError.java:14: First usage here\n" + - "src/test/pkg/PasteError.java:71: Warning: The id R.id.textView1 has already been looked up in this method; possible cut & paste error? [CutPasteId]\n" + - " view2 = findViewById(R.id.textView1);\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - " src/test/pkg/PasteError.java:68: First usage here\n" + - "src/test/pkg/PasteError.java:78: Warning: The id R.id.textView1 has already been looked up in this method; possible cut & paste error? [CutPasteId]\n" + - " view2 = findViewById(R.id.textView1);\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - " src/test/pkg/PasteError.java:76: First usage here\n" + - "src/test/pkg/PasteError.java:86: Warning: The id R.id.textView1 has already been looked up in this method; possible cut & paste error? [CutPasteId]\n" + - " view2 = findViewById(R.id.textView1);\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - " src/test/pkg/PasteError.java:83: First usage here\n" + - "src/test/pkg/PasteError.java:95: Warning: The id R.id.textView1 has already been looked up in this method; possible cut & paste error? [CutPasteId]\n" + - " view2 = findViewById(R.id.textView1);\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - " src/test/pkg/PasteError.java:91: First usage here\n" + - "0 errors, 5 warnings\n", - - lintProject("src/test/pkg/PasteError.java.txt=>" + - "src/test/pkg/PasteError.java")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/DeprecationDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/DeprecationDetectorTest.java deleted file mode 100644 index f399014..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/DeprecationDetectorTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class DeprecationDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new DeprecationDetector(); - } - - public void testApi1() throws Exception { - assertEquals( - "res/layout/deprecation.xml:2: Warning: AbsoluteLayout is deprecated [Deprecated]\n" + - "<AbsoluteLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" + - "^\n" + - "res/layout/deprecation.xml:18: Warning: android:editable is deprecated: Use an <EditText> to make it editable [Deprecated]\n" + - " android:editable=\"true\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/deprecation.xml:26: Warning: android:editable is deprecated: <EditText> is already editable [Deprecated]\n" + - " <EditText android:editable=\"true\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/deprecation.xml:27: Warning: android:editable is deprecated: Use inputType instead [Deprecated]\n" + - " <EditText android:editable=\"false\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "0 errors, 4 warnings\n", - - lintProject( - "apicheck/minsdk1.xml=>AndroidManifest.xml", - "res/layout/deprecation.xml")); - } - - public void testApi4() throws Exception { - assertEquals( - "res/layout/deprecation.xml:2: Warning: AbsoluteLayout is deprecated [Deprecated]\n" + - "<AbsoluteLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" + - "^\n" + - "res/layout/deprecation.xml:16: Warning: android:autoText is deprecated: Use inputType instead [Deprecated]\n" + - " android:autoText=\"true\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/deprecation.xml:17: Warning: android:capitalize is deprecated: Use inputType instead [Deprecated]\n" + - " android:capitalize=\"true\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/deprecation.xml:18: Warning: android:editable is deprecated: Use an <EditText> to make it editable [Deprecated]\n" + - " android:editable=\"true\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/deprecation.xml:20: Warning: android:inputMethod is deprecated: Use inputType instead [Deprecated]\n" + - " android:inputMethod=\"@+id/foo\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/deprecation.xml:21: Warning: android:numeric is deprecated: Use inputType instead [Deprecated]\n" + - " android:numeric=\"true\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/deprecation.xml:22: Warning: android:password is deprecated: Use inputType instead [Deprecated]\n" + - " android:password=\"true\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/deprecation.xml:23: Warning: android:phoneNumber is deprecated: Use inputType instead [Deprecated]\n" + - " android:phoneNumber=\"true\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/deprecation.xml:26: Warning: android:editable is deprecated: <EditText> is already editable [Deprecated]\n" + - " <EditText android:editable=\"true\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/deprecation.xml:27: Warning: android:editable is deprecated: Use inputType instead [Deprecated]\n" + - " <EditText android:editable=\"false\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "0 errors, 10 warnings\n", - - lintProject( - "apicheck/minsdk4.xml=>AndroidManifest.xml", - "res/layout/deprecation.xml")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/DetectMissingPrefixTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/DetectMissingPrefixTest.java deleted file mode 100644 index e8a6f23..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/DetectMissingPrefixTest.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class DetectMissingPrefixTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new DetectMissingPrefix(); - } - - public void test() throws Exception { - assertEquals( - "res/layout/namespace.xml:2: Error: Attribute is missing the Android namespace prefix [MissingPrefix]\n" + - "<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\" xmlns:other=\"http://foo.bar\" android:id=\"@+id/newlinear\" android:orientation=\"vertical\" android:layout_width=\"match_parent\" android:layout_height=\"match_parent\" orientation=\"true\">\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/namespace.xml:3: Error: Attribute is missing the Android namespace prefix [MissingPrefix]\n" + - " <Button style=\"@style/setupWizardOuterFrame\" android.text=\"Button\" android:id=\"@+id/button1\" android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\"></Button>\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/namespace.xml:5: Error: Unexpected namespace prefix \"other\" found for tag LinearLayout [MissingPrefix]\n" + - " <LinearLayout other:orientation=\"horizontal\"/>\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "3 errors, 0 warnings\n", - - lintFiles("res/layout/namespace.xml")); - } - - public void testCustomNamespace() throws Exception { - assertEquals( - "res/layout/namespace2.xml:8: Error: Attribute is missing the Android namespace prefix [MissingPrefix]\n" + - " customprefix:orientation=\"vertical\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~\n" + - "1 errors, 0 warnings\n" + - "", - - lintFiles("res/layout/namespace2.xml")); - } - - public void testManifest() throws Exception { - assertEquals( - "AndroidManifest.xml:4: Error: Attribute is missing the Android namespace prefix [MissingPrefix]\n" + - " versionCode=\"1\"\n" + - " ~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:11: Error: Attribute is missing the Android namespace prefix [MissingPrefix]\n" + - " android.label=\"@string/app_name\" >\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:18: Error: Attribute is missing the Android namespace prefix [MissingPrefix]\n" + - " <category name=\"android.intent.category.LAUNCHER\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "3 errors, 0 warnings\n", - - lintFiles("missingprefix.xml=>AndroidManifest.xml")); - } - - public void testLayoutAttributes() throws Exception { - assertEquals( - "No warnings.", - - lintFiles("res/layout/namespace3.xml")); - } - - public void testLayoutAttributes2() throws Exception { - assertEquals( - "No warnings.", - - lintFiles("res/layout/namespace4.xml")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/DosLineEndingDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/DosLineEndingDetectorTest.java deleted file mode 100644 index 3682420..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/DosLineEndingDetectorTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class DosLineEndingDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new DosLineEndingDetector(); - } - - public void test() throws Exception { - assertEquals( - "res/layout/crcrlf.xml:4: Error: Incorrect line ending: found carriage return (\\r) without corresponding newline (\\n) [MangledCRLF]\n" + - " android:layout_height=\"match_parent\" >\r\n" + - "^\n" + - "1 errors, 0 warnings\n", - lintProject("res/layout/crcrlf.xml")); - } - - public void testIgnore() throws Exception { - assertEquals( - "No warnings.", - lintProject("res/layout/crcrlf_ignore.xml")); - } - - public void testNegative() throws Exception { - // Make sure we don't get warnings for a correct file - assertEquals( - "No warnings.", - lintProject("res/layout/layout1.xml")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/DuplicateIdDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/DuplicateIdDetectorTest.java deleted file mode 100644 index 72a9035..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/DuplicateIdDetectorTest.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class DuplicateIdDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new DuplicateIdDetector(); - } - - public void testDuplicate() throws Exception { - assertEquals( - "res/layout/duplicate.xml:5: Warning: Duplicate id @+id/android_logo, already defined earlier in this layout [DuplicateIds]\n" + - " <ImageButton android:id=\"@+id/android_logo\" android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:src=\"@drawable/android_button\" android:focusable=\"false\" android:clickable=\"false\" android:layout_weight=\"1.0\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - " res/layout/duplicate.xml:4: @+id/android_logo originally defined here\n" + - "0 errors, 1 warnings\n" + - "", - lintFiles("res/layout/duplicate.xml")); - } - - public void testDuplicateChains() throws Exception { - assertEquals( - "res/layout/layout1.xml:7: Warning: Duplicate id @+id/button1, defined or included multiple times in layout/layout1.xml: [layout/layout1.xml defines @+id/button1, layout/layout1.xml => layout/layout2.xml => layout/layout3.xml defines @+id/button1, layout/layout1.xml => layout/layout2.xml => layout/layout4.xml defines @+id/button1] [DuplicateIncludedIds]\n" + - " <include\n" + - " ^\n" + - " res/layout/layout1.xml:13: Defined here\n" + - " res/layout/layout3.xml:8: Defined here, included via layout/layout1.xml => layout/layout2.xml => layout/layout3.xml defines @+id/button1\n" + - " res/layout/layout4.xml:8: Defined here, included via layout/layout1.xml => layout/layout2.xml => layout/layout4.xml defines @+id/button1\n" + - "res/layout/layout1.xml:7: Warning: Duplicate id @+id/button2, defined or included multiple times in layout/layout1.xml: [layout/layout1.xml defines @+id/button2, layout/layout1.xml => layout/layout2.xml => layout/layout4.xml defines @+id/button2] [DuplicateIncludedIds]\n" + - " <include\n" + - " ^\n" + - " res/layout/layout1.xml:19: Defined here\n" + - " res/layout/layout4.xml:14: Defined here, included via layout/layout1.xml => layout/layout2.xml => layout/layout4.xml defines @+id/button2\n" + - "res/layout/layout2.xml:18: Warning: Duplicate id @+id/button1, defined or included multiple times in layout/layout2.xml: [layout/layout2.xml => layout/layout3.xml defines @+id/button1, layout/layout2.xml => layout/layout4.xml defines @+id/button1] [DuplicateIncludedIds]\n" + - " <include\n" + - " ^\n" + - " res/layout/layout3.xml:8: Defined here, included via layout/layout2.xml => layout/layout3.xml defines @+id/button1\n" + - " res/layout/layout4.xml:8: Defined here, included via layout/layout2.xml => layout/layout4.xml defines @+id/button1\n" + - "0 errors, 3 warnings\n" + - "", - - // layout1: defines @+id/button1, button2 - // layout3: defines @+id/button1 - // layout4: defines @+id/button1, button2 - // layout1 include layout2 - // layout2 includes layout3 and layout4 - - // Therefore, layout3 and layout4 have no problems - // In layout2, there's a duplicate definition of button1 (coming from 3 and 4) - // In layout1, there's a duplicate definition of button1 (coming from layout1, 3 and 4) - // In layout1, there'sa duplicate definition of button2 (coming from 1 and 4) - - lintProject("res/layout/layout1.xml", "res/layout/layout2.xml", - "res/layout/layout3.xml", "res/layout/layout4.xml")); - } - - public void testSuppress() throws Exception { - assertEquals( - "res/layout/layout2.xml:18: Warning: Duplicate id @+id/button1, defined or included multiple times in layout/layout2.xml: [layout/layout2.xml => layout/layout3.xml defines @+id/button1, layout/layout2.xml => layout/layout4.xml defines @+id/button1] [DuplicateIncludedIds]\n" + - " <include\n" + - " ^\n" + - " res/layout/layout3.xml:8: Defined here, included via layout/layout2.xml => layout/layout3.xml defines @+id/button1\n" + - " res/layout/layout4.xml:8: Defined here, included via layout/layout2.xml => layout/layout4.xml defines @+id/button1\n" + - "0 errors, 1 warnings\n" + - "", - - lintProject( - "res/layout/layout1_ignore.xml=>res/layout/layout1.xml", - "res/layout/layout2.xml", - "res/layout/layout3.xml", - "res/layout/layout4.xml")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/DuplicateResourceDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/DuplicateResourceDetectorTest.java deleted file mode 100644 index a4a5a68..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/DuplicateResourceDetectorTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class DuplicateResourceDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new DuplicateResourceDetector(); - } - - public void test() throws Exception { - assertEquals( - "res/values/customattr2.xml:2: Error: ContentFrame has already been defined in this folder [DuplicateDefinition]\n" + - " <declare-styleable name=\"ContentFrame\">\n" + - " ~~~~~~~~~~~~~~~~~~~\n" + - " res/values/customattr.xml:2: Previously defined here\n" + - "res/values/strings2.xml:19: Error: wallpaper_instructions has already been defined in this folder [DuplicateDefinition]\n" + - " <string name=\"wallpaper_instructions\">Tap image to set landscape wallpaper</string>\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - " res/values/strings.xml:29: Previously defined here\n" + - "2 errors, 0 warnings\n", - - lintProject( - "res/values/strings.xml", - "res/values-land/strings.xml=>res/values/strings2.xml", - "res/values-cs/strings.xml", - "res/values/customattr.xml", - "res/values/customattr.xml=>res/values/customattr2.xml")); - } - - public void testOk() throws Exception { - assertEquals( - "No warnings.", - - lintProject( - "res/values/strings.xml", - "res/values-cs/strings.xml", - "res/values-de-rDE/strings.xml", - "res/values-es/strings.xml", - "res/values-es-rUS/strings.xml", - "res/values-land/strings.xml", - "res/values-cs/arrays.xml", - "res/values-es/donottranslate.xml", - "res/values-nl-rNL/strings.xml")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/ExtraTextDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/ExtraTextDetectorTest.java deleted file mode 100644 index 9f6c2d3..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/ExtraTextDetectorTest.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class ExtraTextDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new ExtraTextDetector(); - } - - public void testBroken() throws Exception { - assertEquals( - "res/layout/broken.xml:6: Warning: Unexpected text found in layout file: \"ImageButton android:id=\"@+id/android_logo2\" android:layout_width=\"wrap_content\" android:layout_heigh...\" [ExtraText]\n" + - " <Button android:text=\"Button\" android:id=\"@+id/button2\" android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\"></Button>\n" + - " ^\n" + - "0 errors, 1 warnings\n" + - "", - lintProject("res/layout/broken.xml")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/FieldGetterDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/FieldGetterDetectorTest.java deleted file mode 100644 index aa7607f..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/FieldGetterDetectorTest.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class FieldGetterDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new FieldGetterDetector(); - } - - public void test() throws Exception { - assertEquals( - "src/test/bytecode/GetterTest.java:47: Warning: Calling getter method getFoo1() on self is slower than field access (mFoo1) [FieldGetter]\n" + - " getFoo1();\n" + - " ~~~~~~~\n" + - "src/test/bytecode/GetterTest.java:48: Warning: Calling getter method getFoo2() on self is slower than field access (mFoo2) [FieldGetter]\n" + - " getFoo2();\n" + - " ~~~~~~~\n" + - "src/test/bytecode/GetterTest.java:52: Warning: Calling getter method isBar1() on self is slower than field access (mBar1) [FieldGetter]\n" + - " isBar1();\n" + - " ~~~~~~\n" + - "src/test/bytecode/GetterTest.java:54: Warning: Calling getter method getFoo1() on self is slower than field access (mFoo1) [FieldGetter]\n" + - " this.getFoo1();\n" + - " ~~~~~~~\n" + - "src/test/bytecode/GetterTest.java:55: Warning: Calling getter method getFoo2() on self is slower than field access (mFoo2) [FieldGetter]\n" + - " this.getFoo2();\n" + - " ~~~~~~~\n" + - "0 errors, 5 warnings\n" + - "", - - lintProject( - "bytecode/.classpath=>.classpath", - "apicheck/minsdk1.xml=>AndroidManifest.xml", - "bytecode/GetterTest.java.txt=>src/test/bytecode/GetterTest.java", - "bytecode/GetterTest.class.data=>bin/classes/test/bytecode/GetterTest.class" - )); - } - - public void testPostFroyo() throws Exception { - assertEquals( - "No warnings.", - - lintProject( - "bytecode/.classpath=>.classpath", - "apicheck/minsdk10.xml=>AndroidManifest.xml", - "bytecode/GetterTest.java.txt=>src/test/bytecode/GetterTest.java", - "bytecode/GetterTest.class.data=>bin/classes/test/bytecode/GetterTest.class" - )); - } - - public void testLibraries() throws Exception { - // This tests the infrastructure: it makes sure that we *don't* run this - // check in jars that are on the jar library dependency path (testJar() checks - // that it *does* work for local jar classes) - assertEquals( - "No warnings.", - - lintProject( - "bytecode/classpath-lib=>.classpath", - "apicheck/minsdk1.xml=>AndroidManifest.xml", - "bytecode/GetterTest.java.txt=>src/test/bytecode/GetterTest.java", - "bytecode/GetterTest.jar.data=>libs/library.jar" - )); - } - - public void testJar() throws Exception { - assertEquals( - "src/test/bytecode/GetterTest.java:47: Warning: Calling getter method getFoo1() on self is slower than field access (mFoo1) [FieldGetter]\n" + - " getFoo1();\n" + - " ~~~~~~~\n" + - "src/test/bytecode/GetterTest.java:48: Warning: Calling getter method getFoo2() on self is slower than field access (mFoo2) [FieldGetter]\n" + - " getFoo2();\n" + - " ~~~~~~~\n" + - "src/test/bytecode/GetterTest.java:52: Warning: Calling getter method isBar1() on self is slower than field access (mBar1) [FieldGetter]\n" + - " isBar1();\n" + - " ~~~~~~\n" + - "src/test/bytecode/GetterTest.java:54: Warning: Calling getter method getFoo1() on self is slower than field access (mFoo1) [FieldGetter]\n" + - " this.getFoo1();\n" + - " ~~~~~~~\n" + - "src/test/bytecode/GetterTest.java:55: Warning: Calling getter method getFoo2() on self is slower than field access (mFoo2) [FieldGetter]\n" + - " this.getFoo2();\n" + - " ~~~~~~~\n" + - "0 errors, 5 warnings\n" + - "", - - lintProject( - "bytecode/classpath-jar=>.classpath", - "apicheck/minsdk1.xml=>AndroidManifest.xml", - "bytecode/GetterTest.java.txt=>src/test/bytecode/GetterTest.java", - "bytecode/GetterTest.jar.data=>bin/classes.jar" - )); - } - - public void testTruncatedData() throws Exception { - assertEquals( - "No warnings.", - - lintProject( - "bytecode/classpath-jar=>.classpath", - "bytecode/GetterTest.jar.data=>bin/test/pkg/bogus.class" - )); - } - - public void testCornerCases() throws Exception { - assertEquals( - "src/test/pkg/TestFieldGetter.java:21: Warning: Calling getter method getPath() on self is slower than field access (path) [FieldGetter]\n" + - " getPath(); // Should be flagged\n" + - " ~~~~~~~\n" + - "0 errors, 1 warnings\n", - - lintProject( - "bytecode/classpath-jar=>.classpath", - "apicheck/minsdk1.xml=>AndroidManifest.xml", - "bytecode/TestFieldGetter.java.txt=>src/test/pkg/TestFieldGetter.java", - "bytecode/TestFieldGetter.class.data=>bin/classes/test/pkg/TestFieldGetter.class" - )); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/FragmentDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/FragmentDetectorTest.java deleted file mode 100644 index 0654ddc..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/FragmentDetectorTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class FragmentDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new FragmentDetector(); - } - - public void test() throws Exception { - assertEquals( - "src/test/pkg/FragmentTest.java:10: Error: This fragment class should be public (test.pkg.FragmentTest.Fragment1) [ValidFragment]\n" + - " private static class Fragment1 extends Fragment {\n" + - " ^\n" + - "src/test/pkg/FragmentTest.java:15: Error: This fragment inner class should be static (test.pkg.FragmentTest.Fragment2) [ValidFragment]\n" + - " public class Fragment2 extends Fragment {\n" + - " ^\n" + - "src/test/pkg/FragmentTest.java:21: Error: The default constructor must be public [ValidFragment]\n" + - " private Fragment3() {\n" + - " ~~~~~~~~~\n" + - "src/test/pkg/FragmentTest.java:26: Error: This fragment should provide a default constructor (a public constructor with no arguments) (test.pkg.FragmentTest.Fragment4) [ValidFragment]\n" + - " public static class Fragment4 extends Fragment {\n" + - " ~~~~~~~~~\n" + - "src/test/pkg/FragmentTest.java:27: Error: Avoid non-default constructors in fragments: use a default constructor plus Fragment#setArguments(Bundle) instead [ValidFragment]\n" + - " private Fragment4(int dummy) {\n" + - " ~~~~~~~~~\n" + - "src/test/pkg/FragmentTest.java:36: Error: Avoid non-default constructors in fragments: use a default constructor plus Fragment#setArguments(Bundle) instead [ValidFragment]\n" + - " public Fragment5(int dummy) {\n" + - " ~~~~~~~~~\n" + - "6 errors, 0 warnings\n", - - lintProject( - "bytecode/FragmentTest$Fragment1.class.data=>bin/classes/test/pkg/FragmentTest$Fragment1.class", - "bytecode/FragmentTest$Fragment2.class.data=>bin/classes/test/pkg/FragmentTest$Fragment2.class", - "bytecode/FragmentTest$Fragment3.class.data=>bin/classes/test/pkg/FragmentTest$Fragment3.class", - "bytecode/FragmentTest$Fragment4.class.data=>bin/classes/test/pkg/FragmentTest$Fragment4.class", - "bytecode/FragmentTest$Fragment5.class.data=>bin/classes/test/pkg/FragmentTest$Fragment5.class", - "bytecode/FragmentTest$Fragment6.class.data=>bin/classes/test/pkg/FragmentTest$Fragment6.class", - "bytecode/FragmentTest$NotAFragment.class.data=>bin/classes/test/pkg/FragmentTest$NotAFragment.class", - "bytecode/FragmentTest.java.txt=>src/test/pkg/FragmentTest.java")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/GridLayoutDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/GridLayoutDetectorTest.java deleted file mode 100644 index dee52e1..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/GridLayoutDetectorTest.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class GridLayoutDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new GridLayoutDetector(); - } - - public void testGridLayout1() throws Exception { - assertEquals( - "res/layout/gridlayout.xml:36: Error: Column attribute (3) exceeds declared grid column count (2) [GridLayout]\n" + - " android:layout_column=\"3\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "1 errors, 0 warnings\n" + - "", - lintFiles("res/layout/gridlayout.xml")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/HandlerDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/HandlerDetectorTest.java deleted file mode 100644 index 1e9350c..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/HandlerDetectorTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class HandlerDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new HandlerDetector(); - } - - public void testRegistered() throws Exception { - assertEquals( - "src/test/pkg/HandlerTest.java:12: Warning: This Handler class should be static or leaks might occur (test.pkg.HandlerTest.Inner) [HandlerLeak]\n" + - " public class Inner extends Handler { // ERROR\n" + - " ~~~~~\n" + - "src/test/pkg/HandlerTest.java:18: Warning: This Handler class should be static or leaks might occur (test.pkg.HandlerTest.1) [HandlerLeak]\n" + - " Handler anonymous = new Handler() { // ERROR\n" + - " ~~~~~~~\n" + - "0 errors, 2 warnings\n" + - "", - - lintProject( - "bytecode/HandlerTest.java.txt=>src/test/pkg/HandlerTest.java", - "bytecode/HandlerTest.class.data=>bin/classes/test/pkg/HandlerTest.class", - "bytecode/HandlerTest$Inner.class.data=>bin/classes/test/pkg/HandlerTest$Inner.class", - "bytecode/HandlerTest$StaticInner.class.data=>bin/classes/test/pkg/HandlerTest$StaticInner.class", - "bytecode/HandlerTest$1.class.data=>bin/classes/test/pkg/HandlerTest$1.class")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/HardcodedDebugModeDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/HardcodedDebugModeDetectorTest.java deleted file mode 100644 index edb6c50..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/HardcodedDebugModeDetectorTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class HardcodedDebugModeDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new HardcodedDebugModeDetector(); - } - - public void test() throws Exception { - assertEquals( - "AndroidManifest.xml:10: Warning: Avoid hardcoding the debug mode; leaving it out allows debug and release builds to automatically assign one [HardcodedDebugMode]\n" + - " android:debuggable=\"true\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "0 errors, 1 warnings\n" + - "", - lintProject("debuggable.xml=>AndroidManifest.xml")); - } - - public void testOk() throws Exception { - assertEquals( - "No warnings.", - lintProject("AndroidManifest.xml")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/HardcodedValuesDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/HardcodedValuesDetectorTest.java deleted file mode 100644 index b326fd4..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/HardcodedValuesDetectorTest.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class HardcodedValuesDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new HardcodedValuesDetector(); - } - - public void testStrings() throws Exception { - assertEquals( - "res/layout/accessibility.xml:3: Warning: [I18N] Hardcoded string \"Button\", should use @string resource [HardcodedText]\n" + - " <Button android:text=\"Button\" android:id=\"@+id/button1\" android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\"></Button>\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/accessibility.xml:6: Warning: [I18N] Hardcoded string \"Button\", should use @string resource [HardcodedText]\n" + - " <Button android:text=\"Button\" android:id=\"@+id/button2\" android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\"></Button>\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "0 errors, 2 warnings\n", - - lintFiles("res/layout/accessibility.xml")); - } - - public void testMenus() throws Exception { - assertEquals( - "res/menu/menu.xml:7: Warning: [I18N] Hardcoded string \"My title 1\", should use @string resource [HardcodedText]\n" + - " android:title=\"My title 1\">\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/menu/menu.xml:13: Warning: [I18N] Hardcoded string \"My title 2\", should use @string resource [HardcodedText]\n" + - " android:title=\"My title 2\">\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "0 errors, 2 warnings\n", - - lintFiles("res/menu/menu.xml")); - } - - public void testMenusOk() throws Exception { - assertEquals( - "No warnings.", - lintFiles("res/menu/titles.xml")); - } - - public void testSuppress() throws Exception { - // All but one errors in the file contain ignore attributes - direct, inherited - // and lists - assertEquals( - "res/layout/ignores.xml:61: Warning: [I18N] Hardcoded string \"Hardcoded\", should use @string resource [HardcodedText]\n" + - " android:text=\"Hardcoded\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "0 errors, 1 warnings\n" + - "", - - lintFiles("res/layout/ignores.xml")); - } - -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/IconDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/IconDetectorTest.java deleted file mode 100644 index 7cbbdc5..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/IconDetectorTest.java +++ /dev/null @@ -1,461 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.annotations.NonNull; -import com.android.tools.lint.client.api.LintClient; -import com.android.tools.lint.client.api.LintDriver; -import com.android.tools.lint.detector.api.Detector; -import com.android.tools.lint.detector.api.Issue; -import com.android.tools.lint.detector.api.Project; - -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; - -@SuppressWarnings("javadoc") -public class IconDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new IconDetector(); - } - - private Set<Issue> mEnabled = new HashSet<Issue>(); - private boolean mAbbreviate; - - private static Set<Issue> ALL = new HashSet<Issue>(); - static { - ALL.add(IconDetector.DUPLICATES_CONFIGURATIONS); - ALL.add(IconDetector.DUPLICATES_NAMES); - ALL.add(IconDetector.GIF_USAGE); - ALL.add(IconDetector.ICON_DENSITIES); - ALL.add(IconDetector.ICON_DIP_SIZE); - ALL.add(IconDetector.ICON_EXTENSION); - ALL.add(IconDetector.ICON_LOCATION); - ALL.add(IconDetector.ICON_MISSING_FOLDER); - ALL.add(IconDetector.ICON_NODPI); - ALL.add(IconDetector.ICON_COLORS); - ALL.add(IconDetector.ICON_XML_AND_PNG); - ALL.add(IconDetector.ICON_LAUNCHER_SHAPE); - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - mAbbreviate = true; - } - - @Override - protected void configureDriver(LintDriver driver) { - driver.setAbbreviating(mAbbreviate); - } - - @Override - protected TestConfiguration getConfiguration(LintClient client, Project project) { - return new TestConfiguration(client, project, null) { - @Override - public boolean isEnabled(@NonNull Issue issue) { - return super.isEnabled(issue) && mEnabled.contains(issue); - } - }; - } - - public void test() throws Exception { - mEnabled = ALL; - assertEquals( - "res/drawable-mdpi/sample_icon.gif: Warning: Using the .gif format for bitmaps is discouraged [GifUsage]\n" + - "res/drawable/ic_launcher.png: Warning: The ic_launcher.png icon has identical contents in the following configuration folders: drawable-mdpi, drawable [IconDuplicatesConfig]\n" + - " res/drawable-mdpi/ic_launcher.png: <No location-specific message\n" + - "res/drawable/ic_launcher.png: Warning: Found bitmap drawable res/drawable/ic_launcher.png in densityless folder [IconLocation]\n" + - "res/drawable-hdpi: Warning: Missing the following drawables in drawable-hdpi: sample_icon.gif (found in drawable-mdpi) [IconDensities]\n" + - "res: Warning: Missing density variation folders in res: drawable-xhdpi [IconMissingDensityFolder]\n" + - "0 errors, 5 warnings\n" + - "", - - lintProject( - // Use minSDK4 to ensure that we get warnings about missing drawables - "apicheck/minsdk4.xml=>AndroidManifest.xml", - "res/drawable/ic_launcher.png", - "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher.png", - "res/drawable-mdpi/sample_icon.gif", - // Make a dummy file named .svn to make sure it doesn't get seen as - // an icon name - "res/drawable-mdpi/sample_icon.gif=>res/drawable-hdpi/.svn", - "res/drawable-hdpi/ic_launcher.png")); - } - - public void testMixed() throws Exception { - mEnabled = Collections.singleton(IconDetector.ICON_XML_AND_PNG); - assertEquals( - "res/drawable/background.xml: Warning: The following images appear both as density independent .xml files and as bitmap files: res/drawable-mdpi/background.png, res/drawable/background.xml [IconXmlAndPng]\n" + - " res/drawable-mdpi/background.png: <No location-specific message\n" + - "0 errors, 1 warnings\n", - - lintProject( - "apicheck/minsdk4.xml=>AndroidManifest.xml", - "apicheck/minsdk4.xml=>res/drawable/background.xml", - "res/drawable/ic_launcher.png=>res/drawable-mdpi/background.png")); - } - - public void testApi1() throws Exception { - mEnabled = ALL; - assertEquals( - "No warnings.", - - lintProject( - // manifest file which specifies uses sdk = 2 - "apicheck/minsdk2.xml=>AndroidManifest.xml", - "res/drawable/ic_launcher.png")); - } - - public void test2() throws Exception { - mEnabled = ALL; - assertEquals( - "res/drawable-hdpi/other.9.png: Warning: The following unrelated icon files have identical contents: appwidget_bg.9.png, other.9.png [IconDuplicates]\n" + - " res/drawable-hdpi/appwidget_bg.9.png: <No location-specific message\n" + - "res/drawable-hdpi/unrelated.png: Warning: The following unrelated icon files have identical contents: ic_launcher.png, unrelated.png [IconDuplicates]\n" + - " res/drawable-hdpi/ic_launcher.png: <No location-specific message\n" + - "res: Warning: Missing density variation folders in res: drawable-mdpi, drawable-xhdpi [IconMissingDensityFolder]\n" + - "0 errors, 3 warnings\n" + - "", - - lintProject( - "res/drawable-hdpi/unrelated.png", - "res/drawable-hdpi/appwidget_bg.9.png", - "res/drawable-hdpi/appwidget_bg_focus.9.png", - "res/drawable-hdpi/other.9.png", - "res/drawable-hdpi/ic_launcher.png" - )); - } - - public void testNoDpi() throws Exception { - mEnabled = ALL; - assertEquals( - "res/drawable-mdpi/frame.png: Warning: The following images appear in both -nodpi and in a density folder: frame.png [IconNoDpi]\n" + - "res/drawable-xlarge-nodpi-v11/frame.png: Warning: The frame.png icon has identical contents in the following configuration folders: drawable-mdpi, drawable-nodpi, drawable-xlarge-nodpi-v11 [IconDuplicatesConfig]\n" + - " res/drawable-nodpi/frame.png: <No location-specific message\n" + - " res/drawable-mdpi/frame.png: <No location-specific message\n" + - "res: Warning: Missing density variation folders in res: drawable-hdpi, drawable-xhdpi [IconMissingDensityFolder]\n" + - "0 errors, 3 warnings\n" + - "", - - lintProject( - "res/drawable-mdpi/frame.png", - "res/drawable-nodpi/frame.png", - "res/drawable-xlarge-nodpi-v11/frame.png")); - } - - public void testNoDpi2() throws Exception { - mEnabled = ALL; - // Having additional icon names in the no-dpi folder should not cause any complaints - assertEquals( - "res/drawable-xhdpi/frame.png: Warning: The image frame.png varies significantly in its density-independent (dip) size across the various density versions: drawable-ldpi/frame.png: 629x387 dp (472x290 px), drawable-mdpi/frame.png: 472x290 dp (472x290 px), drawable-hdpi/frame.png: 315x193 dp (472x290 px), drawable-xhdpi/frame.png: 236x145 dp (472x290 px) [IconDipSize]\n" + - " res/drawable-hdpi/frame.png: <No location-specific message\n" + - " res/drawable-mdpi/frame.png: <No location-specific message\n" + - " res/drawable-ldpi/frame.png: <No location-specific message\n" + - "res/drawable-xhdpi/frame.png: Warning: The following unrelated icon files have identical contents: frame.png, frame.png, frame.png, file1.png, file2.png, frame.png [IconDuplicates]\n" + - " res/drawable-nodpi/file2.png: <No location-specific message\n" + - " res/drawable-nodpi/file1.png: <No location-specific message\n" + - " res/drawable-mdpi/frame.png: <No location-specific message\n" + - " res/drawable-ldpi/frame.png: <No location-specific message\n" + - " res/drawable-hdpi/frame.png: <No location-specific message\n" + - "0 errors, 2 warnings\n" + - "", - - lintProject( - "res/drawable-mdpi/frame.png=>res/drawable-mdpi/frame.png", - "res/drawable-mdpi/frame.png=>res/drawable-hdpi/frame.png", - "res/drawable-mdpi/frame.png=>res/drawable-ldpi/frame.png", - "res/drawable-mdpi/frame.png=>res/drawable-xhdpi/frame.png", - "res/drawable-mdpi/frame.png=>res/drawable-nodpi/file1.png", - "res/drawable-mdpi/frame.png=>res/drawable-nodpi/file2.png")); - } - - public void testNoDpiMix() throws Exception { - mEnabled = ALL; - assertEquals( - "res/drawable-mdpi/frame.xml: Warning: The following images appear in both -nodpi and in a density folder: frame.png, frame.xml [IconNoDpi]\n" + - " res/drawable-mdpi/frame.png: <No location-specific message\n" + - "res/drawable-nodpi/frame.xml: Warning: The following images appear both as density independent .xml files and as bitmap files: res/drawable-mdpi/frame.png, res/drawable-nodpi/frame.xml [IconXmlAndPng]\n" + - " res/drawable-mdpi/frame.png: <No location-specific message\n" + - "res: Warning: Missing density variation folders in res: drawable-hdpi, drawable-xhdpi [IconMissingDensityFolder]\n" + - "0 errors, 3 warnings\n", - - lintProject( - "res/drawable-mdpi/frame.png", - "res/drawable/states.xml=>res/drawable-nodpi/frame.xml")); - } - - - public void testMixedFormat() throws Exception { - mEnabled = ALL; - // Test having a mixture of .xml and .png resources for the same name - // Make sure we don't get: - // drawable-hdpi: Warning: Missing the following drawables in drawable-hdpi: f.png (found in drawable-mdpi) - // drawable-xhdpi: Warning: Missing the following drawables in drawable-xhdpi: f.png (found in drawable-mdpi) - assertEquals( - "res/drawable-xhdpi/f.xml: Warning: The following images appear both as density independent .xml files and as bitmap files: res/drawable-hdpi/f.xml, res/drawable-mdpi/f.png [IconXmlAndPng]\n" + - " res/drawable-mdpi/f.png: <No location-specific message\n" + - " res/drawable-hdpi/f.xml: <No location-specific message\n" + - "0 errors, 1 warnings\n", - - lintProject( - "res/drawable-mdpi/frame.png=>res/drawable-mdpi/f.png", - "res/drawable/states.xml=>res/drawable-hdpi/f.xml", - "res/drawable/states.xml=>res/drawable-xhdpi/f.xml")); - } - - public void testMisleadingFileName() throws Exception { - mEnabled = Collections.singleton(IconDetector.ICON_EXTENSION); - assertEquals( - "res/drawable-mdpi/frame.gif: Warning: Misleading file extension; named .gif but the file format is png [IconExtension]\n" + - "res/drawable-mdpi/frame.jpg: Warning: Misleading file extension; named .jpg but the file format is png [IconExtension]\n" + - "res/drawable-mdpi/myjpg.png: Warning: Misleading file extension; named .png but the file format is JPEG [IconExtension]\n" + - "res/drawable-mdpi/sample_icon.jpeg: Warning: Misleading file extension; named .jpeg but the file format is gif [IconExtension]\n" + - "res/drawable-mdpi/sample_icon.jpg: Warning: Misleading file extension; named .jpg but the file format is gif [IconExtension]\n" + - "res/drawable-mdpi/sample_icon.png: Warning: Misleading file extension; named .png but the file format is gif [IconExtension]\n" + - "0 errors, 6 warnings\n", - - lintProject( - "res/drawable-mdpi/sample_icon.jpg=>res/drawable-mdpi/myjpg.jpg", // VALID - "res/drawable-mdpi/sample_icon.jpg=>res/drawable-mdpi/myjpg.jpeg", // VALID - "res/drawable-mdpi/frame.png=>res/drawable-mdpi/frame.gif", - "res/drawable-mdpi/frame.png=>res/drawable-mdpi/frame.jpg", - "res/drawable-mdpi/sample_icon.jpg=>res/drawable-mdpi/myjpg.png", - "res/drawable-mdpi/sample_icon.gif=>res/drawable-mdpi/sample_icon.jpg", - "res/drawable-mdpi/sample_icon.gif=>res/drawable-mdpi/sample_icon.jpeg", - "res/drawable-mdpi/sample_icon.gif=>res/drawable-mdpi/sample_icon.png")); - } - - public void testColors() throws Exception { - mEnabled = Collections.singleton(IconDetector.ICON_COLORS); - assertEquals( - "res/drawable-mdpi/ic_menu_my_action.png: Warning: Action Bar icons should use a single gray color (#333333 for light themes (with 60%/30% opacity for enabled/disabled), and #FFFFFF with opacity 80%/30% for dark themes [IconColors]\n" + - "res/drawable-mdpi-v11/ic_stat_my_notification.png: Warning: Notification icons must be entirely white [IconColors]\n" + - "res/drawable-mdpi-v9/ic_stat_my_notification2.png: Warning: Notification icons must be entirely white [IconColors]\n" + - "0 errors, 3 warnings\n", - - lintProject( - "apicheck/minsdk14.xml=>AndroidManifest.xml", - "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_menu_my_action.png", - "res/drawable/ic_launcher.png=>res/drawable-mdpi-v11/ic_stat_my_notification.png", - "res/drawable/ic_launcher.png=>res/drawable-mdpi-v9/ic_stat_my_notification2.png", - "res/drawable-mdpi/ic_menu_add_clip_normal.png")); // OK - } - - public void testNotActionBarIcons() throws Exception { - mEnabled = Collections.singleton(IconDetector.ICON_COLORS); - assertEquals( - "No warnings.", - - // No Java code designates the menu as an action bar menu - lintProject( - "apicheck/minsdk14.xml=>AndroidManifest.xml", - "res/menu/menu.xml", - "res/drawable/ic_launcher.png=>res/drawable-mdpi/icon1.png", - "res/drawable/ic_launcher.png=>res/drawable-mdpi/icon2.png", - "res/drawable/ic_launcher.png=>res/drawable-mdpi/icon3.png", // Not action bar - "res/drawable-mdpi/ic_menu_add_clip_normal.png")); // OK - } - - public void testActionBarIcons() throws Exception { - mEnabled = Collections.singleton(IconDetector.ICON_COLORS); - assertEquals( - "res/drawable-mdpi/icon1.png: Warning: Action Bar icons should use a single gray color (#333333 for light themes (with 60%/30% opacity for enabled/disabled), and #FFFFFF with opacity 80%/30% for dark themes [IconColors]\n" + - "res/drawable-mdpi/icon2.png: Warning: Action Bar icons should use a single gray color (#333333 for light themes (with 60%/30% opacity for enabled/disabled), and #FFFFFF with opacity 80%/30% for dark themes [IconColors]\n" + - "0 errors, 2 warnings\n", - - lintProject( - "apicheck/minsdk14.xml=>AndroidManifest.xml", - "res/menu/menu.xml", - "src/test/pkg/ActionBarTest.java.txt=>src/test/pkg/ActionBarTest.java", - "res/drawable/ic_launcher.png=>res/drawable-mdpi/icon1.png", - "res/drawable/ic_launcher.png=>res/drawable-mdpi/icon2.png", - "res/drawable/ic_launcher.png=>res/drawable-mdpi/icon3.png", // Not action bar - "res/drawable-mdpi/ic_menu_add_clip_normal.png")); // OK - } - - public void testOkActionBarIcons() throws Exception { - mEnabled = Collections.singleton(IconDetector.ICON_COLORS); - assertEquals( - "No warnings.", - - lintProject( - "apicheck/minsdk14.xml=>AndroidManifest.xml", - "res/menu/menu.xml", - "res/drawable-mdpi/ic_menu_add_clip_normal.png=>res/drawable-mdpi/icon1.png", - "res/drawable-mdpi/ic_menu_add_clip_normal.png=>res/drawable-mdpi/icon2.png")); - } - - public void testNotificationIcons() throws Exception { - mEnabled = Collections.singleton(IconDetector.ICON_COLORS); - assertEquals( - "res/drawable-mdpi/icon1.png: Warning: Notification icons must be entirely white [IconColors]\n" + - "res/drawable-mdpi/icon2.png: Warning: Notification icons must be entirely white [IconColors]\n" + - "res/drawable-mdpi/icon3.png: Warning: Notification icons must be entirely white [IconColors]\n" + - "res/drawable-mdpi/icon4.png: Warning: Notification icons must be entirely white [IconColors]\n" + - "res/drawable-mdpi/icon5.png: Warning: Notification icons must be entirely white [IconColors]\n" + - "0 errors, 5 warnings\n", - - lintProject( - "apicheck/minsdk14.xml=>AndroidManifest.xml", - "src/test/pkg/NotificationTest.java.txt=>src/test/pkg/NotificationTest.java", - "res/drawable/ic_launcher.png=>res/drawable-mdpi/icon1.png", - "res/drawable/ic_launcher.png=>res/drawable-mdpi/icon2.png", - "res/drawable/ic_launcher.png=>res/drawable-mdpi/icon3.png", - "res/drawable/ic_launcher.png=>res/drawable-mdpi/icon4.png", - "res/drawable/ic_launcher.png=>res/drawable-mdpi/icon5.png", - "res/drawable/ic_launcher.png=>res/drawable-mdpi/icon6.png", // not a notification - "res/drawable/ic_launcher.png=>res/drawable-mdpi/icon7.png", // ditto - "res/drawable-mdpi/ic_menu_add_clip_normal.png")); // OK - } - - public void testOkNotificationIcons() throws Exception { - mEnabled = Collections.singleton(IconDetector.ICON_COLORS); - assertEquals( - "No warnings.", - - lintProject( - "apicheck/minsdk14.xml=>AndroidManifest.xml", - "src/test/pkg/NotificationTest.java.txt=>src/test/pkg/NotificationTest.java", - "res/drawable-mdpi/ic_menu_add_clip_normal.png=>res/drawable-mdpi/icon1.png", - "res/drawable-mdpi/ic_menu_add_clip_normal.png=>res/drawable-mdpi/icon2.png", - "res/drawable-mdpi/ic_menu_add_clip_normal.png=>res/drawable-mdpi/icon3.png", - "res/drawable-mdpi/ic_menu_add_clip_normal.png=>res/drawable-mdpi/icon4.png", - "res/drawable-mdpi/ic_menu_add_clip_normal.png=>res/drawable-mdpi/icon5.png")); - } - - public void testExpectedSize() throws Exception { - mEnabled = Collections.singleton(IconDetector.ICON_EXPECTED_SIZE); - assertEquals( - "res/drawable-mdpi/ic_launcher.png: Warning: Incorrect icon size for drawable-mdpi/ic_launcher.png: expected 48x48, but was 24x24 [IconExpectedSize]\n" + - "res/drawable-mdpi/icon1.png: Warning: Incorrect icon size for drawable-mdpi/icon1.png: expected 32x32, but was 48x48 [IconExpectedSize]\n" + - "res/drawable-mdpi/icon3.png: Warning: Incorrect icon size for drawable-mdpi/icon3.png: expected 24x24, but was 48x48 [IconExpectedSize]\n" + - "0 errors, 3 warnings\n", - - lintProject( - "apicheck/minsdk14.xml=>AndroidManifest.xml", - "src/test/pkg/NotificationTest.java.txt=>src/test/pkg/NotificationTest.java", - "res/menu/menu.xml", - "src/test/pkg/ActionBarTest.java.txt=>src/test/pkg/ActionBarTest.java", - - // 3 wrong-sized icons: - "res/drawable/ic_launcher.png=>res/drawable-mdpi/icon1.png", - "res/drawable/ic_launcher.png=>res/drawable-mdpi/icon3.png", - "res/drawable-mdpi/stat_notify_alarm.png=>res/drawable-mdpi/ic_launcher.png", - - // OK sizes - "res/drawable-mdpi/ic_menu_add_clip_normal.png=>res/drawable-mdpi/icon2.png", - "res/drawable-mdpi/stat_notify_alarm.png=>res/drawable-mdpi/icon4.png", - "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher2.png" - )); - } - - public void testAbbreviate() throws Exception { - mEnabled = Collections.singleton(IconDetector.ICON_DENSITIES); - assertEquals( - "res/drawable-hdpi: Warning: Missing the following drawables in drawable-hdpi: " + - "ic_launcher10.png, ic_launcher11.png, ic_launcher12.png, ic_launcher2.png, " + - "ic_launcher3.png... (6 more) [IconDensities]\n" + - "res/drawable-xhdpi: Warning: Missing the following drawables in drawable-xhdpi: " + - "ic_launcher10.png, ic_launcher11.png, ic_launcher12.png, ic_launcher2.png, " + - "ic_launcher3.png... (6 more) [IconDensities]\n" + - "0 errors, 2 warnings\n", - - lintProject( - // Use minSDK4 to ensure that we get warnings about missing drawables - "apicheck/minsdk4.xml=>AndroidManifest.xml", - "res/drawable/ic_launcher.png=>res/drawable-hdpi/ic_launcher1.png", - "res/drawable/ic_launcher.png=>res/drawable-xhdpi/ic_launcher1.png", - "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher1.png", - "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher2.png", - "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher3.png", - "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher4.png", - "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher5.png", - "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher6.png", - "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher7.png", - "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher8.png", - "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher9.png", - "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher10.png", - "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher11.png", - "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher12.png" - )); - } - - - public void testShowAll() throws Exception { - mEnabled = Collections.singleton(IconDetector.ICON_DENSITIES); - mAbbreviate = false; - assertEquals( - "res/drawable-hdpi: Warning: Missing the following drawables in drawable-hdpi: " + - "ic_launcher10.png, ic_launcher11.png, ic_launcher12.png, ic_launcher2.png, " + - "ic_launcher3.png, ic_launcher4.png, ic_launcher5.png, ic_launcher6.png, " + - "ic_launcher7.png, ic_launcher8.png, ic_launcher9.png [IconDensities]\n" + - "res/drawable-xhdpi: Warning: Missing the following drawables in drawable-xhdpi: " + - "ic_launcher10.png, ic_launcher11.png, ic_launcher12.png, ic_launcher2.png," + - " ic_launcher3.png, ic_launcher4.png, ic_launcher5.png, ic_launcher6.png, " + - "ic_launcher7.png, ic_launcher8.png, ic_launcher9.png [IconDensities]\n" + - "0 errors, 2 warnings\n", - - lintProject( - // Use minSDK4 to ensure that we get warnings about missing drawables - "apicheck/minsdk4.xml=>AndroidManifest.xml", - "res/drawable/ic_launcher.png=>res/drawable-hdpi/ic_launcher1.png", - "res/drawable/ic_launcher.png=>res/drawable-xhdpi/ic_launcher1.png", - "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher1.png", - "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher2.png", - "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher3.png", - "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher4.png", - "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher5.png", - "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher6.png", - "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher7.png", - "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher8.png", - "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher9.png", - "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher10.png", - "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher11.png", - "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher12.png" - )); - } - - public void testIgnoreMissingFolders() throws Exception { - mEnabled = Collections.singleton(IconDetector.ICON_DENSITIES); - assertEquals( - "No warnings.", - - lintProject( - // Use minSDK4 to ensure that we get warnings about missing drawables - "apicheck/minsdk4.xml=>AndroidManifest.xml", - "ignoremissing.xml=>lint.xml", - "res/drawable/ic_launcher.png=>res/drawable-hdpi/ic_launcher1.png", - "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher1.png", - "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher2.png" - )); - } - - public void testSquareLauncher() throws Exception { - mEnabled = Collections.singleton(IconDetector.ICON_LAUNCHER_SHAPE); - assertEquals( - "res/drawable-hdpi/ic_launcher_filled.png: Warning: Launcher icons should not fill every pixel of their square region; see the design guide for details [IconLauncherShape]\n" + - "0 errors, 1 warnings\n", - - lintProject( - "apicheck/minsdk4.xml=>AndroidManifest.xml", - "res/drawable-hdpi/filled.png=>res/drawable-hdpi/ic_launcher_filled.png", - "res/drawable-mdpi/sample_icon.gif=>res/drawable-mdpi/ic_launcher_2.gif" - )); - } -}
\ No newline at end of file diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/InefficientWeightDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/InefficientWeightDetectorTest.java deleted file mode 100644 index c642ab1..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/InefficientWeightDetectorTest.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class InefficientWeightDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new InefficientWeightDetector(); - } - - public void testWeights() throws Exception { - assertEquals( - "res/layout/inefficient_weight.xml:3: Error: Wrong orientation? No orientation specified, and the default is horizontal, yet this layout has multiple children where at least one has layout_width=\"match_parent\" [Orientation]\n" + - "<LinearLayout\n" + - "^\n" + - "res/layout/inefficient_weight.xml:10: Warning: Use a layout_width of 0dip instead of match_parent for better performance [InefficientWeight]\n" + - " android:layout_width=\"match_parent\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/inefficient_weight.xml:24: Warning: Use a layout_height of 0dip instead of wrap_content for better performance [InefficientWeight]\n" + - " android:layout_height=\"wrap_content\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "1 errors, 2 warnings\n", - lintFiles("res/layout/inefficient_weight.xml")); - } - - public void testWeights2() throws Exception { - assertEquals( - "res/layout/nested_weights.xml:23: Warning: Nested weights are bad for performance [NestedWeights]\n" + - " android:layout_weight=\"1\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "0 errors, 1 warnings\n" + - "", - lintFiles("res/layout/nested_weights.xml")); - } - - public void testWeights3() throws Exception { - assertEquals( - "res/layout/baseline_weights.xml:2: Warning: Set android:baselineAligned=\"false\" on this element for better performance [DisableBaselineAlignment]\n" + - "<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" + - "^\n" + - "0 errors, 1 warnings\n" + - "", - lintFiles("res/layout/baseline_weights.xml")); - } - - public void testWeights4() throws Exception { - assertEquals( - "res/layout/activity_item_two_pane.xml:1: Warning: Set android:baselineAligned=\"false\" on this element for better performance [DisableBaselineAlignment]\n" + - "<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" + - "^\n" + - "0 errors, 1 warnings\n", - lintFiles("res/layout/activity_item_two_pane.xml")); - } - - public void testNoVerticalWeights3() throws Exception { - // Orientation=vertical - assertEquals( - "No warnings.", - lintFiles("res/layout/baseline_weights2.xml")); - } - - public void testNoVerticalWeights4() throws Exception { - // Orientation not specified ==> horizontal - assertEquals( - "res/layout/baseline_weights3.xml:2: Warning: Set android:baselineAligned=\"false\" on this element for better performance [DisableBaselineAlignment]\n" + - "<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" + - "^\n" + - "0 errors, 1 warnings\n" + - "", - lintFiles("res/layout/baseline_weights3.xml")); - } - - public void testSuppressed() throws Exception { - assertEquals( - "No warnings.", - - lintFiles("res/layout/inefficient_weight2.xml")); - } - - public void testNestedWeights() throws Exception { - // Regression test for http://code.google.com/p/android/issues/detail?id=22889 - // (Comment 8) - assertEquals( - "No warnings.", - - lintFiles("res/layout/nested_weights2.xml")); - } - - public void testWrong0Dp() throws Exception { - assertEquals( - "res/layout/wrong0dp.xml:19: Error: Suspicious size: this will make the view invisible, should be used with layout_weight [Suspicious0dp]\n" + - " android:layout_width=\"0dp\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/wrong0dp.xml:25: Error: Suspicious size: this will make the view invisible, should be used with layout_weight [Suspicious0dp]\n" + - " android:layout_height=\"0dp\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/wrong0dp.xml:34: Error: Suspicious size: this will make the view invisible, probably intended for layout_height [Suspicious0dp]\n" + - " android:layout_width=\"0dp\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/wrong0dp.xml:67: Error: Suspicious size: this will make the view invisible, probably intended for layout_width [Suspicious0dp]\n" + - " android:layout_height=\"0dp\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/wrong0dp.xml:90: Error: Suspicious size: this will make the view invisible, probably intended for layout_width [Suspicious0dp]\n" + - " android:layout_height=\"0dp\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "5 errors, 0 warnings\n", - - lintFiles("res/layout/wrong0dp.xml")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/InvalidPackageDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/InvalidPackageDetectorTest.java deleted file mode 100644 index b634255..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/InvalidPackageDetectorTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class InvalidPackageDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new InvalidPackageDetector(); - } - - public void testUnsupportedJavaLibraryCode() throws Exception { - // See http://code.google.com/p/android/issues/detail?id=39109 - assertEquals( - "libs/unsupported.jar: Error: Invalid package reference in library; not included in Android: java.awt. Referenced from test.pkg.LibraryClass. [InvalidPackage]\n" + - "libs/unsupported.jar: Error: Invalid package reference in library; not included in Android: javax.swing. Referenced from test.pkg.LibraryClass. [InvalidPackage]\n" + - "2 errors, 0 warnings\n", - - lintProject( - "apicheck/minsdk14.xml=>AndroidManifest.xml", - "apicheck/layout.xml=>res/layout/layout.xml", - "apicheck/themes.xml=>res/values/themes.xml", - "apicheck/themes.xml=>res/color/colors.xml", - "apicheck/unsupported.jar.data=>libs/unsupported.jar" - )); - } - - public void testOk() throws Exception { - assertEquals( - "No warnings.", - - lintProject( - "apicheck/classpath=>.classpath", - "apicheck/minsdk2.xml=>AndroidManifest.xml", - "apicheck/ApiCallTest.class.data=>bin/classes/foo/bar/ApiCallTest.class", - "bytecode/GetterTest.jar.data=>libs/GetterTest.jar", - "bytecode/classes.jar=>libs/classes.jar" - )); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/JavaPerformanceDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/JavaPerformanceDetectorTest.java deleted file mode 100644 index 5d47c5c..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/JavaPerformanceDetectorTest.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class JavaPerformanceDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new JavaPerformanceDetector(); - } - - public void test() throws Exception { - boolean isInAospEnvironment = System.getenv("ANDROID_BUILD_TOP") != null; - assertEquals( - "src/test/pkg/JavaPerformanceTest.java:28: Warning: Avoid object allocations during draw/layout operations (preallocate and reuse instead) [DrawAllocation]\n" + - " new String(\"foo\");\n" + - " ~~~~~~~~~~~~~~~~~\n" + - "src/test/pkg/JavaPerformanceTest.java:29: Warning: Avoid object allocations during draw/layout operations (preallocate and reuse instead) [DrawAllocation]\n" + - " String s = new String(\"bar\");\n" + - " ~~~~~~~~~~~~~~~~~\n" + - "src/test/pkg/JavaPerformanceTest.java:103: Warning: Avoid object allocations during draw/layout operations (preallocate and reuse instead) [DrawAllocation]\n" + - " new String(\"flag me\");\n" + - " ~~~~~~~~~~~~~~~~~~~~~\n" + - "src/test/pkg/JavaPerformanceTest.java:109: Warning: Avoid object allocations during draw/layout operations (preallocate and reuse instead) [DrawAllocation]\n" + - " new String(\"flag me\");\n" + - " ~~~~~~~~~~~~~~~~~~~~~\n" + - "src/test/pkg/JavaPerformanceTest.java:112: Warning: Avoid object allocations during draw/layout operations (preallocate and reuse instead) [DrawAllocation]\n" + - " Bitmap.createBitmap(100, 100, null);\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "src/test/pkg/JavaPerformanceTest.java:113: Warning: Avoid object allocations during draw/layout operations (preallocate and reuse instead) [DrawAllocation]\n" + - " android.graphics.Bitmap.createScaledBitmap(null, 100, 100, false);\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "src/test/pkg/JavaPerformanceTest.java:114: Warning: Avoid object allocations during draw/layout operations (preallocate and reuse instead) [DrawAllocation]\n" + - " BitmapFactory.decodeFile(null);\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "src/test/pkg/JavaPerformanceTest.java:116: Warning: Avoid object allocations during draw operations: Use Canvas.getClipBounds(Rect) instead of Canvas.getClipBounds() which allocates a temporary Rect [DrawAllocation]\n" + - " canvas.getClipBounds(); // allocates on your behalf\n" + - " ~~~~~~~~~~~~~~~~~~~~~~\n" + - "src/test/pkg/JavaPerformanceTest.java:140: Warning: Avoid object allocations during draw/layout operations (preallocate and reuse instead) [DrawAllocation]\n" + - " new String(\"foo\");\n" + - " ~~~~~~~~~~~~~~~~~\n" + - "src/test/pkg/JavaPerformanceTest.java:70: Warning: Use new SparseArray<String>(...) instead for better performance [UseSparseArrays]\n" + - " Map<Integer, String> myMap = new HashMap<Integer, String>();\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "src/test/pkg/JavaPerformanceTest.java:72: Warning: Use new SparseBooleanArray(...) instead for better performance [UseSparseArrays]\n" + - " Map<Integer, Boolean> myBoolMap = new HashMap<Integer, Boolean>();\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "src/test/pkg/JavaPerformanceTest.java:74: Warning: Use new SparseIntArray(...) instead for better performance [UseSparseArrays]\n" + - " Map<Integer, Integer> myIntMap = new java.util.HashMap<Integer, Integer>();\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "src/test/pkg/JavaPerformanceTest.java:190: Warning: Use new SparseIntArray(...) instead for better performance [UseSparseArrays]\n" + - " new SparseArray<Integer>(); // Use SparseIntArray instead\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - - (isInAospEnvironment ? - "src/test/pkg/JavaPerformanceTest.java:191: Warning: Use new SparseLongArray(...) instead for better performance [UseSparseArrays]\n" + - " new SparseArray<Long>(); // Use SparseLongArray instead\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~\n" : "") + - - "src/test/pkg/JavaPerformanceTest.java:192: Warning: Use new SparseBooleanArray(...) instead for better performance [UseSparseArrays]\n" + - " new SparseArray<Boolean>(); // Use SparseBooleanArray instead\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "src/test/pkg/JavaPerformanceTest.java:33: Warning: Use Integer.valueOf(5) instead [UseValueOf]\n" + - " Integer i = new Integer(5);\n" + - " ~~~~~~~~~~~~~~\n" + - "src/test/pkg/JavaPerformanceTest.java:145: Warning: Use Integer.valueOf(42) instead [UseValueOf]\n" + - " Integer i1 = new Integer(42);\n" + - " ~~~~~~~~~~~~~~~\n" + - "src/test/pkg/JavaPerformanceTest.java:146: Warning: Use Long.valueOf(42L) instead [UseValueOf]\n" + - " Long l1 = new Long(42L);\n" + - " ~~~~~~~~~~~~~\n" + - "src/test/pkg/JavaPerformanceTest.java:147: Warning: Use Boolean.valueOf(true) instead [UseValueOf]\n" + - " Boolean b1 = new Boolean(true);\n" + - " ~~~~~~~~~~~~~~~~~\n" + - "src/test/pkg/JavaPerformanceTest.java:148: Warning: Use Character.valueOf('c') instead [UseValueOf]\n" + - " Character c1 = new Character('c');\n" + - " ~~~~~~~~~~~~~~~~~~\n" + - "src/test/pkg/JavaPerformanceTest.java:149: Warning: Use Float.valueOf(1.0f) instead [UseValueOf]\n" + - " Float f1 = new Float(1.0f);\n" + - " ~~~~~~~~~~~~~~~\n" + - "src/test/pkg/JavaPerformanceTest.java:150: Warning: Use Double.valueOf(1.0) instead [UseValueOf]\n" + - " Double d1 = new Double(1.0);\n" + - " ~~~~~~~~~~~~~~~\n" + - (isInAospEnvironment ? - "0 errors, 22 warnings\n" : "0 errors, 21 warnings\n"), - - lintProject("src/test/pkg/JavaPerformanceTest.java.txt=>" + - "src/test/pkg/JavaPerformanceTest.java")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/LabelForDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/LabelForDetectorTest.java deleted file mode 100644 index 6d69e00..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/LabelForDetectorTest.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class LabelForDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new LabelForDetector(); - } - - public void test() throws Exception { - assertEquals( - "res/layout/labelfor.xml:54: Warning: No label views point to this text field with an android:labelFor=\"@+id/@+id/editText2\" attribute [LabelFor]\n" + - " <EditText\n" + - " ^\n" + - "res/layout/labelfor.xml:61: Warning: No label views point to this text field with an android:labelFor=\"@+id/@+id/autoCompleteTextView2\" attribute [LabelFor]\n" + - " <AutoCompleteTextView\n" + - " ^\n" + - "res/layout/labelfor.xml:68: Warning: No label views point to this text field with an android:labelFor=\"@+id/@+id/multiAutoCompleteTextView2\" attribute [LabelFor]\n" + - " <MultiAutoCompleteTextView\n" + - " ^\n" + - "0 errors, 3 warnings\n", - - lintProject( - "apicheck/minsdk17.xml=>AndroidManifest.xml", - "res/layout/labelfor.xml" - )); - } - - public void testSuppressed() throws Exception { - assertEquals( - "No warnings.", - - lintProject( - "apicheck/minsdk17.xml=>AndroidManifest.xml", - "res/layout/labelfor_ignore.xml" - )); - } - - - public void testOk() throws Exception { - assertEquals( - "No warnings.", - - lintProject( - "apicheck/minsdk17.xml=>AndroidManifest.xml", - "res/layout/accessibility.xml" - )); - } - - public void testNotApplicable() throws Exception { - assertEquals( - "No warnings.", - - lintProject( - "apicheck/minsdk14.xml=>AndroidManifest.xml", - "res/layout/labelfor.xml" - )); - } -} - diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/LocaleDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/LocaleDetectorTest.java deleted file mode 100644 index 2ac3c4e..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/LocaleDetectorTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class LocaleDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new LocaleDetector(); - } - - public void test() throws Exception { - assertEquals( - "src/test/pkg/LocaleTest.java:11: Warning: Implicitly using the default locale is a common source of bugs: Use toUpperCase(Locale) instead [DefaultLocale]\n" + - " System.out.println(\"WRONG\".toUpperCase());\n" + - " ~~~~~~~~~~~\n" + - "src/test/pkg/LocaleTest.java:16: Warning: Implicitly using the default locale is a common source of bugs: Use toLowerCase(Locale) instead [DefaultLocale]\n" + - " System.out.println(\"WRONG\".toLowerCase());\n" + - " ~~~~~~~~~~~\n" + - "src/test/pkg/LocaleTest.java:20: Warning: Implicitly using the default locale is a common source of bugs: Use String.format(Locale, ...) instead [DefaultLocale]\n" + - " String.format(\"WRONG: %f\", 1.0f); // Implies locale\n" + - " ~~~~~~\n" + - "src/test/pkg/LocaleTest.java:21: Warning: Implicitly using the default locale is a common source of bugs: Use String.format(Locale, ...) instead [DefaultLocale]\n" + - " String.format(\"WRONG: %1$f\", 1.0f);\n" + - " ~~~~~~\n" + - "src/test/pkg/LocaleTest.java:22: Warning: Implicitly using the default locale is a common source of bugs: Use String.format(Locale, ...) instead [DefaultLocale]\n" + - " String.format(\"WRONG: %e\", 1.0f);\n" + - " ~~~~~~\n" + - "src/test/pkg/LocaleTest.java:23: Warning: Implicitly using the default locale is a common source of bugs: Use String.format(Locale, ...) instead [DefaultLocale]\n" + - " String.format(\"WRONG: %d\", 1.0f);\n" + - " ~~~~~~\n" + - "src/test/pkg/LocaleTest.java:24: Warning: Implicitly using the default locale is a common source of bugs: Use String.format(Locale, ...) instead [DefaultLocale]\n" + - " String.format(\"WRONG: %g\", 1.0f);\n" + - " ~~~~~~\n" + - "src/test/pkg/LocaleTest.java:25: Warning: Implicitly using the default locale is a common source of bugs: Use String.format(Locale, ...) instead [DefaultLocale]\n" + - " String.format(\"WRONG: %g\", 1.0f);\n" + - " ~~~~~~\n" + - "src/test/pkg/LocaleTest.java:26: Warning: Implicitly using the default locale is a common source of bugs: Use String.format(Locale, ...) instead [DefaultLocale]\n" + - " String.format(\"WRONG: %1$tm %1$te,%1$tY\",\n" + - " ~~~~~~\n" + - "src/test/pkg/LocaleTest.java:32: Warning: To get local formatting use getDateInstance(), getDateTimeInstance(), or getTimeInstance(), or use new SimpleDateFormat(String template, Locale locale) with for example Locale.US for ASCII dates. [SimpleDateFormat]\n" + - " new SimpleDateFormat(); // WRONG\n" + - " ~~~~~~~~~~~~~~~~\n" + - "src/test/pkg/LocaleTest.java:33: Warning: To get local formatting use getDateInstance(), getDateTimeInstance(), or getTimeInstance(), or use new SimpleDateFormat(String template, Locale locale) with for example Locale.US for ASCII dates. [SimpleDateFormat]\n" + - " new SimpleDateFormat(\"yyyy-MM-dd\"); // WRONG\n" + - " ~~~~~~~~~~~~~~~~\n" + - "src/test/pkg/LocaleTest.java:34: Warning: To get local formatting use getDateInstance(), getDateTimeInstance(), or getTimeInstance(), or use new SimpleDateFormat(String template, Locale locale) with for example Locale.US for ASCII dates. [SimpleDateFormat]\n" + - " new SimpleDateFormat(\"yyyy-MM-dd\", DateFormatSymbols.getInstance()); // WRONG\n" + - " ~~~~~~~~~~~~~~~~\n" + - "0 errors, 12 warnings\n", - - lintProject( - "bytecode/.classpath=>.classpath", - "bytecode/AndroidManifest.xml=>AndroidManifest.xml", - "res/layout/onclick.xml=>res/layout/onclick.xml", - "bytecode/LocaleTest.java.txt=>src/test/pkg/LocaleTest.java", - "bytecode/LocaleTest.class.data=>bin/classes/test/pkg/LocaleTest.class" - )); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/ManifestOrderDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/ManifestOrderDetectorTest.java deleted file mode 100644 index 06e6fba..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/ManifestOrderDetectorTest.java +++ /dev/null @@ -1,323 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.annotations.NonNull; -import com.android.tools.lint.client.api.LintClient; -import com.android.tools.lint.detector.api.Detector; -import com.android.tools.lint.detector.api.Issue; -import com.android.tools.lint.detector.api.Project; - -import java.io.File; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; - -@SuppressWarnings("javadoc") -public class ManifestOrderDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new ManifestOrderDetector(); - } - - private Set<Issue> mEnabled = new HashSet<Issue>(); - - @Override - protected TestConfiguration getConfiguration(LintClient client, Project project) { - return new TestConfiguration(client, project, null) { - @Override - public boolean isEnabled(@NonNull Issue issue) { - return super.isEnabled(issue) && mEnabled.contains(issue); - } - }; - } - - public void testOrderOk() throws Exception { - mEnabled = Collections.singleton(ManifestOrderDetector.ORDER); - assertEquals( - "No warnings.", - lintProject( - "AndroidManifest.xml", - "res/values/strings.xml")); - } - - public void testBrokenOrder() throws Exception { - mEnabled = Collections.singleton(ManifestOrderDetector.ORDER); - assertEquals( - "AndroidManifest.xml:16: Warning: <uses-sdk> tag appears after <application> tag [ManifestOrder]\n" + - " <uses-sdk android:minSdkVersion=\"Froyo\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "0 errors, 1 warnings\n" + - "", - - lintProject( - "broken-manifest.xml=>AndroidManifest.xml", - "res/values/strings.xml")); - } - - public void testMissingUsesSdk() throws Exception { - mEnabled = Collections.singleton(ManifestOrderDetector.USES_SDK); - assertEquals( - "AndroidManifest.xml: Warning: Manifest should specify a minimum API level with <uses-sdk android:minSdkVersion=\"?\" />; if it really supports all versions of Android set it to 1. [UsesMinSdkAttributes]\n" + - "0 errors, 1 warnings\n", - lintProject( - "missingusessdk.xml=>AndroidManifest.xml", - "res/values/strings.xml")); - } - - public void testMissingMinSdk() throws Exception { - mEnabled = Collections.singleton(ManifestOrderDetector.USES_SDK); - assertEquals( - "AndroidManifest.xml:7: Warning: <uses-sdk> tag should specify a minimum API level with android:minSdkVersion=\"?\" [UsesMinSdkAttributes]\n" + - " <uses-sdk android:targetSdkVersion=\"10\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "0 errors, 1 warnings\n" + - "", - lintProject( - "missingmin.xml=>AndroidManifest.xml", - "res/values/strings.xml")); - } - - public void testMissingTargetSdk() throws Exception { - mEnabled = Collections.singleton(ManifestOrderDetector.USES_SDK); - assertEquals( - "AndroidManifest.xml:7: Warning: <uses-sdk> tag should specify a target API level (the highest verified version; when running on later versions, compatibility behaviors may be enabled) with android:targetSdkVersion=\"?\" [UsesMinSdkAttributes]\n" + - " <uses-sdk android:minSdkVersion=\"10\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "0 errors, 1 warnings\n", - lintProject( - "missingtarget.xml=>AndroidManifest.xml", - "res/values/strings.xml")); - } - - public void testOldTargetSdk() throws Exception { - mEnabled = Collections.singleton(ManifestOrderDetector.TARGET_NEWER); - assertEquals( - "AndroidManifest.xml:7: Warning: Not targeting the latest versions of Android; compatibility modes apply. Consider testing and updating this version. Consult the android.os.Build.VERSION_CODES javadoc for details. [OldTargetApi]\n" + - " <uses-sdk android:minSdkVersion=\"10\" android:targetSdkVersion=\"14\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "0 errors, 1 warnings\n", - lintProject( - "oldtarget.xml=>AndroidManifest.xml", - "res/values/strings.xml")); - } - - public void testMultipleSdk() throws Exception { - mEnabled = Collections.singleton(ManifestOrderDetector.MULTIPLE_USES_SDK); - assertEquals( - "AndroidManifest.xml:8: Error: There should only be a single <uses-sdk> element in the manifest: merge these together [MultipleUsesSdk]\n" + - " <uses-sdk android:targetSdkVersion=\"14\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - " AndroidManifest.xml:7: Also appears here\n" + - " AndroidManifest.xml:9: Also appears here\n" + - "1 errors, 0 warnings\n", - - lintProject( - "multiplesdk.xml=>AndroidManifest.xml", - "res/values/strings.xml")); - } - - public void testWrongLocation() throws Exception { - mEnabled = Collections.singleton(ManifestOrderDetector.WRONG_PARENT); - assertEquals( - "AndroidManifest.xml:8: Error: The <uses-sdk> element must be a direct child of the <manifest> root element [WrongManifestParent]\n" + - " <uses-sdk android:minSdkVersion=\"Froyo\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:9: Error: The <uses-permission> element must be a direct child of the <manifest> root element [WrongManifestParent]\n" + - " <uses-permission />\n" + - " ~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:10: Error: The <permission> element must be a direct child of the <manifest> root element [WrongManifestParent]\n" + - " <permission />\n" + - " ~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:11: Error: The <permission-tree> element must be a direct child of the <manifest> root element [WrongManifestParent]\n" + - " <permission-tree />\n" + - " ~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:12: Error: The <permission-group> element must be a direct child of the <manifest> root element [WrongManifestParent]\n" + - " <permission-group />\n" + - " ~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:14: Error: The <uses-sdk> element must be a direct child of the <manifest> root element [WrongManifestParent]\n" + - " <uses-sdk />\n" + - " ~~~~~~~~~~~~\n" + - "AndroidManifest.xml:15: Error: The <uses-configuration> element must be a direct child of the <manifest> root element [WrongManifestParent]\n" + - " <uses-configuration />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:16: Error: The <uses-feature> element must be a direct child of the <manifest> root element [WrongManifestParent]\n" + - " <uses-feature />\n" + - " ~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:17: Error: The <supports-screens> element must be a direct child of the <manifest> root element [WrongManifestParent]\n" + - " <supports-screens />\n" + - " ~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:18: Error: The <compatible-screens> element must be a direct child of the <manifest> root element [WrongManifestParent]\n" + - " <compatible-screens />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:19: Error: The <supports-gl-texture> element must be a direct child of the <manifest> root element [WrongManifestParent]\n" + - " <supports-gl-texture />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:24: Error: The <uses-library> element must be a direct child of the <application> element [WrongManifestParent]\n" + - " <uses-library />\n" + - " ~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:25: Error: The <activity> element must be a direct child of the <application> element [WrongManifestParent]\n" + - " <activity android:name=\".HelloWorld\"\n" + - " ^\n" + - "13 errors, 0 warnings\n" + - "", - - lintProject("broken-manifest2.xml=>AndroidManifest.xml")); - } - - public void testDuplicateActivity() throws Exception { - mEnabled = Collections.singleton(ManifestOrderDetector.DUPLICATE_ACTIVITY); - assertEquals( - "AndroidManifest.xml:16: Error: Duplicate registration for activity com.example.helloworld.HelloWorld [DuplicateActivity]\n" + - " <activity android:name=\"com.example.helloworld.HelloWorld\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "1 errors, 0 warnings\n" + - "", - - lintProject( - "duplicate-manifest.xml=>AndroidManifest.xml", - "res/values/strings.xml")); - } - - public void testIgnoreDuplicateActivity() throws Exception { - mEnabled = Collections.singleton(ManifestOrderDetector.DUPLICATE_ACTIVITY); - assertEquals( - "No warnings.", - - lintProject( - "duplicate-manifest-ignore.xml=>AndroidManifest.xml", - "res/values/strings.xml")); - } - - public void testAllowBackup() throws Exception { - mEnabled = Collections.singleton(ManifestOrderDetector.ALLOW_BACKUP); - assertEquals( - "AndroidManifest.xml:9: Warning: Should explicitly set android:allowBackup to " + - "true or false (it's true by default, and that can have some security " + - "implications for the application's data) [AllowBackup]\n" + - " <application\n" + - " ^\n" + - "0 errors, 1 warnings\n", - lintProject( - "AndroidManifest.xml", - "apicheck/minsdk14.xml=>AndroidManifest.xml", - "res/values/strings.xml")); - } - - public void testAllowBackupOk() throws Exception { - mEnabled = Collections.singleton(ManifestOrderDetector.ALLOW_BACKUP); - assertEquals( - "No warnings.", - lintProject( - "allowbackup.xml=>AndroidManifest.xml", - "res/values/strings.xml")); - } - - public void testAllowBackupOk2() throws Exception { - // Requires build api >= 4 - mEnabled = Collections.singleton(ManifestOrderDetector.ALLOW_BACKUP); - assertEquals( - "No warnings.", - lintProject( - "AndroidManifest.xml", - "apicheck/minsdk1.xml=>AndroidManifest.xml", - "res/values/strings.xml")); - } - - - public void testAllowIgnore() throws Exception { - mEnabled = Collections.singleton(ManifestOrderDetector.ALLOW_BACKUP); - assertEquals( - "No warnings.", - lintProject( - "allowbackup_ignore.xml=>AndroidManifest.xml", - "res/values/strings.xml")); - } - - public void testDuplicatePermissions() throws Exception { - mEnabled = Collections.singleton(ManifestOrderDetector.UNIQUE_PERMISSION); - assertEquals( - "AndroidManifest.xml:12: Error: Permission name SEND_SMS is not unique (appears in both foo.permission.SEND_SMS and bar.permission.SEND_SMS) [UniquePermission]\n" + - " <permission android:name=\"bar.permission.SEND_SMS\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - " AndroidManifest.xml:9: Previous permission here\n" + - "1 errors, 0 warnings\n", - - lintProject( - "duplicate_permissions1.xml=>AndroidManifest.xml", - "res/values/strings.xml")); - } - - public void testDuplicatePermissionsMultiProject() throws Exception { - mEnabled = Collections.singleton(ManifestOrderDetector.UNIQUE_PERMISSION); - - File master = getProjectDir("MasterProject", - // Master project - "duplicate_permissions2.xml=>AndroidManifest.xml", - "multiproject/main-merge.properties=>project.properties", - "multiproject/MainCode.java.txt=>src/foo/main/MainCode.java" - ); - File library = getProjectDir("LibraryProject", - // Library project - "duplicate_permissions3.xml=>AndroidManifest.xml", - "multiproject/library.properties=>project.properties", - "multiproject/LibraryCode.java.txt=>src/foo/library/LibraryCode.java", - "multiproject/strings.xml=>res/values/strings.xml" - ); - assertEquals( - "LibraryProject/AndroidManifest.xml:9: Error: Permission name SEND_SMS is not unique (appears in both foo.permission.SEND_SMS and bar.permission.SEND_SMS) [UniquePermission]\n" + - " <permission android:name=\"bar.permission.SEND_SMS\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "1 errors, 0 warnings\n", - - checkLint(Arrays.asList(master, library))); - } - - public void testMissingVersion() throws Exception { - mEnabled = Collections.singleton(ManifestOrderDetector.SET_VERSION); - assertEquals("" - + "AndroidManifest.xml:2: Warning: Should set android:versionCode to specify the application version [MissingVersion]\n" - + "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" - + "^\n" - + "AndroidManifest.xml:2: Warning: Should set android:versionName to specify the application version [MissingVersion]\n" - + "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" - + "^\n" - + "0 errors, 2 warnings\n", - lintProject("no_version.xml=>AndroidManifest.xml")); - } - - public void testIllegalReference() throws Exception { - mEnabled = Collections.singleton(ManifestOrderDetector.ILLEGAL_REFERENCE); - assertEquals("" - + "AndroidManifest.xml:2: Warning: The android:versionCode cannot be a resource url, it must be a literal integer [IllegalResourceRef]\n" - + "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" - + "^\n" - + "AndroidManifest.xml:2: Warning: The android:versionName cannot be a resource url, it must be a literal string [IllegalResourceRef]\n" - + "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" - + "^\n" - + "AndroidManifest.xml:7: Warning: The android:minSdkVersion cannot be a resource url, it must be a literal integer (or string if a preview codename) [IllegalResourceRef]\n" - + " <uses-sdk android:minSdkVersion=\"@dimen/minSdkVersion\" android:targetSdkVersion=\"@dimen/targetSdkVersion\" />\n" - + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" - + "AndroidManifest.xml:7: Warning: The android:targetSdkVersion cannot be a resource url, it must be a literal integer (or string if a preview codename) [IllegalResourceRef]\n" - + " <uses-sdk android:minSdkVersion=\"@dimen/minSdkVersion\" android:targetSdkVersion=\"@dimen/targetSdkVersion\" />\n" - + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" - + "0 errors, 4 warnings\n", - - lintProject("illegal_version.xml=>AndroidManifest.xml")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/ManifestTypoDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/ManifestTypoDetectorTest.java deleted file mode 100644 index f0ce60d..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/ManifestTypoDetectorTest.java +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.annotations.NonNull; -import com.android.tools.lint.client.api.LintClient; -import com.android.tools.lint.detector.api.Detector; -import com.android.tools.lint.detector.api.Issue; -import com.android.tools.lint.detector.api.Project; - -import java.io.File; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; - -@SuppressWarnings("javadoc") -public class ManifestTypoDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new ManifestTypoDetector(); - } - - private Set<Issue> mEnabled = new HashSet<Issue>(); - - @Override - protected TestConfiguration getConfiguration(LintClient client, Project project) { - return new TestConfiguration(client, project, null) { - @Override - public boolean isEnabled(@NonNull Issue issue) { - return super.isEnabled(issue) && mEnabled.contains(issue); - } - }; - } - - public void testOk() throws Exception { - mEnabled = Collections.singleton(ManifestTypoDetector.ISSUE); - assertEquals( - "No warnings.", - lintProject( - "typo_not_found.xml=>AndroidManifest.xml", - "res/values/strings.xml")); - } - - public void testTypoUsesSdk() throws Exception { - mEnabled = Collections.singleton(ManifestTypoDetector.ISSUE); - assertEquals( - "AndroidManifest.xml:7: " + - "Warning: <use-sdk> looks like a typo; did you mean <uses-sdk> ? [ManifestTypos]\n" + - " <use-sdk android:minSdkVersion=\"14\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "0 errors, 1 warnings\n" + - "", - - lintProject( - "typo_uses_sdk.xml=>AndroidManifest.xml", - "res/values/strings.xml")); - } - - public void testTypoUsesSdk2() throws Exception { - mEnabled = Collections.singleton(ManifestTypoDetector.ISSUE); - assertEquals( - "AndroidManifest.xml:7: " + - "Warning: <user-sdk> looks like a typo; did you mean <uses-sdk> ? [ManifestTypos]\n" + - " <user-sdk android:minSdkVersion=\"14\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "0 errors, 1 warnings\n" + - "", - - lintProject( - "typo_uses_sdk2.xml=>AndroidManifest.xml", - "res/values/strings.xml")); - } - - public void testTypoUsesPermission() throws Exception { - mEnabled = Collections.singleton(ManifestTypoDetector.ISSUE); - assertEquals( - "AndroidManifest.xml:9: " + - "Warning: <use-permission> looks like a typo; " + - "did you mean <uses-permission> ? [ManifestTypos]\n" + - " <use-permission android:name=\"com.example.helloworld.permission\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "0 errors, 1 warnings\n" + - "", - - lintProject( - "typo_uses_permission.xml=>AndroidManifest.xml", - "res/values/strings.xml")); - } - - public void testTypoUsesPermission2() throws Exception { - mEnabled = Collections.singleton(ManifestTypoDetector.ISSUE); - assertEquals( - "AndroidManifest.xml:9: " + - "Warning: <user-permission> looks like a typo; " + - "did you mean <uses-permission> ? [ManifestTypos]\n" + - " <user-permission android:name=\"com.example.helloworld.permission\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "0 errors, 1 warnings\n" + - "", - - lintProject( - "typo_uses_permission2.xml=>AndroidManifest.xml", - "res/values/strings.xml")); - } - - public void testTypoUsesFeature() throws Exception { - mEnabled = Collections.singleton(ManifestTypoDetector.ISSUE); - assertEquals( - "AndroidManifest.xml:11: " + - "Warning: <use-feature> looks like a typo; " + - "did you mean <uses-feature> ? [ManifestTypos]\n" + - " <use-feature android:name=\"android.hardware.wifi\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "0 errors, 1 warnings\n" + - "", - - lintProject( - "typo_uses_feature.xml=>AndroidManifest.xml", - "res/values/strings.xml")); - } - - public void testTypoUsesFeature2() throws Exception { - mEnabled = Collections.singleton(ManifestTypoDetector.ISSUE); - assertEquals( - "AndroidManifest.xml:11: " + - "Warning: <user-feature> looks like a typo; " + - "did you mean <uses-feature> ? [ManifestTypos]\n" + - " <user-feature android:name=\"android.hardware.wifi\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "0 errors, 1 warnings\n" + - "", - - lintProject( - "typo_uses_feature2.xml=>AndroidManifest.xml", - "res/values/strings.xml")); - } - - public void testTypoUsesLibrary() throws Exception { - mEnabled = Collections.singleton(ManifestTypoDetector.ISSUE); - assertEquals( - "AndroidManifest.xml:16: " + - "Warning: <use-library> looks like a typo; " + - "did you mean <uses-library> ? [ManifestTypos]\n" + - " <use-library android:name=\"com.example.helloworld\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "0 errors, 1 warnings\n" + - "", - - lintProject( - "typo_uses_library.xml=>AndroidManifest.xml", - "res/values/strings.xml")); - } - - public void testTypoUsesLibrary2() throws Exception { - mEnabled = Collections.singleton(ManifestTypoDetector.ISSUE); - assertEquals( - "AndroidManifest.xml:16: " + - "Warning: <user-library> looks like a typo; " + - "did you mean <uses-library> ? [ManifestTypos]\n" + - " <user-library android:name=\"com.example.helloworld\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "0 errors, 1 warnings\n" + - "", - - lintProject( - "typo_uses_library2.xml=>AndroidManifest.xml", - "res/values/strings.xml")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/MathDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/MathDetectorTest.java deleted file mode 100644 index da12bda..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/MathDetectorTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class MathDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new MathDetector(); - } - - public void test() throws Exception { - assertEquals( - "src/test/bytecode/MathTest.java:11: Warning: Use java.lang.Math#cos instead of android.util.FloatMath#cos() since it is faster as of API 8 [FloatMath]\n" + - " floatResult = FloatMath.cos(x);\n" + - " ~~~\n" + - "src/test/bytecode/MathTest.java:12: Warning: Use java.lang.Math#sin instead of android.util.FloatMath#sin() since it is faster as of API 8 [FloatMath]\n" + - " floatResult = FloatMath.sin((float) y);\n" + - " ~~~\n" + - "src/test/bytecode/MathTest.java:13: Warning: Use java.lang.Math#ceil instead of android.util.FloatMath#ceil() since it is faster as of API 8 [FloatMath]\n" + - " floatResult = android.util.FloatMath.ceil((float) y);\n" + - " ~~~~\n" + - "src/test/bytecode/MathTest.java:14: Warning: Use java.lang.Math#floor instead of android.util.FloatMath#floor() since it is faster as of API 8 [FloatMath]\n" + - " System.out.println(FloatMath.floor(x));\n" + - " ~~~~~\n" + - "src/test/bytecode/MathTest.java:15: Warning: Use java.lang.Math#sqrt instead of android.util.FloatMath#sqrt() since it is faster as of API 8 [FloatMath]\n" + - " System.out.println(FloatMath.sqrt(z));\n" + - " ~~~~\n" + - "0 errors, 5 warnings\n", - - lintProject( - "bytecode/.classpath=>.classpath", - "bytecode/AndroidManifest.xml=>AndroidManifest.xml", - "bytecode/MathTest.java.txt=>src/test/bytecode/MathTest.java", - "bytecode/MathTest.class.data=>bin/classes/test/bytecode/MathTest.class" - )); - } - - public void testNoWarningsPreFroyo() throws Exception { - assertEquals( - "No warnings.", - - lintProject( - "bytecode/.classpath=>.classpath", - "apicheck/minsdk2.xml=>AndroidManifest.xml", - "bytecode/MathTest.java.txt=>src/test/bytecode/MathTest.java", - "bytecode/MathTest.class.data=>bin/classes/test/bytecode/MathTest.class" - )); - } - -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/MergeRootFrameLayoutDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/MergeRootFrameLayoutDetectorTest.java deleted file mode 100644 index 22a001f..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/MergeRootFrameLayoutDetectorTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class MergeRootFrameLayoutDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new MergeRootFrameLayoutDetector(); - } - - - public void testMergeRefFromJava() throws Exception { - assertEquals( - "res/layout/simple.xml:3: Warning: This <FrameLayout> can be replaced with a <merge> tag [MergeRootFrame]\n" + - "<FrameLayout\n" + - "^\n" + - "0 errors, 1 warnings\n" + - "", - lintProject( - "res/layout/simple.xml", - "src/test/pkg/ImportFrameActivity.java.txt=>src/test/pkg/ImportFrameActivity.java" - )); - } - - public void testMergeRefFromInclude() throws Exception { - assertEquals( - "res/layout/simple.xml:3: Warning: This <FrameLayout> can be replaced with a <merge> tag [MergeRootFrame]\n" + - "<FrameLayout\n" + - "^\n" + - "0 errors, 1 warnings\n" + - "", - lintProject( - "res/layout/simple.xml", - "res/layout/simpleinclude.xml" - )); - } - - public void testMergeRefFromIncludeSuppressed() throws Exception { - assertEquals( - "No warnings.", - lintProject( - "res/layout/simple_ignore.xml=>res/layout/simple.xml", - "res/layout/simpleinclude.xml" - )); - } - - public void testNotIncluded() throws Exception { - assertEquals( - "No warnings.", - lintProject("res/layout/simple.xml")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/MissingClassDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/MissingClassDetectorTest.java deleted file mode 100644 index b3ff056..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/MissingClassDetectorTest.java +++ /dev/null @@ -1,393 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import static com.android.tools.lint.checks.MissingClassDetector.INNERCLASS; -import static com.android.tools.lint.checks.MissingClassDetector.INSTANTIATABLE; -import static com.android.tools.lint.checks.MissingClassDetector.MISSING; - -import com.android.annotations.NonNull; -import com.android.tools.lint.client.api.LintClient; -import com.android.tools.lint.detector.api.Detector; -import com.android.tools.lint.detector.api.Issue; -import com.android.tools.lint.detector.api.Project; -import com.android.tools.lint.detector.api.Scope; -import com.google.common.collect.Sets; - -import java.io.File; -import java.util.Arrays; -import java.util.EnumSet; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -@SuppressWarnings("javadoc") -public class MissingClassDetectorTest extends AbstractCheckTest { - private EnumSet<Scope> mScopes; - private Set<Issue> mEnabled = new HashSet<Issue>(); - - @Override - protected Detector getDetector() { - return new MissingClassDetector(); - } - - @Override - protected EnumSet<Scope> getLintScope(List<File> file) { - return mScopes; - } - - @Override - protected TestConfiguration getConfiguration(LintClient client, Project project) { - return new TestConfiguration(client, project, null) { - @Override - public boolean isEnabled(@NonNull Issue issue) { - return super.isEnabled(issue) && mEnabled.contains(issue); - } - }; - } - - public void test() throws Exception { - mScopes = null; - mEnabled = Sets.newHashSet(MISSING); - assertEquals( - "AndroidManifest.xml:13: Error: Class referenced in the manifest, test.pkg.TestProvider, was not found in the project or the libraries [MissingRegistered]\n" + - " <activity android:name=\".TestProvider\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:14: Error: Class referenced in the manifest, test.pkg.TestProvider2, was not found in the project or the libraries [MissingRegistered]\n" + - " <service android:name=\"test.pkg.TestProvider2\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:15: Error: Class referenced in the manifest, test.pkg.TestService, was not found in the project or the libraries [MissingRegistered]\n" + - " <provider android:name=\".TestService\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:16: Error: Class referenced in the manifest, test.pkg.OnClickActivity, was not found in the project or the libraries [MissingRegistered]\n" + - " <receiver android:name=\"OnClickActivity\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:17: Error: Class referenced in the manifest, test.pkg.TestReceiver, was not found in the project or the libraries [MissingRegistered]\n" + - " <service android:name=\"TestReceiver\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "5 errors, 0 warnings\n", - - lintProject( - "bytecode/AndroidManifestWrongRegs.xml=>AndroidManifest.xml", - "apicheck/ApiCallTest.class.data=>bin/classes/foo/bar/ApiCallTest.class", - "bytecode/.classpath=>.classpath" - )); - } - - public void testIncrementalInManifest() throws Exception { - mScopes = Scope.MANIFEST_SCOPE; - mEnabled = Sets.newHashSet(MISSING, INSTANTIATABLE, INNERCLASS); - assertEquals( - "No warnings.", - - lintProject( - "bytecode/AndroidManifestWrongRegs.xml=>AndroidManifest.xml", - "bytecode/.classpath=>.classpath" - )); - } - - public void testNoWarningBeforeBuild() throws Exception { - mScopes = null; - mEnabled = Sets.newHashSet(MISSING, INSTANTIATABLE, INNERCLASS); - assertEquals( - "No warnings.", - - lintProject( - "bytecode/AndroidManifestWrongRegs.xml=>AndroidManifest.xml", - "bytecode/.classpath=>.classpath" - )); - } - - public void testOkClasses() throws Exception { - mScopes = null; - mEnabled = Sets.newHashSet(MISSING, INSTANTIATABLE, INNERCLASS); - assertEquals( - "No warnings.", - - lintProject( - "bytecode/AndroidManifestRegs.xml=>AndroidManifest.xml", - "bytecode/.classpath=>.classpath", - "bytecode/OnClickActivity.java.txt=>src/test/pkg/OnClickActivity.java", - "bytecode/OnClickActivity.class.data=>bin/classes/test/pkg/OnClickActivity.class", - "bytecode/TestService.java.txt=>src/test/pkg/TestService.java", - "bytecode/TestService.class.data=>bin/classes/test/pkg/TestService.class", - "bytecode/TestProvider.java.txt=>src/test/pkg/TestProvider.java", - "bytecode/TestProvider.class.data=>bin/classes/test/pkg/TestProvider.class", - "bytecode/TestProvider2.java.txt=>src/test/pkg/TestProvider2.java", - "bytecode/TestProvider2.class.data=>bin/classes/test/pkg/TestProvider2.class", - "bytecode/TestReceiver.java.txt=>src/test/pkg/TestReceiver.java", - "bytecode/TestReceiver.class.data=>bin/classes/test/pkg/TestReceiver.class" - )); - } - - public void testOkLibraries() throws Exception { - mScopes = null; - mEnabled = Sets.newHashSet(MISSING, INSTANTIATABLE, INNERCLASS); - assertEquals( - "No warnings.", - - lintProject( - "bytecode/AndroidManifestRegs.xml=>AndroidManifest.xml", - "bytecode/.classpath=>.classpath", - "bytecode/classes.jar=>libs/classes.jar" - )); - } - - public void testLibraryProjects() throws Exception { - mScopes = null; - mEnabled = Sets.newHashSet(MISSING, INSTANTIATABLE, INNERCLASS); - File master = getProjectDir("MasterProject", - // Master project - "bytecode/AndroidManifestRegs.xml=>AndroidManifest.xml", - "multiproject/main.properties=>project.properties", - "bytecode/TestService.java.txt=>src/test/pkg/TestService.java", - "bytecode/TestService.class.data=>bin/classes/test/pkg/TestService.class", - "bytecode/.classpath=>.classpath" - ); - File library = getProjectDir("LibraryProject", - // Library project - "multiproject/library-manifest.xml=>AndroidManifest.xml", - "multiproject/library.properties=>project.properties", - "bytecode/OnClickActivity.java.txt=>src/test/pkg/OnClickActivity.java", - "bytecode/OnClickActivity.class.data=>bin/classes/test/pkg/OnClickActivity.class", - "bytecode/TestProvider.java.txt=>src/test/pkg/TestProvider.java", - "bytecode/TestProvider.class.data=>bin/classes/test/pkg/TestProvider.class", - "bytecode/TestProvider2.java.txt=>src/test/pkg/TestProvider2.java", - "bytecode/TestProvider2.class.data=>bin/classes/test/pkg/TestProvider2.class" - // Missing TestReceiver: Test should complain about just that class - ); - assertEquals("" - + "MasterProject/AndroidManifest.xml:32: Error: Class referenced in the manifest, test.pkg.TestReceiver, was not found in the project or the libraries [MissingRegistered]\n" - + " <receiver android:name=\"TestReceiver\" />\n" - + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" - + "1 errors, 0 warnings\n", - - checkLint(Arrays.asList(master, library))); - } - - public void testInnerClassStatic() throws Exception { - mScopes = null; - mEnabled = Sets.newHashSet(MISSING, INSTANTIATABLE, INNERCLASS); - assertEquals( - "src/test/pkg/Foo.java:8: Warning: This inner class should be static (test.pkg.Foo.Baz) [Instantiatable]\n" + - " public class Baz extends Activity {\n" + - " ^\n" + - "0 errors, 1 warnings\n", - - lintProject( - "registration/AndroidManifest.xml=>AndroidManifest.xml", - "bytecode/.classpath=>.classpath", - "registration/Foo.java.txt=>src/test/pkg/Foo.java", - "registration/Foo.class.data=>bin/classes/test/pkg/Foo.class", - "registration/Foo$Bar.class.data=>bin/classes/test/pkg/Foo$Bar.class", - "registration/Foo$Baz.class.data=>bin/classes/test/pkg/Foo$Baz.class" - )); - } - - public void testInnerClassPublic() throws Exception { - mScopes = null; - mEnabled = Sets.newHashSet(MISSING, INSTANTIATABLE, INNERCLASS); - assertEquals( - "src/test/pkg/Foo/Bar.java:6: Warning: The default constructor must be public [Instantiatable]\n" + - " private Bar() {\n" + - " ^\n" + - "0 errors, 1 warnings\n", - - lintProject( - "registration/AndroidManifestInner.xml=>AndroidManifest.xml", - "bytecode/.classpath=>.classpath", - "registration/Bar.java.txt=>src/test/pkg/Foo/Bar.java", - "registration/Bar.class.data=>bin/classes/test/pkg/Foo/Bar.class" - )); - } - - public void testInnerClass() throws Exception { - mScopes = null; - mEnabled = Sets.newHashSet(MISSING, INSTANTIATABLE, INNERCLASS); - assertEquals( - "AndroidManifest.xml:14: Error: Class referenced in the manifest, test.pkg.Foo.Bar, was not found in the project or the libraries [MissingRegistered]\n" + - " <activity\n" + - " ^\n" + - "AndroidManifest.xml:23: Error: Class referenced in the manifest, test.pkg.Foo.Baz, was not found in the project or the libraries [MissingRegistered]\n" + - " <activity\n" + - " ^\n" + - "2 errors, 0 warnings\n", - - lintProject( - "registration/AndroidManifest.xml=>AndroidManifest.xml", - "bytecode/.classpath=>.classpath", - "apicheck/ApiCallTest.class.data=>bin/classes/foo/bar/ApiCallTest.class", - "registration/Foo.java.txt=>src/test/pkg/Foo.java" - )); - } - - public void testInnerClass2() throws Exception { - mScopes = null; - mEnabled = Sets.newHashSet(MISSING, INSTANTIATABLE, INNERCLASS); - assertEquals( - "AndroidManifest.xml:14: Error: Class referenced in the manifest, test.pkg.Foo.Bar, was not found in the project or the libraries [MissingRegistered]\n" + - " <activity\n" + - " ^\n" + - "1 errors, 0 warnings\n", - - lintProject( - "registration/AndroidManifestInner.xml=>AndroidManifest.xml", - "bytecode/.classpath=>.classpath", - "apicheck/ApiCallTest.class.data=>bin/classes/foo/bar/ApiCallTest.class", - "registration/Bar.java.txt=>src/test/pkg/Foo/Bar.java" - )); - } - - public void testWrongSeparator1() throws Exception { - mScopes = null; - mEnabled = Sets.newHashSet(MISSING, INSTANTIATABLE, INNERCLASS); - assertEquals( - "AndroidManifest.xml:14: Error: Class referenced in the manifest, test.pkg.Foo.Bar, was not found in the project or the libraries [MissingRegistered]\n" + - " <activity\n" + - " ^\n" + - "1 errors, 0 warnings\n", - - lintProject( - "registration/AndroidManifestWrong.xml=>AndroidManifest.xml", - "bytecode/.classpath=>.classpath", - "apicheck/ApiCallTest.class.data=>bin/classes/foo/bar/ApiCallTest.class", - "registration/Bar.java.txt=>src/test/pkg/Foo/Bar.java" - )); - } - - public void testWrongSeparator2() throws Exception { - mScopes = null; - mEnabled = Sets.newHashSet(MISSING, INSTANTIATABLE, INNERCLASS); - assertEquals( - "AndroidManifest.xml:14: Error: Class referenced in the manifest, test.pkg.Foo.Bar, was not found in the project or the libraries [MissingRegistered]\n" + - " <activity\n" + - " ^\n" + - "AndroidManifest.xml:15: Warning: Use '$' instead of '.' for inner classes (or use only lowercase letters in package names) [InnerclassSeparator]\n" + - " android:name=\".Foo.Bar\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~\n" + - "1 errors, 1 warnings\n", - - lintProject( - "registration/AndroidManifestWrong2.xml=>AndroidManifest.xml", - "bytecode/.classpath=>.classpath", - "apicheck/ApiCallTest.class.data=>bin/classes/foo/bar/ApiCallTest.class", - "registration/Bar.java.txt=>src/test/pkg/Foo/Bar.java" - )); - } - - public void testNoClassesWithLibraries() throws Exception { - mScopes = null; - mEnabled = Sets.newHashSet(MISSING, INSTANTIATABLE, INNERCLASS); - assertEquals( - "No warnings.", - - lintProject( - "bytecode/AndroidManifestWrongRegs.xml=>AndroidManifest.xml", - "bytecode/.classpath=>.classpath", - "bytecode/GetterTest.jar.data=>libs/foo.jar" - )); - } - - public void testFragment() throws Exception { - mScopes = null; - mEnabled = Sets.newHashSet(MISSING, INSTANTIATABLE, INNERCLASS); - assertEquals("" - + "res/layout/fragment2.xml:7: Error: Class referenced in the layout file, my.app.Fragment, was not found in the project or the libraries [MissingRegistered]\n" - + " <fragment\n" - + " ^\n" - + "res/layout/fragment2.xml:12: Error: Class referenced in the layout file, my.app.MyView, was not found in the project or the libraries [MissingRegistered]\n" - + " <view\n" - + " ^\n" - + "res/layout/fragment2.xml:17: Error: Class referenced in the layout file, my.app.Fragment2, was not found in the project or the libraries [MissingRegistered]\n" - + " <fragment\n" - + " ^\n" - + "3 errors, 0 warnings\n", - - lintProject( - "bytecode/AndroidManifestRegs.xml=>AndroidManifest.xml", - "bytecode/.classpath=>.classpath", - "bytecode/OnClickActivity.java.txt=>src/test/pkg/OnClickActivity.java", - "bytecode/OnClickActivity.class.data=>bin/classes/test/pkg/OnClickActivity.class", - "bytecode/TestService.java.txt=>src/test/pkg/TestService.java", - "bytecode/TestService.class.data=>bin/classes/test/pkg/TestService.class", - "bytecode/TestProvider.java.txt=>src/test/pkg/TestProvider.java", - "bytecode/TestProvider.class.data=>bin/classes/test/pkg/TestProvider.class", - "bytecode/TestProvider2.java.txt=>src/test/pkg/TestProvider2.java", - "bytecode/TestProvider2.class.data=>bin/classes/test/pkg/TestProvider2.class", - "bytecode/TestReceiver.java.txt=>src/test/pkg/TestReceiver.java", - "bytecode/TestReceiver.class.data=>bin/classes/test/pkg/TestReceiver.class", - "registration/Foo.java.txt=>src/test/pkg/Foo.java", - "registration/Foo.class.data=>bin/classes/test/pkg/Foo.class", - "registration/Bar.java.txt=>src/test/pkg/Foo/Bar.java", - "registration/Bar.class.data=>bin/classes/test/pkg/Foo/Bar.class", - - "res/layout/fragment2.xml" - )); - } - - public void testAnalytics() throws Exception { - mEnabled = Sets.newHashSet(MISSING, INSTANTIATABLE, INNERCLASS); - assertEquals("" - + "res/values/analytics.xml:13: Error: Class referenced in the analytics file, com.example.app.BaseActivity, was not found in the project or the libraries [MissingRegistered]\n" - + " <string name=\"com.example.app.BaseActivity\">Home</string>\n" - + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" - + "res/values/analytics.xml:14: Error: Class referenced in the analytics file, com.example.app.PrefsActivity, was not found in the project or the libraries [MissingRegistered]\n" - + " <string name=\"com.example.app.PrefsActivity\">Preferences</string>\n" - + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" - + "2 errors, 0 warnings\n", - - lintProject( - "bytecode/.classpath=>.classpath", - "res/values/analytics.xml", - "bytecode/OnClickActivity.java.txt=>src/test/pkg/OnClickActivity.java", - "bytecode/OnClickActivity.class.data=>bin/classes/test/pkg/OnClickActivity.class" - )); - } - - public void testCustomView() throws Exception { - mEnabled = Sets.newHashSet(MISSING, INSTANTIATABLE, INNERCLASS); - assertEquals("" - + "res/layout/customview.xml:21: Error: Class referenced in the layout file, foo.bar.Baz, was not found in the project or the libraries [MissingRegistered]\n" - + " <foo.bar.Baz\n" - + " ^\n" - + "1 errors, 0 warnings\n", - - lintProject( - "bytecode/.classpath=>.classpath", - "res/layout/customview.xml", - "bytecode/OnClickActivity.java.txt=>src/test/pkg/OnClickActivity.java", - "bytecode/OnClickActivity.class.data=>bin/classes/test/pkg/OnClickActivity.class" - )); - } - - public void testFragments() throws Exception { - // Ensure that we don't do instantiation checks here since they are handled by - // the FragmentDetector - assertEquals( - "No warnings.", - - lintProject( - "bytecode/FragmentTest$Fragment1.class.data=>bin/classes/test/pkg/FragmentTest$Fragment1.class", - "bytecode/FragmentTest$Fragment2.class.data=>bin/classes/test/pkg/FragmentTest$Fragment2.class", - "bytecode/FragmentTest$Fragment3.class.data=>bin/classes/test/pkg/FragmentTest$Fragment3.class", - "bytecode/FragmentTest$Fragment4.class.data=>bin/classes/test/pkg/FragmentTest$Fragment4.class", - "bytecode/FragmentTest$Fragment5.class.data=>bin/classes/test/pkg/FragmentTest$Fragment5.class", - "bytecode/FragmentTest$Fragment6.class.data=>bin/classes/test/pkg/FragmentTest$Fragment6.class", - "bytecode/FragmentTest$NotAFragment.class.data=>bin/classes/test/pkg/FragmentTest$NotAFragment.class", - "bytecode/FragmentTest.java.txt=>src/test/pkg/FragmentTest.java")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/MissingIdDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/MissingIdDetectorTest.java deleted file mode 100644 index b72d8c8..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/MissingIdDetectorTest.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class MissingIdDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new MissingIdDetector(); - } - - public void test() throws Exception { - assertEquals( - "res/layout/fragment.xml:7: Warning: This <fragment> tag should specify an id or a tag to preserve state across activity restarts [MissingId]\n" + - " <fragment\n" + - " ^\n" + - "0 errors, 1 warnings\n", - - lintProject("res/layout/fragment.xml")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/NamespaceDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/NamespaceDetectorTest.java deleted file mode 100644 index 91aedb2..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/NamespaceDetectorTest.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class NamespaceDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new NamespaceDetector(); - } - - public void testCustom() throws Exception { - assertEquals( - "res/layout/customview.xml:5: Error: When using a custom namespace attribute in a library project, use the namespace \"http://schemas.android.com/apk/res-auto\" instead. [LibraryCustomView]\n" + - " xmlns:foo=\"http://schemas.android.com/apk/res/foo\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "1 errors, 0 warnings\n", - - lintProject( - "multiproject/library-manifest.xml=>AndroidManifest.xml", - "multiproject/library.properties=>project.properties", - "res/layout/customview.xml" - )); - } - - public void testCustomOk() throws Exception { - assertEquals( - "No warnings.", - - lintProject( - "multiproject/library-manifest.xml=>AndroidManifest.xml", - - // Use a standard project properties instead: no warning since it's - // not a library project: - //"multiproject/library.properties=>project.properties", - - "res/layout/customview.xml" - )); - } - - public void testCustomOk2() throws Exception { - assertEquals( - "No warnings.", - - lintProject( - "multiproject/library-manifest.xml=>AndroidManifest.xml", - "multiproject/library.properties=>project.properties", - // This project already uses the res-auto package - "res/layout/customview2.xml" - )); - } - - public void testTypo() throws Exception { - assertEquals( - "res/layout/wrong_namespace.xml:2: Warning: Unexpected namespace URI bound to the \"android\" prefix, was http://schemas.android.com/apk/res/andriod, expected http://schemas.android.com/apk/res/android [NamespaceTypo]\n" + - "<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/andriod\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "0 errors, 1 warnings\n" + - "", - - lintProject("res/layout/wrong_namespace.xml")); - } - - public void testTypo2() throws Exception { - assertEquals( - "res/layout/wrong_namespace2.xml:2: Warning: URI is case sensitive: was \"http://schemas.android.com/apk/res/Android\", expected \"http://schemas.android.com/apk/res/android\" [NamespaceTypo]\n" + - "<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/Android\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "0 errors, 1 warnings\n" + - "", - - lintProject("res/layout/wrong_namespace2.xml")); - } - - public void testTypo3() throws Exception { - assertEquals( - "res/layout/wrong_namespace3.xml:2: Warning: Unexpected namespace URI bound to the \"android\" prefix, was http://schemas.android.com/apk/res/androi, expected http://schemas.android.com/apk/res/android [NamespaceTypo]\n" + - "<LinearLayout xmlns:a=\"http://schemas.android.com/apk/res/androi\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "0 errors, 1 warnings\n" + - "", - - lintProject("res/layout/wrong_namespace3.xml")); - } - - public void testTypo4() throws Exception { - assertEquals( - "res/layout/wrong_namespace5.xml:2: Warning: Suspicious namespace: should start with http:// [NamespaceTypo]\n" + - " xmlns:noturi=\"tp://schems.android.com/apk/res/com.my.package\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/wrong_namespace5.xml:3: Warning: Possible typo in URL: was \"http://schems.android.com/apk/res/com.my.package\", should probably be \"http://schemas.android.com/apk/res/com.my.package\" [NamespaceTypo]\n" + - " xmlns:typo1=\"http://schems.android.com/apk/res/com.my.package\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/wrong_namespace5.xml:4: Warning: Possible typo in URL: was \"http://schems.android.comm/apk/res/com.my.package\", should probably be \"http://schemas.android.com/apk/res/com.my.package\" [NamespaceTypo]\n" + - " xmlns:typo2=\"http://schems.android.comm/apk/res/com.my.package\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "0 errors, 3 warnings\n", - - lintProject("res/layout/wrong_namespace5.xml")); - } - - public void testTypoOk() throws Exception { - assertEquals( - "No warnings.", - - lintProject("res/layout/wrong_namespace4.xml")); - } - - public void testUnused() throws Exception { - assertEquals( - "res/layout/unused_namespace.xml:3: Warning: Unused namespace unused1 [UnusedNamespace]\n" + - " xmlns:unused1=\"http://schemas.android.com/apk/res/unused1\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/unused_namespace.xml:4: Warning: Unused namespace unused2 [UnusedNamespace]\n" + - " xmlns:unused2=\"http://schemas.android.com/apk/res/unused1\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "0 errors, 2 warnings\n" + - "", - - lintProject("res/layout/unused_namespace.xml")); - } - - public void testUnusedOk() throws Exception { - assertEquals( - "No warnings.", - - lintProject("res/layout/layout1.xml")); - } - - public void testLayoutAttributesOk() throws Exception { - assertEquals( - "No warnings.", - - lintFiles("res/layout/namespace3.xml")); - } - - public void testLayoutAttributesOk2() throws Exception { - assertEquals( - "No warnings.", - - lintFiles("res/layout/namespace4.xml")); - } - - public void testLayoutAttributes() throws Exception { - assertEquals( - "res/layout/namespace3.xml:2: Error: When using a custom namespace attribute in a library project, use the namespace \"http://schemas.android.com/apk/res-auto\" instead. [LibraryCustomView]\n" + - " xmlns:app=\"http://schemas.android.com/apk/res/com.example.apicalltest\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "1 errors, 0 warnings\n", - - lintFiles("res/layout/namespace3.xml", - "multiproject/library-manifest.xml=>AndroidManifest.xml", - "multiproject/library.properties=>project.properties")); - } - - public void testLayoutAttributes2() throws Exception { - assertEquals( - "res/layout/namespace4.xml:3: Error: When using a custom namespace attribute in a library project, use the namespace \"http://schemas.android.com/apk/res-auto\" instead. [LibraryCustomView]\n" + - " xmlns:app=\"http://schemas.android.com/apk/res/com.example.apicalltest\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "1 errors, 0 warnings\n", - - lintFiles("res/layout/namespace4.xml", - "multiproject/library-manifest.xml=>AndroidManifest.xml", - "multiproject/library.properties=>project.properties")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/NestedScrollingWidgetDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/NestedScrollingWidgetDetectorTest.java deleted file mode 100644 index 55da17e..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/NestedScrollingWidgetDetectorTest.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class NestedScrollingWidgetDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new NestedScrollingWidgetDetector(); - } - - public void testNested() throws Exception { - assertEquals( - "res/layout/scrolling.xml:13: Warning: The vertically scrolling ScrollView should not contain another vertically scrolling widget (ListView) [NestedScrolling]\n" + - " <ListView\n" + - " ^\n" + - "0 errors, 1 warnings\n", - - lintFiles("res/layout/scrolling.xml")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/NonInternationalizedSmsDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/NonInternationalizedSmsDetectorTest.java deleted file mode 100644 index f875fa1..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/NonInternationalizedSmsDetectorTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class NonInternationalizedSmsDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new NonInternationalizedSmsDetector(); - } - - public void test() throws Exception { - assertEquals( - "src/test/pkg/NonInternationalizedSmsDetectorTest.java:18: Warning: To make sure the SMS can be sent by all users, please start the SMS number with a + and a country code or restrict the code invocation to people in the country you are targeting. [UnlocalizedSms]\n" + - " sms.sendMultipartTextMessage(\"001234567890\", null, null, null, null);\n" + - " ~~~~~~~~~~~~~~\n" + - "0 errors, 1 warnings\n" + - "", - - lintProject("src/test/pkg/NonInternationalizedSmsDetectorTest.java.txt=>src/test/pkg/NonInternationalizedSmsDetectorTest.java")); - } -}
\ No newline at end of file diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/ObsoleteLayoutParamsDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/ObsoleteLayoutParamsDetectorTest.java deleted file mode 100644 index 87211a2..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/ObsoleteLayoutParamsDetectorTest.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class ObsoleteLayoutParamsDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new ObsoleteLayoutParamsDetector(); - } - - public void test() throws Exception { - assertEquals( - "res/layout/wrongparams.xml:11: Warning: Invalid layout param in a FrameLayout: layout_weight [ObsoleteLayoutParam]\n" + - " android:layout_weight=\"1\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/wrongparams.xml:23: Warning: Invalid layout param in a LinearLayout: layout_alignParentLeft [ObsoleteLayoutParam]\n" + - " android:layout_alignParentLeft=\"true\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/wrongparams.xml:24: Warning: Invalid layout param in a LinearLayout: layout_alignParentTop [ObsoleteLayoutParam]\n" + - " android:layout_alignParentTop=\"true\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/wrongparams.xml:33: Warning: Invalid layout param in a LinearLayout: layout_alignBottom [ObsoleteLayoutParam]\n" + - " android:layout_alignBottom=\"@+id/button1\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/wrongparams.xml:34: Warning: Invalid layout param in a LinearLayout: layout_toRightOf [ObsoleteLayoutParam]\n" + - " android:layout_toRightOf=\"@+id/button1\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/wrongparams.xml:42: Warning: Invalid layout param in a LinearLayout: layout_alignLeft [ObsoleteLayoutParam]\n" + - " android:layout_alignLeft=\"@+id/button1\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/wrongparams.xml:43: Warning: Invalid layout param in a LinearLayout: layout_below [ObsoleteLayoutParam]\n" + - " android:layout_below=\"@+id/button1\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "0 errors, 7 warnings\n" + - "", - - lintProject("res/layout/wrongparams.xml")); - } - - public void test2() throws Exception { - // Test <merge> and custom view handling - - assertEquals( - "No warnings.", - - lintProject("res/layout/wrongparams2.xml")); - } - - public void test3() throws Exception { - // Test includes across files (wrong layout param on root element) - assertEquals( - "res/layout/wrongparams3.xml:5: Warning: Invalid layout param 'layout_alignParentTop' (included from within a LinearLayout in layout/wrongparams4.xml) [ObsoleteLayoutParam]\n" + - " android:layout_alignParentTop=\"true\" >\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "0 errors, 1 warnings\n" + - "", - - lintProject("res/layout/wrongparams4.xml", "res/layout/wrongparams3.xml")); - } - - public void test4() throws Exception { - // Test includes with a <merge> (wrong layout param on child of root merge element) - assertEquals( - "res/layout/wrongparams5.xml:8: Warning: Invalid layout param 'layout_alignParentTop' (included from within a LinearLayout in layout/wrongparams6.xml) [ObsoleteLayoutParam]\n" + - " android:layout_alignParentTop=\"true\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/wrongparams5.xml:15: Warning: Invalid layout param 'layout_alignParentLeft' (included from within a LinearLayout in layout/wrongparams6.xml) [ObsoleteLayoutParam]\n" + - " android:layout_alignParentLeft=\"true\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "0 errors, 2 warnings\n" + - "", - - lintProject("res/layout/wrongparams5.xml", "res/layout/wrongparams6.xml")); - } - - public void testIgnore() throws Exception { - assertEquals( - // Ignoring all but one of the warnings - "res/layout/wrongparams.xml:12: Warning: Invalid layout param in a FrameLayout: layout_weight [ObsoleteLayoutParam]\n" + - " android:layout_weight=\"1\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "0 errors, 1 warnings\n" + - "", - - lintProject("res/layout/wrongparams_ignore.xml=>res/layout/wrongparams.xml")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/OnClickDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/OnClickDetectorTest.java deleted file mode 100644 index e4d8bb5..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/OnClickDetectorTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class OnClickDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new OnClickDetector(); - } - - public void test() throws Exception { - assertEquals( - "src/test/pkg/OnClickActivity.java:27: Error: On click handler wrong5(View) must be public [OnClick]\n" + - " void wrong5(View view) {\n" + - " ~~~~~~\n" + - "src/test/pkg/OnClickActivity.java:31: Error: On click handler wrong6(View) should not be static [OnClick]\n" + - " public static void wrong6(View view) {\n" + - " ~~~~~~\n" + - "src/test/pkg/OnClickActivity.java:45: Error: On click handler wrong7(View) must be public [OnClick]\n" + - " void wrong7(View view) {\n" + - " ~~~~~~\n" + - "res/layout/onclick.xml:10: Error: Corresponding method handler 'public void nonexistent(android.view.View)' not found [OnClick]\n" + - " android:onClick=\"nonexistent\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/onclick.xml:16: Error: Corresponding method handler 'public void wrong1(android.view.View)' not found [OnClick]\n" + - " android:onClick=\"wrong1\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/onclick.xml:22: Error: Corresponding method handler 'public void wrong2(android.view.View)' not found [OnClick]\n" + - " android:onClick=\"wrong2\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/onclick.xml:28: Error: Corresponding method handler 'public void wrong3(android.view.View)' not found [OnClick]\n" + - " android:onClick=\"wrong3\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/onclick.xml:34: Error: Corresponding method handler 'public void wrong4(android.view.View)' not found [OnClick]\n" + - " android:onClick=\"wrong4\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/onclick.xml:58: Error: Corresponding method handler 'public void simple_typo(android.view.View)' not found (did you mean void test.pkg.OnClickActivity#simple_tyop(android.view.View) ?) [OnClick]\n" + - " android:onClick=\"simple_typo\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "9 errors, 0 warnings\n", - - lintProject( - "bytecode/.classpath=>.classpath", - "bytecode/AndroidManifest.xml=>AndroidManifest.xml", - "res/layout/onclick.xml=>res/layout/onclick.xml", - "bytecode/OnClickActivity.java.txt=>src/test/pkg/OnClickActivity.java", - "bytecode/OnClickActivity.class.data=>bin/classes/test/pkg/OnClickActivity.class" - )); - } - - public void testOk() throws Exception { - // No onClick attributes - assertEquals( - "No warnings.", - - lintProject("res/layout/accessibility.xml")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/OverdrawDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/OverdrawDetectorTest.java deleted file mode 100644 index 7da4004..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/OverdrawDetectorTest.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class OverdrawDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new OverdrawDetector(); - } - - public void test() throws Exception { - assertEquals( - "res/layout/main.xml:5: Warning: Possible overdraw: Root element paints background @drawable/ic_launcher with a theme that also paints a background (inferred theme is @style/MyTheme_First) [Overdraw]\n" + - " android:background=\"@drawable/ic_launcher\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/second.xml:5: Warning: Possible overdraw: Root element paints background @drawable/ic_launcher with a theme that also paints a background (inferred theme is @style/MyTheme) [Overdraw]\n" + - " android:background=\"@drawable/ic_launcher\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/sixth.xml:4: Warning: Possible overdraw: Root element paints background @drawable/custombg with a theme that also paints a background (inferred theme is @style/MyTheme) [Overdraw]\n" + - " android:background=\"@drawable/custombg\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/third.xml:5: Warning: Possible overdraw: Root element paints background @drawable/ic_launcher with a theme that also paints a background (inferred theme is @style/MyTheme_Third) [Overdraw]\n" + - " android:background=\"@drawable/ic_launcher\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "0 errors, 4 warnings\n" + - "", - - lintProject( - "overdraw/.classpath=>.classpath", - "overdraw/.project=>.project", - "overdraw/AndroidManifest.xml=>AndroidManifest.xml", - "overdraw/project.properties=>project.properties", - "overdraw/res/drawable/custombg.xml=>res/drawable/custombg.xml", - "overdraw/res/drawable/custombg2.xml=>res/drawable/custombg2.xml", - "overdraw/res/drawable-hdpi/ic_launcher.png=>res/drawable-hdpi/ic_launcher.png", - "overdraw/res/drawable-ldpi/ic_launcher.png=>res/drawable-ldpi/ic_launcher.png", - "overdraw/res/drawable-mdpi/ic_launcher.png=>res/drawable-mdpi/ic_launcher.png", - "overdraw/res/layout/sixth.xml=>res/layout/sixth.xml", - "overdraw/res/layout/fifth.xml=>res/layout/fifth.xml", - "overdraw/res/layout/fourth.xml=>res/layout/fourth.xml", - "overdraw/res/layout/main.xml=>res/layout/main.xml", - "overdraw/res/layout/second.xml=>res/layout/second.xml", - "overdraw/res/layout/third.xml=>res/layout/third.xml", - "overdraw/res/values/strings.xml=>res/values/strings.xml", - "overdraw/res/values/styles.xml=>res/values/styles.xml", - - // Java files must be renamed in source tree - "overdraw/gen/test/pkg/BuildConfig.java.txt=>gen/test/pkg/BuildConfig.java", - "overdraw/gen/test/pkg/R.java.txt=>gen/test/pkg/R.java", - "overdraw/src/test/pkg/FourthActivity.java.txt=>src/test/pkg/FourthActivity.java", - "overdraw/src/test/pkg/OverdrawActivity.java.txt=>src/test/pkg/OverdrawActivity.java", - "overdraw/src/test/pkg/SecondActivity.java.txt=>src/test/pkg/SecondActivity.java", - "overdraw/src/test/pkg/ThirdActivity.java.txt=>src/test/pkg/ThirdActivity.java" - )); - } - - public void testSuppressed() throws Exception { - assertEquals( - "No warnings.", - - lintProject( - "overdraw/.classpath=>.classpath", - "overdraw/.project=>.project", - "overdraw/AndroidManifest.xml=>AndroidManifest.xml", - "overdraw/project.properties=>project.properties", - "overdraw/res/drawable/custombg.xml=>res/drawable/custombg.xml", - "overdraw/res/drawable/custombg2.xml=>res/drawable/custombg2.xml", - "overdraw/res/drawable-hdpi/ic_launcher.png=>res/drawable-hdpi/ic_launcher.png", - "overdraw/res/drawable-ldpi/ic_launcher.png=>res/drawable-ldpi/ic_launcher.png", - "overdraw/res/drawable-mdpi/ic_launcher.png=>res/drawable-mdpi/ic_launcher.png", - "overdraw/res/layout/main_ignore.xml=>res/layout/main.xml", - "overdraw/res/values/strings.xml=>res/values/strings.xml", - "overdraw/res/values/styles.xml=>res/values/styles.xml", - - // Java files must be renamed in source tree - "overdraw/gen/test/pkg/BuildConfig.java.txt=>gen/test/pkg/BuildConfig.java", - "overdraw/gen/test/pkg/R.java.txt=>gen/test/pkg/R.java", - "overdraw/src/test/pkg/FourthActivity.java.txt=>src/test/pkg/FourthActivity.java", - "overdraw/src/test/pkg/OverdrawActivity.java.txt=>src/test/pkg/OverdrawActivity.java", - "overdraw/src/test/pkg/SecondActivity.java.txt=>src/test/pkg/SecondActivity.java", - "overdraw/src/test/pkg/ThirdActivity.java.txt=>src/test/pkg/ThirdActivity.java" - )); - } - -}
\ No newline at end of file diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/OverrideDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/OverrideDetectorTest.java deleted file mode 100644 index 68f80f9..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/OverrideDetectorTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class OverrideDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new OverrideDetector(); - } - - public void test() throws Exception { - assertEquals( - "src/pkg2/Class2.java:7: Error: This package private method may be unintentionally overriding method in pkg1.Class1 [DalvikOverride]\n" + - " void method() { // Flag this as an accidental override\n" + - " ~~~~~~\n" + - " src/pkg1/Class1.java:4: This method is treated as overridden\n" + - "1 errors, 0 warnings\n", - - lintProject( - "bytecode/.classpath=>.classpath", - "bytecode/AndroidManifest.xml=>AndroidManifest.xml", - "src/pkg1/Class1.java.txt=>src/pkg1/Class1.java", - "src/pkg2/Class2.java.txt=>src/pkg2/Class2.java", - "bytecode/Class1.class.data=>bin/classes/pkg1/Class1.class", - "bytecode/Class1$Class4.class.data=>bin/classes/pkg1/Class1$Class4.class", - "bytecode/Class2.class.data=>bin/classes/pkg2/Class2.class", - "bytecode/Class2$Class3.class.data=>bin/classes/pkg2/Class2$Class3.class" - )); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/PrivateKeyDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/PrivateKeyDetectorTest.java deleted file mode 100644 index ff72dcb..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/PrivateKeyDetectorTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class PrivateKeyDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new PrivateKeyDetector(); - } - - @Override - protected boolean includeParentPath() { - return true; - } - - public void testPrivateKey() throws Exception { - assertEquals( - "res/private_key.pem: Warning: The res/private_key.pem file seems to be a private key file. Please make sure not to embed this in your APK file. [PackagedPrivateKey]\n" + - "0 errors, 1 warnings\n", - lintProject( - // Not a private key file - "res/values/strings.xml=>res/values/strings/xml", - // Private key file - "res/private_key.pem=>res/private_key.pem")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/PrivateResourceDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/PrivateResourceDetectorTest.java deleted file mode 100644 index ce1b717..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/PrivateResourceDetectorTest.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class PrivateResourceDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new PrivateResourceDetector(); - } - - public void testPrivate() throws Exception { - assertEquals( - "res/layout/private.xml:3: Error: Illegal resource reference: @*android resources are private and not always present [PrivateResource]\n" + - " <ImageView android:id=\"@+id/android_logo\" android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:src=\"@*android:drawable/android_button\" android:focusable=\"false\" android:clickable=\"false\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "1 errors, 0 warnings\n" + - "", - lintProject("res/layout/private.xml")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/ProguardDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/ProguardDetectorTest.java deleted file mode 100644 index c493b8c..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/ProguardDetectorTest.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class ProguardDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new ProguardDetector(); - } - - public void testProguard() throws Exception { - assertEquals( - "proguard.cfg:21: Error: Obsolete ProGuard file; use -keepclasseswithmembers instead of -keepclasseswithmembernames [Proguard]\n" + - "-keepclasseswithmembernames class * {\n" + - "^\n" + - "1 errors, 0 warnings\n" + - "", - lintFiles("proguard.cfg")); - } - - public void testProguardNewPath() throws Exception { - assertEquals( - "proguard-project.txt:21: Error: Obsolete ProGuard file; use -keepclasseswithmembers instead of -keepclasseswithmembernames [Proguard]\n" + - "-keepclasseswithmembernames class * {\n" + - "^\n" + - "1 errors, 0 warnings\n" + - "", - lintFiles("proguard.cfg=>proguard-project.txt")); - } - - public void testProguardRandomName() throws Exception { - assertEquals( - "myfile.txt:21: Error: Obsolete ProGuard file; use -keepclasseswithmembers instead of -keepclasseswithmembernames [Proguard]\n" + - "-keepclasseswithmembernames class * {\n" + - "^\n" + - "myfile.txt:8: Warning: Local ProGuard configuration contains general Android configuration: Inherit these settings instead? Modify project.properties to define proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:myfile.txt and then keep only project-specific configuration here [ProguardSplit]\n" + - "-keep public class * extends android.app.Activity\n" + - "^\n" + - "1 errors, 1 warnings\n" + - "", - lintProject( - "proguard.cfg=>myfile.txt", - "proguard.properties=>project.properties")); - } - - public void testSilent() throws Exception { - assertEquals( - "No warnings.", - - lintFiles( - "proguard.pro=>proguard.cfg", - "project.properties1=>project.properties")); - } - - public void testSilent2() throws Exception { - assertEquals( - "No warnings.", - - lintFiles( - "proguard.pro=>proguard.cfg", - "project.properties3=>project.properties")); - } - - public void testSplit() throws Exception { - assertEquals( - "proguard.cfg:14: Warning: Local ProGuard configuration contains general Android configuration: Inherit these settings instead? Modify project.properties to define proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard.cfg and then keep only project-specific configuration here [ProguardSplit]\n" + - "-keep public class * extends android.app.Activity\n" + - "^\n" + - "0 errors, 1 warnings\n" + - "", - - lintFiles( - "proguard.pro=>proguard.cfg", - "project.properties2=>project.properties")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/PxUsageDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/PxUsageDetectorTest.java deleted file mode 100644 index 68f218f..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/PxUsageDetectorTest.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class PxUsageDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new PxUsageDetector(); - } - - public void testPx() throws Exception { - assertEquals( - "res/layout/now_playing_after.xml:49: Warning: Avoid using \"mm\" as units (it does not work accurately on all devices); use \"dp\" instead [InOrMmUsage]\n" + - " android:layout_width=\"100mm\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/now_playing_after.xml:50: Warning: Avoid using \"in\" as units (it does not work accurately on all devices); use \"dp\" instead [InOrMmUsage]\n" + - " android:layout_height=\"120in\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/now_playing_after.xml:41: Warning: Avoid using \"px\" as units; use \"dp\" instead [PxUsage]\n" + - " android:layout_width=\"1px\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "0 errors, 3 warnings\n", - lintFiles("res/layout/now_playing_after.xml")); - } - - public void testSp() throws Exception { - assertEquals( - "res/layout/textsize.xml:11: Warning: Should use \"sp\" instead of \"dp\" for text sizes [SpUsage]\n" + - " android:textSize=\"14dp\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/textsize.xml:16: Warning: Should use \"sp\" instead of \"dp\" for text sizes [SpUsage]\n" + - " android:textSize=\"14dip\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/textsize.xml:33: Warning: Avoid using sizes smaller than 12sp: 11sp [SmallSp]\n" + - " android:textSize=\"11sp\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/textsize.xml:37: Warning: Avoid using sizes smaller than 12sp: 6sp [SmallSp]\n" + - " android:layout_height=\"6sp\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "0 errors, 4 warnings\n", - - lintFiles("res/layout/textsize.xml")); - } - - public void testStyles() throws Exception { - assertEquals( - "res/values/pxsp.xml:23: Warning: Avoid using \"mm\" as units (it does not work accurately on all devices); use \"dp\" instead [InOrMmUsage]\n" + - " <item name=\"android:textSize\">50mm</item>\n" + - " ^\n" + - "res/values/pxsp.xml:25: Warning: Avoid using \"in\" as units (it does not work accurately on all devices); use \"dp\" instead [InOrMmUsage]\n" + - " 50in\n" + - " ^\n" + - "res/values/pxsp.xml:6: Warning: Should use \"sp\" instead of \"dp\" for text sizes [SpUsage]\n" + - " <item name=\"android:textSize\">50dp</item>\n" + - " ^\n" + - "res/values/pxsp.xml:12: Warning: Should use \"sp\" instead of \"dp\" for text sizes [SpUsage]\n" + - " <item name=\"android:textSize\"> 50dip </item>\n" + - " ^\n" + - "res/values/pxsp.xml:9: Warning: Avoid using \"px\" as units; use \"dp\" instead [PxUsage]\n" + - " <item name=\"android:textSize\">50px</item>\n" + - " ^\n" + - "res/values/pxsp.xml:17: Warning: Avoid using \"px\" as units; use \"dp\" instead [PxUsage]\n" + - " <item name=\"android:paddingRight\"> 50px </item>\n" + - " ^\n" + - "res/values/pxsp.xml:18: Warning: Avoid using \"px\" as units; use \"dp\" instead [PxUsage]\n" + - " <item name=\"android:paddingTop\">50px</item>\n" + - " ^\n" + - "0 errors, 7 warnings\n", - - lintFiles("res/values/pxsp.xml")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/RegistrationDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/RegistrationDetectorTest.java deleted file mode 100644 index 23a5ac3..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/RegistrationDetectorTest.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class RegistrationDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new RegistrationDetector(); - } - - public void testRegistered() throws Exception { - assertEquals( - "src/test/pkg/OnClickActivity.java:8: Warning: The <activity> test.pkg.OnClickActivity is not registered in the manifest [Registered]\n" + - "public class OnClickActivity extends Activity {\n" + - " ~~~~~~~~~~~~~~~\n" + - "src/test/pkg/TestProvider.java:8: Warning: The <provider> test.pkg.TestProvider is not registered in the manifest [Registered]\n" + - "public class TestProvider extends ContentProvider {\n" + - " ~~~~~~~~~~~~\n" + - "src/test/pkg/TestProvider2.java:3: Warning: The <provider> test.pkg.TestProvider2 is not registered in the manifest [Registered]\n" + - "public class TestProvider2 extends TestProvider {\n" + - "^\n" + - "src/test/pkg/TestService.java:7: Warning: The <service> test.pkg.TestService is not registered in the manifest [Registered]\n" + - "public class TestService extends Service {\n" + - " ~~~~~~~~~~~\n" + - "0 errors, 4 warnings\n" + - "", - - lintProject( - "bytecode/.classpath=>.classpath", - "bytecode/OnClickActivity.java.txt=>src/test/pkg/OnClickActivity.java", - "bytecode/OnClickActivity.class.data=>bin/classes/test/pkg/OnClickActivity.class", - "bytecode/TestService.java.txt=>src/test/pkg/TestService.java", - "bytecode/TestService.class.data=>bin/classes/test/pkg/TestService.class", - "bytecode/TestProvider.java.txt=>src/test/pkg/TestProvider.java", - "bytecode/TestProvider.class.data=>bin/classes/test/pkg/TestProvider.class", - "bytecode/TestProvider2.java.txt=>src/test/pkg/TestProvider2.java", - "bytecode/TestProvider2.class.data=>bin/classes/test/pkg/TestProvider2.class", - "bytecode/TestReceiver.java.txt=>src/test/pkg/TestReceiver.java", - "bytecode/TestReceiver.class.data=>bin/classes/test/pkg/TestReceiver.class" - )); - } - - public void testNoDot() throws Exception { - assertEquals( - "No warnings.", - - lintProject( - "bytecode/AndroidManifestReg.xml=>AndroidManifest.xml", - "bytecode/.classpath=>.classpath", - "bytecode/CommentsActivity.java.txt=>src/test/pkg/Foo/CommentsActivity.java", - "bytecode/CommentsActivity.class.data=>bin/classes/test/pkg/Foo/CommentsActivity.class" - )); - } - - public void testWrongRegistrations() throws Exception { - assertEquals( - "src/test/pkg/OnClickActivity.java:8: Warning: test.pkg.OnClickActivity is a <activity> but is registered in the manifest as a <receiver> [Registered]\n" + - "public class OnClickActivity extends Activity {\n" + - " ~~~~~~~~~~~~~~~\n" + - "src/test/pkg/TestProvider.java:8: Warning: test.pkg.TestProvider is a <provider> but is registered in the manifest as a <activity> [Registered]\n" + - "public class TestProvider extends ContentProvider {\n" + - " ~~~~~~~~~~~~\n" + - "src/test/pkg/TestProvider2.java:3: Warning: test.pkg.TestProvider2 is a <provider> but is registered in the manifest as a <service> [Registered]\n" + - "public class TestProvider2 extends TestProvider {\n" + - "^\n" + - "src/test/pkg/TestReceiver.java:7: Warning: test.pkg.TestReceiver is a <receiver> but is registered in the manifest as a <service> [Registered]\n" + - "public class TestReceiver extends BroadcastReceiver {\n" + - " ~~~~~~~~~~~~\n" + - "src/test/pkg/TestService.java:7: Warning: test.pkg.TestService is a <service> but is registered in the manifest as a <provider> [Registered]\n" + - "public class TestService extends Service {\n" + - " ~~~~~~~~~~~\n" + - "0 errors, 5 warnings\n" + - "", - - lintProject( - "bytecode/.classpath=>.classpath", - "bytecode/AndroidManifestWrongRegs.xml=>AndroidManifest.xml", - "bytecode/OnClickActivity.java.txt=>src/test/pkg/OnClickActivity.java", - "bytecode/OnClickActivity.class.data=>bin/classes/test/pkg/OnClickActivity.class", - "bytecode/AbstractActivity.java.txt=>src/test/pkg/AbstractActivity.java", - "bytecode/AbstractActivity.class.data=>bin/classes/test/pkg/AbstractActivity.class", - "bytecode/TestService.java.txt=>src/test/pkg/TestService.java", - "bytecode/TestService.class.data=>bin/classes/test/pkg/TestService.class", - "bytecode/TestProvider.java.txt=>src/test/pkg/TestProvider.java", - "bytecode/TestProvider.class.data=>bin/classes/test/pkg/TestProvider.class", - "bytecode/TestProvider2.java.txt=>src/test/pkg/TestProvider2.java", - "bytecode/TestProvider2.class.data=>bin/classes/test/pkg/TestProvider2.class", - "bytecode/TestReceiver.java.txt=>src/test/pkg/TestReceiver.java", - "bytecode/TestReceiver.class.data=>bin/classes/test/pkg/TestReceiver.class", - "bytecode/TestReceiver$1.class.data=>bin/classes/test/pkg/TestReceiver$1.class" - )); - } - - public void testLibraryProjects() throws Exception { - // If a library project provides additional activities, it is not an error to - // not register all of those here - assertEquals( - "No warnings.", - - lintProject( - // Master project - "multiproject/main-manifest.xml=>AndroidManifest.xml", - "multiproject/main.properties=>project.properties", - - // Library project - "multiproject/library-manifest.xml=>../LibraryProject/AndroidManifest.xml", - "multiproject/library.properties=>../LibraryProject/project.properties", - - "bytecode/.classpath=>../LibraryProject/.classpath", - "bytecode/OnClickActivity.java.txt=>../LibraryProject/src/test/pkg/OnClickActivity.java", - "bytecode/OnClickActivity.class.data=>../LibraryProject/bin/classes/test/pkg/OnClickActivity.class" - )); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/RequiredAttributeDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/RequiredAttributeDetectorTest.java deleted file mode 100644 index 9b60532..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/RequiredAttributeDetectorTest.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class RequiredAttributeDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new RequiredAttributeDetector(); - } - - public void test() throws Exception { - // Simple: Only consider missing attributes in the layout xml file - // (though skip warnings on <merge> tags and under <GridLayout> - assertEquals( - "res/layout/size.xml:13: Error: The required layout_height attribute is missing [RequiredSize]\n" + - " <RadioButton\n" + - " ^\n" + - "res/layout/size.xml:18: Error: The required layout_width attribute is missing [RequiredSize]\n" + - " <EditText\n" + - " ^\n" + - "res/layout/size.xml:23: Error: The required layout_width and layout_height attributes are missing [RequiredSize]\n" + - " <EditText\n" + - " ^\n" + - "3 errors, 0 warnings\n", - - lintProject("res/layout/size.xml")); - } - - public void test2() throws Exception { - // Consider styles (specifying sizes) and includes (providing sizes for the root tags) - assertEquals( - "res/layout/size2.xml:9: Error: The required layout_width and layout_height attributes are missing [RequiredSize]\n" + - " <Button\n" + - " ^\n" + - "res/layout/size2.xml:18: Error: The required layout_height attribute is missing [RequiredSize]\n" + - " <Button\n" + - " ^\n" + - "2 errors, 0 warnings\n", - - lintProject( - "res/layout/size2.xml", - "res/layout/sizeincluded.xml", - "res/values/sizestyles.xml" - )); - } - - public void testInflaters() throws Exception { - // Consider java inflation - assertEquals( - "res/layout/size5.xml:2: Error: The required layout_width and layout_height attributes are missing [RequiredSize]\n" + - "<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" + - "^\n" + - "1 errors, 0 warnings\n", - - lintProject( - "src/test/pkg/InflaterTest.java.txt=>src/test/pkg/InflaterTest.java", - "res/layout/sizeincluded.xml=>res/layout/size1.xml", - "res/layout/sizeincluded.xml=>res/layout/size2.xml", - "res/layout/sizeincluded.xml=>res/layout/size3.xml", - "res/layout/sizeincluded.xml=>res/layout/size4.xml", - "res/layout/sizeincluded.xml=>res/layout/size5.xml", - "res/layout/sizeincluded.xml=>res/layout/size6.xml", - "res/layout/sizeincluded.xml=>res/layout/size7.xml" - )); - } - - public void testRequestFocus() throws Exception { - // See http://code.google.com/p/android/issues/detail?id=38700 - assertEquals( - "No warnings.", - - lintProject( - "res/layout/edit_type.xml" - )); - } - - public void testFrameworkStyles() throws Exception { - // See http://code.google.com/p/android/issues/detail?id=38958 - assertEquals( - "No warnings.", - - lintProject( - "res/layout/listseparator.xml" - )); - } - - public void testThemeStyles() throws Exception { - // Check that we don't complain about cases where the size is defined in a theme - assertEquals( - "No warnings.", - - lintProject( - "res/layout/size.xml", - "res/values/themes.xml" - )); - } - - public void testThemeStyles2() throws Exception { - // Check that we don't complain about cases where the size is defined in a theme - assertEquals( - "No warnings.", - - lintProject( - "res/layout/size.xml", - "res/values/themes2.xml" - )); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/ScrollViewChildDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/ScrollViewChildDetectorTest.java deleted file mode 100644 index ba79c50..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/ScrollViewChildDetectorTest.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class ScrollViewChildDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new ScrollViewChildDetector(); - } - - public void testScrollView() throws Exception { - assertEquals( - "res/layout/wrong_dimension.xml:10: Warning: This LinearLayout should use android:layout_width=\"wrap_content\" [ScrollViewSize]\n" + - " android:layout_width=\"match_parent\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "0 errors, 1 warnings\n" + - "", - lintFiles("res/layout/wrong_dimension.xml")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/SdCardDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/SdCardDetectorTest.java deleted file mode 100644 index 5ad46b9..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/SdCardDetectorTest.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class SdCardDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new SdCardDetector(); - } - - public void test() throws Exception { - assertEquals( - "src/test/pkg/SdCardTest.java:13: Warning: Do not hardcode \"/sdcard/\"; use Environment.getExternalStorageDirectory().getPath() instead [SdCardPath]\n" + - " private static final String SDCARD_TEST_HTML = \"/sdcard/test.html\";\n" + - " ~~~~~~~~~~~~~~~~~~~\n" + - "src/test/pkg/SdCardTest.java:14: Warning: Do not hardcode \"/sdcard/\"; use Environment.getExternalStorageDirectory().getPath() instead [SdCardPath]\n" + - " public static final String SDCARD_ROOT = \"/sdcard\";\n" + - " ~~~~~~~~~\n" + - "src/test/pkg/SdCardTest.java:15: Warning: Do not hardcode \"/sdcard/\"; use Environment.getExternalStorageDirectory().getPath() instead [SdCardPath]\n" + - " public static final String PACKAGES_PATH = \"/sdcard/o/packages/\";\n" + - " ~~~~~~~~~~~~~~~~~~~~~\n" + - "src/test/pkg/SdCardTest.java:16: Warning: Do not hardcode \"/sdcard/\"; use Environment.getExternalStorageDirectory().getPath() instead [SdCardPath]\n" + - " File deviceDir = new File(\"/sdcard/vr\");\n" + - " ~~~~~~~~~~~~\n" + - "src/test/pkg/SdCardTest.java:20: Warning: Do not hardcode \"/sdcard/\"; use Environment.getExternalStorageDirectory().getPath() instead [SdCardPath]\n" + - " android.os.Debug.startMethodTracing(\"/sdcard/launcher\");\n" + - " ~~~~~~~~~~~~~~~~~~\n" + - "src/test/pkg/SdCardTest.java:22: Warning: Do not hardcode \"/sdcard/\"; use Environment.getExternalStorageDirectory().getPath() instead [SdCardPath]\n" + - " if (new File(\"/sdcard\").exists()) {\n" + - " ~~~~~~~~~\n" + - "src/test/pkg/SdCardTest.java:24: Warning: Do not hardcode \"/sdcard/\"; use Environment.getExternalStorageDirectory().getPath() instead [SdCardPath]\n" + - " String FilePath = \"/sdcard/\" + new File(\"test\");\n" + - " ~~~~~~~~~~\n" + - "src/test/pkg/SdCardTest.java:29: Warning: Do not hardcode \"/sdcard/\"; use Environment.getExternalStorageDirectory().getPath() instead [SdCardPath]\n" + - " intent.setDataAndType(Uri.parse(\"file://sdcard/foo.json\"), \"application/bar-json\");\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "src/test/pkg/SdCardTest.java:30: Warning: Do not hardcode \"/sdcard/\"; use Environment.getExternalStorageDirectory().getPath() instead [SdCardPath]\n" + - " intent.putExtra(\"path-filter\", \"/sdcard(/.+)*\");\n" + - " ~~~~~~~~~~~~~~~\n" + - "src/test/pkg/SdCardTest.java:31: Warning: Do not hardcode \"/sdcard/\"; use Environment.getExternalStorageDirectory().getPath() instead [SdCardPath]\n" + - " intent.putExtra(\"start-dir\", \"/sdcard\");\n" + - " ~~~~~~~~~\n" + - "src/test/pkg/SdCardTest.java:32: Warning: Do not hardcode \"/data/\"; use Context.getFilesDir().getPath() instead [SdCardPath]\n" + - " String mypath = \"/data/data/foo\";\n" + - " ~~~~~~~~~~~~~~~~\n" + - "src/test/pkg/SdCardTest.java:33: Warning: Do not hardcode \"/data/\"; use Context.getFilesDir().getPath() instead [SdCardPath]\n" + - " String base = \"/data/data/foo.bar/test-profiling\";\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "src/test/pkg/SdCardTest.java:34: Warning: Do not hardcode \"/sdcard/\"; use Environment.getExternalStorageDirectory().getPath() instead [SdCardPath]\n" + - " String s = \"file://sdcard/foo\";\n" + - " ~~~~~~~~~~~~~~~~~~~\n" + - "0 errors, 13 warnings\n", - - lintProject("src/test/pkg/SdCardTest.java.txt=>src/test/pkg/SdCardTest.java")); - } - - public void testSuppress() throws Exception { - assertEquals( - // The only reference in the file not covered by an annotation - "src/test/pkg/SuppressTest5.java:40: Warning: Do not hardcode \"/sdcard/\"; use Environment.getExternalStorageDirectory().getPath() instead [SdCardPath]\n" + - " String notAnnotated = \"/sdcard/mypath\";\n" + - " ~~~~~~~~~~~~~~~~\n" + - "0 errors, 1 warnings\n" + - "", - - // File with lots of /sdcard references, but with @SuppressLint warnings - // on fields, methods, variable declarations etc - lintProject("src/test/pkg/SuppressTest5.java.txt=>src/test/pkg/SuppressTest5.java")); - } - - public void testUtf8Bom() throws Exception { - assertEquals( - "src/test/pkg/Utf8BomTest.java:4: Warning: Do not hardcode \"/sdcard/\"; use Environment.getExternalStorageDirectory().getPath() instead [SdCardPath]\n" + - " String s = \"/sdcard/mydir\";\n" + - " ~~~~~~~~~~~~~~~\n" + - "0 errors, 1 warnings\n" + - "", - - lintProject("src/test/pkg/Utf8BomTest.java.data=>src/test/pkg/Utf8BomTest.java")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/SecureRandomDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/SecureRandomDetectorTest.java deleted file mode 100644 index 0ecbe02..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/SecureRandomDetectorTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class SecureRandomDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new SecureRandomDetector(); - } - - public void test1() throws Exception { - assertEquals( - "src/test/pkg/SecureRandomTest.java:12: Warning: It is dangerous to seed SecureRandom with the current time because that value is more predictable to an attacker than the default seed. [SecureRandom]\n" + - " random1.setSeed(System.currentTimeMillis()); // OK\n" + - " ~~~~~~~\n" + - "src/test/pkg/SecureRandomTest.java:14: Warning: Do not call setSeed() on a SecureRandom with a fixed seed: it is not secure. Use getSeed(). [SecureRandom]\n" + - " random1.setSeed(0); // Wrong\n" + - " ~~~~~~~\n" + - "src/test/pkg/SecureRandomTest.java:15: Warning: Do not call setSeed() on a SecureRandom with a fixed seed: it is not secure. Use getSeed(). [SecureRandom]\n" + - " random1.setSeed(1); // Wrong\n" + - " ~~~~~~~\n" + - "src/test/pkg/SecureRandomTest.java:16: Warning: Do not call setSeed() on a SecureRandom with a fixed seed: it is not secure. Use getSeed(). [SecureRandom]\n" + - " random1.setSeed((int)1023); // Wrong\n" + - " ~~~~~~~\n" + - "src/test/pkg/SecureRandomTest.java:17: Warning: Do not call setSeed() on a SecureRandom with a fixed seed: it is not secure. Use getSeed(). [SecureRandom]\n" + - " random1.setSeed(1023L); // Wrong\n" + - " ~~~~~~~\n" + - "src/test/pkg/SecureRandomTest.java:18: Warning: Do not call setSeed() on a SecureRandom with a fixed seed: it is not secure. Use getSeed(). [SecureRandom]\n" + - " random1.setSeed(FIXED_SEED); // Wrong\n" + - " ~~~~~~~\n" + - "src/test/pkg/SecureRandomTest.java:28: Warning: Do not call setSeed() on a SecureRandom with a fixed seed: it is not secure. Use getSeed(). [SecureRandom]\n" + - " random3.setSeed(0); // Wrong: owner is java/util/Random, but applied to SecureRandom object\n" + - " ~~~~~~~\n" + - "0 errors, 7 warnings\n" + - "", - // Missing error on line 40, using flow analysis to determine that the seed byte - // array passed into the SecureRandom constructor is static. - - lintProject( - "bytecode/.classpath=>.classpath", - "bytecode/AndroidManifest.xml=>AndroidManifest.xml", - "res/layout/onclick.xml=>res/layout/onclick.xml", - "bytecode/SecureRandomTest.java.txt=>src/test/pkg/SecureRandomTest.java", - "bytecode/SecureRandomTest.class.data=>bin/classes/test/pkg/SecureRandomTest.class" - )); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/SecurityDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/SecurityDetectorTest.java deleted file mode 100644 index 198058d..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/SecurityDetectorTest.java +++ /dev/null @@ -1,213 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class SecurityDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new SecurityDetector(); - } - - public void testBroken() throws Exception { - assertEquals( - "AndroidManifest.xml:12: Warning: Exported service does not require permission [ExportedService]\n" + - " <service\n" + - " ^\n" + - "0 errors, 1 warnings\n" + - "", - lintProject( - "exportservice1.xml=>AndroidManifest.xml", - "res/values/strings.xml")); - } - - public void testBroken2() throws Exception { - assertEquals( - "AndroidManifest.xml:12: Warning: Exported service does not require permission [ExportedService]\n" + - " <service\n" + - " ^\n" + - "0 errors, 1 warnings\n" + - "", - lintProject( - "exportservice2.xml=>AndroidManifest.xml", - "res/values/strings.xml")); - } - - public void testBroken3() throws Exception { - // Not defining exported, but have intent-filters - assertEquals( - "AndroidManifest.xml:12: Warning: Exported service does not require permission [ExportedService]\n" + - " <service\n" + - " ^\n" + - "0 errors, 1 warnings\n" + - "", - lintProject( - "exportservice5.xml=>AndroidManifest.xml", - "res/values/strings.xml")); - } - - public void testOk1() throws Exception { - // Defines a permission on the <service> element - assertEquals( - "No warnings.", - lintProject( - "exportservice3.xml=>AndroidManifest.xml", - "res/values/strings.xml")); - } - - public void testOk2() throws Exception { - // Defines a permission on the parent <application> element - assertEquals( - "No warnings.", - lintProject( - "exportservice4.xml=>AndroidManifest.xml", - "res/values/strings.xml")); - } - - public void testUri() throws Exception { - assertEquals( - "AndroidManifest.xml:25: Warning: Content provider shares everything; this is potentially dangerous. [GrantAllUris]\n" + - " <grant-uri-permission android:path=\"/\"/>\n" + - " ~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:26: Warning: Content provider shares everything; this is potentially dangerous. [GrantAllUris]\n" + - " <grant-uri-permission android:pathPrefix=\"/\"/>\n" + - " ~~~~~~~~~~~~~~~~~~~~~~\n" + - "0 errors, 2 warnings\n" + - "", - - lintProject( - "grantpermission.xml=>AndroidManifest.xml", - "res/values/strings.xml")); - } - - // exportprovider1.xml has two exported content providers with no permissions - public void testContentProvider1() throws Exception { - assertEquals( - "AndroidManifest.xml:14: Warning: Exported content providers can provide access to potentially sensitive data [ExportedContentProvider]\n" + - " <provider\n" + - " ^\n" + - "AndroidManifest.xml:20: Warning: Exported content providers can provide access to potentially sensitive data [ExportedContentProvider]\n" + - " <provider\n" + - " ^\n" + - "0 errors, 2 warnings\n" + - "", - lintProject( - "exportprovider1.xml=>AndroidManifest.xml", - "res/values/strings.xml")); - } - - // exportprovider2.xml has no un-permissioned exported content providers - public void testContentProvider2() throws Exception { - assertEquals( - "No warnings.", - lintProject( - "exportprovider2.xml=>AndroidManifest.xml", - "res/values/strings.xml")); - } - - public void testWorldWriteable() throws Exception { - assertEquals( - "src/test/pkg/WorldWriteableFile.java:26: Warning: Using MODE_WORLD_READABLE when creating files can be risky, review carefully [WorldReadableFiles]\n" + - " out = openFileOutput(mFile.getName(), MODE_WORLD_READABLE);\n" + - " ~~~~~~~~~~~~~~~~~~~\n" + - "src/test/pkg/WorldWriteableFile.java:31: Warning: Using MODE_WORLD_READABLE when creating files can be risky, review carefully [WorldReadableFiles]\n" + - " prefs = getSharedPreferences(mContext, MODE_WORLD_READABLE);\n" + - " ~~~~~~~~~~~~~~~~~~~\n" + - "src/test/pkg/WorldWriteableFile.java:25: Warning: Using MODE_WORLD_WRITEABLE when creating files can be risky, review carefully [WorldWriteableFiles]\n" + - " out = openFileOutput(mFile.getName(), MODE_WORLD_WRITEABLE);\n" + - " ~~~~~~~~~~~~~~~~~~~~\n" + - "src/test/pkg/WorldWriteableFile.java:30: Warning: Using MODE_WORLD_WRITEABLE when creating files can be risky, review carefully [WorldWriteableFiles]\n" + - " prefs = getSharedPreferences(mContext, MODE_WORLD_WRITEABLE);\n" + - " ~~~~~~~~~~~~~~~~~~~~\n" + - "0 errors, 4 warnings\n" + - "", - - lintProject( - // Java files must be renamed in source tree - "src/test/pkg/WorldWriteableFile.java.txt=>src/test/pkg/WorldWriteableFile.java")); - } - - public void testReceiver0() throws Exception { - // Activities that do not have intent-filters do not need warnings - assertEquals( - "No warnings.", - lintProject( - "exportreceiver0.xml=>AndroidManifest.xml", - "res/values/strings.xml")); - } - - public void testReceiver1() throws Exception { - assertEquals( - "AndroidManifest.xml:12: Warning: Exported receiver does not require permission [ExportedReceiver]\n" + - " <receiver\n" + - " ^\n" + - "0 errors, 1 warnings\n" + - "", - lintProject( - "exportreceiver1.xml=>AndroidManifest.xml", - "res/values/strings.xml")); - } - - public void testReceiver2() throws Exception { - // Defines a permission on the <activity> element - assertEquals( - "No warnings.", - lintProject( - "exportreceiver2.xml=>AndroidManifest.xml", - "res/values/strings.xml")); - } - - public void testReceiver3() throws Exception { - // Defines a permission on the parent <application> element - assertEquals( - "No warnings.", - lintProject( - "exportreceiver3.xml=>AndroidManifest.xml", - "res/values/strings.xml")); - } - - public void testReceiver4() throws Exception { - // Not defining exported, but have intent-filters - assertEquals( - "AndroidManifest.xml:12: Warning: Exported receiver does not require permission [ExportedReceiver]\n" + - " <receiver\n" + - " ^\n" + - "0 errors, 1 warnings\n" + - "", - lintProject( - "exportreceiver4.xml=>AndroidManifest.xml", - "res/values/strings.xml")); - } - - public void testReceiver5() throws Exception { - // Intent filter for standard Android action - assertEquals( - "No warnings.", - lintProject( - "exportreceiver5.xml=>AndroidManifest.xml", - "res/values/strings.xml")); - } - - public void testStandard() throws Exception { - // Various regression tests for http://code.google.com/p/android/issues/detail?id=33976 - assertEquals( - "No warnings.", - lintProject("exportreceiver6.xml=>AndroidManifest.xml")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/SetJavaScriptEnabledDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/SetJavaScriptEnabledDetectorTest.java deleted file mode 100644 index 4979e6a..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/SetJavaScriptEnabledDetectorTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class SetJavaScriptEnabledDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new SetJavaScriptEnabledDetector(); - } - - public void test() throws Exception { - assertEquals( - "src/test/pkg/SetJavaScriptEnabled.java:14: Warning: Using setJavaScriptEnabled can introduce XSS vulnerabilities into you application, review carefully. [SetJavaScriptEnabled]\n" + - " webView.getSettings().setJavaScriptEnabled(true); // bad\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "0 errors, 1 warnings\n" + - "", - lintProject( - "src/test/pkg/SetJavaScriptEnabled.java.txt=>src/test/pkg/SetJavaScriptEnabled.java")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/SharedPrefsDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/SharedPrefsDetectorTest.java deleted file mode 100644 index 7035c21..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/SharedPrefsDetectorTest.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class SharedPrefsDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new SharedPrefsDetector(); - } - - public void test() throws Exception { - assertEquals( - "src/test/pkg/SharedPrefsTest.java:54: Warning: SharedPreferences.edit() without a corresponding commit() or apply() call [CommitPrefEdits]\n" + - " SharedPreferences.Editor editor = preferences.edit();\n" + - " ~~~~~~~~~~~~~~~~~~\n" + - "src/test/pkg/SharedPrefsTest.java:62: Warning: SharedPreferences.edit() without a corresponding commit() or apply() call [CommitPrefEdits]\n" + - " SharedPreferences.Editor editor = preferences.edit();\n" + - " ~~~~~~~~~~~~~~~~~~\n" + - "0 errors, 2 warnings\n" + - "", - - lintProject("src/test/pkg/SharedPrefsTest.java.txt=>" + - "src/test/pkg/SharedPrefsTest.java")); - } - - public void test2() throws Exception { - // Regression test 1 for http://code.google.com/p/android/issues/detail?id=34322 - assertEquals( - "src/test/pkg/SharedPrefsTest2.java:13: Warning: SharedPreferences.edit() without a corresponding commit() or apply() call [CommitPrefEdits]\n" + - " SharedPreferences.Editor editor = preferences.edit();\n" + - " ~~~~~~~~~~~~~~~~~~\n" + - "src/test/pkg/SharedPrefsTest2.java:17: Warning: SharedPreferences.edit() without a corresponding commit() or apply() call [CommitPrefEdits]\n" + - " Editor editor = preferences.edit();\n" + - " ~~~~~~~~~~~~~~~~~~\n" + - "0 errors, 2 warnings\n", - - lintProject("src/test/pkg/SharedPrefsTest2.java.txt=>" + - "src/test/pkg/SharedPrefsTest2.java")); - } - - public void test3() throws Exception { - // Regression test 2 for http://code.google.com/p/android/issues/detail?id=34322 - assertEquals( - "src/test/pkg/SharedPrefsTest3.java:13: Warning: SharedPreferences.edit() without a corresponding commit() or apply() call [CommitPrefEdits]\n" + - " Editor editor = preferences.edit();\n" + - " ~~~~~~~~~~~~~~~~~~\n" + - "0 errors, 1 warnings\n", - - lintProject("src/test/pkg/SharedPrefsTest3.java.txt=>" + - "src/test/pkg/SharedPrefsTest3.java")); - } - - public void test4() throws Exception { - // Regression test 3 for http://code.google.com/p/android/issues/detail?id=34322 - assertEquals( - "No warnings.", - - lintProject("src/test/pkg/SharedPrefsTest4.java.txt=>" + - "src/test/pkg/SharedPrefsTest4.java")); - } - - public void test5() throws Exception { - // Check fields too: http://code.google.com/p/android/issues/detail?id=39134 - assertEquals( - "src/test/pkg/SharedPrefsTest5.java:16: Warning: SharedPreferences.edit() without a corresponding commit() or apply() call [CommitPrefEdits]\n" + - " mPreferences.edit().putString(PREF_FOO, \"bar\");\n" + - " ~~~~~~~~~~~~~~~~~~~\n" + - "src/test/pkg/SharedPrefsTest5.java:17: Warning: SharedPreferences.edit() without a corresponding commit() or apply() call [CommitPrefEdits]\n" + - " mPreferences.edit().remove(PREF_BAZ).remove(PREF_FOO);\n" + - " ~~~~~~~~~~~~~~~~~~~\n" + - "src/test/pkg/SharedPrefsTest5.java:26: Warning: SharedPreferences.edit() without a corresponding commit() or apply() call [CommitPrefEdits]\n" + - " preferences.edit().putString(PREF_FOO, \"bar\");\n" + - " ~~~~~~~~~~~~~~~~~~\n" + - "src/test/pkg/SharedPrefsTest5.java:27: Warning: SharedPreferences.edit() without a corresponding commit() or apply() call [CommitPrefEdits]\n" + - " preferences.edit().remove(PREF_BAZ).remove(PREF_FOO);\n" + - " ~~~~~~~~~~~~~~~~~~\n" + - "src/test/pkg/SharedPrefsTest5.java:32: Warning: SharedPreferences.edit() without a corresponding commit() or apply() call [CommitPrefEdits]\n" + - " preferences.edit().putString(PREF_FOO, \"bar\");\n" + - " ~~~~~~~~~~~~~~~~~~\n" + - "src/test/pkg/SharedPrefsTest5.java:33: Warning: SharedPreferences.edit() without a corresponding commit() or apply() call [CommitPrefEdits]\n" + - " preferences.edit().remove(PREF_BAZ).remove(PREF_FOO);\n" + - " ~~~~~~~~~~~~~~~~~~\n" + - "src/test/pkg/SharedPrefsTest5.java:38: Warning: SharedPreferences.edit() without a corresponding commit() or apply() call [CommitPrefEdits]\n" + - " Editor editor = preferences.edit().putString(PREF_FOO, \"bar\");\n" + - " ~~~~~~~~~~~~~~~~~~\n" + - "0 errors, 7 warnings\n", - - lintProject("src/test/pkg/SharedPrefsTest5.java.txt=>" + - "src/test/pkg/SharedPrefsTest5.java")); - } - -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/StateListDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/StateListDetectorTest.java deleted file mode 100644 index 9ff67f4..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/StateListDetectorTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class StateListDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new StateListDetector(); - } - - public void testStates() throws Exception { - assertEquals( - "res/drawable/states.xml:3: Warning: This item is unreachable because a previous item (item #1) is a more general match than this one [StateListReachable]\n" + - " <item android:state_pressed=\"true\"\n" + - " ^\n" + - " res/drawable/states.xml:2: Earlier item which masks item\n" + - "0 errors, 1 warnings\n" + - "", - lintProject("res/drawable/states.xml")); - } - - public void testCustomStates() throws Exception { - assertEquals( - "No warnings.", - lintProject("res/drawable/states2.xml")); - } - - public void testStates3() throws Exception { - assertEquals( - "res/drawable/states3.xml:24: Warning: This item is unreachable because a previous item (item #1) is a more general match than this one [StateListReachable]\n" + - " <item android:state_checked=\"false\" android:state_window_focused=\"false\"\n" + - " ^\n" + - " res/drawable/states3.xml:18: Earlier item which masks item\n" + - "0 errors, 1 warnings\n" + - "", - lintProject("res/drawable/states3.xml")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/StringFormatDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/StringFormatDetectorTest.java deleted file mode 100644 index 47fbea1..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/StringFormatDetectorTest.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import static com.android.tools.lint.checks.StringFormatDetector.isLocaleSpecific; - -import com.android.tools.lint.detector.api.Detector; - -import java.util.HashSet; -import java.util.Set; - -@SuppressWarnings("javadoc") -public class StringFormatDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new StringFormatDetector(); - } - - public void testAll() throws Exception { - assertEquals( - "src/test/pkg/StringFormatActivity.java:13: Error: Wrong argument type for formatting argument '#1' in hello: conversion is 'd', received String [StringFormatMatches]\n" + - " String output1 = String.format(hello, target);\n" + - " ~~~~~~\n" + - " res/values-es/formatstrings.xml:3: Conflicting argument declaration here\n" + - "src/test/pkg/StringFormatActivity.java:15: Error: Wrong argument count, format string hello2 requires 3 but format call supplies 2 [StringFormatMatches]\n" + - " String output2 = String.format(hello2, target, \"How are you\");\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - " res/values-es/formatstrings.xml:4: This definition requires 3 arguments\n" + - "src/test/pkg/StringFormatActivity.java:24: Error: Wrong argument count, format string hello2 requires 3 but format call supplies 2 [StringFormatMatches]\n" + - " String.format(getResources().getString(R.string.hello2), target, \"How are you\");\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - " res/values-es/formatstrings.xml:4: This definition requires 3 arguments\n" + - "src/test/pkg/StringFormatActivity.java:25: Error: Wrong argument count, format string hello2 requires 3 but format call supplies 2 [StringFormatMatches]\n" + - " getResources().getString(hello2, target, \"How are you\");\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - " res/values-es/formatstrings.xml:4: This definition requires 3 arguments\n" + - "src/test/pkg/StringFormatActivity.java:26: Error: Wrong argument count, format string hello2 requires 3 but format call supplies 2 [StringFormatMatches]\n" + - " getResources().getString(R.string.hello2, target, \"How are you\");\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - " res/values-es/formatstrings.xml:4: This definition requires 3 arguments\n" + - "src/test/pkg/StringFormatActivity.java:33: Error: Wrong argument type for formatting argument '#1' in hello: conversion is 'd', received String [StringFormatMatches]\n" + - " String output1 = String.format(hello, target);\n" + - " ~~~~~~\n" + - " res/values-es/formatstrings.xml:3: Conflicting argument declaration here\n" + - "res/values-es/formatstrings.xml:3: Error: Inconsistent formatting types for argument #1 in format string hello ('%1$d'): Found both 's' and 'd' (in values/formatstrings.xml) [StringFormatMatches]\n" + - " <string name=\"hello\">%1$d</string>\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - " res/values/formatstrings.xml:3: Conflicting argument type here\n" + - "res/values-es/formatstrings.xml:4: Warning: Inconsistent number of arguments in formatting string hello2; found both 2 and 3 [StringFormatCount]\n" + - " <string name=\"hello2\">%3$d: %1$s, %2$s?</string>\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - " res/values/formatstrings.xml:4: Conflicting number of arguments here\n" + - "res/values/formatstrings.xml:5: Warning: Formatting string 'missing' is not referencing numbered arguments [1, 2] [StringFormatCount]\n" + - " <string name=\"missing\">Hello %3$s World</string>\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "7 errors, 2 warnings\n" + - "", - - lintProject( - "res/values/formatstrings.xml", - "res/values-es/formatstrings.xml", - // Java files must be renamed in source tree - "src/test/pkg/StringFormatActivity.java.txt=>src/test/pkg/StringFormatActivity.java" - )); - } - - public void testArgCount() { - assertEquals(3, StringFormatDetector.getFormatArgumentCount( - "First: %1$s, Second %2$s, Third %3$s", null)); - assertEquals(11, StringFormatDetector.getFormatArgumentCount( - "Skipping stuff: %11$s", null)); - assertEquals(1, StringFormatDetector.getFormatArgumentCount( - "First: %1$s, Skip \\%2$s", null)); - assertEquals(1, StringFormatDetector.getFormatArgumentCount( - "First: %s, Skip \\%s", null)); - - Set<Integer> indices = new HashSet<Integer>(); - assertEquals(11, StringFormatDetector.getFormatArgumentCount( - "Skipping stuff: %2$d %11$s", indices)); - assertEquals(2, indices.size()); - assertTrue(indices.contains(2)); - assertTrue(indices.contains(11)); - } - - public void testArgType() { - assertEquals("s", StringFormatDetector.getFormatArgumentType( - "First: %1$s, Second %2$s, Third %3$s", 1)); - assertEquals("d", StringFormatDetector.getFormatArgumentType( - "First: %1$s, Second %2$-5d, Third %3$s", 2)); - assertEquals("s", StringFormatDetector.getFormatArgumentType( - "Skipping stuff: %11$s",11)); - assertEquals("d", StringFormatDetector.getFormatArgumentType( - "First: %1$s, Skip \\%2$s, Value=%2$d", 2)); - } - - public void testWrongSyntax() throws Exception { - assertEquals( - "No warnings.", - - lintProject( - "res/values/formatstrings2.xml" - )); - } - - public void testDateStrings() throws Exception { - assertEquals( - "No warnings.", - - lintProject( - "res/values/formatstrings-version1.xml=>res/values-tl/donottranslate-cldr.xml", - "res/values/formatstrings-version2.xml=>res/values/donottranslate-cldr.xml" - )); - } - - public void testUa() throws Exception { - assertEquals( - "No warnings.", - - lintProject( - "res/values/formatstrings-version1.xml=>res/values-tl/donottranslate-cldr.xml", - "src/test/pkg/StringFormat2.java.txt=>src/test/pkg/StringFormat2.java" - )); - } - - public void testSuppressed() throws Exception { - assertEquals( - "No warnings.", - - lintProject( - "res/values/formatstrings_ignore.xml=>res/values/formatstrings.xml", - "res/values-es/formatstrings_ignore.xml=>res/values-es/formatstrings.xml", - "src/test/pkg/StringFormatActivity_ignore.java.txt=>src/test/pkg/StringFormatActivity.java" - )); - } - - public void testIssue27108() throws Exception { - assertEquals( - "No warnings.", - - lintProject("res/values/formatstrings3.xml")); - } - - public void testIssue39758() throws Exception { - assertEquals( - "No warnings.", - - lintProject( - "res/values/formatstrings4.xml", - "src/test/pkg/StringFormatActivity2.java.txt=>src/test/pkg/StringFormatActivity2.java")); - } - - public void testIssue42798() throws Exception { - // http://code.google.com/p/android/issues/detail?id=42798 - // String playsCount = String.format(Locale.FRANCE, this.context.getString(R.string.gridview_views_count), article.playsCount); - assertEquals("" - + "src/test/pkg/StringFormat3.java:12: Error: Wrong argument type for formatting argument '#1' in gridview_views_count: conversion is 'd', received String [StringFormatMatches]\n" - + " context.getString(R.string.gridview_views_count), \"wrong\");\n" - + " ~~~~~~~\n" - + " res/values/formatstrings5.xml:3: Conflicting argument declaration here\n" - + "src/test/pkg/StringFormat3.java:13: Error: Wrong argument type for formatting argument '#1' in gridview_views_count: conversion is 'd', received String [StringFormatMatches]\n" - + " String s4 = String.format(context.getString(R.string.gridview_views_count), \"wrong\");\n" - + " ~~~~~~~\n" - + " res/values/formatstrings5.xml:3: Conflicting argument declaration here\n" - + "2 errors, 0 warnings\n", - - lintProject( - "res/values/formatstrings5.xml", - "src/test/pkg/StringFormat3.java.txt=>src/test/pkg/StringFormat3.java")); - } - - public void testIsLocaleSpecific() throws Exception { - assertFalse(isLocaleSpecific("")); - assertFalse(isLocaleSpecific("Hello World!")); - assertFalse(isLocaleSpecific("%% %n")); - assertFalse(isLocaleSpecific(" %%f")); - assertFalse(isLocaleSpecific("%x %A %c %b %B %h %n %%")); - assertTrue(isLocaleSpecific("%f")); - assertTrue(isLocaleSpecific(" %1$f ")); - assertTrue(isLocaleSpecific(" %5$e ")); - assertTrue(isLocaleSpecific(" %E ")); - assertTrue(isLocaleSpecific(" %g ")); - assertTrue(isLocaleSpecific(" %1$tm %1$te,%1$tY ")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/StyleCycleDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/StyleCycleDetectorTest.java deleted file mode 100644 index d4823d7..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/StyleCycleDetectorTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class StyleCycleDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new StyleCycleDetector(); - } - - public void test() throws Exception { - assertEquals( - "res/values/styles.xml:9: Error: Style DetailsPage_EditorialBuyButton should not extend itself [StyleCycle]\n" + - "<style name=\"DetailsPage_EditorialBuyButton\" parent=\"@style/DetailsPage_EditorialBuyButton\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "1 errors, 0 warnings\n" + - "", - - lintProject("res/values/styles.xml")); - } - - public void test2() throws Exception { - assertEquals( - "res/values/stylecycle.xml:3: Error: Potential cycle: PropertyToggle is the implied parent of PropertyToggle.Base and this defines the opposite [StyleCycle]\n" + - " <style name=\"PropertyToggle\" parent=\"@style/PropertyToggle.Base\"></style>\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "1 errors, 0 warnings\n" + - "", - - lintProject("res/values/stylecycle.xml")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/SystemPermissionsDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/SystemPermissionsDetectorTest.java deleted file mode 100644 index 061882c..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/SystemPermissionsDetectorTest.java +++ /dev/null @@ -1,300 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class SystemPermissionsDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new SystemPermissionsDetector(); - } - - public void testBrokenOrder() throws Exception { - assertEquals( - "AndroidManifest.xml:15: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.intent.category.MASTER_CLEAR.permission.C2D_MESSAGE\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:16: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.ACCESS_CACHE_FILESYSTEM\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:17: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.ACCESS_CHECKIN_PROPERTIES\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:18: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.ACCESS_MTP\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:19: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.ACCESS_SURFACE_FLINGER\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:20: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.ACCOUNT_MANAGER\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:21: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.ALLOW_ANY_CODEC_FOR_PLAYBACK\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:22: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.ASEC_ACCESS\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:23: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.ASEC_CREATE\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:24: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.ASEC_DESTROY\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:25: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.ASEC_MOUNT_UNMOUNT\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:26: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.ASEC_RENAME\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:27: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.BACKUP\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:28: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.BIND_APPWIDGET\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:29: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.BIND_DEVICE_ADMIN\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:30: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.BIND_INPUT_METHOD\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:31: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.BIND_PACKAGE_VERIFIER\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:32: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.BIND_REMOTEVIEWS\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:33: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.BIND_TEXT_SERVICE\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:34: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.BIND_VPN_SERVICE\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:35: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.BIND_WALLPAPER\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:36: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.BRICK\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:37: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.BROADCAST_PACKAGE_REMOVED\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:38: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.BROADCAST_SMS\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:39: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.BROADCAST_WAP_PUSH\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:40: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.CALL_PRIVILEGED\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:41: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.CHANGE_BACKGROUND_DATA_SETTING\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:42: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.CHANGE_COMPONENT_ENABLED_STATE\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:43: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.CLEAR_APP_USER_DATA\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:44: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.CONFIRM_FULL_BACKUP\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:45: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.CONNECTIVITY_INTERNAL\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:46: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.CONTROL_LOCATION_UPDATES\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:47: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.COPY_PROTECTED_DATA\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:48: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.CRYPT_KEEPER\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:49: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.DELETE_CACHE_FILES\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:50: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.DELETE_PACKAGES\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:51: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.DEVICE_POWER\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:52: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.DIAGNOSTIC\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:53: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.DUMP\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:54: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.FACTORY_TEST\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:55: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.FORCE_BACK\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:56: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.FORCE_STOP_PACKAGES\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:57: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.GLOBAL_SEARCH\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:58: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.GLOBAL_SEARCH_CONTROL\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:59: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.HARDWARE_TEST\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:60: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.INJECT_EVENTS\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:61: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.INSTALL_LOCATION_PROVIDER\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:62: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.INSTALL_PACKAGES\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:63: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.INTERNAL_SYSTEM_WINDOW\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:64: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.MANAGE_APP_TOKENS\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:65: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.MANAGE_NETWORK_POLICY\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:66: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.MANAGE_USB\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:67: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.MASTER_CLEAR\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:68: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.MODIFY_NETWORK_ACCOUNTING\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:69: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.MODIFY_PHONE_STATE\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:70: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.MOVE_PACKAGE\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:71: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.NET_ADMIN\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:72: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.MODIFY_PHONE_STATE\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:73: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.PACKAGE_USAGE_STATS\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:74: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.PACKAGE_VERIFICATION_AGENT\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:75: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.PERFORM_CDMA_PROVISIONING\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:76: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.READ_FRAME_BUFFER\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:77: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.READ_INPUT_STATE\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:78: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.READ_NETWORK_USAGE_HISTORY\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:79: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.READ_PRIVILEGED_PHONE_STATE\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:80: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.REBOOT\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:81: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.RECEIVE_EMERGENCY_BROADCAST\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:82: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.REMOVE_TASKS\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:83: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.RETRIEVE_WINDOW_CONTENT\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:84: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.SEND_SMS_NO_CONFIRMATION\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:85: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.SET_ACTIVITY_WATCHER\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:86: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.SET_ORIENTATION\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:87: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.SET_POINTER_SPEED\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:88: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.SET_PREFERRED_APPLICATIONS\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:89: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.SET_SCREEN_COMPATIBILITY\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:90: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.SET_TIME\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:91: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.SET_WALLPAPER_COMPONENT\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:92: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.SHUTDOWN\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:93: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.STATUS_BAR\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:94: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.STATUS_BAR_SERVICE\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:95: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.STOP_APP_SWITCHES\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:96: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.UPDATE_DEVICE_STATS\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:97: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.WRITE_APN_SETTINGS\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:98: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.WRITE_GSERVICES\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:99: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.WRITE_MEDIA_STORAGE\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "AndroidManifest.xml:100: Error: Permission is only granted to system apps [ProtectedPermissions]\n" + - " <uses-permission android:name=\"android.permission.WRITE_SECURE_SETTINGS\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "86 errors, 0 warnings\n", - - lintProject( - "protectedpermissions.xml=>AndroidManifest.xml")); - } - - public void testSuppressed() throws Exception { - assertEquals( - "No warnings.", - - lintProject("protectedpermissions2.xml=>AndroidManifest.xml")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/TextFieldDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/TextFieldDetectorTest.java deleted file mode 100644 index 795bc85..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/TextFieldDetectorTest.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class TextFieldDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new TextFieldDetector(); - } - - public void testField() throws Exception { - assertEquals( - "res/layout/note_edit.xml:50: Warning: This text field does not specify an inputType or a hint [TextFields]\n" + - " <EditText\n" + - " ^\n" + - "0 errors, 1 warnings\n" + - "", - lintFiles("res/layout/note_edit.xml")); - } - - public void testTypeFromName() throws Exception { - assertEquals( - "res/layout/edit_type.xml:14: Warning: The view name (@+id/mypassword) suggests this is a password, but it does not include 'textPassword' in the inputType [TextFields]\n" + - " android:inputType=\"text\" >\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~\n" + - " res/layout/edit_type.xml:10: id defined here\n" + - "res/layout/edit_type.xml:45: Warning: The view name (@+id/password_length) suggests this is a number, but it does not include a numeric inputType (such as 'numberSigned') [TextFields]\n" + - " android:inputType=\"text\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~\n" + - " res/layout/edit_type.xml:41: id defined here\n" + - "res/layout/edit_type.xml:54: Warning: The view name (@+id/welcome_url) suggests this is a URI, but it does not include 'textUri' in the inputType [TextFields]\n" + - " android:inputType=\"text\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~\n" + - " res/layout/edit_type.xml:50: id defined here\n" + - "res/layout/edit_type.xml:63: Warning: The view name (@+id/start_date) suggests this is a date, but it does not include 'date' or 'datetime' in the inputType [TextFields]\n" + - " android:inputType=\"text\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~\n" + - " res/layout/edit_type.xml:59: id defined here\n" + - "res/layout/edit_type.xml:72: Warning: The view name (@+id/email_address) suggests this is an e-mail address, but it does not include 'textEmail' in the inputType [TextFields]\n" + - " android:inputType=\"text\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~\n" + - " res/layout/edit_type.xml:68: id defined here\n" + - "res/layout/edit_type.xml:81: Warning: The view name (@+id/login_pin) suggests this is a password, but it does not include 'numberPassword' in the inputType [TextFields]\n" + - " android:inputType=\"textPassword\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - " res/layout/edit_type.xml:77: id defined here\n" + - "res/layout/edit_type.xml:83: Warning: This text field does not specify an inputType or a hint [TextFields]\n" + - " <EditText\n" + - " ^\n" + - "res/layout/edit_type.xml:84: Warning: The view name (@+id/number_of_items) suggests this is a number, but it does not include a numeric inputType (such as 'numberSigned') [TextFields]\n" + - " android:id=\"@+id/number_of_items\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "0 errors, 8 warnings\n", - - lintFiles("res/layout/edit_type.xml")); - } - - public void testContainsWord() { - assertFalse(containsWord("", "foob")); - assertFalse(containsWord("foo", "foob")); - - assertTrue(containsWord("foo", "foo")); - assertTrue(containsWord("Foo", "foo")); - assertTrue(containsWord("foo_bar", "foo")); - assertTrue(containsWord("bar_foo", "foo")); - assertTrue(containsWord("bar_Foo", "foo")); - assertTrue(containsWord("bar_foo_baz", "foo")); - assertTrue(containsWord("bar_Foo_baz", "foo")); - assertTrue(containsWord("barFooBaz", "foo")); - assertTrue(containsWord("barFOO_", "foo")); - assertTrue(containsWord("FooBaz", "foo")); - assertTrue(containsWord("BarFoo", "foo")); - assertFalse(containsWord("barfoo", "foo")); - assertTrue(containsWord("barfoo", "foo", false, true)); - assertTrue(containsWord("foobar", "foo", true, false)); - assertFalse(containsWord("foobar", "foo")); - assertFalse(containsWord("barfoobar", "foo")); - - assertTrue(containsWord("phoneNumber", "phone")); - assertTrue(containsWord("phoneNumber", "number")); - assertTrue(containsWord("uri_prefix", "uri")); - assertTrue(containsWord("fooURI", "uri")); - assertTrue(containsWord("my_url", "url")); - assertTrue(containsWord("network_prefix_length", "length")); - - assertFalse(containsWord("sizer", "size")); - assertFalse(containsWord("synthesize_to_filename", "size")); - assertFalse(containsWord("update_text", "date")); - assertFalse(containsWord("daten", "date")); - - assertFalse(containsWord("phonenumber", "phone")); - assertFalse(containsWord("myphone", "phone")); - assertTrue(containsWord("phonenumber", "phone", true, true)); - assertTrue(containsWord("myphone", "phone", true, true)); - assertTrue(containsWord("phoneNumber", "phone")); - - assertTrue(containsWord("phoneNumber", "phone")); - assertTrue(containsWord("@id/phoneNumber", "phone")); - assertTrue(containsWord("@+id/phoneNumber", "phone")); - } - - private static boolean containsWord(String name, String word, boolean allowPrefix, - boolean allowSuffix) { - return TextFieldDetector.containsWord(name, word, allowPrefix, allowSuffix); - } - - private static boolean containsWord(String name, String word) { - return TextFieldDetector.containsWord(name, word); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/TextViewDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/TextViewDetectorTest.java deleted file mode 100644 index 0ee144b..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/TextViewDetectorTest.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class TextViewDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new TextViewDetector(); - } - - public void test() throws Exception { - assertEquals( - "res/layout/edit_textview.xml:13: Warning: Attribute android:autoText should not be used with <TextView>: Change element type to <EditText> ? [TextViewEdits]\n" + - " android:autoText=\"true\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/edit_textview.xml:14: Warning: Attribute android:bufferType should not be used with <TextView>: Change element type to <EditText> ? [TextViewEdits]\n" + - " android:bufferType=\"editable\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/edit_textview.xml:15: Warning: Attribute android:capitalize should not be used with <TextView>: Change element type to <EditText> ? [TextViewEdits]\n" + - " android:capitalize=\"words\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/edit_textview.xml:16: Warning: Attribute android:cursorVisible should not be used with <TextView>: Change element type to <EditText> ? [TextViewEdits]\n" + - " android:cursorVisible=\"true\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/edit_textview.xml:17: Warning: Attribute android:digits should not be used with <TextView>: Change element type to <EditText> ? [TextViewEdits]\n" + - " android:digits=\"\"\n" + - " ~~~~~~~~~~~~~~~~~\n" + - "res/layout/edit_textview.xml:18: Warning: Attribute android:editable should not be used with <TextView>: Change element type to <EditText> ? [TextViewEdits]\n" + - " android:editable=\"true\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/edit_textview.xml:19: Warning: Attribute android:editorExtras should not be used with <TextView>: Change element type to <EditText> ? [TextViewEdits]\n" + - " android:editorExtras=\"@+id/foobar\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/edit_textview.xml:22: Warning: Attribute android:imeActionId should not be used with <TextView>: Change element type to <EditText> ? [TextViewEdits]\n" + - " android:imeActionId=\"@+id/foo\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/edit_textview.xml:23: Warning: Attribute android:imeActionLabel should not be used with <TextView>: Change element type to <EditText> ? [TextViewEdits]\n" + - " android:imeActionLabel=\"\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/edit_textview.xml:24: Warning: Attribute android:imeOptions should not be used with <TextView>: Change element type to <EditText> ? [TextViewEdits]\n" + - " android:imeOptions=\"\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/edit_textview.xml:25: Warning: Attribute android:inputMethod should not be used with <TextView>: Change element type to <EditText> ? [TextViewEdits]\n" + - " android:inputMethod=\"\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/edit_textview.xml:26: Warning: Attribute android:inputType should not be used with <TextView>: Change element type to <EditText> ? [TextViewEdits]\n" + - " android:inputType=\"text\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/edit_textview.xml:27: Warning: Attribute android:numeric should not be used with <TextView>: Change element type to <EditText> ? [TextViewEdits]\n" + - " android:numeric=\"\"\n" + - " ~~~~~~~~~~~~~~~~~~\n" + - "res/layout/edit_textview.xml:28: Warning: Attribute android:password should not be used with <TextView>: Change element type to <EditText> ? [TextViewEdits]\n" + - " android:password=\"true\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/edit_textview.xml:29: Warning: Attribute android:phoneNumber should not be used with <TextView>: Change element type to <EditText> ? [TextViewEdits]\n" + - " android:phoneNumber=\"true\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/edit_textview.xml:30: Warning: Attribute android:privateImeOptions should not be used with <TextView>: Change element type to <EditText> ? [TextViewEdits]\n" + - " android:privateImeOptions=\"\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/edit_textview.xml:38: Warning: Attribute android:cursorVisible should not be used with <Button>: intended for editable text widgets [TextViewEdits]\n" + - " android:cursorVisible=\"true\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/edit_textview.xml:44: Warning: Attribute android:cursorVisible should not be used with <CheckedTextView>: intended for editable text widgets [TextViewEdits]\n" + - " android:cursorVisible=\"true\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/edit_textview.xml:50: Warning: Attribute android:cursorVisible should not be used with <CheckBox>: intended for editable text widgets [TextViewEdits]\n" + - " android:cursorVisible=\"true\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/edit_textview.xml:56: Warning: Attribute android:cursorVisible should not be used with <RadioButton>: intended for editable text widgets [TextViewEdits]\n" + - " android:cursorVisible=\"true\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/edit_textview.xml:62: Warning: Attribute android:cursorVisible should not be used with <ToggleButton>: intended for editable text widgets [TextViewEdits]\n" + - " android:cursorVisible=\"true\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/edit_textview.xml:83: Warning: Consider making the text value selectable by specifying android:textIsSelectable=\"true\" [SelectableText]\n" + - " <TextView\n" + - " ^\n" + - "0 errors, 22 warnings\n", - - lintFiles( - "apicheck/minsdk14.xml=>AndroidManifest.xml", // API >= 11 for selectable issue - "res/layout/edit_textview.xml")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/TitleDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/TitleDetectorTest.java deleted file mode 100644 index 7259cde..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/TitleDetectorTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class TitleDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new TitleDetector(); - } - - public void test() throws Exception { - assertEquals( - "res/menu/titles.xml:3: Warning: Menu items should specify a title [MenuTitle]\n" + - " <item android:id=\"@+id/action_bar_progress_spinner\"\n" + - " ^\n" + - "res/menu/titles.xml:12: Warning: Menu items should specify a title [MenuTitle]\n" + - " <item android:id=\"@+id/menu_plus_one\"\n" + - " ^\n" + - "0 errors, 2 warnings\n", - - lintProject( - "apicheck/minsdk14.xml=>AndroidManifest.xml", - "res/menu/titles.xml")); - } - - public void testOk() throws Exception { - assertEquals( - "No warnings.", - - lintProject( - "apicheck/minsdk1.xml=>AndroidManifest.xml", - "res/menu/titles.xml")); - } - - public void testOk2() throws Exception { - assertEquals( - "No warnings.", - - lintProject("res/menu-land/actions.xml")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/ToastDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/ToastDetectorTest.java deleted file mode 100644 index 07941b7..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/ToastDetectorTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class ToastDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new ToastDetector(); - } - - public void test() throws Exception { - assertEquals( - "src/test/pkg/ToastTest.java:31: Warning: Toast created but not shown: did you forget to call show() ? [ShowToast]\n" + - " Toast.makeText(context, \"foo\", Toast.LENGTH_LONG);\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "src/test/pkg/ToastTest.java:32: Warning: Expected duration Toast.LENGTH_SHORT or Toast.LENGTH_LONG, a custom duration value is not supported [ShowToast]\n" + - " Toast toast = Toast.makeText(context, R.string.app_name, 5000);\n" + - " ~~~~\n" + - "src/test/pkg/ToastTest.java:32: Warning: Toast created but not shown: did you forget to call show() ? [ShowToast]\n" + - " Toast toast = Toast.makeText(context, R.string.app_name, 5000);\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "src/test/pkg/ToastTest.java:38: Warning: Toast created but not shown: did you forget to call show() ? [ShowToast]\n" + - " Toast.makeText(context, \"foo\", Toast.LENGTH_LONG);\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "0 errors, 4 warnings\n" + - "", - - lintProject("src/test/pkg/ToastTest.java.txt=>src/test/pkg/ToastTest.java")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/TooManyViewsDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/TooManyViewsDetectorTest.java deleted file mode 100644 index 51b977d..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/TooManyViewsDetectorTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class TooManyViewsDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new TooManyViewsDetector(); - } - - public void testTooMany() throws Exception { - assertEquals( - "res/layout/too_many.xml:399: Warning: too_many.xml has more than 80 views, bad for performance [TooManyViews]\n" + - " <Button\n" + - " ^\n" + - "0 errors, 1 warnings\n" + - "", - lintFiles("res/layout/too_many.xml")); - } - - public void testTooDeep() throws Exception { - assertEquals( - "res/layout/too_deep.xml:46: Warning: too_deep.xml has more than 10 levels, bad for performance [TooDeepLayout]\n" + - " <LinearLayout\n" + - " ^\n" + - "0 errors, 1 warnings\n" + - "", - lintFiles("res/layout/too_deep.xml")); - } -} 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 deleted file mode 100644 index ee1a2f2..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/TranslationDetectorTest.java +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class TranslationDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new TranslationDetector(); - } - - @Override - protected boolean includeParentPath() { - return true; - } - - public void testTranslation() throws Exception { - TranslationDetector.sCompleteRegions = false; - assertEquals( - // Sample files from the Home app - "res/values/strings.xml:20: Error: \"show_all_apps\" is not translated in nl-rNL [MissingTranslation]\n" + - " <string name=\"show_all_apps\">All</string>\n" + - " ~~~~~~~~~~~~~~~~~~~~\n" + - "res/values/strings.xml:23: Error: \"menu_wallpaper\" is not translated in nl-rNL [MissingTranslation]\n" + - " <string name=\"menu_wallpaper\">Wallpaper</string>\n" + - " ~~~~~~~~~~~~~~~~~~~~~\n" + - "res/values/strings.xml:25: Error: \"menu_settings\" is not translated in cs, de-rDE, es, es-rUS, nl-rNL [MissingTranslation]\n" + - " <string name=\"menu_settings\">Settings</string>\n" + - " ~~~~~~~~~~~~~~~~~~~~\n" + - "res/values-cs/arrays.xml:3: Error: \"security_questions\" is translated here but not found in default locale [ExtraTranslation]\n" + - " <string-array name=\"security_questions\">\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - " res/values-es/strings.xml:12: Also translated here\n" + - "res/values-de-rDE/strings.xml:11: Error: \"continue_skip_label\" is translated here but not found in default locale [ExtraTranslation]\n" + - " <string name=\"continue_skip_label\">\"Weiter\"</string>\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "5 errors, 0 warnings\n" + - "", - - lintProject( - "res/values/strings.xml", - "res/values-cs/strings.xml", - "res/values-de-rDE/strings.xml", - "res/values-es/strings.xml", - "res/values-es-rUS/strings.xml", - "res/values-land/strings.xml", - "res/values-cs/arrays.xml", - "res/values-es/donottranslate.xml", - "res/values-nl-rNL/strings.xml")); - } - - public void testTranslationWithCompleteRegions() throws Exception { - TranslationDetector.sCompleteRegions = true; - assertEquals( - // Sample files from the Home app - "res/values/strings.xml:19: Error: \"home_title\" is not translated in es-rUS [MissingTranslation]\n" + - " <string name=\"home_title\">Home Sample</string>\n" + - " ~~~~~~~~~~~~~~~~~\n" + - "res/values/strings.xml:20: Error: \"show_all_apps\" is not translated in es-rUS, nl-rNL [MissingTranslation]\n" + - " <string name=\"show_all_apps\">All</string>\n" + - " ~~~~~~~~~~~~~~~~~~~~\n" + - "res/values/strings.xml:23: Error: \"menu_wallpaper\" is not translated in es-rUS, nl-rNL [MissingTranslation]\n" + - " <string name=\"menu_wallpaper\">Wallpaper</string>\n" + - " ~~~~~~~~~~~~~~~~~~~~~\n" + - "res/values/strings.xml:25: Error: \"menu_settings\" is not translated in cs, de-rDE, es-rUS, nl-rNL [MissingTranslation]\n" + - " <string name=\"menu_settings\">Settings</string>\n" + - " ~~~~~~~~~~~~~~~~~~~~\n" + - "res/values/strings.xml:29: Error: \"wallpaper_instructions\" is not translated in es-rUS [MissingTranslation]\n" + - " <string name=\"wallpaper_instructions\">Tap picture to set portrait wallpaper</string>\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - " res/values-land/strings.xml:19: <No location-specific message\n" + - "res/values-de-rDE/strings.xml:11: Error: \"continue_skip_label\" is translated here but not found in default locale [ExtraTranslation]\n" + - " <string name=\"continue_skip_label\">\"Weiter\"</string>\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "6 errors, 0 warnings\n" + - "", - - lintProject( - "res/values/strings.xml", - "res/values-cs/strings.xml", - "res/values-de-rDE/strings.xml", - "res/values-es-rUS/strings.xml", - "res/values-land/strings.xml", - "res/values-nl-rNL/strings.xml")); - } - - public void testHandleBom() throws Exception { - // This isn't really testing translation detection; it's just making sure that the - // XML parser doesn't bomb on BOM bytes (byte order marker) at the beginning of - // the XML document - assertEquals( - "No warnings.", - lintProject( - "res/values-de/strings.xml" - )); - } - - public void testTranslatedArrays() throws Exception { - TranslationDetector.sCompleteRegions = true; - assertEquals( - "No warnings.", - - lintProject( - "res/values/translatedarrays.xml", - "res/values-cs/translatedarrays.xml")); - } - - public void testTranslationSuppresss() throws Exception { - TranslationDetector.sCompleteRegions = false; - assertEquals( - "No warnings.", - - lintProject( - "res/values/strings_ignore.xml=>res/values/strings.xml", - "res/values-es/strings_ignore.xml=>res/values-es/strings.xml", - "res/values-nl-rNL/strings.xml=>res/values-nl-rNL/strings.xml")); - } - - public void testMixedTranslationArrays() throws Exception { - // See issue http://code.google.com/p/android/issues/detail?id=29263 - assertEquals( - "No warnings.", - - lintProject( - "res/values/strings3.xml=>res/values/strings.xml", - "res/values-fr/strings.xml=>res/values-fr/strings.xml")); - } - - public void testLibraryProjects() throws Exception { - // If a library project provides additional locales, that should not force - // the main project to include all those translations - assertEquals( - "No warnings.", - - lintProject( - // Master project - "multiproject/main-manifest.xml=>AndroidManifest.xml", - "multiproject/main.properties=>project.properties", - "res/values/strings2.xml", - - // Library project - "multiproject/library-manifest.xml=>../LibraryProject/AndroidManifest.xml", - "multiproject/library.properties=>../LibraryProject/project.properties", - - "res/values/strings.xml=>../LibraryProject/res/values/strings.xml", - "res/values-cs/strings.xml=>../LibraryProject/res/values-cs/strings.xml", - "res/values-cs/strings.xml=>../LibraryProject/res/values-de/strings.xml", - "res/values-cs/strings.xml=>../LibraryProject/res/values-nl/strings.xml" - )); - } - - public void testNonTranslatable1() throws Exception { - TranslationDetector.sCompleteRegions = true; - assertEquals( - "res/values-nb/nontranslatable.xml:3: Error: The resource string \"dummy\" has been marked as translatable=\"false\" [ExtraTranslation]\n" + - " <string name=\"dummy\">Ignore Me</string>\n" + - " ~~~~~~~~~~~~\n" + - "1 errors, 0 warnings\n" + - "", - - lintProject("res/values/nontranslatable.xml", - "res/values/nontranslatable2.xml=>res/values-nb/nontranslatable.xml")); - } - - public void testNonTranslatable2() throws Exception { - TranslationDetector.sCompleteRegions = true; - assertEquals( - "res/values-nb/nontranslatable.xml:3: Error: Non-translatable resources should only be defined in the base values/ folder [ExtraTranslation]\n" + - " <string name=\"dummy\" translatable=\"false\">Ignore Me</string>\n" + - " ~~~~~~~~~~~~~~~~~~~~\n" + - "1 errors, 0 warnings\n" + - "", - - lintProject("res/values/nontranslatable.xml=>res/values-nb/nontranslatable.xml")); - } - - public void testSpecifiedLanguageOk() throws Exception { - TranslationDetector.sCompleteRegions = false; - assertEquals( - "No warnings.", - - lintProject( - "res/values-es/strings.xml=>res/values-es/strings.xml", - "res/values-es-rUS/strings.xml")); - } - - public void testSpecifiedLanguage() throws Exception { - TranslationDetector.sCompleteRegions = false; - assertEquals( - "No warnings.", - - lintProject( - "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/TypoDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/TypoDetectorTest.java deleted file mode 100644 index 3c49b3a..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/TypoDetectorTest.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -import java.util.Arrays; - -@SuppressWarnings("javadoc") -public class TypoDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new TypoDetector(); - } - - public void testPlainValues() throws Exception { - assertEquals( - "res/values/strings.xml:6: Warning: \"Andriod\" is a common misspelling; did you mean \"Android\" ? [Typos]\n" + - " <string name=\"s2\">Andriod activites!</string>\n" + - " ^\n" + - "res/values/strings.xml:6: Warning: \"activites\" is a common misspelling; did you mean \"activities\" ? [Typos]\n" + - " <string name=\"s2\">Andriod activites!</string>\n" + - " ^\n" + - "res/values/strings.xml:8: Warning: \"Cmoputer\" is a common misspelling; did you mean \"Computer\" ? [Typos]\n" + - " <string name=\"s3\"> (Cmoputer </string>\n" + - " ^\n" + - "res/values/strings.xml:10: Warning: \"throught\" is a common misspelling; did you mean \"thought\" or \"through\" or \"throughout\" ? [Typos]\n" + - " <string name=\"s4\"><b>throught</b></string>\n" + - " ^\n" + - "res/values/strings.xml:12: Warning: \"Seach\" is a common misspelling; did you mean \"Search\" ? [Typos]\n" + - " <string name=\"s5\">Seach</string>\n" + - " ^\n" + - "res/values/strings.xml:16: Warning: \"Tuscon\" is a common misspelling; did you mean \"Tucson\" ? [Typos]\n" + - " <string name=\"s7\">Tuscon tuscon</string>\n" + - " ^\n" + - "res/values/strings.xml:20: Warning: \"Ok\" is usually capitalized as \"OK\" [Typos]\n" + - " <string name=\"dlg_button_ok\">Ok</string>\n" + - " ^\n" + - "0 errors, 7 warnings\n" + - "", - lintProject("res/values/typos.xml=>res/values/strings.xml")); - } - - public void testEnLanguage() throws Exception { - assertEquals( - "res/values-en-rUS/strings-en.xml:6: Warning: \"Andriod\" is a common misspelling; did you mean \"Android\" ? [Typos]\n" + - " <string name=\"s2\">Andriod activites!</string>\n" + - " ^\n" + - "res/values-en-rUS/strings-en.xml:6: Warning: \"activites\" is a common misspelling; did you mean \"activities\" ? [Typos]\n" + - " <string name=\"s2\">Andriod activites!</string>\n" + - " ^\n" + - "res/values-en-rUS/strings-en.xml:8: Warning: \"Cmoputer\" is a common misspelling; did you mean \"Computer\" ? [Typos]\n" + - " <string name=\"s3\"> (Cmoputer </string>\n" + - " ^\n" + - "res/values-en-rUS/strings-en.xml:10: Warning: \"throught\" is a common misspelling; did you mean \"thought\" or \"through\" or \"throughout\" ? [Typos]\n" + - " <string name=\"s4\"><b>throught</b></string>\n" + - " ^\n" + - "res/values-en-rUS/strings-en.xml:12: Warning: \"Seach\" is a common misspelling; did you mean \"Search\" ? [Typos]\n" + - " <string name=\"s5\">Seach</string>\n" + - " ^\n" + - "res/values-en-rUS/strings-en.xml:16: Warning: \"Tuscon\" is a common misspelling; did you mean \"Tucson\" ? [Typos]\n" + - " <string name=\"s7\">Tuscon tuscon</string>\n" + - " ^\n" + - "res/values-en-rUS/strings-en.xml:20: Warning: \"Ok\" is usually capitalized as \"OK\" [Typos]\n" + - " <string name=\"dlg_button_ok\">Ok</string>\n" + - " ^\n" + - "0 errors, 7 warnings\n" + - "", - lintProject("res/values/typos.xml=>res/values-en-rUS/strings-en.xml")); - } - - public void testNorwegian() throws Exception { - // UTF-8 handling - assertEquals( - "res/values-nb/typos.xml:6: Warning: \"Andriod\" is a common misspelling; did you mean \"Android\" ? [Typos]\n" + - " <string name=\"s2\">Mer morro med Andriod</string>\n" + - " ^\n" + - "res/values-nb/typos.xml:6: Warning: \"morro\" is a common misspelling; did you mean \"moro\" ? [Typos]\n" + - " <string name=\"s2\">Mer morro med Andriod</string>\n" + - " ^\n" + - "res/values-nb/typos.xml:8: Warning: \"Parallel\" is a common misspelling; did you mean \"Parallell\" ? [Typos]\n" + - " <string name=\"s3\"> Parallel </string>\n" + - " ^\n" + - "res/values-nb/typos.xml:10: Warning: \"altid\" is a common misspelling; did you mean \"alltid\" ? [Typos]\n" + - " <string name=\"s4\"><b>altid</b></string>\n" + - " ^\n" + - "res/values-nb/typos.xml:12: Warning: \"Altid\" is a common misspelling; did you mean \"Alltid\" ? [Typos]\n" + - " <string name=\"s5\">Altid</string>\n" + - " ^\n" + - "res/values-nb/typos.xml:18: Warning: \"karriære\" is a common misspelling; did you mean \"karrière\" ? [Typos]\n" + - " <string name=\"s7\">Koding er en spennende karriære</string>\n" + - " ^\n" + - "0 errors, 6 warnings\n" + - "", - lintProject("res/values-nb/typos.xml")); - } - - public void testGerman() throws Exception { - // Test globbing and multiple word matching - assertEquals( - "res/values-de/typos.xml:6: Warning: \"befindet eine\" is a common misspelling; did you mean \"befindet sich eine\" ? [Typos]\n" + - " wo befindet eine ip\n" + - " ^\n" + - "res/values-de/typos.xml:9: Warning: \"Authorisierungscode\" is a common misspelling; did you mean \"Autorisierungscode\" ? [Typos]\n" + - " <string name=\"s2\">(Authorisierungscode!)</string>\n" + - " ^\n" + - "res/values-de/typos.xml:10: Warning: \"zurück gefoobaren\" is a common misspelling; did you mean \"zurückgefoobaren\" ? [Typos]\n" + - " <string name=\"s3\"> zurück gefoobaren!</string>\n" + - " ^\n" + - "0 errors, 3 warnings\n" + - "", - lintProject("res/values-de/typos.xml")); - } - - public void testOk() throws Exception { - assertEquals( - "No warnings.", - lintProject("res/values/typos.xml=>res/values-xy/strings.xml")); - } - - public void testGetReplacements() { - String s = "\"throught\" is a common misspelling; did you mean \"thought\" or " + - "\"through\" or \"throughout\" ?\n"; - assertEquals("throught", TypoDetector.getTypo(s)); - assertEquals(Arrays.asList("thought", "through", "throughout"), - TypoDetector.getSuggestions(s)); - } - - public void testNorwegianDefault() throws Exception { - assertEquals( - "res/values/typos.xml:5: Warning: \"altid\" is a common misspelling; did you mean \"alltid\" ? [Typos]\n" + - " <string name=\"s4\"><b>altid</b></string>\n" + - " ^\n" + - "res/values/typos.xml:7: Warning: \"Altid\" is a common misspelling; did you mean \"Alltid\" ? [Typos]\n" + - " <string name=\"s5\">Altid</string>\n" + - " ^\n" + - "0 errors, 2 warnings\n", - - lintProject("res/values-nb/typos_locale.xml=>res/values/typos.xml")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/TypoLookupTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/TypoLookupTest.java deleted file mode 100644 index e57b8ce..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/TypoLookupTest.java +++ /dev/null @@ -1,523 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.client.api.LintClient; -import com.android.tools.lint.detector.api.Detector; -import com.google.common.base.Charsets; -import com.google.common.base.Splitter; -import com.google.common.io.Files; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; -import java.io.Writer; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.regex.Pattern; - -@SuppressWarnings("javadoc") -public class TypoLookupTest extends AbstractCheckTest { - private static final String SEPARATOR = "->"; - - public void testCapitalization() throws Exception { - LintClient client = new TestLintClient(); - // Make sure it can be read in - TypoLookup db = TypoLookup.get(client, "de", null); - assertNotNull(db); - assertNotNull(db.getTypos("Andriod".getBytes(Charsets.UTF_8), 0, "Andriod".length())); - } - - public void testDictionary_English() throws Exception { - validateDictionary("en"); - } - - public void testDictionary_German() throws Exception { - validateDictionary("de"); - } - - public void testDictionary_Spanish() throws Exception { - validateDictionary("es"); - } - - public void testDictionary_Hungarian() throws Exception { - validateDictionary("hu"); - } - - public void testDictionary_Italian() throws Exception { - validateDictionary("it"); - } - - public void testDictionary_Norwegian() throws Exception { - validateDictionary("nb"); - } - - public void testDictionary_Portuguese() throws Exception { - validateDictionary("pt"); - } - - public void testDictionary_Turkish() throws Exception { - validateDictionary("tr"); - } - - public void test1() { - TypoLookup db = TypoLookup.get(new TestLintClient(), "en", null); - assertNull(db.getTypos("hello", 0, "hello".length())); - assertNull(db.getTypos("this", 0, "this".length())); - - assertNotNull(db.getTypos("wiht", 0, "wiht".length())); - assertNotNull(db.getTypos("woudl", 0, "woudl".length())); - assertEquals("would", db.getTypos("woudl", 0, "woudl".length()).get(1)); - assertEquals("would", db.getTypos(" woudl ", 2, 7).get(1)); - assertNotNull(db.getTypos("foo wiht bar", 4, 8)); - - List<String> typos = db.getTypos("throught", 0, "throught".length()); - assertEquals("throught", typos.get(0)); // the typo - assertEquals("thought", typos.get(1)); - assertEquals("through", typos.get(2)); - assertEquals("throughout", typos.get(3)); - - // Capitalization handling - assertNotNull(db.getTypos("Woudl", 0, "Woudl".length())); - assertNotNull(db.getTypos("Enlish", 0, "Enlish".length())); - assertNull(db.getTypos("enlish", 0, "enlish".length())); - assertNull(db.getTypos("enlish".getBytes(Charsets.UTF_8), 0, "enlish".length())); - assertNotNull(db.getTypos("ok", 0, "ok".length())); - assertNotNull(db.getTypos("Ok", 0, "Ok".length())); - assertNull(db.getTypos("OK", 0, "OK".length())); - } - - public void testRegion() { - TypoLookup db = TypoLookup.get(new TestLintClient(), "en", "US"); - assertNotNull(db.getTypos("wiht", 0, "wiht".length())); - db = TypoLookup.get(new TestLintClient(), "en", "GB"); - assertNotNull(db.getTypos("wiht", 0, "wiht".length())); - } - - public void test2() { - TypoLookup db = TypoLookup.get(new TestLintClient(), "nb", null); //$NON-NLS-1$ - assertNull(db.getTypos("hello", 0, "hello".length())); - assertNull(db.getTypos("this", 0, "this".length())); - - assertNotNull(db.getTypos("altid", 0, "altid".length())); - assertEquals("alltid", db.getTypos("altid", 0, "altid".length()).get(1)); - assertEquals("alltid", db.getTypos(" altid ", 2, 7).get(1)); - assertNotNull(db.getTypos("foo altid bar", 4, 9)); - - // Test utf-8 string which isn't ASCII - String s = "karriære"; - byte[] sb = s.getBytes(Charsets.UTF_8); - assertNotNull(db.getTypos(sb, 0, sb.length)); - - assertEquals("karrière", db.getTypos(sb, 0, sb.length).get(1)); - } - - public void testMultiWords() { - // Some language dictionaries contain multi-word sequences (e.g. where there's a - // space on the left hand side). This needs some particular care in the lookup - // which is usually word oriented. - TypoLookup db = TypoLookup.get(new TestLintClient(), "de", "DE"); //$NON-NLS-1$ - - // all zu->allzu - - // Text handling - String t = "all zu"; - assertNotNull(db.getTypos(t, 0, t.length())); - assertEquals("allzu", db.getTypos(t, 0, t.length()).get(1)); - - // Byte handling - byte[] text = "all zu".getBytes(Charsets.UTF_8); - assertNotNull(db.getTypos(text, 0, text.length)); - assertEquals("allzu", db.getTypos(text, 0, text.length).get(1)); - - // Test automatically extending search beyond current word - text = "all zu".getBytes(Charsets.UTF_8); - assertNotNull(db.getTypos(text, 0, 3)); - assertEquals("allzu", db.getTypos(text, 0, text.length).get(1)); - - - text = ") all zu (".getBytes(Charsets.UTF_8); - assertNotNull(db.getTypos(text, 2, 8)); - assertEquals("allzu", db.getTypos(text, 2, 8).get(1)); - - text = "am einem".getBytes(Charsets.UTF_8); - assertNotNull(db.getTypos(text, 0, text.length)); - assertEquals("an einem", db.getTypos(text, 0, text.length).get(1)); - } - - public void testGlobbing() { - TypoLookup db = TypoLookup.get(new TestLintClient(), "de", null); - - // Authorisierung*->Autorisierung* - String text = "Authorisierungscode"; - byte[] bytes = text.getBytes(Charsets.UTF_8); - - assertNotNull(db.getTypos(text, 0, text.length())); - assertEquals("Autorisierungscode", db.getTypos(text, 0, text.length()).get(1)); - assertEquals(text, db.getTypos(text, 0, text.length()).get(0)); - - assertNotNull(db.getTypos(bytes, 0, bytes.length)); - assertEquals("Autorisierungscode", db.getTypos(bytes, 0, bytes.length).get(1)); - - // befindet ein*->befindet sich ein* - text = "wo befindet eine ip"; - assertEquals("befindet sich eine", db.getTypos(text, 3, 16).get(1)); - - // zurück ge*->zurückge* - text = "zurück gefoobaren"; - bytes = text.getBytes(Charsets.UTF_8); - assertNotNull(db.getTypos(bytes, 0, bytes.length)); - assertEquals("zurückgefoobaren", db.getTypos(bytes, 0, bytes.length).get(1)); - } - - public void testComparisons() throws Exception { - // Ensure that the two comparison methods agree - - LintClient client = new TestLintClient(); - for (String locale : new String[] { "de", "nb", "es", "en", "pt", "hu", "it", "tr" }) { - File f = client.findResource(String.format("tools/support/typos-%1$s.txt", locale)); - assertTrue(locale, f != null && f.exists()); - - Set<String> typos = new HashSet<String>(2000); - List<String> lines = Files.readLines(f, Charsets.UTF_8); - for (int i = 0, n = lines.size(); i < n; i++) { - String line = lines.get(i); - if (line.isEmpty() || line.trim().startsWith("#")) { //$NON-NLS-1$ - continue; - } - - int index = line.indexOf(SEPARATOR); - if (index == -1) { - continue; - } - String typo = line.substring(0, index).trim(); - typos.add(typo); - } - - List<String> words = new ArrayList<String>(typos); - - // Make sure that the two comparison methods agree on all the strings - // (which should be in a semi-random order now that they're in a set ordered - // by their hash codes) - - String prevText = words.get(0) + '\000'; - byte[] prevBytes = prevText.getBytes(Charsets.UTF_8); - - for (int i = 1; i < words.size(); i++) { - String text = words.get(i) + '\000';; - byte[] bytes = text.getBytes(Charsets.UTF_8); - - int textCompare = TypoLookup.compare(prevBytes, 0, (byte) 0, text, 0, - text.length()); - int byteCompare = TypoLookup.compare(prevBytes, 0, (byte) 0, bytes, 0, - bytes.length); - assertEquals("Word " + text + " versus prev " + prevText + " at " + i, - Math.signum(textCompare), Math.signum(byteCompare)); - } - } - } - - public void testComparison1() throws Exception { - String prevText = "heraus gebracht\u0000"; - byte[] prevBytes = prevText.getBytes(Charsets.UTF_8); - - String text = "Päsident\u0000"; - byte[] bytes = text.getBytes(Charsets.UTF_8); - - - int textCompare = TypoLookup.compare(prevBytes, 0, (byte) 0, text, 0, - text.length()); - int byteCompare = TypoLookup.compare(prevBytes, 0, (byte) 0, bytes, 0, - bytes.length); - assertTrue(byteCompare < 0); - assertTrue(textCompare < 0); - assertEquals("Word " + text + " versus prev " + prevText, - Math.signum(textCompare), Math.signum(byteCompare)); - } - - public void testComparison2() throws Exception { - String prevText = "intepretation\u0000"; - byte[] prevBytes = prevText.getBytes(Charsets.UTF_8); - - String text = "Woudl\u0000"; - byte[] bytes = text.getBytes(Charsets.UTF_8); - - int textCompare = TypoLookup.compare(prevBytes, 0, (byte) 0, text, 0, text.length()); - int byteCompare = TypoLookup.compare(prevBytes, 0, (byte) 0, bytes, 0, bytes.length); - assertTrue(byteCompare < 0); - assertTrue(textCompare < 0); - assertEquals("Word " + text + " versus prev " + prevText, - Math.signum(textCompare), Math.signum(byteCompare)); - - // Reverse capitalization and ensure that it's still the same - prevText = "Intepretation\u0000"; - prevBytes = prevText.getBytes(Charsets.UTF_8); - - text = "woudl\u0000"; - bytes = text.getBytes(Charsets.UTF_8); - - textCompare = TypoLookup.compare(prevBytes, 0, (byte) 0, text, 0, text.length()); - byteCompare = TypoLookup.compare(prevBytes, 0, (byte) 0, bytes, 0, bytes.length); - assertTrue(byteCompare < 0); - assertTrue(textCompare < 0); - assertEquals("Word " + text + " versus prev " + prevText, - Math.signum(textCompare), Math.signum(byteCompare)); - } - - // Some dictionaries contain actual sentences regarding usage; these must be stripped out. - // They're just hardcoded here as we find them - private static final String[] sRemove = new String[] { - "- besser ganz darauf verzichten", - "oft fälschlich für \"angekündigt\"", - "hinausgehende* − insb. „darüber hinausgehende“", - " - besser ganz darauf verzichten", - "svw. bzw. so viel wie bzw. sprachverwandt" - }; - - private void validateDictionary(String locale) throws Exception { - // Check that all the typo files are well formed - LintClient client = new TestLintClient(); - File f = client.findResource(String.format("tools/support/typos-%1$s.txt", locale)); - assertTrue(locale, f != null && f.exists()); - - Set<String> typos = new HashSet<String>(2000); - List<Pattern> patterns = new ArrayList<Pattern>(100); - - List<String> lines = Files.readLines(f, Charsets.UTF_8); - for (int i = 0, n = lines.size(); i < n; i++) { - String line = lines.get(i); - if (line.isEmpty() || line.trim().startsWith("#")) { //$NON-NLS-1$ - continue; - } - - assertTrue(msg(f, i, "Line should contain '->': %1$s", line), - line.contains(SEPARATOR)); - int index = line.indexOf(SEPARATOR); - String typo = line.substring(0, index).trim(); - String replacements = line.substring(index + SEPARATOR.length()).trim(); - - if (typo.contains("*") && !typo.endsWith("*")) { - fixDictionary(f); - fail(msg(f, i, "Globbing (*) not supported anywhere but at the tail: %1$s", line)); - } else if (typo.contains("*") && !replacements.contains("*")) { - fail(msg(f, i, "No glob found in the replacements for %1$s", line)); - } - - if (replacements.indexOf(',') != -1) { - Set<String> seen = new HashSet<String>(); - for (String s : Splitter.on(',').omitEmptyStrings().split(replacements)) { - if (seen.contains(s)) { - fixDictionary(f); - fail(msg(f, i, "For typo " + typo - + " there are repeated replacements (" + s + "): " + line)); - } - } - } - - assertTrue(msg(f, i, "Typo entry was empty: %1$s", line), !typo.isEmpty()); - assertTrue(msg(f, i, "Typo replacements was empty: %1$s", line), - !replacements.isEmpty()); - - for (String blacklist : sRemove) { - if (replacements.contains(blacklist)) { - fail(msg(f, i, "Replacements for typo %1$s contain description: %2$s", - typo, replacements)); - } - } - if (typo.equals("sólo") && locale.equals("es")) { - // sólo->solo - // This seems to trigger a lot of false positives - fail(msg(f, i, "Typo %1$s triggers a lot of false positives, should be omitted", - typo)); - } - if (locale.equals("tr") && (typo.equals("hiç bir")|| typo.equals("öğe"))) { - // hiç bir->hiçbir - // öğe->öge - // According to a couple of native speakers these are not necessarily - // typos - fail(msg(f, i, "Typo %1$s triggers a lot of false positives, should be omitted", - typo)); - } - - if (typo.contains("*")) { - patterns.add(Pattern.compile(typo.replace("*", ".*"))); - } else if (!patterns.isEmpty()) { - for (Pattern pattern : patterns) { - if (pattern.matcher(typo).matches()) { - fixDictionary(f); - fail(msg(f, i, "The typo " + typo + " matches an earlier glob: ignoring")); - continue; - } - } - } - - - if (typos.contains(typo)) { - fixDictionary(f); - fail(msg(f, i, "Typo appeared more than once on lhs: %1$s", typo)); - } - typos.add(typo); - } - - // Make sure it can be read in - TypoLookup db = TypoLookup.get(client, locale, null); - assertNotNull(db); - assertNull(db.getTypos("abcdefghijklmnopqrstuvxyz", 0, 25)); - assertNull(db.getTypos("abcdefghijklmnopqrstuvxyz".getBytes(Charsets.UTF_8), 0, 25)); - assertNotNull(db.getTypos("Andriod", 0, "Andriod".length())); - assertNotNull(db.getTypos("Andriod".getBytes(Charsets.UTF_8), 0, "Andriod".length())); - } - - private void fixDictionary(File original) throws Exception { - File fixed = new File(original.getParentFile(), "fixed-" + original.getName()); - - Map<String, Integer> typos = new HashMap<String, Integer>(2000); - List<Pattern> patterns = new ArrayList<Pattern>(100); - List<String> lines = Files.readLines(original, Charsets.UTF_8); - List<String> output = new ArrayList<String>(lines.size()); - - wordLoop: - for (int i = 0, n = lines.size(); i < n; i++) { - String line = lines.get(i); - if (line.isEmpty() || line.trim().startsWith("#")) { //$NON-NLS-1$ - output.add(line); - continue; - } - - if (!line.contains(SEPARATOR)) { - System.err.println("Commented out line missing ->: " + line); - output.add("# " + line); - continue; - } - int index = line.indexOf(SEPARATOR); - String typo = line.substring(0, index).trim(); - String replacements = line.substring(index + SEPARATOR.length()).trim(); - - if (typo.isEmpty()) { - System.err.println("Commented out line missing a typo on the lhs: " + line); - output.add("# " + line); - continue; - } - if (replacements.isEmpty()) { - System.err.println("Commented out line missing replacements on the rhs: " + line); - output.add("# " + line); - continue; - } - - // Ensure that all the replacements are unique - if (replacements.indexOf(',') != -1) { - Set<String> seen = new HashSet<String>(); - List<String> out = new ArrayList<String>(); - boolean rewrite = false; - for (String s : Splitter.on(',').omitEmptyStrings().split(replacements)) { - if (seen.contains(s)) { - System.err.println("For typo " + typo - + " there are repeated replacements (" + s + "): " + line); - rewrite = true; - } - seen.add(s); - out.add(s); - } - if (rewrite) { - StringBuilder sb = new StringBuilder(); - for (String s : out) { - if (sb.length() > 0) { - sb.append(","); - } - sb.append(s); - } - replacements = sb.toString(); - line = typo + SEPARATOR + replacements; - } - } - - if (typo.contains("*")) { - if (!typo.endsWith("*")) { - // Globbing not supported anywhere but the end - // Drop the whole word - System.err.println("Skipping typo " + typo - + " because globbing is only supported at the end of the word"); - continue; - } - patterns.add(Pattern.compile(typo.replace("*", ".*"))); - } else if (replacements.contains("*")) { - System.err.println("Skipping typo " + typo + " because unexpected " + - "globbing character found in replacements: " - + replacements); - continue; - } else if (!patterns.isEmpty()) { - for (Pattern pattern : patterns) { - if (pattern.matcher(typo).matches()) { - System.err.println("The typo " + typo - + " matches an earlier glob: ignoring"); - continue wordLoop; - } - } - } - - // TODO: Strip whitespace around ->, prefix of # etc such that reading in - // the databases needs to do less work at runtime - - if (typos.containsKey(typo)) { - int l = typos.get(typo); - String prev = output.get(l); - assertTrue(prev.startsWith(typo)); - // Append new replacements and put back into the list - // (unless they're already listed as replacements) - Set<String> seen = new HashSet<String>(); - for (String s : Splitter.on(',').split(prev.substring(prev.indexOf(SEPARATOR) - + 2))) { - seen.add(s); - } - for (String s : Splitter.on(',').omitEmptyStrings().split(replacements)) { - if (!seen.contains(s)) { - prev = prev + "," + s; - } - seen.add(s); - } - output.set(l, prev); - } else { - typos.put(typo, output.size()); - output.add(line); - } - } - - Writer writer = new BufferedWriter(new FileWriter(fixed)); - for (String line : output) { - writer.write(line); - writer.write('\n'); - } - writer.close(); - - System.err.println("==> Wrote fixed typo file to " + fixed.getPath()); - } - - private static String msg(File file, int line, String message, Object... args) { - return file.getName() + ':' + Integer.toString(line + 1) + ':' + ' ' + - String.format(message, args); - } - - @Override - protected Detector getDetector() { - fail("This is not used in the TypoLookupTest"); - return null; - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/TypographyDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/TypographyDetectorTest.java deleted file mode 100644 index 5173011..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/TypographyDetectorTest.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import static com.android.tools.lint.checks.TypographyDetector.FRACTION_PATTERN; -import static com.android.tools.lint.checks.TypographyDetector.GRAVE_QUOTATION; -import static com.android.tools.lint.checks.TypographyDetector.HYPHEN_RANGE_PATTERN; -import static com.android.tools.lint.checks.TypographyDetector.SINGLE_QUOTE; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class TypographyDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new TypographyDetector(); - } - - public void test() throws Exception { - assertEquals( - "res/values/typography.xml:17: Warning: Replace \"-\" with an \"en dash\" character (–, –) ? [TypographyDashes]\n" + - " <string name=\"ndash\">For ages 3-5</string>\n" + - " ^\n" + - "res/values/typography.xml:18: Warning: Replace \"-\" with an \"en dash\" character (–, –) ? [TypographyDashes]\n" + - " <string name=\"ndash2\">Copyright 2007 - 2011</string>\n" + - " ^\n" + - "res/values/typography.xml:20: Warning: Replace \"--\" with an \"em dash\" character (—, —) ? [TypographyDashes]\n" + - " <string name=\"mdash\">Not found -- please try again</string>\n" + - " ^\n" + - "res/values/typography.xml:24: Warning: Replace \"-\" with an \"en dash\" character (–, –) ? [TypographyDashes]\n" + - " <item>Ages 3-5</item>\n" + - " ^\n" + - "res/values/typography.xml:15: Warning: Replace \"...\" with ellipsis character (…, …) ? [TypographyEllipsis]\n" + - " <string name=\"ellipsis\">40 times...</string>\n" + - " ^\n" + - "res/values/typography.xml:12: Warning: Use fraction character ½ (½) instead of 1/2 ? [TypographyFractions]\n" + - " <string name=\"fraction1\">5 1/2 times</string>\n" + - " ^\n" + - "res/values/typography.xml:13: Warning: Use fraction character ¼ (¼) instead of 1/4 ? [TypographyFractions]\n" + - " <string name=\"fraction4\">1/4 times</string>\n" + - " ^\n" + - "res/values/typography.xml:25: Warning: Use fraction character ½ (½) instead of 1/2 ? [TypographyFractions]\n" + - " <item>Age 5 1/2</item>\n" + - " ^\n" + - "res/values/typography.xml:3: Warning: Replace straight quotes ('') with directional quotes (‘’, ‘ and ’) ? [TypographyQuotes]\n" + - " <string name=\"home_title\">Home 'Sample'</string>\n" + - " ^\n" + - "res/values/typography.xml:5: Warning: Replace straight quotes (\") with directional quotes (“”, “ and ”) ? [TypographyQuotes]\n" + - " <string name=\"show_all_apps2\">Show \"All\"</string>\n" + - " ^\n" + - "res/values/typography.xml:6: Warning: Replace straight quotes (\") with directional quotes (“”, “ and ”) ? [TypographyQuotes]\n" + - " <string name=\"escaped\">Skip \\\"All\\\"</string>\n" + - " ^\n" + - "res/values/typography.xml:7: Warning: Replace apostrophe (') with typographic apostrophe (’, ’) ? [TypographyQuotes]\n" + - " <string name=\"single\">Android's</string>\n" + - " ^\n" + - "res/values/typography.xml:9: Warning: Replace apostrophe (') with typographic apostrophe (’, ’) ? [TypographyQuotes]\n" + - " <string name=\"badquotes1\">`First'</string>\n" + - " ^\n" + - "res/values/typography.xml:10: Warning: Avoid quoting with grave accents; use apostrophes or better yet directional quotes instead [TypographyQuotes]\n" + - " <string name=\"badquotes2\">``second''</string>\n" + - " ^\n" + - "res/values/typography.xml:11: Warning: Replace straight quotes ('') with directional quotes (‘’, ‘ and ’) ? [TypographyQuotes]\n" + - " <string name=\"notbadquotes\">Type Option-` then 'Escape'</string>\n" + - " ^\n" + - "res/values/typography.xml:8: Warning: Replace (c) with copyright symbol © (©) ? [TypographyOther]\n" + - " <string name=\"copyright\">(c) 2011</string>\n" + - " ^\n" + - "0 errors, 16 warnings\n" + - "", - - lintProject("res/values/typography.xml")); - } - - public void testAnalytics() throws Exception { - assertEquals("" - + "No warnings.", - - lintProject("res/values/analytics.xml")); - } - - public void testSingleQuotesRange() { - assertTrue(SINGLE_QUOTE.matcher("Foo: 'bar'").matches()); - assertTrue(SINGLE_QUOTE.matcher("'Foo': bar").matches()); - assertTrue(SINGLE_QUOTE.matcher("\"'foo'\"").matches()); - assertTrue(SINGLE_QUOTE.matcher("\"'foo bar'\"").matches()); - - assertFalse(SINGLE_QUOTE.matcher("foo bar'").matches()); - assertFalse(SINGLE_QUOTE.matcher("Mind your P's and Q's").matches()); - - // This isn't asserted by the regexp: checked independently in - // the detector. The goal here is to assert that we need to - // have some text on either side of the quotes. - //assertFalse(SINGLE_QUOTE.matcher("'foo bar'").matches()); - } - - public void testGraveRegexp() { - assertTrue(GRAVE_QUOTATION.matcher("`a'").matches()); - assertTrue(GRAVE_QUOTATION.matcher(" `a' ").matches()); - assertTrue(GRAVE_QUOTATION.matcher(" ``a'' ").matches()); - assertFalse(GRAVE_QUOTATION.matcher("`a''").matches()); - } - - public void testFractionRegexp() { - assertTrue(FRACTION_PATTERN.matcher("fraction 1/2.").matches()); - assertTrue(FRACTION_PATTERN.matcher("1/2").matches()); - assertTrue(FRACTION_PATTERN.matcher("1/3").matches()); - assertTrue(FRACTION_PATTERN.matcher("1/4").matches()); - assertTrue(FRACTION_PATTERN.matcher("3/4").matches()); - assertTrue(FRACTION_PATTERN.matcher("1 / 2").matches()); - assertTrue(FRACTION_PATTERN.matcher("1 / 3").matches()); - assertTrue(FRACTION_PATTERN.matcher("1 / 4").matches()); - assertTrue(FRACTION_PATTERN.matcher("3 / 4").matches()); - - assertFalse(FRACTION_PATTERN.matcher("3 // 4").matches()); - assertFalse(FRACTION_PATTERN.matcher("11 / 2").matches()); - assertFalse(FRACTION_PATTERN.matcher("1 / 22").matches()); - } - - public void testNDashRegexp() { - assertTrue(HYPHEN_RANGE_PATTERN.matcher("3-4").matches()); - assertTrue(HYPHEN_RANGE_PATTERN.matcher("13- 14").matches()); - assertTrue(HYPHEN_RANGE_PATTERN.matcher("13 - 14").matches()); - assertTrue(HYPHEN_RANGE_PATTERN.matcher("The range is 13 - 14").matches()); - assertTrue(HYPHEN_RANGE_PATTERN.matcher("13 - 14.").matches()); - - assertFalse(HYPHEN_RANGE_PATTERN.matcher("13 - x").matches()); - assertFalse(HYPHEN_RANGE_PATTERN.matcher("x - 14").matches()); - assertFalse(HYPHEN_RANGE_PATTERN.matcher("x-y").matches()); - assertFalse(HYPHEN_RANGE_PATTERN.matcher("-y").matches()); - assertFalse(HYPHEN_RANGE_PATTERN.matcher("x-").matches()); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/UnusedResourceDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/UnusedResourceDetectorTest.java deleted file mode 100644 index d668a81..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/UnusedResourceDetectorTest.java +++ /dev/null @@ -1,277 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; -import com.android.tools.lint.detector.api.Issue; - -import java.io.File; -import java.util.Arrays; - -@SuppressWarnings("javadoc") -public class UnusedResourceDetectorTest extends AbstractCheckTest { - private boolean mEnableIds = false; - - @Override - protected Detector getDetector() { - return new UnusedResourceDetector(); - } - - @Override - protected boolean isEnabled(Issue issue) { - if (issue == UnusedResourceDetector.ISSUE_IDS) { - return mEnableIds; - } else { - return true; - } - } - - public void testUnused() throws Exception { - mEnableIds = false; - assertEquals( - "res/layout/accessibility.xml: Warning: The resource R.layout.accessibility appears to be unused [UnusedResources]\n" + - "res/layout/main.xml: Warning: The resource R.layout.main appears to be unused [UnusedResources]\n" + - "res/layout/other.xml: Warning: The resource R.layout.other appears to be unused [UnusedResources]\n" + - "res/values/strings2.xml:3: Warning: The resource R.string.hello appears to be unused [UnusedResources]\n" + - " <string name=\"hello\">Hello</string>\n" + - " ~~~~~~~~~~~~\n" + - "0 errors, 4 warnings\n" + - "", - - lintProject( - "res/values/strings2.xml", - "res/layout/layout1.xml=>res/layout/main.xml", - "res/layout/layout1.xml=>res/layout/other.xml", - - // Rename .txt files to .java - "src/my/pkg/Test.java.txt=>src/my/pkg/Test.java", - "gen/my/pkg/R.java.txt=>gen/my/pkg/R.java", - "AndroidManifest.xml", - "res/layout/accessibility.xml")); - } - - public void testUnusedIds() throws Exception { - mEnableIds = true; - - assertEquals( - "res/layout/accessibility.xml: Warning: The resource R.layout.accessibility appears to be unused [UnusedResources]\n" + - "Warning: The resource R.layout.main appears to be unused [UnusedResources]\n" + - "Warning: The resource R.layout.other appears to be unused [UnusedResources]\n" + - "Warning: The resource R.string.hello appears to be unused [UnusedResources]\n" + - "Warning: The resource R.id.imageView1 appears to be unused [UnusedIds]\n" + - "Warning: The resource R.id.include1 appears to be unused [UnusedIds]\n" + - "Warning: The resource R.id.linearLayout2 appears to be unused [UnusedIds]\n" + - "res/layout/accessibility.xml:2: Warning: The resource R.id.newlinear appears to be unused [UnusedIds]\n" + - "<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\" android:id=\"@+id/newlinear\" android:orientation=\"vertical\" android:layout_width=\"match_parent\" android:layout_height=\"match_parent\">\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/accessibility.xml:3: Warning: The resource R.id.button1 appears to be unused [UnusedIds]\n" + - " <Button android:text=\"Button\" android:id=\"@+id/button1\" android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\"></Button>\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/accessibility.xml:4: Warning: The resource R.id.android_logo appears to be unused [UnusedIds]\n" + - " <ImageView android:id=\"@+id/android_logo\" android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:src=\"@drawable/android_button\" android:focusable=\"false\" android:clickable=\"false\" android:layout_weight=\"1.0\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/accessibility.xml:5: Warning: The resource R.id.android_logo2 appears to be unused [UnusedIds]\n" + - " <ImageButton android:importantForAccessibility=\"yes\" android:id=\"@+id/android_logo2\" android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:src=\"@drawable/android_button\" android:focusable=\"false\" android:clickable=\"false\" android:layout_weight=\"1.0\" />\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "0 errors, 11 warnings\n" + - "", - - lintProject( - // Rename .txt files to .java - "src/my/pkg/Test.java.txt=>src/my/pkg/Test.java", - "gen/my/pkg/R.java.txt=>gen/my/pkg/R.java", - "AndroidManifest.xml", - "res/layout/accessibility.xml")); - } - - public void testArrayReference() throws Exception { - assertEquals( - "res/values/arrayusage.xml:3: Warning: The resource R.array.my_array appears to be unused [UnusedResources]\n" + - "<string-array name=\"my_array\">\n" + - " ~~~~~~~~~~~~~~~\n" + - "0 errors, 1 warnings\n" + - "", - - lintProject( - "AndroidManifest.xml", - "res/values/arrayusage.xml")); - } - - public void testAttrs() throws Exception { - assertEquals( - "res/layout/customattrlayout.xml: Warning: The resource R.layout.customattrlayout appears to be unused [UnusedResources]\n" + - "0 errors, 1 warnings\n" + - "", - - lintProject( - "res/values/customattr.xml", - "res/layout/customattrlayout.xml", - "unusedR.java.txt=>gen/my/pkg/R.java", - "AndroidManifest.xml")); - } - - public void testMultiProjectIgnoreLibraries() throws Exception { - assertEquals( - "No warnings.", - - lintProject( - // Master project - "multiproject/main-manifest.xml=>AndroidManifest.xml", - "multiproject/main.properties=>project.properties", - "multiproject/MainCode.java.txt=>src/foo/main/MainCode.java", - - // Library project - "multiproject/library-manifest.xml=>../LibraryProject/AndroidManifest.xml", - "multiproject/library.properties=>../LibraryProject/project.properties", - "multiproject/LibraryCode.java.txt=>../LibraryProject/src/foo/library/LibraryCode.java", - "multiproject/strings.xml=>../LibraryProject/res/values/strings.xml" - )); - } - - public void testMultiProject() throws Exception { - File master = getProjectDir("MasterProject", - // Master project - "multiproject/main-manifest.xml=>AndroidManifest.xml", - "multiproject/main.properties=>project.properties", - "multiproject/MainCode.java.txt=>src/foo/main/MainCode.java" - ); - File library = getProjectDir("LibraryProject", - // Library project - "multiproject/library-manifest.xml=>AndroidManifest.xml", - "multiproject/library.properties=>project.properties", - "multiproject/LibraryCode.java.txt=>src/foo/library/LibraryCode.java", - "multiproject/strings.xml=>res/values/strings.xml" - ); - assertEquals( - // string1 is defined and used in the library project - // string2 is defined in the library project and used in the master project - // string3 is defined in the library project and not used anywhere - "/TESTROOT/LibraryProject/res/values/strings.xml:7: Warning: The resource R.string.string3 appears to be unused [UnusedResources]\n" + - " <string name=\"string3\">String 3</string>\n" + - " ~~~~~~~~~~~~~~\n" + - "0 errors, 1 warnings\n", - - checkLint(Arrays.asList(master, library))); - } - - public void testFqcnReference() throws Exception { - assertEquals( - "No warnings.", - - lintProject( - "res/layout/layout1.xml=>res/layout/main.xml", - "src/test/pkg/UnusedReference.java.txt=>src/test/pkg/UnusedReference.java", - "AndroidManifest.xml")); - } - - public void testIgnoreXmlDrawable() throws Exception { - assertEquals( - "No warnings.", - - lintProject( - "res/drawable/ic_menu_help.xml", - "gen/my/pkg/R2.java.txt=>gen/my/pkg/R.java" - )); - } - - public void testPlurals() throws Exception { - assertEquals( - "res/values/plurals.xml:3: Warning: The resource R.plurals.my_plural appears to be unused [UnusedResources]\n" + - " <plurals name=\"my_plural\">\n" + - " ~~~~~~~~~~~~~~~~\n" + - "0 errors, 1 warnings\n" + - "", - - lintProject( - "res/values/strings4.xml", - "res/values/plurals.xml", - "AndroidManifest.xml")); - } - - public void testNoMerging() throws Exception { - // http://code.google.com/p/android/issues/detail?id=36952 - - File master = getProjectDir("MasterProject", - // Master project - "multiproject/main-manifest.xml=>AndroidManifest.xml", - "multiproject/main.properties=>project.properties", - "multiproject/MainCode.java.txt=>src/foo/main/MainCode.java" - ); - File library = getProjectDir("LibraryProject", - // Library project - "multiproject/library-manifest.xml=>AndroidManifest.xml", - "multiproject/library.properties=>project.properties", - "multiproject/LibraryCode.java.txt=>src/foo/library/LibraryCode.java", - "multiproject/strings.xml=>res/values/strings.xml" - ); - assertEquals( - // The strings are all referenced in the library project's manifest file - // which in this project is merged in - "/TESTROOT/LibraryProject/res/values/strings.xml:7: Warning: The resource R.string.string3 appears to be unused [UnusedResources]\n" + - " <string name=\"string3\">String 3</string>\n" + - " ~~~~~~~~~~~~~~\n" + - "0 errors, 1 warnings\n", - - checkLint(Arrays.asList(master, library))); - } - - public void testLibraryMerging() throws Exception { - // http://code.google.com/p/android/issues/detail?id=36952 - File master = getProjectDir("MasterProject", - // Master project - "multiproject/main-manifest.xml=>AndroidManifest.xml", - "multiproject/main-merge.properties=>project.properties", - "multiproject/MainCode.java.txt=>src/foo/main/MainCode.java" - ); - File library = getProjectDir("LibraryProject", - // Library project - "multiproject/library-manifest.xml=>AndroidManifest.xml", - "multiproject/library.properties=>project.properties", - "multiproject/LibraryCode.java.txt=>src/foo/library/LibraryCode.java", - "multiproject/strings.xml=>res/values/strings.xml" - ); - assertEquals( - // The strings are all referenced in the library project's manifest file - // which in this project is merged in - "No warnings.", - - checkLint(Arrays.asList(master, library))); - } - - public void testCornerCase() throws Exception { - // See http://code.google.com/p/projectlombok/issues/detail?id=415 - mEnableIds = true; - assertEquals( - "No warnings.", - - lintProject( - "res/layout/accessibility.xml", - "src/test/pkg/Foo.java.txt=>src/test/pkg/Foo.java", - "AndroidManifest.xml")); - } - - public void testAnalytics() throws Exception { - // See http://code.google.com/p/android/issues/detail?id=42565 - mEnableIds = false; - assertEquals( - "No warnings.", - - lintProject( - "res/values/analytics.xml" - )); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/UseCompoundDrawableDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/UseCompoundDrawableDetectorTest.java deleted file mode 100644 index 146ff6f..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/UseCompoundDrawableDetectorTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class UseCompoundDrawableDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new UseCompoundDrawableDetector(); - } - - public void testCompound() throws Exception { - assertEquals( - "res/layout/compound.xml:3: Warning: This tag and its children can be replaced by one <TextView/> and a compound drawable [UseCompoundDrawables]\n" + - "<LinearLayout\n" + - "^\n" + - "0 errors, 1 warnings\n" + - "", - lintFiles("res/layout/compound.xml")); - } - - public void testCompound2() throws Exception { - // Ignore layouts that set a custom background - assertEquals( - "No warnings.", - lintFiles("res/layout/compound2.xml")); - } - - public void testCompound3() throws Exception { - // Ignore layouts that set an image scale type - assertEquals( - "No warnings.", - lintFiles("res/layout/compound3.xml")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/UselessViewDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/UselessViewDetectorTest.java deleted file mode 100644 index c34b987..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/UselessViewDetectorTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class UselessViewDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new UselessViewDetector(); - } - - public void testUseless() throws Exception { - assertEquals( - "res/layout/useless.xml:85: Warning: This FrameLayout view is useless (no children, no background, no id, no style) [UselessLeaf]\n" + - " <FrameLayout\n" + - " ^\n" + - "res/layout/useless.xml:13: Warning: This LinearLayout layout or its FrameLayout parent is useless [UselessParent]\n" + - " <LinearLayout\n" + - " ^\n" + - "res/layout/useless.xml:47: Warning: This LinearLayout layout or its FrameLayout parent is useless; transfer the background attribute to the other view [UselessParent]\n" + - " <LinearLayout\n" + - " ^\n" + - "res/layout/useless.xml:65: Warning: This LinearLayout layout or its FrameLayout parent is useless; transfer the background attribute to the other view [UselessParent]\n" + - " <LinearLayout\n" + - " ^\n" + - "0 errors, 4 warnings\n" + - "", - lintFiles("res/layout/useless.xml")); - } - - public void testTabHost() throws Exception { - assertEquals( - "No warnings.", - - lintFiles("res/layout/useless2.xml")); - } - - public void testStyleAttribute() throws Exception { - assertEquals( - "No warnings.", - - lintFiles("res/layout/useless3.xml")); - } - - public void testUselessLeafRoot() throws Exception { - assertEquals( - "No warnings.", - - lintFiles("res/layout/breadcrumbs_in_fragment.xml")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/Utf8DetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/Utf8DetectorTest.java deleted file mode 100644 index d1a118d..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/Utf8DetectorTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class Utf8DetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new Utf8Detector(); - } - - public void test() throws Exception { - assertEquals( - "res/layout/encoding.xml:1: Warning: iso-latin-1: Not using UTF-8 as the file encoding. This can lead to subtle bugs with non-ascii characters [EnforceUTF8]\n" + - "<?xml version=\"1.0\" encoding=\"iso-latin-1\"?>\n" + - " ~~~~~~~~~~~\n" + - "0 errors, 1 warnings\n" + - "", - lintProject("res/layout/encoding.xml")); - } - - public void testWithR() throws Exception { - assertEquals( - "res/layout/encoding2.xml:1: Warning: iso-latin-1: Not using UTF-8 as the file encoding. This can lead to subtle bugs with non-ascii characters [EnforceUTF8]\n" + - "<?xml version=\"1.0\" encoding=\"iso-latin-1\"?>\n" + - " ~~~~~~~~~~~\n" + - "0 errors, 1 warnings\n" + - "", - // encoding2.xml = encoding.xml but with \n => \r - lintProject("res/layout/encoding2.xml")); - } - - public void testNegative() throws Exception { - // Make sure we don't get warnings for a correct file - assertEquals( - "No warnings.", - lintProject("res/layout/layout1.xml")); - } - -} 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 deleted file mode 100644 index a84a74f..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/ViewConstructorDetectorTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class ViewConstructorDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new ViewConstructorDetector(); - } - - public void test() throws Exception { - assertEquals( - "src/test/bytecode/CustomView1.java: Warning: Custom view test/pkg/CustomView1 is missing constructor used by tools: (Context) or (Context,AttributeSet) or (Context,AttributeSet,int) [ViewConstructor]\n" + - "src/test/bytecode/CustomView2.java: Warning: Custom view test/pkg/CustomView2 is missing constructor used by tools: (Context) or (Context,AttributeSet) or (Context,AttributeSet,int) [ViewConstructor]\n" + - "0 errors, 2 warnings\n" + - "", - - lintProject( - "bytecode/.classpath=>.classpath", - "bytecode/AndroidManifest.xml=>AndroidManifest.xml", - "bytecode/CustomView1.java.txt=>src/test/bytecode/CustomView1.java", - "bytecode/CustomView2.java.txt=>src/test/bytecode/CustomView2.java", - "bytecode/CustomView3.java.txt=>src/test/bytecode/CustomView3.java", - "bytecode/CustomView1.class.data=>bin/classes/test/bytecode/CustomView1.class", - "bytecode/CustomView2.class.data=>bin/classes/test/bytecode/CustomView2.class", - "bytecode/CustomView3.class.data=>bin/classes/test/bytecode/CustomView3.class" - )); - } - - public void testInheritLocal() throws Exception { - assertEquals( - "src/test/pkg/CustomViewTest.java: Warning: Custom view test/pkg/CustomViewTest is missing constructor used by tools: (Context) or (Context,AttributeSet) or (Context,AttributeSet,int) [ViewConstructor]\n" + - "0 errors, 1 warnings\n" + - "", - - lintProject( - "bytecode/.classpath=>.classpath", - "bytecode/AndroidManifest.xml=>AndroidManifest.xml", - "apicheck/Intermediate.java.txt=>src/test/pkg/Intermediate.java.txt", - "src/test/pkg/CustomViewTest.java.txt=>src/test/pkg/CustomViewTest.java", - "bytecode/CustomViewTest.class.data=>bin/classes/test/pkg/CustomViewTest.class", - "apicheck/Intermediate.class.data=>bin/classes/test/pkg/Intermediate.class", - "apicheck/Intermediate$IntermediateCustomV.class.data=>" + - "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/ViewTagDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/ViewTagDetectorTest.java deleted file mode 100644 index 8d9e2d5..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/ViewTagDetectorTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class ViewTagDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new ViewTagDetector(); - } - - public void test() throws Exception { - assertEquals( - "src/test/pkg/ViewTagTest.java:21: Warning: Avoid setting views as values for setTag: Can lead to memory leaks in versions older than Android 4.0 [ViewTag]\n" + - " view.setTag(android.R.id.button1, group); // ERROR\n" + - " ~~~~~~\n" + - "src/test/pkg/ViewTagTest.java:22: Warning: Avoid setting views as values for setTag: Can lead to memory leaks in versions older than Android 4.0 [ViewTag]\n" + - " view.setTag(android.R.id.icon, view.findViewById(android.R.id.icon)); // ERROR\n" + - " ~~~~~~\n" + - "src/test/pkg/ViewTagTest.java:23: Warning: Avoid setting cursors as values for setTag: Can lead to memory leaks in versions older than Android 4.0 [ViewTag]\n" + - " view.setTag(android.R.id.icon1, cursor1); // ERROR\n" + - " ~~~~~~\n" + - "src/test/pkg/ViewTagTest.java:24: Warning: Avoid setting cursors as values for setTag: Can lead to memory leaks in versions older than Android 4.0 [ViewTag]\n" + - " view.setTag(android.R.id.icon2, cursor2); // ERROR\n" + - " ~~~~~~\n" + - "src/test/pkg/ViewTagTest.java:25: Warning: Avoid setting view holders as values for setTag: Can lead to memory leaks in versions older than Android 4.0 [ViewTag]\n" + - " view.setTag(android.R.id.copy, new MyViewHolder()); // ERROR\n" + - " ~~~~~~\n" + - "0 errors, 5 warnings\n", - - lintProject( - "bytecode/.classpath=>.classpath", - "bytecode/AndroidManifest.xml=>AndroidManifest.xml", - "res/layout/onclick.xml=>res/layout/onclick.xml", - "bytecode/ViewTagTest.java.txt=>src/test/pkg/ViewTagTest.java", - "bytecode/ViewTagTest.class.data=>bin/classes/test/pkg/ViewTagTest.class" - )); - } - - public void testICS() throws Exception { - assertEquals( - "No warnings.", - - lintProject( - "bytecode/.classpath=>.classpath", - "apicheck/minsdk14.xml=>AndroidManifest.xml", - "res/layout/onclick.xml=>res/layout/onclick.xml", - "bytecode/ViewTagTest.java.txt=>src/test/pkg/ViewTagTest.java", - "bytecode/ViewTagTest.class.data=>bin/classes/test/pkg/ViewTagTest.class" - )); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/ViewTypeDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/ViewTypeDetectorTest.java deleted file mode 100644 index cf38197..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/ViewTypeDetectorTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class ViewTypeDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new ViewTypeDetector(); - } - - public void test() throws Exception { - assertEquals( - "src/test/pkg/WrongCastActivity.java:13: Error: Unexpected cast to ToggleButton: layout tag was Button [WrongViewCast]\n" + - " ToggleButton toggleButton = (ToggleButton) findViewById(R.id.button);\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "1 errors, 0 warnings\n", - - lintProject( - "res/layout/casts.xml", - "src/test/pkg/WrongCastActivity.java.txt=>src/test/pkg/WrongCastActivity.java" - )); - } - - public void test2() throws Exception { - assertEquals( - "src/test/pkg/WrongCastActivity.java:13: Error: Unexpected cast to ToggleButton: layout tag was Button|RadioButton [WrongViewCast]\n" + - " ToggleButton toggleButton = (ToggleButton) findViewById(R.id.button);\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "1 errors, 0 warnings\n", - - lintProject( - "res/layout/casts.xml", - "res/layout/casts3.xml", - "src/test/pkg/WrongCastActivity.java.txt=>src/test/pkg/WrongCastActivity.java" - )); - } - - public void test3() throws Exception { - assertEquals( - "No warnings.", - - lintProject( - "res/layout/casts.xml", - "res/layout/casts4.xml", - "src/test/pkg/WrongCastActivity.java.txt=>src/test/pkg/WrongCastActivity.java" - )); - } - - public void test27441() throws Exception { - assertEquals( - "No warnings.", - - lintProject( - "res/layout/casts2.xml", - "src/test/pkg/WrongCastActivity2.java.txt=>src/test/pkg/WrongCastActivity2.java" - )); - } - - public void testCheckable() throws Exception { - assertEquals( - "No warnings.", - - lintProject( - "res/layout/casts2.xml", - "src/test/pkg/WrongCastActivity3.java.txt=>src/test/pkg/WrongCastActivity3.java" - )); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/WakelockDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/WakelockDetectorTest.java deleted file mode 100644 index 21434bb..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/WakelockDetectorTest.java +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class WakelockDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new WakelockDetector(); - } - - public void test1() throws Exception { - assertEquals( - "src/test/pkg/WakelockActivity1.java:15: Warning: Found a wakelock acquire() but no release() calls anywhere [Wakelock]\n" + - " mWakeLock.acquire(); // Never released\n" + - " ~~~~~~~\n" + - "0 errors, 1 warnings\n" + - "", - - lintProject( - "bytecode/.classpath=>.classpath", - "bytecode/AndroidManifest.xml=>AndroidManifest.xml", - "res/layout/onclick.xml=>res/layout/onclick.xml", - "bytecode/WakelockActivity1.java.txt=>src/test/pkg/WakelockActivity1.java", - "bytecode/WakelockActivity1.class.data=>bin/classes/test/pkg/WakelockActivity1.class" - )); - } - - public void test2() throws Exception { - assertEquals( - "src/test/pkg/WakelockActivity2.java:13: Warning: Wakelocks should be released in onPause, not onDestroy [Wakelock]\n" + - " mWakeLock.release(); // Should be done in onPause instead\n" + - " ~~~~~~~\n" + - "0 errors, 1 warnings\n" + - "", - - lintProject( - "bytecode/.classpath=>.classpath", - "bytecode/AndroidManifest.xml=>AndroidManifest.xml", - "res/layout/onclick.xml=>res/layout/onclick.xml", - "bytecode/WakelockActivity2.java.txt=>src/test/pkg/WakelockActivity2.java", - "bytecode/WakelockActivity2.class.data=>bin/classes/test/pkg/WakelockActivity2.class" - )); - } - - public void test3() throws Exception { - assertEquals( - "src/test/pkg/WakelockActivity3.java:13: Warning: The release() call is not always reached [Wakelock]\n" + - " lock.release(); // Should be in finally block\n" + - " ~~~~~~~\n" + - "0 errors, 1 warnings\n" + - "", - - lintProject( - "bytecode/.classpath=>.classpath", - "bytecode/AndroidManifest.xml=>AndroidManifest.xml", - "res/layout/onclick.xml=>res/layout/onclick.xml", - "bytecode/WakelockActivity3.java.txt=>src/test/pkg/WakelockActivity3.java", - "bytecode/WakelockActivity3.class.data=>bin/classes/test/pkg/WakelockActivity3.class" - )); - } - - public void test4() throws Exception { - assertEquals( - "src/test/pkg/WakelockActivity4.java:10: Warning: The release() call is not always reached [Wakelock]\n" + - " getLock().release(); // Should be in finally block\n" + - " ~~~~~~~\n" + - "0 errors, 1 warnings\n" + - "", - - lintProject( - "bytecode/.classpath=>.classpath", - "bytecode/AndroidManifest.xml=>AndroidManifest.xml", - "res/layout/onclick.xml=>res/layout/onclick.xml", - "bytecode/WakelockActivity4.java.txt=>src/test/pkg/WakelockActivity4.java", - "bytecode/WakelockActivity4.class.data=>bin/classes/test/pkg/WakelockActivity4.class" - )); - } - - public void test5() throws Exception { - assertEquals( - "src/test/pkg/WakelockActivity5.java:13: Warning: The release() call is not always reached [Wakelock]\n" + - " lock.release(); // Should be in finally block\n" + - " ~~~~~~~\n" + - "0 errors, 1 warnings\n" + - "", - - lintProject( - "bytecode/.classpath=>.classpath", - "bytecode/AndroidManifest.xml=>AndroidManifest.xml", - "res/layout/onclick.xml=>res/layout/onclick.xml", - "bytecode/WakelockActivity5.java.txt=>src/test/pkg/WakelockActivity5.java", - "bytecode/WakelockActivity5.class.data=>bin/classes/test/pkg/WakelockActivity5.class" - )); - } - - public void test6() throws Exception { - assertEquals( - "src/test/pkg/WakelockActivity6.java:19: Warning: The release() call is not always reached [Wakelock]\n" + - " lock.release(); // Wrong\n" + - " ~~~~~~~\n" + - "src/test/pkg/WakelockActivity6.java:28: Warning: The release() call is not always reached [Wakelock]\n" + - " lock.release(); // Wrong\n" + - " ~~~~~~~\n" + - "src/test/pkg/WakelockActivity6.java:65: Warning: The release() call is not always reached [Wakelock]\n" + - " lock.release(); // Wrong\n" + - " ~~~~~~~\n" + - "0 errors, 3 warnings\n" + - "", - - lintProject( - "bytecode/.classpath=>.classpath", - "bytecode/AndroidManifest.xml=>AndroidManifest.xml", - "res/layout/onclick.xml=>res/layout/onclick.xml", - "bytecode/WakelockActivity6.java.txt=>src/test/pkg/WakelockActivity6.java", - "bytecode/WakelockActivity6.class.data=>bin/classes/test/pkg/WakelockActivity6.class" - )); - } - - public void test7() throws Exception { - assertEquals( - "No warnings.", - - lintProject( - "bytecode/.classpath=>.classpath", - "bytecode/AndroidManifest.xml=>AndroidManifest.xml", - "res/layout/onclick.xml=>res/layout/onclick.xml", - "bytecode/WakelockActivity7.java.txt=>src/test/pkg/WakelockActivity7.java", - "bytecode/WakelockActivity7.class.data=>bin/classes/test/pkg/WakelockActivity7.class" - )); - } - - public void test8() throws Exception { - assertEquals( - "No warnings.", - - lintProject( - "bytecode/.classpath=>.classpath", - "bytecode/AndroidManifest.xml=>AndroidManifest.xml", - "bytecode/WakelockActivity8.java.txt=>src/test/pkg/WakelockActivity8.java", - "bytecode/WakelockActivity8.class.data=>bin/classes/test/pkg/WakelockActivity8.class" - )); - } - - public void testFlags() throws Exception { - assertEquals("" - + "src/test/pkg/PowerManagerFlagTest.java:15: Warning: Should not set both PARTIAL_WAKE_LOCK and ACQUIRE_CAUSES_WAKEUP. If you do not want the screen to turn on, get rid of ACQUIRE_CAUSES_WAKEUP [Wakelock]\n" - + " pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK|ACQUIRE_CAUSES_WAKEUP, \"Test\"); // Bad\n" - + " ~~~~~~~~~~~\n" - + "0 errors, 1 warnings\n", - - lintProject( - "bytecode/.classpath=>.classpath", - "bytecode/AndroidManifest.xml=>AndroidManifest.xml", - "bytecode/PowerManagerFlagTest.java.txt=>src/test/pkg/PowerManagerFlagTest.java", - "bytecode/PowerManagerFlagTest.class.data=>bin/classes/test/pkg/PowerManagerFlagTest.class" - )); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/WrongCallDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/WrongCallDetectorTest.java deleted file mode 100644 index ff557ab..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/WrongCallDetectorTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class WrongCallDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new WrongCallDetector(); - } - - public void test() throws Exception { - assertEquals("" - + "src/test/pkg/LayoutTest.java:23: Error: Suspicious method call; should probably call \"layout\" rather than \"onLayout\" [WrongCall]\n" - + " child.onLayout(changed, left, top, right, bottom); // Not OK\n" - + " ~~~~~~~~\n" - + "src/test/pkg/LayoutTest.java:25: Error: Suspicious method call; should probably call \"measure\" rather than \"onMeasure\" [WrongCall]\n" - + " super.onMeasure(0, 0); // Not OK\n" - + " ~~~~~~~~~\n" - + "src/test/pkg/LayoutTest.java:26: Error: Suspicious method call; should probably call \"draw\" rather than \"onDraw\" [WrongCall]\n" - + " super.onDraw(null); // Not OK\n" - + " ~~~~~~\n" - + "src/test/pkg/LayoutTest.java:33: Error: Suspicious method call; should probably call \"layout\" rather than \"onLayout\" [WrongCall]\n" - + " super.onLayout(false, 0, 0, 0, 0); // Not OK\n" - + " ~~~~~~~~\n" - + "src/test/pkg/LayoutTest.java:34: Error: Suspicious method call; should probably call \"measure\" rather than \"onMeasure\" [WrongCall]\n" - + " child.onMeasure(widthMeasureSpec, heightMeasureSpec); // Not OK\n" - + " ~~~~~~~~~\n" - + "src/test/pkg/LayoutTest.java:41: Error: Suspicious method call; should probably call \"draw\" rather than \"onDraw\" [WrongCall]\n" - + " child.onDraw(canvas); // Not OK\n" - + " ~~~~~~\n" - + "6 errors, 0 warnings\n", - - lintProject( - "bytecode/.classpath=>.classpath", - "bytecode/AndroidManifest.xml=>AndroidManifest.xml", - "res/layout/onclick.xml=>res/layout/onclick.xml", - "bytecode/LayoutTest.java.txt=>src/test/pkg/LayoutTest.java", - "bytecode/LayoutTest.class.data=>bin/classes/test/pkg/LayoutTest.class" - )); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/WrongCaseDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/WrongCaseDetectorTest.java deleted file mode 100644 index 8f7ed9c..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/WrongCaseDetectorTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class WrongCaseDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new WrongCaseDetector(); - } - - public void test() throws Exception { - assertEquals("" - + "res/layout/case.xml:18: Warning: Invalid tag <Merge>; should be <merge> [WrongCase]\n" - + "<Merge xmlns:android=\"http://schemas.android.com/apk/res/android\" >\n" - + "^\n" - + "res/layout/case.xml:20: Warning: Invalid tag <Fragment>; should be <fragment> [WrongCase]\n" - + " <Fragment android:name=\"foo.bar.Fragment\" />\n" - + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" - + "res/layout/case.xml:21: Warning: Invalid tag <Include>; should be <include> [WrongCase]\n" - + " <Include layout=\"@layout/foo\" />\n" - + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" - + "res/layout/case.xml:22: Warning: Invalid tag <RequestFocus>; should be <requestFocus> [WrongCase]\n" - + " <RequestFocus />\n" - + " ~~~~~~~~~~~~~~~~\n" - + "0 errors, 4 warnings\n", - - lintProject("res/layout/case.xml")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/WrongIdDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/WrongIdDetectorTest.java deleted file mode 100644 index b3fd203..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/WrongIdDetectorTest.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class WrongIdDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new WrongIdDetector(); - } - - public void test() throws Exception { - assertEquals( - "res/layout/layout1.xml:14: Error: The id \"button5\" is not defined anywhere. Did you mean one of {button1, button2, button3, button4} ? [UnknownId]\n" + - " android:layout_alignBottom=\"@+id/button5\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/layout1.xml:17: Error: The id \"my_id3\" is not defined anywhere. Did you mean my_id2 ? [UnknownId]\n" + - " android:layout_alignRight=\"@+id/my_id3\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/layout1.xml:18: Error: The id \"my_id1\" is defined but not assigned to any views. Did you mean my_id2 ? [UnknownId]\n" + - " android:layout_alignTop=\"@+id/my_id1\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/layout1.xml:15: Warning: The id \"my_id2\" is not referring to any views in this layout [UnknownIdInLayout]\n" + - " android:layout_alignLeft=\"@+id/my_id2\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "3 errors, 1 warnings\n" + - "", - - lintProject( - "wrongid/layout1.xml=>res/layout/layout1.xml", - "wrongid/layout2.xml=>res/layout/layout2.xml", - "wrongid/ids.xml=>res/values/ids.xml" - )); - } - - public void testSingleFile() throws Exception { - assertEquals( - "res/layout/layout1.xml:14: Warning: The id \"button5\" is not referring to any views in this layout [UnknownIdInLayout]\n" + - " android:layout_alignBottom=\"@+id/button5\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/layout1.xml:15: Warning: The id \"my_id2\" is not referring to any views in this layout [UnknownIdInLayout]\n" + - " android:layout_alignLeft=\"@+id/my_id2\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/layout1.xml:17: Warning: The id \"my_id3\" is not referring to any views in this layout [UnknownIdInLayout]\n" + - " android:layout_alignRight=\"@+id/my_id3\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "res/layout/layout1.xml:18: Warning: The id \"my_id1\" is not referring to any views in this layout [UnknownIdInLayout]\n" + - " android:layout_alignTop=\"@+id/my_id1\"\n" + - " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + - "0 errors, 4 warnings\n" + - "", - - lintFiles("wrongid/layout1.xml=>res/layout/layout1.xml")); - } - - public void testSuppressed() throws Exception { - assertEquals( - "No warnings.", - - lintProject( - "wrongid/ignorelayout1.xml=>res/layout/layout1.xml", - "wrongid/layout2.xml=>res/layout/layout2.xml", - "wrongid/ids.xml=>res/values/ids.xml" - )); - } - - public void testSuppressedSingleFile() throws Exception { - assertEquals( - "No warnings.", - - lintFiles("wrongid/ignorelayout1.xml=>res/layout/layout1.xml")); - } - - public void testNewIdPrefix() throws Exception { - assertEquals( - "No warnings.", - - lintFiles("res/layout/default_item_badges.xml", - "res/layout/detailed_item.xml")); - } - -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/WrongImportDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/WrongImportDetectorTest.java deleted file mode 100644 index c44f204..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/WrongImportDetectorTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class WrongImportDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new WrongImportDetector(); - } - - public void test() throws Exception { - assertEquals( - "src/test/pkg/BadImport.java:5: Warning: Don't include android.R here; use a fully qualified name for each usage instead [SuspiciousImport]\n" + - "import android.R;\n" + - "~~~~~~~~~~~~~~~~~\n" + - "0 errors, 1 warnings\n" + - "", - - lintProject( - // Java files must be renamed in source tree - "src/test/pkg/BadImport.java.txt=>src/test/pkg/BadImport.java")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/WrongLocationDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/WrongLocationDetectorTest.java deleted file mode 100644 index f30a604..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/WrongLocationDetectorTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.checks; - -import com.android.tools.lint.detector.api.Detector; - -@SuppressWarnings("javadoc") -public class WrongLocationDetectorTest extends AbstractCheckTest { - @Override - protected Detector getDetector() { - return new WrongLocationDetector(); - } - - public void test() throws Exception { - assertEquals( - "res/layout/alias.xml:17: Error: This file should be placed in a values/ folder, not a layout/ folder [WrongFolder]\n" + - "<resources>\n" + - "^\n" + - "1 errors, 0 warnings\n", - - lintProject("res/values/strings.xml=>res/layout/alias.xml")); - } - - public void testOk() throws Exception { - assertEquals("No warnings.", - - lintProject("res/values/strings.xml")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/AbstractActivity.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/AbstractActivity.java.txt deleted file mode 100644 index a9e0400..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/AbstractActivity.java.txt +++ /dev/null @@ -1,6 +0,0 @@ -package test.pkg; - -import android.app.Activity; - -public abstract class AbstractActivity extends Activity { -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/AndroidManifest.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/AndroidManifest.xml deleted file mode 100644 index 75ef31c..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/AndroidManifest.xml +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="foo.bar2" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="14" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - <activity - android:label="@string/app_name" - android:name=".Foo2Activity" > - <intent-filter > - <action android:name="android.intent.action.MAIN" /> - - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - </application> - -</manifest>
\ No newline at end of file diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/allowbackup.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/allowbackup.xml deleted file mode 100644 index 2a95252..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/allowbackup.xml +++ /dev/null @@ -1,24 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="foo.bar2" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="14" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" - android:allowBackup="true" > - <activity - android:label="@string/app_name" - android:name=".Foo2Activity" > - <intent-filter > - <action android:name="android.intent.action.MAIN" /> - - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - </application> - -</manifest> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/allowbackup_ignore.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/allowbackup_ignore.xml deleted file mode 100644 index 72f8bb4..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/allowbackup_ignore.xml +++ /dev/null @@ -1,25 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:tools="http://schemas.android.com/tools" - package="foo.bar2" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="14" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" - tools:ignore="AllowBackup" - <activity - android:label="@string/app_name" - android:name=".Foo2Activity" > - <intent-filter > - <action android:name="android.intent.action.MAIN" /> - - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - </application> - -</manifest> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest.class.data Binary files differdeleted file mode 100644 index 4e2b100..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest.java.txt deleted file mode 100644 index 456dd8b..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest.java.txt +++ /dev/null @@ -1,52 +0,0 @@ -package test.pkg; - -import org.w3c.dom.DOMError; -import org.w3c.dom.DOMErrorHandler; -import org.w3c.dom.DOMLocator; - -import android.view.ViewGroup.LayoutParams; -import android.app.Activity; -import android.app.ApplicationErrorReport; -import android.app.ApplicationErrorReport.BatteryInfo; -import android.graphics.PorterDuff; -import android.graphics.PorterDuff.Mode; -import android.widget.Chronometer; -import android.widget.GridLayout; -import dalvik.bytecode.OpcodeInfo; - -public class ApiCallTest extends Activity { - public void method(Chronometer chronometer, DOMLocator locator) { - // Virtual call - getActionBar(); // API 11 - - // Class references (no call or field access) - DOMError error = null; // API 8 - Class<?> clz = DOMErrorHandler.class; // API 8 - - // Method call - chronometer.getOnChronometerTickListener(); // API 3 - - // Inherited method call (from TextView - chronometer.setTextIsSelectable(true); // API 11 - - // Field access - int field = OpcodeInfo.MAXIMUM_VALUE; // API 11 - int fillParent = LayoutParams.FILL_PARENT; // API 1 - // This is a final int, which means it gets inlined - int matchParent = LayoutParams.MATCH_PARENT; // API 8 - // Field access: non final - BatteryInfo batteryInfo = getReport().batteryInfo; - - // Enum access - Mode mode = PorterDuff.Mode.OVERLAY; // API 11 - } - - // Return type - GridLayout getGridLayout() { // API 14 - return null; - } - - private ApplicationErrorReport getReport() { - return null; - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest10.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest10.class.data Binary files differdeleted file mode 100644 index 23ef1bd..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest10.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest10.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest10.java.txt deleted file mode 100644 index ae02a81..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest10.java.txt +++ /dev/null @@ -1,45 +0,0 @@ -package test.pkg; - -import android.os.Build; -import android.view.MotionEvent; -import android.view.View; -import android.view.accessibility.AccessibilityEvent; - -public class ApiCallTest10 extends View { - public ApiCallTest10() { - super(null, null, 0); - } - - @Override - public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { - onPopulateAccessibilityEvent(event); // Shouldn't warn here: method - // exists locally - return true; - } - return super.dispatchPopulateAccessibilityEvent(event); - } - - @Override - public void onPopulateAccessibilityEvent(AccessibilityEvent event) { - super.onPopulateAccessibilityEvent(event); // Valid lint warning - // Additional override code here: - } - - @Override - protected boolean dispatchGenericFocusedEvent(MotionEvent event) { - return super.dispatchGenericFocusedEvent(event); // Should flag this - } - - protected boolean dispatchHoverEvent(int event) { - return false; - } - - public void test1() { - // Should flag this, because the local method has the wrong signature - dispatchHoverEvent(null); - - // Shouldn't flag this, local method makes it available - dispatchGenericFocusedEvent(null); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest11$MyActivity.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest11$MyActivity.class.data Binary files differdeleted file mode 100644 index 5368daf..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest11$MyActivity.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest11$MyLinear.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest11$MyLinear.class.data Binary files differdeleted file mode 100644 index 5ee9e96..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest11$MyLinear.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest11.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest11.class.data Binary files differdeleted file mode 100644 index 17e10d6..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest11.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest11.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest11.java.txt deleted file mode 100644 index 8fb592c..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest11.java.txt +++ /dev/null @@ -1,50 +0,0 @@ -package test.pkg; - -import android.annotation.SuppressLint; -import android.app.ActionBar; -import android.app.Activity; -import android.content.Context; -import android.graphics.drawable.Drawable; -import android.widget.LinearLayout; - -public class ApiCallTest11 extends Activity { - MyActivity mActionBarHost; - - public ActionBar getActionBar() { - return mActionBarHost.getActionBar(); - } - - public boolean isDestroyed() { - return true; - } - - @SuppressLint("Override") - public void finishAffinity() { - } - - private class MyLinear extends LinearLayout { - private Drawable mDividerDrawable; - - public MyLinear(Context context) { - super(context); - } - - /** - * Javadoc here - * - * - * - * - */ - public void setDividerDrawable(Drawable dividerDrawable) { - mDividerDrawable = dividerDrawable; - } - } - - private class MyActivity { - public ActionBar getActionBar() { - return null; - } - } -} - diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest12.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest12.class.data Binary files differdeleted file mode 100644 index 4056133..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest12.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest12.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest12.java.txt deleted file mode 100644 index 6ac71db..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest12.java.txt +++ /dev/null @@ -1,30 +0,0 @@ -package test.pkg; - -import android.annotation.SuppressLint; -import android.annotation.TargetApi; -import android.os.Build; - -import java.text.DateFormatSymbols; -import java.text.SimpleDateFormat; -import java.util.Locale; - -@SuppressWarnings({ "unused", "javadoc" }) -@SuppressLint("SimpleDateFormat") -public class ApiCallTest12 { - public void test() { - // Normal SimpleDateFormat calls - new SimpleDateFormat(); - new SimpleDateFormat("yyyy-MM-dd"); - new SimpleDateFormat("yyyy-MM-dd", DateFormatSymbols.getInstance()); - new SimpleDateFormat("yyyy-MM-dd", Locale.US); - new SimpleDateFormat("MMMM", Locale.US); - - // Flag format strings requiring API 9 - new SimpleDateFormat("yyyy-MM-dd LL", Locale.US); - - SimpleDateFormat format = new SimpleDateFormat("cc yyyy-MM-dd"); - - // Escaped text - new SimpleDateFormat("MM-dd 'My Location'", Locale.US); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest2.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest2.class.data Binary files differdeleted file mode 100644 index 32c3657..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest2.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest2.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest2.java.txt deleted file mode 100644 index aa6f344..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest2.java.txt +++ /dev/null @@ -1,9 +0,0 @@ -package android.support.foo; - -import org.w3c.dom.DOMError; - -public class Foo { - private void foo() { - DOMError error = null; // API 8 - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest3.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest3.class.data Binary files differdeleted file mode 100644 index 3d39e74..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest3.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest3.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest3.java.txt deleted file mode 100644 index d1ea3e4..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest3.java.txt +++ /dev/null @@ -1,12 +0,0 @@ -package test.pkg; - -/** - * Call test where the parent class is some other project class which in turn - * extends the public API - */ -public class ApiCallTest3 extends Intermediate { - public void foo() { - // Virtual call - getActionBar(); // API 11 - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest4$1.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest4$1.class.data Binary files differdeleted file mode 100644 index 8d3fbf7..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest4$1.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest4$InnerClass1$InnerInnerClass1.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest4$InnerClass1$InnerInnerClass1.class.data Binary files differdeleted file mode 100644 index 940b83d..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest4$InnerClass1$InnerInnerClass1.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest4$InnerClass1.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest4$InnerClass1.class.data Binary files differdeleted file mode 100644 index 4da3d3b..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest4$InnerClass1.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest4$InnerClass2.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest4$InnerClass2.class.data Binary files differdeleted file mode 100644 index c8e914b..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest4$InnerClass2.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest4.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest4.class.data Binary files differdeleted file mode 100644 index b51d04a..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest4.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest4.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest4.java.txt deleted file mode 100644 index de6be04..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest4.java.txt +++ /dev/null @@ -1,41 +0,0 @@ -package test.pkg; - -import android.annotation.SuppressLint; -import android.widget.GridLayout; - -@SuppressWarnings("unused") -public class ApiCallTest4 { - public void foo() { - new GridLayout(null, null, 0); - } - - @SuppressLint("NewApi") - void foo2() { - // Inner class suppressed via a method in outer class - new Runnable() { - @Override - public void run() { - new GridLayout(null, null, 0); - } - }; - } - - @SuppressLint("NewApi") - private class InnerClass1 { - void foo() { - new GridLayout(null, null, 0); - } - - private class InnerInnerClass1 { - public void foo() { - new GridLayout(null, null, 0); - } - } - } - - private class InnerClass2 { - public void foo() { - new GridLayout(null, null, 0); - } - } -}
\ No newline at end of file diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest5.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest5.class.data Binary files differdeleted file mode 100644 index ad0cd48..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest5.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest5.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest5.java.txt deleted file mode 100644 index 4be8258..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest5.java.txt +++ /dev/null @@ -1,23 +0,0 @@ -package test.pkg; - -import android.annotation.TargetApi; -import android.content.Context; -import android.view.View; - -public class ApiCallTest5 extends View { - public ApiCallTest5(Context context) { - super(context); - } - - @SuppressWarnings("unused") - @Override - @TargetApi(2) - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - int measuredWidth = View.resolveSizeAndState(widthMeasureSpec, - widthMeasureSpec, 0); - int measuredHeight = resolveSizeAndState(heightMeasureSpec, - heightMeasureSpec, 0); - View.combineMeasuredStates(0, 0); - ApiCallTest5.combineMeasuredStates(0, 0); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest6.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest6.class.data Binary files differdeleted file mode 100644 index 7c0f3a7..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest6.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest6.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest6.java.txt deleted file mode 100644 index ae6e5fa..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest6.java.txt +++ /dev/null @@ -1,10 +0,0 @@ -package test.pkg; - -import java.io.IOException; - -public class ApiCallTest6 { - public void test(Throwable throwable) { - // IOException(Throwable) requires API 9 - IOException ioException = new IOException(throwable); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest7.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest7.class.data Binary files differdeleted file mode 100644 index e9f739d..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest7.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest7.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest7.java.txt deleted file mode 100644 index 37ad6a7..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest7.java.txt +++ /dev/null @@ -1,14 +0,0 @@ -package test.pkg; - -import java.io.IOException; - -@SuppressWarnings("serial") -public class ApiCallTest7 extends IOException { - public ApiCallTest7(String message, Throwable cause) { - super(message, cause); // API 9 - } - - public void fun() throws IOException { - super.toString(); throw new IOException((Throwable) null); // API 9 - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest8.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest8.class.data Binary files differdeleted file mode 100644 index b92e7d9..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest8.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest8.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest8.java.txt deleted file mode 100644 index f742ad1..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest8.java.txt +++ /dev/null @@ -1,10 +0,0 @@ -package test.pkg; - -import android.text.style.LeadingMarginSpan; - -@SuppressWarnings("unused") -public class ApiCallTest8 { - public void test() { - LeadingMarginSpan.LeadingMarginSpan2 span = null; - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest9.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest9.class.data Binary files differdeleted file mode 100644 index f50ebab..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest9.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest9.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest9.java.txt deleted file mode 100644 index 199231e..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest9.java.txt +++ /dev/null @@ -1,19 +0,0 @@ -package test.pkg; - -import android.annotation.SuppressLint; -import android.widget.GridLayout; - -/** Test suppress on fields */ -public class ApiCallTest9 { - // Actual initialization code lives in the synthetic method <init> - private GridLayout field1 = new GridLayout(null); - - // Actual initialization code lives in the synthetic method <clinit> - private static GridLayout field2 = new GridLayout(null); - - @SuppressLint("NewApi") - private GridLayout field3 = new GridLayout(null); - - @SuppressLint("NewApi") - private static GridLayout field4 = new GridLayout(null); -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiSourceCheck.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiSourceCheck.class.data Binary files differdeleted file mode 100644 index 726b8a5..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiSourceCheck.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiSourceCheck.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiSourceCheck.java.txt deleted file mode 100644 index 429b388..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiSourceCheck.java.txt +++ /dev/null @@ -1,123 +0,0 @@ -package test.pkg; - -import android.util.Property; -import android.view.View; -import static android.view.View.MEASURED_STATE_MASK; -import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR1; -import android.view.*; -import android.annotation.*; -import android.app.*; -import android.widget.*; -import static android.widget.ZoomControls.*; -import android.Manifest.permission; -import android.Manifest; - -/** Various tests for source-level checks */ -final class ApiSourceCheck extends LinearLayout { - public ApiSourceCheck(android.content.Context context) { - super(context); - } - - /** - * Return only the state bits of {@link #getMeasuredWidthAndState()} and - * {@link #getMeasuredHeightAndState()}, combined into one integer. The - * width component is in the regular bits {@link #MEASURED_STATE_MASK} and - * the height component is at the shifted bits - * {@link #MEASURED_HEIGHT_STATE_SHIFT}>>{@link #MEASURED_STATE_MASK}. - */ - public static int m1(View child) { - // from static import of field - int x = MEASURED_STATE_MASK; - - // fully qualified name field access - int y = android.view.View.MEASURED_STATE_MASK; - - // from explicitly imported class - int z = View.MEASURED_STATE_MASK; - int find2 = View.FIND_VIEWS_WITH_TEXT; // requires API 14 - - // from wildcard import of package - int w = ActivityManager.MOVE_TASK_NO_USER_ACTION; - int find1 = ZoomButton.FIND_VIEWS_WITH_CONTENT_DESCRIPTION; // requires - // API 14 - // from static wildcard import - int overScroll = OVER_SCROLL_ALWAYS; // requires API 9 - - // Inherited field from ancestor class (View) - int auto = IMPORTANT_FOR_ACCESSIBILITY_AUTO; // requires API 16 - - // object field reference: ensure that we don't get two errors - // (one from source scan, the other from class scan) - Object rotationX = ZoomButton.ROTATION_X; // Requires API 14 - - // different type of expression than variable declaration - return (child.getMeasuredWidth() & View.MEASURED_STATE_MASK) - | ((child.getMeasuredHeight() >> View.MEASURED_HEIGHT_STATE_SHIFT) & (View.MEASURED_STATE_MASK >> View.MEASURED_HEIGHT_STATE_SHIFT)); - } - - @SuppressLint("NewApi") - private void testSuppress1() { - // Checks suppress on surrounding method - int w = ActivityManager.MOVE_TASK_NO_USER_ACTION; - } - - private void testSuppress2() { - // Checks suppress on surrounding declaration statement - @SuppressLint("NewApi") - int w, z = ActivityManager.MOVE_TASK_NO_USER_ACTION; - } - - @TargetApi(17) - private void testTargetApi1() { - // Checks @TargetApi on surrounding method - int w, z = ActivityManager.MOVE_TASK_NO_USER_ACTION; - } - - @TargetApi(android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) - private void testTargetApi2() { - // Checks @TargetApi with codename - int w, z = ActivityManager.MOVE_TASK_NO_USER_ACTION; - } - - @TargetApi(JELLY_BEAN_MR1) - private void testTargetApi3() { - // Checks @TargetApi with codename - int w, z = ActivityManager.MOVE_TASK_NO_USER_ACTION; - } - - private void checkOtherFields() { - // Look at fields that aren't capitalized - int custom = android.R.id.custom; // API 8 - } - - private void innerclass() { - String setPointerSpeed = permission.SET_POINTER_SPEED; - String setPointerSpeed2 = Manifest.permission.SET_POINTER_SPEED; - } - - private void test() { - // Make sure that local variable references which look like fields, - // even imported ones, aren't taken as invalid references - int OVER_SCROLL_ALWAYS = 1, IMPORTANT_FOR_ACCESSIBILITY_AUTO = 2; - int x = OVER_SCROLL_ALWAYS; - int y = IMPORTANT_FOR_ACCESSIBILITY_AUTO; - findViewById(IMPORTANT_FOR_ACCESSIBILITY_AUTO); // yes, nonsensical - } - - private void testBenignUsages(int x) { - // Certain types of usages (such as switch/case constants) are okay - switch (x) { - case View.MEASURED_STATE_MASK: { // OK - break; - } - } - if (x == View.MEASURED_STATE_MASK) { // OK - } - if (false || x == View.MEASURED_STATE_MASK) { // OK - } - if (x >= View.MEASURED_STATE_MASK) { // OK - } - int y = View.MEASURED_STATE_MASK; // Not OK - testBenignUsages(View.MEASURED_STATE_MASK); // Not OK - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiSourceCheck2.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiSourceCheck2.class.data Binary files differdeleted file mode 100644 index a37d62c..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiSourceCheck2.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiSourceCheck2.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiSourceCheck2.java.txt deleted file mode 100644 index adce4f0..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiSourceCheck2.java.txt +++ /dev/null @@ -1,18 +0,0 @@ -package test.pkg; - -import android.widget.AbsListView; -import android.widget.ListView; - -@SuppressWarnings("unused") -public class ApiSourceCheck2 { - public void test() { - int mode1 = AbsListView.CHOICE_MODE_MULTIPLE; - int mode2 = AbsListView.CHOICE_MODE_MULTIPLE_MODAL; - int mode3 = AbsListView.CHOICE_MODE_NONE; - int mode4 = AbsListView.CHOICE_MODE_SINGLE; - int mode5 = ListView.CHOICE_MODE_MULTIPLE; - int mode6 = ListView.CHOICE_MODE_MULTIPLE_MODAL; - int mode7 = ListView.CHOICE_MODE_NONE; - int mode8 = ListView.CHOICE_MODE_SINGLE; - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest$LocalClass.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest$LocalClass.class.data Binary files differdeleted file mode 100644 index 136eed5..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest$LocalClass.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest.class.data Binary files differdeleted file mode 100644 index 7dc3d60..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest.java.txt deleted file mode 100644 index 8626858..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest.java.txt +++ /dev/null @@ -1,42 +0,0 @@ -package test.pkg; - -import org.w3c.dom.DOMErrorHandler; - -import android.annotation.TargetApi; - -// Test using the @TargetApi annotation to temporarily override -// the required API levels -@SuppressWarnings("unused") -public class ApiTargetTest { - public void test1() { - // No annotation: should generate warning if manifest SDK < 8 - Class<?> clz = DOMErrorHandler.class; // API 8 - } - - // Temporarily setting method min sdk to 12 - @TargetApi(12) - public void test2() { - Class<?> clz = DOMErrorHandler.class; // API 8 - } - - // Temporarily setting method min sdk to 14 - @TargetApi(4) - public void test3() { - Class<?> clz = DOMErrorHandler.class; // API 8 - } - - // Temporarily setting class min sdk to 12 - @TargetApi(value=11) - public static class LocalClass { - public void test4() { - Class<?> clz = DOMErrorHandler.class; // API 8 - } - - // Overriding class min sdk: this should generate - // an API warning again - @TargetApi(7) - public void test5() { - Class<?> clz = DOMErrorHandler.class; // API 8 - } - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest2$1$1.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest2$1$1.class.data Binary files differdeleted file mode 100644 index f18f226..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest2$1$1.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest2$1$2.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest2$1$2.class.data Binary files differdeleted file mode 100644 index ac3863e..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest2$1$2.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest2$1.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest2$1.class.data Binary files differdeleted file mode 100644 index f51c54b..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest2$1.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest2.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest2.class.data Binary files differdeleted file mode 100644 index defae98..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest2.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest2.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest2.java.txt deleted file mode 100644 index 7574805..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest2.java.txt +++ /dev/null @@ -1,39 +0,0 @@ -package test.pkg; - -import android.annotation.TargetApi; -import android.widget.GridLayout; - -// Test using the @TargetApi annotation on inner classes and anonymous inner classes -@SuppressWarnings("unused") -public class ApiTargetTest2 { - @TargetApi(value=14) - void foo2() { - new Runnable() { - @Override - public void run() { - new GridLayout(null, null, 0); - } - - void foo3() { - new Runnable() { - @Override - public void run() { - new GridLayout(null, null, 0); - } - }; - } - - @TargetApi(value=3) - void foo4() { - new Runnable() { - @Override - public void run() { - // This should be marked as an error since the effective target API is 3 here - new GridLayout(null, null, 0); - } - }; - } - - }; - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/CloseTest.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/CloseTest.class.data Binary files differdeleted file mode 100644 index acb19e5..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/CloseTest.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/CloseTest.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/CloseTest.java.txt deleted file mode 100644 index dc3e538..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/CloseTest.java.txt +++ /dev/null @@ -1,9 +0,0 @@ -package test.pkg; - -import android.database.sqlite.SQLiteStatement; - -public class CloseTest { - public void close(SQLiteStatement statement) { - statement.close(); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/Intermediate$IntermediateCustomV.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/Intermediate$IntermediateCustomV.class.data Binary files differdeleted file mode 100644 index cbf323c..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/Intermediate$IntermediateCustomV.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/Intermediate.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/Intermediate.class.data Binary files differdeleted file mode 100644 index 8d187da..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/Intermediate.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/Intermediate.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/Intermediate.java.txt deleted file mode 100644 index fea5c4f..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/Intermediate.java.txt +++ /dev/null @@ -1,15 +0,0 @@ -package test.pkg; - -import android.app.Activity; -import android.widget.Button; - -/** Local activity */ -public abstract class Intermediate extends Activity { - - /** Local Custom view */ - public abstract static class IntermediateCustomV extends Button { - public IntermediateCustomV() { - super(null); - } - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/MyActivityImpl.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/MyActivityImpl.class.data Binary files differdeleted file mode 100644 index 6ae6b28..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/MyActivityImpl.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/MyActivityImpl.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/MyActivityImpl.java.txt deleted file mode 100644 index e39daf8..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/MyActivityImpl.java.txt +++ /dev/null @@ -1,15 +0,0 @@ -package test.pkg; - -import android.app.Activity; -import android.support.v4.app.FragmentActivity; - -public class MyActivityImpl extends FragmentActivity { - public void test() { - boolean isChanging = super.isChangingConfigurations(); - } - - @Override - public boolean isChangingConfigurations() { - return super.isChangingConfigurations(); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest1.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest1.class.data Binary files differdeleted file mode 100644 index 60d4e81..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest1.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest1.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest1.java.txt deleted file mode 100644 index a8775d7..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest1.java.txt +++ /dev/null @@ -1,137 +0,0 @@ -package test.pkg; - -import org.w3c.dom.DOMError; -import org.w3c.dom.DOMErrorHandler; -import org.w3c.dom.DOMLocator; - -import android.view.ViewGroup.LayoutParams; -import android.annotations.tools.SuppressLint; -import android.app.Activity; -import android.app.ApplicationErrorReport; -import android.app.ApplicationErrorReport.BatteryInfo; -import android.graphics.PorterDuff; -import android.graphics.PorterDuff.Mode; -import android.widget.Chronometer; -import android.widget.GridLayout; -import dalvik.bytecode.OpcodeInfo; - -public class SuppressTest1 extends Activity { - @SuppressLint("all") - public void method1(Chronometer chronometer, DOMLocator locator) { - // Virtual call - getActionBar(); // API 11 - - // Class references (no call or field access) - DOMError error = null; // API 8 - Class<?> clz = DOMErrorHandler.class; // API 8 - - // Method call - chronometer.getOnChronometerTickListener(); // API 3 - - // Inherited method call (from TextView - chronometer.setTextIsSelectable(true); // API 11 - - // Field access - int field = OpcodeInfo.MAXIMUM_VALUE; // API 11 - int fillParent = LayoutParams.FILL_PARENT; // API 1 - // This is a final int, which means it gets inlined - int matchParent = LayoutParams.MATCH_PARENT; // API 8 - // Field access: non final - BatteryInfo batteryInfo = getReport().batteryInfo; - - // Enum access - Mode mode = PorterDuff.Mode.OVERLAY; // API 11 - } - - @SuppressLint("NewApi") - public void method2(Chronometer chronometer, DOMLocator locator) { - // Virtual call - getActionBar(); // API 11 - - // Class references (no call or field access) - DOMError error = null; // API 8 - Class<?> clz = DOMErrorHandler.class; // API 8 - - // Method call - chronometer.getOnChronometerTickListener(); // API 3 - - // Inherited method call (from TextView - chronometer.setTextIsSelectable(true); // API 11 - - // Field access - int field = OpcodeInfo.MAXIMUM_VALUE; // API 11 - int fillParent = LayoutParams.FILL_PARENT; // API 1 - // This is a final int, which means it gets inlined - int matchParent = LayoutParams.MATCH_PARENT; // API 8 - // Field access: non final - BatteryInfo batteryInfo = getReport().batteryInfo; - - // Enum access - Mode mode = PorterDuff.Mode.OVERLAY; // API 11 - } - - @SuppressLint("SomethingElse") - public void method3(Chronometer chronometer, DOMLocator locator) { - // Virtual call - getActionBar(); // API 11 - - // Class references (no call or field access) - DOMError error = null; // API 8 - Class<?> clz = DOMErrorHandler.class; // API 8 - - // Method call - chronometer.getOnChronometerTickListener(); // API 3 - - // Inherited method call (from TextView - chronometer.setTextIsSelectable(true); // API 11 - - // Field access - int field = OpcodeInfo.MAXIMUM_VALUE; // API 11 - int fillParent = LayoutParams.FILL_PARENT; // API 1 - // This is a final int, which means it gets inlined - int matchParent = LayoutParams.MATCH_PARENT; // API 8 - // Field access: non final - BatteryInfo batteryInfo = getReport().batteryInfo; - - // Enum access - Mode mode = PorterDuff.Mode.OVERLAY; // API 11 - } - - @SuppressLint({"SomethingElse", "NewApi"}) - public void method4(Chronometer chronometer, DOMLocator locator) { - // Virtual call - getActionBar(); // API 11 - - // Class references (no call or field access) - DOMError error = null; // API 8 - Class<?> clz = DOMErrorHandler.class; // API 8 - - // Method call - chronometer.getOnChronometerTickListener(); // API 3 - - // Inherited method call (from TextView - chronometer.setTextIsSelectable(true); // API 11 - - // Field access - int field = OpcodeInfo.MAXIMUM_VALUE; // API 11 - int fillParent = LayoutParams.FILL_PARENT; // API 1 - // This is a final int, which means it gets inlined - int matchParent = LayoutParams.MATCH_PARENT; // API 8 - // Field access: non final - BatteryInfo batteryInfo = getReport().batteryInfo; - - // Enum access - Mode mode = PorterDuff.Mode.OVERLAY; // API 11 - } - - // Return type - @SuppressLint("NewApi") - GridLayout getGridLayout() { // API 14 - return null; - } - - @SuppressLint("all") - private ApplicationErrorReport getReport() { - return null; - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest2.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest2.class.data Binary files differdeleted file mode 100644 index fdb512b..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest2.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest2.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest2.java.txt deleted file mode 100644 index e325413..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest2.java.txt +++ /dev/null @@ -1,25 +0,0 @@ -package test.pkg; - -import org.w3c.dom.DOMLocator; - -import android.annotations.tools.SuppressLint; -import android.app.Activity; -import android.app.ApplicationErrorReport; -import android.widget.Chronometer; -import android.widget.GridLayout; - -@SuppressLint("all") -public class SuppressTest2 extends Activity { - public void method(Chronometer chronometer, DOMLocator locator) { - getActionBar(); // API 11 - } - - // Return type - GridLayout getGridLayout() { // API 14 - return null; - } - - private ApplicationErrorReport getReport() { - return null; - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest3.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest3.class.data Binary files differdeleted file mode 100644 index 23e8b5c..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest3.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest3.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest3.java.txt deleted file mode 100644 index c430ce4..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest3.java.txt +++ /dev/null @@ -1,25 +0,0 @@ -package test.pkg; - -import org.w3c.dom.DOMLocator; - -import android.annotations.tools.SuppressLint; -import android.app.Activity; -import android.app.ApplicationErrorReport; -import android.widget.Chronometer; -import android.widget.GridLayout; - -@SuppressLint("NewApi") -public class SuppressTest3 extends Activity { - public void method(Chronometer chronometer, DOMLocator locator) { - getActionBar(); // API 11 - } - - // Return type - GridLayout getGridLayout() { // API 14 - return null; - } - - private ApplicationErrorReport getReport() { - return null; - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest4.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest4.class.data Binary files differdeleted file mode 100644 index c85a4ff..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest4.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest4.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest4.java.txt deleted file mode 100644 index 2fa2af8..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest4.java.txt +++ /dev/null @@ -1,21 +0,0 @@ -package test.pkg; - -import android.annotations.tools.SuppressLint; -import android.app.Activity; -import android.app.ApplicationErrorReport; -import android.app.ApplicationErrorReport.BatteryInfo; - -public class SuppressTest4 extends Activity { - public void method() { - - // These annotations within the method do not end up - // in the bytecode, so they have no effect. We need a - // lint annotation check to find these. - - @SuppressLint("NewApi") - ApplicationErrorReport report = null; - - @SuppressLint("NewApi") - BatteryInfo batteryInfo = report.batteryInfo; - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/TestEnum.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/TestEnum.class.data Binary files differdeleted file mode 100644 index fa676b9..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/TestEnum.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/TestEnum.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/TestEnum.java.txt deleted file mode 100644 index 2d68b28..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/TestEnum.java.txt +++ /dev/null @@ -1,67 +0,0 @@ -package test.pkg; - -import android.annotation.SuppressLint; -import android.graphics.Bitmap.CompressFormat; -import android.graphics.PorterDuff; - -@SuppressWarnings("incomplete-switch") -public class TestEnum { - public static void test1(final CompressFormat format) { - switch (format) { - case JPEG: { - System.out.println("jpeg"); - break; - } - default: { - System.out.println("Default"); - } - } - } - - public static void test2(final PorterDuff.Mode mode) { - switch (mode) { - case CLEAR: { - System.out.println("clear"); - } - case OVERLAY: { - System.out.println("add"); - break; - } - } - - // Second usage: should also complain here - switch (mode) { - case CLEAR: { - System.out.println("clear"); - } - case OVERLAY: { - System.out.println("add"); - break; - } - } - } - - @SuppressLint("NewApi") - public static void test3(PorterDuff.Mode mode) { - // Third usage: no complaint because it's suppressed - switch (mode) { - case CLEAR: { - System.out.println("clear"); - } - case OVERLAY: { - System.out.println("add"); - break; - } - } - } - - public static void test4(final android.renderscript.Element.DataType type) { - // Switch usage where the whole underlying enum requires a higher API level: - // test customized error message - switch (type) { - case RS_FONT: { - System.out.println("font"); - } - } - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/TestLint.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/TestLint.class.data Binary files differdeleted file mode 100644 index 9e74a7a..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/TestLint.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/android-support-v4.jar.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/android-support-v4.jar.data Binary files differdeleted file mode 100644 index 6080877..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/android-support-v4.jar.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/classpath b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/classpath deleted file mode 100644 index a4763d1..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/classpath +++ /dev/null @@ -1,8 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="src" path="src"/> - <classpathentry kind="src" path="gen"/> - <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> - <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/> - <classpathentry kind="output" path="bin/classes"/> -</classpath> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/colors.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/colors.xml deleted file mode 100644 index fc84a61..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/colors.xml +++ /dev/null @@ -1,6 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources> - <color name="color1">@android:color/black</color> - <!-- Requires API 14 --> - <color name="color2">@android:color/holo_blue_bright</color> -</resources> 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 deleted file mode 100644 index 4244319..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/divider.xml +++ /dev/null @@ -1,37 +0,0 @@ -<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/apicheck/holomanifest.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/holomanifest.xml deleted file mode 100644 index 8890afc..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/holomanifest.xml +++ /dev/null @@ -1,24 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="test.bytecode" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="4" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - <activity - android:name=".BytecodeTestsActivity" - android:label="@string/app_name" - android:theme="@android:style/Theme.Holo" > - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - </application> - -</manifest> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/layout.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/layout.xml deleted file mode 100644 index 83b6b0a..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/layout.xml +++ /dev/null @@ -1,32 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="fill_parent" - android:layout_height="match_parent" - android:orientation="vertical" > - - <!-- Requires API 5 --> - - <QuickContactBadge - android:layout_width="wrap_content" - android:layout_height="wrap_content" /> - - <!-- Requires API 11 --> - - <CalendarView - android:layout_width="fill_parent" - android:layout_height="fill_parent" /> - - <!-- Requires API 14 --> - - <GridLayout - foo="@android:attr/actionBarSplitStyle" - bar="@android:color/holo_red_light" - android:layout_width="fill_parent" - android:layout_height="fill_parent" > - - <Button - android:layout_width="fill_parent" - android:layout_height="fill_parent" /> - </GridLayout> - -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/layout_targetapi.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/layout_targetapi.xml deleted file mode 100644 index 51ce945..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/layout_targetapi.xml +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:tools="http://schemas.android.com/tools" - android:layout_width="fill_parent" - android:layout_height="match_parent" - android:orientation="vertical" - tools:targetApi="11" > - - <!-- Requires API 5 --> - - <QuickContactBadge - android:layout_width="wrap_content" - android:layout_height="wrap_content" /> - - <!-- Requires API 11 --> - - <CalendarView - android:layout_width="fill_parent" - android:layout_height="fill_parent" /> - - <!-- Requires API 14 --> - - <GridLayout - foo="@android:attr/actionBarSplitStyle" - bar="@android:color/holo_red_light" - android:layout_width="fill_parent" - android:layout_height="fill_parent" - tools:targetApi="ICE_CREAM_SANDWICH" > - - <Button - android:layout_width="fill_parent" - android:layout_height="fill_parent" /> - </GridLayout> - -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/minsdk1.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/minsdk1.xml deleted file mode 100644 index 6a9c919..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/minsdk1.xml +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="test.bytecode" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="1" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - <activity - android:name=".BytecodeTestsActivity" - android:label="@string/app_name" > - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - </application> - -</manifest> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/minsdk10.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/minsdk10.xml deleted file mode 100644 index 2896fc8..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/minsdk10.xml +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="test.bytecode" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="10" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - <activity - android:name=".BytecodeTestsActivity" - android:label="@string/app_name" > - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - </application> - -</manifest>
\ No newline at end of file diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/minsdk14.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/minsdk14.xml deleted file mode 100644 index 391a8aa..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/minsdk14.xml +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="test.bytecode" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="14" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - <activity - android:name=".BytecodeTestsActivity" - android:label="@string/app_name" > - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - </application> - -</manifest> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/minsdk17.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/minsdk17.xml deleted file mode 100644 index 1837db9..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/minsdk17.xml +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="test.bytecode" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="17" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - <activity - android:name=".BytecodeTestsActivity" - android:label="@string/app_name" > - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - </application> - -</manifest> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/minsdk2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/minsdk2.xml deleted file mode 100644 index 23a15be..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/minsdk2.xml +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="test.bytecode" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="2" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - <activity - android:name=".BytecodeTestsActivity" - android:label="@string/app_name" > - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - </application> - -</manifest> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/minsdk4.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/minsdk4.xml deleted file mode 100644 index be95440..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/minsdk4.xml +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="test.bytecode" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="4" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - <activity - android:name=".BytecodeTestsActivity" - android:label="@string/app_name" > - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - </application> - -</manifest> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/themes.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/themes.xml deleted file mode 100644 index 478940e..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/themes.xml +++ /dev/null @@ -1,16 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources> - <style name="Theme" parent="android:Theme"/> - - <style name="Theme.Test" parent="android:style/Theme.Light"> - <item name="android:windowNoTitle">true</item> - <item name="android:windowContentOverlay">@null</item> - <!-- Requires API 14 --> - <item name="android:windowBackground"> @android:color/holo_red_light </item> - </style> - - <style name="Theme.Test.Transparent"> - <item name="android:windowBackground">@android:color/transparent</item> - </style> - -</resources> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/unsupported.jar.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/unsupported.jar.data Binary files differdeleted file mode 100644 index 7cbedc1..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/unsupported.jar.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/view.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/view.xml deleted file mode 100644 index 2f9fc84..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/view.xml +++ /dev/null @@ -1,27 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="fill_parent" - android:layout_height="match_parent" - android:orientation="vertical" > - - <!-- Requires API 5 --> - - <view - android:layout_width="wrap_content" - android:layout_height="wrap_content" - class="QuickContactBadge" /> - - <!-- Requires API 11 --> - - <view - android:layout_width="fill_parent" - android:layout_height="fill_parent" - class="CalendarView" /> - - <Button - android:layout_width="fill_parent" - android:layout_height="fill_parent" - unknown="?android:attr/dividerHorizontal" - android:textColor="?android:attr/textColorLinkInverse" /> - -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/broken-manifest.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/broken-manifest.xml deleted file mode 100644 index e55e908..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/broken-manifest.xml +++ /dev/null @@ -1,18 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="com.example.helloworld" - android:versionCode="1" - android:versionName="1.0"> - <application android:icon="@drawable/icon" android:label="@string/app_name"> - <activity android:name=".HelloWorld" - android:label="@string/app_name"> - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - - </application> - <uses-sdk android:minSdkVersion="Froyo" /> - -</manifest> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/broken-manifest2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/broken-manifest2.xml deleted file mode 100644 index 307046b..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/broken-manifest2.xml +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="com.example.helloworld" - android:versionCode="1" - android:versionName="1.0"> - <application android:icon="@drawable/icon" android:label="@string/app_name"> - <!-- Wrong declaration locations --> - <uses-sdk android:minSdkVersion="Froyo" /> - <uses-permission /> - <permission /> - <permission-tree /> - <permission-group /> - <instrumentation /> - <uses-sdk /> - <uses-configuration /> - <uses-feature /> - <supports-screens /> - <compatible-screens /> - <supports-gl-texture /> - - </application> - - <!-- Wrong declaration locations --> - <uses-library /> - <activity android:name=".HelloWorld" - android:label="@string/app_name" /> - -</manifest> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/.classpath b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/.classpath deleted file mode 100644 index a4763d1..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/.classpath +++ /dev/null @@ -1,8 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="src" path="src"/> - <classpathentry kind="src" path="gen"/> - <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> - <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/> - <classpathentry kind="output" path="bin/classes"/> -</classpath> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AbstractActivity.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AbstractActivity.class.data Binary files differdeleted file mode 100644 index 85ebb78..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AbstractActivity.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AbstractActivity.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AbstractActivity.java.txt deleted file mode 100644 index a9e0400..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AbstractActivity.java.txt +++ /dev/null @@ -1,6 +0,0 @@ -package test.pkg; - -import android.app.Activity; - -public abstract class AbstractActivity extends Activity { -} 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 Binary files differdeleted file mode 100644 index 8dc3dc6..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AbstractCustomView.class.data +++ /dev/null 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 deleted file mode 100644 index aedbafd..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AbstractCustomView.java.txt +++ /dev/null @@ -1,9 +0,0 @@ -package test.pkg; - -import android.view.View; - -public abstract class AbstractCustomView extends View { - public AbstractCustomView() { - super(null); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AndroidManifest.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AndroidManifest.xml deleted file mode 100644 index 2896fc8..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AndroidManifest.xml +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="test.bytecode" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="10" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - <activity - android:name=".BytecodeTestsActivity" - android:label="@string/app_name" > - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - </application> - -</manifest>
\ No newline at end of file diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AndroidManifestReg.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AndroidManifestReg.xml deleted file mode 100644 index 82fda69..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AndroidManifestReg.xml +++ /dev/null @@ -1,18 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="test.pkg.Foo" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="15" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - <activity - android:name="CommentsActivity" - android:label="@string/app_name" > - </activity> - </application> - -</manifest>
\ No newline at end of file diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AndroidManifestRegs.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AndroidManifestRegs.xml deleted file mode 100644 index e52f73c..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AndroidManifestRegs.xml +++ /dev/null @@ -1,36 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - ~ Copyright (C) 2012 The Android Open Source Project - ~ - ~ Licensed under the Apache License, Version 2.0 (the "License"); - ~ you may not use this file except in compliance with the License. - ~ You may obtain a copy of the License at - ~ - ~ http://www.apache.org/licenses/LICENSE-2.0 - ~ - ~ Unless required by applicable law or agreed to in writing, software - ~ distributed under the License is distributed on an "AS IS" BASIS, - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - ~ See the License for the specific language governing permissions and - ~ limitations under the License. - --> - -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="test.pkg" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="10" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - <provider android:name=".TestProvider" /> - <provider android:name="test.pkg.TestProvider2" /> - <service android:name=".TestService" /> - <activity android:name="OnClickActivity" /> - <receiver android:name="TestReceiver" /> - - </application> - -</manifest> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AndroidManifestWrongRegs.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AndroidManifestWrongRegs.xml deleted file mode 100644 index efe7213..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AndroidManifestWrongRegs.xml +++ /dev/null @@ -1,21 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="test.pkg" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="10" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - <!-- These registrations are bogus (wrong type) --> - <activity android:name=".TestProvider" /> - <service android:name="test.pkg.TestProvider2" /> - <provider android:name=".TestService" /> - <receiver android:name="OnClickActivity" /> - <service android:name="TestReceiver" /> - - </application> - -</manifest> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/Class1$Class4.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/Class1$Class4.class.data Binary files differdeleted file mode 100644 index bfd88db..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/Class1$Class4.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/Class1.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/Class1.class.data Binary files differdeleted file mode 100644 index cee3058..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/Class1.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/Class2$Class3.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/Class2$Class3.class.data Binary files differdeleted file mode 100644 index 2a58332..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/Class2$Class3.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/Class2.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/Class2.class.data Binary files differdeleted file mode 100644 index 1b72f03..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/Class2.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CommentsActivity.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CommentsActivity.class.data Binary files differdeleted file mode 100644 index 7f9f23b..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CommentsActivity.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CommentsActivity.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CommentsActivity.java.txt deleted file mode 100644 index 941a01d..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CommentsActivity.java.txt +++ /dev/null @@ -1,6 +0,0 @@ -package test.pkg.Foo; - -import android.app.Activity; - -public class CommentsActivity extends Activity { -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CommitTest.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CommitTest.class.data Binary files differdeleted file mode 100644 index 842fb21..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CommitTest.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CommitTest.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CommitTest.java.txt deleted file mode 100644 index 24edaf3..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CommitTest.java.txt +++ /dev/null @@ -1,91 +0,0 @@ -package test.pkg; - -import android.app.Activity; -import android.app.Fragment; -import android.app.FragmentManager; -import android.app.FragmentTransaction; - -@SuppressWarnings("unused") -public class CommitTest extends Activity { - public void ok1() { - getFragmentManager().beginTransaction().commit(); - } - - public void ok2() { - FragmentTransaction transaction = getFragmentManager().beginTransaction(); - transaction.commit(); - } - - public void ok3() { - FragmentTransaction transaction = getFragmentManager().beginTransaction(); - transaction.commitAllowingStateLoss(); - } - - public void error1() { - getFragmentManager().beginTransaction(); // Missing commit - } - - public void error() { - FragmentTransaction transaction1 = getFragmentManager().beginTransaction(); - FragmentTransaction transaction2 = getFragmentManager().beginTransaction(); // Missing commit - transaction1.commit(); - } - - public void error3_public() { - error3(); - } - - private void error3() { - getFragmentManager().beginTransaction(); // Missing commit - } - - public void ok4(FragmentManager manager, String tag) { - FragmentTransaction ft = manager.beginTransaction(); - ft.add(null, tag); - ft.commit(); - } - - // Support library - - private android.support.v4.app.FragmentManager getSupportFragmentManager() { - return null; - } - - public void ok5() { - getSupportFragmentManager().beginTransaction().commit(); - } - - public void ok6(android.support.v4.app.FragmentManager manager, String tag) { - android.support.v4.app.FragmentTransaction ft = manager.beginTransaction(); - ft.add(null, tag); - ft.commit(); - } - - public void error4() { - getSupportFragmentManager().beginTransaction(); - } - - android.support.v4.app.Fragment mFragment1 = null; - Fragment mFragment2 = null; - - public void ok7() { - getSupportFragmentManager().beginTransaction().add(android.R.id.content, mFragment1).commit(); - } - - public void ok8() { - getFragmentManager().beginTransaction().add(android.R.id.content, mFragment2).commit(); - } - - public void ok10() { - // Test chaining - FragmentManager fragmentManager = getFragmentManager(); - fragmentManager.beginTransaction().addToBackStack("test").attach(mFragment2).detach(mFragment2) - .disallowAddToBackStack().hide(mFragment2).setBreadCrumbShortTitle("test") - .show(mFragment2).setCustomAnimations(0, 0).commit(); - } - - public void ok9() { - FragmentManager fragmentManager = getFragmentManager(); - fragmentManager.beginTransaction().commit(); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CustomView1.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CustomView1.class.data Binary files differdeleted file mode 100644 index d6a8ad7..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CustomView1.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CustomView1.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CustomView1.java.txt deleted file mode 100644 index e871e74..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CustomView1.java.txt +++ /dev/null @@ -1,9 +0,0 @@ -package test.pkg; - -import android.view.View; - -public class CustomView1 extends View { - public CustomView1() { - super(null); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CustomView2.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CustomView2.class.data Binary files differdeleted file mode 100644 index 0788ef3..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CustomView2.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CustomView2.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CustomView2.java.txt deleted file mode 100644 index dccc8ec..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CustomView2.java.txt +++ /dev/null @@ -1,12 +0,0 @@ -package test.pkg; - -import android.content.Context; -import android.util.AttributeSet; -import android.widget.Button; - -public class CustomView2 extends Button { - public CustomView2(boolean foo, - Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CustomView3.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CustomView3.class.data Binary files differdeleted file mode 100644 index a4b7c7d..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CustomView3.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CustomView3.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CustomView3.java.txt deleted file mode 100644 index 86d983f..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CustomView3.java.txt +++ /dev/null @@ -1,20 +0,0 @@ -package test.pkg; - -import android.content.Context; -import android.util.AttributeSet; -import android.widget.TextView; - -public class CustomView3 extends TextView { - - public CustomView3(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - } - - public CustomView3(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public CustomView3(Context context) { - super(context); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CustomViewTest.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CustomViewTest.class.data Binary files differdeleted file mode 100644 index e145fbc..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CustomViewTest.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/DialogFragment.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/DialogFragment.class.data Binary files differdeleted file mode 100644 index f57a263..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/DialogFragment.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$Fragment1.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$Fragment1.class.data Binary files differdeleted file mode 100644 index 11a98dd..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$Fragment1.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$Fragment2.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$Fragment2.class.data Binary files differdeleted file mode 100644 index d77579a..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$Fragment2.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$Fragment3.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$Fragment3.class.data Binary files differdeleted file mode 100644 index b1ec17d..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$Fragment3.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$Fragment4.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$Fragment4.class.data Binary files differdeleted file mode 100644 index f89f8ed..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$Fragment4.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$Fragment5.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$Fragment5.class.data Binary files differdeleted file mode 100644 index 4a23e03..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$Fragment5.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$Fragment6.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$Fragment6.class.data Binary files differdeleted file mode 100644 index 2e10e12..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$Fragment6.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$NotAFragment.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$NotAFragment.class.data Binary files differdeleted file mode 100644 index 8f5b827..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$NotAFragment.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$ValidFragment1.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$ValidFragment1.class.data Binary files differdeleted file mode 100644 index a3354a7..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$ValidFragment1.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest.class.data Binary files differdeleted file mode 100644 index 6cc8387..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest.java.txt deleted file mode 100644 index d27c04a..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest.java.txt +++ /dev/null @@ -1,55 +0,0 @@ -package test.pkg; - -import android.annotation.SuppressLint; -import android.app.Fragment; - -@SuppressWarnings("unused") -public class FragmentTest { - - // Should be public - private static class Fragment1 extends Fragment { - - } - - // Should be static - public class Fragment2 extends Fragment { - - } - - // Should have a public constructor - public static class Fragment3 extends Fragment { - private Fragment3() { - } - } - - // Should have a public constructor with no arguments - public static class Fragment4 extends Fragment { - private Fragment4(int dummy) { - } - } - - // Should *only* have the default constructor, not the - // multi-argument one - public static class Fragment5 extends Fragment { - public Fragment5() { - } - public Fragment5(int dummy) { - } - } - - // Suppressed - @SuppressLint("ValidFragment") - public static class Fragment6 extends Fragment { - private Fragment6() { - } - } - - public static class ValidFragment1 extends Fragment { - public ValidFragment1() { - } - } - - // (Not a fragment) - private class NotAFragment { - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/GetterTest.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/GetterTest.class.data Binary files differdeleted file mode 100644 index 73a9947..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/GetterTest.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/GetterTest.jar.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/GetterTest.jar.data Binary files differdeleted file mode 100644 index f5ef6d1..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/GetterTest.jar.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/GetterTest.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/GetterTest.java.txt deleted file mode 100644 index 25f3421..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/GetterTest.java.txt +++ /dev/null @@ -1,59 +0,0 @@ -package test.bytecode; - -public class GetterTest { - private int mFoo1; - private String mFoo2; - private int mBar1; - private static int sFoo4; - - public int getFoo1() { - return mFoo1; - } - - public String getFoo2() { - return mFoo2; - } - - public int isBar1() { - return mBar1; - } - - // Not "plain" getters: - - public String getFoo3() { - // NOT a plain getter - if (mFoo2 == null) { - mFoo2 = ""; - } - return mFoo2; - } - - public int getFoo4() { - // NOT a plain getter (using static) - return sFoo4; - } - - public int getFoo5(int x) { - // NOT a plain getter (has extra argument) - return sFoo4; - } - - public int isBar2(String s) { - // NOT a plain getter (has extra argument) - return mFoo1; - } - - public void test() { - getFoo1(); - getFoo2(); - getFoo3(); - getFoo4(); - getFoo5(42); - isBar1(); - isBar2("foo"); - this.getFoo1(); - this.getFoo2(); - this.getFoo3(); - this.getFoo4(); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/HandlerTest$1.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/HandlerTest$1.class.data Binary files differdeleted file mode 100644 index ae65532..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/HandlerTest$1.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/HandlerTest$Inner.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/HandlerTest$Inner.class.data Binary files differdeleted file mode 100644 index 3975896..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/HandlerTest$Inner.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/HandlerTest$StaticInner.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/HandlerTest$StaticInner.class.data Binary files differdeleted file mode 100644 index 690ee89..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/HandlerTest$StaticInner.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/HandlerTest.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/HandlerTest.class.data Binary files differdeleted file mode 100644 index 93f9999..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/HandlerTest.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/HandlerTest.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/HandlerTest.java.txt deleted file mode 100644 index 7622c98..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/HandlerTest.java.txt +++ /dev/null @@ -1,24 +0,0 @@ -package test.pkg; - -import android.os.Handler; -import android.os.Message; - -public class HandlerTest extends Handler { // OK - public static class StaticInner extends Handler { // OK - public void dispatchMessage(Message msg) { - super.dispatchMessage(msg); - }; - } - public class Inner extends Handler { // ERROR - public void dispatchMessage(Message msg) { - super.dispatchMessage(msg); - }; - } - void method() { - Handler anonymous = new Handler() { // ERROR - public void dispatchMessage(Message msg) { - super.dispatchMessage(msg); - }; - }; - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/LayoutTest.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/LayoutTest.class.data Binary files differdeleted file mode 100644 index 27e6042..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/LayoutTest.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/LayoutTest.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/LayoutTest.java.txt deleted file mode 100644 index 28ab089..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/LayoutTest.java.txt +++ /dev/null @@ -1,66 +0,0 @@ -package test.pkg; - -import android.content.Context; -import android.graphics.Canvas; -import android.util.AttributeSet; -import android.view.ViewGroup; -import android.widget.Button; -import android.widget.FrameLayout; -import android.widget.LinearLayout; - -@SuppressWarnings("unused") -public class LayoutTest extends LinearLayout { - private MyChild child; - - public LayoutTest(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - } - - @Override - protected void onLayout(boolean changed, int left, int top, int right, - int bottom) { - super.onLayout(changed, left, top, right, bottom); // OK - child.onLayout(changed, left, top, right, bottom); // Not OK - - super.onMeasure(0, 0); // Not OK - super.onDraw(null); // Not OK - child.layout(left, top, right, bottom); // OK - } - - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - super.onMeasure(widthMeasureSpec, heightMeasureSpec); // OK - super.onLayout(false, 0, 0, 0, 0); // Not OK - child.onMeasure(widthMeasureSpec, heightMeasureSpec); // Not OK - child.measure(widthMeasureSpec, heightMeasureSpec); // OK - } - - @Override - protected void onDraw(Canvas canvas) { - super.onDraw(canvas); // OK - child.onDraw(canvas); // Not OK - child.draw(canvas); // OK - } - - private class MyChild extends FrameLayout { - public MyChild(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - } - - @Override - protected void onLayout(boolean changed, int left, int top, int right, - int bottom) { - super.onLayout(changed, left, top, right, bottom); - } - - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - super.onMeasure(widthMeasureSpec, heightMeasureSpec); - } - - @Override - protected void onDraw(Canvas canvas) { - super.onDraw(canvas); - } - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/LocaleTest.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/LocaleTest.class.data Binary files differdeleted file mode 100644 index 2b10aa9..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/LocaleTest.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/LocaleTest.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/LocaleTest.java.txt deleted file mode 100644 index 3c60c9d..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/LocaleTest.java.txt +++ /dev/null @@ -1,37 +0,0 @@ -package test.pkg; - -import java.text.*; -import java.util.*; - -public class LocaleTest { - public void testStrings() { - System.out.println("OK".toUpperCase(Locale.getDefault())); - System.out.println("OK".toUpperCase(Locale.US)); - System.out.println("OK".toUpperCase(Locale.CHINA)); - System.out.println("WRONG".toUpperCase()); - - System.out.println("OK".toLowerCase(Locale.getDefault())); - System.out.println("OK".toLowerCase(Locale.US)); - System.out.println("OK".toLowerCase(Locale.CHINA)); - System.out.println("WRONG".toLowerCase()); - - String.format(Locale.getDefault(), "OK: %f", 1.0f); - String.format("OK: %x %A %c %b %B %h %n %%", 1, 2, 'c', true, false, 5); - String.format("WRONG: %f", 1.0f); // Implies locale - String.format("WRONG: %1$f", 1.0f); - String.format("WRONG: %e", 1.0f); - String.format("WRONG: %d", 1.0f); - String.format("WRONG: %g", 1.0f); - String.format("WRONG: %g", 1.0f); - String.format("WRONG: %1$tm %1$te,%1$tY", - new GregorianCalendar(2012, GregorianCalendar.AUGUST, 27)); - } - - @android.annotation.SuppressLint("NewApi") // DateFormatSymbols requires API 9 - public void testSimpleDateFormat() { - new SimpleDateFormat(); // WRONG - new SimpleDateFormat("yyyy-MM-dd"); // WRONG - new SimpleDateFormat("yyyy-MM-dd", DateFormatSymbols.getInstance()); // WRONG - new SimpleDateFormat("yyyy-MM-dd", Locale.US); // OK - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/MathTest.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/MathTest.class.data Binary files differdeleted file mode 100644 index 6647f1c..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/MathTest.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/MathTest.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/MathTest.java.txt deleted file mode 100644 index 0193f81..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/MathTest.java.txt +++ /dev/null @@ -1,21 +0,0 @@ -package test.bytecode; - -import android.util.FloatMath; - -//Test data for the MathDetector -public class MathTest { - public float floatResult; - public double doubleResult; - - public void floatToFloatTest(float x, double y, int z) { - floatResult = FloatMath.cos(x); - floatResult = FloatMath.sin((float) y); - floatResult = android.util.FloatMath.ceil((float) y); - System.out.println(FloatMath.floor(x)); - System.out.println(FloatMath.sqrt(z)); - - // No warnings for plain math - floatResult = (float) Math.cos(x); - floatResult = (float) java.lang.Math.sin(x); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/OnClickActivity.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/OnClickActivity.class.data Binary files differdeleted file mode 100644 index 216a865..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/OnClickActivity.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/OnClickActivity.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/OnClickActivity.java.txt deleted file mode 100644 index 557ba0a..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/OnClickActivity.java.txt +++ /dev/null @@ -1,48 +0,0 @@ -package test.pkg; - -import android.app.Activity; -import android.util.Log; -import android.view.View; - -/** Test data for the OnClickDetector */ -public class OnClickActivity extends Activity { - // Wrong argument type 1 - public void wrong1() { - } - - // Wrong argument type 2 - public void wrong2(int i) { - } - - // Wrong argument type 3 - public void wrong3(View view, int i) { - } - - // Wrong return type - public int wrong4(View view) { - return 0; - } - - // Wrong modifier (not public) - void wrong5(View view) { - } - - // Wrong modifier (is static) - public static void wrong6(View view) { - } - - public void ok(View view) { - } - - // Ok: Unicode escapes - public void my\u1234method(View view) { - } - - // Typo - public void simple_tyop(View view) { - } - - void wrong7(View view) { - Log.i("x", "wrong7: called"); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/PowerManagerFlagTest.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/PowerManagerFlagTest.class.data Binary files differdeleted file mode 100644 index c8b4da9..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/PowerManagerFlagTest.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/PowerManagerFlagTest.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/PowerManagerFlagTest.java.txt deleted file mode 100644 index c3794ed..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/PowerManagerFlagTest.java.txt +++ /dev/null @@ -1,18 +0,0 @@ -package test.pkg; - -import static android.os.PowerManager.ACQUIRE_CAUSES_WAKEUP; -import static android.os.PowerManager.FULL_WAKE_LOCK; -import static android.os.PowerManager.PARTIAL_WAKE_LOCK; -import android.content.Context; -import android.os.PowerManager; - -public class PowerManagerFlagTest { - @SuppressWarnings("deprecation") - public void test(Context context) { - PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); - - pm.newWakeLock(PARTIAL_WAKE_LOCK, "Test"); // OK - pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK|ACQUIRE_CAUSES_WAKEUP, "Test"); // Bad - pm.newWakeLock(FULL_WAKE_LOCK|ACQUIRE_CAUSES_WAKEUP, "Test"); // OK - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/RecycleTest.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/RecycleTest.class.data Binary files differdeleted file mode 100644 index 3bdc829..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/RecycleTest.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/RecycleTest.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/RecycleTest.java.txt deleted file mode 100644 index 2a026f2..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/RecycleTest.java.txt +++ /dev/null @@ -1,159 +0,0 @@ -package test.pkg; - -import com.unit.test.R; - -import android.annotation.SuppressLint; -import android.content.Context; -import android.content.res.TypedArray; -import android.os.Message; -import android.os.Parcel; -import android.util.AttributeSet; -import android.view.MotionEvent; -import android.view.VelocityTracker; -import android.view.View; - -@SuppressWarnings("unused") -public class RecycleTest extends View { - // ---- Check recycling TypedArrays ---- - - public RecycleTest(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - } - - public void ok1(AttributeSet attrs, int defStyle) { - final TypedArray a = getContext().obtainStyledAttributes(attrs, - R.styleable.MyView, defStyle, 0); - String example = a.getString(R.styleable.MyView_exampleString); - a.recycle(); - } - - public void ok2(AttributeSet attrs, int defStyle) { - final TypedArray a = getContext().obtainStyledAttributes(attrs, - R.styleable.MyView, defStyle, 0); - String example = a.getString(R.styleable.MyView_exampleString); - // If there's complicated logic, don't flag - if (something()) { - a.recycle(); - } - } - - public TypedArray ok3(AttributeSet attrs, int defStyle) { - // Value passes out of method: don't flag, caller might be recycling - return getContext().obtainStyledAttributes(attrs, R.styleable.MyView, - defStyle, 0); - } - - private TypedArray myref; - - public void ok4(AttributeSet attrs, int defStyle) { - // Value stored in a field: might be recycled later - TypedArray ref = getContext().obtainStyledAttributes(attrs, - R.styleable.MyView, defStyle, 0); - myref = ref; - } - - public void wrong1(AttributeSet attrs, int defStyle) { - final TypedArray a = getContext().obtainStyledAttributes(attrs, - R.styleable.MyView, defStyle, 0); - String example = a.getString(R.styleable.MyView_exampleString); - // a.recycle(); - } - - public void wrong2(AttributeSet attrs, int defStyle) { - final TypedArray a = getContext().obtainStyledAttributes(new int[0]); - // a.recycle(); - } - - public void unknown(AttributeSet attrs, int defStyle) { - final TypedArray a = getContext().obtainStyledAttributes(attrs, - R.styleable.MyView, defStyle, 0); - // We don't know what this method is (usually it will be in a different - // class) - // so don't flag it; it might recycle - handle(a); - } - - // ---- Check recycling VelocityTracker ---- - - public void tracker() { - VelocityTracker tracker = VelocityTracker.obtain(); - } - - // ---- Check recycling Message ---- - - public void message() { - Message message1 = getHandler().obtainMessage(); - Message message2 = Message.obtain(); - } - - // ---- Check recycling MotionEvent ---- - - public void motionEvent() { - MotionEvent event1 = MotionEvent.obtain(null); - MotionEvent event2 = MotionEvent.obtainNoHistory(null); - } - - public void motionEvent2() { - MotionEvent event1 = MotionEvent.obtain(null); // OK - MotionEvent event2 = MotionEvent.obtainNoHistory(null); // Not recycled - event1.recycle(); - } - - public void motionEvent3() { - MotionEvent event1 = MotionEvent.obtain(null); // Not recycled - MotionEvent event2 = MotionEvent.obtain(event1); - event2.recycle(); - } - - // ---- Using recycled objects ---- - - public void recycled() { - MotionEvent event1 = MotionEvent.obtain(null); // Not recycled - event1.recycle(); - int contents2 = event1.describeContents(); // BAD, after recycle - final TypedArray a = getContext().obtainStyledAttributes(new int[0]); - String example = a.getString(R.styleable.MyView_exampleString); // OK - a.recycle(); - example = a.getString(R.styleable.MyView_exampleString); // BAD, after recycle - } - - // ---- Check recycling Parcel ---- - - public void parcelOk() { - Parcel myparcel = Parcel.obtain(); - myparcel.createBinderArray(); - myparcel.recycle(); - } - - public void parcelMissing() { - Parcel myparcel = Parcel.obtain(); - myparcel.createBinderArray(); - } - - - // ---- Check suppress ---- - - @SuppressLint("Recycle") - public void recycledSuppress() { - MotionEvent event1 = MotionEvent.obtain(null); // Not recycled - event1.recycle(); - int contents2 = event1.describeContents(); // BAD, after recycle - final TypedArray a = getContext().obtainStyledAttributes(new int[0]); - String example = a.getString(R.styleable.MyView_exampleString); // OK - } - - // ---- Stubs ---- - - static void handle(TypedArray a) { - // Unknown method - } - - protected boolean something() { - return true; - } - - public android.content.res.TypedArray obtainStyledAttributes( - AttributeSet set, int[] attrs, int defStyleAttr, int defStyleRes) { - return null; - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/SecureRandomTest.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/SecureRandomTest.class.data Binary files differdeleted file mode 100644 index 3236187..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/SecureRandomTest.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/SecureRandomTest.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/SecureRandomTest.java.txt deleted file mode 100644 index c05fbd9..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/SecureRandomTest.java.txt +++ /dev/null @@ -1,42 +0,0 @@ -package test.pkg; - -import java.security.SecureRandom; -import java.util.Random; - -public class SecureRandomTest { - private static final long FIXED_SEED = 1000L; - protected int getDynamicSeed() { return 1; } - - public void testLiterals() { - SecureRandom random1 = new SecureRandom(); - random1.setSeed(System.currentTimeMillis()); // OK - random1.setSeed(getDynamicSeed()); // OK - random1.setSeed(0); // Wrong - random1.setSeed(1); // Wrong - random1.setSeed((int)1023); // Wrong - random1.setSeed(1023L); // Wrong - random1.setSeed(FIXED_SEED); // Wrong - } - - public void testRandomTypeOk() { - Random random2 = new Random(); - random2.setSeed(0); // OK - } - - public void testRandomTypeWrong() { - Random random3 = new SecureRandom(); - random3.setSeed(0); // Wrong: owner is java/util/Random, but applied to SecureRandom object - } - - public void testBytesOk() { - SecureRandom random1 = new SecureRandom(); - byte[] seed = random1.generateSeed(4); - random1.setSeed(seed); // OK - } - - public void testBytesWrong() { - SecureRandom random2 = new SecureRandom(); - byte[] seed = new byte[3]; - random2.setSeed(seed); // Wrong - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestFieldGetter.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestFieldGetter.class.data Binary files differdeleted file mode 100644 index d922751..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestFieldGetter.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestFieldGetter.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestFieldGetter.java.txt deleted file mode 100644 index 00da161..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestFieldGetter.java.txt +++ /dev/null @@ -1,36 +0,0 @@ -package test.pkg; - -import java.io.File; -import java.util.List; - -import android.content.Context; - -public class TestFieldGetter { - private int path; - private int foo; - - public int getPath() { - return path; - } - - public int getFoo() { - return foo; - } - - public void test(TestFieldGetter other) { - getPath(); // Should be flagged - other.getPath(); // Ignore - File file = new File("/dummy"); - file.getPath(); // Ignore - } - - public static void test2(TestFieldGetter other) { - other.getPath(); // Ignore - } - - public class Inner extends TestFieldGetter { - public void test() { - getFoo(); // Ignore - } - } -}
\ No newline at end of file diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestProvider.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestProvider.class.data Binary files differdeleted file mode 100644 index 945742f..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestProvider.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestProvider.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestProvider.java.txt deleted file mode 100644 index 2bf1bb8..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestProvider.java.txt +++ /dev/null @@ -1,40 +0,0 @@ -package test.pkg; - -import android.content.ContentProvider; -import android.content.ContentValues; -import android.database.Cursor; -import android.net.Uri; - -public class TestProvider extends ContentProvider { - @Override - public int delete(Uri uri, String selection, String[] selectionArgs) { - return 0; - } - - @Override - public String getType(Uri uri) { - return null; - } - - @Override - public Uri insert(Uri uri, ContentValues values) { - return null; - } - - @Override - public boolean onCreate() { - return false; - } - - @Override - public Cursor query(Uri uri, String[] projection, String selection, - String[] selectionArgs, String sortOrder) { - return null; - } - - @Override - public int update(Uri uri, ContentValues values, String selection, - String[] selectionArgs) { - return 0; - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestProvider2.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestProvider2.class.data Binary files differdeleted file mode 100644 index 0973dbe..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestProvider2.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestProvider2.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestProvider2.java.txt deleted file mode 100644 index 881975d..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestProvider2.java.txt +++ /dev/null @@ -1,4 +0,0 @@ -package test.pkg; - -public class TestProvider2 extends TestProvider { -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestReceiver$1.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestReceiver$1.class.data Binary files differdeleted file mode 100644 index 7ede85a..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestReceiver$1.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestReceiver.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestReceiver.class.data Binary files differdeleted file mode 100644 index 6180e40..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestReceiver.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestReceiver.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestReceiver.java.txt deleted file mode 100644 index 90893c8..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestReceiver.java.txt +++ /dev/null @@ -1,21 +0,0 @@ -package test.pkg; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; - -public class TestReceiver extends BroadcastReceiver { - - @Override - public void onReceive(Context context, Intent intent) { - } - - // Anonymous classes should NOT be counted as a must-register - private BroadcastReceiver dummy() { - return new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - } - }; - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestService.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestService.class.data Binary files differdeleted file mode 100644 index a98f7aa..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestService.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestService.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestService.java.txt deleted file mode 100644 index d3f128a..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestService.java.txt +++ /dev/null @@ -1,14 +0,0 @@ -package test.pkg; - -import android.app.Service; -import android.content.Intent; -import android.os.IBinder; - -public class TestService extends Service { - - @Override - public IBinder onBind(Intent intent) { - return null; - } - -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/ViewTagTest.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/ViewTagTest.class.data Binary files differdeleted file mode 100644 index f26032c..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/ViewTagTest.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/ViewTagTest.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/ViewTagTest.java.txt deleted file mode 100644 index 8e72fd0..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/ViewTagTest.java.txt +++ /dev/null @@ -1,37 +0,0 @@ -package test.pkg; - -import android.annotation.SuppressLint; -import android.content.Context; -import android.database.Cursor; -import android.database.MatrixCursor; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.CursorAdapter; -import android.widget.ImageView; -import android.widget.TextView; - -@SuppressWarnings("unused") -public abstract class ViewTagTest { - public View newView(Context context, ViewGroup group, Cursor cursor1, - MatrixCursor cursor2) { - LayoutInflater inflater = LayoutInflater.from(context); - View view = inflater.inflate(android.R.layout.activity_list_item, null); - view.setTag(android.R.id.background, "Some random tag"); // OK - view.setTag(android.R.id.button1, group); // ERROR - view.setTag(android.R.id.icon, view.findViewById(android.R.id.icon)); // ERROR - view.setTag(android.R.id.icon1, cursor1); // ERROR - view.setTag(android.R.id.icon2, cursor2); // ERROR - view.setTag(android.R.id.copy, new MyViewHolder()); // ERROR - return view; - } - - @SuppressLint("ViewTag") - public void checkSuppress(Context context, View view) { - view.setTag(android.R.id.icon, view.findViewById(android.R.id.icon)); - } - - private class MyViewHolder { - View view; - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity1.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity1.class.data Binary files differdeleted file mode 100644 index d4733e6..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity1.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity1.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity1.java.txt deleted file mode 100644 index 0b14691..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity1.java.txt +++ /dev/null @@ -1,17 +0,0 @@ -package test.pkg; - -import android.app.Activity; -import android.os.Bundle; -import android.os.PowerManager; - -public class WakelockActivity1 extends Activity { - private PowerManager.WakeLock mWakeLock; - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - PowerManager manager = (PowerManager) getSystemService(POWER_SERVICE); - mWakeLock = manager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Test"); - mWakeLock.acquire(); // Never released - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity2.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity2.class.data Binary files differdeleted file mode 100644 index 89e35c1..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity2.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity2.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity2.java.txt deleted file mode 100644 index fa91a43..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity2.java.txt +++ /dev/null @@ -1,24 +0,0 @@ -package test.pkg; - -import android.app.Activity; -import android.os.PowerManager; - -public class WakelockActivity2 extends Activity { - private PowerManager.WakeLock mWakeLock; - - @Override - protected void onDestroy() { - super.onDestroy(); - if (mWakeLock != null && mWakeLock.isHeld()) { - mWakeLock.release(); // Should be done in onPause instead - } - } - - @Override - protected void onPause() { - super.onDestroy(); - if (mWakeLock != null && mWakeLock.isHeld()) { - mWakeLock.release(); // OK - } - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity3.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity3.class.data Binary files differdeleted file mode 100644 index b430519..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity3.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity3.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity3.java.txt deleted file mode 100644 index 8a842eb..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity3.java.txt +++ /dev/null @@ -1,19 +0,0 @@ -package test.pkg; - -import android.app.Activity; -import android.os.PowerManager; - -public class WakelockActivity3 extends Activity { - void wrongFlow() { - PowerManager manager = (PowerManager) getSystemService(POWER_SERVICE); - PowerManager.WakeLock lock = - manager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Test"); - lock.acquire(); - randomCall(); - lock.release(); // Should be in finally block - } - - static void randomCall() { - System.out.println("test"); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity4.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity4.class.data Binary files differdeleted file mode 100644 index 8905203..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity4.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity4.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity4.java.txt deleted file mode 100644 index 9d6331f..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity4.java.txt +++ /dev/null @@ -1,27 +0,0 @@ -package test.pkg; - -import android.app.Activity; -import android.os.PowerManager; - -public class WakelockActivity4 extends Activity { - void wrongFlow2() { - getLock().acquire(); - randomCall(); - getLock().release(); // Should be in finally block - } - - private PowerManager.WakeLock mLock; - - PowerManager.WakeLock getLock() { - if (mLock == null) { - PowerManager manager = (PowerManager) getSystemService(POWER_SERVICE); - mLock = manager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Test"); - } - - return mLock; - } - - static void randomCall() { - System.out.println("test"); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity5.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity5.class.data Binary files differdeleted file mode 100644 index 9eca365..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity5.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity5.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity5.java.txt deleted file mode 100644 index 060f2b1..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity5.java.txt +++ /dev/null @@ -1,19 +0,0 @@ -package test.pkg; - -import android.app.Activity; -import android.os.PowerManager; - -public class WakelockActivity5 extends Activity { - void wrongFlow() { - PowerManager manager = (PowerManager) getSystemService(POWER_SERVICE); - PowerManager.WakeLock lock = - manager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Test"); - lock.acquire(); - randomCall(); - lock.release(); // Should be in finally block - } - - static void randomCall() { - System.out.println("test"); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity6.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity6.class.data Binary files differdeleted file mode 100644 index 51fdf69..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity6.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity6.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity6.java.txt deleted file mode 100644 index a122fa3..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity6.java.txt +++ /dev/null @@ -1,71 +0,0 @@ -package test.pkg; - -import com.example.test3.BuildConfig; - -import android.annotation.SuppressLint; -import android.app.Activity; -import android.os.PowerManager; -import android.os.PowerManager.WakeLock;; - -public class WakelockActivity6 extends Activity { - void wrongFlow1() { - PowerManager manager = (PowerManager) getSystemService(POWER_SERVICE); - PowerManager.WakeLock lock = - manager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Test"); - lock.acquire(); - if (getTaskId() == 50) { - randomCall(); - } else { - lock.release(); // Wrong - } - } - - void wrongFlow2(PowerManager.WakeLock lock) { - lock.acquire(); - if (getTaskId() == 50) { - randomCall(); - } else { - lock.release(); // Wrong - } - } - - void okFlow1(WakeLock lock) { - lock.acquire(); - try { - randomCall(); - } catch (Exception e) { - e.printStackTrace(); - } finally { - lock.release(); // OK - } - } - - public void checkNullGuard(WakeLock lock) { - lock.acquire(); - if (lock != null) { - lock.release(); // OK - } - } - - @SuppressLint("Wakelock") - public void checkDisabled1(PowerManager.WakeLock lock) { - lock.acquire(); - randomCall(); - lock.release(); // Wrong, but disabled - } - - void wrongFlow3(WakeLock lock) { - int id = getTaskId(); - lock.acquire(); - if (id < 50) { - System.out.println(1); - } else { - System.out.println(2); - } - lock.release(); // Wrong - } - - static void randomCall() { - System.out.println("test"); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity7.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity7.class.data Binary files differdeleted file mode 100644 index 289b0d3..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity7.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity7.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity7.java.txt deleted file mode 100644 index be48dac..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity7.java.txt +++ /dev/null @@ -1,17 +0,0 @@ -package test.pkg; - -import android.os.PowerManager.WakeLock; - -public class WakelockActivity7 { - public void test(WakeLock lock) { - try { - lock.acquire(); - new Runnable() { - public void run() { - } - }; - } finally { - lock.release(); - } - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity8.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity8.class.data Binary files differdeleted file mode 100644 index 5bd3ae2..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity8.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity8.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity8.java.txt deleted file mode 100644 index a6307c5..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity8.java.txt +++ /dev/null @@ -1,24 +0,0 @@ -package test.pkg; - -import android.app.Activity; -import android.os.Bundle; -import android.os.PowerManager; -import android.os.PowerManager.WakeLock; - -import com.google.io.demo.R; - -public class WakelockActivity8 extends Activity { - private WakeLock mWakeLock; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.main); - PowerManager manager = (PowerManager) getSystemService(POWER_SERVICE); - mWakeLock = manager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Test"); - mWakeLock.acquire(); - if (mWakeLock.isHeld()) { - mWakeLock.release(); - } - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/classes.jar b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/classes.jar Binary files differdeleted file mode 100644 index fa52dcf..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/classes.jar +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/classpath-jar b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/classpath-jar deleted file mode 100644 index 53f7d6c..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/classpath-jar +++ /dev/null @@ -1,8 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="src" path="src"/> - <classpathentry kind="src" path="gen"/> - <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> - <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/> - <classpathentry kind="output" path="bin/classes.jar"/> -</classpath> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/classpath-lib b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/classpath-lib deleted file mode 100644 index e730df8..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/classpath-lib +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="src" path="src"/> - <classpathentry kind="src" path="gen"/> - <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> - <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/> - <classpathentry kind="lib" path="libs/library.jar"/> - <classpathentry kind="output" path="bin/classes"/> -</classpath> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/debuggable.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/debuggable.xml deleted file mode 100644 index 1c234e4..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/debuggable.xml +++ /dev/null @@ -1,24 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="foo.bar2" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="14" /> - - <application - android:debuggable="true" - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - <activity - android:label="@string/app_name" - android:name=".Foo2Activity" > - <intent-filter > - <action android:name="android.intent.action.MAIN" /> - - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - </application> - -</manifest> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/duplicate-manifest-ignore.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/duplicate-manifest-ignore.xml deleted file mode 100644 index 76cfd4d..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/duplicate-manifest-ignore.xml +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:tools="http://schemas.android.com/tools" - package="com.example.helloworld" - android:versionCode="1" - android:versionName="1.0"> - <uses-sdk android:minSdkVersion="14" /> - <application android:icon="@drawable/icon" android:label="@string/app_name" tools:ignore="DuplicateActivity"> - <activity android:name=".HelloWorld" - android:label="@string/app_name"> - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - - <activity android:name="com.example.helloworld.HelloWorld" - android:label="@string/app_name"> - </activity> - - </application> - -</manifest> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/duplicate-manifest.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/duplicate-manifest.xml deleted file mode 100644 index e1fc3c6..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/duplicate-manifest.xml +++ /dev/null @@ -1,22 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="com.example.helloworld" - android:versionCode="1" - android:versionName="1.0"> - <uses-sdk android:minSdkVersion="14" /> - <application android:icon="@drawable/icon" android:label="@string/app_name"> - <activity android:name=".HelloWorld" - android:label="@string/app_name"> - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - - <activity android:name="com.example.helloworld.HelloWorld" - android:label="@string/app_name"> - </activity> - - </application> - -</manifest> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/duplicate_permissions1.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/duplicate_permissions1.xml deleted file mode 100644 index 511fa46..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/duplicate_permissions1.xml +++ /dev/null @@ -1,21 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="foo.bar2" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="14" /> - - <permission android:name="foo.permission.SEND_SMS" - android:label="@string/foo" - android:description="@string/foo" /> - <permission android:name="bar.permission.SEND_SMS" - android:label="@string/foo" - android:description="@string/foo" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - </application> - -</manifest> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/duplicate_permissions2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/duplicate_permissions2.xml deleted file mode 100644 index 3729f79..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/duplicate_permissions2.xml +++ /dev/null @@ -1,18 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="foo.bar2" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="14" /> - - <permission android:name="foo.permission.SEND_SMS" - android:label="@string/foo" - android:description="@string/foo" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - </application> - -</manifest> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/duplicate_permissions3.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/duplicate_permissions3.xml deleted file mode 100644 index a1a0638..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/duplicate_permissions3.xml +++ /dev/null @@ -1,18 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="foo.bar2" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="14" /> - - <permission android:name="bar.permission.SEND_SMS" - android:label="@string/foo" - android:description="@string/foo" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - </application> - -</manifest> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportactivity0.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportactivity0.xml deleted file mode 100644 index cc436d0..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportactivity0.xml +++ /dev/null @@ -1,19 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="foo.bar2" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="14" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - <activity - android:label="@string/app_name" - android:name="com.sample.service.serviceClass" > - </activity> - </application> - -</manifest> - diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportactivity1.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportactivity1.xml deleted file mode 100644 index 0fc80f3..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportactivity1.xml +++ /dev/null @@ -1,32 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="foo.bar2" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="14" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - <activity - android:label="@string/app_name" - android:name="com.sample.service.serviceClass" > - <intent-filter > - <action android:name="com.sample.service.serviceClass" > - </action> - </intent-filter> - </activity> - <activity - android:label="@string/app_name" - android:name="com.sample.service.mainClass" > - <intent-filter > - <action android:name="com.sample.service.mainClass" > - </action> - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - </application> - -</manifest> - diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportactivity2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportactivity2.xml deleted file mode 100644 index 2b4cf6a..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportactivity2.xml +++ /dev/null @@ -1,24 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="foo.bar2" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="14" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - <activity - android:label="@string/app_name" - android:name="com.sample.service.serviceClass" - android:permission="android.permission.RECEIVE_BOOT_COMPLETED" - android:process=":remote" > - <intent-filter > - <action android:name="com.sample.service.serviceClass" > - </action> - </intent-filter> - </activity> - </application> - -</manifest> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportactivity3.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportactivity3.xml deleted file mode 100644 index 191c699..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportactivity3.xml +++ /dev/null @@ -1,24 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="foo.bar2" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="14" /> - - <application - android:icon="@drawable/ic_launcher" - android:permission="android.permission.RECEIVE_BOOT_COMPLETED" - android:label="@string/app_name" > - <activity - android:label="@string/app_name" - android:name="com.sample.service.serviceClass" - android:process=":remote" > - <intent-filter > - <action android:name="com.sample.service.serviceClass" > - </action> - </intent-filter> - </activity> - </application> - -</manifest> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportactivity4.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportactivity4.xml deleted file mode 100644 index 31345cc..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportactivity4.xml +++ /dev/null @@ -1,24 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="foo.bar2" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="14" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - <activity - android:label="@string/app_name" - android:name="com.sample.service.serviceClass" - android:process=":remote" > - <intent-filter > - <action android:name="com.sample.service.serviceClass" > - </action> - </intent-filter> - </activity> - </application> - -</manifest> - diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportprovider1.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportprovider1.xml deleted file mode 100644 index 02ec2e0..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportprovider1.xml +++ /dev/null @@ -1,33 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="foo.bar2" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="14" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - - <!-- exported implicitly, fail --> - <provider - android:name="com.sample.provider.providerClass1" - android:authorities="com.sample.provider.providerData"> - </provider> - - <!-- exported explicitly, fail --> - <provider - android:exported="true" - android:name="com.sample.provider.providerClass2" - android:authorities="com.sample.provider.providerData"> - </provider> - - <!-- not exported, win --> - <provider - android:exported="false" - android:name="com.sample.provider.providerClass3" - android:authorities="com.sample.provider.providerData"> - </provider> - </application> -</manifest> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportprovider2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportprovider2.xml deleted file mode 100644 index 4e3fc1b..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportprovider2.xml +++ /dev/null @@ -1,39 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="foo.bar2" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="14" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - - <!-- read+write permission attribute, win --> - <provider - android:name="com.sample.provider.providerClass" - android:authorities="com.sample.provider.providerData" - android:readPermission="com.sample.provider.READ_PERMISSON" - android:writePermission="com.sample.provider.WRITE_PERMISSON"> - </provider> - - <!-- permission attribute, win --> - <provider - android:name="com.sample.provider.providerClass" - android:authorities="com.sample.provider.providerData" - android:permission="com.sample.provider.PERMISSION"> - </provider> - - <!-- path-permission, win --> - <provider - android:name="com.sample.provider.providerClass" - android:authorities="com.sample.provider.providerData"> - <path-permission - android:pathPrefix="/hello" - android:permission="com.sample.provider.PERMISSION"> - </path-permission> - </provider> - </application> - -</manifest> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportreceiver0.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportreceiver0.xml deleted file mode 100644 index f9c5190..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportreceiver0.xml +++ /dev/null @@ -1,19 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="foo.bar2" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="14" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - <receiver - android:label="@string/app_name" - android:name="com.sample.service.serviceClass" > - </receiver> - </application> - -</manifest> - diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportreceiver1.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportreceiver1.xml deleted file mode 100644 index 0652d49..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportreceiver1.xml +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="foo.bar2" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="14" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - <receiver - android:label="@string/app_name" - android:name="com.sample.service.serviceClass" > - <intent-filter > - <action android:name="com.sample.service.serviceClass" > - </action> - </intent-filter> - </receiver> - </application> - -</manifest> - diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportreceiver2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportreceiver2.xml deleted file mode 100644 index 46d5dcb..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportreceiver2.xml +++ /dev/null @@ -1,24 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="foo.bar2" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="14" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - <receiver - android:label="@string/app_name" - android:name="com.sample.service.serviceClass" - android:permission="android.permission.RECEIVE_BOOT_COMPLETED" - android:process=":remote" > - <intent-filter > - <action android:name="com.sample.service.serviceClass" > - </action> - </intent-filter> - </receiver> - </application> - -</manifest> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportreceiver3.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportreceiver3.xml deleted file mode 100644 index bc3ec8a..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportreceiver3.xml +++ /dev/null @@ -1,24 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="foo.bar2" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="14" /> - - <application - android:icon="@drawable/ic_launcher" - android:permission="android.permission.RECEIVE_BOOT_COMPLETED" - android:label="@string/app_name" > - <receiver - android:label="@string/app_name" - android:name="com.sample.service.serviceClass" - android:process=":remote" > - <intent-filter > - <action android:name="com.sample.service.serviceClass" > - </action> - </intent-filter> - </receiver> - </application> - -</manifest> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportreceiver4.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportreceiver4.xml deleted file mode 100644 index 5d9a826..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportreceiver4.xml +++ /dev/null @@ -1,24 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="foo.bar2" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="14" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - <receiver - android:label="@string/app_name" - android:name="com.sample.service.serviceClass" - android:process=":remote" > - <intent-filter > - <action android:name="com.sample.service.serviceClass" > - </action> - </intent-filter> - </receiver> - </application> - -</manifest> - diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportreceiver5.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportreceiver5.xml deleted file mode 100644 index afa74cf..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportreceiver5.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="foo.bar2" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="14" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name"> - <receiver> - <intent-filter> - <action android:name="android.intent.action.BOOT_COMPLETED" /> - </intent-filter> - </receiver> - </application> - -</manifest> - diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportreceiver6.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportreceiver6.xml deleted file mode 100644 index b1ce3e3..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportreceiver6.xml +++ /dev/null @@ -1,43 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="foo.bar2" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="14" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - - <receiver android:name=".DockReceiver" > - <intent-filter> - <action android:name="android.intent.action.DOCK_EVENT" /> - <action android:name="android.app.action.ENTER_CAR_MODE" /> - </intent-filter> - </receiver> - - <receiver - android:name="com.foo.BarReceiver" - android:enabled="false" > - <intent-filter> - <action android:name="android.intent.action.ACTION_POWER_CONNECTED" /> - <action android:name="android.net.conn.CONNECTIVITY_CHANGE" /> - </intent-filter> - </receiver> - - <receiver - android:name=".AppWidget" - android:exported="true" - android:label="@string/label" > - <intent-filter> - <action android:name="android.appwidget.action.APPWIDGET_UPDATE" /> - </intent-filter> - - <meta-data - android:name="android.appwidget.provider" - android:resource="@xml/config" /> - </receiver> - </application> - -</manifest> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportservice1.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportservice1.xml deleted file mode 100644 index 67e519f..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportservice1.xml +++ /dev/null @@ -1,25 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="foo.bar2" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="14" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - <service - android:exported="true" - android:label="@string/app_name" - android:name="com.sample.service.serviceClass" - android:process=":remote" > - <intent-filter > - <action android:name="com.sample.service.serviceClass" > - </action> - </intent-filter> - </service> - </application> - -</manifest> - diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportservice2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportservice2.xml deleted file mode 100644 index 491a14f..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportservice2.xml +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="foo.bar2" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="14" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - <service - android:label="@string/app_name" - android:name="com.sample.service.serviceClass" - android:process=":remote" > - <intent-filter > - <action android:name="com.sample.service.serviceClass" > - </action> - </intent-filter> - </service> - </application> - -</manifest> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportservice3.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportservice3.xml deleted file mode 100644 index 8d5f166..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportservice3.xml +++ /dev/null @@ -1,24 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="foo.bar2" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="14" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - <service - android:label="@string/app_name" - android:name="com.sample.service.serviceClass" - android:permission="android.permission.RECEIVE_BOOT_COMPLETED" - android:process=":remote" > - <intent-filter > - <action android:name="com.sample.service.serviceClass" > - </action> - </intent-filter> - </service> - </application> - -</manifest> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportservice4.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportservice4.xml deleted file mode 100644 index f952225..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportservice4.xml +++ /dev/null @@ -1,24 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="foo.bar2" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="14" /> - - <application - android:icon="@drawable/ic_launcher" - android:permission="android.permission.RECEIVE_BOOT_COMPLETED" - android:label="@string/app_name" > - <service - android:label="@string/app_name" - android:name="com.sample.service.serviceClass" - android:process=":remote" > - <intent-filter > - <action android:name="com.sample.service.serviceClass" > - </action> - </intent-filter> - </service> - </application> - -</manifest> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportservice5.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportservice5.xml deleted file mode 100644 index c9b9a78..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportservice5.xml +++ /dev/null @@ -1,24 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="foo.bar2" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="14" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - <service - android:label="@string/app_name" - android:name="com.sample.service.serviceClass" - android:process=":remote" > - <intent-filter > - <action android:name="com.sample.service.serviceClass" > - </action> - </intent-filter> - </service> - </application> - -</manifest> - diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/gen/my/pkg/R.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/gen/my/pkg/R.java.txt deleted file mode 100644 index fad43bf..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/gen/my/pkg/R.java.txt +++ /dev/null @@ -1,23 +0,0 @@ -public final class R { - public static final class attr { - } - public static final class drawable { - public static final int ic_launcher=0x7f020000; - } - public static final class id { - public static final int button1=0x7f050000; - public static final int button2=0x7f050004; - public static final int imageView1=0x7f050003; - public static final int include1=0x7f050005; - public static final int linearLayout1=0x7f050001; - public static final int linearLayout2=0x7f050002; - } - public static final class layout { - public static final int main=0x7f030000; - public static final int other=0x7f030001; - } - public static final class string { - public static final int app_name=0x7f040001; - public static final int hello=0x7f040000; - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/gen/my/pkg/R2.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/gen/my/pkg/R2.java.txt deleted file mode 100644 index ed8fd7d..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/gen/my/pkg/R2.java.txt +++ /dev/null @@ -1,5 +0,0 @@ -public final class R { - public static final class drawable { - public static final int ic_menu_help=0x7f020000; - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/grantpermission.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/grantpermission.xml deleted file mode 100644 index e07c370..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/grantpermission.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="foo.bar2" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="14" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - <activity - android:label="@string/app_name" - android:name=".Foo2Activity" - android:permission="Foo" > - <intent-filter > - <action android:name="android.intent.action.MAIN" /> - - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - <!-- good: --> - <grant-uri-permission android:pathPrefix="/all_downloads/"/> - <!-- bad: --> - <grant-uri-permission android:path="/"/> - <grant-uri-permission android:pathPrefix="/"/> - <grant-uri-permission android:pathPattern=".*"/> - </application> - -</manifest> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/ignoremissing.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/ignoremissing.xml deleted file mode 100644 index 99d804e..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/ignoremissing.xml +++ /dev/null @@ -1,6 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<lint> - <issue id="IconDensities" severity="warning"> - <ignore path="res/drawable-hdpi" /> - </issue> -</lint> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/illegal_version.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/illegal_version.xml deleted file mode 100644 index 3028117..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/illegal_version.xml +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="foo.bar2" - android:versionCode="@dimen/versionCode" - android:versionName="@dimen/versionName" > - - <uses-sdk android:minSdkVersion="@dimen/minSdkVersion" android:targetSdkVersion="@dimen/targetSdkVersion" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - <activity - android:label="@string/app_name" - android:name=".Foo2Activity" > - <intent-filter > - <action android:name="android.intent.action.MAIN" /> - - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - </application> - -</manifest> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/minsdk5targetsdk14.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/minsdk5targetsdk14.xml deleted file mode 100644 index 482b7fa..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/minsdk5targetsdk14.xml +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="test.bytecode" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="5" android:targetSdkVersion="14" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - <activity - android:name=".BytecodeTestsActivity" - android:label="@string/app_name" > - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - </application> - -</manifest> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/minsdk5targetsdk9.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/minsdk5targetsdk9.xml deleted file mode 100644 index 1cc7596..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/minsdk5targetsdk9.xml +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="test.bytecode" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="5" android:targetSdkVersion="9" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - <activity - android:name=".BytecodeTestsActivity" - android:label="@string/app_name" > - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - </application> - -</manifest> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/missingmin.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/missingmin.xml deleted file mode 100644 index 19b3d0a..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/missingmin.xml +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="test.bytecode" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:targetSdkVersion="10" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - <activity - android:name=".BytecodeTestsActivity" - android:label="@string/app_name" > - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - </application> - -</manifest> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/missingprefix.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/missingprefix.xml deleted file mode 100644 index 2bb6824..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/missingprefix.xml +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="foo.bar2" - versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="14" /> - - <application - android:icon="@drawable/ic_launcher" - android.label="@string/app_name" > - <activity - android:label="@string/app_name" - android:name=".Foo2Activity" > - <intent-filter > - <action android:name="android.intent.action.MAIN" /> - - <category name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - </application> - -</manifest> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/missingtarget.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/missingtarget.xml deleted file mode 100644 index 1f4fba0..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/missingtarget.xml +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="test.bytecode" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="10" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - <activity - android:name=".BytecodeTestsActivity" - android:label="@string/app_name" > - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - </application> - -</manifest> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/missingusessdk.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/missingusessdk.xml deleted file mode 100644 index 00c0167..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/missingusessdk.xml +++ /dev/null @@ -1,21 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="test.bytecode" - android:versionCode="1" - android:versionName="1.0" > - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - <activity - android:name=".BytecodeTestsActivity" - android:label="@string/app_name" > - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - </application> - -</manifest> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiplesdk.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiplesdk.xml deleted file mode 100644 index 950cf4d..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiplesdk.xml +++ /dev/null @@ -1,25 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="test.bytecode" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="5" /> - <uses-sdk android:targetSdkVersion="14" /> - <uses-sdk android:maxSdkVersion="15" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - <activity - android:name=".BytecodeTestsActivity" - android:label="@string/app_name" > - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - </application> - -</manifest> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/LibraryCode.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/LibraryCode.java.txt deleted file mode 100644 index 25a9d75..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/LibraryCode.java.txt +++ /dev/null @@ -1,7 +0,0 @@ -package foo.library; - -public class LibraryCode { - static { - System.out.println(R.string.string1); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/MainCode.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/MainCode.java.txt deleted file mode 100644 index 7955e6b..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/MainCode.java.txt +++ /dev/null @@ -1,7 +0,0 @@ -package foo.main; - -public class MainCode { - static { - System.out.println(R.string.string2); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/library-manifest.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/library-manifest.xml deleted file mode 100644 index ed6e65b..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/library-manifest.xml +++ /dev/null @@ -1,31 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="foo.library" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="14" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - <activity - android:name=".LibraryProjectActivity" - android:label="@string/app_name" > - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - - <!-- Dummy string references for unused resource check --> - <meta-data - android:name="com.google.android.backup.api_key" - android:value="@string/string3" /> - <meta-data - android:name="foo" - android:value="@string/string1" /> - </application> - -</manifest> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/library.properties b/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/library.properties deleted file mode 100644 index d525577..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/library.properties +++ /dev/null @@ -1,12 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system use, -# "ant.properties", and override values to adapt the script to your -# project structure. - -# Project target. -target=android-14 -android.library=true diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/main-manifest.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/main-manifest.xml deleted file mode 100644 index 5c50721..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/main-manifest.xml +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="foo.master" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="14" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - <activity - android:name=".MasterProjectActivity" - android:label="@string/app_name" > - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - </application> - -</manifest>
\ No newline at end of file diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/main-merge.properties b/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/main-merge.properties deleted file mode 100644 index f1b8f95..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/main-merge.properties +++ /dev/null @@ -1,13 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system use, -# "ant.properties", and override values to adapt the script to your -# project structure. - -# Project target. -target=android-14 -manifestmerger.enabled=true -android.library.reference.1=../LibraryProject diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/main.properties b/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/main.properties deleted file mode 100644 index f366140..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/main.properties +++ /dev/null @@ -1,12 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system use, -# "ant.properties", and override values to adapt the script to your -# project structure. - -# Project target. -target=android-14 -android.library.reference.1=../LibraryProject diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/strings.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/strings.xml deleted file mode 100644 index f53e15f..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/strings.xml +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources> - - <string name="app_name">LibraryProject</string> - <string name="string1">String 1</string> - <string name="string2">String 2</string> - <string name="string3">String 3</string> - -</resources> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/no_version.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/no_version.xml deleted file mode 100644 index 1c3c0a4..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/no_version.xml +++ /dev/null @@ -1,21 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="foo.bar2" > - - <uses-sdk android:minSdkVersion="14" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - <activity - android:label="@string/app_name" - android:name=".Foo2Activity" > - <intent-filter > - <action android:name="android.intent.action.MAIN" /> - - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - </application> - -</manifest> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/oldtarget.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/oldtarget.xml deleted file mode 100644 index d72d7fc..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/oldtarget.xml +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="test.bytecode" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="10" android:targetSdkVersion="14" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - <activity - android:name=".BytecodeTestsActivity" - android:label="@string/app_name" > - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - </application> - -</manifest> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/.classpath b/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/.classpath deleted file mode 100644 index a4763d1..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/.classpath +++ /dev/null @@ -1,8 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="src" path="src"/> - <classpathentry kind="src" path="gen"/> - <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> - <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/> - <classpathentry kind="output" path="bin/classes"/> -</classpath> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/.project b/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/.project deleted file mode 100644 index 5479f13..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/.project +++ /dev/null @@ -1,33 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>overdraw</name> - <comment></comment> - <projects> - </projects> - <buildSpec> - <buildCommand> - <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.jdt.core.javabuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>com.android.ide.eclipse.adt.ApkBuilder</name> - <arguments> - </arguments> - </buildCommand> - </buildSpec> - <natures> - <nature>com.android.ide.eclipse.adt.AndroidNature</nature> - <nature>org.eclipse.jdt.core.javanature</nature> - </natures> -</projectDescription> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/AndroidManifest.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/AndroidManifest.xml deleted file mode 100644 index c9c6127..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/AndroidManifest.xml +++ /dev/null @@ -1,38 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="test.pkg" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="10" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" - android:theme="@style/MyTheme" > - <activity - android:name=".OverdrawActivity" - android:label="@string/app_name" - android:theme="@style/MyTheme.First" > - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - <activity - android:name=".SecondActivity" - android:label="@string/app_name" > - </activity> - <activity - android:name=".ThirdActivity" - android:label="@string/app_name" > - </activity> - <activity - android:name="test.pkg.FourthActivity" - android:label="@string/app_name" - android:theme="@style/MyTheme.Fourth" > - </activity> - </application> - -</manifest> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/gen/test/pkg/BuildConfig.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/gen/test/pkg/BuildConfig.java.txt deleted file mode 100644 index 57e2a0e..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/gen/test/pkg/BuildConfig.java.txt +++ /dev/null @@ -1,6 +0,0 @@ -/** Automatically generated file. DO NOT MODIFY */ -package test.pkg; - -public final class BuildConfig { - public final static boolean DEBUG = true; -}
\ No newline at end of file diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/gen/test/pkg/R.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/gen/test/pkg/R.java.txt deleted file mode 100644 index c7900de..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/gen/test/pkg/R.java.txt +++ /dev/null @@ -1,34 +0,0 @@ -/* AUTO-GENERATED FILE. DO NOT MODIFY. - * - * This class was automatically generated by the - * aapt tool from the resource data it found. It - * should not be modified by hand. - */ - -package test.pkg; - -public final class R { - public static final class attr { - } - public static final class drawable { - public static final int ic_launcher=0x7f020000; - } - public static final class layout { - public static final int fifth=0x7f030000; - public static final int fourth=0x7f030001; - public static final int main=0x7f030002; - public static final int second=0x7f030003; - public static final int third=0x7f030004; - } - public static final class string { - public static final int app_name=0x7f040001; - public static final int hello=0x7f040000; - } - public static final class style { - public static final int MyTheme=0x7f050000; - public static final int MyTheme_First=0x7f050001; - public static final int MyTheme_Fourth=0x7f050004; - public static final int MyTheme_Second=0x7f050002; - public static final int MyTheme_Third=0x7f050003; - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/project.properties b/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/project.properties deleted file mode 100644 index f049142..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/project.properties +++ /dev/null @@ -1,11 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system use, -# "ant.properties", and override values to adapt the script to your -# project structure. - -# Project target. -target=android-10 diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/drawable-hdpi/ic_launcher.png b/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/drawable-hdpi/ic_launcher.png Binary files differdeleted file mode 100644 index 8074c4c..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/drawable-hdpi/ic_launcher.png +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/drawable-ldpi/ic_launcher.png b/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/drawable-ldpi/ic_launcher.png Binary files differdeleted file mode 100644 index 1095584..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/drawable-ldpi/ic_launcher.png +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/drawable-mdpi/ic_launcher.png b/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/drawable-mdpi/ic_launcher.png Binary files differdeleted file mode 100644 index a07c69f..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/drawable-mdpi/ic_launcher.png +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/drawable/custombg.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/drawable/custombg.xml deleted file mode 100644 index a8e70d4..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/drawable/custombg.xml +++ /dev/null @@ -1,5 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<bitmap - xmlns:android="http://schemas.android.com/apk/res/android" - android:src="@drawable/ic_launcher" - android:tileMode="clamp" />
\ No newline at end of file diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/drawable/custombg2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/drawable/custombg2.xml deleted file mode 100644 index 47513c3..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/drawable/custombg2.xml +++ /dev/null @@ -1,5 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<selector xmlns:android="http://schemas.android.com/apk/res/android"> - <item android:drawable="@drawable/ic_launcher" /> -</selector> - diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/layout/fifth.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/layout/fifth.xml deleted file mode 100644 index 00a5c25..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/layout/fifth.xml +++ /dev/null @@ -1,13 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="fill_parent" - android:layout_height="fill_parent" - android:background="@drawable/custombg2" - android:orientation="vertical" > - - <TextView - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:text="@string/hello" /> - -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/layout/fourth.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/layout/fourth.xml deleted file mode 100644 index 3102f2c..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/layout/fourth.xml +++ /dev/null @@ -1,13 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="fill_parent" - android:layout_height="fill_parent" - android:background="@drawable/ic_launcher" - android:orientation="vertical" > - - <TextView - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:text="@string/hello" /> - -</LinearLayout>
\ No newline at end of file diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/layout/main.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/layout/main.xml deleted file mode 100644 index 3102f2c..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/layout/main.xml +++ /dev/null @@ -1,13 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="fill_parent" - android:layout_height="fill_parent" - android:background="@drawable/ic_launcher" - android:orientation="vertical" > - - <TextView - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:text="@string/hello" /> - -</LinearLayout>
\ No newline at end of file diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/layout/main_ignore.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/layout/main_ignore.xml deleted file mode 100644 index 63f0fd3..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/layout/main_ignore.xml +++ /dev/null @@ -1,15 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:tools="http://schemas.android.com/tools" - android:layout_width="fill_parent" - android:layout_height="fill_parent" - android:background="@drawable/ic_launcher" - tools:ignore="Overdraw" - android:orientation="vertical" > - - <TextView - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:text="@string/hello" /> - -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/layout/second.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/layout/second.xml deleted file mode 100644 index 3102f2c..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/layout/second.xml +++ /dev/null @@ -1,13 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="fill_parent" - android:layout_height="fill_parent" - android:background="@drawable/ic_launcher" - android:orientation="vertical" > - - <TextView - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:text="@string/hello" /> - -</LinearLayout>
\ No newline at end of file diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/layout/sixth.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/layout/sixth.xml deleted file mode 100644 index 7f17c9e..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/layout/sixth.xml +++ /dev/null @@ -1,13 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="fill_parent" - android:background="@drawable/custombg" - android:layout_height="fill_parent" - android:orientation="vertical" > - - <TextView - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:text="@string/hello" /> - -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/layout/third.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/layout/third.xml deleted file mode 100644 index 3102f2c..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/layout/third.xml +++ /dev/null @@ -1,13 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="fill_parent" - android:layout_height="fill_parent" - android:background="@drawable/ic_launcher" - android:orientation="vertical" > - - <TextView - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:text="@string/hello" /> - -</LinearLayout>
\ No newline at end of file diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/values/strings.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/values/strings.xml deleted file mode 100644 index bb302bc..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/values/strings.xml +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources> - - <string name="hello">Hello World, OverdrawActivity!</string> - <string name="app_name">Overdraw</string> - -</resources>
\ No newline at end of file diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/values/styles.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/values/styles.xml deleted file mode 100644 index 5ab6ad6..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/values/styles.xml +++ /dev/null @@ -1,25 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources> - - <style name="MyTheme" parent="@android:style/Theme.Light"> - <item name="android:windowBackground">@drawable/ic_launcher</item> - </style> - - <style name="MyTheme.First"> - <item name="android:textColor">#ff00ff00</item> - </style> - - <style name="MyTheme.Second"> - <item name="android:windowIsTranslucent">true</item> - </style> - - <style name="MyTheme.Third"> - <item name="android:textColor">#ff000000</item> - </style> - - <style name="MyTheme.Fourth"> - <item name="android:windowBackground">@null</item> - <item name="android:textColor">#ff000000</item> - </style> - -</resources>
\ No newline at end of file diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/src/test/pkg/FourthActivity.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/src/test/pkg/FourthActivity.java.txt deleted file mode 100644 index 04fac3f..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/src/test/pkg/FourthActivity.java.txt +++ /dev/null @@ -1,13 +0,0 @@ -package test.pkg; - -import android.app.Activity; -import android.os.Bundle; - -public class FourthActivity extends Activity { - /** Called when the activity is first created. */ - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.fourth); - } -}
\ No newline at end of file diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/src/test/pkg/OverdrawActivity.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/src/test/pkg/OverdrawActivity.java.txt deleted file mode 100644 index 8779c19..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/src/test/pkg/OverdrawActivity.java.txt +++ /dev/null @@ -1,13 +0,0 @@ -package test.pkg; - -import android.app.Activity; -import android.os.Bundle; - -public class OverdrawActivity extends Activity { - /** Called when the activity is first created. */ - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.main); - } -}
\ No newline at end of file diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/src/test/pkg/SecondActivity.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/src/test/pkg/SecondActivity.java.txt deleted file mode 100644 index 52b7ca0..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/src/test/pkg/SecondActivity.java.txt +++ /dev/null @@ -1,13 +0,0 @@ -package test.pkg; - -import android.app.Activity; -import android.os.Bundle; - -public class SecondActivity extends Activity { - /** Called when the activity is first created. */ - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.second); - } -}
\ No newline at end of file diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/src/test/pkg/ThirdActivity.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/src/test/pkg/ThirdActivity.java.txt deleted file mode 100644 index 3d4da95..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/src/test/pkg/ThirdActivity.java.txt +++ /dev/null @@ -1,14 +0,0 @@ -package test.pkg; - -import android.app.Activity; -import android.os.Bundle; - -public class ThirdActivity extends Activity { - /** Called when the activity is first created. */ - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setTheme(R.style.MyTheme_Third); - setContentView(R.layout.third); - } -}
\ No newline at end of file diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/proguard.cfg b/lint/cli/src/test/java/com/android/tools/lint/checks/data/proguard.cfg deleted file mode 100644 index 12dd039..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/proguard.cfg +++ /dev/null @@ -1,36 +0,0 @@ --optimizationpasses 5 --dontusemixedcaseclassnames --dontskipnonpubliclibraryclasses --dontpreverify --verbose --optimizations !code/simplification/arithmetic,!field/*,!class/merging/* - --keep public class * extends android.app.Activity --keep public class * extends android.app.Application --keep public class * extends android.app.Service --keep public class * extends android.content.BroadcastReceiver --keep public class * extends android.content.ContentProvider --keep public class * extends android.app.backup.BackupAgentHelper --keep public class * extends android.preference.Preference --keep public class com.android.vending.licensing.ILicensingService - --keepclasseswithmembernames class * { - native <methods>; -} - --keepclasseswithmembernames class * { - public <init>(android.content.Context, android.util.AttributeSet); -} - --keepclasseswithmembernames class * { - public <init>(android.content.Context, android.util.AttributeSet, int); -} - --keepclassmembers enum * { - public static **[] values(); - public static ** valueOf(java.lang.String); -} - --keep class * implements android.os.Parcelable { - public static final android.os.Parcelable$Creator *; -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/proguard.pro b/lint/cli/src/test/java/com/android/tools/lint/checks/data/proguard.pro deleted file mode 100644 index 53f41fe..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/proguard.pro +++ /dev/null @@ -1,64 +0,0 @@ --optimizationpasses 5 --dontusemixedcaseclassnames --dontskipnonpubliclibraryclasses --verbose --optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/* --allowaccessmodification --keepattributes *Annotation* - - -# dex does not like code run through proguard optimize and preverify steps. --dontoptimize --dontpreverify - --keep public class * extends android.app.Activity --keep public class * extends android.app.Application --keep public class * extends android.app.Service --keep public class * extends android.content.BroadcastReceiver --keep public class * extends android.content.ContentProvider --keep public class * extends android.app.backup.BackupAgent --keep public class * extends android.preference.Preference --keep public class com.android.vending.licensing.ILicensingService - -# For native methods, see http://proguard.sourceforge.net/manual/examples.html#native --keepclasseswithmembernames class * { - native <methods>; -} - --keep public class * extends android.view.View { - public <init>(android.content.Context); - public <init>(android.content.Context, android.util.AttributeSet); - public <init>(android.content.Context, android.util.AttributeSet, int); - public void set*(...); -} - --keepclasseswithmembers class * { - public <init>(android.content.Context, android.util.AttributeSet); -} - --keepclasseswithmembers class * { - public <init>(android.content.Context, android.util.AttributeSet, int); -} - --keepclassmembers class * extends android.app.Activity { - public void *(android.view.View); -} - -# For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations --keepclassmembers enum * { - public static **[] values(); - public static ** valueOf(java.lang.String); -} - --keep class * implements android.os.Parcelable { - public static final android.os.Parcelable$Creator *; -} - --keepclassmembers class **.R$* { - public static <fields>; -} - -# The support library contains references to newer platform versions. -# Don't warn about those in case this app is linking against an older -# platform version. We know about them, and they are safe. --dontwarn android.support.** diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/proguard.properties b/lint/cli/src/test/java/com/android/tools/lint/checks/data/proguard.properties deleted file mode 100644 index 989c3c7..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/proguard.properties +++ /dev/null @@ -1,2 +0,0 @@ -target=android-14 -proguard.config=${sdk.dir}/foo.cfg:${user.home}/bar.pro;myfile.txt diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/project.properties1 b/lint/cli/src/test/java/com/android/tools/lint/checks/data/project.properties1 deleted file mode 100644 index 2b783dd..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/project.properties1 +++ /dev/null @@ -1,14 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system edit -# "ant.properties", and override values to adapt the script to your -# project structure. -# -# To enable ProGuard to shrink and obfuscate your code, uncomment this: -#proguard.config=proguard.cfg - -# Project target. -target=android-3 diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/project.properties2 b/lint/cli/src/test/java/com/android/tools/lint/checks/data/project.properties2 deleted file mode 100644 index d9a28ec..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/project.properties2 +++ /dev/null @@ -1,14 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system edit -# "ant.properties", and override values to adapt the script to your -# project structure. -# -# To enable ProGuard to shrink and obfuscate your code, uncomment this: -proguard.config=proguard.cfg - -# Project target. -target=android-3 diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/project.properties3 b/lint/cli/src/test/java/com/android/tools/lint/checks/data/project.properties3 deleted file mode 100644 index 3cb9d31..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/project.properties3 +++ /dev/null @@ -1,11 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system edit -# "ant.properties", and override values to adapt the script to your -# project structure. - -# Project target. -target=android-3 diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/project.properties4 b/lint/cli/src/test/java/com/android/tools/lint/checks/data/project.properties4 deleted file mode 100644 index fca9311..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/project.properties4 +++ /dev/null @@ -1,14 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system edit -# "ant.properties", and override values to adapt the script to your -# project structure. -# -# To enable ProGuard to shrink and obfuscate your code, uncomment this: -proguard.config=${sdk.dir}/tools/proguard/android-defaults.pro:proguard.pro - -# Project target. -target=android-3 diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/protectedpermissions.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/protectedpermissions.xml deleted file mode 100644 index 8b62497..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/protectedpermissions.xml +++ /dev/null @@ -1,116 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="foo.bar2" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="14" /> - - <!-- No warnings for those --> - <uses-permission android:name="android.permission.GET_ACCOUNTS" /> - <uses-permission android:name="android.permission.SEND_SMS" /> - <uses-permission android:name="android.permission.INTERNET" /> - - <!-- Warnings for those --> - <uses-permission android:name="android.intent.category.MASTER_CLEAR.permission.C2D_MESSAGE" /> - <uses-permission android:name="android.permission.ACCESS_CACHE_FILESYSTEM" /> - <uses-permission android:name="android.permission.ACCESS_CHECKIN_PROPERTIES" /> - <uses-permission android:name="android.permission.ACCESS_MTP" /> - <uses-permission android:name="android.permission.ACCESS_SURFACE_FLINGER" /> - <uses-permission android:name="android.permission.ACCOUNT_MANAGER" /> - <uses-permission android:name="android.permission.ALLOW_ANY_CODEC_FOR_PLAYBACK" /> - <uses-permission android:name="android.permission.ASEC_ACCESS" /> - <uses-permission android:name="android.permission.ASEC_CREATE" /> - <uses-permission android:name="android.permission.ASEC_DESTROY" /> - <uses-permission android:name="android.permission.ASEC_MOUNT_UNMOUNT" /> - <uses-permission android:name="android.permission.ASEC_RENAME" /> - <uses-permission android:name="android.permission.BACKUP" /> - <uses-permission android:name="android.permission.BIND_APPWIDGET" /> - <uses-permission android:name="android.permission.BIND_DEVICE_ADMIN" /> - <uses-permission android:name="android.permission.BIND_INPUT_METHOD" /> - <uses-permission android:name="android.permission.BIND_PACKAGE_VERIFIER" /> - <uses-permission android:name="android.permission.BIND_REMOTEVIEWS" /> - <uses-permission android:name="android.permission.BIND_TEXT_SERVICE" /> - <uses-permission android:name="android.permission.BIND_VPN_SERVICE" /> - <uses-permission android:name="android.permission.BIND_WALLPAPER" /> - <uses-permission android:name="android.permission.BRICK" /> - <uses-permission android:name="android.permission.BROADCAST_PACKAGE_REMOVED" /> - <uses-permission android:name="android.permission.BROADCAST_SMS" /> - <uses-permission android:name="android.permission.BROADCAST_WAP_PUSH" /> - <uses-permission android:name="android.permission.CALL_PRIVILEGED" /> - <uses-permission android:name="android.permission.CHANGE_BACKGROUND_DATA_SETTING" /> - <uses-permission android:name="android.permission.CHANGE_COMPONENT_ENABLED_STATE" /> - <uses-permission android:name="android.permission.CLEAR_APP_USER_DATA" /> - <uses-permission android:name="android.permission.CONFIRM_FULL_BACKUP" /> - <uses-permission android:name="android.permission.CONNECTIVITY_INTERNAL" /> - <uses-permission android:name="android.permission.CONTROL_LOCATION_UPDATES" /> - <uses-permission android:name="android.permission.COPY_PROTECTED_DATA" /> - <uses-permission android:name="android.permission.CRYPT_KEEPER" /> - <uses-permission android:name="android.permission.DELETE_CACHE_FILES" /> - <uses-permission android:name="android.permission.DELETE_PACKAGES" /> - <uses-permission android:name="android.permission.DEVICE_POWER" /> - <uses-permission android:name="android.permission.DIAGNOSTIC" /> - <uses-permission android:name="android.permission.DUMP" /> - <uses-permission android:name="android.permission.FACTORY_TEST" /> - <uses-permission android:name="android.permission.FORCE_BACK" /> - <uses-permission android:name="android.permission.FORCE_STOP_PACKAGES" /> - <uses-permission android:name="android.permission.GLOBAL_SEARCH" /> - <uses-permission android:name="android.permission.GLOBAL_SEARCH_CONTROL" /> - <uses-permission android:name="android.permission.HARDWARE_TEST" /> - <uses-permission android:name="android.permission.INJECT_EVENTS" /> - <uses-permission android:name="android.permission.INSTALL_LOCATION_PROVIDER" /> - <uses-permission android:name="android.permission.INSTALL_PACKAGES" /> - <uses-permission android:name="android.permission.INTERNAL_SYSTEM_WINDOW" /> - <uses-permission android:name="android.permission.MANAGE_APP_TOKENS" /> - <uses-permission android:name="android.permission.MANAGE_NETWORK_POLICY" /> - <uses-permission android:name="android.permission.MANAGE_USB" /> - <uses-permission android:name="android.permission.MASTER_CLEAR" /> - <uses-permission android:name="android.permission.MODIFY_NETWORK_ACCOUNTING" /> - <uses-permission android:name="android.permission.MODIFY_PHONE_STATE" /> - <uses-permission android:name="android.permission.MOVE_PACKAGE" /> - <uses-permission android:name="android.permission.NET_ADMIN" /> - <uses-permission android:name="android.permission.MODIFY_PHONE_STATE" /> - <uses-permission android:name="android.permission.PACKAGE_USAGE_STATS" /> - <uses-permission android:name="android.permission.PACKAGE_VERIFICATION_AGENT" /> - <uses-permission android:name="android.permission.PERFORM_CDMA_PROVISIONING" /> - <uses-permission android:name="android.permission.READ_FRAME_BUFFER" /> - <uses-permission android:name="android.permission.READ_INPUT_STATE" /> - <uses-permission android:name="android.permission.READ_NETWORK_USAGE_HISTORY" /> - <uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE" /> - <uses-permission android:name="android.permission.REBOOT" /> - <uses-permission android:name="android.permission.RECEIVE_EMERGENCY_BROADCAST" /> - <uses-permission android:name="android.permission.REMOVE_TASKS" /> - <uses-permission android:name="android.permission.RETRIEVE_WINDOW_CONTENT" /> - <uses-permission android:name="android.permission.SEND_SMS_NO_CONFIRMATION" /> - <uses-permission android:name="android.permission.SET_ACTIVITY_WATCHER" /> - <uses-permission android:name="android.permission.SET_ORIENTATION" /> - <uses-permission android:name="android.permission.SET_POINTER_SPEED" /> - <uses-permission android:name="android.permission.SET_PREFERRED_APPLICATIONS" /> - <uses-permission android:name="android.permission.SET_SCREEN_COMPATIBILITY" /> - <uses-permission android:name="android.permission.SET_TIME" /> - <uses-permission android:name="android.permission.SET_WALLPAPER_COMPONENT" /> - <uses-permission android:name="android.permission.SHUTDOWN" /> - <uses-permission android:name="android.permission.STATUS_BAR" /> - <uses-permission android:name="android.permission.STATUS_BAR_SERVICE" /> - <uses-permission android:name="android.permission.STOP_APP_SWITCHES" /> - <uses-permission android:name="android.permission.UPDATE_DEVICE_STATS" /> - <uses-permission android:name="android.permission.WRITE_APN_SETTINGS" /> - <uses-permission android:name="android.permission.WRITE_GSERVICES" /> - <uses-permission android:name="android.permission.WRITE_MEDIA_STORAGE" /> - <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - <activity - android:label="@string/app_name" - android:name=".Foo2Activity" > - <intent-filter > - <action android:name="android.intent.action.MAIN" /> - - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - </application> - -</manifest>
\ No newline at end of file diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/protectedpermissions2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/protectedpermissions2.xml deleted file mode 100644 index d3b88da..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/protectedpermissions2.xml +++ /dev/null @@ -1,32 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:tools="http://schemas.android.com/tools" - package="foo.bar2" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="14" /> - - <!-- No warnings for these: --> - <uses-permission android:name="android.permission.GET_ACCOUNTS" /> - <uses-permission android:name="android.permission.SEND_SMS" /> - <uses-permission android:name="android.permission.INTERNET" /> - - <!-- Warnings for these: --> - <uses-permission android:name="android.intent.category.MASTER_CLEAR.permission.C2D_MESSAGE" tools:ignore="ProtectedPermissions" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - <activity - android:label="@string/app_name" - android:name=".Foo2Activity" > - <intent-filter > - <action android:name="android.intent.action.MAIN" /> - - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - </application> - -</manifest> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/AndroidManifest.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/AndroidManifest.xml deleted file mode 100644 index 0b07cdf..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/AndroidManifest.xml +++ /dev/null @@ -1,29 +0,0 @@ -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="test.pkg" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk - android:minSdkVersion="8" - android:targetSdkVersion="16" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" - android:theme="@style/AppTheme" > - <activity - android:name=".Foo$Bar" - android:label="@string/app_name" > - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - <activity - android:name=".Foo$Baz" - android:label="@string/app_name" > - </activity> - </application> - -</manifest> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/AndroidManifestInner.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/AndroidManifestInner.xml deleted file mode 100644 index 1b87d9d..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/AndroidManifestInner.xml +++ /dev/null @@ -1,25 +0,0 @@ -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="test.pkg.Foo" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk - android:minSdkVersion="8" - android:targetSdkVersion="16" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" - android:theme="@style/AppTheme" > - <activity - android:name=".Bar" - android:label="@string/app_name" > - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - </application> - -</manifest> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/AndroidManifestWrong.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/AndroidManifestWrong.xml deleted file mode 100644 index bfdcde0..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/AndroidManifestWrong.xml +++ /dev/null @@ -1,25 +0,0 @@ -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="test.pkg.Foo" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk - android:minSdkVersion="8" - android:targetSdkVersion="16" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" - android:theme="@style/AppTheme" > - <activity - android:name="test.pkg.Foo.Bar" - android:label="@string/app_name" > - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - </application> - -</manifest> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/AndroidManifestWrong2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/AndroidManifestWrong2.xml deleted file mode 100644 index 8773e0f..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/AndroidManifestWrong2.xml +++ /dev/null @@ -1,25 +0,0 @@ -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="test.pkg" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk - android:minSdkVersion="8" - android:targetSdkVersion="16" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" - android:theme="@style/AppTheme" > - <activity - android:name=".Foo.Bar" - android:label="@string/app_name" > - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - </application> - -</manifest> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/Bar.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/Bar.class.data Binary files differdeleted file mode 100644 index e51a0e8..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/Bar.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/Bar.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/Bar.java.txt deleted file mode 100644 index b514f11..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/Bar.java.txt +++ /dev/null @@ -1,8 +0,0 @@ -package test.pkg.Foo; - -import android.app.Activity; - -public class Bar extends Activity { - private Bar() { - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/Foo$Bar.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/Foo$Bar.class.data Binary files differdeleted file mode 100644 index da45ebb..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/Foo$Bar.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/Foo$Baz.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/Foo$Baz.class.data Binary files differdeleted file mode 100644 index aadd767..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/Foo$Baz.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/Foo.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/Foo.class.data Binary files differdeleted file mode 100644 index aafcc73..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/Foo.class.data +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/Foo.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/Foo.java.txt deleted file mode 100644 index a647030..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/Foo.java.txt +++ /dev/null @@ -1,10 +0,0 @@ -package test.pkg; - -import android.app.Activity; - -public class Foo { - public static class Bar extends Activity { - } - public class Baz extends Activity { - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-hdpi/appwidget_bg.9.png b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-hdpi/appwidget_bg.9.png Binary files differdeleted file mode 100644 index d9af8fb..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-hdpi/appwidget_bg.9.png +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-hdpi/appwidget_bg_focus.9.png b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-hdpi/appwidget_bg_focus.9.png Binary files differdeleted file mode 100644 index ee098af..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-hdpi/appwidget_bg_focus.9.png +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-hdpi/filled.png b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-hdpi/filled.png Binary files differdeleted file mode 100644 index 59fd90a..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-hdpi/filled.png +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-hdpi/ic_launcher.png b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-hdpi/ic_launcher.png Binary files differdeleted file mode 100644 index 8074c4c..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-hdpi/ic_launcher.png +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-hdpi/other.9.png b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-hdpi/other.9.png Binary files differdeleted file mode 100644 index d9af8fb..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-hdpi/other.9.png +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-hdpi/unrelated.png b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-hdpi/unrelated.png Binary files differdeleted file mode 100644 index 8074c4c..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-hdpi/unrelated.png +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-mdpi/frame.png b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-mdpi/frame.png Binary files differdeleted file mode 100644 index 840b2c2..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-mdpi/frame.png +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-mdpi/ic_menu_add_clip_normal.png b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-mdpi/ic_menu_add_clip_normal.png Binary files differdeleted file mode 100644 index 26f5afe..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-mdpi/ic_menu_add_clip_normal.png +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-mdpi/sample_icon.gif b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-mdpi/sample_icon.gif Binary files differdeleted file mode 100644 index 1a0be94..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-mdpi/sample_icon.gif +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-mdpi/sample_icon.jpg b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-mdpi/sample_icon.jpg Binary files differdeleted file mode 100644 index f872487..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-mdpi/sample_icon.jpg +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-mdpi/stat_notify_alarm.png b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-mdpi/stat_notify_alarm.png Binary files differdeleted file mode 100644 index c61626c..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-mdpi/stat_notify_alarm.png +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-nodpi/frame.png b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-nodpi/frame.png Binary files differdeleted file mode 100644 index 840b2c2..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-nodpi/frame.png +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-xlarge-nodpi-v11/frame.png b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-xlarge-nodpi-v11/frame.png Binary files differdeleted file mode 100644 index 840b2c2..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-xlarge-nodpi-v11/frame.png +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable/ic_launcher.png b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable/ic_launcher.png Binary files differdeleted file mode 100644 index a07c69f..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable/ic_launcher.png +++ /dev/null diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable/ic_menu_help.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable/ic_menu_help.xml deleted file mode 100644 index 41f840f..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable/ic_menu_help.xml +++ /dev/null @@ -1,5 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<bitmap xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:tools="http://schemas.android.com/tools" - android:src="@android:drawable/ic_menu_help" - tools:ignore="UnusedResources" /> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable/states.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable/states.xml deleted file mode 100644 index 3dedb64..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable/states.xml +++ /dev/null @@ -1,7 +0,0 @@ -<selector xmlns:android="http://schemas.android.com/apk/res/android"> - <item android:color="#ff000000"/> <!-- WRONG, SHOULD BE LAST --> - <item android:state_pressed="true" - android:color="#ffff0000"/> <!-- pressed --> - <item android:state_focused="true" - android:color="#ff0000ff"/> <!-- focused --> -</selector> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable/states2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable/states2.xml deleted file mode 100644 index dac176d..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable/states2.xml +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<selector xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res/com.domain.pkg"> -<item - app:mystate_custom="false" - android:drawable="@drawable/item" /> -</selector> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable/states3.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable/states3.xml deleted file mode 100644 index c3fc533..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable/states3.xml +++ /dev/null @@ -1,49 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2008 The Android Open Source Project - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> - -<selector xmlns:android="http://schemas.android.com/apk/res/android"> - <item android:state_checked="false" android:state_window_focused="false" - android:drawable="@drawable/btn_star_big_off" /> - <item android:state_checked="true" android:state_window_focused="false" - android:drawable="@drawable/btn_star_big_on" /> - <item android:state_checked="true" android:state_window_focused="false" - android:state_enabled="false" android:drawable="@drawable/btn_star_big_on_disable" /> - <item android:state_checked="false" android:state_window_focused="false" - android:state_enabled="false" android:drawable="@drawable/btn_star_big_off_disable" /> - - <item android:state_checked="true" android:state_pressed="true" - android:drawable="@drawable/btn_star_big_on_pressed" /> - <item android:state_checked="false" android:state_pressed="true" - android:drawable="@drawable/btn_star_big_off_pressed" /> - - <item android:state_checked="true" android:state_focused="true" - android:drawable="@drawable/btn_star_big_on_selected" /> - <item android:state_checked="false" android:state_focused="true" - android:drawable="@drawable/btn_star_big_off_selected" /> - - <item android:state_checked="true" android:state_focused="true" android:state_enabled="false" - android:drawable="@drawable/btn_star_big_on_disable_focused" /> - <item android:state_checked="true" android:state_focused="false" android:state_enabled="false" - android:drawable="@drawable/btn_star_big_on_disable" /> - - <item android:state_checked="false" android:state_focused="true" android:state_enabled="false" - android:drawable="@drawable/btn_star_big_off_disable_focused" /> - <item android:state_checked="false" android:state_focused="false" android:state_enabled="false" - android:drawable="@drawable/btn_star_big_off_disable" /> - - <item android:state_checked="false" android:drawable="@drawable/btn_star_big_off" /> - <item android:state_checked="true" android:drawable="@drawable/btn_star_big_on" /> -</selector>
\ No newline at end of file diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/accessibility.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/accessibility.xml deleted file mode 100644 index c00a880..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/accessibility.xml +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/newlinear" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> - <Button android:text="Button" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> - <ImageView android:id="@+id/android_logo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/android_button" android:focusable="false" android:clickable="false" android:layout_weight="1.0" /> - <ImageButton android:importantForAccessibility="yes" android:id="@+id/android_logo2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/android_button" android:focusable="false" android:clickable="false" android:layout_weight="1.0" /> - <Button android:text="Button" android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> - <Button android:id="@+android:id/summary" android:contentDescription="@string/label" /> - <ImageButton android:importantForAccessibility="no" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/android_button" android:focusable="false" android:clickable="false" android:layout_weight="1.0" /> -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/accessibility2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/accessibility2.xml deleted file mode 100644 index 3f45c26..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/accessibility2.xml +++ /dev/null @@ -1,12 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/newlinear" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> - <Button android:text="Button" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> - <ImageView android:id="@+id/android_logo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/android_button" android:focusable="false" android:clickable="false" android:layout_weight="1.0" /> - <ImageButton android:importantForAccessibility="yes" android:id="@+id/android_logo2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/android_button" android:focusable="false" android:clickable="false" android:layout_weight="1.0" /> - <Button android:text="Button" android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> - <Button android:id="@+android:id/summary" android:contentDescription="@string/label" /> - <ImageButton android:importantForAccessibility="no" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/android_button" android:focusable="false" android:clickable="false" android:layout_weight="1.0" /> - <EditText android:hint="@string/label" android:id="@+android:id/summary" android:contentDescription="@string/label" /> - <EditText android:id="@+android:id/summary" android:contentDescription="@string/label" /> - <EditText tools:ignore="ContentDescription" android:hint="@string/label" android:id="@+android:id/summary" android:contentDescription="@string/label" /> -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/activity_item_two_pane.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/activity_item_two_pane.xml deleted file mode 100644 index b19047a..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/activity_item_two_pane.xml +++ /dev/null @@ -1,37 +0,0 @@ -<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:attr/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/res/layout/baseline_weights.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/baseline_weights.xml deleted file mode 100644 index fa5a39a..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/baseline_weights.xml +++ /dev/null @@ -1,41 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:orientation="horizontal" > - - <LinearLayout - android:id="@+id/linearLayout1" - android:layout_weight="0.3" - android:layout_width="wrap_content" - android:layout_height="match_parent" - android:orientation="vertical" > - - - <Button - android:id="@+id/button1" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Button" /> - - <Button - android:id="@+id/button2" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Button" /> - - <Button - android:id="@+id/button3" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Button" /> - </LinearLayout> - - <FrameLayout - android:id="@+id/frameLayout1" - android:layout_weight="0.7" - android:layout_width="match_parent" - android:layout_height="match_parent" > - </FrameLayout> - -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/baseline_weights2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/baseline_weights2.xml deleted file mode 100644 index 2e4af6b..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/baseline_weights2.xml +++ /dev/null @@ -1,40 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:orientation="vertical" > - - <LinearLayout - android:id="@+id/linearLayout1" - android:layout_weight="0.3" - android:layout_width="wrap_content" - android:layout_height="match_parent" - android:orientation="vertical" > - - <Button - android:id="@+id/button1" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Button" /> - - <Button - android:id="@+id/button2" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Button" /> - - <Button - android:id="@+id/button3" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Button" /> - </LinearLayout> - - <FrameLayout - android:id="@+id/frameLayout1" - android:layout_weight="0.7" - android:layout_width="match_parent" - android:layout_height="match_parent" > - </FrameLayout> - -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/baseline_weights3.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/baseline_weights3.xml deleted file mode 100644 index 079bd24..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/baseline_weights3.xml +++ /dev/null @@ -1,39 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="match_parent" > - - <LinearLayout - android:id="@+id/linearLayout1" - android:layout_weight="0.3" - android:layout_width="wrap_content" - android:layout_height="match_parent" - android:orientation="vertical" > - - <Button - android:id="@+id/button1" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Button" /> - - <Button - android:id="@+id/button2" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Button" /> - - <Button - android:id="@+id/button3" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Button" /> - </LinearLayout> - - <FrameLayout - android:id="@+id/frameLayout1" - android:layout_weight="0.7" - android:layout_width="match_parent" - android:layout_height="match_parent" > - </FrameLayout> - -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/breadcrumbs_in_fragment.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/breadcrumbs_in_fragment.xml deleted file mode 100644 index 5e8824a..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/breadcrumbs_in_fragment.xml +++ /dev/null @@ -1,5 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="0dip" - android:layout_height="0dip" - android:visibility="gone" /> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/broken.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/broken.xml deleted file mode 100644 index 5dd9d2d..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/broken.xml +++ /dev/null @@ -1,8 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/newlinear" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> - <Button android:text="Button" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> - <ImageView android:id="@+id/android_logo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/android_button" android:focusable="false" android:clickable="false" android:layout_weight="1.0" /> - ImageButton android:id="@+id/android_logo2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/android_button" android:focusable="false" android:clickable="false" android:layout_weight="1.0" /> - <Button android:text="Button" android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> - <Button android:id="@+android:id/summary" android:contentDescription="@string/label" /> -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/buttonbar.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/buttonbar.xml deleted file mode 100644 index d02d49b..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/buttonbar.xml +++ /dev/null @@ -1,188 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:orientation="vertical" > - - <!-- Hardcoded strings, wrong order --> - <LinearLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" > - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="OK" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Cancel" /> - </LinearLayout> - - <!-- Hardcoded strings, right order --> - <LinearLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" > - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Cancel" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="OK" /> - </LinearLayout> - - <!-- @android:string resources, wrong order --> - <LinearLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" > - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@android:string/ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@android:string/cancel" /> - </LinearLayout> - - <!-- @android:string resources, right order --> - <LinearLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" > - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@android:string/cancel" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@android:string/ok" /> - </LinearLayout> - - <!-- @string/ok/cancel resources, right order --> - <LinearLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" > - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/cancel" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/ok" /> - </LinearLayout> - - <!-- @string/ok/cancel resources, wrong order --> - <LinearLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" > - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/cancel" /> - </LinearLayout> - - <!-- Random name resources, right order --> - <LinearLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" > - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/giveup" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/resume" /> - </LinearLayout> - - <!-- Random name resources, wrong order --> - <LinearLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" > - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/resume" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/giveup" /> - </LinearLayout> - - <!-- Random name resources with varying case, wrong order --> - <LinearLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" > - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/resume2" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/giveup2" /> - </LinearLayout> - - <!-- Resources with only one of OK and Cancel, wrong order --> - <LinearLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" > - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/abort" /> - </LinearLayout> - - <!-- Resources with only one of OK and Cancel, wrong order --> - <LinearLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" > - - <Button - android:layout_width="wrap_content" android:background="?android:attr/selectableItemBackground" - android:layout_height="wrap_content" - android:text="@string/send" /> - - <Button - android:layout_width="wrap_content" android:background="?android:attr/selectableItemBackground" - android:layout_height="wrap_content" - android:text="@string/cancel" /> - </LinearLayout> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/goback" /> - -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/buttonbar2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/buttonbar2.xml deleted file mode 100644 index f6ae19b..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/buttonbar2.xml +++ /dev/null @@ -1,52 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="wrap_content" - android:layout_height="wrap_content" > - - <ProgressBar - android:id="@+id/loading_progress" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignParentLeft="true" - android:layout_alignParentTop="true" - android:layout_marginBottom="60dip" - android:layout_marginLeft="40dip" - android:layout_marginTop="40dip" - android:max="10000" /> - - <TextView - android:id="@+id/text" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignParentTop="true" - android:layout_alignWithParentIfMissing="true" - android:layout_marginBottom="60dip" - android:layout_marginLeft="40dip" - android:layout_marginTop="40dip" - android:layout_toRightOf="@id/loading_progress" - android:ellipsize="end" - android:maxLines="3" - android:paddingRight="120dip" - android:text="@string/creating_instant_mix" - android:textAppearance="?android:attr/textAppearanceMedium" /> - - <Button - android:id="@+id/cancel" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignParentLeft="true" - android:layout_alignRight="@id/text" - android:layout_below="@id/text" - android:background="@null" - android:text="@string/cancel" /> - - <ImageView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_above="@id/cancel" - android:layout_alignLeft="@id/cancel" - android:layout_alignRight="@id/cancel" - android:scaleType="fitXY" - android:src="@drawable/menu_list_divider" /> - -</RelativeLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/buttonbar3.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/buttonbar3.xml deleted file mode 100644 index 8dbcb10..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/buttonbar3.xml +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:orientation="vertical" > - - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_gravity="center_horizontal" - android:text="@string/weekpicker_title" - android:textAppearance="?android:attr/textAppearanceMedium" /> - - <RelativeLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:background="#ffffff" - android:padding="6dip" > - - <Button - android:id="@+id/set" - android:layout_width="120dip" - android:layout_height="wrap_content" - android:layout_alignParentLeft="true" - android:text="@string/weekpicker_set" /> - - <Button - android:id="@+id/cancel" - android:layout_width="120dip" - android:layout_height="wrap_content" - android:layout_alignParentRight="true" - android:text="@string/cancel" /> - </RelativeLayout> - -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/buttonbar4.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/buttonbar4.xml deleted file mode 100644 index 9fe69d5..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/buttonbar4.xml +++ /dev/null @@ -1,55 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:visibility="gone" > - - <RatingBar - android:id="@+id/review_form_rating" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignParentRight="true" - android:numStars="5" - android:stepSize="1" /> - - <EditText - android:id="@+id/review_form_title" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignParentLeft="true" - android:layout_toLeftOf="@id/review_form_rating" - android:hint="@string/review_form_title_hint" - android:inputType="text|textCapSentences|textAutoCorrect" - android:lines="1" /> - - <EditText - android:id="@+id/review_form_review" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_below="@id/review_form_title" - android:gravity="top" - android:hint="@string/review_form_content_hint" - android:inputType="text|textCapSentences|textAutoCorrect|textMultiLine" - android:minLines="3" - android:singleLine="false" - android:visibility="gone" /> - - <Button - android:id="@+id/review_form_submit" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignParentRight="true" - android:layout_below="@id/review_form_review" - android:text="@string/submit" - android:visibility="gone" /> - - <Button - android:id="@+id/review_form_cancel" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_below="@id/review_form_review" - android:layout_toLeftOf="@id/review_form_submit" - android:text="@string/cancel" - android:visibility="gone" /> - -</RelativeLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/buttonbar_suppressed.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/buttonbar_suppressed.xml deleted file mode 100644 index a03824d..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/buttonbar_suppressed.xml +++ /dev/null @@ -1,43 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<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:orientation="vertical" > - - <!-- Hardcoded strings, wrong order --> - <LinearLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" > - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="OK" - tools:ignore="ButtonOrder" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Cancel" - tools:ignore="ButtonOrder" /> - </LinearLayout> - - <!-- @android:string resources, wrong order --> - <LinearLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" - tools:ignore="ButtonOrder" > - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@android:string/ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@android:string/cancel" /> - </LinearLayout> - -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/case.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/case.xml deleted file mode 100644 index 22e0eb6..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/case.xml +++ /dev/null @@ -1,24 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - ~ Copyright (C) 2013 The Android Open Source Project - ~ - ~ Licensed under the Apache License, Version 2.0 (the "License"); - ~ you may not use this file except in compliance with the License. - ~ You may obtain a copy of the License at - ~ - ~ http://www.apache.org/licenses/LICENSE-2.0 - ~ - ~ Unless required by applicable law or agreed to in writing, software - ~ distributed under the License is distributed on an "AS IS" BASIS, - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - ~ See the License for the specific language governing permissions and - ~ limitations under the License. - --> - -<Merge xmlns:android="http://schemas.android.com/apk/res/android" > - - <Fragment android:name="foo.bar.Fragment" /> - <Include layout="@layout/foo" /> - <RequestFocus /> - -</Merge> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/casts.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/casts.xml deleted file mode 100644 index 40f01ed..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/casts.xml +++ /dev/null @@ -1,19 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:orientation="vertical" > - - <Button - android:id="@+id/button" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Button" /> - - <EditText - android:id="@+id/edittext" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="EditText" /> - -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/casts2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/casts2.xml deleted file mode 100644 index 249c02f..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/casts2.xml +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- unit test from issue 27441 --> -<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="wrap_content" > - - <RadioGroup - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="vertical" > - - <RadioButton - android:id="@+id/additional" - android:layout_width="match_parent" - android:layout_height="wrap_content" /> - - <Spinner - android:id="@+id/reminder_lead" - android:layout_width="match_parent" - android:layout_height="wrap_content" /> - </RadioGroup> - -</ScrollView> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/casts3.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/casts3.xml deleted file mode 100644 index 990e5f0..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/casts3.xml +++ /dev/null @@ -1,19 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:orientation="vertical" > - - <RadioButton - android:id="@+id/button" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Button" /> - - <EditText - android:id="@+id/edittext" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="EditText" /> - -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/casts4.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/casts4.xml deleted file mode 100644 index 371964e..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/casts4.xml +++ /dev/null @@ -1,19 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:orientation="vertical" > - - <ToggleButton - android:id="@+id/button" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Button" /> - - <EditText - android:id="@+id/edittext" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="EditText" /> - -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/compound.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/compound.xml deleted file mode 100644 index f7b28ef..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/compound.xml +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> - -<LinearLayout - xmlns:android="http://schemas.android.com/apk/res/android" - - android:layout_width="match_parent" - android:layout_height="match_parent"> - - <ImageView - android:layout_width="wrap_content" - android:layout_height="wrap_content" /> - - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" /> - -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/compound2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/compound2.xml deleted file mode 100644 index 24f45dc..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/compound2.xml +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> - -<LinearLayout - xmlns:android="http://schemas.android.com/apk/res/android" - android:background="@android:drawable/ic_dialog_alert" - android:layout_width="match_parent" - android:layout_height="match_parent"> - - <ImageView - android:layout_width="wrap_content" - android:layout_height="wrap_content" /> - - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" /> - -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/compound3.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/compound3.xml deleted file mode 100644 index 68d42fa..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/compound3.xml +++ /dev/null @@ -1,18 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> - -<LinearLayout - xmlns:android="http://schemas.android.com/apk/res/android" - - android:layout_width="match_parent" - android:layout_height="match_parent"> - - <ImageView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:scaleType="fitStart" /> - - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" /> - -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/crcrlf.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/crcrlf.xml deleted file mode 100644 index d029725..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/crcrlf.xml +++ /dev/null @@ -1,14 +0,0 @@ -<RelativeLayout 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" >
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_centerHorizontal="true"
- android:layout_centerVertical="true"
- android:text="Hello"
- tools:context=".MainActivity" />
-
-</RelativeLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/crcrlf_ignore.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/crcrlf_ignore.xml deleted file mode 100644 index 680a765..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/crcrlf_ignore.xml +++ /dev/null @@ -1,19 +0,0 @@ -<RelativeLayout 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"
- tools:ignore="MangledCRLF" >
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_centerHorizontal="true"
- android:layout_centerVertical="true"
- android:text="@string/app_name"
- tools:context=".MainActivity" />
-
-
-
-
-
-</RelativeLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/customattrlayout.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/customattrlayout.xml deleted file mode 100644 index b4c49f0..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/customattrlayout.xml +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<foo.bar.ContentFrame - xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:foobar="http://schemas.android.com/apk/res/foo.bar" - android:layout_width="match_parent" - android:layout_height="match_parent" - foobar:contentId="@+id/test" /> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/customview.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/customview.xml deleted file mode 100644 index 976d636..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/customview.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:tools="http://schemas.android.com/tools" - xmlns:other="http://schemas.foo.bar.com/other" - xmlns:foo="http://schemas.android.com/apk/res/foo" - android:id="@+id/newlinear" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:orientation="vertical" > - - <foo.bar.Baz - android:id="@+id/button1" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Button1" - foo:misc="Custom attribute" - tools:ignore="HardcodedText" > - </foo.bar.Baz> - - <!-- Wrong namespace uri prefix: Don't warn --> - <foo.bar.Baz - android:id="@+id/button1" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Button1" - other:misc="Custom attribute" - tools:ignore="HardcodedText" > - </foo.bar.Baz> - -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/customview2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/customview2.xml deleted file mode 100644 index fcd43e6..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/customview2.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:tools="http://schemas.android.com/tools" - xmlns:other="http://schemas.foo.bar.com/other" - xmlns:foo="http://schemas.android.com/apk/res-auto" - android:id="@+id/newlinear" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:orientation="vertical" > - - <foo.bar.Baz - android:id="@+id/button1" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Button1" - foo:misc="Custom attribute" - tools:ignore="HardcodedText" > - </foo.bar.Baz> - -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/default_item_badges.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/default_item_badges.xml deleted file mode 100644 index 082a520..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/default_item_badges.xml +++ /dev/null @@ -1,5 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:id="@+id/video_badges" - android:layout_width="wrap_content" - android:layout_height="wrap_content" /> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/deprecation.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/deprecation.xml deleted file mode 100644 index 70b7f23..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/deprecation.xml +++ /dev/null @@ -1,29 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="match_parent" > - - <Button - android:id="@+id/button1" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_x="5dp" - android:layout_y="100dp" - android:text="Button" /> - - <!-- Deprecated attributes --> - <TextView - android:autoText="true" - android:capitalize="true" - android:editable="true" - android:enabled="true" - android:inputMethod="@+id/foo" - android:numeric="true" - android:password="true" - android:phoneNumber="true" - android:singleLine="true" /> - - <EditText android:editable="true" /> - <EditText android:editable="false" /> - -</AbsoluteLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/detailed_item.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/detailed_item.xml deleted file mode 100644 index a5d4226..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/detailed_item.xml +++ /dev/null @@ -1,12 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<RelativeLayout - xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="wrap_content" > - - <FrameLayout - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_below="@id/video_badges" /> - -</RelativeLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/duplicate.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/duplicate.xml deleted file mode 100644 index e142e9e..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/duplicate.xml +++ /dev/null @@ -1,8 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/newlinear" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> - <Button android:text="Button" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> - <ImageView android:id="@+id/android_logo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/android_button" android:focusable="false" android:clickable="false" android:layout_weight="1.0" /> - <ImageButton android:id="@+id/android_logo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/android_button" android:focusable="false" android:clickable="false" android:layout_weight="1.0" /> - <Button android:text="Button" android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> -</LinearLayout> - diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/edit_textview.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/edit_textview.xml deleted file mode 100644 index c0d8cda..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/edit_textview.xml +++ /dev/null @@ -1,94 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:orientation="vertical" > - - <!-- Various attributes that should be set on EditTexts, not TextViews --> - - <TextView - android:text="label" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:autoText="true" - android:bufferType="editable" - android:capitalize="words" - android:cursorVisible="true" - android:digits="" - android:editable="true" - android:editorExtras="@+id/foobar" - android:focusable="true" - android:focusableInTouchMode="true" - android:imeActionId="@+id/foo" - android:imeActionLabel="" - android:imeOptions="" - android:inputMethod="" - android:inputType="text" - android:numeric="" - android:password="true" - android:phoneNumber="true" - android:privateImeOptions="" /> - - <!-- Various attributes that should be set on EditTexts, not Buttons --> - - <Button - android:id="@+id/button" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:cursorVisible="true" /> - - <CheckedTextView - android:id="@+id/checkedTextView" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:cursorVisible="true" /> - - <CheckBox - android:id="@+id/checkbox" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:cursorVisible="true" /> - - <RadioButton - android:id="@+id/radioButton" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:cursorVisible="true" /> - - <ToggleButton - android:id="@+id/toggleButton" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:cursorVisible="true" /> - - - <!-- Ok #1 --> - - <TextView - android:text="label" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:bufferType="spannable" - android:freezesText="true" - android:editable="false" - android:inputType="none" /> - - <!-- Ok #2 --> - - <TextView - android:text="label" - android:layout_width="wrap_content" - android:layout_height="wrap_content" /> - - <TextView - android:id="@+id/dynamictext" - android:layout_width="wrap_content" - android:layout_height="wrap_content" /> - - <TextView - android:id="@+id/dynamictext" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:textIsSelectable="true" /> - -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/edit_type.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/edit_type.xml deleted file mode 100644 index 8f8cf90..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/edit_type.xml +++ /dev/null @@ -1,96 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:orientation="vertical" > - - <!-- Wrong: doesn't specify textPassword --> - - <EditText - android:id="@+id/mypassword" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:ems="10" - android:inputType="text" > - - <requestFocus /> - </EditText> - - <!-- OK, specifies textPassword: --> - - <EditText - android:id="@+id/password1" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:ems="10" - android:inputType="text|numberPassword" /> - - <!-- OK, specifies password: --> - - <EditText - android:id="@+id/password2" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:ems="10" - android:inputType="text" - android:password="true" /> - - <!-- Wrong, doesn't include number --> - - <EditText - android:id="@+id/password_length" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:ems="10" - android:inputType="text" /> - - <!-- Wrong, doesn't include URL --> - - <EditText - android:id="@+id/welcome_url" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:ems="10" - android:inputType="text" /> - - <!-- Wrong, doesn't include date --> - - <EditText - android:id="@+id/start_date" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:ems="10" - android:inputType="text" /> - - <!-- Wrong, doesn't include e-mail --> - - <EditText - android:id="@+id/email_address" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:ems="10" - android:inputType="text" /> - - <!-- Wrong, uses wrong password type for PIN --> - - <EditText - android:id="@+id/login_pin" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:ems="10" - android:inputType="textPassword" /> - - <EditText - android:id="@+id/number_of_items" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:ems="10" /> - - <EditText - style="@style/foo" - android:id="@+id/number_of_items" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:ems="10" /> - -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/encoding.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/encoding.xml deleted file mode 100644 index 390aec4..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/encoding.xml +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="iso-latin-1"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:orientation="vertical" > - -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/encoding2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/encoding2.xml deleted file mode 100644 index fe6e092..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/encoding2.xml +++ /dev/null @@ -1 +0,0 @@ -<?xml version="1.0" encoding="iso-latin-1"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>
\ No newline at end of file diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/fragment.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/fragment.xml deleted file mode 100644 index bec72b2..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/fragment.xml +++ /dev/null @@ -1,24 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:orientation="vertical" > - - <fragment - android:name="android.app.ListFragment" - android:layout_width="match_parent" - android:layout_height="wrap_content" /> - - <fragment - android:name="android.app.DialogFragment" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:tag="mytag" /> - - <fragment - android:id="@+id/fragment3" - android:name="android.preference.PreferenceFragment" - android:layout_width="match_parent" - android:layout_height="wrap_content" /> - -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/fragment2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/fragment2.xml deleted file mode 100644 index 3a672d1..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/fragment2.xml +++ /dev/null @@ -1,53 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<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:orientation="vertical" > - - <fragment - class="my.app.Fragment" - android:layout_width="match_parent" - android:layout_height="wrap_content" /> - - <view - class="my.app.MyView" - android:layout_width="match_parent" - android:layout_height="wrap_content" /> - - <fragment - android:name="my.app.Fragment2" - android:layout_width="match_parent" - android:layout_height="wrap_content" /> - - <view - android:name="test.pkg.TestService" - android:layout_width="match_parent" - android:layout_height="wrap_content" /> - - <view - class="test.pkg.TestService" - android:layout_width="match_parent" - android:layout_height="wrap_content" /> - - <fragment - android:name="test.pkg.TestService" - android:layout_width="match_parent" - android:layout_height="wrap_content" /> - - <fragment - class="test.pkg.TestService" - android:layout_width="match_parent" - android:layout_height="wrap_content" /> - - <fragment - class="test.pkg.Foo$Bar" - android:layout_width="match_parent" - android:layout_height="wrap_content" /> - - <fragment - class="test.pkg.Nonexistent" - android:layout_width="match_parent" - android:layout_height="wrap_content" - tools:ignore="MissingRegistered" /> - -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/gridlayout.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/gridlayout.xml deleted file mode 100644 index 026f673..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/gridlayout.xml +++ /dev/null @@ -1,41 +0,0 @@ -<!-- Copyright (C) 2010 The Android Open Source Project - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> - -<GridLayout - xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:columnCount="2" > - <Space - android:layout_row="0" - android:layout_column="0" - android:layout_width="109dip" - android:layout_height="108dip"/> - - <Button - android:text="Button 1" - android:layout_row="0" - android:layout_column="1" - /> - - <Button - android:text="Button 2" - android:layout_row="1" - android:layout_column="3" - /> - -</GridLayout> - - diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/has_children.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/has_children.xml deleted file mode 100644 index cac27d4..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/has_children.xml +++ /dev/null @@ -1,13 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> - -<ListView - xmlns:android="http://schemas.android.com/apk/res/android" - - android:layout_width="match_parent" - android:layout_height="match_parent"> - - <ListView - android:layout_width="match_parent" - android:layout_height="match_parent" /> - -</ListView>
\ No newline at end of file diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/has_children2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/has_children2.xml deleted file mode 100644 index bd8c301..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/has_children2.xml +++ /dev/null @@ -1,11 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> - -<ListView - xmlns:android="http://schemas.android.com/apk/res/android" - - android:layout_width="match_parent" - android:layout_height="match_parent"> - - <requestFocus/> - -</ListView> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/ignores.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/ignores.xml deleted file mode 100644 index d4be910..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/ignores.xml +++ /dev/null @@ -1,65 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:tools="http://schemas.android.com/tools" - android:id="@+id/newlinear" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:orientation="vertical" > - - <!-- Ignored via attribute, should be hidden --> - - <Button - android:id="@+id/button1" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Button1" - tools:ignore="HardcodedText" > - </Button> - - <!-- Inherited ignore from parent --> - - <LinearLayout - android:id="@+id/parent" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - tools:ignore="HardcodedText" > - - <Button - android:id="@+id/button2" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Button2" > - </Button> - </LinearLayout> - - <!-- Hardcoded text warning ignored through "all" --> - - <Button - android:id="@+id/button3" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Button3" - tools:ignore="all" > - </Button> - - <!-- Ignored through item in ignore list --> - - <Button - android:id="@+id/button4" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Hardcoded" - tools:ignore="NewApi,HardcodedText" > - </Button> - - <!-- Not ignored: should show up as a warning --> - - <Button - android:id="@+id/button5" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Hardcoded" - tools:ignore="Other" > - </Button> - -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/inefficient_weight.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/inefficient_weight.xml deleted file mode 100644 index 196e00b..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/inefficient_weight.xml +++ /dev/null @@ -1,60 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> - -<LinearLayout - xmlns:android="http://schemas.android.com/apk/res/android" - - android:layout_width="match_parent" - android:layout_height="match_parent"> - - <Button - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_weight="1.0" /> - - <LinearLayout - xmlns:android="http://schemas.android.com/apk/res/android" - - android:layout_width="match_parent" - android:layout_height="match_parent" - - android:orientation="vertical"> - - <Button - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_weight="1.0" /> - - </LinearLayout> - - <LinearLayout - xmlns:android="http://schemas.android.com/apk/res/android" - - android:layout_width="match_parent" - android:layout_height="match_parent" - - android:orientation="vertical"> - - <Button - android:layout_width="match_parent" - android:layout_height="0dip" - android:layout_weight="1.0" /> - - </LinearLayout> - - <LinearLayout - xmlns:android="http://schemas.android.com/apk/res/android" - style="@style/MyStyle" - android:layout_width="match_parent" - android:layout_height="match_parent"> - <Button - android:layout_width="match_parent" - android:layout_height="wrap_content" /> - - <Button - android:layout_width="match_parent" - android:layout_height="wrap_content" /> - - </LinearLayout> - - -</LinearLayout>
\ No newline at end of file diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/inefficient_weight2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/inefficient_weight2.xml deleted file mode 100644 index 0e7f396..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/inefficient_weight2.xml +++ /dev/null @@ -1,22 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<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"> - - <SeekBar - android:id="@+id/seekbar" - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:layout_gravity="center_vertical" - android:layout_weight="1" - android:max="100" - android:paddingBottom="10dip" - android:paddingLeft="15dip" - android:paddingRight="15dip" - android:paddingTop="10dip" - android:secondaryProgress="0" - tools:ignore="InefficientWeight" /> - -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/labelfor.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/labelfor.xml deleted file mode 100644 index 7d4935c..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/labelfor.xml +++ /dev/null @@ -1,84 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:orientation="vertical" > - - <TextView - android:id="@+id/textView1" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:labelFor="@+id/editText1" - android:text="Medium Text" - android:textAppearance="?android:attr/textAppearanceMedium" /> - - <EditText - android:id="@+id/editText1" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:ems="10" - android:inputType="textPersonName" > - - <requestFocus /> - </EditText> - - <TextView - android:id="@+id/textView2" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:labelFor="@+id/autoCompleteTextView1" - android:text="TextView" /> - - <AutoCompleteTextView - android:id="@+id/autoCompleteTextView1" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:ems="10" - android:text="AutoCompleteTextView" /> - - <TextView - android:id="@+id/textView3" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:labelFor="@+id/multiAutoCompleteTextView1" - android:text="Large Text" - android:textAppearance="?android:attr/textAppearanceLarge" /> - - <MultiAutoCompleteTextView - android:id="@+id/multiAutoCompleteTextView1" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:ems="10" - android:text="MultiAutoCompleteTextView" /> - - <EditText - android:id="@+id/editText2" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:ems="10" - android:inputType="textPostalAddress" /> - - <AutoCompleteTextView - android:id="@+id/autoCompleteTextView2" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:ems="10" - android:text="AutoCompleteTextView" /> - - <MultiAutoCompleteTextView - android:id="@+id/multiAutoCompleteTextView2" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:ems="10" - android:text="MultiAutoCompleteTextView" /> - - <EditText - android:id="@+id/editText20" - android:hint="Enter your address" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:ems="10" - android:inputType="textPostalAddress" /> - - -</LinearLayout>
\ No newline at end of file diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/labelfor_ignore.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/labelfor_ignore.xml deleted file mode 100644 index 41d2821..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/labelfor_ignore.xml +++ /dev/null @@ -1,16 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<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:orientation="vertical" > - - <EditText - android:id="@+id/editText2" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:ems="10" - android:inputType="textPostalAddress" - tools:ignore="LabelFor"/> - -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/layout1.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/layout1.xml deleted file mode 100644 index efd6be0..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/layout1.xml +++ /dev/null @@ -1,24 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:orientation="vertical" > - - <include - android:layout_width="wrap_content" - android:layout_height="wrap_content" - layout="@layout/layout2" /> - - <Button - android:id="@+id/button1" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Button" /> - - <Button - android:id="@+id/button2" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Button" /> - -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/layout1_ignore.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/layout1_ignore.xml deleted file mode 100644 index 13bd075..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/layout1_ignore.xml +++ /dev/null @@ -1,26 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<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:orientation="vertical" > - - <include - android:layout_width="wrap_content" - android:layout_height="wrap_content" - layout="@layout/layout2" - tools:ignore="DuplicateIncludedIds" /> - - <Button - android:id="@+id/button1" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Button" /> - - <Button - android:id="@+id/button2" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Button" /> - -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/layout2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/layout2.xml deleted file mode 100644 index 9fc9c5f..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/layout2.xml +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:orientation="vertical" > - - <RadioButton - android:id="@+id/radioButton1" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="RadioButton" /> - - <include - android:layout_width="wrap_content" - android:layout_height="wrap_content" - layout="@layout/layout3" /> - - <include - android:layout_width="wrap_content" - android:layout_height="wrap_content" - layout="@layout/layout4" /> - -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/layout3.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/layout3.xml deleted file mode 100644 index aa5a137..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/layout3.xml +++ /dev/null @@ -1,19 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:orientation="vertical" > - - <Button - android:id="@+id/button1" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Button" /> - - <CheckBox - android:id="@+id/checkBox1" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="CheckBox" /> - -</LinearLayout>
\ No newline at end of file diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/layout4.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/layout4.xml deleted file mode 100644 index 442efd4..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/layout4.xml +++ /dev/null @@ -1,19 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:orientation="vertical" > - - <Button - android:id="@+id/button1" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Button" /> - - <Button - android:id="@+id/button2" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Button" /> - -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/listseparator.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/listseparator.xml deleted file mode 100644 index ac50ff7..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/listseparator.xml +++ /dev/null @@ -1,3 +0,0 @@ -<TextView xmlns:android="http://schemas.android.com/apk/res/android" - android:id="@id/text1" - style="?android:attr/listSeparatorTextViewStyle" /> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/namespace.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/namespace.xml deleted file mode 100644 index a984333..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/namespace.xml +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:other="http://foo.bar" android:id="@+id/newlinear" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" orientation="true"> - <Button style="@style/setupWizardOuterFrame" android.text="Button" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> - <ImageView android:style="@style/bogus" android:id="@+id/android_logo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/android_button" android:focusable="false" android:clickable="false" android:layout_weight="1.0" /> - <LinearLayout other:orientation="horizontal"/> -</LinearLayout> - diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/namespace2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/namespace2.xml deleted file mode 100644 index 59001c2..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/namespace2.xml +++ /dev/null @@ -1,29 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout - xmlns:customprefix="http://schemas.android.com/apk/res/android" - xmlns:bogus="http://foo.com/bar" - customprefix:id="@+id/newlinear" - customprefix:layout_width="match_parent" - customprefix:layout_height="match_parent" - customprefix:orientation="vertical" - orientation="true"> - - <view class="foo.bar.LinearLayout"> - bogus:orientation="bogus" - </view> - - <foo.bar.LinearLayout - customprefix:id="@+id/newlinear2" - customprefix:layout_width="match_parent" - customprefix:layout_height="match_parent" - customprefix:orientation="vertical" - bogus:orientation="bogus" - orientation="true"> - - <view class="foo.bar.LinearLayout"> - bogus:orientation="bogus" - </view> - - </foo.bar.LinearLayout> - -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/namespace3.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/namespace3.xml deleted file mode 100644 index fcc5aa4..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/namespace3.xml +++ /dev/null @@ -1,17 +0,0 @@ -<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res/com.example.apicalltest" - android:layout_width="match_parent" - android:layout_height="match_parent" > - - <com.example.library.MyView - android:layout_width="300dp" - android:layout_height="300dp" - android:background="#ccc" - android:paddingBottom="40dp" - android:paddingLeft="20dp" - app:exampleColor="#33b5e5" - app:exampleDimension="24sp" - app:exampleDrawable="@android:drawable/ic_menu_add" - app:exampleString="Hello, MyView" /> - -</FrameLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/namespace4.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/namespace4.xml deleted file mode 100644 index e7ecb06..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/namespace4.xml +++ /dev/null @@ -1,18 +0,0 @@ -<android.support.v7.widget.GridLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:tools="http://schemas.android.com/tools" - xmlns:app="http://schemas.android.com/apk/res/com.example.apicalltest" - android:layout_width="match_parent" - android:layout_height="match_parent" - app:columnCount="1" - tools:context=".MainActivity" > - - <Button - android:id="@+id/button1" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - app:layout_column="0" - app:layout_gravity="center" - app:layout_row="0" - android:text="Button" /> - -</android.support.v7.widget.GridLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/nested_weights.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/nested_weights.xml deleted file mode 100644 index a375e06..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/nested_weights.xml +++ /dev/null @@ -1,40 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:orientation="horizontal" > - - <Button - android:id="@+id/button1" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Button" /> - - <LinearLayout - android:id="@+id/linearLayout1" - android:layout_weight="1" - android:layout_width="match_parent" - android:layout_height="match_parent" > - - <Button - android:id="@+id/button3" - android:layout_width="0dp" - android:layout_height="wrap_content" - android:layout_weight="1" - android:text="Button" /> - </LinearLayout> - - <FrameLayout - android:id="@+id/frameLayout1" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_weight="1" > - - <Button - android:id="@+id/button2" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Button" /> - </FrameLayout> - -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/nested_weights2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/nested_weights2.xml deleted file mode 100644 index 7002b89..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/nested_weights2.xml +++ /dev/null @@ -1,38 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="fill_parent" - android:layout_height="fill_parent" > - - <LinearLayout - android:layout_width="fill_parent" - android:layout_height="fill_parent" - android:orientation="vertical" > - - <LinearLayout - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:orientation="horizontal" > - - <ImageView - android:layout_width="32dp" - android:layout_height="32dp" - android:layout_gravity="center_vertical" - android:src="@drawable/launcher_icon" /> - - <TextView - android:layout_width="0dp" - android:layout_height="fill_parent" - android:layout_gravity="center_vertical" - android:layout_weight="1" - android:text="test" /> - </LinearLayout> - - <LinearLayout - android:layout_width="fill_parent" - android:layout_weight="1" - android:layout_height="0dp" - android:orientation="vertical" > - </LinearLayout> - </LinearLayout> - -</FrameLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/note_edit.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/note_edit.xml deleted file mode 100644 index 0b84439..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/note_edit.xml +++ /dev/null @@ -1,78 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:orientation="vertical" - android:layout_width="fill_parent" - android:layout_height="fill_parent"> - <include layout="@layout/colorstrip" android:layout_height="@dimen/colorstrip_height" android:layout_width="match_parent"/> - - <LinearLayout style="@style/TitleBar" android:id="@+id/header"> - <ImageView style="@style/TitleBarLogo" - android:contentDescription="@string/description_logo" - android:src="@drawable/title_logo" /> - - <View style="@style/TitleBarSpring" /> - - <ImageView style="@style/TitleBarSeparator" /> - <ImageButton style="@style/TitleBarAction" - android:id="@+id/btn_title_refresh" - android:contentDescription="@string/description_refresh" - android:src="@drawable/ic_title_refresh" - android:layout_width="wrap_content" - android:layout_height="42dp" - android:onClick="onRefreshClick" /> - <ProgressBar style="@style/TitleBarProgressIndicator" - android:id="@+id/title_refresh_progress" - android:layout_width="wrap_content" - android:visibility="visible"/> - - <ImageView style="@style/TitleBarSeparator" /> - <ImageButton style="@style/TitleBarAction" - android:contentDescription="@string/description_search" - android:src="@drawable/ic_title_search" - android:layout_width="wrap_content" - android:layout_height="42dp" - android:onClick="onSearchClick" /> - </LinearLayout> - - <LinearLayout - android:id="@+id/noteArea" - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:layout_weight="1" - android:layout_margin="5dip"> - <EditText - android:id="@android:id/text1" - android:layout_height="fill_parent" - android:hint="@string/note_hint" - android:freezesText="true" - android:gravity="top" android:layout_width="wrap_content" android:layout_weight="1"> - </EditText> - <EditText - android:id="@android:id/text2" - android:layout_height="fill_parent" - android:freezesText="true" - android:gravity="top" android:layout_width="wrap_content" android:layout_weight="1"> - <requestFocus /> - </EditText> - </LinearLayout> - - <LinearLayout - android:orientation="horizontal" - android:layout_width="fill_parent" - android:layout_height="wrap_content" - style="@android:style/ButtonBar"> - <Button - android:layout_width="0dip" - android:layout_height="wrap_content" - android:layout_weight="1" - android:onClick="onSaveClick" - android:text="@string/note_save" /> - <Button - android:layout_width="0dip" - android:layout_height="wrap_content" - android:layout_weight="1" - android:onClick="onDiscardClick" - android:text="@string/note_discard" /> - </LinearLayout> - -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/now_playing_after.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/now_playing_after.xml deleted file mode 100644 index 64f681c..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/now_playing_after.xml +++ /dev/null @@ -1,53 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:id="@+id/now_playing" - android:layout_width="fill_parent" - android:layout_height="@dimen/now_playing_height" - android:orientation="horizontal"> - <LinearLayout - android:background="@color/background2" - android:paddingLeft="14dip" - android:paddingRight="14dip" - android:paddingTop="10dip" - android:paddingBottom="10dip" - android:layout_width="fill_parent" - android:layout_height="fill_parent" - android:layout_weight="1" - android:orientation="vertical"> - <TextView - android:id="@+id/now_playing_title" - android:duplicateParentState="true" - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:textStyle="bold" - android:textSize="@dimen/text_size_large" - android:textColor="@color/foreground1" - android:text="@string/now_playing_after_title" - android:maxLines="2" - android:ellipsize="end" /> - <TextView - android:id="@+id/now_playing_subtitle" - android:duplicateParentState="true" - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:paddingTop="3dip" - android:textColor="@color/foreground2" - android:textSize="@dimen/text_size_small" - android:text="@string/now_playing_after_subtitle" - android:singleLine="true" - android:ellipsize="end" /> - </LinearLayout> - <View - android:layout_width="1px" - android:layout_height="fill_parent" - android:background="@android:color/white" /> - <ImageButton - android:background="@drawable/btn_now_playing_more" - android:id="@+id/now_playing_more" - android:src="@drawable/ic_now_playing_logo" - android:padding="12dip" - android:layout_width="100mm" - android:layout_height="120in" - android:onClick="onNowPlayingLogoClick" - android:scaleType="center" /> -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/onclick.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/onclick.xml deleted file mode 100644 index 882c035..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/onclick.xml +++ /dev/null @@ -1,79 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:orientation="vertical" > - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:onClick="nonexistent" - android:text="Button" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:onClick="wrong1" - android:text="Button" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:onClick="wrong2" - android:text="Button" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:onClick="wrong3" - android:text="Button" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:onClick="wrong4" - android:text="Button" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:onClick="wrong5" - android:text="Button" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:onClick="wrong6" - android:text="Button" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:onClick="ok" - android:text="Button" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:onClick="simple_typo" - android:text="Button" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:onClick="my\u1234method" - android:text="Button" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:onClick="wrong7" - android:text="Button" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:onClick="@string/ok" - android:text="Button" /> - -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/private.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/private.xml deleted file mode 100644 index c98797d..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/private.xml +++ /dev/null @@ -1,4 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/newlinear" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> - <ImageView android:id="@+id/android_logo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@*android:drawable/android_button" android:focusable="false" android:clickable="false" /> -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/scrolling.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/scrolling.xml deleted file mode 100644 index 0bed702..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/scrolling.xml +++ /dev/null @@ -1,19 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> - -<ScrollView - xmlns:android="http://schemas.android.com/apk/res/android" - - android:layout_width="match_parent" - android:layout_height="match_parent"> - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="match_parent"> - - <ListView - android:layout_width="match_parent" - android:layout_height="match_parent" /> - - </LinearLayout> - -</ScrollView> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/simple.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/simple.xml deleted file mode 100644 index d462c69..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/simple.xml +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> - -<FrameLayout - xmlns:android="http://schemas.android.com/apk/res/android" - - android:layout_width="match_parent" - android:layout_height="match_parent" /> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/simple_ignore.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/simple_ignore.xml deleted file mode 100644 index 1b3de90..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/simple_ignore.xml +++ /dev/null @@ -1,8 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> - -<FrameLayout - 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" - tools:ignore="MergeRootFrame" /> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/simpleinclude.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/simpleinclude.xml deleted file mode 100644 index 4cb994b..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/simpleinclude.xml +++ /dev/null @@ -1,24 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:orientation="vertical" > - - <include - android:layout_width="wrap_content" - android:layout_height="wrap_content" - layout="@layout/simple" /> - - <Button - android:id="@+id/button1" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Button" /> - - <Button - android:id="@+id/button2" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Button" /> - -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/size.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/size.xml deleted file mode 100644 index e4d4a9b..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/size.xml +++ /dev/null @@ -1,27 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:orientation="vertical" > - - <RadioButton - android:id="@+id/button" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Button" /> - - <RadioButton - android:id="@+id/button2" - android:layout_width="wrap_content" - android:text="Button" /> - - <EditText - android:id="@+id/edittext" - android:layout_height="wrap_content" - android:text="EditText" /> - - <EditText - android:id="@+id/edittext2" - android:text="EditText" /> - -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/size2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/size2.xml deleted file mode 100644 index d06d00f..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/size2.xml +++ /dev/null @@ -1,43 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<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:orientation="vertical" - tools:ignore="HardcodedText" > - - <Button - android:id="@+id/button1" - android:text="Button" /> - - <Button - android:id="@+id/button2" - style="@style/WidthAndHeight" - android:text="Button" /> - - <Button - android:id="@+id/button3" - style="@style/Width" - android:text="Button" /> - - <Button - android:id="@+id/button4" - style="@style/MyStyle" - android:text="Button" /> - - <Button - android:id="@+id/button5" - style="@style/MyStyle.Big" - android:text="Button" /> - - <Button - android:id="@+id/button6" - style="@style/MyOtherStyle" - android:text="Button" /> - - <include - android:layout_width="match_parent" - android:layout_height="match_parent" - layout="@layout/sizeincluded" /> - -</LinearLayout>
\ No newline at end of file diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/sizeincluded.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/sizeincluded.xml deleted file mode 100644 index 5fccff6..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/sizeincluded.xml +++ /dev/null @@ -1,5 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:orientation="vertical" > - -</LinearLayout>
\ No newline at end of file diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/textsize.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/textsize.xml deleted file mode 100644 index 610867e..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/textsize.xml +++ /dev/null @@ -1,51 +0,0 @@ -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:tools="http://schemas.android.com/tools" - android:id="@+id/LinearLayout1" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:orientation="vertical" > - - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:textSize="14dp" /> - - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:textSize="14dip" /> - - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:textSize="14sp" /> - - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:textSize="@android/dimen/mysizedp" /> - - <!-- Small --> - - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:textSize="11sp" /> - - <ImageView - android:layout_width="wrap_content" - android:layout_height="6sp" /> - - <!-- No warnings: wrong attribute, size == 0, etc --> - - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:textSize="0sp" /> - - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:marginTop="5sp" /> - -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/too_deep.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/too_deep.xml deleted file mode 100644 index 7e92008..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/too_deep.xml +++ /dev/null @@ -1,85 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> - -<LinearLayout - xmlns:android="http://schemas.android.com/apk/res/android" - - android:layout_width="match_parent" - android:layout_height="match_parent"> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="match_parent"> - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="match_parent"> - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="match_parent"> - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="match_parent"> - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="match_parent"> - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="match_parent"> - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="match_parent"> - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="match_parent"> - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="match_parent"> - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="match_parent"> - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="match_parent"> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - </LinearLayout> - - </LinearLayout> - - </LinearLayout> - - </LinearLayout> - - </LinearLayout> - - </LinearLayout> - - </LinearLayout> - - </LinearLayout> - - </LinearLayout> - - </LinearLayout> - - </LinearLayout> - -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/too_many.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/too_many.xml deleted file mode 100644 index e2dbd6b..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/too_many.xml +++ /dev/null @@ -1,413 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> - -<FrameLayout - xmlns:android="http://schemas.android.com/apk/res/android" - - android:layout_width="match_parent" - android:layout_height="match_parent"> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="match_parent"> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="match_parent"> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - </LinearLayout> - - </LinearLayout> - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="match_parent"> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="match_parent"> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Ok" /> - - </LinearLayout> - - </LinearLayout> - -</FrameLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/unused_namespace.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/unused_namespace.xml deleted file mode 100644 index f633e4b..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/unused_namespace.xml +++ /dev/null @@ -1,14 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<foo.bar.LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:unused1="http://schemas.android.com/apk/res/unused1" - xmlns:unused2="http://schemas.android.com/apk/res/unused1" - xmlns:unused3="http://foo.bar.com/foo" - xmlns:notunused="http://schemas.android.com/apk/res/notunused" - xmlns:tools="http://schemas.android.com/tools" > - - <foo.bar.Button - notunused:foo="Foo" - tools:ignore="HardcodedText" > - </foo.bar.Button> - -</foo.bar.LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/useless.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/useless.xml deleted file mode 100644 index c317235..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/useless.xml +++ /dev/null @@ -1,89 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<merge xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="match_parent" > - - <!-- Neither parent nor child define background: delete is okay --> - - <FrameLayout - android:id="@+id/LinearLayout" - android:layout_width="match_parent" - android:layout_height="match_parent" > - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="match_parent" > - - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" /> - </LinearLayout> - </FrameLayout> - - <!-- Both define background: cannot be deleted --> - - <FrameLayout - android:layout_width="match_parent" - android:layout_height="match_parent" - android:background="@drawable/bg" > - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="match_parent" - android:background="@drawable/bg" > - - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" /> - </LinearLayout> - </FrameLayout> - - <!-- Only child defines background: delete is okay --> - - <FrameLayout - android:layout_width="match_parent" - android:layout_height="match_parent" > - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="match_parent" - android:background="@drawable/bg" > - - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" /> - </LinearLayout> - </FrameLayout> - - <!-- Only parent defines background: delete is okay --> - - <FrameLayout - android:layout_width="match_parent" - android:layout_height="match_parent" - android:background="@drawable/bg" > - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="match_parent" > - - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" /> - </LinearLayout> - </FrameLayout> - - <!-- Leaf cannot be deleted because it has a background --> - - <FrameLayout - android:layout_width="match_parent" - android:layout_height="match_parent" - android:background="@drawable/bg" > - </FrameLayout> - - <!-- Useless leaf --> - - <FrameLayout - android:layout_width="match_parent" - android:layout_height="match_parent" > - </FrameLayout> -</merge> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/useless2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/useless2.xml deleted file mode 100644 index a819036..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/useless2.xml +++ /dev/null @@ -1,26 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<TabHost xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="match_parent" > - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="match_parent" - android:orientation="vertical" > - - <TabWidget - android:layout_width="match_parent" - android:layout_height="wrap_content" /> - - <FrameLayout - android:layout_width="match_parent" - android:layout_height="0px" - android:layout_weight="1" > - - <Button - android:layout_width="wrap_content" - android:layout_height="wrap_content" /> - </FrameLayout> - </LinearLayout> - -</TabHost> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/useless3.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/useless3.xml deleted file mode 100644 index 1d9e9b7..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/useless3.xml +++ /dev/null @@ -1,5 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<TableRow - xmlns:android="http://schemas.android.com/apk/res/android" - style="@style/keyboard_table_row"> -</TableRow> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrong0dp.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrong0dp.xml deleted file mode 100644 index 136329f..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrong0dp.xml +++ /dev/null @@ -1,103 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<FrameLayout 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:orientation="vertical" - tools:ignore="HardcodedText" > - - <!-- Vertical Layout --> - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="match_parent" - android:orientation="vertical" > - - <!-- No weight: Always an error --> - - <Button - android:layout_width="0dp" - android:layout_height="wrap_content" - android:text="Button" /> - - <Button - android:layout_width="wrap_content" - android:layout_height="0dp" - android:text="Button" /> - - <!-- - 0dp not along the orientation axis is wrong; - here layout_height is okay, layout_width is not - --> - - <Button - android:layout_width="0dp" - android:layout_height="wrap_content" - android:layout_weight="1.0" - android:text="Button" /> - - <!-- OK --> - - <Button - android:layout_width="wrap_content" - android:layout_height="0dp" - android:layout_weight="1.0" - android:text="Button" /> - </LinearLayout> - - <!-- Horizontal Layout --> - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="match_parent" - android:orientation="horizontal" > - - <!-- OK --> - - <Button - android:layout_width="0dp" - android:layout_height="wrap_content" - android:layout_weight="1.0" - android:text="Button" /> - - <!-- Not OK --> - - <Button - android:layout_width="wrap_content" - android:layout_height="0dp" - android:layout_weight="1.0" - android:text="Button" /> - </LinearLayout> - - <!-- No orientation specified, so horizontal --> - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="match_parent" > - - <!-- OK --> - - <Button - android:layout_width="0dp" - android:layout_height="wrap_content" - android:layout_weight="1.0" - android:text="Button" /> - - <!-- Not OK --> - - <Button - android:layout_width="wrap_content" - android:layout_height="0dp" - android:layout_weight="1.0" - android:text="Button" /> - - <!-- Check suppressed --> - - <Button - android:layout_width="0dp" - android:layout_height="wrap_content" - android:text="Button" - tools:ignore="Suspicious0dp" /> - </LinearLayout> - -</FrameLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrong_dimension.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrong_dimension.xml deleted file mode 100644 index 79b922b..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrong_dimension.xml +++ /dev/null @@ -1,13 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> - -<HorizontalScrollView - xmlns:android="http://schemas.android.com/apk/res/android" - - android:layout_width="match_parent" - android:layout_height="match_parent"> - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="match_parent" /> - -</HorizontalScrollView> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrong_namespace.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrong_namespace.xml deleted file mode 100644 index c6e2143..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrong_namespace.xml +++ /dev/null @@ -1,24 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/andriod" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:orientation="vertical" > - - <include - android:layout_width="wrap_content" - android:layout_height="wrap_content" - layout="@layout/layout2" /> - - <Button - android:id="@+id/button1" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Button" /> - - <Button - android:id="@+id/button2" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Button" /> - -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrong_namespace2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrong_namespace2.xml deleted file mode 100644 index 49dc611..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrong_namespace2.xml +++ /dev/null @@ -1,24 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/Android" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:orientation="vertical" > - - <include - android:layout_width="wrap_content" - android:layout_height="wrap_content" - layout="@layout/layout2" /> - - <Button - android:id="@+id/button1" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Button" /> - - <Button - android:id="@+id/button2" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Button" /> - -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrong_namespace3.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrong_namespace3.xml deleted file mode 100644 index 02252b4..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrong_namespace3.xml +++ /dev/null @@ -1,24 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:a="http://schemas.android.com/apk/res/androi" - a:layout_width="match_parent" - a:layout_height="match_parent" - a:orientation="vertical" > - - <include - a:layout_width="wrap_content" - a:layout_height="wrap_content" - layout="@layout/layout2" /> - - <Button - a:id="@+id/button1" - a:layout_width="wrap_content" - a:layout_height="wrap_content" - a:text="Button" /> - - <Button - a:id="@+id/button2" - a:layout_width="wrap_content" - a:layout_height="wrap_content" - a:text="Button" /> - -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrong_namespace4.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrong_namespace4.xml deleted file mode 100644 index 4142622..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrong_namespace4.xml +++ /dev/null @@ -1,27 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- This file does *not* have a wrong namespace: it's testdata to make sure we don't complain when "a" is defined for something unrelated --> -<LinearLayout - xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:a="http://something/very/different" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:orientation="vertical" > - - <include - android:layout_width="wrap_content" - android:layout_height="wrap_content" - layout="@layout/layout2" /> - - <Button - android:id="@+id/button1" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Button" /> - - <Button - android:id="@+id/button2" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Button" /> - -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrong_namespace5.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrong_namespace5.xml deleted file mode 100644 index ce0fc4b..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrong_namespace5.xml +++ /dev/null @@ -1,10 +0,0 @@ -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:noturi="tp://schems.android.com/apk/res/com.my.package" - xmlns:typo1="http://schems.android.com/apk/res/com.my.package" - xmlns:typo2="http://schems.android.comm/apk/res/com.my.package" - xmlns:ok="http://foo.bar/res/unrelated" - xmlns:tools="http://schemas.android.com/tools" - android:layout_width="match_parent" - android:layout_height="match_parent" > - -</RelativeLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrongparams.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrongparams.xml deleted file mode 100644 index 9c8bd5c..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrongparams.xml +++ /dev/null @@ -1,88 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:orientation="vertical" > - - <Button - android:id="@+id/button2" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_weight="1" - android:text="Button" /> - - <LinearLayout - android:id="@+id/relativeLayout1" - android:layout_width="match_parent" - android:layout_height="wrap_content" > - - <Button - android:id="@+id/button1" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignParentLeft="true" - android:layout_alignParentTop="true" - android:layout_marginLeft="17dp" - android:layout_marginTop="16dp" - android:text="Button" /> - - <TextView - android:id="@+id/textView1" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignBottom="@+id/button1" - android:layout_toRightOf="@+id/button1" - android:text="Medium Text" - android:textAppearance="?android:attr/textAppearanceMedium" /> - - <RadioButton - android:id="@+id/radioButton1" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignLeft="@+id/button1" - android:layout_below="@+id/button1" - android:text="RadioButton" /> - </LinearLayout> - <TableLayout - android:id="@+id/tableLayout1" - android:layout_width="match_parent" - android:layout_height="match_parent" > - - <TableRow - android:id="@+id/tableRow1" - android:layout_width="wrap_content" - android:layout_height="wrap_content" > - - <Button - android:id="@+id/button3" - android:layout_column="0" - android:layout_span="1" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_weight="1" - android:text="Button" /> - </TableRow> - - <Button - android:id="@+id/button4" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_weight="1" - android:text="Button" /> - </TableLayout> - - <GridLayout - android:id="@+id/gridLayout1" - android:layout_width="match_parent" - android:layout_height="match_parent" > - - <Button - android:id="@+id/button10" - android:layout_column="0" - android:layout_row="0" - android:layout_width="wrap_content" - android:layout_height="wrap_content" /> - </GridLayout> - -</FrameLayout> - diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrongparams2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrongparams2.xml deleted file mode 100644 index 309dffd..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrongparams2.xml +++ /dev/null @@ -1,15 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<merge xmlns:android="http://schemas.android.com/apk/res/android" > - - <foo.bar.ActionBarHost - android:layout_width="fill_parent" - android:layout_height="fill_parent" - android:orientation="vertical" > - - <FrameLayout - android:layout_width="fill_parent" - android:layout_height="0dp" - android:layout_weight="1" /> - </foo.bar.ActionBarHost> - -</merge> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrongparams3.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrongparams3.xml deleted file mode 100644 index 79173c7..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrongparams3.xml +++ /dev/null @@ -1,13 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:layout_alignParentTop="true" > - - <Button - android:id="@+id/button1" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Button" /> - -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrongparams4.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrongparams4.xml deleted file mode 100644 index 802e215..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrongparams4.xml +++ /dev/null @@ -1,13 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:orientation="vertical" > - - <include - android:id="@+id/include1" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - layout="@layout/wrongparams3" /> - -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrongparams5.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrongparams5.xml deleted file mode 100644 index 947bf48..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrongparams5.xml +++ /dev/null @@ -1,18 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<merge xmlns:android="http://schemas.android.com/apk/res/android" > - - <Button - android:id="@+id/button1" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignParentTop="true" - android:text="Button" /> - - <Button - android:id="@+id/button2" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignParentLeft="true" - android:text="Button" /> - -</merge> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrongparams6.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrongparams6.xml deleted file mode 100644 index 8691d7c..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrongparams6.xml +++ /dev/null @@ -1,13 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:orientation="vertical" > - - <include - android:id="@+id/include1" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - layout="@layout/wrongparams5" /> - -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrongparams_ignore.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrongparams_ignore.xml deleted file mode 100644 index d0e6ff0..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrongparams_ignore.xml +++ /dev/null @@ -1,92 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<FrameLayout 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:orientation="vertical" > - - <Button - android:id="@+id/button2" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_weight="1" - android:text="Button" /> - - <LinearLayout - android:id="@+id/relativeLayout1" - android:layout_width="match_parent" - android:layout_height="wrap_content" > - - <Button - android:id="@+id/button1" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignParentLeft="true" - android:layout_alignParentTop="true" - android:layout_marginLeft="17dp" - android:layout_marginTop="16dp" - android:text="Button" - tools:ignore="all" /> - - <TextView - android:id="@+id/textView1" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignBottom="@+id/button1" - android:layout_toRightOf="@+id/button1" - android:text="Medium Text" - android:textAppearance="?android:attr/textAppearanceMedium" - tools:ignore="ObsoleteLayoutParam" /> - - <RadioButton - android:id="@+id/radioButton1" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignLeft="@+id/button1" - android:layout_below="@+id/button1" - android:text="RadioButton" - tools:ignore="ObsoleteLayoutParam" /> - </LinearLayout> - <TableLayout - android:id="@+id/tableLayout1" - android:layout_width="match_parent" - android:layout_height="match_parent" > - - <TableRow - android:id="@+id/tableRow1" - android:layout_width="wrap_content" - android:layout_height="wrap_content" > - - <Button - android:id="@+id/button3" - android:layout_column="0" - android:layout_span="1" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_weight="1" - android:text="Button" /> - </TableRow> - - <Button - android:id="@+id/button4" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_weight="1" - android:text="Button" /> - </TableLayout> - - <GridLayout - android:id="@+id/gridLayout1" - android:layout_width="match_parent" - android:layout_height="match_parent" > - - <Button - android:id="@+id/button10" - android:layout_column="0" - android:layout_row="0" - android:layout_width="wrap_content" - android:layout_height="wrap_content" /> - </GridLayout> - -</FrameLayout> - diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/menu-land/actions.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/menu-land/actions.xml deleted file mode 100644 index 89fa751..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/menu-land/actions.xml +++ /dev/null @@ -1,62 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<menu xmlns:android="http://schemas.android.com/apk/res/android"> - - <item - android:id="@+id/menu_search" - android:showAsAction="always|collapseActionView" - android:actionViewClass="android.widget.SearchView" /> - - <group android:id="@+id/reader_items"> - - <item - android:id="@+id/menu_table_of_contents" - android:showAsAction="always" - android:actionLayout="@layout/action_table_of_contents" /> - - <item - android:id="@+id/menu_settings" - android:showAsAction="always" /> - - <item android:id="@+id/menu_mode" - android:showAsAction="never" /> - - <item - android:id="@+id/menu_buy" - android:showAsAction="never" /> - - <item - android:id="@+id/menu_about" - android:showAsAction="never" /> - - <item - android:id="@+id/menu_share" - android:showAsAction="never" /> - - <item - android:id="@+id/menu_keep" - android:checkable="true" - android:showAsAction="never" /> - - <item - android:id="@+id/menu_d" - android:showAsAction="never" /> - - <item - android:id="@+id/menu_help" - android:showAsAction="never" /> - - </group> - - <group android:id="@+id/search_items"> - - <item - android:id="@+id/menu_table_of_contents" - android:showAsAction="always" - android:actionLayout="@layout/action_table_of_contents" /> - - <item android:id="@+id/menu_search_exit" - android:showAsAction="never" /> - - </group> - -</menu> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/menu-land/actions2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/menu-land/actions2.xml deleted file mode 100644 index 35b85d4..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/menu-land/actions2.xml +++ /dev/null @@ -1,62 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<menu xmlns:android="http://schemas.android.com/apk/res/android"> - - <item - android:id="@+id/menu_search" - android:showAsAction="always|collapseActionView" - android:actionViewClass="android.widget.SearchView" /> - - <group android:id="@+id/reader_items"> - - <item - android:id="@+id/menu_table_of_contents" - android:showAsAction="always|collapseActionView" - android:actionLayout="@layout/action_table_of_contents" /> - - <item - android:id="@+id/menu_settings" - android:showAsAction="always|collapseActionView" /> - - <item android:id="@+id/menu_mode" - android:showAsAction="never" /> - - <item - android:id="@+id/menu_buy" - android:showAsAction="never" /> - - <item - android:id="@+id/menu_about" - android:showAsAction="never" /> - - <item - android:id="@+id/menu_share" - android:showAsAction="never" /> - - <item - android:id="@+id/menu_keep" - android:checkable="true" - android:showAsAction="never" /> - - <item - android:id="@+id/menu_d" - android:showAsAction="never" /> - - <item - android:id="@+id/menu_help" - android:showAsAction="never" /> - - </group> - - <group android:id="@+id/search_items"> - - <item - android:id="@+id/menu_table_of_contents" - android:showAsAction="always|collapseActionView" - android:actionLayout="@layout/action_table_of_contents" /> - - <item android:id="@+id/menu_search_exit" - android:showAsAction="never" /> - - </group> - -</menu> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/menu-land/actions2_ignore.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/menu-land/actions2_ignore.xml deleted file mode 100644 index 47cd32e..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/menu-land/actions2_ignore.xml +++ /dev/null @@ -1,64 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<menu xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:tools="http://schemas.android.com/tools"> - - <item - android:id="@+id/menu_search" - android:showAsAction="always|collapseActionView" - android:actionViewClass="android.widget.SearchView" - tools:ignore="AlwaysShowAction" /> - - <group android:id="@+id/reader_items"> - - <item - android:id="@+id/menu_table_of_contents" - android:showAsAction="always|collapseActionView" - android:actionLayout="@layout/action_table_of_contents" /> - - <item - android:id="@+id/menu_settings" - android:showAsAction="always|collapseActionView" /> - - <item android:id="@+id/menu_mode" - android:showAsAction="never" /> - - <item - android:id="@+id/menu_buy" - android:showAsAction="never" /> - - <item - android:id="@+id/menu_about" - android:showAsAction="never" /> - - <item - android:id="@+id/menu_share" - android:showAsAction="never" /> - - <item - android:id="@+id/menu_keep" - android:checkable="true" - android:showAsAction="never" /> - - <item - android:id="@+id/menu_d" - android:showAsAction="never" /> - - <item - android:id="@+id/menu_help" - android:showAsAction="never" /> - - </group> - - <group android:id="@+id/search_items"> - - <item - android:id="@+id/menu_table_of_contents" - android:showAsAction="always|collapseActionView" - android:actionLayout="@layout/action_table_of_contents" /> - - <item android:id="@+id/menu_search_exit" - android:showAsAction="never" /> - - </group> - -</menu> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/menu/menu.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/menu/menu.xml deleted file mode 100644 index 4f0839b..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/menu/menu.xml +++ /dev/null @@ -1,16 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<menu xmlns:android="http://schemas.android.com/apk/res/android" > - - <item - android:id="@+id/item1" - android:icon="@drawable/icon1" - android:title="My title 1"> - </item> - <item - android:id="@+id/item2" - android:icon="@drawable/icon2" - android:showAsAction="ifRoom" - android:title="My title 2"> - </item> - -</menu>
\ No newline at end of file diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/menu/titles.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/menu/titles.xml deleted file mode 100644 index a1ae5bb..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/menu/titles.xml +++ /dev/null @@ -1,15 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<menu xmlns:android="http://schemas.android.com/apk/res/android"> - <item android:id="@+id/action_bar_progress_spinner" - android:showAsAction="always" - android:background="@null" - android:selectableItemBackground="@null" - android:actionLayout="@layout/action_bar_progress_spinner_layout"/> - <item android:id="@+id/refresh" - android:title="@string/menu_refresh" - android:showAsAction="always" - android:icon="@drawable/ic_menu_refresh"/> - <item android:id="@+id/menu_plus_one" - android:showAsAction="always" - android:icon="@drawable/ic_menu_plus1"/> -</menu> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/private_key.pem b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/private_key.pem deleted file mode 100644 index 03b9477..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/private_key.pem +++ /dev/null @@ -1,18 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -Proc-Type: 4,ENCRYPTED -DEK-Info: DES-EDE3-CBC,77F426A58B274623 - -FH1NdgJgrX1OGKM0WfzwWUWmLTmfawdaUPeFNJbz1+WJ5DEt1DmC6o0QkXoxIPC -Te/+FS80gNruYgYIWu4WXWtCSdvSfGI8LP1JZ7hmMCW055J2mLVKT4o6HqAQnHrb -hTATVG6CB/GdHTFPG3J65qIyTlG50jyzfwZtliMCCAWi+AaAlo5xzUe0DgedytB2 -sFkLq5EiD6066P/LXPH/Z5WJKiMCFOl0Gjwd3M9ohZufnWJPJT5ap2fm7OSJSfa6 -jPREY+UwhPyKkYOc2cWgojj6HrsSQlXPl176b1+31c19hhhRAtDfJBIU2OrOFVk/ -V88/Dm0I+ROyLme0rYfFg8uHz2aIymWEMds5ZKEFTFbBhaWbVYKIX7+82tftnd+P -2kT15JAK9V27F0p4SRiWQ5RsDkT3rBWWjtk9Rptkrgec9WKoTaO2fT8bPaWFR/M1 -6X7kjMqhLw1sHmsSeDKx0YCWfS+gWh7RPWGQ2EfH2pxoZkWAR5R3cZCEn3Ia1BeV -UTFWy+DwjEeSrNkO96E0WH1r8204cJAKK8cWS4HSAPMsQPf5cZjIrrAak/9Wupkq -fnrB0Ae6GFO2gWHYQfbSWdEq6w5+S6XZyTauVyaJAjjIFWmegfaKWHzNvqCWJ4T -YPsiptUrKz6WWYyhiUrNJQKcyGWHWrwMNIblWqSBNCa8OIVoaZiRibgO1SIafAGAS -9MDXXVaY6rqx1yfZYDcWVgKGXTJhBXALCeGMWF43bvAmPq3M13QJA0rlO7lAUUF2 -5INqBUeJxZWYxn6tRr9WMty/UcYnPR3YHgt0RDZycvbcqPsU5tHk9Q== ------END RSA PRIVATE KEY-----
\ No newline at end of file diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-cs/arrays.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-cs/arrays.xml deleted file mode 100644 index dd8e580..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-cs/arrays.xml +++ /dev/null @@ -1,9 +0,0 @@ -<resources xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> - <string-array name="security_questions"> - <item>"Oblíbené jídlo?"</item> - <item>"Město narození."</item> - <item>"Jméno nejlepšího kamaráda z dětství?"</item> - <item>"Název střední školy"</item> - </string-array> -</resources> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-cs/strings.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-cs/strings.xml deleted file mode 100644 index 2830534..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-cs/strings.xml +++ /dev/null @@ -1,11 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<resources xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> - <string name="home_title">"Domů"</string> - <string name="show_all_apps">"Vše"</string> - <string name="menu_wallpaper">"Tapeta"</string> - <string name="menu_search">"Hledat"</string> - <!-- no translation found for menu_settings (1769059051084007158) --> - <skip /> - <string name="wallpaper_instructions">"Klepnutím na obrázek nastavíte tapetu portrétu"</string> -</resources> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-cs/translatedarrays.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-cs/translatedarrays.xml deleted file mode 100644 index f20dd3a..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-cs/translatedarrays.xml +++ /dev/null @@ -1,4 +0,0 @@ -<resources> - <string name="item1">Item1-cs</string> - <string name="item2">Item2-cs</string> -</resources> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-de-rDE/strings.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-de-rDE/strings.xml deleted file mode 100644 index 82510ae..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-de-rDE/strings.xml +++ /dev/null @@ -1,12 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<resources xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> - <string name="home_title">"Startseite"</string> - <string name="show_all_apps">"Alle"</string> - <string name="menu_wallpaper">"Bildschirmhintergrund"</string> - <string name="menu_search">"Suchen"</string> - <!-- no translation found for menu_settings (1769059051084007158) --> - <skip /> - <string name="wallpaper_instructions">"Tippen Sie auf Bild, um Porträt-Bildschirmhintergrund einzustellen"</string> - <string name="continue_skip_label">"Weiter"</string> -</resources> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-de/strings.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-de/strings.xml deleted file mode 100644 index 055dd52..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-de/strings.xml +++ /dev/null @@ -1,4 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> - <string name="app_name">Unit Test</string> -</resources> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-de/typos.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-de/typos.xml deleted file mode 100644 index 5108cc9..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-de/typos.xml +++ /dev/null @@ -1,14 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources> - - <string name="s1"> - - wo befindet eine ip - - </string> - <string name="s2">(Authorisierungscode!)</string> - <string name="s3"> zurück gefoobaren!</string> - <!-- escaped separator --> - <string name="issue39599">"ü test\nciht zu"</string> - -</resources> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-es-rUS/strings.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-es-rUS/strings.xml deleted file mode 100644 index 4de53dd..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-es-rUS/strings.xml +++ /dev/null @@ -1,5 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<resources xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> - <string name="menu_search">"Búsqueda"</string> -</resources> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-es/donottranslate.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-es/donottranslate.xml deleted file mode 100644 index f28594c..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-es/donottranslate.xml +++ /dev/null @@ -1,4 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> - <string name="full_wday_month_day_no_year">EEEE, d MMMM</string> -</resources> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-es/formatstrings.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-es/formatstrings.xml deleted file mode 100644 index 4ef3d94..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-es/formatstrings.xml +++ /dev/null @@ -1,5 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources> - <string name="hello">%1$d</string> - <string name="hello2">%3$d: %1$s, %2$s?</string> -</resources> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-es/formatstrings_ignore.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-es/formatstrings_ignore.xml deleted file mode 100644 index 0cf7008..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-es/formatstrings_ignore.xml +++ /dev/null @@ -1,5 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources xmlns:tools="http://schemas.android.com/tools"> - <string name="hello" tools:ignore="StringFormatMatches">%1$d</string> - <string name="hello2" tools:ignore="StringFormatMatches,StringFormatCount">%3$d: %1$s, %2$s?</string> -</resources> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-es/strings.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-es/strings.xml deleted file mode 100644 index ae5822a..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-es/strings.xml +++ /dev/null @@ -1,18 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<resources xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> - <string name="home_title">"Casa"</string> - <string name="show_all_apps">"Todo"</string> - <string name="menu_wallpaper">"Papel tapiz"</string> - <string name="menu_search">"Búsqueda"</string> - <!-- no translation found for menu_settings (1769059051084007158) --> - <skip /> - <string name="wallpaper_instructions">"Puntee en la imagen para establecer papel tapiz vertical"</string> - - <string-array name="security_questions"> - <item>"Comida favorita"</item> - <item>"Ciudad de nacimiento"</item> - <item>"Nombre de tu mejor amigo/a de la infancia"</item> - <item>"Nombre de tu colegio"</item> - </string-array> -</resources> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-es/strings_ignore.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-es/strings_ignore.xml deleted file mode 100644 index 4358448..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-es/strings_ignore.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<resources xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:tools="http://schemas.android.com/tools" - xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> - <string name="home_title">"Casa"</string> - <string name="show_all_apps">"Todo"</string> - <string name="menu_wallpaper">"Papel tapiz"</string> - <string name="menu_search">"Búsqueda"</string> - <!-- no translation found for menu_settings (1769059051084007158) --> - <skip /> - <string name="wallpaper_instructions">"Puntee en la imagen para establecer papel tapiz vertical"</string> - <string name="other" tools:ignore="ExtraTranslation">"?"</string> - - <string-array name="security_questions" tools:ignore="ExtraTranslation"> - <item>"Comida favorita"</item> - <item>"Ciudad de nacimiento"</item> - <item>"Nombre de tu mejor amigo/a de la infancia"</item> - <item>"Nombre de tu colegio"</item> - </string-array> -</resources> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-es/strings_locale.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-es/strings_locale.xml deleted file mode 100644 index b485dee..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-es/strings_locale.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<resources xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2" - xmlns:tools="http://schemas.android.com/tools" - tools:locale="es"> - <string name="home_title">"Casa"</string> - <string name="show_all_apps">"Todo"</string> - <string name="menu_wallpaper">"Papel tapiz"</string> - <string name="menu_search">"Búsqueda"</string> - <!-- no translation found for menu_settings (1769059051084007158) --> - <skip /> - <string name="wallpaper_instructions">"Puntee en la imagen para establecer papel tapiz vertical"</string> - - <string-array name="security_questions"> - <item>"Comida favorita"</item> - <item>"Ciudad de nacimiento"</item> - <item>"Nombre de tu mejor amigo/a de la infancia"</item> - <item>"Nombre de tu colegio"</item> - </string-array> -</resources> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-fr/strings.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-fr/strings.xml deleted file mode 100644 index 85a28c9..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-fr/strings.xml +++ /dev/null @@ -1,8 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources> - - <string-array name="test_string_array"> - <item>Test (French)</item> - </string-array> - -</resources>
\ No newline at end of file diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-it/stringarrays.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-it/stringarrays.xml deleted file mode 100644 index 7bd83e9..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-it/stringarrays.xml +++ /dev/null @@ -1,12 +0,0 @@ -<?xml version='1.0' encoding='utf-8'?> -<resources> - <string-array name="track_type_desc"> - <item>Pendenza</item> - </string-array> - <string-array name="map_density_desc"> - <item>Automatico (mappa leggibile su display HD)</item> - </string-array> - <string-array name="cache_size_desc"> - <item>Piccolo (100)</item> - </string-array> -</resources>
\ No newline at end of file diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-land/arrays.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-land/arrays.xml deleted file mode 100644 index 4495dfd..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-land/arrays.xml +++ /dev/null @@ -1,11 +0,0 @@ -<resources> - <array name="signal_strength"> - <item>@drawable/ic_setups_signal_0</item> - <item>@drawable/ic_setups_signal_1</item> - <item>@drawable/ic_setups_signal_2</item> - <item>@drawable/ic_setups_signal_3</item> - <item>@drawable/ic_setups_signal_4</item> - <item>@drawable/extra</item> - </array> -</resources> - diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-land/arrays_ignore.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-land/arrays_ignore.xml deleted file mode 100644 index 24e76cd..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-land/arrays_ignore.xml +++ /dev/null @@ -1,11 +0,0 @@ -<resources xmlns:tools="http://schemas.android.com/tools"> - <array name="signal_strength" tools:ignore="InconsistentArrays"> - <item>@drawable/ic_setups_signal_0</item> - <item>@drawable/ic_setups_signal_1</item> - <item>@drawable/ic_setups_signal_2</item> - <item>@drawable/ic_setups_signal_3</item> - <item>@drawable/ic_setups_signal_4</item> - <item>@drawable/extra</item> - </array> -</resources> - diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-land/strings.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-land/strings.xml deleted file mode 100644 index 824df2a..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-land/strings.xml +++ /dev/null @@ -1,21 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2007 The Android Open Source Project - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> - -<resources> - <!-- Wallpaper --> - <string name="wallpaper_instructions">Tap image to set landscape wallpaper</string> -</resources> - diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-nb/typos.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-nb/typos.xml deleted file mode 100644 index 06cec0d..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-nb/typos.xml +++ /dev/null @@ -1,22 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources> - <!-- No typos --> - <string name="s1">Dette er en test</string> - <!-- Plain typos --> - <string name="s2">Mer morro med Andriod</string> - <!-- Make capitalization match typo --> - <string name="s3"> Parallel </string> - <!-- Markup indirection --> - <string name="s4"><b>altid</b></string> - <!-- Typo, match capitalized --> - <string name="s5">Altid</string> - <!-- random words, shouldn't flag --> - <string name="s6">abcdefg qwerty asdf jklm</string> - <!-- typo, but should only match when capitalized --> - <string name="s7">Midt-Østen midt-østen</string> - <!-- Non-ASCII UTF-8 string --> - <string name="s7">Koding er en spennende karriære</string> - <string name="internet">"Koble til Internett.</string> - -</resources> - diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-nb/typos_locale.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-nb/typos_locale.xml deleted file mode 100644 index ed1edd1..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-nb/typos_locale.xml +++ /dev/null @@ -1,8 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources xmlns:tools="http://schemas.android.com/tools" - tools:locale="nb"> - <!-- Markup indirection --> - <string name="s4"><b>altid</b></string> - <!-- Typo, match capitalized --> - <string name="s5">Altid</string> -</resources>
\ No newline at end of file diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-nl-rNL/arrays.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-nl-rNL/arrays.xml deleted file mode 100644 index 36faf96..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-nl-rNL/arrays.xml +++ /dev/null @@ -1,8 +0,0 @@ -<resources xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> - <string-array name="security_questions"> - <item>"Favoriete eten?"</item> - <item>"Geboorteplaats?"</item> - <item>"Naam van middelbare school?"</item> - </string-array> -</resources> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-nl-rNL/strings.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-nl-rNL/strings.xml deleted file mode 100644 index 1bd9ea2..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-nl-rNL/strings.xml +++ /dev/null @@ -1,13 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<resources xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> - <string name="home_title">"Start"</string> - <!-- Commented out in the unit test to generate extra warnings: - <string name="show_all_apps">"Alles"</string> - <string name="menu_wallpaper">"Achtergrond"</string> - --> - <string name="menu_search">"Zoeken"</string> - <!-- no translation found for menu_settings (1769059051084007158) --> - <skip /> - <string name="wallpaper_instructions">"Tik op afbeelding om portretachtergrond in te stellen"</string> -</resources> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/analytics.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/analytics.xml deleted file mode 100644 index 8ea40a8..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/analytics.xml +++ /dev/null @@ -1,16 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<resources> - <!--Replace placeholder ID with your tracking ID--> - <string name="ga_trackingId">UA-12345678-1</string> - - <!--Enable Activity tracking--> - <bool name="ga_autoActivityTracking">true</bool> - - <!--Enable automatic exception tracking--> - <bool name="ga_reportUncaughtExceptions">true</bool> - - <!-- The screen names that will appear in your reporting --> - <string name="com.example.app.BaseActivity">Home</string> - <string name="com.example.app.PrefsActivity">Preferences</string> - <string name="test.pkg.OnClickActivity">Clicks</string> -</resources> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/arrays.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/arrays.xml deleted file mode 100644 index de544b3..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/arrays.xml +++ /dev/null @@ -1,18 +0,0 @@ -<resources> - <!-- Choices for Locations in SetupWizard's Set Time and Data Activity --> - <string-array name="security_questions"> - <item>Favorite food?</item> - <item>City of birth?</item> - <item>Best childhood friend\'s name?</item> - <item>Highschool name?</item> - </string-array> - - <array name="signal_strength"> - <item>@drawable/ic_setups_signal_0</item> - <item>@drawable/ic_setups_signal_1</item> - <item>@drawable/ic_setups_signal_2</item> - <item>@drawable/ic_setups_signal_3</item> - <item>@drawable/ic_setups_signal_4</item> - </array> -</resources> - diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/arrayusage.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/arrayusage.xml deleted file mode 100644 index 0b890f7..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/arrayusage.xml +++ /dev/null @@ -1,6 +0,0 @@ -<resources> -<string name="my_item">An Item</string> -<string-array name="my_array"> - <item>@string/my_item</item> -</string-array> -</resources> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/buttonbar-values.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/buttonbar-values.xml deleted file mode 100644 index 4a32e7d..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/buttonbar-values.xml +++ /dev/null @@ -1,15 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources> - - <string name="button"> Button </string> - <string name="ok"> OK </string> - <string name="cancel"> Cancel </string> - <string name="resume"> OK </string> - <string name="giveup"> Cancel </string> - <string name="resume2"> Ok </string> - <string name="giveup2">"CANCEL"</string> - <string name="send"> Send </string> - <string name="abort">Abort</string> - <string name="goback">'Back'</string> - -</resources> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/customattr.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/customattr.xml deleted file mode 100644 index e1ca2d4..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/customattr.xml +++ /dev/null @@ -1,6 +0,0 @@ -<resources> - <declare-styleable name="ContentFrame"> - <attr name="content" format="reference" /> - <attr name="contentId" format="reference" /> - </declare-styleable> -</resources> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings-version1.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings-version1.xml deleted file mode 100644 index 4d3e5a7..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings-version1.xml +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources> - <string name="hour_minute_24">%-k:%M</string> - <string name="numeric_date">%Y-%m-%d</string> - <string name="month_day_year">%Y %B %-e</string> - <string translatable="false" name="web_user_agent"> - Foo (Bar %s) Foo/731.11+ (Foo, like Bar) Version/1.2.3 Foo Bar/123.14.4 - </string> -</resources> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings-version2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings-version2.xml deleted file mode 100644 index d1757f7..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings-version2.xml +++ /dev/null @@ -1,6 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources> - <string name="hour_minute_24">%H:%M</string> - <string name="numeric_date">%-m/%-e/%Y</string> - <string name="month_day_year">%B %-e, %Y</string> -</resources> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings.xml deleted file mode 100644 index 6b1985c..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings.xml +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources> - <string name="hello">Hello %1$s</string> - <string name="hello2">Hello %1$s, %2$s?</string> - <string name="missing">Hello %3$s World</string> - <string name="score">Score: %1$d</string> -</resources> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings2.xml deleted file mode 100644 index 23291d2..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings2.xml +++ /dev/null @@ -1,6 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources> - <string name="hour_minute_24">%H:%M</string> - <string name="numeric_wday1_mdy1_time1_wday2_mdy2_time2">%5$s %1$s, %4$s-%2$s-%3$s – %10$s %6$s, %9$s-%7$s-%8$s</string> - <string name="bogus">%2.99999s</string> -</resources> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings3.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings3.xml deleted file mode 100644 index 2424078..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings3.xml +++ /dev/null @@ -1,4 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources> - <string name="multiple_formats_with_percentage">%1$s 3%% %2$s</string> -</resources> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings4.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings4.xml deleted file mode 100644 index c4e245e..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings4.xml +++ /dev/null @@ -1,10 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources> - <string name="formattest1">"%1$s, %2$tF %3$tR"</string> - <string name="formattest2">%1$s, %2$tF %3$tR</string> - <string name="formattest3">"Note: Start point RPM differs by %d%%.\n\n"</string> - <string name="formattest4">Note: Start point RPM differs by %d%%.\n\n</string> - <string name="formattest5">%s%% c</string> - <string name="formattest6">%s%% </string> - <string name="formattest7">%1$s%%</string> -</resources> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings5.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings5.xml deleted file mode 100644 index 6b14570..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings5.xml +++ /dev/null @@ -1,4 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources> - <string name="gridview_views_count">%d vues</string> -</resources> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings_ignore.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings_ignore.xml deleted file mode 100644 index 9834119..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings_ignore.xml +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources xmlns:tools="http://schemas.android.com/tools"> - <string name="hello" tools:ignore="StringFormatMatches">Hello %1$s</string> - <string name="hello2" tools:ignore="StringFormatMatches,StringFormatCount">Hello %1$s, %2$s?</string> - <string name="missing" tools:ignore="StringFormatCount">Hello %3$s World</string> - <string name="score">Score: %1$d</string> -</resources> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/nontranslatable.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/nontranslatable.xml deleted file mode 100644 index f608bff..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/nontranslatable.xml +++ /dev/null @@ -1,5 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources> - <string name="dummy" translatable="false">Ignore Me</string> -</resources> - diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/nontranslatable2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/nontranslatable2.xml deleted file mode 100644 index 4fcfdc6..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/nontranslatable2.xml +++ /dev/null @@ -1,5 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources> - <string name="dummy">Ignore Me</string> -</resources> - diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/plurals.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/plurals.xml deleted file mode 100644 index 703a841..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/plurals.xml +++ /dev/null @@ -1,8 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources> - <plurals name="my_plural"> - <item quantity="one">@string/hello</item> - <item quantity="few">@string/hello</item> - <item quantity="other">@string/hello</item> - </plurals> -</resources> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/pxsp.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/pxsp.xml deleted file mode 100644 index 7a44201..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/pxsp.xml +++ /dev/null @@ -1,34 +0,0 @@ -<resources> - <style name="Style1"> - <item name="android:textSize">50sp</item> - </style> - <style name="Style2"> - <item name="android:textSize">50dp</item> - </style> - <style name="Style3"> - <item name="android:textSize">50px</item> - </style> - <style name="Style4"> - <item name="android:textSize"> 50dip </item> - </style> - - <style name="Style5"> - <item name="android:paddingLeft">@dimen/whats_on_item_padding</item> - <item name="android:paddingRight"> 50px </item> - <item name="android:paddingTop">50px</item> - <item name="android:paddingBottom">50dip</item> - </style> - - <style name="Style6"> - <item name="android:textSize">50mm</item> - <item name="android:textSize"> - 50in - </item> - </style> - - <style name="Widget.TabStrip" parent="Widget"> - <item name="android:divider">?android:attr/listDivider</item> - <item name="android:showDividers">middle</item> - <item name="android:dividerPadding">0px</item> - </style> -</resources> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/sizestyles.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/sizestyles.xml deleted file mode 100644 index 468974e..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/sizestyles.xml +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources> - - <style name="WidthAndHeight" parent="@android:attr/textAppearanceMedium"> - <item name="android:layout_width">match_parent</item> - <item name="android:layout_height">match_parent</item> - </style> - - <style name="Width" parent="@android:attr/textAppearanceMedium"> - <item name="android:layout_width">match_parent</item> - </style> - - <style name="MyStyle" parent="@style/WidthAndHeight"></style> - <style name="MyStyle.Big"></style> - <style name="MyOtherStyle" parent="@style/MyStyle.Big"></style> - -</resources>
\ No newline at end of file diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/stringarrays.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/stringarrays.xml deleted file mode 100644 index 6405580..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/stringarrays.xml +++ /dev/null @@ -1,13 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources> - <string-array name="map_density_desc"> - <item>Automatic (readable map on HD displays)</item> - <item>1 map pixel = 1 screen pixel</item> - <item>1 map pixel = 1.25 screen pixels</item> - <item>1 map pixel = 1.5 screen pixels</item> - <item>1 map pixel = 2 screen pixels</item> - </string-array> - <string-array name="spatial_resolution_desc"> - <item>5m/yd (fine, default)</item> - </string-array> -</resources>
\ No newline at end of file diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/strings.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/strings.xml deleted file mode 100644 index 5aec951..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/strings.xml +++ /dev/null @@ -1,31 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2007 The Android Open Source Project - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> - -<resources> - <!-- Home --> - <string name="home_title">Home Sample</string> - <string name="show_all_apps">All</string> - - <!-- Home Menus --> - <string name="menu_wallpaper">Wallpaper</string> - <string name="menu_search">Search</string> - <string name="menu_settings">Settings</string> - <string name="dummy" translatable="false">Ignore Me</string> - - <!-- Wallpaper --> - <string name="wallpaper_instructions">Tap picture to set portrait wallpaper</string> -</resources> - diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/strings2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/strings2.xml deleted file mode 100644 index bce9e32..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/strings2.xml +++ /dev/null @@ -1,5 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources> - <string name="hello">Hello</string> -</resources> - diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/strings3.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/strings3.xml deleted file mode 100644 index 6da33ae..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/strings3.xml +++ /dev/null @@ -1,10 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation"> - - <string name="test_string">Test (English)</string> - - <string-array name="test_string_array"> - <item>@string/test_string</item> - </string-array> - -</resources> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/strings4.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/strings4.xml deleted file mode 100644 index 76d88a4..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/strings4.xml +++ /dev/null @@ -1,4 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources xmlns:tools="http://schemas.android.com/tools"> - <string name="hello">Hello</string> -</resources> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/strings_ignore.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/strings_ignore.xml deleted file mode 100644 index a69d4c8..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/strings_ignore.xml +++ /dev/null @@ -1,15 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources xmlns:tools="http://schemas.android.com/tools"> - <!-- Home --> - <string name="home_title">Home Sample</string> - <string name="show_all_apps" tools:ignore="MissingTranslation">All</string> - - <!-- Home Menus --> - <string name="menu_wallpaper" tools:ignore="MissingTranslation">Wallpaper</string> - <string name="menu_search">Search</string> - <string name="menu_settings" tools:ignore="all">Settings</string> - <string name="dummy" translatable="false">Ignore Me</string> - - <!-- Wallpaper --> - <string name="wallpaper_instructions">Tap picture to set portrait wallpaper</string> -</resources> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/stylecycle.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/stylecycle.xml deleted file mode 100644 index 448eb9c..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/stylecycle.xml +++ /dev/null @@ -1,5 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources xmlns:android="http://schemas.android.com/apk/res/android"> - <style name="PropertyToggle" parent="@style/PropertyToggle.Base"></style> - <style name="PropertyToggle.Base"></style> -</resources> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/styles.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/styles.xml deleted file mode 100644 index 34e2d6f..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/styles.xml +++ /dev/null @@ -1,15 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources> - -<style name="DetailsPage_BuyButton" parent="@style/DetailsPage_Button"> - <item name="android:textColor">@color/buy_button</item> - <item name="android:background">@drawable/details_page_buy_button</item> -</style> - -<style name="DetailsPage_EditorialBuyButton" parent="@style/DetailsPage_EditorialBuyButton" /> -<!-- Should have been: -<style name="DetailsPage_EditorialBuyButton" parent="@style/DetailsPage_BuyButton" /> ---> - -</resources> - 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 deleted file mode 100644 index 45422cb..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/styles2.xml +++ /dev/null @@ -1,8 +0,0 @@ -<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> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/themes.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/themes.xml deleted file mode 100644 index eba1c3c..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/themes.xml +++ /dev/null @@ -1,8 +0,0 @@ -<resources xmlns:android="http://schemas.android.com/apk/res/android"> - - <style name="MyTheme" parent="@android:style/Theme"> - <item name="android:layout_width">wrap_content</item> - <item name="android:layout_height">wrap_content</item> - </style> - -</resources> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/themes2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/themes2.xml deleted file mode 100644 index b587923..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/themes2.xml +++ /dev/null @@ -1,10 +0,0 @@ -<resources xmlns:android="http://schemas.android.com/apk/res/android"> - - <style name="MyStyle" parent="@style/Theme.Holo.Light"></style> - <style name="MyStyle.Big"></style> - <style name="MyOtherStyle" parent="@style/MyStyle.Big"> - <item name="android:layout_width">wrap_content</item> - <item name="android:layout_height">wrap_content</item> - </style> - -</resources> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/translatedarrays.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/translatedarrays.xml deleted file mode 100644 index 4707734..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/translatedarrays.xml +++ /dev/null @@ -1,8 +0,0 @@ -<resources> - <string name="item1">Item1</string> - <string name="item2">Item2</string> - <string-array name="myarray"> - <item>@string/item1</item> - <item>@string/item2</item> - </string-array> -</resources> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/typography.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/typography.xml deleted file mode 100644 index 02ffb1c..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/typography.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources> - <string name="home_title">Home 'Sample'</string> - <string name="show_all_apps">"All"</string> - <string name="show_all_apps2">Show "All"</string> - <string name="escaped">Skip \"All\"</string> - <string name="single">Android's</string> - <string name="copyright">(c) 2011</string> - <string name="badquotes1">`First'</string> - <string name="badquotes2">``second''</string> - <string name="notbadquotes">Type Option-` then 'Escape'</string> - <string name="fraction1">5 1/2 times</string> - <string name="fraction4">1/4 times</string> - <string name="notfraction">51/2 times, 1/20</string> - <string name="ellipsis">40 times...</string> - <string name="notellipsis">40 times.......</string> - <string name="ndash">For ages 3-5</string> - <string name="ndash2">Copyright 2007 - 2011</string> - <string name="nontndash">x-y</string> - <string name="mdash">Not found -- please try again</string> - <string name="nontndash">----</string> - <string name="notdirectional">A's and B's</string> - <string-array name="typography"> - <item>Ages 3-5</item> - <item>Age 5 1/2</item> - </string-array> - <string name="ndash">X Y Z: 10 10 -1</string> - <string name="ga_trackingId">UA-0000-0</string> -</resources> - diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/typos.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/typos.xml deleted file mode 100644 index dd24812..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/typos.xml +++ /dev/null @@ -1,25 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources> - <!-- No typos --> - <string name="s1">Home Sample</string> - <!-- Plain typos --> - <string name="s2">Andriod activites!</string> - <!-- Make capitalization match typo --> - <string name="s3"> (Cmoputer </string> - <!-- Markup indirection --> - <string name="s4"><b>throught</b></string> - <!-- Typo, match capitalized --> - <string name="s5">Seach</string> - <!-- random words, shouldn't flag --> - <string name="s6">abcdefg qwerty asdf jklm</string> - <!-- typo, but should only match when capitalized --> - <string name="s7">Tuscon tuscon</string> - <!-- case changes only: valid --> - <string name="s8">OK Cancel dialog with a long message</string> - <!-- case changes only: invalid --> - <string name="dlg_button_ok">Ok</string> - <!-- escaped separator --> - <string name="issue39599">"Please take a moment\nto rate ^1"</string> - <!-- escaped separator 2 --> - <string name="issue39599_2">"\nto</string> -</resources>
\ No newline at end of file diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/my/pkg/Test.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/my/pkg/Test.java.txt deleted file mode 100644 index 3905b8c..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/my/pkg/Test.java.txt +++ /dev/null @@ -1,10 +0,0 @@ -package my.pgk; - -class Test { - private static String s = " R.id.button1 \" "; // R.id.button1 should not be considered referenced - static { - System.out.println(R.id.button2); - char c = '"'; - System.out.println(R.id.linearLayout1); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/pkg1/Class1.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/pkg1/Class1.java.txt deleted file mode 100644 index 193ff3c..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/pkg1/Class1.java.txt +++ /dev/null @@ -1,29 +0,0 @@ -package pkg1; - -public class Class1 { - void method() { - } - - void method2(int foo) { - } - - void method3() { - } - - void method4() { - } - - void method5() { - } - - void method6() { - } - - void method7() { - } - - public static class Class4 extends Class1 { - void method() { // Not an error: same package - } - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/pkg2/Class2.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/pkg2/Class2.java.txt deleted file mode 100644 index 651c021..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/pkg2/Class2.java.txt +++ /dev/null @@ -1,33 +0,0 @@ -package pkg2; - -import android.annotation.SuppressLint; -import pkg1.Class1; - -public class Class2 extends Class1 { - void method() { // Flag this as an accidental override - } - - void method2(String foo) { // not an override: different signature - } - - static void method4() { // not an override: static - } - - private void method3() { // not an override: private - } - - protected void method5() { // not an override: protected - } - - public void method6() { // not an override: public - } - - @SuppressLint("DalvikOverride") - public void method7() { // suppressed: no warning - } - - public class Class3 extends Object { - void method() { // Not an override: not a subclass - } - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/ActionBarTest.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/ActionBarTest.java.txt deleted file mode 100644 index 217f3b6..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/ActionBarTest.java.txt +++ /dev/null @@ -1,14 +0,0 @@ -package test.pkg; - -import android.app.Activity; -import android.view.Menu; -import android.view.MenuInflater; - -public class ActionBarTest extends Activity { - @Override - public boolean onCreateOptionsMenu(Menu menu) { - MenuInflater inflater = getMenuInflater(); - inflater.inflate(R.menu.menu, menu); - return true; - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/ActionTest1.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/ActionTest1.java.txt deleted file mode 100644 index deeffde..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/ActionTest1.java.txt +++ /dev/null @@ -1,9 +0,0 @@ -package test.pkg; - -import android.view.MenuItem; - -public class ActionTest1 { - public void foo() { - System.out.println(MenuItem.SHOW_AS_ACTION_ALWAYS); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/ActionTest1_ignore.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/ActionTest1_ignore.java.txt deleted file mode 100644 index 5fea6be..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/ActionTest1_ignore.java.txt +++ /dev/null @@ -1,10 +0,0 @@ -package test.pkg; - -import android.view.MenuItem; - -public class ActionTest1 { - @SuppressLint("AlwaysShowAction") - public void foo() { - System.out.println(MenuItem.SHOW_AS_ACTION_ALWAYS); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/ActionTest2.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/ActionTest2.java.txt deleted file mode 100644 index 2d5df6f..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/ActionTest2.java.txt +++ /dev/null @@ -1,9 +0,0 @@ -package test.pkg; - -import android.view.MenuItem; - -public class ActionTest2 { - public void foo() { - System.out.println(MenuItem.SHOW_AS_ACTION_IF_ROOM); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/BadImport.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/BadImport.java.txt deleted file mode 100644 index f5b4dd0..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/BadImport.java.txt +++ /dev/null @@ -1,9 +0,0 @@ -package test.pkg; - -import android.app.Activity; -import android.os.Bundle; -import android.R; -import android.widget.*; - -public class BadImport { -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/CustomViewTest.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/CustomViewTest.java.txt deleted file mode 100644 index 1862ccc..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/CustomViewTest.java.txt +++ /dev/null @@ -1,6 +0,0 @@ -package test.pkg; - -import test.pkg.Intermediate.IntermediateCustomV; - -public class CustomViewTest extends IntermediateCustomV { -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/Foo.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/Foo.java.txt deleted file mode 100644 index 6e16a72..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/Foo.java.txt +++ /dev/null @@ -1,7 +0,0 @@ -// http://code.google.com/p/projectlombok/issues/detail?id=415 -package test.pkg; -public class X { - public void X(Y parent) { - parent.new Z(parent.getW()).execute(); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/Hidden.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/Hidden.java.txt deleted file mode 100644 index 847cd88..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/Hidden.java.txt +++ /dev/null @@ -1,14 +0,0 @@ -package test.pkg; - -public class Hidden { - // Innocent comment...? - /* \u002a\u002f static { System.out.println("I'm executed on class load"); } \u002f\u002a */ - /* \u002A\U002F static { System.out.println("I'm executed on class load"); } \u002f\u002a */ - /* Normal \\u002A\U002F */ // OK - static { - String s = "\u002a\u002f"; // OK - } - // STOPSHIP - /* We must STOPSHIP! */ - String x = "STOPSHIP"; // OK -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/ImportFrameActivity.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/ImportFrameActivity.java.txt deleted file mode 100644 index 510dadc..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/ImportFrameActivity.java.txt +++ /dev/null @@ -1,13 +0,0 @@ -package test.pkg; - -import foo.bar.R; -import android.app.Activity; -import android.os.Bundle; - -public class ImportFrameActivity extends Activity { - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.simple); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/InflaterTest.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/InflaterTest.java.txt deleted file mode 100644 index 5a4e346..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/InflaterTest.java.txt +++ /dev/null @@ -1,65 +0,0 @@ -package test.pkg; - -import com.example.includetest.R; - -import android.app.Activity; -import android.content.Context; -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.Button; - -@SuppressWarnings("unused") -public class InflaterTest extends Activity { - private LayoutInflater mInflater; - private View mRootView; - - private LayoutInflater getInflater() { - if (mInflater == null) { - mInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); - } - return mInflater; - } - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - } - - public void testInflate1() { - View.inflate(this, R.layout.size1, null); - } - - public void testInflate2() { - mRootView = getInflater().inflate(R.layout.size2, null); - } - - public void testInflate4() { - getInflater().inflate(R.layout.size3, null, false); - } - - public void testInflate5() { - int mylayout = R.layout.size4; - getInflater().inflate(mylayout, null, false); - } - - public void testNotNull(ViewGroup root) { - getInflater().inflate(R.layout.size5, root, false); // Should be flagged - } - - public void testInflate6() { - int mylayout = R.layout.size7; - View.inflate(this, mylayout, null); - } - - public class MyButton extends Button { - public MyButton(Context context) { - super(context); - } - - public void test() { - inflate(getContext(), R.layout.size6, null); - } - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/JavaPerformanceTest.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/JavaPerformanceTest.java.txt deleted file mode 100644 index a8caccb..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/JavaPerformanceTest.java.txt +++ /dev/null @@ -1,195 +0,0 @@ -package test.pkg; - -import java.util.HashMap; -import java.util.Map; - -import android.annotation.SuppressLint; -import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.graphics.Canvas; -import android.graphics.Rect; -import android.util.AttributeSet; -import android.widget.Button; -/** Some test data for the JavaPerformanceDetector */ -@SuppressWarnings("unused") -public class JavaPerformanceTest extends Button { - public JavaPerformanceTest(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - } - - private Rect cachedRect; - - @Override - protected void onDraw(android.graphics.Canvas canvas) { - super.onDraw(canvas); - - // Various allocations: - new String("foo"); - String s = new String("bar"); - - // This one should not be reported: - @SuppressLint("DrawAllocation") - Integer i = new Integer(5); - - // Cached object initialized lazily: should not complain about these - if (cachedRect == null) { - cachedRect = new Rect(0, 0, 100, 100); - } - if (cachedRect == null || cachedRect.width() != 50) { - cachedRect = new Rect(0, 0, 50, 100); - } - - boolean b = Boolean.valueOf(true); // auto-boxing - dummy(1, 2); - - // Non-allocations - super.animate(); - dummy2(1, 2); - int x = 4 + '5'; - - // This will involve allocations, but we don't track - // inter-procedural stuff here - someOtherMethod(); - } - - void dummy(Integer foo, int bar) { - dummy2(foo, bar); - } - - void dummy2(int foo, int bar) { - } - - void someOtherMethod() { - // Allocations are okay here - new String("foo"); - String s = new String("bar"); - boolean b = Boolean.valueOf(true); // auto-boxing - - // Sparse array candidates - Map<Integer, String> myMap = new HashMap<Integer, String>(); - // Should use SparseBooleanArray - Map<Integer, Boolean> myBoolMap = new HashMap<Integer, Boolean>(); - // Should use SparseIntArray - Map<Integer, Integer> myIntMap = new java.util.HashMap<Integer, Integer>(); - - // This one should not be reported: - @SuppressLint("UseSparseArrays") - Map<Integer, Object> myOtherMap = new HashMap<Integer, Object>(); - } - - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec, - boolean x) { // wrong signature - new String("not an error"); - } - - protected void onMeasure(int widthMeasureSpec) { // wrong signature - new String("not an error"); - } - - protected void onLayout(boolean changed, int left, int top, int right, - int bottom, int wrong) { // wrong signature - new String("not an error"); - } - - protected void onLayout(boolean changed, int left, int top, int right) { - // wrong signature - new String("not an error"); - } - - @Override - protected void onLayout(boolean changed, int left, int top, int right, - int bottom) { - new String("flag me"); - } - - @SuppressWarnings("null") // not real code - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - new String("flag me"); - - // Forbidden factory methods: - Bitmap.createBitmap(100, 100, null); - android.graphics.Bitmap.createScaledBitmap(null, 100, 100, false); - BitmapFactory.decodeFile(null); - Canvas canvas = null; - canvas.getClipBounds(); // allocates on your behalf - canvas.getClipBounds(null); // NOT an error - - final int layoutWidth = getWidth(); - final int layoutHeight = getHeight(); - if (mAllowCrop && (mOverlay == null || mOverlay.getWidth() != layoutWidth || - mOverlay.getHeight() != layoutHeight)) { - mOverlay = Bitmap.createBitmap(layoutWidth, layoutHeight, Bitmap.Config.ARGB_8888); - mOverlayCanvas = new Canvas(mOverlay); - } - - if (widthMeasureSpec == 42) { - throw new IllegalStateException("Test"); // NOT an allocation - } - - // More lazy init tests - boolean initialized = false; - if (!initialized) { - new String("foo"); - initialized = true; - } - - // NOT lazy initialization - if (!initialized || mOverlay == null) { - new String("foo"); - } - } - - void factories() { - Integer i1 = new Integer(42); - Long l1 = new Long(42L); - Boolean b1 = new Boolean(true); - Character c1 = new Character('c'); - Float f1 = new Float(1.0f); - Double d1 = new Double(1.0); - - // The following should not generate errors: - Object i2 = new foo.bar.Integer(42); - Integer i3 = Integer.valueOf(42); - } - - private boolean mAllowCrop; - private Canvas mOverlayCanvas; - private Bitmap mOverlay; - - @Override - public void layout(int l, int t, int r, int b) { - // Using "this." to reference fields - if (this.shader == null) - this.shader = new LinearGradient(0, 0, getWidth(), 0, GRADIENT_COLORS, null, - TileMode.REPEAT); - } - - @Override - public void layout(int l, int t, int r, int b) { - int width = getWidth(); - int height = getHeight(); - - if ((shader == null) || (lastWidth != width) || (lastHeight != height)) - { - lastWidth = width; - lastHeight = height; - - shader = new LinearGradient(0, 0, width, 0, GRADIENT_COLORS, null, TileMode.REPEAT); - } - } - - @Override - public void layout(int l, int t, int r, int b) { - if ((shader == null) || (lastWidth != getWidth()) || (lastHeight != getHeight())) { - } - } - - public void inefficientSparseArray() { - new SparseArray<Integer>(); // Use SparseIntArray instead - new SparseArray<Long>(); // Use SparseLongArray instead - new SparseArray<Boolean>(); // Use SparseBooleanArray instead - new SparseArray<Object>(); // OK - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/NonInternationalizedSmsDetectorTest.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/NonInternationalizedSmsDetectorTest.java.txt deleted file mode 100644 index 354f5bf..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/NonInternationalizedSmsDetectorTest.java.txt +++ /dev/null @@ -1,20 +0,0 @@ -package foo.bar; - -import android.app.Activity; -import android.content.Context; -import android.os.Bundle; -import android.telephony.SmsManager; - -public class NonInternationalizedSmsDetectorTest { - private void sendLocalizedMessage(Context context) { - // Don't warn here - SmsManager sms = SmsManager.getDefault(); - sms.sendTextMessage("+1234567890", null, null, null, null); - } - - private void sendAlternativeCountryPrefix(Context context) { - // Do warn here - SmsManager sms = SmsManager.getDefault(); - sms.sendMultipartTextMessage("001234567890", null, null, null, null); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/NotificationTest.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/NotificationTest.java.txt deleted file mode 100644 index b03f7a8..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/NotificationTest.java.txt +++ /dev/null @@ -1,39 +0,0 @@ -package test.pkg; - -import android.app.Notification; -import android.app.Notification.Builder; -import android.content.Context; -import android.graphics.Bitmap; - -@SuppressWarnings({ "deprecation", "unused", "javadoc" }) -class NotificationTest { - public void test1() { - Notification notification = new Notification(R.drawable.icon1, "Test1", 0); - } - - public void test2() { - int resource = R.drawable.icon2; - Notification notification = new Notification(resource, "Test1", 0); - } - - public void test3() { - int icon = R.drawable.icon3; - CharSequence tickerText = "Hello"; - long when = System.currentTimeMillis(); - Notification notification = new Notification(icon, tickerText, when); - } - - public void test4(Context context, String sender, String subject, Bitmap bitmap) { - Notification notification = new Notification.Builder(context) - .setContentTitle("New mail from " + sender.toString()) - .setContentText(subject).setSmallIcon(R.drawable.icon4) - .setLargeIcon(bitmap).build(); - } - - public void test5(Context context, String sender, String subject, Bitmap bitmap) { - Notification notification = new Builder(context) - .setContentTitle("New mail from " + sender.toString()) - .setContentText(subject).setSmallIcon(R.drawable.icon5) - .setLargeIcon(bitmap).build(); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/PasteError.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/PasteError.java.txt deleted file mode 100644 index b12b56b..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/PasteError.java.txt +++ /dev/null @@ -1,109 +0,0 @@ -package test.pkg; - -import android.app.Activity; -import android.view.View; - -public class PasteError extends Activity { - protected void ok() { - Button button1 = (Button) findViewById(R.id.textView1); - mView2 = findViewById(R.id.textView2); - View view3 = findViewById(R.id.activity_main); - } - - protected void error() { - View view1 = findViewById(R.id.textView1); - View view2 = findViewById(R.id.textView1); - View view3 = findViewById(R.id.textView2); - } - - protected void ok2() { - View view1; - if (true) { - view1 = findViewById(R.id.textView1); - } else { - view1 = findViewById(R.id.textView1); - } - } - - @SuppressLint("CutPasteId") - protected void suppressed() { - View view1 = findViewById(R.id.textView1); - View view2 = findViewById(R.id.textView1); - } - - private void ok3() { - if (view == null || view.findViewById(R.id.city_name) == null) { - view = mInflater.inflate(R.layout.city_list_item, parent, false); - } - TextView name = (TextView) view.findViewById(R.id.city_name); - } - - private void ok4() { - mPrevAlbumWrapper = mPrevTrackLayout.findViewById(R.id.album_wrapper); - mNextAlbumWrapper = mNextTrackLayout.findViewById(R.id.album_wrapper); - } - - @Override - public View getView(int position, View convertView, ViewGroup parent) { - View listItem = convertView; - if (getItemViewType(position) == VIEW_TYPE_HEADER) { - TextView header = (TextView) listItem.findViewById(R.id.name); - } else if (getItemViewType(position) == VIEW_TYPE_BOOLEAN) { - TextView filterName = (TextView) listItem.findViewById(R.id.name); - } else { - TextView filterName = (TextView) listItem.findViewById(R.id.name); - } - } - - protected void ok_branch_1() { - if (true) { - view1 = findViewById(R.id.textView1); - } else { - view2 = findViewById(R.id.textView1); - } - } - - protected void error_branch_1() { - if (true) { - view1 = findViewById(R.id.textView1); - } - if (true) { - view2 = findViewById(R.id.textView1); - } - } - - protected void error_branch_2() { - view1 = findViewById(R.id.textView1); - if (true) { - view2 = findViewById(R.id.textView1); - } - } - - protected void error_branch_3() { - view1 = findViewById(R.id.textView1); - if (true) { - } else { - view2 = findViewById(R.id.textView1); - } - } - - protected void error_branch_4() { - view1 = findViewById(R.id.textView1); - if (true) { - } else { - if (true) { - view2 = findViewById(R.id.textView1); - } - } - } - - protected void ok_branch_2() { - if (true) { - view1 = findViewById(R.id.textView1); - } else { - if (true) { - view2 = findViewById(R.id.textView1); - } - } - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SdCardTest.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SdCardTest.java.txt deleted file mode 100644 index 2087857..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SdCardTest.java.txt +++ /dev/null @@ -1,36 +0,0 @@ -package test.pkg; - -import java.io.File; - -import android.content.Intent; -import android.net.Uri; - -/** - * Ignore comments - create("/sdcard/foo") - */ -public class SdCardTest { - private static final boolean PROFILE_STARTUP = true; - private static final String SDCARD_TEST_HTML = "/sdcard/test.html"; - public static final String SDCARD_ROOT = "/sdcard"; - public static final String PACKAGES_PATH = "/sdcard/o/packages/"; - File deviceDir = new File("/sdcard/vr"); - - public SdCardTest() { - if (PROFILE_STARTUP) { - android.os.Debug.startMethodTracing("/sdcard/launcher"); - } - if (new File("/sdcard").exists()) { - } - String FilePath = "/sdcard/" + new File("test"); - System.setProperty("foo.bar", "file://sdcard"); - - - Intent intent = new Intent(Intent.ACTION_PICK); - intent.setDataAndType(Uri.parse("file://sdcard/foo.json"), "application/bar-json"); - intent.putExtra("path-filter", "/sdcard(/.+)*"); - intent.putExtra("start-dir", "/sdcard"); - String mypath = "/data/data/foo"; - String base = "/data/data/foo.bar/test-profiling"; - String s = "file://sdcard/foo"; - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SetJavaScriptEnabled.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SetJavaScriptEnabled.java.txt deleted file mode 100644 index ad8383a..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SetJavaScriptEnabled.java.txt +++ /dev/null @@ -1,28 +0,0 @@ -package com.company.something; - -import android.app.Activity; -import android.os.Bundle; -import android.webkit.WebView; - -public class HelloWebApp extends Activity { - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.main); - WebView webView = (WebView)findViewById(R.id.webView); - webView.getSettings().setJavaScriptEnabled(true); // bad - webView.getSettings().setJavaScriptEnabled(false); // good - webView.loadUrl("file:///android_asset/www/index.html"); - } - - // Test Suppress - // Constructor: See issue 35588 - @SuppressLint("SetJavaScriptEnabled") - public HelloWebApp() { - WebView webView = (WebView)findViewById(R.id.webView); - webView.getSettings().setJavaScriptEnabled(true); // bad - webView.getSettings().setJavaScriptEnabled(false); // good - webView.loadUrl("file:///android_asset/www/index.html"); - } -}
\ No newline at end of file diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SharedPrefsTest.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SharedPrefsTest.java.txt deleted file mode 100644 index 5261e34..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SharedPrefsTest.java.txt +++ /dev/null @@ -1,66 +0,0 @@ -package foo.bar; - -import android.app.Activity; -import android.content.Context; -import android.os.Bundle; -import android.widget.Toast; - -public class SharedPrefsText { - // OK 1 - public void onCreate1(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); - SharedPreferences.Editor editor = preferences.edit(); - editor.putString("foo", "bar"); - editor.putInt("bar", 42); - editor.commit(); - } - - // OK 2 - public void onCreate2(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); - SharedPreferences.Editor editor = preferences.edit(); - editor.putString("foo", "bar"); - editor.putInt("bar", 42); - if (apply) { - editor.apply(); - } - } - - // OK 3 - public boolean test1(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); - SharedPreferences.Editor editor = preferences.edit(); - editor.putString("foo", "bar"); - editor.putInt("bar", 42); - return editor.apply(); - } - - // Not a bug - public void test(Foo foo) { - Bar bar1 = foo.edit(); - Bar bar2 = Foo.edit(); - Bar bar3 = edit(); - SharedPreferences.Editor editor = preferences.edit(42); - apply(); - } - - // Bug - public void bug1(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); - SharedPreferences.Editor editor = preferences.edit(); - editor.putString("foo", "bar"); - editor.putInt("bar", 42); - } - - // Constructor test - public SharedPrefsText(Context context) { - SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); - SharedPreferences.Editor editor = preferences.edit(); - editor.putString("foo", "bar"); - } - } - diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SharedPrefsTest2.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SharedPrefsTest2.java.txt deleted file mode 100644 index 20c3a21..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SharedPrefsTest2.java.txt +++ /dev/null @@ -1,19 +0,0 @@ -package test.pkg; - -import android.annotation.SuppressLint; -import android.app.Activity; -import android.content.SharedPreferences; -import android.content.SharedPreferences.Editor; -import android.os.Bundle; -import android.preference.PreferenceManager; - -@SuppressWarnings("unused") -public class SharedPrefsTest2 extends Activity { - public void test1(SharedPreferences preferences) { - SharedPreferences.Editor editor = preferences.edit(); - } - - public void test2(SharedPreferences preferences) { - Editor editor = preferences.edit(); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SharedPrefsTest3.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SharedPrefsTest3.java.txt deleted file mode 100644 index e5baa00..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SharedPrefsTest3.java.txt +++ /dev/null @@ -1,15 +0,0 @@ -package test.pkg; - -import android.annotation.SuppressLint; -import android.app.Activity; -import android.content.SharedPreferences; -import android.content.SharedPreferences.*; -import android.os.Bundle; -import android.preference.PreferenceManager; - -@SuppressWarnings("unused") -public class SharedPrefsTest3 extends Activity { - public void test(SharedPreferences preferences) { - Editor editor = preferences.edit(); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SharedPrefsTest4.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SharedPrefsTest4.java.txt deleted file mode 100644 index 28de959..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SharedPrefsTest4.java.txt +++ /dev/null @@ -1,15 +0,0 @@ -package test.pkg; - -import android.annotation.SuppressLint; -import android.app.Activity; -import android.content.SharedPreferences; -import foo.bar.Editor; -import android.os.Bundle; -import android.preference.PreferenceManager; - -@SuppressWarnings("unused") -public class SharedPrefsTest4 extends Activity { - public void test(SharedPreferences preferences) { - Editor editor = preferences.edit(); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SharedPrefsTest5.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SharedPrefsTest5.java.txt deleted file mode 100644 index f005162..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SharedPrefsTest5.java.txt +++ /dev/null @@ -1,54 +0,0 @@ -package test.pkg; - -import android.content.Context; -import android.content.SharedPreferences; -import android.content.SharedPreferences.Editor; -import android.preference.PreferenceManager; - -@SuppressWarnings("unused") -class SharedPrefsTest5 { - SharedPreferences mPreferences; - private static final String PREF_FOO = "foo"; - private static final String PREF_BAZ = "bar"; - - private void wrong() { - // Field reference to preferences - mPreferences.edit().putString(PREF_FOO, "bar"); - mPreferences.edit().remove(PREF_BAZ).remove(PREF_FOO); - } - - private void ok() { - mPreferences.edit().putString(PREF_FOO, "bar").commit(); - mPreferences.edit().remove(PREF_BAZ).remove(PREF_FOO).commit(); - } - - private void wrong2(SharedPreferences preferences) { - preferences.edit().putString(PREF_FOO, "bar"); - preferences.edit().remove(PREF_BAZ).remove(PREF_FOO); - } - - private void wrong3(Context context) { - SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); - preferences.edit().putString(PREF_FOO, "bar"); - preferences.edit().remove(PREF_BAZ).remove(PREF_FOO); - } - - private void wrong4(Context context) { - SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); - Editor editor = preferences.edit().putString(PREF_FOO, "bar"); - } - - private void ok2(Context context) { - SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); - preferences.edit().putString(PREF_FOO, "bar").commit(); - } - - private final SharedPreferences mPrefs; - - public void ok3() { - final SharedPreferences.Editor editor = mPrefs.edit().putBoolean( - PREF_FOO, true); - editor.putString(PREF_BAZ, ""); - editor.apply(); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/StringFormat2.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/StringFormat2.java.txt deleted file mode 100644 index a09e44b..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/StringFormat2.java.txt +++ /dev/null @@ -1,14 +0,0 @@ -package test.pkg; - -import android.app.Activity; -import android.os.Bundle; - -public class StringFormat2 extends Activity { - public static final String buildUserAgent(Context context) { - StringBuilder arg = new StringBuilder(); - // Snip - final String base = context.getResources().getText(R.string.web_user_agent).toString(); - String ua = String.format(base, arg); - return ua; - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/StringFormat3.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/StringFormat3.java.txt deleted file mode 100644 index d1bfe44..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/StringFormat3.java.txt +++ /dev/null @@ -1,20 +0,0 @@ -package test.pkg; - -import android.app.Activity; - -public class StringFormat3 extends Activity { - public final void test(Context context) { - String s1 = String.format(Locale.FRANCE, - context.getString(R.string.gridview_views_count), article.playsCount); - String s2 = String.format(Locale.FRANCE, - context.getString(R.string.gridview_views_count), 5); - String s3 = String.format(Locale.FRANCE, - context.getString(R.string.gridview_views_count), "wrong"); - String s4 = String.format(context.getString(R.string.gridview_views_count), "wrong"); - String s5 = String.format(context.getString(R.string.gridview_views_count), 5); // OK - String s6 = String.format(Locale.getDefault(), - context.getString(R.string.gridview_views_count), 5); - String s7 = String.format(null, - context.getString(R.string.gridview_views_count), 5); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/StringFormatActivity.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/StringFormatActivity.java.txt deleted file mode 100644 index c22828f..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/StringFormatActivity.java.txt +++ /dev/null @@ -1,35 +0,0 @@ -package test.pkg; - -import android.app.Activity; -import android.os.Bundle; - -public class StringFormatActivity extends Activity { - /** Called when the activity is first created. */ - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - String target = "World"; - String hello = getResources().getString(R.string.hello); - String output1 = String.format(hello, target); - String hello2 = getResources().getString(R.string.hello2); - String output2 = String.format(hello2, target, "How are you"); - setContentView(R.layout.main); - String score = getResources().getString(R.string.score); - int points = 50; - boolean won = true; - String output3 = String.format(score, points); - String output4 = String.format(score, true); // wrong - String output4 = String.format(score, won); // wrong - String output5 = String.format(score, 75); - String.format(getResources().getString(R.string.hello2), target, "How are you"); - getResources().getString(hello2, target, "How are you"); - getResources().getString(R.string.hello2, target, "How are you"); - } - - // Test constructor handling (issue 35588) - public StringFormatActivity() { - String target = "World"; - String hello = getResources().getString(R.string.hello); - String output1 = String.format(hello, target); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/StringFormatActivity2.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/StringFormatActivity2.java.txt deleted file mode 100644 index c039dce..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/StringFormatActivity2.java.txt +++ /dev/null @@ -1,20 +0,0 @@ -package test.pkg; - -import android.app.Activity; -import android.os.Bundle; - -public class StringFormatActivity2 extends Activity { - /** Called when the activity is first created. */ - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - String target = "World"; - getResources().getString(R.string.formattest1, "hello"); - getResources().getString(R.string.formattest2, "hello"); - getResources().getString(R.string.formattest3, 42); - getResources().getString(R.string.formattest4, 42); - getResources().getString(R.string.formattest5, "hello"); - getResources().getString(R.string.formattest6, "hello"); - getResources().getString(R.string.formattest7, "hello"); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/StringFormatActivity_ignore.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/StringFormatActivity_ignore.java.txt deleted file mode 100644 index 58717dc..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/StringFormatActivity_ignore.java.txt +++ /dev/null @@ -1,27 +0,0 @@ -package test.pkg; - -import android.app.Activity; -import android.os.Bundle; -import android.annotations.tools.SuppressLint; - -public class StringFormatActivity extends Activity { - /** Called when the activity is first created. */ - @SuppressLint("all") - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - String target = "World"; - String hello = getResources().getString(R.string.hello); - String output1 = String.format(hello, target); - String hello2 = getResources().getString(R.string.hello2); - String output2 = String.format(hello2, target, "How are you"); - setContentView(R.layout.main); - String score = getResources().getString(R.string.score); - int points = 50; - boolean won = true; - String output3 = String.format(score, points); - String output4 = String.format(score, true); // wrong - String output4 = String.format(score, won); // wrong - String output5 = String.format(score, 75); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SuppressTest5.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SuppressTest5.java.txt deleted file mode 100644 index 1646216..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SuppressTest5.java.txt +++ /dev/null @@ -1,57 +0,0 @@ -package test.pkg; - -import android.annotations.tools.SuppressLint; - -@SuppressWarnings("unused") -public class SuppressTest5 { - private String suppressVariable() { - @SuppressLint("SdCardPath") - String string = "/sdcard/mypath1"; - return string; - } - - @SuppressLint("SdCardPath") - private String suppressMethod() { - String string = "/sdcard/mypath2"; - return string; - } - - @SuppressLint("SdCardPath") - private static class SuppressClass { - private String suppressMethod() { - String string = "/sdcard/mypath3"; - return string; - } - } - - private String suppressAll() { - @SuppressLint("all") - String string = "/sdcard/mypath4"; - return string; - } - - private String suppressCombination() { - @SuppressLint({"foo1", "foo2", "SdCardPath"}) - String string = "/sdcard/mypath5"; - - // This is NOT annotated and *should* generate - // a warning (here to make sure we don't just - // suppress everything when we see an annotation - String notAnnotated = "/sdcard/mypath"; - - return string; - } - - private String suppressWarnings() { - @SuppressWarnings("all") - String string = "/sdcard/mypath6"; - - @SuppressWarnings("SdCardPath") - String string2 = "/sdcard/mypath7"; - - return string; - } - - @SuppressLint("SdCardPath") - private String supressField = "/sdcard/mypath8"; -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/ToastTest.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/ToastTest.java.txt deleted file mode 100644 index ce8af3a..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/ToastTest.java.txt +++ /dev/null @@ -1,41 +0,0 @@ -package foo.bar; - -import android.app.Activity; -import android.content.Context; -import android.os.Bundle; -import android.widget.Toast; - -public class ToastTest { - private Toast createToast(Context context) { - // Don't warn here - return Toast.makeText(context, "foo", Toast.LENGTH_LONG); - } - - private void showToast(Context context) { - // Don't warn here - Toast toast = Toast.makeText(context, "foo", Toast.LENGTH_LONG); - System.out.println("Other intermediate code here"); - int temp = 5 + 2; - toast.show(); - } - - private void showToast2(Context context) { - // Don't warn here - int duration = Toast.LENGTH_LONG; - Toast.makeText(context, "foo", Toast.LENGTH_LONG).show(); - Toast.makeText(context, R.string.app_name, duration).show(); - } - - private void broken(Context context) { - // Errors - Toast.makeText(context, "foo", Toast.LENGTH_LONG); - Toast toast = Toast.makeText(context, R.string.app_name, 5000); - toast.getDuration(); - } - - // Constructor test - public ToastTest(Context context) { - Toast.makeText(context, "foo", Toast.LENGTH_LONG); - } -} - diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/UnusedReference.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/UnusedReference.java.txt deleted file mode 100644 index 5d7cb87..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/UnusedReference.java.txt +++ /dev/null @@ -1,12 +0,0 @@ -package test.pkg; - -import android.app.Activity; -import android.os.Bundle; - -public class UnusedReference extends Activity { - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(test.pkg.R.layout.main); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/Utf8BomTest.java.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/Utf8BomTest.java.data deleted file mode 100644 index c8fefcd..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/Utf8BomTest.java.data +++ /dev/null @@ -1,5 +0,0 @@ -package test.pkg; - -public class Utf8BomTest { - String s = "/sdcard/mydir"; -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/WorldWriteableFile.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/WorldWriteableFile.java.txt deleted file mode 100644 index 1e6285b..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/WorldWriteableFile.java.txt +++ /dev/null @@ -1,38 +0,0 @@ -package test.pkg; - -import java.io.File; -import java.io.IOException; -import java.io.OutputStream; -import java.io.InputStream; -import java.io.FileNotFoundException; -import android.content.Context; -import android.content.SharedPreferences; -import android.app.Activity; -import android.os.Bundle; - -public class WorldWriteableFile { - File mFile; - Context mContext; - - public void foo() { - OutputStream out = null; - SharedPreferences prefs = null; - - boolean success = false; - try { - out = openFileOutput(mFile.getName()); // ok - out = openFileOutput(mFile.getName(), MODE_PRIVATE); // ok - out = openFileOutput(mFile.getName(), MODE_WORLD_WRITEABLE); - out = openFileOutput(mFile.getName(), MODE_WORLD_READABLE); - - prefs = getSharedPreferences(mContext, 0); // ok - prefs = getSharedPreferences(mContext, MODE_PRIVATE); // ok - prefs = getSharedPreferences(mContext, MODE_WORLD_WRITEABLE); - prefs = getSharedPreferences(mContext, MODE_WORLD_READABLE); - // Flickr.get().downloadPhoto(params[0], Flickr.PhotoSize.LARGE, - // out); - success = true; - } catch (FileNotFoundException e) { - } - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/WrongAnnotation.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/WrongAnnotation.java.txt deleted file mode 100644 index 45743ce..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/WrongAnnotation.java.txt +++ /dev/null @@ -1,36 +0,0 @@ -package test.pkg; - -import android.annotation.SuppressLint; -import android.view.View; - -public class WrongAnnotation { - @Override - @SuppressLint("NewApi") // Valid: class-file check on method - public static void foobar(View view, @SuppressLint("NewApi") int foo) { // Invalid: class-file check - @SuppressLint("NewApi") // Invalid - boolean a; - @SuppressLint({"SdCardPath", "NewApi"}) // Invalid: class-file based check on local variable - boolean b; - @android.annotation.SuppressLint({"SdCardPath", "NewApi"}) // Invalid (FQN) - boolean c; - @SuppressLint("SdCardPath") // Valid: AST-based check - boolean d; - } - - @SuppressLint("NewApi") - private int field1; - - @SuppressLint("NewApi") - private int field2 = 5; - - static { - // Local variable outside method: invalid - @SuppressLint("NewApi") - int localvar = 5; - } - - private static void test() { - @SuppressLint("NewApi") // Invalid - int a = View.MEASURED_STATE_MASK; - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/WrongCastActivity.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/WrongCastActivity.java.txt deleted file mode 100644 index 45e53d0..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/WrongCastActivity.java.txt +++ /dev/null @@ -1,16 +0,0 @@ -package test.pkg; - -import android.app.Activity; -import android.os.Bundle; -import android.widget.*; - -public class WrongCastActivity extends Activity { - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.casts); - Button button = (Button) findViewById(R.id.button); - ToggleButton toggleButton = (ToggleButton) findViewById(R.id.button); - TextView textView = (TextView) findViewById(R.id.edittext); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/WrongCastActivity2.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/WrongCastActivity2.java.txt deleted file mode 100644 index 7cd422a..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/WrongCastActivity2.java.txt +++ /dev/null @@ -1,15 +0,0 @@ -package test.pkg; - -import android.app.*; -import android.view.*; -import android.widget.*; - -public class WrongCastActivity2 extends Activity { - private TextView additionalButton; - - private void configureAdditionalButton(View bodyView) { - this.additionalButton = (TextView) bodyView - .findViewById(R.id.additional); - Object x = (AdapterView<?>) bodyView.findViewById(R.id.reminder_lead); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/WrongCastActivity3.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/WrongCastActivity3.java.txt deleted file mode 100644 index 1701600..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/WrongCastActivity3.java.txt +++ /dev/null @@ -1,11 +0,0 @@ -package test.pkg; - -import android.app.*; -import android.view.*; -import android.widget.*; - -public class WrongCastActivity3 extends Activity { - private void test() { - final Checkable check = (Checkable) findViewById(R.id.additional); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/WrongColor.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/WrongColor.java.txt deleted file mode 100644 index cacd834..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/WrongColor.java.txt +++ /dev/null @@ -1,16 +0,0 @@ -package test.pkg; - -import android.view.*; -import android.widget.*; - -public class WrongColor { - public void foo(TextView textView) { - Paint paint2 = new Paint(); - paint2.setColor(R.color.blue); - // Wrong - textView.setTextColor(R.color.red); - textView.setTextColor(android.R.color.red); - // OK - textView.setTextColor(getResources().getColor(R.color.red)); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_not_found.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_not_found.xml deleted file mode 100644 index 9cd3640..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_not_found.xml +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="foo.bar2" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="14" /> - - <uses-permission android:name="com.example.helloworld.permission" /> - - <uses-feature android:name="android.hardware.wifi" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - <uses-library android:name="com.example.helloworld" /> - <activity - android:label="@string/app_name" - android:name=".Foo2Activity" > - <intent-filter > - <action android:name="android.intent.action.MAIN" /> - - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - </application> - -</manifest>
\ No newline at end of file diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_feature.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_feature.xml deleted file mode 100644 index cff7f2e..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_feature.xml +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="foo.bar2" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="14" /> - - <uses-permission android:name="com.example.helloworld.permission" /> - - <use-feature android:name="android.hardware.wifi" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - <uses-library android:name="com.example.helloworld" /> - <activity - android:label="@string/app_name" - android:name=".Foo2Activity" > - <intent-filter > - <action android:name="android.intent.action.MAIN" /> - - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - </application> - -</manifest>
\ No newline at end of file diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_feature2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_feature2.xml deleted file mode 100644 index d4d8f6e..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_feature2.xml +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="foo.bar2" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="14" /> - - <uses-permission android:name="com.example.helloworld.permission" /> - - <user-feature android:name="android.hardware.wifi" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - <uses-library android:name="com.example.helloworld" /> - <activity - android:label="@string/app_name" - android:name=".Foo2Activity" > - <intent-filter > - <action android:name="android.intent.action.MAIN" /> - - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - </application> - -</manifest>
\ No newline at end of file diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_library.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_library.xml deleted file mode 100644 index 5273642..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_library.xml +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="foo.bar2" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="14" /> - - <uses-permission android:name="com.example.helloworld.permission" /> - - <uses-feature android:name="android.hardware.wifi" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - <use-library android:name="com.example.helloworld" /> - <activity - android:label="@string/app_name" - android:name=".Foo2Activity" > - <intent-filter > - <action android:name="android.intent.action.MAIN" /> - - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - </application> - -</manifest>
\ No newline at end of file diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_library2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_library2.xml deleted file mode 100644 index 966caf4..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_library2.xml +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="foo.bar2" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="14" /> - - <uses-permission android:name="com.example.helloworld.permission" /> - - <uses-feature android:name="android.hardware.wifi" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - <user-library android:name="com.example.helloworld" /> - <activity - android:label="@string/app_name" - android:name=".Foo2Activity" > - <intent-filter > - <action android:name="android.intent.action.MAIN" /> - - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - </application> - -</manifest>
\ No newline at end of file diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_permission.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_permission.xml deleted file mode 100644 index 18a31ae..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_permission.xml +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="foo.bar2" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="14" /> - - <use-permission android:name="com.example.helloworld.permission" /> - - <uses-feature android:name="android.hardware.wifi" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - <uses-library android:name="com.example.helloworld" /> - <activity - android:label="@string/app_name" - android:name=".Foo2Activity" > - <intent-filter > - <action android:name="android.intent.action.MAIN" /> - - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - </application> - -</manifest>
\ No newline at end of file diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_permission2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_permission2.xml deleted file mode 100644 index 2f070c5..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_permission2.xml +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="foo.bar2" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="14" /> - - <user-permission android:name="com.example.helloworld.permission" /> - - <uses-feature android:name="android.hardware.wifi" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - <uses-library android:name="com.example.helloworld" /> - <activity - android:label="@string/app_name" - android:name=".Foo2Activity" > - <intent-filter > - <action android:name="android.intent.action.MAIN" /> - - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - </application> - -</manifest>
\ No newline at end of file diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_sdk.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_sdk.xml deleted file mode 100644 index c086515..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_sdk.xml +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="foo.bar2" - android:versionCode="1" - android:versionName="1.0" > - - <use-sdk android:minSdkVersion="14" /> - - <uses-permission android:name="com.example.helloworld.permission" /> - - <uses-feature android:name="android.hardware.wifi" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - <uses-library android:name="com.example.helloworld" /> - <activity - android:label="@string/app_name" - android:name=".Foo2Activity" > - <intent-filter > - <action android:name="android.intent.action.MAIN" /> - - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - </application> - -</manifest>
\ No newline at end of file diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_sdk2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_sdk2.xml deleted file mode 100644 index 148a3fc..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_sdk2.xml +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="foo.bar2" - android:versionCode="1" - android:versionName="1.0" > - - <user-sdk android:minSdkVersion="14" /> - - <uses-permission android:name="com.example.helloworld.permission" /> - - <uses-feature android:name="android.hardware.wifi" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - <uses-library android:name="com.example.helloworld" /> - <activity - android:label="@string/app_name" - android:name=".Foo2Activity" > - <intent-filter > - <action android:name="android.intent.action.MAIN" /> - - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - </application> - -</manifest>
\ No newline at end of file diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/unusedR.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/unusedR.java.txt deleted file mode 100644 index 3eae431..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/unusedR.java.txt +++ /dev/null @@ -1,14 +0,0 @@ -/* AUTO-GENERATED FILE. DO NOT MODIFY. - * - * This class was automatically generated by the - * aapt tool from the resource data it found. It - * should not be modified by hand. - */ - -package my.pkg; - -public final class R { - public static final class attr { - public static final int contentId=0x7f020000; - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/wrongid/ids.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/wrongid/ids.xml deleted file mode 100644 index 07e8ae9..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/wrongid/ids.xml +++ /dev/null @@ -1,6 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources> - - <item name="my_id1" type="id"/> - -</resources> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/wrongid/ignorelayout1.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/wrongid/ignorelayout1.xml deleted file mode 100644 index bc6d5fd..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/wrongid/ignorelayout1.xml +++ /dev/null @@ -1,47 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:tools="http://schemas.android.com/tools" - android:id="@+id/RelativeLayout1" - android:layout_width="fill_parent" - android:layout_height="fill_parent" - android:orientation="vertical" > - - <!-- my_id1 is defined in ids.xml, my_id2 is defined in main2, my_id3 does not exist --> - - <Button - android:id="@+id/button1" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignBottom="@+id/button5" - android:layout_alignLeft="@+id/my_id2" - android:layout_alignParentTop="true" - android:layout_alignRight="@+id/my_id3" - android:layout_alignTop="@+id/my_id1" - android:text="Button" - tools:ignore="UnknownIdInLayout,UnknownId" /> - - <Button - android:id="@+id/button2" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignParentLeft="true" - android:layout_below="@+id/button1" - android:text="Button" /> - - <Button - android:id="@+id/button3" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignParentLeft="true" - android:layout_below="@+id/button2" - android:text="Button" /> - - <Button - android:id="@+id/button4" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignParentLeft="true" - android:layout_below="@+id/button3" - android:text="Button" /> - -</RelativeLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/wrongid/layout1.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/wrongid/layout1.xml deleted file mode 100644 index 073dddd..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/wrongid/layout1.xml +++ /dev/null @@ -1,45 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:id="@+id/RelativeLayout1" - android:layout_width="fill_parent" - android:layout_height="fill_parent" - android:orientation="vertical" > - - <!-- my_id1 is defined in ids.xml, my_id2 is defined in main2, my_id3 does not exist --> - - <Button - android:id="@+id/button1" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignBottom="@+id/button5" - android:layout_alignLeft="@+id/my_id2" - android:layout_alignParentTop="true" - android:layout_alignRight="@+id/my_id3" - android:layout_alignTop="@+id/my_id1" - android:text="Button" /> - - <Button - android:id="@+id/button2" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignParentLeft="true" - android:layout_below="@+id/button1" - android:text="Button" /> - - <Button - android:id="@+id/button3" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignParentLeft="true" - android:layout_below="@+id/button2" - android:text="Button" /> - - <Button - android:id="@+id/button4" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignParentLeft="true" - android:layout_below="@+id/button3" - android:text="Button" /> - -</RelativeLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/wrongid/layout2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/wrongid/layout2.xml deleted file mode 100644 index 54dd91a..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/wrongid/layout2.xml +++ /dev/null @@ -1,13 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:orientation="vertical" > - - <Button - android:id="@+id/my_id2" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Button" /> - -</LinearLayout> diff --git a/lint/cli/src/test/java/com/android/tools/lint/client/api/DefaultSdkInfoTest.java b/lint/cli/src/test/java/com/android/tools/lint/client/api/DefaultSdkInfoTest.java deleted file mode 100644 index afdc985..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/client/api/DefaultSdkInfoTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.client.api; - -import junit.framework.TestCase; - -@SuppressWarnings("javadoc") -public class DefaultSdkInfoTest extends TestCase { - public void testGetParentClass() { - DefaultSdkInfo info = new DefaultSdkInfo(); - assertNull(info.getParentViewClass("android.view.View")); - assertEquals("android.view.View", info.getParentViewClass("android.view.ViewGroup")); - assertEquals("android.view.ViewGroup", - info.getParentViewClass("android.widget.LinearLayout")); - assertEquals("android.widget.LinearLayout", - info.getParentViewClass("android.widget.TableLayout")); - } - - public void testGetParentName() { - DefaultSdkInfo info = new DefaultSdkInfo(); - assertNull(info.getParentViewName("View")); - assertEquals("View", info.getParentViewName("ViewGroup")); - assertEquals("ViewGroup", info.getParentViewName("LinearLayout")); - assertEquals("LinearLayout", info.getParentViewName("TableLayout")); - } - - public void testIsSubViewOf() { - DefaultSdkInfo info = new DefaultSdkInfo(); - assertTrue(info.isSubViewOf("Button", "Button")); - assertTrue(info.isSubViewOf("TextView", "Button")); - assertTrue(info.isSubViewOf("TextView", "RadioButton")); - assertTrue(info.isSubViewOf("AdapterView", "Spinner")); - assertTrue(info.isSubViewOf("AdapterView<?>", "Spinner")); - assertFalse(info.isSubViewOf("Button", "TextView")); - assertFalse(info.isSubViewOf("CheckBox", "ToggleButton")); - assertFalse(info.isSubViewOf("ToggleButton", "CheckBox")); - assertTrue(info.isSubViewOf("LinearLayout", "LinearLayout")); - assertTrue(info.isSubViewOf("LinearLayout", "TableLayout")); - assertFalse(info.isSubViewOf("TableLayout", "LinearLayout")); - assertTrue(info.isSubViewOf("TextView", "EditText")); - assertFalse(info.isSubViewOf("EditText", "TextView")); - assertTrue(info.isSubViewOf("View", "TextView")); - assertFalse(info.isSubViewOf("TextView", "View")); - assertFalse(info.isSubViewOf("Spinner", "AdapterView<?>")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/client/api/LintClientTest.java b/lint/cli/src/test/java/com/android/tools/lint/client/api/LintClientTest.java deleted file mode 100644 index a4376d8..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/client/api/LintClientTest.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.client.api; - -import com.android.tools.lint.Main; - -import junit.framework.TestCase; - -@SuppressWarnings("javadoc") -public class LintClientTest extends TestCase { - public void test() throws Exception { - Main client = new Main(); - int max = client.getHighestKnownApiLevel(); - assertTrue(max >= 16); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/client/api/LintDriverTest.java b/lint/cli/src/test/java/com/android/tools/lint/client/api/LintDriverTest.java deleted file mode 100644 index f4dba93..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/client/api/LintDriverTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.client.api; - -import com.android.tools.lint.client.api.LintDriver.ClassEntry; - -import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import junit.framework.TestCase; - -@SuppressWarnings("javadoc") -public class LintDriverTest extends TestCase { - public void testClassEntryCompare() throws Exception { - ClassEntry c0 = new ClassEntry(new File("/a1/Foo.class"), null, null, null); - ClassEntry c1 = new ClassEntry(new File("/a1/Foo.clazz"), null, null, null); - ClassEntry c2 = new ClassEntry(new File("/a1/Foo$Inner1.class"), null, null, null); - ClassEntry c3 = new ClassEntry(new File("/a1/Foo$Inner1$Inner.class"), null, null, null); - ClassEntry c4 = new ClassEntry(new File("/a2/Foo$Inner2.clas"), null, null, null); - ClassEntry c5 = new ClassEntry(new File("/a2/Foo$Inner2.class"), null, null, null); - - List<ClassEntry> expected = Arrays.asList(c0, c1, c2, c3, c4, c5); - List<ClassEntry> list = new ArrayList<ClassEntry>(expected); - Collections.sort(list); - assertEquals(list, list); - - List<ClassEntry> list2 = Arrays.asList(c5, c4, c3, c2, c1, c0); - Collections.sort(list2); - assertEquals(expected, list2); - - List<ClassEntry> list3 = Arrays.asList(c3, c0, c1, c5, c2, c4); - Collections.sort(list3); - assertEquals(expected, list3); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/client/api/ProjectTest.java b/lint/cli/src/test/java/com/android/tools/lint/client/api/ProjectTest.java deleted file mode 100644 index 4f3c9ef..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/client/api/ProjectTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.client.api; - -import com.android.tools.lint.checks.AbstractCheckTest; -import com.android.tools.lint.checks.UnusedResourceDetector; -import com.android.tools.lint.detector.api.Detector; - -import java.io.File; -import java.util.Arrays; - -public class ProjectTest extends AbstractCheckTest { - @Override - protected boolean ignoreSystemErrors() { - return false; - } - - public void testCycle() throws Exception { - // Ensure that a cycle in library project dependencies doesn't cause - // infinite directory traversal - File master = getProjectDir("MasterProject", - // Master project - "multiproject/main-manifest.xml=>AndroidManifest.xml", - "multiproject/main.properties=>project.properties", - "multiproject/MainCode.java.txt=>src/foo/main/MainCode.java" - ); - File library = getProjectDir("LibraryProject", - // Library project - "multiproject/library-manifest.xml=>AndroidManifest.xml", - "multiproject/main.properties=>project.properties", // RECURSIVE - points to self - "multiproject/LibraryCode.java.txt=>src/foo/library/LibraryCode.java", - "multiproject/strings.xml=>res/values/strings.xml" - ); - - assertEquals("" - + "MasterProject/project.properties: Error: Circular library dependencies; check your project.properties files carefully [LintError]\n" - + "1 errors, 0 warnings\n", - - checkLint(Arrays.asList(master, library))); - } - - @Override - protected Detector getDetector() { - return new UnusedResourceDetector(); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/detector/api/ClassContextTest.java b/lint/cli/src/test/java/com/android/tools/lint/detector/api/ClassContextTest.java deleted file mode 100644 index 71c3486..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/detector/api/ClassContextTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.detector.api; - -import junit.framework.TestCase; - -@SuppressWarnings("javadoc") -public class ClassContextTest extends TestCase { - public void testCreateSignature() { - assertEquals("foo.bar.Foo.Bar", - ClassContext.createSignature("foo/bar/Foo$Bar", null, null)); - assertEquals("void foo.bar.Foo.Bar#name(int)", - ClassContext.createSignature("foo/bar/Foo$Bar", "name", "(I)V")); - assertEquals("void foo.bar.Foo.Bar#name(Integer)", - ClassContext.createSignature("foo/bar/Foo$Bar", "name", "(Ljava/lang/Integer;)V")); - } - - public void testGetInternalName() { - assertEquals("foo/bar/Foo$Bar", - ClassContext.getInternalName("foo.bar.Foo.Bar")); - } - - public void testGetFqcn() { - assertEquals("foo.bar.Foo.Bar", ClassContext.getFqcn("foo/bar/Foo$Bar")); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/detector/api/IssueTest.java b/lint/cli/src/test/java/com/android/tools/lint/detector/api/IssueTest.java deleted file mode 100644 index c8aaf12..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/detector/api/IssueTest.java +++ /dev/null @@ -1,222 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.detector.api; - -import static com.android.SdkConstants.AUTO_URI; -import static com.android.tools.lint.detector.api.Issue.convertMarkup; -import junit.framework.TestCase; - -@SuppressWarnings("javadoc") -public class IssueTest extends TestCase { - public void testConvertMarkup() throws Exception { - assertEquals("", convertMarkup("", true)); - - // Normal escapes - assertEquals("foo bar", convertMarkup("foo bar", true)); - assertEquals("foo<br/>\nbar", convertMarkup("foo\nbar", true)); - assertEquals("foo<br/>\nbar", convertMarkup("foo\nbar", true)); - assertEquals("<&>'\"", convertMarkup("<&>'\"", true)); - - // HTML Formatting - assertEquals("<code>@TargetApi(11)</code>, ", convertMarkup("`@TargetApi(11)`, ", - true)); - assertEquals("with <code>getArguments()</code>.", - convertMarkup("with `getArguments()`.", - true)); - assertEquals("(<code>dip</code>)", convertMarkup("(`dip`)", true)); - assertEquals(" <code>0dp</code> ", convertMarkup(" `0dp` ", true)); - assertEquals( - "resources under <code>$ANDROID_SK/platforms/android-$VERSION/data/res/.</code>", - convertMarkup( - "resources under `$ANDROID_SK/platforms/android-$VERSION/data/res/.`", - true)); - assertEquals("wrong format. Instead of <code>-keepclasseswithmembernames</code> use ", - convertMarkup("wrong format. Instead of `-keepclasseswithmembernames` use ", - true)); - assertEquals("<code>exported=false</code>)", convertMarkup("`exported=false`)", - true)); - assertEquals("by setting <code>inputType=\"text\"</code>.", - convertMarkup("by setting `inputType=\"text\"`.", true)); - assertEquals("* <code>View(Context context)</code><br/>\n", - convertMarkup("* `View(Context context)`\n", true)); - assertEquals("The <code>@+id/</code> syntax", convertMarkup("The `@+id/` syntax", - true)); - assertEquals("", convertMarkup("", true)); - assertEquals("", convertMarkup("", true)); - assertEquals("This is <b>bold</b>", convertMarkup("This is *bold*", true)); - assertEquals("Visit <a href=\"http://google.com\">http://google.com</a>.", - convertMarkup("Visit http://google.com.", true)); - assertEquals("This is <code>monospace</code>!", convertMarkup("This is `monospace`!", - true)); - assertEquals( - "See <a href=\"http://developer.android.com/reference/android/view/" + - "WindowManager.LayoutParams.html#FLAG_KEEP_SCREEN_ON\">http://developer." + - "android.com/reference/android/view/WindowManager.LayoutParams.html#" + - "FLAG_KEEP_SCREEN_ON</a>.", - convertMarkup( - "See http://developer.android.com/reference/android/view/WindowManager.Layout" + - "Params.html#FLAG_KEEP_SCREEN_ON.", true)); - - // Text formatting - assertEquals("@TargetApi(11), ", convertMarkup("`@TargetApi(11)`, ", false)); - assertEquals("with getArguments().", convertMarkup("with `getArguments()`.", false)); - assertEquals("bold", convertMarkup("*bold*", false)); - assertEquals("Visit http://google.com.", convertMarkup("Visit http://google.com.", - false)); - - // Corners (match at the beginning and end) - assertEquals("<b>bold</b>", convertMarkup("*bold*", true)); - assertEquals("<code>monospace</code>!", convertMarkup("`monospace`!", true)); - - // Not formatting - assertEquals("a*b", convertMarkup("a*b", true)); - assertEquals("a* b*", convertMarkup("a* b*", true)); - assertEquals("*a *b", convertMarkup("*a *b", true)); - assertEquals("Prefix is http:// ", convertMarkup("Prefix is http:// ", true)); - assertEquals("", convertMarkup("", true)); - assertEquals("", convertMarkup("", true)); - assertEquals("", convertMarkup("", true)); - assertEquals("", convertMarkup("", true)); - assertEquals("This is * not * bold", convertMarkup("This is * not * bold", true)); - assertEquals("* List item 1<br/>\n* List Item 2", - convertMarkup("* List item 1\n* List Item 2", true)); - assertEquals("myhttp://foo.bar", convertMarkup("myhttp://foo.bar", true)); - } - - public void testConvertMarkup2() throws Exception { - // http at the end: - // Explanation from ManifestOrderDetector#TARGET_NEWER - String explanation = - "When your application runs on a version of Android that is more recent than your " + - "targetSdkVersion specifies that it has been tested with, various compatibility " + - "modes kick in. This ensures that your application continues to work, but it may " + - "look out of place. For example, if the targetSdkVersion is less than 14, your " + - "app may get an option button in the UI.\n" + - "\n" + - "To fix this issue, set the targetSdkVersion to the highest available value. Then " + - "test your app to make sure everything works correctly. You may want to consult " + - "the compatibility notes to see what changes apply to each version you are adding " + - "support for: " + - "http://developer.android.com/reference/android/os/Build.VERSION_CODES.html"; - - assertEquals( - "When your application runs on a version of Android that is more recent than your " + - "targetSdkVersion specifies that it has been tested with, various compatibility " + - "modes kick in. This ensures that your application continues to work, but it may " + - "look out of place. For example, if the targetSdkVersion is less than 14, your " + - "app may get an option button in the UI.<br/>\n" + - "<br/>\n" + - "To fix this issue, set the targetSdkVersion to the highest available value. Then " + - "test your app to make sure everything works correctly. You may want to consult " + - "the compatibility notes to see what changes apply to each version you are adding " + - "support for: " + - "<a href=\"http://developer.android.com/reference/android/os/Build.VERSION_CODES." + - "html\">http://developer.android.com/reference/android/os/Build.VERSION_CODES.html" + - "</a>", - convertMarkup(explanation, true)); - } - - public void testConvertMarkup3() throws Exception { - // embedded http markup test - // Explanation from NamespaceDetector#CUSTOMVIEW - String explanation = - "When using a custom view with custom attributes in a library project, the layout " + - "must use the special namespace " + AUTO_URI + " instead of a URI which includes " + - "the library project's own package. This will be used to automatically adjust the " + - "namespace of the attributes when the library resources are merged into the " + - "application project."; - assertEquals( - "When using a custom view with custom attributes in a library project, the layout " + - "must use the special namespace " + - "<a href=\"http://schemas.android.com/apk/res-auto\">" + - "http://schemas.android.com/apk/res-auto</a> " + - "instead of a URI which includes the library project's own package. " + - "This will be used to automatically adjust the namespace of the attributes when " + - "the library resources are merged into the application project.", - convertMarkup(explanation, true)); - } - - public void testConvertMarkup4() throws Exception { - // monospace test - String explanation = - "The manifest should contain a `<uses-sdk>` element which defines the " + - "minimum minimum API Level required for the application to run, " + - "as well as the target version (the highest API level you have tested " + - "the version for.)"; - - assertEquals( - "The manifest should contain a <code><uses-sdk></code> element which defines the " + - "minimum minimum API Level required for the application to run, " + - "as well as the target version (the highest API level you have tested " + - "the version for.)", - convertMarkup(explanation, true)); - } - - public void testConvertMarkup5() throws Exception { - // monospace and bold test - // From ManifestOrderDetector#MULTIPLE_USES_SDK - String explanation = - "The `<uses-sdk>` element should appear just once; the tools will *not* merge the " + - "contents of all the elements so if you split up the atttributes across multiple " + - "elements, only one of them will take effect. To fix this, just merge all the " + - "attributes from the various elements into a single <uses-sdk> element."; - - assertEquals( - "The <code><uses-sdk></code> element should appear just once; the tools " + - "will <b>not</b> merge the " + - "contents of all the elements so if you split up the atttributes across multiple " + - "elements, only one of them will take effect. To fix this, just merge all the " + - "attributes from the various elements into a single <uses-sdk> element.", - convertMarkup(explanation, true)); - } - - public void testConvertMarkup6() throws Exception { - // Embedded code next to attributes - // From AlwaysShowActionDetector#ISSUE - String explanation = - "Using `showAsAction=\"always\"` in menu XML, or `MenuItem.SHOW_AS_ACTION_ALWAYS` in "+ - "Java code is usually a deviation from the user interface style guide." + - "Use `ifRoom` or the corresponding `MenuItem.SHOW_AS_ACTION_IF_ROOM` instead.\n" + - "\n" + - "If `always` is used sparingly there are usually no problems and behavior is " + - "roughly equivalent to `ifRoom` but with preference over other `ifRoom` " + - "items. Using it more than twice in the same menu is a bad idea.\n" + - "\n" + - "This check looks for menu XML files that contain more than two `always` " + - "actions, or some `always` actions and no `ifRoom` actions. In Java code, " + - "it looks for projects that contain references to `MenuItem.SHOW_AS_ACTION_ALWAYS` " + - "and no references to `MenuItem.SHOW_AS_ACTION_IF_ROOM`."; - - assertEquals( - "Using <code>showAsAction=\"always\"</code> in menu XML, or " + - "<code>MenuItem.SHOW_AS_ACTION_ALWAYS</code> in Java code is usually a deviation " + - "from the user interface style guide.Use <code>ifRoom</code> or the " + - "corresponding <code>MenuItem.SHOW_AS_ACTION_IF_ROOM</code> instead.<br/>\n" + - "<br/>\n" + - "If <code>always</code> is used sparingly there are usually no problems and " + - "behavior is roughly equivalent to <code>ifRoom</code> but with preference over " + - "other <code>ifRoom</code> items. Using it more than twice in the same menu " + - "is a bad idea.<br/>\n" + - "<br/>\n" + - "This check looks for menu XML files that contain more than two <code>always</code> " + - "actions, or some <code>always</code> actions and no <code>ifRoom</code> actions. " + - "In Java code, it looks for projects that contain references to " + - "<code>MenuItem.SHOW_AS_ACTION_ALWAYS</code> and no references to " + - "<code>MenuItem.SHOW_AS_ACTION_IF_ROOM</code>.", - convertMarkup(explanation, true)); - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/detector/api/LintUtilsTest.java b/lint/cli/src/test/java/com/android/tools/lint/detector/api/LintUtilsTest.java deleted file mode 100644 index 7dfa260..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/detector/api/LintUtilsTest.java +++ /dev/null @@ -1,359 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.detector.api; - -import static com.android.tools.lint.detector.api.LintUtils.getLocaleAndRegion; -import static com.android.tools.lint.detector.api.LintUtils.isImported; -import static com.android.tools.lint.detector.api.LintUtils.splitPath; - -import com.android.annotations.Nullable; -import com.android.tools.lint.LombokParser; -import com.android.tools.lint.Main; -import com.android.tools.lint.checks.BuiltinIssueRegistry; -import com.android.tools.lint.client.api.IJavaParser; -import com.android.tools.lint.client.api.LintDriver; -import com.google.common.collect.Iterables; - -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.OutputStreamWriter; -import java.util.Arrays; - -import junit.framework.TestCase; -import lombok.ast.Node; - -@SuppressWarnings("javadoc") -public class LintUtilsTest extends TestCase { - public void testPrintList() throws Exception { - assertEquals("foo, bar, baz", - LintUtils.formatList(Arrays.asList("foo", "bar", "baz"), 3)); - assertEquals("foo, bar, baz", - LintUtils.formatList(Arrays.asList("foo", "bar", "baz"), 5)); - - assertEquals("foo, bar, baz... (3 more)", - LintUtils.formatList( - Arrays.asList("foo", "bar", "baz", "4", "5", "6"), 3)); - assertEquals("foo... (5 more)", - LintUtils.formatList( - Arrays.asList("foo", "bar", "baz", "4", "5", "6"), 1)); - assertEquals("foo, bar, baz", - LintUtils.formatList(Arrays.asList("foo", "bar", "baz"), 0)); - } - - public void testEndsWith() throws Exception { - assertTrue(LintUtils.endsWith("Foo", "")); - assertTrue(LintUtils.endsWith("Foo", "o")); - assertTrue(LintUtils.endsWith("Foo", "oo")); - assertTrue(LintUtils.endsWith("Foo", "Foo")); - assertTrue(LintUtils.endsWith("Foo", "FOO")); - assertTrue(LintUtils.endsWith("Foo", "fOO")); - - assertFalse(LintUtils.endsWith("Foo", "f")); - } - - public void testStartsWith() throws Exception { - assertTrue(LintUtils.startsWith("FooBar", "Bar", 3)); - assertTrue(LintUtils.startsWith("FooBar", "BAR", 3)); - assertTrue(LintUtils.startsWith("FooBar", "Foo", 0)); - assertFalse(LintUtils.startsWith("FooBar", "Foo", 2)); - } - - public void testIsXmlFile() throws Exception { - assertTrue(LintUtils.isXmlFile(new File("foo.xml"))); - assertTrue(LintUtils.isXmlFile(new File("foo.Xml"))); - assertTrue(LintUtils.isXmlFile(new File("foo.XML"))); - - assertFalse(LintUtils.isXmlFile(new File("foo.png"))); - assertFalse(LintUtils.isXmlFile(new File("xml"))); - assertFalse(LintUtils.isXmlFile(new File("xml.png"))); - } - - public void testGetBasename() throws Exception { - assertEquals("foo", LintUtils.getBaseName("foo.png")); - assertEquals("foo", LintUtils.getBaseName("foo.9.png")); - assertEquals(".foo", LintUtils.getBaseName(".foo")); - } - - public void testEditDistance() { - assertEquals(0, LintUtils.editDistance("kitten", "kitten")); - - // editing kitten to sitting has edit distance 3: - // replace k with s - // replace e with i - // append g - assertEquals(3, LintUtils.editDistance("kitten", "sitting")); - - assertEquals(3, LintUtils.editDistance("saturday", "sunday")); - assertEquals(1, LintUtils.editDistance("button", "bitton")); - assertEquals(6, LintUtils.editDistance("radiobutton", "bitton")); - } - - public void testSplitPath() throws Exception { - assertTrue(Arrays.equals(new String[] { "/foo", "/bar", "/baz" }, - Iterables.toArray(splitPath("/foo:/bar:/baz"), String.class))); - - assertTrue(Arrays.equals(new String[] { "/foo", "/bar" }, - Iterables.toArray(splitPath("/foo;/bar"), String.class))); - - assertTrue(Arrays.equals(new String[] { "/foo", "/bar:baz" }, - Iterables.toArray(splitPath("/foo;/bar:baz"), String.class))); - - assertTrue(Arrays.equals(new String[] { "\\foo\\bar", "\\bar\\foo" }, - Iterables.toArray(splitPath("\\foo\\bar;\\bar\\foo"), String.class))); - - assertTrue(Arrays.equals(new String[] { "${sdk.dir}\\foo\\bar", "\\bar\\foo" }, - Iterables.toArray(splitPath("${sdk.dir}\\foo\\bar;\\bar\\foo"), - String.class))); - - assertTrue(Arrays.equals(new String[] { "${sdk.dir}/foo/bar", "/bar/foo" }, - Iterables.toArray(splitPath("${sdk.dir}/foo/bar:/bar/foo"), - String.class))); - - assertTrue(Arrays.equals(new String[] { "C:\\foo", "/bar" }, - Iterables.toArray(splitPath("C:\\foo:/bar"), String.class))); - } - - public void testCommonParen1() { - assertEquals(new File("/a"), (LintUtils.getCommonParent( - new File("/a/b/c/d/e"), new File("/a/c")))); - assertEquals(new File("/a"), (LintUtils.getCommonParent( - new File("/a/c"), new File("/a/b/c/d/e")))); - - assertEquals(new File("/"), LintUtils.getCommonParent( - new File("/foo/bar"), new File("/bar/baz"))); - assertEquals(new File("/"), LintUtils.getCommonParent( - new File("/foo/bar"), new File("/"))); - assertNull(LintUtils.getCommonParent( - new File("C:\\Program Files"), new File("F:\\"))); - assertNull(LintUtils.getCommonParent( - new File("C:/Program Files"), new File("F:/"))); - - assertEquals(new File("/foo/bar/baz"), LintUtils.getCommonParent( - new File("/foo/bar/baz"), new File("/foo/bar/baz"))); - assertEquals(new File("/foo/bar"), LintUtils.getCommonParent( - new File("/foo/bar/baz"), new File("/foo/bar"))); - assertEquals(new File("/foo/bar"), LintUtils.getCommonParent( - new File("/foo/bar/baz"), new File("/foo/bar/foo"))); - assertEquals(new File("/foo"), LintUtils.getCommonParent( - new File("/foo/bar"), new File("/foo/baz"))); - assertEquals(new File("/foo"), LintUtils.getCommonParent( - new File("/foo/bar"), new File("/foo/baz"))); - assertEquals(new File("/foo/bar"), LintUtils.getCommonParent( - new File("/foo/bar"), new File("/foo/bar/baz"))); - } - - public void testCommonParent2() { - assertEquals(new File("/"), LintUtils.getCommonParent( - Arrays.asList(new File("/foo/bar"), new File("/bar/baz")))); - assertEquals(new File("/"), LintUtils.getCommonParent( - Arrays.asList(new File("/foo/bar"), new File("/")))); - assertNull(LintUtils.getCommonParent( - Arrays.asList(new File("C:\\Program Files"), new File("F:\\")))); - assertNull(LintUtils.getCommonParent( - Arrays.asList(new File("C:/Program Files"), new File("F:/")))); - - assertEquals(new File("/foo"), LintUtils.getCommonParent( - Arrays.asList(new File("/foo/bar"), new File("/foo/baz")))); - assertEquals(new File("/foo"), LintUtils.getCommonParent( - Arrays.asList(new File("/foo/bar"), new File("/foo/baz"), - new File("/foo/baz/f")))); - assertEquals(new File("/foo/bar"), LintUtils.getCommonParent( - Arrays.asList(new File("/foo/bar"), new File("/foo/bar/baz"), - new File("/foo/bar/foo2/foo3")))); - } - - public void testStripIdPrefix() throws Exception { - assertEquals("foo", LintUtils.stripIdPrefix("@+id/foo")); - assertEquals("foo", LintUtils.stripIdPrefix("@id/foo")); - assertEquals("foo", LintUtils.stripIdPrefix("foo")); - } - - public void testIdReferencesMatch() throws Exception { - assertTrue(LintUtils.idReferencesMatch("@+id/foo", "@+id/foo")); - assertTrue(LintUtils.idReferencesMatch("@id/foo", "@id/foo")); - assertTrue(LintUtils.idReferencesMatch("@id/foo", "@+id/foo")); - assertTrue(LintUtils.idReferencesMatch("@+id/foo", "@id/foo")); - - assertFalse(LintUtils.idReferencesMatch("@+id/foo", "@+id/bar")); - assertFalse(LintUtils.idReferencesMatch("@id/foo", "@+id/bar")); - assertFalse(LintUtils.idReferencesMatch("@+id/foo", "@id/bar")); - assertFalse(LintUtils.idReferencesMatch("@+id/foo", "@+id/bar")); - - assertFalse(LintUtils.idReferencesMatch("@+id/foo", "@+id/foo1")); - assertFalse(LintUtils.idReferencesMatch("@id/foo", "@id/foo1")); - assertFalse(LintUtils.idReferencesMatch("@id/foo", "@+id/foo1")); - assertFalse(LintUtils.idReferencesMatch("@+id/foo", "@id/foo1")); - - assertFalse(LintUtils.idReferencesMatch("@+id/foo1", "@+id/foo")); - assertFalse(LintUtils.idReferencesMatch("@id/foo1", "@id/foo")); - assertFalse(LintUtils.idReferencesMatch("@id/foo1", "@+id/foo")); - assertFalse(LintUtils.idReferencesMatch("@+id/foo1", "@id/foo")); - } - - private static void checkEncoding(String encoding, boolean writeBom, String lineEnding) - throws Exception { - StringBuilder sb = new StringBuilder(); - - // Norwegian extra vowel characters such as "latin small letter a with ring above" - String value = "\u00e6\u00d8\u00e5"; - String expected = "First line." + lineEnding + "Second line." + lineEnding - + "Third line." + lineEnding + value + lineEnding; - sb.append(expected); - File file = File.createTempFile("getEncodingTest" + encoding + writeBom, ".txt"); - file.deleteOnExit(); - BufferedOutputStream stream = new BufferedOutputStream(new FileOutputStream(file)); - OutputStreamWriter writer = new OutputStreamWriter(stream, encoding); - - if (writeBom) { - String normalized = encoding.toLowerCase().replace("-", "_"); - if (normalized.equals("utf_8")) { - stream.write(0xef); - stream.write(0xbb); - stream.write(0xbf); - } else if (normalized.equals("utf_16")) { - stream.write(0xfe); - stream.write(0xff); - } else if (normalized.equals("utf_16le")) { - stream.write(0xff); - stream.write(0xfe); - } else if (normalized.equals("utf_32")) { - stream.write(0x0); - stream.write(0x0); - stream.write(0xfe); - stream.write(0xff); - } else if (normalized.equals("utf_32le")) { - stream.write(0xff); - stream.write(0xfe); - stream.write(0x0); - stream.write(0x0); - } else { - fail("Can't write BOM for encoding " + encoding); - } - } - writer.write(sb.toString()); - writer.close(); - - String s = LintUtils.getEncodedString(new Main(), file); - assertEquals(expected, s); - } - - public void testGetEncodedString() throws Exception { - checkEncoding("utf-8", false /*bom*/, "\n"); - checkEncoding("UTF-8", false /*bom*/, "\n"); - checkEncoding("UTF_16", false /*bom*/, "\n"); - checkEncoding("UTF-16", false /*bom*/, "\n"); - checkEncoding("UTF_16LE", false /*bom*/, "\n"); - - // Try BOM's - checkEncoding("utf-8", true /*bom*/, "\n"); - checkEncoding("UTF-8", true /*bom*/, "\n"); - checkEncoding("UTF_16", true /*bom*/, "\n"); - checkEncoding("UTF-16", true /*bom*/, "\n"); - checkEncoding("UTF_16LE", true /*bom*/, "\n"); - checkEncoding("UTF_32", true /*bom*/, "\n"); - checkEncoding("UTF_32LE", true /*bom*/, "\n"); - - // Make sure this works for \r and \r\n as well - checkEncoding("UTF-16", false /*bom*/, "\r"); - checkEncoding("UTF_16LE", false /*bom*/, "\r"); - checkEncoding("UTF-16", false /*bom*/, "\r\n"); - checkEncoding("UTF_16LE", false /*bom*/, "\r\n"); - checkEncoding("UTF-16", true /*bom*/, "\r"); - checkEncoding("UTF_16LE", true /*bom*/, "\r"); - checkEncoding("UTF_32", true /*bom*/, "\r"); - checkEncoding("UTF_32LE", true /*bom*/, "\r"); - checkEncoding("UTF-16", true /*bom*/, "\r\n"); - checkEncoding("UTF_16LE", true /*bom*/, "\r\n"); - checkEncoding("UTF_32", true /*bom*/, "\r\n"); - checkEncoding("UTF_32LE", true /*bom*/, "\r\n"); - } - - public void testGetLocaleAndRegion() throws Exception { - assertNull(getLocaleAndRegion("")); - assertNull(getLocaleAndRegion("values")); - assertNull(getLocaleAndRegion("values-xlarge-port")); - assertEquals("en", getLocaleAndRegion("values-en")); - assertEquals("pt-rPT", getLocaleAndRegion("values-pt-rPT-nokeys")); - assertEquals("zh-rCN", getLocaleAndRegion("values-zh-rCN-keyshidden")); - assertEquals("ms", getLocaleAndRegion("values-ms-keyshidden")); - } - - public void testIsImported() throws Exception { - assertFalse(isImported(getCompilationUnit( - "package foo.bar;\n" + - "class Foo {\n" + - "}\n"), - "android.app.Activity")); - - assertTrue(isImported(getCompilationUnit( - "package foo.bar;\n" + - "import foo.bar.*;\n" + - "import android.app.Activity;\n" + - "import foo.bar.Baz;\n" + - "class Foo {\n" + - "}\n"), - "android.app.Activity")); - - assertTrue(isImported(getCompilationUnit( - "package foo.bar;\n" + - "import android.app.Activity;\n" + - "class Foo {\n" + - "}\n"), - "android.app.Activity")); - - assertTrue(isImported(getCompilationUnit( - "package foo.bar;\n" + - "import android.app.*;\n" + - "class Foo {\n" + - "}\n"), - "android.app.Activity")); - - assertFalse(isImported(getCompilationUnit( - "package foo.bar;\n" + - "import android.app.*;\n" + - "import foo.bar.Activity;\n" + - "class Foo {\n" + - "}\n"), - "android.app.Activity")); - } - - private Node getCompilationUnit(String javaSource) { - IJavaParser parser = new LombokParser(); - TestContext context = new TestContext(javaSource, new File("test")); - Node compilationUnit = parser.parseJava(context); - assertNotNull(javaSource, compilationUnit); - return compilationUnit; - } - - private class TestContext extends JavaContext { - private final String mJavaSource; - public TestContext(String javaSource, File file) { - super(new LintDriver(new BuiltinIssueRegistry(), - new Main()), new Main().getProject(new File("dummy"), new File("dummy")), - null, file); - - mJavaSource = javaSource; - } - - @Override - @Nullable - public String getContents() { - return mJavaSource; - } - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/detector/api/LocationTest.java b/lint/cli/src/test/java/com/android/tools/lint/detector/api/LocationTest.java deleted file mode 100644 index 6404202..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/detector/api/LocationTest.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.detector.api; - -import java.io.File; -import java.io.IOException; - -import junit.framework.TestCase; - -@SuppressWarnings("javadoc") -public class LocationTest extends TestCase { - public void testReverse() throws IOException { - File file1 = new File("parent/location1"); - File file2 = new File("parent/location2"); - File file3 = new File("parent/location3"); - File file4 = new File("parent/location4"); - - Location location1 = Location.create(file1); - Location location2 = Location.create(file2); - Location location3 = Location.create(file3); - Location location4 = Location.create(file4); - - // 1-element location list - assertSame(location1, Location.reverse(location1)); - assertFalse(containsCycle(location1)); - - // 2-element location list - location1.setSecondary(location2); - assertSame(location2, Location.reverse(location1)); - assertFalse(containsCycle(location2)); - assertSame(location1, location2.getSecondary()); - - // 3-element location list - location1.setSecondary(location2); - location2.setSecondary(location3); - assertSame(location3, Location.reverse(location1)); - assertFalse(containsCycle(location3)); - assertSame(location2, location3.getSecondary()); - assertSame(location1, location2.getSecondary()); - - // 4-element location list - location1.setSecondary(location2); - location2.setSecondary(location3); - location3.setSecondary(location4); - assertSame(location4, Location.reverse(location1)); - assertFalse(containsCycle(location4)); - assertSame(location3, location4.getSecondary()); - assertSame(location2, location3.getSecondary()); - assertSame(location1, location2.getSecondary()); - } - - public void testFaen() throws Exception { - File[] paths = new File[] { - new File("values-zh-rTW/arrays.xml"), new File("values-zh-rCN/arrays.xml"), - new File("values-vi/arrays.xml"), new File("values-uk/arrays.xml"), - new File("values-tr/arrays.xml"), new File("values-tl/arrays.xml"), - new File("values-th/arrays.xml"), new File("values-sv/arrays.xml"), - new File("values-sr/arrays.xml"), new File("values-sl/arrays.xml"), - new File("values-sk/arrays.xml"), new File("values-ru/arrays.xml"), - new File("values-ro/arrays.xml"), new File("values-rm/arrays.xml"), - new File("values-pt-rPT/arrays.xml"), new File("values-pt/arrays.xml"), - new File("values-pl/arrays.xml"), new File("values-nl/arrays.xml"), - new File("values-nb/arrays.xml"), new File("values-lv/arrays.xml"), - new File("values-lt/arrays.xml"), new File("values-ko/arrays.xml"), - new File("values-ja/arrays.xml"), new File("values-iw/arrays.xml"), - new File("values-it/arrays.xml"), new File("values-in/arrays.xml"), - new File("values-hu/arrays.xml"), new File("values-hr/arrays.xml"), - new File("values-fr/arrays.xml"), new File("values-fi/arrays.xml"), - new File("values-fa/arrays.xml"), new File("values-es-rUS/arrays.xml"), - new File("values-es/arrays.xml"), new File("values-en-rGB/arrays.xml"), - new File("values-el/arrays.xml"), new File("values-de/arrays.xml"), - new File("values-da/arrays.xml"), new File("values-cs/arrays.xml"), - new File("values-ca/arrays.xml"), new File("values-bg/arrays.xml"), - new File("values-ar/arrays.xml"), new File("values/arrays.xml") - }; - - Location last = null; - for (int i = paths.length - 1; i >= 0; i--) { - Location location = Location.create(paths[i]); - location.setSecondary(last); - last = location; - } - - assertFalse(containsCycle(last)); - Location.reverse(last); - assertFalse(containsCycle(last)); - } - - private static boolean containsCycle(Location location) { - // Make sure there's no cycle: iterate - Location a = location; - Location b = location; - - while (true) { - b = b.getSecondary(); - if (b == null) { - // OK! Found list end - return false; - } - if (b == a) { - return true; - } - b = b.getSecondary(); - if (b == null) { - // OK! Found list end - return false; - } - if (b == a) { - return true; - } - - a = a.getSecondary(); - assert a != null; - } - } -} diff --git a/lint/cli/src/test/java/com/android/tools/lint/detector/api/ScopeTest.java b/lint/cli/src/test/java/com/android/tools/lint/detector/api/ScopeTest.java deleted file mode 100644 index e95c502..0000000 --- a/lint/cli/src/test/java/com/android/tools/lint/detector/api/ScopeTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tools.lint.detector.api; - -import java.util.EnumSet; - -import junit.framework.TestCase; - -@SuppressWarnings("javadoc") -public class ScopeTest extends TestCase { - public void testIntersect() { - assertEquals(Scope.RESOURCE_FILE_SCOPE, - Scope.intersect(Scope.RESOURCE_FILE_SCOPE, Scope.RESOURCE_FILE_SCOPE)); - - assertEquals(EnumSet.of(Scope.RESOURCE_FILE), - Scope.intersect( - EnumSet.of(Scope.RESOURCE_FILE), - EnumSet.of(Scope.RESOURCE_FILE))); - - assertEquals(EnumSet.of(Scope.RESOURCE_FILE), - Scope.intersect( - EnumSet.of(Scope.RESOURCE_FILE, Scope.JAVA_FILE), - EnumSet.of(Scope.RESOURCE_FILE))); - - assertEquals(EnumSet.of(Scope.JAVA_FILE), - Scope.intersect( - EnumSet.of(Scope.RESOURCE_FILE, Scope.JAVA_FILE), - EnumSet.of(Scope.JAVA_FILE))); - - assertEquals(EnumSet.of(Scope.RESOURCE_FILE), - Scope.intersect( - EnumSet.of(Scope.RESOURCE_FILE), - EnumSet.of(Scope.RESOURCE_FILE, Scope.JAVA_FILE))); - - assertEquals(EnumSet.of(Scope.JAVA_FILE), - Scope.intersect( - EnumSet.of(Scope.JAVA_FILE), - EnumSet.of(Scope.RESOURCE_FILE, Scope.JAVA_FILE))); - - assertTrue(Scope.intersect( - EnumSet.of(Scope.JAVA_FILE), EnumSet.of(Scope.RESOURCE_FILE)).isEmpty()); - } -} |