Commit d8ea1f60 by olly Committed by Oliver Woodman

Annotate tests to use Robolectric's LEGACY LooperMode.

The default Robolectric Looper simulation mode is changing to PAUSED from LEGACY.
The following tests fail in this new mode, and are thus being defaulted to LEGACY.

For more details see ​go/robolectric-legacy-looper-mode-lsc

Cleanup change automatically generated by error-prone refactoring
//third_party/android/androidx_test/tools/errorprone/java/androidx/test/tools/errorprone:LegacyLooperModeConverter_refactoring

Tested:
    TAP train for global presubmit queue
    http://test/OCL:297627974:BASE:298600828:1583273401491:7d94dbaa
PiperOrigin-RevId: 298809656
parent 63256a48
...@@ -21,6 +21,7 @@ import static com.google.android.exoplayer2.AudioFocusManager.PLAYER_COMMAND_WAI ...@@ -21,6 +21,7 @@ import static com.google.android.exoplayer2.AudioFocusManager.PLAYER_COMMAND_WAI
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import static org.robolectric.annotation.Config.TARGET_SDK; import static org.robolectric.annotation.Config.TARGET_SDK;
import static org.robolectric.annotation.LooperMode.Mode.LEGACY;
import android.content.Context; import android.content.Context;
import android.media.AudioFocusRequest; import android.media.AudioFocusRequest;
...@@ -36,9 +37,11 @@ import org.junit.Test; ...@@ -36,9 +37,11 @@ import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.robolectric.Shadows; import org.robolectric.Shadows;
import org.robolectric.annotation.Config; import org.robolectric.annotation.Config;
import org.robolectric.annotation.LooperMode;
import org.robolectric.shadows.ShadowAudioManager; import org.robolectric.shadows.ShadowAudioManager;
/** Unit tests for {@link AudioFocusManager}. */ /** Unit tests for {@link AudioFocusManager}. */
@LooperMode(LEGACY)
@RunWith(AndroidJUnit4.class) @RunWith(AndroidJUnit4.class)
public class AudioFocusManagerTest { public class AudioFocusManagerTest {
private static final int NO_COMMAND_RECEIVED = ~PLAYER_COMMAND_WAIT_FOR_CALLBACK; private static final int NO_COMMAND_RECEIVED = ~PLAYER_COMMAND_WAIT_FOR_CALLBACK;
......
...@@ -18,6 +18,7 @@ package com.google.android.exoplayer2; ...@@ -18,6 +18,7 @@ package com.google.android.exoplayer2;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertNull; import static org.junit.Assert.assertNull;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.robolectric.annotation.LooperMode.Mode.LEGACY;
import android.net.Uri; import android.net.Uri;
import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.ext.junit.runners.AndroidJUnit4;
...@@ -37,8 +38,10 @@ import java.util.Collections; ...@@ -37,8 +38,10 @@ import java.util.Collections;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.robolectric.annotation.LooperMode;
/** Unit tests for {@link MediaPeriodQueue}. */ /** Unit tests for {@link MediaPeriodQueue}. */
@LooperMode(LEGACY)
@RunWith(AndroidJUnit4.class) @RunWith(AndroidJUnit4.class)
public final class MediaPeriodQueueTest { public final class MediaPeriodQueueTest {
......
...@@ -20,6 +20,7 @@ import static com.google.android.exoplayer2.testutil.TestUtil.assertBufferInfosE ...@@ -20,6 +20,7 @@ import static com.google.android.exoplayer2.testutil.TestUtil.assertBufferInfosE
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertThrows; import static org.junit.Assert.assertThrows;
import static org.robolectric.Shadows.shadowOf; import static org.robolectric.Shadows.shadowOf;
import static org.robolectric.annotation.LooperMode.Mode.LEGACY;
import android.media.MediaCodec; import android.media.MediaCodec;
import android.media.MediaFormat; import android.media.MediaFormat;
...@@ -36,9 +37,11 @@ import org.junit.Before; ...@@ -36,9 +37,11 @@ import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.robolectric.Shadows; import org.robolectric.Shadows;
import org.robolectric.annotation.LooperMode;
import org.robolectric.shadows.ShadowLooper; import org.robolectric.shadows.ShadowLooper;
/** Unit tests for {@link DedicatedThreadAsyncMediaCodecAdapter}. */ /** Unit tests for {@link DedicatedThreadAsyncMediaCodecAdapter}. */
@LooperMode(LEGACY)
@RunWith(AndroidJUnit4.class) @RunWith(AndroidJUnit4.class)
public class DedicatedThreadAsyncMediaCodecAdapterTest { public class DedicatedThreadAsyncMediaCodecAdapterTest {
private DedicatedThreadAsyncMediaCodecAdapter adapter; private DedicatedThreadAsyncMediaCodecAdapter adapter;
......
...@@ -20,6 +20,7 @@ import static com.google.android.exoplayer2.testutil.TestUtil.assertBufferInfosE ...@@ -20,6 +20,7 @@ import static com.google.android.exoplayer2.testutil.TestUtil.assertBufferInfosE
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertThrows; import static org.junit.Assert.assertThrows;
import static org.robolectric.Shadows.shadowOf; import static org.robolectric.Shadows.shadowOf;
import static org.robolectric.annotation.LooperMode.Mode.LEGACY;
import android.media.MediaCodec; import android.media.MediaCodec;
import android.media.MediaFormat; import android.media.MediaFormat;
...@@ -36,9 +37,11 @@ import org.junit.Before; ...@@ -36,9 +37,11 @@ import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.robolectric.Shadows; import org.robolectric.Shadows;
import org.robolectric.annotation.LooperMode;
import org.robolectric.shadows.ShadowLooper; import org.robolectric.shadows.ShadowLooper;
/** Unit tests for {@link MultiLockAsyncMediaCodecAdapter}. */ /** Unit tests for {@link MultiLockAsyncMediaCodecAdapter}. */
@LooperMode(LEGACY)
@RunWith(AndroidJUnit4.class) @RunWith(AndroidJUnit4.class)
public class MultiLockAsyncMediaCodecAdapterTest { public class MultiLockAsyncMediaCodecAdapterTest {
private MultiLockAsyncMediaCodecAdapter adapter; private MultiLockAsyncMediaCodecAdapter adapter;
......
...@@ -18,6 +18,7 @@ package com.google.android.exoplayer2.upstream.cache; ...@@ -18,6 +18,7 @@ package com.google.android.exoplayer2.upstream.cache;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static java.util.Arrays.copyOf; import static java.util.Arrays.copyOf;
import static java.util.Arrays.copyOfRange; import static java.util.Arrays.copyOfRange;
import static org.robolectric.annotation.LooperMode.Mode.LEGACY;
import android.content.Context; import android.content.Context;
import android.net.Uri; import android.net.Uri;
...@@ -39,8 +40,10 @@ import java.io.IOException; ...@@ -39,8 +40,10 @@ import java.io.IOException;
import java.util.Random; import java.util.Random;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.robolectric.annotation.LooperMode;
/** Additional tests for {@link CacheDataSource}. */ /** Additional tests for {@link CacheDataSource}. */
@LooperMode(LEGACY)
@RunWith(AndroidJUnit4.class) @RunWith(AndroidJUnit4.class)
public final class CacheDataSourceTest2 { public final class CacheDataSourceTest2 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment