1 19 package org.netbeans.modules.html.editor.folding; 20 21 import java.io.File ; 22 import java.io.IOException ; 23 import java.util.Iterator ; 24 import java.util.List ; 25 import javax.swing.text.BadLocationException ; 26 import org.netbeans.editor.BaseDocument; 27 import org.netbeans.editor.ext.html.HTMLSyntaxSupport; 28 import org.netbeans.modules.editor.html.HTMLKit; 29 import org.netbeans.modules.html.editor.folding.HTMLFoldManager.FoldInfo; 30 import org.netbeans.modules.html.editor.test.TestBase; 31 import org.netbeans.modules.html.editor.test.Utils; 32 33 37 public class HTMLFoldingTest extends TestBase { 38 39 private HTMLFoldManager fm; 40 41 public HTMLFoldingTest() { 42 super("html-folding-test"); 43 fm = new HTMLFoldManager(); 44 fm.documentDirty = false; 45 } 46 47 public void testModelBasis() throws Exception { 49 BaseDocument doc = createDocument(); 51 HTMLSyntaxSupport sup = new HTMLSyntaxSupport(doc); 52 53 doc.insertString(0,"\n <b>\n ahoj\n </b>\n ",null); List fis = fm.generateFolds(sup); 55 56 assertEquals(1, fis.size()); 58 } 60 61 public void testIndexHtml() throws Exception { 62 testFolds(new File (getDataDir(), "input/HTMLFoldingTest/index.html")); 63 } 64 65 private void testFolds(File inputFile) throws IOException , BadLocationException , HTMLFoldManager.ParsingCancelledException { 66 String content = Utils.readFileContentToString(inputFile); 67 BaseDocument doc = createDocument(); 68 doc.insertString(0,content,null); 69 HTMLSyntaxSupport sup = new HTMLSyntaxSupport(doc); 70 71 List fis = fm.generateFolds(sup); 72 dumpFoldInfos(fis); 73 74 compareReferenceFiles(); 75 } 76 77 private void dumpFoldInfos(List foldInfos) { 78 Iterator i = foldInfos.iterator(); 79 while(i.hasNext()) { 80 FoldInfo fi = (FoldInfo)i.next(); 81 getRef().println(fi); 82 } 83 } 84 85 } 86 | Popular Tags |