Beispiel #1
0
 def test_command(self):
     IDE = 1
     NAME = '&Name...'
     DESC = 'desc'
     SHORTCUT_NAME = 'dummy'
     CLEAN_NAME = 'Name'
     NAME_AND_SHORTCUT = '&Name...\tdummy'
     
     self.flag = 0
     def dummy():
         self.flag = 1
     class DummyShortcut():
         name = SHORTCUT_NAME
         
     DEF_SHORTCUTS = [DummyShortcut()]
     
     c = Command(IDE, NAME, DESC, dummy, DEF_SHORTCUTS)
     
     self.assertEquals(IDE, c.ide)
     self.assertEquals(NAME, c.name)
     self.assertEquals(DESC, c.description)
     self.assertEquals(dummy, c._function)
     self.assertEquals(DEF_SHORTCUTS, c.default_shortcuts)
     self.assertEquals([], c.shortcuts)
     self.assertEquals(c.name_and_shortcut, NAME)
     self.assertEquals(c.clean_name, CLEAN_NAME)
     
     c.load_default_shortcut()
     self.assertEquals(DEF_SHORTCUTS, c.shortcuts)
     self.assertEquals(c.name_and_shortcut, NAME_AND_SHORTCUT)
     
     c()
     self.assertEquals(self.flag, 1)
Beispiel #2
0
 def test_commands_created(self):
     w = BaseMainWindow(None, None)
         
     cmd1 = Command(1, 'Name1', 'Desc1', lambda: 1, [])
     cmd2 = Command(2, 'Name2', 'Desc2', lambda: 1, [])
     cat1 = CommandCategory('Cat1')
     cat2 = CommandCategory('Cat2')
     
     cat1.append(cmd1)
     cat1.append(cat2)
     cat2.append(cmd2)
     
     tree = [cat1]
     
     pub.sendMessage('commands.created', command_tree=tree)
     
     self.assertEqual(1, w.main_menu.MenuCount)
     self.assertEqual(2, w.main_menu.GetMenu(0).MenuItemCount)
     self.assertEqual(1, w.main_menu.GetMenu(0).FindItemByPosition(1).SubMenu.MenuItemCount)
     
     cmd1.name = 'Nome1'
     cmd1.description = 'Descricao1'
     cmd2.name = 'Nome2'
     cmd2.description = 'Descricao2'
     cat1.name = 'Categoria1'
     cat2.name = 'Categoria2'
     
     pub.sendMessage('commands.changed', command_tree=tree, accel_table=wx.AcceleratorTable([]))
     
     self.assertEqual(cat1.name, w.main_menu.GetMenuLabel(0))
     self.assertEqual(cmd1.name, w.main_menu.GetMenu(0).FindItemByPosition(0).ItemLabel)
     self.assertEqual(cat2.name, w.main_menu.GetMenu(0).FindItemByPosition(1).ItemLabel)
     self.assertEqual(cmd2.name, w.main_menu.GetMenu(0).FindItemByPosition(1).SubMenu.FindItemByPosition(0).ItemLabel)