Make unit tests pass on TravisCI.

This commit is contained in:
Josh Matthews 2017-04-29 10:03:02 -04:00
parent 0abd5bbabd
commit f3f9e28e88
6 changed files with 53 additions and 28 deletions

View file

@ -431,8 +431,11 @@ fn combinator_to_restyle_hint(combinator: Option<Combinator>) -> RestyleHint {
#[derive(Debug)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
struct Sensitivities {
/// The aspects of an selector which are sensitive.
pub struct Sensitivities {
/// The states which are sensitive.
pub states: ElementState,
/// Whether attributes are sensitive.
pub attrs: bool,
}
@ -469,11 +472,13 @@ impl Sensitivities {
/// change may have on the style of elements in the document.
#[derive(Debug)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
struct Dependency {
pub struct Dependency {
#[cfg_attr(feature = "servo", ignore_heap_size_of = "Arc")]
selector: SelectorInner<SelectorImpl>,
hint: RestyleHint,
sensitivities: Sensitivities,
/// The hint associated with this dependency.
pub hint: RestyleHint,
/// The sensitivities associated with this dependency.
pub sensitivities: Sensitivities,
}
@ -681,27 +686,9 @@ impl DependencySet {
}
}
}
}
#[test]
#[cfg(all(test, feature = "servo"))]
fn smoke_restyle_hints() {
use cssparser::Parser;
use selector_parser::SelectorParser;
use stylesheets::{Origin, Namespaces};
let namespaces = Namespaces::default();
let parser = SelectorParser {
stylesheet_origin: Origin::Author,
namespaces: &namespaces,
};
let mut dependencies = DependencySet::new();
let mut p = Parser::new(":not(:active) ~ label");
let selector = ComplexSelector::parse(&parser, &mut p).unwrap();
dependencies.note_selector(&selector);
assert_eq!(dependencies.len(), 1);
assert_eq!(dependencies.state_deps.len(), 1);
assert!(!dependencies.state_deps[0].sensitivities.states.is_empty());
assert!(dependencies.state_deps[0].hint.contains(RESTYLE_LATER_SIBLINGS));
/// Get the dependencies affected by state.
pub fn get_state_deps(&self) -> &[Dependency] {
&self.state_deps
}
}