aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMs2ger <Ms2ger@gmail.com>2016-06-08 11:55:47 +0200
committerMs2ger <Ms2ger@gmail.com>2016-12-22 15:58:53 +0100
commit86d59212feef057dd2b36e99c22e6903b09993fd (patch)
tree3ca4204e8f9a778b1d9408579805fb7e9d970820 /tests
parentb843be49752c68926521a8b5f6b0405b1ff01e9b (diff)
downloadservo-86d59212feef057dd2b36e99c22e6903b09993fd.tar.gz
servo-86d59212feef057dd2b36e99c22e6903b09993fd.zip
Introduce a script::test module to expose the APIs needed for unit tests.
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/script/headers.rs17
-rw-r--r--tests/unit/script/size_of.rs15
-rw-r--r--tests/unit/script/textinput.rs2
3 files changed, 12 insertions, 22 deletions
diff --git a/tests/unit/script/headers.rs b/tests/unit/script/headers.rs
index 5334056ec70..e990b706cdd 100644
--- a/tests/unit/script/headers.rs
+++ b/tests/unit/script/headers.rs
@@ -2,14 +2,13 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-use script::dom::bindings::str::ByteString;
-use script::dom::headers;
+use script::test::{ByteString, normalize_value};
#[test]
fn test_normalize_empty_bytestring() {
// empty ByteString test
let empty_bytestring = ByteString::new(vec![]);
- let actual = headers::normalize_value(empty_bytestring);
+ let actual = normalize_value(empty_bytestring);
let expected = ByteString::new(vec![]);
assert_eq!(actual, expected);
}
@@ -18,7 +17,7 @@ fn test_normalize_empty_bytestring() {
fn test_normalize_all_whitespace_bytestring() {
// All whitespace test. A horizontal tab, a line feed, a carriage return , and a space
let all_whitespace_bytestring = ByteString::new(vec![b'\t', b'\n', b'\r', b' ']);
- let actual = headers::normalize_value(all_whitespace_bytestring);
+ let actual = normalize_value(all_whitespace_bytestring);
let expected = ByteString::new(vec![]);
assert_eq!(actual, expected);
}
@@ -27,7 +26,7 @@ fn test_normalize_all_whitespace_bytestring() {
fn test_normalize_non_empty_no_whitespace_bytestring() {
// Non-empty, no whitespace ByteString test
let no_whitespace_bytestring = ByteString::new(vec![b'S', b'!']);
- let actual = headers::normalize_value(no_whitespace_bytestring);
+ let actual = normalize_value(no_whitespace_bytestring);
let expected = ByteString::new(vec![b'S', b'!']);
assert_eq!(actual, expected);
}
@@ -36,7 +35,7 @@ fn test_normalize_non_empty_no_whitespace_bytestring() {
fn test_normalize_non_empty_leading_whitespace_bytestring() {
// Non-empty, leading whitespace, no trailing whitespace ByteString test
let leading_whitespace_bytestring = ByteString::new(vec![b'\t', b'\n', b' ', b'\r', b'S', b'!']);
- let actual = headers::normalize_value(leading_whitespace_bytestring);
+ let actual = normalize_value(leading_whitespace_bytestring);
let expected = ByteString::new(vec![b'S', b'!']);
assert_eq!(actual, expected);
}
@@ -45,7 +44,7 @@ fn test_normalize_non_empty_leading_whitespace_bytestring() {
fn test_normalize_non_empty_no_leading_whitespace_trailing_whitespace_bytestring() {
// Non-empty, no leading whitespace, but with trailing whitespace ByteString test
let trailing_whitespace_bytestring = ByteString::new(vec![b'S', b'!', b'\t', b'\n', b' ', b'\r']);
- let actual = headers::normalize_value(trailing_whitespace_bytestring);
+ let actual = normalize_value(trailing_whitespace_bytestring);
let expected = ByteString::new(vec![b'S', b'!']);
assert_eq!(actual, expected);
}
@@ -55,7 +54,7 @@ fn test_normalize_non_empty_leading_and_trailing_whitespace_bytestring() {
// Non-empty, leading whitespace, and trailing whitespace ByteString test
let whitespace_sandwich_bytestring =
ByteString::new(vec![b'\t', b'\n', b' ', b'\r', b'S', b'!', b'\t', b'\n', b' ', b'\r']);
- let actual = headers::normalize_value(whitespace_sandwich_bytestring);
+ let actual = normalize_value(whitespace_sandwich_bytestring);
let expected = ByteString::new(vec![b'S', b'!']);
assert_eq!(actual, expected);
}
@@ -68,7 +67,7 @@ fn test_normalize_non_empty_leading_trailing_and_internal_whitespace_bytestring(
ByteString::new(vec![b'\t', b'\n', b' ', b'\r', b'S',
b'\t', b'\n', b' ', b'\r', b'!',
b'\t', b'\n', b' ', b'\r']);
- let actual = headers::normalize_value(whitespace_bigmac_bytestring);
+ let actual = normalize_value(whitespace_bigmac_bytestring);
let expected = ByteString::new(vec![b'S', b'\t', b'\n', b' ', b'\r', b'!']);
assert_eq!(actual, expected);
}
diff --git a/tests/unit/script/size_of.rs b/tests/unit/script/size_of.rs
index 3930180a9cf..64a2f37e67d 100644
--- a/tests/unit/script/size_of.rs
+++ b/tests/unit/script/size_of.rs
@@ -2,25 +2,16 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-use script::dom::characterdata::CharacterData;
-use script::dom::element::Element;
-use script::dom::eventtarget::EventTarget;
-use script::dom::htmldivelement::HTMLDivElement;
-use script::dom::htmlelement::HTMLElement;
-use script::dom::htmlspanelement::HTMLSpanElement;
-use script::dom::node::Node;
-use script::dom::text::Text;
-use script::layout_wrapper::ServoThreadSafeLayoutNode;
-use std::mem::size_of;
+use script::test::size_of;
// Macro so that we can stringify type names
// I'd really prefer the tests themselves to be run at plugin time,
// however rustc::middle doesn't have access to the full type data
macro_rules! sizeof_checker (
- ($testname: ident, $t:ty, $known_size:expr) => (
+ ($testname: ident, $t: ident, $known_size: expr) => (
#[test]
fn $testname() {
- let new = size_of::<$t>();
+ let new = size_of::$t();
let old = $known_size;
if new < old {
panic!("Your changes have decreased the stack size of commonly used DOM struct {} from {} to {}. \
diff --git a/tests/unit/script/textinput.rs b/tests/unit/script/textinput.rs
index 677132d393c..01e28433ed6 100644
--- a/tests/unit/script/textinput.rs
+++ b/tests/unit/script/textinput.rs
@@ -13,7 +13,7 @@ use msg::constellation_msg::CONTROL;
#[cfg(target_os = "macos")]
use msg::constellation_msg::SUPER;
use script::clipboard_provider::DummyClipboardContext;
-use script::dom::bindings::str::DOMString;
+use script::test::DOMString;
use script::textinput::{TextInput, TextPoint, Selection, Lines, Direction, SelectionDirection};
fn text_input(lines: Lines, s: &str) -> TextInput<DummyClipboardContext> {