From db2d5df860295b3d852ef386587386a2af590884 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 19 Sep 2022 12:32:30 +0200 Subject: [PATCH] Add GUI test for notable traits element position --- src/test/rustdoc-gui/notable-trait.goml | 91 +++++++++++++++++++++++ src/test/rustdoc-gui/src/test_docs/lib.rs | 12 +++ 2 files changed, 103 insertions(+) create mode 100644 src/test/rustdoc-gui/notable-trait.goml diff --git a/src/test/rustdoc-gui/notable-trait.goml b/src/test/rustdoc-gui/notable-trait.goml new file mode 100644 index 0000000000000..69088a0774fc4 --- /dev/null +++ b/src/test/rustdoc-gui/notable-trait.goml @@ -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"), +) diff --git a/src/test/rustdoc-gui/src/test_docs/lib.rs b/src/test/rustdoc-gui/src/test_docs/lib.rs index 4eedf7f15c3d4..e6177ff84b42e 100644 --- a/src/test/rustdoc-gui/src/test_docs/lib.rs +++ b/src/test/rustdoc-gui/src/test_docs/lib.rs @@ -325,3 +325,15 @@ pub mod doc_block_table { } } + +pub struct NotableStructWithLongName(R); + +impl NotableStructWithLongName { + pub fn create_an_iterator_from_read(r: R) -> NotableStructWithLongName { Self(r) } +} + +impl std::iter::Iterator for NotableStructWithLongName { + type Item = (); + + fn next(&mut self) -> Option { () } +}