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

Commit e8ce1497 authored by Ang Li's avatar Ang Li Committed by Android (Google) Code Review
Browse files

Merge "Add tests for null views in animateReorder" into main

parents a9ec86fc 769ce86f
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -44,6 +44,8 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.function.IntSupplier;
@@ -268,6 +270,18 @@ public class StackAnimationControllerTest extends PhysicsAnimationLayoutTestCase
        verify(mFloatingContentCoordinator, times(1)).onContentRemoved(any());
    }

    @Test
    public void testAnimateReorder_swappedWithNullView_doesNotCrash() {
        // This test verifies that animateReorder does not crash when the provided list of views
        // contains null elements and a reorder occurs.
        List<View> reorderedViews = new ArrayList<>();
        reorderedViews.add(mViews.get(mViews.size() - 1)); // Move the last view to the front.
        reorderedViews.add(null);                          // Add a null entry.

        // The test will fail if animateReorder() throws an exception.
        mStackController.animateReorder(reorderedViews, mock(Runnable.class));
    }

    /**
     * Checks every child view to make sure it's stacked at the given coordinates, off to the left
     * or right side depending on offset multiplier.