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

Commit 80d3911a authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Temporarily disable DeviceConfigTest.testOnPropertiesChangedListener"

parents c10f441e fe3a9024
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();