Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 29 additions & 7 deletions Lib/idlelib/idle_test/test_sidebar.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""Test sidebar, coverage 93%"""
import idlelib.sidebar
from sys import platform
from itertools import chain
import unittest
import unittest.mock
Expand All @@ -7,7 +9,6 @@

from idlelib.delegator import Delegator
from idlelib.percolator import Percolator
import idlelib.sidebar


class Dummy_editwin:
Expand Down Expand Up @@ -239,6 +240,7 @@ def get_width():
self.assert_sidebar_n_lines(1)
self.assertEqual(get_width(), 1)

@unittest.skipIf(platform == 'darwin', 'test tk version dependent')
def test_click_selection(self):
self.linenumber.show_sidebar()
self.text.insert('1.0', 'one\ntwo\nthree\nfour\n')
Expand All @@ -252,14 +254,15 @@ def test_click_selection(self):

self.assertEqual(self.get_selection(), ('2.0', '3.0'))

def test_drag_selection(self):
@unittest.skipIf(platform == 'darwin', 'test tk version dependent')
def test_drag_selection_down(self):
self.linenumber.show_sidebar()
self.text.insert('1.0', 'one\ntwo\nthree\nfour\n')
self.text.insert('1.0', 'one\ntwo\nthree\nfour\nfive\n')
self.root.update()

# Drag from the first line to the third line.
start_x, start_y = self.get_line_screen_position(1)
end_x, end_y = self.get_line_screen_position(3)
# Drag from the second line to the fourth line.
start_x, start_y = self.get_line_screen_position(2)
end_x, end_y = self.get_line_screen_position(4)
self.linenumber.sidebar_text.event_generate('<Button-1>',
x=start_x, y=start_y)
self.linenumber.sidebar_text.event_generate('<B1-Motion>',
Expand All @@ -269,8 +272,27 @@ def test_drag_selection(self):
self.linenumber.sidebar_text.event_generate('<ButtonRelease-1>',
x=end_x, y=end_y)
self.root.update()
self.assertEqual(self.get_selection(), ('2.0', '5.0'))

@unittest.skipIf(platform == 'darwin', 'test tk version dependent')
def test_drag_selection_up(self):
self.linenumber.show_sidebar()
self.text.insert('1.0', 'one\ntwo\nthree\nfour\nfive\n')
self.root.update()

self.assertEqual(self.get_selection(), ('1.0', '4.0'))
# Drag from the fourth line to the second line.
start_x, start_y = self.get_line_screen_position(4)
end_x, end_y = self.get_line_screen_position(2)
self.linenumber.sidebar_text.event_generate('<Button-1>',
x=start_x, y=start_y)
self.linenumber.sidebar_text.event_generate('<B1-Motion>',
x=start_x, y=start_y)
self.linenumber.sidebar_text.event_generate('<B1-Motion>',
x=end_x, y=end_y)
self.linenumber.sidebar_text.event_generate('<ButtonRelease-1>',
x=end_x, y=end_y)
self.root.update()
self.assertEqual(self.get_selection(), ('2.0', '5.0'))

def test_scroll(self):
self.linenumber.show_sidebar()
Expand Down