Skip to content
Permalink
Browse files

fixup! Use iterators for iterating through CSS rules

Update the media queries unit tests to use iterators
  • Loading branch information...
luniv committed Apr 10, 2015
1 parent 85dcc2d commit f9b5de75f2881d0616023b11ae304eda0ca401c6
Showing with 5 additions and 6 deletions.
  1. +5 −6 tests/unit/style/media_queries.rs
@@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

use geom::size::TypedSize2D;
use style::stylesheets::{iter_stylesheet_media_rules, iter_stylesheet_style_rules, Stylesheet};
use style::stylesheets::{Stylesheet, CSSRuleIteratorExt};
use style::stylesheets::Origin;
use style::media_queries::*;
use style::values::specified;
@@ -16,18 +16,17 @@ fn test_media_rule<F>(css: &str, callback: F) where F: Fn(&MediaQueryList, &str)
let url = Url::parse("http://localhost").unwrap();
let stylesheet = Stylesheet::from_str(css, url, Origin::Author);
let mut rule_count = 0;
iter_stylesheet_media_rules(&stylesheet, |rule| {
for rule in stylesheet.rules().media() {
rule_count += 1;
callback(&rule.media_queries, css);
});
}
assert!(rule_count > 0);
}

fn media_query_test(device: &Device, css: &str, expected_rule_count: u32) {
fn media_query_test(device: &Device, css: &str, expected_rule_count: usize) {
let url = Url::parse("http://localhost").unwrap();
let ss = Stylesheet::from_str(css, url, Origin::Author);
let mut rule_count: u32 = 0;
iter_stylesheet_style_rules(&ss, device, |_| rule_count += 1);
let rule_count = ss.effective_rules(device).style().count();
assert!(rule_count == expected_rule_count, css.to_owned());
}

0 comments on commit f9b5de7

Please sign in to comment.
You can’t perform that action at this time.