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

« back to all changes in this revision

Viewing changes to mago/application/baobab.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 "baobab" module.
6
 
 
7
 
This module provides a wrapper for LDTP to make writing Baobab 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 Baobab(Application):
26
 
    """
27
 
    baobab manages the Baobab application.
28
 
    """
29
 
 
30
 
    LAUNCHER = 'baobab'
31
 
    LAUNCHER_ARGS = []
32
 
    WINDOW = 'frmDiskUsageAnalyzer'
33
 
    
34
 
    DLG_SELECTFOLDER = _('dlgSelectFolder')
35
 
    BTN_REFRESH = _('btnRefresh')
36
 
    BTN_SCANFILESYSTEM = _('btnScanFilesystem')
37
 
    BTN_SCANFOLDER = _('btnScanFolder')
38
 
    BTN_SCANHOME = _('btnScanHome')
39
 
    BTN_SCANREMOTEFOLDER = _('btnScanRemoteFolder')
40
 
    BTN_STOP = _('btnStop')
41
 
    BTN_TYPEAFILENAME = _('tbtnTypeafilename')
42
 
    MNU_ABOUT = _('mnuAbout')
43
 
    MNU_COLLAPSEALL = _('mnuCollapseAll')
44
 
    MNU_CONTENTS = _('mnuContents')
45
 
    MNU_EMPTY = _('mnuEmpty')
46
 
    MNU_EMPTY1 = _('mnuEmpty1')
47
 
    MNU_EMPTY2 = _('mnuEmpty2')
48
 
    MNU_EMPTY3 = _('mnuEmpty3')
49
 
    MNU_EXPANDALL = _('mnuExpandAll')
50
 
    MNU_PREFERENCES = _('mnuPreferences')
51
 
    MNU_QUIT = _('mnuQuit')
52
 
    MNU_REFRESH = _('mnuRefresh')
53
 
    MNU_SCANFILESYSTEM = _('mnuScanFilesystem')
54
 
    MNU_SCANFOLDER = _('mnuScanFolder')
55
 
    MNU_SCANHOMEFOLDER = _('mnuScanHomeFolder')
56
 
    MNU_SCANREMOTEFOLDER = _('mnuScanRemoteFolder')
57
 
    MNU_STOP = _('mnuStop')
58
 
    MNU_VIEWASRINGSCHART = _('mnuViewasRingsChart')
59
 
    MNU_VIEWASTREEMAPCHART = _('mnuViewasTreemapChart')
60
 
    TXT_LOCATION = _('txtLocation')
61
 
    CBO_VIEWAS = _('cboViewas*')
62
 
    
63
 
    
64
 
    def baobab_scan_home(self):
65
 
        baobab = ooldtp.context(self.name)
66
 
        
67
 
        #Scan the home folder and wait till the end of the scan.
68
 
        baobab.getchild(self.MNU_SCANHOMEFOLDER).selectmenuitem()
69
 
        buttonStop = baobab.getchild(self.BTN_STOP)
70
 
        
71
 
        while buttonStop.stateenabled():
72
 
            ldtp.wait()
73
 
        
74
 
        self.baobab_change_views()      
75
 
        #Scan the home again now this time using the button in the toolbar.
76
 
        baobab.getchild(self.BTN_SCANHOME).click()
77
 
             
78
 
        while buttonStop.stateenabled(): 
79
 
            ldtp.wait()
80
 
        
81
 
        self.baobab_change_views()
82
 
                
83
 
    def baobab_scan_folder(self, path):
84
 
        baobab = ooldtp.context(self.name)
85
 
        
86
 
        baobab.getchild(self.BTN_SCANFOLDER).click()
87
 
 
88
 
        ldtp.waittillguiexist(self.DLG_SELECTFOLDER)
89
 
        
90
 
        if (ldtp.guiexist(self.DLG_SELECTFOLDER)):
91
 
            selectFiles = ooldtp.context(self.DLG_SELECTFOLDER)
92
 
            if not (selectFiles.getchild(self.TXT_LOCATION)):
93
 
                ldtp.generatekeyevent('<ctrl>l')
94
 
            textLocation = selectFiles.getchild(self.TXT_LOCATION)
95
 
            textLocation.settextvalue(path)
96
 
            ldtp.generatekeyevent('<return>')
97
 
        ldtp.wait(2)
98
 
                
99
 
        buttonStop = baobab.getchild(self.BTN_STOP)
100
 
        
101
 
        while buttonStop.stateenabled():
102
 
            ldtp.wait()
103
 
        
104
 
        self.baobab_change_views()
105
 
        
106
 
    def baobab_scan_filesystem(self):
107
 
        baobab = ooldtp.context(self.name)
108
 
        
109
 
        #Scan the filesystem 
110
 
        baobab.getchild(self.MNU_SCANFILESYSTEM).selectmenuitem()
111
 
        buttonStop = baobab.getchild(self.BTN_STOP)
112
 
        
113
 
        while buttonStop.stateenabled():
114
 
            ldtp.wait(2)
115
 
        
116
 
        #Change the views again to see if that works and we don't get any crash.
117
 
        self.baobab_change_views()
118
 
        
119
 
    def baobab_change_views(self):
120
 
        baobab = ooldtp.context(self.name)
121
 
        
122
 
        #Change the graph view.
123
 
        comboView = baobab.getchild(self.CBO_VIEWAS)
124
 
        
125
 
        for item in comboView.getallitem():
126
 
            ldtp.wait(2)
127
 
            comboView.selectitem(item)
128
 
        
129
 
        #Collapse and expand the tree
130
 
        baobab.getchild(self.MNU_EXPANDALL).selectmenuitem()
131
 
        ldtp.wait(2)
132
 
        baobab.getchild(self.MNU_COLLAPSEALL).selectmenuitem()
133
 
    
134
 
    def __init__(self):
135
 
        Application.__init__(self)