Module: Cukunity::Android::App
- Extended by:
- Utils, Utils
- Defined in:
- lib/cukunity/drivers/android/app.rb
Class Method Summary
collapse
Methods included from Utils
adb, launchable_activity_name, monkey, package_name, shell
Methods included from Utils
check_timeout, merge_options, restrict_options, to_options, wait_connectivity
Class Method Details
.install(path, options = {}) ⇒ Object
7
8
9
10
11
12
13
14
15
16
|
# File 'lib/cukunity/drivers/android/app.rb', line 7
def self.install(path, options = {})
options = merge_options(options, { :max_time => 30 })
output, status = adb ['install', '-r', path]
unless status.exited? and status.exitstatus == 0
raise Exception::InstallFailed.new
end
raise Exception::InstallTimeout.new if check_timeout(options[:max_time]) do
installed?(path)
end
end
|
.installed ⇒ Object
29
30
31
32
33
|
# File 'lib/cukunity/drivers/android/app.rb', line 29
def self.installed
shell('pm list packages').scan(/^package:(\S+)/).inject([]) do |packages, m|
packages << m[0]
end
end
|
.installed?(path) ⇒ Boolean
35
36
37
38
39
40
|
# File 'lib/cukunity/drivers/android/app.rb', line 35
def self.installed?(path)
package = package_name(path).downcase
installed.any? do |p|
p.downcase == package
end
end
|
.uninstall(path, options = {}) ⇒ Object
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/cukunity/drivers/android/app.rb', line 18
def self.uninstall(path, options = {})
options = merge_options(options, { :max_time => 30 })
output, status = adb ['uninstall', package_name(path)]
unless status.exited? and status.exitstatus == 0
raise Exception::UninstallFailed.new
end
raise Exception::UninstallTimeout.new if check_timeout(options[:max_time]) do
not installed?(path)
end
end
|