about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2021-05-02 18:59:31 +0200
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2021-05-31 10:30:16 +0200
commitbc888ba840c8273e8d1d83157c693a9df49f5ebf (patch)
treede08765a9c34ed0d41d6b47c3100888bcb704767
parentdab01a05fb0300873728cedff8164f87804f19ef (diff)
downloadrust-bc888ba840c8273e8d1d83157c693a9df49f5ebf.tar.gz
rust-bc888ba840c8273e8d1d83157c693a9df49f5ebf.zip
Add sidebar GUI tests
-rw-r--r--src/test/rustdoc-gui/sidebar.goml47
-rw-r--r--src/test/rustdoc-gui/src/lib2.rs11
2 files changed, 58 insertions, 0 deletions
diff --git a/src/test/rustdoc-gui/sidebar.goml b/src/test/rustdoc-gui/sidebar.goml
new file mode 100644
index 00000000000..7e6b8a9b965
--- /dev/null
+++ b/src/test/rustdoc-gui/sidebar.goml
@@ -0,0 +1,47 @@
+goto: file://|DOC_PATH|/test_docs/index.html
+assert: (".sidebar > .location", "Crate test_docs")
+// In modules, we only have one "location" element.
+assert: (".sidebar .location", 1)
+assert: (".sidebar-elems > #all-types", "See all test_docs's items")
+// We check that we have the crates list and that the "current" on is "test_docs".
+assert: (".sidebar-elems > .crate > ul > li > a.current", "test_docs")
+// And we're also supposed to have the list of items in the current module.
+assert: (".sidebar-elems > .items > ul > li:nth-child(1)", "Modules")
+assert: (".sidebar-elems > .items > ul > li:nth-child(2)", "Structs")
+assert: (".sidebar-elems > .items > ul > li:nth-child(3)", "Enums")
+assert: (".sidebar-elems > .items > ul > li:nth-child(4)", "Traits")
+assert: (".sidebar-elems > .items > ul > li:nth-child(5)", "Functions")
+assert: (".sidebar-elems > .items > ul > li:nth-child(6)", "Keywords")
+assert: ("#structs + table td > a", "Foo")
+click: "#structs + table td > a"
+
+// PAGE: struct.Foo.html
+assert: (".sidebar .location", 2)
+// We check that we have the crates list and that the "current" on is still "test_docs".
+assert: (".sidebar-elems > .crate > ul > li > a.current", "test_docs")
+// We now move to the other crate to check if its submodules have the correct sidebar elements too.
+click: ".sidebar-elems > .crate > ul > li:first-child > a"
+
+// PAGE: lib2/index.html
+assert: (".sidebar > .location", "Crate lib2")
+// We check that we have the crates list and that the "current" on is now "lib2".
+assert: (".sidebar-elems > .crate > ul > li > a.current", "lib2")
+// We now go to the "foobar" function page.
+assert: (".sidebar-elems > .items > ul > li:nth-child(1)", "Modules")
+assert: (".sidebar-elems > .items > ul > li:nth-child(2)", "Functions")
+assert:	("#functions + table td > a", "foobar")
+click: "#functions + table td > a"
+
+// PAGE: fn.foobar.html
+// In items containing no items (like functions or constants) and in modules, we have one
+// "location" elements.
+assert: (".sidebar .location", 1)
+// We check that we still have the crates list and that the "current" on is still "lib2".
+assert: (".sidebar-elems > .crate > ul > li > a.current", "lib2")
+goto: ./module/sub_module/sub_sub_module/index.html
+
+assert: (".sidebar > .location", "Module sub_sub_module")
+assert: (".sidebar-elems > .crate > ul > li:nth-child(2) > a", "test_docs")
+assert: (".sidebar-elems > .crate > ul > li:nth-child(2) > a", "href", "../../../../test_docs/index.html")
+assert: (".sidebar-elems > .items > ul > li:nth-child(1)", "Functions")
+assert: ("#functions + table td > a", "foo")
diff --git a/src/test/rustdoc-gui/src/lib2.rs b/src/test/rustdoc-gui/src/lib2.rs
new file mode 100644
index 00000000000..73384cbf906
--- /dev/null
+++ b/src/test/rustdoc-gui/src/lib2.rs
@@ -0,0 +1,11 @@
+pub mod module {
+    pub mod sub_module {
+        pub mod sub_sub_module {
+            pub fn foo() {}
+        }
+        pub fn bar() {}
+    }
+    pub fn whatever() {}
+}
+
+pub fn foobar() {}