Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse sizes attribute implementation #10989

Closed
wants to merge 6 commits into from
Closed
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

test cases

  • Loading branch information
sneha1302 committed May 4, 2016
commit 263c652ff554c998272ed0887d9e3a1e7bd030e9

Some generated files are not rendered by default. Learn more.

@@ -13,5 +13,12 @@ msg = {path = "../../../components/msg"}
plugins = {path = "../../../components/plugins"}
script = {path = "../../../components/script"}
style = {path = "../../../components/style"}
style_traits = {path = "../../../components/style_traits"}
util = {path = "../../../components/util"}
app_units = {version = "0.2.3", features = ["plugins"]}
cssparser = {version = "0.5.4", features = ["heap_size"]}
euclid = {version = "0.6.4", features = ["plugins"]}
selectors = {version = "0.5", features = ["heap_size"]}
string_cache = {version = "0.2", features = ["heap_size"]}
url = {version = "1.0.0", features = ["heap_size"]}
rustc-serialize = "0.3"
@@ -5,37 +5,61 @@
#![feature(plugin)]
#![plugin(plugins)]

//use cssparser::Parser;
use script::dom::htmlimageelement::parse_a_sizes_attribute;
//use style::values::specified::{Length, ViewportPercentageLength};
use script::dom::htmlimageelement::Size;
extern crate app_units;
extern crate cssparser;
extern crate style;

use app_units::Au;
use cssparser::{Parser, SourcePosition};
use script::dom::htmlimageelement::{parse_a_sizes_attribute, Size};
use style::media_queries::*;
use style::values::specified;
use util::str::DOMString;

#[test]
fn some_parse_sizes_test() {
let result = parse_a_sizes_attribute(DOMString::from("(min-width: 900px) 1000px,
(max-width: 900px) and (min-width: 400px) 50em,
100vw"),
100vw "),
None);
assert_eq!(result.len(), 3);
}

//testing the second element which has two expressions
#[test]
fn some_parse_sizes_1_test() {
let mut result = parse_a_sizes_attribute(DOMString::from("(min-width: 900px) 1000px,
(max-width: 900px) and (min-width: 400px) 50em,
100vw "),
None);
let trimmed = "100vw";
let mut component = result.pop();
let mut component_secondlast = result.pop();
if component_secondlast.is_some() {
let component_query = component_secondlast.unwrap().query;
if component_query.is_some(){
if component_query.is_some() {
let component_query_expr = component_query.unwrap().expressions;
assert_eq!(component_query_expr.len() , 2);
}
}
}
}

#[test]
fn some_parse_sizes_2_test() {
let mut result = parse_a_sizes_attribute(DOMString::from("(min-width: 900px) 1000px,
(max-width: 900px) and (min-width: 400px) 50em,
100vw "),
None);
let mut component = result.pop();
let mut component_secondlast_1 = result.pop();
let mut component_first = result.pop();
if component_first.is_some() {
let component_query = component_first.unwrap().query;
if component_query.is_some() {
let component_query_expr = component_query.unwrap().expressions;
match component_query_expr[0] {
Expression::Width(Range::Min(w)) => assert!(w == specified::Length::Absolute(Au::from_px(900))),
_ => panic!("wrong expression type"),
}
}
}
}
extern crate msg;
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.