зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1251519 Part 4 - Add tests for dragging caret to content boundary. r=mats
These tests should fail without Part 5. MozReview-Commit-ID: 2FAW02tusCg --HG-- extra : rebase_source : 8634f1e76a172b8c602743692b50376ddda04ebd
This commit is contained in:
Родитель
970a0bf203
Коммит
14b8c376fa
|
@ -22,7 +22,9 @@ class AccessibleCaretCursorModeTestCase(MarionetteTestCase):
|
|||
'''
|
||||
# Element IDs.
|
||||
_input_id = 'input'
|
||||
_input_padding_id = 'input-padding'
|
||||
_textarea_id = 'textarea'
|
||||
_textarea_one_line_id = 'textarea-one-line'
|
||||
_contenteditable_id = 'contenteditable'
|
||||
|
||||
# Test html files.
|
||||
|
@ -185,15 +187,19 @@ class AccessibleCaretCursorModeTestCase(MarionetteTestCase):
|
|||
|
||||
self.assertEqual(target_content, sel.content)
|
||||
|
||||
def test_caret_not_jump_when_dragging_to_editable_content_boundary(self):
|
||||
@parameterized(_input_id, el_id=_input_id)
|
||||
@parameterized(_input_padding_id, el_id=_input_padding_id)
|
||||
@parameterized(_textarea_one_line_id, el_id=_textarea_one_line_id)
|
||||
@parameterized(_contenteditable_id, el_id=_contenteditable_id)
|
||||
def test_caret_not_jump_when_dragging_to_editable_content_boundary(self, el_id):
|
||||
self.open_test_html(self._cursor_html)
|
||||
el = self.marionette.find_element(By.ID, self._input_id)
|
||||
el = self.marionette.find_element(By.ID, el_id)
|
||||
sel = SelectionManager(el)
|
||||
content_to_add = '!'
|
||||
non_target_content = sel.content + content_to_add
|
||||
|
||||
# Goal: the cursor position does not being changed after dragging the
|
||||
# caret down on the Y-axis.
|
||||
# Goal: the cursor position is not changed after dragging the caret down
|
||||
# on the Y-axis.
|
||||
el.tap()
|
||||
sel.move_cursor_to_front()
|
||||
el.tap(*sel.cursor_location())
|
||||
|
@ -204,6 +210,30 @@ class AccessibleCaretCursorModeTestCase(MarionetteTestCase):
|
|||
self.actions.key_down(content_to_add).key_up(content_to_add).perform()
|
||||
self.assertNotEqual(non_target_content, sel.content)
|
||||
|
||||
@parameterized(_input_id, el_id=_input_id)
|
||||
@parameterized(_input_padding_id, el_id=_input_padding_id)
|
||||
@parameterized(_textarea_one_line_id, el_id=_textarea_one_line_id)
|
||||
@parameterized(_contenteditable_id, el_id=_contenteditable_id)
|
||||
def test_caret_not_jump_to_front_when_dragging_up_to_editable_content_boundary(self, el_id):
|
||||
self.open_test_html(self._cursor_html)
|
||||
el = self.marionette.find_element(By.ID, el_id)
|
||||
sel = SelectionManager(el)
|
||||
content_to_add = '!'
|
||||
non_target_content = content_to_add + sel.content
|
||||
|
||||
# Goal: the cursor position is not changed after dragging the caret down
|
||||
# on the Y-axis.
|
||||
el.tap()
|
||||
sel.move_cursor_to_end()
|
||||
sel.move_cursor_by_offset(1, backward=True)
|
||||
el.tap(*sel.cursor_location())
|
||||
x, y = sel.first_caret_location()
|
||||
|
||||
# Drag the caret up by 50px, and insert '!'.
|
||||
self.actions.flick(el, x, y, x, y - 50).perform()
|
||||
self.actions.key_down(content_to_add).key_up(content_to_add).perform()
|
||||
self.assertNotEqual(non_target_content, sel.content)
|
||||
|
||||
def test_drag_caret_from_front_to_end_across_columns(self):
|
||||
self.open_test_html('test_carets_columns.html')
|
||||
el = self.marionette.find_element(By.ID, 'columns-inner')
|
||||
|
|
|
@ -25,8 +25,10 @@ class AccessibleCaretSelectionModeTestCase(MarionetteTestCase):
|
|||
'''Test cases for AccessibleCaret under selection mode.'''
|
||||
# Element IDs.
|
||||
_input_id = 'input'
|
||||
_input_padding_id = 'input-padding'
|
||||
_textarea_id = 'textarea'
|
||||
_textarea2_id = 'textarea2'
|
||||
_textarea_one_line_id = 'textarea-one-line'
|
||||
_textarea_rtl_id = 'textarea-rtl'
|
||||
_contenteditable_id = 'contenteditable'
|
||||
_contenteditable2_id = 'contenteditable2'
|
||||
|
@ -542,16 +544,20 @@ class AccessibleCaretSelectionModeTestCase(MarionetteTestCase):
|
|||
self.actions.flick(el, caret2_x, caret2_y, caret1_x, caret1_y).perform()
|
||||
self.assertEqual(words[0][0], sel.selected_content)
|
||||
|
||||
def test_carets_do_not_jump_when_dragging_to_editable_content_boundary(self):
|
||||
@parameterized(_input_id, el_id=_input_id)
|
||||
@parameterized(_input_padding_id, el_id=_input_padding_id)
|
||||
@parameterized(_textarea_one_line_id, el_id=_textarea_one_line_id)
|
||||
@parameterized(_contenteditable_id, el_id=_contenteditable_id)
|
||||
def test_carets_not_jump_when_dragging_to_editable_content_boundary(self, el_id):
|
||||
self.open_test_html(self._selection_html)
|
||||
el = self.marionette.find_element(By.ID, self._input_id)
|
||||
el = self.marionette.find_element(By.ID, el_id)
|
||||
sel = SelectionManager(el)
|
||||
original_content = sel.content
|
||||
words = original_content.split()
|
||||
self.assertTrue(len(words) >= 3, 'Expect at least three words in the content.')
|
||||
|
||||
# Goal: the selection does not being changed after dragging the caret
|
||||
# on the Y-axis only.
|
||||
# Goal: the selection is not changed after dragging the caret on the
|
||||
# Y-axis.
|
||||
target_content = words[1]
|
||||
|
||||
self.long_press_on_word(el, 1)
|
||||
|
@ -561,6 +567,6 @@ class AccessibleCaretSelectionModeTestCase(MarionetteTestCase):
|
|||
self.actions.flick(el, caret1_x, caret1_y, caret1_x, caret1_y - 50).perform()
|
||||
self.assertEqual(target_content, sel.selected_content)
|
||||
|
||||
# Drag the first caret down by 50px.
|
||||
# Drag the second caret down by 50px.
|
||||
self.actions.flick(el, caret2_x, caret2_y, caret2_x, caret2_y + 50).perform()
|
||||
self.assertEqual(target_content, sel.selected_content)
|
||||
|
|
|
@ -16,9 +16,15 @@
|
|||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div><input id="input" value="ABCDEFGHI"></div>
|
||||
<div>
|
||||
<input id="input" value="ABCDEFGHI">
|
||||
<input id="input-padding" style="padding: 1em;" value="ABCDEFGHI">
|
||||
</div>
|
||||
<br>
|
||||
<div><textarea name="textarea" id="textarea" rows="4" cols="6">ABCDEFGHI</textarea></div>
|
||||
<div>
|
||||
<textarea name="textarea" id="textarea" rows="4" cols="6">ABCDEFGHI</textarea>
|
||||
<textarea id="textarea-one-line" rows="3">ABCDEFGHI</textarea>
|
||||
</div>
|
||||
<br>
|
||||
<div class="block" contenteditable="true" id="contenteditable">ABCDEFGHI</div>
|
||||
</body>
|
||||
|
|
|
@ -7,26 +7,32 @@
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>Marionette tests for AccessibleCaret in selection mode</title>
|
||||
<style>
|
||||
.block {
|
||||
width: 10em;
|
||||
height: 4em;
|
||||
word-wrap: break-word;
|
||||
overflow: auto;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<style>
|
||||
div.block {
|
||||
width: 10em;
|
||||
height: 4em;
|
||||
word-wrap: break-word;
|
||||
overflow: auto;
|
||||
}
|
||||
</style>
|
||||
<div><input id="input" value="ABC DEF GHI"></div>
|
||||
<br />
|
||||
<div><textarea id="textarea" rows="4" cols="8">ABC DEF GHI JKL MNO PQR</textarea></div>
|
||||
<br />
|
||||
<div>
|
||||
<input id="input" value="ABC DEF GHI">
|
||||
<input id="input-padding" style="padding: 1em;" value="ABC DEF GHI">
|
||||
</div>
|
||||
<br>
|
||||
<div>
|
||||
<textarea id="textarea" rows="4" cols="8">ABC DEF GHI JKL MNO PQR</textarea>
|
||||
<textarea id="textarea-one-line" rows="4" cols="12">ABC DEF GHI</textarea>
|
||||
</div>
|
||||
<br>
|
||||
<div><textarea dir="rtl" id="textarea-rtl" rows="8" cols="8">موزيلا فيرفكس موزيلا فيرفكس</textarea></div>
|
||||
<br />
|
||||
<br>
|
||||
<div class="block" contenteditable="true" id="contenteditable">ABC DEF GHI</div>
|
||||
<br />
|
||||
<br>
|
||||
<div class="block" id="content">ABC DEF GHI</div>
|
||||
<br />
|
||||
<br>
|
||||
<div style="-moz-user-select: none;" id="non-selectable">Non-selectable</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Загрузка…
Ссылка в новой задаче