viewpager2/src/androidTest/java/androidx/viewpager2/widget/SwipeTest.java
@SuppressWarnings("SameParameterValue")
    private static TestConfig createRandomTest(int id, int totalPages, int sequenceLength,
            double configChangeProbability, double mutationProbability, double advanceProbability,
            Class<? extends BaseActivity> activityClass) {
        Random random = new Random();

        List<Integer> pageSequence = new ArrayList<>();
        List<Integer> configChanges = new ArrayList<>();
        List<Pair<Integer, Integer>> stepToNewValue = new ArrayList<>();

        int pageIx = 0;
        Double goRightProbability = null;
        for (int currentStep = 0; currentStep < sequenceLength; currentStep++) {
            if (random.nextDouble() < configChangeProbability) {
                configChanges.add(currentStep);
            }

            if (random.nextDouble() < mutationProbability) {
                stepToNewValue.add(Pair.create(currentStep, random.nextInt(10_000)));
            }

            boolean goRight;
            if (pageIx == 0) {
                goRight = true;
                goRightProbability = advanceProbability;
            } else if (pageIx == totalPages - 1) { // last page
                goRight = false;
                goRightProbability = 1 - advanceProbability;
            } else {
                goRight = random.nextDouble() < goRightProbability;
            }
            pageSequence.add(goRight ? ++pageIx : --pageIx);
        }

        return new TestConfig("random_" + id, pageSequence, configChanges, stepToNewValue,
                totalPages, activityClass, HORIZONTAL);
    }
/**
     * @param advanceProbability determines the probability of a swipe direction being towards
     *                           the next edge - e.g. if we start from the left, it's the
     *                           probability that the next swipe will go right. <p> Setting it to
     *                           values closer to 0.5 results in a lot of back and forth, while
     *                           setting it closer to 1.0 results in going edge to edge with few
     *                           back-swipes.
     */
@param advanceProbability determines the probability of a swipe direction being towards
the next edge - e.g. if we start from the left, it's the
probability that the next swipe will go right.  Setting it to
values closer to 0.5 results in a lot of back and forth, while
setting it closer to 1.0 results in going edge to edge with few
back-swipes.
@param advanceProbability determines the probability of a swipe direction being towards the next edge - e . g . if we start from the left it ' s the probability that the next swipe will go right . Setting it to values closer to 0 . 5 results in a lot of back and forth while setting it closer to 1 . 0 results in going edge to edge with few back - swipes .
@SuppressWarnings("SameParameterValue")
    private static TestConfig createRandomTest(int id, int totalPages, int sequenceLength,
            double configChangeProbability, double mutationProbability, double advanceProbability,
            Class<? extends BaseActivity> activityClass) {
        Random random = new Random();
        List<Integer> pageSequence = new ArrayList<>();
        List<Integer> configChanges = new ArrayList<>();
        List<Pair<Integer, Integer>> stepToNewValue = new ArrayList<>();
        int pageIx = 0;
        Double goRightProbability = null;
        for (int currentStep = 0; currentStep < sequenceLength; currentStep++) {
            if (random.nextDouble() < configChangeProbability) {
                configChanges.add(currentStep);
            }
            if (random.nextDouble() < mutationProbability) {
                stepToNewValue.add(Pair.create(currentStep, random.nextInt(10_000)));
            }
            boolean goRight;
            if (pageIx == 0) {
                goRight = true;
                goRightProbability = advanceProbability;
            } else if (pageIx == totalPages - 1) { 
                goRight = false;
                goRightProbability = 1 - advanceProbability;
            } else {
                goRight = random.nextDouble() < goRightProbability;
            }
            pageSequence.add(goRight ? ++pageIx : --pageIx);
        }
        return new TestConfig("random_" + id, pageSequence, configChanges, stepToNewValue,
                totalPages, activityClass, HORIZONTAL);
    }
@ SuppressWarnings ( "SameParameterValue" ) private static TestConfig createRandomTest ( int id , int totalPages , int sequenceLength , double configChangeProbability , double mutationProbability , double advanceProbability , Class < ? extends BaseActivity > activityClass ) { Random random = new Random ( ) ; List < Integer > pageSequence = new ArrayList < > ( ) ; List < Integer > configChanges = new ArrayList < > ( ) ; List < Pair < Integer , Integer > > stepToNewValue = new ArrayList < > ( ) ; int pageIx = 0 ; Double goRightProbability = null ; for ( int currentStep = 0 ; currentStep < sequenceLength ; currentStep ++ ) { if ( random . nextDouble ( ) < configChangeProbability ) { configChanges . add ( currentStep ) ; } if ( random . nextDouble ( ) < mutationProbability ) { stepToNewValue . add ( Pair . create ( currentStep , random . nextInt ( 10_000 ) ) ) ; } boolean goRight ; if ( pageIx == 0 ) { goRight = true ; goRightProbability = advanceProbability ; } else if ( pageIx == totalPages - 1 ) { goRight = false ; goRightProbability = 1 - advanceProbability ; } else { goRight = random . nextDouble ( ) < goRightProbability ; } pageSequence . add ( goRight ? ++ pageIx : -- pageIx ) ; } return new TestConfig ( "random_" + id , pageSequence , configChanges , stepToNewValue , totalPages , activityClass , HORIZONTAL ) ; }
@param advanceProbability determines the probability of a swipe direction being towards
                           the next edge - e.g.
@param advanceProbability determines the probability of a swipe direction being towards the next edge - e . g .
// last page