Ticket #2333: fckdataprocessor.html

File fckdataprocessor.html, 6.1 KB (added by Byeongweon Moon, 12 years ago)

testcase file for produce same bug

Line 
1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2<!--
3 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
4 * Copyright (C) 2003-2008 Frederico Caldeira Knabben
5 *
6 * == BEGIN LICENSE ==
7 *
8 * Licensed under the terms of any of the following licenses at your
9 * choice:
10 *
11 *  - GNU General Public License Version 2 or later (the "GPL")
12 *    http://www.gnu.org/licenses/gpl.html
13 *
14 *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
15 *    http://www.gnu.org/licenses/lgpl.html
16 *
17 *  - Mozilla Public License Version 1.1 or later (the "MPL")
18 *    http://www.mozilla.org/MPL/MPL-1.1.html
19 *
20 * == END LICENSE ==
21-->
22<html xmlns="http://www.w3.org/1999/xhtml">
23<head>
24        <title>FCKDataProcessor - Tests for JsUnit</title>
25        <script src="../../../editor/_source/fckscriptloader.js" type="text/javascript"></script>
26        <script type="text/javascript" src="tests.js"></script>
27        <script type="text/javascript" src="../_jsunit/app/jsUnitCore.js"></script>
28        <script type="text/javascript">
29
30var FCK =
31{
32        IsDirty : function() { return true ; }
33}
34
35FCKScriptLoader.Load( 'FCKDataProcessor' ) ;
36
37        </script>
38        <script src="../../../fckconfig.js" type="text/javascript"></script>
39        <script type="text/javascript">
40
41function test_ConvertToHtml()
42{
43        var dataProcessor = new FCKDataProcessor() ;
44
45        assertEquals(
46                '<html dir="ltr"><head><title></title></head><body>This is some <strong>sample text</strong>.</body></html>',
47                dataProcessor.ConvertToHtml( 'This is some <strong>sample text</strong>.' ) ) ;
48}
49
50function test_ConvertToHtml_Empty()
51{
52        var dataProcessor = new FCKDataProcessor() ;
53
54        assertEquals(
55                '<html dir="ltr"><head><title></title></head><body></body></html>',
56                dataProcessor.ConvertToHtml( '' ) ) ;
57}
58
59function test_ConvertToHtml_Full()
60{
61        FCKConfig.FullPage = true ;
62
63        var dataProcessor = new FCKDataProcessor() ;
64
65        assertEquals(
66                '<html dir="rtl"><head><title>My Test</title><style></style></head><body class="Test">This is some <strong>sample text</strong>.</body></html>',
67                dataProcessor.ConvertToHtml( '<html dir="rtl"><head><title>My Test</title><style></style></head><body class="Test">This is some <strong>sample text</strong>.</body></html>' ) ) ;
68
69        // Reset the config for other tests.
70        FCKConfig.FullPage = false ;
71}
72
73function test_ConvertToHtml_Full_Incomplete()
74{
75        FCKConfig.FullPage = true ;
76
77        var dataProcessor = new FCKDataProcessor() ;
78
79        assertEquals(
80                '<html dir="ltr"><head><title></title></head><body>This is some <strong>sample text</strong>.</body></html>',
81                dataProcessor.ConvertToHtml( 'This is some <strong>sample text</strong>.' ) ) ;
82
83        // Reset the config for other tests.
84        FCKConfig.FullPage = false ;
85}
86
87function test_ConvertToHtml_Full_Empty()
88{
89        FCKConfig.FullPage = true ;
90
91        var dataProcessor = new FCKDataProcessor() ;
92
93        assertEquals(
94                '<html dir="ltr"><head><title></title></head><body></body></html>',
95                dataProcessor.ConvertToHtml( '' ) ) ;
96
97        // Reset the config for other tests.
98        FCKConfig.FullPage = false ;
99}
100
101function test_ConvertToHtml_Settings()
102{
103        FCKConfig.ContentLangDirection = 'rtl' ;
104        FCKConfig.DocType = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' ;
105        FCKConfig.BodyId = 'TestId' ;
106        FCKConfig.BodyClass = 'TestClass'
107
108        var dataProcessor = new FCKDataProcessor() ;
109
110        if ( navigator.userAgent.indexOf( 'MSIE' ) > -1 )       // IE
111        {
112                assertEquals(
113                        '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' +
114                        '<html dir="rtl" style="overflow-y: scroll"><head><title></title></head><body id="TestId" class="TestClass">This is some <strong>sample text</strong>.</body></html>',
115                        dataProcessor.ConvertToHtml( 'This is some <strong>sample text</strong>.' ) ) ;
116        }
117        else
118        {
119                assertEquals(
120                        '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' +
121                        '<html dir="rtl"><head><title></title></head><body id="TestId" class="TestClass">This is some <strong>sample text</strong>.</body></html>',
122                        dataProcessor.ConvertToHtml( 'This is some <strong>sample text</strong>.' ) ) ;
123        }
124        // Reset the config for other tests.
125        FCKConfig.ContentLangDirection = 'ltr' ;
126        FCKConfig.DocType = '' ;
127        FCKConfig.BodyId = '' ;
128        FCKConfig.BodyClass = ''
129}
130
131function test_ConvertToDataFormat_Exclude_NoFormat()
132{
133        var dataProcessor = new FCKDataProcessor() ;
134
135        assertEquals(
136                '<p>This is a <strong>test</strong>.</p><p>Another paragraph.</p>',
137                dataProcessor.ConvertToDataFormat( document.getElementById('xDiv1'), true ) ) ;
138}
139
140function test_ConvertToDataFormat_NoExclude_NoFormat()
141{
142        var dataProcessor = new FCKDataProcessor() ;
143
144        assertEquals(
145                '<div id="xDiv1"><p>This is a <strong>test</strong>.</p><p>Another paragraph.</p></div>',
146                dataProcessor.ConvertToDataFormat( document.getElementById('xDiv1'), false ) ) ;
147}
148
149function test_ConvertToDataFormat_NoExclude_Format()
150{
151        var dataProcessor = new FCKDataProcessor() ;
152
153        assertEquals(
154                '<div id="xDiv1">\n<p>This is a <strong>test</strong>.</p>\n<p>Another paragraph.</p>\n</div>',
155                dataProcessor.ConvertToDataFormat( document.getElementById('xDiv1'), false, false, true ) ) ;
156}
157
158function test_ConvertToDataFormat_IgnoreEmpty()
159{
160        var dataProcessor = new FCKDataProcessor() ;
161
162        assertEquals(
163                '',
164                dataProcessor.ConvertToDataFormat( document.getElementById('xDiv2'), true, true ) ) ;
165}
166
167// added by Byeongweon Moon. to test &gt; replace bug
168function test_ConvertToDataFormat_Character_Transform()
169{
170        var dataProcessor = new FCKDataProcessor() ;
171
172        assertEquals(
173                '<p>&lt;&lt;GetText(Edit)&gt;&gt;</p>',
174                dataProcessor.ConvertToDataFormat( document.getElementById('xDiv3'), true, true ) ) ;
175}
176
177        </script>
178</head>
179<body>
180        <div id="xDiv1"><p>This is a <strong>test</strong>.</p><p>Another paragraph.</p></div>
181        <div id="xDiv2"><p>&nbsp;</p></div>
182        <div id="xDiv3"><p>&lt;&lt;GetText(Edit)&gt;&gt;</p></div>
183</body>
184</html>
© 2003 – 2019 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy