assets/ckeditor/tests/plugins/widget/_helpers/tools.js
// dialog object as its first argument.
dialog object as its first argument.
dialog object as its first argument .
function assertWidgetDialog( editorBot, commandName, editorHtml, focusedWidgetIndex, expectedValues, htmlWithSelectionSource, onResume ) {
		var editor = editorBot.editor,
			dialogCheckedTab = 'info'; 
		editor.once( 'dialogShow', function( evt ) {
			var dialog = evt.data;
			resume( function() {
				try {
					expectedValues = expectedValues || {};
					for ( var i in expectedValues )
						assert.areSame( expectedValues[ i ], dialog.getValueOf( dialogCheckedTab, i ), 'Dialog field "' + i + '" in tab "' + dialogCheckedTab + '" has invalid value.' );
				} catch ( e ) {
					dialog.hide();
					throw e;
				}
				onResume && onResume( dialog );
				dialog.hide();
			} );
		} );
		editorBot.setData( editorHtml, function() {
			var widget = null;
			if ( typeof htmlWithSelectionSource == 'string' )
				editorBot.htmlWithSelection( htmlWithSelectionSource );
			if ( typeof focusedWidgetIndex == 'number' ) {
				widget = getWidgetByDOMOffset( editor, focusedWidgetIndex );
				assert.isNotNull( widget, 'Could not find widget with index ' + focusedWidgetIndex );
			} else if ( typeof focusedWidgetIndex == 'string' ) {
				widget = getWidgetById( editor, focusedWidgetIndex );
				assert.isNotNull( widget, 'Could not find widget with id ' + focusedWidgetIndex );
			}
			if ( widget )
				widget.focus();
			assert.isTrue( true );
			editor.execCommand( commandName );
			wait();
		} );
	}
function assertWidgetDialog ( editorBot , commandName , editorHtml , focusedWidgetIndex , expectedValues , htmlWithSelectionSource , onResume ) { var editor = editorBot . editor , dialogCheckedTab = 'info' ; editor . once ( 'dialogShow' , function ( evt ) { var dialog = evt . data ; resume ( function ( ) { try { expectedValues = expectedValues || { } ; for ( var i in expectedValues ) assert . areSame ( expectedValues [ i ] , dialog . getValueOf ( dialogCheckedTab , i ) , 'Dialog field "' + i + '" in tab "' + dialogCheckedTab + '" has invalid value.' ) ; } catch ( e ) { dialog . hide ( ) ; throw e ; } onResume && onResume ( dialog ) ; dialog . hide ( ) ; } ) ; } ) ; editorBot . setData ( editorHtml , function ( ) { var widget = null ; if ( typeof htmlWithSelectionSource == 'string' ) editorBot . htmlWithSelection ( htmlWithSelectionSource ) ; if ( typeof focusedWidgetIndex == 'number' ) { widget = getWidgetByDOMOffset ( editor , focusedWidgetIndex ) ; assert . isNotNull ( widget , 'Could not find widget with index ' + focusedWidgetIndex ) ; } else if ( typeof focusedWidgetIndex == 'string' ) { widget = getWidgetById ( editor , focusedWidgetIndex ) ; assert . isNotNull ( widget , 'Could not find widget with id ' + focusedWidgetIndex ) ; } if ( widget ) widget . focus ( ) ; assert . isTrue ( true ) ; editor . execCommand ( commandName ) ; wait ( ) ; } ) ; }
dialog object as its first argument.
dialog object as its first argument .
// Tab name in dialog. // Registering dialogShow listener, which will invoke resume(). // Lets check dialog contents. // Propagate error. // If html with seleciton was requested - override. // If index of widget to be focused is number. // In this case id was given.