mirror of
https://github.com/servo/servo.git
synced 2025-08-16 02:45:36 +01:00
Refactor util::prefs
operations to be methods on static struct.
This commit is contained in:
parent
307844a8c1
commit
22928f50ac
30 changed files with 166 additions and 162 deletions
|
@ -5,7 +5,7 @@
|
|||
use std::fs::{self, File};
|
||||
use std::io::{Read, Write};
|
||||
use util::basedir;
|
||||
use util::prefs::{PrefValue, extend_prefs, read_prefs_from_file, get_pref, set_pref, reset_pref};
|
||||
use util::prefs::{PREFS, PrefValue, read_prefs_from_file};
|
||||
|
||||
#[test]
|
||||
fn test_create_pref() {
|
||||
|
@ -30,20 +30,20 @@ fn test_get_set_reset_extend() {
|
|||
\"shell.homepage\": \"https://google.com\"\
|
||||
}";
|
||||
|
||||
assert_eq!(*get_pref("test"), PrefValue::Missing);
|
||||
set_pref("test", PrefValue::String("hi".to_owned()));
|
||||
assert_eq!(*get_pref("test"), PrefValue::String("hi".to_owned()));
|
||||
assert_eq!(*get_pref("shell.homepage"), PrefValue::String("http://servo.org".to_owned()));
|
||||
set_pref("shell.homepage", PrefValue::Boolean(true));
|
||||
assert_eq!(*get_pref("shell.homepage"), PrefValue::Boolean(true));
|
||||
reset_pref("shell.homepage");
|
||||
assert_eq!(*get_pref("shell.homepage"), PrefValue::String("http://servo.org".to_owned()));
|
||||
assert_eq!(*PREFS.get("test"), PrefValue::Missing);
|
||||
PREFS.set("test", PrefValue::String("hi".to_owned()));
|
||||
assert_eq!(*PREFS.get("test"), PrefValue::String("hi".to_owned()));
|
||||
assert_eq!(*PREFS.get("shell.homepage"), PrefValue::String("http://servo.org".to_owned()));
|
||||
PREFS.set("shell.homepage", PrefValue::Boolean(true));
|
||||
assert_eq!(*PREFS.get("shell.homepage"), PrefValue::Boolean(true));
|
||||
PREFS.reset("shell.homepage");
|
||||
assert_eq!(*PREFS.get("shell.homepage"), PrefValue::String("http://servo.org".to_owned()));
|
||||
|
||||
let extension = read_prefs_from_file(json_str.as_bytes()).unwrap();
|
||||
extend_prefs(extension);
|
||||
assert_eq!(*get_pref("shell.homepage"), PrefValue::String("https://google.com".to_owned()));
|
||||
assert_eq!(*get_pref("layout.writing-mode.enabled"), PrefValue::Boolean(true));
|
||||
assert_eq!(*get_pref("extra.stuff"), PrefValue::Boolean(false));
|
||||
PREFS.extend(extension);
|
||||
assert_eq!(*PREFS.get("shell.homepage"), PrefValue::String("https://google.com".to_owned()));
|
||||
assert_eq!(*PREFS.get("layout.writing-mode.enabled"), PrefValue::Boolean(true));
|
||||
assert_eq!(*PREFS.get("extra.stuff"), PrefValue::Boolean(false));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue