FileDocCategorySizeDatePackage
AsmGeneratorTest.javaAPI DocAndroid 1.5 API2812Wed May 06 22:42:02 BST 2009com.android.tools.layoutlib.create

AsmGeneratorTest

public class AsmGeneratorTest extends Object
Unit tests for some methods of {@link AsmGenerator}.

Fields Summary
private com.android.tools.layoutlib.create.LogTest.MockLog
mLog
private ArrayList
mOsJarPath
private String
mOsDestJar
private File
mTempFile
Constructors Summary
Methods Summary
public voidsetUp()

        mLog = new LogTest.MockLog();
        URL url = this.getClass().getClassLoader().getResource("data/mock_android.jar");
        
        mOsJarPath = new ArrayList<String>();
        mOsJarPath.add(url.getFile());

        mTempFile = File.createTempFile("mock", "jar");
        mOsDestJar = mTempFile.getAbsolutePath();
        mTempFile.deleteOnExit();
    
public voidtearDown()

        if (mTempFile != null) {
            mTempFile.delete();
            mTempFile = null;
        }
    
public voidtestClassRenaming()

        
        AsmGenerator agen = new AsmGenerator(mLog, mOsDestJar,
            null, // classes to inject in the final JAR
            null,  // methods to force override
            new String[] {  // classes to rename (so that we can replace them)
                "mock_android.view.View", "mock_android.view._Original_View",
                "not.an.actual.ClassName", "anoter.fake.NewClassName",
            },
            null // methods deleted from their return type.
            );

        AsmAnalyzer aa = new AsmAnalyzer(mLog, mOsJarPath, agen,
                null,                 // derived from
                new String[] {        // include classes
                    "**"
                });
        aa.analyze();
        agen.generate();
        
        Set<String> notRenamed = agen.getClassesNotRenamed();
        assertArrayEquals(new String[] { "not/an/actual/ClassName" }, notRenamed.toArray());