summaryrefslogtreecommitdiffstats
path: root/testing/geckodriver/marionette/src/marionette.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /testing/geckodriver/marionette/src/marionette.rs
parentInitial commit. (diff)
downloadthunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz
thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--testing/geckodriver/marionette/src/marionette.rs69
1 files changed, 69 insertions, 0 deletions
diff --git a/testing/geckodriver/marionette/src/marionette.rs b/testing/geckodriver/marionette/src/marionette.rs
new file mode 100644
index 0000000000..c06e2d60c7
--- /dev/null
+++ b/testing/geckodriver/marionette/src/marionette.rs
@@ -0,0 +1,69 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+use serde::{Deserialize, Serialize};
+
+use crate::common::BoolValue;
+
+#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
+#[allow(non_camel_case_types)]
+pub enum AppStatus {
+ eAttemptQuit,
+ eConsiderQuit,
+ eForceQuit,
+ eRestart,
+}
+
+#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
+pub enum Command {
+ #[serde(rename = "Marionette:AcceptConnections")]
+ AcceptConnections(BoolValue),
+ #[serde(rename = "Marionette:Quit")]
+ DeleteSession { flags: Vec<AppStatus> },
+ #[serde(rename = "Marionette:GetContext")]
+ GetContext,
+ #[serde(rename = "Marionette:GetScreenOrientation")]
+ GetScreenOrientation,
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use crate::test::assert_ser_de;
+ use serde_json::json;
+
+ #[test]
+ fn test_json_command_accept_connections() {
+ assert_ser_de(
+ &Command::AcceptConnections(BoolValue::new(false)),
+ json!({"Marionette:AcceptConnections": {"value": false }}),
+ );
+ }
+
+ #[test]
+ fn test_json_command_delete_session() {
+ let data = &Command::DeleteSession {
+ flags: vec![AppStatus::eForceQuit],
+ };
+ assert_ser_de(data, json!({"Marionette:Quit": {"flags": ["eForceQuit"]}}));
+ }
+
+ #[test]
+ fn test_json_command_get_context() {
+ assert_ser_de(&Command::GetContext, json!("Marionette:GetContext"));
+ }
+
+ #[test]
+ fn test_json_command_get_screen_orientation() {
+ assert_ser_de(
+ &Command::GetScreenOrientation,
+ json!("Marionette:GetScreenOrientation"),
+ );
+ }
+
+ #[test]
+ fn test_json_command_invalid() {
+ assert!(serde_json::from_value::<Command>(json!("foo")).is_err());
+ }
+}