From c83fd7596aec6e4c739ca95b5f519a70440ea574 Mon Sep 17 00:00:00 2001 From: Chris Lord Date: Thu, 2 Feb 2012 09:02:49 +0000 Subject: [PATCH] Bug 717349 - Add checkerboard testing to Robotium. r=jmaher Add functions to Robotium to test for checkerboarding. --- build/mobile/robocop/Driver.java.in | 3 ++ .../mobile/robocop/FennecNativeDriver.java.in | 40 +++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/build/mobile/robocop/Driver.java.in b/build/mobile/robocop/Driver.java.in index 957283a1b305..7ef39ba9c32e 100644 --- a/build/mobile/robocop/Driver.java.in +++ b/build/mobile/robocop/Driver.java.in @@ -69,6 +69,9 @@ public interface Driver { 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 diff --git a/build/mobile/robocop/FennecNativeDriver.java.in b/build/mobile/robocop/FennecNativeDriver.java.in index aa14d2c86e70..d1d440f5809a 100644 --- a/build/mobile/robocop/FennecNativeDriver.java.in +++ b/build/mobile/robocop/FennecNativeDriver.java.in @@ -83,6 +83,8 @@ public class FennecNativeDriver implements Driver { private Method sendGE; private Method _startFrameRecording; private Method _stopFrameRecording; + private Method _startCheckerboardRecording; + private Method _stopCheckerboardRecording; private Method _getPixels; public FennecNativeDriver(Activity activity, Solo robocop){ @@ -110,6 +112,8 @@ public class FennecNativeDriver implements Driver { 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"); @@ -222,6 +226,42 @@ public class FennecNativeDriver implements Driver { 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) {