calabash-android 0.2.22 → 0.3.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,2 +1,51 @@
1
1
  require 'bundler'
2
+ load 'lib/calabash-android/helpers.rb'
3
+
4
+ def build
5
+ test_server_template_dir = File.join(File.dirname(__FILE__), 'test-server')
6
+
7
+ Dir.mktmpdir do |workspace_dir|
8
+
9
+ @test_server_dir = File.join(workspace_dir, 'test-server')
10
+ FileUtils.cp_r(test_server_template_dir, workspace_dir)
11
+
12
+ ant_executable = (is_windows? ? "ant.bat" : "ant")
13
+ args = [
14
+ ant_executable,
15
+ "clean",
16
+ "package",
17
+ "-Dandroid.api.level=#{api_level}",
18
+ ]
19
+ Dir.chdir(@test_server_dir) do
20
+ STDOUT.sync = true
21
+ IO.popen(args.join(" ")) do |io|
22
+ io.each { |s| print s }
23
+ end
24
+ if $?.exitstatus != 0
25
+ puts "Could not build the test server. Please see the output above."
26
+ exit $?.exitstatus
27
+ end
28
+ end
29
+
30
+ FileUtils.mkdir_p "test_servers" unless File.exist? "test_servers"
31
+
32
+ FileUtils.cp(File.join(@test_server_dir, "bin", "Test_unsigned.apk"), File.join(File.dirname(__FILE__), 'lib/calabash-android/lib/TestServer.apk'))
33
+ end
34
+ end
35
+
36
+
37
+
38
+ task :build do
39
+ unless File.exists? "test-server/calabash-js/src"
40
+ puts "calabash-js not found!"
41
+ puts "For instuctions see: https://github.com/calabash/calabash-android/wiki/Building-calabash-android"
42
+ exit 1
43
+ end
44
+
45
+ build
46
+
47
+ Rake::Task["install"].execute
48
+
49
+ end
50
+
2
51
  Bundler::GemHelper.install_tasks
@@ -1,48 +1,25 @@
1
1
  def calabash_build(app)
2
-
3
-
4
-
5
2
  keystore = read_keystore_info()
6
3
 
7
- test_server_template_dir = File.join(File.dirname(__FILE__), '..', 'test-server')
8
-
9
- Dir.mktmpdir do |workspace_dir|
10
-
11
- @test_server_dir = File.join(workspace_dir, 'test-server')
12
- FileUtils.cp_r(test_server_template_dir, workspace_dir)
13
-
14
- ant_executable = (is_windows? ? "ant.bat" : "ant")
15
- args = [
16
- ant_executable,
17
- "clean",
18
- "package",
19
- "-Dtested.package_name=#{package_name(app)}",
20
- "-Dtested.main_activity=#{main_activity(app)}",
21
- "-Dtested.project.apk=\"#{app}\"",
22
- "-Dandroid.api.level=#{api_level}",
23
- "-Dkey.store=\"#{File.expand_path keystore["keystore_location"]}\"",
24
- "-Dkey.store.password=#{keystore["keystore_password"]}",
25
- "-Dkey.alias=#{keystore["keystore_alias"]}",
26
- "-Dkey.alias.password=#{keystore["keystore_alias_password"]}",
27
- ]
28
- Dir.chdir(@test_server_dir) {
29
- STDOUT.sync = true
30
- IO.popen(args.join(" ")) do |io|
31
- io.each { |s| print s }
32
- end
33
- if $?.exitstatus != 0
34
- puts "Could not build the test server. Please see the output above."
35
- exit $?.exitstatus
36
- end
37
- }
4
+ test_server_file_name = test_server_path(app)
5
+ unsigned_test_apk = File.join(File.dirname(__FILE__), '..', 'lib/calabash-android/lib/TestServer.apk')
6
+ android_platform = Dir["#{ENV["ANDROID_HOME"]}/platforms/android-*"].last
38
7
 
39
- FileUtils.mkdir_p "test_servers" unless File.exist? "test_servers"
8
+ Dir.mktmpdir do |workspace_dir|
9
+ Dir.chdir(workspace_dir) do
10
+ FileUtils.cp(unsigned_test_apk, "TestServer.apk")
11
+ FileUtils.cp(File.join(File.dirname(__FILE__), '..', 'test-server/AndroidManifest.xml'), "AndroidManifest.xml")
40
12
 
