Bug 1480920 - Bump versions for Android test runner packages r=jchen
MozReview-Commit-ID: GlC0qJCVl4V
--- a/build.gradle
+++ b/build.gradle
@@ -105,16 +105,19 @@ afterEvaluate {
// Add compiler args for all code except third-party code.
options.compilerArgs += [
// Turn on all warnings, except...
"-Xlint:all",
// Deprecation, because we do use deprecated API for compatibility.
"-Xlint:-deprecation",
// Serial, because we don't use Java serialization.
"-Xlint:-serial",
+ // Classfile, because javac has a bug with MethodParameters attributes
+ // with Java 7. https://bugs.openjdk.java.net/browse/JDK-8190452
+ "-Xlint:-classfile",
// Turn all remaining warnings into errors,
// unless marked by @SuppressWarnings.
"-Werror"]
}
if (project.name == 'app') {
tasks.withType(JavaCompile) {
// Turn off classfile warnings because upon updating to play services 15.0.0
// a warning is being thrown from play-services-base which fails the build
--- a/mobile/android/geckoview/build.gradle
+++ b/mobile/android/geckoview/build.gradle
@@ -195,19 +195,19 @@ dependencies {
implementation "com.android.support:palette-v7:$support_library_version"
testImplementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
testImplementation 'junit:junit:4.12'
testImplementation 'org.robolectric:robolectric:3.8'
testImplementation 'org.mockito:mockito-core:1.10.19'
androidTestImplementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
- androidTestImplementation 'com.android.support.test:runner:0.5'
- androidTestImplementation 'com.android.support.test:rules:0.5'
- androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2'
+ androidTestImplementation 'com.android.support.test:runner:1.0.2'
+ androidTestImplementation 'com.android.support.test:rules:1.0.2'
+ androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
androidTestImplementation "com.android.support:support-annotations:$support_library_version"
}
apply from: "${topsrcdir}/mobile/android/gradle/with_gecko_binaries.gradle"
android.libraryVariants.all { variant ->
// See the notes in mobile/android/app/build.gradle for details on including
// Gecko binaries and the Omnijar.
--- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/GeckoResultTest.java
+++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/GeckoResultTest.java
@@ -26,19 +26,16 @@ import static org.junit.Assert.assertTha
@RunWith(AndroidJUnit4.class)
@MediumTest
public class GeckoResultTest {
private static final long DEFAULT_TIMEOUT = 5000;
private static class MockException extends RuntimeException {
}
- @Rule
- public UiThreadTestRule mUiThreadTestRule = new UiThreadTestRule();
-
private boolean mDone;
private void waitUntilDone() {
assertThat("We should not be done", mDone, equalTo(false));
while (!mDone) {
UiThreadUtils.loopUntilIdle(DEFAULT_TIMEOUT);
}
--- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/rule/GeckoSessionTestRule.java
+++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/rule/GeckoSessionTestRule.java
@@ -1,18 +1,18 @@
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.geckoview.test.rule;
+import org.junit.rules.TestRule;
import org.mozilla.gecko.gfx.GeckoDisplay;
import org.mozilla.geckoview.BuildConfig;
-import org.mozilla.geckoview.GeckoResponse;
import org.mozilla.geckoview.GeckoResult;
import org.mozilla.geckoview.GeckoResult.OnExceptionListener;
import org.mozilla.geckoview.GeckoResult.OnValueListener;
import org.mozilla.geckoview.GeckoRuntime;
import org.mozilla.geckoview.GeckoRuntimeSettings;
import org.mozilla.geckoview.GeckoSession;
import org.mozilla.geckoview.GeckoSessionSettings;
import org.mozilla.geckoview.SessionTextInput;
@@ -37,27 +37,22 @@ import org.junit.runners.model.Statement
import android.app.Instrumentation;
import android.graphics.Point;
import android.graphics.SurfaceTexture;
import android.net.LocalSocketAddress;
import android.os.Build;
import android.os.Bundle;
import android.os.Debug;
-import android.os.Handler;
import android.os.Looper;
-import android.os.Message;
-import android.os.MessageQueue;
import android.os.Process;
import android.os.SystemClock;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.test.InstrumentationRegistry;
-import android.support.test.rule.UiThreadTestRule;
-import android.util.Log;
import android.util.Pair;
import android.view.MotionEvent;
import android.view.Surface;
import java.io.File;
import java.lang.annotation.Annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
@@ -72,28 +67,29 @@ import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.atomic.AtomicReference;
import java.util.regex.Pattern;
import kotlin.jvm.JvmClassMappingKt;
import kotlin.reflect.KClass;
/**
* TestRule that, for each test, sets up a GeckoSession, runs the test on the UI thread,
* and tears down the GeckoSession at the end of the test. The rule also provides methods
* for waiting on particular callbacks to be called, and methods for asserting that
* callbacks are called in the proper order.
*/
-public class GeckoSessionTestRule extends UiThreadTestRule {
+public class GeckoSessionTestRule implements TestRule {
private static final String LOGTAG = "GeckoSessionTestRule";
private static final long DEFAULT_TIMEOUT_MILLIS = 10000;
private static final long DEFAULT_ARM_DEVICE_TIMEOUT_MILLIS = 30000;
private static final long DEFAULT_ARM_EMULATOR_TIMEOUT_MILLIS = 120000;
private static final long DEFAULT_X86_DEVICE_TIMEOUT_MILLIS = 30000;
private static final long DEFAULT_X86_EMULATOR_TIMEOUT_MILLIS = 5000;
private static final long DEFAULT_IDE_DEBUG_TIMEOUT_MILLIS = 86400000;
@@ -1473,33 +1469,45 @@ public class GeckoSessionTestRule extend
mLastWaitEnd = 0;
mTimeoutMillis = 0;
mRDPTabs = null;
mRDPChromeProcess = null;
}
@Override
public Statement apply(final Statement base, final Description description) {
- return super.apply(new Statement() {
+ return new Statement() {
@Override
public void evaluate() throws Throwable {
- try {
- prepareStatement(description);
- base.evaluate();
- performTestEndCheck();
- } finally {
- cleanupStatement();
+ final AtomicReference<Throwable> exceptionRef = new AtomicReference<>();
+ mInstrumentation.runOnMainSync(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ prepareStatement(description);
+ base.evaluate();
+ performTestEndCheck();
+ } catch (Throwable t) {
+ exceptionRef.set(t);
+ } finally {
+ try {
+ cleanupStatement();
+ } catch (Throwable t) {
+ exceptionRef.set(t);
+ }
+ }
+ }
+ });
+
+ Throwable throwable = exceptionRef.get();
+ if (throwable != null) {
+ throw throwable;
}
}
- }, description);
- }
-
- @Override
- protected boolean shouldRunOnUiThread(final Description description) {
- return true;
+ };
}
/**
* Wait until a page load has finished on any session. A session must have started a
* page load since the last wait, or this method will wait indefinitely.
*/
public void waitForPageStop() {
waitForPageStop(/* session */ null);