def test_to_native_coordinates( orientation, device_resolution, expected_coordinates, coordinate_system): description = "{source}-{orientation}".format( source=coordinate_system.name.lower().replace("_", "-"), orientation=orientation) screenshot = cv2.imread(_find_file( "images/android/coordinates/%s-screenshot.png" % description)) icon = "images/android/coordinates/%s-reference.png" % description m = match(icon, screenshot) screenshot_x, screenshot_y = _centre_point(m.region) native_x, native_y = _to_native_coordinates( screenshot_x, screenshot_y, coordinate_system, _Dimensions(*device_resolution)) print(native_x, native_y) assert isclose(native_x, expected_coordinates[0], atol=1) assert isclose(native_y, expected_coordinates[1], atol=1)
def test_centre_point_raises(r): with pytest.raises(TypeError): _centre_point(r)
def test_centre_point(r): assert _centre_point(r) == (25, 12)