~ubuntu-branches/ubuntu/quantal/mago/quantal

« back to all changes in this revision

Viewing changes to mago/application/computer_janitor_gtk.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 "computer_janitor_gtk" module.
 
6
 
 
7
This module provides a wrapper for LDTP to make writing Computer_janitor_gtk 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 Computer_janitor_gtk(Application):
 
26
    """
 
27
    computer_janitor_gtk manages the Computer_janitor_gtk application.
 
28
    """
 
29
 
 
30
    LAUNCHER = 'computer-janitor-gtk'
 
31
    LAUNCHER_ARGS = []
 
32
    WINDOW = 'frmComputerJanitor'
 
33
 
 
34
    BTN_DOSELECTEDTASKS = _('btnDoselectedtasks')
 
35
    MNU_ABOUT = _('mnuAbout')
 
36
    MNU_QUIT = _('mnuQuit')
 
37
 
 
38
 
 
39
    def runAboutdialog(self):
 
40
        """
 
41
        This basic test simply verifies that the application launches
 
42
        and that the UI reacts
 
43
        The About dialog is the only menu that is always present in the UI
 
44
        """
 
45
        if self.MNU_ABOUT:
 
46
            self.main_window.click(self.MNU_ABOUT)
 
47
 
 
48
            # Wait for the dialog to open
 
49
            # Name of about dialogs change with the app
 
50
            timeout=60
 
51
            dlgAbout=None
 
52
            while not ( timeout>0 and dlgAbout):
 
53
                dlgs=[ w for w in ldtp.getwindowlist() if w.startswith('dlgAbout')]
 
54
                if dlgs:
 
55
                    dlgAbout = dlgs[0]
 
56
                timeout -= 1
 
57
                time.sleep(1)
 
58
 
 
59
            if not dlgAbout:
 
60
                raise AssertionError('About Dialog not found')
 
61
 
 
62
 
 
63
            # Looking for a button to close the window
 
64
            found = None
 
65
            for btnClose in ('btnClose', 'btnOK', 'btnCancel'):
 
66
                try:
 
67
                    found = ldtp.getchild(dlgAbout, btnClose, 'push button')
 
68
                    break
 
69
                except:
 
70
                    pass
 
71
 
 
72
            if not found:
 
73
                return
 
74
 
 
75
            ldtp.click(dlgAbout, btnClose)
 
76
 
 
77
 
 
78
    def __init__(self):
 
79
        Application.__init__(self)
 
80
        self.main_window = ooldtp.context(self.WINDOW)