Bug 1239964 - [mozdevice] Expose screen recorder capabilites
--- a/testing/mozbase/mozdevice/adb_tests/test_devicemanagerADB.py
+++ b/testing/mozbase/mozdevice/adb_tests/test_devicemanagerADB.py
@@ -161,16 +161,28 @@ class TestFileOperations(DeviceManagerAD
self.dm.pushFile(self.tempLocalFile, self.tempRemoteSystemFile)
self.assertTrue(self.dm.fileExists(self.tempRemoteSystemFile))
self.dm.removeFile(self.tempRemoteSystemFile)
self.assertFalse(self.dm.fileExists(self.tempRemoteSystemFile))
self.dm.shell(['mount', '-r', '-o', 'remount', '/system'], out)
out.close()
self.assertTrue(find_mount_permissions(self.dm, "/system") == "ro")
+ def test_record_and_video(self):
+ video_remote_location = '/sdcard/screenrecord.mp4'
+ video_local_location = os.path.join("tempDir", "tempvideo.mp4")
+
+ self.dm.startScreenRecord(remoteLocation=video_remote_location)
+ self.dm.stopScreenRecord()
+
+ self.dm.getFile(remoteFile=video_remote_location, localFile=video_local_location)
+ video_file_size = os.path.getsize(video_remote_location)
+
+ self.assertGreater(video_file_size, 0)
+
class TestOther(DeviceManagerADBTestCase):
def test_get_list_of_processes(self):
self.assertEquals(type(self.dm.getProcessList()), list)
def test_get_current_time(self):
self.assertEquals(type(self.dm.getCurrentTime()), int)
--- a/testing/mozbase/mozdevice/mozdevice/devicemanagerADB.py
+++ b/testing/mozbase/mozdevice/mozdevice/devicemanagerADB.py
@@ -4,16 +4,17 @@
import logging
import re
import os
import shutil
import tempfile
import time
import traceback
+import signal
from devicemanager import DeviceManager, DMError
from mozprocess import ProcessHandler
import mozfile
class DeviceManagerADB(DeviceManager):
"""
@@ -643,16 +644,25 @@ class DeviceManagerADB(DeviceManager):
self._checkCmd(["shell", "chmod", mask, remoteEntry], timeout=self.short_timeout)
self._logger.info("chmod %s" % remoteEntry)
self._checkCmd(["shell", "chmod", mask, remoteDir], timeout=self.short_timeout)
self._logger.debug("chmod %s" % remoteDir)
else:
self._checkCmd(["shell", "chmod", mask, remoteDir.strip()], timeout=self.short_timeout)
self._logger.debug("chmod %s" % remoteDir.strip())
+ def startScreenRecord(self, remoteLocation='/sdcard/screenrecord.mp4'):
+ self.shell(cmd='screenrecord %s' % remoteLocation,
+ outputfile='/dev/null')
+
+ def stopScreenRecord(self):
+ self.killProcess(appname='screenrecord',
+ sig=signal.SIGINT # video file gets corrupted if using another signal
+ )
+
def _verifyADB(self):
"""
Check to see if adb itself can be executed.
"""
if self._adbPath != 'adb':
if not os.access(self._adbPath, os.X_OK):
raise DMError("invalid adb path, or adb not executable: %s" % self._adbPath)