41
- test_apk = File.join(@test_server_dir, "bin", "Test.apk")
42
- test_server_file_name = test_server_path(app)
43
- FileUtils.cp(test_apk, test_server_file_name)
44
- puts "Done building the test server. Moved it to #{test_server_file_name}"
13
+ system %Q{ruby -pi.bak -e "gsub(/#targetPackage#/, '#{package_name(app)}')" AndroidManifest.xml}
14
+
15
+ system("aapt package -M AndroidManifest.xml -I #{android_platform}/android.jar -F dummy.apk")
16
+ system("unzip -o dummy.apk AndroidManifest.xml")
17
+ system("zip TestServer.apk AndroidManifest.xml")
18
+ end
19
+ cmd = "jarsigner -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"]}"
20
+ system(cmd)
45
21
  end
22
+ puts "Done signing the test server. Moved it to #{test_server_file_name}"
46
23
  end
47
24
 
48
25
  def read_keystore_info
@@ -14,7 +14,7 @@ def calabash_run(app_path = nil)
14
14
 
15
15
  if app_path
16
16
  unless File.exist?(test_server_path(app_path))
17
- puts "No test server found for this combination of app and calabash version. Rebuilding test server."
17
+ puts "No test server found for this combination of app and calabash version. Recreating test server."
18
18
  calabash_build(app_path)
19
19
  end
20
20
 
@@ -25,6 +25,7 @@ def calabash_run(app_path = nil)
25
25
  test_server_port = "34777"
26
26
  end
27
27
  env = "PACKAGE_NAME=#{package_name(app_path)} "\
28
+ "MAIN_ACTIVITY=#{main_activity(app_path)} "\
28
29
  "TEST_PACKAGE_NAME=#{package_name(test_server_path)} "\
29
30
  "APP_PATH=\"#{app_path}\" "\
30
31
  "TEST_APP_PATH=\"#{test_server_path}\" "\
@@ -11,14 +11,12 @@ Gem::Specification.new do |s|
11
11
  s.homepage = "http://github.com/calabash"
12
12
  s.summary = %q{Client for calabash-android for automated functional testing on Android}
13
13
  s.description = %q{calabash-android drives tests for native and hybrid Android apps. }
14
- s.files = `git ls-files`.split("\n") + Dir["test-server/calabash-js/src/*.js"]
15
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ s.files = `git ls-files`.split("\n") + Dir["test-server/calabash-js/src/*.js"] + ["lib/calabash-android/lib/TestServer.apk"]
16
15
  s.executables = "calabash-android"
17
16
  s.require_paths = ["lib"]
18
17
 
19
18
  s.add_dependency( "cucumber" )
20
19
  s.add_dependency( "json" )
21
- s.add_dependency( "slowhandcuke" )
22
20
  s.add_dependency( "retriable" )
23
21
 
24
22
  end
@@ -1,17 +1,6 @@
1
1
  require 'calabash-android/management/adb'
2
2
 
3
3
  Before do |scenario|
4
- # John Gallagher provided the "scenario_is_outline" fix: https://groups.google.com/forum/?fromgroups#!topic/calabash-ios/ICA4f24eSsY
5
- # ...there may be a better way of doing this...
6
- @scenario_is_outline = (scenario.class == Cucumber::Ast::OutlineTable::ExampleRow)
7
- if @scenario_is_outline
8
- scenario = scenario.scenario_outline
9
- # Still need to call connect_to_test_server...
10
- elsif scenario.failed?
11
- return #No need to start the server is anything before this has failed.
12
- end
13
-
14
- return if scenario.failed? #No need to start the server is anything before this has failed.
15
4
  start_test_server_in_background
16
5
  end
17
6
 
@@ -275,8 +275,7 @@ module Operations
275
275
  end
276
276
 
277
277
  def start_test_server_in_background
