зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1676216 - Revert "Bug 1607537: Fix timeouts in ParentCrashTest.crashParent and re-enable the test" r=owlish
The code in this patch is not needed anymore because now we can handle multiple in-app runtimes after Bug 1696460. This reverts commit d49a34c51bc537caffcd559cda07be994105cebb. Differential Revision: https://phabricator.services.mozilla.com/D123980
This commit is contained in:
Родитель
22c6b5887b
Коммит
33356cb6e5
|
@ -20,7 +20,6 @@ import org.junit.rules.TemporaryFolder
|
|||
import org.junit.runner.RunWith
|
||||
import org.mozilla.geckoview.test.TestCrashHandler
|
||||
import org.mozilla.geckoview.test.util.Environment
|
||||
import org.mozilla.geckoview.test.util.RuntimeCreator
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@MediumTest
|
||||
|
@ -35,11 +34,6 @@ class ParentCrashTest {
|
|||
|
||||
@Before
|
||||
fun setup() {
|
||||
// Since this test starts up its own GeckoRuntime via
|
||||
// RemoteGeckoService, we need to shutdown any runtime already running
|
||||
// in the RuntimeCreator.
|
||||
RuntimeCreator.shutdownRuntime()
|
||||
|
||||
val context = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
val intent = Intent(context, RemoteGeckoService::class.java)
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@ import org.mozilla.geckoview.test.TestCrashHandler;
|
|||
|
||||
import static org.mozilla.geckoview.ContentBlocking.SafeBrowsingProvider;
|
||||
|
||||
import android.os.Looper;
|
||||
import android.os.Process;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
@ -21,8 +20,6 @@ import androidx.test.platform.app.InstrumentationRegistry;
|
|||
import android.util.Log;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.FutureTask;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class RuntimeCreator {
|
||||
public static final int TEST_SUPPORT_INITIAL = 0;
|
||||
|
@ -129,20 +126,6 @@ public class RuntimeCreator {
|
|||
sPortDelegate = portDelegate;
|
||||
}
|
||||
|
||||
private static GeckoRuntime.Delegate sShutdownDelegate;
|
||||
|
||||
private static GeckoRuntime.Delegate sWrapperShutdownDelegate = new GeckoRuntime.Delegate() {
|
||||
@Override
|
||||
public void onShutdown() {
|
||||
if (sShutdownDelegate != null) {
|
||||
sShutdownDelegate.onShutdown();
|
||||
return;
|
||||
}
|
||||
|
||||
Process.killProcess(Process.myPid());
|
||||
}
|
||||
};
|
||||
|
||||
@UiThread
|
||||
public static GeckoRuntime getRuntime() {
|
||||
if (sRuntime != null) {
|
||||
|
@ -179,76 +162,8 @@ public class RuntimeCreator {
|
|||
|
||||
registerTestSupport();
|
||||
|
||||
sRuntime.setDelegate(sWrapperShutdownDelegate);
|
||||
sRuntime.setDelegate(() -> Process.killProcess(Process.myPid()));
|
||||
|
||||
return sRuntime;
|
||||
}
|
||||
|
||||
private static final class ShutdownCompleteIndicator implements GeckoRuntime.Delegate {
|
||||
private boolean mDone = false;
|
||||
|
||||
@Override
|
||||
public void onShutdown() {
|
||||
mDone = true;
|
||||
}
|
||||
|
||||
public boolean isDone() {
|
||||
return mDone;
|
||||
}
|
||||
}
|
||||
|
||||
@UiThread
|
||||
private static void shutdownRuntimeInternal(final long timeoutMillis) {
|
||||
if (sRuntime == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final ShutdownCompleteIndicator indicator = new ShutdownCompleteIndicator();
|
||||
sShutdownDelegate = indicator;
|
||||
|
||||
sRuntime.shutdown();
|
||||
|
||||
UiThreadUtils.waitForCondition(() -> indicator.isDone(), timeoutMillis);
|
||||
if (!indicator.isDone()) {
|
||||
throw new RuntimeException("Timed out waiting for GeckoRuntime shutdown to complete");
|
||||
}
|
||||
|
||||
sRuntime = null;
|
||||
sShutdownDelegate = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* ParentCrashTest needs to start a GeckoRuntime inside a separate service in a separate
|
||||
* process from this one. Unfortunately that does not play well with the GeckoRuntime in this
|
||||
* process, since as far as Android is concerned, they are both running inside the same
|
||||
* Application.
|
||||
*
|
||||
* Any test that starts its own GeckoRuntime should call this method during its setup to shut
|
||||
* down any extant GeckoRuntime, thus ensuring only one GeckoRuntime is active at once.
|
||||
*/
|
||||
public static void shutdownRuntime() {
|
||||
// It takes a while to shutdown an existing runtime in debug builds, so
|
||||
// we double the timeout for this method.
|
||||
final long timeoutMillis = 2 * env.getDefaultTimeoutMillis();
|
||||
|
||||
if (Looper.myLooper() == Looper.getMainLooper()) {
|
||||
shutdownRuntimeInternal(timeoutMillis);
|
||||
return;
|
||||
}
|
||||
|
||||
final Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
RuntimeCreator.shutdownRuntimeInternal(timeoutMillis);
|
||||
}
|
||||
};
|
||||
|
||||
final FutureTask<Void> task = new FutureTask<>(runnable, null);
|
||||
InstrumentationRegistry.getInstrumentation().runOnMainSync(task);
|
||||
try {
|
||||
task.get(timeoutMillis, TimeUnit.MILLISECONDS);
|
||||
} catch (final Throwable e) {
|
||||
throw new RuntimeException(e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче