Make sure all files that should be present are present.

This commit is contained in:
Storm Dragon
2024-10-17 16:33:13 -04:00
parent 9d78a3fbee
commit c615709602
1395 changed files with 1344591 additions and 0 deletions

10
test/harness/.gitignore vendored Normal file
View File

@ -0,0 +1,10 @@
cthulhu-customizations.py
cthulhu-customizations.pyc
user-settings.conf
utils.pyc
*.debug
*.speech
*.braille
*.out
app-settings
cthulhu-scripts

0
test/harness/__init__.py Executable file
View File

98
test/harness/bin/progressbar Executable file
View File

@ -0,0 +1,98 @@
#!/usr/bin/env python
# Modified file based upon John Finlay's PyGTK 2.0 Tutorial
# http://www.pygtk.org/pygtk2tutorial/sec-ProgressBars.html
import pygtk
pygtk.require('2.0')
import gtk, gobject
# Update the value of the progress bar so that we get
# some movement
def progress_timeout(pbobj):
# Calculate the value of the progress bar using the
# value range set in the adjustment object
new_val = pbobj.pbar.get_fraction() + 0.10
if new_val > 1.0:
return False
# Set the new value
pbobj.pbar.set_fraction(new_val)
# As this is a timeout function, return TRUE so that it
# continues to get called until we reach 1.0
return True
class ProgressBar:
# start the progress bar
def start_progress(self, widget, data=None):
# Add a timer callback to update the value of the progress bar
try:
gobject.source_remove(self.timer)
except:
pass
self.pbar.set_fraction(0.0)
self.timer = 0
self.timer = gobject.timeout_add (500, progress_timeout, self)
# Clean up allocated memory and remove the timer
def destroy_progress(self, widget, data=None):
try:
gobject.source_remove(self.timer)
except:
pass
self.timer = 0
gtk.main_quit()
def __init__(self):
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.set_resizable(True)
self.window.connect("destroy", self.destroy_progress)
self.window.set_title("ProgressBar")
self.window.set_border_width(0)
vbox = gtk.VBox(False, 5)
vbox.set_border_width(10)
self.window.add(vbox)
vbox.show()
# Create a centering alignment object
align = gtk.Alignment(0.5, 0.5, 0, 0)
vbox.pack_start(align, False, False, 5)
align.show()
# Create the ProgressBar
self.pbar = gtk.ProgressBar()
self.pbar.set_text("some text")
self.pbar.set_fraction(0.0)
align.add(self.pbar)
self.pbar.show()
separator = gtk.HSeparator()
vbox.pack_start(separator, False, False, 0)
separator.show()
# Add a button to start the progress button
button = gtk.Button("start")
button.connect("clicked", self.start_progress)
vbox.pack_start(button, False, False, 0)
button.show()
# Add a button to exit the program
button = gtk.Button("close")
button.connect("clicked", self.destroy_progress)
vbox.pack_start(button, False, False, 0)
button.show()
self.window.show()
def main():
gtk.main()
return 0
if __name__ == "__main__":
ProgressBar()
main()

63
test/harness/bin/slider Executable file
View File

@ -0,0 +1,63 @@
#!/usr/bin/env python
import pygtk
pygtk.require('2.0')
import gtk, gobject
class Slider:
def __init__(self):
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.set_resizable(True)
self.window.connect("destroy", self.quit)
self.window.set_title("Slider")
self.window.set_border_width(0)
vbox = gtk.VBox(False, 5)
vbox.set_border_width(10)
self.window.add(vbox)
vbox.show()
# Create a label
self.label = gtk.Label("")
vbox.pack_start(self.label, False, False, 0)
self.label.show()
# Create a centering alignment object
align = gtk.Alignment(0.5, 0.5, 0, 0)
vbox.pack_start(align, False, False, 5)
align.show()
# Create the Slider
self.slider = gtk.HScale(adjustment=gtk.Adjustment(
value=0,
lower=0, upper=10,
step_incr=1, page_incr=2, page_size=2))
align.add(self.slider)
self.slider.show()
self.label.set_mnemonic_widget(self.slider)
self.label.set_text_with_mnemonic("_Some slider:")
separator = gtk.HSeparator()
vbox.pack_start(separator, False, False, 0)
separator.show()
# Add a button to exit the program
button = gtk.Button("close")
button.connect("clicked", self.quit)
vbox.pack_start(button, False, False, 0)
button.show()
self.window.show()
def quit(self, widget, data=None):
gtk.main_quit()
def main():
gtk.main()
return 0
if __name__ == "__main__":
Slider()
main()

View File

@ -0,0 +1,15 @@
# -*- coding: utf-8 -*-
# Contains settings that should apply to all runs of the Cthulhu
# test harness.
import cthulhu.debug
cthulhu.debug.debugLevel = cthulhu.debug.LEVEL_ALL
import cthulhu.settings
cthulhu.settings.enableRemoteLogging = True
cthulhu.settings.enableSpeech = True
cthulhu.settings.speechFactoryModules = []
cthulhu.settings.speechServerFactory = None
cthulhu.settings.asyncMode = False
cthulhu.settings.progressBarUpdateInterval = 0

