Skip to content

Commit

Permalink
Removed some methods in ViewFetcher
Browse files Browse the repository at this point in the history
  • Loading branch information
renas committed Feb 13, 2015
1 parent 1affded commit 5422490
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 53 deletions.
8 changes: 4 additions & 4 deletions robotium-solo/src/main/java/com/robotium/solo/Clicker.java
Expand Up @@ -37,7 +37,7 @@ class Clicker {
private final Waiter waiter;
private final WebUtils webUtils;
private final DialogUtils dialogUtils;
private final int MINI_WAIT = 200;
private final int MINI_WAIT = 300;
private final int WAIT_TIME = 1500;


Expand Down Expand Up @@ -78,7 +78,7 @@ public void clickOnScreen(float x, float y, View view) {
int retry = 0;
SecurityException ex = null;

while(!successfull && retry < 10) {
while(!successfull && retry < 20) {
long downTime = SystemClock.uptimeMillis();
long eventTime = SystemClock.uptimeMillis();
MotionEvent event = MotionEvent.obtain(downTime, eventTime,
Expand Down Expand Up @@ -123,7 +123,7 @@ public void clickLongOnScreen(float x, float y, int time, View view) {
long eventTime = SystemClock.uptimeMillis();
MotionEvent event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_DOWN, x, y, 0);

while(!successfull && retry < 10) {
while(!successfull && retry < 20) {
try{
inst.sendPointerSync(event);
successfull = true;
Expand Down Expand Up @@ -213,7 +213,7 @@ public void clickOnScreen(View view, boolean longClick, int time) {
*/

private float[] getClickCoordinates(View view){
sleeper.sleep(MINI_WAIT);
sleeper.sleep(200);
int[] xyLocation = new int[2];
float[] xyToClick = new float[2];

Expand Down
50 changes: 2 additions & 48 deletions robotium-solo/src/main/java/com/robotium/solo/ViewFetcher.java
Expand Up @@ -399,6 +399,7 @@ public View getIdenticalView(View view) {
break;
}
}

return viewToReturn;
}

Expand All @@ -412,66 +413,19 @@ public View getIdenticalView(View view) {
*/

private boolean areViewsIdentical(View firstView, View secondView){

if(firstView.getId() != secondView.getId() || !firstView.getClass().isAssignableFrom(secondView.getClass())){
return false;
}

if(!isSamePlacementInRespectiveTree(firstView, secondView)){
return false;
}

if (firstView.getParent() != null && firstView.getParent() instanceof View &&
secondView.getParent() != null && secondView.getParent() instanceof View) {

return areViewsIdentical((View) firstView.getParent(), (View) secondView.getParent());
} else {
return true;
}
}

/**
* Compares if two views have the same placement in their respective trees.
*
* @param firstView the first view to compare
* @param secondView the second view to compare
* @return true if equal placement and false if not
*/

private boolean isSamePlacementInRespectiveTree(View firstView, View secondView){

if(getObjectPlacementNumber(firstView) == getObjectPlacementNumber(secondView)){
return true;
}
return false;
}

/**
* Returns the placement number of the specified view relative to its parent.
*
* @param view the view to check placement number
* @return the object placement number of the specified view
*/

private int getObjectPlacementNumber(View view){
final ArrayList<View> allViewsFirst = new ArrayList<View>();
int numberOrder = 0;
try{
ViewParent parent = view.getParent();
if(parent instanceof ViewGroup){
addChildren(allViewsFirst, (ViewGroup) parent, true);
}

for(View v : allViewsFirst){
numberOrder++;
if(v.equals(view)){
break;
}
}
}catch(Exception ignored){}
return numberOrder;
}

private static Class<?> windowManager;
static{
try {
Expand Down
2 changes: 1 addition & 1 deletion robotium-solo/src/main/java/com/robotium/solo/Waiter.java
Expand Up @@ -30,7 +30,7 @@ class Waiter {
private final Searcher searcher;
private final Scroller scroller;
private final Sleeper sleeper;
private final int MINISLEEP = 15;
private final int MINISLEEP = 10;


/**
Expand Down

0 comments on commit 5422490

Please sign in to comment.