Skip to content

Commit

Permalink
remove usages of controlTypes.stateLabels and negativeStateLabels (#1…
Browse files Browse the repository at this point in the history
…2821)

Part of #12549

Summary of the issue:
controlTypes.stateLabels has been deprecated, usages such as controlTypes.stateLabels[controlTypes.State.*] should be replaced to their equivalent controlTypes.State.*.displayString

Description of how this pull request fixes the issue:
Use displayString and negativeDisplayString instead of stateLabels and negativeStateLabels.
  • Loading branch information
seanbudd authored Sep 13, 2021
1 parent f8f62b0 commit da36a66
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions source/appModules/msimn.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ def _get_name(self):
nameList=[]
imageState=watchdog.cancellableSendMessage(self.windowHandle,sysListView32.LVM_GETITEMSTATE,self.IAccessibleChildID-1,sysListView32.LVIS_STATEIMAGEMASK)>>12
if imageState==5:
nameList.append(controlTypes.stateLabels[controlTypes.State.COLLAPSED])
nameList.append(controlTypes.State.COLLAPSED.displayString)
elif imageState==6:
nameList.append(controlTypes.stateLabels[controlTypes.State.EXPANDED])
nameList.append(controlTypes.State.EXPANDED.displayString)
if self.isUnread:
# Translators: Displayed in outlook or live mail to indicate an email is unread
nameList.append(_("unread"))
Expand Down
4 changes: 2 additions & 2 deletions source/appModules/outlook.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,9 +439,9 @@ class UIAGridRow(RowWithFakeNavigation,UIA):
def _get_name(self):
textList=[]
if controlTypes.State.EXPANDED in self.states:
textList.append(controlTypes.stateLabels[controlTypes.State.EXPANDED])
textList.append(controlTypes.State.EXPANDED.displayString)
elif controlTypes.State.COLLAPSED in self.states:
textList.append(controlTypes.stateLabels[controlTypes.State.COLLAPSED])
textList.append(controlTypes.State.COLLAPSED.displayString)
selection=None
if self.appModule.nativeOm:
try:
Expand Down
2 changes: 1 addition & 1 deletion source/appModules/thunderbird.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def event_gainFocus(self, obj, nextHandler):
except:
# Fall back to reading the entire status bar.
statusText = api.getStatusBarText(statusBar)
speech.speakMessage(controlTypes.stateLabels[controlTypes.State.BUSY])
speech.speakMessage(controlTypes.State.BUSY.displayString)
speech.speakMessage(statusText)
return
nextHandler()
2 changes: 1 addition & 1 deletion source/appModules/totalcmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def reportFocus(self):
if self.name:
speakList=[]
if controlTypes.State.SELECTED in self.states:
speakList.append(controlTypes.stateLabels[controlTypes.State.SELECTED])
speakList.append(controlTypes.State.SELECTED.displayString)
speakList.append(self.name.split("\\")[-1])
speech.speakMessage(" ".join(speakList))
else:
Expand Down
4 changes: 2 additions & 2 deletions source/speech/speech.py
Original file line number Diff line number Diff line change
Expand Up @@ -1288,7 +1288,7 @@ def getTextInfoSpeech( # noqa: C901
# We entered the most outer clickable, so announce it, if we won't be announcing anything else interesting for this field
presCat=field.getPresentationCategory(newControlFieldStack[0:count],formatConfig,reason)
if not presCat or presCat is field.PRESCAT_LAYOUT:
speechSequence.append(controlTypes.stateLabels[controlTypes.State.CLICKABLE])
speechSequence.append(controlTypes.State.CLICKABLE.displayString)
shouldConsiderTextInfoBlank = False
inClickable=True
fieldSequence = info.getControlFieldSpeech(
Expand Down Expand Up @@ -1392,7 +1392,7 @@ def isControlEndFieldCommand(x):
# Announce it if there is nothing else interesting about the field, but not if the user turned it off.
presCat=command.field.getPresentationCategory(newControlFieldStack[0:],formatConfig,reason)
if not presCat or presCat is command.field.PRESCAT_LAYOUT:
fieldSequence.append(controlTypes.stateLabels[controlTypes.State.CLICKABLE])
fieldSequence.append(controlTypes.State.CLICKABLE.displayString)
inClickable=True
fieldSequence.extend(info.getControlFieldSpeech(
command.field,
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/test_controlTypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def test_legacy_roleLabels(self):
if name.startswith("ROLE_"):
self.assertIsNotNone(controlTypes.roleLabels.get(const),msg="{name} has no label".format(name=name))

def test_roleLabels(self):
def test_role_displayString(self):
"""Test to check whether every role has its own display string"""
for role in controlTypes.Role:
role.displayString
Expand All @@ -32,7 +32,7 @@ def test_legacy_positiveStateLabels(self):
if name.startswith("STATE_"):
self.assertIsNotNone(controlTypes.stateLabels.get(const),msg="{name} has no label".format(name=name))

def test_stateLabels(self):
def test_state_displayString(self):
"""Test to check whether every state has its own display string and negative display string"""
for state in controlTypes.State:
state.displayString
Expand Down Expand Up @@ -93,7 +93,7 @@ def test_positiveMergedStatesOutput(self):
obj.states,
None
),
[controlTypes.stateLabels[controlTypes.State.CHECKED]]
[controlTypes.State.CHECKED.displayString]
)

def test_negativeMergedStatesOutput(self):
Expand All @@ -113,5 +113,5 @@ def test_negativeMergedStatesOutput(self):
obj.states,
None
),
[controlTypes.negativeStateLabels[controlTypes.State.CHECKED]]
[controlTypes.State.CHECKED.negativeDisplayString]
)

0 comments on commit da36a66

Please sign in to comment.