View File

@ -0,0 +1,11 @@
{"enableKeyEcho": false,
"keyboardLayout": 2,
"magSourceDisplay": ":0.0",
"magTargetDisplay": ":0.0",
"cthulhuModifierKeys": ["Caps_Lock, Shift_Lock"],
"profile": ["Laptop", "laptop"],
"quitCthulhuNoConfirmation": true,
"speechServerFactory": "cthulhu.speechdispatcherfactory",
"speechServerInfo": ["Sintetizador predeterminado", "default"],
"verbalizePunctuationStyle": 2
}

View File

@ -0,0 +1,32 @@
{
"keybindings": {
"reviewCurrentCharacterHandler": [
[
"KP_4",
"365",
"0",
"1"
],
[
null,
"365",
"0",
"3"
]
]
},
"profile": [
"Imported profile",
"imported_profile"
],
"pronunciations": {
"btw": [
"BTW",
"by the way"
],
"asap": [
"ASAP",
"as soon as possible"
]
}
}

View File

@ -0,0 +1,4 @@
{"profile": ["Laptop", "laptop"],
"keyboardLayout": 2,
"quitCthulhuNoConfirmation": true
}

View File

@ -0,0 +1,18 @@
{
"keybindings": {
"reviewCurrentCharacterHandler": [
[
"KP_2",
"365",
"0",
"1"
],
[
null,
"365",
"0",
"1"
]
]
}
}

View File

@ -0,0 +1,4 @@
{"pronunciations": {
"asap": ["ASAP", "as soon as possible"],
"btw": ["BTW", "by the way"]}
}

248
test/harness/runall.sh Executable file
View File

