Skip to content

Commit

Permalink
Add GUI test for item info position
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Jul 27, 2022
1 parent 51e658f commit 9903f41
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 8 deletions.
8 changes: 0 additions & 8 deletions src/test/rustdoc-gui/item-info-width.goml

This file was deleted.

32 changes: 32 additions & 0 deletions src/test/rustdoc-gui/item-info.goml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// This test ensures a few things for item info elements.
goto: file://|DOC_PATH|/lib2/struct.Foo.html
// Ensuring that the item information don't take 100% of the width if unnecessary.
// We set a fixed size so there is no chance of "random" resize.
size: (1100, 800)
// We check that ".item-info" is bigger than its content.
assert-css: (".item-info", {"width": "790px"})
assert-css: (".item-info .stab", {"width": "289px"})
assert-position: (".item-info .stab", {"x": 295})

// Now we ensure that they're not rendered on the same line.
goto: file://|DOC_PATH|/lib2/trait.Trait.html
// We first ensure that there are two item info on the trait.
assert-count: ("#main-content > .item-info .stab", 2)
// They should not have the same `y` position!
compare-elements-position-false: (
"#main-content > .item-info .stab:nth-of-type(1)",
"#main-content > .item-info .stab:nth-of-type(2)",
("y"),
)
// But they should have the same `x` position.
compare-elements-position: (
"#main-content > .item-info .stab:nth-of-type(1)",
"#main-content > .item-info .stab:nth-of-type(2)",
("x"),
)
// They are supposed to have the same height too.
compare-elements-css: (
"#main-content > .item-info .stab:nth-of-type(1)",
"#main-content > .item-info .stab:nth-of-type(2)",
["height"],
)
3 changes: 3 additions & 0 deletions src/test/rustdoc-gui/src/lib2/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@ impl Foo {
pub fn a_method(&self) {}
}

#[doc(cfg(feature = "foo-method"))]
#[deprecated = "Whatever [`Foo::a_method`](#method.a_method)"]
pub trait Trait {
type X;
const Y: u32;

#[deprecated = "Whatever [`Foo`](#tadam)"]
fn foo() {}
}

Expand Down

0 comments on commit 9903f41

Please sign in to comment.