-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
T/200 #206
base: master
Are you sure you want to change the base?
T/200 #206
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
define( function() { | ||
'use strict'; | ||
|
||
return { | ||
// Returns a key event mockup. | ||
// @param {Number} keystroke Keystroke with modifiers. eg. CKEDITOR.SHIFT + 9 // shift + tab | ||
getKeyEvent: function( keystroke ) { | ||
// This fancy construction will remove modifier bits. | ||
var key = keystroke & ~( CKEDITOR.CTRL | CKEDITOR.ALT | CKEDITOR.SHIFT ); | ||
|
||
return { | ||
getKey: function() { | ||
return key; | ||
}, | ||
getKeystroke: function() { | ||
return keystroke; | ||
}, | ||
stopPropagation: function() { | ||
}, | ||
preventDefault: function() { | ||
} | ||
}; | ||
} | ||
} | ||
} ); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,14 +2,47 @@ | |
* @license Copyright (c) 2014-2016, CKSource - Frederico Knabben. All rights reserved. | ||
* For licensing, see LICENSE.md or http://ckeditor.com/license | ||
*/ | ||
/* bender-ckeditor-plugins: a11ychecker,toolbar,undo */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need undo plugin? |
||
/* bender-tags: a11ychecker,unit */ | ||
|
||
( function() { | ||
'use strict'; | ||
|
||
bender.require( [ 'ui/Viewer', 'ui/ViewerDescription', 'mocking' ], function( Viewer, ViewerDescription, mocking ) { | ||
bender.require( [ 'ui/Viewer', 'ui/ViewerDescription', 'mocking', 'EngineMock', 'testSuite', 'helpers/keyEvent' ], function( Viewer, ViewerDescription, mocking, EngineMock, testSuite, keyEvent ) { | ||
testSuite.useEngine( EngineMock ); | ||
|
||
bender.editors = { | ||
classic: { | ||
name: 'editor1', | ||
startupData: '<p>foo</p>' | ||
}, | ||
inline: { | ||
name: 'editor2', | ||
creator: 'inline', | ||
startupData: '<p>foo</p>' | ||
} | ||
}; | ||
|
||
var tests = { | ||
tearDown: function() { | ||
// For each test a11ychecker needs to be closed. | ||
// Note that we have 2 editor instances, but only 1 can be enabled at | ||
// a time. | ||
function cleanupAC( editor ) { | ||
var a11ychecker = editor._.a11ychecker; | ||
|
||
if ( a11ychecker.issues && a11ychecker.issues.getFocused() ) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to reset the focus in this test suite? I don't think it's explicitly focused in any of these tests. With that |
||
// @todo: it might be worth to investigate what's causing wrong selection if we won't call resetFocus(). | ||
a11ychecker.issues.resetFocus(); | ||
} | ||
|
||
a11ychecker.close(); | ||
} | ||
|
||
cleanupAC( this.editors.classic ); | ||
cleanupAC( this.editors.inline ); | ||
}, | ||
|
||
bender.test( { | ||
'test Viewer.setupDescription': function() { | ||
var mock = { | ||
setupDescription: Viewer.prototype.setupDescription | ||
|
@@ -31,7 +64,24 @@ | |
// Ensure that append method was called for elem in panel.parts. | ||
assert.areSame( 1, appendMock.callCount, 'panel.parts.content.append call count' ); | ||
mocking.assert.alwaysCalledWith( appendMock, mock.description.parts.wrapper ); | ||
}, | ||
'test Viewer close with hotkey': function( editor ) { | ||
var a11ychecker = editor._.a11ychecker, | ||
viewer = a11ychecker.viewerController.viewer, | ||
closeButton = viewer.panel.parts.close; | ||
|
||
viewer.panel.blur = mocking.spy(); | ||
viewer.panel.hide = mocking.spy(); | ||
|
||
a11ychecker.exec(); | ||
|
||
closeButton.fire( 'keydown', keyEvent.getKeyEvent( 32 ) ); | ||
|
||
assert.isTrue( viewer.panel.blur.called ); | ||
assert.isTrue( viewer.panel.hide.called ); | ||
} | ||
} ); | ||
}; | ||
|
||
testSuite.testEditors( bender.editors, tests ); | ||
} ); | ||
} )(); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,6 +91,28 @@ define( [ | |
}, this ); | ||
} ); | ||
|
||
this.panel.addShowListener( function() { | ||
return this.parts.close.on( 'keydown', function( evt ) { | ||
var keystroke = evt.data.getKeystroke(); | ||
|
||
// Hide the panel on space key press in close button. | ||
if ( keystroke == 32 ) { | ||
this.blur(); | ||
this.hide(); | ||
evt.data.preventDefault(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} | ||
}, this ); | ||
} ); | ||
|
||
// Hide the panel once the closing X is clicked. | ||
this.panel.addShowListener( function() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You've added another click listener here, it's not needed. |
||
return this.parts.close.on( 'click', function( evt ) { | ||
this.blur(); | ||
this.hide(); | ||
evt.data.preventDefault(); | ||
}, this ); | ||
} ); | ||
|
||
this.panel.addShowListener( function() { | ||
return this.parts.panel.on( 'keydown', function( evt ) { | ||
var keystroke = evt.data.getKeystroke(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, put the last TC "- Open Accessiblity Checker, press
Shift+Tab
twice. The close button should be focused. Ensure that in this state pressing thespace
key closes Accessiblity Checker." into a dedicated manual test case.Create a
.md
file withtc
tag, and target AC version (1.0.1).