@ -0,0 +1,248 @@
#!/bin/bash
#
# See http://live.gnome.org/Cthulhu/RegressionTesting for more info.
#
# runall.sh can take the following optional parameters:
#
# -a <appDir> - absolute path to directory with tests for a single app
# -c - analyze test coverage instead of regression testing
# -h|--help - print a usage message.
# -k <keystrokesDir> - alternate keystroke directory (default is ../keystrokes).
# -p - create profile information instead of regression testing
# -r <resultsDir> - alternate results directory (default is ../results).
# -s - require the tester to press return between each test
#
OPERATING_SYSTEMS="SunOS Linux"
foo=`dirname $0`
harnessDir=`cd $foo; pwd`
keystrokesDir=$harnessDir/../keystrokes
resultsDir=$harnessDir/../results
# OpenOffice 2.2 executables are installed in
# /usr/lib/openoffice/program
#
export PATH=$harnessDir/bin:$PATH:/usr/lib/openoffice/program
coverageMode=0
profileMode=0
runCthulhuOnce=0
process_cl () {
while [ $# != 0 ]; do
case "$1" in
-a )
shift
if [ $# == 0 ]; then
echo "Option -a requires an argument."
exit 1
fi
testDirs=$1
;;
-c )
coverageMode=1
;;
-k )
shift
if [ $# == 0 ]; then
echo "Option -k requires an argument."
exit 1
fi
keystrokesDir=$1
;;
-p )
profileMode=1
;;
-r )
shift
if [ $# == 0 ]; then
echo "Option -r requires an argument."
exit 1
fi
resultsDir=$1
;;
-s )
stepMode=1
;;
-h|--help)
echo "Usage: $0 [options]"
echo "options:"
echo " -a appDir run tests only from appDir (absolute path)"
echo " -c perform code coverage analysis"
echo " -h, --help print this usage message"
echo " -k keystrokeDir specify an alternate keystrokes directory"
echo " -p create profile information"
echo " -r resultsDir specify an alternate results directory"
echo " -s require a return to be pressed between keystrokes files"
exit 0
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
shift
done
}
# Process the users command line options.
#
process_cl "${@}"
if [ "$coverageMode" -eq 1 ]
then
runCthulhuOnce=1
export HARNESS_ASSERT=0
echo generating coverage map...
coverageDir=../coverage/`date +%Y-%m-%d_%H:%M:%S`
mkdir -p $coverageDir
cp $harnessDir/user-settings.conf.in user-settings.conf
#echo $harnessDir/user-settings.conf.in
trace2html.py -o $coverageDir -w cthulhu -r $harnessDir/runcthulhu.py &
trace_pid=$!
sleep 10
fi
if [ "$profileMode" -eq 1 ]
then
runCthulhuOnce=1
export HARNESS_ASSERT=0
echo generating profile information...
cp $harnessDir/user-settings.conf.in user-settings.conf
python $harnessDir/runprofiler.py&
profiler_pid=$!
sleep 10
fi
# Look in the keystrokes directory for directories.
# The name of each directory under the keystrokes directory
# is expected to be the name of an application to run. For
# example, the gnome-terminal keystrokes should live under
# a directory called gnome-terminal. If there isn't an
# application associated with the directory name, we just
# assume the test should apply to the desktop in general.
#
# There is expected to be a keystrokes file in each of the
# found sub-directories. We go ahead and run this using our
# runone.sh script.
#
dirprefix=`date +%Y-%m-%d_%H:%M:%S`
if [ "x$testDirs" == "x" ]
then
testDirs=`find $keystrokesDir -type d | grep -v "[.]svn" | sort`
fi
for testDir in $testDirs
do
application=`basename $testDir`
if [ $application != ".svn" ] && [ $application != `basename $keystrokesDir` ]
then
# (Bug #359919). Check to see if the application exists.
# If it does, then supply that as the $2 parameter to the runone.sh command.
# If it doesn't exist see if the name is in a list of system types that
# we care about (currently "SunOS" and "Linux").
# If it is, then compare the directory name against the result of running
# `uname`.
# If they match, then run the scripts in that directory.
# If they don't match, ignore that directory.
# If it isn't, then don't supply a $2 parameter to the runone.sh command.
oldifs="$IFS"
IFS=:
found=0
for dir in $PATH; do
test -x "$dir/$application" && {
found=1
break
}
done
IFS="$oldifs"
outputdir=$dirprefix/$application
currentdir=`pwd`
# We run under ./tmp as a means to help provide consistent
# output for things that expose directory paths.
#
mkdir -p ./tmp/$application
cd ./tmp/$application
for testFile in `find $testDir -xtype f -name "*.py" | sort`; do
echo ========================================
echo Running $testFile
if [ "$found" -gt 0 ]
then
$harnessDir/runone.sh $testFile $application $runCthulhuOnce
else
osType=`uname`
for os in $OPERATING_SYSTEMS; do
if [ $application == $os ]
then
found=1
if [ $osType == $os ]
then
$harnessDir/runone.sh $testFile $runCthulhuOnce
fi
fi
done
if [ "$found" -eq 0 ]
then
$harnessDir/runone.sh $testFile $runCthulhuOnce
fi
fi
if [ "$runCthulhuOnce" -eq 0 ]
then
# Copy the results (.cthulhu) file to the output directory.
# This is the file that will be used for regression
# testing.
newResultsFile=`basename $testFile .py`
mkdir -p $currentdir/$outputdir
# Filter the results...
#
# For braille, get rid of spurious "Desktop Frame" lines which
# happen when there's enough of a pause for nautilus to think
# it has focus.
#
# For speech, we do the same thing, but we need to get rid of
# several lines in a row. So, we use sed.
#
grep -v "Desktop Frame" $newResultsFile.braille > $currentdir/$outputdir/$newResultsFile.braille
mv $newResultsFile.braille $currentdir/$outputdir/$newResultsFile.braille.unfiltered
sed "/speech.speakUtterances utterance='Desktop frame'/,/speech.speakUtterances utterance='Icon View layered pane'/ d" $newResultsFile.speech > $currentdir/$outputdir/$newResultsFile.speech
mv $newResultsFile.speech $currentdir/$outputdir/$newResultsFile.speech.unfiltered
mv $newResultsFile.debug $currentdir/$outputdir
rm -rf *
fi
echo Finished running $testFile.
if [ "x$stepMode" == "x1" ]
then
echo Press Return to continue...
read foo
fi
echo ========================================
done
cd $currentdir
rm -rf ./tmp/$application
fi
done
if [ "$coverageMode" -eq 1 ]
then
rm user-settings.conf
echo ...finished generating coverage map.
fi
if [ "$profileMode" -eq 1 ]
then
rm -f user-settings.conf
mkdir -p ../profile
profileFilePrefix=../profile/`date +%Y-%m-%d_%H:%M:%S`
python -c "import pstats; pstats.Stats('cthulhuprof').sort_stats('cumulative').print_stats()" > $profileFilePrefix.txt
mv cthulhuprof $profileFilePrefix.cthulhuprof
echo ...finished generating profile information.
fi
echo $dirprefix completed at `date +%Y-%m-%d_%H:%M:%S`

63
test/harness/runcthulhu.py Executable file
View File

