author | Shawn Walker <shawn.walker@oracle.com> |
Fri, 07 May 2010 16:26:13 -0500 | |
changeset 1890 | 011afb71c52a |
parent 1715 | 8f305f0a6864 |
child 2036 | a1a3b15b6850 |
permissions | -rw-r--r-- |
1516
8c950a3b4171
10485 move pkg(5) to Python 2.6
Rich Burridge <rich.burridge@sun.com>
parents:
1317
diff
changeset
|
1 |
#!/usr/bin/python |
1297
2924ade539eb
10580 Include automated tests for the Package Manager
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff
changeset
|
2 |
# |
2924ade539eb
10580 Include automated tests for the Package Manager
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff
changeset
|
3 |
# CDDL HEADER START |
2924ade539eb
10580 Include automated tests for the Package Manager
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff
changeset
|
4 |
# |
2924ade539eb
10580 Include automated tests for the Package Manager
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff
changeset
|
5 |
# The contents of this file are subject to the terms of the |
2924ade539eb
10580 Include automated tests for the Package Manager
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff
changeset
|
6 |
# Common Development and Distribution License (the "License"). |
2924ade539eb
10580 Include automated tests for the Package Manager
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff
changeset
|
7 |
# You may not use this file except in compliance with the License. |
2924ade539eb
10580 Include automated tests for the Package Manager
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff
changeset
|
8 |
# |
2924ade539eb
10580 Include automated tests for the Package Manager
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff
changeset
|
9 |
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
2924ade539eb
10580 Include automated tests for the Package Manager
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff
changeset
|
10 |
# or http://www.opensolaris.org/os/licensing. |
2924ade539eb
10580 Include automated tests for the Package Manager
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff
changeset
|
11 |
# See the License for the specific language governing permissions |
2924ade539eb
10580 Include automated tests for the Package Manager
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff
changeset
|
12 |
# and limitations under the License. |
2924ade539eb
10580 Include automated tests for the Package Manager
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff
changeset
|
13 |
# |
2924ade539eb
10580 Include automated tests for the Package Manager
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff
changeset
|
14 |
# When distributing Covered Code, include this CDDL HEADER in each |
2924ade539eb
10580 Include automated tests for the Package Manager
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff
changeset
|
15 |
# file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
2924ade539eb
10580 Include automated tests for the Package Manager
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff
changeset
|
16 |
# If applicable, add the following below this CDDL HEADER, with the |
2924ade539eb
10580 Include automated tests for the Package Manager
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff
changeset
|
17 |
# fields enclosed by brackets "[]" replaced with your own identifying |
2924ade539eb
10580 Include automated tests for the Package Manager
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff
changeset
|
18 |
# information: Portions Copyright [yyyy] [name of copyright owner] |
2924ade539eb
10580 Include automated tests for the Package Manager
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff
changeset
|
19 |
# |
2924ade539eb
10580 Include automated tests for the Package Manager
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff
changeset
|
20 |
# CDDL HEADER END |
2924ade539eb
10580 Include automated tests for the Package Manager
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff
changeset
|
21 |
# |
2924ade539eb
10580 Include automated tests for the Package Manager
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff
changeset
|
22 |
|
1890
011afb71c52a
15037 action parsing can't handle unicode objects which don't decode to ascii
Shawn Walker <shawn.walker@oracle.com>
parents:
1715
diff
changeset
|
23 |
# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. |
1297
2924ade539eb
10580 Include automated tests for the Package Manager
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff
changeset
|
24 |
|
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
25 |
import os |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
26 |
import sys |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
27 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
28 |
# Set the path so that modules can be found |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
29 |
path_to_parent = os.path.join(os.path.dirname(__file__), "..") |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
30 |
sys.path.insert(0, path_to_parent) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
31 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
32 |
import pkg5testenv |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
33 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
34 |
def setup_environment(proto): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
35 |
pkg5testenv.setup_environment(proto) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
36 |
|
1317
e42a9b752ba4
10662 test suite fails if pygtk, gtk not present
Tom Mueller <Tom.Mueller@sun.com>
parents:
1297
diff
changeset
|
37 |
try: |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
38 |
if "DISPLAY" in os.environ: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
39 |
import pygtk |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
40 |
pygtk.require('2.0') |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
41 |
import gtk |
1317
e42a9b752ba4
10662 test suite fails if pygtk, gtk not present
Tom Mueller <Tom.Mueller@sun.com>
parents:
1297
diff
changeset
|
42 |
except ImportError: |
e42a9b752ba4
10662 test suite fails if pygtk, gtk not present
Tom Mueller <Tom.Mueller@sun.com>
parents:
1297
diff
changeset
|
43 |
pass |
e42a9b752ba4
10662 test suite fails if pygtk, gtk not present
Tom Mueller <Tom.Mueller@sun.com>
parents:
1297
diff
changeset
|
44 |
|
e42a9b752ba4
10662 test suite fails if pygtk, gtk not present
Tom Mueller <Tom.Mueller@sun.com>
parents:
1297
diff
changeset
|
45 |
def check_for_gtk(): |
e42a9b752ba4
10662 test suite fails if pygtk, gtk not present
Tom Mueller <Tom.Mueller@sun.com>
parents:
1297
diff
changeset
|
46 |
return "gtk" in globals() |
1297
2924ade539eb
10580 Include automated tests for the Package Manager
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff
changeset
|
47 |
|
2924ade539eb
10580 Include automated tests for the Package Manager
Michal Pryc <Michal.Pryc@Sun.Com>
parents:
diff
changeset
|
48 |
def check_if_a11y_enabled(): |
1317
e42a9b752ba4
10662 test suite fails if pygtk, gtk not present
Tom Mueller <Tom.Mueller@sun.com>
parents:
1297
diff
changeset
|
49 |
if not check_for_gtk(): |
e42a9b752ba4
10662 test suite fails if pygtk, gtk not present
Tom Mueller <Tom.Mueller@sun.com>
parents:
1297
diff
changeset
|
50 |
return False |
e42a9b752ba4
10662 test suite fails if pygtk, gtk not present
Tom Mueller <Tom.Mueller@sun.com>
parents:
1297
diff
changeset
|
51 |
# To determine if A11Y is enabled we are starting small gtk application |
e42a9b752ba4
10662 test suite fails if pygtk, gtk not present
Tom Mueller <Tom.Mueller@sun.com>
parents:
1297
diff
changeset
|
52 |
# and then we do check if the applications' window does contain |
e42a9b752ba4
10662 test suite fails if pygtk, gtk not present
Tom Mueller <Tom.Mueller@sun.com>
parents:
1297
diff
changeset
|
53 |
# accessible widget. This allows us to be sure that A11Y is not |
e42a9b752ba4
10662 test suite fails if pygtk, gtk not present
Tom Mueller <Tom.Mueller@sun.com>
parents:
1297
diff
changeset
|
54 |
# only enabled in the gconf key, but it's truly running. |
e42a9b752ba4
10662 test suite fails if pygtk, gtk not present
Tom Mueller <Tom.Mueller@sun.com>
parents:
1297
diff
changeset
|
55 |
window = gtk.Window(gtk.WINDOW_TOPLEVEL) |
e42a9b752ba4
10662 test suite fails if pygtk, gtk not present
Tom Mueller <Tom.Mueller@sun.com>
parents:
1297
diff
changeset
|
56 |
button = gtk.Button("Check Accessibility") |
e42a9b752ba4
10662 test suite fails if pygtk, gtk not present
Tom Mueller <Tom.Mueller@sun.com>
parents:
1297
diff
changeset
|
57 |
window.add(button) |
e42a9b752ba4
10662 test suite fails if pygtk, gtk not present
Tom Mueller <Tom.Mueller@sun.com>
parents:
1297
diff
changeset
|
58 |
a11y_enabled = False |
e42a9b752ba4
10662 test suite fails if pygtk, gtk not present
Tom Mueller <Tom.Mueller@sun.com>
parents:
1297
diff
changeset
|
59 |
if window.get_accessible().get_n_accessible_children() != 0: |
e42a9b752ba4
10662 test suite fails if pygtk, gtk not present
Tom Mueller <Tom.Mueller@sun.com>
parents:
1297
diff
changeset
|
60 |
a11y_enabled = True |
e42a9b752ba4
10662 test suite fails if pygtk, gtk not present
Tom Mueller <Tom.Mueller@sun.com>
parents:
1297
diff
changeset
|
61 |
return a11y_enabled |