@Override public void callOnDetachedFromWindow() { super.callOnDetachedFromWindow(); }
/** * Calls {@code performClick()} on a {@code View} after ensuring that it and its ancestors are visible and that it * is enabled. * * @param view the view to click on * @return true if {@code View.OnClickListener}s were found and fired, false otherwise. * @throws RuntimeException if the preconditions are not met. */ public static boolean clickOn(View view) { ShadowView shadowView = Shadow.extract(view); return shadowView.checkedPerformClick(); }
/** * Returns the text contained within this view. * * @param view the view to scan for text * @return Text contained within this view. */ @SuppressWarnings("UnusedDeclaration") public static String innerText(View view) { ShadowView shadowView = Shadow.extract(view); return shadowView.innerText(); }
@Implementation protected void scrollBy(int x, int y) { scrollTo(getScrollX() + x, getScrollY() + y); }
protected void dumpFirstPart(PrintStream out, int indent) { dumpIndent(out, indent); out.print("<" + realView.getClass().getSimpleName()); dumpAttributes(out); }
@Test public void checkedClick_shouldClickOnView() throws Exception { OnClickListener clickListener = mock(OnClickListener.class); shadowOf(view).setMyParent(ReflectionHelpers.createNullProxy(ViewParent.class)); view.setOnClickListener(clickListener); shadowOf(view).checkedPerformClick(); verify(clickListener).onClick(view); }
@Implementation protected void setOnClickListener(View.OnClickListener onClickListener) { this.onClickListener = onClickListener; directly().setOnClickListener(onClickListener); }
/** * Dumps the status of this {@code View} to {@code System.out} */ public void dump() { dump(System.out, 0); }
@Implementation protected void setScrollY(int scrollY) { scrollTo(scrollToCoordinates.x, scrollY); }
@Override protected void dumpAttributes(PrintStream out) { super.dumpAttributes(out); CharSequence text = realTextView.getText(); if (text != null && text.length() > 0) { dumpAttribute(out, "text", text.toString()); } }
/** * Dumps the status of this {@code View} to {@code System.out} at the given indentation level * @param out Output stream. * @param indent Indentation level. */ public void dump(PrintStream out, int indent) { dumpFirstPart(out, indent); out.println("/>"); }
protected void dumpAttributes(PrintStream out) { if (realView.getId() > 0) { dumpAttribute(out, "id", realView.getContext().getResources().getResourceName(realView.getId())); } switch (realView.getVisibility()) { case View.VISIBLE: break; case View.INVISIBLE: dumpAttribute(out, "visibility", "INVISIBLE"); break; case View.GONE: dumpAttribute(out, "visibility", "GONE"); break; } }
protected void dumpFirstPart(PrintStream out, int indent) { dumpIndent(out, indent); out.print("<" + realView.getClass().getSimpleName()); dumpAttributes(out); }
@Implementation protected void setOnLongClickListener(View.OnLongClickListener onLongClickListener) { this.onLongClickListener = onLongClickListener; directly().setOnLongClickListener(onLongClickListener); }
/** * Emits an xml-like representation of the view to System.out. * * @param view the view to dump */ @SuppressWarnings("UnusedDeclaration") public static void dump(View view) { ShadowView shadowView = Shadow.extract(view); shadowView.dump(); }
@Implementation protected void setScrollX(int scrollX) { scrollTo(scrollX, scrollToCoordinates.y); }
@Implementation protected void scrollBy(int x, int y) { scrollTo(getScrollX() + x, getScrollY() + y); }
@Override protected void dumpAttributes(PrintStream out) { super.dumpAttributes(out); CharSequence text = realTextView.getText(); if (text != null && text.length() > 0) { dumpAttribute(out, "text", text.toString()); } }
/** * Dumps the status of this {@code View} to {@code System.out} at the given indentation level * @param out Output stream. * @param indent Indentation level. */ public void dump(PrintStream out, int indent) { dumpFirstPart(out, indent); out.println("/>"); }
protected void dumpAttributes(PrintStream out) { if (realView.getId() > 0) { dumpAttribute(out, "id", realView.getContext().getResources().getResourceName(realView.getId())); } switch (realView.getVisibility()) { case View.VISIBLE: break; case View.INVISIBLE: dumpAttribute(out, "visibility", "INVISIBLE"); break; case View.GONE: dumpAttribute(out, "visibility", "GONE"); break; } }