calabash-android 0.8.4 → 0.9.0.pre1

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: b16768904abfc9f45b44ee8cd664e99ea7ec365f
4
- data.tar.gz: cf07f1a01782c50d3bffdeefc75e597da66ce675
3
+ metadata.gz: edc88bc8eeb9c7dc9dea37c99103d2071e70b67b
4
+ data.tar.gz: 7101653b3282165fe7ff093af7bf9a3ecbfb4525
5
5
  SHA512:
6
- metadata.gz: 5b97485571e71463cc4d2d4f57330f73c337e3d58fede230f74a9907cf6ec22e7abe1f335479b5b3e6cf937aabef1afa24b966971ef64e41d0fb5e5462b99d3d
7
- data.tar.gz: ad1d3d6bdfef0aa635d9e32a3d50fa0d6b038f9b22ab196bb78b3d0ddef16cc492e5bb7bfe2d1b27deffc5af3287193890fe21731aebdf851199463ba572f9a6
6
+ metadata.gz: 72acb203da0cb7a76a5bc03f23378b1849588bc10bc92dfe2403b231e9989ecf1fc18f11def1c6d3a090d6406ef01b9a4320388f600fdeed617da12f1babc3aa
7
+ data.tar.gz: f80bf8ce279a0bfed373d5ed89e21cd5bd24e49510099085ca145f2554c71ab4340e83f60bc6df691f8f55241143a2403830d81f64690bc70c2caf7a8cdc3da8
@@ -15,9 +15,8 @@ Before do |scenario|
15
15
  log 'First scenario in feature - reinstalling apps'
16
16
  end
17
17
 
18
- uninstall_apps
19
- install_app(ENV['TEST_APP_PATH'])
20
- install_app(ENV['APP_PATH'])
18
+ ensure_app_installed
19
+ clear_app_data
21
20
  FeatureMemory.feature = feature
22
21
  FeatureMemory.invocation = 1
23
22
  else
@@ -391,17 +391,17 @@ module Calabash
391
391
  end
392
392
  end
393
393
 
394
- if File.exist?('~/Library/Developer/Xamarin/android-sdk-mac_x86/')
395
- return '~/Library/Developer/Xamarin/android-sdk-mac_x86/'
394
+ if File.exist?(File.expand_path('~/Library/Developer/Xamarin/android-sdk-mac_x86/'))
395
+ return File.expand_path('~/Library/Developer/Xamarin/android-sdk-mac_x86/')
396
396
  end
397
397
 
398
- if File.exist?('~/Library/Developer/Xamarin/android-sdk-macosx/')
399
- return '~/Library/Developer/Xamarin/android-sdk-macosx/'
398
+ if File.exist?(File.expand_path('~/Library/Developer/Xamarin/android-sdk-macosx/'))
399
+ return File.expand_path('~/Library/Developer/Xamarin/android-sdk-macosx/')
400
400
  end
401
401
 
402
402
  # Default location when installing with Android Studio
403
- if File.exist?('~/Library/Android/sdk/')
404
- return '~/Library/Android/sdk/'
403
+ if File.exist?(File.expand_path('~/Library/Android/sdk/'))
404
+ return File.expand_path('~/Library/Android/sdk/')
405
405
  end
406
406
 
407
407
  if File.exist?('C:\\Android\\android-sdk')
@@ -8,6 +8,7 @@ require 'calabash-android/environment'
8
8
  require 'calabash-android/logging'
9
9
  require 'calabash-android/dependencies'
10
10
  require 'calabash-android/version'
11
+ require 'calabash-android/utils'
11
12
 
12
13
  def package_name(app)
13
14
  unless File.exist?(app)
@@ -190,8 +191,8 @@ def fingerprint_from_apk(app_path)
190
191
  cmd = "\"#{Calabash::Android::Dependencies.keytool_path}\" -v -printcert -J\"-Dfile.encoding=utf-8\" -file \"#{signature_files.first}\""
191
192
  log cmd
192
193
  fingerprints = `#{cmd}`
193
- md5_fingerprint = extract_md5_fingerprint(fingerprints)
194
- log "MD5 fingerprint for signing cert (#{app_path}): #{md5_fingerprint}"
194
+ md5_fingerprint = extract_sha1_fingerprint(fingerprints)
195
+ log "SHA1 fingerprint for signing cert (#{app_path}): #{md5_fingerprint}"
195
196
  md5_fingerprint
