From 2e05190e687143030b83829422cac590177643c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sun, 24 Apr 2016 19:16:50 +0200 Subject: [PATCH] layout: Add test for size of ServoThreadSafeLayoutNode --- components/layout/lib.rs | 1 + tests/unit/layout/size_of.rs | 25 +++++++++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/components/layout/lib.rs b/components/layout/lib.rs index f4978023d76..22dc6546629 100644 --- a/components/layout/lib.rs +++ b/components/layout/lib.rs @@ -103,3 +103,4 @@ mod wrapper; // For unit tests: pub use fragment::Fragment; +pub use wrapper::ServoThreadSafeLayoutNode; diff --git a/tests/unit/layout/size_of.rs b/tests/unit/layout/size_of.rs index f79e352cdc9..87f1dcb3d44 100644 --- a/tests/unit/layout/size_of.rs +++ b/tests/unit/layout/size_of.rs @@ -3,6 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use layout::Fragment; +use layout::ServoThreadSafeLayoutNode; use std::mem::size_of; #[test] @@ -12,7 +13,7 @@ fn test_size_of_fragment() { 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/layout/size_of.rs", + from {} to {}. Good work! Please update the size in tests/unit/layout/size_of.rs", expected, actual); } @@ -20,7 +21,27 @@ fn test_size_of_fragment() { 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/layout/size_of.rs.", + tests/unit/layout/size_of.rs.", + expected, actual); + } +} + +#[test] +fn test_size_of_layout_node() { + let expected = 16; + let actual = size_of::(); + + if actual < expected { + panic!("Your changes have decreased the stack size of layout::wrapper::ServoThreadSafeLayoutNode \ + from {} to {}. Good work! Please update the size in tests/layout/unit/size_of.rs", + expected, actual); + } + + if actual > expected { + panic!("Your changes have increased the stack size of layout::wrapper::ServoThreadSafeLayoutNode \ + 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); } }