Update of 
/var/cvs/contributions/CMSContainer/cmsc/richtext/src/tests/org/mmbase/applications/wordfilter
In directory 
james.mmbase.org:/tmp/cvs-serv32469/cmsc/richtext/src/tests/org/mmbase/applications/wordfilter

Modified Files:
      Tag: v1_3
        WordHtmlCleanerTest.java 
Log Message:
CMSC-421 Wordfilter whitespaces


See also: 
http://cvs.mmbase.org/viewcvs/contributions/CMSContainer/cmsc/richtext/src/tests/org/mmbase/applications/wordfilter
See also: http://www.mmbase.org/jira/browse/CMSC-421


Index: WordHtmlCleanerTest.java
===================================================================
RCS file: 
/var/cvs/contributions/CMSContainer/cmsc/richtext/src/tests/org/mmbase/applications/wordfilter/WordHtmlCleanerTest.java,v
retrieving revision 1.5
retrieving revision 1.5.2.1
diff -u -b -r1.5 -r1.5.2.1
--- WordHtmlCleanerTest.java    31 May 2007 14:04:14 -0000      1.5
+++ WordHtmlCleanerTest.java    5 May 2008 15:26:20 -0000       1.5.2.1
@@ -10,7 +10,7 @@
 public class WordHtmlCleanerTest extends TestCase {
 
    /**
-    * Test for jira issue NIJ-385. Bold tags with only spaces in it where 
reduced to a self closing tag, which will
+    * Test for NIJ-385. Bold tags with only spaces in it where reduced to a 
self closing tag, which will
     * render al following text bold in IE.<br/>
     * E.g. The following html <code>&lt;b&gt; &lt;/b&gt;</code> would be 
cleaned as <code>&lt;b/&gt;</code>. 
     */
@@ -23,25 +23,35 @@
    }
    
    /**
-    * Tests for jira issue CMSC-421, test a bunch of cleanups for the 
whitespace.
+    * Tests for CMSC-421, test a bunch of cleanups for the whitespace.
     */
    public void testRemoveWhiteSpace() {
        doTestFilter("<p>test</p><p>test</p>", "test<br/><br/>test");
-   }
-   public void testRemoveWhiteSpace2() {
        doTestFilter("test<br/><br/><br/><br/>test", 
"test<br/><br/><br/><br/>test");
-   }
-   public void testRemoveWhiteSpace3() {
        doTestFilter("<p>test</p><p>x</p><p>test</p>", 
"test<br/><br/>x<br/><br/>test");
-   }
-   public void testRemoveWhiteSpace4() {
-      doTestFilter("<p>test</p><p></p><p>test</p>", 
"test<br/><br/><br/><br/>test");
-   }
-   public void testRemoveWhiteSpace5() {
+       doTestFilter("<p>test</p><p></p><p>test</p>", "test<br/><br/>test");
       doTestFilter("<p>test</p><p><p>test</p>", "test<br/><br/>test");
-   }
-   public void testRemoveWhiteSpace6() {
       doTestFilter("<p>test</p><p>test", "test<br/><br/>test");
+       doTestFilter("<p>test</p><p>test&nbsp;</p>", "test<br/><br/>test");
+       doTestFilter(
+           "  <p><font face=\"Times New Roman\" size=\"3\">Heading</font></p>" 
+ 
+           "  <p> </p>" + 
+           "  <p><font face=\"Times New Roman\" size=\"3\">Paragraph 
one</font></p>" + 
+           "  <p> </p>" + 
+           "  <p><font face=\"Times New Roman\" size=\"3\">Paragraph 
two</font></p>" + 
+           "  <p> </p>" + 
+           "  <p> </p>" + 
+           "  <p> </p>",
+           "Heading<br/><br/>Paragraph one<br/><br/>Paragraph two");
+       doTestFilter(
+           "  <p><font face=\"Times New Roman\" size=\"3\">Heading</font></p>" 
+ 
+           "  <p>&nbsp;</p>" + 
+           "  <p><font face=\"Times New Roman\" size=\"3\">Paragraph 
one</font></p>" + 
+           "  <p>&nbsp;</p>" + 
+           "  <p><font face=\"Times New Roman\" size=\"3\">Paragraph 
two</font></p>" + 
+           "  <p>&nbsp;</p>" + 
+           "  <p>&nbsp;</p>",
+           "Heading<br/><br/><br/><br/>Paragraph 
one<br/><br/><br/><br/>Paragraph two");
    }
    
    
@@ -55,19 +65,15 @@
                      "<p style=\"margin-left: 53.4pt; text-indent: -18pt;\" 
class=\"MsoNormal\"><!--[if !supportLists]--><span style=\"font-family: 
Wingdings;\">?<span style=\"font-family: &quot;Times New Roman&quot;; 
font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; 
line-height: normal; font-size-adjust: none; font-stretch: 
normal;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+
                      
"</span></span><!--[endif]--><span>&nbsp;</span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 </span>Twee</p>";
       doTestFilter(input, "<ul><li>Een</li><li>Twee</li></ul>");
-   }
    
