Bug 1307816 - 11. Use GeckoThread for waiting on Gecko; r=esawin

Right now we send a "process-gecko-events" message to
GeckoInputConnection in order to wait on Gecko during testing. However,
now we have GeckoThread.waitOnGecko() to do that, so we can just use
that directly.
This commit is contained in:
Jim Chen 2016-10-25 12:28:54 -04:00
Родитель 6044706d5d
Коммит 7aeb565019
3 изменённых файлов: 14 добавлений и 38 удалений

Просмотреть файл

@ -24,7 +24,6 @@ import android.content.res.Configuration;
import android.graphics.Matrix;
import android.graphics.RectF;
import android.media.AudioManager;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.SystemClock;
@ -172,29 +171,6 @@ class GeckoInputConnection
return true;
}
@Override
public boolean performPrivateCommand(final String action, final Bundle data) {
switch (action) {
case "process-gecko-events":
// Process all currently pending Gecko thread events before returning.
final Editable editable = getEditable();
if (editable == null) {
return false;
}
// Removing an invalid span is essentially a no-op, but it does force the
// current thread to wait for the Gecko thread when we call length(), in order
// to process the removeSpan event. Once Gecko thread processes the removeSpan
// event, all previous events in the Gecko event queue would have been
// processed as well.
editable.removeSpan(null);
editable.length();
return true;
}
return false;
}
@Override
public ExtractedText getExtractedText(ExtractedTextRequest req, int flags) {
if (req == null)

Просмотреть файл

@ -10,6 +10,7 @@ import static org.mozilla.gecko.tests.helpers.AssertionHelper.fAssertNotSame;
import static org.mozilla.gecko.tests.helpers.AssertionHelper.fAssertSame;
import static org.mozilla.gecko.tests.helpers.AssertionHelper.fAssertTrue;
import org.mozilla.gecko.GeckoThread;
import org.mozilla.gecko.R;
import org.mozilla.gecko.tests.UITestContext;
import org.mozilla.gecko.tests.helpers.FrameworkHelper;
@ -118,12 +119,11 @@ public class GeckoViewComponent extends BaseComponent {
* Processes pending events on the Gecko thread before returning.
* Must be called on the input connection thread during a test.
*/
protected void processGeckoEvents(final InputConnection ic) {
protected void processGeckoEvents() {
fAssertSame("Should be called on input connection thread",
Looper.myLooper(), inputConnectionHandler.getLooper());
fAssertTrue("Should be able to process Gecko events",
ic.performPrivateCommand("process-gecko-events", null));
GeckoThread.waitOnGecko();
}
private static ExtractedText getExtractedText(final InputConnection ic) {

Просмотреть файл

@ -191,7 +191,7 @@ public class testInputConnection extends JavascriptBridgeTest {
assertTextAndSelectionAt("Can set the composing text", ic, "bad", 3);
getJS().asyncCall("test_reflush_changes");
// Wait for text change notifications to come in.
processGeckoEvents(ic);
processGeckoEvents();
assertTextAndSelectionAt("Can re-flush text changes", ic, "good", 4);
ic.setComposingText("done", 1);
assertTextAndSelectionAt("Can update composition after re-flushing", ic, "done", 4);
@ -206,7 +206,7 @@ public class testInputConnection extends JavascriptBridgeTest {
assertTextAndSelectionAt("Can set the composing text", ic, "foobar", 6);
getJS().asyncCall("test_set_selection");
// Wait for text change notifications to come in.
processGeckoEvents(ic);
processGeckoEvents();
assertTextAndSelectionAt("Can select after committing", ic, "foobar", 3);
ic.setComposingText("barfoo", 1);
assertTextAndSelectionAt("Can compose after selecting", ic, "barfoo", 6);
@ -244,7 +244,7 @@ public class testInputConnection extends JavascriptBridgeTest {
assertTextAndSelectionAt("Can clear text", ic, "", 0);
// Make sure we don't leave behind stale events for the following test.
processGeckoEvents(ic);
processGeckoEvents();
processInputConnectionEvents();
}
}
@ -275,21 +275,21 @@ public class testInputConnection extends JavascriptBridgeTest {
// and the input connection thread. Therefore, to ensure these events are
// issued and to ensure the bug appears, we have to process all Gecko events,
// then all input connection events, and finally all Gecko events again.
processGeckoEvents(ic);
processGeckoEvents();
processInputConnectionEvents();
processGeckoEvents(ic);
processGeckoEvents();
assertTextAndSelectionAt("Can set composing region (resetting)", ic, "foo", 3);
ic.setComposingText("foobar", 1);
processGeckoEvents(ic);
processGeckoEvents();
processInputConnectionEvents();
processGeckoEvents(ic);
processGeckoEvents();
assertTextAndSelectionAt("Can change composing text (resetting)", ic, "foobar", 6);
ic.setComposingText("baz", 1);
processGeckoEvents(ic);
processGeckoEvents();
processInputConnectionEvents();
processGeckoEvents(ic);
processGeckoEvents();
assertTextAndSelectionAt("Can reset composing text (resetting)", ic, "baz", 3);
ic.finishComposingText();
@ -299,7 +299,7 @@ public class testInputConnection extends JavascriptBridgeTest {
assertTextAndSelectionAt("Can clear text", ic, "", 0);
// Make sure we don't leave behind stale events for the following test.
processGeckoEvents(ic);
processGeckoEvents();
processInputConnectionEvents();
}
}
@ -329,7 +329,7 @@ public class testInputConnection extends JavascriptBridgeTest {
assertTextAndSelectionAt("Can handle hiding input", ic, "foo", 3);
// Make sure we don't leave behind stale events for the following test.
processGeckoEvents(ic);
processGeckoEvents();
processInputConnectionEvents();
}
}