Class: BaseMonitor
- Includes:
- ReportMonitor, RoiHelper, TmcHelpers
- Defined in:
- lib/test_case/monitoring/base_monitor.rb
Direct Known Subclasses
AppleMonitor, DtaMonitor, IguideMonitor, MdnMonitor, OdnMonitor, PassportMonitor, RokuMonitor, SaraMonitor, SpecMonitor
Instance Attribute Summary collapse
-
#health_hash ⇒ Object
readonly
Returns the value of attribute health_hash.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#identity ⇒ Object
readonly
Returns the value of attribute identity.
-
#iteration ⇒ Object
readonly
Returns the value of attribute iteration.
-
#job ⇒ Object
readonly
Returns the value of attribute job.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#ssh ⇒ Object
readonly
Returns the value of attribute ssh.
-
#start_time ⇒ Object
readonly
Returns the value of attribute start_time.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#stop_time ⇒ Object
readonly
Returns the value of attribute stop_time.
Instance Method Summary collapse
- #black_screen_roi ⇒ Object
- #check_black_screen ⇒ Object
-
#check_health ⇒ Object
Should check for video displayed and then check for the guide to init.
- #check_live_video? ⇒ Boolean
- #check_menu ⇒ Object
- #check_platform ⇒ Object
- #check_power ⇒ Object
- #dut ⇒ Object
- #find_mac ⇒ Object
-
#initialize(testcase, result_hash) ⇒ BaseMonitor
constructor
A new instance of BaseMonitor.
-
#no_input_roi ⇒ Object
ROIs for no input and blackscreen.
-
#report_parental_controls(roi) ⇒ Object
Will take an roi that is meant to check for a parental control lock.
-
#server_name ⇒ Object
Public: Gets server name.
Methods included from TmcHelpers
#aws_config, #aws_create_s3_bucket, #aws_delete_s3, #aws_delete_s3_bucket, #aws_read_s3, #aws_upload_s3, #aws_write_s3, #get_clean_ocr_text, #get_readable_size, #get_readable_time, #get_string_similarity, #get_substring_similarity, #is_rating?, #is_year?, #jsonify, #pick_random, #rubify, #send_webex_alert, #to_camel_case, #to_pascal_case, #to_snake_case, #twb_case_exists?, #twb_get_case_instance_id, #twb_get_suite_instance_id, #twb_post_screenshot, #twb_post_screenshot!, #twb_post_suite, #twb_post_testcase, #twb_post_teststep, #twb_post_teststep!, #twb_prep_s3_screenshot, #twb_suite_exists?, #until_condition, #until_equals, #until_includes, #until_not_empty, #until_not_equals, #until_not_includes, #until_not_nil, #until_same, #web_delete, #web_get, #web_post, #web_put
Methods included from HttpHelper
Methods included from CsvHelper
Methods included from SshHelper
Methods included from EmailHelper
#send_email, #send_email_setup
Methods included from SnmpHelper
Methods included from ReportMonitor
#assign_email_params?, #assign_test_params, #confirm_platform, #generate_email_msg, #invalid_report, #log_hash, #send_legacy_err_hash, #set_err_result, #sword_send_results, #take_screenshot
Methods included from RoiHelper
Constructor Details
#initialize(testcase, result_hash) ⇒ BaseMonitor
Returns a new instance of BaseMonitor.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/test_case/monitoring/base_monitor.rb', line 11 def initialize(testcase, result_hash) #stuff to do when monitor created @test_case = testcase @job = @test_case.job @logger = @test_case.logger @dut = @test_case.dut @host = @test_case.host @identity = @test_case.job @health_hash = result_hash end |
Instance Attribute Details
#health_hash ⇒ Object (readonly)
Returns the value of attribute health_hash.
22 23 24 |
# File 'lib/test_case/monitoring/base_monitor.rb', line 22 def health_hash @health_hash end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
22 23 24 |
# File 'lib/test_case/monitoring/base_monitor.rb', line 22 def host @host end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
22 23 24 |
# File 'lib/test_case/monitoring/base_monitor.rb', line 22 def id @id end |
#identity ⇒ Object (readonly)
Returns the value of attribute identity.
22 23 24 |
# File 'lib/test_case/monitoring/base_monitor.rb', line 22 def identity @identity end |
#iteration ⇒ Object (readonly)
Returns the value of attribute iteration.
22 23 24 |
# File 'lib/test_case/monitoring/base_monitor.rb', line 22 def iteration @iteration end |
#job ⇒ Object (readonly)
Returns the value of attribute job.
22 23 24 |
# File 'lib/test_case/monitoring/base_monitor.rb', line 22 def job @job end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
22 23 24 |
# File 'lib/test_case/monitoring/base_monitor.rb', line 22 def logger @logger end |
#ssh ⇒ Object (readonly)
Returns the value of attribute ssh.
22 23 24 |
# File 'lib/test_case/monitoring/base_monitor.rb', line 22 def ssh @ssh end |
#start_time ⇒ Object (readonly)
Returns the value of attribute start_time.
22 23 24 |
# File 'lib/test_case/monitoring/base_monitor.rb', line 22 def start_time @start_time end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
22 23 24 |
# File 'lib/test_case/monitoring/base_monitor.rb', line 22 def status @status end |
#stop_time ⇒ Object (readonly)
Returns the value of attribute stop_time.
22 23 24 |
# File 'lib/test_case/monitoring/base_monitor.rb', line 22 def stop_time @stop_time end |
Instance Method Details
#black_screen_roi ⇒ Object
42 43 44 45 46 47 |
# File 'lib/test_case/monitoring/base_monitor.rb', line 42 def black_screen_roi # DO NOT increase similarity. The blackest of black screens are met at 94%. roi_resolution(dut.roi.color.new(:x => 0, :y => 0, :width => 1710, :height => 1080, :similarity => 94, :rgb => [0, 0, 0], :ref_img => ""), dut.height, dut.width) end |
#check_black_screen ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/test_case/monitoring/base_monitor.rb', line 74 def check_black_screen stand_by_black_screen = black_screen_roi 5.times do if stand_by_black_screen.displayed?(timeout:2000) dut.press_key('guide', sleep_time:2.sec) end break if !stand_by_black_screen.displayed?(timeout:2000) end set_err_result(@health_hash, 'Black Screen', 'B2.2') if stand_by_black_screen.displayed?(timeout:2000) # exit out of guide dut.press_key('exit', :sleep_time=>1.sec) end |
#check_health ⇒ Object
Should check for video displayed and then check for the guide to init.
98 99 100 101 102 103 104 |
# File 'lib/test_case/monitoring/base_monitor.rb', line 98 def check_health dut.press_key('exit', :sleep_time=>2.sec) set_err_result(@health_hash, "Failed to display video", 'B5') unless check_live_video? set_err_result(@health_hash, 'Failed to navigate to guide', 'B6') unless dut.screens.guide.navigate? @health_hash[:result] = 'Pass' sword_send_results(@health_hash) end |
#check_live_video? ⇒ Boolean
121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/test_case/monitoring/base_monitor.rb', line 121 def check_live_video? health_check = dut.roi.video.new(x: 0, y: 0, width: dut.width, height: dut.height, threshold: 0.1, ref_img: '') video_displayed = false chan_to_check = %w[32 101 8] chan_to_check.each do |ch| ch.split('').each { |d| dut.press_key(d, sleep_time: 500) } dut.press_key('select', :sleep_time=>2.sec) return true if health_check.displayed?(timeout:10.sec, verifies_for: 2.sec) end false end |
#check_menu ⇒ Object
87 88 89 90 |
# File 'lib/test_case/monitoring/base_monitor.rb', line 87 def @health_hash # override to check menu end |
#check_platform ⇒ Object
106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/test_case/monitoring/base_monitor.rb', line 106 def check_platform platform = dut.platform.downcase name = dut.name.downcase supported_plats = %w[odn spectrum roku iguide apple passport sara mdn dta] # add to this as we add more platforms bad_names = %w[no bad change unused] check = supported_plats.select { |el| platform.downcase.include?(el) } bad = bad_names.select { |el| name.downcase.include?(el) } bad_platform = bad_names.select { |el| platform.downcase.include?(el) } # Cases of 'Unused, Bad' etc found in platform too. set_err_result(@health_hash, 'Invalid Platform..Health check unsupported platform', 'B1.1') if check.empty? # array is empty if current platform supported set_err_result(@health_hash, "Invalid Device/No Device. Name is #{dut.name}", 'B1.2') unless bad.empty? set_err_result(@health_hash, 'Invalid Platform Name for Slot', 'B1.3') unless bad_platform.empty? end |
#check_power ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/test_case/monitoring/base_monitor.rb', line 49 def check_power logger.info('Ensuring STB has soft power') # Navigate to the guide to ensure a non-black screen dut.press_key('exit', :sleep_time=>1.sec) dut.press_key('exit', :sleep_time=>1.sec) dut.press_key('guide', :sleep_time=>2.sec) stand_by_noinput = no_input_roi tries = 0 loop do # check standby tries += 1 # if standby power on nav to guide if stand_by_noinput.displayed? dut.press_key('power', :sleep_time=>5.sec) dut.press_key('guide', :sleep_time=>2.sec) end # check again break if !stand_by_noinput.displayed?(timeout:3000) || tries >= 5 end set_err_result(@health_hash, 'No Input Signal', 'B2.1') if stand_by_noinput.displayed?(timeout: 3000) check_black_screen end |
#dut ⇒ Object
24 25 26 |
# File 'lib/test_case/monitoring/base_monitor.rb', line 24 def dut @dut end |
#find_mac ⇒ Object
92 93 94 95 |
# File 'lib/test_case/monitoring/base_monitor.rb', line 92 def find_mac # should just call the platform specific version # does nothing in base monitor end |
#no_input_roi ⇒ Object
ROIs for no input and blackscreen
35 36 37 38 39 40 |
# File 'lib/test_case/monitoring/base_monitor.rb', line 35 def no_input_roi roi_resolution(dut.roi.text.new(:x => 530, :y => 446, :width => 908, :height => 144, :similarity => 70, :text => ['No Input Signal', 'No Signal', 'Unsupported Signal'], :only_digits => false, :ref_img => ""), dut.height, dut.width) end |
#report_parental_controls(roi) ⇒ Object
Will take an roi that is meant to check for a parental control lock. If found, set the err result.
roi - Text ROI to be checked.
137 138 139 |
# File 'lib/test_case/monitoring/base_monitor.rb', line 137 def report_parental_controls(roi) set_err_result(@health_hash, 'Parental Lock Found', 'B4') if roi.displayed? end |
#server_name ⇒ Object
Public: Gets server name.
Returns the String name of the TMC server.
30 31 32 |
# File 'lib/test_case/monitoring/base_monitor.rb', line 30 def server_name server_info['name'] end |