Home | History | Annotate | Download | only in camera_HAL3Server
      1 # Copyright 2018 The Chromium OS 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 import logging
      6 import os
      7 from autotest_lib.server import autotest, test
      8 from autotest_lib.server.cros.multimedia import remote_facade_factory
      9 
     10 
     11 class camera_HAL3Server(test.test):
     12     """
     13     Server side camera_HAL3 test for configure dummy image on chart tablet and
     14     run test on DUT.
     15     """
     16     version = 1
     17     DISPLAY_LEVEL = 96.0
     18     SCENE_NAME = 'scene.pdf'
     19     BRIGHTNESS_CMD = 'backlight_tool --get_brightness_percent'
     20     SET_BRIGHTNESS_CMD = 'backlight_tool --set_brightness_percent=%s'
     21 
     22     def setup(self, chart_host):
     23         # prepare chart device
     24         self.chart_dir = chart_host.get_tmp_dir()
     25         logging.debug('chart_dir=%s', self.chart_dir)
     26         self.display_facade = remote_facade_factory.RemoteFacadeFactory(
     27                 chart_host).create_display_facade()
     28 
     29         # set chart display brightness
     30         self.init_display_level = chart_host.run(
     31                 self.BRIGHTNESS_CMD).stdout.rstrip()
     32         chart_host.run(self.SET_BRIGHTNESS_CMD % self.DISPLAY_LEVEL)
     33 
     34         # keep display always on
     35         chart_host.run('stop powerd', ignore_status=True)
     36 
     37         # scp scene to chart_host
     38         chart_host.send_file(
     39                 os.path.join(self.bindir, 'files', self.SCENE_NAME),
     40                 self.chart_dir)
     41         chart_host.run('chmod', args=('-R', '755', self.chart_dir))
     42 
     43         # display scene
     44         self.display_facade.load_url(
     45                 'file://' + os.path.join(self.chart_dir, self.SCENE_NAME))
     46         self.display_facade.set_fullscreen(True)
     47 
     48     def run_once(self, host, chart_host, **kwargs):
     49         autotest.Autotest(host).run_test('camera_HAL3', **kwargs)
     50 
     51     def cleanup(self, chart_host):
     52         # restore display default behavior
     53         chart_host.run('start powerd', ignore_status=True)
     54         chart_host.run(self.SET_BRIGHTNESS_CMD % self.init_display_level)
     55