diff --git a/components/layout/lib.rs b/components/layout/lib.rs index 9f943cf48b3..b272ad503de 100644 --- a/components/layout/lib.rs +++ b/components/layout/lib.rs @@ -98,3 +98,4 @@ pub mod wrapper; // For unit tests: pub use fragment::Fragment; +pub use fragment::SpecificFragmentInfo; diff --git a/tests/unit/layout/size_of.rs b/tests/unit/layout/size_of.rs index 320f85e0169..08d11df86cd 100644 --- a/tests/unit/layout/size_of.rs +++ b/tests/unit/layout/size_of.rs @@ -3,24 +3,35 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use layout::Fragment; +use layout::SpecificFragmentInfo; use std::mem::size_of; +fn check_size_for(name: &'static str, expected: usize, actual: usize) { + if actual < expected { + panic!("Your changes have decreased the stack size of {} \ + from {} to {}. Good work! Please update the size in tests/unit/layout/size_of.rs", + name, expected, actual); + } + + if actual > expected { + panic!("Your changes have increased the stack size of {} \ + from {} to {}. Please consider choosing a design which avoids this increase. \ + If you feel that the increase is necessary, update the size in \ + tests/unit/layout/size_of.rs.", + name, expected, actual); + } +} + #[test] fn test_size_of_fragment() { let expected = 160; let actual = size_of::(); - - if actual < expected { - panic!("Your changes have decreased the stack size of layout::fragment::Fragment \ - from {} to {}. Good work! Please update the size in tests/unit/layout/size_of.rs", - expected, actual); - } - - if actual > expected { - panic!("Your changes have increased the stack size of layout::fragment::Fragment \ - from {} to {}. Please consider choosing a design which avoids this increase. \ - If you feel that the increase is necessary, update the size in \ - tests/unit/layout/size_of.rs.", - expected, actual); - } + check_size_for("layout::fragment::Fragment", expected, actual); +} + +#[test] +fn test_size_of_specific_fragment_info() { + let expected = 24; + let actual = size_of::(); + check_size_for("layout::fragment::SpecificFragmentInfo", expected, actual); }