-   public void testFixLists2() {
-       String input = "<p style=\"margin-left: 89.4pt; text-indent: -18pt;\" 
class=\"MsoNormal\"><!--[if !supportLists]--><span style=\"font-family: 
Symbol;\">?<span style=\"font-family: &quot;Times New Roman&quot;; font-style: 
normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: 
normal; font-size-adjust: none; font-stretch: 
normal;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+
+      String input2 = "<p style=\"margin-left: 89.4pt; text-indent: -18pt;\" 
class=\"MsoNormal\"><!--[if !supportLists]--><span style=\"font-family: 
Symbol;\">?<span style=\"font-family: &quot;Times New Roman&quot;; font-style: 
normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: 
normal; font-size-adjust: none; font-stretch: 
normal;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+
                      "</span></span><!--[endif]-->Een</p>"+
                      "<p style=\"margin-left: 89.4pt; text-indent: -18pt;\" 
class=\"MsoNormal\"><!--[if !supportLists]--><span style=\"font-family: 
Symbol;\">?<span style=\"font-family: &quot;Times New Roman&quot;; font-style: 
normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: 
normal; font-size-adjust: none; font-stretch: 
normal;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+
                      "</span></span><!--[endif]-->Twee</p>";
-      doTestFilter(input, "<ul><li>Een</li><li>Twee</li></ul>");
-   }
+      doTestFilter(input2, "<ul><li>Een</li><li>Twee</li></ul>");
    
-   public void testFixLists3() {
-      String input = "<ol><li>Een</li><li>Twee</li></ol>";
-      doTestFilter(input, "<ol><li>Een</li><li>Twee</li></ol>");
+      String input3 = "<ol><li>Een</li><li>Twee</li></ol>";
+      doTestFilter(input3, "<ol><li>Een</li><li>Twee</li></ol>");
    }
    
    /**
@@ -75,10 +81,24 @@
     */
    public void testLinebreaksInHtmlIfComments() {
       doTestFilter("te<!--[if !supportLineBreaknewLine]-->x<!--[endif]-->st", 
"test");
+      doTestFilter("te<!--[if 
!supportLineBreaknewLine]-->\r\n<!--[endif]-->st", "test");
    }
 
-   public void testLinebreaksInHtmlIfComments2() {
-      doTestFilter("te<!--[if 
!supportLineBreaknewLine]-->\r\n<!--[endif]-->st", "test");
+    /**
+     * As specified in NIJ-780, only a single <br/> should be the result of a 
replaced <p></p>
+     */
+    public void testReplaceParagraphSingleBr() {
+       doTestFilter("<p>This is paragraph</p><p>paragraph 2</p>", "This is 
paragraph<br/><br/>paragraph 2");
+    }
+    
+       /**
+     * As specified in NIJ-780, h1 till h7 should be replaced by a 
<strong>...</strong><br/>
+     */
+    public void testReplaceHeaderEnd() {
+       for(int count = 1; count <= 7; count++) {
+               doTestFilter("<h"+count+">Header</h"+count+">", 
"<strong>Header</strong>");
+            doTestFilter("<h"+count+">Header</h"+count+"><p>paragraph 2</p>", 
"<strong>Header</strong><br/>paragraph 2");
+       }
    }
    
    private void doTestFilter(String input, String expected) {
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to