~ubuntu-branches/ubuntu/utopic/dogtail/utopic

« back to all changes in this revision

Viewing changes to examples/gedit-test-utf8-procedural-api.py

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2006-12-21 13:33:47 UTC
  • mfrom: (1.2.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 5.
  • Revision ID: james.westby@ubuntu.com-20061221133347-xo9jg11afp5plcka
Tags: upstream-0.6.1
ImportĀ upstreamĀ versionĀ 0.6.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
from dogtail.utils import screenshot
11
11
 
12
12
# These next two lines get us translations for free. To see the script run
13
 
# translated, run it like this: 
 
13
# translated, run it like this:
14
14
#  LANG=ja_JP.UTF-8 ./gedit-test-utf8-procedural-api.py
15
 
# You might also want to set config.debugTranslation and 
 
15
# You might also want to set config.debugTranslation and
16
16
# config.debugSearching to True, just for fun.
17
17
import dogtail.i18n
18
18
dogtail.i18n.loadTranslationsFromPackageMoFiles('gedit')
24
24
 
25
25
# Remove the output file, if it's still there from a previous run
26
26
if path.isfile(path.join(path.expandvars("$HOME"), "Desktop", "UTF8demo.txt")):
27
 
        remove(path.join(path.expandvars("$HOME"), "Desktop", "UTF8demo.txt"))
 
27
    remove(path.join(path.expandvars("$HOME"), "Desktop", "UTF8demo.txt"))
28
28
 
29
29
# Start gedit.
30
30
run('gedit')
51
51
 
52
52
# Focus gedit's Save As... dialog
53
53
try:
54
 
        # This string changed somewhere around gedit 2.13.2.
55
 
        # This is the new string
56
 
        focus.dialog(u'Save As\u2026')
 
54
    # This string changed somewhere around gedit 2.13.2.
 
55
    # This is the new string
 
56
    focus.dialog(u'Save As\u2026')
57
57
except FocusError:
58
 
        # Fall back to the old string.
59
 
        focus.dialog('Save as...')
 
58
    # Fall back to the old string.
 
59
    focus.dialog('Save as...')
60
60
 
61
61
# click the Browse for other folders widget
62
62
activate('Browse for other folders')
74
74
# Let's quit now.
75
75
click('Quit')
76
76
 
77
 
# We have driven gedit now lets check to see if the saved file is the same as 
 
77
# We have driven gedit now lets check to see if the saved file is the same as
78
78
# the baseline file
79
79
 
80
80
# Read in the "gold" file
81
81
import codecs
82
82
try:
83
 
        # When reading the file, we have to make sure and tell codecs.open() which 
84
 
        # encoding we're using, otherwise python gets confused later.
85
 
        gold = open(path[0] + '/data/UTF-8-demo.txt', encoding='utf-8').readlines()
 
83
    # When reading the file, we have to make sure and tell codecs.open() which
 
84
    # encoding we're using, otherwise python gets confused later.
 
85
    gold = open(path[0] + '/data/UTF-8-demo.txt', encoding='utf-8').readlines()
86
86
except IOError:
87
 
        print "File open failed"
 
87
    print "File open failed"
88
88
 
89
89
# Read the test file for comparison
90
90
filepath = environ['HOME'] + '/Desktop/UTF8demo.txt'
91
 
# When reading the file, we have to make sure and tell codecs.open() which 
 
91
# When reading the file, we have to make sure and tell codecs.open() which
92
92
# encoding we're using, otherwise python gets confused later.
93
93
testfile = open(filepath, encoding='utf-8').readlines()
94
94
 
96
96
# by line to see if they are the same
97
97
i = 0
98
98
for baseline in gold:
99
 
        label = "line test " + str(i + 1)
100
 
        TestString.compare(label, baseline, testfile[i], encoding='utf-8')
101
 
        i = i + 1
102
 
 
 
99
    label = "line test " + str(i + 1)
 
100
    TestString.compare(label, baseline, testfile[i], encoding='utf-8')
 
101
    i = i + 1