class UserInterfaceTest(EntertainerTest): '''Test for entertainerlib.gui.user_interface''' def setUp(self): EntertainerTest.setUp(self) self.ui = UserInterface(None, None, None, None) def test_create(self): '''Test correct UserInterface initialization''' self.assertTrue(isinstance(self.ui, UserInterface)) def test_handle_keyboard_event(self): '''Test clutter keyboard events are handled correctly.''' def mock_event_handler(event): '''Test some expected values.''' kind = event.get_type() if (not (kind == UserEvent.DEFAULT_EVENT or kind == UserEvent.NAVIGATE_SELECT)): self.fail() good_event = MockClutterKeyboardEvent(clutter.keysyms.Return) self.ui.handle_keyboard_event(None, good_event, mock_event_handler) bad_event = MockClutterKeyboardEvent(-1) self.ui.handle_keyboard_event(None, bad_event, mock_event_handler) def test_confirm_exit(self): '''Test confirm exit stays on Question screen if it's already there.''' question = Question(None, None, []) self.ui.current = question # Current will be the same if the screen didn't move. self.assertEqual(self.ui.current, question)
def __init__(self): config = Configuration() music_library = MusicLibrary() image_library = ImageLibrary() video_library = VideoLibrary() self.ui = UserInterface(image_library, music_library, video_library, self.quit_client) if config.tray_icon_enabled: SystemTrayIcon(self.quit_client, self.toggle_interface_visibility) startLogging(sys.stdout) client = EntertainerLocalClientProtocol ClientCreator(reactor, client)
class Client(object): '''This is a client application of Entertainer. Entertainer's client hooks into the server, and then provides a user interface for the data the server creates.''' def __init__(self): config = Configuration() music_library = MusicLibrary() image_library = ImageLibrary() video_library = VideoLibrary() self.ui = UserInterface(image_library, music_library, video_library, self.quit_client) if config.tray_icon_enabled: SystemTrayIcon(self.quit_client, self.toggle_interface_visibility) startLogging(sys.stdout) client = EntertainerLocalClientProtocol ClientCreator(reactor, client) # ClientCreator(reactor, client).connectTCP( # config.network_options['host'], # config.network_options['port']) def start(self): '''Start the necessary main loop.''' self.ui.start_up() self.interface_visible = True gtk.gdk.threads_enter() reactor.run() gtk.gdk.threads_leave() def quit_client(self): '''Close the client.''' reactor.stop() sys.exit(0) def toggle_interface_visibility(self): '''Toggle between showing and hiding the interface's visibility.''' if self.interface_visible: self.ui.hide() self.interface_visible = False else: self.ui.show() self.interface_visible = True
def setUp(self): EntertainerTest.setUp(self) self.ui = UserInterface(None, None, None, None)