calabash-android 0.4.15.pre1 → 0.4.15.pre2

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: d5eae7958aa42bb890bce213080b57a787677f4b
4
- data.tar.gz: 6c053a02a4974b3b87738453e9f516a9ea4927e4
3
+ metadata.gz: e755b2bf29c1fc5dfb3dcf8a268cc4a742af6153
4
+ data.tar.gz: 0d9cb17214c52a01e58166d8fce6e6ab6fc01087
5
5
  SHA512:
6
- metadata.gz: a53197a47f6009f6cf5b1f6017df9065396bd4aad5e5c97dcac0dcb5fe03dfb81513202a4c9ebf1049f0a54f8a938c7ce256a44c9f51ca54ab7b7a87e4fc82d0
7
- data.tar.gz: 19dfb707600e501ff59abb80f8fb0cbb881d32658b376cbe4be6fe9f912c75a903c0f969b16f7130f5cd3bc1c24ce25e7108977e33a4f23d24cc3e644eebe80c
6
+ metadata.gz: bc5a1b74c3e3cbca6e1ba51ec043392d4e2bf4fdf1ad66aaa39c7d8d74ada62c5859ab17d96f64c548d4c5e7c96acb50102d7dbe91ff3fc035f310db2807c29f
7
+ data.tar.gz: 95c1a94f439c58ace65d2a9343736cec61f1ecd17f70f8dde301a31a86ad0d610e41b8da6a285b01a6a126eadc870884174b611914442ac48eedd5756cce21fb
@@ -1,5 +1,5 @@
1
1
  module Calabash
2
2
  module Android
3
- VERSION = "0.4.15.pre1"
3
+ VERSION = "0.4.15.pre2"
4
4
  end
5
5
  end
@@ -5,7 +5,7 @@ import android.app.Instrumentation;
5
5
 
