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

Commit 5eb6944e authored by Charles Chen's avatar Charles Chen
Browse files

Fix ConfigurationDispatcherTest failure

The tests fail because RoundedCornerTest updated Confguration.EMPTY
value. This CL changes Configuration.EMPTY to new Configuration().

This CL also updates Configuration#toString to reflect the differences
of ScreenLayout round and compact_enabled, which was missed previously.

Test: run v2/android-virtual-infra/test_mapping/presubmit-avd via abtd
Flag: EXEMPT bugfix
Fixes: 400675837

Change-Id: Ia9975b93ef83a88e1dbced065f3ec814dad63460
parent 4c21197c
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -1195,6 +1195,16 @@ public final class Configuration implements Parcelable, Comparable<Configuration
            default: sb.append(" layoutLong=");
                    sb.append(screenLayout&SCREENLAYOUT_LONG_MASK); break;
        }
        switch ((screenLayout & SCREENLAYOUT_ROUND_MASK)) {
            case SCREENLAYOUT_ROUND_UNDEFINED: sb.append(" ?round"); break;
            case SCREENLAYOUT_ROUND_NO:  /* not-round is not interesting to print */ break;
            case SCREENLAYOUT_ROUND_YES: sb.append(" round"); break;
            default: sb.append(" layoutRound=");
                sb.append(screenLayout & SCREENLAYOUT_ROUND_MASK); break;
        }
        if ((screenLayout & SCREENLAYOUT_COMPAT_NEEDED) != 0) {
            sb.append(" compactNeeded");
        }
        switch ((colorMode &COLOR_MODE_HDR_MASK)) {
            case COLOR_MODE_HDR_UNDEFINED: sb.append(" ?ldr"); break; // most likely not HDR
            case COLOR_MODE_HDR_NO: /* ldr is not interesting to print */ break;
+1 −1
Original line number Diff line number Diff line
@@ -68,7 +68,7 @@ public class RoundedCornersTest {
    @Before
    public void setUp() {
        MockitoAnnotations.initMocks(this);
        mConfiguration = Configuration.EMPTY;
        mConfiguration = new Configuration();
    }

    final RoundedCorners mRoundedCorners = new RoundedCorners(
+22 −8
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ import android.content.res.Configuration.ORIENTATION_PORTRAIT
import android.platform.test.annotations.Presubmit
import android.view.Display.DEFAULT_DISPLAY
import androidx.test.filters.SmallTest
import com.google.common.truth.Truth.assertThat
import com.google.common.truth.Truth.assertWithMessage
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.Parameterized
@@ -52,7 +52,14 @@ class ConfigurationDispatcherTest(private val shouldReportPrivateChanges: Boolea
        // Verify public config field change
        receiver.windowToken.onConfigurationChangedInner(receiver, config, DEFAULT_DISPLAY, true)

        assertThat(receiver.receivedConfig).isEqualTo(config)
        assertWithMessage(
            "expected: $config, but was ${receiver.receivedConfig}. "
                    + "The diff is "
                    + Configuration.configurationDiffToString(
                receiver.receivedConfig.diff(config)
            )
        )
            .that(receiver.receivedConfig).isEqualTo(config)

        // Clear the config value
        receiver.receivedConfig.unset()
@@ -62,13 +69,20 @@ class ConfigurationDispatcherTest(private val shouldReportPrivateChanges: Boolea

        receiver.windowToken.onConfigurationChangedInner(receiver, config, DEFAULT_DISPLAY, true)

        assertThat(receiver.receivedConfig).isEqualTo(
            if (shouldReportPrivateChanges) {
        val expectedConfig = if (shouldReportPrivateChanges) {
            config
        } else {
            Configuration.EMPTY
        }

        assertWithMessage(
            "expected: $expectedConfig, but was ${receiver.receivedConfig}. "
                    + "The diff is "
                    + Configuration.configurationDiffToString(
                        receiver.receivedConfig.diff(expectedConfig)
                    )
        )
            .that(receiver.receivedConfig).isEqualTo(expectedConfig)
    }

    /**