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

Commit 8409284b authored by Sunny Goyal's avatar Sunny Goyal Committed by Android (Google) Code Review
Browse files

Merge "Cleaning up properly after RaceConditionReproducerTest" into ub-launcher3-master

parents 6b62f28e bffbd752
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import static org.junit.Assert.assertTrue;
import androidx.test.filters.LargeTest;
import androidx.test.runner.AndroidJUnit4;

import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
@@ -45,6 +46,11 @@ public class RaceConditionReproducerTest {
        eventProcessor = new RaceConditionReproducer();
    }

    @After
    public void tearDown() {
        TraceHelperForTest.cleanup();
    }

    private void run3_3_TestAction() throws InterruptedException {
        Thread tb = new Thread(() -> {
            eventProcessor.onEvent("B1");
@@ -125,9 +131,7 @@ public class RaceConditionReproducerTest {
    @Test
    // 2 threads, 3 events each; reproducing a particular event sequence.
    public void test3_3_ReproMode() throws Exception {
        final RaceConditionReproducer eventProcessor = new RaceConditionReproducer(
                SOME_VALID_SEQUENCE_3_3);

        eventProcessor = new RaceConditionReproducer(SOME_VALID_SEQUENCE_3_3);
        eventProcessor.startIteration();
        run3_3_TestAction();
        assertTrue(!eventProcessor.finishIteration());
+5 −0
Original line number Diff line number Diff line
@@ -33,6 +33,11 @@ public class TraceHelperForTest extends TraceHelper {
        INSTANCE_FOR_TEST.mRaceConditionReproducer = reproducer;
    }

    public static void cleanup() {
        INSTANCE_FOR_TEST.mRaceConditionReproducer = null;
        INSTANCE_FOR_TEST.mFlagsChangeListener = null;
    }

    public static void setFlagsChangeListener(IntConsumer listener) {
        TraceHelper.INSTANCE = INSTANCE_FOR_TEST;
        INSTANCE_FOR_TEST.mFlagsChangeListener = listener;