| 117 | |
| 118 | /** |
| 119 | * All tests in this case share a fully interacted 'playground' editor instance. |
| 120 | */ |
| 121 | CKEDITOR.test.InteractiveEditorTestCase = function( template ) { |
| 122 | CKEDITOR.test.InteractiveEditorTestCase.superclass.constructor.call( this, template ); |
| 123 | // The editor instance shared by all tests. |
| 124 | this.editor = null; |
| 125 | }; |
| 126 | |
| 127 | YAHOO.lang.extend( CKEDITOR.test.InteractiveEditorTestCase, YAHOO.tool.TestCase, { |
| 128 | |
| 129 | /** |
| 130 | * Load the editor and wait for fully interactable, the editor is created by replacement mode. |
| 131 | * @param {CKEDITOR.config} config The config options for the shared editor instance. |
| 132 | * @param {Functoin} callback The callback continuation function. |
| 133 | */ |
| 134 | waitForEditor :function ( callback, config ) |
| 135 | { |
| 136 | if ( this.editor ) |
| 137 | callback.call( this ); |
| 138 | else |
| 139 | { |
| 140 | var editorName = this.editorName || 'test_editor'; |
| 141 | CKEDITOR.on( 'instanceReady', function( evt ) |
| 142 | { |
| 143 | if ( evt.editor.name == editorName ) |
| 144 | { |
| 145 | window.setTimeout( CKEDITOR.tools.bind( function() |
| 146 | { |
| 147 | |
| 148 | this.editor = evt.editor; |
| 149 | this.editor.focus(); |
| 150 | this.resume( CKEDITOR.tools.bind( callback, this ) ); |
| 151 | |
| 152 | }, this ), 0 ); |
| 153 | } |
| 154 | }, this ); |
| 155 | |
| 156 | var element = CKEDITOR.document.getBody().append( |
| 157 | CKEDITOR.dom.element.createFromHtml( |
| 158 | '<textarea id="' + editorName + '"></textarea>') ); |
| 159 | element.setValue( this.defaultEditorData ); |
| 160 | |
| 161 | CKEDITOR.replace( element.getAttribute( 'id' ), config ); |
| 162 | |
| 163 | // First load, async |
| 164 | this.wait(); |
| 165 | } |
| 166 | }, |
| 167 | |
| 168 | setUp : function() { |
| 169 | if(this.editor) |
| 170 | { |
| 171 | this.editor.loadSnapshot( this.defaultEditorData ); |
| 172 | this.editor.focus(); |
| 173 | } |
| 174 | }, |
| 175 | |
| 176 | /** |
| 177 | * Clear up the editor data for each test. |
| 178 | */ |
| 179 | tearDown : function() { |
| 180 | if( this.editor ) |
| 181 | { |
| 182 | this.editor.loadSnapshot(''); |
| 183 | } |
| 184 | } |
| 185 | }); |
| 186 | No newline at end of file |