# Copyright 2018 The Chromium OS Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. import logging, time from autotest_lib.client.bin import utils from autotest_lib.client.common_lib.cros import chrome from autotest_lib.client.common_lib import error from autotest_lib.client.cros import service_stopper from autotest_lib.client.cros.graphics import graphics_utils from autotest_lib.client.cros.power import power_rapl from autotest_lib.client.cros.power import power_status from autotest_lib.client.cros.power import power_utils TEST_NAME_AND_FLAGS = [ ['hw_overlays_hw_decode', ['']], ['no_overlays_hw_decode', ['--enable-hardware-overlays=']], ['hw_overlays_sw_decode', ['--disable-accelerated-video-decode']], [ 'no_overlays_sw_decode', ['--disable-accelerated-video-decode', '--enable-hardware-overlays='] ] ] # Amount of time to wait for the URL to load and the video to start playing. PREAMBLE_DURATION_SECONDS = 8 # Amount of time to let the video play while measuring power consumption. MEASUREMENT_DURATION_SECONDS = 12 # Time in seconds to wait for cpu idle until giveup. IDLE_CPU_WAIT_TIMEOUT_SECONDS = 60.0 # Maximum percent of cpu usage considered as idle. IDLE_CPU_LOAD_PERCENTAGE = 0.2 GRAPH_NAME = 'power_consumption' class graphics_VideoRenderingPower(graphics_utils.GraphicsTest): """This test renders on screen for a short while a video from a given (controlled) URL while measuring the power consumption of the different SoC domains. """ version = 1 _backlight = None _service_stopper = None _power_status = None def initialize(self): super(graphics_VideoRenderingPower, self).initialize() self._backlight = power_utils.Backlight() self._backlight.set_default() self._service_stopper = service_stopper.ServiceStopper( service_stopper.ServiceStopper.POWER_DRAW_SERVICES) self._service_stopper.stop_services() self._power_status = power_status.get_status() def cleanup(self): if self._backlight: self._backlight.restore() if self._service_stopper: self._service_stopper.restore_services() super(graphics_VideoRenderingPower, self).cleanup() @graphics_utils.GraphicsTest.failure_report_decorator( 'graphics_VideoRenderingPower') def run_once(self, video_url, video_short_name): """Runs the graphics_VideoRenderingPower test. @param video_url: URL with autoplay video inside. It's assumed that there's just one