Beispiel #1
0
class TestSliceFinderFilter(unittest.TestCase):
    def setUp(self):
        self.gui = GUI(GeistFakeBackend())

    def test_index(self):
        screen = self.gui.capture_locations()[0]
        self.locs = LocationList([Location(0, 0, w=10, h=10, parent=screen),
                                  Location(0, 8, w=10, h=10, parent=screen),
                                  Location(0, 2, w=10, h=10, parent=screen),
                                  Location(6, 8, w=10, h=10, parent=screen)])
        expected = LocationList([Location(0, 0, w=10, h=10, parent=screen),
                                 Location(0, 8, w=10, h=10, parent=screen)])
        finder = SliceFinderFilter(self.locs)
        actual = self.gui.find_all(finder[:2])
        self.assertListEqual(actual, expected)

    def test_slice(self):
        screen = self.gui.capture_locations()[0]
        self.locs = LocationList([Location(0, 0, w=10, h=10, parent=screen),
                                  Location(0, 8, w=10, h=10, parent=screen),
                                  Location(0, 2, w=10, h=10, parent=screen),
                                  Location(6, 8, w=10, h=10, parent=screen)])
        expected = LocationList([Location(0, 0, w=10, h=10, parent=screen),
                                 Location(0, 8, w=10, h=10, parent=screen)])
        finder = SliceFinderFilter(self.locs)
        actual = self.gui.find_all(finder[slice(0, 2)])
        self.assertListEqual(actual, expected)
Beispiel #2
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))
Beispiel #3
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))
Beispiel #4
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)
     ])
Beispiel #5
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]]])
Beispiel #6
0
class TestLocationFinderFilter(unittest.TestCase):
    def setUp(self):
        self.gui = GUI(GeistFakeBackend())

    def test_filter(self):
        in_location = self.gui.wait_find_one(Location(10, 10, 100, 100))
        parent_x, parent_y = 40, 50
        child_x, child_y = 100, 17
        finder = FinderInFinder(Location(child_x, child_y, 100, 100), Location(parent_x, parent_y, 500, 500))
        result = self.gui.wait_find_one(finder)
        self.assertEqual(parent_x + child_x, result.x)
        self.assertEqual(parent_y + child_y, result.y)
Beispiel #7
0
class TestLocationFinderFilter(unittest.TestCase):
    def setUp(self):
        self.gui = GUI(GeistFakeBackend())

    def test_filter(self):
        in_location = self.gui.wait_find_one(Location(10, 10, 100, 100))
        parent_x, parent_y = 40, 50
        child_x, child_y = 100, 17
        finder = FinderInFinder(Location(child_x, child_y, 100, 100),
                                Location(parent_x, parent_y, 500, 500))
        result = self.gui.wait_find_one(finder)
        self.assertEqual(parent_x + child_x, result.x)
        self.assertEqual(parent_y + child_y, result.y)
Beispiel #8
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
Beispiel #9
0
class TestSortingFinder(unittest.TestCase):
    def setUp(self):
        self.gui = GUI(GeistFakeBackend())

    def test_sort(self):
        screen = self.gui.capture_locations()[0]
        self.locs = LocationList([Location(0, 0, w=10, h=10, parent=screen),
                                  Location(0, 8, w=10, h=10, parent=screen),
                                  Location(0, 2, w=10, h=10, parent=screen),
                                  Location(6, 8, w=10, h=10, parent=screen)])
        self.key = lambda loc: loc.y
        expected = sorted(self.locs, key=self.key)
        finder = SortingFinder(self.locs, key=self.key)
        actual = self.gui.find_all(finder)
        self.assertListEqual(actual, expected)
Beispiel #10
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]]])))
     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]]])
Beispiel #11
0
class TestLocationFinderFilter(unittest.TestCase):
    def setUp(self):
        self.gui = GUI(GeistFakeBackend())

    def test_filter(self):
        screen = self.gui.capture_locations()[0]
        self.locs = LocationList([Location(0, 0, w=10, h=10, parent=screen),
                                  Location(0, 8, w=10, h=10, parent=screen),
                                  Location(0, 2, w=10, h=10, parent=screen),
                                  Location(6, 8, w=10, h=10, parent=screen)])
        filter = lambda loc: loc.y == 8
        expected = LocationList([Location(0, 8, w=10, h=10, parent=screen),
                                 Location(6, 8, w=10, h=10, parent=screen)])
        finder = LocationFinderFilter(filter, self.locs)
        actual = self.gui.find_all(finder)
        self.assertListEqual(actual, expected)
