def test_checkXEvent( self ): old_logger_name = self.logger.name self.logger.name = "TestXDisplay.test_getRootXWindow" d = pyxt.XDisplay() l = d.checkXEvent() p = popen2.Popen4( "xlogo" ) time.sleep( 1 ) l = d.checkXEvent() found = False for w in l: if w.window_title == "xlogo": found = True logo_window = w.this_window self.assert_( found ) os.kill( p.pid,9 ) p.wait() time.sleep( 1 ) l = d.checkXEvent() found = False for w in l: if w.this_window == logo_window: found = True self.assert_( found ) self.logger.name = old_logger_name
def test_getRootXWindow( self ): old_logger_name = self.logger.name self.logger.name = "TestXDisplay.test_getRootXWindow" d = pyxt.XDisplay() w = d.getRootXWindow() self.assertEqual( w.window_title, "" ) self.logger.name = old_logger_name
def test_command(self): old_logger_name = self.logger.name self.logger.name = "TestPyxt.test_command" d = pyxt.XDisplay() w = d.getActiveXWindow() cmd = pyxt.PyxtCommand(w, "abc") self.assertEqual(cmd.xwindow, w) self.assertEqual(cmd.cmd_strings[0], "abc") cmd.addStrings("def") self.assertEqual(cmd.cmd_strings[1], "def") self.logger.name = old_logger_name
def setUp(self): if TestXWindow.logger is None: self.logger = logging.getLogger("TestXWindow.setUp") self.logger.setLevel(30 - TestXWindow.debug_level * 10) handler = logging.StreamHandler() formatter = logging.Formatter( "%(name)s() - %(filename)s:%(lineno)s\n %(message)s") handler.setFormatter(formatter) self.logger.addHandler(handler) else: self.logger = TestXWindow.logger self.xdisplay = pyxt.XDisplay()
def test_send(self): old_logger_name = self.logger.name self.logger.name = "TestPyxt.test_send" d = pyxt.XDisplay() p = popen2.Popen4("zenity --info --title='test_send'") time.sleep(1) w = d.getActiveXWindow() c = pyxt.PyxtCommand(w, pyxt.key_alt + 'o') self.p.send(c) time.sleep(1) po = p.poll() self.assertNotEqual(po, -1) self.logger.name = old_logger_name
def test_init_no_string(self): old_logger_name = self.logger.name self.logger.name = "TestXDisplay.test_XDisplay" d = pyxt.XDisplay() self.assertEqual(d.xdisplay_string, ":0") self.logger.name = old_logger_name