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

« back to all changes in this revision

Viewing changes to mago/application/windowmanager.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
"""
 
2
This is the "windowmanager" module.
 
3
 
 
4
This module provides wrappers for LDTP to make the writing of WindowManager tests
 
5
easier.
 
6
"""
 
7
import ldtp , ooldtp
 
8
from .main import Application
 
9
from ..backend.pywo.core import Gravity, Size, Geometry, Window, WindowManager as WM
 
10
from time import sleep
 
11
from mago.application.main import Application
 
12
from random import random
 
13
 
 
14
 
 
15
class WindowManager(Application):
 
16
    app = None
 
17
    LAUNCHER = None
 
18
    mainwindow = None
 
19
 
 
20
    def __init__(self):
 
21
        self.WM = WM()
 
22
 
 
23
    def open(self, appname=None, windowname=None, closetype=None, closename=None):
 
24
        """ Open the application whose binary is 'appname' """
 
25
        self.app = Application(windowname, close_type=closetype, close_name=closename)
 
26
        self.app.LAUNCHER = appname
 
27
        self.app.open()
 
28
        self.mainwindow = ooldtp.context(windowname)
 
29
 
 
30
    def maximize(self, vert=True, horz=True, rand=False, count=5):
 
31
        """Exercise Maximize feature of the window manager
 
32
 
 
33
        vert: True to Maximize vertically
 
34
        horz: True to Maximize horizontally
 
35
        rand: True to Maximize randomly
 
36
        count: Number of iteration to maximize/minimize
 
37
        """
 
38
 
 
39
        self.mainwindow.activatewindow()
 
40
        ldtp.wait(5)
 
41
        win = self.WM.active_window()
 
42
 
 
43
        statev = 0
 
44
        stateh = 0
 
45
 
 
46
        if vert: statev = Window.STATE_MAXIMIZED_VERT
 
47
        if horz: statev = Window.STATE_MAXIMIZED_HORZ
 
48
 
 
49
        for i in range(0, count):
 
50
            if random:
 
51
                statev =  Window.STATE_MAXIMIZED_VERT if (int(random() * 2) > 0) else False
 
52
                stateh =  Window.STATE_MAXIMIZED_HORZ if (int(random() * 2) > 0) else False
 
53
 
 
54
            for x in range(0,2):
 
55
                win.maximize(Window.MODE_TOGGLE, statev, stateh)
 
56
                WM.flush()
 
57
                sleep(.5)
 
58
 
 
59
 
 
60
    def close(self):
 
61
        pass