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_WebGL(power_test.power_Test): 12 """class for power_WebGL test. 13 """ 14 version = 1 15 16 # Google Earth permalink for Googleplex 17 URL = 'https://earth.app.goo.gl/Tj5Wj' 18 19 def run_once(self, url=URL, duration=180): 20 """run_once method. 21 22 @param 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 logging.info('Navigating to url: %s', url) 36 tab.Navigate(url) 37 tab.WaitForDocumentReadyStateToBeComplete() 38 39 self.start_measurements() 40 time.sleep(duration) 41