// Testing Case #5 public void testVideoPageCyclicScrolling() { enterVideoPageWaitForIdle(); long startTime = SystemClock.elapsedRealtime(); VideoPage p = mActivity.getVideoPage(); final int pageCount = p.getTotalVideoPage(); final int beginIndex = p.getIndex(); for (int i = 0; i < pageCount; ++i) { CommonTestUtil.sendDragSync(mInstrumentation, mActivity, CommonTestUtil.DragDirection.UP); } CommonTestUtil.wait(mInstrumentation, CommonTestUtil.WAIT_FOR_INNER_PAGE_SWITCH_TIME_IN_SECS); assertTrue(mMedia3DView.getCurrentPage() == p); final int afterUpScrollingIndex = p.getIndex(); assertEquals(beginIndex, afterUpScrollingIndex); for (int i = 0; i < pageCount; ++i) { CommonTestUtil.sendDragSync(mInstrumentation, mActivity, CommonTestUtil.DragDirection.DOWN); } CommonTestUtil.wait(mInstrumentation, CommonTestUtil.WAIT_FOR_INNER_PAGE_SWITCH_TIME_IN_SECS); assertTrue(mMedia3DView.getCurrentPage() == p); final int afterDownScrollingIndex = p.getIndex(); assertEquals(beginIndex, afterDownScrollingIndex); }
// Testing Case #3 public void testBasicDrag() { enterVideoPageWaitForIdle(); VideoPage v = mActivity.getVideoPage(); if (0 == v.getTotalVideoPage()) { return; // no video, skip this test } // sub-case #1 int currentPageIndex = v.getVideoPage(); CommonTestUtil.sendDragSync(mInstrumentation, mActivity, CommonTestUtil.DragDirection.UP); CommonTestUtil.wait(mInstrumentation, CommonTestUtil.WAIT_FOR_INNER_PAGE_SWITCH_TIME_IN_SECS); int pageAfterFlingUpIndex = v.getVideoPage(); if (v.getTotalVideoPage() > 1) { assertTrue(currentPageIndex != pageAfterFlingUpIndex); } else { assertTrue(currentPageIndex == pageAfterFlingUpIndex); // at the last page } // sub-case #2 currentPageIndex = v.getVideoPage(); CommonTestUtil.sendDragSync(mInstrumentation, mActivity, CommonTestUtil.DragDirection.DOWN); CommonTestUtil.wait(mInstrumentation, CommonTestUtil.WAIT_FOR_INNER_PAGE_SWITCH_TIME_IN_SECS); int pageAfterFlingDownIndex = v.getVideoPage(); if (currentPageIndex == 0) { assertTrue(currentPageIndex == pageAfterFlingDownIndex); } else { assertTrue(currentPageIndex != pageAfterFlingDownIndex); } }
// Testing Case #2 public void testLeaveVideoPageBySlide() { enterVideoPageWaitForIdle(); CommonTestUtil.sendDragSync(mInstrumentation, mActivity, CommonTestUtil.DragDirection.RIGHT); assertTrue(mMedia3DView.getCurrentPage() != mActivity.getVideoPage()); CommonTestUtil.sendDragSync(mInstrumentation, mActivity, CommonTestUtil.DragDirection.LEFT); assertTrue(mMedia3DView.getCurrentPage() == mActivity.getVideoPage()); }