Beispiel #12
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')
Beispiel #13
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))
Beispiel #14
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)
Beispiel #15
0
class TestViewer(unittest.TestCase):
    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]]])))
        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 test_get_colour(self):
        red = self.V._get_colour(self.red)
        result = self.gui.find_all(BinaryRegionFinder(red))
        expected = [Location(0,0, w=1, h=1, parent=self.screen)]
        self.assertListEqual(result, expected)


    def test_get_colour_range(self):
        reds = self.V._get_colour(self.more_reds)
        result = self.gui.find_all(BinaryRegionFinder(reds))
        expected = [Location(0,0, w=2, h=1, parent=self.screen)]
        self.assertListEqual(result, expected)


    def test_save(self):
        self.V._save('test_file', np.array([0]))
        self.assertIn('test_file', self.repo.entries)


    def test_save_overwrite(self):
        self.V._save('test_file', np.array([0]))
        with self.assertRaises(KeyError):
            self.V._save('test_file', np.array([1]))


    def test_save_force(self):
        self.V._save('test_file', np.array([0]))
        self.V._save('test_file', np.array([1]), force=True)
        self.assertEqual(self.repo['test_file'].image, np.array([1]))


    def tearDown(self):
        if 'test_file' in self.repo.entries:
            del self.repo['test_file']
Beispiel #16
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)])
Beispiel #17
0
class TestViewer(unittest.TestCase):
    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 test_get_colour(self):
        red = self.V._get_colour(self.red)
        result = self.gui.find_all(BinaryRegionFinder(red))
        expected = [Location(0, 0, w=1, h=4, parent=self.screen)]
        self.assertListEqual(result, expected)

    def test_get_colour_range(self):
        reds = self.V._get_colour(self.more_reds)
        result = self.gui.find_all(BinaryRegionFinder(reds))
        expected = [Location(0, 0, w=2, h=4, parent=self.screen)]
        self.assertListEqual(result, expected)

    def test_save(self):
        self.V._save('test_file', np.array([0]))
        self.assertIn('test_file', self.repo.entries)

    def test_save_overwrite(self):
        self.V._save('test_file', np.array([0]))
        with self.assertRaises(KeyError):
            self.V._save('test_file', np.array([1]))

    def test_save_force(self):
        self.V._save('test_file', np.array([0]))
        self.V._save('test_file', np.array([1]), force=True)
        self.assertEqual(self.repo['test_file'].image, np.array([1]))

    def tearDown(self):
        if 'test_file' in self.repo.entries:
            del self.repo['test_file']
Beispiel #18
0
class TestViewer(unittest.TestCase):
    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]]])))
        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 test_get_colour(self):
        red = self.V._get_colour(self.red)
        result = self.gui.find_all(BinaryRegionFinder(red))
        expected = [Location(0,0, w=1, h=1, parent=self.screen)]
        self.assertListEqual(result, expected)
    
    
    def test_get_colour_range(self):
        reds = self.V._get_colour(self.more_reds)
        result = self.gui.find_all(BinaryRegionFinder(reds))
        expected = [Location(0,0, w=2, h=1, parent=self.screen)]
        self.assertListEqual(result, expected)