196
197
  end
197
198
  end
@@ -203,6 +204,12 @@ def extract_md5_fingerprint(fingerprints)
203
204
  m.first
204
205
  end
205
206
 
207
+ def extract_sha1_fingerprint(fingerprints)
208
+ m = fingerprints.scan(/SHA1.*((?:[a-fA-F\d]{2}:){15}[a-fA-F\d]{2})/).flatten
209
+ raise "No SHA1 fingerprint found:\n #{fingerprints}" if m.empty?
210
+ m.first
211
+ end
212
+
206
213
  def extract_signature_algorithm_name(fingerprints)
207
214
  m = fingerprints.scan(/Signature algorithm name: (.*)/).flatten
208
215
  raise "No signature algorithm names found:\n #{fingerprints}" if m.empty?
@@ -210,5 +217,7 @@ def extract_signature_algorithm_name(fingerprints)
210
217
  end
211
218
 
212
219
  def log(message, error = false)
213
- $stdout.puts "#{Time.now.strftime("%Y-%m-%d %H:%M:%S")} - #{message}" if (error or ARGV.include? "-v" or ARGV.include? "--verbose")
220
+ if error or ARGV.include? "-v" or ARGV.include? "--verbose" or ENV["DEBUG"] == "1"
221
+ $stdout.puts "#{Time.now.strftime("%Y-%m-%d %H:%M:%S")} - #{message}"
222
+ end
214
223
  end
@@ -38,7 +38,7 @@ class JavaKeystore
38
38
  @password = password
39
39
  log "Key store data:"
40
40
  log keystore_data
41
- @fingerprint = extract_md5_fingerprint(keystore_data)
41
+ @fingerprint = extract_sha1_fingerprint(keystore_data)
42
42
  @signature_algorithm_name = extract_signature_algorithm_name(keystore_data)
43
43
  log "Fingerprint: #{fingerprint}"
44
44
  log "Signature algorithm name: #{signature_algorithm_name}"
@@ -26,6 +26,7 @@ require 'cucumber'
26
26
  require 'date'
27
27
  require 'time'
28
28
  require 'shellwords'
29
+ require 'digest'
29
30
 
30
31
  Calabash::Android::Dependencies.setup
31
32
 
@@ -54,7 +55,7 @@ module Calabash module Android
54
55
  end
55
56
 
56
57
  def log(message)
57
- $stdout.puts "#{Time.now.strftime("%Y-%m-%d %H:%M:%S")} - #{message}" if (ARGV.include? "-v" or ARGV.include? "--verbose")
58
+ $stdout.puts "#{Time.now.strftime("%Y-%m-%d %H:%M:%S")} - #{message}" if (ARGV.include? "-v" or ARGV.include? "--verbose" or ENV["DEBUG"] == "1")
58
59
  end
59
60
 
60
61
  def macro(txt)
@@ -106,6 +107,14 @@ module Calabash module Android
106
107
  default_device.reinstall_apps
107
108
  end
108
109
 
110
+ # Ensures that the application and the test-server are installed.
111
+ #
112
+ # If the application has already been installed, it does nothing.
113
+ # If the test-server has already been installed, it does nothing.
114
+ def ensure_app_installed
115
+ default_device.ensure_apps_installed
116
+ end
117
+
109
118
  def reinstall_test_server
110
119
  default_device.reinstall_test_server
111
120
  end
@@ -333,6 +342,24 @@ module Calabash module Android
333
342
  install_app(@test_server_path)
334
343
  end
335
344
 
345
+ @@installed_apps ||= {}
346
+
347
+ def ensure_apps_installed
348
+ apps = [@app_path, @test_server_path]
349
+
350
+ apps.each do |app|
351
+ package = package_name(app)
352
+ md5 = Digest::MD5.file(File.expand_path(app))
353
+
354
+ if !application_installed?(package) || (!@@installed_apps.keys.include?(package) || @@installed_apps[package] != md5)
355
+ log "MD5 checksum for app '#{app}' (#{package}): #{md5}"
356
+ uninstall_app(package)
357
+ install_app(app)
358
+ @@installed_apps[package] = md5
359
+ end
360
+ end
361
+ end
362
+
336
363
  def install_app(app_path)
337
364
  if _sdk_version >= 23
338
365
  cmd = "#{adb_command} install -g \"#{app_path}\""
