leanback/src/androidTest/java/androidx/leanback/widget/GridWidgetTest.java
@Test
    public void testAccessibilityOfItemsBeingPushedOut() throws Throwable {
        Intent intent = new Intent();
        intent.putExtra(GridActivity.EXTRA_LAYOUT_RESOURCE_ID, R.layout.horizontal_grid);
        intent.putExtra(GridActivity.EXTRA_NUM_ITEMS, 100);
        intent.putExtra(GridActivity.EXTRA_STAGGERED, false);
        mOrientation = BaseGridView.HORIZONTAL;
        mNumRows = 3;

        initActivity(intent);

        final int lastPos = mGridView.getChildAdapterPosition(
                mGridView.getChildAt(mGridView.getChildCount() - 1));
        mActivityTestRule.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                mGridView.getLayoutManager().setItemPrefetchEnabled(false);
            }
        });
        final int numItemsToPushOut = mNumRows;
        mActivityTestRule.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                // set longer enough so that accessibility service will initialize node
                // within setImportantForAccessibility().
                mGridView.getItemAnimator().setRemoveDuration(2000);
                mGridView.getItemAnimator().setAddDuration(2000);
                final int[] newItems = new int[numItemsToPushOut];
                final int newItemValue = mActivity.mItemLengths[0];
                for (int i = 0; i < newItems.length; i++) {
                    newItems[i] = newItemValue;
                }
                mActivity.addItems(lastPos - numItemsToPushOut + 1, newItems);
            }
        });
        waitForItemAnimation();
    }
/**
     * This test would need talkback on.
     */
This test would need talkback on.
This test would need talkback on .
@Test
    public void testAccessibilityOfItemsBeingPushedOut() throws Throwable {
        Intent intent = new Intent();
        intent.putExtra(GridActivity.EXTRA_LAYOUT_RESOURCE_ID, R.layout.horizontal_grid);
        intent.putExtra(GridActivity.EXTRA_NUM_ITEMS, 100);
        intent.putExtra(GridActivity.EXTRA_STAGGERED, false);
        mOrientation = BaseGridView.HORIZONTAL;
        mNumRows = 3;
        initActivity(intent);
        final int lastPos = mGridView.getChildAdapterPosition(
                mGridView.getChildAt(mGridView.getChildCount() - 1));
        mActivityTestRule.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                mGridView.getLayoutManager().setItemPrefetchEnabled(false);
            }
        });
        final int numItemsToPushOut = mNumRows;
        mActivityTestRule.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                mGridView.getItemAnimator().setRemoveDuration(2000);
                mGridView.getItemAnimator().setAddDuration(2000);
                final int[] newItems = new int[numItemsToPushOut];
                final int newItemValue = mActivity.mItemLengths[0];
                for (int i = 0; i < newItems.length; i++) {
                    newItems[i] = newItemValue;
                }
                mActivity.addItems(lastPos - numItemsToPushOut + 1, newItems);
            }
        });
        waitForItemAnimation();
    }
@ Test public void testAccessibilityOfItemsBeingPushedOut ( ) throws Throwable { Intent intent = new Intent ( ) ; intent . putExtra ( GridActivity . EXTRA_LAYOUT_RESOURCE_ID , R . layout . horizontal_grid ) ; intent . putExtra ( GridActivity . EXTRA_NUM_ITEMS , 100 ) ; intent . putExtra ( GridActivity . EXTRA_STAGGERED , false ) ; mOrientation = BaseGridView . HORIZONTAL ; mNumRows = 3 ; initActivity ( intent ) ; final int lastPos = mGridView . getChildAdapterPosition ( mGridView . getChildAt ( mGridView . getChildCount ( ) - 1 ) ) ; mActivityTestRule . runOnUiThread ( new Runnable ( ) { @ Override public void run ( ) { mGridView . getLayoutManager ( ) . setItemPrefetchEnabled ( false ) ; } } ) ; final int numItemsToPushOut = mNumRows ; mActivityTestRule . runOnUiThread ( new Runnable ( ) { @ Override public void run ( ) { mGridView . getItemAnimator ( ) . setRemoveDuration ( 2000 ) ; mGridView . getItemAnimator ( ) . setAddDuration ( 2000 ) ; final int [ ] newItems = new int [ numItemsToPushOut ] ; final int newItemValue = mActivity . mItemLengths [ 0 ] ; for ( int i = 0 ; i < newItems . length ; i ++ ) { newItems [ i ] = newItemValue ; } mActivity . addItems ( lastPos - numItemsToPushOut + 1 , newItems ) ; } } ) ; waitForItemAnimation ( ) ; }
This test would need talkback on.
This test would need talkback on .
// set longer enough so that accessibility service will initialize node // within setImportantForAccessibility().