mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-21 01:05:45 +00:00
Backed out 3 changesets (bug 1456209) for bustage in /builds/worker/workspace/build/src/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java:22 on a CLOSED TREE
Backed out changeset b89f665eed0f (bug 1456209) Backed out changeset 2a11c1864d44 (bug 1456209) Backed out changeset 041289f66ad9 (bug 1456209)
This commit is contained in:
parent
c28467f0a5
commit
35e1d98f27
@ -37,7 +37,7 @@ open class BaseSessionTest(noErrorCollector: Boolean = false) {
|
||||
@get:Rule val sessionRule = GeckoSessionTestRule()
|
||||
|
||||
@get:Rule val errors = ErrorCollector()
|
||||
fun <T> assertThat(reason: String, v: T, m: Matcher<in T>) = sessionRule.checkThat(reason, v, m)
|
||||
fun <T> assertThat(reason: String, v: T, m: Matcher<T>) = sessionRule.assertThat(reason, v, m)
|
||||
|
||||
init {
|
||||
if (!noErrorCollector) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*-
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
* 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
|
||||
|
||||
|
@ -1,25 +1,23 @@
|
||||
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*-
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
* 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
|
||||
|
||||
import org.mozilla.geckoview.GeckoSession
|
||||
import org.mozilla.geckoview.GeckoSessionSettings
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.AssertCalled
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.ClosedSessionAtStart
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.Setting
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.TimeoutException
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.TimeoutMillis
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.WithDisplay
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.WithDevToolsAPI
|
||||
import org.mozilla.geckoview.test.util.Callbacks
|
||||
|
||||
import android.support.test.filters.LargeTest
|
||||
import android.support.test.filters.MediumTest
|
||||
import android.support.test.runner.AndroidJUnit4
|
||||
|
||||
import org.hamcrest.Matchers.*
|
||||
import org.junit.Assume.assumeThat
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
@ -38,7 +36,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
||||
sessionRule.session.isOpen, equalTo(true))
|
||||
}
|
||||
|
||||
@ClosedSessionAtStart
|
||||
@GeckoSessionTestRule.ClosedSessionAtStart
|
||||
@Test fun getSession_closedSession() {
|
||||
assertThat("Session is closed", sessionRule.session.isOpen, equalTo(false))
|
||||
}
|
||||
@ -60,8 +58,9 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
||||
equalTo(true))
|
||||
}
|
||||
|
||||
@Test(expected = TimeoutException::class)
|
||||
@Test(expected = AssertionError::class)
|
||||
@TimeoutMillis(1000)
|
||||
@LargeTest
|
||||
fun noPendingCallbacks() {
|
||||
// Make sure we don't have unexpected pending callbacks at the start of a test.
|
||||
sessionRule.waitUntilCalled(object : Callbacks.All {})
|
||||
@ -795,9 +794,10 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
||||
assertThat("New session has same settings", newSession.settings, equalTo(settings))
|
||||
}
|
||||
|
||||
@Test(expected = TimeoutException::class)
|
||||
@Test(expected = AssertionError::class)
|
||||
@TimeoutMillis(1000)
|
||||
@ClosedSessionAtStart
|
||||
@LargeTest
|
||||
@GeckoSessionTestRule.ClosedSessionAtStart
|
||||
fun noPendingCallbacks_withSpecificSession() {
|
||||
sessionRule.createOpenSession()
|
||||
// Make sure we don't have unexpected pending callbacks after opening a session.
|
||||
@ -1046,11 +1046,8 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
||||
assertThat("Callback count should be correct", counter, equalTo(2))
|
||||
}
|
||||
|
||||
@WithDisplay(width = 10, height = 10)
|
||||
@GeckoSessionTestRule.WithDisplay(width = 10, height = 10)
|
||||
@Test fun synthesizeTap() {
|
||||
// synthesizeTap is unreliable under e10s.
|
||||
assumeThat(sessionRule.env.isMultiprocess, equalTo(false))
|
||||
|
||||
sessionRule.session.loadTestPath(CLICK_TO_RELOAD_HTML_PATH)
|
||||
sessionRule.session.waitForPageStop()
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*-
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
* 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
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*-
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
* 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
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*-
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
* 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
|
||||
|
||||
|
@ -1,12 +1,9 @@
|
||||
/* -*- 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/. */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
package org.mozilla.geckoview.test.rule;
|
||||
|
||||
import org.mozilla.gecko.gfx.GeckoDisplay;
|
||||
import org.mozilla.geckoview.BuildConfig;
|
||||
import org.mozilla.geckoview.GeckoRuntime;
|
||||
import org.mozilla.geckoview.GeckoRuntimeSettings;
|
||||
import org.mozilla.geckoview.GeckoSession;
|
||||
@ -14,7 +11,7 @@ import org.mozilla.geckoview.GeckoSessionSettings;
|
||||
import org.mozilla.geckoview.test.util.Callbacks;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import org.hamcrest.Matcher;
|
||||
|
||||
@ -25,7 +22,6 @@ import org.junit.runners.model.Statement;
|
||||
import android.app.Instrumentation;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.SurfaceTexture;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Debug;
|
||||
import android.os.Handler;
|
||||
@ -37,7 +33,6 @@ 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;
|
||||
@ -73,15 +68,9 @@ import kotlin.reflect.KClass;
|
||||
* callbacks are called in the proper order.
|
||||
*/
|
||||
public class GeckoSessionTestRule extends UiThreadTestRule {
|
||||
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;
|
||||
|
||||
private static final long DEFAULT_DEBUG_TIMEOUT_MILLIS = 86400000;
|
||||
public static final String APK_URI_PREFIX = "resource://android/";
|
||||
|
||||
private static final Method sOnLocationChange;
|
||||
@ -99,10 +88,8 @@ public class GeckoSessionTestRule extends UiThreadTestRule {
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify the timeout for any of the wait methods, in milliseconds, relative to
|
||||
* {@link #DEFAULT_TIMEOUT_MILLIS}. When the default timeout scales to account
|
||||
* for differences in the device under test, the timeout value here will be
|
||||
* scaled as well. Can be used on classes or methods.
|
||||
* Specify the timeout for any of the wait methods, in milliseconds. Can be used
|
||||
* on classes or methods.
|
||||
*/
|
||||
@Target({ElementType.METHOD, ElementType.TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@ -186,11 +173,12 @@ public class GeckoSessionTestRule extends UiThreadTestRule {
|
||||
settings.setInt((GeckoSessionSettings.Key<Integer>) mKey,
|
||||
(Integer) GeckoSessionSettings.class.getField(value)
|
||||
.get(null));
|
||||
return;
|
||||
} catch (final NoSuchFieldException | IllegalAccessException |
|
||||
ClassCastException e) {
|
||||
settings.setInt((GeckoSessionSettings.Key<Integer>) mKey,
|
||||
Integer.valueOf(value));
|
||||
}
|
||||
settings.setInt((GeckoSessionSettings.Key<Integer>) mKey,
|
||||
Integer.valueOf(value));
|
||||
} else if (String.class.equals(mType)) {
|
||||
settings.setString((GeckoSessionSettings.Key<String>) mKey, value);
|
||||
} else {
|
||||
@ -258,12 +246,6 @@ public class GeckoSessionTestRule extends UiThreadTestRule {
|
||||
int[] order() default 0;
|
||||
}
|
||||
|
||||
public static class TimeoutException extends RuntimeException {
|
||||
public TimeoutException(final String detailMessage) {
|
||||
super(detailMessage);
|
||||
}
|
||||
}
|
||||
|
||||
public static class CallRequirement {
|
||||
public final boolean allowed;
|
||||
public final int count;
|
||||
@ -429,18 +411,6 @@ public class GeckoSessionTestRule extends UiThreadTestRule {
|
||||
public boolean isDebugging() {
|
||||
return Debug.isDebuggerConnected();
|
||||
}
|
||||
|
||||
public boolean isEmulator() {
|
||||
return "generic".equals(Build.DEVICE) || Build.DEVICE.startsWith("generic_");
|
||||
}
|
||||
|
||||
public boolean isDebugBuild() {
|
||||
return BuildConfig.DEBUG_BUILD;
|
||||
}
|
||||
|
||||
public String getCPUArch() {
|
||||
return BuildConfig.ANDROID_CPU_ARCH;
|
||||
}
|
||||
}
|
||||
|
||||
protected class CallbackDelegates {
|
||||
@ -539,7 +509,6 @@ public class GeckoSessionTestRule extends UiThreadTestRule {
|
||||
|
||||
private static final List<Class<?>> CALLBACK_CLASSES = Arrays.asList(getCallbackClasses());
|
||||
private static GeckoRuntime sRuntime;
|
||||
private static long sLongestWait;
|
||||
|
||||
public final Environment env = new Environment();
|
||||
|
||||
@ -595,27 +564,27 @@ public class GeckoSessionTestRule extends UiThreadTestRule {
|
||||
* @param value Value to check
|
||||
* @param matcher Matcher for checking the value
|
||||
*/
|
||||
public <T> void checkThat(final String reason, final T value, final Matcher<? super T> matcher) {
|
||||
public <T> void assertThat(final String reason, final T value, final Matcher<T> matcher) {
|
||||
if (mErrorCollector != null) {
|
||||
mErrorCollector.checkThat(reason, value, matcher);
|
||||
} else {
|
||||
assertThat(reason, value, matcher);
|
||||
org.junit.Assert.assertThat(reason, value, matcher);
|
||||
}
|
||||
}
|
||||
|
||||
private void assertAllowMoreCalls(final MethodCall call) {
|
||||
final int count = call.getCount();
|
||||
if (count != -1) {
|
||||
checkThat(call.method.getName() + " call count should be within limit",
|
||||
call.getCurrentCount() + 1, lessThanOrEqualTo(count));
|
||||
assertThat(call.method.getName() + " call count should be within limit",
|
||||
call.getCurrentCount() + 1, lessThanOrEqualTo(count));
|
||||
}
|
||||
}
|
||||
|
||||
private void assertOrder(final MethodCall call, final int order) {
|
||||
final int newOrder = call.getOrder();
|
||||
if (newOrder != 0) {
|
||||
checkThat(call.method.getName() + " should be in order",
|
||||
newOrder, greaterThanOrEqualTo(order));
|
||||
assertThat(call.method.getName() + " should be in order",
|
||||
newOrder, greaterThanOrEqualTo(order));
|
||||
}
|
||||
}
|
||||
|
||||
@ -625,14 +594,15 @@ public class GeckoSessionTestRule extends UiThreadTestRule {
|
||||
}
|
||||
final int count = call.getCount();
|
||||
if (count == 0) {
|
||||
checkThat(call.method.getName() + " should not be called",
|
||||
call.getCurrentCount(), equalTo(0));
|
||||
assertThat(call.method.getName() + " should not be called",
|
||||
call.getCurrentCount(), equalTo(0));
|
||||
} else if (count == -1) {
|
||||
checkThat(call.method.getName() + " should be called",
|
||||
call.getCurrentCount(), greaterThan(0));
|
||||
assertThat(call.method.getName() + " should be called",
|
||||
call.getCurrentCount(), greaterThan(0));
|
||||
} else {
|
||||
checkThat(call.method.getName() + " should be called specified number of times",
|
||||
call.getCurrentCount(), equalTo(count));
|
||||
assertThat(call.method.getName() +
|
||||
" should be called specified number of times",
|
||||
call.getCurrentCount(), equalTo(count));
|
||||
}
|
||||
}
|
||||
|
||||
@ -668,10 +638,7 @@ public class GeckoSessionTestRule extends UiThreadTestRule {
|
||||
final GeckoSessionSettings settings) {
|
||||
for (final Annotation annotation : annotations) {
|
||||
if (TimeoutMillis.class.equals(annotation.annotationType())) {
|
||||
// Scale timeout based on the default timeout to account for the device under test.
|
||||
final long value = ((TimeoutMillis) annotation).value();
|
||||
final long timeout = value * getDefaultTimeoutMillis() / DEFAULT_TIMEOUT_MILLIS;
|
||||
mTimeoutMillis = Math.max(timeout, 1000);
|
||||
mTimeoutMillis = Math.max(((TimeoutMillis) annotation).value(), 100);
|
||||
} else if (Setting.class.equals(annotation.annotationType())) {
|
||||
((Setting) annotation).key().set(settings, ((Setting) annotation).value());
|
||||
} else if (Setting.List.class.equals(annotation.annotationType())) {
|
||||
@ -698,19 +665,10 @@ public class GeckoSessionTestRule extends UiThreadTestRule {
|
||||
return new RuntimeException(cause != null ? cause : e);
|
||||
}
|
||||
|
||||
private long getDefaultTimeoutMillis() {
|
||||
if ("x86".equals(env.getCPUArch())) {
|
||||
return env.isEmulator() ? DEFAULT_X86_EMULATOR_TIMEOUT_MILLIS
|
||||
: DEFAULT_X86_DEVICE_TIMEOUT_MILLIS;
|
||||
}
|
||||
return env.isEmulator() ? DEFAULT_ARM_EMULATOR_TIMEOUT_MILLIS
|
||||
: DEFAULT_ARM_DEVICE_TIMEOUT_MILLIS;
|
||||
}
|
||||
|
||||
protected void prepareStatement(final Description description) throws Throwable {
|
||||
final GeckoSessionSettings settings = new GeckoSessionSettings(mDefaultSettings);
|
||||
mTimeoutMillis = env.isDebugging() ? DEFAULT_IDE_DEBUG_TIMEOUT_MILLIS
|
||||
: getDefaultTimeoutMillis();
|
||||
mTimeoutMillis = !env.isDebugging() ? DEFAULT_TIMEOUT_MILLIS
|
||||
: DEFAULT_DEBUG_TIMEOUT_MILLIS;
|
||||
mClosedSession = false;
|
||||
|
||||
applyAnnotations(Arrays.asList(description.getTestClass().getAnnotations()), settings);
|
||||
@ -741,8 +699,6 @@ public class GeckoSessionTestRule extends UiThreadTestRule {
|
||||
if (!ignore) {
|
||||
assertThat("Callbacks must be on UI thread",
|
||||
Looper.myLooper(), equalTo(Looper.getMainLooper()));
|
||||
assertThat("Callback first argument must be session object",
|
||||
args, arrayWithSize(greaterThan(0)));
|
||||
assertThat("Callback first argument must be session object",
|
||||
args[0], instanceOf(GeckoSession.class));
|
||||
|
||||
@ -811,12 +767,21 @@ public class GeckoSessionTestRule extends UiThreadTestRule {
|
||||
* @param session Session to open.
|
||||
*/
|
||||
public void openSession(final GeckoSession session) {
|
||||
session.open(sRuntime);
|
||||
waitForInitialLoad(session);
|
||||
}
|
||||
final boolean e10s = session.getSettings().getBoolean(
|
||||
GeckoSessionSettings.USE_MULTIPROCESS);
|
||||
|
||||
private void waitForInitialLoad(final GeckoSession session) {
|
||||
// We receive an initial about:blank load; don't expose that to the test.
|
||||
if (e10s) {
|
||||
// Give any pending calls a chance to catch up.
|
||||
loopUntilIdle(/* timeout */ 0);
|
||||
}
|
||||
|
||||
session.open(sRuntime);
|
||||
|
||||
if (!e10s) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Under e10s, we receive an initial about:blank load; don't expose that to the test.
|
||||
// The about:blank load is bounded by onLocationChange and onPageStop calls,
|
||||
// so find the first about:blank onLocationChange, then the next onPageStop,
|
||||
// and ignore everything in-between from that session.
|
||||
@ -842,7 +807,7 @@ public class GeckoSessionTestRule extends UiThreadTestRule {
|
||||
};
|
||||
|
||||
do {
|
||||
loopUntilIdle(getDefaultTimeoutMillis());
|
||||
loopUntilIdle(mTimeoutMillis);
|
||||
} while (mCallRecordHandler != null);
|
||||
|
||||
} finally {
|
||||
@ -945,7 +910,7 @@ public class GeckoSessionTestRule extends UiThreadTestRule {
|
||||
final Runnable timeoutRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
throw new TimeoutException("Timed out after " + timeout + "ms");
|
||||
fail("Timed out after " + timeout + "ms");
|
||||
}
|
||||
};
|
||||
if (timeout > 0) {
|
||||
@ -954,7 +919,6 @@ public class GeckoSessionTestRule extends UiThreadTestRule {
|
||||
queue.addIdleHandler(idleHandler);
|
||||
}
|
||||
|
||||
final long startTime = SystemClock.uptimeMillis();
|
||||
try {
|
||||
while (true) {
|
||||
final Message msg;
|
||||
@ -968,7 +932,7 @@ public class GeckoSessionTestRule extends UiThreadTestRule {
|
||||
break;
|
||||
} else if (msg.getTarget() == null) {
|
||||
looper.quit();
|
||||
return;
|
||||
break;
|
||||
}
|
||||
msg.getTarget().dispatchMessage(msg);
|
||||
|
||||
@ -977,12 +941,6 @@ public class GeckoSessionTestRule extends UiThreadTestRule {
|
||||
queue.addIdleHandler(idleHandler);
|
||||
}
|
||||
}
|
||||
|
||||
final long waitDuration = SystemClock.uptimeMillis() - startTime;
|
||||
if (waitDuration > sLongestWait) {
|
||||
sLongestWait = waitDuration;
|
||||
Log.i(LOGTAG, "New longest wait: " + waitDuration + "ms");
|
||||
}
|
||||
} finally {
|
||||
if (timeout > 0) {
|
||||
handler.removeCallbacks(timeoutRunnable);
|
||||
@ -1181,16 +1139,16 @@ public class GeckoSessionTestRule extends UiThreadTestRule {
|
||||
// instead of through GeckoSession directly, so that we can still record calls even with
|
||||
// custom handlers set.
|
||||
for (final Class<?> ifce : CALLBACK_CLASSES) {
|
||||
final Object callback;
|
||||
try {
|
||||
callback = getCallbackGetter(ifce).invoke(session == null ? mMainSession : session);
|
||||
assertThat("Callbacks should be set through" +
|
||||
" GeckoSessionTestRule delegate methods",
|
||||
getCallbackGetter(ifce).invoke(session == null ? mMainSession
|
||||
: session),
|
||||
sameInstance(mCallbackProxy));
|
||||
} catch (final NoSuchMethodException | IllegalAccessException |
|
||||
InvocationTargetException e) {
|
||||
InvocationTargetException e) {
|
||||
throw unwrapRuntimeException(e);
|
||||
}
|
||||
assertThat(ifce.getSimpleName() + " callbacks should be " +
|
||||
"accessed through GeckoSessionTestRule delegate methods",
|
||||
callback, sameInstance(mCallbackProxy));
|
||||
}
|
||||
|
||||
boolean calledAny = false;
|
||||
@ -1279,8 +1237,8 @@ public class GeckoSessionTestRule extends UiThreadTestRule {
|
||||
}
|
||||
|
||||
final int i = methodCalls.indexOf(record.methodCall);
|
||||
checkThat(record.method.getName() + " should be found",
|
||||
i, greaterThanOrEqualTo(0));
|
||||
assertThat(record.method.getName() + " should be found",
|
||||
i, greaterThanOrEqualTo(0));
|
||||
|
||||
final MethodCall methodCall = methodCalls.get(i);
|
||||
assertAllowMoreCalls(methodCall);
|
||||
@ -1306,9 +1264,9 @@ public class GeckoSessionTestRule extends UiThreadTestRule {
|
||||
}
|
||||
}
|
||||
|
||||
checkThat("Should have called one of " +
|
||||
Arrays.toString(callback.getClass().getInterfaces()),
|
||||
calledAny, equalTo(true));
|
||||
assertThat("Should have called one of " +
|
||||
Arrays.toString(callback.getClass().getInterfaces()),
|
||||
calledAny, equalTo(true));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1326,7 +1284,7 @@ public class GeckoSessionTestRule extends UiThreadTestRule {
|
||||
/**
|
||||
* Delegate implemented interfaces to the specified callback object for all sessions,
|
||||
* for the rest of the test. Only GeckoSession callback interfaces are supported.
|
||||
* Delegates for {@code delegateUntilTestEnd} can be temporarily overridden by
|
||||
* Delegates for {@link #delegateUntilTestEnd} can be temporarily overridden by
|
||||
* delegates for {@link #delegateDuringNextWait}.
|
||||
*
|
||||
* @param callback Callback object, or null to clear all previously-set delegates.
|
||||
@ -1352,7 +1310,7 @@ public class GeckoSessionTestRule extends UiThreadTestRule {
|
||||
/**
|
||||
* Delegate implemented interfaces to the specified callback object for all sessions,
|
||||
* during the next wait. Only GeckoSession callback interfaces are supported.
|
||||
* Delegates for {@code delegateDuringNextWait} can temporarily take precedence over
|
||||
* Delegates for {@link #delegateDuringNextWait} can temporarily take precedence over
|
||||
* delegates for {@link #delegateUntilTestEnd}.
|
||||
*
|
||||
* @param callback Callback object, or null to clear all previously-set delegates.
|
||||
@ -1472,8 +1430,7 @@ public class GeckoSessionTestRule extends UiThreadTestRule {
|
||||
* @param values Input array
|
||||
* @return Value from input array indexed by the current call counter.
|
||||
*/
|
||||
@SafeVarargs
|
||||
public final <T> T forEachCall(T... values) {
|
||||
public <T> T forEachCall(T... values) {
|
||||
assertThat("Should be in a method call", mCurrentMethodCall, notNullValue());
|
||||
return values[Math.min(mCurrentMethodCall.getCurrentCount(), values.length) - 1];
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
/* -*- 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/. */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
package org.mozilla.geckoview.test.util
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user