~ubuntu-branches/ubuntu/utopic/sikuli/utopic

« back to all changes in this revision

Viewing changes to sikuli-script/src/test/python/test_region.py

  • Committer: Bazaar Package Importer
  • Author(s): Gilles Filippini
  • Date: 2011-10-04 23:32:13 UTC
  • mfrom: (4.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20111004233213-36fm78hx0z53tkuw
Tags: 1.0~x~rc3-dfsg1-2
* New patch fix-cmake-sikuli-ide.patch:
  + Fix random FTBFS due to missing inter target dependency

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
import unittest
 
3
from sikuli import *
 
4
from org.sikuli.script import JButtons
 
5
 
 
6
class TestRegion(unittest.TestCase):
 
7
 
 
8
   @classmethod
 
9
   def setUpClass(cls):
 
10
      cls.r = Region(0,0,100,100)
 
11
      cls.r.setThrowException(False)
 
12
      cls.r.setAutoWaitTimeout(0)
 
13
      cls.img = "test-res/network.png"
 
14
 
 
15
   @classmethod
 
16
   def tearDownClass(cls):
 
17
      pass
 
18
 
 
19
   def testFind(self):
 
20
      self.r.find(self.img)
 
21
 
 
22
   def testFindAll(self):
 
23
      self.r.findAll(self.img)
 
24
 
 
25
   def testWait(self):
 
26
      self.r.wait(1)
 
27
      self.r.wait(0.1)
 
28
      self.r.wait(self.img)
 
29
      self.r.wait(self.img, 0.1)
 
30
      try:
 
31
         self.r.wait(self.img, 1, "blah")
 
32
         self.fail("wait() should not take so many arguments.")
 
33
      except TypeError,e:
 
34
         assert e != None
 
35
 
 
36
   def testWaitVanish(self):
 
37
      self.r.waitVanish(self.img)
 
38
      self.r.waitVanish(self.img, 0.1)
 
39
 
 
40
   def testExists(self):
 
41
      self.r.exists(self.img)
 
42
      self.r.exists(self.img, 0.1)
 
43
 
 
44
   def testClick(self):
 
45
      self.r.click(self.img)
 
46
      self.r.click(self.img, KEY_CTRL)
 
47
 
 
48
   def testDoubleClick(self):
 
49
      self.r.doubleClick(self.img)
 
50
      self.r.doubleClick(self.img, KEY_CTRL)
 
51
 
 
52
   def testRightClick(self):
 
53
      self.r.rightClick(self.img)
 
54
      self.r.rightClick(self.img, KEY_CTRL)
 
55
 
 
56
   def testHover(self):
 
57
      self.r.hover(self.img)
 
58
 
 
59
   def testType(self):
 
60
      self.r.type("a string")
 
61
      self.r.type(self.img, "a string")
 
62
      self.r.type(self.img, "a string", KEY_SHIFT)
 
63
 
 
64
   def testPaste(self):
 
65
      #App.open("TextEdit.app")
 
66
      #self.r.wait(2)
 
67
      self.r.paste("a string 中文")
 
68
      self.r.paste(self.img, u"a string 中文")
 
69
 
 
70
   def testDragDrop(self):
 
71
      self.r.dragDrop(self.img, self.img)
 
72
      self.r.dragDrop(self.img, Location(0,0), KEY_CTRL)
 
73
 
 
74
   def testDrag(self):
 
75
      self.r.drag(self.img)
 
76
 
 
77
   def testDropAt(self):
 
78
      self.r.dropAt(self.img)
 
79
      self.r.dropAt(self.img, 1)
 
80
 
 
81
   def testMouseMove(self):
 
82
      self.r.mouseMove(self.img)
 
83
 
 
84
   def testMouseDownAndUp(self):
 
85
      self.r.mouseDown(Button.LEFT)
 
86
      self.r.mouseUp()
 
87
      self.r.mouseDown(Button.LEFT)
 
88
      self.r.mouseUp(Button.LEFT)
 
89
 
 
90
   def testKeyDownAndUp(self):
 
91
      self.r.keyDown('a')
 
92
      self.r.keyUp()
 
93
      self.r.keyDown('b')
 
94
      self.r.keyUp('b')
 
95