Example #1
0
def test_wait_for_object_by_string_data_with_searching_area_negative():
    with pytest.raises(vhat_client.LookupError) as exc:
        obj = hmi.wait_for_object(icon)
        top_left, bottom_right = get_negative_top_left_bottom_right_from_object(
            obj)
        hmi.wait_for_object(icon, DEF_TIMEOUT, top_left, bottom_right)
    logging.exception(exc)
Example #2
0
def test_neg_invalid_rectangle_coordinates_for_wildcard(test_data):
    top_left_coordinate, bottom_right_coordinate = test_data
    wildcard = vhat_client.Wildcard(*data(path, 'wildcard_test_data'))

    with pytest.raises(vhat_client.InvalidRectangleCoordinates) as exc:
        hmi.wait_for_object(wildcard, DEF_TIMEOUT, top_left_coordinate,
                            bottom_right_coordinate)
    logging.exception(exc)
Example #3
0
 def wait_for_page_to_load(self):
     for indicator in self._load_indicators:
         try:
             wait_for_object(indicator)
             return
         except vhat_client.LookupError:
             pass
     raise PageNotLoadedError('{} page unable to open'.format(
         self.__class__.__name__))
Example #4
0
def test_wildcard_wait_for_object():
    wildcard_data = data(path, 'wildcard_test_data')
    wildcard = vhat_client.Wildcard(*wildcard_data)
    check_wildcard_results_amount(wildcard.getMatchObjects(), wildcard_data, 2)

    try:
        hmi.wait_for_object(wildcard)
    except vhat_client.LookupError:
        assert False, 'Failed waitForObject for wildcard with params {}'.format(
            wildcard_data)
Example #5
0
 def _try_to_recognize(self, current, total):
     try:
         hmi.wait_for_object(self.name)
         self.success += 1
         logging.info('{} object recognized {} times'.format(
             self.name, self.success))
     except LookupError:
         self.fail += 1
         logging.warning('{} object not recognized {} times'.format(
             self.name, self.fail))
Example #6
0
def test_wildcard_wait_for_object_with_searching_area_negative():
    wildcard_data = data(path, 'wildcard_test_data')
    wildcard = vhat_client.Wildcard(*wildcard_data)
    # to check several results
    check_wildcard_results_amount(wildcard.getMatchObjects(), wildcard_data, 2)

    with pytest.raises(vhat_client.LookupError) as exc:
        obj = hmi.wait_for_object(wildcard)
        top_left, bottom_right = get_negative_top_left_bottom_right_from_object(
            obj)
        hmi.wait_for_object(wildcard, DEF_TIMEOUT, top_left, bottom_right)
    logging.exception(exc)
Example #7
0
def test_wildcard_wait_for_object_with_searching_area_positive():
    wildcard_data = data(path, 'wildcard_test_data')
    wildcard = vhat_client.Wildcard(*wildcard_data)
    # to check several results
    check_wildcard_results_amount(wildcard.getMatchObjects(), wildcard_data, 2)

    try:
        obj = hmi.wait_for_object(wildcard)
        top_left, bottom_right = get_top_left_bottom_right_from_object(obj)
        hmi.wait_for_object(wildcard, DEF_TIMEOUT, top_left, bottom_right)
    except vhat_client.LookupError:
        assert False, 'Failed waitForObject for wildcard with params {}'.format(
            data(path, 'wildcard_test_data'))
Example #8
0
def get_coordinates_of_text_on_page():
    target = hmi.wait_for_object(check_object)
    # get left-up and right-down coordinates text +- 2pc as a recognition distance buffer
    recognition_distance_buffer = 2
    x1 = int(target.x - target.width / 2 - recognition_distance_buffer)
    y1 = int(target.y - target.height / 2 - recognition_distance_buffer)
    x2 = int(target.x + target.width / 2 + recognition_distance_buffer)
    y2 = int(target.y + target.height / 2 + recognition_distance_buffer)
    return [x1, y1, x2, y2]
Example #9
0
def check_active_in_list(name, width, height):
    wildcard_data = {
        "sync_collection_mode": vhat_client.CollectionMode.ANY,
        "name": name
    }
    wildcard = vhat_client.Wildcard(wildcard_data)
    # to ensure list contains several items
    check_wildcard_results_amount(wildcard.getMatchObjects(), wildcard_data, 3)
    obj = hmi.wait_for_object(wildcard)
    assert obj.width == width and obj.height == height
Example #10
0
def get_coordinates_rectangle_for_empty_area():
    target = hmi.wait_for_object(check_object)
    # get right-down coordinates Sound text
    # and use this point as left-up coordinate for rectangle in empty area
    empty_area_size = 5
    x1 = int(target.x + target.width / 2)
    y1 = int(target.y + target.height / 2)
    x2 = x1 + empty_area_size
    y2 = y1 + empty_area_size
    return [x1, y1, x2, y2]
Example #11
0
def test_wait_for_object_by_object_data(object_data):
    obj = hmi.wait_for_object(*object_data)
    assert isinstance(obj, object)
Example #12
0
def tap(name):
    """ Tap on object if it visible. """
    obj = hmi.wait_for_object(name)
    hmi.tap_object(obj)
    sleep(2)
    logging.info("Tap on {} with coordinates x:{}, y:{}".format(name, obj.x, obj.y))
Example #13
0
def test_wildcard_wait_for_object_no_text_detected():
    wildcard_data = {"name": data(path, 'text')}
    wildcard = vhat_client.Wildcard(wildcard_data)
    check_wildcard_results_amount(wildcard.getMatchObjects(), wildcard_data, 0)
    with pytest.raises(vhat_client.LookupError):
        hmi.wait_for_object(wildcard)
Example #14
0
def test_wait_for_object_by_string_data(string_data):
    obj = hmi.wait_for_object(*string_data)
    assert isinstance(obj, vhat_client.object)
Example #15
0
def test_neg_invalid_rectangle_coordinates_for_object(test_data):
    top_left_coordinate, bottom_right_coordinate = test_data
    with pytest.raises(vhat_client.InvalidRectangleCoordinates) as exc:
        hmi.wait_for_object(icon, DEF_TIMEOUT, top_left_coordinate,
                            bottom_right_coordinate)
    logging.exception(exc)
Example #16
0
def test_wait_for_object_exceptions(exception_data):
    param, error = exception_data
    with pytest.raises(error):
        hmi.wait_for_object(param)
Example #17
0
def test_wait_for_object_by_string_data_with_searching_area_positive():
    obj = hmi.wait_for_object(icon)
    top_left, bottom_right = get_top_left_bottom_right_from_object(obj)
    result_obj = hmi.wait_for_object(icon, DEF_TIMEOUT, top_left, bottom_right)
    assert isinstance(result_obj, vhat_client.object)