FileDocCategorySizeDatePackage
SignatureSourcerTest.javaAPI DocAndroid 1.5 API4647Wed May 06 22:41:10 BST 2009com.android.mkstubs.sourcer

SignatureSourcerTest

public class SignatureSourcerTest extends Object

Fields Summary
private SignatureSourcer
mSourcer
Constructors Summary
Methods Summary
public voidsetUp()

        mSourcer = new SignatureSourcer();
    
public voidtearDown()

    
public voidtestFormalParameters1()

        SignatureReader reader = new SignatureReader("<X:TT;Y:Ljava/lang/Object;>()V");
        reader.accept(mSourcer);

        Assert.assertTrue(mSourcer.hasFormalsContent());
        
        String result = mSourcer.formalsToString();
        Assert.assertEquals(
                "<X extends T, Y extends java.lang.Object>",
                result);
    
public voidtestFormalParameters2()

        SignatureReader reader = new SignatureReader("<T::Ljava/lang/Comparable<-TT;>;>(Ljava/util/List<TT;>;)V");
        reader.accept(mSourcer);

        Assert.assertTrue(mSourcer.hasFormalsContent());
        
        String result = mSourcer.formalsToString();
        Assert.assertEquals(
                "<T extends java.lang.Comparable<? super T>>",
                result);
    
public voidtestManyArgs()

        SignatureReader reader = new SignatureReader(
                "<X:TT;Y:Ljava/lang/Object;>(Ljava/util/List<TT;>;Ljava/util/Map<TT;TU;>;Ljava/util/Map<TX;Ljava/util/Set<-TY;>;>;)V");
        reader.accept(mSourcer);

        Assert.assertTrue(mSourcer.hasFormalsContent());
        String formals = mSourcer.formalsToString();
        Assert.assertEquals(
                "<X extends T, Y extends java.lang.Object>",
                formals);

        String result = mSourcer.getReturnType().toString();
        Assert.assertEquals(
                "void",
                result);
        
        ArrayList<SignatureSourcer> params = mSourcer.getParameters();
        Assert.assertNotNull(params);
        
        String[] array = toStringArray(params);

        Assert.assertArrayEquals(
                new String[] { "java.util.List<T>",
                               "java.util.Map<T, U>",
                               "java.util.Map<X, java.util.Set<? super Y>>" },
                array);
    
public voidtestReturnMapNoArgs()

        SignatureReader reader = new SignatureReader(
                "()Ljava/util/Map<Ljava/util/ArrayList<TT;>;Ljava/util/Map<Ljava/lang/String;Ljava/util/ArrayList<TU;>;>;>;");
        reader.accept(mSourcer);
        String result = mSourcer.getReturnType().toString();
        
        Assert.assertEquals(
                "java.util.Map<java.util.ArrayList<T>, java.util.Map<java.lang.String, java.util.ArrayList<U>>>",
                result);
    
public voidtestReturnVoid()

        SignatureReader reader = new SignatureReader(
                "(Ljava/util/List<+Lorg/w3c/dom/css/Rect;>;)V");
        reader.accept(mSourcer);
        String result = mSourcer.getReturnType().toString();
        
        Assert.assertEquals(
                "void",
                result);
    
public voidtestSimpleArg()

        SignatureReader reader = new SignatureReader(
                "(Ljava/util/List<+Lorg/w3c/dom/css/Rect;>;)V");
        reader.accept(mSourcer);
        
        ArrayList<SignatureSourcer> params = mSourcer.getParameters();
        Assert.assertNotNull(params);
        
        String[] array = toStringArray(params);

        Assert.assertArrayEquals(
                new String[] { "java.util.List<? extends org.w3c.dom.css.Rect>" },
                array);
    
private java.lang.String[]toStringArray(java.util.ArrayList params)

        String[] array = new String[params.size()];
        for (int i = 0; i < params.size(); i++) {
            array[i] = params.get(i).toString();
        }
        return array;