MDL-44871 Atto: Move custom select text step to atto specific step definition.

This commit is contained in:
Damyon Wiese
2014-06-11 15:29:20 +08:00
parent 7d8f825bbf
commit e3adee555b
22 changed files with 90 additions and 65 deletions
@@ -235,12 +235,4 @@ class behat_form_field {
return $this->fieldlocator;
}
/**
* Select all the text in the form field.
*
*/
public function select_text() {
throw new coding_exception('select_text() is not supported for this form field type: ' . get_class($this));
}
}
@@ -8,7 +8,7 @@ Feature: Atto accessibility helper
And I follow "Admin User"
And I follow "Edit profile"
And I set the field "Description" to "<p>Some plain text</p><img src='/broken-image' alt='Image 1'/><p><a href='#fsd'>Some link text</a></p>"
And I select the text in the "Description" field
And I select the text in the "Description" Atto editor
When I click on "Show more buttons" "button"
And I click on "Screenreader helper" "button"
Then I should see "Links in text editor"
@@ -25,10 +25,10 @@ Feature: Atto accessibility helper
And I follow "Edit profile"
And I set the field "Description" to "<p>Some plain text</p>"
When I click on "Show more buttons" "button"
And I select the text in the "Description" field
And I select the text in the "Description" Atto editor
And I click on "Unordered list" "button"
And I click on "Screenreader helper" "button"
And I select the text in the "Description" field
And I select the text in the "Description" Atto editor
# This shows the current HTML tags applied to the selected text.
# This is required because they are not always read by a screen reader.
Then I should see "UL, LI"
@@ -10,7 +10,7 @@ Feature: Atto align text
And I set the field "Description" to "<p>Fascism</p>"
And I set the field "Text editor" to "Plain text area"
And I click on "Show more buttons" "button"
And I select the text in the "Description" field
And I select the text in the "Description" Atto editor
When I click on "Right align" "button"
And I press "Update profile"
And I follow "Edit profile"
@@ -24,7 +24,7 @@ Feature: Atto align text
And I set the field "Description" to "<p>Communism</p>"
And I set the field "Text editor" to "Plain text area"
And I click on "Show more buttons" "button"
And I select the text in the "Description" field
And I select the text in the "Description" Atto editor
When I click on "Right align" "button"
And I click on "Left align" "button"
And I press "Update profile"
@@ -39,7 +39,7 @@ Feature: Atto align text
And I set the field "Description" to "<p>United Future</p>"
And I set the field "Text editor" to "Plain text area"
And I click on "Show more buttons" "button"
And I select the text in the "Description" field
And I select the text in the "Description" Atto editor
When I click on "Center" "button"
And I press "Update profile"
And I follow "Edit profile"
@@ -9,7 +9,7 @@ Feature: Atto bold button
And I follow "Edit profile"
And I set the field "Text editor" to "Plain text area"
And I set the field "Description" to "Badger"
And I select the text in the "Description" field
And I select the text in the "Description" Atto editor
When I click on "Bold" "button"
And I press "Update profile"
And I follow "Edit profile"
@@ -22,7 +22,7 @@ Feature: Atto bold button
And I follow "Edit profile"
And I set the field "Text editor" to "Plain text area"
And I set the field "Description" to "Mouse"
And I select the text in the "Description" field
And I select the text in the "Description" Atto editor
When I click on "Bold" "button"
And I click on "Bold" "button"
And I press "Update profile"
@@ -9,7 +9,7 @@ Feature: Atto charmap button
And I follow "Edit profile"
And I set the field "Text editor" to "Plain text area"
And I set the field "Description" to "<p>1980 Mullet</p>"
And I select the text in the "Description" field
And I select the text in the "Description" Atto editor
When I click on "Show more buttons" "button"
And I click on "Insert character" "button"
And I click on "copyright sign" "button"
@@ -10,7 +10,7 @@ Feature: Atto clear button
And I set the field "Text editor" to "Plain text area"
And I set the field "Description" to "<p><i>Pisa</i></p>"
When I click on "Show more buttons" "button"
And I select the text in the "Description" field
And I select the text in the "Description" Atto editor
And I click on "Clear formatting" "button"
And I press "Update profile"
And I follow "Edit profile"
@@ -8,7 +8,7 @@ Feature: Atto equation editor
When I follow "Admin User"
And I follow "Edit profile"
And I set the field "Description" to "<p>Equation test</p>"
And I select the text in the "Description" field
And I select the text in the "Description" Atto editor
And I click on "Show more buttons" "button"
And I click on "Equation editor" "button"
And I set the field "Edit equation using" to " = 1 \div 0"
@@ -11,7 +11,7 @@ Feature: Add images to Atto
When I follow "Admin User"
And I follow "Edit profile"
And I set the field "Description" to "<p>Image test</p>"
And I select the text in the "Description" field
And I select the text in the "Description" Atto editor
And I click on "Image" "button"
And I click on "Browse repositories..." "button"
And I click on "Private files" "link"
@@ -23,7 +23,7 @@ Feature: Add images to Atto
And I click on "Save image" "button"
And I click on "Update profile" "button"
And I follow "Edit profile"
And I select the text in the "Description" field
And I select the text in the "Description" Atto editor
And I click on "Image" "button"
Then the field "Describe this image" matches value "It's the Moodle"
@@ -9,7 +9,7 @@ Feature: Indent text in Atto
And I follow "Edit profile"
And I set the field "Description" to "<p>I need some space.</p>"
And I set the field "Text editor" to "Plain text area"
And I select the text in the "Description" field
And I select the text in the "Description" Atto editor
And I click on "Show more buttons" "button"
And I click on "Indent" "button"
And I press "Update profile"
@@ -23,7 +23,7 @@ Feature: Indent text in Atto
And I follow "Edit profile"
And I set the field "Description" to "<p>I need some space.</p>"
And I set the field "Text editor" to "Plain text area"
And I select the text in the "Description" field
And I select the text in the "Description" Atto editor
And I click on "Show more buttons" "button"
And I click on "Indent" "button"
And I click on "Outdent" "button"
@@ -9,7 +9,7 @@ Feature: Atto italic button
And I follow "Edit profile"
And I set the field "Description" to "Tower of Pisa"
And I set the field "Text editor" to "Plain text area"
And I select the text in the "Description" field
And I select the text in the "Description" Atto editor
When I click on "Italic" "button"
And I press "Update profile"
And I follow "Edit profile"
@@ -22,7 +22,7 @@ Feature: Atto italic button
And I follow "Edit profile"
And I set the field "Description" to "GHD - for hair"
And I set the field "Text editor" to "Plain text area"
And I select the text in the "Description" field
And I select the text in the "Description" Atto editor
When I click on "Italic" "button"
And I click on "Italic" "button"
And I press "Update profile"
@@ -12,7 +12,7 @@ Feature: Add links to Atto
And I follow "Edit profile"
And I set the field "Text editor" to "Plain text area"
And I set the field "Description" to "Super cool"
And I select the text in the "Description" field
And I select the text in the "Description" Atto editor
And I click on "Link" "button"
And I click on "Browse repositories..." "button"
And I click on "Private files" "link"
@@ -13,7 +13,7 @@ Feature: Add media to Atto
And I expand "Blogs" node
And I follow "Add a new entry"
And I set the field "Blog entry body" to "<p>Media test</p>"
And I select the text in the "Blog entry body" field
And I select the text in the "Blog entry body" Atto editor
And I set the field "Entry title" to "The best video in the entire world (not really)"
And I click on "Media" "button"
And I click on "Browse repositories..." "button"
@@ -9,7 +9,7 @@ Feature: Atto ordered list button
And I follow "Edit profile"
And I set the field "Description" to "Have you heard the news everyone's talking<br/> Life is good 'cause everything's awesome<br/>"
And I set the field "Text editor" to "Plain text area"
And I select the text in the "Description" field
And I select the text in the "Description" Atto editor
When I click on "Ordered list" "button"
And I press "Update profile"
And I follow "Edit profile"
@@ -9,7 +9,7 @@ Feature: Atto strike button
And I follow "Edit profile"
And I set the field "Description" to "MUA"
And I set the field "Text editor" to "Plain text area"
And I select the text in the "Description" field
And I select the text in the "Description" Atto editor
And I click on "Show more buttons" "button"
When I click on "Strike through" "button"
And I press "Update profile"
@@ -9,7 +9,7 @@ Feature: Atto subscript button
And I follow "Edit profile"
And I set the field "Description" to "Submarine"
And I set the field "Text editor" to "Plain text area"
And I select the text in the "Description" field
And I select the text in the "Description" Atto editor
And I click on "Show more buttons" "button"
When I click on "Subscript" "button"
And I press "Update profile"
@@ -9,7 +9,7 @@ Feature: Atto superscript button
And I follow "Edit profile"
And I set the field "Description" to "Helicopter"
And I set the field "Text editor" to "Plain text area"
And I select the text in the "Description" field
And I select the text in the "Description" Atto editor
And I click on "Show more buttons" "button"
When I click on "Superscript" "button"
And I press "Update profile"
@@ -11,7 +11,7 @@ Feature: Atto tables
And I follow "Add a new entry"
And I set the field "Entry title" to "How to make a table"
And I set the field "Blog entry body" to "Table test"
And I select the text in the "Blog entry body" field
And I select the text in the "Blog entry body" Atto editor
And I click on "Show more buttons" "button"
When I click on "Table" "button"
And I set the field "Caption" to "Dinner"
@@ -28,7 +28,7 @@ Feature: Atto tables
And I follow "Add a new entry"
And I set the field "Entry title" to "How to make a table"
And I set the field "Blog entry body" to "<table><tr><td>Cell</td></tr></table>"
And I select the text in the "Blog entry body" field
And I select the text in the "Blog entry body" Atto editor
And I click on "Show more buttons" "button"
And I click on "Table" "button"
And I click on "Edit table" "link"
@@ -9,7 +9,7 @@ Feature: Atto title
And I follow "Edit profile"
And I set the field "Text editor" to "Plain text area"
And I set the field "Description" to "How The Rock Has Made the WWE World Heavyweight Title More Important Than Ever"
And I select the text in the "Description" field
And I select the text in the "Description" Atto editor
When I click on "Paragraph styles" "button"
When I click on "Heading 1" "link"
And I press "Update profile"
@@ -9,7 +9,7 @@ Feature: Atto underline button
And I follow "Edit profile"
And I set the field "Description" to "Deprecated HTML Tag"
And I set the field "Text editor" to "Plain text area"
And I select the text in the "Description" field
And I select the text in the "Description" Atto editor
And I click on "Show more buttons" "button"
When I click on "Underline" "button"
And I press "Update profile"
@@ -9,7 +9,7 @@ Feature: Atto unordered list button
And I follow "Edit profile"
And I set the field "Description" to "Things, dogs, clogs, they're awesome<br/> Rocks, clocks, and socks, they're awesome<br/> Figs, and wigs, and twigs, that's awesome<br/> Everything you see or think or say is awesome"
And I set the field "Text editor" to "Plain text area"
And I select the text in the "Description" field
And I select the text in the "Description" Atto editor
When I click on "Unordered list" "button"
And I press "Update profile"
And I follow "Edit profile"
@@ -0,0 +1,62 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Atto custom steps definitions.
*
* @package editor_atto
* @category test
* @copyright 2014 Damyon Wiese
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php.
/**
* Steps definitions to deal with the atto text editor
*
* @package editor_atto
* @category test
* @copyright 2014 Damyon Wiese
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class behat_editor_atto extends behat_base {
/**
* Select the text in an Atto field.
*
* @Given /^I select the text in the "([^"]*)" Atto editor$/
* @throws ElementNotFoundException Thrown by behat_base::find
* @param string $field
* @return void
*/
public function select_the_text_in_the_atto_editor($fieldlocator) {
if (!$this->running_javascript()) {
throw new coding_exception('Selecting text requires javascript.');
}
// We delegate to behat_form_field class, it will
// guess the type properly.
$field = behat_field_manager::get_form_field_from_label($fieldlocator, $this);
if (!method_exists($field, 'select_text')) {
throw new coding_exception('Field does not support the select_text function.');
}
$field->select_text();
}
}
-29
View File
@@ -155,18 +155,6 @@ class behat_forms extends behat_base {
$this->set_field_value($field, $value);
}
/**
* Select all the text in a field.
*
* @Given /^I select the text in the "([^"]*)" field$/
* @throws ElementNotFoundException Thrown by behat_base::find
* @param string $field
* @return void
*/
public function i_select_the_text_in_the_field($field) {
$this->select_text($field);
}
/**
* Checks, the field matches the value. More info in http://docs.moodle.org/dev/Acceptance_testing#Providing_values_to_steps.
*
@@ -344,23 +332,6 @@ class behat_forms extends behat_base {
}
}
/**
* Call select_text on the field.
*
* Internal API method, a generic *I select the text in the "FIELD" field*
* is based on it.
*
* @param string $fieldlocator The pointer to the field, it will depend on the field type.
* @return void
*/
protected function select_text($fieldlocator) {
// We delegate to behat_form_field class, it will
// guess the type properly.
$field = behat_field_manager::get_form_field_from_label($fieldlocator, $this);
$field->select_text();
}
/**
* Generic field setter.
*