Ticket #3046: test-list-cancel2.patch

File test-list-cancel2.patch, 3.4 KB (added by Garry Yao, 15 years ago)

Functional test case

  • _source/tests/plugins/list/list.html

     
     1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     2<html xmlns="http://www.w3.org/1999/xhtml">
     3<head>
     4        <title>Plugin: toolbar</title>
     5        <link rel="stylesheet" type="text/css" href="../../test.css" />
     6        <script type="text/javascript" src="../../../../ckeditor_source.js"></script>
     7        <script type="text/javascript" src="../../test.js"></script>
     8        <script type="text/javascript">
     9        //<![CDATA[
     10/**
     11 * Load the editor and wait for fully interactable.
     12 * @param {Object} elementId
     13 * @parma {Object} mode
     14 * @param {Object} config
     15 * @param {Object} callback Continuation with {@param editor}.
     16 * @param {Object} context
     17 */
     18function prepareEditor( elementId, mode, config, callback, context )
     19{
     20        CKEDITOR.on( 'instanceReady',
     21                function( evt )
     22                {
     23                        var isMe = mode == CKEDITOR.ELEMENT_MODE_REPLACE ?
     24                                evt.editor.name == elementId
     25                                : evt.editor.element.$ ==
     26                                        document.getElementById( elementId );
     27                        if ( isMe )
     28                        {
     29                                callback.call( context, evt.editor );
     30                        }
     31                }, this );
     32
     33        mode = mode || CKEDITOR.ELEMENT_MODE_REPLACE;
     34        switch( mode )
     35        {
     36                case CKEDITOR.ELEMENT_MODE_REPLACE :
     37                        CKEDITOR.replace( elementId, config );
     38                        break;
     39                case CKEDITOR.ELEMENT_MODE_APPENDTO :
     40                        CKEDITOR.appendTo( elementId, config );
     41                        break;
     42        }
     43}
     44
     45/**
     46 * Find the specific UI item by row and column index.
     47 * @param {Object} editor
     48 * @param {Object} rowIndex
     49 * @param {Object} colIndex
     50 */
     51function getToolbarUIItem( editor, rowIndex, colIndex){
     52        return editor.toolbox.toolbars[ rowIndex -1].items[ colIndex-1];
     53}
     54
     55/**
     56 * IE always returning CRLF for line-feed, so remove it when retrieving
     57 * pre-formated text from text area.
     58 */
     59function getTextAreaValue( id )
     60{
     61        return CKEDITOR.document.getById( id ).getValue().replace( /\r/gi, '' );
     62}
     63
     64CKEDITOR.test.addTestCase( ( function()
     65        {
     66               
     67                // Local references.
     68                var assert = CKEDITOR.test.assert,
     69                        doc = CKEDITOR.document,
     70                        action = YAHOO.util.UserAction,
     71                        selector = YAHOO.util.Selector;
     72                       
     73                return  {
     74                       
     75                        /**
     76                         *  Test apply and revert numbered list in normal paragraphs in one shot.
     77                         */
     78                        test_applyNumberedList2 : function()
     79                        {
     80                                prepareEditor( 'editor2', null, null, function( editor )
     81                                        {
     82                                                this.resume( function()
     83                                                {
     84                                                        editor.focus();
     85                                                        var sel = editor.getSelection();
     86                                                        sel.selectElement( editor.document.getById( 'listTarget2' ) );
     87                                                        //asycn for 'comand state'
     88                                                        editor.execCommand( 'numberedlist' );
     89                                                        this.wait( function(){
     90                                                                editor.execCommand( 'numberedlist' );
     91                                                                assert.areSame( getTextAreaValue( 'htmlResult2' ), editor.getData(),
     92                                                                        'Content after apply list format doesn\'t match.' );
     93                                                        }, 1000);
     94                                                       
     95                                                } );
     96                                        }, this );
     97                                        this.wait();   
     98                        },
     99
     100
     101                        name :document.title
     102                };
     103        } )() );
     104        //]]>
     105        </script>
     106</head>
     107<body>
     108<textarea id="editor2" name="editor2"><p id="listTarget2">text</p></textarea>
     109<textarea id="htmlResult2"><p>
     110        text
     111</p></textarea>
     112</body>
     113</html>
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy