Home | History | Annotate | Download | only in conventional
      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 base_test
     21 from vts.runners.host import test_runner
     22 
     23 
     24 class SampleLightTest(base_test.BaseTestClass):
     25     """A sample testcase for the legacy lights HAL."""
     26 
     27     def setUpClass(self):
     28         self.dut = self.android_devices[0]
     29         self.dut.hal.InitConventionalHal(
     30             target_type="light",
     31             target_basepaths=["/data/local/tmp/64/hw"],
     32             target_version=1.0,
     33             bits=64,
     34             target_package="hal.conventional.light")
     35         self.dut.hal.light.OpenConventionalHal("backlight")
     36 
     37     def testTurnOnBackgroundLight(self):
     38         """A simple testcase which just calls a function."""
     39         # TODO: support ability to test non-instrumented hals.
     40         arg = self.dut.hal.light.light_state_t(
     41             color=0xffffff00,
     42             flashMode=self.dut.hal.light.LIGHT_FLASH_HARDWARE,
     43             flashOnMs=100,
     44             flashOffMs=200,
     45             brightnessMode=self.dut.hal.light.BRIGHTNESS_MODE_USER)
     46         self.dut.hal.light.set_light(None, arg)
     47 
     48     def testTurnOnBackgroundLightUsingInstrumentedLib(self):
     49         """A simple testcase which just calls a function."""
     50         arg = self.dut.hal.light.light_state_t(
     51             color=0xffffff00,
     52             flashMode=self.dut.hal.light.LIGHT_FLASH_HARDWARE,
     53             flashOnMs=100,
     54             flashOffMs=200,
     55             brightnessMode=self.dut.hal.light.BRIGHTNESS_MODE_USER)
     56         logging.debug(self.dut.hal.light.set_light(None, arg))
     57 
     58 
     59 if __name__ == "__main__":
     60     test_runner.main()
     61