Add ICU message format support
[chromium-blink-merge.git] / tools / accessibility / dump_accessibility_tree_auralinux.py
blob70e33b0685b1426c1d8b5d675df6be0757c9b47d
1 #!/usr/bin/env python
2 # Copyright 2015 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
6 """Dump Chrome's ATK accessibility tree to the command line.
8 Accerciser is slow and buggy. This is a quick way to check that Chrome is
9 exposing its interface to ATK from the command line.
10 """
12 import pyatspi
14 # Helper function to check application name
15 def AppNameFinder(name):
16 if (name.lower().find('chromium') !=0 and
17 name.lower().find('chrome') !=0 and
18 name.lower().find('google chrome') != 0):
19 return False
20 return True
22 def Dump(obj, indent):
23 if not obj:
24 return
25 indent_str = ' ' * indent
26 role = obj.get_role_name()
27 name = obj.get_name()
28 bounds = obj.get_extents(pyatspi.DESKTOP_COORDS)
29 bounds_str = '(%d, %d) size (%d x %d)' % (
30 bounds.x, bounds.y, bounds.width, bounds.height)
31 print '%s%s name="%s" %s' % (indent_str, role, name, bounds_str)
33 # Don't recurse into applications other than Chrome
34 if role == 'application':
35 if (not AppNameFinder(name)):
36 return
38 for i in range(obj.get_child_count()):
39 Dump(obj.get_child_at_index(i), indent + 1)
41 desktop = pyatspi.Registry.getDesktop(0)
42 Dump(desktop, 0)