]> git.lizzy.rs Git - rust.git/blob - src/test/rustdoc-gui/search-result-color.goml
Auto merge of #101378 - matthiaskrgr:rollup-s1awa47, r=matthiaskrgr
[rust.git] / src / test / rustdoc-gui / search-result-color.goml
1 // The goal of this test is to ensure the color of the text is the one expected.
2 goto: file://|DOC_PATH|/test_docs/index.html?search=coo
3
4 // This is needed so that the text color is computed.
5 show-text: true
6
7 // Ayu theme
8 local-storage: {
9     "rustdoc-theme": "ayu",
10     "rustdoc-preferred-dark-theme": "ayu",
11     "rustdoc-use-system-theme": "false",
12 }
13 reload:
14
15 // Waiting for the search results to appear...
16 wait-for: "#titles"
17 assert-css: (
18     "//*[@class='desc']//*[text()='Just a normal struct.']",
19     {"color": "rgb(197, 197, 197)"},
20 )
21 assert-css: (
22     "//*[@class='result-name']/*[text()='test_docs::']",
23     {"color": "rgb(0, 150, 207)"},
24 )
25
26 // Checking the color for "keyword".
27 assert-css: (
28     "//*[@class='result-name']//*[text()='(keyword)']",
29     {"color": "rgb(120, 135, 151)"},
30 )
31
32 // Checking the `<a>` container.
33 assert-css: (
34     "//*[@class='result-name']/*[text()='test_docs::']/ancestor::a",
35     {"color": "rgb(0, 150, 207)", "background-color": "rgba(0, 0, 0, 0)"},
36 )
37
38 // Checking color and background on hover.
39 move-cursor-to: "//*[@class='desc']//*[text()='Just a normal struct.']"
40 assert-css: (
41     "//*[@class='result-name']/*[text()='test_docs::']",
42     {"color": "rgb(255, 255, 255)"},
43 )
44 assert-css: (
45     "//*[@class='result-name']/*[text()='test_docs::']/ancestor::a",
46     {"color": "rgb(255, 255, 255)", "background-color": "rgb(60, 60, 60)"},
47 )
48
49 // Dark theme
50 local-storage: {
51     "rustdoc-theme": "dark",
52     "rustdoc-preferred-dark-theme": "dark",
53     "rustdoc-use-system-theme": "false",
54 }
55 reload:
56
57 // Waiting for the search results to appear...
58 wait-for: "#titles"
59 assert-css: (
60     "//*[@class='desc']//*[text()='Just a normal struct.']",
61     {"color": "rgb(221, 221, 221)"},
62 )
63 assert-css: (
64     "//*[@class='result-name']/*[text()='test_docs::']",
65     {"color": "rgb(221, 221, 221)"},
66 )
67
68 // Checking the color for "keyword".
69 assert-css: (
70     "//*[@class='result-name']//*[text()='(keyword)']",
71     {"color": "rgb(221, 221, 221)"},
72 )
73
74 // Checking the `<a>` container.
75 assert-css: (
76     "//*[@class='result-name']/*[text()='test_docs::']/ancestor::a",
77     {"color": "rgb(221, 221, 221)", "background-color": "rgba(0, 0, 0, 0)"},
78 )
79
80 // Checking color and background on hover.
81 move-cursor-to: "//*[@class='desc']//*[text()='Just a normal struct.']"
82 assert-css: (
83     "//*[@class='result-name']/*[text()='test_docs::']",
84     {"color": "rgb(221, 221, 221)"},
85 )
86 assert-css: (
87     "//*[@class='result-name']/*[text()='test_docs::']/ancestor::a",
88     {"color": "rgb(221, 221, 221)", "background-color": "rgb(119, 119, 119)"},
89 )
90
91 // Light theme
92 local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"}
93 reload:
94
95 // Waiting for the search results to appear...
96 wait-for: "#titles"
97 assert-css: (
98     "//*[@class='desc']//*[text()='Just a normal struct.']",
99     {"color": "rgb(0, 0, 0)"},
100 )
101 assert-css: (
102     "//*[@class='result-name']/*[text()='test_docs::']",
103     {"color": "rgb(0, 0, 0)"},
104 )
105
106 // Checking the color for "keyword".
107 assert-css: (
108     "//*[@class='result-name']//*[text()='(keyword)']",
109     {"color": "rgb(0, 0, 0)"},
110 )
111
112 // Checking the `<a>` container.
113 assert-css: (
114     "//*[@class='result-name']/*[text()='test_docs::']/ancestor::a",
115     {"color": "rgb(0, 0, 0)", "background-color": "rgba(0, 0, 0, 0)"},
116 )
117
118 // Checking color and background on hover.
119 move-cursor-to: "//*[@class='desc']//*[text()='Just a normal struct.']"
120 assert-css: (
121     "//*[@class='result-name']/*[text()='test_docs::']",
122     {"color": "rgb(0, 0, 0)"},
123 )
124 assert-css: (
125     "//*[@class='result-name']/*[text()='test_docs::']/ancestor::a",
126     {"color": "rgb(0, 0, 0)", "background-color": "rgb(221, 221, 221)"},
127 )
128
129 // Check the alias more specifically in the dark theme.
130 goto: file://|DOC_PATH|/test_docs/index.html
131 // We set the theme so we're sure that the correct values will be used, whatever the computer
132 // this test is running on.
133 local-storage: {
134     "rustdoc-theme": "dark",
135     "rustdoc-preferred-dark-theme": "dark",
136     "rustdoc-use-system-theme": "false",
137 }
138 // If the text isn't displayed, the browser doesn't compute color style correctly...
139 show-text: true
140 // We reload the page so the local storage settings are being used.
141 reload:
142 write: (".search-input", "thisisanalias")
143 // To be SURE that the search will be run.
144 press-key: 'Enter'
145 // Waiting for the search results to appear...
146 wait-for: "#titles"
147 // Checking that the colors for the alias element are the ones expected.
148 assert-css: (".result-name > .alias", {"color": "rgb(255, 255, 255)"})
149 assert-css: (".result-name > .alias > .grey", {"color": "rgb(204, 204, 204)"})