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:
Ting-Yu Lin 2016-03-10 17:38:32 +08:00
Родитель 970a0bf203
Коммит 14b8c376fa
4 изменённых файлов: 74 добавлений и 26 удалений

Просмотреть файл

@ -22,7 +22,9 @@ class AccessibleCaretCursorModeTestCase(MarionetteTestCase):
''' '''
# Element IDs. # Element IDs.
_input_id = 'input' _input_id = 'input'
_input_padding_id = 'input-padding'
_textarea_id = 'textarea' _textarea_id = 'textarea'
_textarea_one_line_id = 'textarea-one-line'
_contenteditable_id = 'contenteditable' _contenteditable_id = 'contenteditable'
# Test html files. # Test html files.
@ -185,15 +187,19 @@ class AccessibleCaretCursorModeTestCase(MarionetteTestCase):
self.assertEqual(target_content, sel.content) 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) 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) sel = SelectionManager(el)
content_to_add = '!' content_to_add = '!'
non_target_content = sel.content + content_to_add non_target_content = sel.content + content_to_add
# Goal: the cursor position does not being changed after dragging the # Goal: the cursor position is not changed after dragging the caret down
# caret down on the Y-axis. # on the Y-axis.
el.tap() el.tap()
sel.move_cursor_to_front() sel.move_cursor_to_front()
el.tap(*sel.cursor_location()) 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.actions.key_down(content_to_add).key_up(content_to_add).perform()
self.assertNotEqual(non_target_content, sel.content) 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): def test_drag_caret_from_front_to_end_across_columns(self):
self.open_test_html('test_carets_columns.html') self.open_test_html('test_carets_columns.html')
el = self.marionette.find_element(By.ID, 'columns-inner') el = self.marionette.find_element(By.ID, 'columns-inner')

Просмотреть файл

@ -25,8 +25,10 @@ class AccessibleCaretSelectionModeTestCase(MarionetteTestCase):
'''Test cases for AccessibleCaret under selection mode.''' '''Test cases for AccessibleCaret under selection mode.'''
# Element IDs. # Element IDs.
_input_id = 'input' _input_id = 'input'
_input_padding_id = 'input-padding'
_textarea_id = 'textarea' _textarea_id = 'textarea'
_textarea2_id = 'textarea2' _textarea2_id = 'textarea2'
_textarea_one_line_id = 'textarea-one-line'
_textarea_rtl_id = 'textarea-rtl' _textarea_rtl_id = 'textarea-rtl'
_contenteditable_id = 'contenteditable' _contenteditable_id = 'contenteditable'
_contenteditable2_id = 'contenteditable2' _contenteditable2_id = 'contenteditable2'
@ -542,16 +544,20 @@ class AccessibleCaretSelectionModeTestCase(MarionetteTestCase):
self.actions.flick(el, caret2_x, caret2_y, caret1_x, caret1_y).perform() self.actions.flick(el, caret2_x, caret2_y, caret1_x, caret1_y).perform()
self.assertEqual(words[0][0], sel.selected_content) 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) 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) sel = SelectionManager(el)
original_content = sel.content original_content = sel.content
words = original_content.split() words = original_content.split()
self.assertTrue(len(words) >= 3, 'Expect at least three words in the content.') self.assertTrue(len(words) >= 3, 'Expect at least three words in the content.')
# Goal: the selection does not being changed after dragging the caret # Goal: the selection is not changed after dragging the caret on the
# on the Y-axis only. # Y-axis.
target_content = words[1] target_content = words[1]
self.long_press_on_word(el, 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.actions.flick(el, caret1_x, caret1_y, caret1_x, caret1_y - 50).perform()
self.assertEqual(target_content, sel.selected_content) 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.actions.flick(el, caret2_x, caret2_y, caret2_x, caret2_y + 50).perform()
self.assertEqual(target_content, sel.selected_content) self.assertEqual(target_content, sel.selected_content)

Просмотреть файл

@ -16,9 +16,15 @@
</style> </style>
</head> </head>
<body> <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> <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> <br>
<div class="block" contenteditable="true" id="contenteditable">ABCDEFGHI</div> <div class="block" contenteditable="true" id="contenteditable">ABCDEFGHI</div>
</body> </body>

Просмотреть файл

@ -7,26 +7,32 @@
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Marionette tests for AccessibleCaret in selection mode</title> <title>Marionette tests for AccessibleCaret in selection mode</title>
</head>
<body>
<style> <style>
div.block { .block {
width: 10em; width: 10em;
height: 4em; height: 4em;
word-wrap: break-word; word-wrap: break-word;
overflow: auto; overflow: auto;
} }
</style> </style>
<div><input id="input" value="ABC DEF GHI"></div> </head>
<br /> <body>
<div><textarea id="textarea" rows="4" cols="8">ABC DEF GHI JKL MNO PQR</textarea></div> <div>
<br /> <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> <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> <div class="block" contenteditable="true" id="contenteditable">ABC DEF GHI</div>
<br /> <br>
<div class="block" id="content">ABC DEF GHI</div> <div class="block" id="content">ABC DEF GHI</div>
<br /> <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> </body>
</html> </html>