Class: AppleMonitor

Inherits:
BaseMonitor show all
Defined in:
lib/test_case/monitoring/apple_monitor.rb

Instance Attribute Summary

Attributes inherited from BaseMonitor

#health_hash, #host, #id, #identity, #iteration, #job, #logger, #ssh, #start_time, #status, #stop_time

Instance Method Summary collapse

Methods inherited from BaseMonitor

#black_screen_roi, #check_black_screen, #check_live_video?, #check_platform, #dut, #initialize, #no_input_roi, #report_parental_controls, #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

#web_request

Methods included from CsvHelper

#csv_parse, #csv_read

Methods included from SshHelper

#ssh_to

Methods included from EmailHelper

#send_email, #send_email_setup

Methods included from SnmpHelper

#snmp_get, #snmp_set

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

#roi_resolution

Constructor Details

This class inherits a constructor from BaseMonitor

Instance Method Details

#apple_homeObject

ROI’s



6
7
8
# File 'lib/test_case/monitoring/apple_monitor.rb', line 6

def apple_home
  dut.roi.color.new(:x => 10, :y => 10, :width => 72, :height => 84, :similarity => 90, :rgb => [185, 187, 197], :ref_img => "")
end

#apple_modelObject



26
27
28
# File 'lib/test_case/monitoring/apple_monitor.rb', line 26

def apple_model
  dut.roi.text.new(:x => 1322, :y => 286, :width => 502, :height => 60, :similarity => 70, :text => '', :only_digits => false, :ref_img => "")
end

#apple_snObject



30
31
32
# File 'lib/test_case/monitoring/apple_monitor.rb', line 30

def apple_sn
  dut.roi.text.new(:x => 1322, :y => 360, :width => 502, :height => 60, :similarity => 70, :text => '', :only_digits => false, :ref_img => "")
end

#check_healthObject

Should do nothing since we don’t need to check guide or live tv



49
50
51
# File 'lib/test_case/monitoring/apple_monitor.rb', line 49

def check_health
  
end

#check_menuObject



53
54
55
56
57
58
# File 'lib/test_case/monitoring/apple_monitor.rb', line 53

def check_menu
  app_home = roi_resolution(apple_home, dut.height, dut.width)
  set_err_result(@health_hash, 'Unable to nav to menu. Check platform or device health', 'A3.1') unless app_home.press_key_until_displayed?('menu', presses: 12, timeout: 12.sec, try_every: 1.sec)

  [nav_to_setting, nav_to_about].select { |a| return a unless a.nil? }[0]
end

#check_powerObject



42
43
44
45
46
47
# File 'lib/test_case/monitoring/apple_monitor.rb', line 42

def check_power
  dut.press_key('exit', :sleep_time=>1.sec)
  dut.press_key('exit', :sleep_time=>1.sec)
  dut.press_key('menu', :sleep_time=>2.sec)
  super
end

#find_macObject



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/test_case/monitoring/apple_monitor.rb', line 86

def find_mac
  url = take_screenshot
  # if result.length > 0
  #   return {result: result, url: url}
  # end
  apple_model_roi = roi_resolution(apple_model, dut.height, dut.width)
  apple_sn_roi = roi_resolution(apple_sn, dut.height, dut.width)
  ip_add_roi = roi_resolution(ip_add, dut.height, dut.width)
  mac_add_roi = roi_resolution(mac_add, dut.height, dut.width)
  @health_hash[:sn] = apple_sn_roi.retrieve.gsub(',', '').strip,
  @health_hash[:model] = apple_model_roi.retrieve
  @health_hash[:ip] = ip_add_roi.retrieve
  @health_hash[:mac] = mac_add_roi.retrieve.upcase.gsub(':', '').gsub(' ', '')
  @health_hash[:url] = url
  

  @health_hash
end

#general_selectedObject



22
23
24
# File 'lib/test_case/monitoring/apple_monitor.rb', line 22

def general_selected
  dut.roi.color.new(:x => 1698, :y => 200, :width => 46, :height => 30, :similarity => 90, :rgb => [237, 242, 244], :ref_img => "")
end

#home_rowObject



10
11
12
# File 'lib/test_case/monitoring/apple_monitor.rb', line 10

def home_row
  dut.roi.text.new(:x => 62, :y => 930, :width => 1608, :height => 44, :similarity => 70, :text => '', :only_digits => false, :ref_img => "")
end

#ip_addObject



34
35
36
# File 'lib/test_case/monitoring/apple_monitor.rb', line 34

def ip_add
  dut.roi.text.new(:x => 1322, :y => 600, :width => 502, :height => 60, :similarity => 70, :text => '', :only_digits => false, :ref_img => "")
end

#mac_addObject



38
39
40
# File 'lib/test_case/monitoring/apple_monitor.rb', line 38

def mac_add
  dut.roi.text.new(:x => 1390, :y => 696, :width => 448, :height => 62, :similarity => 70, :text => '', :only_digits => false, :ref_img => "")
end


74
75
76
77
78
79
80
81
82
83
84
# File 'lib/test_case/monitoring/apple_monitor.rb', line 74

def nav_to_about
  setting_home_roi = roi_resolution(setting_home, dut.height, dut.width)
  general_selected_roi = roi_resolution(general_selected, dut.height, dut.width)
  set_err_result(@health_hash, 'Not at settings', 'A3.4') unless setting_home_roi.press_key_until_displayed?('select', presses: 3, timeout: 4000, try_every: 750)

  general_selected_roi.press_key_until_displayed?('up_arrow', presses: 10, timeout: 10_000, try_every: 1000)
  setting_home_roi.text = 'About'
  set_err_result(@health_hash, 'Failed to nav to About Page', 'A3.5') unless setting_home_roi.press_key_until_displayed?('select', presses: 6, timeout:6000, try_every: 750)
  
  nil
end


60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/test_case/monitoring/apple_monitor.rb', line 60

def nav_to_setting
  settings_txt_roi = roi_resolution(home_row, dut.height, dut.width)
  # make sure we are at left most part of menu
  4.times { dut.press_key('left_arrow', sleep_time: 500) }
  if dut.height == 1080
    setting_home_roi = setting_img_1080
    set_err_result(@health_hash, 'Could not nav to settings', 'A3.2') unless setting_home_roi.press_key_until_displayed?('down_arrow', presses: 5, timeout: 15.sec, try_every: 3.sec)
  else
    # need to make 720 roi?
  end
  settings_txt_roi.text = 'Settings'
  set_err_result(@health_hash, 'had trouble navigating to settings', 'A3.3') unless settings_txt_roi.press_key_until_displayed?('right_arrow', presses: 5, timeout: 5.sec, try_every: 750)
end

#setting_homeObject



18
19
20
# File 'lib/test_case/monitoring/apple_monitor.rb', line 18

def setting_home
  dut.roi.text.new(:x => 828, :y => 58, :width => 260, :height => 66, :similarity => 70, :text => 'Settings', :only_digits => false, :ref_img => "")
end

#setting_img_1080Object



14
15
16
# File 'lib/test_case/monitoring/apple_monitor.rb', line 14

def setting_img_1080
  dut.roi.image.new(:x => 58, :y => 706, :width => 1616, :height => 58, :similarity => 90, :img_x => 58, :img_y => 726, :img_width => 342, :img_height => 38, :ref_img => "tsimages/reference/apple_tv/settings.jpg")
end