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

Commit 769ce86f authored by AI test gen's avatar AI test gen Committed by Mykola Podolian
Browse files

Add tests for null views in animateReorder

Adds unit test for the `animateReorder` method in
`StackAnimationController` to ensure it does not crash when the provided
list of bubble views contains null elements.

Original Change: ag/34961761
Bug: 431235865
Test: StackAnimationControllerTest
Flag: TEST_ONLY

Change-Id: I3c591c82d3f9f28bb9b1272b945803e85820551c
parent 77631918
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.