Exemplo n.º 1
0
 def test_show_value_editor(self):
     editor = ArrayEditor()
     editor.set_value(Array([-1.0]))
     table_view = editor._ui.array_table_view
     model = table_view.model()
     rect = table_view.visualRect(model.index(0, 0))
     editor.open_value_editor = MagicMock()
     menu = ArrayTableContextMenu(editor, table_view, rect.center())
     open_action = _find_action(menu, "Open value editor...")
     self.assertIsNotNone(open_action)
     open_action.trigger()
     editor.open_value_editor.assert_called_once_with(model.index(0, 0))
Exemplo n.º 2
0
 def test_remove_rows(self):
     editor = ArrayEditor()
     editor.set_value(Array([-1.0, -2.0]))
     table_view = editor._ui.array_table_view
     table_view.selectRow(0)
     model = table_view.model()
     rect = table_view.visualRect(model.index(0, 0))
     menu = ArrayTableContextMenu(editor, table_view, rect.center())
     remove_action = _find_action(menu, "Remove rows")
     self.assertIsNotNone(remove_action)
     remove_action.trigger()
     self.assertEqual(model.rowCount(), 1 + 1)
     self.assertEqual(model.index(0, 0).data(), -2.0)
Exemplo n.º 3
0
 def test_insert_row_before(self):
     editor = ArrayEditor()
     editor.set_value(Array([-1.0]))
     table_view = editor._ui.array_table_view
     table_view.selectRow(0)
     model = table_view.model()
     rect = table_view.visualRect(model.index(0, 0))
     menu = ArrayTableContextMenu(editor, table_view, rect.center())
     insert_action = _find_action(menu, "Insert row before")
     self.assertIsNotNone(insert_action)
     insert_action.trigger()
     self.assertEqual(model.rowCount(), 2 + 1)
     self.assertEqual(model.index(0, 0).data(), 0.0)
     self.assertEqual(model.index(1, 0).data(), -1.0)