@Test public void touchEvents() { TouchUtils.scrollToBottom(this, getActivity(), list); getInstrumentation().waitForIdleSync(); Assert.assertEquals(24, list.getLastVisiblePosition()); } }
public static void swipeVertically(InstrumentationTestCase test, View v, Direction direction) { int[] xy = new int[2]; v.getLocationOnScreen(xy); final int viewWidth = v.getWidth(); final int viewHeight = v.getHeight(); float distanceFromEdge = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, v.getResources().getDisplayMetrics()); float x = xy[0] + (viewWidth / 2.0f); float yStart = xy[1] + ((direction == Direction.UP) ? (viewHeight - distanceFromEdge) : distanceFromEdge); float yEnd = xy[1] + ((direction == Direction.UP) ? distanceFromEdge : (viewHeight - distanceFromEdge)); TouchUtils.drag(test, x, x, yStart, yEnd, DRAG_STEP_COUNT); }
public void testNewDocument_CreatesOverviewEntry() { // Given a initialized Activity assertNotNull("mDocumentCentricActivity is null", mDocumentCentricActivity); final Button createNewDocumentButton = (Button) mDocumentCentricActivity .findViewById(R.id.new_document_button); assertNotNull(createNewDocumentButton); // When "Create new Document" Button is clicked TouchUtils.clickView(this, createNewDocumentButton); // Then a entry in overview app tasks is created. List<ActivityManager.AppTask> recentAppTasks = getRecentAppTasks(); assertEquals("# of recentAppTasks does not match", 2, recentAppTasks.size()); }
/** * Test that swiping on the populated list triggers a refresh. */ public void testSwipingListView() { // Given a SwipeRefreshLayout which is displaying a populated list // When the swipe refresh layout is dragged TouchUtils.dragViewBy(this, mSwipeRefreshLayout, Gravity.CENTER, 0, Math.round(mSwipeRefreshLayout.getHeight() * 0.4f)); // Then the SwipeRefreshLayout should be refreshing // We need to use runOnMainSync here as fake dragging uses waitForIdleSync() getInstrumentation().runOnMainSync(new Runnable() { @Override public void run() { assertTrue(mSwipeRefreshLayout.isRefreshing()); } }); }
public void testScroll() throws Throwable { TouchUtils.touchAndCancelView(this, scrollable); getInstrumentation().waitForIdleSync(); UiTestUtils.swipeVertically(this, scrollable, UiTestUtils.Direction.UP); getInstrumentation().waitForIdleSync(); UiTestUtils.swipeVertically(this, scrollable, UiTestUtils.Direction.DOWN); getInstrumentation().waitForIdleSync(); UiTestUtils.swipeVertically(this, scrollable, UiTestUtils.Direction.DOWN); getInstrumentation().waitForIdleSync(); }
/** * Test that the floating shape can be dragged and that it's raised while dragging. */ public void testDrag() { final float initialX = mFloatingShape.getX(); // Drag the shape to the left edge. TouchUtils.dragViewToX(this, mFloatingShape, Gravity.CENTER, 0); // Check that the view is dragging and that it's been raised. // We need to use runOnMainSync here as fake dragging uses waitForIdleSync(). getInstrumentation().runOnMainSync(new Runnable() { @Override public void run() { // Check that the view has moved. float deltaX = mFloatingShape.getX() - initialX; assertTrue(Math.abs(deltaX) > 0f); // Check that the view is raised. assertTrue(mFloatingShape.getZ() > 0f); } }); } }
/** * Triggers a click on the button and tests if the view is clipped afterwards. */ public void testClipping() { View clippedView = mTestActivity.findViewById(R.id.frame); // Initially, the view is not clipped. assertFalse(clippedView.getClipToOutline()); // Trigger a click on the button to activate clipping. TouchUtils.clickView(this, mTestActivity.findViewById(R.id.button)); // Check that the view has been clipped. assertTrue(clippedView.getClipToOutline()); } }
/** * Test that swiping on the populated list triggers a refresh. */ public void testSwipingListView() { // Given a SwipeRefreshLayout which is displaying a populated list // When the swipe refresh layout is dragged TouchUtils.dragViewBy(this, mSwipeRefreshLayout, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, Math.round(mSwipeRefreshLayout.getHeight() * 0.4f)); // Then the SwipeRefreshLayout should be refreshing // We need to use runOnMainSync here as fake dragging uses waitForIdleSync() getInstrumentation().runOnMainSync(new Runnable() { @Override public void run() { assertTrue(mSwipeRefreshLayout.isRefreshing()); } }); }
public void testScroll() throws Throwable { TouchUtils.touchAndCancelView(this, scrollable); getInstrumentation().waitForIdleSync(); UiTestUtils.swipeVertically(this, scrollable, UiTestUtils.Direction.UP); getInstrumentation().waitForIdleSync(); UiTestUtils.swipeVertically(this, scrollable, UiTestUtils.Direction.DOWN); getInstrumentation().waitForIdleSync(); UiTestUtils.swipeVertically(this, scrollable, UiTestUtils.Direction.DOWN); getInstrumentation().waitForIdleSync(); }
@Test public void touchEvents() { TouchUtils.scrollToBottom(this, getActivity(), list); getInstrumentation().waitForIdleSync(); Assert.assertEquals(24, list.getLastVisiblePosition()); } }
public void testScroll() throws Throwable { TouchUtils.touchAndCancelView(this, scrollable); getInstrumentation().waitForIdleSync(); UiTestUtils.swipeVertically(this, scrollable, UiTestUtils.Direction.UP); getInstrumentation().waitForIdleSync(); UiTestUtils.swipeVertically(this, scrollable, UiTestUtils.Direction.DOWN); getInstrumentation().waitForIdleSync(); UiTestUtils.swipeVertically(this, scrollable, UiTestUtils.Direction.DOWN); getInstrumentation().waitForIdleSync(); }
public static void swipeHorizontally(InstrumentationTestCase test, View v, Direction direction) { int[] xy = new int[2]; v.getLocationOnScreen(xy); final int viewWidth = v.getWidth(); final int viewHeight = v.getHeight(); float distanceFromEdge = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, v.getResources().getDisplayMetrics()); float xStart = xy[0] + ((direction == Direction.LEFT) ? (viewWidth - distanceFromEdge) : distanceFromEdge); float xEnd = xy[0] + ((direction == Direction.LEFT) ? distanceFromEdge : (viewWidth - distanceFromEdge)); float y = xy[1] + (viewHeight / 2.0f); TouchUtils.drag(test, xStart, xEnd, y, y, DRAG_STEP_COUNT); }
@Test public void touchEvents() { TouchUtils.scrollToBottom(this, getActivity(), list); getInstrumentation().waitForIdleSync(); Assert.assertEquals(24, list.getLastVisiblePosition()); } }
public void testScroll() throws Throwable { TouchUtils.touchAndCancelView(this, scrollable); getInstrumentation().waitForIdleSync(); UiTestUtils.swipeVertically(this, scrollable, UiTestUtils.Direction.UP); getInstrumentation().waitForIdleSync(); UiTestUtils.swipeVertically(this, scrollable, UiTestUtils.Direction.DOWN); getInstrumentation().waitForIdleSync(); UiTestUtils.swipeVertically(this, scrollable, UiTestUtils.Direction.DOWN); getInstrumentation().waitForIdleSync(); }
@Test public void touchEvents() { TouchUtils.scrollToBottom(this, getActivity(), list); getInstrumentation().waitForIdleSync(); Assert.assertEquals(24, list.getLastVisiblePosition()); } }
public void testScroll() throws Throwable { TouchUtils.touchAndCancelView(this, scrollable); getInstrumentation().waitForIdleSync(); UiTestUtils.swipeVertically(this, scrollable, UiTestUtils.Direction.UP); getInstrumentation().waitForIdleSync(); UiTestUtils.swipeVertically(this, scrollable, UiTestUtils.Direction.DOWN); getInstrumentation().waitForIdleSync(); UiTestUtils.swipeVertically(this, scrollable, UiTestUtils.Direction.DOWN); getInstrumentation().waitForIdleSync(); }
@Test public void touchEvents() { TouchUtils.scrollToBottom(this, getActivity(), list); getInstrumentation().waitForIdleSync(); Assert.assertEquals(24, list.getLastVisiblePosition()); } }