Beispiel #19
0
class TestMouseDrag(unittest.TestCase):
    def setUp(self):
        self.backend = GeistMouseBackend()
        self.gui = GUI(self.backend)

    # need ot be getting cursor position while the drag operation is happening
    # need to define functions to run concurrently
    def test_mouse_drag_y_dir(self):
        self.gui.drag(Location(200, 200), Location(201, 900))
        # this overshoots on y then goes back, not ideal!!
        positions = [
            (200, 200), (200, 250), (200, 300), (200, 350), (200, 400),
            (200, 450), (200, 500), (200, 550), (200, 600), (200, 650),
            (200, 700), (200, 750), (200, 800), (200, 850), (201, 900),
            (201, 900)
        ]
        self.assertEquals(sorted(positions),
                          sorted(self.backend.list_of_points))
        self.assertTrue(self.backend.button_down_pressed)
        self.assertTrue(self.backend.button_up_pressed)

    def test_mouse_drag_equal_dirs(self):
        self.gui.drag(Location(200, 200), Location(400, 400))
        positions = [(200, 200), (240, 240), (280, 280), (320, 320),
                     (360, 360), (400, 400), (400, 400)]
        self.assertEquals(sorted(positions),
                          sorted(self.backend.list_of_points))
        self.assertTrue(self.backend.button_down_pressed)
        self.assertTrue(self.backend.button_up_pressed)

    def test_mouse_drag_x_dir(self):
        self.gui.drag(Location(200, 200), Location(0, 200))
        positions = [(0, 200), (0, 200), (50, 200), (100, 200), (150, 200),
                     (200, 200)]
        self.assertEquals(sorted(positions),
                          sorted(self.backend.list_of_points))
        self.assertTrue(self.backend.button_down_pressed)
        self.assertTrue(self.backend.button_up_pressed)

    def test_mouse_move_increment(self):
        self.gui.drag(Location(200, 200),
                      Location(400, 400),
                      mouse_move_increment=100)
        positions = [(200, 200), (300, 300), (400, 400), (400, 400)]
        self.assertEquals(sorted(positions),
                          sorted(self.backend.list_of_points))
        self.assertTrue(self.backend.button_down_pressed)
        self.assertTrue(self.backend.button_up_pressed)
Beispiel #20
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
Beispiel #21
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)
Beispiel #22
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))
Beispiel #23
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')
Beispiel #24
0
class TestMouseDrag(unittest.TestCase):
    def setUp(self):
        self.backend = GeistMouseBackend()
        self.gui = GUI(self.backend)
                
    # need ot be getting cursor position while the drag operation is happening
    # need to define functions to run concurrently
    def test_mouse_drag_y_dir(self):
        self.gui.drag(Location(200,200), Location(201,900))
        # this overshoots on y then goes back, not ideal!!
        positions = [(200, 200), (200, 250), (200, 300), (200, 350), 
                        (200, 400), (200, 450), (200, 500), (200, 550), 
                        (200, 600), (200, 650), (200, 700), (200, 750), 
                        (200, 800), (200, 850), (201, 900), (201, 900)]
        self.assertEquals(sorted(positions), sorted(self.backend.list_of_points))
        self.assertTrue(self.backend.button_down_pressed)
        self.assertTrue(self.backend.button_up_pressed)

    def test_mouse_drag_equal_dirs(self):
        self.gui.drag(Location(200,200), Location(400, 400))
        positions = [(200,200),(240,240), (280, 280), (320, 320), (360, 360), (400,400), (400,400)]
        self.assertEquals(sorted(positions), sorted(self.backend.list_of_points))
        self.assertTrue(self.backend.button_down_pressed)
        self.assertTrue(self.backend.button_up_pressed)

    def test_mouse_drag_x_dir(self):
        self.gui.drag(Location(200,200), Location(0, 200))
        positions = [(0, 200), (0, 200), (50, 200), (100, 200), (150, 200), (200, 200)]
        self.assertEquals(sorted(positions), sorted(self.backend.list_of_points))
        self.assertTrue(self.backend.button_down_pressed)
        self.assertTrue(self.backend.button_up_pressed)
        
    def test_mouse_move_increment(self):
        self.gui.drag(Location(200,200), Location(400, 400), mouse_move_increment=100)
        positions = [(200,200), (300, 300), (400,400), (400,400)]
        self.assertEquals(sorted(positions), sorted(self.backend.list_of_points))
        self.assertTrue(self.backend.button_down_pressed)
        self.assertTrue(self.backend.button_up_pressed)        
Beispiel #25
0
 def setUp(self):
     self.backend = GeistMouseBackend()
     self.gui = GUI(self.backend)
