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

Commit ec6b28d0 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Un-ignore ignored test. They're no longer flakey" into main

parents ebb8b933 d932ecbc
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package android.os;

import android.platform.test.annotations.IgnoreUnderRavenwood;
import android.platform.test.ravenwood.RavenwoodRule;

import androidx.test.filters.MediumTest;
@@ -154,7 +153,6 @@ public class MessageQueueTest {

    @Test
    @MediumTest
    @IgnoreUnderRavenwood(reason = "Flaky test, b/315872700")
    public void testFieldIntegrity() throws Exception {

        TestHandlerThread tester = new TestFieldIntegrityHandler() {
+0 −3
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@ package android.util;

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

import android.platform.test.annotations.IgnoreUnderRavenwood;
import android.platform.test.ravenwood.RavenwoodRule;

import androidx.test.filters.SmallTest;
@@ -37,7 +36,6 @@ public class SparseSetArrayTest {
    public final RavenwoodRule mRavenwood = new RavenwoodRule();

    @Test
    @IgnoreUnderRavenwood(reason = "Flaky test, b/315872700")
    public void testAddAll() {
        final SparseSetArray<Integer> sparseSetArray = new SparseSetArray<>();

@@ -59,7 +57,6 @@ public class SparseSetArrayTest {
    }

    @Test
    @IgnoreUnderRavenwood(reason = "b/315036461")
    public void testCopyConstructor() {
        final SparseSetArray<Integer> sparseSetArray = new SparseSetArray<>();

+24 −9
Original line number Diff line number Diff line
@@ -18,17 +18,19 @@ package android.util;

import static org.junit.Assert.assertEquals;

import android.platform.test.annotations.IgnoreUnderRavenwood;
import android.platform.test.ravenwood.RavenwoodRule;

import androidx.test.runner.AndroidJUnit4;

import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.TimeZone;
import java.util.function.Consumer;

@RunWith(AndroidJUnit4.class)
@@ -42,6 +44,22 @@ public class TimeUtilsTest {
    public static final long DAY_IN_MILLIS = HOUR_IN_MILLIS * 24;
    public static final long WEEK_IN_MILLIS = DAY_IN_MILLIS * 7;

    private TimeZone mOrigTimezone;

    @Before
    public void setUp() {
        mOrigTimezone = TimeZone.getDefault();

        TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
    }

    @After
    public void tearDown() {
        if (mOrigTimezone != null) {
            TimeZone.setDefault(mOrigTimezone);
        }
    }

    @Test
    public void testFormatTime() {
        assertEquals("1672556400000 (now)",
@@ -85,32 +103,29 @@ public class TimeUtilsTest {
    }

    @Test
    @IgnoreUnderRavenwood(reason = "Flaky test, b/315872700")
    public void testDumpTime() {
        assertEquals("2023-01-01 00:00:00.000", runWithPrintWriter((pw) -> {
        assertEquals("2023-01-01 07:00:00.000", runWithPrintWriter((pw) -> {
            TimeUtils.dumpTime(pw, 1672556400000L);
        }));
        assertEquals("2023-01-01 00:00:00.000 (now)", runWithPrintWriter((pw) -> {
        assertEquals("2023-01-01 07:00:00.000 (now)", runWithPrintWriter((pw) -> {
            TimeUtils.dumpTimeWithDelta(pw, 1672556400000L, 1672556400000L);
        }));
        assertEquals("2023-01-01 00:00:00.000 (-10ms)", runWithPrintWriter((pw) -> {
        assertEquals("2023-01-01 07:00:00.000 (-10ms)", runWithPrintWriter((pw) -> {
            TimeUtils.dumpTimeWithDelta(pw, 1672556400000L, 1672556400000L + 10);
        }));
    }

    @Test
    @IgnoreUnderRavenwood(reason = "Flaky test, b/315872700")
    public void testFormatForLogging() {
        assertEquals("unknown", TimeUtils.formatForLogging(0));
        assertEquals("unknown", TimeUtils.formatForLogging(-1));
        assertEquals("unknown", TimeUtils.formatForLogging(Long.MIN_VALUE));
        assertEquals("2023-01-01 00:00:00", TimeUtils.formatForLogging(1672556400000L));
        assertEquals("2023-01-01 07:00:00", TimeUtils.formatForLogging(1672556400000L));
    }

    @Test
    @IgnoreUnderRavenwood(reason = "Flaky test, b/315872700")
    public void testLogTimeOfDay() {
        assertEquals("01-01 00:00:00.000", TimeUtils.logTimeOfDay(1672556400000L));
        assertEquals("01-01 07:00:00.000", TimeUtils.logTimeOfDay(1672556400000L));
    }

    public static String runWithPrintWriter(Consumer<PrintWriter> consumer) {