Bug 1480920 - Bump versions for Android test runner packages r=jchen

This also removes the trivial tests for geckoview_example that were
causing problems.

Differential Revision: https://phabricator.services.mozilla.com/D3991

--HG--
extra : moz-landing-system : lando
This commit is contained in:
James Willcox 2018-08-23 13:12:20 +00:00
parent e6844b61ad
commit e641866f27
8 changed files with 34 additions and 95 deletions

View file

@ -111,6 +111,9 @@ afterEvaluate {
"-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"]

View file

@ -200,9 +200,9 @@ dependencies {
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"
}

View file

@ -29,9 +29,6 @@ public class GeckoResultTest {
private static class MockException extends RuntimeException {
}
@Rule
public UiThreadTestRule mUiThreadTestRule = new UiThreadTestRule();
private boolean mDone;
private void waitUntilDone() {

View file

@ -7,7 +7,6 @@ package org.mozilla.geckoview.test.rule;
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;
@ -32,6 +31,7 @@ import org.hamcrest.Matcher;
import org.json.JSONObject;
import org.junit.rules.ErrorCollector;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
@ -42,17 +42,12 @@ 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;
@ -77,6 +72,7 @@ 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;
@ -88,7 +84,7 @@ import kotlin.reflect.KClass;
* 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;
@ -1478,23 +1474,35 @@ public class GeckoSessionTestRule extends UiThreadTestRule {
@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;
};
}
/**

View file

@ -15,7 +15,6 @@ android {
applicationId "org.mozilla.geckoview_example"
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
@ -30,16 +29,8 @@ 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'
// 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')
}

View file

@ -1,13 +0,0 @@
package org.mozilla.geckoview_example;
import android.app.Application;
import android.test.ApplicationTestCase;
/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
}

View file

@ -1,32 +0,0 @@
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; 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_example;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
@RunWith(AndroidJUnit4.class)
public class GeckoViewActivityTest {
@Rule
public ActivityTestRule<GeckoViewActivity> mActivityRule = new ActivityTestRule<>(GeckoViewActivity.class);
@Test
public void testA() throws InterruptedException {
onView(withId(R.id.gecko_view))
.check(matches(isDisplayed()));
}
}

View file

@ -1,15 +0,0 @@
package org.mozilla.geckoview_example;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* To work on unit tests, switch the Test Artifact in the Build Variants view.
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
}