1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2024-10-06 19:01:15 +01:00

camerarecord: add possibility to select slow_motion recording mode

Signed-off-by: Michele Di Giorgio <michele.digiorgio@arm.com>
This commit is contained in:
Michele Di Giorgio 2016-07-13 15:23:36 +01:00
parent 662033399f
commit 2dd3a2ba4d
2 changed files with 24 additions and 1 deletions

View File

@ -15,6 +15,7 @@
from wlauto import UiAutomatorWorkload, Parameter
from wlauto.utils.types import range_dict
from wlauto.exceptions import WorkloadError
class Camerarecord(UiAutomatorWorkload):
@ -28,6 +29,7 @@ class Camerarecord(UiAutomatorWorkload):
package = 'com.google.android.gallery3d'
activity = 'com.android.camera.CameraActivity'
run_timeout = 0
camera_modes = ['normal', 'slow_motion']
api_packages = range_dict()
api_packages[1] = 'com.google.android.gallery3d'
@ -36,6 +38,8 @@ class Camerarecord(UiAutomatorWorkload):
parameters = [
Parameter('recording_time', kind=int, default=60,
description='The video recording time in seconds.'),
Parameter('recording_mode', kind=str, allowed_values=camera_modes,
default='normal', description='The video recording mode.'),
]
def initialize(self, context):
@ -48,8 +52,15 @@ class Camerarecord(UiAutomatorWorkload):
version = self.device.get_installed_package_version(self.package)
version = version.replace(' ', '_')
self.uiauto_params['version'] = version
self.uiauto_params['recording_mode'] = self.recording_mode
def setup(self, context):
if self.recording_mode != 'normal':
if self.device.get_sdk_version() < 23:
raise WorkloadError('{} recording mode only supported by '
'Android version M onwards'
.format(self.recording_mode))
super(Camerarecord, self).setup(context)
# Start camera activity
self.device.execute('am start -n {}/{}'.format(self.package, self.activity))

View File

@ -38,6 +38,7 @@ public class UiAutomation extends BaseUiAutomation {
int timeout = 4;
int sleepTime = 2;
int recordingTime = 0;
String recordingMode = "normal";
int api = 0;
Integer[] version = {0,0,0};
@ -46,6 +47,7 @@ public class UiAutomation extends BaseUiAutomation {
if (parameters.size() > 0) {
recordingTime = Integer.parseInt(parameters
.getString("recording_time"));
recordingMode = parameters.getString("recording_mode");
api = Integer.parseInt(parameters.getString("api_level"));
String versionString = parameters.getString("version");
version = splitVersion(versionString);
@ -95,8 +97,18 @@ public class UiAutomation extends BaseUiAutomation {
UiObject viewFinder = new UiObject(new UiSelector().resourceId("com.android.camera2:id/viewfinder_frame"));
viewFinder.swipeLeft(5);
String captureButtonId = "com.android.camera2:id/photo_video_button";
// Enable slow motion if requested
if (recordingMode.equals("slow_motion")) {
getUiDevice().pressMenu();
UiObject slowMoButton = new UiObject(new UiSelector().text("Slow Motion").className("android.widget.TextView"));
slowMoButton.waitForExists(TimeUnit.SECONDS.toMillis(5));
slowMoButton.click();
captureButtonId = "com.android.camera2:id/video_hfr_shutter_button";
}
// click to capture photos
UiObject clickCaptureButton = new UiObject(new UiSelector().resourceId("com.android.camera2:id/photo_video_button"));
UiObject clickCaptureButton = new UiObject(new UiSelector().resourceId(captureButtonId));
clickCaptureButton.longClick();
sleep(recordingTime);