Module: Appium::Core::Ios::Xcuitest::Device::Performance

Defined in:
lib/appium_lib_core/ios/xcuitest/device/performance.rb

Class Method Summary collapse

Class Method Details

.add_methodsObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/appium_lib_core/ios/xcuitest/device/performance.rb', line 21

def self.add_methods
  ::Appium::Core::Device.add_endpoint_method(:start_performance_record) do
    def start_performance_record(timeout: 300_000, profile_name: 'Activity Monitor', pid: nil)
      option = {}
      option[:timeout] = timeout
      option[:profileName] = profile_name
      option[:pid] = pid if pid

      execute_script 'mobile: startPerfRecord', option
    end
  end

  ::Appium::Core::Device.add_endpoint_method(:get_performance_record) do
    def get_performance_record(save_file_path: './performance', profile_name: 'Activity Monitor',
                               remote_path: nil, user: nil, pass: nil, method: 'PUT',
                               file_field_name: nil, form_fields: nil, headers: nil)
      option = ::Appium::Core::Base::Device::ScreenRecord.new(
        remote_path: remote_path, user: user, pass: pass, method: method,
        file_field_name: file_field_name, form_fields: form_fields, headers: headers
      ).upload_option

      option[:profileName] = profile_name
      result = execute_script 'mobile: stopPerfRecord', option

      File.open("#{save_file_path}.zip", 'wb') { |f| f << result.unpack('m')[0] }
    end
  end
end