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

« back to all changes in this revision

Viewing changes to mago/application/sol.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 "sol" module.
6
 
 
7
 
This module provides a wrapper for LDTP to make writing Sol 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 Sol(Application):
26
 
    """
27
 
    sol manages the Sol application.
28
 
    """
29
 
 
30
 
    LAUNCHER = 'sol'
31
 
    LAUNCHER_ARGS = []
32
 
    WINDOW = 'frmKlondike'
33
 
 
34
 
    BTN_DEAL = _('btnDeal')
35
 
    BTN_HINT = _('btnHint')
36
 
    BTN_LEAVEFULLSCREEN = _('btnLeaveFullscreen')
37
 
    BTN_NEW = _('btnNew')
38
 
    BTN_REDOMOVE = _('btnRedoMove')
39
 
    BTN_RESTART = _('btnRestart')
40
 
    BTN_SELECTGAME = _('btnSelectGame')
41
 
    BTN_UNDOMOVE = _('btnUndoMove')
42
 
    MNU_ABOUT = _('mnuAbout')
43
 
    MNU_CLOSE = _('mnuClose')
44
 
    MNU_CONTENTS = _('mnuContents')
45
 
    MNU_DEAL = _('mnuDeal')
46
 
    MNU_EMPTY = _('mnuEmpty')
47
 
    MNU_EMPTY1 = _('mnuEmpty1')
48
 
    MNU_EMPTY2 = _('mnuEmpty2')
49
 
    MNU_EMPTY3 = _('mnuEmpty3')
50
 
    MNU_EMPTY4 = _('mnuEmpty4')
51
 
    MNU_EMPTY5 = _('mnuEmpty5')
52
 
    MNU_EMPTY6 = _('mnuEmpty6')
53
 
    MNU_GETHELPONLINE = _('mnuGetHelpOnline')
54
 
    MNU_HINT = _('mnuHint')
55
 
    MNU_INSTALLCARDTHEMES___ = _('mnuInstallcardthemes***')
56
 
    MNU_KLONDIKE = _('mnuKlondike')
57
 
    MNU_KLONDIKE2 = _('mnuKlondike2')
58
 
    MNU_NEW = _('mnuNew')
59
 
    MNU_REDOMOVE = _('mnuRedoMove')
60
 
    MNU_REPORTAPROBLEM = _('mnuReportaProblem')
61
 
    MNU_RESTART = _('mnuRestart')
62
 
    MNU_SELECTGAME = _('mnuSelectGame')
63
 
    MNU_STATISTICS = _('mnuStatistics')
64
 
    MNU_TRANSLATETHISAPPLICATION = _('mnuTranslateThisApplication')
65
 
    MNU_UNDOMOVE = _('mnuUndoMove')
66
 
 
67
 
 
68
 
    def runAboutdialog(self):
69
 
        """
70
 
        This basic test simply verifies that the application launches
71
 
        and that the UI reacts
72
 
        The About dialog is the only menu that is always present in the UI
73
 
        """
74
 
        if self.MNU_ABOUT:
75
 
            self.main_window.click(self.MNU_ABOUT)
76
 
 
77
 
            # Wait for the dialog to open
78
 
            # Name of about dialogs change with the app
79
 
            timeout=60
80
 
            dlgAbout=None
81
 
            while not ( timeout>0 and dlgAbout):
82
 
                dlgs=[ w for w in ldtp.getwindowlist() if w.startswith('dlgAbout')]
83
 
                if dlgs:
84
 
                    dlgAbout = dlgs[0]
85
 
                timeout -= 1
86
 
                time.sleep(1)
87
 
 
88
 
            if not dlgAbout:
89
 
                raise AssertionError('About Dialog not found')
90
 
 
91
 
 
92
 
            # Looking for a button to close the window
93
 
            found = None
94
 
            for btnClose in ('btnClose', 'btnOK', 'btnCancel'):
95
 
                try:
96
 
                    found = ldtp.getchild(dlgAbout, btnClose, 'push button')
97
 
                    break
98
 
                except:
99
 
                    pass
100
 
 
101
 
            if not found:
102
 
                return
103
 
 
104
 
            ldtp.click(dlgAbout, btnClose)
105
 
 
106
 
 
107
 
    def close(self):
108
 
        self.main_window.click('mnuClose')
109
 
 
110
 
    def __init__(self):
111
 
        Application.__init__(self)
112
 
        self.main_window = ooldtp.context(self.WINDOW)