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

Commit fe3a9024 authored by Matt Pape's avatar Matt Pape
Browse files

Temporarily disable DeviceConfigTest.testOnPropertiesChangedListener

This test is flaky in presubmit. Suppress until the root cause is fixed.

Test: atest SettingsProviderTest:DeviceConfigServiceTest
Bug: 142727848
Change-Id: I6cdf9a7a62bc2ed55639d12632a0981eb1378fcd
parent 245edfe7
Loading
Loading
Loading
Loading
+24 −28
Original line number Diff line number Diff line
@@ -16,12 +16,10 @@

package android.provider;

import static android.provider.DeviceConfig.OnPropertiesChangedListener;
import static android.provider.DeviceConfig.Properties;

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

import android.app.ActivityThread;
import android.content.ContentResolver;
import android.os.Bundle;
import android.platform.test.annotations.Presubmit;
@@ -35,9 +33,6 @@ import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

/** Tests that ensure appropriate settings are backed up. */
@Presubmit
@RunWith(AndroidJUnit4.class)
@@ -482,29 +477,30 @@ public class DeviceConfigTest {
        assertThat(properties.getString(KEY3, DEFAULT_VALUE)).isEqualTo(DEFAULT_VALUE);
    }

    @Test
    public void testOnPropertiesChangedListener() throws InterruptedException {
        final CountDownLatch countDownLatch = new CountDownLatch(1);

        OnPropertiesChangedListener changeListener = (properties) -> {
            assertThat(properties.getNamespace()).isEqualTo(NAMESPACE);
            assertThat(properties.getKeyset()).contains(KEY);
            assertThat(properties.getString(KEY, "default_value")).isEqualTo(VALUE);
            countDownLatch.countDown();
        };

        try {
            DeviceConfig.addOnPropertiesChangedListener(NAMESPACE,
                    ActivityThread.currentApplication().getMainExecutor(), changeListener);
            DeviceConfig.setProperty(NAMESPACE, KEY, VALUE, false);
            assertThat(countDownLatch.await(
                    WAIT_FOR_PROPERTY_CHANGE_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)).isTrue();
        } catch (InterruptedException e) {
            Assert.fail(e.getMessage());
        } finally {
            DeviceConfig.removeOnPropertiesChangedListener(changeListener);
        }
    }
    // TODO(mpape): resolve b/142727848 and re-enable this test
//    @Test
//    public void testOnPropertiesChangedListener() throws InterruptedException {
//        final CountDownLatch countDownLatch = new CountDownLatch(1);
//
//        OnPropertiesChangedListener changeListener = (properties) -> {
//            assertThat(properties.getNamespace()).isEqualTo(NAMESPACE);
//            assertThat(properties.getKeyset()).contains(KEY);
//            assertThat(properties.getString(KEY, "default_value")).isEqualTo(VALUE);
//            countDownLatch.countDown();
//        };
//
//        try {
//            DeviceConfig.addOnPropertiesChangedListener(NAMESPACE,
//                    ActivityThread.currentApplication().getMainExecutor(), changeListener);
//            DeviceConfig.setProperty(NAMESPACE, KEY, VALUE, false);
//            assertThat(countDownLatch.await(
//                    WAIT_FOR_PROPERTY_CHANGE_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)).isTrue();
//        } catch (InterruptedException e) {
//            Assert.fail(e.getMessage());
//        } finally {
//            DeviceConfig.removeOnPropertiesChangedListener(changeListener);
//        }
//    }

    private static boolean deleteViaContentProvider(String namespace, String key) {
        ContentResolver resolver = InstrumentationRegistry.getContext().getContentResolver();