1# Copyright 2017 The Chromium Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5"""A test which verifies the camera function with HAL3 interface.""" 6 7import os, logging 8import xml.etree.ElementTree 9from autotest_lib.client.bin import test, utils 10from autotest_lib.client.cros import service_stopper 11from sets import Set 12 13class camera_HAL3(test.test): 14 """ 15 This test is a wrapper of the test binary arc_camera3_test. 16 """ 17 18 version = 1 19 test_binary = 'arc_camera3_test' 20 dep = 'camera_hal3' 21 adapter_service = 'camera-halv3-adapter' 22 timeout = 600 23 media_profiles_path = os.path.join('vendor', 'etc', 'media_profiles.xml') 24 tablet_board_list = ['scarlet'] 25 26 def setup(self): 27 """ 28 Run common setup steps. 29 """ 30 self.dep_dir = os.path.join(self.autodir, 'deps', self.dep) 31 self.job.setup_dep([self.dep]) 32 logging.debug('mydep is at %s' % self.dep_dir) 33 34 def run_once(self): 35 """ 36 Entry point of this test. 37 """ 38 self.job.install_pkg(self.dep, 'dep', self.dep_dir) 39 40 with service_stopper.ServiceStopper([self.adapter_service]): 41 cmd = [ os.path.join(self.dep_dir, 'bin', self.test_binary) ] 42 xml_content = utils.system_output( 43 ' '.join(['android-sh', '-c', '\"cat', 44 self.media_profiles_path + '\"'])) 45 root = xml.etree.ElementTree.fromstring(xml_content) 46 recording_params = Set() 47 for camcorder_profiles in root.findall('CamcorderProfiles'): 48 for encoder_profile in camcorder_profiles.findall('EncoderProfile'): 49 video = encoder_profile.find('Video') 50 recording_params.add('%s:%s:%s:%s' % ( 51 camcorder_profiles.get('cameraId'), video.get('width'), 52 video.get('height'), video.get('frameRate'))) 53 if recording_params: 54 cmd.append('--recording_params=' + ','.join(recording_params)) 55 if utils.get_current_board() in self.tablet_board_list: 56 cmd.append('--gtest_filter=-*SensorOrientationTest/*') 57 58 utils.system(' '.join(cmd), timeout=self.timeout) 59