@@ -384,7 +411,7 @@ module Calabash module Android
384
411
  log "Uninstalling: #{package_name}"
385
412
  log `#{adb_command} uninstall #{package_name}`
386
413
 
387
- succeeded = !(`#{adb_command} shell pm list packages`.lines.map{|line| line.chomp.sub("package:", "")}.include?(package_name))
414
+ succeeded = !application_installed?(package_name)
388
415
 
389
416
  unless succeeded
390
417
  ::Cucumber.wants_to_quit = true
@@ -392,6 +419,10 @@ module Calabash module Android
392
419
  end
393
420
  end
394
421
 
422
+ def application_installed?(package_name)
423
+ (`#{adb_command} shell pm list packages`.lines.map{|line| line.chomp.sub("package:", "")}.include?(package_name))
424
+ end
425
+
395
426
  def app_running?
396
427
  begin
397
428
  http("/ping") == "pong"
@@ -625,6 +656,9 @@ module Calabash module Android
625
656
  end
626
657
 
627
658
  def connected_devices
659
+ # Run empty ADB command to remove eventual first-run messages
660
+ `"#{Calabash::Android::Dependencies.adb_path}" devices`
661
+
628
662
  lines = `"#{Calabash::Android::Dependencies.adb_path}" devices`.split("\n")
629
663
  start_index = lines.index{ |x| x =~ /List of devices attached/ } + 1
630
664
  lines[start_index..-1].collect { |l| l.split("\t").first }
@@ -642,8 +676,21 @@ module Calabash module Android
642
676
  end
643
677
 
644
678
  def clear_app_data
645
- cmd = "#{adb_command} shell am instrument #{package_name(@test_server_path)}/sh.calaba.instrumentationbackend.ClearAppData"
679
+ unless application_installed?(package_name(@app_path))
680
+ raise "Cannot clear data, application #{package_name(@app_path)} is not installed"
681
+ end
682
+
683
+ unless application_installed?(package_name(@test_server_path))
684
+ raise "Cannot clear data, test-server #{package_name(@test_server_path)} is not installed"
685
+ end
686
+
687
+ cmd = "#{adb_command} shell am instrument #{package_name(@test_server_path)}/sh.calaba.instrumentationbackend.ClearAppData2"
646
688
  raise "Could not clear data" unless system(cmd)
689
+
690
+ # Wait for the cleanup activity to finish. This is a hard sleep for now
691
+ sleep 2
692
+
693
+ true
647
694
  end
648
695
 
649
696
  def pull(remote, local)
@@ -1,5 +1,5 @@
1
1
  module Calabash
2
2
  module Android
3
- VERSION = "0.8.4"
3
+ VERSION = "0.9.0.pre1"
4
4
  end
5
5
  end
@@ -18,12 +18,12 @@ module Calabash
18
18
 
19
19
  def wait_for(options_or_timeout=DEFAULT_OPTS, &block)
20
20
  #note Hash is preferred, number acceptable for backwards compat
21
- default_timeout = 30
22
21
  timeout = options_or_timeout || default_timeout
23
- post_timeout=0
24
- retry_frequency=0.3
25
- timeout_message = nil
26
- screenshot_on_error = true
22
+ default_timeout = DEFAULT_OPTS[:timeout]
23
+ post_timeout = DEFAULT_OPTS[:post_timeout]
24
+ retry_frequency = DEFAULT_OPTS[:retry_frequency]
25
+ timeout_message = DEFAULT_OPTS[:timeout_message]
26
+ screenshot_on_error = DEFAULT_OPTS[:screenshot_on_error]
27
27
 
28
28
  if options_or_timeout.is_a?(Hash)
29
29
  timeout = options_or_timeout[:timeout] || default_timeout
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: calabash-android
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.4
4
+ version: 0.9.0.pre1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonas Maturana Larsen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-07 00:00:00.000000000 Z
11
+ date: 2017-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cucumber
@@ -385,9 +385,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
385
385
  version: '0'
386
386
  required_rubygems_version: !ruby/object:Gem::Requirement
387
387
  requirements:
388
- - - ">="
388
+ - - ">"
389
389
  - !ruby/object:Gem::Version
390
- version: '0'
390
+ version: 1.3.1
391
391
  requirements: []
392
392
  rubyforge_project:
393
393
  rubygems_version: 2.5.1