The Android Open Source Project | f805710 | 2009-03-15 16:47:16 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package testprogress2; |
| 18 | |
| 19 | import com.sun.javadoc.AnnotationDesc; |
| 20 | import com.sun.javadoc.ClassDoc; |
| 21 | import com.sun.javadoc.MethodDoc; |
| 22 | |
| 23 | /** |
| 24 | * |
| 25 | */ |
| 26 | public class MethodOriginator implements Originator { |
| 27 | private final MethodDoc mMethod; |
| 28 | |
| 29 | private final String mComment; |
| 30 | |
| 31 | private final ClassDoc mClass; |
| 32 | |
| 33 | private String knownFailure = null; |
| 34 | |
| 35 | private String brokenTest = null; |
| 36 | |
| 37 | private String toBeFixed = null; |
| 38 | |
| 39 | /** |
| 40 | * @param testMethod |
| 41 | * @param clazz we need to provide the clazz since junit collects the |
| 42 | * testMethods from all super classes - and thus MethodDoc's |
| 43 | * class can point to a superclass. However, we want to know the |
| 44 | * class where the TestTargetClass is pointing to the API class. |
| 45 | * @param comment |
| 46 | */ |
| 47 | MethodOriginator(MethodDoc testMethod, ClassDoc clazz, String comment) { |
| 48 | mMethod = testMethod; |
| 49 | mComment = comment; |
| 50 | mClass = clazz; |
| 51 | |
| 52 | AnnotationDesc[] annots = testMethod.annotations(); |
| 53 | for (AnnotationDesc annot : annots) { |
| 54 | if (annot.annotationType().qualifiedName().equals( |
| 55 | "dalvik.annotation.KnownFailure")) { |
| 56 | knownFailure = "<b>@KnownFailure:</b>" |
| 57 | + (String)annot.elementValues()[0].value().value(); |
| 58 | } else if (annot.annotationType().qualifiedName().equals( |
| 59 | "dalvik.annotation.BrokenTest")) { |
| 60 | brokenTest = "<b>@BrokenTest:</b>" |
| 61 | + (String)annot.elementValues()[0].value().value(); |
| 62 | } else if (annot.annotationType().qualifiedName().equals( |
| 63 | "dalvik.annotation.ToBeFixed")) { |
Scott Su | d4bccd3 | 2009-04-02 23:55:10 -0700 | [diff] [blame] | 64 | String info = "N/A"; |
| 65 | if (annot.elementValues().length > 0) { |
| 66 | info = (String)annot.elementValues()[0].value().value(); |
| 67 | } |
| 68 | |
| 69 | toBeFixed = "<b>@ToBeFixed:</b>" + info; |
The Android Open Source Project | f805710 | 2009-03-15 16:47:16 -0700 | [diff] [blame] | 70 | } |
| 71 | // else some other annotation - ignore |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | /* |
| 76 | * (non-Javadoc) |
| 77 | * @see testprogress.Originator#asString() |
| 78 | */ |
| 79 | public String asString() { |
| 80 | return (mComment != null ? "comment:" + mComment + " - " : "") |
| 81 | + mClass.qualifiedName() + ": <b>" + mMethod.name() + "</b>" |
| 82 | + mMethod.signature() |
| 83 | + (brokenTest != null ? " [" + brokenTest + "]" : "") |
| 84 | + (toBeFixed != null ? " [" + toBeFixed + "]" : "") |
| 85 | + (knownFailure != null ? " [" + knownFailure + "]" : ""); |
| 86 | } |
| 87 | |
| 88 | public boolean isDisabled() { |
| 89 | return mMethod.name().startsWith("_test"); |
| 90 | } |
| 91 | |
| 92 | public String getBrokenTest() { |
| 93 | return brokenTest; |
| 94 | } |
| 95 | |
| 96 | public String getToBeFixed() { |
| 97 | return toBeFixed; |
| 98 | } |
| 99 | |
| 100 | public String getKnownFailure() { |
| 101 | return knownFailure; |
| 102 | } |
| 103 | |
| 104 | } |