mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Added test for serialize method
This commit is contained in:
parent
839a7559e7
commit
47279179fa
1 changed files with 39 additions and 0 deletions
|
@ -7,6 +7,10 @@ use std::env;
|
|||
use std::fs::{File, remove_file};
|
||||
use std::path::Path;
|
||||
use std::process::Command;
|
||||
use std::sync::Arc;
|
||||
use style::computed_values::display::T::inline_block;
|
||||
use style::properties::{PropertyDeclaration, PropertyDeclarationBlock, DeclaredValue};
|
||||
use style::values::specified::{Length, LengthOrPercentageOrAuto, LengthOrPercentage};
|
||||
|
||||
#[test]
|
||||
fn properties_list_json() {
|
||||
|
@ -51,3 +55,38 @@ fn find_python() -> String {
|
|||
"python"
|
||||
}.to_owned()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn property_declaration_block_should_serialize_correctly() {
|
||||
let mut normal = Vec::new();
|
||||
let mut important = Vec::new();
|
||||
|
||||
let length = LengthOrPercentageOrAuto::Length(Length::from_px(70f32));
|
||||
let value = DeclaredValue::Value(length);
|
||||
normal.push(PropertyDeclaration::Width(value));
|
||||
|
||||
let min_height = LengthOrPercentage::Length(Length::from_px(20f32));
|
||||
let value = DeclaredValue::Value(min_height);
|
||||
normal.push(PropertyDeclaration::MinHeight(value));
|
||||
|
||||
let value = DeclaredValue::Value(inline_block);
|
||||
normal.push(PropertyDeclaration::Display(value));
|
||||
|
||||
let height = LengthOrPercentageOrAuto::Length(Length::from_px(20f32));
|
||||
let value = DeclaredValue::Value(height);
|
||||
important.push(PropertyDeclaration::Height(value));
|
||||
|
||||
normal.reverse();
|
||||
important.reverse();
|
||||
let block = PropertyDeclarationBlock {
|
||||
normal: Arc::new(normal),
|
||||
important: Arc::new(important)
|
||||
};
|
||||
|
||||
let css_string = block.serialize();
|
||||
|
||||
assert_eq!(
|
||||
css_string,
|
||||
"width: 70px; min-height: 20px; display: inline-block; height: 20px ! important;"
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue