Module: Cukunity::Android::Utils

Includes:
Utils
Included in:
App, KeyboardInput, Process, TouchInput, TunnelClientMethods
Defined in:
lib/cukunity/drivers/android/utils.rb

Instance Method Summary collapse

Methods included from Utils

#check_timeout, #merge_options, #restrict_options, #to_options, #wait_connectivity

Instance Method Details

#adb(cmd, options = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/cukunity/drivers/android/utils.rb', line 14

def adb(cmd, options = {})
  options = merge_options(options, { :wait => true })
  cmd_line = ['adb', '-d'] + cmd + [:err => [:child, :out]]
  return IO.popen(cmd_line) if !options[:wait]
  output = IO.popen(cmd_line) do |io|
    if block_given?
      yield io
    else
      io.readlines
    end
  end
  [output, $?]
end

#launchable_activity_name(path) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/cukunity/drivers/android/utils.rb', line 28

def launchable_activity_name(path)
  return path unless File.exists?(path)
  dump_badging(path).match(/launchable-activity:.*name='(.[^']+)'/) do |m|
    return m[1]
  end
  raise Exception::InvalidApp.new(path)
end

#monkeyObject



6
7
8
# File 'lib/cukunity/drivers/android/utils.rb', line 6

def monkey
  Android::MonkeyClient.instance
end

#package_name(path) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/cukunity/drivers/android/utils.rb', line 36

def package_name(path)
  return path unless File.exists?(path)
  dump_badging(path).match(/package:.*name='(.[^']+)'/) do |m|
    return m[1]
  end
  throw InvalidApp.new(path)
end

#shell(cmd_line) ⇒ Object



10
11
12
# File 'lib/cukunity/drivers/android/utils.rb', line 10

def shell(cmd_line)
  `adb -d shell #{cmd_line}`
end