mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
This adds some more tests to the parsing of preferences, especially some
non-obvious ones. Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
This commit is contained in:
parent
e9e6f59c8b
commit
488a395370
2 changed files with 57 additions and 1 deletions
|
@ -172,7 +172,7 @@ impl DebugOptions {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
|
||||
pub enum OutputOptions {
|
||||
/// Database connection config (hostname, name, user, pass)
|
||||
FileName(String),
|
||||
|
|
|
@ -705,3 +705,59 @@ fn test_create_prefs_map() {
|
|||
}";
|
||||
assert_eq!(read_prefs_map(json_str).len(), 3);
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
fn test_parse(arg: &str) -> (Opts, Preferences, ServoShellPreferences) {
|
||||
let args = vec!["servo".to_string(), arg.to_string()];
|
||||
match parse_command_line_arguments(args) {
|
||||
ArgumentParsingResult::ContentProcess(..) => {
|
||||
unreachable!("No preferences for content process")
|
||||
},
|
||||
ArgumentParsingResult::ChromeProcess(opts, preferences, servoshell_preferences) => {
|
||||
(opts, preferences, servoshell_preferences)
|
||||
},
|
||||
ArgumentParsingResult::Exit => panic!("should not happen"),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_profiling_args() {
|
||||
assert_eq!(
|
||||
test_parse("-p 10").0.time_profiling.unwrap(),
|
||||
OutputOptions::Stdout(10_f64)
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
test_parse("-p").0.time_profiling.unwrap(),
|
||||
OutputOptions::Stdout(5_f64)
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
test_parse("-p foo.txt").0.time_profiling.unwrap(),
|
||||
OutputOptions::FileName(String::from("foo.txt"))
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_servoshell_cmd() {
|
||||
assert_eq!(
|
||||
test_parse("-o foo.png").2.device_pixel_ratio_override,
|
||||
Some(1.0)
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
test_parse("--screen-size=1000x1000")
|
||||
.2
|
||||
.screen_size_override
|
||||
.unwrap(),
|
||||
Size2D::new(1000, 1000)
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
test_parse("--certificate-path=/tmp/test")
|
||||
.0
|
||||
.certificate_path
|
||||
.unwrap(),
|
||||
String::from("/tmp/test")
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue