fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

master
6.1 KiB160 linesraw
1// Checking the colors of the search tab headers.
2go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html?search=foo"
3show-text: true
4
5define-function: (
6    "check-colors",
7    (theme, background, background_selected, background_hover, border_bottom,
8     border_bottom_selected, border_bottom_hover, border_top, border_top_selected,
9     border_top_hover),
10    block {
11        // Setting the theme.
12        set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
13        reload:
14
15        // These two commands are used to be sure the search will be run.
16        focus: ".search-input"
17        press-key: "Enter"
18
19        wait-for: "#search-tabs"
20        assert-css: ("#search-tabs > button:not(.selected)", {
21            "background-color": |background|,
22            "border-bottom": |border_bottom|,
23            "border-top": |border_top|,
24        })
25        assert-css: ("#search-tabs > button.selected", {
26            "background-color": |background_selected|,
27            "border-bottom": |border_bottom_selected|,
28            "border-top": |border_top_selected|,
29        })
30        move-cursor-to: "#search-tabs > button:not(.selected)"
31        assert-css: ("#search-tabs > button:not(.selected):hover", {
32            "background-color": |background_hover|,
33            "border-bottom": |border_bottom_hover|,
34            "border-top": |border_top_hover|,
35        })
36        // To prevent disrupting next run of this function.
37        move-cursor-to: ".search-input"
38    },
39)
40
41call-function: ("check-colors", {
42    "theme": "ayu",
43    "background": "transparent",
44    "background_selected": "#141920",
45    "background_hover": "transparent",
46    "border_bottom": "0px none #c5c5c5",
47    "border_bottom_selected": "1px solid #ffb44c",
48    "border_bottom_hover": "1px solid rgba(242, 151, 24, 0.3)",
49    "border_top": "0px none #c5c5c5",
50    "border_top_selected": "0px none #c5c5c5",
51    "border_top_hover": "0px none #c5c5c5",
52})
53call-function: ("check-colors", {
54    "theme": "dark",
55    "background": "#252525",
56    "background_selected": "#353535",
57    "background_hover": "#353535",
58    "border_bottom": "0px none #ddd",
59    "border_bottom_selected": "0px none #ddd",
60    "border_bottom_hover": "0px none #ddd",
61    "border_top": "2px solid #252525",
62    "border_top_selected": "2px solid #0089ff",
63    "border_top_hover": "2px solid #0089ff",
64})
65call-function: ("check-colors", {
66    "theme": "light",
67    "background": "#e6e6e6",
68    "background_selected": "#fff",
69    "background_hover": "#fff",
70    "border_bottom": "0px none #000",
71    "border_bottom_selected": "0px none #000",
72    "border_bottom_hover": "0px none #000",
73    "border_top": "2px solid #e6e6e6",
74    "border_top_selected": "2px solid #0089ff",
75    "border_top_hover": "2px solid #0089ff",
76})
77
78// set size wide enough that the text is in a single row
79set-window-size: (851, 600)
80
81// Check the size and count in tabs
82assert-text: ("#search-tabs > button:nth-child(1) > .count", " (23) ")
83assert-text: ("#search-tabs > button:nth-child(2) > .count", " (4)  ")
84assert-text: ("#search-tabs > button:nth-child(3) > .count", " (0)  ")
85store-property: ("#search-tabs > button:nth-child(1)", {"offsetWidth": buttonWidth})
86assert-property: ("#search-tabs > button:nth-child(2)", {"offsetWidth": |buttonWidth|})
87assert-property: ("#search-tabs > button:nth-child(3)", {"offsetWidth": |buttonWidth|})
88store-property: ("#search-tabs > button:nth-child(1) > .count", {"offsetWidth": countWidth})
89assert-property: ("#search-tabs > button:nth-child(2) > .count", {"offsetWidth": |countWidth|})
90assert-property: ("#search-tabs > button:nth-child(3) > .count", {"offsetWidth": |countWidth|})
91
92// Check that counts are in a row with each other
93compare-elements-position: (
94    "#search-tabs > button:nth-child(1) > .count",
95    "#search-tabs > button:nth-child(2) > .count",
96    ("y")
97)
98compare-elements-position: (
99    "#search-tabs > button:nth-child(2) > .count",
100    "#search-tabs > button:nth-child(3) > .count",
101    ("y")
102)
103// Check that counts are beside the titles and haven't wrapped
104compare-elements-position-near: (
105    "#search-tabs > button:nth-child(1)",
106    "#search-tabs > button:nth-child(1) > .count",
107    {"y": 8}
108)
109compare-elements-position-near: (
110    "#search-tabs > button:nth-child(2)",
111    "#search-tabs > button:nth-child(2) > .count",
112    {"y": 8}
113)
114compare-elements-position-near: (
115    "#search-tabs > button:nth-child(2)",
116    "#search-tabs > button:nth-child(2) > .count",
117    {"y": 8}
118)
119
120// Set size narrow enough that they wrap.
121// When I tested it, it wrapped at 811px, but I added some fudge factor to ensure it
122// doesn't prematurely wrap with slightly different font kerning or whatever, with a
123// @media query
124set-window-size: (850, 600)
125
126// all counts and buttons still have same size
127store-property: ("#search-tabs > button:nth-child(1)", {"offsetWidth": buttonWidth})
128assert-property: ("#search-tabs > button:nth-child(2)", {"offsetWidth": |buttonWidth|})
129assert-property: ("#search-tabs > button:nth-child(3)", {"offsetWidth": |buttonWidth|})
130store-property: ("#search-tabs > button:nth-child(1) > .count", {"offsetWidth": countWidth})
131assert-property: ("#search-tabs > button:nth-child(2) > .count", {"offsetWidth": |countWidth|})
132assert-property: ("#search-tabs > button:nth-child(3) > .count", {"offsetWidth": |countWidth|})
133
134// Check that counts are still in a row with each other
135compare-elements-position: (
136    "#search-tabs > button:nth-child(1) > .count",
137    "#search-tabs > button:nth-child(2) > .count",
138    ("y")
139)
140compare-elements-position: (
141    "#search-tabs > button:nth-child(2) > .count",
142    "#search-tabs > button:nth-child(3) > .count",
143    ("y")
144)
145// Check that counts are NOT beside the titles; now they have wrapped
146compare-elements-position-near-false: (
147    "#search-tabs > button:nth-child(1)",
148    "#search-tabs > button:nth-child(1) > .count",
149    {"y": 8}
150)
151compare-elements-position-near-false: (
152    "#search-tabs > button:nth-child(2)",
153    "#search-tabs > button:nth-child(2) > .count",
154    {"y": 8}
155)
156compare-elements-position-near-false: (
157    "#search-tabs > button:nth-child(2)",
158    "#search-tabs > button:nth-child(2) > .count",
159    {"y": 8}
160)