From 460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- karm/test/lifetest.php | 221 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 221 insertions(+) create mode 100644 karm/test/lifetest.php (limited to 'karm/test/lifetest.php') diff --git a/karm/test/lifetest.php b/karm/test/lifetest.php new file mode 100644 index 000000000..7a24bd3d7 --- /dev/null +++ b/karm/test/lifetest.php @@ -0,0 +1,221 @@ +#!/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 --geometry 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); +?> \ No newline at end of file -- cgit v1.2.1