def test_appButtons(self): """ L{ShellServer._appButtons} returns an iterator the elements of which are L{Button} instances, one for each L{ITerminalServerFactory} powerup. When one of these buttons is activated, L{ShellServer} is switched to the corresponding L{ITerminalServerFactory}'s protocol. """ store = Store() terminal = FakeTerminal() server = ShellServer(store) server.makeConnection(terminal) firstFactory = MockTerminalServerFactoryItem( store=store, name=u"first - \N{ROMAN NUMERAL ONE}") installOn(firstFactory, store) secondFactory = MockTerminalServerFactoryItem( store=store, name=u"second - \N{ROMAN NUMERAL TWO}") installOn(secondFactory, store) buttons = list(server._appButtons()) self.assertEqual(len(buttons), 2) # For now, we'll say the order isn't significant. buttons.sort(key=lambda b: b.label) self.assertEqual( buttons[0].label, firstFactory.name.encode('utf-8')) buttons[0].onPress() server.keystrokeReceived('x', None) self.assertEqual( firstFactory.terminalProtocolInstance.keystrokes, [('x', None)]) self.assertEqual( buttons[1].label, secondFactory.name.encode('utf-8')) buttons[1].onPress() server.keystrokeReceived('y', None) self.assertEqual( secondFactory.terminalProtocolInstance.keystrokes, [('y', None)])
def test_appButtons(self): """ L{ShellServer._appButtons} returns an iterator the elements of which are L{Button} instances, one for each L{ITerminalServerFactory} powerup. When one of these buttons is activated, L{ShellServer} is switched to the corresponding L{ITerminalServerFactory}'s protocol. """ store = Store() terminal = FakeTerminal() server = ShellServer(store) server.makeConnection(terminal) firstFactory = MockTerminalServerFactoryItem( store=store, name=u"first - \N{ROMAN NUMERAL ONE}") installOn(firstFactory, store) secondFactory = MockTerminalServerFactoryItem( store=store, name=u"second - \N{ROMAN NUMERAL TWO}") installOn(secondFactory, store) buttons = list(server._appButtons()) self.assertEqual(len(buttons), 2) # For now, we'll say the order isn't significant. buttons.sort(key=lambda b: b.label) self.assertEqual(buttons[0].label, firstFactory.name.encode('utf-8')) buttons[0].onPress() server.keystrokeReceived('x', None) self.assertEqual(firstFactory.terminalProtocolInstance.keystrokes, [('x', None)]) self.assertEqual(buttons[1].label, secondFactory.name.encode('utf-8')) buttons[1].onPress() server.keystrokeReceived('y', None) self.assertEqual(secondFactory.terminalProtocolInstance.keystrokes, [('y', None)])