use of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument in project webtools.sourceediting by eclipse.
the class CSSPageRuleTest method testInsertText5.
public void testInsertText5() throws IOException {
ICSSModel model = getModel();
IStructuredDocument structuredDocument = model.getStructuredDocument();
structuredDocument.set(FileUtil.createString("src/org/eclipse/wst/css/core/tests/testfiles", "CSSPageRuleTest.css"));
CSSStyleSheet sheet = (CSSStyleSheet) model.getDocument();
CSSRuleList ruleList = sheet.getCssRules();
assertEquals(6, ruleList.getLength());
CSSRule rule;
CSSStyleDeclaration declaration;
CSSValue value;
CSSValueList valueList;
// rule 5
rule = ruleList.item(4);
assertEquals(CSSRule.PAGE_RULE, rule.getType());
assertTrue(rule instanceof CSSPageRule);
assertEquals("narrow", ((CSSPageRule) rule).getSelectorText());
declaration = ((CSSPageRule) rule).getStyle();
assertEquals(1, declaration.getLength());
value = declaration.getPropertyCSSValue("size");
assertTrue(value instanceof CSSValueList);
valueList = (CSSValueList) value;
assertEquals(2, valueList.getLength());
checkPrimitiveNumber(valueList.item(0), new PrimitiveNumber(CSSPrimitiveValue.CSS_CM, 9));
checkPrimitiveNumber(valueList.item(1), new PrimitiveNumber(CSSPrimitiveValue.CSS_CM, 18));
}
use of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument in project webtools.sourceediting by eclipse.
the class AttrTest3 method testModel.
public void testModel() {
IDOMModel model = createXMLModel();
try {
IStructuredDocument structuredDocument = model.getStructuredDocument();
Document document = model.getDocument();
structuredDocument.setText(this, "<a xmlns='default-uri' xmlns:b='b-uri'><c d='d-value' b:e='e-value'/></a>");
printSource(model);
printTree(model);
Element a = (Element) document.getFirstChild();
Element c = (Element) a.getFirstChild();
Attr xmlns = a.getAttributeNode("xmlns");
fOutputWriter.writeln("xmlns [" + xmlns.getNamespaceURI() + "]");
Attr xmlns_b = a.getAttributeNode("xmlns:b");
fOutputWriter.writeln("xmlns:b [" + xmlns_b.getNamespaceURI() + "]");
Attr d = c.getAttributeNode("d");
fOutputWriter.writeln("d [" + d.getNamespaceURI() + "]");
Attr b_e = c.getAttributeNode("b:e");
fOutputWriter.writeln("b:e [" + b_e.getNamespaceURI() + "]");
saveAndCompareTestResults();
} finally {
model.releaseFromEdit();
}
}
use of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument in project webtools.sourceediting by eclipse.
the class AttrValueTest method testModel.
/* (non-Javadoc)
* @see org.eclipse.wst.html.core.tests.parser.ModelTest#testModel()
*/
public void testModel() {
IDOMModel model = createHTMLModel();
try {
assertNotNull(model);
IStructuredDocument document = model.getStructuredDocument();
assertNotNull(document);
document.setText(this, "<button value=\"" + VALUES[0] + "\"></button><button value=\"" + VALUES[1] + "\"></button><button value=\"" + VALUES[2] + "\"></button>");
IDOMDocument dom = model.getDocument();
NodeList nodes = dom.getElementsByTagName("button");
assertTrue("Must be 3 button elements in the document.", nodes.getLength() == 3);
for (int i = 0; i < nodes.getLength(); i++) {
Node node = nodes.item(i);
Node attr = node.getAttributes().getNamedItem("value");
assertTrue("Attribute 'value' not present.", attr != null && attr.getNodeValue().length() > 0);
assertEquals("Attribute values are not equal", VALUES[i], attr.getNodeValue());
}
} finally {
if (model != null) {
model.releaseFromEdit();
}
}
}
use of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument in project webtools.sourceediting by eclipse.
the class EleTest method testModel.
public void testModel() {
IDOMModel model = createHTMLModel();
try {
IStructuredDocument structuredDocument = model.getStructuredDocument();
Document document = model.getDocument();
structuredDocument.replaceText(null, 0, 0, "<html><body><DL>\n\n<DD>Add a \"set top\" rule for the specified parameters1.\n<DD>Add a \"set top\" rule for the specified parameters2.\n<DD>Add a \"set top\" rule for the specified parameters3.\n<DD>Add a \"set top\" rule for the specified parameters4.\n<DD>Add a \"set top\" rule for the specified parameters5.\n<DD>Add a \"set top\" rule for the specified parameters6.\n<DD>Add a \"set top\" rule for the specified parameters7.\n<DD>Add a \"set top\" rule for the specified parameters8.\n<DD>Add a \"set top\" rule for the specified parameters9.\n<DD>Add a \"set top\" rule for the specified parameters10.\n<DD>Add a \"set top\" rule for the specified parameters11.\n<DD>Add a \"set top\" rule for the specified parameters12.\n<DD>Add a \"set top\" rule for the specified parameters.\n<DD>Add a \"set top\" rule for the specified parameters.\n<DD>Add a \"set top\" rule for the specified parameters.\n<DD>Add a \"set top\" rule for the specified parameters.\n<DD>Add a \"set top\" rule for the specified parameters.\n<DD>Add a \"set top\" rule for the specified parameters.\n<DD>Add a \"set top\" rule for the specified parameters.\n<DD>Add a \"set top\" rule for the specified parameters.\n</DL></body></html>");
Node a = document.getElementsByTagName("DL").item(0);
System.out.println(((Element) a).getElementsByTagName("DD").getLength());
} finally {
model.releaseFromEdit();
}
}
use of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument in project webtools.sourceediting by eclipse.
the class EntityTest8 method testModel.
public void testModel() {
IDOMModel model = createXMLModel();
try {
// Document document = model.getDocument();
IStructuredDocument structuredDocument = model.getStructuredDocument();
structuredDocument.setText(this, "&ibm;&rtp;");
printSource(model);
printTree(model);
saveAndCompareTestResults();
} finally {
model.releaseFromEdit();
}
}
Aggregations