1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
|
/* bender-tags: editor */
/* bender-ckeditor-plugins: floatingspace,toolbar,basicstyles,list,link,about */
function testToolbarExpanded( bot ) {
var editor = bot.editor,
collapser = editor.ui.space( 'toolbar_collapser' );
if ( editor.elementMode == CKEDITOR.ELEMENT_MODE_INLINE )
return testInline( editor, collapser );
var toolbox = collapser.getPrevious();
assert.areEqual( '', toolbox.getStyle( 'display' ) );
assert.isFalse( collapser.hasClass( 'cke_toolbox_collapser_min' ) );
editor.execCommand( 'toolbarCollapse' );
assert.areEqual( 'none', toolbox.getStyle( 'display' ) );
assert.isTrue( collapser.hasClass( 'cke_toolbox_collapser_min' ) );
}
function testInline( editor, collapser ) {
assert.isNull( collapser, 'No collapser for inline editor' );
var toolboxInner = editor.ui.space( 'toolbox' ).getFirst( function( node ) {
return node.type == CKEDITOR.NODE_ELEMENT;
} );
assert.isFalse( toolboxInner.hasClass( 'cke_toolbox_main' ), 'There should be no .cke_toolbox_main inside toolbox space' );
}
bender.editor = {
config: {
toolbar: 'Basic'
}
};
var F11 = 122,
ESC = 27;
bender.test( {
'test toolbar': function() {
assert.isNotNull( this.editor.ui.space( 'toolbox' ) );
assert.isNull( this.editor.ui.space( 'toolbar_collapser' ), 'No collapser by default' );
},
'test toolbarStartupExpanded=false': function() {
bender.editorBot.create(
{
name: 'editor1',
config: {
toolbarCanCollapse: true,
toolbarStartupExpanded: false
}
},
function( bot ) {
var editor = bot.editor,
collapser = editor.ui.space( 'toolbar_collapser' );
if ( editor.elementMode == CKEDITOR.ELEMENT_MODE_INLINE )
return testInline( editor, collapser );
var toolbox = collapser.getPrevious();
assert.areEqual( 'none', toolbox.getStyle( 'display' ) );
assert.isTrue( collapser.hasClass( 'cke_toolbox_collapser_min' ) );
editor.execCommand( 'toolbarCollapse' );
assert.areEqual( '', toolbox.getStyle( 'display' ) );
assert.isFalse( collapser.hasClass( 'cke_toolbox_collapser_min' ) );
}
);
},
'test toolbarStartupExpanded=true': function() {
bender.editorBot.create(
{
name: 'editor2',
config: {
toolbarCanCollapse: true,
toolbarStartupExpanded: true
}
},
testToolbarExpanded
);
},
'test toolbarCanCollapse=true': function() {
bender.editorBot.create(
{
name: 'editor3',
config: {
toolbarCanCollapse: true
}
},
testToolbarExpanded
);
},
'test toolbar collapse/expand fire resize event': function() {
bender.editorBot.create( {
name: 'editor4',
config: {
toolbarCanCollapse: true,
// Set the empty toolbar, so bazillions of buttons in the build mode will not
// break this test (the height comparison).
toolbar: [ [ 'Bold' ] ]
}
},
function( bot ) {
var resizeData = [],
editor = bot.editor;
editor.on( 'resize', function( e ) {
resizeData.push( e.data );
} );
editor.resize( 200, 400 );
assert.areEqual( 200, resizeData[ 0 ].outerWidth, 'Width should be set properly.' );
assert.areEqual( 400, resizeData[ 0 ].outerHeight, 'Height should be set properly.' );
editor.execCommand( 'toolbarCollapse' );
assert.isTrue( resizeData[ 1 ].outerHeight < resizeData[ 0 ].outerHeight, 'Height after collapse should be less.' );
editor.execCommand( 'toolbarCollapse' );
assert.areSame( resizeData[ 0 ].outerHeight, resizeData[ 2 ].outerHeight, 'Height should properly restore to same value.' );
}
);
},
// (#438)
'test focusing elements path': function() {
var editor = this.editor,
commandSpy = sinon.spy( editor, 'execCommand' ),
toolboxUIPart = editor.ui.space( 'toolbox' ).findOne( '.cke_button' );
this.editorBot.setHtmlWithSelection( '<b>f^oo</b>' );
// ALT + F11
toolboxUIPart.fireEventHandler( 'keydown', {
keyCode: F11,
altKey: true
} );
commandSpy.restore();
assert.isTrue( commandSpy.calledWith( 'elementsPathFocus' ) );
},
// (#438)
'test focusing editor': function() {
var editor = this.editor,
focusSpy = sinon.spy( editor, 'focus' ),
toolboxUIPart = editor.ui.space( 'toolbox' ).findOne( '.cke_button' );
this.editorBot.setHtmlWithSelection( '<b>f^oo</b>' );
toolboxUIPart.fireEventHandler( 'keydown', {
keyCode: ESC
} );
focusSpy.restore();
assert.isTrue( focusSpy.calledOnce );
}
} );
|