278
- test_server_package = package_name(@test_server_path)
279
- cmd = "#{adb_command} shell am instrument -w -e class sh.calaba.instrumentationbackend.InstrumentationBackend #{test_server_package}/sh.calaba.instrumentationbackend.CalabashInstrumentationTestRunner"
278
+ cmd = "#{adb_command} shell am instrument -w -e target_package #{ENV["PACKAGE_NAME"]} -e main_activity #{ENV["MAIN_ACTIVITY"]} -e class sh.calaba.instrumentationbackend.InstrumentationBackend sh.calaba.android.test/sh.calaba.instrumentationbackend.CalabashInstrumentationTestRunner"
280
279
  log "Starting test server using:"
281
280
  log cmd
282
281
  if is_windows?
@@ -1,5 +1,5 @@
1
1
  module Calabash
2
2
  module Android
3
- VERSION = "0.2.22"
3
+ VERSION = "0.3.0.pre1"
4
4
  end
5
5
  end
@@ -1,6 +1,6 @@
1
1
  <?xml version="1.0" encoding="utf-8"?>
2
2
  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
3
- package="#TESTED_APP_PACKAGE#.test"
3
+ package="sh.calaba.android.test"
4
4
  android:versionCode="3"
5
5
  android:versionName="0.3.0">
6
6
  <application android:label="instrumentation_backend">
@@ -8,6 +8,6 @@
8
8
  <uses-library android:name="com.google.android.maps" android:required="false" />
9
9
  </application>
10
10
  <uses-sdk android:minSdkVersion="4" />
11
- <instrumentation android:targetPackage="#TESTED_APP_PACKAGE#" android:name="sh.calaba.instrumentationbackend.CalabashInstrumentationTestRunner" />
11
+ <instrumentation android:targetPackage="#targetPackage#" android:name="sh.calaba.instrumentationbackend.CalabashInstrumentationTestRunner" />
12
12
  <uses-permission android:name="android.permission.INTERNET" />
13
13
  </manifest>
@@ -9,11 +9,9 @@
9
9
  <property file="build.properties"/>
10
10
  <property name="staging.dir" location="staging"/>
11
11
  <property name="bin.dir" location="bin"/>
12
- <property name="test.app" location="${bin.dir}/Test.apk"/>
13
12
  <property name="test.app.aapt" location="${bin.dir}/Test_aapt.apk"/>
14
13
  <property name="dex.file" location="${bin.dir}/classes.dex"/>
15
14
  <property name="test.app.unsigned" location="${bin.dir}/Test_unsigned.apk"/>
16
- <property name="test.app.signed" location="${bin.dir}/Test.apk"/>
17
15
  <property name="calabashjs.dir" location="calabash-js/src"/>
18
16
 
19
17
 
@@ -48,33 +46,18 @@
48
46
  </path>
49
47
 
50
48
  <target name="-check.preconditions">
51
- <available file="${tested.project.apk}" property="tested.apk.found" />
52
- <fail unless="tested.apk.found" message="Tested apk: '${tested.project.apk}' could not be found"/>
53
49
  <available file="${calabashjs.dir}" type="dir" property="doesCalabashJsExist" />
54
50
  <fail unless="doesCalabashJsExist">
55
51
  ${calabashjs.dir} does not exist.
56
52
  </fail>
57
53
  </target>
58
54
 
59
- <target name="-init" depends="-check.preconditions">
60
- <uptodate property="test.app.upto.date" targetfile="${test.app.signed}" >
61
- <srcfiles dir= "instrumentation-backend/" includes="**/*"/>
62
- <srcfiles file="build.properties"/>
63
- </uptodate>
64
- </target>
65
-
66
55
  <target name="-stage">
67
56
  <mkdir dir="${staging.dir}"/>
68
57
  <mkdir dir="${bin.dir}"/>
69
- <antcall target="-prepare.manifest"/>
70
58
  <antcall target="-prepare.testserver"/>
71
59
  </target>
72
60
 
73
- <target name="-prepare.manifest" description="Makes sure the manifest matches the tested application by looking at its manifest file">
74
- <copy file="AndroidManifest.xml" todir="${staging.dir}"/>
75
- <replace file="${staging.dir}/AndroidManifest.xml" token="#TESTED_APP_PACKAGE#" value="${tested.package_name}"/>
76
- </target>
77
-
78
61
  <target name="-prepare.testserver" description="Makes sure the testserver matches the tested application by looking at its manifest file">
