@@ -104,6 +104,43 @@ impl Display for Flavor {
104104 }
105105}
106106
107+ #[ derive( Debug , clap:: ValueEnum , Clone ) ]
108+ pub enum FrontCamera {
109+ #[ clap( name = "none" ) ]
110+ None ,
111+ #[ clap( name = "emulated" ) ]
112+ Emulated ,
113+ }
114+
115+ impl Display for FrontCamera {
116+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
117+ match self {
118+ FrontCamera :: None => f. write_str ( "none" ) ,
119+ FrontCamera :: Emulated => f. write_str ( "emulated" ) ,
120+ }
121+ }
122+ }
123+
124+ #[ derive( Debug , clap:: ValueEnum , Clone ) ]
125+ pub enum BackCamera {
126+ #[ clap( name = "none" ) ]
127+ None ,
128+ #[ clap( name = "virtualscene" ) ]
129+ VirtualScene ,
130+ #[ clap( name = "emulated" ) ]
131+ Emulated ,
132+ }
133+
134+ impl Display for BackCamera {
135+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
136+ match self {
137+ BackCamera :: None => f. write_str ( "none" ) ,
138+ BackCamera :: VirtualScene => f. write_str ( "virtualscene" ) ,
139+ BackCamera :: Emulated => f. write_str ( "emulated" ) ,
140+ }
141+ }
142+ }
143+
107144#[ allow( clippy:: too_many_arguments) ]
108145pub ( crate ) async fn run (
109146 application : Option < std:: path:: PathBuf > ,
@@ -122,6 +159,8 @@ pub(crate) async fn run(
122159 application_bundle : Option < Vec < String > > ,
123160 library_bundle : Option < Vec < PathBuf > > ,
124161 mock_location : bool ,
162+ front_camera : Option < FrontCamera > ,
163+ back_camera : Option < BackCamera > ,
125164) -> Result < bool > {
126165 if application. is_none ( )
127166 && test_application. is_none ( )
@@ -183,6 +222,7 @@ If you are interesting in library testing then please use advance mode with --li
183222 }
184223
185224 validate_device_configuration ( & os_version, & system_image, & device, & flavor) ?;
225+ validate_camera_configuration ( & system_image, & front_camera, & back_camera) ?;
186226
187227 let filter_file = common. filter_file . map ( filtering:: convert:: convert) ;
188228 let filtering_configuration = match filter_file {
@@ -284,6 +324,8 @@ If you are interesting in library testing then please use advance mode with --li
284324 library_bundle,
285325 None ,
286326 None ,
327+ front_camera. map ( |x| x. to_string ( ) ) ,
328+ back_camera. map ( |x| x. to_string ( ) ) ,
287329 formatter,
288330 )
289331 . await
@@ -370,6 +412,26 @@ pub(crate) fn validate_device_configuration(
370412 Ok ( ( ) )
371413}
372414
415+ pub ( crate ) fn validate_camera_configuration (
416+ system_image : & Option < SystemImage > ,
417+ front_camera : & Option < FrontCamera > ,
418+ back_camera : & Option < BackCamera > ,
419+ ) -> Result < ( ) > {
420+ if front_camera. is_none ( ) && back_camera. is_none ( ) {
421+ return Ok ( ( ) ) ;
422+ }
423+
424+ match system_image {
425+ Some ( SystemImage :: GoogleApis ) | Some ( SystemImage :: GoogleApisPlaystore ) => Ok ( ( ) ) ,
426+ _ => Err ( ConfigurationError :: UnsupportedRunConfiguration {
427+ message :
428+ "Camera options (--front-camera, --back-camera) are only supported with google_apis or google_apis_playstore system images"
429+ . into ( ) ,
430+ }
431+ . into ( ) ) ,
432+ }
433+ }
434+
373435pub ( crate ) async fn validate (
374436 application : Option < PathBuf > ,
375437 test_application : Option < PathBuf > ,
0 commit comments