Module: KrakenMobile::Protocol::FileProtocol
- Included in:
- Runner::MonkeyRunner
- Defined in:
- lib/kraken-mobile/protocols/file_protocol.rb
Instance Method Summary collapse
-
#build_scenario_id(scenario) ⇒ Object
helpers.
- #devices_ready_start(devices_manager, scenario_id) ⇒ Object
- #devices_ready_to_finish(devices_manager, scenario_id) ⇒ Object
- #end_setup(channel, scenario) ⇒ Object
- #feature_tags(scenario) ⇒ Object
- #ordered_feature_tags(scenario) ⇒ Object
- #readAnySignal(channel, timeout) ⇒ Object
- #readLastSignal(channel) ⇒ Object
- #readSignal(channel, content, timeout) ⇒ Object
- #readSignalWithKeyworkd(channel, keyword, timeout) ⇒ Object
- #start_setup(channel, scenario) ⇒ Object
- #writeSignal(channel, content) ⇒ Object
- #writeSignalToAll(content) ⇒ Object
- #writeSignalToAnyDevice(content) ⇒ Object
Instance Method Details
#build_scenario_id(scenario) ⇒ Object
helpers
87 88 89 90 91 92 |
# File 'lib/kraken-mobile/protocols/file_protocol.rb', line 87 def build_scenario_id scenario location = scenario.location.to_s index_of_line_number_start = location.index(":") real_location = location[0..index_of_line_number_start-1] Digest::SHA256.hexdigest(real_location) end |
#devices_ready_start(devices_manager, scenario_id) ⇒ Object
117 118 119 |
# File 'lib/kraken-mobile/protocols/file_protocol.rb', line 117 def devices_ready_start devices_manager, scenario_id devices_manager.connected_devices.select { |device| devices_manager.device_helper.read_file_content(KrakenMobile::Constants::KRAKEN_CONFIGURATION_FILE_NAME, device.id) == "ready_#{scenario_id}" } end |
#devices_ready_to_finish(devices_manager, scenario_id) ⇒ Object
121 122 123 |
# File 'lib/kraken-mobile/protocols/file_protocol.rb', line 121 def devices_ready_to_finish devices_manager, scenario_id devices_manager.connected_devices.select { |device| devices_manager.device_helper.read_file_content(KrakenMobile::Constants::KRAKEN_CONFIGURATION_FILE_NAME, device.id) == "end_#{scenario_id}" } end |
#end_setup(channel, scenario) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/kraken-mobile/protocols/file_protocol.rb', line 73 def end_setup channel, scenario devices_manager = DevicesHelper::Manager.new({runner: ENV["RUNNER"], config_path: ENV["CONFIG_PATH"]}) device_id = channel_to_device_id(channel) scenario_id = build_scenario_id(scenario) devices_manager.device_helper.write_content_to_file "end_#{scenario_id}", KrakenMobile::Constants::KRAKEN_CONFIGURATION_FILE_NAME, device_id = scenario while true compare_criteria = devices_manager.connected_devices.count >= .count ? .count : devices_manager.connected_devices.count break if devices_ready_to_finish(devices_manager, scenario_id).count >= compare_criteria sleep(1) end end |
#feature_tags(scenario) ⇒ Object
94 95 96 97 98 99 100 101 102 |
# File 'lib/kraken-mobile/protocols/file_protocol.rb', line 94 def scenario tag_objects = scenario.feature.children.map { |e| e. if e. }.compact = [] tag_objects.each do |tag_object| names = tag_object.map { |tag| tag.name if tag.name } .concat names end .uniq.select{ |tag| tag.start_with? "@user" }.sort end |
#ordered_feature_tags(scenario) ⇒ Object
104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/kraken-mobile/protocols/file_protocol.rb', line 104 def scenario = scenario = [] .count.times do |index| if [index].include? "@user#{index+1}" << [index] else break end end end |
#readAnySignal(channel, timeout) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/kraken-mobile/protocols/file_protocol.rb', line 23 def readAnySignal(channel, timeout) devices_helper = DevicesHelper::Manager.new({runner: ENV["RUNNER"], config_path: ENV["CONFIG_PATH"]}).device_helper device_id = channel_to_device_id(channel) Timeout::timeout(timeout, RuntimeError) do sleep(1) until devices_helper.read_file_content(KrakenMobile::Constants::DEVICE_INBOX_NAME, device_id) != "" end end |
#readLastSignal(channel) ⇒ Object
17 18 19 20 21 |
# File 'lib/kraken-mobile/protocols/file_protocol.rb', line 17 def readLastSignal(channel) devices_helper = DevicesHelper::Manager.new({runner: ENV["RUNNER"], config_path: ENV["CONFIG_PATH"]}).device_helper device_id = channel_to_device_id(channel) devices_helper.read_file_content(KrakenMobile::Constants::DEVICE_INBOX_NAME, device_id) end |
#readSignal(channel, content, timeout) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/kraken-mobile/protocols/file_protocol.rb', line 9 def readSignal(channel, content, timeout) devices_helper = DevicesHelper::Manager.new({runner: ENV["RUNNER"], config_path: ENV["CONFIG_PATH"]}).device_helper device_id = channel_to_device_id(channel) Timeout::timeout(timeout, RuntimeError) do sleep(1) until devices_helper.read_file_content(KrakenMobile::Constants::DEVICE_INBOX_NAME, device_id) == content end end |
#readSignalWithKeyworkd(channel, keyword, timeout) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/kraken-mobile/protocols/file_protocol.rb', line 31 def readSignalWithKeyworkd(channel, keyword, timeout) devices_helper = DevicesHelper::Manager.new({runner: ENV["RUNNER"], config_path: ENV["CONFIG_PATH"]}).device_helper device_id = channel_to_device_id(channel) Timeout::timeout(timeout, RuntimeError) do sleep(1) until devices_helper.read_file_content(KrakenMobile::Constants::DEVICE_INBOX_NAME, device_id).include?(keyword) return devices_helper.read_file_content(KrakenMobile::Constants::DEVICE_INBOX_NAME, device_id) end end |
#start_setup(channel, scenario) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/kraken-mobile/protocols/file_protocol.rb', line 60 def start_setup channel, scenario devices_manager = DevicesHelper::Manager.new({runner: ENV["RUNNER"], config_path: ENV["CONFIG_PATH"]}) device_id = channel_to_device_id(channel) scenario_id = build_scenario_id(scenario) devices_manager.device_helper.write_content_to_file "ready_#{scenario_id}", KrakenMobile::Constants::KRAKEN_CONFIGURATION_FILE_NAME, device_id = scenario while true compare_criteria = devices_manager.connected_devices.count >= .count ? .count : devices_manager.connected_devices.count break if devices_ready_start(devices_manager, scenario_id).count >= compare_criteria sleep(1) end end |
#writeSignal(channel, content) ⇒ Object
40 41 42 43 44 |
# File 'lib/kraken-mobile/protocols/file_protocol.rb', line 40 def writeSignal(channel, content) devices_helper = DevicesHelper::Manager.new({runner: ENV["RUNNER"], config_path: ENV["CONFIG_PATH"]}).device_helper device_id = channel_to_device_id(channel) devices_helper.write_content_to_file(content, KrakenMobile::Constants::DEVICE_INBOX_NAME, device_id) end |
#writeSignalToAll(content) ⇒ Object
46 47 48 49 50 51 |
# File 'lib/kraken-mobile/protocols/file_protocol.rb', line 46 def writeSignalToAll(content) devices_manager = DevicesHelper::Manager.new({runner: ENV["RUNNER"], config_path: ENV["CONFIG_PATH"]}) devices_manager.connected_devices.each do |device| devices_manager.device_helper.write_content_to_file(content, KrakenMobile::Constants::DEVICE_INBOX_NAME, device.id) end end |
#writeSignalToAnyDevice(content) ⇒ Object
53 54 55 56 57 58 |
# File 'lib/kraken-mobile/protocols/file_protocol.rb', line 53 def writeSignalToAnyDevice(content) devices_manager = DevicesHelper::Manager.new({runner: ENV["RUNNER"], config_path: ENV["CONFIG_PATH"]}) device = devices_manager.connected_devices.sample devices_manager.device_helper.write_content_to_file(content, KrakenMobile::Constants::DEVICE_INBOX_NAME, device.id) device end |