From 55149061eaf65df7a31c8c331334b960bd2a1f84 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Tue, 16 Jul 2024 10:04:40 -0700 Subject: [PATCH] rustdoc: add test cases for mile wide bar --- tests/rustdoc-gui/huge-logo.goml | 1 + tests/rustdoc-gui/sidebar.goml | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/tests/rustdoc-gui/huge-logo.goml b/tests/rustdoc-gui/huge-logo.goml index 01999401e60..d207ab5bb37 100644 --- a/tests/rustdoc-gui/huge-logo.goml +++ b/tests/rustdoc-gui/huge-logo.goml @@ -7,6 +7,7 @@ set-window-size: (1280, 1024) assert-property: (".sidebar-crate .logo-container", {"offsetWidth": "96", "offsetHeight": 48}) // offsetWidth = width of sidebar, offsetHeight = height + top padding assert-property: (".sidebar-crate .logo-container img", {"offsetWidth": "48", "offsetHeight": 64}) +assert-css: (".sidebar-crate .logo-container img", {"border-top-width": "16px", "margin-top": "-16px"}) set-window-size: (400, 600) // offset = size + margin diff --git a/tests/rustdoc-gui/sidebar.goml b/tests/rustdoc-gui/sidebar.goml index 452545958f9..56453517a55 100644 --- a/tests/rustdoc-gui/sidebar.goml +++ b/tests/rustdoc-gui/sidebar.goml @@ -179,3 +179,18 @@ assert-property: (".sidebar .sidebar-crate h2 a", { "offsetTop": |index_sidebar_y|, "offsetLeft": |index_sidebar_x|, }) + +// Check that the sidebar links touch the left side of the box +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" +assert-position: (".sidebar .block a", {"x": -4}) +assert-position: (".sidebar-crate > h2 > a", {"x": -3}) + +// Check that the main sidebar links touch the left side of the box +// but the crate name doesn't, because the logo takes that space +go-to: "file://" + |DOC_PATH| + "/huge_logo/index.html" +assert-position: (".sidebar .block a", {"x": -4}) +// when side-by-side, it's not line wrapped +assert-position-false: (".sidebar-crate > h2 > a", {"x": -3}) +// when line-wrapped, see that it becomes flush-left again +drag-and-drop: ((205, 100), (108, 100)) +assert-position: (".sidebar-crate > h2 > a", {"x": -3})