Skip to content

Commit

Permalink
Rollup merge of #102008 - GuillaumeGomez:notable-trait-gui-test, r=no…
Browse files Browse the repository at this point in the history
…triddle

Add GUI test for notable traits element position

Fixes #101891.

r? ````@notriddle````
  • Loading branch information
notriddle committed Sep 20, 2022
2 parents 2c57a5b + db2d5df commit 0922172
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 0 deletions.
91 changes: 91 additions & 0 deletions src/test/rustdoc-gui/notable-trait.goml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// This test checks the position of the `i` for the notable traits.
goto: file://|DOC_PATH|/test_docs/struct.NotableStructWithLongName.html
show-text: true
// We start with a wide screen.
size: (1100, 600)
// Checking they have the same y position.
compare-elements-position: (
"//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
"//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",
("y"),
)
// Checking they don't have the same x position.
compare-elements-position-false: (
"//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
"//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",
("x"),
)
// The `i` should be *after* the type.
assert-position: (
"//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
{"x": 692},
)
assert-position: (
"//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",
{"x": 966},
)


// Now only the `i` should be on the next line.
size: (1055, 600)
compare-elements-position-false: (
"//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
"//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",
("y", "x"),
)

// Now both the `i` and the struct name should be on the next line.
size: (980, 600)
// Checking they have the same y position.
compare-elements-position: (
"//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
"//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",
("y"),
)
// Checking they don't have the same x position.
compare-elements-position-false: (
"//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
"//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",
("x"),
)
// The `i` should be *after* the type.
assert-position: (
"//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
{"x": 245},
)
assert-position: (
"//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",
{"x": 519},
)

// Checking on mobile now.
size: (650, 600)
// Checking they have the same y position.
compare-elements-position: (
"//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
"//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",
("y"),
)
// Checking they don't have the same x position.
compare-elements-position-false: (
"//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
"//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",
("x"),
)
// The `i` should be *after* the type.
assert-position: (
"//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
{"x": 15},
)
assert-position: (
"//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",
{"x": 289},
)

// Checking on very small mobile. The `i` should be on its own line.
size: (410, 600)
compare-elements-position-false: (
"//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
"//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",
("y", "x"),
)
12 changes: 12 additions & 0 deletions src/test/rustdoc-gui/src/test_docs/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,3 +325,15 @@ pub mod doc_block_table {
}

}

pub struct NotableStructWithLongName<R>(R);

impl<R: std::io::Read> NotableStructWithLongName<R> {
pub fn create_an_iterator_from_read(r: R) -> NotableStructWithLongName<R> { Self(r) }
}

impl<R: std::io::Read> std::iter::Iterator for NotableStructWithLongName<R> {
type Item = ();

fn next(&mut self) -> Option<Self::Item> { () }
}

0 comments on commit 0922172

Please sign in to comment.