MCPcopy Create free account
hub / github.com/FastLED/FastLED / main

Function main

ci/wasm_audio_url_test.py:115–358  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

113
114
115async def main() -> None:
116 args = parse_args()
117
118 console.print()
119 console.print(
120 Panel.fit(
121 f"[bold cyan]FastLED WASM Audio URL Test[/bold cyan]\n\n"
122 f"[yellow]Will:[/yellow]\n"
123 f" [green]1.[/green] Launch headless Chromium with autoplay enabled\n"
124 f" [green]2.[/green] Load [bold]{args.example}[/bold] WASM example\n"
125 f" [green]3.[/green] Wait for FastLED init + audio element creation\n"
126 f" [green]4.[/green] Verify audio element exists with correct src\n"
127 f" [green]5.[/green] Verify audio readyState >= 2 (has data)\n"
128 f" [green]6.[/green] Verify audio is playing (not paused)",
129 title="[bold magenta]Test Plan[/bold magenta]",
130 border_style="cyan",
131 )
132 )
133 console.print()
134
135 install_playwright_browsers()
136
137 port = _find_free_port(8080)
138 console.print(f"[dim]Using port: {port}[/dim]")
139
140 os.chdir(str(PROJECT_ROOT))
141 directory = Path(f"examples/{args.example}/fastled_js")
142
143 if not directory.exists():
144 console.print(f"[bold red]Error:[/bold red] Directory not found: {directory}")
145 console.print(
146 f"[yellow]Hint:[/yellow] Run: uv run ci/wasm_compile.py examples/{args.example} --just-compile"
147 )
148 sys.exit(1)
149
150 console.print(f"[cyan]Testing example:[/cyan] [bold]{args.example}[/bold]")
151 console.print(f"[dim]Server directory: {directory}[/dim]")
152 server_process = start_http_server(port=port, directory=directory)
153
154 try:
155 time.sleep(2)
156
157 if not server_process.is_alive():
158 raise Exception(f"HTTP server failed to start on port {port}")
159
160 async with async_playwright() as p:
161 # Launch with autoplay policy disabled so audio plays without gesture
162 browser = await p.chromium.launch(
163 args=["--autoplay-policy=no-user-gesture-required"]
164 )
165 page = await browser.new_page()
166
167 try:
168 browser_errors: list[str] = []
169 audio_logs: list[str] = []
170
171 def console_log_handler(msg: ConsoleMessage) -> None:
172 text = msg.text

Callers 1

Calls 13

anyFunction · 0.85
CounterClass · 0.85
onMethod · 0.80
terminateMethod · 0.80
parse_argsFunction · 0.70
_find_free_portFunction · 0.70
start_http_serverFunction · 0.70
printMethod · 0.45
getMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected