Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0ac567bf authored by Alan Viverette's avatar Alan Viverette
Browse files

Remove flaky ListManagedCursorTest tests, clean up lint warnings

Also removes trailing ws.

Bug: 23811652
Change-Id: I2ae5c954606e95bcb4cfe52297717d4caf444cd0
parent cbfbf0f2
Loading
Loading
Loading
Loading
+18 −88
Original line number Diff line number Diff line
@@ -17,11 +17,9 @@
package android.widget.listview;

import android.app.Instrumentation;
import android.test.ActivityInstrumentationTestCase;
import android.test.FlakyTest;
import android.test.ActivityInstrumentationTestCase2;
import android.test.suitebuilder.annotation.LargeTest;
import android.test.suitebuilder.annotation.MediumTest;
import android.test.suitebuilder.annotation.Suppress;
import android.view.KeyEvent;
import android.widget.ListView;
import android.test.TouchUtils;
@@ -29,12 +27,12 @@ import android.test.TouchUtils;
/**
 * Tests restoring the scroll position in a list with a managed cursor.
 */
public class ListManagedCursorTest extends ActivityInstrumentationTestCase<ListManagedCursor> {
public class ListManagedCursorTest extends ActivityInstrumentationTestCase2<ListManagedCursor> {
    private ListManagedCursor mActivity;
    private ListView mListView;

    public ListManagedCursorTest() {
        super("com.android.frameworks.coretests", ListManagedCursor.class);
        super(ListManagedCursor.class);
    }

    @Override
@@ -70,24 +68,6 @@ public class ListManagedCursorTest extends ActivityInstrumentationTestCase<ListM
                firstVisiblePosition == mListView.getFirstVisiblePosition());
    }

    /**
     * Scroll the list using touch, launch new activity, hit back, make sure we're still scrolled.
     */
    @LargeTest
    @Suppress  // Flaky
    public void testTouchScrolling() {
        Instrumentation inst = getInstrumentation();
        
       int firstVisiblePosition = touchScroll(inst);
        
        inst.sendCharacterSync(KeyEvent.KEYCODE_BACK);
        inst.waitForIdleSync();
        
        assertTrue("List not in touch mode", mListView.isInTouchMode()); 
        assertTrue("List did not preserve scroll position", 
                firstVisiblePosition == mListView.getFirstVisiblePosition()); 
    }
    
    /**
     * Scroll the list using arrows, launch new activity, change to touch mode, hit back, make sure
     * we're still scrolled.
@@ -98,7 +78,7 @@ public class ListManagedCursorTest extends ActivityInstrumentationTestCase<ListM

        int firstVisiblePosition = arrowScroll(inst);

        TouchUtils.dragQuarterScreenUp(this);
        TouchUtils.dragQuarterScreenUp(this, getActivity());
        inst.sendCharacterSync(KeyEvent.KEYCODE_BACK);
        inst.waitForIdleSync();

@@ -107,30 +87,6 @@ public class ListManagedCursorTest extends ActivityInstrumentationTestCase<ListM
                firstVisiblePosition == mListView.getFirstVisiblePosition());
    }


    /**
     * Scroll the list using touch, launch new activity, change to trackball mode, hit back, make
     * sure we're still scrolled.
     */
    @FlakyTest(tolerance=3)
    @LargeTest
    @Suppress  // Flaky
    public void testTouchScrollingToTrackballMode() {
        Instrumentation inst = getInstrumentation();

        int firstVisiblePosition = touchScroll(inst);

        inst.sendCharacterSync(KeyEvent.KEYCODE_DPAD_DOWN);
        inst.waitForIdleSync();
        inst.sendCharacterSync(KeyEvent.KEYCODE_DPAD_DOWN);
        inst.waitForIdleSync();
        inst.sendCharacterSync(KeyEvent.KEYCODE_BACK);
        inst.waitForIdleSync();
        assertTrue("List not in trackball mode", !mListView.isInTouchMode());
        assertTrue("List did not preserve scroll position", firstVisiblePosition == mListView
                .getFirstVisiblePosition());
    }
    
    public int arrowScroll(Instrumentation inst) {
        int count = mListView.getChildCount();

@@ -154,30 +110,4 @@ public class ListManagedCursorTest extends ActivityInstrumentationTestCase<ListM

        return firstVisiblePosition;
    }

    public int touchScroll(Instrumentation inst) {
        TouchUtils.dragQuarterScreenUp(this);
        inst.waitForIdleSync();
        TouchUtils.dragQuarterScreenUp(this);
        inst.waitForIdleSync();
        TouchUtils.dragQuarterScreenUp(this);
        inst.waitForIdleSync();
        TouchUtils.dragQuarterScreenUp(this);
        inst.waitForIdleSync();

        int firstVisiblePosition = mListView.getFirstVisiblePosition();
        assertTrue("Touch scroll did not happen", firstVisiblePosition > 0);
        assertTrue("List not in touch mode", mListView.isInTouchMode());

        TouchUtils.clickView(this, mListView.getChildAt(mListView.getChildCount() - 1));
        inst.waitForIdleSync();

        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        return firstVisiblePosition;
    }
}