id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
30,000
uber/NullAway
jar-infer/jar-infer-lib/src/main/java/com/uber/nullaway/jarinfer/DefinitelyDerefedParamsDriver.java
DefinitelyDerefedParamsDriver.getSimpleTypeName
private static String getSimpleTypeName(TypeReference typ) { final Map<String, String> mapFullTypeName = ImmutableMap.<String, String>builder() .put("B", "byte") .put("C", "char") .put("D", "double") .put("F", "float") .put("I", "int") .put("J", "long") .put("S", "short") .put("Z", "boolean") .build(); if (typ.isArrayType()) return "Array"; String typName = typ.getName().toString(); if (typName.startsWith("L")) { typName = typName.split("<")[0].substring(1); // handle generics typName = typName.substring(typName.lastIndexOf('/') + 1); // get unqualified name typName = typName.substring(typName.lastIndexOf('$') + 1); // handle inner classes } else { typName = mapFullTypeName.get(typName); } return typName; }
java
private static String getSimpleTypeName(TypeReference typ) { final Map<String, String> mapFullTypeName = ImmutableMap.<String, String>builder() .put("B", "byte") .put("C", "char") .put("D", "double") .put("F", "float") .put("I", "int") .put("J", "long") .put("S", "short") .put("Z", "boolean") .build(); if (typ.isArrayType()) return "Array"; String typName = typ.getName().toString(); if (typName.startsWith("L")) { typName = typName.split("<")[0].substring(1); // handle generics typName = typName.substring(typName.lastIndexOf('/') + 1); // get unqualified name typName = typName.substring(typName.lastIndexOf('$') + 1); // handle inner classes } else { typName = mapFullTypeName.get(typName); } return typName; }
[ "private", "static", "String", "getSimpleTypeName", "(", "TypeReference", "typ", ")", "{", "final", "Map", "<", "String", ",", "String", ">", "mapFullTypeName", "=", "ImmutableMap", ".", "<", "String", ",", "String", ">", "builder", "(", ")", ".", "put", "...
Get simple unqualified type name. @param typ Type Reference. @return String Unqualified type name.
[ "Get", "simple", "unqualified", "type", "name", "." ]
c3979b4241f80411dbba6aac3ff653acbb88d00b
https://github.com/uber/NullAway/blob/c3979b4241f80411dbba6aac3ff653acbb88d00b/jar-infer/jar-infer-lib/src/main/java/com/uber/nullaway/jarinfer/DefinitelyDerefedParamsDriver.java#L400-L422
30,001
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/GLRenderWrapper.java
GLRenderWrapper.savePixels
private Bitmap savePixels(int x, int y, int w, int h) { int b[] = new int[w * (y + h)]; int bt[] = new int[w * h]; IntBuffer ib = IntBuffer.wrap(b); ib.position(0); GLES20.glReadPixels(x, 0, w, y + h, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, ib); for (int i = 0, k = 0; i < h; i++, k++) { // remember, that OpenGL bitmap is incompatible with Android bitmap // and so, some correction need. for (int j = 0; j < w; j++) { int pix = b[i * w + j]; int pb = (pix >> 16) & 0xff; int pr = (pix << 16) & 0x00ff0000; int pix1 = (pix & 0xff00ff00) | pr | pb; bt[(h - k - 1) * w + j] = pix1; } } Bitmap sb = Bitmap.createBitmap(bt, w, h, Bitmap.Config.ARGB_8888); return sb; }
java
private Bitmap savePixels(int x, int y, int w, int h) { int b[] = new int[w * (y + h)]; int bt[] = new int[w * h]; IntBuffer ib = IntBuffer.wrap(b); ib.position(0); GLES20.glReadPixels(x, 0, w, y + h, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, ib); for (int i = 0, k = 0; i < h; i++, k++) { // remember, that OpenGL bitmap is incompatible with Android bitmap // and so, some correction need. for (int j = 0; j < w; j++) { int pix = b[i * w + j]; int pb = (pix >> 16) & 0xff; int pr = (pix << 16) & 0x00ff0000; int pix1 = (pix & 0xff00ff00) | pr | pb; bt[(h - k - 1) * w + j] = pix1; } } Bitmap sb = Bitmap.createBitmap(bt, w, h, Bitmap.Config.ARGB_8888); return sb; }
[ "private", "Bitmap", "savePixels", "(", "int", "x", ",", "int", "y", ",", "int", "w", ",", "int", "h", ")", "{", "int", "b", "[", "]", "=", "new", "int", "[", "w", "*", "(", "y", "+", "h", ")", "]", ";", "int", "bt", "[", "]", "=", "new",...
Extract the bitmap from OpenGL @param x the start column @param y the start line @param w the width of the bitmap @param h the height of the bitmap
[ "Extract", "the", "bitmap", "from", "OpenGL" ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/GLRenderWrapper.java#L128-L150
30,002
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/Scroller.java
Scroller.drag
public void drag(float fromX, float toX, float fromY, float toY, int stepCount) { long downTime = SystemClock.uptimeMillis(); long eventTime = SystemClock.uptimeMillis(); float y = fromY; float x = fromX; float yStep = (toY - fromY) / stepCount; float xStep = (toX - fromX) / stepCount; MotionEvent event = MotionEvent.obtain(downTime, eventTime,MotionEvent.ACTION_DOWN, fromX, fromY, 0); try { inst.sendPointerSync(event); } catch (SecurityException ignored) {} for (int i = 0; i < stepCount; ++i) { y += yStep; x += xStep; eventTime = SystemClock.uptimeMillis(); event = MotionEvent.obtain(downTime, eventTime,MotionEvent.ACTION_MOVE, x, y, 0); try { inst.sendPointerSync(event); } catch (SecurityException ignored) {} } eventTime = SystemClock.uptimeMillis(); event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_UP,toX, toY, 0); try { inst.sendPointerSync(event); } catch (SecurityException ignored) {} }
java
public void drag(float fromX, float toX, float fromY, float toY, int stepCount) { long downTime = SystemClock.uptimeMillis(); long eventTime = SystemClock.uptimeMillis(); float y = fromY; float x = fromX; float yStep = (toY - fromY) / stepCount; float xStep = (toX - fromX) / stepCount; MotionEvent event = MotionEvent.obtain(downTime, eventTime,MotionEvent.ACTION_DOWN, fromX, fromY, 0); try { inst.sendPointerSync(event); } catch (SecurityException ignored) {} for (int i = 0; i < stepCount; ++i) { y += yStep; x += xStep; eventTime = SystemClock.uptimeMillis(); event = MotionEvent.obtain(downTime, eventTime,MotionEvent.ACTION_MOVE, x, y, 0); try { inst.sendPointerSync(event); } catch (SecurityException ignored) {} } eventTime = SystemClock.uptimeMillis(); event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_UP,toX, toY, 0); try { inst.sendPointerSync(event); } catch (SecurityException ignored) {} }
[ "public", "void", "drag", "(", "float", "fromX", ",", "float", "toX", ",", "float", "fromY", ",", "float", "toY", ",", "int", "stepCount", ")", "{", "long", "downTime", "=", "SystemClock", ".", "uptimeMillis", "(", ")", ";", "long", "eventTime", "=", "...
Simulate touching a specific location and dragging to a new location. This method was copied from {@code TouchUtils.java} in the Android Open Source Project, and modified here. @param fromX X coordinate of the initial touch, in screen coordinates @param toX Xcoordinate of the drag destination, in screen coordinates @param fromY X coordinate of the initial touch, in screen coordinates @param toY Y coordinate of the drag destination, in screen coordinates @param stepCount How many move steps to include in the drag
[ "Simulate", "touching", "a", "specific", "location", "and", "dragging", "to", "a", "new", "location", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Scroller.java#L69-L95
30,003
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/Scroller.java
Scroller.scrollView
public boolean scrollView(final View view, int direction){ if(view == null){ return false; } int height = view.getHeight(); height--; int scrollTo = -1; if (direction == DOWN) { scrollTo = height; } else if (direction == UP) { scrollTo = -height; } int originalY = view.getScrollY(); final int scrollAmount = scrollTo; inst.runOnMainSync(new Runnable(){ public void run(){ view.scrollBy(0, scrollAmount); } }); if (originalY == view.getScrollY()) { return false; } else{ return true; } }
java
public boolean scrollView(final View view, int direction){ if(view == null){ return false; } int height = view.getHeight(); height--; int scrollTo = -1; if (direction == DOWN) { scrollTo = height; } else if (direction == UP) { scrollTo = -height; } int originalY = view.getScrollY(); final int scrollAmount = scrollTo; inst.runOnMainSync(new Runnable(){ public void run(){ view.scrollBy(0, scrollAmount); } }); if (originalY == view.getScrollY()) { return false; } else{ return true; } }
[ "public", "boolean", "scrollView", "(", "final", "View", "view", ",", "int", "direction", ")", "{", "if", "(", "view", "==", "null", ")", "{", "return", "false", ";", "}", "int", "height", "=", "view", ".", "getHeight", "(", ")", ";", "height", "--",...
Scrolls a ScrollView. @param direction the direction to be scrolled @return {@code true} if scrolling occurred, false if it did not
[ "Scrolls", "a", "ScrollView", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Scroller.java#L105-L136
30,004
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/Scroller.java
Scroller.scroll
@SuppressWarnings("unchecked") public boolean scroll(int direction, boolean allTheWay) { ArrayList<View> viewList = RobotiumUtils.removeInvisibleViews(viewFetcher.getAllViews(true)); ArrayList<View> filteredViews = RobotiumUtils.filterViewsToSet(new Class[] { ListView.class, ScrollView.class, GridView.class, WebView.class}, viewList); List<View> scrollableSupportPackageViews = viewFetcher.getScrollableSupportPackageViews(true); for(View viewToScroll : scrollableSupportPackageViews){ filteredViews.add(viewToScroll); } View view = viewFetcher.getFreshestView(filteredViews); if (view == null) { return false; } if (view instanceof AbsListView) { return scrollList((AbsListView)view, direction, allTheWay); } if(view instanceof WebView){ return scrollWebView((WebView)view, direction, allTheWay); } if (allTheWay) { scrollViewAllTheWay(view, direction); return false; } else { return scrollView(view, direction); } }
java
@SuppressWarnings("unchecked") public boolean scroll(int direction, boolean allTheWay) { ArrayList<View> viewList = RobotiumUtils.removeInvisibleViews(viewFetcher.getAllViews(true)); ArrayList<View> filteredViews = RobotiumUtils.filterViewsToSet(new Class[] { ListView.class, ScrollView.class, GridView.class, WebView.class}, viewList); List<View> scrollableSupportPackageViews = viewFetcher.getScrollableSupportPackageViews(true); for(View viewToScroll : scrollableSupportPackageViews){ filteredViews.add(viewToScroll); } View view = viewFetcher.getFreshestView(filteredViews); if (view == null) { return false; } if (view instanceof AbsListView) { return scrollList((AbsListView)view, direction, allTheWay); } if(view instanceof WebView){ return scrollWebView((WebView)view, direction, allTheWay); } if (allTheWay) { scrollViewAllTheWay(view, direction); return false; } else { return scrollView(view, direction); } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "boolean", "scroll", "(", "int", "direction", ",", "boolean", "allTheWay", ")", "{", "ArrayList", "<", "View", ">", "viewList", "=", "RobotiumUtils", ".", "removeInvisibleViews", "(", "viewFetcher", "...
Scrolls up and down. @param direction the direction in which to scroll @param allTheWay <code>true</code> if the view should be scrolled to the beginning or end, <code>false</code> to scroll one page up or down. @return {@code true} if more scrolling can be done
[ "Scrolls", "up", "and", "down", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Scroller.java#L181-L214
30,005
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/Scroller.java
Scroller.scrollWebView
public boolean scrollWebView(final WebView webView, int direction, final boolean allTheWay){ if (direction == DOWN) { inst.runOnMainSync(new Runnable(){ public void run(){ canScroll = webView.pageDown(allTheWay); } }); } if(direction == UP){ inst.runOnMainSync(new Runnable(){ public void run(){ canScroll = webView.pageUp(allTheWay); } }); } return canScroll; }
java
public boolean scrollWebView(final WebView webView, int direction, final boolean allTheWay){ if (direction == DOWN) { inst.runOnMainSync(new Runnable(){ public void run(){ canScroll = webView.pageDown(allTheWay); } }); } if(direction == UP){ inst.runOnMainSync(new Runnable(){ public void run(){ canScroll = webView.pageUp(allTheWay); } }); } return canScroll; }
[ "public", "boolean", "scrollWebView", "(", "final", "WebView", "webView", ",", "int", "direction", ",", "final", "boolean", "allTheWay", ")", "{", "if", "(", "direction", "==", "DOWN", ")", "{", "inst", ".", "runOnMainSync", "(", "new", "Runnable", "(", ")...
Scrolls a WebView. @param webView the WebView to scroll @param direction the direction to scroll @param allTheWay {@code true} to scroll the view all the way up or down, {@code false} to scroll one page up or down or down. @return {@code true} if more scrolling can be done
[ "Scrolls", "a", "WebView", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Scroller.java#L225-L242
30,006
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/Scroller.java
Scroller.scrollList
public <T extends AbsListView> boolean scrollList(T absListView, int direction, boolean allTheWay) { if(absListView == null){ return false; } if (direction == DOWN) { int listCount = absListView.getCount(); int lastVisiblePosition = absListView.getLastVisiblePosition(); if (allTheWay) { scrollListToLine(absListView, listCount-1); return false; } if (lastVisiblePosition >= listCount - 1) { if(lastVisiblePosition > 0){ scrollListToLine(absListView, lastVisiblePosition); } return false; } int firstVisiblePosition = absListView.getFirstVisiblePosition(); if(firstVisiblePosition != lastVisiblePosition) scrollListToLine(absListView, lastVisiblePosition); else scrollListToLine(absListView, firstVisiblePosition + 1); } else if (direction == UP) { int firstVisiblePosition = absListView.getFirstVisiblePosition(); if (allTheWay || firstVisiblePosition < 2) { scrollListToLine(absListView, 0); return false; } int lastVisiblePosition = absListView.getLastVisiblePosition(); final int lines = lastVisiblePosition - firstVisiblePosition; int lineToScrollTo = firstVisiblePosition - lines; if(lineToScrollTo == lastVisiblePosition) lineToScrollTo--; if(lineToScrollTo < 0) lineToScrollTo = 0; scrollListToLine(absListView, lineToScrollTo); } sleeper.sleep(); return true; }
java
public <T extends AbsListView> boolean scrollList(T absListView, int direction, boolean allTheWay) { if(absListView == null){ return false; } if (direction == DOWN) { int listCount = absListView.getCount(); int lastVisiblePosition = absListView.getLastVisiblePosition(); if (allTheWay) { scrollListToLine(absListView, listCount-1); return false; } if (lastVisiblePosition >= listCount - 1) { if(lastVisiblePosition > 0){ scrollListToLine(absListView, lastVisiblePosition); } return false; } int firstVisiblePosition = absListView.getFirstVisiblePosition(); if(firstVisiblePosition != lastVisiblePosition) scrollListToLine(absListView, lastVisiblePosition); else scrollListToLine(absListView, firstVisiblePosition + 1); } else if (direction == UP) { int firstVisiblePosition = absListView.getFirstVisiblePosition(); if (allTheWay || firstVisiblePosition < 2) { scrollListToLine(absListView, 0); return false; } int lastVisiblePosition = absListView.getLastVisiblePosition(); final int lines = lastVisiblePosition - firstVisiblePosition; int lineToScrollTo = firstVisiblePosition - lines; if(lineToScrollTo == lastVisiblePosition) lineToScrollTo--; if(lineToScrollTo < 0) lineToScrollTo = 0; scrollListToLine(absListView, lineToScrollTo); } sleeper.sleep(); return true; }
[ "public", "<", "T", "extends", "AbsListView", ">", "boolean", "scrollList", "(", "T", "absListView", ",", "int", "direction", ",", "boolean", "allTheWay", ")", "{", "if", "(", "absListView", "==", "null", ")", "{", "return", "false", ";", "}", "if", "(",...
Scrolls a list. @param absListView the list to be scrolled @param direction the direction to be scrolled @param allTheWay {@code true} to scroll the view all the way up or down, {@code false} to scroll one page up or down @return {@code true} if more scrolling can be done
[ "Scrolls", "a", "list", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Scroller.java#L253-L308
30,007
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/Scroller.java
Scroller.scrollListToLine
public <T extends AbsListView> void scrollListToLine(final T view, final int line){ if(view == null) Assert.fail("AbsListView is null!"); final int lineToMoveTo; if(view instanceof GridView) { lineToMoveTo = line+1; } else { lineToMoveTo = line; } inst.runOnMainSync(new Runnable(){ public void run(){ view.setSelection(lineToMoveTo); } }); }
java
public <T extends AbsListView> void scrollListToLine(final T view, final int line){ if(view == null) Assert.fail("AbsListView is null!"); final int lineToMoveTo; if(view instanceof GridView) { lineToMoveTo = line+1; } else { lineToMoveTo = line; } inst.runOnMainSync(new Runnable(){ public void run(){ view.setSelection(lineToMoveTo); } }); }
[ "public", "<", "T", "extends", "AbsListView", ">", "void", "scrollListToLine", "(", "final", "T", "view", ",", "final", "int", "line", ")", "{", "if", "(", "view", "==", "null", ")", "Assert", ".", "fail", "(", "\"AbsListView is null!\"", ")", ";", "fina...
Scroll the list to a given line @param view the {@link AbsListView} to scroll @param line the line to scroll to
[ "Scroll", "the", "list", "to", "a", "given", "line" ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Scroller.java#L318-L335
30,008
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/Scroller.java
Scroller.scrollViewToSide
public void scrollViewToSide(View view, Side side, float scrollPosition, int stepCount) { int[] corners = new int[2]; view.getLocationOnScreen(corners); int viewHeight = view.getHeight(); int viewWidth = view.getWidth(); float x = corners[0] + viewWidth * scrollPosition; float y = corners[1] + viewHeight / 2.0f; if (side == Side.LEFT) drag(corners[0], x, y, y, stepCount); else if (side == Side.RIGHT) drag(x, corners[0], y, y, stepCount); }
java
public void scrollViewToSide(View view, Side side, float scrollPosition, int stepCount) { int[] corners = new int[2]; view.getLocationOnScreen(corners); int viewHeight = view.getHeight(); int viewWidth = view.getWidth(); float x = corners[0] + viewWidth * scrollPosition; float y = corners[1] + viewHeight / 2.0f; if (side == Side.LEFT) drag(corners[0], x, y, y, stepCount); else if (side == Side.RIGHT) drag(x, corners[0], y, y, stepCount); }
[ "public", "void", "scrollViewToSide", "(", "View", "view", ",", "Side", "side", ",", "float", "scrollPosition", ",", "int", "stepCount", ")", "{", "int", "[", "]", "corners", "=", "new", "int", "[", "2", "]", ";", "view", ".", "getLocationOnScreen", "(",...
Scrolls view horizontally. @param view the view to scroll @param side the side to which to scroll; {@link Side#RIGHT} or {@link Side#LEFT} @param scrollPosition the position to scroll to, from 0 to 1 where 1 is all the way. Example is: 0.55. @param stepCount how many move steps to include in the scroll. Less steps results in a faster scroll
[ "Scrolls", "view", "horizontally", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Scroller.java#L372-L383
30,009
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/ScreenshotTaker.java
ScreenshotTaker.getScreenshotView
private View getScreenshotView() { View decorView = viewFetcher.getRecentDecorView(viewFetcher.getWindowDecorViews()); final long endTime = SystemClock.uptimeMillis() + Timeout.getSmallTimeout(); while (decorView == null) { final boolean timedOut = SystemClock.uptimeMillis() > endTime; if (timedOut){ return null; } sleeper.sleepMini(); decorView = viewFetcher.getRecentDecorView(viewFetcher.getWindowDecorViews()); } wrapAllGLViews(decorView); return decorView; }
java
private View getScreenshotView() { View decorView = viewFetcher.getRecentDecorView(viewFetcher.getWindowDecorViews()); final long endTime = SystemClock.uptimeMillis() + Timeout.getSmallTimeout(); while (decorView == null) { final boolean timedOut = SystemClock.uptimeMillis() > endTime; if (timedOut){ return null; } sleeper.sleepMini(); decorView = viewFetcher.getRecentDecorView(viewFetcher.getWindowDecorViews()); } wrapAllGLViews(decorView); return decorView; }
[ "private", "View", "getScreenshotView", "(", ")", "{", "View", "decorView", "=", "viewFetcher", ".", "getRecentDecorView", "(", "viewFetcher", ".", "getWindowDecorViews", "(", ")", ")", ";", "final", "long", "endTime", "=", "SystemClock", ".", "uptimeMillis", "(...
Gets the proper view to use for a screenshot.
[ "Gets", "the", "proper", "view", "to", "use", "for", "a", "screenshot", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/ScreenshotTaker.java#L149-L166
30,010
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/ScreenshotTaker.java
ScreenshotTaker.wrapAllGLViews
private void wrapAllGLViews(View decorView) { ArrayList<GLSurfaceView> currentViews = viewFetcher.getCurrentViews(GLSurfaceView.class, true, decorView); final CountDownLatch latch = new CountDownLatch(currentViews.size()); for (GLSurfaceView glView : currentViews) { Object renderContainer = new Reflect(glView).field("mGLThread") .type(GLSurfaceView.class).out(Object.class); Renderer renderer = new Reflect(renderContainer).field("mRenderer").out(Renderer.class); if (renderer == null) { renderer = new Reflect(glView).field("mRenderer").out(Renderer.class); renderContainer = glView; } if (renderer == null) { latch.countDown(); continue; } if (renderer instanceof GLRenderWrapper) { GLRenderWrapper wrapper = (GLRenderWrapper) renderer; wrapper.setTakeScreenshot(); wrapper.setLatch(latch); } else { GLRenderWrapper wrapper = new GLRenderWrapper(glView, renderer, latch); new Reflect(renderContainer).field("mRenderer").in(wrapper); } } try { latch.await(); } catch (InterruptedException ex) { ex.printStackTrace(); } }
java
private void wrapAllGLViews(View decorView) { ArrayList<GLSurfaceView> currentViews = viewFetcher.getCurrentViews(GLSurfaceView.class, true, decorView); final CountDownLatch latch = new CountDownLatch(currentViews.size()); for (GLSurfaceView glView : currentViews) { Object renderContainer = new Reflect(glView).field("mGLThread") .type(GLSurfaceView.class).out(Object.class); Renderer renderer = new Reflect(renderContainer).field("mRenderer").out(Renderer.class); if (renderer == null) { renderer = new Reflect(glView).field("mRenderer").out(Renderer.class); renderContainer = glView; } if (renderer == null) { latch.countDown(); continue; } if (renderer instanceof GLRenderWrapper) { GLRenderWrapper wrapper = (GLRenderWrapper) renderer; wrapper.setTakeScreenshot(); wrapper.setLatch(latch); } else { GLRenderWrapper wrapper = new GLRenderWrapper(glView, renderer, latch); new Reflect(renderContainer).field("mRenderer").in(wrapper); } } try { latch.await(); } catch (InterruptedException ex) { ex.printStackTrace(); } }
[ "private", "void", "wrapAllGLViews", "(", "View", "decorView", ")", "{", "ArrayList", "<", "GLSurfaceView", ">", "currentViews", "=", "viewFetcher", ".", "getCurrentViews", "(", "GLSurfaceView", ".", "class", ",", "true", ",", "decorView", ")", ";", "final", "...
Extract and wrap the all OpenGL ES Renderer.
[ "Extract", "and", "wrap", "the", "all", "OpenGL", "ES", "Renderer", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/ScreenshotTaker.java#L171-L204
30,011
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/ScreenshotTaker.java
ScreenshotTaker.getBitmapOfWebView
private Bitmap getBitmapOfWebView(final WebView webView){ Picture picture = webView.capturePicture(); Bitmap b = Bitmap.createBitmap( picture.getWidth(), picture.getHeight(), Bitmap.Config.ARGB_8888); Canvas c = new Canvas(b); picture.draw(c); return b; }
java
private Bitmap getBitmapOfWebView(final WebView webView){ Picture picture = webView.capturePicture(); Bitmap b = Bitmap.createBitmap( picture.getWidth(), picture.getHeight(), Bitmap.Config.ARGB_8888); Canvas c = new Canvas(b); picture.draw(c); return b; }
[ "private", "Bitmap", "getBitmapOfWebView", "(", "final", "WebView", "webView", ")", "{", "Picture", "picture", "=", "webView", ".", "capturePicture", "(", ")", ";", "Bitmap", "b", "=", "Bitmap", ".", "createBitmap", "(", "picture", ".", "getWidth", "(", ")",...
Returns a bitmap of a given WebView. @param webView the webView to save a bitmap from @return a bitmap of the given web view
[ "Returns", "a", "bitmap", "of", "a", "given", "WebView", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/ScreenshotTaker.java#L215-L221
30,012
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/ScreenshotTaker.java
ScreenshotTaker.getBitmapOfView
private Bitmap getBitmapOfView(final View view){ view.destroyDrawingCache(); view.buildDrawingCache(false); Bitmap orig = view.getDrawingCache(); Bitmap.Config config = null; if(orig == null) { return null; } config = orig.getConfig(); if(config == null) { config = Bitmap.Config.ARGB_8888; } Bitmap b = orig.copy(config, false); orig.recycle(); view.destroyDrawingCache(); return b; }
java
private Bitmap getBitmapOfView(final View view){ view.destroyDrawingCache(); view.buildDrawingCache(false); Bitmap orig = view.getDrawingCache(); Bitmap.Config config = null; if(orig == null) { return null; } config = orig.getConfig(); if(config == null) { config = Bitmap.Config.ARGB_8888; } Bitmap b = orig.copy(config, false); orig.recycle(); view.destroyDrawingCache(); return b; }
[ "private", "Bitmap", "getBitmapOfView", "(", "final", "View", "view", ")", "{", "view", ".", "destroyDrawingCache", "(", ")", ";", "view", ".", "buildDrawingCache", "(", "false", ")", ";", "Bitmap", "orig", "=", "view", ".", "getDrawingCache", "(", ")", ";...
Returns a bitmap of a given View. @param view the view to save a bitmap from @return a bitmap of the given view
[ "Returns", "a", "bitmap", "of", "a", "given", "View", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/ScreenshotTaker.java#L231-L250
30,013
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/ScreenshotTaker.java
ScreenshotTaker.getFileName
private String getFileName(final String name){ SimpleDateFormat sdf = new SimpleDateFormat("ddMMyy-hhmmss"); String fileName = null; if(name == null){ if(config.screenshotFileType == ScreenshotFileType.JPEG){ fileName = sdf.format( new Date()).toString()+ ".jpg"; } else{ fileName = sdf.format( new Date()).toString()+ ".png"; } } else { if(config.screenshotFileType == ScreenshotFileType.JPEG){ fileName = name + ".jpg"; } else { fileName = name + ".png"; } } return fileName; }
java
private String getFileName(final String name){ SimpleDateFormat sdf = new SimpleDateFormat("ddMMyy-hhmmss"); String fileName = null; if(name == null){ if(config.screenshotFileType == ScreenshotFileType.JPEG){ fileName = sdf.format( new Date()).toString()+ ".jpg"; } else{ fileName = sdf.format( new Date()).toString()+ ".png"; } } else { if(config.screenshotFileType == ScreenshotFileType.JPEG){ fileName = name + ".jpg"; } else { fileName = name + ".png"; } } return fileName; }
[ "private", "String", "getFileName", "(", "final", "String", "name", ")", "{", "SimpleDateFormat", "sdf", "=", "new", "SimpleDateFormat", "(", "\"ddMMyy-hhmmss\"", ")", ";", "String", "fileName", "=", "null", ";", "if", "(", "name", "==", "null", ")", "{", ...
Returns a proper filename depending on if name is given or not. @param name the given name @return a proper filename depedning on if a name is given or not
[ "Returns", "a", "proper", "filename", "depending", "on", "if", "name", "is", "given", "or", "not", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/ScreenshotTaker.java#L260-L280
30,014
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/ScreenshotTaker.java
ScreenshotTaker.initScreenShotSaver
private void initScreenShotSaver() { if(screenShotSaverThread == null || screenShotSaver == null) { screenShotSaverThread = new HandlerThread("ScreenShotSaver"); screenShotSaverThread.start(); screenShotSaver = new ScreenShotSaver(screenShotSaverThread); } }
java
private void initScreenShotSaver() { if(screenShotSaverThread == null || screenShotSaver == null) { screenShotSaverThread = new HandlerThread("ScreenShotSaver"); screenShotSaverThread.start(); screenShotSaver = new ScreenShotSaver(screenShotSaverThread); } }
[ "private", "void", "initScreenShotSaver", "(", ")", "{", "if", "(", "screenShotSaverThread", "==", "null", "||", "screenShotSaver", "==", "null", ")", "{", "screenShotSaverThread", "=", "new", "HandlerThread", "(", "\"ScreenShotSaver\"", ")", ";", "screenShotSaverTh...
This method initializes the aysnc screenshot saving logic
[ "This", "method", "initializes", "the", "aysnc", "screenshot", "saving", "logic" ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/ScreenshotTaker.java#L285-L291
30,015
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/ActivityUtils.java
ActivityUtils.createStackAndPushStartActivity
private void createStackAndPushStartActivity(){ activityStack = new Stack<WeakReference<Activity>>(); if (activity != null && config.trackActivities){ WeakReference<Activity> weakReference = new WeakReference<Activity>(activity); activity = null; activityStack.push(weakReference); } }
java
private void createStackAndPushStartActivity(){ activityStack = new Stack<WeakReference<Activity>>(); if (activity != null && config.trackActivities){ WeakReference<Activity> weakReference = new WeakReference<Activity>(activity); activity = null; activityStack.push(weakReference); } }
[ "private", "void", "createStackAndPushStartActivity", "(", ")", "{", "activityStack", "=", "new", "Stack", "<", "WeakReference", "<", "Activity", ">", ">", "(", ")", ";", "if", "(", "activity", "!=", "null", "&&", "config", ".", "trackActivities", ")", "{", ...
Creates a new activity stack and pushes the start activity.
[ "Creates", "a", "new", "activity", "stack", "and", "pushes", "the", "start", "activity", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/ActivityUtils.java#L69-L76
30,016
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/ActivityUtils.java
ActivityUtils.setupActivityMonitor
private void setupActivityMonitor() { if(config.trackActivities){ try { IntentFilter filter = null; activityMonitor = inst.addMonitor(filter, null, false); } catch (Exception e) { e.printStackTrace(); } } }
java
private void setupActivityMonitor() { if(config.trackActivities){ try { IntentFilter filter = null; activityMonitor = inst.addMonitor(filter, null, false); } catch (Exception e) { e.printStackTrace(); } } }
[ "private", "void", "setupActivityMonitor", "(", ")", "{", "if", "(", "config", ".", "trackActivities", ")", "{", "try", "{", "IntentFilter", "filter", "=", "null", ";", "activityMonitor", "=", "inst", ".", "addMonitor", "(", "filter", ",", "null", ",", "fa...
This is were the activityMonitor is set up. The monitor will keep check for the currently active activity.
[ "This", "is", "were", "the", "activityMonitor", "is", "set", "up", ".", "The", "monitor", "will", "keep", "check", "for", "the", "currently", "active", "activity", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/ActivityUtils.java#L103-L112
30,017
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/ActivityUtils.java
ActivityUtils.removeActivityFromStack
private void removeActivityFromStack(Activity activity){ Iterator<WeakReference<Activity>> activityStackIterator = activityStack.iterator(); while(activityStackIterator.hasNext()){ Activity activityFromWeakReference = activityStackIterator.next().get(); if(activityFromWeakReference == null){ activityStackIterator.remove(); } if(activity != null && activityFromWeakReference != null && activityFromWeakReference.equals(activity)){ activityStackIterator.remove(); } } }
java
private void removeActivityFromStack(Activity activity){ Iterator<WeakReference<Activity>> activityStackIterator = activityStack.iterator(); while(activityStackIterator.hasNext()){ Activity activityFromWeakReference = activityStackIterator.next().get(); if(activityFromWeakReference == null){ activityStackIterator.remove(); } if(activity != null && activityFromWeakReference != null && activityFromWeakReference.equals(activity)){ activityStackIterator.remove(); } } }
[ "private", "void", "removeActivityFromStack", "(", "Activity", "activity", ")", "{", "Iterator", "<", "WeakReference", "<", "Activity", ">>", "activityStackIterator", "=", "activityStack", ".", "iterator", "(", ")", ";", "while", "(", "activityStackIterator", ".", ...
Removes a given activity from the activity stack @param activity the activity to remove
[ "Removes", "a", "given", "activity", "from", "the", "activity", "stack" ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/ActivityUtils.java#L176-L190
30,018
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/ActivityUtils.java
ActivityUtils.addActivityToStack
private void addActivityToStack(Activity activity){ activitiesStoredInActivityStack.push(activity.toString()); weakActivityReference = new WeakReference<Activity>(activity); activity = null; activityStack.push(weakActivityReference); }
java
private void addActivityToStack(Activity activity){ activitiesStoredInActivityStack.push(activity.toString()); weakActivityReference = new WeakReference<Activity>(activity); activity = null; activityStack.push(weakActivityReference); }
[ "private", "void", "addActivityToStack", "(", "Activity", "activity", ")", "{", "activitiesStoredInActivityStack", ".", "push", "(", "activity", ".", "toString", "(", ")", ")", ";", "weakActivityReference", "=", "new", "WeakReference", "<", "Activity", ">", "(", ...
Adds an activity to the stack @param activity the activity to add
[ "Adds", "an", "activity", "to", "the", "stack" ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/ActivityUtils.java#L243-L248
30,019
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/ActivityUtils.java
ActivityUtils.waitForActivityIfNotAvailable
private final void waitForActivityIfNotAvailable(){ if(activityStack.isEmpty() || activityStack.peek().get() == null){ if (activityMonitor != null) { Activity activity = activityMonitor.getLastActivity(); while (activity == null){ sleeper.sleepMini(); activity = activityMonitor.getLastActivity(); } addActivityToStack(activity); } else if(config.trackActivities){ sleeper.sleepMini(); setupActivityMonitor(); waitForActivityIfNotAvailable(); } } }
java
private final void waitForActivityIfNotAvailable(){ if(activityStack.isEmpty() || activityStack.peek().get() == null){ if (activityMonitor != null) { Activity activity = activityMonitor.getLastActivity(); while (activity == null){ sleeper.sleepMini(); activity = activityMonitor.getLastActivity(); } addActivityToStack(activity); } else if(config.trackActivities){ sleeper.sleepMini(); setupActivityMonitor(); waitForActivityIfNotAvailable(); } } }
[ "private", "final", "void", "waitForActivityIfNotAvailable", "(", ")", "{", "if", "(", "activityStack", ".", "isEmpty", "(", ")", "||", "activityStack", ".", "peek", "(", ")", ".", "get", "(", ")", "==", "null", ")", "{", "if", "(", "activityMonitor", "!...
Waits for an activity to be started if one is not provided by the constructor.
[ "Waits", "for", "an", "activity", "to", "be", "started", "if", "one", "is", "not", "provided", "by", "the", "constructor", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/ActivityUtils.java#L255-L272
30,020
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/ActivityUtils.java
ActivityUtils.getString
public String getString(int resId) { Activity activity = getCurrentActivity(false); if(activity == null){ return ""; } return activity.getString(resId); }
java
public String getString(int resId) { Activity activity = getCurrentActivity(false); if(activity == null){ return ""; } return activity.getString(resId); }
[ "public", "String", "getString", "(", "int", "resId", ")", "{", "Activity", "activity", "=", "getCurrentActivity", "(", "false", ")", ";", "if", "(", "activity", "==", "null", ")", "{", "return", "\"\"", ";", "}", "return", "activity", ".", "getString", ...
Returns a localized string. @param resId the resource ID for the string @return the localized string
[ "Returns", "a", "localized", "string", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/ActivityUtils.java#L361-L368
30,021
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/ActivityUtils.java
ActivityUtils.stopActivityMonitor
private void stopActivityMonitor(){ try { // Remove the monitor added during startup if (activityMonitor != null) { inst.removeMonitor(activityMonitor); activityMonitor = null; } } catch (Exception ignored) {} }
java
private void stopActivityMonitor(){ try { // Remove the monitor added during startup if (activityMonitor != null) { inst.removeMonitor(activityMonitor); activityMonitor = null; } } catch (Exception ignored) {} }
[ "private", "void", "stopActivityMonitor", "(", ")", "{", "try", "{", "// Remove the monitor added during startup", "if", "(", "activityMonitor", "!=", "null", ")", "{", "inst", ".", "removeMonitor", "(", "activityMonitor", ")", ";", "activityMonitor", "=", "null", ...
Removes the ActivityMonitor
[ "Removes", "the", "ActivityMonitor" ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/ActivityUtils.java#L384-L393
30,022
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/ActivityUtils.java
ActivityUtils.finishOpenedActivities
public void finishOpenedActivities(){ // Stops the activityStack listener activitySyncTimer.cancel(); if(!config.trackActivities){ useGoBack(3); return; } ArrayList<Activity> activitiesOpened = getAllOpenedActivities(); // Finish all opened activities for (int i = activitiesOpened.size()-1; i >= 0; i--) { sleeper.sleep(MINISLEEP); finishActivity(activitiesOpened.get(i)); } activitiesOpened = null; sleeper.sleep(MINISLEEP); // Finish the initial activity, pressing Back for good measure finishActivity(getCurrentActivity(true, false)); stopActivityMonitor(); setRegisterActivities(false); this.activity = null; sleeper.sleepMini(); useGoBack(1); clearActivityStack(); }
java
public void finishOpenedActivities(){ // Stops the activityStack listener activitySyncTimer.cancel(); if(!config.trackActivities){ useGoBack(3); return; } ArrayList<Activity> activitiesOpened = getAllOpenedActivities(); // Finish all opened activities for (int i = activitiesOpened.size()-1; i >= 0; i--) { sleeper.sleep(MINISLEEP); finishActivity(activitiesOpened.get(i)); } activitiesOpened = null; sleeper.sleep(MINISLEEP); // Finish the initial activity, pressing Back for good measure finishActivity(getCurrentActivity(true, false)); stopActivityMonitor(); setRegisterActivities(false); this.activity = null; sleeper.sleepMini(); useGoBack(1); clearActivityStack(); }
[ "public", "void", "finishOpenedActivities", "(", ")", "{", "// Stops the activityStack listener", "activitySyncTimer", ".", "cancel", "(", ")", ";", "if", "(", "!", "config", ".", "trackActivities", ")", "{", "useGoBack", "(", "3", ")", ";", "return", ";", "}"...
All activites that have been opened are finished.
[ "All", "activites", "that", "have", "been", "opened", "are", "finished", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/ActivityUtils.java#L399-L422
30,023
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/ActivityUtils.java
ActivityUtils.useGoBack
private void useGoBack(int numberOfTimes){ for(int i = 0; i < numberOfTimes; i++){ try { inst.sendKeyDownUpSync(KeyEvent.KEYCODE_BACK); sleeper.sleep(MINISLEEP); inst.sendKeyDownUpSync(KeyEvent.KEYCODE_BACK); } catch (Throwable ignored) { // Guard against lack of INJECT_EVENT permission } } }
java
private void useGoBack(int numberOfTimes){ for(int i = 0; i < numberOfTimes; i++){ try { inst.sendKeyDownUpSync(KeyEvent.KEYCODE_BACK); sleeper.sleep(MINISLEEP); inst.sendKeyDownUpSync(KeyEvent.KEYCODE_BACK); } catch (Throwable ignored) { // Guard against lack of INJECT_EVENT permission } } }
[ "private", "void", "useGoBack", "(", "int", "numberOfTimes", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "numberOfTimes", ";", "i", "++", ")", "{", "try", "{", "inst", ".", "sendKeyDownUpSync", "(", "KeyEvent", ".", "KEYCODE_BACK", ")", ...
Sends the back button command a given number of times @param numberOfTimes the number of times to press "back"
[ "Sends", "the", "back", "button", "command", "a", "given", "number", "of", "times" ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/ActivityUtils.java#L430-L440
30,024
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/ActivityUtils.java
ActivityUtils.finishActivity
private void finishActivity(Activity activity){ if(activity != null) { try{ activity.finish(); }catch(Throwable e){ e.printStackTrace(); } } }
java
private void finishActivity(Activity activity){ if(activity != null) { try{ activity.finish(); }catch(Throwable e){ e.printStackTrace(); } } }
[ "private", "void", "finishActivity", "(", "Activity", "activity", ")", "{", "if", "(", "activity", "!=", "null", ")", "{", "try", "{", "activity", ".", "finish", "(", ")", ";", "}", "catch", "(", "Throwable", "e", ")", "{", "e", ".", "printStackTrace",...
Finishes an activity. @param activity the activity to finish
[ "Finishes", "an", "activity", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/ActivityUtils.java#L458-L466
30,025
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/ViewFetcher.java
ViewFetcher.getScrollOrListParent
public View getScrollOrListParent(View view) { if (!(view instanceof android.widget.AbsListView) && !(view instanceof android.widget.ScrollView) && !(view instanceof WebView)) { try{ return getScrollOrListParent((View) view.getParent()); }catch(Exception e){ return null; } } else { return view; } }
java
public View getScrollOrListParent(View view) { if (!(view instanceof android.widget.AbsListView) && !(view instanceof android.widget.ScrollView) && !(view instanceof WebView)) { try{ return getScrollOrListParent((View) view.getParent()); }catch(Exception e){ return null; } } else { return view; } }
[ "public", "View", "getScrollOrListParent", "(", "View", "view", ")", "{", "if", "(", "!", "(", "view", "instanceof", "android", ".", "widget", ".", "AbsListView", ")", "&&", "!", "(", "view", "instanceof", "android", ".", "widget", ".", "ScrollView", ")", ...
Returns the scroll or list parent view @param view the view who's parent should be returned @return the parent scroll view, list view or null
[ "Returns", "the", "scroll", "or", "list", "parent", "view" ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/ViewFetcher.java#L71-L82
30,026
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/ViewFetcher.java
ViewFetcher.getAllViews
public ArrayList<View> getAllViews(boolean onlySufficientlyVisible) { final View[] views = getWindowDecorViews(); final ArrayList<View> allViews = new ArrayList<View>(); final View[] nonDecorViews = getNonDecorViews(views); View view = null; if(nonDecorViews != null){ for(int i = 0; i < nonDecorViews.length; i++){ view = nonDecorViews[i]; try { addChildren(allViews, (ViewGroup)view, onlySufficientlyVisible); } catch (Exception ignored) {} if(view != null) allViews.add(view); } } if (views != null && views.length > 0) { view = getRecentDecorView(views); try { addChildren(allViews, (ViewGroup)view, onlySufficientlyVisible); } catch (Exception ignored) {} if(view != null) allViews.add(view); } return allViews; }
java
public ArrayList<View> getAllViews(boolean onlySufficientlyVisible) { final View[] views = getWindowDecorViews(); final ArrayList<View> allViews = new ArrayList<View>(); final View[] nonDecorViews = getNonDecorViews(views); View view = null; if(nonDecorViews != null){ for(int i = 0; i < nonDecorViews.length; i++){ view = nonDecorViews[i]; try { addChildren(allViews, (ViewGroup)view, onlySufficientlyVisible); } catch (Exception ignored) {} if(view != null) allViews.add(view); } } if (views != null && views.length > 0) { view = getRecentDecorView(views); try { addChildren(allViews, (ViewGroup)view, onlySufficientlyVisible); } catch (Exception ignored) {} if(view != null) allViews.add(view); } return allViews; }
[ "public", "ArrayList", "<", "View", ">", "getAllViews", "(", "boolean", "onlySufficientlyVisible", ")", "{", "final", "View", "[", "]", "views", "=", "getWindowDecorViews", "(", ")", ";", "final", "ArrayList", "<", "View", ">", "allViews", "=", "new", "Array...
Returns views from the shown DecorViews. @param onlySufficientlyVisible if only sufficiently visible views should be returned @return all the views contained in the DecorViews
[ "Returns", "views", "from", "the", "shown", "DecorViews", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/ViewFetcher.java#L91-L117
30,027
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/ViewFetcher.java
ViewFetcher.getRecentDecorView
public final View getRecentDecorView(View[] views) { if(views == null) return null; final View[] decorViews = new View[views.length]; int i = 0; View view; for (int j = 0; j < views.length; j++) { view = views[j]; if (isDecorView(view)){ decorViews[i] = view; i++; } } return getRecentContainer(decorViews); }
java
public final View getRecentDecorView(View[] views) { if(views == null) return null; final View[] decorViews = new View[views.length]; int i = 0; View view; for (int j = 0; j < views.length; j++) { view = views[j]; if (isDecorView(view)){ decorViews[i] = view; i++; } } return getRecentContainer(decorViews); }
[ "public", "final", "View", "getRecentDecorView", "(", "View", "[", "]", "views", ")", "{", "if", "(", "views", "==", "null", ")", "return", "null", ";", "final", "View", "[", "]", "decorViews", "=", "new", "View", "[", "views", ".", "length", "]", ";...
Returns the most recent DecorView @param views the views to check @return the most recent DecorView
[ "Returns", "the", "most", "recent", "DecorView" ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/ViewFetcher.java#L126-L142
30,028
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/ViewFetcher.java
ViewFetcher.getRecentContainer
private final View getRecentContainer(View[] views) { View container = null; long drawingTime = 0; View view; for(int i = 0; i < views.length; i++){ view = views[i]; if (view != null && view.isShown() && view.hasWindowFocus() && view.getDrawingTime() > drawingTime) { container = view; drawingTime = view.getDrawingTime(); } } return container; }
java
private final View getRecentContainer(View[] views) { View container = null; long drawingTime = 0; View view; for(int i = 0; i < views.length; i++){ view = views[i]; if (view != null && view.isShown() && view.hasWindowFocus() && view.getDrawingTime() > drawingTime) { container = view; drawingTime = view.getDrawingTime(); } } return container; }
[ "private", "final", "View", "getRecentContainer", "(", "View", "[", "]", "views", ")", "{", "View", "container", "=", "null", ";", "long", "drawingTime", "=", "0", ";", "View", "view", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "views", ...
Returns the most recent view container @param views the views to check @return the most recent view container
[ "Returns", "the", "most", "recent", "view", "container" ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/ViewFetcher.java#L151-L164
30,029
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/ViewFetcher.java
ViewFetcher.getNonDecorViews
private final View[] getNonDecorViews(View[] views) { View[] decorViews = null; if(views != null) { decorViews = new View[views.length]; int i = 0; View view; for (int j = 0; j < views.length; j++) { view = views[j]; if (!isDecorView(view)) { decorViews[i] = view; i++; } } } return decorViews; }
java
private final View[] getNonDecorViews(View[] views) { View[] decorViews = null; if(views != null) { decorViews = new View[views.length]; int i = 0; View view; for (int j = 0; j < views.length; j++) { view = views[j]; if (!isDecorView(view)) { decorViews[i] = view; i++; } } } return decorViews; }
[ "private", "final", "View", "[", "]", "getNonDecorViews", "(", "View", "[", "]", "views", ")", "{", "View", "[", "]", "decorViews", "=", "null", ";", "if", "(", "views", "!=", "null", ")", "{", "decorViews", "=", "new", "View", "[", "views", ".", "...
Returns all views that are non DecorViews @param views the views to check @return the non DecorViews
[ "Returns", "all", "views", "that", "are", "non", "DecorViews" ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/ViewFetcher.java#L173-L191
30,030
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/ViewFetcher.java
ViewFetcher.isDecorView
private boolean isDecorView(View view) { if (view == null) { return false; } final String nameOfClass = view.getClass().getName(); return (nameOfClass.equals("com.android.internal.policy.impl.PhoneWindow$DecorView") || nameOfClass.equals("com.android.internal.policy.impl.MultiPhoneWindow$MultiPhoneDecorView") || nameOfClass.equals("com.android.internal.policy.PhoneWindow$DecorView")); }
java
private boolean isDecorView(View view) { if (view == null) { return false; } final String nameOfClass = view.getClass().getName(); return (nameOfClass.equals("com.android.internal.policy.impl.PhoneWindow$DecorView") || nameOfClass.equals("com.android.internal.policy.impl.MultiPhoneWindow$MultiPhoneDecorView") || nameOfClass.equals("com.android.internal.policy.PhoneWindow$DecorView")); }
[ "private", "boolean", "isDecorView", "(", "View", "view", ")", "{", "if", "(", "view", "==", "null", ")", "{", "return", "false", ";", "}", "final", "String", "nameOfClass", "=", "view", ".", "getClass", "(", ")", ".", "getName", "(", ")", ";", "retu...
Returns whether a view is a DecorView @param view @return true if view is a DecorView, false otherwise
[ "Returns", "whether", "a", "view", "is", "a", "DecorView" ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/ViewFetcher.java#L198-L207
30,031
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/ViewFetcher.java
ViewFetcher.getScrollListWindowHeight
@SuppressWarnings("deprecation") public float getScrollListWindowHeight(View view) { final int[] xyParent = new int[2]; View parent = getScrollOrListParent(view); final float windowHeight; if(parent == null){ WindowManager windowManager = (WindowManager) instrumentation.getTargetContext().getSystemService(Context.WINDOW_SERVICE); windowHeight = windowManager.getDefaultDisplay().getHeight(); } else{ parent.getLocationOnScreen(xyParent); windowHeight = xyParent[1] + parent.getHeight(); } parent = null; return windowHeight; }
java
@SuppressWarnings("deprecation") public float getScrollListWindowHeight(View view) { final int[] xyParent = new int[2]; View parent = getScrollOrListParent(view); final float windowHeight; if(parent == null){ WindowManager windowManager = (WindowManager) instrumentation.getTargetContext().getSystemService(Context.WINDOW_SERVICE); windowHeight = windowManager.getDefaultDisplay().getHeight(); } else{ parent.getLocationOnScreen(xyParent); windowHeight = xyParent[1] + parent.getHeight(); } parent = null; return windowHeight; }
[ "@", "SuppressWarnings", "(", "\"deprecation\"", ")", "public", "float", "getScrollListWindowHeight", "(", "View", "view", ")", "{", "final", "int", "[", "]", "xyParent", "=", "new", "int", "[", "2", "]", ";", "View", "parent", "=", "getScrollOrListParent", ...
Returns the height of the scroll or list view parent @param view the view who's parents height should be returned @return the height of the scroll or list view parent
[ "Returns", "the", "height", "of", "the", "scroll", "or", "list", "view", "parent" ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/ViewFetcher.java#L304-L323
30,032
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/ViewFetcher.java
ViewFetcher.getFreshestView
public final <T extends View> T getFreshestView(ArrayList<T> views){ final int[] locationOnScreen = new int[2]; T viewToReturn = null; long drawingTime = 0; if(views == null){ return null; } for(T view : views){ if(view != null){ view.getLocationOnScreen(locationOnScreen); if (locationOnScreen[0] < 0 || !(view.getHeight() > 0)){ continue; } if(view.getDrawingTime() > drawingTime){ drawingTime = view.getDrawingTime(); viewToReturn = view; } else if (view.getDrawingTime() == drawingTime){ if(view.isFocused()){ viewToReturn = view; } } } } views = null; return viewToReturn; }
java
public final <T extends View> T getFreshestView(ArrayList<T> views){ final int[] locationOnScreen = new int[2]; T viewToReturn = null; long drawingTime = 0; if(views == null){ return null; } for(T view : views){ if(view != null){ view.getLocationOnScreen(locationOnScreen); if (locationOnScreen[0] < 0 || !(view.getHeight() > 0)){ continue; } if(view.getDrawingTime() > drawingTime){ drawingTime = view.getDrawingTime(); viewToReturn = view; } else if (view.getDrawingTime() == drawingTime){ if(view.isFocused()){ viewToReturn = view; } } } } views = null; return viewToReturn; }
[ "public", "final", "<", "T", "extends", "View", ">", "T", "getFreshestView", "(", "ArrayList", "<", "T", ">", "views", ")", "{", "final", "int", "[", "]", "locationOnScreen", "=", "new", "int", "[", "2", "]", ";", "T", "viewToReturn", "=", "null", ";...
Tries to guess which view is the most likely to be interesting. Returns the most recently drawn view, which presumably will be the one that the user was most recently interacting with. @param views A list of potentially interesting views, likely a collection of views from a set of types, such as [{@link Button}, {@link TextView}] or [{@link ScrollView}, {@link ListView}] @param index the index of the view @return most recently drawn view, or null if no views were passed
[ "Tries", "to", "guess", "which", "view", "is", "the", "most", "likely", "to", "be", "interesting", ".", "Returns", "the", "most", "recently", "drawn", "view", "which", "presumably", "will", "be", "the", "one", "that", "the", "user", "was", "most", "recentl...
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/ViewFetcher.java#L377-L406
30,033
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/ViewFetcher.java
ViewFetcher.getRecyclerView
public <T extends View> ViewGroup getRecyclerView(int recyclerViewIndex, int timeOut) { final long endTime = SystemClock.uptimeMillis() + timeOut; while (SystemClock.uptimeMillis() < endTime) { View recyclerView = getRecyclerView(true, recyclerViewIndex); if(recyclerView != null){ return (ViewGroup) recyclerView; } } return null; }
java
public <T extends View> ViewGroup getRecyclerView(int recyclerViewIndex, int timeOut) { final long endTime = SystemClock.uptimeMillis() + timeOut; while (SystemClock.uptimeMillis() < endTime) { View recyclerView = getRecyclerView(true, recyclerViewIndex); if(recyclerView != null){ return (ViewGroup) recyclerView; } } return null; }
[ "public", "<", "T", "extends", "View", ">", "ViewGroup", "getRecyclerView", "(", "int", "recyclerViewIndex", ",", "int", "timeOut", ")", "{", "final", "long", "endTime", "=", "SystemClock", ".", "uptimeMillis", "(", ")", "+", "timeOut", ";", "while", "(", ...
Waits for a RecyclerView and returns it. @param recyclerViewIndex the index of the RecyclerView @return {@code ViewGroup} if RecycleView is displayed
[ "Waits", "for", "a", "RecyclerView", "and", "returns", "it", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/ViewFetcher.java#L417-L427
30,034
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/ViewFetcher.java
ViewFetcher.getRecyclerView
public View getRecyclerView(boolean shouldSleep, int recyclerViewIndex){ Set<View> uniqueViews = new HashSet<View>(); if(shouldSleep){ sleeper.sleep(); } @SuppressWarnings("unchecked") ArrayList<View> views = RobotiumUtils.filterViewsToSet(new Class[] {ViewGroup.class}, getAllViews(false)); views = RobotiumUtils.removeInvisibleViews(views); for(View view : views){ if(isViewType(view.getClass(), "widget.RecyclerView")){ uniqueViews.add(view); } if(uniqueViews.size() > recyclerViewIndex) { return (ViewGroup) view; } } return null; }
java
public View getRecyclerView(boolean shouldSleep, int recyclerViewIndex){ Set<View> uniqueViews = new HashSet<View>(); if(shouldSleep){ sleeper.sleep(); } @SuppressWarnings("unchecked") ArrayList<View> views = RobotiumUtils.filterViewsToSet(new Class[] {ViewGroup.class}, getAllViews(false)); views = RobotiumUtils.removeInvisibleViews(views); for(View view : views){ if(isViewType(view.getClass(), "widget.RecyclerView")){ uniqueViews.add(view); } if(uniqueViews.size() > recyclerViewIndex) { return (ViewGroup) view; } } return null; }
[ "public", "View", "getRecyclerView", "(", "boolean", "shouldSleep", ",", "int", "recyclerViewIndex", ")", "{", "Set", "<", "View", ">", "uniqueViews", "=", "new", "HashSet", "<", "View", ">", "(", ")", ";", "if", "(", "shouldSleep", ")", "{", "sleeper", ...
Returns a RecyclerView or null if none is found @param viewList the list to check in @return a RecyclerView
[ "Returns", "a", "RecyclerView", "or", "null", "if", "none", "is", "found" ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/ViewFetcher.java#L438-L459
30,035
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/ViewFetcher.java
ViewFetcher.getScrollableSupportPackageViews
public List<View> getScrollableSupportPackageViews(boolean shouldSleep){ List <View> viewsToReturn = new ArrayList<View>(); if(shouldSleep){ sleeper.sleep(); } @SuppressWarnings("unchecked") ArrayList<View> views = RobotiumUtils.filterViewsToSet(new Class[] {ViewGroup.class}, getAllViews(true)); views = RobotiumUtils.removeInvisibleViews(views); for(View view : views){ if(isViewType(view.getClass(), "widget.RecyclerView") || isViewType(view.getClass(), "widget.NestedScrollView")){ viewsToReturn.add(view); } } return viewsToReturn; }
java
public List<View> getScrollableSupportPackageViews(boolean shouldSleep){ List <View> viewsToReturn = new ArrayList<View>(); if(shouldSleep){ sleeper.sleep(); } @SuppressWarnings("unchecked") ArrayList<View> views = RobotiumUtils.filterViewsToSet(new Class[] {ViewGroup.class}, getAllViews(true)); views = RobotiumUtils.removeInvisibleViews(views); for(View view : views){ if(isViewType(view.getClass(), "widget.RecyclerView") || isViewType(view.getClass(), "widget.NestedScrollView")){ viewsToReturn.add(view); } } return viewsToReturn; }
[ "public", "List", "<", "View", ">", "getScrollableSupportPackageViews", "(", "boolean", "shouldSleep", ")", "{", "List", "<", "View", ">", "viewsToReturn", "=", "new", "ArrayList", "<", "View", ">", "(", ")", ";", "if", "(", "shouldSleep", ")", "{", "sleep...
Returns a Set of all RecyclerView or empty Set if none is found @return a Set of RecyclerViews
[ "Returns", "a", "Set", "of", "all", "RecyclerView", "or", "empty", "Set", "if", "none", "is", "found" ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/ViewFetcher.java#L468-L487
30,036
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/ViewFetcher.java
ViewFetcher.getIdenticalView
public View getIdenticalView(View view) { if(view == null){ return null; } View viewToReturn = null; List<? extends View> visibleViews = RobotiumUtils.removeInvisibleViews(getCurrentViews(view.getClass(), true)); for(View v : visibleViews){ if(areViewsIdentical(v, view)){ viewToReturn = v; break; } } return viewToReturn; }
java
public View getIdenticalView(View view) { if(view == null){ return null; } View viewToReturn = null; List<? extends View> visibleViews = RobotiumUtils.removeInvisibleViews(getCurrentViews(view.getClass(), true)); for(View v : visibleViews){ if(areViewsIdentical(v, view)){ viewToReturn = v; break; } } return viewToReturn; }
[ "public", "View", "getIdenticalView", "(", "View", "view", ")", "{", "if", "(", "view", "==", "null", ")", "{", "return", "null", ";", "}", "View", "viewToReturn", "=", "null", ";", "List", "<", "?", "extends", "View", ">", "visibleViews", "=", "Roboti...
Returns an identical View to the one specified. @param view the view to find @return identical view of the specified view
[ "Returns", "an", "identical", "View", "to", "the", "one", "specified", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/ViewFetcher.java#L508-L523
30,037
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/ViewFetcher.java
ViewFetcher.getWindowDecorViews
@SuppressWarnings("unchecked") public View[] getWindowDecorViews() { Field viewsField; Field instanceField; try { viewsField = windowManager.getDeclaredField("mViews"); instanceField = windowManager.getDeclaredField(windowManagerString); viewsField.setAccessible(true); instanceField.setAccessible(true); Object instance = instanceField.get(null); View[] result; if (android.os.Build.VERSION.SDK_INT >= 19) { result = ((ArrayList<View>) viewsField.get(instance)).toArray(new View[0]); } else { result = (View[]) viewsField.get(instance); } return result; } catch (Exception e) { e.printStackTrace(); } return null; }
java
@SuppressWarnings("unchecked") public View[] getWindowDecorViews() { Field viewsField; Field instanceField; try { viewsField = windowManager.getDeclaredField("mViews"); instanceField = windowManager.getDeclaredField(windowManagerString); viewsField.setAccessible(true); instanceField.setAccessible(true); Object instance = instanceField.get(null); View[] result; if (android.os.Build.VERSION.SDK_INT >= 19) { result = ((ArrayList<View>) viewsField.get(instance)).toArray(new View[0]); } else { result = (View[]) viewsField.get(instance); } return result; } catch (Exception e) { e.printStackTrace(); } return null; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "View", "[", "]", "getWindowDecorViews", "(", ")", "{", "Field", "viewsField", ";", "Field", "instanceField", ";", "try", "{", "viewsField", "=", "windowManager", ".", "getDeclaredField", "(", "\"mVie...
Returns the WindorDecorViews shown on the screen. @return the WindorDecorViews shown on the screen
[ "Returns", "the", "WindorDecorViews", "shown", "on", "the", "screen", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/ViewFetcher.java#L572-L595
30,038
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/ViewFetcher.java
ViewFetcher.setWindowManagerString
private void setWindowManagerString(){ if (android.os.Build.VERSION.SDK_INT >= 17) { windowManagerString = "sDefaultWindowManager"; } else if(android.os.Build.VERSION.SDK_INT >= 13) { windowManagerString = "sWindowManager"; } else { windowManagerString = "mWindowManager"; } }
java
private void setWindowManagerString(){ if (android.os.Build.VERSION.SDK_INT >= 17) { windowManagerString = "sDefaultWindowManager"; } else if(android.os.Build.VERSION.SDK_INT >= 13) { windowManagerString = "sWindowManager"; } else { windowManagerString = "mWindowManager"; } }
[ "private", "void", "setWindowManagerString", "(", ")", "{", "if", "(", "android", ".", "os", ".", "Build", ".", "VERSION", ".", "SDK_INT", ">=", "17", ")", "{", "windowManagerString", "=", "\"sDefaultWindowManager\"", ";", "}", "else", "if", "(", "android", ...
Sets the window manager string.
[ "Sets", "the", "window", "manager", "string", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/ViewFetcher.java#L600-L611
30,039
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/RobotiumUtils.java
RobotiumUtils.removeInvisibleViews
public static <T extends View> ArrayList<T> removeInvisibleViews(Iterable<T> viewList) { ArrayList<T> tmpViewList = new ArrayList<T>(); for (T view : viewList) { if (view != null && view.isShown()) { tmpViewList.add(view); } } return tmpViewList; }
java
public static <T extends View> ArrayList<T> removeInvisibleViews(Iterable<T> viewList) { ArrayList<T> tmpViewList = new ArrayList<T>(); for (T view : viewList) { if (view != null && view.isShown()) { tmpViewList.add(view); } } return tmpViewList; }
[ "public", "static", "<", "T", "extends", "View", ">", "ArrayList", "<", "T", ">", "removeInvisibleViews", "(", "Iterable", "<", "T", ">", "viewList", ")", "{", "ArrayList", "<", "T", ">", "tmpViewList", "=", "new", "ArrayList", "<", "T", ">", "(", ")",...
Removes invisible Views. @param viewList an Iterable with Views that is being checked for invisible Views @return a filtered Iterable with no invisible Views
[ "Removes", "invisible", "Views", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/RobotiumUtils.java#L32-L40
30,040
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/RobotiumUtils.java
RobotiumUtils.filterViews
public static <T> ArrayList<T> filterViews(Class<T> classToFilterBy, Iterable<?> viewList) { ArrayList<T> filteredViews = new ArrayList<T>(); for (Object view : viewList) { if (view != null && classToFilterBy.isAssignableFrom(view.getClass())) { filteredViews.add(classToFilterBy.cast(view)); } } viewList = null; return filteredViews; }
java
public static <T> ArrayList<T> filterViews(Class<T> classToFilterBy, Iterable<?> viewList) { ArrayList<T> filteredViews = new ArrayList<T>(); for (Object view : viewList) { if (view != null && classToFilterBy.isAssignableFrom(view.getClass())) { filteredViews.add(classToFilterBy.cast(view)); } } viewList = null; return filteredViews; }
[ "public", "static", "<", "T", ">", "ArrayList", "<", "T", ">", "filterViews", "(", "Class", "<", "T", ">", "classToFilterBy", ",", "Iterable", "<", "?", ">", "viewList", ")", "{", "ArrayList", "<", "T", ">", "filteredViews", "=", "new", "ArrayList", "<...
Filters Views based on the given class type. @param classToFilterBy the class to filter @param viewList the Iterable to filter from @return an ArrayList with filtered views
[ "Filters", "Views", "based", "on", "the", "given", "class", "type", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/RobotiumUtils.java#L50-L59
30,041
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/RobotiumUtils.java
RobotiumUtils.filterViewsToSet
public static ArrayList<View> filterViewsToSet(Class<View> classSet[], Iterable<View> viewList) { ArrayList<View> filteredViews = new ArrayList<View>(); for (View view : viewList) { if (view == null) continue; for (Class<View> filter : classSet) { if (filter.isAssignableFrom(view.getClass())) { filteredViews.add(view); break; } } } return filteredViews; }
java
public static ArrayList<View> filterViewsToSet(Class<View> classSet[], Iterable<View> viewList) { ArrayList<View> filteredViews = new ArrayList<View>(); for (View view : viewList) { if (view == null) continue; for (Class<View> filter : classSet) { if (filter.isAssignableFrom(view.getClass())) { filteredViews.add(view); break; } } } return filteredViews; }
[ "public", "static", "ArrayList", "<", "View", ">", "filterViewsToSet", "(", "Class", "<", "View", ">", "classSet", "[", "]", ",", "Iterable", "<", "View", ">", "viewList", ")", "{", "ArrayList", "<", "View", ">", "filteredViews", "=", "new", "ArrayList", ...
Filters all Views not within the given set. @param classSet contains all classes that are ok to pass the filter @param viewList the Iterable to filter form @return an ArrayList with filtered views
[ "Filters", "all", "Views", "not", "within", "the", "given", "set", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/RobotiumUtils.java#L69-L82
30,042
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/RobotiumUtils.java
RobotiumUtils.sortViewsByLocationOnScreen
public static void sortViewsByLocationOnScreen(List<? extends View> views, boolean yAxisFirst) { Collections.sort(views, new ViewLocationComparator(yAxisFirst)); }
java
public static void sortViewsByLocationOnScreen(List<? extends View> views, boolean yAxisFirst) { Collections.sort(views, new ViewLocationComparator(yAxisFirst)); }
[ "public", "static", "void", "sortViewsByLocationOnScreen", "(", "List", "<", "?", "extends", "View", ">", "views", ",", "boolean", "yAxisFirst", ")", "{", "Collections", ".", "sort", "(", "views", ",", "new", "ViewLocationComparator", "(", "yAxisFirst", ")", "...
Orders Views by their location on-screen. @param views The views to sort @param yAxisFirst Whether the y-axis should be compared before the x-axis @see ViewLocationComparator
[ "Orders", "Views", "by", "their", "location", "on", "-", "screen", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/RobotiumUtils.java#L103-L105
30,043
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/RobotiumUtils.java
RobotiumUtils.getNumberOfMatches
public static int getNumberOfMatches(String regex, TextView view, Set<TextView> uniqueTextViews){ if(view == null) { return uniqueTextViews.size(); } Pattern pattern = null; try{ pattern = Pattern.compile(regex); }catch(PatternSyntaxException e){ pattern = Pattern.compile(regex, Pattern.LITERAL); } Matcher matcher = pattern.matcher(view.getText().toString()); if (matcher.find()){ uniqueTextViews.add(view); } if (view.getError() != null){ matcher = pattern.matcher(view.getError().toString()); if (matcher.find()){ uniqueTextViews.add(view); } } if (view.getText().toString().equals("") && view.getHint() != null){ matcher = pattern.matcher(view.getHint().toString()); if (matcher.find()){ uniqueTextViews.add(view); } } return uniqueTextViews.size(); }
java
public static int getNumberOfMatches(String regex, TextView view, Set<TextView> uniqueTextViews){ if(view == null) { return uniqueTextViews.size(); } Pattern pattern = null; try{ pattern = Pattern.compile(regex); }catch(PatternSyntaxException e){ pattern = Pattern.compile(regex, Pattern.LITERAL); } Matcher matcher = pattern.matcher(view.getText().toString()); if (matcher.find()){ uniqueTextViews.add(view); } if (view.getError() != null){ matcher = pattern.matcher(view.getError().toString()); if (matcher.find()){ uniqueTextViews.add(view); } } if (view.getText().toString().equals("") && view.getHint() != null){ matcher = pattern.matcher(view.getHint().toString()); if (matcher.find()){ uniqueTextViews.add(view); } } return uniqueTextViews.size(); }
[ "public", "static", "int", "getNumberOfMatches", "(", "String", "regex", ",", "TextView", "view", ",", "Set", "<", "TextView", ">", "uniqueTextViews", ")", "{", "if", "(", "view", "==", "null", ")", "{", "return", "uniqueTextViews", ".", "size", "(", ")", ...
Checks if a View matches a certain string and returns the amount of total matches. @param regex the regex to match @param view the view to check @param uniqueTextViews set of views that have matched @return number of total matches
[ "Checks", "if", "a", "View", "matches", "a", "certain", "string", "and", "returns", "the", "amount", "of", "total", "matches", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/RobotiumUtils.java#L116-L147
30,044
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/Clicker.java
Clicker.clickOnScreen
public void clickOnScreen(float x, float y, View view) { boolean successfull = false; int retry = 0; SecurityException ex = null; while(!successfull && retry < 20) { long downTime = SystemClock.uptimeMillis(); long eventTime = SystemClock.uptimeMillis(); MotionEvent event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_DOWN, x, y, 0); MotionEvent event2 = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_UP, x, y, 0); try{ inst.sendPointerSync(event); inst.sendPointerSync(event2); successfull = true; }catch(SecurityException e){ ex = e; dialogUtils.hideSoftKeyboard(null, false, true); sleeper.sleep(MINI_WAIT); retry++; View identicalView = viewFetcher.getIdenticalView(view); if(identicalView != null){ float[] xyToClick = getClickCoordinates(identicalView); x = xyToClick[0]; y = xyToClick[1]; } } } if(!successfull) { Assert.fail("Click at ("+x+", "+y+") can not be completed! ("+(ex != null ? ex.getClass().getName()+": "+ex.getMessage() : "null")+")"); } }
java
public void clickOnScreen(float x, float y, View view) { boolean successfull = false; int retry = 0; SecurityException ex = null; while(!successfull && retry < 20) { long downTime = SystemClock.uptimeMillis(); long eventTime = SystemClock.uptimeMillis(); MotionEvent event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_DOWN, x, y, 0); MotionEvent event2 = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_UP, x, y, 0); try{ inst.sendPointerSync(event); inst.sendPointerSync(event2); successfull = true; }catch(SecurityException e){ ex = e; dialogUtils.hideSoftKeyboard(null, false, true); sleeper.sleep(MINI_WAIT); retry++; View identicalView = viewFetcher.getIdenticalView(view); if(identicalView != null){ float[] xyToClick = getClickCoordinates(identicalView); x = xyToClick[0]; y = xyToClick[1]; } } } if(!successfull) { Assert.fail("Click at ("+x+", "+y+") can not be completed! ("+(ex != null ? ex.getClass().getName()+": "+ex.getMessage() : "null")+")"); } }
[ "public", "void", "clickOnScreen", "(", "float", "x", ",", "float", "y", ",", "View", "view", ")", "{", "boolean", "successfull", "=", "false", ";", "int", "retry", "=", "0", ";", "SecurityException", "ex", "=", "null", ";", "while", "(", "!", "success...
Clicks on a given coordinate on the screen. @param x the x coordinate @param y the y coordinate
[ "Clicks", "on", "a", "given", "coordinate", "on", "the", "screen", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Clicker.java#L79-L111
30,045
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/Clicker.java
Clicker.clickLongOnScreen
public void clickLongOnScreen(float x, float y, int time, View view) { boolean successfull = false; int retry = 0; SecurityException ex = null; long downTime = SystemClock.uptimeMillis(); long eventTime = SystemClock.uptimeMillis(); MotionEvent event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_DOWN, x, y, 0); while(!successfull && retry < 20) { try{ inst.sendPointerSync(event); successfull = true; sleeper.sleep(MINI_WAIT); }catch(SecurityException e){ ex = e; dialogUtils.hideSoftKeyboard(null, false, true); sleeper.sleep(MINI_WAIT); retry++; View identicalView = viewFetcher.getIdenticalView(view); if(identicalView != null){ float[] xyToClick = getClickCoordinates(identicalView); x = xyToClick[0]; y = xyToClick[1]; } } } if(!successfull) { Assert.fail("Long click at ("+x+", "+y+") can not be completed! ("+(ex != null ? ex.getClass().getName()+": "+ex.getMessage() : "null")+")"); } eventTime = SystemClock.uptimeMillis(); event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_MOVE, x + 1.0f, y + 1.0f, 0); inst.sendPointerSync(event); if(time > 0) sleeper.sleep(time); else sleeper.sleep((int)(ViewConfiguration.getLongPressTimeout() * 2.5f)); eventTime = SystemClock.uptimeMillis(); event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_UP, x, y, 0); inst.sendPointerSync(event); sleeper.sleep(); }
java
public void clickLongOnScreen(float x, float y, int time, View view) { boolean successfull = false; int retry = 0; SecurityException ex = null; long downTime = SystemClock.uptimeMillis(); long eventTime = SystemClock.uptimeMillis(); MotionEvent event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_DOWN, x, y, 0); while(!successfull && retry < 20) { try{ inst.sendPointerSync(event); successfull = true; sleeper.sleep(MINI_WAIT); }catch(SecurityException e){ ex = e; dialogUtils.hideSoftKeyboard(null, false, true); sleeper.sleep(MINI_WAIT); retry++; View identicalView = viewFetcher.getIdenticalView(view); if(identicalView != null){ float[] xyToClick = getClickCoordinates(identicalView); x = xyToClick[0]; y = xyToClick[1]; } } } if(!successfull) { Assert.fail("Long click at ("+x+", "+y+") can not be completed! ("+(ex != null ? ex.getClass().getName()+": "+ex.getMessage() : "null")+")"); } eventTime = SystemClock.uptimeMillis(); event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_MOVE, x + 1.0f, y + 1.0f, 0); inst.sendPointerSync(event); if(time > 0) sleeper.sleep(time); else sleeper.sleep((int)(ViewConfiguration.getLongPressTimeout() * 2.5f)); eventTime = SystemClock.uptimeMillis(); event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_UP, x, y, 0); inst.sendPointerSync(event); sleeper.sleep(); }
[ "public", "void", "clickLongOnScreen", "(", "float", "x", ",", "float", "y", ",", "int", "time", ",", "View", "view", ")", "{", "boolean", "successfull", "=", "false", ";", "int", "retry", "=", "0", ";", "SecurityException", "ex", "=", "null", ";", "lo...
Long clicks a given coordinate on the screen. @param x the x coordinate @param y the y coordinate @param time the amount of time to long click
[ "Long", "clicks", "a", "given", "coordinate", "on", "the", "screen", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Clicker.java#L121-L163
30,046
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/Clicker.java
Clicker.clickOnScreen
public void clickOnScreen(View view, boolean longClick, int time) { if(view == null) Assert.fail("View is null and can therefore not be clicked!"); float[] xyToClick = getClickCoordinates(view); float x = xyToClick[0]; float y = xyToClick[1]; if(x == 0 || y == 0){ sleeper.sleepMini(); try { view = viewFetcher.getIdenticalView(view); } catch (Exception ignored){} if(view != null){ xyToClick = getClickCoordinates(view); x = xyToClick[0]; y = xyToClick[1]; } } sleeper.sleep(300); if (longClick) clickLongOnScreen(x, y, time, view); else clickOnScreen(x, y, view); }
java
public void clickOnScreen(View view, boolean longClick, int time) { if(view == null) Assert.fail("View is null and can therefore not be clicked!"); float[] xyToClick = getClickCoordinates(view); float x = xyToClick[0]; float y = xyToClick[1]; if(x == 0 || y == 0){ sleeper.sleepMini(); try { view = viewFetcher.getIdenticalView(view); } catch (Exception ignored){} if(view != null){ xyToClick = getClickCoordinates(view); x = xyToClick[0]; y = xyToClick[1]; } } sleeper.sleep(300); if (longClick) clickLongOnScreen(x, y, time, view); else clickOnScreen(x, y, view); }
[ "public", "void", "clickOnScreen", "(", "View", "view", ",", "boolean", "longClick", ",", "int", "time", ")", "{", "if", "(", "view", "==", "null", ")", "Assert", ".", "fail", "(", "\"View is null and can therefore not be clicked!\"", ")", ";", "float", "[", ...
Private method used to click on a given view. @param view the view that should be clicked @param longClick true if the click should be a long click @param time the amount of time to long click
[ "Private", "method", "used", "to", "click", "on", "a", "given", "view", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Clicker.java#L184-L210
30,047
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/Clicker.java
Clicker.getClickCoordinates
private float[] getClickCoordinates(View view){ int[] xyLocation = new int[2]; float[] xyToClick = new float[2]; int trialCount = 0; view.getLocationOnScreen(xyLocation); while(xyLocation[0] == 0 && xyLocation[1] == 0 && trialCount < 10) { sleeper.sleep(300); view.getLocationOnScreen(xyLocation); trialCount++; } final int viewWidth = view.getWidth(); final int viewHeight = view.getHeight(); final float x = xyLocation[0] + (viewWidth / 2.0f); float y = xyLocation[1] + (viewHeight / 2.0f); xyToClick[0] = x; xyToClick[1] = y; return xyToClick; }
java
private float[] getClickCoordinates(View view){ int[] xyLocation = new int[2]; float[] xyToClick = new float[2]; int trialCount = 0; view.getLocationOnScreen(xyLocation); while(xyLocation[0] == 0 && xyLocation[1] == 0 && trialCount < 10) { sleeper.sleep(300); view.getLocationOnScreen(xyLocation); trialCount++; } final int viewWidth = view.getWidth(); final int viewHeight = view.getHeight(); final float x = xyLocation[0] + (viewWidth / 2.0f); float y = xyLocation[1] + (viewHeight / 2.0f); xyToClick[0] = x; xyToClick[1] = y; return xyToClick; }
[ "private", "float", "[", "]", "getClickCoordinates", "(", "View", "view", ")", "{", "int", "[", "]", "xyLocation", "=", "new", "int", "[", "2", "]", ";", "float", "[", "]", "xyToClick", "=", "new", "float", "[", "2", "]", ";", "int", "trialCount", ...
Returns click coordinates for the specified view. @param view the view to get click coordinates from @return click coordinates for a specified view
[ "Returns", "click", "coordinates", "for", "the", "specified", "view", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Clicker.java#L219-L240
30,048
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/Clicker.java
Clicker.openMenu
private void openMenu(){ sleeper.sleepMini(); if(!dialogUtils.waitForDialogToOpen(MINI_WAIT, false)) { try{ sender.sendKeyCode(KeyEvent.KEYCODE_MENU); dialogUtils.waitForDialogToOpen(WAIT_TIME, true); }catch(SecurityException e){ Assert.fail("Can not open the menu!"); } } }
java
private void openMenu(){ sleeper.sleepMini(); if(!dialogUtils.waitForDialogToOpen(MINI_WAIT, false)) { try{ sender.sendKeyCode(KeyEvent.KEYCODE_MENU); dialogUtils.waitForDialogToOpen(WAIT_TIME, true); }catch(SecurityException e){ Assert.fail("Can not open the menu!"); } } }
[ "private", "void", "openMenu", "(", ")", "{", "sleeper", ".", "sleepMini", "(", ")", ";", "if", "(", "!", "dialogUtils", ".", "waitForDialogToOpen", "(", "MINI_WAIT", ",", "false", ")", ")", "{", "try", "{", "sender", ".", "sendKeyCode", "(", "KeyEvent",...
Opens the menu and waits for it to open.
[ "Opens", "the", "menu", "and", "waits", "for", "it", "to", "open", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Clicker.java#L274-L285
30,049
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/Clicker.java
Clicker.clickOnMenuItem
public void clickOnMenuItem(String text, boolean subMenu) { sleeper.sleepMini(); TextView textMore = null; int [] xy = new int[2]; int x = 0; int y = 0; if(!dialogUtils.waitForDialogToOpen(MINI_WAIT, false)) { try{ sender.sendKeyCode(KeyEvent.KEYCODE_MENU); dialogUtils.waitForDialogToOpen(WAIT_TIME, true); }catch(SecurityException e){ Assert.fail("Can not open the menu!"); } } boolean textShown = waiter.waitForText(text, 1, WAIT_TIME, true) != null; if(subMenu && (viewFetcher.getCurrentViews(TextView.class, true).size() > 5) && !textShown){ for(TextView textView : viewFetcher.getCurrentViews(TextView.class, true)){ x = xy[0]; y = xy[1]; textView.getLocationOnScreen(xy); if(xy[0] > x || xy[1] > y) textMore = textView; } } if(textMore != null) clickOnScreen(textMore); clickOnText(text, false, 1, true, 0); }
java
public void clickOnMenuItem(String text, boolean subMenu) { sleeper.sleepMini(); TextView textMore = null; int [] xy = new int[2]; int x = 0; int y = 0; if(!dialogUtils.waitForDialogToOpen(MINI_WAIT, false)) { try{ sender.sendKeyCode(KeyEvent.KEYCODE_MENU); dialogUtils.waitForDialogToOpen(WAIT_TIME, true); }catch(SecurityException e){ Assert.fail("Can not open the menu!"); } } boolean textShown = waiter.waitForText(text, 1, WAIT_TIME, true) != null; if(subMenu && (viewFetcher.getCurrentViews(TextView.class, true).size() > 5) && !textShown){ for(TextView textView : viewFetcher.getCurrentViews(TextView.class, true)){ x = xy[0]; y = xy[1]; textView.getLocationOnScreen(xy); if(xy[0] > x || xy[1] > y) textMore = textView; } } if(textMore != null) clickOnScreen(textMore); clickOnText(text, false, 1, true, 0); }
[ "public", "void", "clickOnMenuItem", "(", "String", "text", ",", "boolean", "subMenu", ")", "{", "sleeper", ".", "sleepMini", "(", ")", ";", "TextView", "textMore", "=", "null", ";", "int", "[", "]", "xy", "=", "new", "int", "[", "2", "]", ";", "int"...
Clicks on a menu item with a given text. @param text the menu text that should be clicked on. The parameter <strong>will</strong> be interpreted as a regular expression. @param subMenu true if the menu item could be located in a sub menu
[ "Clicks", "on", "a", "menu", "item", "with", "a", "given", "text", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Clicker.java#L306-L339
30,050
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/Clicker.java
Clicker.clickOnActionBarItem
public void clickOnActionBarItem(int resourceId){ sleeper.sleep(); Activity activity = activityUtils.getCurrentActivity(); if(activity != null){ inst.invokeMenuActionSync(activity, resourceId, 0); } }
java
public void clickOnActionBarItem(int resourceId){ sleeper.sleep(); Activity activity = activityUtils.getCurrentActivity(); if(activity != null){ inst.invokeMenuActionSync(activity, resourceId, 0); } }
[ "public", "void", "clickOnActionBarItem", "(", "int", "resourceId", ")", "{", "sleeper", ".", "sleep", "(", ")", ";", "Activity", "activity", "=", "activityUtils", ".", "getCurrentActivity", "(", ")", ";", "if", "(", "activity", "!=", "null", ")", "{", "in...
Clicks on an ActionBar item with a given resource id @param resourceId the R.id of the ActionBar item
[ "Clicks", "on", "an", "ActionBar", "item", "with", "a", "given", "resource", "id" ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Clicker.java#L347-L353
30,051
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/Clicker.java
Clicker.clickOnWebElement
public void clickOnWebElement(By by, int match, boolean scroll, boolean useJavaScriptToClick){ WebElement webElement = null; if(useJavaScriptToClick){ webElement = waiter.waitForWebElement(by, match, Timeout.getSmallTimeout(), false); if(webElement == null){ Assert.fail("WebElement with " + webUtils.splitNameByUpperCase(by.getClass().getSimpleName()) + ": '" + by.getValue() + "' is not found!"); } webUtils.executeJavaScript(by, true); return; } WebElement webElementToClick = waiter.waitForWebElement(by, match, Timeout.getSmallTimeout(), scroll); if(webElementToClick == null){ if(match > 1) { Assert.fail(match + " WebElements with " + webUtils.splitNameByUpperCase(by.getClass().getSimpleName()) + ": '" + by.getValue() + "' are not found!"); } else { Assert.fail("WebElement with " + webUtils.splitNameByUpperCase(by.getClass().getSimpleName()) + ": '" + by.getValue() + "' is not found!"); } } clickOnScreen(webElementToClick.getLocationX(), webElementToClick.getLocationY(), null); }
java
public void clickOnWebElement(By by, int match, boolean scroll, boolean useJavaScriptToClick){ WebElement webElement = null; if(useJavaScriptToClick){ webElement = waiter.waitForWebElement(by, match, Timeout.getSmallTimeout(), false); if(webElement == null){ Assert.fail("WebElement with " + webUtils.splitNameByUpperCase(by.getClass().getSimpleName()) + ": '" + by.getValue() + "' is not found!"); } webUtils.executeJavaScript(by, true); return; } WebElement webElementToClick = waiter.waitForWebElement(by, match, Timeout.getSmallTimeout(), scroll); if(webElementToClick == null){ if(match > 1) { Assert.fail(match + " WebElements with " + webUtils.splitNameByUpperCase(by.getClass().getSimpleName()) + ": '" + by.getValue() + "' are not found!"); } else { Assert.fail("WebElement with " + webUtils.splitNameByUpperCase(by.getClass().getSimpleName()) + ": '" + by.getValue() + "' is not found!"); } } clickOnScreen(webElementToClick.getLocationX(), webElementToClick.getLocationY(), null); }
[ "public", "void", "clickOnWebElement", "(", "By", "by", ",", "int", "match", ",", "boolean", "scroll", ",", "boolean", "useJavaScriptToClick", ")", "{", "WebElement", "webElement", "=", "null", ";", "if", "(", "useJavaScriptToClick", ")", "{", "webElement", "=...
Clicks on a web element using the given By method. @param by the By object e.g. By.id("id"); @param match if multiple objects match, this determines which one will be clicked @param scroll true if scrolling should be performed @param useJavaScriptToClick true if click should be perfomed through JavaScript
[ "Clicks", "on", "a", "web", "element", "using", "the", "given", "By", "method", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Clicker.java#L401-L425
30,052
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/Clicker.java
Clicker.getViewOnAbsListLine
private View getViewOnAbsListLine(AbsListView absListView, int index, int lineIndex){ final long endTime = SystemClock.uptimeMillis() + Timeout.getSmallTimeout(); View view = absListView.getChildAt(lineIndex); while(view == null){ final boolean timedOut = SystemClock.uptimeMillis() > endTime; if (timedOut){ Assert.fail("View is null and can therefore not be clicked!"); } sleeper.sleep(); absListView = (AbsListView) viewFetcher.getIdenticalView(absListView); if(absListView == null){ absListView = waiter.waitForAndGetView(index, AbsListView.class); } view = absListView.getChildAt(lineIndex); } return view; }
java
private View getViewOnAbsListLine(AbsListView absListView, int index, int lineIndex){ final long endTime = SystemClock.uptimeMillis() + Timeout.getSmallTimeout(); View view = absListView.getChildAt(lineIndex); while(view == null){ final boolean timedOut = SystemClock.uptimeMillis() > endTime; if (timedOut){ Assert.fail("View is null and can therefore not be clicked!"); } sleeper.sleep(); absListView = (AbsListView) viewFetcher.getIdenticalView(absListView); if(absListView == null){ absListView = waiter.waitForAndGetView(index, AbsListView.class); } view = absListView.getChildAt(lineIndex); } return view; }
[ "private", "View", "getViewOnAbsListLine", "(", "AbsListView", "absListView", ",", "int", "index", ",", "int", "lineIndex", ")", "{", "final", "long", "endTime", "=", "SystemClock", ".", "uptimeMillis", "(", ")", "+", "Timeout", ".", "getSmallTimeout", "(", ")...
Returns the view in the specified list line @param absListView the ListView to use @param index the index of the list. E.g. Index 1 if two lists are available @param lineIndex the line index of the View @return the View located at a specified list line
[ "Returns", "the", "view", "in", "the", "specified", "list", "line" ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Clicker.java#L659-L679
30,053
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/Clicker.java
Clicker.getViewOnRecyclerItemIndex
private View getViewOnRecyclerItemIndex(ViewGroup recyclerView, int recyclerViewIndex, int itemIndex){ final long endTime = SystemClock.uptimeMillis() + Timeout.getSmallTimeout(); View view = recyclerView.getChildAt(itemIndex); while(view == null){ final boolean timedOut = SystemClock.uptimeMillis() > endTime; if (timedOut){ Assert.fail("View is null and can therefore not be clicked!"); } sleeper.sleep(); recyclerView = (ViewGroup) viewFetcher.getIdenticalView(recyclerView); if(recyclerView == null){ recyclerView = (ViewGroup) viewFetcher.getRecyclerView(false, recyclerViewIndex); } if(recyclerView != null){ view = recyclerView.getChildAt(itemIndex); } } return view; }
java
private View getViewOnRecyclerItemIndex(ViewGroup recyclerView, int recyclerViewIndex, int itemIndex){ final long endTime = SystemClock.uptimeMillis() + Timeout.getSmallTimeout(); View view = recyclerView.getChildAt(itemIndex); while(view == null){ final boolean timedOut = SystemClock.uptimeMillis() > endTime; if (timedOut){ Assert.fail("View is null and can therefore not be clicked!"); } sleeper.sleep(); recyclerView = (ViewGroup) viewFetcher.getIdenticalView(recyclerView); if(recyclerView == null){ recyclerView = (ViewGroup) viewFetcher.getRecyclerView(false, recyclerViewIndex); } if(recyclerView != null){ view = recyclerView.getChildAt(itemIndex); } } return view; }
[ "private", "View", "getViewOnRecyclerItemIndex", "(", "ViewGroup", "recyclerView", ",", "int", "recyclerViewIndex", ",", "int", "itemIndex", ")", "{", "final", "long", "endTime", "=", "SystemClock", ".", "uptimeMillis", "(", ")", "+", "Timeout", ".", "getSmallTime...
Returns the view in the specified item index @param recyclerView the RecyclerView to use @param itemIndex the item index of the View @return the View located at a specified item index
[ "Returns", "the", "view", "in", "the", "specified", "item", "index" ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Clicker.java#L689-L711
30,054
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/WebElement.java
WebElement.getAttribute
public String getAttribute(String attributeName) { if (attributeName != null){ return this.attributes.get(attributeName); } return null; }
java
public String getAttribute(String attributeName) { if (attributeName != null){ return this.attributes.get(attributeName); } return null; }
[ "public", "String", "getAttribute", "(", "String", "attributeName", ")", "{", "if", "(", "attributeName", "!=", "null", ")", "{", "return", "this", ".", "attributes", ".", "get", "(", "attributeName", ")", ";", "}", "return", "null", ";", "}" ]
Returns the value for the specified attribute. @return the value for the specified attribute
[ "Returns", "the", "value", "for", "the", "specified", "attribute", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/WebElement.java#L201-L207
30,055
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/Asserter.java
Asserter.assertMemoryNotLow
public void assertMemoryNotLow() { ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo(); ((ActivityManager)activityUtils.getCurrentActivity().getSystemService("activity")).getMemoryInfo(mi); Assert.assertFalse("Low memory available: " + mi.availMem + " bytes!", mi.lowMemory); }
java
public void assertMemoryNotLow() { ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo(); ((ActivityManager)activityUtils.getCurrentActivity().getSystemService("activity")).getMemoryInfo(mi); Assert.assertFalse("Low memory available: " + mi.availMem + " bytes!", mi.lowMemory); }
[ "public", "void", "assertMemoryNotLow", "(", ")", "{", "ActivityManager", ".", "MemoryInfo", "mi", "=", "new", "ActivityManager", ".", "MemoryInfo", "(", ")", ";", "(", "(", "ActivityManager", ")", "activityUtils", ".", "getCurrentActivity", "(", ")", ".", "ge...
Asserts that the available memory is not considered low by the system.
[ "Asserts", "that", "the", "available", "memory", "is", "not", "considered", "low", "by", "the", "system", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Asserter.java#L125-L129
30,056
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/Setter.java
Setter.setSlidingDrawer
public void setSlidingDrawer(final SlidingDrawer slidingDrawer, final int status){ if(slidingDrawer != null){ Activity activity = activityUtils.getCurrentActivity(false); if(activity != null){ activity.runOnUiThread(new Runnable() { public void run() { try{ switch (status) { case CLOSED: slidingDrawer.close(); break; case OPENED: slidingDrawer.open(); break; } }catch (Exception ignored){} } }); } } }
java
public void setSlidingDrawer(final SlidingDrawer slidingDrawer, final int status){ if(slidingDrawer != null){ Activity activity = activityUtils.getCurrentActivity(false); if(activity != null){ activity.runOnUiThread(new Runnable() { public void run() { try{ switch (status) { case CLOSED: slidingDrawer.close(); break; case OPENED: slidingDrawer.open(); break; } }catch (Exception ignored){} } }); } } }
[ "public", "void", "setSlidingDrawer", "(", "final", "SlidingDrawer", "slidingDrawer", ",", "final", "int", "status", ")", "{", "if", "(", "slidingDrawer", "!=", "null", ")", "{", "Activity", "activity", "=", "activityUtils", ".", "getCurrentActivity", "(", "fals...
Sets the status of a given SlidingDrawer. Examples are Solo.CLOSED and Solo.OPENED. @param slidingDrawer the {@link SlidingDrawer} @param status the status that the {@link SlidingDrawer} should be set to
[ "Sets", "the", "status", "of", "a", "given", "SlidingDrawer", ".", "Examples", "are", "Solo", ".", "CLOSED", "and", "Solo", ".", "OPENED", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Setter.java#L130-L152
30,057
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/Setter.java
Setter.setNavigationDrawer
public void setNavigationDrawer(final int status){ final View homeView = getter.getView("home", 0); final View leftDrawer = getter.getView("left_drawer", 0); try{ switch (status) { case CLOSED: if(leftDrawer != null && homeView != null && leftDrawer.isShown()){ clicker.clickOnScreen(homeView); } break; case OPENED: if(leftDrawer != null && homeView != null && !leftDrawer.isShown()){ clicker.clickOnScreen(homeView); Condition condition = new Condition() { @Override public boolean isSatisfied() { return leftDrawer.isShown(); } }; waiter.waitForCondition(condition, Timeout.getSmallTimeout()); } break; } }catch (Exception ignored){} }
java
public void setNavigationDrawer(final int status){ final View homeView = getter.getView("home", 0); final View leftDrawer = getter.getView("left_drawer", 0); try{ switch (status) { case CLOSED: if(leftDrawer != null && homeView != null && leftDrawer.isShown()){ clicker.clickOnScreen(homeView); } break; case OPENED: if(leftDrawer != null && homeView != null && !leftDrawer.isShown()){ clicker.clickOnScreen(homeView); Condition condition = new Condition() { @Override public boolean isSatisfied() { return leftDrawer.isShown(); } }; waiter.waitForCondition(condition, Timeout.getSmallTimeout()); } break; } }catch (Exception ignored){} }
[ "public", "void", "setNavigationDrawer", "(", "final", "int", "status", ")", "{", "final", "View", "homeView", "=", "getter", ".", "getView", "(", "\"home\"", ",", "0", ")", ";", "final", "View", "leftDrawer", "=", "getter", ".", "getView", "(", "\"left_dr...
Sets the status of the NavigationDrawer. Examples are Solo.CLOSED and Solo.OPENED. @param status the status that the {@link NavigationDrawer} should be set to
[ "Sets", "the", "status", "of", "the", "NavigationDrawer", ".", "Examples", "are", "Solo", ".", "CLOSED", "and", "Solo", ".", "OPENED", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Setter.java#L160-L189
30,058
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/DialogUtils.java
DialogUtils.isDialogOpen
private boolean isDialogOpen(){ final Activity activity = activityUtils.getCurrentActivity(false); final View[] views = viewFetcher.getWindowDecorViews(); View view = viewFetcher.getRecentDecorView(views); if(!isDialog(activity, view)){ for(View v : views){ if(isDialog(activity, v)){ return true; } } } else { return true; } return false; }
java
private boolean isDialogOpen(){ final Activity activity = activityUtils.getCurrentActivity(false); final View[] views = viewFetcher.getWindowDecorViews(); View view = viewFetcher.getRecentDecorView(views); if(!isDialog(activity, view)){ for(View v : views){ if(isDialog(activity, v)){ return true; } } } else { return true; } return false; }
[ "private", "boolean", "isDialogOpen", "(", ")", "{", "final", "Activity", "activity", "=", "activityUtils", ".", "getCurrentActivity", "(", "false", ")", ";", "final", "View", "[", "]", "views", "=", "viewFetcher", ".", "getWindowDecorViews", "(", ")", ";", ...
Checks if a dialog is open. @return true if dialog is open
[ "Checks", "if", "a", "dialog", "is", "open", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/DialogUtils.java#L103-L119
30,059
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/DialogUtils.java
DialogUtils.isDialog
private boolean isDialog(Activity activity, View decorView){ if(decorView == null || !decorView.isShown() || activity == null){ return false; } Context viewContext = null; if(decorView != null){ viewContext = decorView.getContext(); } if (viewContext instanceof ContextThemeWrapper) { ContextThemeWrapper ctw = (ContextThemeWrapper) viewContext; viewContext = ctw.getBaseContext(); } Context activityContext = activity; Context activityBaseContext = activity.getBaseContext(); return (activityContext.equals(viewContext) || activityBaseContext.equals(viewContext)) && (decorView != activity.getWindow().getDecorView()); }
java
private boolean isDialog(Activity activity, View decorView){ if(decorView == null || !decorView.isShown() || activity == null){ return false; } Context viewContext = null; if(decorView != null){ viewContext = decorView.getContext(); } if (viewContext instanceof ContextThemeWrapper) { ContextThemeWrapper ctw = (ContextThemeWrapper) viewContext; viewContext = ctw.getBaseContext(); } Context activityContext = activity; Context activityBaseContext = activity.getBaseContext(); return (activityContext.equals(viewContext) || activityBaseContext.equals(viewContext)) && (decorView != activity.getWindow().getDecorView()); }
[ "private", "boolean", "isDialog", "(", "Activity", "activity", ",", "View", "decorView", ")", "{", "if", "(", "decorView", "==", "null", "||", "!", "decorView", ".", "isShown", "(", ")", "||", "activity", "==", "null", ")", "{", "return", "false", ";", ...
Checks that the specified DecorView and the Activity DecorView are not equal. @param activity the activity which DecorView is to be compared @param decorView the DecorView to compare @return true if not equal
[ "Checks", "that", "the", "specified", "DecorView", "and", "the", "Activity", "DecorView", "are", "not", "equal", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/DialogUtils.java#L129-L145
30,060
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/DialogUtils.java
DialogUtils.hideSoftKeyboard
public void hideSoftKeyboard(EditText editText, boolean shouldSleepFirst, boolean shouldSleepAfter) { InputMethodManager inputMethodManager; Activity activity = activityUtils.getCurrentActivity(shouldSleepFirst); if(activity == null){ inputMethodManager = (InputMethodManager) instrumentation.getTargetContext().getSystemService(Context.INPUT_METHOD_SERVICE); } else { inputMethodManager = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE); } if(editText != null) { inputMethodManager.hideSoftInputFromWindow(editText.getWindowToken(), 0); return; } View focusedView = activity.getCurrentFocus(); if(!(focusedView instanceof EditText)) { EditText freshestEditText = viewFetcher.getFreshestView(viewFetcher.getCurrentViews(EditText.class, true)); if(freshestEditText != null){ focusedView = freshestEditText; } } if(focusedView != null) { inputMethodManager.hideSoftInputFromWindow(focusedView.getWindowToken(), 0); } if(shouldSleepAfter){ sleeper.sleep(); } }
java
public void hideSoftKeyboard(EditText editText, boolean shouldSleepFirst, boolean shouldSleepAfter) { InputMethodManager inputMethodManager; Activity activity = activityUtils.getCurrentActivity(shouldSleepFirst); if(activity == null){ inputMethodManager = (InputMethodManager) instrumentation.getTargetContext().getSystemService(Context.INPUT_METHOD_SERVICE); } else { inputMethodManager = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE); } if(editText != null) { inputMethodManager.hideSoftInputFromWindow(editText.getWindowToken(), 0); return; } View focusedView = activity.getCurrentFocus(); if(!(focusedView instanceof EditText)) { EditText freshestEditText = viewFetcher.getFreshestView(viewFetcher.getCurrentViews(EditText.class, true)); if(freshestEditText != null){ focusedView = freshestEditText; } } if(focusedView != null) { inputMethodManager.hideSoftInputFromWindow(focusedView.getWindowToken(), 0); } if(shouldSleepAfter){ sleeper.sleep(); } }
[ "public", "void", "hideSoftKeyboard", "(", "EditText", "editText", ",", "boolean", "shouldSleepFirst", ",", "boolean", "shouldSleepAfter", ")", "{", "InputMethodManager", "inputMethodManager", ";", "Activity", "activity", "=", "activityUtils", ".", "getCurrentActivity", ...
Hides the soft keyboard @param shouldSleepFirst whether to sleep a default pause first @param shouldSleepAfter whether to sleep a default pause after
[ "Hides", "the", "soft", "keyboard" ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/DialogUtils.java#L154-L183
30,061
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/Waiter.java
Waiter.isActivityMatching
private boolean isActivityMatching(Activity currentActivity, String name){ if(currentActivity != null && currentActivity.getClass().getSimpleName().equals(name)) { return true; } return false; }
java
private boolean isActivityMatching(Activity currentActivity, String name){ if(currentActivity != null && currentActivity.getClass().getSimpleName().equals(name)) { return true; } return false; }
[ "private", "boolean", "isActivityMatching", "(", "Activity", "currentActivity", ",", "String", "name", ")", "{", "if", "(", "currentActivity", "!=", "null", "&&", "currentActivity", ".", "getClass", "(", ")", ".", "getSimpleName", "(", ")", ".", "equals", "(",...
Compares Activity names. @param currentActivity the Activity that is currently active @param name the name to compare @return true if the Activity names match
[ "Compares", "Activity", "names", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Waiter.java#L111-L116
30,062
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/Waiter.java
Waiter.isActivityMatching
private boolean isActivityMatching(Class<? extends Activity> activityClass, Activity currentActivity){ if(currentActivity != null && currentActivity.getClass().equals(activityClass)) { return true; } return false; }
java
private boolean isActivityMatching(Class<? extends Activity> activityClass, Activity currentActivity){ if(currentActivity != null && currentActivity.getClass().equals(activityClass)) { return true; } return false; }
[ "private", "boolean", "isActivityMatching", "(", "Class", "<", "?", "extends", "Activity", ">", "activityClass", ",", "Activity", "currentActivity", ")", "{", "if", "(", "currentActivity", "!=", "null", "&&", "currentActivity", ".", "getClass", "(", ")", ".", ...
Compares Activity classes. @param activityClass the Activity class to compare @param currentActivity the Activity that is currently active @return true if Activity classes match
[ "Compares", "Activity", "classes", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Waiter.java#L171-L176
30,063
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/Waiter.java
Waiter.getActivityMonitor
private ActivityMonitor getActivityMonitor(){ IntentFilter filter = null; ActivityMonitor activityMonitor = instrumentation.addMonitor(filter, null, false); return activityMonitor; }
java
private ActivityMonitor getActivityMonitor(){ IntentFilter filter = null; ActivityMonitor activityMonitor = instrumentation.addMonitor(filter, null, false); return activityMonitor; }
[ "private", "ActivityMonitor", "getActivityMonitor", "(", ")", "{", "IntentFilter", "filter", "=", "null", ";", "ActivityMonitor", "activityMonitor", "=", "instrumentation", ".", "addMonitor", "(", "filter", ",", "null", ",", "false", ")", ";", "return", "activityM...
Creates a new ActivityMonitor and returns it @return an ActivityMonitor
[ "Creates", "a", "new", "ActivityMonitor", "and", "returns", "it" ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Waiter.java#L183-L187
30,064
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/Waiter.java
Waiter.waitForViews
public <T extends View> boolean waitForViews(boolean scrollMethod, Class<? extends T>... classes) { final long endTime = SystemClock.uptimeMillis() + Timeout.getSmallTimeout(); while (SystemClock.uptimeMillis() < endTime) { for (Class<? extends T> classToWaitFor : classes) { if (waitForView(classToWaitFor, 0, false, false)) { return true; } } if(scrollMethod){ scroller.scroll(Scroller.DOWN); } else { scroller.scrollDown(); } sleeper.sleep(); } return false; }
java
public <T extends View> boolean waitForViews(boolean scrollMethod, Class<? extends T>... classes) { final long endTime = SystemClock.uptimeMillis() + Timeout.getSmallTimeout(); while (SystemClock.uptimeMillis() < endTime) { for (Class<? extends T> classToWaitFor : classes) { if (waitForView(classToWaitFor, 0, false, false)) { return true; } } if(scrollMethod){ scroller.scroll(Scroller.DOWN); } else { scroller.scrollDown(); } sleeper.sleep(); } return false; }
[ "public", "<", "T", "extends", "View", ">", "boolean", "waitForViews", "(", "boolean", "scrollMethod", ",", "Class", "<", "?", "extends", "T", ">", "...", "classes", ")", "{", "final", "long", "endTime", "=", "SystemClock", ".", "uptimeMillis", "(", ")", ...
Waits for two views to be shown. @param scrollMethod {@code true} if it's a method used for scrolling @param classes the classes to wait for @return {@code true} if any of the views are shown and {@code false} if none of the views are shown before the timeout
[ "Waits", "for", "two", "views", "to", "be", "shown", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Waiter.java#L273-L292
30,065
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/Waiter.java
Waiter.waitForView
public boolean waitForView(View view){ View viewToWaitFor = waitForView(view, Timeout.getLargeTimeout(), true, true); if(viewToWaitFor != null) { return true; } return false; }
java
public boolean waitForView(View view){ View viewToWaitFor = waitForView(view, Timeout.getLargeTimeout(), true, true); if(viewToWaitFor != null) { return true; } return false; }
[ "public", "boolean", "waitForView", "(", "View", "view", ")", "{", "View", "viewToWaitFor", "=", "waitForView", "(", "view", ",", "Timeout", ".", "getLargeTimeout", "(", ")", ",", "true", ",", "true", ")", ";", "if", "(", "viewToWaitFor", "!=", "null", "...
Waits for a given view. Default timeout is 20 seconds. @param view the view to wait for @return {@code true} if view is shown and {@code false} if it is not shown before the timeout
[ "Waits", "for", "a", "given", "view", ".", "Default", "timeout", "is", "20", "seconds", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Waiter.java#L302-L310
30,066
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/Waiter.java
Waiter.waitForWebElement
public WebElement waitForWebElement(final By by, int minimumNumberOfMatches, int timeout, boolean scroll){ final long endTime = SystemClock.uptimeMillis() + timeout; while (true) { final boolean timedOut = SystemClock.uptimeMillis() > endTime; if (timedOut){ searcher.logMatchesFound(by.getValue()); return null; } sleeper.sleep(); WebElement webElementToReturn = searcher.searchForWebElement(by, minimumNumberOfMatches); if(webElementToReturn != null) return webElementToReturn; if(scroll) { scroller.scrollDown(); } } }
java
public WebElement waitForWebElement(final By by, int minimumNumberOfMatches, int timeout, boolean scroll){ final long endTime = SystemClock.uptimeMillis() + timeout; while (true) { final boolean timedOut = SystemClock.uptimeMillis() > endTime; if (timedOut){ searcher.logMatchesFound(by.getValue()); return null; } sleeper.sleep(); WebElement webElementToReturn = searcher.searchForWebElement(by, minimumNumberOfMatches); if(webElementToReturn != null) return webElementToReturn; if(scroll) { scroller.scrollDown(); } } }
[ "public", "WebElement", "waitForWebElement", "(", "final", "By", "by", ",", "int", "minimumNumberOfMatches", ",", "int", "timeout", ",", "boolean", "scroll", ")", "{", "final", "long", "endTime", "=", "SystemClock", ".", "uptimeMillis", "(", ")", "+", "timeout...
Waits for a web element. @param by the By object. Examples are By.id("id") and By.name("name") @param minimumNumberOfMatches the minimum number of matches that are expected to be shown. {@code 0} means any number of matches @param timeout the the amount of time in milliseconds to wait @param scroll {@code true} if scrolling should be performed
[ "Waits", "for", "a", "web", "element", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Waiter.java#L483-L505
30,067
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/Waiter.java
Waiter.waitForAndGetView
public <T extends View> T waitForAndGetView(int index, Class<T> classToFilterBy){ long endTime = SystemClock.uptimeMillis() + Timeout.getSmallTimeout(); while (SystemClock.uptimeMillis() <= endTime && !waitForView(classToFilterBy, index, true, true)); int numberOfUniqueViews = searcher.getNumberOfUniqueViews(); ArrayList<T> views = RobotiumUtils.removeInvisibleViews(viewFetcher.getCurrentViews(classToFilterBy, true)); if(views.size() < numberOfUniqueViews){ int newIndex = index - (numberOfUniqueViews - views.size()); if(newIndex >= 0) index = newIndex; } T view = null; try{ view = views.get(index); }catch (IndexOutOfBoundsException exception) { int match = index + 1; if(match > 1) { Assert.fail(match + " " + classToFilterBy.getSimpleName() +"s" + " are not found!"); } else { Assert.fail(classToFilterBy.getSimpleName() + " is not found!"); } } views = null; return view; }
java
public <T extends View> T waitForAndGetView(int index, Class<T> classToFilterBy){ long endTime = SystemClock.uptimeMillis() + Timeout.getSmallTimeout(); while (SystemClock.uptimeMillis() <= endTime && !waitForView(classToFilterBy, index, true, true)); int numberOfUniqueViews = searcher.getNumberOfUniqueViews(); ArrayList<T> views = RobotiumUtils.removeInvisibleViews(viewFetcher.getCurrentViews(classToFilterBy, true)); if(views.size() < numberOfUniqueViews){ int newIndex = index - (numberOfUniqueViews - views.size()); if(newIndex >= 0) index = newIndex; } T view = null; try{ view = views.get(index); }catch (IndexOutOfBoundsException exception) { int match = index + 1; if(match > 1) { Assert.fail(match + " " + classToFilterBy.getSimpleName() +"s" + " are not found!"); } else { Assert.fail(classToFilterBy.getSimpleName() + " is not found!"); } } views = null; return view; }
[ "public", "<", "T", "extends", "View", ">", "T", "waitForAndGetView", "(", "int", "index", ",", "Class", "<", "T", ">", "classToFilterBy", ")", "{", "long", "endTime", "=", "SystemClock", ".", "uptimeMillis", "(", ")", "+", "Timeout", ".", "getSmallTimeout...
Waits for and returns a View. @param index the index of the view @param classToFilterby the class to filter @return the specified View
[ "Waits", "for", "and", "returns", "a", "View", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Waiter.java#L645-L671
30,068
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/Waiter.java
Waiter.waitForFragment
public boolean waitForFragment(String tag, int id, int timeout){ long endTime = SystemClock.uptimeMillis() + timeout; while (SystemClock.uptimeMillis() <= endTime) { if(getSupportFragment(tag, id) != null) return true; if(getFragment(tag, id) != null) return true; } return false; }
java
public boolean waitForFragment(String tag, int id, int timeout){ long endTime = SystemClock.uptimeMillis() + timeout; while (SystemClock.uptimeMillis() <= endTime) { if(getSupportFragment(tag, id) != null) return true; if(getFragment(tag, id) != null) return true; } return false; }
[ "public", "boolean", "waitForFragment", "(", "String", "tag", ",", "int", "id", ",", "int", "timeout", ")", "{", "long", "endTime", "=", "SystemClock", ".", "uptimeMillis", "(", ")", "+", "timeout", ";", "while", "(", "SystemClock", ".", "uptimeMillis", "(...
Waits for a Fragment with a given tag or id to appear. @param tag the name of the tag or null if no tag @param id the id of the tag @param timeout the amount of time in milliseconds to wait @return true if fragment appears and false if it does not appear before the timeout
[ "Waits", "for", "a", "Fragment", "with", "a", "given", "tag", "or", "id", "to", "appear", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Waiter.java#L682-L693
30,069
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/Waiter.java
Waiter.getSupportFragment
private Fragment getSupportFragment(String tag, int id){ FragmentActivity fragmentActivity = null; try{ fragmentActivity = (FragmentActivity) activityUtils.getCurrentActivity(false); }catch (Throwable ignored) {} if(fragmentActivity != null){ try{ if(tag == null) return fragmentActivity.getSupportFragmentManager().findFragmentById(id); else return fragmentActivity.getSupportFragmentManager().findFragmentByTag(tag); }catch (NoSuchMethodError ignored) {} } return null; }
java
private Fragment getSupportFragment(String tag, int id){ FragmentActivity fragmentActivity = null; try{ fragmentActivity = (FragmentActivity) activityUtils.getCurrentActivity(false); }catch (Throwable ignored) {} if(fragmentActivity != null){ try{ if(tag == null) return fragmentActivity.getSupportFragmentManager().findFragmentById(id); else return fragmentActivity.getSupportFragmentManager().findFragmentByTag(tag); }catch (NoSuchMethodError ignored) {} } return null; }
[ "private", "Fragment", "getSupportFragment", "(", "String", "tag", ",", "int", "id", ")", "{", "FragmentActivity", "fragmentActivity", "=", "null", ";", "try", "{", "fragmentActivity", "=", "(", "FragmentActivity", ")", "activityUtils", ".", "getCurrentActivity", ...
Returns a SupportFragment with a given tag or id. @param tag the tag of the SupportFragment or null if no tag @param id the id of the SupportFragment @return a SupportFragment with a given tag or id
[ "Returns", "a", "SupportFragment", "with", "a", "given", "tag", "or", "id", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Waiter.java#L703-L719
30,070
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/Waiter.java
Waiter.getLog
private StringBuilder getLog(StringBuilder stringBuilder) { Process p = null; BufferedReader reader = null; String line = null; try { // read output from logcat p = Runtime.getRuntime().exec("logcat -d"); reader = new BufferedReader( new InputStreamReader(p.getInputStream())); stringBuilder.setLength(0); while ((line = reader.readLine()) != null) { stringBuilder.append(line); } reader.close(); // read error from logcat StringBuilder errorLog = new StringBuilder(); reader = new BufferedReader(new InputStreamReader( p.getErrorStream())); errorLog.append("logcat returns error: "); while ((line = reader.readLine()) != null) { errorLog.append(line); } reader.close(); // Exception would be thrown if we get exitValue without waiting for the process // to finish p.waitFor(); // if exit value of logcat is non-zero, it means error if (p.exitValue() != 0) { destroy(p, reader); throw new Exception(errorLog.toString()); } } catch (IOException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } destroy(p, reader); return stringBuilder; }
java
private StringBuilder getLog(StringBuilder stringBuilder) { Process p = null; BufferedReader reader = null; String line = null; try { // read output from logcat p = Runtime.getRuntime().exec("logcat -d"); reader = new BufferedReader( new InputStreamReader(p.getInputStream())); stringBuilder.setLength(0); while ((line = reader.readLine()) != null) { stringBuilder.append(line); } reader.close(); // read error from logcat StringBuilder errorLog = new StringBuilder(); reader = new BufferedReader(new InputStreamReader( p.getErrorStream())); errorLog.append("logcat returns error: "); while ((line = reader.readLine()) != null) { errorLog.append(line); } reader.close(); // Exception would be thrown if we get exitValue without waiting for the process // to finish p.waitFor(); // if exit value of logcat is non-zero, it means error if (p.exitValue() != 0) { destroy(p, reader); throw new Exception(errorLog.toString()); } } catch (IOException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } destroy(p, reader); return stringBuilder; }
[ "private", "StringBuilder", "getLog", "(", "StringBuilder", "stringBuilder", ")", "{", "Process", "p", "=", "null", ";", "BufferedReader", "reader", "=", "null", ";", "String", "line", "=", "null", ";", "try", "{", "// read output from logcat", "p", "=", "Runt...
Returns the log in the given stringBuilder. @param stringBuilder the StringBuilder object to return the log in @return the log
[ "Returns", "the", "log", "in", "the", "given", "stringBuilder", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Waiter.java#L751-L798
30,071
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/Waiter.java
Waiter.clearLog
public void clearLog(){ Process p = null; try { p = Runtime.getRuntime().exec("logcat -c"); }catch(IOException e){ e.printStackTrace(); } }
java
public void clearLog(){ Process p = null; try { p = Runtime.getRuntime().exec("logcat -c"); }catch(IOException e){ e.printStackTrace(); } }
[ "public", "void", "clearLog", "(", ")", "{", "Process", "p", "=", "null", ";", "try", "{", "p", "=", "Runtime", ".", "getRuntime", "(", ")", ".", "exec", "(", "\"logcat -c\"", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "e", ".", "...
Clears the log.
[ "Clears", "the", "log", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Waiter.java#L804-L811
30,072
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/Waiter.java
Waiter.destroy
private void destroy(Process p, BufferedReader reader){ p.destroy(); try { reader.close(); } catch (IOException e) { e.printStackTrace(); } }
java
private void destroy(Process p, BufferedReader reader){ p.destroy(); try { reader.close(); } catch (IOException e) { e.printStackTrace(); } }
[ "private", "void", "destroy", "(", "Process", "p", ",", "BufferedReader", "reader", ")", "{", "p", ".", "destroy", "(", ")", ";", "try", "{", "reader", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "e", ".", "printSt...
Destroys the process and closes the BufferedReader. @param p the process to destroy @param reader the BufferedReader to close
[ "Destroys", "the", "process", "and", "closes", "the", "BufferedReader", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Waiter.java#L820-L827
30,073
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/Waiter.java
Waiter.getFragment
private android.app.Fragment getFragment(String tag, int id){ try{ if(tag == null) return activityUtils.getCurrentActivity().getFragmentManager().findFragmentById(id); else return activityUtils.getCurrentActivity().getFragmentManager().findFragmentByTag(tag); }catch (Throwable ignored) {} return null; }
java
private android.app.Fragment getFragment(String tag, int id){ try{ if(tag == null) return activityUtils.getCurrentActivity().getFragmentManager().findFragmentById(id); else return activityUtils.getCurrentActivity().getFragmentManager().findFragmentByTag(tag); }catch (Throwable ignored) {} return null; }
[ "private", "android", ".", "app", ".", "Fragment", "getFragment", "(", "String", "tag", ",", "int", "id", ")", "{", "try", "{", "if", "(", "tag", "==", "null", ")", "return", "activityUtils", ".", "getCurrentActivity", "(", ")", ".", "getFragmentManager", ...
Returns a Fragment with a given tag or id. @param tag the tag of the Fragment or null if no tag @param id the id of the Fragment @return a SupportFragment with a given tag or id
[ "Returns", "a", "Fragment", "with", "a", "given", "tag", "or", "id", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Waiter.java#L837-L847
30,074
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/WebUtils.java
WebUtils.createAndReturnTextViewsFromWebElements
private ArrayList <TextView> createAndReturnTextViewsFromWebElements(boolean javaScriptWasExecuted){ ArrayList<TextView> webElementsAsTextViews = new ArrayList<TextView>(); if(javaScriptWasExecuted){ for(WebElement webElement : webElementCreator.getWebElementsFromWebViews()){ if(isWebElementSufficientlyShown(webElement)){ RobotiumTextView textView = new RobotiumTextView(inst.getContext(), webElement.getText(), webElement.getLocationX(), webElement.getLocationY()); webElementsAsTextViews.add(textView); } } } return webElementsAsTextViews; }
java
private ArrayList <TextView> createAndReturnTextViewsFromWebElements(boolean javaScriptWasExecuted){ ArrayList<TextView> webElementsAsTextViews = new ArrayList<TextView>(); if(javaScriptWasExecuted){ for(WebElement webElement : webElementCreator.getWebElementsFromWebViews()){ if(isWebElementSufficientlyShown(webElement)){ RobotiumTextView textView = new RobotiumTextView(inst.getContext(), webElement.getText(), webElement.getLocationX(), webElement.getLocationY()); webElementsAsTextViews.add(textView); } } } return webElementsAsTextViews; }
[ "private", "ArrayList", "<", "TextView", ">", "createAndReturnTextViewsFromWebElements", "(", "boolean", "javaScriptWasExecuted", ")", "{", "ArrayList", "<", "TextView", ">", "webElementsAsTextViews", "=", "new", "ArrayList", "<", "TextView", ">", "(", ")", ";", "if...
Creates and returns TextView objects based on WebElements @return an ArrayList with TextViews
[ "Creates", "and", "returns", "TextView", "objects", "based", "on", "WebElements" ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/WebUtils.java#L71-L83
30,075
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/WebUtils.java
WebUtils.getWebElements
public ArrayList<WebElement> getWebElements(final By by, boolean onlySufficientlyVisbile){ boolean javaScriptWasExecuted = executeJavaScript(by, false); if(config.useJavaScriptToClickWebElements){ if(!javaScriptWasExecuted){ return new ArrayList<WebElement>(); } return webElementCreator.getWebElementsFromWebViews(); } return getWebElements(javaScriptWasExecuted, onlySufficientlyVisbile); }
java
public ArrayList<WebElement> getWebElements(final By by, boolean onlySufficientlyVisbile){ boolean javaScriptWasExecuted = executeJavaScript(by, false); if(config.useJavaScriptToClickWebElements){ if(!javaScriptWasExecuted){ return new ArrayList<WebElement>(); } return webElementCreator.getWebElementsFromWebViews(); } return getWebElements(javaScriptWasExecuted, onlySufficientlyVisbile); }
[ "public", "ArrayList", "<", "WebElement", ">", "getWebElements", "(", "final", "By", "by", ",", "boolean", "onlySufficientlyVisbile", ")", "{", "boolean", "javaScriptWasExecuted", "=", "executeJavaScript", "(", "by", ",", "false", ")", ";", "if", "(", "config", ...
Returns an ArrayList of WebElements of the specified By object currently shown in the active WebView. @param by the By object. Examples are By.id("id") and By.name("name") @param onlySufficientlyVisible true if only sufficiently visible {@link WebElement} objects should be returned @return an {@code ArrayList} of the {@link WebElement} objects currently shown in the active WebView
[ "Returns", "an", "ArrayList", "of", "WebElements", "of", "the", "specified", "By", "object", "currently", "shown", "in", "the", "active", "WebView", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/WebUtils.java#L106-L117
30,076
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/WebUtils.java
WebUtils.getWebElements
private ArrayList<WebElement> getWebElements(boolean javaScriptWasExecuted, boolean onlySufficientlyVisbile){ ArrayList<WebElement> webElements = new ArrayList<WebElement>(); if(javaScriptWasExecuted){ for(WebElement webElement : webElementCreator.getWebElementsFromWebViews()){ if(!onlySufficientlyVisbile){ webElements.add(webElement); } else if(isWebElementSufficientlyShown(webElement)){ webElements.add(webElement); } } } return webElements; }
java
private ArrayList<WebElement> getWebElements(boolean javaScriptWasExecuted, boolean onlySufficientlyVisbile){ ArrayList<WebElement> webElements = new ArrayList<WebElement>(); if(javaScriptWasExecuted){ for(WebElement webElement : webElementCreator.getWebElementsFromWebViews()){ if(!onlySufficientlyVisbile){ webElements.add(webElement); } else if(isWebElementSufficientlyShown(webElement)){ webElements.add(webElement); } } } return webElements; }
[ "private", "ArrayList", "<", "WebElement", ">", "getWebElements", "(", "boolean", "javaScriptWasExecuted", ",", "boolean", "onlySufficientlyVisbile", ")", "{", "ArrayList", "<", "WebElement", ">", "webElements", "=", "new", "ArrayList", "<", "WebElement", ">", "(", ...
Returns the sufficiently shown WebElements @param javaScriptWasExecuted true if JavaScript was executed @param onlySufficientlyVisible true if only sufficiently visible {@link WebElement} objects should be returned @return the sufficiently shown WebElements
[ "Returns", "the", "sufficiently", "shown", "WebElements" ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/WebUtils.java#L127-L141
30,077
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/WebUtils.java
WebUtils.prepareForStartOfJavascriptExecution
private String prepareForStartOfJavascriptExecution(List<WebView> webViews) { webElementCreator.prepareForStart(); WebChromeClient currentWebChromeClient = getCurrentWebChromeClient(); if(currentWebChromeClient != null && !currentWebChromeClient.getClass().isAssignableFrom(RobotiumWebClient.class)){ originalWebChromeClient = currentWebChromeClient; } robotiumWebCLient.enableJavascriptAndSetRobotiumWebClient(webViews, originalWebChromeClient); return getJavaScriptAsString(); }
java
private String prepareForStartOfJavascriptExecution(List<WebView> webViews) { webElementCreator.prepareForStart(); WebChromeClient currentWebChromeClient = getCurrentWebChromeClient(); if(currentWebChromeClient != null && !currentWebChromeClient.getClass().isAssignableFrom(RobotiumWebClient.class)){ originalWebChromeClient = currentWebChromeClient; } robotiumWebCLient.enableJavascriptAndSetRobotiumWebClient(webViews, originalWebChromeClient); return getJavaScriptAsString(); }
[ "private", "String", "prepareForStartOfJavascriptExecution", "(", "List", "<", "WebView", ">", "webViews", ")", "{", "webElementCreator", ".", "prepareForStart", "(", ")", ";", "WebChromeClient", "currentWebChromeClient", "=", "getCurrentWebChromeClient", "(", ")", ";",...
Prepares for start of JavaScript execution @return the JavaScript as a String
[ "Prepares", "for", "start", "of", "JavaScript", "execution" ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/WebUtils.java#L149-L159
30,078
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/WebUtils.java
WebUtils.getCurrentWebChromeClient
private WebChromeClient getCurrentWebChromeClient(){ WebChromeClient currentWebChromeClient = null; Object currentWebView = viewFetcher.getFreshestView(viewFetcher.getCurrentViews(WebView.class, true)); if (android.os.Build.VERSION.SDK_INT >= 16) { try{ currentWebView = new Reflect(currentWebView).field("mProvider").out(Object.class); }catch(IllegalArgumentException ignored) {} } try{ if (android.os.Build.VERSION.SDK_INT >= 19) { Object mClientAdapter = new Reflect(currentWebView).field("mContentsClientAdapter").out(Object.class); currentWebChromeClient = new Reflect(mClientAdapter).field("mWebChromeClient").out(WebChromeClient.class); } else { Object mCallbackProxy = new Reflect(currentWebView).field("mCallbackProxy").out(Object.class); currentWebChromeClient = new Reflect(mCallbackProxy).field("mWebChromeClient").out(WebChromeClient.class); } }catch(Exception ignored){} return currentWebChromeClient; }
java
private WebChromeClient getCurrentWebChromeClient(){ WebChromeClient currentWebChromeClient = null; Object currentWebView = viewFetcher.getFreshestView(viewFetcher.getCurrentViews(WebView.class, true)); if (android.os.Build.VERSION.SDK_INT >= 16) { try{ currentWebView = new Reflect(currentWebView).field("mProvider").out(Object.class); }catch(IllegalArgumentException ignored) {} } try{ if (android.os.Build.VERSION.SDK_INT >= 19) { Object mClientAdapter = new Reflect(currentWebView).field("mContentsClientAdapter").out(Object.class); currentWebChromeClient = new Reflect(mClientAdapter).field("mWebChromeClient").out(WebChromeClient.class); } else { Object mCallbackProxy = new Reflect(currentWebView).field("mCallbackProxy").out(Object.class); currentWebChromeClient = new Reflect(mCallbackProxy).field("mWebChromeClient").out(WebChromeClient.class); } }catch(Exception ignored){} return currentWebChromeClient; }
[ "private", "WebChromeClient", "getCurrentWebChromeClient", "(", ")", "{", "WebChromeClient", "currentWebChromeClient", "=", "null", ";", "Object", "currentWebView", "=", "viewFetcher", ".", "getFreshestView", "(", "viewFetcher", ".", "getCurrentViews", "(", "WebView", "...
Returns the current WebChromeClient through reflection @return the current WebChromeClient
[ "Returns", "the", "current", "WebChromeClient", "through", "reflection" ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/WebUtils.java#L168-L191
30,079
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/WebUtils.java
WebUtils.enterTextIntoWebElement
public void enterTextIntoWebElement(final By by, final String text){ if(by instanceof By.Id){ executeJavaScriptFunction("enterTextById(\""+by.getValue()+"\", \""+text+"\");"); } else if(by instanceof By.Xpath){ executeJavaScriptFunction("enterTextByXpath(\""+by.getValue()+"\", \""+text+"\");"); } else if(by instanceof By.CssSelector){ executeJavaScriptFunction("enterTextByCssSelector(\""+by.getValue()+"\", \""+text+"\");"); } else if(by instanceof By.Name){ executeJavaScriptFunction("enterTextByName(\""+by.getValue()+"\", \""+text+"\");"); } else if(by instanceof By.ClassName){ executeJavaScriptFunction("enterTextByClassName(\""+by.getValue()+"\", \""+text+"\");"); } else if(by instanceof By.Text){ executeJavaScriptFunction("enterTextByTextContent(\""+by.getValue()+"\", \""+text+"\");"); } else if(by instanceof By.TagName){ executeJavaScriptFunction("enterTextByTagName(\""+by.getValue()+"\", \""+text+"\");"); } }
java
public void enterTextIntoWebElement(final By by, final String text){ if(by instanceof By.Id){ executeJavaScriptFunction("enterTextById(\""+by.getValue()+"\", \""+text+"\");"); } else if(by instanceof By.Xpath){ executeJavaScriptFunction("enterTextByXpath(\""+by.getValue()+"\", \""+text+"\");"); } else if(by instanceof By.CssSelector){ executeJavaScriptFunction("enterTextByCssSelector(\""+by.getValue()+"\", \""+text+"\");"); } else if(by instanceof By.Name){ executeJavaScriptFunction("enterTextByName(\""+by.getValue()+"\", \""+text+"\");"); } else if(by instanceof By.ClassName){ executeJavaScriptFunction("enterTextByClassName(\""+by.getValue()+"\", \""+text+"\");"); } else if(by instanceof By.Text){ executeJavaScriptFunction("enterTextByTextContent(\""+by.getValue()+"\", \""+text+"\");"); } else if(by instanceof By.TagName){ executeJavaScriptFunction("enterTextByTagName(\""+by.getValue()+"\", \""+text+"\");"); } }
[ "public", "void", "enterTextIntoWebElement", "(", "final", "By", "by", ",", "final", "String", "text", ")", "{", "if", "(", "by", "instanceof", "By", ".", "Id", ")", "{", "executeJavaScriptFunction", "(", "\"enterTextById(\\\"\"", "+", "by", ".", "getValue", ...
Enters text into a web element using the given By method @param by the By object e.g. By.id("id"); @param text the text to enter
[ "Enters", "text", "into", "a", "web", "element", "using", "the", "given", "By", "method" ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/WebUtils.java#L200-L222
30,080
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/WebUtils.java
WebUtils.executeJavaScript
public boolean executeJavaScript(final By by, boolean shouldClick){ if(by instanceof By.Id){ return executeJavaScriptFunction("id(\""+by.getValue()+"\", \"" + String.valueOf(shouldClick) + "\");"); } else if(by instanceof By.Xpath){ return executeJavaScriptFunction("xpath(\""+by.getValue()+"\", \"" + String.valueOf(shouldClick) + "\");"); } else if(by instanceof By.CssSelector){ return executeJavaScriptFunction("cssSelector(\""+by.getValue()+"\", \"" + String.valueOf(shouldClick) + "\");"); } else if(by instanceof By.Name){ return executeJavaScriptFunction("name(\""+by.getValue()+"\", \"" + String.valueOf(shouldClick) + "\");"); } else if(by instanceof By.ClassName){ return executeJavaScriptFunction("className(\""+by.getValue()+"\", \"" + String.valueOf(shouldClick) + "\");"); } else if(by instanceof By.Text){ return executeJavaScriptFunction("textContent(\""+by.getValue()+"\", \"" + String.valueOf(shouldClick) + "\");"); } else if(by instanceof By.TagName){ return executeJavaScriptFunction("tagName(\""+by.getValue()+"\", \"" + String.valueOf(shouldClick) + "\");"); } return false; }
java
public boolean executeJavaScript(final By by, boolean shouldClick){ if(by instanceof By.Id){ return executeJavaScriptFunction("id(\""+by.getValue()+"\", \"" + String.valueOf(shouldClick) + "\");"); } else if(by instanceof By.Xpath){ return executeJavaScriptFunction("xpath(\""+by.getValue()+"\", \"" + String.valueOf(shouldClick) + "\");"); } else if(by instanceof By.CssSelector){ return executeJavaScriptFunction("cssSelector(\""+by.getValue()+"\", \"" + String.valueOf(shouldClick) + "\");"); } else if(by instanceof By.Name){ return executeJavaScriptFunction("name(\""+by.getValue()+"\", \"" + String.valueOf(shouldClick) + "\");"); } else if(by instanceof By.ClassName){ return executeJavaScriptFunction("className(\""+by.getValue()+"\", \"" + String.valueOf(shouldClick) + "\");"); } else if(by instanceof By.Text){ return executeJavaScriptFunction("textContent(\""+by.getValue()+"\", \"" + String.valueOf(shouldClick) + "\");"); } else if(by instanceof By.TagName){ return executeJavaScriptFunction("tagName(\""+by.getValue()+"\", \"" + String.valueOf(shouldClick) + "\");"); } return false; }
[ "public", "boolean", "executeJavaScript", "(", "final", "By", "by", ",", "boolean", "shouldClick", ")", "{", "if", "(", "by", "instanceof", "By", ".", "Id", ")", "{", "return", "executeJavaScriptFunction", "(", "\"id(\\\"\"", "+", "by", ".", "getValue", "(",...
Executes JavaScript determined by the given By object @param by the By object e.g. By.id("id"); @param shouldClick true if click should be performed @return true if JavaScript function was executed
[ "Executes", "JavaScript", "determined", "by", "the", "given", "By", "object" ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/WebUtils.java#L232-L255
30,081
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/WebUtils.java
WebUtils.executeJavaScriptFunction
private boolean executeJavaScriptFunction(final String function) { List<WebView> webViews = viewFetcher.getCurrentViews(WebView.class, true); final WebView webView = viewFetcher.getFreshestView((ArrayList<WebView>) webViews); if(webView == null) { return false; } final String javaScript = setWebFrame(prepareForStartOfJavascriptExecution(webViews)); inst.runOnMainSync(new Runnable() { public void run() { if(webView != null){ webView.loadUrl("javascript:" + javaScript + function); } } }); return true; }
java
private boolean executeJavaScriptFunction(final String function) { List<WebView> webViews = viewFetcher.getCurrentViews(WebView.class, true); final WebView webView = viewFetcher.getFreshestView((ArrayList<WebView>) webViews); if(webView == null) { return false; } final String javaScript = setWebFrame(prepareForStartOfJavascriptExecution(webViews)); inst.runOnMainSync(new Runnable() { public void run() { if(webView != null){ webView.loadUrl("javascript:" + javaScript + function); } } }); return true; }
[ "private", "boolean", "executeJavaScriptFunction", "(", "final", "String", "function", ")", "{", "List", "<", "WebView", ">", "webViews", "=", "viewFetcher", ".", "getCurrentViews", "(", "WebView", ".", "class", ",", "true", ")", ";", "final", "WebView", "webV...
Executes the given JavaScript function @param function the function as a String @return true if JavaScript function was executed
[ "Executes", "the", "given", "JavaScript", "function" ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/WebUtils.java#L264-L282
30,082
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/WebUtils.java
WebUtils.splitNameByUpperCase
public String splitNameByUpperCase(String name) { String [] texts = name.split("(?=\\p{Upper})"); StringBuilder stringToReturn = new StringBuilder(); for(String string : texts){ if(stringToReturn.length() > 0) { stringToReturn.append(" " + string.toLowerCase()); } else { stringToReturn.append(string.toLowerCase()); } } return stringToReturn.toString(); }
java
public String splitNameByUpperCase(String name) { String [] texts = name.split("(?=\\p{Upper})"); StringBuilder stringToReturn = new StringBuilder(); for(String string : texts){ if(stringToReturn.length() > 0) { stringToReturn.append(" " + string.toLowerCase()); } else { stringToReturn.append(string.toLowerCase()); } } return stringToReturn.toString(); }
[ "public", "String", "splitNameByUpperCase", "(", "String", "name", ")", "{", "String", "[", "]", "texts", "=", "name", ".", "split", "(", "\"(?=\\\\p{Upper})\"", ")", ";", "StringBuilder", "stringToReturn", "=", "new", "StringBuilder", "(", ")", ";", "for", ...
Splits a name by upper case. @param name the name to split @return a String with the split name
[ "Splits", "a", "name", "by", "upper", "case", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/WebUtils.java#L323-L337
30,083
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/WebUtils.java
WebUtils.getJavaScriptAsString
private String getJavaScriptAsString() { InputStream fis = getClass().getResourceAsStream("RobotiumWeb.js"); StringBuffer javaScript = new StringBuffer(); try { BufferedReader input = new BufferedReader(new InputStreamReader(fis)); String line = null; while (( line = input.readLine()) != null){ javaScript.append(line); javaScript.append("\n"); } input.close(); } catch (IOException e) { throw new RuntimeException(e); } return javaScript.toString(); }
java
private String getJavaScriptAsString() { InputStream fis = getClass().getResourceAsStream("RobotiumWeb.js"); StringBuffer javaScript = new StringBuffer(); try { BufferedReader input = new BufferedReader(new InputStreamReader(fis)); String line = null; while (( line = input.readLine()) != null){ javaScript.append(line); javaScript.append("\n"); } input.close(); } catch (IOException e) { throw new RuntimeException(e); } return javaScript.toString(); }
[ "private", "String", "getJavaScriptAsString", "(", ")", "{", "InputStream", "fis", "=", "getClass", "(", ")", ".", "getResourceAsStream", "(", "\"RobotiumWeb.js\"", ")", ";", "StringBuffer", "javaScript", "=", "new", "StringBuffer", "(", ")", ";", "try", "{", ...
Returns the JavaScript file RobotiumWeb.js as a String @return the JavaScript file RobotiumWeb.js as a {@code String}
[ "Returns", "the", "JavaScript", "file", "RobotiumWeb", ".", "js", "as", "a", "String" ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/WebUtils.java#L345-L361
30,084
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/Searcher.java
Searcher.searchFor
public <T extends View> boolean searchFor(Set<T> uniqueViews, Class<T> viewClass, final int index) { ArrayList<T> allViews = RobotiumUtils.removeInvisibleViews(viewFetcher.getCurrentViews(viewClass, true)); int uniqueViewsFound = (getNumberOfUniqueViews(uniqueViews, allViews)); if(uniqueViewsFound > 0 && index < uniqueViewsFound) { return true; } if(uniqueViewsFound > 0 && index == 0) { return true; } return false; }
java
public <T extends View> boolean searchFor(Set<T> uniqueViews, Class<T> viewClass, final int index) { ArrayList<T> allViews = RobotiumUtils.removeInvisibleViews(viewFetcher.getCurrentViews(viewClass, true)); int uniqueViewsFound = (getNumberOfUniqueViews(uniqueViews, allViews)); if(uniqueViewsFound > 0 && index < uniqueViewsFound) { return true; } if(uniqueViewsFound > 0 && index == 0) { return true; } return false; }
[ "public", "<", "T", "extends", "View", ">", "boolean", "searchFor", "(", "Set", "<", "T", ">", "uniqueViews", ",", "Class", "<", "T", ">", "viewClass", ",", "final", "int", "index", ")", "{", "ArrayList", "<", "T", ">", "allViews", "=", "RobotiumUtils"...
Searches for a view class. @param uniqueViews the set of unique views @param viewClass the view class to search for @param index the index of the view class @return true if view class if found a given number of times
[ "Searches", "for", "a", "view", "class", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Searcher.java#L141-L154
30,085
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/Searcher.java
Searcher.searchFor
public <T extends View> boolean searchFor(View view) { ArrayList<View> views = viewFetcher.getAllViews(true); for(View v : views){ if(v.equals(view)){ return true; } } return false; }
java
public <T extends View> boolean searchFor(View view) { ArrayList<View> views = viewFetcher.getAllViews(true); for(View v : views){ if(v.equals(view)){ return true; } } return false; }
[ "public", "<", "T", "extends", "View", ">", "boolean", "searchFor", "(", "View", "view", ")", "{", "ArrayList", "<", "View", ">", "views", "=", "viewFetcher", ".", "getAllViews", "(", "true", ")", ";", "for", "(", "View", "v", ":", "views", ")", "{",...
Searches for a given view. @param view the view to search @param scroll true if scrolling should be performed @return true if view is found
[ "Searches", "for", "a", "given", "view", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Searcher.java#L164-L172
30,086
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/Searcher.java
Searcher.searchForWebElement
public WebElement searchForWebElement(final By by, int minimumNumberOfMatches){ if(minimumNumberOfMatches < 1){ minimumNumberOfMatches = 1; } List<WebElement> viewsFromScreen = webUtils.getWebElements(by, true); addViewsToList (webElements, viewsFromScreen); return getViewFromList(webElements, minimumNumberOfMatches); }
java
public WebElement searchForWebElement(final By by, int minimumNumberOfMatches){ if(minimumNumberOfMatches < 1){ minimumNumberOfMatches = 1; } List<WebElement> viewsFromScreen = webUtils.getWebElements(by, true); addViewsToList (webElements, viewsFromScreen); return getViewFromList(webElements, minimumNumberOfMatches); }
[ "public", "WebElement", "searchForWebElement", "(", "final", "By", "by", ",", "int", "minimumNumberOfMatches", ")", "{", "if", "(", "minimumNumberOfMatches", "<", "1", ")", "{", "minimumNumberOfMatches", "=", "1", ";", "}", "List", "<", "WebElement", ">", "vie...
Searches for a web element. @param by the By object e.g. By.id("id"); @param minimumNumberOfMatches the minimum number of matches that are expected to be shown. {@code 0} means any number of matches @return the web element or null if not found
[ "Searches", "for", "a", "web", "element", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Searcher.java#L231-L241
30,087
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/Searcher.java
Searcher.addViewsToList
private void addViewsToList(List<WebElement> allWebElements, List<WebElement> webElementsOnScreen){ int[] xyViewFromSet = new int[2]; int[] xyViewFromScreen = new int[2]; for(WebElement textFromScreen : webElementsOnScreen){ boolean foundView = false; textFromScreen.getLocationOnScreen(xyViewFromScreen); for(WebElement textFromList : allWebElements){ textFromList.getLocationOnScreen(xyViewFromSet); if(textFromScreen.getText().equals(textFromList.getText()) && xyViewFromScreen[0] == xyViewFromSet[0] && xyViewFromScreen[1] == xyViewFromSet[1]) { foundView = true; } } if(!foundView){ allWebElements.add(textFromScreen); } } }
java
private void addViewsToList(List<WebElement> allWebElements, List<WebElement> webElementsOnScreen){ int[] xyViewFromSet = new int[2]; int[] xyViewFromScreen = new int[2]; for(WebElement textFromScreen : webElementsOnScreen){ boolean foundView = false; textFromScreen.getLocationOnScreen(xyViewFromScreen); for(WebElement textFromList : allWebElements){ textFromList.getLocationOnScreen(xyViewFromSet); if(textFromScreen.getText().equals(textFromList.getText()) && xyViewFromScreen[0] == xyViewFromSet[0] && xyViewFromScreen[1] == xyViewFromSet[1]) { foundView = true; } } if(!foundView){ allWebElements.add(textFromScreen); } } }
[ "private", "void", "addViewsToList", "(", "List", "<", "WebElement", ">", "allWebElements", ",", "List", "<", "WebElement", ">", "webElementsOnScreen", ")", "{", "int", "[", "]", "xyViewFromSet", "=", "new", "int", "[", "2", "]", ";", "int", "[", "]", "x...
Adds views to a given list. @param allWebElements the list of all views @param webTextViewsOnScreen the list of views shown on screen
[ "Adds", "views", "to", "a", "given", "list", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Searcher.java#L250-L272
30,088
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/Searcher.java
Searcher.getViewFromList
private WebElement getViewFromList(List<WebElement> webElements, int match){ WebElement webElementToReturn = null; if(webElements.size() >= match){ try{ webElementToReturn = webElements.get(--match); }catch(Exception ignored){} } if(webElementToReturn != null) webElements.clear(); return webElementToReturn; }
java
private WebElement getViewFromList(List<WebElement> webElements, int match){ WebElement webElementToReturn = null; if(webElements.size() >= match){ try{ webElementToReturn = webElements.get(--match); }catch(Exception ignored){} } if(webElementToReturn != null) webElements.clear(); return webElementToReturn; }
[ "private", "WebElement", "getViewFromList", "(", "List", "<", "WebElement", ">", "webElements", ",", "int", "match", ")", "{", "WebElement", "webElementToReturn", "=", "null", ";", "if", "(", "webElements", ".", "size", "(", ")", ">=", "match", ")", "{", "...
Returns a text view with a given match. @param webElements the list of views @param match the match of the view to return @return the view with a given match
[ "Returns", "a", "text", "view", "with", "a", "given", "match", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Searcher.java#L282-L296
30,089
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/Searcher.java
Searcher.getNumberOfUniqueViews
public <T extends View> int getNumberOfUniqueViews(Set<T>uniqueViews, ArrayList<T> views){ for(int i = 0; i < views.size(); i++){ uniqueViews.add(views.get(i)); } numberOfUniqueViews = uniqueViews.size(); return numberOfUniqueViews; }
java
public <T extends View> int getNumberOfUniqueViews(Set<T>uniqueViews, ArrayList<T> views){ for(int i = 0; i < views.size(); i++){ uniqueViews.add(views.get(i)); } numberOfUniqueViews = uniqueViews.size(); return numberOfUniqueViews; }
[ "public", "<", "T", "extends", "View", ">", "int", "getNumberOfUniqueViews", "(", "Set", "<", "T", ">", "uniqueViews", ",", "ArrayList", "<", "T", ">", "views", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "views", ".", "size", "(", ...
Returns the number of unique views. @param uniqueViews the set of unique views @param views the list of all views @return number of unique views
[ "Returns", "the", "number", "of", "unique", "views", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Searcher.java#L306-L312
30,090
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/SystemUtils.java
SystemUtils.setMobileData
public void setMobileData(Boolean turnedOn){ ConnectivityManager dataManager=(ConnectivityManager)instrumentation.getTargetContext().getSystemService(Context.CONNECTIVITY_SERVICE); Method dataClass = null; try { dataClass = ConnectivityManager.class.getDeclaredMethod("setMobileDataEnabled", boolean.class); dataClass.setAccessible(true); dataClass.invoke(dataManager, turnedOn); } catch (Exception e) { e.printStackTrace(); } }
java
public void setMobileData(Boolean turnedOn){ ConnectivityManager dataManager=(ConnectivityManager)instrumentation.getTargetContext().getSystemService(Context.CONNECTIVITY_SERVICE); Method dataClass = null; try { dataClass = ConnectivityManager.class.getDeclaredMethod("setMobileDataEnabled", boolean.class); dataClass.setAccessible(true); dataClass.invoke(dataManager, turnedOn); } catch (Exception e) { e.printStackTrace(); } }
[ "public", "void", "setMobileData", "(", "Boolean", "turnedOn", ")", "{", "ConnectivityManager", "dataManager", "=", "(", "ConnectivityManager", ")", "instrumentation", ".", "getTargetContext", "(", ")", ".", "getSystemService", "(", "Context", ".", "CONNECTIVITY_SERVI...
Sets if mobile data should be turned on or off. Requires android.permission.CHANGE_NETWORK_STATE in the AndroidManifest.xml of the application under test. @param turnedOn true if mobile data is to be turned on and false if not
[ "Sets", "if", "mobile", "data", "should", "be", "turned", "on", "or", "off", ".", "Requires", "android", ".", "permission", ".", "CHANGE_NETWORK_STATE", "in", "the", "AndroidManifest", ".", "xml", "of", "the", "application", "under", "test", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/SystemUtils.java#L33-L44
30,091
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/SystemUtils.java
SystemUtils.setWiFiData
public void setWiFiData(Boolean turnedOn){ WifiManager wifiManager = (WifiManager)instrumentation.getTargetContext().getSystemService(Context.WIFI_SERVICE); try{ wifiManager.setWifiEnabled(turnedOn); }catch(Exception e){ e.printStackTrace(); } }
java
public void setWiFiData(Boolean turnedOn){ WifiManager wifiManager = (WifiManager)instrumentation.getTargetContext().getSystemService(Context.WIFI_SERVICE); try{ wifiManager.setWifiEnabled(turnedOn); }catch(Exception e){ e.printStackTrace(); } }
[ "public", "void", "setWiFiData", "(", "Boolean", "turnedOn", ")", "{", "WifiManager", "wifiManager", "=", "(", "WifiManager", ")", "instrumentation", ".", "getTargetContext", "(", ")", ".", "getSystemService", "(", "Context", ".", "WIFI_SERVICE", ")", ";", "try"...
Sets if wifi data should be turned on or off. Requires android.permission.CHANGE_WIFI_STATE in the AndroidManifest.xml of the application under test. @param turnedOn true if mobile wifi is to be turned on and false if not
[ "Sets", "if", "wifi", "data", "should", "be", "turned", "on", "or", "off", ".", "Requires", "android", ".", "permission", ".", "CHANGE_WIFI_STATE", "in", "the", "AndroidManifest", ".", "xml", "of", "the", "application", "under", "test", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/SystemUtils.java#L53-L60
30,092
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/Solo.java
Solo.getActivityMonitor
public ActivityMonitor getActivityMonitor(){ if(config.commandLogging){ Log.d(config.commandLoggingTag, "getActivityMonitor()"); } return activityUtils.getActivityMonitor(); }
java
public ActivityMonitor getActivityMonitor(){ if(config.commandLogging){ Log.d(config.commandLoggingTag, "getActivityMonitor()"); } return activityUtils.getActivityMonitor(); }
[ "public", "ActivityMonitor", "getActivityMonitor", "(", ")", "{", "if", "(", "config", ".", "commandLogging", ")", "{", "Log", ".", "d", "(", "config", ".", "commandLoggingTag", ",", "\"getActivityMonitor()\"", ")", ";", "}", "return", "activityUtils", ".", "g...
Returns the ActivityMonitor used by Robotium. @return the ActivityMonitor used by Robotium
[ "Returns", "the", "ActivityMonitor", "used", "by", "Robotium", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Solo.java#L297-L303
30,093
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/Solo.java
Solo.getViews
public ArrayList<View> getViews() { try { if(config.commandLogging){ Log.d(config.commandLoggingTag, "getViews()"); } return viewFetcher.getViews(null, false); } catch (Exception e) { e.printStackTrace(); return null; } }
java
public ArrayList<View> getViews() { try { if(config.commandLogging){ Log.d(config.commandLoggingTag, "getViews()"); } return viewFetcher.getViews(null, false); } catch (Exception e) { e.printStackTrace(); return null; } }
[ "public", "ArrayList", "<", "View", ">", "getViews", "(", ")", "{", "try", "{", "if", "(", "config", ".", "commandLogging", ")", "{", "Log", ".", "d", "(", "config", ".", "commandLoggingTag", ",", "\"getViews()\"", ")", ";", "}", "return", "viewFetcher",...
Returns an ArrayList of all the View objects located in the focused Activity or Dialog. @return an {@code ArrayList} of the {@link View} objects located in the focused window
[ "Returns", "an", "ArrayList", "of", "all", "the", "View", "objects", "located", "in", "the", "focused", "Activity", "or", "Dialog", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Solo.java#L326-L337
30,094
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/Solo.java
Solo.getTopParent
public View getTopParent(View view) { if(config.commandLogging){ Log.d(config.commandLoggingTag, "getTopParent("+view+")"); } View topParent = viewFetcher.getTopParent(view); return topParent; }
java
public View getTopParent(View view) { if(config.commandLogging){ Log.d(config.commandLoggingTag, "getTopParent("+view+")"); } View topParent = viewFetcher.getTopParent(view); return topParent; }
[ "public", "View", "getTopParent", "(", "View", "view", ")", "{", "if", "(", "config", ".", "commandLogging", ")", "{", "Log", ".", "d", "(", "config", ".", "commandLoggingTag", ",", "\"getTopParent(\"", "+", "view", "+", "\")\"", ")", ";", "}", "View", ...
Returns the absolute top parent View of the specified View. @param view the {@link View} whose top parent is requested @return the top parent {@link View}
[ "Returns", "the", "absolute", "top", "parent", "View", "of", "the", "specified", "View", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Solo.java#L366-L373
30,095
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/Solo.java
Solo.waitForText
public boolean waitForText(String text, int minimumNumberOfMatches, long timeout, boolean scroll, boolean onlyVisible) { if(config.commandLogging){ Log.d(config.commandLoggingTag, "waitForText(\""+text+"\", "+minimumNumberOfMatches+", "+timeout+", "+scroll+", "+onlyVisible+")"); } return (waiter.waitForText(text, minimumNumberOfMatches, timeout, scroll, onlyVisible, true) != null); }
java
public boolean waitForText(String text, int minimumNumberOfMatches, long timeout, boolean scroll, boolean onlyVisible) { if(config.commandLogging){ Log.d(config.commandLoggingTag, "waitForText(\""+text+"\", "+minimumNumberOfMatches+", "+timeout+", "+scroll+", "+onlyVisible+")"); } return (waiter.waitForText(text, minimumNumberOfMatches, timeout, scroll, onlyVisible, true) != null); }
[ "public", "boolean", "waitForText", "(", "String", "text", ",", "int", "minimumNumberOfMatches", ",", "long", "timeout", ",", "boolean", "scroll", ",", "boolean", "onlyVisible", ")", "{", "if", "(", "config", ".", "commandLogging", ")", "{", "Log", ".", "d",...
Waits for the specified text to appear. @param text the text to wait for, specified as a regular expression @param minimumNumberOfMatches the minimum number of matches that are expected to be found. {@code 0} means any number of matches @param timeout the the amount of time in milliseconds to wait @param scroll {@code true} if scrolling should be performed @param onlyVisible {@code true} if only visible text views should be waited for @return {@code true} if text is displayed and {@code false} if it is not displayed before the timeout
[ "Waits", "for", "the", "specified", "text", "to", "appear", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Solo.java#L436-L442
30,096
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/Solo.java
Solo.waitForView
public boolean waitForView(int id){ if(config.commandLogging){ Log.d(config.commandLoggingTag, "waitForView("+id+")"); } return waitForView(id, 0, Timeout.getLargeTimeout(), true); }
java
public boolean waitForView(int id){ if(config.commandLogging){ Log.d(config.commandLoggingTag, "waitForView("+id+")"); } return waitForView(id, 0, Timeout.getLargeTimeout(), true); }
[ "public", "boolean", "waitForView", "(", "int", "id", ")", "{", "if", "(", "config", ".", "commandLogging", ")", "{", "Log", ".", "d", "(", "config", ".", "commandLoggingTag", ",", "\"waitForView(\"", "+", "id", "+", "\")\"", ")", ";", "}", "return", "...
Waits for a View matching the specified resource id. Default timeout is 20 seconds. @param id the R.id of the {@link View} to wait for @return {@code true} if the {@link View} is displayed and {@code false} if it is not displayed before the timeout
[ "Waits", "for", "a", "View", "matching", "the", "specified", "resource", "id", ".", "Default", "timeout", "is", "20", "seconds", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Solo.java#L451-L457
30,097
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/Solo.java
Solo.waitForView
public boolean waitForView(Object tag){ if(config.commandLogging){ Log.d(config.commandLoggingTag, "waitForView("+tag+")"); } return waitForView(tag, 0, Timeout.getLargeTimeout(), true); }
java
public boolean waitForView(Object tag){ if(config.commandLogging){ Log.d(config.commandLoggingTag, "waitForView("+tag+")"); } return waitForView(tag, 0, Timeout.getLargeTimeout(), true); }
[ "public", "boolean", "waitForView", "(", "Object", "tag", ")", "{", "if", "(", "config", ".", "commandLogging", ")", "{", "Log", ".", "d", "(", "config", ".", "commandLoggingTag", ",", "\"waitForView(\"", "+", "tag", "+", "\")\"", ")", ";", "}", "return"...
Waits for a View matching the specified tag. Default timeout is 20 seconds. @param tag the {@link View#getTag() tag} of the {@link View} to wait for @return {@code true} if the {@link View} is displayed and {@code false} if it is not displayed before the timeout
[ "Waits", "for", "a", "View", "matching", "the", "specified", "tag", ".", "Default", "timeout", "is", "20", "seconds", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Solo.java#L506-L512
30,098
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/Solo.java
Solo.waitForView
public boolean waitForView(Object tag, int minimumNumberOfMatches, int timeout){ if(config.commandLogging){ Log.d(config.commandLoggingTag, "waitForView("+tag+", "+minimumNumberOfMatches+", "+timeout+")"); } return waitForView(tag, minimumNumberOfMatches, timeout, true); }
java
public boolean waitForView(Object tag, int minimumNumberOfMatches, int timeout){ if(config.commandLogging){ Log.d(config.commandLoggingTag, "waitForView("+tag+", "+minimumNumberOfMatches+", "+timeout+")"); } return waitForView(tag, minimumNumberOfMatches, timeout, true); }
[ "public", "boolean", "waitForView", "(", "Object", "tag", ",", "int", "minimumNumberOfMatches", ",", "int", "timeout", ")", "{", "if", "(", "config", ".", "commandLogging", ")", "{", "Log", ".", "d", "(", "config", ".", "commandLoggingTag", ",", "\"waitForVi...
Waits for a View matching the specified tag. @param tag the {@link View#getTag() tag} of the {@link View} to wait for @param minimumNumberOfMatches the minimum number of matches that are expected to be found. {@code 0} means any number of matches @param timeout the amount of time in milliseconds to wait @return {@code true} if the {@link View} is displayed and {@code false} if it is not displayed before the timeout
[ "Waits", "for", "a", "View", "matching", "the", "specified", "tag", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Solo.java#L523-L529
30,099
RobotiumTech/robotium
robotium-solo/src/main/java/com/robotium/solo/Solo.java
Solo.waitForView
public <T extends View> boolean waitForView(final Class<T> viewClass){ if(config.commandLogging){ Log.d(config.commandLoggingTag, "waitForView("+viewClass+")"); } return waiter.waitForView(viewClass, 0, Timeout.getLargeTimeout(), true); }
java
public <T extends View> boolean waitForView(final Class<T> viewClass){ if(config.commandLogging){ Log.d(config.commandLoggingTag, "waitForView("+viewClass+")"); } return waiter.waitForView(viewClass, 0, Timeout.getLargeTimeout(), true); }
[ "public", "<", "T", "extends", "View", ">", "boolean", "waitForView", "(", "final", "Class", "<", "T", ">", "viewClass", ")", "{", "if", "(", "config", ".", "commandLogging", ")", "{", "Log", ".", "d", "(", "config", ".", "commandLoggingTag", ",", "\"w...
Waits for a View matching the specified class. Default timeout is 20 seconds. @param viewClass the {@link View} class to wait for @return {@code true} if the {@link View} is displayed and {@code false} if it is not displayed before the timeout
[ "Waits", "for", "a", "View", "matching", "the", "specified", "class", ".", "Default", "timeout", "is", "20", "seconds", "." ]
75e567c38f26a6a87dc8bef90b3886a20e28d291
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Solo.java#L562-L568