ADB 0.5.4 → 0.5.5
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +4 -0
- data/features/step_definitions/adb_steps.rb +13 -9
- data/lib/ADB.rb +17 -4
- data/lib/ADB/version.rb +1 -1
- data/spec/lib/ADB_spec.rb +21 -1
- metadata +4 -4
data/ChangeLog
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
APK_FILE_NAME = 'features/support/ApiDemos.apk'
|
2
|
+
TEMP_FILE_NAME = 'cuke_test_file.txt'
|
3
|
+
TEMP_FILE_REMOTE_LOCATION = '/sdcard/'
|
4
|
+
|
1
5
|
When /^the adb server is started$/ do
|
2
6
|
start_server
|
3
7
|
end
|
@@ -25,14 +29,14 @@ end
|
|
25
29
|
Then /^I should be able to install the sample application$/ do
|
26
30
|
sn = devices[0]
|
27
31
|
wait_for_device({:serial => sn}, 60)
|
28
|
-
install
|
32
|
+
install APK_FILE_NAME, nil, {:serial => sn}, 60
|
29
33
|
last_stdout.should include 'Success'
|
30
34
|
end
|
31
35
|
|
32
36
|
Then /^I should be able to install the sample application using the "(.*?)" option$/ do |option|
|
33
37
|
sn = devices[0]
|
34
38
|
wait_for_device({:serial => sn}, 60)
|
35
|
-
install
|
39
|
+
install APK_FILE_NAME, option, {:serial => sn}, 60
|
36
40
|
end
|
37
41
|
|
38
42
|
Then /^I should be able to uninstall the sample application$/ do
|
@@ -76,15 +80,15 @@ Then /^I should be able to push a file to the local device$/ do
|
|
76
80
|
sn = devices[0]
|
77
81
|
wait_for_device({:serial => sn}, 60)
|
78
82
|
remount({:serial => sn})
|
79
|
-
shell(
|
80
|
-
shell(
|
83
|
+
shell("rm #{TEMP_FILE_NAME}", {:serial => sn})
|
84
|
+
shell("ls #{TEMP_FILE_NAME}", {:serial => sn})
|
81
85
|
last_stdout.should include 'No such file or directory'
|
82
86
|
|
83
87
|
# create the temp file
|
84
|
-
File.open(
|
88
|
+
File.open(TEMP_FILE_NAME, 'w'){ |f| f.write('Temporary file for adb testing. If found, please delete.') }
|
85
89
|
|
86
90
|
# push the file
|
87
|
-
push(
|
91
|
+
push(TEMP_FILE_NAME, "#{TEMP_FILE_REMOTE_LOCATION}#{TEMP_FILE_NAME}", {:serial => sn})
|
88
92
|
last_stderr.should_not include 'failed to copy'
|
89
93
|
|
90
94
|
end
|
@@ -94,11 +98,11 @@ Then /^I should be able to pull a file from the local device$/ do
|
|
94
98
|
sn = devices[0]
|
95
99
|
wait_for_device({:serial => sn}, 60)
|
96
100
|
remount({:serial => sn})
|
97
|
-
shell("touch
|
101
|
+
shell("touch #{TEMP_FILE_REMOTE_LOCATION}#{TEMP_FILE_NAME}", {:serial => sn})
|
98
102
|
|
99
103
|
# pull the file
|
100
|
-
pull
|
104
|
+
pull "#{TEMP_FILE_REMOTE_LOCATION}#{TEMP_FILE_NAME}", #{TEMP_FILE_NAME}", {:serial => sn})
|
101
105
|
|
102
106
|
# confirm that the file was created
|
103
|
-
File.exists?(
|
107
|
+
File.exists?(TEMP_FILE_NAME).should == true
|
104
108
|
end
|
data/lib/ADB.rb
CHANGED
@@ -21,7 +21,7 @@ module ADB
|
|
21
21
|
#
|
22
22
|
def start_server(timeout=30)
|
23
23
|
execute_adb_with(timeout, 'start-server')
|
24
|
-
raise ADBError, "Server didn't start" unless stdout_contains "daemon started successfully"
|
24
|
+
raise ADBError, "Server didn't start#{stdout_stderr_message}" unless stdout_contains "daemon started successfully"
|
25
25
|
end
|
26
26
|
|
27
27
|
#
|
@@ -44,7 +44,7 @@ module ADB
|
|
44
44
|
#
|
45
45
|
def connect(hostname='localhost', port='5555', timeout=30)
|
46
46
|
execute_adb_with(timeout, "connect #{hostname}:#{port}")
|
47
|
-
raise ADBError, "Could not connect to device at #{hostname}:#{port}" unless stdout_contains "connected to #{hostname}"
|
47
|
+
raise ADBError, "Could not connect to device at #{hostname}:#{port}#{stdout_stderr_message}" unless stdout_contains "connected to #{hostname}"
|
48
48
|
end
|
49
49
|
|
50
50
|
#
|
@@ -95,7 +95,7 @@ module ADB
|
|
95
95
|
#
|
96
96
|
def install(installable, options=nil, target={}, timeout=30)
|
97
97
|
execute_adb_with_exactly(timeout, *"#{which_one(target)} wait-for-device install #{options}".split, installable)
|
98
|
-
raise ADBError, "Could not install #{installable}" unless stdout_contains "Success"
|
98
|
+
raise ADBError, "Could not install #{installable}#{stdout_stderr_message}" unless stdout_contains "Success"
|
99
99
|
end
|
100
100
|
|
101
101
|
#
|
@@ -109,7 +109,7 @@ module ADB
|
|
109
109
|
#
|
110
110
|
def uninstall(package, target={}, timeout=30)
|
111
111
|
execute_adb_with(timeout, "#{which_one(target)} uninstall #{package}")
|
112
|
-
raise ADBError, "Could not uninstall #{package}" unless stdout_contains "Success"
|
112
|
+
raise ADBError, "Could not uninstall #{package}#{stdout_stderr_message}" unless stdout_contains "Success"
|
113
113
|
end
|
114
114
|
|
115
115
|
#
|
@@ -204,6 +204,19 @@ module ADB
|
|
204
204
|
|
205
205
|
private
|
206
206
|
|
207
|
+
def stdout_stderr_message
|
208
|
+
if not last_stdout.empty?
|
209
|
+
if not last_stderr.empty?
|
210
|
+
return " Cause: #{last_stdout}, and Error: #{last_stderr}"
|
211
|
+
else
|
212
|
+
return " Cause: #{last_stdout}"
|
213
|
+
end
|
214
|
+
elsif not last_stderr.empty?
|
215
|
+
return " Error: #{last_stderr}"
|
216
|
+
end
|
217
|
+
''
|
218
|
+
end
|
219
|
+
|
207
220
|
def execute_adb_with(timeout, arguments)
|
208
221
|
args = arguments.split
|
209
222
|
execute_adb_with_exactly timeout, *args
|
data/lib/ADB/version.rb
CHANGED
data/spec/lib/ADB_spec.rb
CHANGED
@@ -209,10 +209,30 @@ describe ADB do
|
|
209
209
|
end
|
210
210
|
|
211
211
|
it "should raise an error when the uninstall fails" do
|
212
|
-
ADB.should_receive(:last_stdout).and_return('some error')
|
212
|
+
ADB.should_receive(:last_stdout).any_number_of_times.and_return('some error')
|
213
213
|
should_call_adb_with('uninstall', 'com.example')
|
214
214
|
expect { ADB.uninstall('com.example') }.to raise_error(ADBError)
|
215
215
|
end
|
216
|
+
|
217
|
+
it "should raise an error when the uninstall fails" do
|
218
|
+
ADB.should_receive(:last_stdout).any_number_of_times.and_return('some stdout message')
|
219
|
+
should_call_adb_with('uninstall', 'com.example')
|
220
|
+
expect { ADB.uninstall('com.example') }.to raise_error(ADBError, "Could not uninstall com.example Cause: some stdout message")
|
221
|
+
end
|
222
|
+
|
223
|
+
it "should raise an error when the uninstall fails" do
|
224
|
+
ADB.should_receive(:last_stderr).any_number_of_times.and_return('some stderr message')
|
225
|
+
should_call_adb_with('uninstall', 'com.example')
|
226
|
+
expect { ADB.uninstall('com.example') }.to raise_error(ADBError, "Could not uninstall com.example Error: some stderr message")
|
227
|
+
end
|
228
|
+
|
229
|
+
it "should raise an error when the uninstall fails" do
|
230
|
+
ADB.should_receive(:last_stdout).any_number_of_times.and_return('some stdout message')
|
231
|
+
ADB.should_receive(:last_stderr).any_number_of_times.and_return('some stderr message')
|
232
|
+
should_call_adb_with('uninstall', 'com.example')
|
233
|
+
expect { ADB.uninstall('com.example') }.to raise_error(ADBError, "Could not uninstall com.example Cause: some stdout message, and Error: some stderr message")
|
234
|
+
end
|
235
|
+
|
216
236
|
end
|
217
237
|
|
218
238
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ADB
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-10-29 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: childprocess
|
@@ -105,7 +105,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
105
105
|
version: '0'
|
106
106
|
segments:
|
107
107
|
- 0
|
108
|
-
hash:
|
108
|
+
hash: 4475756240764748213
|
109
109
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
110
|
none: false
|
111
111
|
requirements:
|
@@ -114,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
114
|
version: '0'
|
115
115
|
segments:
|
116
116
|
- 0
|
117
|
-
hash:
|
117
|
+
hash: 4475756240764748213
|
118
118
|
requirements: []
|
119
119
|
rubyforge_project:
|
120
120
|
rubygems_version: 1.8.24
|