6
6
  public class PublicViewFetcher extends ViewFetcher {
7
7
 
8
- public PublicViewFetcher(Instrumentation instrumentation, Activity activity) {
9
- super(new ActivityUtils(instrumentation, activity, new Sleeper()));
8
+ public PublicViewFetcher(ActivityUtils activityUtils) {
9
+ super(activityUtils);
10
10
  }
11
11
  }
@@ -1,96 +1,75 @@
1
- package com.jayway.android.robotium.solo;
2
-
3
- import java.util.List;
4
-
5
- import android.app.Instrumentation;
6
-
7
- public class SoloEnhanced extends Solo {
8
- // private Pincher pincher;
9
- private MapViewUtils mapViewUtils;
10
-
11
- public SoloEnhanced(Instrumentation instrumentation) {
12
- super(instrumentation);
13
- this.mapViewUtils = new MapViewUtils(instrumentation, viewFetcher, sleeper, waiter);
14
- // this.pincher = new Pincher(instrumentation, viewFetcher);
15
- }
16
-
17
- public void setMapCenter( double lat, double lon ) {
18
- mapViewUtils.setCenter(lat, lon);
19
- }
20
-
21
- /** @return {lat,lon} */
22
- public double[] getMapCenter() {
23
- return mapViewUtils.getMapCenter();
24
- }
25
-
26
- public void panMapTo( double lat, double lon ) {
27
- mapViewUtils.panTo(lat, lon);
28
- }
29
-
30
- public boolean zoomInOnMap() {
31
- return mapViewUtils.zoomIn();
32
- }
33
-
34
- public boolean zoomOutOnMap() {
35
- return mapViewUtils.zoomOut();
36
- }
37
-
38
- public int setMapZoom( int zoomLevel ) {
39
- return mapViewUtils.setZoom(zoomLevel);
40
- }
41
-
42
- public int getMapZoom() {
43
- return mapViewUtils.getZoom();
44
- }
45
-
46
- public List<String> getMapMarkerItems() {
47
- return mapViewUtils.getMarkerItems();
48
- }
49
-
50
- public String getMapMarkerItem( String title ) {
51
- return mapViewUtils.getMarkerItem( title );
52
- }
53
-
54
- /**
55
- * @param title
56
- * @param timeout in ms
57
- * @return
58
- */
59
- public boolean tapMapMarkerItem( String title, long timeout ) {
60
- return mapViewUtils.tapMarkerItem( title, timeout );
61
- }
62
-
63
- public boolean tapMapAwayFromMarkers( int step ) {
64
- return mapViewUtils.tapAwayFromMarkerItems( step );
65
- }
66
-
67
- /**
68
- * @return [top, right, bottom, left] in decimal degrees
69
- */
70
- public List<String> getMapBounds() {
71
- return mapViewUtils.getBounds();
72
- }
73
-
74
- // /**
75
- // * Sorry, doesn't work yet
76
- // * @param togetherOrApart - {@link Pincher#TOGETHER} or {@link Pincher#APART}
77
- // */
78
- // public void pinch(int togetherOrApart) {
79
- // switch( togetherOrApart ) {
80
- // case Pincher.TOGETHER: pincher.pinch(Pincher.Direction.TOGETHER); break;
81
- // case Pincher.APART: pincher.pinch(Pincher.Direction.APART); break;
82
- // }
83
- // }
84
- //
85
- // /**
86
- // * Sorry, doesn't work yet
87
- // * @param togetherOrApart - {@link Pincher#TOGETHER} or {@link Pincher#APART}
88
- // * @param view
89
- // */
90
- // public void pinch(int togetherOrApart, View view) {
91
- // switch( togetherOrApart ) {
92
- // case Pincher.TOGETHER: pincher.pinch(Pincher.Direction.TOGETHER, view); break;
93
- // case Pincher.APART: pincher.pinch(Pincher.Direction.APART, view); break;
94
- // }
95
- // }
96
- }
1
+ package com.jayway.android.robotium.solo;
2
+
3
+ import java.util.List;
4
+
5
+ import android.app.Activity;
6
+ import android.app.Instrumentation;
7
+
8
+ public class SoloEnhanced extends Solo {
9
+ private MapViewUtils mapViewUtils;
10
+
11
+ public SoloEnhanced(Instrumentation instrumentation, Activity activity) {
12
+ super(instrumentation, activity);
13
+ this.mapViewUtils = new MapViewUtils(instrumentation, viewFetcher, sleeper, waiter);
14
+ }
15
+ public ActivityUtils getActivityUtils() {
16
+ return activityUtils;
17
+ }
18
+
19
+ public void setMapCenter( double lat, double lon ) {
20
+ mapViewUtils.setCenter(lat, lon);
21
+ }
22
+
23
+ /** @return {lat,lon} */
24
+ public double[] getMapCenter() {
25
+ return mapViewUtils.getMapCenter();
26
+ }
27
+
28
+ public void panMapTo( double lat, double lon ) {
29
+ mapViewUtils.panTo(lat, lon);
30
+ }
31
+
32
+ public boolean zoomInOnMap() {
33
+ return mapViewUtils.zoomIn();
34
+ }
35
+
36
+ public boolean zoomOutOnMap() {
37
+ return mapViewUtils.zoomOut();
38
+ }
39
+
40
+ public int setMapZoom( int zoomLevel ) {
41
+ return mapViewUtils.setZoom(zoomLevel);
42
+ }
43
+
44
+ public int getMapZoom() {
45
+ return mapViewUtils.getZoom();
46
+ }
47
+
48
+ public List<String> getMapMarkerItems() {
49
+ return mapViewUtils.getMarkerItems();
50
+ }
51
+
52
+ public String getMapMarkerItem( String title ) {
53
+ return mapViewUtils.getMarkerItem( title );
54
+ }
55
+
56
+ /**
57
+ * @param title
58
+ * @param timeout in ms
59
+ * @return
60
+ */
61
+ public boolean tapMapMarkerItem( String title, long timeout ) {
62
+ return mapViewUtils.tapMarkerItem( title, timeout );
63
+ }
64
+
65
+ public boolean tapMapAwayFromMarkers( int step ) {
66
+ return mapViewUtils.tapAwayFromMarkerItems( step );
67
+ }
68
+
69
+ /**
70
+ * @return [top, right, bottom, left] in decimal degrees
71
+ */
72
+ public List<String> getMapBounds() {
73
+ return mapViewUtils.getBounds();
74
+ }
75
+ }
@@ -1,5 +1,7 @@
1
1
  package sh.calaba.instrumentationbackend;
2
2
 
3
+ import android.os.Looper;
4
+ import android.os.MessageQueue;
3
5
  import sh.calaba.instrumentationbackend.actions.Actions;
4
6
  import sh.calaba.instrumentationbackend.actions.HttpServer;
5
7
  import android.Manifest;
@@ -16,6 +18,10 @@ import android.util.Log;
16
18
  import com.jayway.android.robotium.solo.PublicViewFetcher;
17
19
  import com.jayway.android.robotium.solo.SoloEnhanced;
18
20
 
21
+ import java.lang.reflect.Field;
22
+ import java.util.List;
23
+ import java.util.concurrent.atomic.AtomicReference;
24
+
19
25
  public class InstrumentationBackend extends ActivityInstrumentationTestCase2<Activity> {
20
26
  public static String testPackage;
21
27
  public static Class<? extends Activity> mainActivity;
@@ -40,8 +46,7 @@ public class InstrumentationBackend extends ActivityInstrumentationTestCase2<Act
40
46
  i.setClassName(testPackage, mainActivity.getName());
41
47
  i.putExtras(extras);
42
48
  setActivityIntent(i);
43
- solo = new SoloEnhanced(getInstrumentation());
44
- viewFetcher = new PublicViewFetcher(getInstrumentation(), this.getActivity());
49
+
45
50
  actions = new Actions(getInstrumentation(), this);
46
51
  instrumentation = getInstrumentation();
47
52
  }
@@ -49,12 +54,70 @@ public class InstrumentationBackend extends ActivityInstrumentationTestCase2<Act
49
54
  /**
50
55
  * Here to have JUnit3 start the instrumentationBackend
51
56
  */
57
+
52
58
  public void testHook() throws Exception {
53
- HttpServer httpServer = HttpServer.getInstance();
54
- httpServer.setReady();
55
- httpServer.waitUntilShutdown();
56
- solo.finishOpenedActivities();
57
- System.exit(0);
59
+
60
+ final AtomicReference<Activity> activityReference = new AtomicReference<Activity>();
61
+ Thread activityStarter = new Thread() {
62
+ public void run() {
63
+ activityReference.set(getActivity());
64
+ }
65
+ };
66
+ activityStarter.start();
67
+ activityStarter.join(10000);
68
+
69
+ Activity activity = null;
70
+ if (activityReference.get() != null) {
71
+ activity = activityReference.get();
72
+ System.out.println("testHook: Activity set to: " + activity);
73
+ } else {
74
+ System.out.println("testHook: Activity not set");
75
+ try {
76
+
77
+ Field mQueue = Looper.getMainLooper().getClass().getDeclaredField("mQueue");
78
+ mQueue.setAccessible(true);
79
+ MessageQueue messageQueue = (MessageQueue)mQueue.get(Looper.getMainLooper());
80
+
81
+ Field f = messageQueue.getClass().getDeclaredField("mIdleHandlers");
82
+ f.setAccessible(true);
83
+ List<?> waiters = (List<?>)f.get(messageQueue);
84
+ for(Object o : waiters) {
85
+ Class<?> activityGoingClazz = o.getClass();
86
+ if (!activityGoingClazz.getName().equals("android.app.Instrumentation$ActivityGoing")) {
87
+ continue;
88
+ }
89
+
90
+
91
+ Field mWaiterField = activityGoingClazz.getDeclaredField("mWaiter");
92
+ mWaiterField.setAccessible(true);
93
+ Object waiter = mWaiterField.get(o);
94
+ Class<?> activityWaiterClazz = waiter.getClass();
95
+
96
+ Field activityField = activityWaiterClazz.getDeclaredField("activity");
97
+ activityField.setAccessible(true);
98
+ activity = (Activity)activityField.get(waiter);
99
+
100
+ instrumentation.addMonitor(new Instrumentation.ActivityMonitor(activity.getClass().getName(), null, false));
101
+
102
+ }
103
+ } catch (Exception e) {
104
+ e.printStackTrace();
105
+ }
106
+ }
107
+ if (activity != null) {
108
+ solo = new SoloEnhanced(getInstrumentation(), activity);
109
+ setActivity(activity);
110
+
111
+ viewFetcher = new PublicViewFetcher(solo.getActivityUtils());
112
+
113
+ HttpServer httpServer = HttpServer.getInstance();
114
+ httpServer.setReady();
115
+ httpServer.waitUntilShutdown();
116
+ solo.finishOpenedActivities();
117
+ System.exit(0);
118
+ } else {
119
+ throw new RuntimeException("Could not get detect the first Activity");
120
+ }
58
121
  }
59
122
 
60
123
  @Override
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.4.15.pre1
4
+ version: 0.4.15.pre2
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: 2013-10-25 00:00:00.000000000 Z
11
+ date: 2013-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cucumber