1#!/usr/bin/env python 2# 3# Copyright (C) 2016 The Android Open Source Project 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16# 17 18import logging 19import time 20 21from vts.runners.host import asserts 22from vts.runners.host import base_test 23from vts.runners.host import test_runner 24from vts.utils.python.controllers import android_device 25 26 27class SampleCameraV3Test(base_test.BaseTestClass): 28 """A sample testcase for the non-HIDL, conventional Camera HAL.""" 29 # Camera HAL version value (v3.4). 30 VERSION_3_4 = 0x1000304 31 MAX_RETRIES = 3 32 33 def setUpClass(self): 34 self.dut = self.registerController(android_device)[0] 35 self.dut.hal.InitConventionalHal(target_type="camera", 36 target_version=3.4, 37 target_basepaths=["/system/lib/hw"], 38 bits=32, 39 target_package="hal.conventional.camera") 40 41 def setUp(self): 42 self.call_count_camera_device_status_change = 0 43 self.call_count_torch_mode_status_change = 0 44 45 def testCameraNormal(self): 46 """A simple testcase which just emulates a normal usage pattern.""" 47 version = self.dut.hal.camera.common.GetAttributeValue("version") 48 logging.info("version: %s", hex(version)) 49 if version != self.VERSION_3_4: 50 asserts.skip("HAL version != v3.4") 51 52 self.dut.hal.camera.common.module.methods.open() # note args are skipped 53 54 ops = self.dut.hal.camera.GetAttributeValue("ops") 55 logging.info("ops: %s", ops) 56 ops.flush(None) 57 58 59if __name__ == "__main__": 60 test_runner.main() 61