Beispiel #26
0
class TestOperators(unittest.TestCase):
    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 test_below(self):
        expected = LocationList([
            Location(0, 24, w=5, h=5, parent=self.screen),
            Location(22, 24, w=5, h=5, parent=self.screen)])
        finder = LocationOperatorFinder(LocationList(self.locs_b), below,
                                        self.locs_a)
        actual = self.gui.find_all(finder)
        self.assertListEqual(actual, expected)

    def test_left_of(self):
        expected = LocationList([
            Location(0, 2, w=5, h=5, parent=self.screen),
            Location(0, 24, w=5, h=5, parent=self.screen)])
        finder = LocationOperatorFinder(LocationList(self.locs_b), left_of,
                                        self.locs_a)
        actual = self.gui.find_all(finder)
        self.assertListEqual(actual, expected)

    def test_right_of(self):
        self.maxDiff = None
        expected = LocationList([
            Location(22, 2, w=5, h=5, parent=self.screen),
            Location(22, 24, w=5, h=5, parent=self.screen),
        ])
        finder = LocationOperatorFinder(LocationList(self.locs_b), right_of,
                                        self.locs_a)
        actual = self.gui.find_all(finder)
        self.assertListEqual(actual, expected)

    def test_and(self):
        below_and_left = below & left_of
        expected = [Location(0, 24, w=5, h=5, parent=self.screen)]
        finder = LocationOperatorFinder(self.locs_b, below_and_left,
                                        self.locs_a)
        actual = self.gui.find_all(finder)
        self.assertListEqual(actual, expected)

    def test_invert(self):
        not_below = ~below
        expected = [Location(0, 2, w=5, h=5, parent=self.screen),
                    Location(22, 2, w=5, h=5, parent=self.screen)]
        finder = LocationOperatorFinder(self.locs_b, not_below, self.locs_a)
        actual = self.gui.find_all(finder)
        self.assertListEqual(actual, expected)

    def test_or(self):
        below_or_left = below | left_of
        expected = [Location(0, 2, w=5, h=5, parent=self.screen),
                    Location(0, 24, w=5, h=5, parent=self.screen),
                    Location(22, 24, w=5, h=5, parent=self.screen)]
        finder = LocationOperatorFinder(self.locs_b, below_or_left,
                                        self.locs_a)
        actual = self.gui.find_all(finder)
        self.assertListEqual(actual, expected)
Beispiel #27
0
class TestOperators(unittest.TestCase):
    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 test_below(self):
        expected = LocationList([
            Location(0, 24, w=5, h=5, parent=self.screen),
            Location(22, 24, w=5, h=5, parent=self.screen)
        ])
        finder = LocationOperatorFinder(LocationList(self.locs_b), below,
                                        self.locs_a)
        actual = self.gui.find_all(finder)
        self.assertListEqual(actual, expected)

    def test_left_of(self):
        expected = LocationList([
            Location(0, 2, w=5, h=5, parent=self.screen),
            Location(0, 24, w=5, h=5, parent=self.screen)
        ])
        finder = LocationOperatorFinder(LocationList(self.locs_b), left_of,
                                        self.locs_a)
        actual = self.gui.find_all(finder)
        self.assertListEqual(actual, expected)

    def test_right_of(self):
        self.maxDiff = None
        expected = LocationList([
            Location(22, 2, w=5, h=5, parent=self.screen),
            Location(22, 24, w=5, h=5, parent=self.screen),
        ])
        finder = LocationOperatorFinder(LocationList(self.locs_b), right_of,
                                        self.locs_a)
        actual = self.gui.find_all(finder)
        self.assertListEqual(actual, expected)

    def test_and(self):
        below_and_left = below & left_of
        expected = [Location(0, 24, w=5, h=5, parent=self.screen)]
        finder = LocationOperatorFinder(self.locs_b, below_and_left,
                                        self.locs_a)
        actual = self.gui.find_all(finder)
        self.assertListEqual(actual, expected)

    def test_invert(self):
        not_below = ~below
        expected = [
            Location(0, 2, w=5, h=5, parent=self.screen),
            Location(22, 2, w=5, h=5, parent=self.screen)
        ]
        finder = LocationOperatorFinder(self.locs_b, not_below, self.locs_a)
        actual = self.gui.find_all(finder)
        self.assertListEqual(actual, expected)

    def test_or(self):
        below_or_left = below | left_of
        expected = [
            Location(0, 2, w=5, h=5, parent=self.screen),
            Location(0, 24, w=5, h=5, parent=self.screen),
            Location(22, 24, w=5, h=5, parent=self.screen)
        ]
        finder = LocationOperatorFinder(self.locs_b, below_or_left,
                                        self.locs_a)
        actual = self.gui.find_all(finder)
        self.assertListEqual(actual, expected)
Beispiel #28
0
 def setUp(self):
     self.gui = GUI(GeistFakeBackend())
Beispiel #29
0
 def setUp(self):
     self.gui = GUI(GeistFakeBackend())
Beispiel #30
0
 def setUp(self):
     self.backend = GeistMouseBackend()
     self.gui = GUI(self.backend)
Beispiel #31
0
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)