Bug 1374482 Part 1 - Simplify focus changing tests for caret selection mode. draft
authorTing-Yu Lin <tlin@mozilla.com>
Mon, 16 Oct 2017 17:58:41 +0800
changeset 681149 bd1fc82d1e01a304e643fb5215e68e1b15fd4c0f
parent 680630 2ba9ba4fa63b942d8d9401f6ff6e40f5730adcd1
child 681150 13d61ec3fc084a805b75be68f21b7f8baab19189
child 681155 959abe297230b2aaa4251e96dc7e125da31d718e
push id84774
push userbmo:tlin@mozilla.com
push dateTue, 17 Oct 2017 02:37:20 +0000
bugs1374482
milestone58.0a1
Bug 1374482 Part 1 - Simplify focus changing tests for caret selection mode. 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
layout/base/tests/marionette/test_accessiblecaret_selection_mode.py
--- a/layout/base/tests/marionette/test_accessiblecaret_selection_mode.py
+++ b/layout/base/tests/marionette/test_accessiblecaret_selection_mode.py
@@ -316,34 +316,36 @@ class AccessibleCaretSelectionModeTestCa
                    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.
+        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)
     @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(self._selection_html)
         el = self.marionette.find_element(By.ID, el_id)