本文整理汇总了Python中marionette_driver.selection.SelectionManager.selection_carets_location方法的典型用法代码示例。如果您正苦于以下问题:Python SelectionManager.selection_carets_location方法的具体用法?Python SelectionManager.selection_carets_location怎么用?Python SelectionManager.selection_carets_location使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类marionette_driver.selection.SelectionManager
的用法示例。
在下文中一共展示了SelectionManager.selection_carets_location方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _test_minimum_select_one_character
# 需要导入模块: from marionette_driver.selection import SelectionManager [as 别名]
# 或者: from marionette_driver.selection.SelectionManager import selection_carets_location [as 别名]
def _test_minimum_select_one_character(self, el, assertFunc,
x=None, y=None):
sel = SelectionManager(el)
original_content = sel.content
words = original_content.split()
self.assertTrue(len(words) >= 1, 'Expect at least one word in the content.')
# Get the location of the selection carets at the end of the content for
# later use.
sel.select_all()
(_, _), (end_caret_x, end_caret_y) = sel.selection_carets_location()
el.tap()
# Goal: Select the first character.
target_content = original_content[0]
if x and y:
# If we got x and y from the arguments, use it as a hint of the
# location of the first word
pass
else:
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.
(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.
(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)
示例2: test_drag_caret_over_non_selectable_field
# 需要导入模块: from marionette_driver.selection import SelectionManager [as 别名]
# 或者: from marionette_driver.selection.SelectionManager import selection_carets_location [as 别名]
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()
# Select target element and get target caret location
self.long_press_on_word(self._sel4, 3)
sel = SelectionManager(self._body)
(_, _), (end_caret_x, end_caret_y) = sel.selection_carets_location()
self.long_press_on_word(self._sel6, 0)
(_, _), (end_caret2_x, end_caret2_y) = sel.selection_carets_location()
# Select start element
self.long_press_on_word(self._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.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.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.assertEqual(self.to_unix_line_ending(sel.selected_content.strip()),
'4\nuser can select this 5\nuser')
示例3: _test_move_selection_carets
# 需要导入模块: from marionette_driver.selection import SelectionManager [as 别名]
# 或者: from marionette_driver.selection.SelectionManager import selection_carets_location [as 别名]
def _test_move_selection_carets(self, el, assertFunc):
sel = SelectionManager(el)
original_content = sel.content
words = original_content.split()
self.assertTrue(len(words) >= 1, 'Expect at least one word in the content.')
# Goal: Select all text after the first word.
target_content = original_content[len(words[0]):]
# Get the location of the selection carets at the end of the content for
# later use.
el.tap()
sel.select_all()
(_, _), (end_caret_x, end_caret_y) = sel.selection_carets_location()
self.long_press_on_word(el, 0)
# Move the right 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.
self.actions.flick(el, caret1_x, caret1_y, caret2_x, caret2_y).perform()
assertFunc(target_content, sel.selected_content)
示例4: test_caret_position_after_changing_orientation_of_device
# 需要导入模块: from marionette_driver.selection import SelectionManager [as 别名]
# 或者: from marionette_driver.selection.SelectionManager import selection_carets_location [as 别名]
def test_caret_position_after_changing_orientation_of_device(self):
'''Bug 1094072
If positions of carets are updated correctly, they should be draggable.
'''
# Skip running test on non-rotatable device ex.desktop browser
if not self.marionette.session_capabilities['rotatable']:
return
self.openTestHtmlLongText(enabled=True)
# Select word in portrait mode, then change to landscape mode
self.marionette.set_orientation('portrait')
self._long_press_to_select_word(self._longtext, 12)
sel = SelectionManager(self._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()
# Change orientation back to portrait mode to prevent affecting
# other tests
self.marionette.set_orientation('portrait')
self.assertEqual(self._to_unix_line_ending(sel.selected_content.strip()), 'o')
示例5: _test_move_selection_carets
# 需要导入模块: from marionette_driver.selection import SelectionManager [as 别名]
# 或者: from marionette_driver.selection.SelectionManager import selection_carets_location [as 别名]
def _test_move_selection_carets(self, el, assertFunc):
sel = SelectionManager(el)
original_content = sel.content
words = original_content.split()
self.assertTrue(len(words) >= 1, "Expect at least one word in the content.")
# Goal: Select all text after the first word.
target_content = original_content[len(words[0]) :]
# Get the location of the selection carets at the end of the content for
# later use.
el.tap()
sel.select_all()
(_, _), (end_caret_x, end_caret_y) = sel.selection_carets_location()
x, y = self._first_word_location(el)
self._long_press_to_select(el, x, y)
# Move the right 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.
self.actions.flick(el, caret1_x, caret1_y, caret2_x, caret2_y).perform()
# Ignore extra spaces at the beginning of the content in comparison.
assertFunc(target_content.lstrip(), sel.selected_content.lstrip())
示例6: _test_handle_tilt_when_carets_overlap_to_each_other
# 需要导入模块: from marionette_driver.selection import SelectionManager [as 别名]
# 或者: from marionette_driver.selection.SelectionManager import selection_carets_location [as 别名]
def _test_handle_tilt_when_carets_overlap_to_each_other(self, el, assertFunc):
'''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.
'''
sel = SelectionManager(el)
original_content = sel.content
words = original_content.split()
self.assertTrue(len(words) >= 1, 'Expect at least one word in the content.')
# Goal: Select the first word.
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
# 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()
# We make two hit tests targeting the left edge of the left tilted caret
# and the right edge of the right tilted caret. If either of the hits is
# missed, selection would be collapsed and both carets should not be
# draggable.
(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;
left_caret_left_edge_x = caret3_x + caret_margin_left + tilt_left_margin_left
el.tap(left_caret_left_edge_x + 2, caret3_y)
right_caret_right_edge_x = (caret4_x + caret_margin_left +
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.
self.actions.flick(el, caret3_x, caret3_y, caret1_x, caret1_y).perform()
assertFunc(target_content, sel.selected_content)
示例7: test_long_press_to_select_when_partial_visible_word_is_selected
# 需要导入模块: from marionette_driver.selection import SelectionManager [as 别名]
# 或者: from marionette_driver.selection.SelectionManager import selection_carets_location [as 别名]
def test_long_press_to_select_when_partial_visible_word_is_selected(self):
self.open_test_html()
el = self._input
sel = SelectionManager(el)
# To successfully select the second word while the first word is being
# selected, use sufficient spaces between 'a' and 'b' to avoid the
# second caret covers on the second word.
original_content = 'aaaaaaaa bbbbbbbb'
el.clear()
el.send_keys(original_content)
words = original_content.split()
# We cannot use self.long_press_on_word() directly since it has will
# change the cursor position which affects this test. We have to store
# the position of word 0 and word 1 before long-pressing to select the
# word.
word0_x, word0_y = self.word_location(el, 0)
word1_x, word1_y = self.word_location(el, 1)
self.long_press_on_location(el, word0_x, word0_y)
self.assertEqual(words[0], sel.selected_content)
self.long_press_on_location(el, word1_x, word1_y)
self.assertEqual(words[1], sel.selected_content)
self.long_press_on_location(el, word0_x, word0_y)
self.assertEqual(words[0], sel.selected_content)
# If the second carets is visible, it can be dragged to the position of
# the first caret. After that, selection will contain only the first
# character.
(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()
self.assertEqual(words[0][0], sel.selected_content)
示例8: _test_handle_tilt_when_carets_overlap_to_each_other
# 需要导入模块: from marionette_driver.selection import SelectionManager [as 别名]
# 或者: from marionette_driver.selection.SelectionManager import selection_carets_location [as 别名]
def _test_handle_tilt_when_carets_overlap_to_each_other(self, el, assertFunc):
'''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.
'''
sel = SelectionManager(el)
original_content = sel.content
words = original_content.split()
self.assertTrue(len(words) >= 1, 'Expect at least one word in the content.')
# Goal: Select the first word.
x, y = self._first_word_location(el)
self._long_press_to_select(el, x, y)
target_content = sel.selected_content
# Move the left caret to the position of the right 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()
# We make two hit tests targeting the left edge of the left tilted caret
# and the right edge of the right tilted caret. If either of the hits is
# missed, selection would be collapsed and both carets should not be
# draggable.
(caret3_x, caret3_y), (caret4_x, caret4_y) = sel.selection_carets_location()
# The following values are from ua.css.
caret_width = 44
caret_margin_left = -23
tilt_right_margin_left = 18
tilt_left_margin_left = -17
left_caret_left_edge_x = caret3_x + caret_margin_left + tilt_left_margin_left
el.tap(ceil(left_caret_left_edge_x), caret3_y)
right_caret_right_edge_x = (caret4_x + caret_margin_left +
tilt_right_margin_left + caret_width)
el.tap(floor(right_caret_right_edge_x), caret4_y)
# Drag the left 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)
示例9: test_caret_position_after_changing_orientation_of_device
# 需要导入模块: from marionette_driver.selection import SelectionManager [as 别名]
# 或者: from marionette_driver.selection.SelectionManager import selection_carets_location [as 别名]
def test_caret_position_after_changing_orientation_of_device(self):
'''Bug 1094072
If positions of carets are updated correctly, they should be draggable.
'''
self.open_test_html_long_text()
# 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)
(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()
# Change orientation back to portrait mode to prevent affecting
# other tests
self.marionette.set_orientation('portrait')
self.assertEqual(self.to_unix_line_ending(sel.selected_content), 'o')
示例10: test_drag_caret_to_beginning_of_a_line
# 需要导入模块: from marionette_driver.selection import SelectionManager [as 别名]
# 或者: from marionette_driver.selection.SelectionManager import selection_carets_location [as 别名]
def test_drag_caret_to_beginning_of_a_line(self):
'''Bug 1094056
Test caret visibility when caret is dragged to beginning of a line
'''
self.open_test_html_multirange()
# Select the first word in the second line
self.long_press_on_word(self._sel2, 0)
sel = SelectionManager(self._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)
# 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()
# 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.assertEqual(self.to_unix_line_ending(sel.selected_content), 'select')
示例11: test_carets_do_not_jump_when_dragging_to_editable_content_boundary
# 需要导入模块: from marionette_driver.selection import SelectionManager [as 别名]
# 或者: from marionette_driver.selection.SelectionManager import selection_carets_location [as 别名]
def test_carets_do_not_jump_when_dragging_to_editable_content_boundary(self):
self.open_test_html()
el = self._input
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.
target_content = words[1]
self.long_press_on_word(el, 1)
(caret1_x, caret1_y), (caret2_x, caret2_y) = sel.selection_carets_location()
# Drag the first caret up by 50px.
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.
self.actions.flick(el, caret2_x, caret2_y, caret2_x, caret2_y + 50).perform()
self.assertEqual(target_content, sel.selected_content)