#!/usr/bin/php '); fclose($handle); }; function simkey($s) // This function simulates keypresses that form the string $s, e.g. for $s==hallo, it simulates the keypress of h, then a, then l and so on. // find a useful list of keycodes under /usr/include/X11/keysymdef.h { for ($i=0; $i/dev/null",$rc); if ($rc==0) echo " You have.\n"; if ($rc==127) echo " You do not have, please get it from http://hoopajoo.net/projects/xautomation.html .\n"; echo "This program will test karm by issueing karm, so, make sure, this calls the version you want to test (make install).\n\n"; echo "This program will now stop unless you give the parameter --batch (confirming that you do not touch the keyboard)\n"; $err=""; $exit=0; } else { if ( system( "which xte 2> /dev/null" ) == "" ) { echo "xte not found\n"; exit(0); } switch (funkeysim("Alt_L")) { case 1: $err.="this must be run in an X environment\n"; break; case 127: $err.="you do not have XAutomation installed, get it from http://hoopajoo.net/projects/xautomation.html\n"; break; } // the following is the same as 'if file_exist(...) unlink(...)', but atomic @unlink ("/tmp/karmtest.ics"); @unlink ("/tmp/example.planner"); if ($err=="") { // start and wait till mainwindow is up // the mouse can be in the way, so, move it out. This here even works with "focus strictly under mouse". system("xte 'mousemove 1 1'"); echo "\nStarting karm"; $process=popen("karm --tqgeometry 200x100+0+0 /tmp/karmtest.ics >/dev/null 2>&1", 'w'); $rc=1; while ($rc==1) system("dcop `dcop 2>/dev/null | grep karm` KarmDCOPIface version",$rc); echo "mainwindow is ready"; sleep (1); funkeysim("Alt_L"); funkeysim("Right",3); funkeysim("Down",2); funkeysim("Return"); sleep (1); funkeysim("Down",2); funkeysim("Tab",5); simkey("/tmp/karmtest.ics"); sleep (1); funkeysim("Return"); sleep (1); funkeysim("Return"); sleep (1); # add a new task funkeysim("Alt_L"); funkeysim("Right",2); funkeysim("Down"); sleep (1); funkeysim("Return"); sleep (1); simkey("example 1"); funkeysim("Return"); sleep (1); echo "\nCreating a planner project file..."; createplannerexample(); # import planner project file funkeysim("Alt_L"); funkeysim("Down",5); funkeysim("Right"); funkeysim("Down"); funkeysim("Return"); sleep (2); keysim("/tmp/example.planner"); sleep (1); funkeysim("Return"); sleep (1); # export to CSV file funkeysim("Alt_L"); funkeysim("Down",5); funkeysim("Right"); funkeysim("Down",2); funkeysim("Return"); sleep(2); keysim("/tmp/exporttest.csv"); sleep(1); funkeysim("Tab",6); system ("xte 'keydown Alt_L'"); system ("xte 'key m'"); system ("xte 'keyup Alt_L'"); sleep(1); funkeysim("Return"); # send CTRL_Q sleep (2); echo "\nsending CTRL_Q...\n"; system ("xte 'keydown Control_L'"); system ("xte 'key Q'"); system ("xte 'keyup Control_L'"); $content=file_get_contents("/tmp/karmtest.ics"); $lines=explode("\n",$content); if (!preg_match("/DTSTAMP:[0-9]{1,8}T[0-9]{1,6}Z/", $lines[4])) $err.="iCal file: wrong dtstamp"; if ($lines[12]<>"SUMMARY:example 1") $err.="iCal file: wrong task, should be example 1, but is $lines[12]"; if ($lines[16]<>"END:VTODO") $err.="iCal file: wrong end of vtodo"; $content=file_get_contents("/tmp/exporttest.csv"); $lines=explode("\n",$content); if (!preg_match("/\"example 1\",,0[,|.]00,0[,|.]00,0[,|.]00,0[,|.]00/", $lines[0])) $err.="csv export is wrong"; pclose($process); if ($err == "") @unlink ("/tmp/karmtest.ics"); @unlink ("/tmp/example.planner"); if ($err == "") @unlink ("/tmp/exporttest.csv"); } } echo $err; if ($err!="") exit(1); ?>