Class: ISandBoxHelper::ISandboxOperator

Inherits:
Object
  • Object
show all
Defined in:
lib/common/isandbox_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeISandboxOperator

Returns a new instance of ISandboxOperator.



155
156
157
158
159
160
161
162
163
# File 'lib/common/isandbox_helper.rb', line 155

def initialize
    fail 'ifuse must be install' unless ifuse_exist?
    # @caps = ConfigHelper::CONF["appium_driver"]["caps"]
    # @udid = @caps["udid"]
    @udid = `idevice_id -l`.split(' ')[0]
    @container = 'com.taobao.alitrip'
    $has_instance = self
    self
end

Instance Attribute Details

#containerObject

Returns the value of attribute container.



153
154
155
# File 'lib/common/isandbox_helper.rb', line 153

def container
  @container
end

#tmp_folder_nameObject

Returns the value of attribute tmp_folder_name.



151
152
153
# File 'lib/common/isandbox_helper.rb', line 151

def tmp_folder_name
  @tmp_folder_name
end

#udidObject

Returns the value of attribute udid.



152
153
154
# File 'lib/common/isandbox_helper.rb', line 152

def udid
  @udid
end

Instance Method Details

#exec_cmd(cmd) ⇒ Object



184
185
186
# File 'lib/common/isandbox_helper.rb', line 184

def exec_cmd(cmd)
    system cmd
end

#ifuse_exist?Boolean

检测用户电脑上是否存在 ifuse

Returns:

  • (Boolean)


189
190
191
# File 'lib/common/isandbox_helper.rb', line 189

def ifuse_exist?
    exec_cmd('ifuse -h > /dev/null 2>&1')
end

#mountObject



165
166
167
168
169
170
171
172
173
174
# File 'lib/common/isandbox_helper.rb', line 165

def mount
    @tmp_folder_name = Time.new.to_i.to_s
    exec_cmd "mkdir #{@tmp_folder_name}" unless File.exists? @tmp_folder_name
    exec_cmd "ifuse -u #{@udid} --container #{@container} #{@tmp_folder_name}"
    @flag_folder = @tmp_folder_name + '/tmp'
    while true
        break if File.directory? @flag_folder
    end
    @has_mount = true
end

#umountObject



176
177
178
179
180
181
182
# File 'lib/common/isandbox_helper.rb', line 176

def umount
    exec_cmd "umount #{@tmp_folder_name}"
    while true
        break unless File.directory? @flag_folder
    end
    exec_cmd "rm -rf #{@tmp_folder_name}"
end