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 18 import logging 19 20 from vts.runners.host import asserts 21 from vts.runners.host import base_test 22 from vts.runners.host import const 23 from vts.runners.host import keys 24 from vts.runners.host import test_runner 25 from vts.utils.python.controllers import android_device 26 from vts.utils.python.precondition import precondition_utils 27 28 29 class TvInputHidlTest(base_test.BaseTestClass): 30 """Two hello world test cases which use the shell driver.""" 31 32 def setUpClass(self): 33 """Creates a mirror and init tv input hal.""" 34 self.dut = self.registerController(android_device)[0] 35 36 self.dut.shell.InvokeTerminal("one") 37 self.dut.shell.one.Execute("setenforce 0") # SELinux permissive mode 38 if not precondition_utils.CanRunHidlHalTest( 39 self, self.dut, self.dut.shell.one): 40 self._skip_all_testcases = True 41 return 42 43 if self.coverage.enabled: 44 self.coverage.LoadArtifacts() 45 self.coverage.InitializeDeviceCoverage(self.dut) 46 47 self.dut.hal.InitHidlHal(target_type="tv_input", 48 target_basepaths=self.dut.libPaths, 49 target_version=1.0, 50 target_package="android.hardware.tv.input", 51 target_component_name="ITvInput", 52 bits=int(self.abi_bitness)) 53 54 self.dut.shell.InvokeTerminal("one") 55 56 def setUp(self): 57 """Setup function that will be called every time before executing each 58 test case in the test class.""" 59 if self.profiling.enabled: 60 self.profiling.EnableVTSProfiling(self.dut.shell.one) 61 62 def tearDown(self): 63 """TearDown function that will be called every time after executing each 64 test case in the test class.""" 65 if self.profiling.enabled: 66 self.profiling.ProcessTraceDataForTestCase(self.dut) 67 self.profiling.DisableVTSProfiling(self.dut.shell.one) 68 69 def tearDownClass(self): 70 """To be executed when all test cases are finished.""" 71 if self._skip_all_testcases: 72 return 73 74 if self.coverage.enabled: 75 self.coverage.SetCoverageData(dut=self.dut, isGlobal=True) 76 77 if self.profiling.enabled: 78 self.profiling.ProcessAndUploadTraceData() 79 80 def testGetStreamConfigurations(self): 81 configs = self.dut.hal.tv_input.getStreamConfigurations(0) 82 logging.info('return value of getStreamConfigurations(0): %s', configs) 83 84 85 if __name__ == "__main__": 86 test_runner.main() 87