Bug 1480920 - Bump versions for Android test runner packages r=jchen
☠☠ backed out by 479342879a30 ☠ ☠
authorJames Willcox <snorp@snorp.net>
Fri, 03 Aug 2018 17:30:52 -0500
changeset 430815 d3978309484acd5512a017190a20bc1e2b4a3618
parent 430814 3113161a3af10892ad42dd8bb856ad50987e6fba
child 430816 a35c331a4bbc5103df2553d6dc044f6f01399595
push id106278
push userjwillcox@mozilla.com
push dateThu, 09 Aug 2018 20:05:41 +0000
treeherdermozilla-inbound@d3978309484a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjchen
bugs1480920
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1480920 - Bump versions for Android test runner packages r=jchen MozReview-Commit-ID: GlC0qJCVl4V
build.gradle
mobile/android/geckoview/build.gradle
mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/GeckoResultTest.java
mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/rule/GeckoSessionTestRule.java
mobile/android/geckoview_example/build.gradle
--- a/build.gradle
+++ b/build.gradle
@@ -106,16 +106,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
@@ -24,19 +24,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);
--- a/mobile/android/geckoview_example/build.gradle
+++ b/mobile/android/geckoview_example/build.gradle
@@ -30,16 +30,16 @@ android {
 }
 
 dependencies {
     testImplementation 'junit:junit:4.12'
 
     implementation "com.android.support:support-annotations:$support_library_version"
     implementation "com.android.support:appcompat-v7:$support_library_version"
 
-    androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2'
-    androidTestImplementation 'com.android.support.test:runner:0.5'
+    androidTestImplementation 'com.android.support.test:runner:1.0.2'
+    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
     // Not defining this library again results in test-app assuming 23.1.1, and the following errors:
     // "Conflict with dependency 'com.android.support:support-annotations'. Resolved versions for app (23.4.0) and test app (23.1.1) differ."
     androidTestImplementation "com.android.support:support-annotations:$support_library_version"
 
     implementation project(path: ':geckoview')
 }