calabash-android 0.1.0 → 0.2.0.pre2
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.
- data/CHANGES.txt +10 -0
- data/bin/calabash-android +19 -2
- data/bin/calabash-android-build.rb +30 -14
- data/bin/calabash-android-generate.rb +0 -1
- data/bin/calabash-android-helpers.rb +0 -15
- data/bin/calabash-android-run.rb +12 -10
- data/features-skeleton/support/app_installation_hooks.rb +2 -1
- data/features-skeleton/support/app_life_cycle_hooks.rb +1 -22
- data/lib/calabash-android/helpers.rb +54 -0
- data/lib/calabash-android/lib/AXMLPrinter2.jar +0 -0
- data/lib/calabash-android/management/adb.rb +0 -11
- data/lib/calabash-android/operations.rb +180 -71
- data/lib/calabash-android/version.rb +2 -2
- data/test-server/build.xml +2 -0
- data/test-server/instrumentation-backend/AndroidManifest.xml +17 -11
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/InstrumentationBackend.java +10 -127
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/HttpServer.java +76 -0
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/NanoHTTPD.java +1084 -0
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/location/FakeGPSLocation.java +66 -10
- metadata +17 -11
- data/lib/calabash-android/management/app_installation.rb +0 -21
- data/test-server/instrumentation-backend/gen/com/lesspainful/simpleui/test/R.java +0 -23
@@ -5,33 +5,89 @@ import sh.calaba.instrumentationbackend.InstrumentationBackend;
|
|
5
5
|
import sh.calaba.instrumentationbackend.Result;
|
6
6
|
import sh.calaba.instrumentationbackend.actions.Action;
|
7
7
|
import android.content.Context;
|
8
|
+
import android.location.Criteria;
|
8
9
|
import android.location.Location;
|
9
10
|
import android.location.LocationManager;
|
10
11
|
import android.location.LocationProvider;
|
11
12
|
|
12
13
|
|
13
14
|
public class FakeGPSLocation implements Action {
|
15
|
+
|
16
|
+
static LocationProviderThread t;
|
14
17
|
|
15
18
|
@Override
|
16
19
|
public Result execute(String... args) {
|
17
20
|
|
18
|
-
LocationManager locationManager = (LocationManager) InstrumentationBackend.solo.getCurrentActivity().getSystemService(Context.LOCATION_SERVICE);
|
19
|
-
|
20
21
|
if(!doesDeviceProvideGPS()) {
|
21
22
|
return new Result(false, "This devices does not support GPS");
|
22
23
|
}
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
Location location = new Location(LocationManager.GPS_PROVIDER);
|
28
|
-
location.setLatitude(Double.parseDouble(args[0]));
|
29
|
-
location.setLongitude(Double.parseDouble(args[1]));
|
30
|
-
location.setTime(System.currentTimeMillis());
|
31
|
-
locationManager.setTestProviderLocation(LocationManager.GPS_PROVIDER, location);
|
25
|
+
final double latitude = Double.parseDouble(args[0]);
|
26
|
+
final double longitude = Double.parseDouble(args[1]);
|
27
|
+
|
32
28
|
|
29
|
+
if (t != null) {
|
30
|
+
t.finish();
|
31
|
+
}
|
32
|
+
|
33
|
+
t = new LocationProviderThread(latitude, longitude);
|
34
|
+
|
35
|
+
t.start();
|
36
|
+
|
33
37
|
return Result.successResult();
|
34
38
|
}
|
39
|
+
|
40
|
+
|
41
|
+
private class LocationProviderThread extends Thread {
|
42
|
+
|
43
|
+
private final double latitude;
|
44
|
+
private final double longitude;
|
45
|
+
|
46
|
+
boolean finish = false;
|
47
|
+
|
48
|
+
LocationProviderThread(double latitude, double longitude) {
|
49
|
+
this.latitude = latitude;
|
50
|
+
this.longitude = longitude;
|
51
|
+
}
|
52
|
+
|
53
|
+
@Override
|
54
|
+
public void run() {
|
55
|
+
LocationManager locationManager = (LocationManager) InstrumentationBackend.solo.getCurrentActivity().getSystemService(Context.LOCATION_SERVICE);
|
56
|
+
locationManager.addTestProvider(LocationManager.NETWORK_PROVIDER, false, false, false, false, false, false, false, Criteria.POWER_LOW, Criteria.ACCURACY_FINE);
|
57
|
+
locationManager.addTestProvider(LocationManager.GPS_PROVIDER, false, false, false, false, false, false, false, Criteria.POWER_LOW, Criteria.ACCURACY_FINE);
|
58
|
+
|
59
|
+
locationManager.setTestProviderEnabled(LocationManager.NETWORK_PROVIDER, true);
|
60
|
+
locationManager.setTestProviderEnabled(LocationManager.GPS_PROVIDER, true);
|
61
|
+
|
62
|
+
while(!finish) {
|
63
|
+
System.out.println("Mocking location to: (" + latitude + ", " + longitude + ")");
|
64
|
+
setLocation(locationManager, LocationManager.NETWORK_PROVIDER, latitude, longitude);
|
65
|
+
setLocation(locationManager, LocationManager.GPS_PROVIDER, latitude, longitude);
|
66
|
+
try {
|
67
|
+
Thread.sleep(1000);
|
68
|
+
} catch (InterruptedException e) {
|
69
|
+
throw new RuntimeException(e);
|
70
|
+
}
|
71
|
+
}
|
72
|
+
}
|
73
|
+
|
74
|
+
private void setLocation(LocationManager locationManager, String locationProvider, double latitude, double longitude) {
|
75
|
+
|
76
|
+
//locationManager.clearTestProviderLocation(locationProvider);
|
77
|
+
|
78
|
+
Location location = new Location(locationProvider);
|
79
|
+
location.setLatitude(latitude);
|
80
|
+
location.setLongitude(longitude);
|
81
|
+
location.setAccuracy(1);
|
82
|
+
location.setTime(System.currentTimeMillis());
|
83
|
+
|
84
|
+
locationManager.setTestProviderLocation(locationProvider, location);
|
85
|
+
}
|
86
|
+
|
87
|
+
public void finish() {
|
88
|
+
finish = true;
|
89
|
+
}
|
90
|
+
}
|
35
91
|
|
36
92
|
@Override
|
37
93
|
public String key() {
|
metadata
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: calabash-android
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 3048859453
|
5
|
+
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 2
|
9
9
|
- 0
|
10
|
-
|
10
|
+
- pre
|
11
|
+
- 2
|
12
|
+
version: 0.2.0.pre2
|
11
13
|
platform: ruby
|
12
14
|
authors:
|
13
15
|
- Jonas Maturana Larsen
|
@@ -15,7 +17,7 @@ autorequire:
|
|
15
17
|
bindir: bin
|
16
18
|
cert_chain: []
|
17
19
|
|
18
|
-
date: 2012-
|
20
|
+
date: 2012-07-23 00:00:00 +02:00
|
19
21
|
default_executable:
|
20
22
|
dependencies:
|
21
23
|
- !ruby/object:Gem::Dependency
|
@@ -99,9 +101,10 @@ files:
|
|
99
101
|
- lib/calabash-android/canned_steps.md
|
100
102
|
- lib/calabash-android/color_helper.rb
|
101
103
|
- lib/calabash-android/cucumber.rb
|
104
|
+
- lib/calabash-android/helpers.rb
|
105
|
+
- lib/calabash-android/lib/AXMLPrinter2.jar
|
102
106
|
- lib/calabash-android/lib/screenShotTaker.jar
|
103
107
|
- lib/calabash-android/management/adb.rb
|
104
|
-
- lib/calabash-android/management/app_installation.rb
|
105
108
|
- lib/calabash-android/operations.rb
|
106
109
|
- lib/calabash-android/steps/additions_manual_steps.rb
|
107
110
|
- lib/calabash-android/steps/app_steps.rb
|
@@ -126,7 +129,6 @@ files:
|
|
126
129
|
- test-server/instrumentation-backend/.settings/org.eclipse.jdt.core.prefs
|
127
130
|
- test-server/instrumentation-backend/AndroidManifest.xml
|
128
131
|
- test-server/instrumentation-backend/assets/foo.bar
|
129
|
-
- test-server/instrumentation-backend/gen/com/lesspainful/simpleui/test/R.java
|
130
132
|
- test-server/instrumentation-backend/libs/robotium-solo-3.3.jar
|
131
133
|
- test-server/instrumentation-backend/project.properties
|
132
134
|
- test-server/instrumentation-backend/res/drawable-hdpi/ic_launcher.png
|
@@ -141,6 +143,8 @@ files:
|
|
141
143
|
- test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/TestHelpers.java
|
142
144
|
- test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/Action.java
|
143
145
|
- test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/Actions.java
|
146
|
+
- test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/HttpServer.java
|
147
|
+
- test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/NanoHTTPD.java
|
144
148
|
- test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/NullAction.java
|
145
149
|
- test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/button/PressButtonNumber.java
|
146
150
|
- test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/button/PressButtonText.java
|
@@ -625,12 +629,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
625
629
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
626
630
|
none: false
|
627
631
|
requirements:
|
628
|
-
- - "
|
632
|
+
- - ">"
|
629
633
|
- !ruby/object:Gem::Version
|
630
|
-
hash:
|
634
|
+
hash: 25
|
631
635
|
segments:
|
632
|
-
-
|
633
|
-
|
636
|
+
- 1
|
637
|
+
- 3
|
638
|
+
- 1
|
639
|
+
version: 1.3.1
|
634
640
|
requirements: []
|
635
641
|
|
636
642
|
rubyforge_project:
|
@@ -1,21 +0,0 @@
|
|
1
|
-
def install_app(app_path)
|
2
|
-
|
3
|
-
cmd = "#{adb_command} install #{app_path}"
|
4
|
-
log "Installing: #{app_path}"
|
5
|
-
result = `#{cmd}`
|
6
|
-
if result.include? "Success"
|
7
|
-
log "Success"
|
8
|
-
else
|
9
|
-
log "#Failure"
|
10
|
-
log "'#{cmd}' said:"
|
11
|
-
log result.strip
|
12
|
-
raise "Could not install app #{app_path}: #{result.strip}"
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def uninstall_apps
|
17
|
-
log "Uninstalling: #{ENV["TEST_PACKAGE_NAME"]}"
|
18
|
-
log `#{adb_command} uninstall #{ENV["TEST_PACKAGE_NAME"]}`
|
19
|
-
log "Uninstalling: #{ENV["PACKAGE_NAME"]}"
|
20
|
-
log `#{adb_command} uninstall #{ENV["PACKAGE_NAME"]}`
|
21
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
/* AUTO-GENERATED FILE. DO NOT MODIFY.
|
2
|
-
*
|
3
|
-
* This class was automatically generated by the
|
4
|
-
* aapt tool from the resource data it found. It
|
5
|
-
* should not be modified by hand.
|
6
|
-
*/
|
7
|
-
|
8
|
-
package com.lesspainful.simpleui.test;
|
9
|
-
|
10
|
-
public final class R {
|
11
|
-
public static final class attr {
|
12
|
-
}
|
13
|
-
public static final class drawable {
|
14
|
-
public static final int ic_launcher=0x7f020000;
|
15
|
-
}
|
16
|
-
public static final class layout {
|
17
|
-
public static final int main=0x7f030000;
|
18
|
-
}
|
19
|
-
public static final class string {
|
20
|
-
public static final int app_name=0x7f040001;
|
21
|
-
public static final int hello=0x7f040000;
|
22
|
-
}
|
23
|
-
}
|