screengrab 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f77fc72be9bccdbde7ac47f9caf489dfd4a695bc
4
- data.tar.gz: c64689b75eac8687ca4d786c6833103e4415bc56
3
+ metadata.gz: 3f74d14d0f19ab1ec79fec8b498b124e51dc53bd
4
+ data.tar.gz: 42119a6f3a72053d12e207ade40280b11e2e6b5f
5
5
  SHA512:
6
- metadata.gz: e4fe5f5217b5746cf4ebb7f86fef5b235a03a24a249f6341cf4d304b9ea90a40482070abd780784685bea4250da8d6fe68a46472e85a1f0fe1664bd01a926623
7
- data.tar.gz: 40645833920cd54544a71c46058d34af5503f79baadfd4760edb154303cfe5a7291384b15228c7a45934ee2b6673455434a1f54857e011e86c88a33c116da1a8
6
+ metadata.gz: 17abb01dd66da35880b93d7a315b5cb7a01a626d240cb8bd0939840b5fae5caf741c9b4c67291b74b82a308c776bc83341103a49427478a20359c96d398f1190
7
+ data.tar.gz: 9414051edff7d5b45c9cf10168d4e74efcd75ced86bc85a22ac99362435f3845c3417785c25348d7d0ac3160db0db006ed66db6292a9e7f4bfccb35edf22d4f3
data/README.md CHANGED
@@ -55,7 +55,7 @@ sudo gem install screengrab
55
55
 
56
56
  ##### Gradle dependency
57
57
  ```java
58
- androidTestCompile 'tools.fastlane:screengrab:0.3.2'
58
+ androidTestCompile 'tools.fastlane:screengrab:0.5.1'
59
59
  ```
60
60
 
61
61
  ##### Configuring your Manifest Permissions
@@ -77,11 +77,15 @@ module Screengrab
77
77
  end
78
78
 
79
79
  def select_device
80
- devices = @executor.execute(command: "adb devices -l", print_all: true, print_command: true).split("\n")
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
- ['unauthorized', 'offline', '* daemon', 'List of devices attached'].any? { |status| device.include? status }
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 = @executor.execute(command: "adb -s #{device_serial} shell echo \\$EXTERNAL_STORAGE",
134
- print_all: true,
135
- print_command: true)
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
- @executor.execute(command: "adb -s #{device_serial} shell rm -rf #{path}",
149
- print_all: true,
150
- print_command: true)
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 = @executor.execute(command: "adb -s #{device_serial} install -r #{app_apk_path}",
176
- print_all: true,
177
- print_command: true)
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 = @executor.execute(command: "adb -s #{device_serial} install -r #{tests_apk_path}",
182
- print_all: true,
183
- print_command: true)
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
- @executor.execute(command: "adb -s #{device_serial} shell pm grant #{@config[:app_package_name]} android.permission.CHANGE_CONFIGURATION",
190
- print_all: true,
191
- print_command: true)
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 = @executor.execute(command: "adb -s #{device_serial} shell getprop ro.build.version.sdk",
194
- print_all: true,
195
- print_command: true).to_i
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
- @executor.execute(command: "adb -s #{device_serial} shell pm grant #{@config[:app_package_name]} android.permission.WRITE_EXTERNAL_STORAGE",
200
- print_all: true,
201
- print_command: true)
202
- @executor.execute(command: "adb -s #{device_serial} shell pm grant #{@config[:app_package_name]} android.permission.READ_EXTERNAL_STORAGE",
203
- print_all: true,
204
- print_command: true)
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 = @executor.execute(command: instrument_command.join(" \\\n"),
220
- print_all: true,
221
- print_command: true)
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
- @executor.execute(command: "adb -s #{device_serial} pull #{path} #{tempdir}",
239
- print_all: false,
240
- print_command: true)
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 @executor.execute(command: "adb -s #{device_serial} shell ls #{device_path}",
302
- print_all: false,
303
- print_command: false).include?('No such file')
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
- @executor.execute(command: "open #{@config[:output_directory]}/*/images/#{device_type_dir_name}/*.png",
316
- print_all: false,
317
- print_command: true)
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
@@ -1,3 +1,3 @@
1
1
  major=0
2
2
  minor=5
3
- patch=1
3
+ patch=2
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.1
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-08-29 00:00:00.000000000 Z
12
+ date: 2016-09-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fastlane_core