Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 30f487c

Browse files
committedOct 25, 2024
Add GUI test for impl block doc display
1 parent b0e8ad5 commit 30f487c

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed
 

‎tests/rustdoc-gui/impl-block-doc.goml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Checks that the first sentence of an impl block doc is always visible even when the impl
2+
// block is collapsed.
3+
go-to: "file://" + |DOC_PATH| + "/test_docs/struct.ImplDoc.html"
4+
5+
set-window-size: (900, 600)
6+
7+
define-function: (
8+
"compare-size-and-pos",
9+
[nth_impl],
10+
block {
11+
// First we collapse the impl block.
12+
store-value: (impl_path, "#implementations-list details:nth-of-type(" + |nth_impl| + ")")
13+
set-property: (|impl_path|, {"open": false})
14+
wait-for: |impl_path| + ":not([open])"
15+
16+
store-value: (impl_path, |impl_path| + " summary")
17+
store-size: (|impl_path|, {"height": impl_height})
18+
store-position: (|impl_path|, {"y": impl_y})
19+
20+
store-size: (|impl_path| + " .docblock", {"height": doc_height})
21+
store-position: (|impl_path| + " .docblock", {"y": doc_y})
22+
23+
assert: |impl_y| + |impl_height| >= |doc_y|
24+
}
25+
)
26+
27+
call-function: ("compare-size-and-pos", {"nth_impl": 1})
28+
// Since the first impl block has a long line, we ensure that it doesn't display all of it.
29+
assert: (|impl_y| + |impl_height|) <= (|doc_y| + |doc_height|)
30+
31+
call-function: ("compare-size-and-pos", {"nth_impl": 2})
32+
// The second impl block has a short line.
33+
assert: (|impl_y| + |impl_height|) >= (|doc_y| + |doc_height|)

‎tests/rustdoc-gui/src/test_docs/lib.rs

+17
Original file line numberDiff line numberDiff line change
@@ -652,3 +652,20 @@ pub mod long_list {
652652
//! * [`FromBytes`](#a) indicates that a type may safely be converted from an arbitrary byte
653653
//! sequence
654654
}
655+
656+
pub struct ImplDoc;
657+
658+
/// bla sondfosdnf sdfasd fadsd fdsa f ads fad sf sad f sad fasdfsafsa df dsafasdasd fsa dfadsfasd
659+
/// fads fadfadd
660+
///
661+
/// bla
662+
impl ImplDoc {
663+
pub fn bar() {}
664+
}
665+
666+
/// bla
667+
///
668+
/// bla
669+
impl ImplDoc {
670+
pub fn bar2() {}
671+
}

0 commit comments

Comments
 (0)
Failed to load comments.