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

Commit 89668be0 authored by Jiaming Cheng's avatar Jiaming Cheng
Browse files

[flexiglass] NullPointerException in QSPanelControllerBaseTest

Several tests in this class failed with a NullPointerException
during its tearDown phase. I couldn't reproduce this locally,
but the stack trace indicates the crash happens within the
LifecycleRegistry when mController.destroy() is called. This
could be caused by an inconsistent lifecycle state when the
ViewLifecycleOwner is destroyed.

This cl fixes the issue by calling onViewDetached() before
destroy() in the test's tearDown method. This can ensure the
view is properly detached and its lifecycle is correctly
handled before the controller is destroyed.

Bug: 430059562
Flag: com.android.systemui.scene_container
Test: com.android.systemui.qs.QSPanelControllerBaseTest
Change-Id: I0b58866cc54f295fe29280951260251d3a427712
parent 6c76dfe7
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -20,6 +20,9 @@ import static com.android.systemui.flags.SceneContainerFlagParameterizationKt.pa

import static com.google.common.truth.Truth.assertThat;

import static kotlinx.coroutines.flow.FlowKt.asStateFlow;
import static kotlinx.coroutines.flow.StateFlowKt.MutableStateFlow;

import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
@@ -35,9 +38,6 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import static kotlinx.coroutines.flow.FlowKt.asStateFlow;
import static kotlinx.coroutines.flow.StateFlowKt.MutableStateFlow;

import android.content.res.Configuration;
import android.content.res.Resources;
import android.platform.test.annotations.EnableFlags;
@@ -70,6 +70,9 @@ import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.ResourcesSplitShadeStateController;
import com.android.systemui.util.animation.DisappearParameters;

import kotlinx.coroutines.flow.MutableStateFlow;
import kotlinx.coroutines.flow.StateFlow;

import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
@@ -85,9 +88,6 @@ import java.util.List;

import javax.inject.Provider;

import kotlinx.coroutines.flow.MutableStateFlow;
import kotlinx.coroutines.flow.StateFlow;

import platform.test.runner.parameterized.ParameterizedAndroidJunit4;
import platform.test.runner.parameterized.Parameters;

@@ -105,6 +105,7 @@ public class QSPanelControllerBaseTest extends SysuiTestCase {
    }

    private final KosmosJavaAdapter mKosmos = new KosmosJavaAdapter(this);

    @Mock
    private QSPanel mQSPanel;
    @Mock
@@ -234,6 +235,7 @@ public class QSPanelControllerBaseTest extends SysuiTestCase {

    @After
    public void tearDown() {
        mController.onViewDetached();
        mController.destroy();
        disallowTestableLooperAsMainThread();
    }