@ -0,0 +1,63 @@
#!/usr/bin/python3
# N.B. Cthulhu's only use of dbus-python is this logger service which is only
# used by the regression tests. It does not introduce a dependency, is not
# encountered by end users, and will be removed in favor for pygi once bugs
# 656325 and 656330 are resolved.
import argparse
import dbus
import dbus.service
import sys
from cthulhu import cthulhu
from dbus.mainloop.glib import DBusGMainLoop
class LoggerService(dbus.service.Object):
def __init__(self, filePrefix):
self._logger = cthulhu.getLogger()
self._logNames = ['braille', 'speech']
self._filePrefix = filePrefix
DBusGMainLoop(set_as_default=True)
busname = dbus.service.BusName('org.gnome.Cthulhu', bus=dbus.SessionBus())
dbus.service.Object.__init__(self, busname, '/org/gnome/Cthulhu')
@dbus.service.method(dbus_interface='org.gnome.Cthulhu.Logger', in_signature='', out_signature='')
def startRecording(self):
for name in self._logNames:
self._logger.clearLog(name)
@dbus.service.method(dbus_interface='org.gnome.Cthulhu.Logger', in_signature='', out_signature='s')
def stopRecording(self):
contents = ''
for name in self._logNames:
content = self._logger.getLogContent(name)
contents += content
fileName = open('%s.%s' % (self._filePrefix, name), 'a', encoding='utf-8')
fileName.writelines(content)
fileName.close()
return contents
def main():
sys.argv[0] = 'cthulhu'
parser = argparse.ArgumentParser()
parser.add_argument("-u", "--user-prefs", action="store")
parser.add_argument("--debug-file", action="store")
args = parser.parse_args()
cthulhu.debug.debugFile = open('%s.debug' % args.debug_file, 'w')
manager = cthulhu.getSettingsManager()
manager.activate(args.user_prefs)
sys.path.insert(0, manager.getPrefsDir())
service = LoggerService(args.debug_file)
return cthulhu.main()
if __name__ == "__main__":
sys.exit(main())

176
test/harness/runone.sh Executable file
View File

