FileDocCategorySizeDatePackage
LayoutParamsParserTest.javaAPI DocAndroid 1.5 API7858Wed May 06 22:41:10 BST 2009com.android.ide.eclipse.adt.sdk

LayoutParamsParserTest

public class LayoutParamsParserTest extends TestCase
Test the inner private methods of PlatformDataParser. Convention: method names that start with an underscore are actually local wrappers that call private methods from {@link AndroidTargetParser} using reflection. This is inspired by the Python coding rule which mandates underscores prefixes for "private" methods.

Fields Summary
private MockLayoutParamsParser
mParser
Constructors Summary
Methods Summary
private AndroidTargetParser_Constructor(java.lang.String osJarPath)
Calls the private constructor of the parser

        Constructor<AndroidTargetParser> constructor =
            AndroidTargetParser.class.getDeclaredConstructor(String.class);
        constructor.setAccessible(true);
        return constructor.newInstance(osJarPath);
    
private com.android.ide.eclipse.common.resources.ViewClassInfo_addGroup(java.lang.Class groupClass)
calls the private addGroup() of the parser

        Method method = LayoutParamsParser.class.getDeclaredMethod("addGroup",  //$NON-NLS-1$
                IClassDescriptor.class);
        method.setAccessible(true);
        return (ViewClassInfo) method.invoke(mParser, new ClassWrapper(groupClass));
    
private com.android.ide.eclipse.common.resources.ViewClassInfo.LayoutParamsInfo_addLayoutParams(java.lang.Class groupClass)
calls the private addLayoutParams() of the parser

        Method method = LayoutParamsParser.class.getDeclaredMethod("addLayoutParams",   //$NON-NLS-1$
                IClassDescriptor.class);
        method.setAccessible(true);
        return (LayoutParamsInfo) method.invoke(mParser, new ClassWrapper(groupClass));
    
private com.android.ide.eclipse.adt.sdk.IAndroidClassLoader.IClassDescriptor_findLayoutParams(java.lang.Class groupClass)
calls the private findLayoutParams() of the parser

        Method method = LayoutParamsParser.class.getDeclaredMethod("findLayoutParams",  //$NON-NLS-1$
                IClassDescriptor.class);
        method.setAccessible(true);
        return (IClassDescriptor) method.invoke(mParser, new ClassWrapper(groupClass));
    
private void_getLayoutClasses()
calls the private getLayoutClasses() of the parser

        Method method = AndroidTargetParser.class.getDeclaredMethod("getLayoutClasses");  //$NON-NLS-1$
        method.setAccessible(true);
        method.invoke(mParser);
    
private com.android.ide.eclipse.common.resources.ViewClassInfo.LayoutParamsInfo_getLayoutParamsInfo(java.lang.Class layoutParamsClass)
calls the private getLayoutParamsInfo() of the parser

        Method method = LayoutParamsParser.class.getDeclaredMethod("getLayoutParamsInfo",   //$NON-NLS-1$
                IClassDescriptor.class);
        method.setAccessible(true);
        return (LayoutParamsInfo) method.invoke(mParser, new ClassWrapper(layoutParamsClass));
    
public voidsetUp()

        mParser = new MockLayoutParamsParser();
    
public voidtearDown()

    
public final voidtestFindLayoutParams()

        assertEquals(mock_android.view.ViewGroup.LayoutParams.class,
            ((ClassWrapper)_findLayoutParams(mock_android.view.ViewGroup.class)).wrappedClass());

        assertEquals(mock_android.widget.LinearLayout.LayoutParams.class,
            ((ClassWrapper)_findLayoutParams(mock_android.widget.LinearLayout.class)).wrappedClass());

        assertEquals(mock_android.widget.TableLayout.LayoutParams.class,
            ((ClassWrapper)_findLayoutParams(mock_android.widget.TableLayout.class)).wrappedClass());
    
public final voidtestGetLayoutClasses()

        // _getLayoutClasses();
    
public final voidtestGetLayoutParamsInfo()

        LayoutParamsInfo info1 = _getLayoutParamsInfo(
                mock_android.view.ViewGroup.LayoutParams.class);
        assertNotNull(info1);
        // ViewGroup.LayoutData has Object for superClass, which we don't map
        assertNull(info1.getSuperClass());

        LayoutParamsInfo info2 = _getLayoutParamsInfo(
                mock_android.widget.LinearLayout.LayoutParams.class);
        assertNotNull(info2);
        // LinearLayout.LayoutData links to ViewGroup.LayoutParams
        assertSame(info1, info2.getSuperClass());
        
        LayoutParamsInfo info3 = _getLayoutParamsInfo(
                mock_android.widget.TableLayout.LayoutParams.class);
        assertNotNull(info3);
        // TableLayout.LayoutData does not link to ViewGroup.LayoutParams nor
        // LinearLayout.LayoutParams
        assertNotSame(info1, info3.getSuperClass());
        assertNotSame(info2, info3.getSuperClass());
        // TableLayout.LayoutParams => ViewGroup.MarginLayoutParams => ViewGroup.LayoutParams
        assertSame(info1, info3.getSuperClass().getSuperClass());