Bug 744094 - Log all robocop-internal exceptions as errors to the error log. r=jmaher

This commit is contained in:
Kartikaya Gupta 2012-04-10 14:20:55 -05:00
parent c40a96a26b
commit a6d539e35e
4 changed files with 51 additions and 49 deletions

View File

@ -63,6 +63,8 @@ import org.json.*;
import com.jayway.android.robotium.solo.Solo;
import static @ANDROID_PACKAGE_NAME@.FennecNativeDriver.LogLevel;
public class FennecNativeActions implements Actions {
private Solo mSolo;
private Instrumentation mInstr;
@ -104,15 +106,15 @@ public class FennecNativeActions implements Actions {
Class gslc = mClassLoader.loadClass("org.mozilla.gecko.gfx.GeckoLayerClient");
mDrawListener = mClassLoader.loadClass("org.mozilla.gecko.gfx.GeckoLayerClient$DrawListener");
mSetDrawListener = gslc.getDeclaredMethod("setDrawListener", mDrawListener);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SecurityException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
}
} catch (ClassNotFoundException e) {
FennecNativeDriver.log(LogLevel.ERROR, e);
} catch (SecurityException e) {
FennecNativeDriver.log(LogLevel.ERROR, e);
} catch (NoSuchMethodException e) {
FennecNativeDriver.log(LogLevel.ERROR, e);
} catch (IllegalArgumentException e) {
FennecNativeDriver.log(LogLevel.ERROR, e);
}
}
class wakeInvocationHandler implements InvocationHandler {
@ -159,7 +161,7 @@ public class FennecNativeActions implements Actions {
try {
this.wait();
} catch (InterruptedException ie) {
ie.printStackTrace();
FennecNativeDriver.log(LogLevel.ERROR, ie);
break;
}
}
@ -175,9 +177,9 @@ public class FennecNativeActions implements Actions {
try {
mUnregisterGEL.invoke(null, mRegistrationParams);
} catch (IllegalAccessException e) {
e.printStackTrace();
FennecNativeDriver.log(LogLevel.ERROR, e);
} catch (InvocationTargetException e) {
e.printStackTrace();
FennecNativeDriver.log(LogLevel.ERROR, e);
}
FennecNativeDriver.log(FennecNativeDriver.LogLevel.DEBUG,
"received event " + mGeckoEvent);
@ -205,9 +207,9 @@ public class FennecNativeActions implements Actions {
return expecter;
} catch (IllegalAccessException e) {
e.printStackTrace();
FennecNativeDriver.log(LogLevel.ERROR, e);
} catch (InvocationTargetException e) {
e.printStackTrace();
FennecNativeDriver.log(LogLevel.ERROR, e);
}
return null;
}
@ -257,14 +259,14 @@ public class FennecNativeActions implements Actions {
try {
this.wait();
} catch (InterruptedException ie) {
ie.printStackTrace();
FennecNativeDriver.log(LogLevel.ERROR, ie);
break;
}
}
try {
mSetDrawListener.invoke(mLayerClient, (Object)null);
} catch (Exception e) {
e.printStackTrace();
FennecNativeDriver.log(LogLevel.ERROR, e);
}
}
@ -281,7 +283,7 @@ public class FennecNativeActions implements Actions {
try {
this.wait();
} catch (InterruptedException ie) {
ie.printStackTrace();
FennecNativeDriver.log(LogLevel.ERROR, ie);
break;
}
}
@ -291,7 +293,7 @@ public class FennecNativeActions implements Actions {
try {
this.wait(millis);
} catch (InterruptedException ie) {
ie.printStackTrace();
FennecNativeDriver.log(LogLevel.ERROR, ie);
break;
}
long endTime = SystemClock.uptimeMillis();
@ -305,7 +307,7 @@ public class FennecNativeActions implements Actions {
try {
mSetDrawListener.invoke(mLayerClient, (Object)null);
} catch (Exception e) {
e.printStackTrace();
FennecNativeDriver.log(LogLevel.ERROR, e);
}
}
}
@ -314,7 +316,7 @@ public class FennecNativeActions implements Actions {
try {
return new PaintExpecter();
} catch (Exception e) {
e.printStackTrace();
FennecNativeDriver.log(LogLevel.ERROR, e);
return null;
}
}

View File

