Bug 737411 - Robocop: update reflection references; r=kats

This commit is contained in:
Geoff Brown 2012-03-22 13:35:19 -04:00
parent a41e5d0dfb
commit da09399809
9 changed files with 45 additions and 11 deletions

View File

@ -100,9 +100,9 @@ public class FennecNativeActions implements Actions {
parameters[0] = mGe; parameters[0] = mGe;
mSendGE = mGas.getMethod("sendEventToGecko", parameters); mSendGE = mGas.getMethod("sendEventToGecko", parameters);
mGetLayerClient = activity.getClass().getMethod("getSoftwareLayerClient"); mGetLayerClient = activity.getClass().getMethod("getLayerClient");
Class gslc = mClassLoader.loadClass("org.mozilla.gecko.gfx.GeckoSoftwareLayerClient"); Class gslc = mClassLoader.loadClass("org.mozilla.gecko.gfx.GeckoLayerClient");
mDrawListener = mClassLoader.loadClass("org.mozilla.gecko.gfx.GeckoSoftwareLayerClient$DrawListener"); mDrawListener = mClassLoader.loadClass("org.mozilla.gecko.gfx.GeckoLayerClient$DrawListener");
mSetDrawListener = gslc.getDeclaredMethod("setDrawListener", mDrawListener); mSetDrawListener = gslc.getDeclaredMethod("setDrawListener", mDrawListener);
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
e.printStackTrace(); e.printStackTrace();

View File

@ -284,17 +284,22 @@ public class FennecNativeDriver implements Driver {
return 0.0f; return 0.0f;
} }
private GLSurfaceView getSurfaceView() { private View getSurfaceView() {
for (View v : mSolo.getCurrentViews()) { try {
if (v instanceof GLSurfaceView) { Class c = Class.forName("org.mozilla.gecko.gfx.LayerView");
return (GLSurfaceView)v; for (View v : mSolo.getCurrentViews()) {
if (c.isInstance(v)) {
return v;
}
} }
} catch (ClassNotFoundException e) {
e.printStackTrace();
} }
return null; return null;
} }
public PaintedSurface getPaintedSurface() { public PaintedSurface getPaintedSurface() {
GLSurfaceView view = getSurfaceView(); View view = getSurfaceView();
if (view == null) { if (view == null) {
return null; return null;
} }

View File

@ -2784,6 +2784,7 @@ abstract public class GeckoApp
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Tab:Add", args.toString())); GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Tab:Add", args.toString()));
} }
/* This method is referenced by Robocop via reflection. */
public GeckoLayerClient getLayerClient() { return mLayerClient; } public GeckoLayerClient getLayerClient() { return mLayerClient; }
public LayerController getLayerController() { return mLayerController; } public LayerController getLayerController() { return mLayerController; }

View File

