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')
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))
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
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))
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)
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) ])
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]]])
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)
def setUp(self): self.gui = GUI(GeistFakeBackend())
def setUp(self): self.backend = GeistMouseBackend() self.gui = GUI(self.backend)
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)