def test_comparison_same_part_screenshots(copy_test_files_to_board): path_1, path_2 = get_path_for_images() # add equal images to compare discrepancy_percentage = get_images_discrepancy(path_1, path_1, ScreenPoint(10, 10), ScreenPoint(50, 50)) assert discrepancy_percentage == 0
def get_negative_top_left_bottom_right_from_object(object): ''' Gets the coordinates of the object to search in the area where this object don't exists. This function moves the existing coordinates of the object to another place so that the search in the area does not find this object again. It selects the correct direction of the move, and always returns the correct coordinates. :param object: Existing object :return: top_left and bottom_right Point ''' x_top_left, y_top_left, x_bottom_right, y_bottom_right = extract_object_coordinates( object) expand_size = 50 additional_expand = 10 expand_top, expand_left = get_possible_expand_status( x_top_left, y_top_left, expand_size) if expand_left: x_top_left -= expand_size x_bottom_right -= (expand_size - additional_expand) else: x_top_left += expand_size x_bottom_right += (expand_size + additional_expand) if expand_top: y_top_left -= expand_size y_bottom_right -= (expand_size - additional_expand) else: y_top_left += expand_size y_bottom_right += (expand_size + additional_expand) return ScreenPoint(x_top_left, y_top_left), ScreenPoint(x_bottom_right, y_bottom_right)
def test_get_image_discrepancy_coordinates_exceptions(copy_test_files_to_board, test_data): x1, y1, x2, y2, error = test_data path_1, path_2 = get_path_for_images() with pytest.raises(error): # set incorrect coordinates values get_images_discrepancy(path_1, path_1, ScreenPoint(x1, y1), ScreenPoint(x2, y2))
def test_comparison_different_whole_screenshots_if_zero_coordinates( copy_test_files_to_board): path_1, path_2 = get_path_for_images() # add equal images to compare discrepancy_percentage = get_images_discrepancy(path_1, path_2, ScreenPoint(0, 0), ScreenPoint(0, 0)) assert 0 < discrepancy_percentage <= 100
def get_top_left_bottom_right_from_object(object): ''' Gets the coordinates of the object to search in the area where this object exists. Since it is impossible to specify coordinates to search for an object already found due to an error when searching on a frame of the same size as the pattern, you need to specify a slightly larger area for the search. This function slightly expands the already known search area. It selects the correct direction of expansion, and always returns the correct coordinates. :param object: Existing object :return: top_left and bottom_right Point ''' x_top_left, y_top_left, x_bottom_right, y_bottom_right = extract_object_coordinates( object) expand_size = 10 min_expand_size = 2 expand_top, expand_left = get_possible_expand_status( x_top_left, y_top_left, expand_size) if expand_top and expand_left: y_top_left -= expand_size x_top_left -= expand_size # Be careful in the future, this hack avoids the restrictions associated with inaccurate coordinates after the search x_bottom_right += expand_size y_bottom_right += min_expand_size elif expand_top and not expand_left: y_top_left -= expand_size x_bottom_right += expand_size # Be careful in the future, this hack avoids the restrictions associated with inaccurate coordinates after the search y_bottom_right += min_expand_size elif not expand_top and expand_left: y_bottom_right += expand_size x_top_left -= expand_size # Be careful in the future, this hack avoids the restrictions associated with inaccurate coordinates after the search x_bottom_right += expand_size elif not expand_top and not expand_left: y_bottom_right += expand_size x_bottom_right += expand_size return ScreenPoint(x_top_left, y_top_left), ScreenPoint(x_bottom_right, y_bottom_right)
def test_comparison_different_part_screenshots(copy_test_files_to_board): path_1, path_2 = get_path_for_images() discrepancy_percentage = get_images_discrepancy(path_1, path_2, ScreenPoint(10, 10), ScreenPoint(50, 50)) assert 0 < discrepancy_percentage <= 100
def get_path_for_images(image1=prepared_image_name1, image2=prepared_image_name2): path_1 = '{}/{}'.format(folder_name, image1) path_2 = '{}/{}'.format(folder_name, image2) return path_1, path_2 @jira_issue("VHAT-1923", description="Issue for testset #8") @jira_test("VHAT-1922") @pytest.mark.parametrize( 'test_data', [ # image1, image2, left_point, right_point, percentage (prepared_image_name1, prepared_image_name1, ScreenPoint( 0, 0), ScreenPoint(0, 0), 0), (prepared_image_name1, 'image4.png', ScreenPoint( 0, 0), ScreenPoint(0, 0), 25), (prepared_image_name1, 'image3.png', ScreenPoint( 0, 0), ScreenPoint(0, 0), 45), (prepared_image_name1, 'image5.png', ScreenPoint( 0, 0), ScreenPoint(0, 0), 50), (prepared_image_name1, 'image6.png', ScreenPoint( 0, 0), ScreenPoint(0, 0), 75), (prepared_image_name1, 'image2.png', ScreenPoint( 0, 0), ScreenPoint(0, 0), 100), (prepared_image_name1, prepared_image_name1, ScreenPoint( 0, 0), ScreenPoint(10, 10), 0), (prepared_image_name1, prepared_image_name2, ScreenPoint( 0, 0), ScreenPoint(10, 10), 100), (prepared_image_name1, 'image3.png', ScreenPoint(
def __init__(self, x, y): vhat_ScreenPoint.__init__(self, x, y)
def wait_for_object(object_name, timeout=7000, top_left=ScreenPoint(0, 0), bottom_right=ScreenPoint(0, 0)): obj = waitForObject(object_name, timeout, top_left, bottom_right) return obj
from functional_tests.pages import hmi from functional_tests.tests.helpers import check_wildcard_results_amount from functional_tests.tests.import_helper_functions import data from functional_tests.utils.report import jira_test from functional_tests.utils.sync4.constants import TASK_LINK pytestmark = [ pytest.mark.regression_sync4, pytest.mark.regression_sync3, pytest.mark.waitForObject ] path = 'test_wait_for_object' icon = data(path, name='icon') DEF_LEFT_POINT = ScreenPoint(0, 0) DEF_RIGHT_POINT = ScreenPoint(0, 0) DEF_TIMEOUT = 1000 TEST_DATA_INVALID_RECTANGLE_COORDINATES = [ (ScreenPoint(-10, 10), DEF_RIGHT_POINT), (DEF_LEFT_POINT, ScreenPoint(10, -10)), (ScreenPoint(9999, 9999), ScreenPoint(9999, 9999)), (ScreenPoint(9999, 10), ScreenPoint(10, 10)), (ScreenPoint(10, 9999), ScreenPoint(10, 10)), (ScreenPoint(10, 9999), ScreenPoint(9999, 10)), (ScreenPoint(10, 20), ScreenPoint(15, 20)), (ScreenPoint(10, 15), ScreenPoint(10, 20)), (ScreenPoint(15, 10), ScreenPoint(15, 10)), ]