]> git.lyx.org Git - lyx.git/blobdiff - development/autotests/keytest.py
ctests: mark failing LyXHTML tests as "lyxbugs"
[lyx.git] / development / autotests / keytest.py
index f403fdc99ec700e396f6323a69f6e62ac3a5f1c8..27b6d484b7457c90d54b8986d282b31c2776ef7f 100755 (executable)
@@ -209,20 +209,23 @@ def sendKeystring(keystr, LYX_PID):
     actual_delay = key_delay
     if actual_delay == '':
         actual_delay = def_delay
-    if not xvkbd_hacked:
-        subprocess.call([xvkbd_exe, "-xsendevent", "-window", lyx_window_name,
-                         "-delay", actual_delay, "-text", keystr], stdout = FNULL, stderr = FNULL)
+    xvpar = [xvkbd_exe]
+    if qt_frontend == 'QT5':
+        xvpar.extend(["-no-jump-pointer"])
     else:
-        subprocess.call([xvkbd_exe, "-no_root", "-wait_idle", lyx_pid,
-                         "-xsendevent", "-window", lyx_window_name,
-                         "-delay", actual_delay, "-text", keystr], stdout = FNULL, stderr = FNULL)
+        xvpar.extend(["-xsendevent"])
+    if xvkbd_hacked:
+        xvpar.extend(["-wait_idle", lyx_pid])
+    xvpar.extend(["-window", lyx_window_name, "-delay", actual_delay, "-text", keystr])
+    
+    subprocess.call(xvpar, stdout = FNULL, stderr = FNULL)
 
 def system_retry(num_retry, cmd):
     i = 0
     rtn = intr_system(cmd)
     while ( ( i < num_retry ) and ( rtn != 0) ):
         i = i + 1
-       rtn = intr_system(cmd)
+        rtn = intr_system(cmd)
         time.sleep(1)
     if ( rtn != 0 ):
         print "Command Failed: "+cmd
@@ -271,6 +274,9 @@ if xvkbd_exe is None:
     xvkbd_exe = "xvkbd"
 
 xvkbd_hacked = os.environ.get('XVKBD_HACKED') != None
+qt_frontend = os.environ.get('QT_FRONTEND')
+if qt_frontend is None:
+    qt_frontend = 'QT4'
 
 locale_dir = os.environ.get('LOCALE_DIR')
 if locale_dir is None:
@@ -342,19 +348,26 @@ while not failed:
             intr_system(lyx_exe + c[9:] + "&")
         else:
             intr_system(lyx_exe + " -userdir " + lyx_userdir + " " + c[9:] + "&")
-        while True:
+        count = 5
+        while count > 0:
             lyx_pid=os.popen("pidof " + lyx).read().rstrip()
             if lyx_pid != "":
                 lyx_window_name=os.popen("wmctrl -l -p | grep ' " + str(lyx_pid) +  " ' | cut -d ' ' -f 1").read().rstrip()
                 if lyx_window_name != "":
                     break
+            else:
+                count = count - 1
             print 'lyx_win: ' + lyx_window_name + '\n'
             print "Waiting for LyX to show up . . ."
             time.sleep(1)
+        if count <= 0:
+            print 'Timeout: could not start ' + lyx_exe, '\n'
+            sys.stdout.flush()
+            failed = True
         print 'lyx_pid: ' + lyx_pid + '\n'
         print 'lyx_win: ' + lyx_window_name + '\n'
     elif c[0:5] == 'Sleep':
-        print "Sleeping for " + c[6:] + "\n"
+        print "Sleeping for " + c[6:] + " seconds\n"
         time.sleep(float(c[6:]))
     elif c[0:4] == 'Exec':
         cmd = c[5:].rstrip()
@@ -384,7 +397,6 @@ while not failed:
         sendKeystring(ResetCommand, lyx_pid)
     elif c[0:6] == 'Assert':
         cmd = c[7:].rstrip()
-        print "Executing " + cmd
         result = intr_system(cmd)
         failed = failed or (result != 0)
         print "result=" + str(result) + ", failed=" + str(failed)
@@ -392,7 +404,7 @@ while not failed:
         time.sleep(0.5)
         if not lyx_exists():
             print "LyX instance not found because of crash or assert !\n"
-            failed = true
+            failed = True
         else:
             print "Terminating lyx instance: " + str(lyx_pid) + "\n"
             intr_system("kill -9 " + str(lyx_pid), True);
@@ -408,7 +420,7 @@ while not failed:
         lang = c[5:].rstrip()
         print "Setting LANG=" + lang + "\n"
         os.environ['LANG'] = lang
-        os.environ['LANGUAGE'] = lang
+        os.environ['LC_ALL'] = lang
 # If it doesn't exist, create a link <locale_dir>/<country-code>/LC_MESSAGES/lyx<version-suffix>.mo
 # pointing to the corresponding .gmo file. Needed to let lyx find the right translation files.
 # See http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg165613.html