(&self, id: &str, timeout_duration: Duration)
| 323 | } |
| 324 | |
| 325 | pub fn wait_until_booted(&self, id: &str, timeout_duration: Duration) -> Result<(), AppError> { |
| 326 | let avd_name = avd_from_id(id)?; |
| 327 | let deadline = Instant::now() + timeout_duration; |
| 328 | loop { |
| 329 | if let Ok(serial) = self.resolve_serial(&avd_name) { |
| 330 | if self |
| 331 | .run_adb(["-s", &serial, "shell", "getprop", "sys.boot_completed"]) |
| 332 | .unwrap_or_default() |
| 333 | .trim() |
| 334 | == "1" |
| 335 | { |
| 336 | return Ok(()); |
| 337 | } |
| 338 | } |
| 339 | if Instant::now() >= deadline { |
| 340 | return Err(AppError::native(format!( |
| 341 | "Android emulator `{avd_name}` did not finish booting in time." |
| 342 | ))); |
| 343 | } |
| 344 | thread::sleep(Duration::from_millis(500)); |
| 345 | } |
| 346 | } |
| 347 | |
| 348 | pub fn screenshot_png(&self, id: &str) -> Result<Vec<u8>, AppError> { |
| 349 | let serial = self.serial_for_id(id)?; |
no test coverage detected