コード例 #1
0
 def test_adding_data(self):
     parent = Parent()
     items = PopupMenuItems(parent, ['Do Something'])
     assert_equal(len(items._items), 1)
     items.add_menu_item(PopupMenuItem('Do', parent=parent))
     assert_equal(len(items._items), 2)
     _test = lambda: None
     items.add_menu_item(PopupMenuItem('Do', callable=_test))
     assert_equal(len(items._items), 3)
     assert_equal(items._items[-1].callable, _test)
コード例 #2
0
    def __init__(self, application):
        Plugin.__init__(self,
                        application,
                        name=None,
                        doc=None,
                        metadata=None,
                        default_settings=None,
                        initially_enabled=True)

        self.menu = [
            ActionInfo("ClearCase", "Check &Out", self.OnCheckOut, position=0),
            ActionInfo("ClearCase",
                       "&Undo Check out",
                       self.OnUndoCheckOut,
                       position=1),
            ActionInfo("ClearCase", "Check &In", self.OnCheckIn, position=2),
        ]

        self.treemenuitems = [
            PopupMenuItem("---"),
            PopupMenuItem("Check Out", self.OnCheckOut, self),
            PopupMenuItem("Undo Check Out", self.OnUndoCheckOut, self),
            PopupMenuItem("Check In", self.OnCheckIn, self)
        ]
コード例 #3
0
 def test_creating_separator(self):
     item = PopupMenuItem('---')
     assert_equal(item.name, '---')
     assert_equal(item.callable, None)
コード例 #4
0
 def test_creation_with_name_shortcut_in_name(self):
     parent = Parent()
     item = PopupMenuItem('Do\tCtrl-x', parent=parent)
     assert_equal(item.name, 'Do\tCtrl-x')
     assert_equal(item.callable, parent.OnDo)
コード例 #5
0
    def test_creation_with_name_and_callable(self):
        def _test():
            pass

        item = PopupMenuItem('Do Something', _test)
        assert_equal(item.callable, _test)
コード例 #6
0
 def test_creation_with_name_and_parent(self):
     parent = Parent()
     item = PopupMenuItem('Do Something', parent=parent)
     assert_equal(item.callable, parent.OnDoSomething)