Bug 717349 - Add checkerboard testing to Robotium. r=jmaher a=akeybl
☠☠ backed out by bdb7d2cdf138 ☠ ☠
authorChris Lord <chrislord.net@gmail.com>
Thu, 02 Feb 2012 09:02:49 +0000
changeset 88347 aeb3e5db799e88c7a800839accf3e7d34a80df3c
parent 88346 dfce8408f9407da0a2f1f96b0998b386a329e5b1
child 88348 0eac67dba10fdf213b0980adb2a62a602575e9bb
push idunknown
push userunknown
push dateunknown
reviewersjmaher, akeybl
bugs717349
milestone12.0a2
Bug 717349 - Add checkerboard testing to Robotium. r=jmaher a=akeybl Add functions to Robotium to test for checkerboarding.
build/mobile/robocop/Driver.java.in
build/mobile/robocop/FennecNativeDriver.java.in
--- a/build/mobile/robocop/Driver.java.in
+++ b/build/mobile/robocop/Driver.java.in
@@ -64,15 +64,18 @@ public interface Driver {
   int getGeckoTop();
   int getGeckoLeft();
   int getGeckoWidth();
   int getGeckoHeight();
 
   void startFrameRecording();
   int stopFrameRecording();
 
+  void startCheckerboardRecording();
+  int stopCheckerboardRecording();
+
   /**
    * Get a copy of the painted content region.
    * @return A 2-D array of pixels (indexed by y, then x). The pixels
    * are in ARGB-8888 format.
    */
   int[][] getPaintedSurface();
 }
--- a/build/mobile/robocop/FennecNativeDriver.java.in
+++ b/build/mobile/robocop/FennecNativeDriver.java.in
@@ -78,16 +78,18 @@ public class FennecNativeDriver implemen
   private Class gel;
   private Class ge;
   private Class gas;
   private Method registerGEL;
   private Method unregisterGEL;
   private Method sendGE;
   private Method _startFrameRecording;
   private Method _stopFrameRecording;
+  private Method _startCheckerboardRecording;
+  private Method _stopCheckerboardRecording;
   private Method _getPixels;
 
   public FennecNativeDriver(Activity activity, Solo robocop){
     this.activity = activity;
     this.solo = robocop;
 
     // Set up table of fennec_ids.
     locators = convertTextToTable(getFile("/mnt/sdcard/fennec_ids.txt"));
@@ -105,16 +107,18 @@ public class FennecNativeDriver implemen
       unregisterGEL = gas.getMethod("unregisterGeckoEventListener", parameters);
       parameters = new Class[1];
       parameters[0] = ge;
       sendGE = gas.getMethod("sendEventToGecko", parameters);
 
       Class gfx = classLoader.loadClass("org.mozilla.gecko.gfx.PanningPerfAPI");
       _startFrameRecording = gfx.getDeclaredMethod("startFrameTimeRecording");
       _stopFrameRecording = gfx.getDeclaredMethod("stopFrameTimeRecording");
+      _startCheckerboardRecording = gfx.getDeclaredMethod("startCheckerboardRecording");
+      _stopCheckerboardRecording = gfx.getDeclaredMethod("stopCheckerboardRecording");
 
       Class layerView = classLoader.loadClass("org.mozilla.gecko.gfx.LayerView");
       _getPixels = layerView.getDeclaredMethod("getPixels");
      } catch (ClassNotFoundException e) {
        e.printStackTrace();
      } catch (SecurityException e) {
        e.printStackTrace();
      } catch (NoSuchMethodException e) {
@@ -213,16 +217,52 @@ public class FennecNativeDriver implemen
       e.printStackTrace();
     } catch (InvocationTargetException e) {
       e.printStackTrace();
     }
 
     return 0;
   }
 
+  public void startCheckerboardRecording() {
+    try {
+      Object [] params = null;
+      _startCheckerboardRecording.invoke(null, params);
+    } catch (IllegalAccessException e) {
+      e.printStackTrace();
+    } catch (InvocationTargetException e) {
+      e.printStackTrace();
+    }
+  }
+
+  public int stopCheckerboardRecording() {
+    Class [] parameters = new Class[1];
+    parameters[0] = null;
+    List checkerboard;
+
+    try {
+      Object [] params = null;
+      checkerboard = (List)_stopCheckerboardRecording.invoke(null, params);
+      Object [] amountarray = checkerboard.toArray();
+      int numIncompleteFrames = 0;
+      for (int i=0; i < amountarray.length; i++) {
+        Float val = (Float)amountarray[i];
+        if (val > 0.0f)
+          numIncompleteFrames++;
+      }
+      return numIncompleteFrames;
+    } catch (IllegalAccessException e) {
+      e.printStackTrace();
+    } catch (InvocationTargetException e) {
+      e.printStackTrace();
+    }
+
+    return 0;
+  }
+
   private GLSurfaceView getSurfaceView() {
     for (View v : solo.getCurrentViews()) {
       if (v instanceof GLSurfaceView) {
         return (GLSurfaceView)v;
       }
     }
     return null;
   }