mirror of
https://gitlab.steamos.cloud/holo/steamos-manager.git
synced 2025-07-05 06:00:30 -04:00
screenreader: Add a test for screenreader.rs.
Test apis for rate, pitch, volume, and enable/disable. Check out of range gives errors, and values stick after errors.
This commit is contained in:
parent
6cf4bb9c04
commit
372df6ff5e
2 changed files with 252 additions and 0 deletions
150
data/test-orca-settings.conf
Normal file
150
data/test-orca-settings.conf
Normal file
|
@ -0,0 +1,150 @@
|
|||
{
|
||||
"general": {
|
||||
"orcaModifierKeys": [
|
||||
"Insert",
|
||||
"KP_Insert"
|
||||
],
|
||||
"enableSpeech": true,
|
||||
"onlySpeakDisplayedText": false,
|
||||
"speechServerFactory": "speechdispatcherfactory",
|
||||
"speechServerInfo": null,
|
||||
"voices": {
|
||||
"default": {
|
||||
"established": false
|
||||
},
|
||||
"uppercase": {
|
||||
"average-pitch": 7.0
|
||||
},
|
||||
"hyperlink": {
|
||||
"established": false
|
||||
},
|
||||
"system": {
|
||||
"established": false
|
||||
}
|
||||
},
|
||||
"speechVerbosityLevel": 1,
|
||||
"readFullRowInGUITable": true,
|
||||
"readFullRowInDocumentTable": true,
|
||||
"readFullRowInSpreadSheet": false,
|
||||
"enableSpeechIndentation": false,
|
||||
"enableEchoByCharacter": false,
|
||||
"enableEchoByWord": false,
|
||||
"enableEchoBySentence": false,
|
||||
"enableKeyEcho": true,
|
||||
"enableAlphabeticKeys": true,
|
||||
"enableNumericKeys": true,
|
||||
"enablePunctuationKeys": true,
|
||||
"enableSpace": true,
|
||||
"enableModifierKeys": true,
|
||||
"enableFunctionKeys": true,
|
||||
"enableActionKeys": true,
|
||||
"enableNavigationKeys": false,
|
||||
"enableDiacriticalKeys": false,
|
||||
"enablePauseBreaks": true,
|
||||
"enableTutorialMessages": true,
|
||||
"enableMnemonicSpeaking": false,
|
||||
"enablePositionSpeaking": false,
|
||||
"enableBraille": true,
|
||||
"disableBrailleEOL": false,
|
||||
"brailleVerbosityLevel": 1,
|
||||
"brailleRolenameStyle": 1,
|
||||
"brailleSelectorIndicator": 192,
|
||||
"brailleLinkIndicator": 192,
|
||||
"enableSound": true,
|
||||
"soundVolume": 0.5,
|
||||
"playSoundForRole": false,
|
||||
"playSoundForState": false,
|
||||
"playSoundForPositionInSet": false,
|
||||
"playSoundForValue": false,
|
||||
"verbalizePunctuationStyle": 1,
|
||||
"presentToolTips": false,
|
||||
"sayAllStyle": 1,
|
||||
"keyboardLayout": 1,
|
||||
"speakBlankLines": true,
|
||||
"speakNumbersAsDigits": false,
|
||||
"speakMisspelledIndicator": true,
|
||||
"textAttributesToSpeak": [],
|
||||
"textAttributesToBraille": [],
|
||||
"textAttributesBrailleIndicator": 0,
|
||||
"profile": [
|
||||
"Default",
|
||||
"default"
|
||||
],
|
||||
"speakProgressBarUpdates": true,
|
||||
"brailleProgressBarUpdates": false,
|
||||
"beepProgressBarUpdates": false,
|
||||
"progressBarUpdateInterval": 10,
|
||||
"progressBarVerbosity": 1,
|
||||
"ignoreStatusBarProgressBars": true,
|
||||
"enableBrailleWordWrap": false,
|
||||
"enableContractedBraille": false,
|
||||
"brailleContractionTable": "",
|
||||
"enableMouseReview": false,
|
||||
"speakCellCoordinates": true,
|
||||
"speakSpreadsheetCoordinates": true,
|
||||
"alwaysSpeakSelectedSpreadsheetRange": false,
|
||||
"speakCellSpan": true,
|
||||
"speakCellHeaders": true,
|
||||
"skipBlankCells": false,
|
||||
"largeObjectTextLength": 75,
|
||||
"structuralNavigationEnabled": true,
|
||||
"wrappedStructuralNavigation": true,
|
||||
"chatMessageVerbosity": 0,
|
||||
"chatSpeakRoomName": false,
|
||||
"chatAnnounceBuddyTyping": false,
|
||||
"chatRoomHistories": false,
|
||||
"enableFlashMessages": true,
|
||||
"brailleFlashTime": 5000,
|
||||
"flashIsPersistent": false,
|
||||
"flashIsDetailed": true,
|
||||
"messagesAreDetailed": true,
|
||||
"presentDateFormat": "%x",
|
||||
"presentTimeFormat": "%X",
|
||||
"activeProfile": [
|
||||
"Default",
|
||||
"default"
|
||||
],
|
||||
"startingProfile": [
|
||||
"Default",
|
||||
"default"
|
||||
],
|
||||
"spellcheckSpellError": true,
|
||||
"spellcheckSpellSuggestion": true,
|
||||
"spellcheckPresentContext": true,
|
||||
"useColorNames": true,
|
||||
"capitalizationStyle": "none",
|
||||
"findResultsVerbosity": 2,
|
||||
"findResultsMinimumLength": 4,
|
||||
"structNavTriggersFocusMode": false,
|
||||
"caretNavTriggersFocusMode": false,
|
||||
"layoutMode": true,
|
||||
"nativeNavTriggersFocusMode": true,
|
||||
"rewindAndFastForwardInSayAll": false,
|
||||
"structNavInSayAll": false,
|
||||
"speakDescription": true,
|
||||
"speakContextBlockquote": true,
|
||||
"speakContextPanel": true,
|
||||
"speakContextLandmark": true,
|
||||
"speakContextNonLandmarkForm": true,
|
||||
"speakContextList": true,
|
||||
"speakContextTable": true,
|
||||
"sayAllContextBlockquote": true,
|
||||
"sayAllContextPanel": true,
|
||||
"sayAllContextLandmark": true,
|
||||
"sayAllContextNonLandmarkForm": true,
|
||||
"sayAllContextList": true,
|
||||
"sayAllContextTable": true
|
||||
},
|
||||
"profiles": {
|
||||
"default": {
|
||||
"profile": [
|
||||
"Default",
|
||||
"default"
|
||||
],
|
||||
"pronunciations": {},
|
||||
"keybindings": {}
|
||||
}
|
||||
},
|
||||
"pronunciations": {},
|
||||
"keybindings": {}
|
||||
}
|
|
@ -93,6 +93,7 @@ impl<'dbus> OrcaManager<'dbus> {
|
|||
return Ok(());
|
||||
}
|
||||
|
||||
#[cfg(not(test))]
|
||||
{
|
||||
let a11ysettings = Settings::new(A11Y_SETTING);
|
||||
a11ysettings
|
||||
|
@ -261,13 +262,114 @@ impl<'dbus> OrcaManager<'dbus> {
|
|||
Ok(write(self.settings_path()?, data.as_bytes()).await?)
|
||||
}
|
||||
|
||||
#[cfg(not(test))]
|
||||
async fn restart_orca(&self) -> Result<()> {
|
||||
trace!("Restarting orca...");
|
||||
self.orca_unit.restart().await
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
async fn restart_orca(&self) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(not(test))]
|
||||
async fn stop_orca(&self) -> Result<()> {
|
||||
trace!("Stopping orca...");
|
||||
self.orca_unit.stop().await
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
async fn stop_orca(&self) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use crate::testing;
|
||||
use tokio::fs::symlink;
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_enable_disable() {
|
||||
let mut h = testing::start();
|
||||
let _ = symlink("data/test-orca-settings.conf", h.test.path().join("orca-settings.conf")).await;
|
||||
let mut manager =
|
||||
OrcaManager::new(&h.new_dbus().await.expect("new_dbus"))
|
||||
.await
|
||||
.expect("OrcaManager::new");
|
||||
let enable_result = manager.set_enabled(true).await;
|
||||
assert!(enable_result.is_ok());
|
||||
assert_eq!(manager.enabled(), true);
|
||||
|
||||
let disable_result = manager.set_enabled(false).await;
|
||||
assert!(disable_result.is_ok());
|
||||
assert_eq!(manager.enabled(), false);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_pitch() {
|
||||
let mut h = testing::start();
|
||||
let _ = symlink("data/test-orca-settings.conf", h.test.path().join("orca-settings.conf")).await;
|
||||
let mut manager =
|
||||
OrcaManager::new(&h.new_dbus().await.expect("new_dbus"))
|
||||
.await
|
||||
.expect("OrcaManager::new");
|
||||
let set_result = manager.set_pitch(5.0).await;
|
||||
assert!(set_result.is_ok());
|
||||
assert_eq!(manager.pitch(), 5.0);
|
||||
|
||||
let too_low_result = manager.set_pitch(-1.0).await;
|
||||
assert!(too_low_result.is_err());
|
||||
assert_eq!(manager.pitch(), 5.0);
|
||||
|
||||
let too_high_result = manager.set_pitch(12.0).await;
|
||||
assert!(too_high_result.is_err());
|
||||
assert_eq!(manager.pitch(), 5.0);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_rate() {
|
||||
let mut h = testing::start();
|
||||
let _ = symlink("data/test-orca-settings.conf", h.test.path().join("orca-settings.conf")).await;
|
||||
let mut manager =
|
||||
OrcaManager::new(&h.new_dbus().await.expect("new_dbus"))
|
||||
.await
|
||||
.expect("OrcaManager::new");
|
||||
let set_result = manager.set_rate(5.0).await;
|
||||
assert!(set_result.is_ok());
|
||||
assert_eq!(manager.rate(), 5.0);
|
||||
|
||||
let too_low_result = manager.set_rate(-1.0).await;
|
||||
assert!(too_low_result.is_err());
|
||||
assert_eq!(manager.rate(), 5.0);
|
||||
|
||||
let too_high_result = manager.set_rate(101.0).await;
|
||||
assert!(too_high_result.is_err());
|
||||
assert_eq!(manager.rate(), 5.0);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_volume() {
|
||||
let mut h = testing::start();
|
||||
let _ = symlink("data/test-orca-settings.conf", h.test.path().join("orca-settings.conf")).await;
|
||||
let mut manager =
|
||||
OrcaManager::new(&h.new_dbus().await.expect("new_dbus"))
|
||||
.await
|
||||
.expect("OrcaManager::new");
|
||||
let set_result = manager.set_volume(5.0).await;
|
||||
assert!(set_result.is_ok());
|
||||
assert_eq!(manager.volume(), 5.0);
|
||||
|
||||
let too_low_result = manager.set_volume(-1.0).await;
|
||||
assert!(too_low_result.is_err());
|
||||
assert_eq!(manager.volume(), 5.0);
|
||||
|
||||
let too_high_result = manager.set_volume(12.0).await;
|
||||
assert!(too_high_result.is_err());
|
||||
assert_eq!(manager.volume(), 5.0);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue