Skip to content

Commit

Permalink
feat(android): add mock_location
Browse files Browse the repository at this point in the history
  • Loading branch information
Malinskiy committed Dec 16, 2024
1 parent 3049a1c commit d56d9f5
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ pub trait RapiClient {
retry_quota_test_reactive: Option<u32>,
analytics_read_only: Option<bool>,
profiling: bool,
mock_location: bool,
filtering_configuration: Option<SparseMarathonfile>,
no_progress_bar: bool,
flavor: Option<String>,
Expand Down Expand Up @@ -145,6 +146,7 @@ impl RapiClient for RapiReqwestClient {
retry_quota_test_reactive: Option<u32>,
analytics_read_only: Option<bool>,
profiling: bool,
mock_location: bool,
filtering_configuration: Option<SparseMarathonfile>,
no_progress_bar: bool,
flavor: Option<String>,
Expand Down Expand Up @@ -256,6 +258,7 @@ impl RapiClient for RapiReqwestClient {
s3_app_path: s3_app_path.clone(),
analytics_read_only: analytics_read_only.clone(),
profiling: profiling,
mock_location: mock_location,
code_coverage: code_coverage.clone(),
concurrency_limit: concurrency_limit.clone(),
country: None,
Expand Down Expand Up @@ -567,6 +570,8 @@ struct CreateRunRequest {
analytics_read_only: Option<bool>,
#[serde(rename = "profiling", default)]
profiling: bool,
#[serde(rename = "mock_location", default)]
mock_location: bool,
#[serde(rename = "code_coverage", default)]
code_coverage: Option<bool>,
#[serde(rename = "concurrency_limit", default)]
Expand Down
11 changes: 11 additions & 0 deletions src/cli/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ pub(crate) async fn run(
pull_files: Option<Vec<String>>,
application_bundle: Option<Vec<String>>,
library_bundle: Option<Vec<PathBuf>>,
mock_location: bool,
) -> Result<bool> {
if application.is_none()
&& test_application.is_none()
Expand Down Expand Up @@ -139,6 +140,15 @@ If you are interesting in library testing then please use advance mode with --li
.into());
}

if let Some(bundles) = &application_bundle {
if bundles.len() > 1 && mock_location {
return Err(ConfigurationError::UnsupportedRunConfiguration {
message: "Mock location access doesn't support multiple application bundles".into(),
}
.into());
}
}

match (device.as_deref(), &flavor, &system_image, &os_version) {
(Some("watch"), _, Some(SystemImage::Default) | None, Some(_) | None)
| (
Expand Down Expand Up @@ -267,6 +277,7 @@ If you are interesting in library testing then please use advance mode with --li
retry_args.retry_quota_test_reactive,
analytics_args.analytics_read_only,
profiling_args.profiling,
mock_location,
filtering_configuration,
&common.output,
application,
Expand Down
1 change: 1 addition & 0 deletions src/cli/ios/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ Second example: If you choose --device iPhone-11 then you will receive an error
retry_args.retry_quota_test_reactive,
analytics_args.analytics_read_only,
false,
false,
filtering_configuration,
&common.output,
Some(application),
Expand Down
9 changes: 9 additions & 0 deletions src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ impl Cli {
application_bundle,
library_bundle,
profiling_args,
mock_location,
} => {
android::run(
application,
Expand All @@ -74,6 +75,7 @@ impl Cli {
pull_files,
application_bundle,
library_bundle,
mock_location,
)
.await
}
Expand Down Expand Up @@ -479,6 +481,13 @@ The format is '<test_apk_path>'.
Example: '--library-bundle apks/library1-debug-androidTest.apk --library-bundle apks/library2-debug-androidTest.apk'"
)]
library_bundle: Option<Vec<PathBuf>>,

#[arg(
long,
default_value_t = false,
help = "Allow mock location access for application"
)]
mock_location: bool,
},
#[allow(non_camel_case_types)]
#[command(name = "ios")]
Expand Down
2 changes: 2 additions & 0 deletions src/interactor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ impl TriggerTestRunInteractor {
retry_quota_test_reactive: Option<u32>,
analytics_read_only: Option<bool>,
profiling: bool,
mock_location: bool,
filtering_configuration: Option<SparseMarathonfile>,
output: &Option<PathBuf>,
application: Option<PathBuf>,
Expand Down Expand Up @@ -167,6 +168,7 @@ impl TriggerTestRunInteractor {
retry_quota_test_reactive,
analytics_read_only,
profiling,
mock_location,
filtering_configuration,
no_progress_bars,
flavor,
Expand Down

0 comments on commit d56d9f5

Please sign in to comment.