AttrsXmlParserTestpublic class AttrsXmlParserTest extends TestCase
Fields Summary |
---|
private AttrsXmlParser | mParser | private String | mFilePath |
Methods Summary |
---|
private org.w3c.dom.Document | _getDocument()
Method method = AttrsXmlParser.class.getDeclaredMethod("getDocument"); //$NON-NLS-1$
method.setAccessible(true);
return (Document) method.invoke(mParser);
| public void | setUp()
mFilePath = AdtTestData.getInstance().getTestFilePath("mock_attrs.xml"); //$NON-NLS-1$
mParser = new AttrsXmlParser(mFilePath);
| public void | tearDown()
| public final void | testDeprecated()
mParser.preload();
DeclareStyleableInfo dep = mParser.getDeclareStyleableList().get("DeprecatedTest");
assertNotNull(dep);
AttributeInfo[] attrs = dep.getAttributes();
assertEquals(4, attrs.length);
assertEquals("deprecated-inline", attrs[0].getName());
assertEquals("In-line deprecated.", attrs[0].getDeprecatedDoc());
assertEquals("Deprecated comments using delimiters.", attrs[0].getJavaDoc());
assertEquals("deprecated-multiline", attrs[1].getName());
assertEquals("Multi-line version of deprecated that works till the next tag.",
attrs[1].getDeprecatedDoc());
assertEquals("Deprecated comments on their own line.", attrs[1].getJavaDoc());
assertEquals("deprecated-not", attrs[2].getName());
assertEquals(null, attrs[2].getDeprecatedDoc());
assertEquals("This attribute is not deprecated.", attrs[2].getJavaDoc());
assertEquals("deprecated-no-javadoc", attrs[3].getName());
assertEquals("There is no other javadoc here.", attrs[3].getDeprecatedDoc());
assertEquals("", attrs[3].getJavaDoc());
| public final void | testEnumFlagValues()
/* The XML being read contains:
<!-- Standard orientation constant. -->
<attr name="orientation">
<!-- Defines an horizontal widget. -->
<enum name="horizontal" value="0" />
<!-- Defines a vertical widget. -->
<enum name="vertical" value="1" />
</attr>
*/
mParser.preload();
Map<String, Map<String, Integer>> attrMap = mParser.getEnumFlagValues();
assertTrue(attrMap.containsKey("orientation"));
Map<String, Integer> valueMap = attrMap.get("orientation");
assertTrue(valueMap.containsKey("horizontal"));
assertTrue(valueMap.containsKey("vertical"));
assertEquals(Integer.valueOf(0), valueMap.get("horizontal"));
assertEquals(Integer.valueOf(1), valueMap.get("vertical"));
| public final void | testGetDocument()
assertNotNull(_getDocument());
| public void | testGetOsAttrsXmlPath()
assertEquals(mFilePath, mParser.getOsAttrsXmlPath());
| public final void | testLoadViewAttributes()
mParser.preload();
ViewClassInfo info = new ViewClassInfo(
false /* isLayout */,
"mock_android.something.Theme", //$NON-NLS-1$
"Theme"); //$NON-NLS-1$
mParser.loadViewAttributes(info);
assertEquals("These are the standard attributes that make up a complete theme.", //$NON-NLS-1$
info.getJavaDoc());
AttributeInfo[] attrs = info.getAttributes();
assertEquals(1, attrs.length);
assertEquals("scrollbarSize", info.getAttributes()[0].getName());
assertEquals(1, info.getAttributes()[0].getFormats().length);
assertEquals(Format.DIMENSION, info.getAttributes()[0].getFormats()[0]);
| public final void | testPreload()
assertSame(mParser, mParser.preload());
|
|