calabash-android 0.3.6 → 0.3.7

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.
@@ -1,3 +1,12 @@
1
+ 0.3.7:
2
+ Added calabash-android resign command
3
+
4
+ Fixed bug: No longer reuses a single result for every success result
5
+
6
+ Will give the app a few seconds to get up and running before failing
7
+
8
+ Fixed skeleton app_life_cycle_hook so screenshots are now taken before the app is shut down
9
+
1
10
  0.3.6:
2
11
  Will fail if the keyguard cannot be disabled when starting the app.
3
12
 
@@ -79,6 +79,13 @@ elsif cmd == 'extract-manifest'
79
79
 
80
80
  puts manifest ARGV.first
81
81
  exit 0
82
+ elsif cmd == 'resign'
83
+ unless File.exist? ARGV.first
84
+ puts "No such file #{ARGV.first}"
85
+ exit 1
86
+ end
87
+ resign_apk(ARGV.first)
88
+
82
89
  elsif cmd == 'version'
83
90
  puts Calabash::Android::VERSION
84
91
  exit 0
@@ -1,4 +1,3 @@
1
- require 'zip/zip'
2
1
  def calabash_build(app)
3
2
  keystore = read_keystore_info()
4
3
 
@@ -23,34 +22,16 @@ def calabash_build(app)
23
22
 
24
23
  Zip::ZipFile.new("dummy.apk").extract("AndroidManifest.xml","customAndroidManifest.xml")
25
24
  Zip::ZipFile.open("TestServer.apk") do |zip_file|
26
- zip_file.add("AndroidManifest.xml", "customAndroidManifest.xml")
25
+ zip_file.add("AndroidManifest.xml", "customAndroidManifest.xml")
27
26
  end
28
27
  end
29
- if is_windows?
30
- jarsigner_path = "\"#{ENV["JAVA_HOME"]}/bin/jarsigner.exe\""
31
- else
32
- jarsigner_path = "jarsigner"
33
- end
28
+ sign_apk("#{workspace_dir}/TestServer.apk", test_server_file_name)
29
+ begin
34
30
 
35
- cmd = "#{jarsigner_path} -sigalg MD5withRSA -digestalg SHA1 -signedjar #{test_server_file_name} -storepass #{keystore["keystore_password"]} -keystore \"#{File.expand_path keystore["keystore_location"]}\" #{workspace_dir}/TestServer.apk #{keystore["keystore_alias"]}"
36
- unless system(cmd)
37
- puts "jarsigner command: #{cmd}"
31
+ rescue Exception => e
32
+ log e
38
33
  raise "Could not sign test server"
39
34
  end
40
35
  end
41
36
  puts "Done signing the test server. Moved it to #{test_server_file_name}"
42
- end
43
-
44
-
45
- def read_keystore_info
46
- if File.exist? ".calabash_settings"
47
- JSON.parse(IO.read(".calabash_settings"))
48
- else
49
- {
50
- "keystore_location" => "#{ENV["HOME"]}/.android/debug.keystore",
51
- "keystore_password" => "android",
52
- "keystore_alias" => "androiddebugkey",
53
- "keystore_alias_password" => "android"
54
- }
55
- end
56
37
  end
@@ -19,6 +19,8 @@ def print_usage
19
19
  generate a features folder structure.
20
20
  setup
21
21
  sets up a non-default keystore to use with this test project.
22
+ resign <apk>
23
+ resigns the app with the currently configured keystore.
22
24
  build <apk>
23
25
  builds the test server that will be used when testing the app.
24
26
  run <apk>
@@ -10,8 +10,5 @@ After do |scenario|
10
10
  if scenario.failed?
11
11
  screenshot_embed
12
12
  end
13
- end
14
-
15
- After do
16
- shutdown_test_server
13
+ shutdown_test_server
17
14
  end
@@ -51,6 +51,9 @@ Find the datepicker by content description and changes the date.
51
51
  Then /^I enter "([^\"]*)" into input field number (\d+)$/ do |text, number|
52
52
  Enters the specified text into the input field with index `number`.
53
53
 
54
+ Then /^I enter text "([^\"]*)" into field with id "([^\"]*)"$/ do |text, view_id|
55
+ Enters Text into the input field with id `view_id`.
56
+
54
57
  Then /^I enter "([^\"]*)" as "([^\"]*)"$/ do |text, target|
55
58
  Then /^I enter "([^\"]*)" into "([^\"]*)"$/ do |text, target|
56
59
  Enters the specified text into the input field that has a content desciption that matches the provided target.
@@ -1,5 +1,7 @@
1
1
  require 'rexml/document'
2
2
  require 'rexml/xpath'
3
+ require 'zip/zip'
4
+ require 'tempfile'
3
5
 
4
6
  include REXML
5
7
 
@@ -10,7 +12,7 @@ def package_name(app)
10
12
  manifest = Document.new(manifest(app))
11
13
  manifest.root.attributes['package']
12
14
  end
13
-
15
+
14
16
  def main_activity(app)