79
62
  <copy todir="${staging.dir}">
80
63
  <fileset dir="instrumentation-backend">
@@ -89,14 +72,6 @@
89
72
  <copy todir="${staging.dir}/assets">
90
73
  <fileset dir="${calabashjs.dir}"/>
91
74
  </copy>
92
- <replace file="${staging.dir}/src/sh/calaba/instrumentationbackend/InstrumentationBackend.java" token="#ACTIVITY_PACKAGE#" value="${tested.package_name}"/>
93
-
94
- <replace file="${staging.dir}/src/sh/calaba/instrumentationbackend/InstrumentationBackend.java" token="#ACTIVITY_QUALIFIED_NAME#" value="${tested.main_activity}"/>
95
- <exec executable="${env.ANDROID_HOME}/platform-tools/aapt" failonerror="true" output="${staging.dir}/assets/ids.txt">
96
- <arg value="dump" />
97
- <arg value="resources" />
98
- <arg file="${tested.project.apk}" />
99
- </exec>
100
75
  </target>
101
76
 
102
77
 
@@ -116,12 +91,11 @@
116
91
  </target>
117
92
 
118
93
 
119
- <target name="package" depends="-init" unless="test.app.upto.date">
94
+ <target name="package" depends="-check.preconditions">
120
95
  <antcall target="-compile" />
121
96
  <antcall target="-aapt" />
122
97
  <antcall target="-dex" />
123
98
  <antcall target="-apk" />
124
- <antcall target="-sign" />
125
99
  </target>
126
100
 
127
101
 
@@ -149,7 +123,9 @@
149
123
  </target>
150
124
 
151
125
  <target name="-dex">
152
- <antcall target="-stage.libs"/>
126
+ <copy todir="${bin.dir}/libs">
127
+ <fileset dir="instrumentation-backend/libs"/>
128
+ </copy>
153
129
  <exec executable="${dx}" failonerror="yes">
154
130
  <arg value="--dex" />
155
131
  <arg value="--output" />
@@ -158,12 +134,6 @@
158
134
  </exec>
159
135
  </target>
160
136
 
161
- <target name="-stage.libs">
162
- <copy todir="${bin.dir}/libs">
163
- <fileset dir="instrumentation-backend/libs"/>
164
- </copy>
165
- </target>
166
-
167
137
  <target name="-apk">
168
138
  <exec executable="${apkbuilder}" failonerror="yes">
169
139
  <arg file="${test.app.unsigned}" />
@@ -175,24 +145,4 @@
175
145
  </exec>
176
146
  </target>
177
147
 
178
-
179
- <target name ="-sign">
180
- <exec executable="jarsigner" failonerror="true">
181
- <arg value="-sigalg" />
182
- <arg value="MD5withRSA" />
183
- <arg value="-digestalg" />
184
- <arg value="SHA1" />
185
- <arg value="-signedjar" />
186
- <arg file="${test.app.signed}" />
187
- <arg value="-storepass" />
188
- <arg value="${key.store.password}" />
189
- <arg value="-keystore" />
190
- <arg file="${key.store}" />
191
-
192
- <arg file="${test.app.unsigned}" />
193
- <arg value="${key.alias}" />
194
-
195
- </exec>
196
- </target>
197
-
198
148
  </project>
@@ -8,4 +8,4 @@
8
8
  # project structure.
9
9
 
10
10
  # Project target.
11
- target=Google Inc.:Google APIs:8
11
+ target=Google Inc.:Google APIs:15
@@ -17,12 +17,21 @@ public class CalabashInstrumentationTestRunner extends InstrumentationTestRunner
17
17
  method.invoke (null, context, null, new String[]{context.getApplicationInfo ().sourceDir});
18
18
  System.out.println("Calabash loaded Mono");
19
19
  } catch (Exception e) {
20
- System.out.println("Calabash could not load Mono");
20
+ System.out.println("Calabash did not load Mono. This is only a problem if you are trying to test a Mono application");
21
21
  }
22
22
 
23
23
  // Start the HttpServer as soon as possible in a not-ready state
24
24
  HttpServer.instantiate();
