PageRenderTime 67ms CodeModel.GetById 55ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

/bundles/plugins-trunk/XML/test/sidekick/html/HtmlParserTest.java

#
Java | 89 lines | 48 code | 20 blank | 21 comment | 0 complexity | af521d7c0bc867146fc1222e3ccbbd74 MD5 | raw file
 1/*
 2 * HtmlParserTest.java
 3 * :folding=explicit:collapseFolds=1:
 4 *
 5 * Copyright (C) 2010 Eric Le Lay
 6 *
 7 * The XML plugin is licensed under the GNU General Public License, with
 8 * the following exception:
 9 *
10 * "Permission is granted to link this code with software released under
11 * the Apache license version 1.1, for example used by the Xerces XML
12 * parser package."
13 */
14package sidekick.html;
15
16// {{{ jUnit imports 
17import java.util.concurrent.TimeUnit;
18
19import org.junit.*;
20import static org.junit.Assert.*;
21
22import org.fest.swing.fixture.*;
23import org.fest.swing.core.*;
24import org.fest.swing.finder.*;
25import org.fest.swing.edt.*;
26import org.fest.swing.timing.*;
27
28import static org.fest.assertions.Assertions.*;
29
30import org.gjt.sp.jedit.testframework.Log;
31
32import static xml.XMLTestUtils.*;
33import static org.gjt.sp.jedit.testframework.EBFixture.*;
34import static org.gjt.sp.jedit.testframework.TestUtils.*;
35import org.gjt.sp.jedit.testframework.PluginOptionsFixture;
36import org.gjt.sp.jedit.testframework.TestUtils;
37
38// }}}
39
40import java.io.*;
41import org.gjt.sp.jedit.textarea.JEditTextArea;
42
43/**
44 * $Id: HtmlParserTest.java 21248 2012-03-05 19:37:01Z kerik-sf $
45 */
46public class HtmlParserTest{
47	private static File testData;
48
49    @BeforeClass
50    public static void setUpjEdit() throws IOException{
51        TestUtils.beforeClass();
52        testData = new File(System.getProperty("test_data")).getCanonicalFile();
53        assertTrue(testData.exists());
54    }
55
56    @AfterClass
57    public static void tearDownjEdit() {
58        TestUtils.afterClass();
59    }
60
61    @Test
62    public void testErrorInCss(){
63    	File xml = new File(testData,"html/error_in_css.html");
64    	
65    	openParseAndWait(xml.getPath());
66    	
67    	action("sidekick-tree");
68    	
69    	FrameFixture sidekick = TestUtils.findFrameByTitle("Sidekick");
70    	JTreeFixture sourceTree = sidekick.tree();
71    	
72		// inspect the tree
73		selectPath(sourceTree,",<html>&lt;html&gt;,<head>,<STYLE type=\"text/css\">");
74		
75		// ensure some coherence in the assets
76		JEditTextArea area = TestUtils.view().getTextArea();
77		assertEquals("<style", area.getBuffer().getText(area.getCaretPosition(),6));
78		
79		// ensure that errors in CSS are reported at the correct location
80		action("error-list-show",1);
81		
82    	FrameFixture errorlist = TestUtils.findFrameByTitle("Error List");
83    	errorlist.resizeWidthTo(1024);
84    	errorlist.tree().selectRow(1);
85    	assertEquals(";",area.getSelectedText());
86    	assertEquals(2,area.getCaretLine());
87    }
88    
89}