@ -0,0 +1,176 @@
#!/bin/bash
useage()
{
echo './runone.sh keystroke_file.py [application_name] [0|1]'
echo 'application_name is the name of the application to run'
echo '0 = start and stop cthulhu inside this shell script'
echo '1 = assume cthulhu is already running'
echo " " # for a blank line
echo 'See http://live.gnome.org/Cthulhu/RegressionTesting for more info.'
exit 1
}
#
# Set up our accessibility environment for those apps that
# don't do it on their own.
#
export GTK_MODULES=:gail:atk-bridge:
export PATH=/usr/lib/openoffice/program:$PATH
export PS1='$ '
foo=`dirname $0`
harnessDir=`cd $foo; pwd`
export PYTHONPATH=$harnessDir:$PYTHONPATH
export PATH=$harnessDir/bin:$PATH
# Switch off i18n transformation.
export LANG=C
export LC_ALL=C
if [ "$1" = "-h" -o "$1" = "-?" -o "$1" = "--help" -o $# -eq 0 ]
then
useage
fi
debugFile=`basename $1 .py`
cp `dirname $0`/cthulhu-customizations.py.in cthulhu-customizations.py
CUSTOMIZATIONS_FILE=`dirname $1`/$debugFile.customizations
if [ -f $CUSTOMIZATIONS_FILE ]
then
cat $CUSTOMIZATIONS_FILE >> cthulhu-customizations.py
fi
SETTINGS_FILE=`dirname $1`/$debugFile.settings
if [ ! -f $SETTINGS_FILE ]
then
SETTINGS_FILE=`dirname $0`/user-settings.conf.in
fi
cp $SETTINGS_FILE user-settings.conf
# Allow us to pass parameters to the command line of the application.
#
# If a <testfilename>.params file exists, it contains parameters to
# pass to the command line of the application.
#
PARAMS_FILE=`dirname $1`/$debugFile.params
if [ -f $PARAMS_FILE ]
then
if [ "x$JDK_DEMO_DIR" == "x" ]
then
JDK_DEMO_DIR="/usr/jdk/latest/demo"
fi
TEST_DIR=`dirname $1`
source $PARAMS_FILE
fi
# Run the app (or gtk-demo if no app was given) and let it settle in.
#
ARGS=""
if [ -n "$3" ]
then
APP_NAME=$2
cthulhuRunning=$3
else
APP_NAME=gtk-demo
if [ -n "$2" ]
then
cthulhuRunning=$2
else
cthulhuRunning=0
fi
fi
if [ "$APP_NAME" == "swriter" ] || [ "$APP_NAME" == "oowriter" ] || [ "$APP_NAME" == "scalc" ] || [ "$APP_NAME" == "oocalc" ] || [ "$APP_NAME" == "simpress" ] || [ "$APP_NAME" == "ooimpress" ] || [ "$APP_NAME" == "sbase" ] || [ "$APP_NAME" == "oobase" ] || [ "$APP_NAME" == "soffice" ] || [ "$APP_NAME" == "ooffice" ]
then
SOFFICE=1
fi
# If we're using Firefox, give it a known profile to work from.
#
if [ "$APP_NAME" = "firefox" ]
then
FF_PROFILE_DIR=/tmp/FirefoxProfile
mkdir -p $FF_PROFILE_DIR
cp $harnessDir/../html/FirefoxProfile/prefs.js $FF_PROFILE_DIR
cp $harnessDir/../html/FirefoxProfile/bookmarks.html $FF_PROFILE_DIR
cp $harnessDir/../html/FirefoxProfile/extensions.rdf $FF_PROFILE_DIR
ARGS="-profile $FF_PROFILE_DIR -width 1000 -height 650"
fi
# Consistent profile for testing Epiphany.
#
if [ "$APP_NAME" = "epiphany" ]
then
EWB_PROFILE_DIR=/tmp/EpiphanyProfile
mkdir -p $EWB_PROFILE_DIR
cp $harnessDir/../html/EpiphanyProfile/bookmarks.rdf $EWB_PROFILE_DIR
cp $harnessDir/../html/EpiphanyProfile/states.xml $EWB_PROFILE_DIR
ARGS="-p --profile=$EWB_PROFILE_DIR"
fi
if [ "x$SOFFICE" == "x1" ]
then
LO_PROFILE_DIR=/tmp/soffice-profile
ARGS="--norestore --nologo --nolockcheck -env:UserInstallation=file://$LO_PROFILE_DIR"
fi
if [ "$APP_NAME" = "gnome-terminal" ]
then
TERMINAL_WORKING_DIR=/tmp/gnome-terminal-wd
mkdir $TERMINAL_WORKING_DIR
ARGS="--working-directory=$TERMINAL_WORKING_DIR"
fi
if [ $cthulhuRunning -eq 0 ]
then
$harnessDir/runcthulhu.py --user-prefs `pwd` --debug-file $debugFile &
sleep 4
fi
# Start the test application and let it settle in. Two processes
# are started for OpenOffice.
#
echo starting test application $APP_NAME $ARGS $PARAMS ...
$APP_NAME $ARGS $PARAMS &
APP_PID=$!
# Play the keystrokes.
#
python3 $1
if [ $cthulhuRunning -eq 0 ]
then
pkill -9 cthulhu > /dev/null 2>&1
fi
# Terminate the running application
if [ "x$SOFFICE" == "x1" ]
then
APP_PID=$(ps -eo pid,ruid,args | grep norestore | grep -v grep | awk '{ print $1 }')
kill $APP_PID > /dev/null 2>&1
rm -rf $LO_PROFILE_DIR
fi
if [ "$APP_NAME" == "gnome-terminal" ]
then
pkill $APP_NAME > /dev/null 2>&1
rm -rf $TERMINAL_WORKING_DIR
fi
if [ "$APP_NAME" == "epiphany" ]
then
pkill epiphany > /dev/null 2>&1
rm -rf $EWB_PROFILE_DIR
fi
if [ "$APP_NAME" == "firefox" ]
then
pkill firefox > /dev/null 2>&1
rm -rf $FF_PROFILE_DIR
else
pkill $APP_NAME > /dev/null 2>&1
fi

View File

@ -0,0 +1,6 @@
try:
import cProfile as myprofiler
except:
import profile as myprofiler
import cthulhu.cthulhu
myprofiler.run('cthulhu.cthulhu.main()', 'cthulhuprof')

View File

@ -0,0 +1,97 @@
from cthulhu import settings_manager
from json import load, dump
from pprint import pprint
def exerciseBackendAPI(backendName, profile):
settingsManager = settings_manager.SettingsManager(backendName)
print("\n\n================ Testing Backend %s ====================\n\n" % \
backendName)
print('Profile: ', profile)
print('Profiles list: ', settingsManager.availableProfiles())
#settingsManager.setProfile(profile)
# Getters
preferences = settingsManager.getPreferences(profile)
print('preferences: \n', preferences, '\n\n')
generalSettings = settingsManager.getGeneralSettings(profile)
print('generalSettings: \n', generalSettings, '\n\n')
pronunciations = settingsManager.getPronunciations(profile)
print('pronunciations: \n', pronunciations, '\n\n')
keybindings = settingsManager.getKeybindings(profile)
print('keybindings: \n', keybindings, '\n\n')
# Adding new settings to the profile and merging them
newGeneralSettings = getSettingsFromFile('general')
print("newGeneralSettings = ")
pprint(newGeneralSettings)
settingsManager._setProfileGeneral(newGeneralSettings)
generalSettings = settingsManager.getGeneralSettings(profile)
print("generalSettings = ")
pprint(generalSettings)
newKeybindingsSettings = getSettingsFromFile('keybindings')
print("\n\nnewKeybindingsSettings = ")
pprint(newKeybindingsSettings)
settingsManager._setProfileKeybindings(newKeybindingsSettings)
keybindings = settingsManager.getKeybindings(profile)
print("keybindings = ")
pprint(keybindings)
newPronunciationsSettings = getSettingsFromFile('pronunciations')
print("\n\nnewPronunciationsSettings = ")
pprint(newPronunciationsSettings)
settingsManager._setProfileGeneral(newPronunciationsSettings)
pronunciations = settingsManager.getPronunciations(profile)
print("pronunciations = ")
pprint(pronunciations)
#settingsManager.saveSettings()
isFirstStart = settingsManager.isFirstStart()
print("\n\nIs First Start? => ", isFirstStart)
print("\n\nSetting firstStart key")
settingsManager.setFirstStart()
isFirstStart = settingsManager.isFirstStart()
print("\n\nIs First Start? => ", isFirstStart)
print("\n\n===========================================================\n\n")
print("\n\nTesting import from a file I")
print("\n===========================================================")
availableProfilesBefore = settingsManager.availableProfiles()
print("\nAvailable Profiles BEFORE the import => ", availableProfilesBefore)
settingsManager.importProfile('importFile.conf')
availableProfilesAfter = settingsManager.availableProfiles()
print("\nAvailable Profiles AFTER the import => ", availableProfilesAfter)
print("\n\nTesting import from a file II")
print("\n===========================================================")
availableProfilesBefore = settingsManager.availableProfiles()
print("\nAvailable Profiles BEFORE the import => ", availableProfilesBefore)
settingsManager.importProfile('importFile2.conf')
availableProfilesAfter = settingsManager.availableProfiles()
print("\nAvailable Profiles AFTER the import => ", availableProfilesAfter)
def getSettingsFromFile(dictName):
fileName = '%sSettings.conf' % dictName
try:
dictFile = open(fileName)
except:
import sys
print("You should run the test from the test directory")
sys.exit()
settings = load(dictFile)
dictFile.close()
return settings
# main
profile = 'default'
print('profile: default backendName: json\n')
exerciseBackendAPI('json', 'default')
#print 'profile: default backendName: gconf\n'
#exerciseBackendAPI('gconf', 'default')
#exerciseBackendAPI('default', 'gsettings', s)

View File

@ -0,0 +1,60 @@
*** trace2html.py 2006-03-15 20:06:47.000000000 -0500
--- trace2html.py 2007-05-22 08:40:13.000000000 -0400
***************
*** 1,4 ****
! #! python
# (C) Copyright 2006 Olivier Grisel
# Author: Olivier Grisel <olivier.grisel@ensta.org>
--- 1,4 ----
! #!/usr/bin/python
# (C) Copyright 2006 Olivier Grisel
# Author: Olivier Grisel <olivier.grisel@ensta.org>
***************
*** 406,411 ****
--- 406,413 ----
# accumulate summary info
sums = {}
+ total_executable_lines = 0
+ total_covered_lines = 0 # really * 100
for filename, count in per_file_counts.iteritems():
# skip some "files" we don't care about...
***************
*** 418,423 ****
--- 420,426 ----
# Get a list of the line numbers which represent executable content
# (returned as a dict for better lookup speed)
lnotab = trace.find_executable_linenos(filename)
+ total_executable_lines += len(lnotab)
source = linecache.getlines(filename)
modulename = trace.fullmodname(filename)
***************
*** 426,435 ****
report_dir, modulename, source, lnotab, count, css_filename)
sums[modulename] = percent
# write the summary
index_filename = os.path.join(report_dir, 'index.html')
! self._writePage(index_filename, 'Coverage Report - All Modules',
self._summary(sums), css_filename)
return os.path.abspath(index_filename)
--- 429,441 ----
report_dir, modulename, source, lnotab, count, css_filename)
sums[modulename] = percent
+ total_covered_lines += (percent * len(lnotab))
# write the summary
index_filename = os.path.join(report_dir, 'index.html')
! self._writePage(index_filename,
! 'Coverage Report - All Modules - %d%s' \
! % (total_covered_lines / total_executable_lines, '%'),
self._summary(sums), css_filename)
return os.path.abspath(index_filename)

