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

Commit a7821a62 authored by Bryce Lee's avatar Bryce Lee Committed by Android (Google) Code Review
Browse files

Merge "Ensure init is called on CommunalHostViewController"

parents 5267c766 15619be8
Loading
Loading
Loading
Loading
+6 −12
Original line number Diff line number Diff line
@@ -90,25 +90,19 @@ public class CommunalHostViewController extends ViewController<CommunalHostView>
        mMainExecutor = mainExecutor;
        mKeyguardStateController = keyguardStateController;
        mStatusBarStateController = statusBarStateController;
        mState = 0;

        if (mKeyguardStateController.isShowing()) {
            mState |= STATE_KEYGUARD_SHOWING;
    }

        if (mStatusBarStateController.isDozing()) {
            mState |= STATE_DOZING;
        }
    @Override
    public void init() {
        super.init();

        mKeyguardStateController.addCallback(mKeyguardCallback);
        mStatusBarStateController.addCallback(mDozeCallback);
        setState(STATE_KEYGUARD_SHOWING, mKeyguardStateController.isShowing());
        setState(STATE_DOZING, mStatusBarStateController.isDozing());
    }

    @Override
    protected void onViewAttached() {
        mKeyguardStateController.removeCallback(mKeyguardCallback);
        mKeyguardStateController.addCallback(mKeyguardCallback);
        mStatusBarStateController.removeCallback(mDozeCallback);
        mStatusBarStateController.addCallback(mDozeCallback);
    }

+1 −0
Original line number Diff line number Diff line
@@ -1045,6 +1045,7 @@ public class NotificationPanelViewController extends PanelViewController {
                    mCommunalViewComponentFactory.build(communalView);
            mCommunalViewController =
                    communalViewComponent.getCommunalHostViewController();
            mCommunalViewController.init();
        }

        if (mKeyguardUserSwitcherController != null) {
+5 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;

import java.lang.ref.WeakReference;
@@ -67,9 +68,12 @@ public class CommunalHostViewControllerTest extends SysuiTestCase {
        MockitoAnnotations.initMocks(this);

        when(mKeyguardStateController.isShowing()).thenReturn(true);
        when(mCommunalView.isAttachedToWindow()).thenReturn(true);

        mController = new CommunalHostViewController(mFakeExecutor, mKeyguardStateController,
                mStatusBarStateController, mCommunalView);
        mController.init();
        mFakeExecutor.runAllReady();
    }

    @Test
@@ -82,6 +86,7 @@ public class CommunalHostViewControllerTest extends SysuiTestCase {

        // Verify the communal view is shown when the controller is initialized with keyguard
        // showing (see setup).
        Mockito.clearInvocations(mCommunalView);
        mController.show(new WeakReference<>(mCommunalSource));
        mFakeExecutor.runAllReady();
        verify(mCommunalView).setVisibility(View.VISIBLE);
+7 −0
Original line number Diff line number Diff line
@@ -837,6 +837,13 @@ public class NotificationPanelViewTest extends SysuiTestCase {
        verify(mKeyguardStatusViewController, never()).displayClock(LARGE);
    }

    @Test
    public void testCommunalhostViewControllerInit() {
        clearInvocations(mCommunalHostViewController);
        givenViewAttached();
        verify(mCommunalHostViewController).init();
    }

    @Test
    public void testCommunalSourceListening() {
        final ArgumentCaptor<CommunalSourceMonitor.Callback> monitorCallback =