Bug 1253989 Part 3 - Use @parameterized to rewrite selection mode tests. r=mtseng

* Inline some of the open_*_html methods since they're called only once.
* Save test running time by finding the elements needed in tests instead
  of find all of the elements in open_*_html methods.
* Remove test_long_press_to_select_non_selectable_word() since it's
  covered by test_focus_not_changed_by_long_press_on_non_selectable().
* Use hyphen for element ids.
* Replace "left" and "right" caret by "first" and "second" caret,
  respectively.

MozReview-Commit-ID: Ey5m5zO3HYc

--HG--
extra : rebase_source : c94b84ced75560ce1167cda35ee94dd4cc81ee4d
This commit is contained in:
Ting-Yu Lin 2016-03-08 22:21:31 +08:00
parent b40db974b8
commit 732119fb5b
2 changed files with 166 additions and 302 deletions

View File

@ -3,11 +3,14 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
import re
from marionette.marionette_test import (
MarionetteTestCase, SkipTest, parameterized
)
from marionette_driver.by import By
from marionette_driver.marionette import Actions
from marionette import MarionetteTestCase, SkipTest
from marionette_driver.selection import SelectionManager
import re
def skip_if_not_rotatable(target):
@ -19,12 +22,19 @@ def skip_if_not_rotatable(target):
class AccessibleCaretSelectionModeTestCase(MarionetteTestCase):
'''Test cases for AccessibleCaret under selection mode, aka selection carets.
'''
'''Test cases for AccessibleCaret under selection mode.'''
_input_id = 'input'
_textarea_id = 'textarea'
_textarea2_id = 'textarea2'
_textarea_rtl_id = 'textarea-rtl'
_contenteditable_id = 'contenteditable'
_contenteditable2_id = 'contenteditable2'
_content_id = 'content'
_content2_id = 'content2'
_non_selectable_id = 'non-selectable'
def setUp(self):
# Code to execute before a tests are run.
# Code to execute before every test is running.
super(AccessibleCaretSelectionModeTestCase, self).setUp()
self.carets_tested_pref = 'layout.accessiblecaret.enabled'
self.prefs = {
@ -36,62 +46,17 @@ class AccessibleCaretSelectionModeTestCase(MarionetteTestCase):
self.actions = Actions(self.marionette)
def open_test_html(self):
'Open html for testing and locate elements.'
test_html = self.marionette.absolute_url('test_selectioncarets.html')
self.marionette.navigate(test_html)
self._input = self.marionette.find_element(By.ID, 'input')
self._textarea = self.marionette.find_element(By.ID, 'textarea')
self._textarea_rtl = self.marionette.find_element(By.ID, 'textarea_rtl')
self._contenteditable = self.marionette.find_element(By.ID, 'contenteditable')
self._content = self.marionette.find_element(By.ID, 'content')
self._non_selectable = self.marionette.find_element(By.ID, 'non_selectable')
def open_test_html2(self):
'Open html for testing and locate elements.'
test_html2 = self.marionette.absolute_url('test_selectioncarets_multipleline.html')
self.marionette.navigate(test_html2)
self._textarea2 = self.marionette.find_element(By.ID, 'textarea2')
self._contenteditable2 = self.marionette.find_element(By.ID, 'contenteditable2')
self._content2 = self.marionette.find_element(By.ID, 'content2')
def open_test_html_multirange(self):
'Open html for testing non-editable support.'
test_html = self.marionette.absolute_url('test_selectioncarets_multiplerange.html')
self.marionette.navigate(test_html)
self._body = self.marionette.find_element(By.ID, 'bd')
self._sel1 = self.marionette.find_element(By.ID, 'sel1')
self._sel2 = self.marionette.find_element(By.ID, 'sel2')
self._sel3 = self.marionette.find_element(By.ID, 'sel3')
self._sel4 = self.marionette.find_element(By.ID, 'sel4')
self._sel6 = self.marionette.find_element(By.ID, 'sel6')
self._nonsel1 = self.marionette.find_element(By.ID, 'nonsel1')
def open_test_html_long_text(self):
'Open html for testing long text.'
test_html = self.marionette.absolute_url('test_selectioncarets_longtext.html')
self.marionette.navigate(test_html)
self._body = self.marionette.find_element(By.ID, 'bd')
self._longtext = self.marionette.find_element(By.ID, 'longtext')
def open_test_html_iframe(self):
'Open html for testing iframe.'
test_html = self.marionette.absolute_url('test_selectioncarets_iframe.html')
self.marionette.navigate(test_html)
self._iframe = self.marionette.find_element(By.ID, 'frame')
def open_test_html_display_none(self):
'Open html for testing html with display: none.'
test_html = self.marionette.absolute_url('test_carets_display_none.html')
self.marionette.navigate(test_html)
self._html = self.marionette.find_element(By.ID, 'html')
self._content = self.marionette.find_element(By.ID, 'content')
def word_offset(self, text, ordinal):
'Get the character offset of the ordinal-th word in text.'
tokens = re.split(r'(\S+)', text) # both words and spaces
@ -129,7 +94,7 @@ class AccessibleCaretSelectionModeTestCase(MarionetteTestCase):
sel = SelectionManager(el)
offset = self.word_offset(sel.content, ordinal)
# Move caret to the word.
# Move the blinking cursor to the word.
el.tap()
sel.move_caret_to_front()
sel.move_caret_by_offset(offset)
@ -184,7 +149,17 @@ class AccessibleCaretSelectionModeTestCase(MarionetteTestCase):
return s.replace('\r\n', '\n').replace('\r', '\n')
def _test_long_press_to_select_a_word(self, el, assertFunc):
@parameterized(_input_id, el_id=_input_id)
@parameterized(_textarea_id, el_id=_textarea_id)
@parameterized(_textarea_rtl_id, el_id=_textarea_rtl_id)
@parameterized(_contenteditable_id, el_id=_contenteditable_id)
@parameterized(_content_id, el_id=_content_id)
def test_long_press_to_select_a_word(self, el_id):
self.open_test_html()
el = self.marionette.find_element(By.ID, el_id)
self._test_long_press_to_select_a_word(el)
def _test_long_press_to_select_a_word(self, el):
sel = SelectionManager(el)
original_content = sel.content
words = original_content.split()
@ -195,9 +170,16 @@ class AccessibleCaretSelectionModeTestCase(MarionetteTestCase):
self.long_press_on_word(el, 0)
# Ignore extra spaces selected after the word.
assertFunc(target_content, sel.selected_content)
self.assertEqual(target_content, sel.selected_content)
def _test_move_selection_carets(self, el, assertFunc):
@parameterized(_input_id, el_id=_input_id)
@parameterized(_textarea_id, el_id=_textarea_id)
@parameterized(_textarea_rtl_id, el_id=_textarea_rtl_id)
@parameterized(_contenteditable_id, el_id=_contenteditable_id)
@parameterized(_content_id, el_id=_content_id)
def test_drag_carets(self, el_id):
self.open_test_html()
el = self.marionette.find_element(By.ID, el_id)
sel = SelectionManager(el)
original_content = sel.content
words = original_content.split()
@ -214,17 +196,34 @@ class AccessibleCaretSelectionModeTestCase(MarionetteTestCase):
self.long_press_on_word(el, 0)
# Move the right caret to the end of the content.
# Drag the second caret to the end of the content.
(caret1_x, caret1_y), (caret2_x, caret2_y) = sel.selection_carets_location()
self.actions.flick(el, caret2_x, caret2_y, end_caret_x, end_caret_y).perform()
# Move the left caret to the previous position of the right caret.
# Drag the first caret to the previous position of the second caret.
self.actions.flick(el, caret1_x, caret1_y, caret2_x, caret2_y).perform()
assertFunc(target_content, sel.selected_content)
self.assertEqual(target_content, sel.selected_content)
def _test_minimum_select_one_character(self, el, assertFunc,
x=None, y=None):
@parameterized(_input_id, el_id=_input_id)
@parameterized(_textarea_id, el_id=_textarea_id)
@parameterized(_textarea_rtl_id, el_id=_textarea_rtl_id)
@parameterized(_contenteditable_id, el_id=_contenteditable_id)
@parameterized(_content_id, el_id=_content_id)
def test_minimum_select_one_character(self, el_id):
self.open_test_html()
el = self.marionette.find_element(By.ID, el_id)
self._test_minimum_select_one_character(el)
@parameterized(_textarea2_id, el_id=_textarea2_id)
@parameterized(_contenteditable2_id, el_id=_contenteditable2_id)
@parameterized(_content2_id, el_id=_content2_id)
def test_minimum_select_one_character2(self, el_id):
self.open_test_html2()
el = self.marionette.find_element(By.ID, el_id)
self._test_minimum_select_one_character(el)
def _test_minimum_select_one_character(self, el, x=None, y=None):
sel = SelectionManager(el)
original_content = sel.content
words = original_content.split()
@ -247,21 +246,45 @@ class AccessibleCaretSelectionModeTestCase(MarionetteTestCase):
x, y = self.word_location(el, 0)
self.long_press_on_location(el, x, y)
# Move the right caret to the end of the content.
# Drag the second caret to the end of the content.
(caret1_x, caret1_y), (caret2_x, caret2_y) = sel.selection_carets_location()
self.actions.flick(el, caret2_x, caret2_y, end_caret_x, end_caret_y).perform()
# Move the right caret to the position of the left caret.
# Drag the second caret to the position of the first caret.
(caret1_x, caret1_y), (caret2_x, caret2_y) = sel.selection_carets_location()
self.actions.flick(el, caret2_x, caret2_y, caret1_x, caret1_y).perform()
assertFunc(target_content, sel.selected_content)
self.assertEqual(target_content, sel.selected_content)
def _test_focus_obtained_by_long_press(self, el1, el2):
@parameterized(_input_id + '_to_' + _textarea_id,
el1_id=_input_id, el2_id=_textarea_id)
@parameterized(_input_id + '_to_' + _contenteditable_id,
el1_id=_input_id, el2_id=_contenteditable_id)
@parameterized(_input_id + '_to_' + _content_id,
el1_id=_input_id, el2_id=_content_id)
@parameterized(_textarea_id + '_to_' + _input_id,
el1_id=_textarea_id, el2_id=_input_id)
@parameterized(_textarea_id + '_to_' + _contenteditable_id,
el1_id=_textarea_id, el2_id=_contenteditable_id)
@parameterized(_textarea_id + '_to_' + _content_id,
el1_id=_textarea_id, el2_id=_content_id)
@parameterized(_contenteditable_id + '_to_' + _input_id,
el1_id=_contenteditable_id, el2_id=_input_id)
@parameterized(_contenteditable_id + '_to_' + _textarea_id,
el1_id=_contenteditable_id, el2_id=_textarea_id)
@parameterized(_contenteditable_id + '_to_' + _content_id,
el1_id=_contenteditable_id, el2_id=_content_id)
@parameterized(_content_id + '_to_' + _input_id,
el1_id=_content_id, el2_id=_input_id)
@parameterized(_content_id + '_to_' + _textarea_id,
el1_id=_content_id, el2_id=_textarea_id)
@parameterized(_content_id + '_to_' + _contenteditable_id,
el1_id=_content_id, el2_id=_contenteditable_id)
def test_long_press_changes_focus_from(self, el1_id, el2_id):
'''Test the focus could be changed from el1 to el2 by long press.
If the focus is changed to e2 successfully, SelectionCarets should
appear and could be dragged.
If the focus is changed to e2 successfully, the carets should appear and
could be dragged.
'''
# Goal: Tap to focus el1, and then select the first character on
@ -270,28 +293,45 @@ class AccessibleCaretSelectionModeTestCase(MarionetteTestCase):
# We want to collect the location of the first word in el2 here
# since self.word_location() has the side effect which would
# change the focus.
self.open_test_html()
el1 = self.marionette.find_element(By.ID, el1_id)
el2 = self.marionette.find_element(By.ID, el2_id)
x, y = self.word_location(el2, 0)
el1.tap()
self._test_minimum_select_one_character(el2, self.assertEqual,
x=x, y=y)
self._test_minimum_select_one_character(el2, x=x, y=y)
@parameterized(_input_id, el_id=_input_id)
@parameterized(_textarea_id, el_id=_textarea_id)
@parameterized(_textarea_rtl_id, el_id=_textarea_rtl_id)
@parameterized(_contenteditable_id, el_id=_contenteditable_id)
def test_focus_not_changed_by_long_press_on_non_selectable(self, el_id):
self.open_test_html()
el = self.marionette.find_element(By.ID, el_id)
non_selectable = self.marionette.find_element(By.ID, self._non_selectable_id)
def _test_focus_not_being_changed_by_long_press_on_non_selectable(self, el):
# Goal: Focus remains on the editable element el after long pressing on
# the non-selectable element.
sel = SelectionManager(el)
self.long_press_on_word(el, 0)
self.long_press_on_location(self._non_selectable)
self.long_press_on_location(non_selectable)
active_sel = SelectionManager(self.marionette.get_active_element())
self.assertEqual(sel.content, active_sel.content)
def _test_handle_tilt_when_carets_overlap_to_each_other(self, el, assertFunc):
@parameterized(_input_id, el_id=_input_id)
@parameterized(_textarea_id, el_id=_textarea_id)
@parameterized(_textarea_rtl_id, el_id=_textarea_rtl_id)
@parameterized(_contenteditable_id, el_id=_contenteditable_id)
@parameterized(_content_id, el_id=_content_id)
def test_handle_tilt_when_carets_overlap_each_other(self, el_id):
'''Test tilt handling when carets overlap to each other.
Let SelectionCarets overlap to each other. If SelectionCarets are set
to tilted successfully, tapping the tilted carets should not cause the
selection to be collapsed and the carets should be draggable.
'''
Let the two carets overlap each other. If they are set to tilted
successfully, tapping the tilted carets should not cause the selection
to be collapsed and the carets should be draggable.
'''
self.open_test_html()
el = self.marionette.find_element(By.ID, el_id)
sel = SelectionManager(el)
original_content = sel.content
words = original_content.split()
@ -301,7 +341,7 @@ class AccessibleCaretSelectionModeTestCase(MarionetteTestCase):
self.long_press_on_word(el, 0)
target_content = sel.selected_content
# Move the left caret to the position of the right caret to trigger
# Drag the first caret to the position of the second caret to trigger
# carets overlapping.
(caret1_x, caret1_y), (caret2_x, caret2_y) = sel.selection_carets_location()
self.actions.flick(el, caret1_x, caret1_y, caret2_x, caret2_y).perform()
@ -313,16 +353,10 @@ class AccessibleCaretSelectionModeTestCase(MarionetteTestCase):
(caret3_x, caret3_y), (caret4_x, caret4_y) = sel.selection_carets_location()
# The following values are from ua.css and all.js
if self.carets_tested_pref == 'selectioncaret.enabled':
caret_width = 44
caret_margin_left = -23
tilt_right_margin_left = 18
tilt_left_margin_left = -17
elif self.carets_tested_pref == 'layout.accessiblecaret.enabled':
caret_width = float(self.marionette.get_pref('layout.accessiblecaret.width'))
caret_margin_left = float(self.marionette.get_pref('layout.accessiblecaret.margin-left'))
tilt_right_margin_left = 0.41 * caret_width;
tilt_left_margin_left = -0.39 * caret_width;
caret_width = float(self.marionette.get_pref('layout.accessiblecaret.width'))
caret_margin_left = float(self.marionette.get_pref('layout.accessiblecaret.margin-left'))
tilt_right_margin_left = 0.41 * caret_width
tilt_left_margin_left = -0.39 * caret_width
left_caret_left_edge_x = caret3_x + caret_margin_left + tilt_left_margin_left
el.tap(left_caret_left_edge_x + 2, caret3_y)
@ -331,53 +365,46 @@ class AccessibleCaretSelectionModeTestCase(MarionetteTestCase):
tilt_right_margin_left + caret_width)
el.tap(right_caret_right_edge_x - 2, caret4_y)
# Drag the left caret back to the initial selection, the first word.
# Drag the first caret back to the initial selection, the first word.
self.actions.flick(el, caret3_x, caret3_y, caret1_x, caret1_y).perform()
assertFunc(target_content, sel.selected_content)
def test_long_press_to_select_non_selectable_word(self):
'''Testing long press on non selectable field.
We should not select anything when long press on non selectable fields.'''
self.open_test_html_multirange()
halfY = self._nonsel1.size['height'] / 2
self.long_press_on_location(self._nonsel1, 0, halfY)
sel = SelectionManager(self._nonsel1)
range_count = sel.range_count()
self.assertEqual(range_count, 0)
self.assertEqual(target_content, sel.selected_content)
def test_drag_caret_over_non_selectable_field(self):
'''Testing drag caret over non selectable field.
So that the selected content should exclude non selectable field and
end selection caret should appear in last range's position.'''
self.open_test_html_multirange()
body = self.marionette.find_element(By.ID, 'bd')
sel3 = self.marionette.find_element(By.ID, 'sel3')
sel4 = self.marionette.find_element(By.ID, 'sel4')
sel6 = self.marionette.find_element(By.ID, 'sel6')
# Select target element and get target caret location
self.long_press_on_word(self._sel4, 3)
sel = SelectionManager(self._body)
self.long_press_on_word(sel4, 3)
sel = SelectionManager(body)
(_, _), (end_caret_x, end_caret_y) = sel.selection_carets_location()
self.long_press_on_word(self._sel6, 0)
self.long_press_on_word(sel6, 0)
(_, _), (end_caret2_x, end_caret2_y) = sel.selection_carets_location()
# Select start element
self.long_press_on_word(self._sel3, 3)
self.long_press_on_word(sel3, 3)
# Drag end caret to target location
(caret1_x, caret1_y), (caret2_x, caret2_y) = sel.selection_carets_location()
self.actions.flick(self._body, caret2_x, caret2_y, end_caret_x, end_caret_y, 1).perform()
self.actions.flick(body, caret2_x, caret2_y, end_caret_x, end_caret_y, 1).perform()
self.assertEqual(self.to_unix_line_ending(sel.selected_content.strip()),
'this 3\nuser can select this')
(caret1_x, caret1_y), (caret2_x, caret2_y) = sel.selection_carets_location()
self.actions.flick(self._body, caret2_x, caret2_y, end_caret2_x, end_caret2_y, 1).perform()
self.actions.flick(body, caret2_x, caret2_y, end_caret2_x, end_caret2_y, 1).perform()
self.assertEqual(self.to_unix_line_ending(sel.selected_content.strip()),
'this 3\nuser can select this 4\nuser can select this 5\nuser')
# Drag first caret to target location
(caret1_x, caret1_y), (caret2_x, caret2_y) = sel.selection_carets_location()
self.actions.flick(self._body, caret1_x, caret1_y, end_caret_x, end_caret_y, 1).perform()
self.actions.flick(body, caret1_x, caret1_y, end_caret_x, end_caret_y, 1).perform()
self.assertEqual(self.to_unix_line_ending(sel.selected_content.strip()),
'4\nuser can select this 5\nuser')
@ -386,21 +413,24 @@ class AccessibleCaretSelectionModeTestCase(MarionetteTestCase):
Test caret visibility when caret is dragged to beginning of a line
'''
self.open_test_html_multirange()
body = self.marionette.find_element(By.ID, 'bd')
sel1 = self.marionette.find_element(By.ID, 'sel1')
sel2 = self.marionette.find_element(By.ID, 'sel2')
# Select the first word in the second line
self.long_press_on_word(self._sel2, 0)
sel = SelectionManager(self._body)
self.long_press_on_word(sel2, 0)
sel = SelectionManager(body)
(start_caret_x, start_caret_y), (end_caret_x, end_caret_y) = sel.selection_carets_location()
# Select target word in the first line
self.long_press_on_word(self._sel1, 2)
self.long_press_on_word(sel1, 2)
# Drag end caret to the beginning of the second line
(caret1_x, caret1_y), (caret2_x, caret2_y) = sel.selection_carets_location()
self.actions.flick(self._body, caret2_x, caret2_y, start_caret_x, start_caret_y).perform()
self.actions.flick(body, caret2_x, caret2_y, start_caret_x, start_caret_y).perform()
# Drag end caret back to the target word
self.actions.flick(self._body, start_caret_x, start_caret_y, caret2_x, caret2_y).perform()
self.actions.flick(body, start_caret_x, start_caret_y, caret2_x, caret2_y).perform()
self.assertEqual(self.to_unix_line_ending(sel.selected_content), 'select')
@ -409,18 +439,23 @@ class AccessibleCaretSelectionModeTestCase(MarionetteTestCase):
'''Bug 1094072
If positions of carets are updated correctly, they should be draggable.
'''
self.open_test_html_long_text()
test_html = self.marionette.absolute_url('test_selectioncarets_longtext.html')
self.marionette.navigate(test_html)
body = self.marionette.find_element(By.ID, 'bd')
longtext = self.marionette.find_element(By.ID, 'longtext')
# Select word in portrait mode, then change to landscape mode
self.marionette.set_orientation('portrait')
self.long_press_on_word(self._longtext, 12)
sel = SelectionManager(self._body)
self.long_press_on_word(longtext, 12)
sel = SelectionManager(body)
(p_start_caret_x, p_start_caret_y), (p_end_caret_x, p_end_caret_y) = sel.selection_carets_location()
self.marionette.set_orientation('landscape')
(l_start_caret_x, l_start_caret_y), (l_end_caret_x, l_end_caret_y) = sel.selection_carets_location()
# Drag end caret to the start caret to change the selected content
self.actions.flick(self._body, l_end_caret_x, l_end_caret_y, l_start_caret_x, l_start_caret_y).perform()
self.actions.flick(body, l_end_caret_x, l_end_caret_y,
l_start_caret_x, l_start_caret_y).perform()
# Change orientation back to portrait mode to prevent affecting
# other tests
@ -435,16 +470,18 @@ class AccessibleCaretSelectionModeTestCase(MarionetteTestCase):
huge offset. If we use the right coordinate system, selection should
work. Otherwise, it would be hard to trigger select word.
'''
self.open_test_html_iframe()
test_html = self.marionette.absolute_url('test_selectioncarets_iframe.html')
self.marionette.navigate(test_html)
iframe = self.marionette.find_element(By.ID, 'frame')
# switch to inner iframe and scroll to the bottom
self.marionette.switch_to_frame(self._iframe)
self.marionette.switch_to_frame(iframe)
self.marionette.execute_script(
'document.getElementById("bd").scrollTop += 999')
# long press to select bottom text
self._body = self.marionette.find_element(By.ID, 'bd')
sel = SelectionManager(self._body)
body = self.marionette.find_element(By.ID, 'bd')
sel = SelectionManager(body)
self._bottomtext = self.marionette.find_element(By.ID, 'bottomtext')
self.long_press_on_location(self._bottomtext)
@ -455,197 +492,24 @@ class AccessibleCaretSelectionModeTestCase(MarionetteTestCase):
display: none.
'''
self.open_test_html_display_none()
test_html = self.marionette.absolute_url('test_carets_display_none.html')
self.marionette.navigate(test_html)
html = self.marionette.find_element(By.ID, 'html')
content = self.marionette.find_element(By.ID, 'content')
# Remove 'display: none' from <html>
self.marionette.execute_script(
'arguments[0].style.display = "unset";',
script_args=[self._html]
script_args=[html]
)
# If AccessibleCaretEventHub is initialized successfully, select a word
# should work.
self._test_long_press_to_select_a_word(self._content, self.assertEqual)
########################################################################
# <input> test cases with selection carets enabled
########################################################################
def test_input_long_press_to_select_a_word(self):
self.open_test_html()
self._test_long_press_to_select_a_word(self._input, self.assertEqual)
def test_input_move_selection_carets(self):
self.open_test_html()
self._test_move_selection_carets(self._input, self.assertEqual)
def test_input_minimum_select_one_character(self):
self.open_test_html()
self._test_minimum_select_one_character(self._input, self.assertEqual)
def test_input_focus_obtained_by_long_press_from_textarea(self):
self.open_test_html()
self._test_focus_obtained_by_long_press(self._textarea, self._input)
def test_input_focus_obtained_by_long_press_from_contenteditable(self):
self.open_test_html()
self._test_focus_obtained_by_long_press(self._contenteditable, self._input)
def test_input_focus_obtained_by_long_press_from_content_non_editable(self):
self.open_test_html()
self._test_focus_obtained_by_long_press(self._content, self._input)
def test_input_handle_tilt_when_carets_overlap_to_each_other(self):
self.open_test_html()
self._test_handle_tilt_when_carets_overlap_to_each_other(self._input, self.assertEqual)
def test_input_focus_not_changed_by_long_press_on_non_selectable(self):
self.open_test_html()
self._test_focus_not_being_changed_by_long_press_on_non_selectable(self._input)
########################################################################
# <textarea> test cases with selection carets enabled
########################################################################
def test_textarea_long_press_to_select_a_word(self):
self.open_test_html()
self._test_long_press_to_select_a_word(self._textarea, self.assertEqual)
def test_textarea_move_selection_carets(self):
self.open_test_html()
self._test_move_selection_carets(self._textarea, self.assertEqual)
def test_textarea_minimum_select_one_character(self):
self.open_test_html()
self._test_minimum_select_one_character(self._textarea, self.assertEqual)
def test_textarea_focus_obtained_by_long_press_from_input(self):
self.open_test_html()
self._test_focus_obtained_by_long_press(self._input, self._textarea)
def test_textarea_focus_obtained_by_long_press_from_contenteditable(self):
self.open_test_html()
self._test_focus_obtained_by_long_press(self._contenteditable, self._textarea)
def test_textarea_focus_obtained_by_long_press_from_content_non_editable(self):
self.open_test_html()
self._test_focus_obtained_by_long_press(self._content, self._textarea)
def test_textarea_handle_tilt_when_carets_overlap_to_each_other(self):
self.open_test_html()
self._test_handle_tilt_when_carets_overlap_to_each_other(self._textarea, self.assertEqual)
def test_textarea_focus_not_changed_by_long_press_on_non_selectable(self):
self.open_test_html()
self._test_focus_not_being_changed_by_long_press_on_non_selectable(self._textarea)
########################################################################
# <textarea> right-to-left test cases with selection carets enabled
########################################################################
def test_textarea_rtl_long_press_to_select_a_word(self):
self.open_test_html()
self._test_long_press_to_select_a_word(self._textarea_rtl, self.assertEqual)
def test_textarea_rtl_move_selection_carets(self):
self.open_test_html()
self._test_move_selection_carets(self._textarea_rtl, self.assertEqual)
def test_textarea_rtl_minimum_select_one_character(self):
self.open_test_html()
self._test_minimum_select_one_character(self._textarea_rtl, self.assertEqual)
def test_textarea_rtl_focus_not_changed_by_long_press_on_non_selectable(self):
self.open_test_html()
self._test_focus_not_being_changed_by_long_press_on_non_selectable(self._textarea_rtl)
########################################################################
# <div> contenteditable test cases with selection carets enabled
########################################################################
def test_contenteditable_long_press_to_select_a_word(self):
self.open_test_html()
self._test_long_press_to_select_a_word(self._contenteditable, self.assertEqual)
def test_contenteditable_move_selection_carets(self):
self.open_test_html()
self._test_move_selection_carets(self._contenteditable, self.assertEqual)
def test_contenteditable_minimum_select_one_character(self):
self.open_test_html()
self._test_minimum_select_one_character(self._contenteditable, self.assertEqual)
def test_contenteditable_focus_obtained_by_long_press_from_input(self):
self.open_test_html()
self._test_focus_obtained_by_long_press(self._input, self._contenteditable)
def test_contenteditable_focus_obtained_by_long_press_from_textarea(self):
self.open_test_html()
self._test_focus_obtained_by_long_press(self._textarea, self._contenteditable)
def test_contenteditable_focus_obtained_by_long_press_from_content_non_editable(self):
self.open_test_html()
self._test_focus_obtained_by_long_press(self._content, self._contenteditable)
def test_contenteditable_handle_tilt_when_carets_overlap_to_each_other(self):
self.open_test_html()
self._test_handle_tilt_when_carets_overlap_to_each_other(self._contenteditable, self.assertEqual)
def test_contenteditable_focus_not_changed_by_long_press_on_non_selectable(self):
self.open_test_html()
self._test_focus_not_being_changed_by_long_press_on_non_selectable(self._contenteditable)
########################################################################
# <div> non-editable test cases with selection carets enabled
########################################################################
def test_content_non_editable_long_press_to_select_a_word(self):
self.open_test_html()
self._test_long_press_to_select_a_word(self._content, self.assertEqual)
def test_content_non_editable_move_selection_carets(self):
self.open_test_html()
self._test_move_selection_carets(self._content, self.assertEqual)
def test_content_non_editable_minimum_select_one_character_by_selection(self):
self.open_test_html()
self._test_minimum_select_one_character(self._content, self.assertEqual)
def test_content_non_editable_focus_obtained_by_long_press_from_input(self):
self.open_test_html()
self._test_focus_obtained_by_long_press(self._input, self._content)
def test_content_non_editable_focus_obtained_by_long_press_from_textarea(self):
self.open_test_html()
self._test_focus_obtained_by_long_press(self._textarea, self._content)
def test_content_non_editable_focus_obtained_by_long_press_from_contenteditable(self):
self.open_test_html()
self._test_focus_obtained_by_long_press(self._contenteditable, self._content)
def test_content_non_editable_handle_tilt_when_carets_overlap_to_each_other(self):
self.open_test_html()
self._test_handle_tilt_when_carets_overlap_to_each_other(self._content, self.assertEqual)
########################################################################
# <textarea> (multi-lines) test cases with selection carets enabled
########################################################################
def test_textarea2_minimum_select_one_character(self):
self.open_test_html2()
self._test_minimum_select_one_character(self._textarea2, self.assertEqual)
########################################################################
# <div> contenteditable2 (multi-lines) test cases with selection carets enabled
########################################################################
def test_contenteditable2_minimum_select_one_character(self):
self.open_test_html2()
self._test_minimum_select_one_character(self._contenteditable2, self.assertEqual)
########################################################################
# <div> non-editable2 (multi-lines) test cases with selection carets enabled
########################################################################
def test_content_non_editable2_minimum_select_one_character(self):
self.open_test_html2()
self._test_minimum_select_one_character(self._content2, self.assertEqual)
self._test_long_press_to_select_a_word(content)
def test_long_press_to_select_when_partial_visible_word_is_selected(self):
self.open_test_html()
el = self._input
el = self.marionette.find_element(By.ID, self._input_id)
sel = SelectionManager(el)
# To successfully select the second word while the first word is being
@ -681,7 +545,7 @@ class AccessibleCaretSelectionModeTestCase(MarionetteTestCase):
def test_carets_do_not_jump_when_dragging_to_editable_content_boundary(self):
self.open_test_html()
el = self._input
el = self.marionette.find_element(By.ID, self._input_id)
sel = SelectionManager(el)
original_content = sel.content
words = original_content.split()

View File

@ -21,12 +21,12 @@
<br />
<div><textarea id="textarea" rows="4" cols="8">ABC DEF GHI JKL MNO PQR</textarea></div>
<br />
<div><textarea dir="rtl" id="textarea_rtl" rows="8" cols="8">موزيلا فيرفكس موزيلا فيرفكس</textarea></div>
<div><textarea dir="rtl" id="textarea-rtl" rows="8" cols="8">موزيلا فيرفكس موزيلا فيرفكس</textarea></div>
<br />
<div class="block" contenteditable="true" id="contenteditable">ABC DEF GHI</div>
<br />
<div class="block" id="content">ABC DEF GHI</div>
<br />
<div style="-moz-user-select: none;" id="non_selectable">Non-selectable</div>
<div style="-moz-user-select: none;" id="non-selectable">Non-selectable</div>
</body>
</html>