View File

@ -0,0 +1,152 @@
{
"pronunciations": {},
"profiles": {
"default": {
"speechServerFactory": "cthulhu.speechdispatcherfactory",
"profile": [
"Default",
"default"
],
"voices": {
"default": {
"average-pitch": 5.0,
"rate": 50.0,
"gain": 10.0
},
"uppercase": {
"average-pitch": 5.6
},
"system": {
"established": false
},
"hyperlink": {
"average-pitch": 3.0
}
},
"speechServerInfo": [
"Default Synthesizer",
"default"
],
"keybindings": {},
"pronunciations": {}
}
},
"keybindings": {},
"general": {
"disableBrailleEOL": false,
"messagesAreDetailed": true,
"enablePunctuationKeys": true,
"presentToolTips": false,
"enableBraille": false,
"enableNavigationKeys": false,
"enableModifierKeys": true,
"enableNumericKeys": true,
"enableMnemonicSpeaking": false,
"enablePositionSpeaking": false,
"sayAllStyle": 1,
"enableSpeechIndentation": false,
"skipBlankCells": false,
"enableDiacriticalKeys": false,
"cthulhuModifierKeys": [
"Insert",
"KP_Insert"
],
"enableSpeech": true,
"flashIsPersistent": false,
"chatRoomHistories": false,
"keyboardLayout": 1,
"spellcheckSpellSuggestion": true,
"brailleFlashTime": 5000,
"speakSpreadsheetCoordinates": true,
"verbalizePunctuationStyle": 1,
"progressBarVerbosity": 1,
"enableEchoByCharacter": false,
"voices": {
"default": {
"established": false
},
"hyperlink": {
"established": false
},
"system": {
"established": false
},
"uppercase": {
"average-pitch": 7.0
}
},
"wrappedStructuralNavigation": true,
"caretNavTriggersFocusMode": false,
"enabledBrailledTextAttributes": "size:; family-name:; weight:400; indent:0; underline:none; strikethrough:false; justification:left; style:normal; text-spelling:none;",
"enableMouseReview": false,
"beepProgressBarUpdates": false,
"capitalizationStyle": "none",
"brailleLinkIndicator": 192,
"onlySpeakDisplayedText": false,
"spellcheckSpellError": true,
"enableFlashMessages": true,
"largeObjectTextLength": 75,
"chatSpeakRoomName": false,
"enableBrailleContext": true,
"enablePauseBreaks": true,
"enableTutorialMessages": false,
"speechServerInfo": null,
"enabledSpokenTextAttributes": "size:; family-name:; weight:400; indent:0; underline:none; strikethrough:false; justification:left; style:normal; paragraph-style:; text-spelling:none; fg-color:; bg-color:;",
"enableContractedBraille": false,
"enableFunctionKeys": true,
"speakNumbersAsDigits": false,
"readFullRowInDocumentTable": true,
"readFullRowInGUITable": true,
"enableAlphabeticKeys": true,
"structuralNavigationEnabled": true,
"brailleSelectorIndicator": 192,
"findResultsMinimumLength": 4,
"speakCellSpan": true,
"brailleProgressBarUpdates": false,
"speechServerFactory": "speechdispatcherfactory",
"mouseDwellDelay": 0,
"speakBlankLines": true,
"enableBrailleMonitor": true,
"startingProfile": [
"Default",
"default"
],
"speakCellCoordinates": true,
"brailleContractionTable": "",
"enableEchoByWord": false,
"structNavTriggersFocusMode": false,
"profile": [
"Default",
"default"
],
"enableActionKeys": true,
"speakCellHeaders": true,
"readFullRowInSpreadSheet": false,
"brailleVerbosityLevel": 1,
"flashIsDetailed": true,
"enableKeyEcho": false,
"spellcheckPresentContext": true,
"presentDateFormat": "%x",
"brailleRolenameStyle": 1,
"speakMultiCaseStringsAsWords": false,
"enableSpace": true,
"textAttributesBrailleIndicator": 0,
"structNavInSayAll": false,
"speechVerbosityLevel": 1,
"findResultsVerbosity": 2,
"enableEchoBySentence": false,
"presentTimeFormat": "%X",
"rewindAndFastForwardInSayAll": false,
"brailleAlignmentStyle": 0,
"progressBarUpdateInterval": 10,
"chatMessageVerbosity": 0,
"useColorNames": true,
"speakProgressBarUpdates": true,
"layoutMode": true,
"activeProfile": [
"Default",
"default"
],
"chatAnnounceBuddyTyping": false
}
}

