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. 4import logging 5import time 6 7from autotest_lib.client.common_lib.cros import chrome 8from autotest_lib.client.cros.input_playback import keyboard 9from autotest_lib.client.cros.power import power_test 10 11class power_ThermalLoad(power_test.power_Test): 12 """class for power_WebGL test. 13 """ 14 version = 1 15 16 JELLYFISH_URL = 'https://arodic.github.io/p/jellyfish/' 17 HOUR = 60 * 60 18 19 def run_once(self, test_url=JELLYFISH_URL, duration=2.5 * HOUR): 20 """run_once method. 21 22 @param test_url: url of webgl heavy page. 23 @param duration: time in seconds to display url and measure power. 24 """ 25 with chrome.Chrome(init_network_controller=True) as self.cr: 26 tab = self.cr.browser.tabs.New() 27 tab.Activate() 28 29 # Just measure power in full-screen. 30 fullscreen = tab.EvaluateJavaScript('document.webkitIsFullScreen') 31 if not fullscreen: 32 with keyboard.Keyboard() as keys: 33 keys.press_key('f4') 34 35 self.backlight.set_percent(100) 36 37 logging.info('Navigating to url: %s', test_url) 38 tab.Navigate(test_url) 39 tab.WaitForDocumentReadyStateToBeComplete() 40 41 if test_url == self.JELLYFISH_URL: 42 # Change param to 100 fast moving jellyfish. 43 tab.EvaluateJavaScript('$("#jCount").val(100);') 44 tab.EvaluateJavaScript('$("#jSpeed").val(0.1);') 45 46 # Jellyfish is added one by one. Wait until we have 100. 47 while tab.EvaluateJavaScript('jellyfish.count') < 100: 48 time.sleep(0.1) 49 50 self.start_measurements() 51 time.sleep(duration) 52