@ -372,6 +372,7 @@ public class GeckoAppShell
putLocaleEnv(); putLocaleEnv();
} }
/* This method is referenced by Robocop via reflection. */
public static void loadSQLiteLibs(Context context, String apkName) { public static void loadSQLiteLibs(Context context, String apkName) {
if (sSQLiteLibsLoaded) if (sSQLiteLibsLoaded)
return; return;
@ -482,6 +483,7 @@ public class GeckoAppShell
} catch (NoSuchElementException e) {} } catch (NoSuchElementException e) {}
} }
/* This method is referenced by Robocop via reflection. */
public static void sendEventToGecko(GeckoEvent e) { public static void sendEventToGecko(GeckoEvent e) {
if (GeckoApp.checkLaunchState(GeckoApp.LaunchState.GeckoRunning)) { if (GeckoApp.checkLaunchState(GeckoApp.LaunchState.GeckoRunning)) {
notifyGeckoOfEvent(e); notifyGeckoOfEvent(e);
@ -1663,6 +1665,7 @@ public class GeckoAppShell
} }
} }
/* This method is referenced by Robocop via reflection. */
public static void registerGeckoEventListener(String event, GeckoEventListener listener) { public static void registerGeckoEventListener(String event, GeckoEventListener listener) {
if (mEventListeners == null) if (mEventListeners == null)
mEventListeners = new HashMap<String, ArrayList<GeckoEventListener>>(); mEventListeners = new HashMap<String, ArrayList<GeckoEventListener>>();
@ -1692,6 +1695,7 @@ public class GeckoAppShell
} }
} }
/* This method is referenced by Robocop via reflection. */
public static void unregisterGeckoEventListener(String event, GeckoEventListener listener) { public static void unregisterGeckoEventListener(String event, GeckoEventListener listener) {
if (mEventListeners == null) if (mEventListeners == null)
return; return;

View File

@ -63,6 +63,9 @@ import android.util.Log;
* Fields have different meanings depending on the event type. * Fields have different meanings depending on the event type.
*/ */
/* This class is referenced by Robocop via reflection; use care when
* modifying the signature.
*/
public class GeckoEvent { public class GeckoEvent {
private static final String LOGTAG = "GeckoEvent"; private static final String LOGTAG = "GeckoEvent";

View File

@ -39,6 +39,9 @@ package org.mozilla.gecko;
import org.json.JSONObject; import org.json.JSONObject;
/* This class is referenced by Robocop via reflection; use care when
* modifying the signature.
*/
public interface GeckoEventListener { public interface GeckoEventListener {
public void handleMessage(String event, JSONObject message); public void handleMessage(String event, JSONObject message);
} }

View File

@ -62,6 +62,8 @@ import java.util.LinkedList;
* *
* This view delegates to LayerRenderer to actually do the drawing. Its role is largely that of a * This view delegates to LayerRenderer to actually do the drawing. Its role is largely that of a
* mediator between the LayerRenderer and the LayerController. * mediator between the LayerRenderer and the LayerController.
*
* Note that LayerView is accessed by Robocop via reflection.
*/ */
public class LayerView extends FlexibleGLSurfaceView { public class LayerView extends FlexibleGLSurfaceView {
private Context mContext; private Context mContext;

View File

@ -113,6 +113,7 @@ public class SQLiteBridge {
return rawQuery(sb.toString(), selectionArgs); return rawQuery(sb.toString(), selectionArgs);
} }
/* This method is referenced by Robocop via reflection. */
public Cursor rawQuery(String sql, String[] selectionArgs) public Cursor rawQuery(String sql, String[] selectionArgs)
throws SQLiteBridgeException { throws SQLiteBridgeException {
return internalQuery(sql, selectionArgs); return internalQuery(sql, selectionArgs);

View File

@ -10,12 +10,22 @@ class PixelTest extends BaseTest {
Actions.RepeatedEventExpecter paintExpecter = mActions.expectPaint(); Actions.RepeatedEventExpecter paintExpecter = mActions.expectPaint();
loadUrl(url); loadUrl(url);
paintExpecter.blockUntilClear(PAINT_CLEAR_DELAY); paintExpecter.blockUntilClear(PAINT_CLEAR_DELAY);
return mDriver.getPaintedSurface(); PaintedSurface p = mDriver.getPaintedSurface();
if (p == null) {
mAsserter.ok(p != null, "checking that painted surface loaded",
"painted surface loaded");
}
return p;
} }
protected final PaintedSurface waitForPaint(Actions.RepeatedEventExpecter expecter) { protected final PaintedSurface waitForPaint(Actions.RepeatedEventExpecter expecter) {
expecter.blockUntilClear(PAINT_CLEAR_DELAY); expecter.blockUntilClear(PAINT_CLEAR_DELAY);
return mDriver.getPaintedSurface(); PaintedSurface p = mDriver.getPaintedSurface();
if (p == null) {
mAsserter.ok(p != null, "checking that painted surface loaded",
"painted surface loaded");
}
return p;
} }
protected final PaintedSurface waitWithNoPaint(Actions.RepeatedEventExpecter expecter) { protected final PaintedSurface waitWithNoPaint(Actions.RepeatedEventExpecter expecter) {
@ -25,7 +35,12 @@ class PixelTest extends BaseTest {
ie.printStackTrace(); ie.printStackTrace();
} }
mAsserter.is(expecter.eventReceived(), false, "Checking gecko didn't draw unnecessarily"); mAsserter.is(expecter.eventReceived(), false, "Checking gecko didn't draw unnecessarily");
return mDriver.getPaintedSurface(); PaintedSurface p = mDriver.getPaintedSurface();
if (p == null) {
mAsserter.ok(p != null, "checking that painted surface loaded",
"painted surface loaded");
}
return p;
} }
// this matches the algorithm in robocop_boxes.html // this matches the algorithm in robocop_boxes.html