@ -142,15 +142,15 @@ public class FennecNativeDriver implements Driver {
Class layerView = mClassLoader.loadClass("org.mozilla.gecko.gfx.LayerView");
_getPixels = layerView.getDeclaredMethod("getPixels");
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SecurityException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
}
} catch (ClassNotFoundException e) {
log(LogLevel.ERROR, e);
} catch (SecurityException e) {
log(LogLevel.ERROR, e);
} catch (NoSuchMethodException e) {
log(LogLevel.ERROR, e);
} catch (IllegalArgumentException e) {
log(LogLevel.ERROR, e);
}
}
//Information on the location of the Gecko Frame.
@ -218,9 +218,9 @@ public class FennecNativeDriver implements Driver {
Object [] params = null;
_startFrameRecording.invoke(null, params);
} catch (IllegalAccessException e) {
e.printStackTrace();
log(LogLevel.ERROR, e);
} catch (InvocationTargetException e) {
e.printStackTrace();
log(LogLevel.ERROR, e);
}
}
@ -239,9 +239,9 @@ public class FennecNativeDriver implements Driver {
}
return numDelays;
} catch (IllegalAccessException e) {
e.printStackTrace();
log(LogLevel.ERROR, e);
} catch (InvocationTargetException e) {
e.printStackTrace();
log(LogLevel.ERROR, e);
}
return 0;
@ -252,9 +252,9 @@ public class FennecNativeDriver implements Driver {
Object [] params = null;
_startCheckerboardRecording.invoke(null, params);
} catch (IllegalAccessException e) {
e.printStackTrace();
log(LogLevel.ERROR, e);
} catch (InvocationTargetException e) {
e.printStackTrace();
log(LogLevel.ERROR, e);
}
}
@ -271,9 +271,9 @@ public class FennecNativeDriver implements Driver {
}
return completeness / (float)checkerboard.size();
} catch (IllegalAccessException e) {
e.printStackTrace();
log(LogLevel.ERROR, e);
} catch (InvocationTargetException e) {
e.printStackTrace();
log(LogLevel.ERROR, e);
}
return 0.0f;
@ -288,7 +288,7 @@ public class FennecNativeDriver implements Driver {
}
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
log(LogLevel.ERROR, e);
}
return null;
}
@ -302,7 +302,7 @@ public class FennecNativeDriver implements Driver {
try {
pixelBuffer = (IntBuffer)_getPixels.invoke(view);
} catch (Exception e) {
e.printStackTrace();
log(LogLevel.ERROR, e);
return null;
}
@ -341,7 +341,7 @@ public class FennecNativeDriver implements Driver {
fos.close();
}
} catch (IOException e) {
e.printStackTrace();
log(LogLevel.ERROR, e);
throw new RoboCopException("exception closing pixel writer on file: " + mapFile);
}
}
@ -393,9 +393,9 @@ public class FennecNativeDriver implements Driver {
finalParams[1] = Proxy.newProxyInstance(mClassLoader, interfaces, new scrollHandler());
mRegisterGEL.invoke(null, finalParams);
} catch (IllegalAccessException e) {
e.printStackTrace();
log(LogLevel.ERROR, e);
} catch (InvocationTargetException e) {
e.printStackTrace();
log(LogLevel.ERROR, e);
}
}
@ -416,8 +416,8 @@ public class FennecNativeDriver implements Driver {
text.append(line);
text.append('\n');
}
} catch(IOException e) {
e.printStackTrace();
} catch (IOException e) {
log(LogLevel.ERROR, e);
} finally {
try {
br.close();

View File

@ -88,7 +88,7 @@ public class FennecNativeElement implements Element {
try {
syncQueue.take();
} catch (InterruptedException e) {
e.printStackTrace();
FennecNativeDriver.log(FennecNativeDriver.LogLevel.ERROR, e);
}
}
@ -129,7 +129,7 @@ public class FennecNativeElement implements Element {
// Wait for the UiThread code to finish running
syncQueue.take();
} catch (InterruptedException e) {
e.printStackTrace();
FennecNativeDriver.log(FennecNativeDriver.LogLevel.ERROR, e);
}
if (mText == null) {
throw new RoboCopException("getText: Text is null for view "+mId);
@ -155,7 +155,7 @@ public class FennecNativeElement implements Element {
try {
syncQueue.take();
} catch (InterruptedException e) {
e.printStackTrace();
FennecNativeDriver.log(FennecNativeDriver.LogLevel.ERROR, e);
}
return mDisplayed;
}

View File

@ -29,9 +29,9 @@ public class PaintedSurface {
FileInputStream pixelFile = new FileInputStream(filename);
mPixelBuffer = pixelFile.getChannel().map(FileChannel.MapMode.READ_ONLY, 0, pixelSize);
} catch (java.io.FileNotFoundException e) {
e.printStackTrace();
FennecNativeDriver.log(FennecNativeDriver.LogLevel.ERROR, e);
} catch (java.io.IOException e) {
e.printStackTrace();
FennecNativeDriver.log(FennecNativeDriver.LogLevel.ERROR, e);
}
}