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

Commit 017577df authored by Peter Kalauskas's avatar Peter Kalauskas Committed by Automerger Merge Worker
Browse files

Merge "Add tests for shouldAnimate and onDoneButtonClicked" into sc-dev am: a74aa47b

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14518676

Change-Id: Ie723bd67379800e8f2d67583a09cf7f7c98e65f0
parents aa6d8dc3 a74aa47b
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import android.widget.LinearLayout;
import android.widget.Switch;
import android.widget.TextView;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.UiEventLogger;
import com.android.systemui.Dependency;
@@ -57,7 +58,8 @@ public class QSDetail extends LinearLayout {
    private ViewGroup mDetailContent;
    protected TextView mDetailSettingsButton;
    protected TextView mDetailDoneButton;
    private QSDetailClipper mClipper;
    @VisibleForTesting
    QSDetailClipper mClipper;
    private DetailAdapter mDetailAdapter;
    private QSPanelController mQsPanelController;

+59 −0
Original line number Diff line number Diff line
@@ -20,7 +20,9 @@ import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.clearInvocations;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

@@ -75,6 +77,7 @@ public class QSDetailTest extends SysuiTestCase {
        mQsPanelController = mock(QSPanelController.class);
        mQuickHeader = mock(QuickStatusBarHeader.class);
        mQsDetail.setQsPanel(mQsPanelController, mQuickHeader, mock(QSFooter.class));
        mQsDetail.mClipper = mock(QSDetailClipper.class);

        mMockDetailAdapter = mock(DetailAdapter.class);
        when(mMockDetailAdapter.createDetailView(any(), any(), any()))
@@ -114,6 +117,62 @@ public class QSDetailTest extends SysuiTestCase {
        assertEquals(QSUserSwitcherEvent.QS_USER_DETAIL_CLOSE.getId(), mUiEventLogger.eventId(0));
    }

    @Test
    public void testShowDetail_ShouldAnimate() {
        mTestableLooper.processAllMessages();

        when(mMockDetailAdapter.shouldAnimate()).thenReturn(true);
        mQsDetail.setFullyExpanded(true);

        mQsDetail.handleShowingDetail(mMockDetailAdapter, 0, 0, false);
        verify(mQsDetail.mClipper).updateCircularClip(eq(true) /* animate */, anyInt(), anyInt(),
                eq(true) /* in */, any());
        clearInvocations(mQsDetail.mClipper);

        mQsDetail.handleShowingDetail(null, 0, 0, false);
        verify(mQsDetail.mClipper).updateCircularClip(eq(true) /* animate */, anyInt(), anyInt(),
                eq(false) /* in */, any());
    }

    @Test
    public void testShowDetail_ShouldNotAnimate() {
        mTestableLooper.processAllMessages();

        when(mMockDetailAdapter.shouldAnimate()).thenReturn(false);
        mQsDetail.setFullyExpanded(true);

        mQsDetail.handleShowingDetail(mMockDetailAdapter, 0, 0, false);
        verify(mQsDetail.mClipper).updateCircularClip(eq(false) /* animate */, anyInt(), anyInt(),
                eq(true) /* in */, any());
        clearInvocations(mQsDetail.mClipper);

        mQsDetail.handleShowingDetail(null, 0, 0, false);
        verify(mQsDetail.mClipper).updateCircularClip(eq(false) /* animate */, anyInt(), anyInt(),
                eq(false) /* in */, any());
    }

    @Test
    public void testDoneButton_CloseDetailPanel() {
        mTestableLooper.processAllMessages();

        when(mMockDetailAdapter.onDoneButtonClicked()).thenReturn(false);

        mQsDetail.handleShowingDetail(mMockDetailAdapter, 0, 0, false);
        mQsDetail.requireViewById(android.R.id.button1).performClick();
        verify(mQsPanelController).closeDetail();
    }

    @Test
    public void testDoneButton_KeepDetailPanelOpen() {
        mTestableLooper.processAllMessages();

        when(mMockDetailAdapter.onDoneButtonClicked()).thenReturn(true);

        mQsDetail.handleShowingDetail(mMockDetailAdapter, 0, 0, false);
        mQsDetail.requireViewById(android.R.id.button1).performClick();
        verify(mQsPanelController, never()).closeDetail();
    }

    @Test
    public void testMoreSettingsButton() {
        mTestableLooper.processAllMessages();