Method: ImageRoi#time_to_change

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

#time_to_change(args = {}) ⇒ Object

Public: Measures the approximate time for the given image Roi to change.

Corresponds to: api_time_for_screen_to_change

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

If default, no key will be pressed.

delay - Integer total milliseconds to delay before starting evaluation (default: 0). timeout - Integer total milliseconds to allow before timing out (default: nil).

If default, timeout will be calculated as [ delay + 5000 ].

scale - Boolean if the larger image should be scaled to the size of the smaller image (default: false). priority - Symbol evaluation priority used to throttle CPU usage (default: :normal):

:critical   - Sleep 10 ms between intensive tasks (USE SPARINGLY)
:high       - Sleep 100 ms between intensive tasks
:normal     - Sleep 1 second between intensive tasks
:low        - Sleep 10 seconds between intensive tasks
:background - Sleep 1 minute between intensive tasks (USE SPARINGLY)

log_every - Integer total milliseconds between logs (default: 1000). report - Boolean indicating whether to report measurements to ITMS (default: true).

Returns the Float total milliseconds for the image Roi to change.



114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/roi/image/image_roi.rb', line 114

def time_to_change(args={})
  logger.info('Measuring time for image to change')
  scale = args.fetch(:scale, false)
  next_img = dut.capture_screen
  measure(args) do
    roi = to_json(ref_img: next_img)
    json = get_json_for_match_2(roi, roi, scale: scale)
    resp = test_case.send(:tmc_post, "/api/roi/image/actions/#{dut.id}", json: json)
    result = !resp['value']
    logger.roi(self, args.merge(message: "Image #{result ? 'changed' : 'did not change'}", use_last_image: true))
    result
  end
end