// Testing Case #6
  public void testFolderOnMenuBar() {
    enterVideoPageWaitForIdle();

    // trigger menu bar
    CommonTestUtil.sendSingleTapConfirmedEventOnUiThread(
        mActivity, mMedia3DView, CommonTestUtil.NON_ACTOR_POINT);
    CommonTestUtil.waitMenuBarForActionSync(
        mInstrumentation, mMedia3DView, CommonTestUtil.DEFAULT_MENU_BAR_TIMEOUT_IN_MS);

    // click folder icon on menu bar
    CommonTestUtil.sendTouchEventsOnUiThread(
        mActivity, mMedia3DView, CommonTestUtil.FOLDER_ICON_IN_TOP_MENU);
    CommonTestUtil.waitPageForIdleSync(
        mInstrumentation,
        mMedia3DView,
        mActivity.getVideoPage(),
        CommonTestUtil.DEFAULT_PAGE_SWITCH_TIMEOUT_IN_MS);

    final int REQUEST_PICK_FOLDER = 0; // refer to VideoPage
    int requestCode =
        mActivity.getVideoPage().hashCode() + REQUEST_PICK_FOLDER; // refer to VideoPage
    CommonTestUtil.finishLaunchedActivity(mActivity, requestCode);
    CommonTestUtil.wait(mInstrumentation, CommonTestUtil.WAIT_FOR_PAGE_SWITCH_TIME_IN_SECS);

    assertTrue(mMedia3DView.getCurrentPage() == mActivity.getVideoPage());
  }
  // 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());
  }
  // Testing Case #4
  public void testPauseResume() {
    enterVideoPageWaitForIdle();

    mInstrumentation.callActivityOnPause(mActivity);
    CommonTestUtil.wait(mInstrumentation, CommonTestUtil.WAIT_FOR_PAGE_SWITCH_TIME_IN_SECS);

    mInstrumentation.callActivityOnResume(mActivity);
    CommonTestUtil.waitPageForIdleSync(
        mInstrumentation,
        mMedia3DView,
        mActivity.getVideoPage(),
        CommonTestUtil.DEFAULT_PAGE_SWITCH_TIMEOUT_IN_MS);
    assertTrue(mMedia3DView.getCurrentPage() == mActivity.getVideoPage());
  }
  // 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);
    }
  }
  public void enterVideoPageWaitForIdle() {
    validateNoNullMember();
    CommonTestUtil.waitPageForIdleSync(
        mInstrumentation,
        mMedia3DView,
        mActivity.getPortalPage(),
        CommonTestUtil.DEFAULT_PAGE_SWITCH_TIMEOUT_IN_MS);
    CommonTestUtil.waitLoadForIdleSync(
        mInstrumentation,
        mActivity.getVideoPage(),
        CommonTestUtil.DEFAULT_PAGE_SWITCH_TIMEOUT_IN_MS);

    CommonTestUtil.sendSingleTapConfirmedEventOnUiThread(
        mActivity, mMedia3DView, CommonTestUtil.VIDEO_ICON_IN_PORTALPAGE);
    CommonTestUtil.waitPageForIdleSync(
        mInstrumentation,
        mMedia3DView,
        mActivity.getVideoPage(),
        CommonTestUtil.DEFAULT_PAGE_SWITCH_TIMEOUT_IN_MS);

    assertTrue(mMedia3DView.getCurrentPage() == mActivity.getVideoPage());
  }