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

Commit 628f2eea authored by Jian-Yang Liu's avatar Jian-Yang Liu Committed by Android (Google) Code Review
Browse files

Merge "Fixed navigation bar to show itself after creating a new user through...

Merge "Fixed navigation bar to show itself after creating a new user through keyguard ui." into rvc-dev
parents e3b51569 4fbd981a
Loading
Loading
Loading
Loading
+4 −2
Original line number Original line Diff line number Diff line
@@ -238,10 +238,12 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks
        }
        }


        buildNavBarContent();
        buildNavBarContent();
        // If the UI was rebuilt (day/night change) while the keyguard was up we need to
        // If the UI was rebuilt (day/night change or user change) while the keyguard was up we need
        // correctly respect that state.
        // to correctly respect that state.
        if (mKeyguardStateControllerLazy.get().isShowing()) {
        if (mKeyguardStateControllerLazy.get().isShowing()) {
            mCarNavigationBarController.showAllKeyguardButtons(isDeviceSetupForUser());
            mCarNavigationBarController.showAllKeyguardButtons(isDeviceSetupForUser());
        } else {
            mCarNavigationBarController.hideAllKeyguardButtons(isDeviceSetupForUser());
        }
        }


        // Upon restarting the Navigation Bar, CarFacetButtonController should immediately apply the
        // Upon restarting the Navigation Bar, CarFacetButtonController should immediately apply the
+41 −9
Original line number Original line Diff line number Diff line
@@ -46,8 +46,6 @@ import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.MockitoAnnotations;


import dagger.Lazy;

@RunWith(AndroidTestingRunner.class)
@RunWith(AndroidTestingRunner.class)
@TestableLooper.RunWithLooper
@TestableLooper.RunWithLooper
@SmallTest
@SmallTest
@@ -68,12 +66,8 @@ public class CarNavigationBarTest extends SysuiTestCase {
    @Mock
    @Mock
    private ButtonSelectionStateListener mButtonSelectionStateListener;
    private ButtonSelectionStateListener mButtonSelectionStateListener;
    @Mock
    @Mock
    private Lazy<KeyguardStateController> mKeyguardStateControllerLazy;
    @Mock
    private KeyguardStateController mKeyguardStateController;
    private KeyguardStateController mKeyguardStateController;
    @Mock
    @Mock
    private Lazy<NavigationBarController> mNavigationBarControllerLazy;
    @Mock
    private NavigationBarController mNavigationBarController;
    private NavigationBarController mNavigationBarController;
    @Mock
    @Mock
    private SuperStatusBarViewFactory mSuperStatusBarViewFactory;
    private SuperStatusBarViewFactory mSuperStatusBarViewFactory;
@@ -89,13 +83,11 @@ public class CarNavigationBarTest extends SysuiTestCase {
        mCarNavigationBar = new CarNavigationBar(mContext, mCarNavigationBarController,
        mCarNavigationBar = new CarNavigationBar(mContext, mCarNavigationBarController,
                mWindowManager, mDeviceProvisionedController, new CommandQueue(mContext),
                mWindowManager, mDeviceProvisionedController, new CommandQueue(mContext),
                mAutoHideController, mButtonSelectionStateListener, mHandler,
                mAutoHideController, mButtonSelectionStateListener, mHandler,
                mKeyguardStateControllerLazy, mNavigationBarControllerLazy,
                () -> mKeyguardStateController, () -> mNavigationBarController,
                mSuperStatusBarViewFactory, mButtonSelectionStateController);
                mSuperStatusBarViewFactory, mButtonSelectionStateController);
        StatusBarWindowView statusBarWindowView = (StatusBarWindowView) LayoutInflater.from(
        StatusBarWindowView statusBarWindowView = (StatusBarWindowView) LayoutInflater.from(
                mContext).inflate(R.layout.super_status_bar, /* root= */ null);
                mContext).inflate(R.layout.super_status_bar, /* root= */ null);
        when(mSuperStatusBarViewFactory.getStatusBarWindowView()).thenReturn(statusBarWindowView);
        when(mSuperStatusBarViewFactory.getStatusBarWindowView()).thenReturn(statusBarWindowView);
        when(mNavigationBarControllerLazy.get()).thenReturn(mNavigationBarController);
        when(mKeyguardStateControllerLazy.get()).thenReturn(mKeyguardStateController);
        when(mKeyguardStateController.isShowing()).thenReturn(false);
        when(mKeyguardStateController.isShowing()).thenReturn(false);
        mDependency.injectMockDependency(WindowManager.class);
        mDependency.injectMockDependency(WindowManager.class);
        // Needed to inflate top navigation bar.
        // Needed to inflate top navigation bar.
@@ -119,4 +111,44 @@ public class CarNavigationBarTest extends SysuiTestCase {


        verify(mButtonSelectionStateListener).onTaskStackChanged();
        verify(mButtonSelectionStateListener).onTaskStackChanged();
    }
    }

    @Test
    public void restartNavBars_newUserNotSetupWithKeyguardShowing_showsKeyguardButtons() {
        ArgumentCaptor<CarDeviceProvisionedController.DeviceProvisionedListener>
                deviceProvisionedCallbackCaptor = ArgumentCaptor.forClass(
                CarDeviceProvisionedController.DeviceProvisionedListener.class);
        when(mDeviceProvisionedController.isCurrentUserSetup()).thenReturn(true);
        mCarNavigationBar.start();
        when(mKeyguardStateController.isShowing()).thenReturn(true);
        // switching the currentUserSetup value to force restart the navbars.
        when(mDeviceProvisionedController.isCurrentUserSetup()).thenReturn(false);
        verify(mDeviceProvisionedController).addCallback(deviceProvisionedCallbackCaptor.capture());

        deviceProvisionedCallbackCaptor.getValue().onUserSwitched();
        waitForIdleSync(mHandler);

        verify(mCarNavigationBarController).showAllKeyguardButtons(false);
    }

    @Test
    public void restartNavbars_newUserIsSetupWithKeyguardHidden_hidesKeyguardButtons() {
        ArgumentCaptor<CarDeviceProvisionedController.DeviceProvisionedListener>
                deviceProvisionedCallbackCaptor = ArgumentCaptor.forClass(
                CarDeviceProvisionedController.DeviceProvisionedListener.class);
        when(mDeviceProvisionedController.isCurrentUserSetup()).thenReturn(true);
        mCarNavigationBar.start();
        when(mKeyguardStateController.isShowing()).thenReturn(true);
        // switching the currentUserSetup value to force restart the navbars.
        when(mDeviceProvisionedController.isCurrentUserSetup()).thenReturn(false);
        verify(mDeviceProvisionedController).addCallback(deviceProvisionedCallbackCaptor.capture());
        deviceProvisionedCallbackCaptor.getValue().onUserSwitched();
        waitForIdleSync(mHandler);
        when(mDeviceProvisionedController.isCurrentUserSetup()).thenReturn(true);
        when(mKeyguardStateController.isShowing()).thenReturn(false);

        deviceProvisionedCallbackCaptor.getValue().onUserSetupChanged();
        waitForIdleSync(mHandler);

        verify(mCarNavigationBarController).hideAllKeyguardButtons(true);
    }
}
}