#!/usr/bin/env python ############################################################################# # # Accessibility Evaluation Test Utils # # Author: # Rodney Dawes # # Copyright 2006 Novell, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of version 2 of the GNU General Public License # as published by the Free Software Foundation # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. # ############################################################################# from ldtp import * from ldtputils import * f = None; def __has_label (windowName, componentName): properties = getobjectinfo (windowName, componentName) for prop in properties: if prop == 'label': return 1 elif prop == 'label_by': return 1 continue return 0 def __has_description (windowName, componentName): properties = getobjectinfo (windowName, componentName) for prop in properties: if prop == 'description': return 1 continue return 0 def __print_properties (errorString, windowName, componentName): utfname = componentName.encode ('utf8') properties = getobjectinfo (windowName, componentName) f.write ('' + errorString + '\n') f.write ('' + utfname + '\n') propValue = getobjectproperty (windowName, componentName, 'class') f.write ('' + propValue + '\n') propValue = getobjectproperty (windowName, componentName, 'parent') f.write ('' + propValue + '\n') def a11y_scan_dialog (windowName, closeButton): waittillguiexist (windowName) objlist = getobjectlist (windowName) f.write ('\n') f.write ('') f.write ('\n') f.write ('') f.write ('\n') f.write ('') has_label = 0 for obj in objlist: if hasstate (windowName, obj, state.FOCUSABLE) == 1: if __has_label (windowName, obj) == 0: f.write ('\n') __print_properties ('Missing Name', windowName, obj) f.write ('\n') if __has_description (windowName, obj) == 0: f.write ('\n') __print_properties ('Missing Description', windowName, obj) f.write ('\n') f.write ('
' + windowName + '
IssueWidgetWidget ClassParent Widget
\n') click (windowName, closeButton) def a11y_scan_window (windowName): waittillguiexist (windowName) objlist = getobjectlist (windowName) f.write ('\n') f.write ('') f.write ('\n') f.write ('') f.write ('\n') f.write ('') has_label = 0 for obj in objlist: print obj if hasstate (windowName, obj, state.FOCUSABLE) == 1: if __has_label (windowName, obj) == 0: f.write ('\n') __print_properties ('Missing Name', windowName, obj) f.write ('\n') if __has_description (windowName, obj) == 0: f.write ('\n') __print_properties ('Missing Description', windowName, obj) f.write ('\n') f.write ('
' + windowName + '
IssueWidgetWidget ClassParent Widget
\n') def a11y_find_panel_with_applet (appletName): panel_titles = [ 'frmBottomExpandedEdgePanel', 'frmBottomEdgePanel', 'frmBottomCenteredPanel', 'frmRightExpandedEdgePanel', 'frmRightEdgePanel', 'frmRightCenteredPanel', 'frmTopExpandedEdgePanel', 'frmTopEdgePanel', 'frmTopCenteredPanel', 'frmLeftExpandedEdgePanel', 'frmLeftEdgePanel', 'frmLeftCenteredPanel' ] for panel_title in panel_titles: if (guiexist (panel_title)): if (objectexist (panel_title, appletName)): return panel_title else: continue else: continue return None def a11y_test_init (programName, argumentList = '', noLaunch = 0, logName = ''): global f ldtp.setlocale ('en_US.UTF-8') if (logName == '' or logName == None): logName = programName; f = open (logName + '.html', 'w') f.write ('') f.write ('\n') f.write ('\n') f.write ('' + programName + ' Accessibility Test Summary\n') f.write ('') f.write ('\n') f.write ('\n') if (noLaunch == 0 or noLaunch == None or noLaunch == ''): if (argumentList != '' and argumentList != None and argumentList != 0): launchapp (programName + ' ' + argumentList, env = 1) else: launchapp (programName, env = 1) def a11y_test_shutdown (): f.write ('\n') f.write ('\n') f.close ()