Method: ImageRoi#displayed?

Defined in:
lib/roi/image/image_roi.rb

#displayed?(args = {}) ⇒ Boolean

Public: Checks if image is displayed as defined in the given ROI.

Corresponds to: api_is_image_area_displayed??

key - String name of key to press to trigger evaluation (default: nil).

If default, no keys will be pressed.

delay - Integer total milliseconds to delay before starting evaluation (default: 0). timeout - Integer total milliseconds to allow before timing out (default: 0). scale - Boolean if the larger image should be scaled to the size of the smaller image (default: false). verifies_for - Integer total milliseconds for which the ROI must verify in order to succeed (default: 0).

If default, the ROI must only verify once.

priority - Symbol representing evaluation priority used to throttle CPU usage (default: :normal):

:critical   - Sleep 10 milliseconds between intensive tasks (should be used sparingly).
:high       - Sleep 100 milliseconds between intensive tasks.
:normal     - Sleep 1 second between intensive tasks (default).
:low        - Sleep 10 seconds between intensive tasks.
:background - Sleep 1 minute between intensive tasks (should be used sparingly).

log_every - Integer interval in milliseconds between logs (default: 1000). ref_img - String path to reference image to override the one in the Roi (default: nil).

Returns a Boolean true if image is displayed before the timeout, otherwise false.



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/roi/image/image_roi.rb', line 65

def displayed?(args={})
  logger.info('Checking if image area is displayed')
  scale = args.fetch(:scale, false)
  frame = args[:frame]
  ref_img_json = ref_img_roi_to_json(ref_img: args[:ref_img])
  verify(args) do
    if frame.nil?
      right_roi = to_json
      json = get_json_for_match_2(ref_img_json, right_roi, scale: scale)
      result = test_case.send(:tmc_post, "/api/roi/image/actions/#{dut.slot}", json: json)['value']
      logger.roi(self, args.merge(message: "Image is#{result ? '' : ' not'} displayed on screen",
                                  use_last_image: true))
    else
      right_roi = to_json(ref_img: frame)
      json = get_json_for_match_2(ref_img_json, right_roi, scale: scale)
      result = test_case.send(:tmc_post, '/api/roi/image/actions', json: json)['value']
      logger.roi(self, args.merge(message: "Image is#{result ? '' : ' not'} displayed in frame", screenshot: false))
    end
    result
  end
end