File: basic.js

package info (click to toggle)
ckeditor 4.16.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 258,804 kB
  • sloc: javascript: 239,590; sh: 184; makefile: 64; python: 37; php: 15; xml: 5
file content (127 lines) | stat: -rw-r--r-- 3,544 bytes parent folder | download | duplicates (2)
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
/* 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'
	}
};

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.' );
			}
		);
	}
} );