| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Dump Chrome's ATK accessibility tree to the command line. | 6 """Dump Chrome's ATK accessibility tree to the command line. |
| 7 | 7 |
| 8 Accerciser is slow and buggy. This is a quick way to check that Chrome is | 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. | 9 exposing its interface to ATK from the command line. |
| 10 """ | 10 """ |
| 11 | 11 |
| 12 import pyatspi | 12 import pyatspi |
| 13 | 13 |
| 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 |
| 21 |
| 14 def Dump(obj, indent): | 22 def Dump(obj, indent): |
| 15 if not obj: | 23 if not obj: |
| 16 return | 24 return |
| 17 indent_str = ' ' * indent | 25 indent_str = ' ' * indent |
| 18 role = obj.get_role_name() | 26 role = obj.get_role_name() |
| 19 name = obj.get_name() | 27 name = obj.get_name() |
| 20 print '%s%s name="%s"' % (indent_str, role, name) | 28 print '%s%s name="%s"' % (indent_str, role, name) |
| 21 | 29 |
| 22 # Don't recurse into applications other than Chrome | 30 # Don't recurse into applications other than Chrome |
| 23 if role == 'application': | 31 if role == 'application': |
| 24 if (name.lower().find('chrom') != 0 and | 32 if (not AppNameFinder(name)): |
| 25 name.lower().find('google chrome') != 0): | |
| 26 return | 33 return |
| 27 | 34 |
| 28 for i in range(obj.get_child_count()): | 35 for i in range(obj.get_child_count()): |
| 29 Dump(obj.get_child_at_index(i), indent + 1) | 36 Dump(obj.get_child_at_index(i), indent + 1) |
| 30 | 37 |
| 31 desktop = pyatspi.Registry.getDesktop(0) | 38 desktop = pyatspi.Registry.getDesktop(0) |
| 32 Dump(desktop, 0) | 39 Dump(desktop, 0) |
| OLD | NEW |