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

Commit 5cd3fabb authored by Chun-Ku Lin's avatar Chun-Ku Lin Committed by Automerger Merge Worker
Browse files

Merge "Update the resource's configuration programmatically to ensure test is...

Merge "Update the resource's configuration programmatically to ensure test is in night mode" into main am: 37826717 am: 875b2ec3

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



Change-Id: I99fd857dcd2bda5b5965b55caa1d68b63a3ba447
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 0df6befb 875b2ec3
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;

import android.app.UiModeManager;
import android.content.res.Configuration;
import android.graphics.Rect;
import android.graphics.drawable.GradientDrawable;
import android.platform.test.annotations.EnableFlags;
@@ -78,6 +79,12 @@ public class MenuViewTest extends SysuiTestCase {
        mNightMode = mUiModeManager.getNightMode();
        mUiModeManager.setNightMode(MODE_NIGHT_YES);

        // Programmatically update the resource's configuration to night mode to reduce flakiness
        Configuration nightConfig = new Configuration(mContext.getResources().getConfiguration());
        nightConfig.uiMode = Configuration.UI_MODE_NIGHT_YES;
        mContext.getResources().updateConfiguration(nightConfig,
                mContext.getResources().getDisplayMetrics(), null);

        mSpyContext = spy(mContext);
        doNothing().when(mSpyContext).startActivity(any());

@@ -101,6 +108,8 @@ public class MenuViewTest extends SysuiTestCase {

    @Test
    public void insetsOnDarkTheme_menuOnLeft_matchInsets() {
        // In dark theme, the inset is not 0 to avoid weird spacing issue between the menu and
        // the edge of the screen.
        mMenuView.onConfigurationChanged(/* newConfig= */ null);
        final InstantInsetLayerDrawable insetLayerDrawable =
                (InstantInsetLayerDrawable) mMenuView.getBackground();