screengrab 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/screengrab/runner.rb +53 -39
- data/version.properties +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3f74d14d0f19ab1ec79fec8b498b124e51dc53bd
|
|
4
|
+
data.tar.gz: 42119a6f3a72053d12e207ade40280b11e2e6b5f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 17abb01dd66da35880b93d7a315b5cb7a01a626d240cb8bd0939840b5fae5caf741c9b4c67291b74b82a308c776bc83341103a49427478a20359c96d398f1190
|
|
7
|
+
data.tar.gz: 9414051edff7d5b45c9cf10168d4e74efcd75ced86bc85a22ac99362435f3845c3417785c25348d7d0ac3160db0db006ed66db6292a9e7f4bfccb35edf22d4f3
|
data/README.md
CHANGED
data/lib/screengrab/runner.rb
CHANGED
|
@@ -77,11 +77,15 @@ module Screengrab
|
|
|
77
77
|
end
|
|
78
78
|
|
|
79
79
|
def select_device
|
|
80
|
-
devices =
|
|
80
|
+
devices = run_adb_command("adb devices -l", print_all: true, print_command: true).split("\n")
|
|
81
81
|
# the first output by adb devices is "List of devices attached" so remove that and any adb startup output
|
|
82
|
-
# devices.reject! { |d| d.include?("List of devices attached") || d.include?("* daemon") || d.include?("unauthorized") || d.include?("offline") }
|
|
83
82
|
devices.reject! do |device|
|
|
84
|
-
[
|
|
83
|
+
[
|
|
84
|
+
'unauthorized', # The device has not yet accepted ADB control
|
|
85
|
+
'offline', # The device is offline, skip it
|
|
86
|
+
'* daemon', # Messages printed when the daemon is starting up
|
|
87
|
+
'List of devices attached' # Header of table for data we want
|
|
88
|
+
].any? { |status| device.include? status }
|
|
85
89
|
end
|
|
86
90
|
|
|
87
91
|
UI.user_error! 'There are no connected and authorized devices or emulators' if devices.empty?
|
|
@@ -130,9 +134,9 @@ module Screengrab
|
|
|
130
134
|
end
|
|
131
135
|
|
|
132
136
|
def determine_external_screenshots_path(device_serial)
|
|
133
|
-
device_ext_storage =
|
|
134
|
-
|
|
135
|
-
|
|
137
|
+
device_ext_storage = run_adb_command("adb -s #{device_serial} shell echo \\$EXTERNAL_STORAGE",
|
|
138
|
+
print_all: true,
|
|
139
|
+
print_command: true)
|
|
136
140
|
File.join(device_ext_storage, @config[:app_package_name], 'screengrab')
|
|
137
141
|
end
|
|
138
142
|
|
|
@@ -145,9 +149,9 @@ module Screengrab
|
|
|
145
149
|
|
|
146
150
|
device_screenshots_paths.each do |device_path|
|
|
147
151
|
if_device_path_exists(device_serial, device_path) do |path|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
152
|
+
run_adb_command("adb -s #{device_serial} shell rm -rf #{path}",
|
|
153
|
+
print_all: true,
|
|
154
|
+
print_command: true)
|
|
151
155
|
end
|
|
152
156
|
end
|
|
153
157
|
end
|
|
@@ -172,36 +176,36 @@ module Screengrab
|
|
|
172
176
|
|
|
173
177
|
def install_apks(device_serial, app_apk_path, tests_apk_path)
|
|
174
178
|
UI.message 'Installing app APK'
|
|
175
|
-
apk_install_output =
|
|
176
|
-
|
|
177
|
-
|
|
179
|
+
apk_install_output = run_adb_command("adb -s #{device_serial} install -r #{app_apk_path}",
|
|
180
|
+
print_all: true,
|
|
181
|
+
print_command: true)
|
|
178
182
|
UI.user_error! "App APK could not be installed" if apk_install_output.include?("Failure [")
|
|
179
183
|
|
|
180
184
|
UI.message 'Installing tests APK'
|
|
181
|
-
apk_install_output =
|
|
182
|
-
|
|
183
|
-
|
|
185
|
+
apk_install_output = run_adb_command("adb -s #{device_serial} install -r #{tests_apk_path}",
|
|
186
|
+
print_all: true,
|
|
187
|
+
print_command: true)
|
|
184
188
|
UI.user_error! "Tests APK could not be installed" if apk_install_output.include?("Failure [")
|
|
185
189
|
end
|
|
186
190
|
|
|
187
191
|
def grant_permissions(device_serial)
|
|
188
192
|
UI.message 'Granting the permission necessary to change locales on the device'
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
193
|
+
run_adb_command("adb -s #{device_serial} shell pm grant #{@config[:app_package_name]} android.permission.CHANGE_CONFIGURATION",
|
|
194
|
+
print_all: true,
|
|
195
|
+
print_command: true)
|
|
192
196
|
|
|
193
|
-
device_api_version =
|
|
194
|
-
|
|
195
|
-
|
|
197
|
+
device_api_version = run_adb_command("adb -s #{device_serial} shell getprop ro.build.version.sdk",
|
|
198
|
+
print_all: true,
|
|
199
|
+
print_command: true).to_i
|
|
196
200
|
|
|
197
201
|
if device_api_version >= 23
|
|
198
202
|
UI.message 'Granting the permissions necessary to access device external storage'
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
203
|
+
run_adb_command("adb -s #{device_serial} shell pm grant #{@config[:app_package_name]} android.permission.WRITE_EXTERNAL_STORAGE",
|
|
204
|
+
print_all: true,
|
|
205
|
+
print_command: true)
|
|
206
|
+
run_adb_command("adb -s #{device_serial} shell pm grant #{@config[:app_package_name]} android.permission.READ_EXTERNAL_STORAGE",
|
|
207
|
+
print_all: true,
|
|
208
|
+
print_command: true)
|
|
205
209
|
end
|
|
206
210
|
end
|
|
207
211
|
|
|
@@ -216,9 +220,9 @@ module Screengrab
|
|
|
216
220
|
instrument_command << "-e package #{test_packages_to_use.join(',')}" if test_packages_to_use
|
|
217
221
|
instrument_command << "#{@config[:tests_package_name]}/#{@config[:test_instrumentation_runner]}"
|
|
218
222
|
|
|
219
|
-
test_output =
|
|
220
|
-
|
|
221
|
-
|
|
223
|
+
test_output = run_adb_command(instrument_command.join(" \\\n"),
|
|
224
|
+
print_all: true,
|
|
225
|
+
print_command: true)
|
|
222
226
|
|
|
223
227
|
UI.user_error!("Tests failed", show_github_issues: false) if test_output.include?("FAILURES!!!")
|
|
224
228
|
end
|
|
@@ -235,9 +239,9 @@ module Screengrab
|
|
|
235
239
|
Dir.mktmpdir do |tempdir|
|
|
236
240
|
device_screenshots_paths.each do |device_path|
|
|
237
241
|
if_device_path_exists(device_serial, device_path) do |path|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
242
|
+
run_adb_command("adb -s #{device_serial} pull #{path} #{tempdir}",
|
|
243
|
+
print_all: false,
|
|
244
|
+
print_command: true)
|
|
241
245
|
end
|
|
242
246
|
end
|
|
243
247
|
|
|
@@ -298,9 +302,9 @@ module Screengrab
|
|
|
298
302
|
# Some device commands fail if executed against a device path that does not exist, so this helper method
|
|
299
303
|
# provides a way to conditionally execute a block only if the provided path exists on the device.
|
|
300
304
|
def if_device_path_exists(device_serial, device_path)
|
|
301
|
-
return if
|
|
302
|
-
|
|
303
|
-
|
|
305
|
+
return if run_adb_command("adb -s #{device_serial} shell ls #{device_path}",
|
|
306
|
+
print_all: false,
|
|
307
|
+
print_command: false).include?('No such file')
|
|
304
308
|
|
|
305
309
|
yield device_path
|
|
306
310
|
rescue
|
|
@@ -312,10 +316,20 @@ module Screengrab
|
|
|
312
316
|
unless @config[:skip_open_summary]
|
|
313
317
|
UI.message "Opening screenshots summary"
|
|
314
318
|
# MCF: this isn't OK on any platform except Mac
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
319
|
+
run_adb_command("open #{@config[:output_directory]}/*/images/#{device_type_dir_name}/*.png",
|
|
320
|
+
print_all: false,
|
|
321
|
+
print_command: true)
|
|
318
322
|
end
|
|
319
323
|
end
|
|
324
|
+
|
|
325
|
+
def run_adb_command(command, print_all: false, print_command: false)
|
|
326
|
+
output = @executor.execute(command: command,
|
|
327
|
+
print_all: print_all,
|
|
328
|
+
print_command: print_command) || ''
|
|
329
|
+
output.lines.reject do |line|
|
|
330
|
+
# Debug/Warning output from ADB}
|
|
331
|
+
line.start_with?('adb: ')
|
|
332
|
+
end.join('') # Lines retain their newline chars
|
|
333
|
+
end
|
|
320
334
|
end
|
|
321
335
|
end
|
data/version.properties
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: screengrab
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.5.
|
|
4
|
+
version: 0.5.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andrea Falcone
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2016-
|
|
12
|
+
date: 2016-09-06 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: fastlane_core
|