22# Use of this source code is governed by a BSD-style license that can be
33# found in the LICENSE file.
44
5- import abc
65import argparse
76import datetime as dt
87import logging
9- from typing import Any , Optional
8+ from typing import Any , Optional , Final
109
1110from typing_extensions import override
1211
2120from crossbench .parse import DurationParser
2221from crossbench .runner .run import Run
2322from crossbench .stories .story import Story
23+ from crossbench .action_runner .action .enums import ReadyState
2424
25- PLAY_AUDIO_SCRIPT = """
26-
27- setTimeout(()=>{
25+ PLAY_AUDIO_SCRIPT : Final [str ] = """
2826 document.getElementById('unmuteButton').click();
29- }, 1000);
30-
3127"""
3228
33- class PowerlineStory (Story , metaclass = abc . ABCMeta ):
29+ class PowerlineStory (Story ):
3430
3531 STORY_NAME = "podcast"
36- URL = "http ://localhost:8000 "
32+ URL = "https ://chromium-workloads.web.app/web-tests/main/synthetic/powerline/podcast.html "
3733
3834 def __init__ (self , run_for : Optional [dt .timedelta ] = dt .timedelta ()):
3935 duration = (run_for or dt .timedelta (seconds = 600 ))
@@ -45,11 +41,16 @@ def run(self, run: Run) -> None:
4541 with run .actions ("Show URL" ) as actions :
4642 actions .show_url (self .URL )
4743 with run .actions ("Autoplay" ) as actions :
48- actions .wait (dt .timedelta (seconds = 5 ))
44+ actions .wait_for_ready_state (
45+ ReadyState .COMPLETE , timeout = dt .timedelta (seconds = 5 )
46+ )
4947 actions .js (PLAY_AUDIO_SCRIPT )
5048 with run .actions ("Screen" ) as actions :
5149 actions .wait (dt .timedelta (seconds = 5 ))
52- actions .platform .sh ("input" , "keyevent" , "26" )
50+ if actions .platform .is_android :
51+ # On Android, put the screen to sleep to simulate playing a
52+ # podcast in the background.
53+ actions .platform .sh ("input" , "keyevent" , "26" )
5354 self ._wait_for_input ()
5455 logging .info ("Stopping benchmark..." )
5556
@@ -69,7 +70,7 @@ def all_story_names(cls) -> tuple[str, ...]:
6970
7071
7172
72- class PowerlineBenchmark (Benchmark , metaclass = abc . ABCMeta ):
73+ class PowerlineBenchmark (Benchmark ):
7374 """
7475 Benchmark runner for the Powerline background power-consumption test.
7576
@@ -94,11 +95,6 @@ def __init__(self,
9495 def _base_dir (cls ) -> pth .LocalPath :
9596 return config .config_dir () / "benchmark" / "powerline"
9697
97- @classmethod
98- @override
99- def default_network_config_path (cls ) -> pth .LocalPath :
100- return cls ._base_dir () / "network_config.hjson"
101-
10298 @classmethod
10399 @override
104100 def default_probe_config_path (cls ) -> pth .LocalPath :
0 commit comments