예제 #1
0
 def test_keyboard_works(self):
     capture_file = os.path.join(_DIR, 'test_keyboard_works.log')
     backend = RecordingBackend(source_backend=GeistFakeBackend(),
                                recording_filename=capture_file)
     gui = GUI(backend)
     gui.key_presses('abcd')
     backend = PlaybackBackend(recording_filename=capture_file)
     gui = GUI(backend)
     gui.key_presses('abcd')
예제 #2
0
 def test_mouse_works(self):
     capture_file = os.path.join(_DIR, 'test_mouse_works.log')
     backend = RecordingBackend(source_backend=GeistFakeBackend(),
                                recording_filename=capture_file)
     gui = GUI(backend)
     gui.click(Location(10, 10))
     backend = PlaybackBackend(recording_filename=capture_file)
     gui = GUI(backend)
     gui.click(Location(10, 10))
예제 #3
0
 def test_replay_capture_works(self):
     capture_file = os.path.join(_DIR, 'test_replay_capture_works.log')
     backend = RecordingBackend(source_backend=GeistFakeBackend(),
                                recording_filename=capture_file)
     gui = GUI(backend)
     locations_record = gui.capture_locations()
     backend = PlaybackBackend(recording_filename=capture_file)
     gui = GUI(backend)
     locations_playback = gui.capture_locations()
     assert locations_record == locations_playback
예제 #4
0
 def test_nontrivial_StopChangingFinder(self):
     backend = GeistFakeBackend(image=np.array([[[0], [0]], [[0], [0]]]))
     gui = GUI(backend)
     finder = StopChangingFinder(self.location)
     #backend.image = np.array([[[0],[0]],[[0],[0]]])
     finder.period = 1
     location_found = gui.wait_find_one(finder)
     self.assertTrue(np.array_equal(location_found.image, backend.image))
예제 #5
0
 def test_ClickingFinder(self):
     backend = GeistMouseBackend()
     gui = GUI(backend)
     finder = ClickingFinder(self.location, gui)
     # things only happen when generator consumed
     list(finder.find(self.location))
     self.assertTrue(backend.button_up_pressed)
     self.assertTrue(backend.button_down_pressed)
     self.assertIn((0, 0), backend.list_of_points)
예제 #6
0
 def setUp(self):
     self.gui = GUI(GeistFakeBackend())
     self.screen = self.gui.capture_locations()[0]
     self.locs_a = LocationList(
         [Location(10, 13, w=5, h=5, parent=self.screen)])
     self.locs_b = LocationList([
         Location(0, 2, w=5, h=5, parent=self.screen),
         Location(0, 24, w=5, h=5, parent=self.screen),
         Location(22, 2, w=5, h=5, parent=self.screen),
         Location(22, 24, w=5, h=5, parent=self.screen)
     ])
예제 #7
0
 def setUp(self):
     self.repo = DirectoryRepo('test_repo')
     self.gui = GUI(
         GeistFakeBackend(image=np.array(
             [[[255, 0, 0], [240, 10, 10], [0, 255, 0], [0, 0, 255]],
              [[255, 0, 0], [240, 10, 10], [0, 255, 0], [0, 0, 255]],
              [[255, 0, 0], [240, 10, 10], [0, 255, 0], [0, 0, 255]],
              [[255, 0, 0], [240, 10, 10], [0, 255, 0], [0, 0, 255]]])))
     self.V = Viewer(self.gui, self.repo)
     self.screen = self.gui.capture_locations()[0]
     self.red = np.array([[[255, 0, 0]]])
     self.more_reds = np.array([[[255, 0, 0], [240, 10, 10]]])
예제 #8
0
 def setUp(self):
     self.repo = DirectoryRepo('test_repo')
     self.gui = GUI(GeistFakeBackend())
     self.V = Viewer(self.gui, self.repo)
     # first need to save some images to repo
     self.image = np.array([[0, 0, 0, 0, 0],
                       [0, 0, 0, 1, 0],
                       [0, 0, 1, 0, 0],
                       [0, 1, 0, 0, 0],
                       [0, 0, 0, 0, 0]])
     self.image2 = np.array([[0, 0, 0, 0, 0, 0, 0],
                       [0, 0, 0, 1, 0, 0, 0],
                       [0, 0, 1, 0, 0, 0, 0],
                       [0, 1, 0, 0, 0, 0, 0],
                       [0, 0, 0, 0, 0, 0, 0]])
     self.image3 = np.array([[[255,0,0],[240,10,10],[0,255,0],[0,0,255]]], dtype=np.int32)
     self.V._save('test_file_1', self.image, force=True)
     self.V._save('test_file_2', self.image2, force=True)
     self.V._save('test_file_3', self.image3, force=True)
예제 #9
0
 def setUp(self):
     self.gui = GUI(GeistFakeBackend())
예제 #10
0
 def setUp(self):
     self.backend = GeistMouseBackend()
     self.gui = GUI(self.backend)
예제 #11
0
파일: prereq.py 프로젝트: Python3pkg/Geist
Use the viewer object to capture images and test finders in an interactive ipython
"""

try:
    get_ipython().magic('pylab')
except (NameError, ):
    pass

from geist.backends import get_platform_backend

from geist import (
    GUI,
    DirectoryRepo,
)

from geist.pyplot import Viewer

# Mark the directory listed as the current image repository
repo = DirectoryRepo(
    "C:\some_filepath")  # <--------------- EDIT ME!!!!!!!!!!!!!!!

# Start a Geist backend, takes an optional screen number to capture.
backend = get_platform_backend()

# Start a Geist GUI
gui = GUI(backend)

# Viewer  object can be used to display results in image form
viewer = Viewer(gui, repo)