FileDocCategorySizeDatePackage
DescriptorsUtilsTest.javaAPI DocAndroid 1.5 API5511Wed May 06 22:41:10 BST 2009com.android.ide.eclipse.editors.descriptors

DescriptorsUtilsTest

public class DescriptorsUtilsTest extends TestCase
Unit tests for DescriptorsUtils in the editors plugin

Fields Summary
Constructors Summary
Methods Summary
protected voidsetUp()

        super.setUp();
    
protected voidtearDown()

        super.tearDown();
    
public voidtestCapitalize()

        assertEquals("UPPER", DescriptorsUtils.capitalize("UPPER"));
        assertEquals("Lower", DescriptorsUtils.capitalize("lower"));
        assertEquals("Capital", DescriptorsUtils.capitalize("Capital"));
        assertEquals("CamelCase", DescriptorsUtils.capitalize("camelCase"));
        assertEquals("", DescriptorsUtils.capitalize(""));
    
public voidtestFormatFormText()

        ElementDescriptor desc = new ElementDescriptor("application");
        desc.setSdkUrl(DescriptorsUtils.MANIFEST_SDK_URL + "TagApplication");
        String docBaseUrl = "http://base";
        assertEquals("<form><li style=\"image\" value=\"image\"></li></form>", DescriptorsUtils.formatFormText("", desc, docBaseUrl));

        assertEquals("<form><li style=\"image\" value=\"image\"><a href=\"http://base/reference/android/R.styleable.html#TagApplication\">application</a></li></form>",
                DescriptorsUtils.formatFormText(
                        "<code>application</code>",
                        desc, docBaseUrl));

        assertEquals("<form><li style=\"image\" value=\"image\"><b>android.content.Intent</b></li></form>",
                DescriptorsUtils.formatFormText(
                        "{@link android.content.Intent}",
                        desc, docBaseUrl));

        assertEquals("<form><li style=\"image\" value=\"image\"><a href=\"http://base/reference/android/R.styleable.html#AndroidManifestPermission\">AndroidManifestPermission</a></li></form>",
                DescriptorsUtils.formatFormText(
                        "{@link #AndroidManifestPermission}",
                        desc, docBaseUrl));

        assertEquals("<form><li style=\"image\" value=\"image\"><a href=\"http://base/reference/android/R.styleable.html#AndroidManifestPermission\">\"permission\"</a></li></form>",
                DescriptorsUtils.formatFormText(
                        "{@link #AndroidManifestPermission <permission>}",
                        desc, docBaseUrl));
    
public voidtestFormatTooltip()

        assertEquals("", DescriptorsUtils.formatTooltip(""));

        assertEquals("\"application\"",
                DescriptorsUtils.formatTooltip(
                        "<code>application</code>"));

        assertEquals("android.content.Intent",
                DescriptorsUtils.formatTooltip(
                        "{@link android.content.Intent}"));
        
        assertEquals("FLAG_ACTIVITY_SINGLE_TOP",
                DescriptorsUtils.formatTooltip(
                        "{@link android.content.Intent#FLAG_ACTIVITY_SINGLE_TOP}"));
        
        assertEquals("activity-alias",
                DescriptorsUtils.formatTooltip(
                        "{@link \t  #AndroidManifestActivityAlias  \tactivity-alias }"));
        
        assertEquals("\"permission\"",
                DescriptorsUtils.formatTooltip(
                        "{@link #AndroidManifestPermission <permission>}"));
        
        assertEquals("and etc.",
                DescriptorsUtils.formatTooltip(
                        "{@link #IntentCategory <category> and etc. }"));
        
        assertEquals("Activity.onNewIntent()",
                DescriptorsUtils.formatTooltip(
                        "{@link android.app.Activity#onNewIntent Activity.onNewIntent()}"));
    
public voidtestPrettyAttributeUiName()

        assertEquals("", DescriptorsUtils.prettyAttributeUiName(""));

        assertEquals("Max width for view",
                DescriptorsUtils.prettyAttributeUiName("maxWidthForView"));

        assertEquals("Layout width",
                DescriptorsUtils.prettyAttributeUiName("layout_width"));

        // X Y and Z are capitalized when used as single words (so "T" becomes "t")
        assertEquals("Axis X", DescriptorsUtils.prettyAttributeUiName("axisX"));
        assertEquals("Axis Y", DescriptorsUtils.prettyAttributeUiName("axisY"));
        assertEquals("Axis Z", DescriptorsUtils.prettyAttributeUiName("axisZ"));
        assertEquals("Axis t", DescriptorsUtils.prettyAttributeUiName("axisT"));

        assertEquals("The X axis", DescriptorsUtils.prettyAttributeUiName("theXAxis"));
        assertEquals("The Y axis", DescriptorsUtils.prettyAttributeUiName("theYAxis"));
        assertEquals("The Z axis", DescriptorsUtils.prettyAttributeUiName("theZAxis"));
        assertEquals("The t axis", DescriptorsUtils.prettyAttributeUiName("theTAxis"));