Update rustdoc tests
This commit is contained in:
parent
0395fc2242
commit
673fd23dff
10 changed files with 72 additions and 156 deletions
|
@ -23,7 +23,7 @@ fn test_html_highlighting() {
|
||||||
let src = include_str!("fixtures/sample.rs");
|
let src = include_str!("fixtures/sample.rs");
|
||||||
let html = {
|
let html = {
|
||||||
let mut out = Buffer::new();
|
let mut out = Buffer::new();
|
||||||
write_code(&mut out, src, None, None);
|
write_code(&mut out, src, None, None, None);
|
||||||
format!("{STYLE}<pre><code>{}</code></pre>\n", out.into_inner())
|
format!("{STYLE}<pre><code>{}</code></pre>\n", out.into_inner())
|
||||||
};
|
};
|
||||||
expect_file!["fixtures/sample.html"].assert_eq(&html);
|
expect_file!["fixtures/sample.html"].assert_eq(&html);
|
||||||
|
@ -37,7 +37,7 @@ fn test_dos_backline() {
|
||||||
println!(\"foo\");\r\n\
|
println!(\"foo\");\r\n\
|
||||||
}\r\n";
|
}\r\n";
|
||||||
let mut html = Buffer::new();
|
let mut html = Buffer::new();
|
||||||
write_code(&mut html, src, None, None);
|
write_code(&mut html, src, None, None, None);
|
||||||
expect_file!["fixtures/dos_line.html"].assert_eq(&html.into_inner());
|
expect_file!["fixtures/dos_line.html"].assert_eq(&html.into_inner());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ let x = super::b::foo;
|
||||||
let y = Self::whatever;";
|
let y = Self::whatever;";
|
||||||
|
|
||||||
let mut html = Buffer::new();
|
let mut html = Buffer::new();
|
||||||
write_code(&mut html, src, None, None);
|
write_code(&mut html, src, None, None, None);
|
||||||
expect_file!["fixtures/highlight.html"].assert_eq(&html.into_inner());
|
expect_file!["fixtures/highlight.html"].assert_eq(&html.into_inner());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ fn test_union_highlighting() {
|
||||||
create_default_session_globals_then(|| {
|
create_default_session_globals_then(|| {
|
||||||
let src = include_str!("fixtures/union.rs");
|
let src = include_str!("fixtures/union.rs");
|
||||||
let mut html = Buffer::new();
|
let mut html = Buffer::new();
|
||||||
write_code(&mut html, src, None, None);
|
write_code(&mut html, src, None, None, None);
|
||||||
expect_file!["fixtures/union.html"].assert_eq(&html.into_inner());
|
expect_file!["fixtures/union.html"].assert_eq(&html.into_inner());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ let a = 4;";
|
||||||
decorations.insert("example2", vec![(22, 32)]);
|
decorations.insert("example2", vec![(22, 32)]);
|
||||||
|
|
||||||
let mut html = Buffer::new();
|
let mut html = Buffer::new();
|
||||||
write_code(&mut html, src, None, Some(&DecorationInfo(decorations)));
|
write_code(&mut html, src, None, Some(&DecorationInfo(decorations)), None);
|
||||||
expect_file!["fixtures/decorations.html"].assert_eq(&html.into_inner());
|
expect_file!["fixtures/decorations.html"].assert_eq(&html.into_inner());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
// Small test to ensure the "src-line-numbers" element is only present once on
|
|
||||||
// the page.
|
|
||||||
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
|
|
||||||
click: "a.src"
|
|
||||||
wait-for: ".src-line-numbers"
|
|
||||||
assert-count: (".src-line-numbers", 1)
|
|
|
@ -111,28 +111,6 @@ wait-for: "pre.example-line-numbers"
|
||||||
// Same check with scraped examples line numbers.
|
// Same check with scraped examples line numbers.
|
||||||
go-to: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html"
|
go-to: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html"
|
||||||
|
|
||||||
assert-css: (
|
|
||||||
".scraped-example .src-line-numbers > pre",
|
|
||||||
{
|
|
||||||
// There should not be a radius on the right of the line numbers.
|
|
||||||
"border-top-left-radius": "6px",
|
|
||||||
"border-bottom-left-radius": "6px",
|
|
||||||
"border-top-right-radius": "0px",
|
|
||||||
"border-bottom-right-radius": "0px",
|
|
||||||
},
|
|
||||||
ALL,
|
|
||||||
)
|
|
||||||
assert-css: (
|
|
||||||
".scraped-example .src-line-numbers",
|
|
||||||
{
|
|
||||||
// There should not be a radius on the right of the line numbers.
|
|
||||||
"border-top-left-radius": "6px",
|
|
||||||
"border-bottom-left-radius": "6px",
|
|
||||||
"border-top-right-radius": "0px",
|
|
||||||
"border-bottom-right-radius": "0px",
|
|
||||||
},
|
|
||||||
ALL,
|
|
||||||
)
|
|
||||||
assert-css: (
|
assert-css: (
|
||||||
".scraped-example .rust",
|
".scraped-example .rust",
|
||||||
{
|
{
|
||||||
|
@ -149,23 +127,15 @@ define-function: (
|
||||||
"check-padding",
|
"check-padding",
|
||||||
[path, padding_bottom],
|
[path, padding_bottom],
|
||||||
block {
|
block {
|
||||||
assert-css: (|path| + " .src-line-numbers", {
|
assert-css: (|path| + " span[data-nosnippet]", {
|
||||||
"padding-top": "0px",
|
"padding-top": "0px",
|
||||||
"padding-bottom": "0px",
|
"padding-bottom": "0px",
|
||||||
"padding-left": "0px",
|
"padding-left": "4px",
|
||||||
"padding-right": "0px",
|
"padding-right": "4px",
|
||||||
}, ALL)
|
"margin-right": "20px",
|
||||||
assert-css: (|path| + " .src-line-numbers > pre", {
|
"margin-left": "0px",
|
||||||
"padding-top": "14px",
|
"margin-top": "0px",
|
||||||
"padding-bottom": |padding_bottom|,
|
"margin-bottom": "0px",
|
||||||
"padding-left": "0px",
|
|
||||||
"padding-right": "0px",
|
|
||||||
}, ALL)
|
|
||||||
assert-css: (|path| + " .src-line-numbers > pre > span", {
|
|
||||||
"padding-top": "0px",
|
|
||||||
"padding-bottom": "0px",
|
|
||||||
"padding-left": "8px",
|
|
||||||
"padding-right": "8px",
|
|
||||||
}, ALL)
|
}, ALL)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -196,13 +166,13 @@ define-function: ("check-line-numbers-existence", [], block {
|
||||||
wait-for-local-storage-false: {"rustdoc-line-numbers": "true" }
|
wait-for-local-storage-false: {"rustdoc-line-numbers": "true" }
|
||||||
assert-false: ".example-line-numbers"
|
assert-false: ".example-line-numbers"
|
||||||
// Line numbers should still be there.
|
// Line numbers should still be there.
|
||||||
assert: ".src-line-numbers"
|
assert-css: ("[data-nosnippet]", { "display": "inline-block"})
|
||||||
// Now disabling the setting.
|
// Now disabling the setting.
|
||||||
click: "input#line-numbers"
|
click: "input#line-numbers"
|
||||||
wait-for-local-storage: {"rustdoc-line-numbers": "true" }
|
wait-for-local-storage: {"rustdoc-line-numbers": "true" }
|
||||||
assert-false: ".example-line-numbers"
|
assert-false: ".example-line-numbers"
|
||||||
// Line numbers should still be there.
|
// Line numbers should still be there.
|
||||||
assert: ".src-line-numbers"
|
assert-css: ("[data-nosnippet]", { "display": "inline-block"})
|
||||||
// Closing settings menu.
|
// Closing settings menu.
|
||||||
click: "#settings-menu"
|
click: "#settings-menu"
|
||||||
wait-for-css: ("#settings", {"display": "none"})
|
wait-for-css: ("#settings", {"display": "none"})
|
||||||
|
@ -214,18 +184,16 @@ call-function: ("check-line-numbers-existence", {})
|
||||||
|
|
||||||
// Now checking the line numbers in the source code page.
|
// Now checking the line numbers in the source code page.
|
||||||
click: ".src"
|
click: ".src"
|
||||||
assert-css: (".src-line-numbers", {
|
assert-css: ("a[data-nosnippet]", {
|
||||||
"padding-top": "20px",
|
|
||||||
"padding-bottom": "20px",
|
|
||||||
"padding-left": "4px",
|
|
||||||
"padding-right": "0px",
|
|
||||||
})
|
|
||||||
assert-css: (".src-line-numbers > a", {
|
|
||||||
"padding-top": "0px",
|
"padding-top": "0px",
|
||||||
"padding-bottom": "0px",
|
"padding-bottom": "0px",
|
||||||
"padding-left": "8px",
|
"padding-left": "4px",
|
||||||
"padding-right": "8px",
|
"padding-right": "4px",
|
||||||
})
|
"margin-top": "0px",
|
||||||
|
"margin-bottom": "0px",
|
||||||
|
"margin-left": "0px",
|
||||||
|
"margin-right": "20px",
|
||||||
|
}, ALL)
|
||||||
// Checking that turning off the line numbers setting won't remove line numbers.
|
// Checking that turning off the line numbers setting won't remove line numbers.
|
||||||
call-function: ("check-line-numbers-existence", {})
|
call-function: ("check-line-numbers-existence", {})
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ define-function: (
|
||||||
block {
|
block {
|
||||||
call-function: ("switch-theme", {"theme": |theme|})
|
call-function: ("switch-theme", {"theme": |theme|})
|
||||||
assert-css: (
|
assert-css: (
|
||||||
"body.src .example-wrap pre.rust a",
|
"body.src .example-wrap pre.rust a:not([data-nosnippet])",
|
||||||
{"background-color": |background_color|},
|
{"background-color": |background_color|},
|
||||||
ALL,
|
ALL,
|
||||||
)
|
)
|
||||||
|
|
|
@ -4,52 +4,18 @@ go-to: "file://" + |DOC_PATH| + "/scrape_examples/fn.test.html"
|
||||||
|
|
||||||
// The next/prev buttons vertically scroll the code viewport between examples
|
// The next/prev buttons vertically scroll the code viewport between examples
|
||||||
move-cursor-to: ".scraped-example-list > .scraped-example"
|
move-cursor-to: ".scraped-example-list > .scraped-example"
|
||||||
store-property: (".scraped-example-list > .scraped-example .src-line-numbers", {
|
wait-for: ".scraped-example-list > .scraped-example .next"
|
||||||
"scrollTop": initialScrollTop,
|
store-value: (initialScrollTop, 250)
|
||||||
})
|
|
||||||
assert-property: (".scraped-example-list > .scraped-example .rust", {
|
assert-property: (".scraped-example-list > .scraped-example .rust", {
|
||||||
"scrollTop": |initialScrollTop|,
|
"scrollTop": |initialScrollTop|,
|
||||||
})
|
}, NEAR)
|
||||||
focus: ".scraped-example-list > .scraped-example .next"
|
focus: ".scraped-example-list > .scraped-example .next"
|
||||||
press-key: "Enter"
|
press-key: "Enter"
|
||||||
assert-property-false: (".scraped-example-list > .scraped-example .src-line-numbers", {
|
|
||||||
"scrollTop": |initialScrollTop|
|
|
||||||
}, NEAR)
|
|
||||||
assert-property-false: (".scraped-example-list > .scraped-example .rust", {
|
assert-property-false: (".scraped-example-list > .scraped-example .rust", {
|
||||||
"scrollTop": |initialScrollTop|
|
"scrollTop": |initialScrollTop|
|
||||||
}, NEAR)
|
}, NEAR)
|
||||||
focus: ".scraped-example-list > .scraped-example .prev"
|
focus: ".scraped-example-list > .scraped-example .prev"
|
||||||
press-key: "Enter"
|
press-key: "Enter"
|
||||||
assert-property: (".scraped-example-list > .scraped-example .src-line-numbers", {
|
|
||||||
"scrollTop": |initialScrollTop|
|
|
||||||
}, NEAR)
|
|
||||||
assert-property: (".scraped-example-list > .scraped-example .rust", {
|
assert-property: (".scraped-example-list > .scraped-example .rust", {
|
||||||
"scrollTop": |initialScrollTop|
|
"scrollTop": |initialScrollTop|
|
||||||
}, NEAR)
|
}, NEAR)
|
||||||
|
|
||||||
// The expand button increases the scrollHeight of the minimized code viewport
|
|
||||||
store-property: (".scraped-example-list > .scraped-example pre", {"offsetHeight": smallOffsetHeight})
|
|
||||||
assert-property: (".scraped-example-list > .scraped-example .src-line-numbers", {
|
|
||||||
"scrollHeight": |smallOffsetHeight|
|
|
||||||
}, NEAR)
|
|
||||||
assert-property: (".scraped-example-list > .scraped-example .rust", {
|
|
||||||
"scrollHeight": |smallOffsetHeight|
|
|
||||||
}, NEAR)
|
|
||||||
focus: ".scraped-example-list > .scraped-example .expand"
|
|
||||||
press-key: "Enter"
|
|
||||||
assert-property-false: (".scraped-example-list > .scraped-example .src-line-numbers", {
|
|
||||||
"offsetHeight": |smallOffsetHeight|
|
|
||||||
}, NEAR)
|
|
||||||
assert-property-false: (".scraped-example-list > .scraped-example .rust", {
|
|
||||||
"offsetHeight": |smallOffsetHeight|
|
|
||||||
}, NEAR)
|
|
||||||
store-property: (".scraped-example-list > .scraped-example .src-line-numbers", {
|
|
||||||
"offsetHeight": fullOffsetHeight,
|
|
||||||
})
|
|
||||||
assert-property: (".scraped-example-list > .scraped-example .rust", {
|
|
||||||
"offsetHeight": |fullOffsetHeight|,
|
|
||||||
"scrollHeight": |fullOffsetHeight|,
|
|
||||||
})
|
|
||||||
assert-property: (".scraped-example-list > .scraped-example .src-line-numbers", {
|
|
||||||
"scrollHeight": |fullOffsetHeight|
|
|
||||||
}, NEAR)
|
|
||||||
|
|
|
@ -3,35 +3,38 @@ go-to: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html"
|
||||||
|
|
||||||
set-window-size: (1000, 1000)
|
set-window-size: (1000, 1000)
|
||||||
|
|
||||||
|
// We move the mouse over the scraped example for the prev button to be generated.
|
||||||
|
move-cursor-to: ".scraped-example"
|
||||||
|
|
||||||
// Check that it's not zero.
|
// Check that it's not zero.
|
||||||
assert-property-false: (
|
assert-property-false: (
|
||||||
".more-scraped-examples .scraped-example .src-line-numbers",
|
".more-scraped-examples .scraped-example span[data-nosnippet]",
|
||||||
{"clientWidth": "0"}
|
{"clientWidth": "0"}
|
||||||
)
|
)
|
||||||
|
|
||||||
// Check that examples with very long lines have the same width as ones that don't.
|
// Check that examples with very long lines have the same width as ones that don't.
|
||||||
store-property: (
|
store-property: (
|
||||||
".more-scraped-examples .scraped-example:nth-child(2) .src-line-numbers",
|
".more-scraped-examples .scraped-example:nth-child(2) span[data-nosnippet]",
|
||||||
{"clientWidth": clientWidth},
|
{"clientWidth": clientWidth},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert-property: (
|
assert-property: (
|
||||||
".more-scraped-examples .scraped-example:nth-child(3) .src-line-numbers",
|
".more-scraped-examples .scraped-example:nth-child(3) span[data-nosnippet]",
|
||||||
{"clientWidth": |clientWidth|}
|
{"clientWidth": |clientWidth|}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert-property: (
|
assert-property: (
|
||||||
".more-scraped-examples .scraped-example:nth-child(4) .src-line-numbers",
|
".more-scraped-examples .scraped-example:nth-child(4) span[data-nosnippet]",
|
||||||
{"clientWidth": |clientWidth|}
|
{"clientWidth": |clientWidth|}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert-property: (
|
assert-property: (
|
||||||
".more-scraped-examples .scraped-example:nth-child(5) .src-line-numbers",
|
".more-scraped-examples .scraped-example:nth-child(5) span[data-nosnippet]",
|
||||||
{"clientWidth": |clientWidth|}
|
{"clientWidth": |clientWidth|}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert-property: (
|
assert-property: (
|
||||||
".more-scraped-examples .scraped-example:nth-child(6) .src-line-numbers",
|
".more-scraped-examples .scraped-example:nth-child(6) span[data-nosnippet]",
|
||||||
{"clientWidth": |clientWidth|}
|
{"clientWidth": |clientWidth|}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -55,25 +58,6 @@ assert-size: (".more-scraped-examples .scraped-example .example-wrap", {
|
||||||
"width": |width|,
|
"width": |width|,
|
||||||
})
|
})
|
||||||
|
|
||||||
// Check that the expand button works and also that line number aligns with code.
|
|
||||||
move-cursor-to: ".scraped-example .rust"
|
|
||||||
click: ".scraped-example .button-holder .expand"
|
|
||||||
wait-for: ".scraped-example.expanded"
|
|
||||||
// They should have the same y position.
|
|
||||||
compare-elements-position: (
|
|
||||||
".scraped-example.expanded .src-line-numbers pre span",
|
|
||||||
".scraped-example.expanded .rust code",
|
|
||||||
["y"],
|
|
||||||
)
|
|
||||||
// And they should have the same height.
|
|
||||||
compare-elements-size: (
|
|
||||||
".scraped-example.expanded .src-line-numbers",
|
|
||||||
".scraped-example.expanded .rust",
|
|
||||||
["height"],
|
|
||||||
)
|
|
||||||
// Collapse code again.
|
|
||||||
click: ".scraped-example .button-holder .expand"
|
|
||||||
|
|
||||||
// Check that for both mobile and desktop sizes, the buttons in scraped examples are displayed
|
// Check that for both mobile and desktop sizes, the buttons in scraped examples are displayed
|
||||||
// correctly.
|
// correctly.
|
||||||
|
|
||||||
|
@ -98,7 +82,7 @@ define-function: (
|
||||||
[],
|
[],
|
||||||
block {
|
block {
|
||||||
// Title should be above the code.
|
// Title should be above the code.
|
||||||
store-position: (".scraped-example .example-wrap .src-line-numbers", {"x": x, "y": y})
|
store-position: (".scraped-example .example-wrap", {"x": x, "y": y})
|
||||||
store-size: (".scraped-example .scraped-example-title", { "height": title_height })
|
store-size: (".scraped-example .scraped-example-title", { "height": title_height })
|
||||||
|
|
||||||
assert-position: (".scraped-example .scraped-example-title", {
|
assert-position: (".scraped-example .scraped-example-title", {
|
||||||
|
@ -107,10 +91,13 @@ define-function: (
|
||||||
})
|
})
|
||||||
|
|
||||||
// Line numbers should be right beside the code.
|
// Line numbers should be right beside the code.
|
||||||
compare-elements-position: (
|
compare-elements-position-near: (
|
||||||
".scraped-example .example-wrap .src-line-numbers",
|
".scraped-example .example-wrap span[data-nosnippet]",
|
||||||
".scraped-example .example-wrap .rust",
|
// On the first line, the code starts with `fn main` so we have a keyword.
|
||||||
["y"],
|
".scraped-example .example-wrap .rust span.kw",
|
||||||
|
// They're not exactly the same size but since they're on the same line,
|
||||||
|
// it's kinda the same.
|
||||||
|
{"y": 2},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -8,13 +8,13 @@ set-window-size: (600, 800)
|
||||||
assert-property: ("html", {"scrollTop": "0"})
|
assert-property: ("html", {"scrollTop": "0"})
|
||||||
|
|
||||||
click: '//a[text() = "barbar" and @href="#5-7"]'
|
click: '//a[text() = "barbar" and @href="#5-7"]'
|
||||||
assert-property: ("html", {"scrollTop": "208"})
|
assert-property: ("html", {"scrollTop": "206"})
|
||||||
click: '//a[text() = "bar" and @href="#28-36"]'
|
click: '//a[text() = "bar" and @href="#28-36"]'
|
||||||
assert-property: ("html", {"scrollTop": "239"})
|
assert-property: ("html", {"scrollTop": "239"})
|
||||||
click: '//a[normalize-space() = "sub_fn" and @href="#2-4"]'
|
click: '//a[normalize-space() = "sub_fn" and @href="#2-4"]'
|
||||||
assert-property: ("html", {"scrollTop": "136"})
|
assert-property: ("html", {"scrollTop": "134"})
|
||||||
|
|
||||||
// We now check that clicking on lines doesn't change the scroll
|
// We now check that clicking on lines doesn't change the scroll
|
||||||
// Extra information: the "sub_fn" function header is on line 1.
|
// Extra information: the "sub_fn" function header is on line 1.
|
||||||
click: '//*[@id="6"]'
|
click: '//*[@id="6"]'
|
||||||
assert-property: ("html", {"scrollTop": "136"})
|
assert-property: ("html", {"scrollTop": "134"})
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
|
go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
|
||||||
set-window-size: (800, 1000)
|
set-window-size: (800, 1000)
|
||||||
// "scrollWidth" should be superior than "clientWidth".
|
// "scrollWidth" should be superior than "clientWidth".
|
||||||
assert-property: ("body", {"scrollWidth": 1776, "clientWidth": 800})
|
assert-property: ("body", {"scrollWidth": 1780, "clientWidth": 800})
|
||||||
|
|
||||||
// Both properties should be equal (ie, no scroll on the code block).
|
// Both properties should be equal (ie, no scroll on the code block).
|
||||||
assert-property: (".example-wrap .rust", {"scrollWidth": 1662, "clientWidth": 1662})
|
assert-property: (".example-wrap .rust", {"scrollWidth": 1715, "clientWidth": 1715})
|
||||||
|
|
|
@ -3,7 +3,7 @@ include: "utils.goml"
|
||||||
go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
|
go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
|
||||||
show-text: true
|
show-text: true
|
||||||
// Check that we can click on the line number.
|
// Check that we can click on the line number.
|
||||||
click: ".src-line-numbers > a:nth-child(4)" // This is the anchor for line 4.
|
click: "//a[@data-nosnippet and text()='4']" // This is the anchor for line 4.
|
||||||
// Ensure that the page URL was updated.
|
// Ensure that the page URL was updated.
|
||||||
assert-document-property: ({"URL": "lib.rs.html#4"}, ENDS_WITH)
|
assert-document-property: ({"URL": "lib.rs.html#4"}, ENDS_WITH)
|
||||||
assert-attribute: ("//*[@id='4']", {"class": "line-highlighted"})
|
assert-attribute: ("//*[@id='4']", {"class": "line-highlighted"})
|
||||||
|
@ -14,11 +14,11 @@ assert-attribute: ("//*[@id='4']", {"class": "line-highlighted"})
|
||||||
assert-css: ("//*[@id='4']", {"border-right-width": "0px"})
|
assert-css: ("//*[@id='4']", {"border-right-width": "0px"})
|
||||||
// We now check that the good anchors are highlighted
|
// We now check that the good anchors are highlighted
|
||||||
go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html#4-6"
|
go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html#4-6"
|
||||||
assert-attribute-false: (".src-line-numbers > a:nth-child(3)", {"class": "line-highlighted"})
|
assert-attribute-false: ("//a[@data-nosnippet and text()='3']", {"class": "line-highlighted"})
|
||||||
assert-attribute: (".src-line-numbers > a:nth-child(4)", {"class": "line-highlighted"})
|
assert-attribute: ("//a[@data-nosnippet and text()='4']", {"class": "line-highlighted"})
|
||||||
assert-attribute: (".src-line-numbers > a:nth-child(5)", {"class": "line-highlighted"})
|
assert-attribute: ("//a[@data-nosnippet and text()='5']", {"class": "line-highlighted"})
|
||||||
assert-attribute: (".src-line-numbers > a:nth-child(6)", {"class": "line-highlighted"})
|
assert-attribute: ("//a[@data-nosnippet and text()='6']", {"class": "line-highlighted"})
|
||||||
assert-attribute-false: (".src-line-numbers > a:nth-child(7)", {"class": "line-highlighted"})
|
assert-attribute-false: ("//a[@data-nosnippet and text()='7']", {"class": "line-highlighted"})
|
||||||
|
|
||||||
define-function: (
|
define-function: (
|
||||||
"check-colors",
|
"check-colors",
|
||||||
|
@ -26,12 +26,12 @@ define-function: (
|
||||||
block {
|
block {
|
||||||
call-function: ("switch-theme", {"theme": |theme|})
|
call-function: ("switch-theme", {"theme": |theme|})
|
||||||
assert-css: (
|
assert-css: (
|
||||||
".src-line-numbers > a:not(.line-highlighted)",
|
"a[data-nosnippet]:not(.line-highlighted)",
|
||||||
{"color": |color|, "background-color": |background_color|},
|
{"color": |color|, "background-color": |background_color|},
|
||||||
ALL,
|
ALL,
|
||||||
)
|
)
|
||||||
assert-css: (
|
assert-css: (
|
||||||
".src-line-numbers > a.line-highlighted",
|
"a[data-nosnippet].line-highlighted",
|
||||||
{"color": |highlight_color|, "background-color": |highlight_background_color|},
|
{"color": |highlight_color|, "background-color": |highlight_background_color|},
|
||||||
ALL,
|
ALL,
|
||||||
)
|
)
|
||||||
|
@ -61,37 +61,37 @@ call-function: ("check-colors", {
|
||||||
})
|
})
|
||||||
|
|
||||||
// This is to ensure that the content is correctly align with the line numbers.
|
// This is to ensure that the content is correctly align with the line numbers.
|
||||||
compare-elements-position: ("//*[@id='1']", ".rust > code > span", ["y"])
|
compare-elements-position-near: ("//*[@id='1']", ".rust > code > span", {"y": 2})
|
||||||
// Check the `href` property so that users can treat anchors as links.
|
// Check the `href` property so that users can treat anchors as links.
|
||||||
assert-property: (".src-line-numbers > a:nth-child(1)", {
|
assert-property: ("//a[@data-nosnippet and text()='1']", {
|
||||||
"href": |DOC_PATH| + "/src/test_docs/lib.rs.html#1"
|
"href": |DOC_PATH| + "/src/test_docs/lib.rs.html#1"
|
||||||
}, ENDS_WITH)
|
}, ENDS_WITH)
|
||||||
assert-property: (".src-line-numbers > a:nth-child(2)", {
|
assert-property: ("//a[@data-nosnippet and text()='2']", {
|
||||||
"href": |DOC_PATH| + "/src/test_docs/lib.rs.html#2"
|
"href": |DOC_PATH| + "/src/test_docs/lib.rs.html#2"
|
||||||
}, ENDS_WITH)
|
}, ENDS_WITH)
|
||||||
assert-property: (".src-line-numbers > a:nth-child(3)", {
|
assert-property: ("//a[@data-nosnippet and text()='3']", {
|
||||||
"href": |DOC_PATH| + "/src/test_docs/lib.rs.html#3"
|
"href": |DOC_PATH| + "/src/test_docs/lib.rs.html#3"
|
||||||
}, ENDS_WITH)
|
}, ENDS_WITH)
|
||||||
assert-property: (".src-line-numbers > a:nth-child(4)", {
|
assert-property: ("//a[@data-nosnippet and text()='4']", {
|
||||||
"href": |DOC_PATH| + "/src/test_docs/lib.rs.html#4"
|
"href": |DOC_PATH| + "/src/test_docs/lib.rs.html#4"
|
||||||
}, ENDS_WITH)
|
}, ENDS_WITH)
|
||||||
assert-property: (".src-line-numbers > a:nth-child(5)", {
|
assert-property: ("//a[@data-nosnippet and text()='5']", {
|
||||||
"href": |DOC_PATH| + "/src/test_docs/lib.rs.html#5"
|
"href": |DOC_PATH| + "/src/test_docs/lib.rs.html#5"
|
||||||
}, ENDS_WITH)
|
}, ENDS_WITH)
|
||||||
assert-property: (".src-line-numbers > a:nth-child(6)", {
|
assert-property: ("//a[@data-nosnippet and text()='6']", {
|
||||||
"href": |DOC_PATH| + "/src/test_docs/lib.rs.html#6"
|
"href": |DOC_PATH| + "/src/test_docs/lib.rs.html#6"
|
||||||
}, ENDS_WITH)
|
}, ENDS_WITH)
|
||||||
|
|
||||||
// Assert that the line numbers text is aligned to the right.
|
// Assert that the line numbers text is aligned to the right.
|
||||||
assert-css: (".src-line-numbers", {"text-align": "right"})
|
assert-css: ("a[data-nosnippet]", {"text-align": "right"}, ALL)
|
||||||
|
|
||||||
// Now let's check that clicking on something else than the line number doesn't
|
// Now let's check that clicking on something else than the line number doesn't
|
||||||
// do anything (and certainly not add a `#NaN` to the URL!).
|
// do anything (and certainly not add a `#NaN` to the URL!).
|
||||||
go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
|
go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
|
||||||
// We use this assert-position to know where we will click.
|
// We use this assert-position to know where we will click.
|
||||||
assert-position: ("//*[@id='1']", {"x": 88, "y": 171})
|
assert-position: ("//*[@id='1']", {"x": 81, "y": 169})
|
||||||
// We click on the left of the "1" anchor but still in the "src-line-number" `<pre>`.
|
// We click on the left of the "1" anchor but still in the `a[data-nosnippet]`.
|
||||||
click: (163, 77)
|
click: (77, 163)
|
||||||
assert-document-property: ({"URL": "/lib.rs.html"}, ENDS_WITH)
|
assert-document-property: ({"URL": "/lib.rs.html"}, ENDS_WITH)
|
||||||
|
|
||||||
// Checking the source code sidebar.
|
// Checking the source code sidebar.
|
||||||
|
|
|
@ -31,7 +31,8 @@ fn babar() {}
|
||||||
//@ has - '//pre[@class="rust"]//a/@href' '/struct.String.html'
|
//@ has - '//pre[@class="rust"]//a/@href' '/struct.String.html'
|
||||||
//@ has - '//pre[@class="rust"]//a/@href' '/primitive.u32.html'
|
//@ has - '//pre[@class="rust"]//a/@href' '/primitive.u32.html'
|
||||||
//@ has - '//pre[@class="rust"]//a/@href' '/primitive.str.html'
|
//@ has - '//pre[@class="rust"]//a/@href' '/primitive.str.html'
|
||||||
//@ count - '//pre[@class="rust"]//a[@href="#23"]' 5
|
// The 5 links to line 23 and the line 23 itself.
|
||||||
|
//@ count - '//pre[@class="rust"]//a[@href="#23"]' 6
|
||||||
//@ has - '//pre[@class="rust"]//a[@href="../../source_code/struct.SourceCode.html"]' \
|
//@ has - '//pre[@class="rust"]//a[@href="../../source_code/struct.SourceCode.html"]' \
|
||||||
// 'source_code::SourceCode'
|
// 'source_code::SourceCode'
|
||||||
pub fn foo(a: u32, b: &str, c: String, d: Foo, e: bar::Bar, f: source_code::SourceCode) {
|
pub fn foo(a: u32, b: &str, c: String, d: Foo, e: bar::Bar, f: source_code::SourceCode) {
|
||||||
|
@ -50,8 +51,8 @@ pub fn foo2<T: bar::sub::Trait, V: Trait>(t: &T, v: &V, b: bool) {}
|
||||||
pub trait AnotherTrait {}
|
pub trait AnotherTrait {}
|
||||||
pub trait WhyNot {}
|
pub trait WhyNot {}
|
||||||
|
|
||||||
//@ has - '//pre[@class="rust"]//a[@href="#50"]' 'AnotherTrait'
|
//@ has - '//pre[@class="rust"]//a[@href="#51"]' 'AnotherTrait'
|
||||||
//@ has - '//pre[@class="rust"]//a[@href="#51"]' 'WhyNot'
|
//@ has - '//pre[@class="rust"]//a[@href="#52"]' 'WhyNot'
|
||||||
pub fn foo3<T, V>(t: &T, v: &V)
|
pub fn foo3<T, V>(t: &T, v: &V)
|
||||||
where
|
where
|
||||||
T: AnotherTrait,
|
T: AnotherTrait,
|
||||||
|
@ -60,7 +61,7 @@ where
|
||||||
|
|
||||||
pub trait AnotherTrait2 {}
|
pub trait AnotherTrait2 {}
|
||||||
|
|
||||||
//@ has - '//pre[@class="rust"]//a[@href="#61"]' 'AnotherTrait2'
|
//@ has - '//pre[@class="rust"]//a[@href="#62"]' 'AnotherTrait2'
|
||||||
pub fn foo4() {
|
pub fn foo4() {
|
||||||
let x: Vec<&dyn AnotherTrait2> = Vec::new();
|
let x: Vec<&dyn AnotherTrait2> = Vec::new();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue