~ubuntu-branches/ubuntu/saucy/mago/saucy

« back to all changes in this revision

Viewing changes to mago/application/gnome_sudoku.py

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2011-02-08 13:32:13 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20110208133213-m1og7ey0m990chg6
Tags: 0.3+bzr20-0ubuntu1
* debian/rules:
  - updated to debhelper 7
  - use dh_python2 instead of python-central
* debian/pycompat:
  - removed, no longer needed
* debian/control:
  - dropped cdbs and python-central dependencies
* bzr snapshot of the current trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
PACKAGE = "mago"
2
 
 
3
 
#-*- coding:utf-8 -*-
4
 
"""
5
 
This is the "gnome_sudoku" module.
6
 
 
7
 
This module provides a wrapper for LDTP to make writing Gnome_sudoku tests easier.
8
 
"""
9
 
import ooldtp
10
 
import ldtp
11
 
import os
12
 
from .main import Application
13
 
from ..gconfwrapper import GConf
14
 
from ..cmd import globals
15
 
import time
16
 
import gettext
17
 
 
18
 
gettext.install (True)
19
 
gettext.bindtextdomain (PACKAGE, globals.LOCALE_SHARE)
20
 
gettext.textdomain (PACKAGE)
21
 
t = gettext.translation(PACKAGE, globals.LOCALE_SHARE, fallback = True)
22
 
_ = t.gettext
23
 
 
24
 
 
25
 
class Gnome_sudoku(Application):
26
 
    """
27
 
    gnome_sudoku manages the Gnome_sudoku application.
28
 
    """
29
 
 
30
 
    LAUNCHER = 'gnome-sudoku'
31
 
    LAUNCHER_ARGS = []
32
 
    WINDOW = 'frmSudoku'
33
 
 
34
 
    BTN_ADD = _('btnAdd')
35
 
    BTN_APPLY = _('btnApply')
36
 
    BTN_CLEAR = _('btnClear')
37
 
    BTN_HIDE = _('btnHide')
38
 
    BTN_HINT = _('btnHint')
39
 
    BTN_NEW = _('btnNew')
40
 
    BTN_REDO = _('btnRedo')
41
 
    BTN_UNDO = _('btnUndo')
42
 
    MNU_ABOUT = _('mnuAbout')
43
 
    MNU_CLEARBOTTOMNOTES = _('mnuClearBottomNotes')
44
 
    MNU_CLEARTOPNOTES = _('mnuClearTopNotes')
45
 
    MNU_CLOSE = _('mnuClose')
46
 
    MNU_CONTENTS = _('mnuContents')
47
 
    MNU_EMPTY = _('mnuEmpty')
48
 
    MNU_EMPTY1 = _('mnuEmpty1')
49
 
    MNU_EMPTY2 = _('mnuEmpty2')
50
 
    MNU_EMPTY3 = _('mnuEmpty3')
51
 
    MNU_FULLSCREEN = _('mnuFullscreen')
52
 
    MNU_GETHELPONLINE = _('mnuGetHelpOnline')
53
 
    MNU_HINT = _('mnuHint')
54
 
    MNU_NEW = _('mnuNew')
55
 
    MNU_PRINT = _('mnuPrint')
56
 
    MNU_PRINTMULTIPLESUDOKUS = _('mnuPrintMultipleSudokus')
57
 
    MNU_PUZZLESTATISTICS = _('mnuPuzzleStatistics')
58
 
    MNU_REDO = _('mnuRedo')
59
 
    MNU_REPORTAPROBLEM = _('mnuReportaProblem')
60
 
    MNU_RESET = _('mnuReset')
61
 
    MNU_TRANSLATETHISAPPLICATION = _('mnuTranslateThisApplication')
62
 
    MNU_UNDO = _('mnuUndo')
63
 
 
64
 
 
65
 
    def runAboutdialog(self):
66
 
        """
67
 
        This basic test simply verifies that the application launches
68
 
        and that the UI reacts
69
 
        The About dialog is the only menu that is always present in the UI
70
 
        """
71
 
        if self.MNU_ABOUT:
72
 
            self.main_window.click(self.MNU_ABOUT)
73
 
 
74
 
            # Wait for the dialog to open
75
 
            # Name of about dialogs change with the app
76
 
            timeout=60
77
 
            dlgAbout=None
78
 
            while not ( timeout>0 and dlgAbout):
79
 
                dlgs=[ w for w in ldtp.getwindowlist() if w.startswith('dlgAbout')]
80
 
                if dlgs:
81
 
                    dlgAbout = dlgs[0]
82
 
                timeout -= 1
83
 
                time.sleep(1)
84
 
 
85
 
            if not dlgAbout:
86
 
                raise AssertionError('About Dialog not found')
87
 
 
88
 
 
89
 
            # Looking for a button to close the window
90
 
            found = None
91
 
            for btnClose in ('btnClose', 'btnOK', 'btnCancel'):
92
 
                try:
93
 
                    found = ldtp.getchild(dlgAbout, btnClose, 'push button')
94
 
                    break
95
 
                except:
96
 
                    pass
97
 
 
98
 
            if not found:
99
 
                return
100
 
 
101
 
            ldtp.click(dlgAbout, btnClose)
102
 
 
103
 
    def close(self):
104
 
        self.main_window.click('mnuClose')
105
 
 
106
 
    def __init__(self):
107
 
        Application.__init__(self)
108
 
        self.main_window = ooldtp.context(self.WINDOW)