Commit edabbd52 by tonihei Committed by Andrew Lewis

Update Robolectric and Truth.

PiperOrigin-RevId: 233612344
parent f299a65a
Showing with 176 additions and 33 deletions
...@@ -23,8 +23,8 @@ project.ext { ...@@ -23,8 +23,8 @@ project.ext {
dexmakerVersion = '1.2' dexmakerVersion = '1.2'
mockitoVersion = '1.9.5' mockitoVersion = '1.9.5'
junitVersion = '4.12' junitVersion = '4.12'
truthVersion = '0.39' truthVersion = '0.42'
robolectricVersion = '3.7.1' robolectricVersion = '4.1'
autoValueVersion = '1.6' autoValueVersion = '1.6'
checkerframeworkVersion = '2.5.0' checkerframeworkVersion = '2.5.0'
testRunnerVersion = '1.1.0-alpha3' testRunnerVersion = '1.1.0-alpha3'
......
...@@ -26,6 +26,8 @@ android { ...@@ -26,6 +26,8 @@ android {
minSdkVersion project.ext.minSdkVersion minSdkVersion project.ext.minSdkVersion
targetSdkVersion project.ext.targetSdkVersion targetSdkVersion project.ext.targetSdkVersion
} }
testOptions.unitTests.includeAndroidResources = true
} }
dependencies { dependencies {
......
...@@ -26,6 +26,8 @@ android { ...@@ -26,6 +26,8 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8
} }
testOptions.unitTests.includeAndroidResources = true
} }
dependencies { dependencies {
......
...@@ -32,6 +32,8 @@ android { ...@@ -32,6 +32,8 @@ android {
jniLibs.srcDir 'src/main/libs' jniLibs.srcDir 'src/main/libs'
jni.srcDirs = [] // Disable the automatic ndk-build call by Android Studio. jni.srcDirs = [] // Disable the automatic ndk-build call by Android Studio.
} }
testOptions.unitTests.includeAndroidResources = true
} }
dependencies { dependencies {
......
...@@ -33,6 +33,8 @@ android { ...@@ -33,6 +33,8 @@ android {
jniLibs.srcDir 'src/main/libs' jniLibs.srcDir 'src/main/libs'
jni.srcDirs = [] // Disable the automatic ndk-build call by Android Studio. jni.srcDirs = [] // Disable the automatic ndk-build call by Android Studio.
} }
testOptions.unitTests.includeAndroidResources = true
} }
dependencies { dependencies {
......
...@@ -26,6 +26,8 @@ android { ...@@ -26,6 +26,8 @@ android {
minSdkVersion 19 minSdkVersion 19
targetSdkVersion project.ext.targetSdkVersion targetSdkVersion project.ext.targetSdkVersion
} }
testOptions.unitTests.includeAndroidResources = true
} }
dependencies { dependencies {
......
...@@ -27,6 +27,8 @@ android { ...@@ -27,6 +27,8 @@ android {
targetSdkVersion project.ext.targetSdkVersion targetSdkVersion project.ext.targetSdkVersion
consumerProguardFiles 'proguard-rules.txt' consumerProguardFiles 'proguard-rules.txt'
} }
testOptions.unitTests.includeAndroidResources = true
} }
dependencies { dependencies {
......
...@@ -28,6 +28,8 @@ android { ...@@ -28,6 +28,8 @@ android {
minSdkVersion project.ext.minSdkVersion minSdkVersion project.ext.minSdkVersion
targetSdkVersion project.ext.targetSdkVersion targetSdkVersion project.ext.targetSdkVersion
} }
testOptions.unitTests.includeAndroidResources = true
} }
dependencies { dependencies {
......
...@@ -26,6 +26,8 @@ android { ...@@ -26,6 +26,8 @@ android {
minSdkVersion 17 minSdkVersion 17
targetSdkVersion project.ext.targetSdkVersion targetSdkVersion project.ext.targetSdkVersion
} }
testOptions.unitTests.includeAndroidResources = true
} }
dependencies { dependencies {
......
...@@ -26,6 +26,8 @@ android { ...@@ -26,6 +26,8 @@ android {
minSdkVersion project.ext.minSdkVersion minSdkVersion project.ext.minSdkVersion
targetSdkVersion project.ext.targetSdkVersion targetSdkVersion project.ext.targetSdkVersion
} }
testOptions.unitTests.includeAndroidResources = true
} }
dependencies { dependencies {
......
...@@ -27,6 +27,8 @@ android { ...@@ -27,6 +27,8 @@ android {
targetSdkVersion project.ext.targetSdkVersion targetSdkVersion project.ext.targetSdkVersion
consumerProguardFiles 'proguard-rules.txt' consumerProguardFiles 'proguard-rules.txt'
} }
testOptions.unitTests.includeAndroidResources = true
} }
dependencies { dependencies {
......
...@@ -33,6 +33,8 @@ android { ...@@ -33,6 +33,8 @@ android {
jniLibs.srcDir 'src/main/libs' jniLibs.srcDir 'src/main/libs'
jni.srcDirs = [] // Disable the automatic ndk-build call by Android Studio. jni.srcDirs = [] // Disable the automatic ndk-build call by Android Studio.
} }
testOptions.unitTests.includeAndroidResources = true
} }
dependencies { dependencies {
......
...@@ -26,6 +26,8 @@ android { ...@@ -26,6 +26,8 @@ android {
minSdkVersion project.ext.minSdkVersion minSdkVersion project.ext.minSdkVersion
targetSdkVersion project.ext.targetSdkVersion targetSdkVersion project.ext.targetSdkVersion
} }
testOptions.unitTests.includeAndroidResources = true
} }
dependencies { dependencies {
......
...@@ -33,6 +33,8 @@ android { ...@@ -33,6 +33,8 @@ android {
jniLibs.srcDir 'src/main/libs' jniLibs.srcDir 'src/main/libs'
jni.srcDirs = [] // Disable the automatic ndk-build call by Android Studio. jni.srcDirs = [] // Disable the automatic ndk-build call by Android Studio.
} }
testOptions.unitTests.includeAndroidResources = true
} }
dependencies { dependencies {
......
## Project-wide Gradle settings. ## Project-wide Gradle settings.
android.useDeprecatedNdk=true android.useDeprecatedNdk=true
android.enableUnitTestBinaryResources=true
buildDir=buildout buildDir=buildout
...@@ -53,6 +53,8 @@ android { ...@@ -53,6 +53,8 @@ android {
// testCoverageEnabled = true // testCoverageEnabled = true
// } // }
} }
testOptions.unitTests.includeAndroidResources = true
} }
dependencies { dependencies {
......
...@@ -21,6 +21,7 @@ import android.media.AudioManager; ...@@ -21,6 +21,7 @@ import android.media.AudioManager;
import android.support.annotation.IntDef; import android.support.annotation.IntDef;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi; import android.support.annotation.RequiresApi;
import android.support.annotation.VisibleForTesting;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.Player;
...@@ -195,6 +196,11 @@ public final class AudioFocusManager { ...@@ -195,6 +196,11 @@ public final class AudioFocusManager {
// Internal methods. // Internal methods.
@VisibleForTesting
/* package */ AudioManager.OnAudioFocusChangeListener getFocusListener() {
return focusListener;
}
@PlayerCommand @PlayerCommand
private int handleIdle(boolean playWhenReady) { private int handleIdle(boolean playWhenReady) {
return playWhenReady ? PLAYER_COMMAND_PLAY_WHEN_READY : PLAYER_COMMAND_DO_NOT_PLAY; return playWhenReady ? PLAYER_COMMAND_PLAY_WHEN_READY : PLAYER_COMMAND_DO_NOT_PLAY;
......
...@@ -19,6 +19,7 @@ import static com.google.common.truth.Truth.assertThat; ...@@ -19,6 +19,7 @@ import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import android.content.Context; import android.content.Context;
import android.graphics.SurfaceTexture;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.view.Surface; import android.view.Surface;
import com.google.android.exoplayer2.Player.DiscontinuityReason; import com.google.android.exoplayer2.Player.DiscontinuityReason;
...@@ -2593,8 +2594,8 @@ public final class ExoPlayerTest { ...@@ -2593,8 +2594,8 @@ public final class ExoPlayerTest {
// Internal methods. // Internal methods.
private static ActionSchedule.Builder addSurfaceSwitch(ActionSchedule.Builder builder) { private static ActionSchedule.Builder addSurfaceSwitch(ActionSchedule.Builder builder) {
final Surface surface1 = new Surface(null); final Surface surface1 = new Surface(new SurfaceTexture(/* texName= */ 0));
final Surface surface2 = new Surface(null); final Surface surface2 = new Surface(new SurfaceTexture(/* texName= */ 1));
return builder return builder
.executeRunnable( .executeRunnable(
new PlayerRunnable() { new PlayerRunnable() {
......
...@@ -35,6 +35,8 @@ android { ...@@ -35,6 +35,8 @@ android {
// testCoverageEnabled = true // testCoverageEnabled = true
// } // }
} }
testOptions.unitTests.includeAndroidResources = true
} }
dependencies { dependencies {
......
...@@ -35,6 +35,8 @@ android { ...@@ -35,6 +35,8 @@ android {
// testCoverageEnabled = true // testCoverageEnabled = true
// } // }
} }
testOptions.unitTests.includeAndroidResources = true
} }
dependencies { dependencies {
......
...@@ -35,6 +35,8 @@ android { ...@@ -35,6 +35,8 @@ android {
// testCoverageEnabled = true // testCoverageEnabled = true
// } // }
} }
testOptions.unitTests.includeAndroidResources = true
} }
dependencies { dependencies {
......
...@@ -34,6 +34,8 @@ android { ...@@ -34,6 +34,8 @@ android {
// testCoverageEnabled = true // testCoverageEnabled = true
// } // }
} }
testOptions.unitTests.includeAndroidResources = true
} }
dependencies { dependencies {
......
...@@ -27,6 +27,8 @@ android { ...@@ -27,6 +27,8 @@ android {
targetSdkVersion project.ext.targetSdkVersion targetSdkVersion project.ext.targetSdkVersion
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
} }
testOptions.unitTests.includeAndroidResources = true
} }
dependencies { dependencies {
......
...@@ -33,6 +33,8 @@ android { ...@@ -33,6 +33,8 @@ android {
// See: https://github.com/junit-team/junit4/pull/1187. // See: https://github.com/junit-team/junit4/pull/1187.
disable 'InvalidPackage' disable 'InvalidPackage'
} }
testOptions.unitTests.includeAndroidResources = true
} }
dependencies { dependencies {
......
...@@ -32,6 +32,8 @@ android { ...@@ -32,6 +32,8 @@ android {
// which is not part of Android. // which is not part of Android.
disable 'InvalidPackage' disable 'InvalidPackage'
} }
testOptions.unitTests.includeAndroidResources = true
} }
dependencies { dependencies {
......
...@@ -165,7 +165,7 @@ public final class RobolectricUtil { ...@@ -165,7 +165,7 @@ public final class RobolectricUtil {
public boolean enqueueMessage(Message msg, long when) { public boolean enqueueMessage(Message msg, long when) {
Looper looper = ShadowLooper.getLooperForThread(looperThread); Looper looper = ShadowLooper.getLooperForThread(looperThread);
if (shadowOf(looper) instanceof CustomLooper if (shadowOf(looper) instanceof CustomLooper
&& shadowOf(looper) != ShadowLooper.getShadowMainLooper()) { && shadowOf(looper) != shadowOf(Looper.getMainLooper())) {
((CustomLooper) shadowOf(looper)).addPendingMessage(msg, when); ((CustomLooper) shadowOf(looper)).addPendingMessage(msg, when);
} else { } else {
super.enqueueMessage(msg, when); super.enqueueMessage(msg, when);
...@@ -177,7 +177,7 @@ public final class RobolectricUtil { ...@@ -177,7 +177,7 @@ public final class RobolectricUtil {
public void removeMessages(Handler handler, int what, Object object) { public void removeMessages(Handler handler, int what, Object object) {
Looper looper = ShadowLooper.getLooperForThread(looperThread); Looper looper = ShadowLooper.getLooperForThread(looperThread);
if (shadowOf(looper) instanceof CustomLooper if (shadowOf(looper) instanceof CustomLooper
&& shadowOf(looper) != ShadowLooper.getShadowMainLooper()) { && shadowOf(looper) != shadowOf(Looper.getMainLooper())) {
((CustomLooper) shadowOf(looper)).removeMessages(handler, what, object); ((CustomLooper) shadowOf(looper)).removeMessages(handler, what, object);
} }
} }
...@@ -186,7 +186,7 @@ public final class RobolectricUtil { ...@@ -186,7 +186,7 @@ public final class RobolectricUtil {
public void removeCallbacksAndMessages(Handler handler, Object object) { public void removeCallbacksAndMessages(Handler handler, Object object) {
Looper looper = ShadowLooper.getLooperForThread(looperThread); Looper looper = ShadowLooper.getLooperForThread(looperThread);
if (shadowOf(looper) instanceof CustomLooper if (shadowOf(looper) instanceof CustomLooper
&& shadowOf(looper) != ShadowLooper.getShadowMainLooper()) { && shadowOf(looper) != shadowOf(Looper.getMainLooper())) {
((CustomLooper) shadowOf(looper)).removeMessages(handler, ANY_MESSAGE, object); ((CustomLooper) shadowOf(looper)).removeMessages(handler, ANY_MESSAGE, object);
} }
} }
......
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