[orca/new-settings] Added new checkings to the settings_test.py and some profile examples



commit 07bce0f766f89f5ae80f5220bbf18cc75a31cd15
Author: Juanje Ojeda <jojeda emergya es>
Date:   Thu Oct 28 08:27:30 2010 +0200

    Added new checkings to the settings_test.py and some profile examples

 test/harness/generalSettings.conf        |   10 +++++
 test/harness/keybindingsSettings.conf    |    4 ++
 test/harness/pronunciationsSettings.conf |    3 +
 test/harness/settings_test.py            |   62 ++++++++++++++++++++++++-----
 4 files changed, 68 insertions(+), 11 deletions(-)
---
diff --git a/test/harness/generalSettings.conf b/test/harness/generalSettings.conf
new file mode 100644
index 0000000..5e35deb
--- /dev/null
+++ b/test/harness/generalSettings.conf
@@ -0,0 +1,10 @@
+ enableKeyEcho: false
+ keyboardLayout: 2
+ magSourceDisplay: :0.0
+ magTargetDisplay: :0.0
+ orcaModifierKeys: [Caps_Lock]
+ profile: [Laptop, laptop]
+ quitOrcaNoConfirmation: true
+ speechServerFactory: orca.speechdispatcherfactory
+ speechServerInfo: [Sintetizador predeterminado, default]
+ verbalizePunctuationStyle: 2
diff --git a/test/harness/keybindingsSettings.conf b/test/harness/keybindingsSettings.conf
new file mode 100644
index 0000000..73f43bd
--- /dev/null
+++ b/test/harness/keybindingsSettings.conf
@@ -0,0 +1,4 @@
+keybindings:
+ reviewCurrentCharacterHandler:
+ - !!python/tuple [KP_2, '365', '0', '1']
+ - !!python/tuple [null, '365', '0', '1']
diff --git a/test/harness/pronunciationsSettings.conf b/test/harness/pronunciationsSettings.conf
new file mode 100644
index 0000000..7e5a958
--- /dev/null
+++ b/test/harness/pronunciationsSettings.conf
@@ -0,0 +1,3 @@
+pronunciations:
+  asap: [ASAP, as soon as possible]
+  btw: [BTW, by the way]
diff --git a/test/harness/settings_test.py b/test/harness/settings_test.py
index 05de800..126bac6 100644
--- a/test/harness/settings_test.py
+++ b/test/harness/settings_test.py
@@ -1,10 +1,14 @@
-from orca.settings_manager import SettingsManager
+from orca import settings_manager
+from yaml import load, dump
+from pprint import pprint
 
-def exerciseBackendAPI(profile, backendName, settingsManager):
-    settingsManager.backendName = backendName
-    settingsManager._loadBackend()
+def exerciseBackendAPI(backendName, profile):
+    settingsManager = settings_manager.SettingsManager(backendName, profile)
 
-    print 'Profiles list', profile, settingsManager.availableProfiles()
+    print "\n\n================ Testing Backend %s ====================\n\n" % \
+            backendName
+    print 'Profile: ', profile
+    print 'Profiles list: ', settingsManager.availableProfiles()
 
     #settingsManager.setProfile(profile)
 
@@ -21,19 +25,55 @@ def exerciseBackendAPI(profile, backendName, settingsManager):
     keybindings = settingsManager.getKeybindings(profile)
     print 'keybindings: \n',keybindings,'\n\n'
 
-    # Other stuff
+    # 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()
     isClassic = settingsManager.isClassic()
-    sFirstStart = settingsManager.isFirstStart()
+    print "\n\nIs Classic Backend? => ", isClassic
+    isFirstStart = settingsManager.isFirstStart()
+    print "\n\nIs First Start? => ", isFirstStart
     #settingsManager.setFirstStart()
+    print "\n\n===========================================================\n\n"
 
+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'
-s = SettingsManager()
-print s
 print 'profile: default backendName: yaml\n'
-exerciseBackendAPI('default', 'yaml', s)
+exerciseBackendAPI('yaml', 'default')
 print 'profile: default backendName: gconf\n'
-exerciseBackendAPI('default', 'gconf', s)
+exerciseBackendAPI('gconf', 'default')
 #exerciseBackendAPI('default', 'gsettings', s)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]