~ubuntu-branches/ubuntu/natty/mago/natty

« back to all changes in this revision

Viewing changes to mago/application/gbrainy.py

  • Committer: Bazaar Package Importer
  • Author(s): Ara Pulido
  • Date: 2010-12-03 16:08:32 UTC
  • Revision ID: james.westby@ubuntu.com-20101203160832-97pz2nxwmo54iwfk
Tags: 0.3-0ubuntu3
* Updated from trunk
 + Added new applications to our tests base
 + Fixes LP: #682845 

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 "gbrainy" module.
 
6
 
 
7
This module provides a wrapper for LDTP to make writing Gbrainy 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 Gbrainy(Application):
 
26
    """
 
27
    gbrainy manages the Gbrainy application.
 
28
    """
 
29
 
 
30
    LAUNCHER = 'gbrainy'
 
31
    LAUNCHER_ARGS = []
 
32
    WINDOW = 'frmgbrainy'
 
33
 
 
34
    BTN_ALL = _('btnAll')
 
35
    BTN_CALCULATION = _('btnCalculation')
 
36
    BTN_FINISH = _('btnFinish')
 
37
    BTN_LOGIC = _('btnLogic')
 
38
    BTN_MEMORY = _('btnMemory')
 
39
    BTN_NEXT = _('btnNext')
 
40
    BTN_OK = _('btnOK')
 
41
    BTN_PAUSE = _('btnPause')
 
42
    BTN_TIP = _('btnTip')
 
43
    BTN_VERBAL = _('btnVerbal')
 
44
    MNU_ABOUT = _('mnuAbout')
 
45
    MNU_ALLGAMES_LOGIC_MENTALCALCULATION_MEMORYANDVERBALANALOGIES_ = _('mnuAllGames(Logic,MentalCalculation,MemoryandVerbalAnalogies)')
 
46
    MNU_CONTENTS = _('mnuContents')
 
47
    MNU_CUSTOMGAMESELECTION = _('mnuCustomGameSelection')
 
48
    MNU_ENDGAME = _('mnuEndGame')
 
49
    MNU_EXTENSIONS = _('mnuExtensions')
 
50
    MNU_FULLSCREEN = _('mnuFullscreen')
 
51
    MNU_GETHELPONLINE = _('mnuGetHelpOnline')
 
52
    MNU_HOWTOEXTENDGBRAINY_SFUNCTIONALITY = _('mnuHowtoExtendgbrainy*sFunctionality')
 
53
    MNU_LOGICPUZZLESONLY = _('mnuLogicPuzzlesOnly')
 
54
    MNU_MEMORYTRAINERSONLY = _('mnuMemoryTrainersOnly')
 
55
    MNU_MENTALCALCULATIONTRAINERSONLY = _('mnuMentalCalculationTrainersOnly')
 
56
    MNU_PAUSEGAME = _('mnuPauseGame')
 
57
    MNU_PLAYER_SGAMESESSIONHISTORY = _('mnuPlayer*sGameSessionHistory')
 
58
    MNU_PREFERENCES = _('mnuPreferences')
 
59
    MNU_QUIT = _('mnuQuit')
 
60
    MNU_REPORTAPROBLEM = _('mnuReportaProblem')
 
61
    MNU_TRANSLATETHISAPPLICATION = _('mnuTranslateThisApplication')
 
62
    MNU_VERBALANALOGIESONLY = _('mnuVerbalAnalogiesOnly')
 
63
    TXT_0 = _('txt0')
 
64
 
 
65
 
 
66
    def runAboutdialog(self):
 
67
        """
 
68
        This basic test simply verifies that the application launches
 
69
        and that the UI reacts
 
70
        The About dialog is the only menu that is always present in the UI
 
71
        """
 
72
        if self.MNU_ABOUT:
 
73
            self.main_window.click(self.MNU_ABOUT)
 
74
 
 
75
            # Wait for the dialog to open
 
76
            # Name of about dialogs change with the app
 
77
            timeout=60
 
78
            dlgAbout=None
 
79
            while not ( timeout>0 and dlgAbout):
 
80
                dlgs=[ w for w in ldtp.getwindowlist() if w.startswith('dlgAbout')]
 
81
                if dlgs:
 
82
                    dlgAbout = dlgs[0]
 
83
                timeout -= 1
 
84
                time.sleep(1)
 
85
 
 
86
            if not dlgAbout:
 
87
                raise AssertionError('About Dialog not found')
 
88
 
 
89
 
 
90
            # Looking for a button to close the window
 
91
            found = None
 
92
            for btnClose in ('btnClose', 'btnOK', 'btnCancel'):
 
93
                try:
 
94
                    found = ldtp.getchild(dlgAbout, btnClose, 'push button')
 
95
                    break
 
96
                except:
 
97
                    pass
 
98
 
 
99
            if not found:
 
100
                return
 
101
 
 
102
            ldtp.click(dlgAbout, btnClose)
 
103
 
 
104
 
 
105
    def __init__(self):
 
106
        Application.__init__(self)
 
107
        self.main_window = ooldtp.context(self.WINDOW)