|
|
@ -83,8 +83,6 @@ class Integration(unittest.TestCase):
|
|
|
|
self.window = launch()
|
|
|
|
self.window = launch()
|
|
|
|
|
|
|
|
|
|
|
|
def tearDown(self):
|
|
|
|
def tearDown(self):
|
|
|
|
# before calling destroy to break everything (happened with
|
|
|
|
|
|
|
|
# check_add_row), make an iteration to clear all pending events.
|
|
|
|
|
|
|
|
gtk_iteration()
|
|
|
|
gtk_iteration()
|
|
|
|
self.window.on_close()
|
|
|
|
self.window.on_close()
|
|
|
|
self.window.window.destroy()
|
|
|
|
self.window.window.destroy()
|
|
|
@ -111,12 +109,14 @@ class Integration(unittest.TestCase):
|
|
|
|
|
|
|
|
|
|
|
|
def test_rows(self):
|
|
|
|
def test_rows(self):
|
|
|
|
"""Comprehensive test for rows."""
|
|
|
|
"""Comprehensive test for rows."""
|
|
|
|
def read():
|
|
|
|
class FakeEvent:
|
|
|
|
"""Always return a different keycode for each row."""
|
|
|
|
def __init__(self, keycode):
|
|
|
|
# + 7 because keycodes usually start at 8
|
|
|
|
self.keycode = keycode
|
|
|
|
return len(self.window.get('key_list').get_children()) + 7
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def change_empty_row(character):
|
|
|
|
def get_keycode(self):
|
|
|
|
|
|
|
|
return [False, self.keycode]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def change_empty_row(keycode, character):
|
|
|
|
"""Modify the one empty row that always exists."""
|
|
|
|
"""Modify the one empty row that always exists."""
|
|
|
|
# wait for the window to create a new empty row if needed
|
|
|
|
# wait for the window to create a new empty row if needed
|
|
|
|
time.sleep(0.2)
|
|
|
|
time.sleep(0.2)
|
|
|
@ -129,14 +129,9 @@ class Integration(unittest.TestCase):
|
|
|
|
self.assertIsNone(row.keycode.get_label())
|
|
|
|
self.assertIsNone(row.keycode.get_label())
|
|
|
|
self.assertEqual(row.character_input.get_text(), '')
|
|
|
|
self.assertEqual(row.character_input.get_text(), '')
|
|
|
|
|
|
|
|
|
|
|
|
# focus the keycode to trigger reading the fake keycode
|
|
|
|
row.on_key_pressed(None, FakeEvent(keycode))
|
|
|
|
self.window.window.set_focus(row.keycode)
|
|
|
|
|
|
|
|
time.sleep(0.2)
|
|
|
|
|
|
|
|
gtk_iteration()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# it should be filled using the `read` patch
|
|
|
|
self.assertEqual(int(row.keycode.get_label()), keycode)
|
|
|
|
self.assertEqual(int(row.keycode.get_label()), len(rows) + 7)
|
|
|
|
|
|
|
|
self.window.window.set_focus(None)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# set the character to make the new row complete
|
|
|
|
# set the character to make the new row complete
|
|
|
|
row.character_input.set_text(character)
|
|
|
|
row.character_input.set_text(character)
|
|
|
@ -145,10 +140,9 @@ class Integration(unittest.TestCase):
|
|
|
|
|
|
|
|
|
|
|
|
return row
|
|
|
|
return row
|
|
|
|
|
|
|
|
|
|
|
|
with patch.object(keycode_reader, 'read', read):
|
|
|
|
|
|
|
|
# add two rows by modifiying the one empty row that exists
|
|
|
|
# add two rows by modifiying the one empty row that exists
|
|
|
|
change_empty_row('a')
|
|
|
|
change_empty_row(10, 'a')
|
|
|
|
change_empty_row('b')
|
|
|
|
change_empty_row(11, 'b')
|
|
|
|
|
|
|
|
|
|
|
|
# one empty row added automatically again
|
|
|
|
# one empty row added automatically again
|
|
|
|
time.sleep(0.2)
|
|
|
|
time.sleep(0.2)
|
|
|
@ -158,8 +152,8 @@ class Integration(unittest.TestCase):
|
|
|
|
time.sleep(0.2)
|
|
|
|
time.sleep(0.2)
|
|
|
|
self.assertEqual(len(self.get_rows()), 3)
|
|
|
|
self.assertEqual(len(self.get_rows()), 3)
|
|
|
|
|
|
|
|
|
|
|
|
self.assertEqual(custom_mapping.get(8), 'a')
|
|
|
|
self.assertEqual(custom_mapping.get(10), 'a')
|
|
|
|
self.assertEqual(custom_mapping.get(9), 'b')
|
|
|
|
self.assertEqual(custom_mapping.get(11), 'b')
|
|
|
|
self.assertTrue(custom_mapping.changed)
|
|
|
|
self.assertTrue(custom_mapping.changed)
|
|
|
|
|
|
|
|
|
|
|
|
self.window.on_save_preset_clicked(None)
|
|
|
|
self.window.on_save_preset_clicked(None)
|
|
|
@ -181,8 +175,8 @@ class Integration(unittest.TestCase):
|
|
|
|
row.get_style_context().list_classes()
|
|
|
|
row.get_style_context().list_classes()
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
self.assertEqual(custom_mapping.get(8), 'c')
|
|
|
|
self.assertEqual(custom_mapping.get(10), 'c')
|
|
|
|
self.assertEqual(custom_mapping.get(9), 'b')
|
|
|
|
self.assertEqual(custom_mapping.get(11), 'b')
|
|
|
|
self.assertTrue(custom_mapping.changed)
|
|
|
|
self.assertTrue(custom_mapping.changed)
|
|
|
|
|
|
|
|
|
|
|
|
def test_rename_and_save(self):
|
|
|
|
def test_rename_and_save(self):
|
|
|
|