calabash-android 0.4.0.pre15 → 0.4.0.pre16
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/calabash-android/lib/TestServer.apk +0 -0
- data/lib/calabash-android/version.rb +2 -2
- data/test-server/instrumentation-backend/antlr/UIQuery.g +4 -1
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/version/Version.java +1 -1
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/Query.java +4 -0
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/UIQuery.tokens +16 -15
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/antlr/UIQueryLexer.java +598 -452
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/antlr/UIQueryParser.java +158 -137
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/ast/UIQueryASTClassName.java +26 -3
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/ast/UIQueryDirection.java +12 -2
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/ast/UIQueryEvaluator.java +4 -9
- metadata +1 -1
@@ -4,6 +4,8 @@ import java.util.ArrayList;
|
|
4
4
|
import java.util.List;
|
5
5
|
import java.util.concurrent.Callable;
|
6
6
|
|
7
|
+
import android.view.View;
|
8
|
+
|
7
9
|
public class UIQueryASTClassName implements UIQueryAST {
|
8
10
|
public final String simpleClassName;
|
9
11
|
@SuppressWarnings("rawtypes")
|
@@ -45,6 +47,9 @@ public class UIQueryASTClassName implements UIQueryAST {
|
|
45
47
|
case PARENT:
|
46
48
|
addParentMatchesToResult(o,result);
|
47
49
|
break;
|
50
|
+
case SIBLING:
|
51
|
+
addSiblingMatchesToResult(o,result);
|
52
|
+
break;
|
48
53
|
}
|
49
54
|
|
50
55
|
|
@@ -56,10 +61,28 @@ public class UIQueryASTClassName implements UIQueryAST {
|
|
56
61
|
|
57
62
|
}
|
58
63
|
|
59
|
-
@SuppressWarnings("rawtypes")
|
64
|
+
@SuppressWarnings({ "rawtypes", "unchecked" })
|
65
|
+
protected void addSiblingMatchesToResult(Object o, List result) {
|
66
|
+
List parents = UIQueryUtils.parents(o);
|
67
|
+
if (parents != null && !parents.isEmpty()) {
|
68
|
+
Object immediateParent = parents.get(0);
|
69
|
+
for (Object v : UIQueryUtils.subviews(immediateParent)) {
|
70
|
+
if (v != o && match(v)) {
|
71
|
+
result.add(v);
|
72
|
+
}
|
73
|
+
}
|
74
|
+
}
|
75
|
+
}
|
76
|
+
|
77
|
+
@SuppressWarnings({ "rawtypes", "unchecked" })
|
60
78
|
private void addParentMatchesToResult(Object o, List result) {
|
61
|
-
|
62
|
-
|
79
|
+
for (Object parent : UIQueryUtils.parents(o))
|
80
|
+
{
|
81
|
+
if (match(parent))
|
82
|
+
{
|
83
|
+
result.add(parent);
|
84
|
+
}
|
85
|
+
}
|
63
86
|
}
|
64
87
|
|
65
88
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
@@ -1,5 +1,15 @@
|
|
1
1
|
package sh.calaba.instrumentationbackend.query.ast;
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
import java.util.List;
|
4
|
+
|
5
|
+
public enum UIQueryDirection implements UIQueryAST {
|
6
|
+
DESCENDANT, CHILD, PARENT, SIBLING;
|
7
|
+
|
8
|
+
@SuppressWarnings("rawtypes")
|
9
|
+
@Override
|
10
|
+
public List evaluateWithViews(List inputViews, UIQueryDirection direction,
|
11
|
+
UIQueryVisibility visibility) {
|
12
|
+
//Never called. Not so pretty, I know.
|
13
|
+
throw new UnsupportedOperationException("This method should never be called");
|
14
|
+
}
|
5
15
|
}
|
@@ -77,8 +77,8 @@ public class UIQueryEvaluator {
|
|
77
77
|
UIQueryVisibility currentVisibility = UIQueryVisibility.VISIBLE;
|
78
78
|
|
79
79
|
for (UIQueryAST step : queryPath) {
|
80
|
-
if (
|
81
|
-
currentDirection =
|
80
|
+
if (step instanceof UIQueryDirection) {
|
81
|
+
currentDirection = (UIQueryDirection) step;
|
82
82
|
}
|
83
83
|
else if (step instanceof UIQueryVisibility) {
|
84
84
|
currentVisibility = (UIQueryVisibility) step;
|
@@ -90,15 +90,10 @@ public class UIQueryEvaluator {
|
|
90
90
|
}
|
91
91
|
return currentResult;
|
92
92
|
}
|
93
|
-
|
94
|
-
public static UIQueryDirection directionFromAst(UIQueryAST step) {
|
95
|
-
// TODO Auto-generated method stub
|
96
|
-
return null;
|
97
|
-
}
|
93
|
+
|
98
94
|
|
99
95
|
public static boolean isDirection(UIQueryAST step) {
|
100
|
-
|
101
|
-
return false;
|
96
|
+
return step instanceof UIQueryDirection;
|
102
97
|
}
|
103
98
|
|
104
99
|
}
|