Bug 1374482 Part 1 - Simplify focus changing tests for caret selection mode. r=mtseng

It uses _test_minimum_select_one_character() to ensure the carets appear,
but the complexity of that test is high. To make the test more stable, I
make it test select a word after changing the focus.

MozReview-Commit-ID: Jml82EpQxNm

--HG--
extra : rebase_source : 73ee1dd063fb7092feb7031f0c28bd342abec8f0
This commit is contained in:
Ting-Yu Lin 2017-10-16 17:58:41 +08:00
Родитель 0c78fa51d2
Коммит ba33d9cde8
1 изменённых файлов: 12 добавлений и 10 удалений

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

@ -321,24 +321,26 @@ class AccessibleCaretSelectionModeTestCase(MarionetteTestCase):
@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.
self.open_test_html(self._selection_html)
el1 = self.marionette.find_element(By.ID, el1_id)
el2 = self.marionette.find_element(By.ID, el2_id)
If the focus is changed to e2 successfully, the carets should appear and
could be dragged.
# Compute the content of the first word in el2.
sel = SelectionManager(el2)
original_content = sel.content
words = original_content.split()
target_content = words[0]
'''
# Goal: Tap to focus el1, and then select the first character on
# el2.
# Goal: Tap to focus el1, and then select the first word on el2.
# 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(self._selection_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, x=x, y=y)
self.long_press_on_location(el2, x, y)
self.assertEqual(target_content, sel.selected_content)
@parameterized(_input_id, el_id=_input_id)
@parameterized(_textarea_id, el_id=_textarea_id)