diff --git a/Cargo.lock b/Cargo.lock index ae2a2fd..4f9cefe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1855,9 +1855,9 @@ checksum = "f87165f0995f63a9fbeea62b64d10b4d9d8e78ec6d7d51fb2125fda7bb36788f" [[package]] name = "rustls-webpki" -version = "0.103.10" +version = "0.103.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df33b2b81ac578cabaf06b89b0631153a3f416b0a886e8a7a1707fb51abbd1ef" +checksum = "61c429a8649f110dddef65e2a5ad240f747e85f7758a6bccc7e5777bd33f756e" dependencies = [ "aws-lc-rs", "ring", diff --git a/src/api.rs b/src/api.rs index 13b504d..12ffa99 100644 --- a/src/api.rs +++ b/src/api.rs @@ -64,6 +64,8 @@ pub trait RapiClient { library_bundle: Option>, granted_permission: Option>, batch_isolation: Option, + front_camera: Option, + back_camera: Option, ) -> Result; async fn get_run(&self, id: &str) -> Result; @@ -164,6 +166,8 @@ impl RapiClient for RapiReqwestClient { library_bundle: Option>, granted_permission: Option>, batch_isolation: Option, + front_camera: Option, + back_camera: Option, ) -> Result { let url = format!("{}/v2/run", self.base_url); let params = [("api_key", self.api_key.clone())]; @@ -299,6 +303,8 @@ impl RapiClient for RapiReqwestClient { bundles, granted_permission: granted_permission.clone(), app_uninstall, + front_camera, + back_camera, }; let response = self.client.post(url).json(&create_request).send().await?; @@ -682,6 +688,10 @@ struct CreateRunRequest { granted_permission: Option>, #[serde(rename = "app_uninstall", default)] app_uninstall: Option, + #[serde(rename = "front_camera", default)] + front_camera: Option, + #[serde(rename = "back_camera", default)] + back_camera: Option, } #[derive(Serialize, Deserialize, Debug)] diff --git a/src/cli/android/maestro/mod.rs b/src/cli/android/maestro/mod.rs index 18b64f7..b990a2d 100644 --- a/src/cli/android/maestro/mod.rs +++ b/src/cli/android/maestro/mod.rs @@ -131,6 +131,8 @@ pub(crate) async fn run( None, None, None, + None, + None, formatter, ) .await diff --git a/src/cli/android/mod.rs b/src/cli/android/mod.rs index 30e36ec..9a38166 100644 --- a/src/cli/android/mod.rs +++ b/src/cli/android/mod.rs @@ -104,6 +104,43 @@ impl Display for Flavor { } } +#[derive(Debug, clap::ValueEnum, Clone)] +pub enum FrontCamera { + #[clap(name = "none")] + None, + #[clap(name = "emulated")] + Emulated, +} + +impl Display for FrontCamera { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + FrontCamera::None => f.write_str("none"), + FrontCamera::Emulated => f.write_str("emulated"), + } + } +} + +#[derive(Debug, clap::ValueEnum, Clone)] +pub enum BackCamera { + #[clap(name = "none")] + None, + #[clap(name = "virtualscene")] + VirtualScene, + #[clap(name = "emulated")] + Emulated, +} + +impl Display for BackCamera { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + BackCamera::None => f.write_str("none"), + BackCamera::VirtualScene => f.write_str("virtualscene"), + BackCamera::Emulated => f.write_str("emulated"), + } + } +} + #[allow(clippy::too_many_arguments)] pub(crate) async fn run( application: Option, @@ -122,6 +159,8 @@ pub(crate) async fn run( application_bundle: Option>, library_bundle: Option>, mock_location: bool, + front_camera: Option, + back_camera: Option, ) -> Result { if application.is_none() && test_application.is_none() @@ -183,6 +222,7 @@ If you are interesting in library testing then please use advance mode with --li } validate_device_configuration(&os_version, &system_image, &device, &flavor)?; + validate_camera_configuration(&system_image, &front_camera, &back_camera)?; let filter_file = common.filter_file.map(filtering::convert::convert); let filtering_configuration = match filter_file { @@ -284,6 +324,8 @@ If you are interesting in library testing then please use advance mode with --li library_bundle, None, None, + front_camera.map(|x| x.to_string()), + back_camera.map(|x| x.to_string()), formatter, ) .await @@ -370,6 +412,26 @@ pub(crate) fn validate_device_configuration( Ok(()) } +pub(crate) fn validate_camera_configuration( + system_image: &Option, + front_camera: &Option, + back_camera: &Option, +) -> Result<()> { + if front_camera.is_none() && back_camera.is_none() { + return Ok(()); + } + + match system_image { + Some(SystemImage::GoogleApis) | Some(SystemImage::GoogleApisPlaystore) => Ok(()), + _ => Err(ConfigurationError::UnsupportedRunConfiguration { + message: + "Camera options (--front-camera, --back-camera) are only supported with google_apis or google_apis_playstore system images" + .into(), + } + .into()), + } +} + pub(crate) async fn validate( application: Option, test_application: Option, diff --git a/src/cli/ios/maestro/mod.rs b/src/cli/ios/maestro/mod.rs index 5fd9982..03360f7 100644 --- a/src/cli/ios/maestro/mod.rs +++ b/src/cli/ios/maestro/mod.rs @@ -158,6 +158,8 @@ pub(crate) async fn run( None, None, None, + None, + None, formatter, ) .await diff --git a/src/cli/ios/mod.rs b/src/cli/ios/mod.rs index 730c5d2..2bea3bc 100644 --- a/src/cli/ios/mod.rs +++ b/src/cli/ios/mod.rs @@ -380,6 +380,8 @@ pub(crate) async fn run( None, granted_permission, batch_isolation, + None, + None, formatter, ) .await diff --git a/src/cli/mod.rs b/src/cli/mod.rs index ffafff0..ae35f88 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -60,6 +60,8 @@ impl Cli { library_bundle, profiling_args, mock_location, + front_camera, + back_camera, } => { android::run( application, @@ -78,6 +80,8 @@ impl Cli { application_bundle, library_bundle, mock_location, + front_camera, + back_camera, ) .await } @@ -549,6 +553,20 @@ Example: '--library-bundle apks/library1-debug-androidTest.apk --library-bundle help = "Allow mock location access for application" )] mock_location: bool, + + #[arg( + value_enum, + long, + help = "Front camera mode. Only supported with google_apis or google_apis_playstore system images" + )] + front_camera: Option, + + #[arg( + value_enum, + long, + help = "Back camera mode. Only supported with google_apis or google_apis_playstore system images" + )] + back_camera: Option, }, #[allow(non_camel_case_types)] #[command(name = "ios")] diff --git a/src/interactor.rs b/src/interactor.rs index 7e13c3e..7abefaa 100644 --- a/src/interactor.rs +++ b/src/interactor.rs @@ -144,6 +144,8 @@ impl TriggerTestRunInteractor { library_bundle: Option>, granted_permission: Option>, batch_isolation: Option, + front_camera: Option, + back_camera: Option, mut formatter: StandardFormatter, ) -> Result { let client = RapiReqwestClient::new(base_url, api_key); @@ -184,6 +186,8 @@ impl TriggerTestRunInteractor { library_bundle, granted_permission, batch_isolation, + front_camera, + back_camera, ) .await?;