220
test/harness/utils.py Normal file
View File

@ -0,0 +1,220 @@
"""Utilities that can be used by tests."""
import difflib
import re
import sys
import gi
gi.require_version("Gdk", "3.0")
gi.require_version("Gtk", "3.0")
from gi.repository import Gio
from gi.repository import Gdk
from gi.repository import Gtk
from macaroon.playback import *
testLogger = Gio.DBusProxy.new_for_bus_sync(
Gio.BusType.SESSION,
Gio.DBusProxyFlags.NONE,
None,
'org.gnome.Cthulhu',
'/org/gnome/Cthulhu',
'org.gnome.Cthulhu.Logger',
None)
enable_assert = \
environ.get('HARNESS_ASSERT', 'yes') in ('yes', 'true', 'y', '1', 1)
errFilename = environ.get('HARNESS_ERR', None)
outFilename = environ.get('HARNESS_OUT', None)
if errFilename and len(errFilename):
myErr = open(errFilename, 'a', 0)
else:
myErr = sys.stderr
if outFilename and len(outFilename):
if outFilename == errFilename:
myOut = myErr
else:
myOut = open(outFilename, 'a', 0)
else:
myOut = sys.stdout
def getKeyCodeForName(name):
keymap = Gdk.Keymap.get_default()
success, entries = keymap.get_entries_for_keyval(Gdk.keyval_from_name(name))
if success:
return entries[-1].keycode
return None
def setClipboardText(text):
clipboard = Gtk.Clipboard.get(Gdk.Atom.intern("CLIPBOARD", False))
clipboard.set_text(text, -1)
class StartRecordingAction(AtomicAction):
'''Tells Cthulhu to log speech and braille output to a string which we
can later obtain and use in an assertion (see AssertPresentationAction)'''
def __init__(self):
if enable_assert:
AtomicAction.__init__(self, 1000, self._startRecording)
else:
AtomicAction.__init__(self, 0, lambda: None)
def _startRecording(self):
testLogger.startRecording()
def __str__(self):
return 'Start Recording Action'
def assertListEquality(rawCthulhuResults, expectedList):
'''Convert raw speech and braille output obtained from Cthulhu into a
list by splitting it at newline boundaries. Compare it to the
list passed in and return the actual results if they differ.
Otherwise, return None to indicate an equality.'''
results = rawCthulhuResults.strip().split("\n")
# Shoot for a string comparison first.
#
if results == expectedList:
return None
elif len(results) != len(expectedList):
return results
# If the string comparison failed, do a regex match item by item
#
for i in range(0, len(expectedList)):
if results[i] == expectedList[i]:
continue
else:
expectedResultRE = re.compile(expectedList[i])
if expectedResultRE.match(results[i]):
continue
else:
return results
return None
class AssertPresentationAction(AtomicAction):
'''Ask Cthulhu for the speech and braille logged since the last use
of StartRecordingAction and apply an assertion predicate.'''
totalCount = 0
totalSucceed = 0
totalFail = 0
totalKnownIssues = 0
def __init__(self, name, expectedResults,
assertionPredicate=assertListEquality):
'''name: the name of the test
expectedResults: the results we want (typically a list of strings
that can be treated as regular expressions)
assertionPredicate: method to compare actual results to expected
results
'''
# [[[WDW: the pause is to wait for Cthulhu to process an event.
# Probably should think of a better way to do this.]]]
#
if enable_assert:
AtomicAction.__init__(self, 1000, self._stopRecording)
self._name = sys.argv[0] + ":" + name
self._expectedResults = expectedResults
self._assertionPredicate = assertionPredicate
AssertPresentationAction.totalCount += 1
self._num = AssertPresentationAction.totalCount
else:
AtomicAction.__init__(self, 0, lambda: None)
def printDiffs(self, results):
"""Compare the expected results with the actual results and print
out a set of diffs.
Arguments:
- results: the actual results.
Returns an indication of whether this test was expected to fail.
"""
knownIssue = False
print("DIFFERENCES FOUND:", file=myErr)
if isinstance(self._expectedResults, [].__class__):
for result in self._expectedResults:
if result.startswith("KNOWN ISSUE") \
or result.startswith("BUG?"):
knownIssue = True
else:
if self._expectedResults.startswith("KNOWN ISSUE") \
or self._expectedResults.startswith("BUG?"):
knownIssue = True
d = difflib.Differ()
try:
# This can stack trace for some odd reason (UTF-8 characters?),
# so we need to capture it. Otherwise, it can hang the tests.
#
diffs = list(d.compare(self._expectedResults, results))
print('\n'.join(list(diffs)), file=myErr)
except:
print("(ERROR COMPUTING DIFFERENCES!!!)", file=myErr)
for i in range(0, max(len(results), len(self._expectedResults))):
try:
print(" EXPECTED: %s" \
% self._expectedResults[i].decode("UTF-8", "replace"), file=myErr)
except:
pass
try:
print(" ACTUAL: %s" \
% results[i].decode("UTF-8", "replace"), file=myErr)
except:
pass
return knownIssue
def _stopRecording(self):
result = testLogger.stopRecording()
results = self._assertionPredicate(result, self._expectedResults)
if not results:
AssertPresentationAction.totalSucceed += 1
print("Test %d of %d SUCCEEDED: %s" \
% (self._num,
AssertPresentationAction.totalCount,
self._name), file=myOut)
else:
AssertPresentationAction.totalFail += 1
print("Test %d of %d FAILED: %s" \
% (self._num,
AssertPresentationAction.totalCount,
self._name), file=myErr)
knownIssue = self.printDiffs(results)
if knownIssue:
AssertPresentationAction.totalKnownIssues += 1
print('[FAILURE WAS EXPECTED - ' \
'LOOK FOR KNOWN ISSUE OR BUG? ' \
'IN EXPECTED RESULTS]', file=myErr)
else:
print('[FAILURE WAS UNEXPECTED]', file=myErr)
def __str__(self):
return 'Assert Presentation Action: %s' % self._name
class AssertionSummaryAction(AtomicAction):
'''Output the summary of successes and failures of
AssertPresentationAction assertions.'''
def __init__(self):
AtomicAction.__init__(self, 0, self._printSummary)
def _printSummary(self):
print("SUMMARY: %d SUCCEEDED and %d FAILED (%d UNEXPECTED) of %d for %s"\
% (AssertPresentationAction.totalSucceed,
AssertPresentationAction.totalFail,
(AssertPresentationAction.totalFail \
- AssertPresentationAction.totalKnownIssues),
AssertPresentationAction.totalCount,
sys.argv[0]), file=myOut)
def __str__(self):
return 'Start Recording Action'