Ticket #3192: test-selection.patch

File test-selection.patch, 2.7 KB (added by Garry Yao, 15 years ago)

Functional Test Case

  • _source/tests/plugins/selection/selection_selectRanges.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: selection</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
     11function prepareEditor( elementId, mode, config, callback, context )
     12{
     13        CKEDITOR.on( 'instanceReady',
     14                function( evt )
     15                {
     16                        var isMe = mode == CKEDITOR.ELEMENT_MODE_REPLACE ?
     17                                evt.editor.name == elementId
     18                                : evt.editor.element.$ ==
     19                                        document.getElementById( elementId );
     20                        if ( isMe )
     21                        {
     22                                callback.call( context, evt.editor );
     23                        }
     24                }, this );
     25
     26        mode = mode || CKEDITOR.ELEMENT_MODE_REPLACE;
     27        switch( mode )
     28        {
     29                case CKEDITOR.ELEMENT_MODE_REPLACE :
     30                        CKEDITOR.replace( elementId, config );
     31                        break;
     32                case CKEDITOR.ELEMENT_MODE_APPENDTO :
     33                        CKEDITOR.appendTo( elementId, config );
     34                        break;
     35        }
     36}
     37
     38var testCase;
     39
     40CKEDITOR.test
     41        .addTestCase( ( function()
     42        {
     43                // Local references.
     44                var assert = YAHOO.util.Assert,
     45                doc = new CKEDITOR.dom.document( document );
     46
     47                return {
     48
     49                        /**
     50                         * Get selection immediately after grab focus.
     51                         */
     52                        test_getSelection_afterFocus1 : function()
     53                        {
     54                                prepareEditor( 'editor1', null, null, function( editor ){
     55                                        this.resume( function(){
     56                                               
     57                                                editor.focus();
     58                                                var selection = editor.getSelection();
     59                                                assert.isNotNull( selection, 'editor selection should not be null.' );
     60                                        } );
     61                                }, this );
     62                        },
     63                       
     64                        /**
     65                         * Get selection after grab focus for a while.
     66                         */
     67                        test_getSelection_afterFocus2 : function()
     68                        {
     69                                prepareEditor( 'editor2', null, null, function( editor ){
     70                                        this.resume( function(){
     71                                               
     72                                                editor.focus();
     73                                                this.wait( function(){
     74                                                        var selection = editor.getSelection();
     75                                                        assert.isNotNull( selection, 'Editor selection should not be null.' );
     76                                                }, 100 );
     77                                        } );
     78                                }, this );
     79                               
     80                                this.wait();
     81                        },
     82                               
     83                        name :document.title
     84                };
     85        } )() );
     86
     87        //]]>
     88        </script>
     89</head>
     90<body>
     91        <textarea id="editor1" name="editor1"></textarea>
     92        <textarea id="editor2" name="editor2"></textarea>
     93        </body>
     94</html>
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy