~xpresser-team/xpresser/cleanup

« back to all changes in this revision

Viewing changes to xpresser/tests/test_xp.py

  • Committer: Chris Wayne
  • Date: 2012-07-05 13:52:37 UTC
  • mfrom: (10.1.6 gtk3-port-with-cairo)
  • Revision ID: chris.wayne@canonical.com-20120705135237-7f52h9sfxwu279dr
Merging in gtk3 support with simple cv, adding debian packaging

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
import threading
21
21
import time
22
22
 
23
 
import gtk
 
23
from gi.repository import Gtk, Gdk
24
24
 
25
25
from xpresser import Xpresser, ImageNotFound
26
26
from xpresser.image import Image
49
49
        self.assertEquals(image.name, "red-circle")
50
50
 
51
51
    def test_type(self):
52
 
        entry = gtk.Entry()
 
52
        entry = Gtk.Entry()
53
53
        window = self.create_window(entry)
54
54
        try:
55
55
            window.present()
72
72
        self.button_rclicked = False
73
73
        self.button_hovered = False
74
74
        self.button_dclicked = False
75
 
                
 
75
 
76
76
        def clicked(widget, event):
77
 
            if event.button == 1 and event.type == gtk.gdk._2BUTTON_PRESS:
 
77
            if event.button == 1 and event.type == Gdk.EventType._2BUTTON_PRESS:
78
78
                self.button_dclicked = True
79
 
            elif event.button == 1 and event.type == gtk.gdk.BUTTON_PRESS:
 
79
            elif event.button == 1 and event.type == Gdk.EventType.BUTTON_PRESS:
80
80
                self.button_clicked = True
81
81
            elif event.button == 3:
82
82
                self.button_rclicked = True
93
93
        self.window.destroy()
94
94
 
95
95
    def get_button_center(self):
96
 
        button_x, button_y = self.button.window.get_position()
97
 
        button_width, button_height = self.button.window.get_size()
 
96
        button_x, button_y = self.button.get_window().get_position()
 
97
        button_width = self.button.get_window().get_width()
 
98
        button_height = self.button.get_window().get_height()
98
99
        return (button_x + button_width//2, button_y + button_height//2)
99
100
 
100
101
    def test_find_image_name(self):
123
124
 
124
125
    def test_find_failed(self):
125
126
        started = time.time()
 
127
        image = self.xp.get_image("blue-square")
 
128
        image.similarity = 1.0
126
129
        self.assertRaises(ImageNotFound,
127
130
                          self.xp.find, "blue-square", timeout=SLEEP_DELAY)
128
131
        self.assertTrue(time.time() - started > SLEEP_DELAY)
142
145
 
143
146
    def test_wait_failed(self):
144
147
        started = time.time()
 
148
        image = self.xp.get_image("blue-square")
 
149
        image.similarity = 1.0
145
150
        self.assertRaises(ImageNotFound,
146
151
                          self.xp.wait, "blue-square", timeout=SLEEP_DELAY)
147
152
        self.assertTrue(time.time() - started > SLEEP_DELAY)