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.
@@ -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
- // TODO Auto-generated method stub
62
- throw new UnsupportedOperationException();
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
- public enum UIQueryDirection {
4
- DESCENDANT, CHILD, PARENT, ANCESTOR, SIBLING;
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 (isDirection(step)) {
81
- currentDirection = directionFromAst(step);
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
- // TODO Auto-generated method stub
101
- return false;
96
+ return step instanceof UIQueryDirection;
102
97
  }
103
98
 
104
99
  }
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.4.0.pre15
4
+ version: 0.4.0.pre16
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors: