Bug 921117 - Enhanced Robocop screenshots, r=jmaher

This commit is contained in:
Mark Capella 2013-09-27 17:04:16 -04:00
parent de4063844e
commit 183bab5e57

View File

@ -464,16 +464,27 @@ class MochiRemote(Mochitest):
return 1
return 0
def printScreenshot(self):
def printScreenshots(self, screenShotDir):
# TODO: This can be re-written after completion of bug 749421
if not self._dm.dirExists(screenShotDir):
log.info("SCREENSHOT: No ScreenShots directory available: " + screenShotDir)
return
printed = 0
for name in self._dm.listFiles(screenShotDir):
fullName = screenShotDir + "/" + name
log.info("SCREENSHOT: FOUND: [%s]", fullName)
try:
image = self._dm.pullFile("/mnt/sdcard/Robotium-Screenshots/robocop-screenshot.jpg")
image = self._dm.pullFile(fullName)
encoded = base64.b64encode(image)
log.info("SCREENSHOT: data:image/jpg;base64,%s", encoded)
printed += 1
except:
# If the test passes, no screenshot will be generated and
# pullFile will fail -- continue silently.
log.info("SCREENSHOT: Could not be parsed")
pass
log.info("SCREENSHOT: TOTAL PRINTED: [%s]", printed)
def printDeviceInfo(self, printLogcat=False):
try:
if printLogcat:
@ -654,7 +665,8 @@ def main():
if (options.dm_trans == "sut"):
dm._runCmds([{"cmd": " ".join(cmd)}])
try:
dm.removeDir("/mnt/sdcard/Robotium-Screenshots")
screenShotDir = "/mnt/sdcard/Robotium-Screenshots"
dm.removeDir(screenShotDir)
dm.recordLogcat()
result = mochitest.runTests(options)
if result != 0:
@ -662,7 +674,7 @@ def main():
log_result = mochitest.addLogData()
if result != 0 or log_result != 0:
mochitest.printDeviceInfo(printLogcat=True)
mochitest.printScreenshot()
mochitest.printScreenshots(screenShotDir)
# Ensure earlier failures aren't overwritten by success on this run
if retVal is None or retVal == 0:
retVal = result