use of org.eclipse.wst.css.core.internal.provisional.document.ICSSModel in project webtools.sourceediting by eclipse.
the class CSSUrlTest method testFixError3.
/**
* Import rule: Url has only one quote, so it is not identified as url. By
* removing quote, url is corrected.
*/
public void testFixError3() {
ICSSModel model = FileUtil.createModel();
IStructuredDocument document = model.getStructuredDocument();
// ____________0123456789012345678901234567890
// $NON-NLS-1$
document.set("@import url(white space.css\");");
UrlInfo[] urls = pickupUrl(document);
assertEquals(0, urls.length);
// correct url
// $NON-NLS-1$
document.replaceText(null, 27, 1, "");
urls = pickupUrl(document);
assertEquals(1, urls.length);
assertEquals(CSSRegionContexts.CSS_URI, urls[0].getType());
// $NON-NLS-1$
assertEquals("white space.css", urls[0].getUrl());
}
use of org.eclipse.wst.css.core.internal.provisional.document.ICSSModel in project webtools.sourceediting by eclipse.
the class CSSUrlTest method testDeclaration4.
/**
* Declaration: with double quote
*/
public void testDeclaration4() {
ICSSModel model = FileUtil.createModel();
IStructuredDocument document = model.getStructuredDocument();
((CSSSourceParser) document.getParser()).setParserMode(CSSSourceParser.MODE_DECLARATION_VALUE);
// $NON-NLS-1$
document.set("background-image: url(\"white space.gif\");");
UrlInfo[] urls = pickupUrl(document);
assertEquals(1, urls.length);
assertEquals(CSSRegionContexts.CSS_DECLARATION_VALUE_URI, urls[0].getType());
// $NON-NLS-1$
assertEquals("white space.gif", urls[0].getUrl());
}
use of org.eclipse.wst.css.core.internal.provisional.document.ICSSModel in project webtools.sourceediting by eclipse.
the class CSSUrlTest method testDeclaration5.
/**
* Declaration: two urls
*/
public void testDeclaration5() {
ICSSModel model = FileUtil.createModel();
IStructuredDocument document = model.getStructuredDocument();
((CSSSourceParser) document.getParser()).setParserMode(CSSSourceParser.MODE_DECLARATION_VALUE);
// $NON-NLS-1$
document.set("background-image: url(white space.gif); list-style-image: url(style image.gif);");
UrlInfo[] urls = pickupUrl(document);
assertEquals(2, urls.length);
assertEquals(CSSRegionContexts.CSS_DECLARATION_VALUE_URI, urls[0].getType());
// $NON-NLS-1$
assertEquals("white space.gif", urls[0].getUrl());
assertEquals(CSSRegionContexts.CSS_DECLARATION_VALUE_URI, urls[1].getType());
// $NON-NLS-1$
assertEquals("style image.gif", urls[1].getUrl());
}
use of org.eclipse.wst.css.core.internal.provisional.document.ICSSModel in project webtools.sourceediting by eclipse.
the class CSSUrlTest method testFixError1.
/**
* Declaration: Two urls but parenthesis are missed, so concatenated url
* is identified. By adding parenthesis, urls are corrected.
*/
public void testFixError1() {
ICSSModel model = FileUtil.createModel();
IStructuredDocument document = model.getStructuredDocument();
((CSSSourceParser) document.getParser()).setParserMode(CSSSourceParser.MODE_DECLARATION_VALUE);
// ____________01234567890123456789012345678901234567890123456789012345678901234567890123456789
// $NON-NLS-1$
document.set("background-image: url(white space.gif; list-style-image: urlstyle image.gif);");
UrlInfo[] urls = pickupUrl(document);
assertEquals(1, urls.length);
assertEquals(CSSRegionContexts.CSS_DECLARATION_VALUE_URI, urls[0].getType());
// $NON-NLS-1$
assertEquals("white space.gif; list-style-image: urlstyle image.gif", urls[0].getUrl());
// correct first url
// $NON-NLS-1$
document.replaceText(null, 37, 0, ")");
urls = pickupUrl(document);
assertEquals(1, urls.length);
assertEquals(CSSRegionContexts.CSS_DECLARATION_VALUE_URI, urls[0].getType());
// $NON-NLS-1$
assertEquals("white space.gif", urls[0].getUrl());
// correct second url
// $NON-NLS-1$
document.replaceText(null, 61, 0, "(");
urls = pickupUrl(document);
assertEquals(2, urls.length);
assertEquals(CSSRegionContexts.CSS_DECLARATION_VALUE_URI, urls[0].getType());
// $NON-NLS-1$
assertEquals("white space.gif", urls[0].getUrl());
assertEquals(CSSRegionContexts.CSS_DECLARATION_VALUE_URI, urls[1].getType());
// $NON-NLS-1$
assertEquals("style image.gif", urls[1].getUrl());
}
use of org.eclipse.wst.css.core.internal.provisional.document.ICSSModel in project webtools.sourceediting by eclipse.
the class CSSUrlTest method testStyleRule1.
/**
* Style rule: two urls
*/
public void testStyleRule1() {
ICSSModel model = FileUtil.createModel();
IStructuredDocument document = model.getStructuredDocument();
// $NON-NLS-1$
document.set("LI { background-image: url(white space.gif);\r\nlist-style-image: url(style image.gif); }");
UrlInfo[] urls = pickupUrl(document);
assertEquals(2, urls.length);
assertEquals(CSSRegionContexts.CSS_DECLARATION_VALUE_URI, urls[0].getType());
// $NON-NLS-1$
assertEquals("white space.gif", urls[0].getUrl());
assertEquals(CSSRegionContexts.CSS_DECLARATION_VALUE_URI, urls[1].getType());
// $NON-NLS-1$
assertEquals("style image.gif", urls[1].getUrl());
}
Aggregations