15
17
  manifest = Document.new(manifest(app))
16
18
  main_activity = manifest.elements["//action[@name='android.intent.action.MAIN']/../.."].attributes['name']
@@ -36,6 +38,53 @@ def test_server_path(apk_file_path)
36
38
  "test_servers/#{checksum(apk_file_path)}_#{Calabash::Android::VERSION}.apk"
37
39
  end
38
40
 
41
+ def resign_apk(app_path)
42
+ log "Resign apk"
43
+ #Delete META-INF/*
44
+ unsigned_path = Tempfile.new('unsigned.apk').path
45
+ FileUtils.cp(app_path, unsigned_path)
46
+
47
+ to_remove = Zip::ZipFile.foreach(unsigned_path).find_all { |e| /^META-INF\// =~ e.name}.collect &:name
48
+
49
+ Zip::ZipFile.open(unsigned_path) do |zip_file|
50
+ to_remove.each do |x|
51
+ log "Removing #{x}"
52
+ zip_file.remove x
53
+ end
54
+ end
55
+ sign_apk(unsigned_path, app_path)
56
+ end
57
+
58
+ def sign_apk(app_path, dest_path)
59
+ keystore = read_keystore_info()
60
+
61
+ if is_windows?
62
+ jarsigner_path = "\"#{ENV["JAVA_HOME"]}/bin/jarsigner.exe\""
63
+ else
64
+ jarsigner_path = "jarsigner"
65
+ end
66
+
67
+ cmd = "#{jarsigner_path} -sigalg MD5withRSA -digestalg SHA1 -signedjar #{dest_path} -storepass #{keystore["keystore_password"]} -keystore \"#{File.expand_path keystore["keystore_location"]}\" #{app_path} #{keystore["keystore_alias"]}"
68
+ log cmd
69
+ unless system(cmd)
70
+ puts "jarsigner command: #{cmd}"
71
+ raise "Could not sign app (#{app_path}"
72
+ end
73
+ end
74
+
75
+ def read_keystore_info
76
+ if File.exist? ".calabash_settings"
77
+ JSON.parse(IO.read(".calabash_settings"))
78
+ else
79
+ {
80
+ "keystore_location" => "#{ENV["HOME"]}/.android/debug.keystore",
81
+ "keystore_password" => "android",
82
+ "keystore_alias" => "androiddebugkey",
83
+ "keystore_alias_password" => "android"
84
+ }
85
+ end
86
+ end
87
+
39
88
  def is_windows?
40
89
  require 'rbconfig'
41
90
  (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/)
@@ -167,7 +167,7 @@ module Operations
167
167
  end
168
168
 
169
169
  def app_running?
170
- `#{adb_command} shell ps`.include?(package_name(@app_path))
170
+ `#{adb_command} shell ps`.include?(ENV["PROCESS_NAME"] || package_name(@app_path))
171
171
  end
172
172
 
173
173
  def keyguard_enabled?
@@ -310,7 +310,9 @@ module Operations
310
310
  log cmd
311
311
  raise "Could not execute command to start test server" unless system("#{cmd} 2>&1")
312
312
 
313
- raise "App did not start" unless app_running?
313
+ retriable :tries => 10, :interval => 1 do
314
+ raise "App did not start" unless app_running?
315
+ end
314
316
 
315
317
  begin
316
318
  retriable :tries => 10, :interval => 3 do
@@ -1,4 +1,3 @@
1
-
2
1
  Then /^I enter "([^\"]*)" as "([^\"]*)"$/ do |text, target|
3
2
  performAction('enter_text_into_named_field', text, target)
4
3
  end
@@ -19,3 +18,6 @@ Then /^I clear input field number (\d+)$/ do |number|
19
18
  performAction('clear_numbered_field',number)
20
19
  end
21
20
 
21
+ Then /^I enter text "([^\"]*)" into field with id "([^\"]*)"$/ do |text, view_id|
22
+ performAction('enter_text_into_id_field', text, view_id)
23
+ end
@@ -1,5 +1,5 @@
1
1
  module Calabash
2
2
  module Android
3
- VERSION = "0.3.6"
3
+ VERSION = "0.3.7"
4
4
  end
5
5
  end
@@ -8,4 +8,4 @@
8
8
  # project structure.
9
9
 
10
10
  # Project target.
11
- target=Google Inc.:Google APIs:15
11
+ target=Google Inc.:Google APIs:16
@@ -7,7 +7,6 @@ import java.util.ArrayList;
7
7
  import java.util.List;
8
8
 
9
9
  public class Result {
10
- private static Result successResult = new Result(true);
11
10
 
12
11
  boolean success;
13
12
  String message;
@@ -62,7 +61,7 @@ public class Result {
62
61
  }
63
62
 
64
63
  public static Result successResult() {
65
- return successResult;
64
+ return new Result(true);
66
65
  }
67
66
 
68
67
  public static Result failedResult() {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: calabash-android
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.3.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-28 00:00:00.000000000 Z
12
+ date: 2012-12-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cucumber