25
25
 
26
+ InstrumentationBackend.testPackage = arguments.getString("target_package");
27
+
28
+ try {
29
+ InstrumentationBackend.mainActivity = Class.forName(arguments.getString("main_activity"));
30
+ } catch (ClassNotFoundException e) {
31
+ throw new RuntimeException(e);
32
+ }
33
+
26
34
  super.onCreate(arguments);
35
+
27
36
  }
28
37
  }
@@ -9,8 +9,8 @@ import android.util.Log;
9
9
  import com.jayway.android.robotium.solo.SoloEnhanced;
10
10
 
11
11
  public class InstrumentationBackend extends ActivityInstrumentationTestCase2 {
12
- public static final String TARGET_PACKAGE = "#ACTIVITY_PACKAGE#"; //Set from Ant at compile time
13
- private static final String LAUNCHER_ACTIVITY_FULL_CLASSNAME = "#ACTIVITY_QUALIFIED_NAME#"; //Set from Ant at compile time
12
+ public static String testPackage;
13
+ public static Class mainActivity;
14
14
 
15
15
  private static final String TAG = "InstrumentationBackend";
16
16
 
@@ -18,16 +18,8 @@ public class InstrumentationBackend extends ActivityInstrumentationTestCase2 {
18
18
  public static SoloEnhanced solo;
19
19
  public static Actions actions;
20
20
 
21
- private static Class getActivityClass() {
22
- try {
23
- return Class.forName(LAUNCHER_ACTIVITY_FULL_CLASSNAME);
24
- } catch (ClassNotFoundException e) {
25
- throw new RuntimeException(e);
26
- }
27
- }
28
-
29
21
  public InstrumentationBackend() {
30
- super(TARGET_PACKAGE, getActivityClass());
22
+ super(testPackage, mainActivity);
31
23
  }
32
24
 
33
25
  @Override
@@ -37,7 +29,6 @@ public class InstrumentationBackend extends ActivityInstrumentationTestCase2 {
37
29
  solo = new SoloEnhanced(getInstrumentation(), this.getActivity());
38
30
  actions = new Actions(getInstrumentation(), this);
39
31
  instrumentation = getInstrumentation();
40
- TestHelpers.loadIds(instrumentation.getContext());
41
32
  }
42
33
 
43
34
  /**
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: calabash-android
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.22
5
- prerelease:
4
+ version: 0.3.0.pre1
5
+ prerelease: 6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jonas Maturana Larsen
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-17 00:00:00.000000000 Z
12
+ date: 2012-09-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cucumber
@@ -43,22 +43,6 @@ dependencies:
43
43
  - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
- - !ruby/object:Gem::Dependency
47
- name: slowhandcuke
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ! '>='
52
- - !ruby/object:Gem::Version
53
- version: '0'
54
- type: :runtime
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
46
  - !ruby/object:Gem::Dependency
63
47
  name: retriable
64
48
  requirement: !ruby/object:Gem::Requirement
@@ -88,7 +72,6 @@ files:
88
72
  - Gemfile
89
73
  - LICENSE
90
74
  - Rakefile
91
- - bin/.DS_Store
92
75
  - bin/calabash-android
93
76
  - bin/calabash-android-build.rb
94
77
  - bin/calabash-android-generate.rb
@@ -669,6 +652,7 @@ files:
669
652
  - test-server/instrumentation-backend/src/sh/calaba/org/codehaus/jackson/util/package-info.java
670
653
  - test-server/calabash-js/src/calabash.js
671
654
  - test-server/calabash-js/src/set_text.js
655
+ - lib/calabash-android/lib/TestServer.apk
672
656
  homepage: http://github.com/calabash
673
657
  licenses: []
674
658
  post_install_message:
@@ -684,9 +668,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
684
668
  required_rubygems_version: !ruby/object:Gem::Requirement
685
669
  none: false
686
670
  requirements:
687
- - - ! '>='
671
+ - - ! '>'
688
672
  - !ruby/object:Gem::Version
689
- version: '0'
673
+ version: 1.3.1
690
674
  requirements: []
691
675
  rubyforge_project:
692
676
  rubygems_version: 1.8.24
Binary file