• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
19
20from vts.runners.host import base_test
21from vts.runners.host import test_runner
22from vts.utils.python.controllers import android_device
23
24
25class SampleLightTest(base_test.BaseTestClass):
26    """A sample testcase for the legacy lights HAL."""
27
28    def setUpClass(self):
29        self.dut = self.registerController(android_device)[0]
30        self.dut.hal.InitConventionalHal(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
59if __name__ == "__main__":
60    test_runner.main()
61